Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 2 | * zfcp device driver |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 4 | * Implementation of FSF commands. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 6 | * Copyright IBM Corporation 2002, 2010 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
Christof Schmitt | ecf39d4 | 2008-12-25 13:39:53 +0100 | [diff] [blame] | 9 | #define KMSG_COMPONENT "zfcp" |
| 10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 11 | |
Stefan Raspl | 0997f1c | 2008-10-16 08:23:39 +0200 | [diff] [blame] | 12 | #include <linux/blktrace_api.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 13 | #include <linux/slab.h> |
Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 14 | #include <scsi/fc/fc_els.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include "zfcp_ext.h" |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 16 | #include "zfcp_fc.h" |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 17 | #include "zfcp_dbf.h" |
Christof Schmitt | 34c2b71 | 2010-02-17 11:18:59 +0100 | [diff] [blame] | 18 | #include "zfcp_qdio.h" |
Christof Schmitt | b6bd2fb | 2010-02-17 11:18:50 +0100 | [diff] [blame] | 19 | #include "zfcp_reqlist.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 21 | static void zfcp_fsf_request_timeout_handler(unsigned long data) |
| 22 | { |
| 23 | struct zfcp_adapter *adapter = (struct zfcp_adapter *) data; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 24 | zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED, |
| 25 | "fsrth_1", NULL); |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | static void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req, |
| 29 | unsigned long timeout) |
| 30 | { |
| 31 | fsf_req->timer.function = zfcp_fsf_request_timeout_handler; |
| 32 | fsf_req->timer.data = (unsigned long) fsf_req->adapter; |
| 33 | fsf_req->timer.expires = jiffies + timeout; |
| 34 | add_timer(&fsf_req->timer); |
| 35 | } |
| 36 | |
| 37 | static void zfcp_fsf_start_erp_timer(struct zfcp_fsf_req *fsf_req) |
| 38 | { |
| 39 | BUG_ON(!fsf_req->erp_action); |
| 40 | fsf_req->timer.function = zfcp_erp_timeout_handler; |
| 41 | fsf_req->timer.data = (unsigned long) fsf_req->erp_action; |
| 42 | fsf_req->timer.expires = jiffies + 30 * HZ; |
| 43 | add_timer(&fsf_req->timer); |
| 44 | } |
| 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | /* association between FSF command and FSF QTCB type */ |
| 47 | static u32 fsf_qtcb_type[] = { |
| 48 | [FSF_QTCB_FCP_CMND] = FSF_IO_COMMAND, |
| 49 | [FSF_QTCB_ABORT_FCP_CMND] = FSF_SUPPORT_COMMAND, |
| 50 | [FSF_QTCB_OPEN_PORT_WITH_DID] = FSF_SUPPORT_COMMAND, |
| 51 | [FSF_QTCB_OPEN_LUN] = FSF_SUPPORT_COMMAND, |
| 52 | [FSF_QTCB_CLOSE_LUN] = FSF_SUPPORT_COMMAND, |
| 53 | [FSF_QTCB_CLOSE_PORT] = FSF_SUPPORT_COMMAND, |
| 54 | [FSF_QTCB_CLOSE_PHYSICAL_PORT] = FSF_SUPPORT_COMMAND, |
| 55 | [FSF_QTCB_SEND_ELS] = FSF_SUPPORT_COMMAND, |
| 56 | [FSF_QTCB_SEND_GENERIC] = FSF_SUPPORT_COMMAND, |
| 57 | [FSF_QTCB_EXCHANGE_CONFIG_DATA] = FSF_CONFIG_COMMAND, |
| 58 | [FSF_QTCB_EXCHANGE_PORT_DATA] = FSF_PORT_COMMAND, |
| 59 | [FSF_QTCB_DOWNLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND, |
| 60 | [FSF_QTCB_UPLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND |
| 61 | }; |
| 62 | |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 63 | static void zfcp_act_eval_err(struct zfcp_adapter *adapter, u32 table) |
| 64 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 65 | u16 subtable = table >> 16; |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 66 | u16 rule = table & 0xffff; |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 67 | const char *act_type[] = { "unknown", "OS", "WWPN", "DID", "LUN" }; |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 68 | |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 69 | if (subtable && subtable < ARRAY_SIZE(act_type)) |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 70 | dev_warn(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 71 | "Access denied according to ACT rule type %s, " |
| 72 | "rule %d\n", act_type[subtable], rule); |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req, |
| 76 | struct zfcp_port *port) |
| 77 | { |
| 78 | struct fsf_qtcb_header *header = &req->qtcb->header; |
| 79 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 80 | "Access denied to port 0x%016Lx\n", |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 81 | (unsigned long long)port->wwpn); |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 82 | zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); |
| 83 | zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 84 | zfcp_erp_port_access_denied(port, "fspad_1", req); |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 85 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 86 | } |
| 87 | |
| 88 | static void zfcp_fsf_access_denied_unit(struct zfcp_fsf_req *req, |
| 89 | struct zfcp_unit *unit) |
| 90 | { |
| 91 | struct fsf_qtcb_header *header = &req->qtcb->header; |
| 92 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 93 | "Access denied to unit 0x%016Lx on port 0x%016Lx\n", |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 94 | (unsigned long long)unit->fcp_lun, |
| 95 | (unsigned long long)unit->port->wwpn); |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 96 | zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); |
| 97 | zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 98 | zfcp_erp_unit_access_denied(unit, "fsuad_1", req); |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 99 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 100 | } |
| 101 | |
| 102 | static void zfcp_fsf_class_not_supp(struct zfcp_fsf_req *req) |
| 103 | { |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 104 | dev_err(&req->adapter->ccw_device->dev, "FCP device not " |
| 105 | "operational because of an unsupported FC class\n"); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 106 | zfcp_erp_adapter_shutdown(req->adapter, 0, "fscns_1", req); |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 107 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 108 | } |
| 109 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 110 | /** |
| 111 | * zfcp_fsf_req_free - free memory used by fsf request |
| 112 | * @fsf_req: pointer to struct zfcp_fsf_req |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | */ |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 114 | void zfcp_fsf_req_free(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 116 | if (likely(req->pool)) { |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 117 | if (likely(req->qtcb)) |
| 118 | mempool_free(req->qtcb, req->adapter->pool.qtcb_pool); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 119 | mempool_free(req, req->pool); |
Heiko Carstens | dd52e0e | 2006-09-18 22:28:49 +0200 | [diff] [blame] | 120 | return; |
| 121 | } |
| 122 | |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 123 | if (likely(req->qtcb)) |
| 124 | kmem_cache_free(zfcp_data.qtcb_cache, req->qtcb); |
| 125 | kfree(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 128 | static void zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | { |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 130 | unsigned long flags; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 131 | struct fsf_status_read_buffer *sr_buf = req->data; |
| 132 | struct zfcp_adapter *adapter = req->adapter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | struct zfcp_port *port; |
Christof Schmitt | 800c0ca | 2009-11-24 16:54:12 +0100 | [diff] [blame] | 134 | int d_id = ntoh24(sr_buf->d_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 136 | read_lock_irqsave(&adapter->port_list_lock, flags); |
| 137 | list_for_each_entry(port, &adapter->port_list, list) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 138 | if (port->d_id == d_id) { |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 139 | zfcp_erp_port_reopen(port, 0, "fssrpc1", req); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 140 | break; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 141 | } |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 142 | read_unlock_irqrestore(&adapter->port_list_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 145 | static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req, char *id, |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 146 | struct fsf_link_down_info *link_down) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 148 | struct zfcp_adapter *adapter = req->adapter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 150 | if (atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED) |
| 151 | return; |
| 152 | |
| 153 | atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status); |
Christof Schmitt | 7093293 | 2009-04-17 15:08:15 +0200 | [diff] [blame] | 154 | |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame] | 155 | zfcp_scsi_schedule_rports_block(adapter); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 156 | |
| 157 | if (!link_down) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | goto out; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 159 | |
| 160 | switch (link_down->error_code) { |
| 161 | case FSF_PSQ_LINK_NO_LIGHT: |
| 162 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 163 | "There is no light signal from the local " |
| 164 | "fibre channel cable\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 165 | break; |
| 166 | case FSF_PSQ_LINK_WRAP_PLUG: |
| 167 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 168 | "There is a wrap plug instead of a fibre " |
| 169 | "channel cable\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 170 | break; |
| 171 | case FSF_PSQ_LINK_NO_FCP: |
| 172 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 173 | "The adjacent fibre channel node does not " |
| 174 | "support FCP\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 175 | break; |
| 176 | case FSF_PSQ_LINK_FIRMWARE_UPDATE: |
| 177 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 178 | "The FCP device is suspended because of a " |
| 179 | "firmware update\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 180 | break; |
| 181 | case FSF_PSQ_LINK_INVALID_WWPN: |
| 182 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 183 | "The FCP device detected a WWPN that is " |
| 184 | "duplicate or not valid\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 185 | break; |
| 186 | case FSF_PSQ_LINK_NO_NPIV_SUPPORT: |
| 187 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 188 | "The fibre channel fabric does not support NPIV\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 189 | break; |
| 190 | case FSF_PSQ_LINK_NO_FCP_RESOURCES: |
| 191 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 192 | "The FCP adapter cannot support more NPIV ports\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 193 | break; |
| 194 | case FSF_PSQ_LINK_NO_FABRIC_RESOURCES: |
| 195 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 196 | "The adjacent switch cannot support " |
| 197 | "more NPIV ports\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 198 | break; |
| 199 | case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE: |
| 200 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 201 | "The FCP adapter could not log in to the " |
| 202 | "fibre channel fabric\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 203 | break; |
| 204 | case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED: |
| 205 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 206 | "The WWPN assignment file on the FCP adapter " |
| 207 | "has been damaged\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 208 | break; |
| 209 | case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED: |
| 210 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 211 | "The mode table on the FCP adapter " |
| 212 | "has been damaged\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 213 | break; |
| 214 | case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT: |
| 215 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 216 | "All NPIV ports on the FCP adapter have " |
| 217 | "been assigned\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 218 | break; |
| 219 | default: |
| 220 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 221 | "The link between the FCP adapter and " |
| 222 | "the FC fabric is down\n"); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 223 | } |
| 224 | out: |
| 225 | zfcp_erp_adapter_failed(adapter, id, req); |
| 226 | } |
| 227 | |
| 228 | static void zfcp_fsf_status_read_link_down(struct zfcp_fsf_req *req) |
| 229 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 230 | struct fsf_status_read_buffer *sr_buf = req->data; |
| 231 | struct fsf_link_down_info *ldi = |
| 232 | (struct fsf_link_down_info *) &sr_buf->payload; |
| 233 | |
| 234 | switch (sr_buf->status_subtype) { |
| 235 | case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 236 | zfcp_fsf_link_down_info_eval(req, "fssrld1", ldi); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 237 | break; |
| 238 | case FSF_STATUS_READ_SUB_FDISC_FAILED: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 239 | zfcp_fsf_link_down_info_eval(req, "fssrld2", ldi); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 240 | break; |
| 241 | case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 242 | zfcp_fsf_link_down_info_eval(req, "fssrld3", NULL); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 243 | }; |
| 244 | } |
| 245 | |
| 246 | static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req) |
| 247 | { |
| 248 | struct zfcp_adapter *adapter = req->adapter; |
| 249 | struct fsf_status_read_buffer *sr_buf = req->data; |
| 250 | |
| 251 | if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 252 | zfcp_dbf_hba_fsf_unsol("dism", adapter->dbf, sr_buf); |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 253 | mempool_free(sr_buf, adapter->pool.status_read_data); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 254 | zfcp_fsf_req_free(req); |
| 255 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 258 | zfcp_dbf_hba_fsf_unsol("read", adapter->dbf, sr_buf); |
Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 259 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 260 | switch (sr_buf->status_type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | case FSF_STATUS_READ_PORT_CLOSED: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 262 | zfcp_fsf_status_read_port_closed(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | case FSF_STATUS_READ_INCOMING_ELS: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 265 | zfcp_fc_incoming_els(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | case FSF_STATUS_READ_SENSE_DATA_AVAIL: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | case FSF_STATUS_READ_BIT_ERROR_THRESHOLD: |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 270 | dev_warn(&adapter->ccw_device->dev, |
| 271 | "The error threshold for checksum statistics " |
| 272 | "has been exceeded\n"); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 273 | zfcp_dbf_hba_berr(adapter->dbf, req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | case FSF_STATUS_READ_LINK_DOWN: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 276 | zfcp_fsf_status_read_link_down(req); |
Sven Schuetz | 2d1e547 | 2010-07-16 15:37:39 +0200 | [diff] [blame^] | 277 | zfcp_fc_enqueue_event(adapter, FCH_EVT_LINKDOWN, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | case FSF_STATUS_READ_LINK_UP: |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 280 | dev_info(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 281 | "The local link has been restored\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | /* All ports should be marked as ready to run again */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 283 | zfcp_erp_modify_adapter_status(adapter, "fssrh_1", NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | ZFCP_STATUS_COMMON_RUNNING, |
| 285 | ZFCP_SET); |
| 286 | zfcp_erp_adapter_reopen(adapter, |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 287 | ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED | |
| 288 | ZFCP_STATUS_COMMON_ERP_FAILED, |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 289 | "fssrh_2", req); |
Sven Schuetz | 2d1e547 | 2010-07-16 15:37:39 +0200 | [diff] [blame^] | 290 | zfcp_fc_enqueue_event(adapter, FCH_EVT_LINKUP, 0); |
| 291 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | break; |
Maxim Shchetynin | 9eb69af | 2006-01-05 09:56:47 +0100 | [diff] [blame] | 293 | case FSF_STATUS_READ_NOTIFICATION_LOST: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 294 | if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_ACT_UPDATED) |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 295 | zfcp_erp_adapter_access_changed(adapter, "fssrh_3", |
| 296 | req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 297 | if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_INCOMING_ELS) |
Swen Schillig | 9eae07e | 2009-11-24 16:54:06 +0100 | [diff] [blame] | 298 | queue_work(adapter->work_queue, &adapter->scan_work); |
Maxim Shchetynin | 9eb69af | 2006-01-05 09:56:47 +0100 | [diff] [blame] | 299 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | case FSF_STATUS_READ_CFDC_UPDATED: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 301 | zfcp_erp_adapter_access_changed(adapter, "fssrh_4", req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | break; |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 303 | case FSF_STATUS_READ_FEATURE_UPDATE_ALERT: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 304 | adapter->adapter_features = sr_buf->payload.word[0]; |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 305 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 307 | |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 308 | mempool_free(sr_buf, adapter->pool.status_read_data); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 309 | zfcp_fsf_req_free(req); |
Swen Schillig | d26ab06 | 2008-05-19 12:17:37 +0200 | [diff] [blame] | 310 | |
| 311 | atomic_inc(&adapter->stat_miss); |
Swen Schillig | 4544683 | 2009-08-18 15:43:17 +0200 | [diff] [blame] | 312 | queue_work(adapter->work_queue, &adapter->stat_work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | } |
| 314 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 315 | static void zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 317 | switch (req->qtcb->header.fsf_status_qual.word[0]) { |
| 318 | case FSF_SQ_FCP_RSP_AVAILABLE: |
| 319 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 320 | case FSF_SQ_NO_RETRY_POSSIBLE: |
| 321 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 322 | return; |
| 323 | case FSF_SQ_COMMAND_ABORTED: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 324 | break; |
| 325 | case FSF_SQ_NO_RECOM: |
| 326 | dev_err(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 327 | "The FCP adapter reported a problem " |
| 328 | "that cannot be recovered\n"); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 329 | zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfsqe1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 330 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 332 | /* all non-return stats set FSFREQ_ERROR*/ |
| 333 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 334 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 336 | static void zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *req) |
| 337 | { |
| 338 | if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) |
| 339 | return; |
Andreas Herrmann | 059c97d | 2005-09-13 21:47:52 +0200 | [diff] [blame] | 340 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 341 | switch (req->qtcb->header.fsf_status) { |
| 342 | case FSF_UNKNOWN_COMMAND: |
| 343 | dev_err(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 344 | "The FCP adapter does not recognize the command 0x%x\n", |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 345 | req->qtcb->header.fsf_command); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 346 | zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfse_1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 347 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | case FSF_ADAPTER_STATUS_AVAILABLE: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 350 | zfcp_fsf_fsfstatus_qual_eval(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | } |
| 354 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 355 | static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 357 | struct zfcp_adapter *adapter = req->adapter; |
| 358 | struct fsf_qtcb *qtcb = req->qtcb; |
| 359 | union fsf_prot_status_qual *psq = &qtcb->prefix.prot_status_qual; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 361 | zfcp_dbf_hba_fsf_response(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 363 | if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) { |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 364 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 365 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | } |
| 367 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 368 | switch (qtcb->prefix.prot_status) { |
| 369 | case FSF_PROT_GOOD: |
| 370 | case FSF_PROT_FSF_STATUS_PRESENTED: |
| 371 | return; |
| 372 | case FSF_PROT_QTCB_VERSION_ERROR: |
| 373 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 374 | "QTCB version 0x%x not supported by FCP adapter " |
| 375 | "(0x%x to 0x%x)\n", FSF_QTCB_CURRENT_VERSION, |
| 376 | psq->word[0], psq->word[1]); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 377 | zfcp_erp_adapter_shutdown(adapter, 0, "fspse_1", req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | break; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 379 | case FSF_PROT_ERROR_STATE: |
| 380 | case FSF_PROT_SEQ_NUMB_ERROR: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 381 | zfcp_erp_adapter_reopen(adapter, 0, "fspse_2", req); |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 382 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | break; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 384 | case FSF_PROT_UNSUPP_QTCB_TYPE: |
| 385 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 386 | "The QTCB type is not supported by the FCP adapter\n"); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 387 | zfcp_erp_adapter_shutdown(adapter, 0, "fspse_3", req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | break; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 389 | case FSF_PROT_HOST_CONNECTION_INITIALIZING: |
| 390 | atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT, |
| 391 | &adapter->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | break; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 393 | case FSF_PROT_DUPLICATE_REQUEST_ID: |
| 394 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 395 | "0x%Lx is an ambiguous request identifier\n", |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 396 | (unsigned long long)qtcb->bottom.support.req_handle); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 397 | zfcp_erp_adapter_shutdown(adapter, 0, "fspse_4", req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | break; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 399 | case FSF_PROT_LINK_DOWN: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 400 | zfcp_fsf_link_down_info_eval(req, "fspse_5", |
| 401 | &psq->link_down_info); |
Christof Schmitt | 452b505 | 2010-02-17 11:18:51 +0100 | [diff] [blame] | 402 | /* go through reopen to flush pending requests */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 403 | zfcp_erp_adapter_reopen(adapter, 0, "fspse_6", req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | break; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 405 | case FSF_PROT_REEST_QUEUE: |
| 406 | /* All ports should be marked as ready to run again */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 407 | zfcp_erp_modify_adapter_status(adapter, "fspse_7", NULL, |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 408 | ZFCP_STATUS_COMMON_RUNNING, |
| 409 | ZFCP_SET); |
| 410 | zfcp_erp_adapter_reopen(adapter, |
| 411 | ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED | |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 412 | ZFCP_STATUS_COMMON_ERP_FAILED, |
| 413 | "fspse_8", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 414 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | default: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 416 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 417 | "0x%x is not a valid transfer protocol status\n", |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 418 | qtcb->prefix.prot_status); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 419 | zfcp_erp_adapter_shutdown(adapter, 0, "fspse_9", req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 421 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | /** |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 425 | * zfcp_fsf_req_complete - process completion of a FSF request |
| 426 | * @fsf_req: The FSF request that has been completed. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | * |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 428 | * When a request has been completed either from the FCP adapter, |
| 429 | * or it has been dismissed due to a queue shutdown, this function |
| 430 | * is called to process the completion status and trigger further |
| 431 | * events related to the FSF request. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | */ |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 433 | static void zfcp_fsf_req_complete(struct zfcp_fsf_req *req) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 434 | { |
| 435 | if (unlikely(req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS)) { |
| 436 | zfcp_fsf_status_read_handler(req); |
| 437 | return; |
| 438 | } |
| 439 | |
| 440 | del_timer(&req->timer); |
| 441 | zfcp_fsf_protstatus_eval(req); |
| 442 | zfcp_fsf_fsfstatus_eval(req); |
| 443 | req->handler(req); |
| 444 | |
| 445 | if (req->erp_action) |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 446 | zfcp_erp_notify(req->erp_action, 0); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 447 | |
| 448 | if (likely(req->status & ZFCP_STATUS_FSFREQ_CLEANUP)) |
| 449 | zfcp_fsf_req_free(req); |
| 450 | else |
Swen Schillig | 058b864 | 2009-08-18 15:43:14 +0200 | [diff] [blame] | 451 | complete(&req->completion); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 452 | } |
| 453 | |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 454 | /** |
| 455 | * zfcp_fsf_req_dismiss_all - dismiss all fsf requests |
| 456 | * @adapter: pointer to struct zfcp_adapter |
| 457 | * |
| 458 | * Never ever call this without shutting down the adapter first. |
| 459 | * Otherwise the adapter would continue using and corrupting s390 storage. |
| 460 | * Included BUG_ON() call to ensure this is done. |
| 461 | * ERP is supposed to be the only user of this function. |
| 462 | */ |
| 463 | void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter) |
| 464 | { |
| 465 | struct zfcp_fsf_req *req, *tmp; |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 466 | LIST_HEAD(remove_queue); |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 467 | |
| 468 | BUG_ON(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP); |
Christof Schmitt | b6bd2fb | 2010-02-17 11:18:50 +0100 | [diff] [blame] | 469 | zfcp_reqlist_move(adapter->req_list, &remove_queue); |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 470 | |
| 471 | list_for_each_entry_safe(req, tmp, &remove_queue, list) { |
| 472 | list_del(&req->list); |
| 473 | req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; |
| 474 | zfcp_fsf_req_complete(req); |
| 475 | } |
| 476 | } |
| 477 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 478 | static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | { |
Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 480 | struct fsf_qtcb_bottom_config *bottom = &req->qtcb->bottom.config; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 481 | struct zfcp_adapter *adapter = req->adapter; |
Andreas Herrmann | 13e1e1f | 2005-09-19 16:56:17 +0200 | [diff] [blame] | 482 | struct Scsi_Host *shost = adapter->scsi_host; |
Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 483 | struct fc_els_flogi *nsp, *plogi; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | |
Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 485 | /* adjust pointers for missing command code */ |
| 486 | nsp = (struct fc_els_flogi *) ((u8 *)&bottom->nport_serv_param |
| 487 | - sizeof(u32)); |
| 488 | plogi = (struct fc_els_flogi *) ((u8 *)&bottom->plogi_payload |
| 489 | - sizeof(u32)); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 490 | |
| 491 | if (req->data) |
| 492 | memcpy(req->data, bottom, sizeof(*bottom)); |
| 493 | |
Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 494 | fc_host_port_name(shost) = nsp->fl_wwpn; |
| 495 | fc_host_node_name(shost) = nsp->fl_wwnn; |
Christof Schmitt | 800c0ca | 2009-11-24 16:54:12 +0100 | [diff] [blame] | 496 | fc_host_port_id(shost) = ntoh24(bottom->s_id); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 497 | fc_host_speed(shost) = bottom->fc_link_speed; |
| 498 | fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3; |
| 499 | |
| 500 | adapter->hydra_version = bottom->adapter_type; |
Christof Schmitt | faf4cd8 | 2010-07-16 15:37:36 +0200 | [diff] [blame] | 501 | adapter->timer_ticks = bottom->timer_interval & ZFCP_FSF_TIMER_INT_MASK; |
Christof Schmitt | 8d88cf3 | 2010-06-21 10:11:33 +0200 | [diff] [blame] | 502 | adapter->stat_read_buf_num = max(bottom->status_read_buf_num, |
| 503 | (u16)FSF_STATUS_READS_RECOM); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 504 | |
| 505 | if (fc_host_permanent_port_name(shost) == -1) |
| 506 | fc_host_permanent_port_name(shost) = fc_host_port_name(shost); |
| 507 | |
| 508 | switch (bottom->fc_topology) { |
| 509 | case FSF_TOPO_P2P: |
Christof Schmitt | 800c0ca | 2009-11-24 16:54:12 +0100 | [diff] [blame] | 510 | adapter->peer_d_id = ntoh24(bottom->peer_d_id); |
Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 511 | adapter->peer_wwpn = plogi->fl_wwpn; |
| 512 | adapter->peer_wwnn = plogi->fl_wwnn; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 513 | fc_host_port_type(shost) = FC_PORTTYPE_PTP; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 514 | break; |
| 515 | case FSF_TOPO_FABRIC: |
| 516 | fc_host_port_type(shost) = FC_PORTTYPE_NPORT; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 517 | break; |
| 518 | case FSF_TOPO_AL: |
| 519 | fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; |
Christof Schmitt | dceab65 | 2009-05-15 13:18:18 +0200 | [diff] [blame] | 520 | /* fall through */ |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 521 | default: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 522 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 523 | "Unknown or unsupported arbitrated loop " |
| 524 | "fibre channel topology detected\n"); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 525 | zfcp_erp_adapter_shutdown(adapter, 0, "fsece_1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 526 | return -EIO; |
| 527 | } |
| 528 | |
| 529 | return 0; |
| 530 | } |
| 531 | |
| 532 | static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req) |
| 533 | { |
| 534 | struct zfcp_adapter *adapter = req->adapter; |
| 535 | struct fsf_qtcb *qtcb = req->qtcb; |
| 536 | struct fsf_qtcb_bottom_config *bottom = &qtcb->bottom.config; |
| 537 | struct Scsi_Host *shost = adapter->scsi_host; |
| 538 | |
| 539 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
| 540 | return; |
| 541 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | adapter->fsf_lic_version = bottom->lic_version; |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 543 | adapter->adapter_features = bottom->adapter_features; |
| 544 | adapter->connection_features = bottom->connection_features; |
| 6f71d9b | 2005-04-10 23:04:28 -0500 | [diff] [blame] | 545 | adapter->peer_wwpn = 0; |
| 546 | adapter->peer_wwnn = 0; |
| 547 | adapter->peer_d_id = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 549 | switch (qtcb->header.fsf_status) { |
| 550 | case FSF_GOOD: |
| 551 | if (zfcp_fsf_exchange_config_evaluate(req)) |
| 552 | return; |
Swen Schillig | 52ef11a | 2007-08-28 09:31:09 +0200 | [diff] [blame] | 553 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 554 | if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) { |
| 555 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 556 | "FCP adapter maximum QTCB size (%d bytes) " |
| 557 | "is too small\n", |
| 558 | bottom->max_qtcb_size); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 559 | zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 560 | return; |
| 561 | } |
| 562 | atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, |
| 563 | &adapter->status); |
| 564 | break; |
| 565 | case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE: |
Andreas Herrmann | 13e1e1f | 2005-09-19 16:56:17 +0200 | [diff] [blame] | 566 | fc_host_node_name(shost) = 0; |
| 567 | fc_host_port_name(shost) = 0; |
| 568 | fc_host_port_id(shost) = 0; |
| 569 | fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; |
Andreas Herrmann | ad757cd | 2006-01-13 02:26:11 +0100 | [diff] [blame] | 570 | fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | adapter->hydra_version = 0; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 572 | |
| 573 | atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK, |
| 574 | &adapter->status); |
| 575 | |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 576 | zfcp_fsf_link_down_info_eval(req, "fsecdh2", |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 577 | &qtcb->header.fsf_status_qual.link_down_info); |
| 578 | break; |
| 579 | default: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 580 | zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh3", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 581 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | } |
| 583 | |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 584 | if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | adapter->hardware_version = bottom->hardware_version; |
Andreas Herrmann | 13e1e1f | 2005-09-19 16:56:17 +0200 | [diff] [blame] | 586 | memcpy(fc_host_serial_number(shost), bottom->serial_number, |
| 587 | min(FC_SERIAL_NUMBER_SIZE, 17)); |
| 588 | EBCASC(fc_host_serial_number(shost), |
| 589 | min(FC_SERIAL_NUMBER_SIZE, 17)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | } |
| 591 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 592 | if (FSF_QTCB_CURRENT_VERSION < bottom->low_qtcb_version) { |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 593 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 594 | "The FCP adapter only supports newer " |
| 595 | "control block versions\n"); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 596 | zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh4", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 597 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 599 | if (FSF_QTCB_CURRENT_VERSION > bottom->high_qtcb_version) { |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 600 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 601 | "The FCP adapter only supports older " |
| 602 | "control block versions\n"); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 603 | zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh5", req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | } |
| 606 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 607 | static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 609 | struct zfcp_adapter *adapter = req->adapter; |
| 610 | struct fsf_qtcb_bottom_port *bottom = &req->qtcb->bottom.port; |
| 611 | struct Scsi_Host *shost = adapter->scsi_host; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 613 | if (req->data) |
| 614 | memcpy(req->data, bottom, sizeof(*bottom)); |
Andreas Herrmann | 2f8f3ed | 2006-02-11 01:41:50 +0100 | [diff] [blame] | 615 | |
Christof Schmitt | 0282985 | 2009-03-02 13:09:06 +0100 | [diff] [blame] | 616 | if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) { |
Andreas Herrmann | 2f8f3ed | 2006-02-11 01:41:50 +0100 | [diff] [blame] | 617 | fc_host_permanent_port_name(shost) = bottom->wwpn; |
Christof Schmitt | 0282985 | 2009-03-02 13:09:06 +0100 | [diff] [blame] | 618 | fc_host_port_type(shost) = FC_PORTTYPE_NPIV; |
| 619 | } else |
Andreas Herrmann | 2f8f3ed | 2006-02-11 01:41:50 +0100 | [diff] [blame] | 620 | fc_host_permanent_port_name(shost) = fc_host_port_name(shost); |
| 621 | fc_host_maxframe_size(shost) = bottom->maximum_frame_size; |
| 622 | fc_host_supported_speeds(shost) = bottom->supported_speed; |
Christof Schmitt | 2d8e62b | 2010-02-17 11:18:58 +0100 | [diff] [blame] | 623 | memcpy(fc_host_supported_fc4s(shost), bottom->supported_fc4_types, |
| 624 | FC_FC4_LIST_SIZE); |
| 625 | memcpy(fc_host_active_fc4s(shost), bottom->active_fc4_types, |
| 626 | FC_FC4_LIST_SIZE); |
Andreas Herrmann | 2f8f3ed | 2006-02-11 01:41:50 +0100 | [diff] [blame] | 627 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 629 | static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 631 | struct fsf_qtcb *qtcb = req->qtcb; |
Andreas Herrmann | 2f8f3ed | 2006-02-11 01:41:50 +0100 | [diff] [blame] | 632 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 633 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | return; |
| 635 | |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 636 | switch (qtcb->header.fsf_status) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 637 | case FSF_GOOD: |
| 638 | zfcp_fsf_exchange_port_evaluate(req); |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 639 | break; |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 640 | case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 641 | zfcp_fsf_exchange_port_evaluate(req); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 642 | zfcp_fsf_link_down_info_eval(req, "fsepdh1", |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 643 | &qtcb->header.fsf_status_qual.link_down_info); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 644 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | } |
| 646 | } |
| 647 | |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 648 | static struct zfcp_fsf_req *zfcp_fsf_alloc(mempool_t *pool) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 649 | { |
| 650 | struct zfcp_fsf_req *req; |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 651 | |
| 652 | if (likely(pool)) |
| 653 | req = mempool_alloc(pool, GFP_ATOMIC); |
| 654 | else |
| 655 | req = kmalloc(sizeof(*req), GFP_ATOMIC); |
| 656 | |
| 657 | if (unlikely(!req)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 658 | return NULL; |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 659 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 660 | memset(req, 0, sizeof(*req)); |
Christof Schmitt | 88f2a97 | 2008-11-04 16:35:07 +0100 | [diff] [blame] | 661 | req->pool = pool; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 662 | return req; |
| 663 | } |
| 664 | |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 665 | static struct fsf_qtcb *zfcp_qtcb_alloc(mempool_t *pool) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 666 | { |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 667 | struct fsf_qtcb *qtcb; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 668 | |
| 669 | if (likely(pool)) |
| 670 | qtcb = mempool_alloc(pool, GFP_ATOMIC); |
| 671 | else |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 672 | qtcb = kmem_cache_alloc(zfcp_data.qtcb_cache, GFP_ATOMIC); |
| 673 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 674 | if (unlikely(!qtcb)) |
| 675 | return NULL; |
| 676 | |
| 677 | memset(qtcb, 0, sizeof(*qtcb)); |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 678 | return qtcb; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 679 | } |
| 680 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 681 | static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 682 | u32 fsf_cmd, u32 sbtype, |
| 683 | mempool_t *pool) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 685 | struct zfcp_adapter *adapter = qdio->adapter; |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 686 | struct zfcp_fsf_req *req = zfcp_fsf_alloc(pool); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 687 | |
| 688 | if (unlikely(!req)) |
Christof Schmitt | 1e9b164 | 2009-07-13 15:06:04 +0200 | [diff] [blame] | 689 | return ERR_PTR(-ENOMEM); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 690 | |
| 691 | if (adapter->req_no == 0) |
| 692 | adapter->req_no++; |
| 693 | |
| 694 | INIT_LIST_HEAD(&req->list); |
| 695 | init_timer(&req->timer); |
Swen Schillig | 058b864 | 2009-08-18 15:43:14 +0200 | [diff] [blame] | 696 | init_completion(&req->completion); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 697 | |
| 698 | req->adapter = adapter; |
| 699 | req->fsf_command = fsf_cmd; |
Christof Schmitt | 52bfb55 | 2009-03-02 13:08:58 +0100 | [diff] [blame] | 700 | req->req_id = adapter->req_no; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 701 | |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 702 | if (likely(fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS)) { |
| 703 | if (likely(pool)) |
| 704 | req->qtcb = zfcp_qtcb_alloc(adapter->pool.qtcb_pool); |
| 705 | else |
| 706 | req->qtcb = zfcp_qtcb_alloc(NULL); |
| 707 | |
| 708 | if (unlikely(!req->qtcb)) { |
| 709 | zfcp_fsf_req_free(req); |
| 710 | return ERR_PTR(-ENOMEM); |
| 711 | } |
| 712 | |
Christof Schmitt | 5bdecd2 | 2010-02-17 11:18:55 +0100 | [diff] [blame] | 713 | req->seq_no = adapter->fsf_req_seq_no; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 714 | req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 715 | req->qtcb->prefix.req_id = req->req_id; |
| 716 | req->qtcb->prefix.ulp_info = 26; |
| 717 | req->qtcb->prefix.qtcb_type = fsf_qtcb_type[req->fsf_command]; |
| 718 | req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION; |
| 719 | req->qtcb->header.req_handle = req->req_id; |
| 720 | req->qtcb->header.fsf_command = req->fsf_command; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 721 | } |
| 722 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 723 | zfcp_qdio_req_init(adapter->qdio, &req->qdio_req, req->req_id, sbtype, |
| 724 | req->qtcb, sizeof(struct fsf_qtcb)); |
| 725 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 726 | return req; |
| 727 | } |
| 728 | |
| 729 | static int zfcp_fsf_req_send(struct zfcp_fsf_req *req) |
| 730 | { |
| 731 | struct zfcp_adapter *adapter = req->adapter; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 732 | struct zfcp_qdio *qdio = adapter->qdio; |
Christof Schmitt | b6bd2fb | 2010-02-17 11:18:50 +0100 | [diff] [blame] | 733 | int with_qtcb = (req->qtcb != NULL); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 734 | int req_id = req->req_id; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 735 | |
Christof Schmitt | b6bd2fb | 2010-02-17 11:18:50 +0100 | [diff] [blame] | 736 | zfcp_reqlist_add(adapter->req_list, req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 737 | |
Swen Schillig | 706eca4 | 2010-07-16 15:37:38 +0200 | [diff] [blame] | 738 | req->qdio_req.qdio_outb_usage = atomic_read(&qdio->req_q_free); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 739 | req->issued = get_clock(); |
Christof Schmitt | 34c2b71 | 2010-02-17 11:18:59 +0100 | [diff] [blame] | 740 | if (zfcp_qdio_send(qdio, &req->qdio_req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 741 | del_timer(&req->timer); |
Christof Schmitt | 3765138 | 2008-11-04 16:35:08 +0100 | [diff] [blame] | 742 | /* lookup request again, list might have changed */ |
Christof Schmitt | b6bd2fb | 2010-02-17 11:18:50 +0100 | [diff] [blame] | 743 | zfcp_reqlist_find_rm(adapter->req_list, req_id); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 744 | zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 745 | return -EIO; |
| 746 | } |
| 747 | |
| 748 | /* Don't increase for unsolicited status */ |
Martin Petermann | 135ea13 | 2009-04-17 15:08:01 +0200 | [diff] [blame] | 749 | if (with_qtcb) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 750 | adapter->fsf_req_seq_no++; |
Christof Schmitt | 52bfb55 | 2009-03-02 13:08:58 +0100 | [diff] [blame] | 751 | adapter->req_no++; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 752 | |
| 753 | return 0; |
| 754 | } |
| 755 | |
| 756 | /** |
| 757 | * zfcp_fsf_status_read - send status read request |
| 758 | * @adapter: pointer to struct zfcp_adapter |
| 759 | * @req_flags: request flags |
| 760 | * Returns: 0 on success, ERROR otherwise |
| 761 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 762 | int zfcp_fsf_status_read(struct zfcp_qdio *qdio) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 763 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 764 | struct zfcp_adapter *adapter = qdio->adapter; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 765 | struct zfcp_fsf_req *req; |
| 766 | struct fsf_status_read_buffer *sr_buf; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 767 | int retval = -EIO; |
| 768 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 769 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 770 | if (zfcp_qdio_sbal_get(qdio)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 773 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_UNSOLICITED_STATUS, 0, |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 774 | adapter->pool.status_read_req); |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 775 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 776 | retval = PTR_ERR(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | goto out; |
| 778 | } |
| 779 | |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 780 | sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 781 | if (!sr_buf) { |
| 782 | retval = -ENOMEM; |
| 783 | goto failed_buf; |
| 784 | } |
| 785 | memset(sr_buf, 0, sizeof(*sr_buf)); |
| 786 | req->data = sr_buf; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 787 | |
| 788 | zfcp_qdio_fill_next(qdio, &req->qdio_req, sr_buf, sizeof(*sr_buf)); |
| 789 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 790 | |
| 791 | retval = zfcp_fsf_req_send(req); |
| 792 | if (retval) |
| 793 | goto failed_req_send; |
| 794 | |
| 795 | goto out; |
| 796 | |
| 797 | failed_req_send: |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 798 | mempool_free(sr_buf, adapter->pool.status_read_data); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 799 | failed_buf: |
| 800 | zfcp_fsf_req_free(req); |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 801 | zfcp_dbf_hba_fsf_unsol("fail", adapter->dbf, NULL); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 802 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 803 | spin_unlock_bh(&qdio->req_q_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | return retval; |
| 805 | } |
| 806 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 807 | static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 809 | struct zfcp_unit *unit = req->data; |
| 810 | union fsf_status_qual *fsq = &req->qtcb->header.fsf_status_qual; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 812 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
| 813 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 815 | switch (req->qtcb->header.fsf_status) { |
| 816 | case FSF_PORT_HANDLE_NOT_VALID: |
| 817 | if (fsq->word[0] == fsq->word[1]) { |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 818 | zfcp_erp_adapter_reopen(unit->port->adapter, 0, |
| 819 | "fsafch1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 820 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 821 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | break; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 823 | case FSF_LUN_HANDLE_NOT_VALID: |
| 824 | if (fsq->word[0] == fsq->word[1]) { |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 825 | zfcp_erp_port_reopen(unit->port, 0, "fsafch2", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 826 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 827 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 828 | break; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 829 | case FSF_FCP_COMMAND_DOES_NOT_EXIST: |
| 830 | req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | break; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 832 | case FSF_PORT_BOXED: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 833 | zfcp_erp_port_boxed(unit->port, "fsafch3", req); |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 834 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 835 | break; |
| 836 | case FSF_LUN_BOXED: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 837 | zfcp_erp_unit_boxed(unit, "fsafch4", req); |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 838 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 839 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | case FSF_ADAPTER_STATUS_AVAILABLE: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 841 | switch (fsq->word[0]) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 843 | zfcp_fc_test_link(unit->port); |
Christof Schmitt | dceab65 | 2009-05-15 13:18:18 +0200 | [diff] [blame] | 844 | /* fall through */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 846 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | break; |
| 848 | } |
| 849 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | case FSF_GOOD: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 851 | req->status |= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED; |
| 852 | break; |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | /** |
| 857 | * zfcp_fsf_abort_fcp_command - abort running SCSI command |
| 858 | * @old_req_id: unsigned long |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 859 | * @unit: pointer to struct zfcp_unit |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 860 | * Returns: pointer to struct zfcp_fsf_req |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 861 | */ |
| 862 | |
| 863 | struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id, |
Christof Schmitt | 63caf36 | 2009-03-02 13:09:00 +0100 | [diff] [blame] | 864 | struct zfcp_unit *unit) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 865 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 866 | struct zfcp_fsf_req *req = NULL; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 867 | struct zfcp_qdio *qdio = unit->port->adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 868 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 869 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 870 | if (zfcp_qdio_sbal_get(qdio)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 871 | goto out; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 872 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_ABORT_FCP_CMND, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 873 | SBAL_FLAGS0_TYPE_READ, |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 874 | qdio->adapter->pool.scsi_abort); |
Swen Schillig | 633528c | 2008-11-26 18:07:37 +0100 | [diff] [blame] | 875 | if (IS_ERR(req)) { |
| 876 | req = NULL; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 877 | goto out; |
Swen Schillig | 633528c | 2008-11-26 18:07:37 +0100 | [diff] [blame] | 878 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 879 | |
| 880 | if (unlikely(!(atomic_read(&unit->status) & |
| 881 | ZFCP_STATUS_COMMON_UNBLOCKED))) |
| 882 | goto out_error_free; |
| 883 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 884 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 885 | |
| 886 | req->data = unit; |
| 887 | req->handler = zfcp_fsf_abort_fcp_command_handler; |
| 888 | req->qtcb->header.lun_handle = unit->handle; |
| 889 | req->qtcb->header.port_handle = unit->port->handle; |
| 890 | req->qtcb->bottom.support.req_handle = (u64) old_req_id; |
| 891 | |
| 892 | zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT); |
| 893 | if (!zfcp_fsf_req_send(req)) |
| 894 | goto out; |
| 895 | |
| 896 | out_error_free: |
| 897 | zfcp_fsf_req_free(req); |
| 898 | req = NULL; |
| 899 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 900 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 901 | return req; |
| 902 | } |
| 903 | |
| 904 | static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req) |
| 905 | { |
| 906 | struct zfcp_adapter *adapter = req->adapter; |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 907 | struct zfcp_fsf_ct_els *ct = req->data; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 908 | struct fsf_qtcb_header *header = &req->qtcb->header; |
| 909 | |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 910 | ct->status = -EINVAL; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 911 | |
| 912 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
| 913 | goto skip_fsfstatus; |
| 914 | |
| 915 | switch (header->fsf_status) { |
| 916 | case FSF_GOOD: |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 917 | zfcp_dbf_san_ct_response(req); |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 918 | ct->status = 0; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 919 | break; |
| 920 | case FSF_SERVICE_CLASS_NOT_SUPPORTED: |
| 921 | zfcp_fsf_class_not_supp(req); |
| 922 | break; |
| 923 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 924 | switch (header->fsf_status_qual.word[0]){ |
| 925 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 926 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 927 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 928 | break; |
| 929 | } |
| 930 | break; |
| 931 | case FSF_ACCESS_DENIED: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 932 | break; |
| 933 | case FSF_PORT_BOXED: |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 934 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 935 | break; |
| 936 | case FSF_PORT_HANDLE_NOT_VALID: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 937 | zfcp_erp_adapter_reopen(adapter, 0, "fsscth1", req); |
Christof Schmitt | dceab65 | 2009-05-15 13:18:18 +0200 | [diff] [blame] | 938 | /* fall through */ |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 939 | case FSF_GENERIC_COMMAND_REJECTED: |
| 940 | case FSF_PAYLOAD_SIZE_MISMATCH: |
| 941 | case FSF_REQUEST_SIZE_TOO_LARGE: |
| 942 | case FSF_RESPONSE_SIZE_TOO_LARGE: |
| 943 | case FSF_SBAL_MISMATCH: |
| 944 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 945 | break; |
| 946 | } |
| 947 | |
| 948 | skip_fsfstatus: |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 949 | if (ct->handler) |
| 950 | ct->handler(ct->handler_data); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 951 | } |
| 952 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 953 | static void zfcp_fsf_setup_ct_els_unchained(struct zfcp_qdio *qdio, |
| 954 | struct zfcp_qdio_req *q_req, |
Christof Schmitt | 426f605 | 2009-07-13 15:06:06 +0200 | [diff] [blame] | 955 | struct scatterlist *sg_req, |
| 956 | struct scatterlist *sg_resp) |
| 957 | { |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 958 | zfcp_qdio_fill_next(qdio, q_req, sg_virt(sg_req), sg_req->length); |
| 959 | zfcp_qdio_fill_next(qdio, q_req, sg_virt(sg_resp), sg_resp->length); |
| 960 | zfcp_qdio_set_sbale_last(qdio, q_req); |
Christof Schmitt | 426f605 | 2009-07-13 15:06:06 +0200 | [diff] [blame] | 961 | } |
| 962 | |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 963 | static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, |
| 964 | struct scatterlist *sg_req, |
Swen Schillig | 01b0475 | 2010-07-16 15:37:37 +0200 | [diff] [blame] | 965 | struct scatterlist *sg_resp) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 966 | { |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 967 | struct zfcp_adapter *adapter = req->adapter; |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 968 | u32 feat = adapter->adapter_features; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 969 | int bytes; |
| 970 | |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 971 | if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) { |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 972 | if (!zfcp_qdio_sg_one_sbale(sg_req) || |
| 973 | !zfcp_qdio_sg_one_sbale(sg_resp)) |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 974 | return -EOPNOTSUPP; |
| 975 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 976 | zfcp_fsf_setup_ct_els_unchained(adapter->qdio, &req->qdio_req, |
| 977 | sg_req, sg_resp); |
Christof Schmitt | 426f605 | 2009-07-13 15:06:06 +0200 | [diff] [blame] | 978 | return 0; |
| 979 | } |
| 980 | |
| 981 | /* use single, unchained SBAL if it can hold the request */ |
Swen Schillig | 30b6777 | 2010-06-21 10:11:31 +0200 | [diff] [blame] | 982 | if (zfcp_qdio_sg_one_sbale(sg_req) && zfcp_qdio_sg_one_sbale(sg_resp)) { |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 983 | zfcp_fsf_setup_ct_els_unchained(adapter->qdio, &req->qdio_req, |
| 984 | sg_req, sg_resp); |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 985 | return 0; |
| 986 | } |
| 987 | |
Swen Schillig | 01b0475 | 2010-07-16 15:37:37 +0200 | [diff] [blame] | 988 | bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, sg_req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 989 | if (bytes <= 0) |
Christof Schmitt | 9072df4 | 2009-07-13 15:06:07 +0200 | [diff] [blame] | 990 | return -EIO; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 991 | req->qtcb->bottom.support.req_buf_length = bytes; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 992 | zfcp_qdio_skip_to_last_sbale(&req->qdio_req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 993 | |
Christof Schmitt | 34c2b71 | 2010-02-17 11:18:59 +0100 | [diff] [blame] | 994 | bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, |
Swen Schillig | 01b0475 | 2010-07-16 15:37:37 +0200 | [diff] [blame] | 995 | sg_resp); |
Christof Schmitt | b1a5898 | 2009-09-24 10:23:21 +0200 | [diff] [blame] | 996 | req->qtcb->bottom.support.resp_buf_length = bytes; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 997 | if (bytes <= 0) |
Christof Schmitt | 9072df4 | 2009-07-13 15:06:07 +0200 | [diff] [blame] | 998 | return -EIO; |
Christof Schmitt | 98fc4d5 | 2009-08-18 15:43:26 +0200 | [diff] [blame] | 999 | |
Christof Schmitt | b1a5898 | 2009-09-24 10:23:21 +0200 | [diff] [blame] | 1000 | return 0; |
| 1001 | } |
| 1002 | |
| 1003 | static int zfcp_fsf_setup_ct_els(struct zfcp_fsf_req *req, |
| 1004 | struct scatterlist *sg_req, |
| 1005 | struct scatterlist *sg_resp, |
Swen Schillig | 01b0475 | 2010-07-16 15:37:37 +0200 | [diff] [blame] | 1006 | unsigned int timeout) |
Christof Schmitt | b1a5898 | 2009-09-24 10:23:21 +0200 | [diff] [blame] | 1007 | { |
| 1008 | int ret; |
| 1009 | |
Swen Schillig | 01b0475 | 2010-07-16 15:37:37 +0200 | [diff] [blame] | 1010 | ret = zfcp_fsf_setup_ct_els_sbals(req, sg_req, sg_resp); |
Christof Schmitt | b1a5898 | 2009-09-24 10:23:21 +0200 | [diff] [blame] | 1011 | if (ret) |
| 1012 | return ret; |
| 1013 | |
Christof Schmitt | 98fc4d5 | 2009-08-18 15:43:26 +0200 | [diff] [blame] | 1014 | /* common settings for ct/gs and els requests */ |
Swen Schillig | 51375ee | 2010-01-14 17:19:02 +0100 | [diff] [blame] | 1015 | if (timeout > 255) |
| 1016 | timeout = 255; /* max value accepted by hardware */ |
Christof Schmitt | 98fc4d5 | 2009-08-18 15:43:26 +0200 | [diff] [blame] | 1017 | req->qtcb->bottom.support.service_class = FSF_CLASS_3; |
Swen Schillig | 51375ee | 2010-01-14 17:19:02 +0100 | [diff] [blame] | 1018 | req->qtcb->bottom.support.timeout = timeout; |
| 1019 | zfcp_fsf_start_timer(req, (timeout + 10) * HZ); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1020 | |
| 1021 | return 0; |
| 1022 | } |
| 1023 | |
| 1024 | /** |
| 1025 | * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS) |
| 1026 | * @ct: pointer to struct zfcp_send_ct with data for request |
| 1027 | * @pool: if non-null this mempool is used to allocate struct zfcp_fsf_req |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1028 | */ |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 1029 | int zfcp_fsf_send_ct(struct zfcp_fc_wka_port *wka_port, |
Swen Schillig | 51375ee | 2010-01-14 17:19:02 +0100 | [diff] [blame] | 1030 | struct zfcp_fsf_ct_els *ct, mempool_t *pool, |
| 1031 | unsigned int timeout) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1032 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1033 | struct zfcp_qdio *qdio = wka_port->adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1034 | struct zfcp_fsf_req *req; |
| 1035 | int ret = -EIO; |
| 1036 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1037 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1038 | if (zfcp_qdio_sbal_get(qdio)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1039 | goto out; |
| 1040 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1041 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_GENERIC, |
| 1042 | SBAL_FLAGS0_TYPE_WRITE_READ, pool); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1043 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1044 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1045 | ret = PTR_ERR(req); |
| 1046 | goto out; |
| 1047 | } |
| 1048 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1049 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Swen Schillig | 01b0475 | 2010-07-16 15:37:37 +0200 | [diff] [blame] | 1050 | ret = zfcp_fsf_setup_ct_els(req, ct->req, ct->resp, timeout); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1051 | if (ret) |
| 1052 | goto failed_send; |
| 1053 | |
| 1054 | req->handler = zfcp_fsf_send_ct_handler; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1055 | req->qtcb->header.port_handle = wka_port->handle; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1056 | req->data = ct; |
| 1057 | |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 1058 | zfcp_dbf_san_ct_request(req, wka_port->d_id); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1059 | |
| 1060 | ret = zfcp_fsf_req_send(req); |
| 1061 | if (ret) |
| 1062 | goto failed_send; |
| 1063 | |
| 1064 | goto out; |
| 1065 | |
| 1066 | failed_send: |
| 1067 | zfcp_fsf_req_free(req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1068 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1069 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1070 | return ret; |
| 1071 | } |
| 1072 | |
| 1073 | static void zfcp_fsf_send_els_handler(struct zfcp_fsf_req *req) |
| 1074 | { |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 1075 | struct zfcp_fsf_ct_els *send_els = req->data; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1076 | struct zfcp_port *port = send_els->port; |
| 1077 | struct fsf_qtcb_header *header = &req->qtcb->header; |
| 1078 | |
| 1079 | send_els->status = -EINVAL; |
| 1080 | |
| 1081 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
| 1082 | goto skip_fsfstatus; |
| 1083 | |
| 1084 | switch (header->fsf_status) { |
| 1085 | case FSF_GOOD: |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1086 | zfcp_dbf_san_els_response(req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1087 | send_els->status = 0; |
| 1088 | break; |
| 1089 | case FSF_SERVICE_CLASS_NOT_SUPPORTED: |
| 1090 | zfcp_fsf_class_not_supp(req); |
| 1091 | break; |
| 1092 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 1093 | switch (header->fsf_status_qual.word[0]){ |
| 1094 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1095 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 1096 | case FSF_SQ_RETRY_IF_POSSIBLE: |
| 1097 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1098 | break; |
| 1099 | } |
| 1100 | break; |
| 1101 | case FSF_ELS_COMMAND_REJECTED: |
| 1102 | case FSF_PAYLOAD_SIZE_MISMATCH: |
| 1103 | case FSF_REQUEST_SIZE_TOO_LARGE: |
| 1104 | case FSF_RESPONSE_SIZE_TOO_LARGE: |
| 1105 | break; |
| 1106 | case FSF_ACCESS_DENIED: |
Christof Schmitt | dc577d5 | 2009-05-15 13:18:22 +0200 | [diff] [blame] | 1107 | if (port) |
| 1108 | zfcp_fsf_access_denied_port(req, port); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1109 | break; |
| 1110 | case FSF_SBAL_MISMATCH: |
| 1111 | /* should never occure, avoided in zfcp_fsf_send_els */ |
| 1112 | /* fall through */ |
| 1113 | default: |
| 1114 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1115 | break; |
| 1116 | } |
| 1117 | skip_fsfstatus: |
| 1118 | if (send_els->handler) |
| 1119 | send_els->handler(send_els->handler_data); |
| 1120 | } |
| 1121 | |
| 1122 | /** |
| 1123 | * zfcp_fsf_send_els - initiate an ELS command (FC-FS) |
| 1124 | * @els: pointer to struct zfcp_send_els with data for the command |
| 1125 | */ |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 1126 | int zfcp_fsf_send_els(struct zfcp_adapter *adapter, u32 d_id, |
Swen Schillig | 51375ee | 2010-01-14 17:19:02 +0100 | [diff] [blame] | 1127 | struct zfcp_fsf_ct_els *els, unsigned int timeout) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1128 | { |
| 1129 | struct zfcp_fsf_req *req; |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 1130 | struct zfcp_qdio *qdio = adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1131 | int ret = -EIO; |
| 1132 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1133 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1134 | if (zfcp_qdio_sbal_get(qdio)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1135 | goto out; |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1136 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1137 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_ELS, |
| 1138 | SBAL_FLAGS0_TYPE_WRITE_READ, NULL); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1139 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1140 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1141 | ret = PTR_ERR(req); |
| 1142 | goto out; |
| 1143 | } |
| 1144 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1145 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Swen Schillig | 01b0475 | 2010-07-16 15:37:37 +0200 | [diff] [blame] | 1146 | |
| 1147 | zfcp_qdio_sbal_limit(qdio, &req->qdio_req, 2); |
| 1148 | |
| 1149 | ret = zfcp_fsf_setup_ct_els(req, els->req, els->resp, timeout); |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 1150 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1151 | if (ret) |
| 1152 | goto failed_send; |
| 1153 | |
Christof Schmitt | 7c7dc19 | 2009-11-24 16:54:13 +0100 | [diff] [blame] | 1154 | hton24(req->qtcb->bottom.support.d_id, d_id); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1155 | req->handler = zfcp_fsf_send_els_handler; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1156 | req->data = els; |
| 1157 | |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 1158 | zfcp_dbf_san_els_request(req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1159 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1160 | ret = zfcp_fsf_req_send(req); |
| 1161 | if (ret) |
| 1162 | goto failed_send; |
| 1163 | |
| 1164 | goto out; |
| 1165 | |
| 1166 | failed_send: |
| 1167 | zfcp_fsf_req_free(req); |
| 1168 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1169 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1170 | return ret; |
| 1171 | } |
| 1172 | |
| 1173 | int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) |
| 1174 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1175 | struct zfcp_fsf_req *req; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1176 | struct zfcp_qdio *qdio = erp_action->adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1177 | int retval = -EIO; |
| 1178 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1179 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1180 | if (zfcp_qdio_sbal_get(qdio)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1181 | goto out; |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1182 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1183 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1184 | SBAL_FLAGS0_TYPE_READ, |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1185 | qdio->adapter->pool.erp_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1186 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1187 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1188 | retval = PTR_ERR(req); |
| 1189 | goto out; |
| 1190 | } |
| 1191 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1192 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1193 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1194 | |
| 1195 | req->qtcb->bottom.config.feature_selection = |
| 1196 | FSF_FEATURE_CFDC | |
| 1197 | FSF_FEATURE_LUN_SHARING | |
| 1198 | FSF_FEATURE_NOTIFICATION_LOST | |
| 1199 | FSF_FEATURE_UPDATE_ALERT; |
| 1200 | req->erp_action = erp_action; |
| 1201 | req->handler = zfcp_fsf_exchange_config_data_handler; |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1202 | erp_action->fsf_req_id = req->req_id; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1203 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1204 | zfcp_fsf_start_erp_timer(req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1205 | retval = zfcp_fsf_req_send(req); |
| 1206 | if (retval) { |
| 1207 | zfcp_fsf_req_free(req); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1208 | erp_action->fsf_req_id = 0; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1209 | } |
| 1210 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1211 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1212 | return retval; |
| 1213 | } |
| 1214 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1215 | int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio, |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1216 | struct fsf_qtcb_bottom_config *data) |
| 1217 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1218 | struct zfcp_fsf_req *req = NULL; |
| 1219 | int retval = -EIO; |
| 1220 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1221 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1222 | if (zfcp_qdio_sbal_get(qdio)) |
Christof Schmitt | ada81b7 | 2009-04-17 15:08:03 +0200 | [diff] [blame] | 1223 | goto out_unlock; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1224 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1225 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, |
| 1226 | SBAL_FLAGS0_TYPE_READ, NULL); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1227 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1228 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1229 | retval = PTR_ERR(req); |
Christof Schmitt | ada81b7 | 2009-04-17 15:08:03 +0200 | [diff] [blame] | 1230 | goto out_unlock; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1231 | } |
| 1232 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1233 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1234 | req->handler = zfcp_fsf_exchange_config_data_handler; |
| 1235 | |
| 1236 | req->qtcb->bottom.config.feature_selection = |
| 1237 | FSF_FEATURE_CFDC | |
| 1238 | FSF_FEATURE_LUN_SHARING | |
| 1239 | FSF_FEATURE_NOTIFICATION_LOST | |
| 1240 | FSF_FEATURE_UPDATE_ALERT; |
| 1241 | |
| 1242 | if (data) |
| 1243 | req->data = data; |
| 1244 | |
| 1245 | zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); |
| 1246 | retval = zfcp_fsf_req_send(req); |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1247 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1248 | if (!retval) |
Swen Schillig | 058b864 | 2009-08-18 15:43:14 +0200 | [diff] [blame] | 1249 | wait_for_completion(&req->completion); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1250 | |
| 1251 | zfcp_fsf_req_free(req); |
Christof Schmitt | ada81b7 | 2009-04-17 15:08:03 +0200 | [diff] [blame] | 1252 | return retval; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1253 | |
Christof Schmitt | ada81b7 | 2009-04-17 15:08:03 +0200 | [diff] [blame] | 1254 | out_unlock: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1255 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1256 | return retval; |
| 1257 | } |
| 1258 | |
| 1259 | /** |
| 1260 | * zfcp_fsf_exchange_port_data - request information about local port |
| 1261 | * @erp_action: ERP action for the adapter for which port data is requested |
| 1262 | * Returns: 0 on success, error otherwise |
| 1263 | */ |
| 1264 | int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action) |
| 1265 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1266 | struct zfcp_qdio *qdio = erp_action->adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1267 | struct zfcp_fsf_req *req; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1268 | int retval = -EIO; |
| 1269 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1270 | if (!(qdio->adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1271 | return -EOPNOTSUPP; |
| 1272 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1273 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1274 | if (zfcp_qdio_sbal_get(qdio)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1275 | goto out; |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1276 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1277 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1278 | SBAL_FLAGS0_TYPE_READ, |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1279 | qdio->adapter->pool.erp_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1280 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1281 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1282 | retval = PTR_ERR(req); |
| 1283 | goto out; |
| 1284 | } |
| 1285 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1286 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1287 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1288 | |
| 1289 | req->handler = zfcp_fsf_exchange_port_data_handler; |
| 1290 | req->erp_action = erp_action; |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1291 | erp_action->fsf_req_id = req->req_id; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1292 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1293 | zfcp_fsf_start_erp_timer(req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1294 | retval = zfcp_fsf_req_send(req); |
| 1295 | if (retval) { |
| 1296 | zfcp_fsf_req_free(req); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1297 | erp_action->fsf_req_id = 0; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1298 | } |
| 1299 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1300 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1301 | return retval; |
| 1302 | } |
| 1303 | |
| 1304 | /** |
| 1305 | * zfcp_fsf_exchange_port_data_sync - request information about local port |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1306 | * @qdio: pointer to struct zfcp_qdio |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1307 | * @data: pointer to struct fsf_qtcb_bottom_port |
| 1308 | * Returns: 0 on success, error otherwise |
| 1309 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1310 | int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio, |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1311 | struct fsf_qtcb_bottom_port *data) |
| 1312 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1313 | struct zfcp_fsf_req *req = NULL; |
| 1314 | int retval = -EIO; |
| 1315 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1316 | if (!(qdio->adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1317 | return -EOPNOTSUPP; |
| 1318 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1319 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1320 | if (zfcp_qdio_sbal_get(qdio)) |
Christof Schmitt | ada81b7 | 2009-04-17 15:08:03 +0200 | [diff] [blame] | 1321 | goto out_unlock; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1322 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1323 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, |
| 1324 | SBAL_FLAGS0_TYPE_READ, NULL); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1325 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1326 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1327 | retval = PTR_ERR(req); |
Christof Schmitt | ada81b7 | 2009-04-17 15:08:03 +0200 | [diff] [blame] | 1328 | goto out_unlock; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1329 | } |
| 1330 | |
| 1331 | if (data) |
| 1332 | req->data = data; |
| 1333 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1334 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1335 | |
| 1336 | req->handler = zfcp_fsf_exchange_port_data_handler; |
| 1337 | zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); |
| 1338 | retval = zfcp_fsf_req_send(req); |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1339 | spin_unlock_bh(&qdio->req_q_lock); |
Christof Schmitt | ada81b7 | 2009-04-17 15:08:03 +0200 | [diff] [blame] | 1340 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1341 | if (!retval) |
Swen Schillig | 058b864 | 2009-08-18 15:43:14 +0200 | [diff] [blame] | 1342 | wait_for_completion(&req->completion); |
| 1343 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1344 | zfcp_fsf_req_free(req); |
| 1345 | |
| 1346 | return retval; |
Christof Schmitt | ada81b7 | 2009-04-17 15:08:03 +0200 | [diff] [blame] | 1347 | |
| 1348 | out_unlock: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1349 | spin_unlock_bh(&qdio->req_q_lock); |
Christof Schmitt | ada81b7 | 2009-04-17 15:08:03 +0200 | [diff] [blame] | 1350 | return retval; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1351 | } |
| 1352 | |
| 1353 | static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req) |
| 1354 | { |
| 1355 | struct zfcp_port *port = req->data; |
| 1356 | struct fsf_qtcb_header *header = &req->qtcb->header; |
Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 1357 | struct fc_els_flogi *plogi; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1358 | |
| 1359 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
Martin Petermann | a17c585 | 2009-05-15 13:18:19 +0200 | [diff] [blame] | 1360 | goto out; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1361 | |
| 1362 | switch (header->fsf_status) { |
| 1363 | case FSF_PORT_ALREADY_OPEN: |
| 1364 | break; |
| 1365 | case FSF_ACCESS_DENIED: |
| 1366 | zfcp_fsf_access_denied_port(req, port); |
| 1367 | break; |
| 1368 | case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED: |
| 1369 | dev_warn(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1370 | "Not enough FCP adapter resources to open " |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 1371 | "remote port 0x%016Lx\n", |
| 1372 | (unsigned long long)port->wwpn); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1373 | zfcp_erp_port_failed(port, "fsoph_1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1374 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1375 | break; |
| 1376 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 1377 | switch (header->fsf_status_qual.word[0]) { |
| 1378 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
| 1379 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1380 | case FSF_SQ_NO_RETRY_POSSIBLE: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1381 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1382 | break; |
| 1383 | } |
| 1384 | break; |
| 1385 | case FSF_GOOD: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1386 | port->handle = header->port_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1387 | atomic_set_mask(ZFCP_STATUS_COMMON_OPEN | |
| 1388 | ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); |
Andreas Herrmann | d736a27b | 2005-06-13 13:23:57 +0200 | [diff] [blame] | 1389 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | |
| 1390 | ZFCP_STATUS_COMMON_ACCESS_BOXED, |
| 1391 | &port->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | /* check whether D_ID has changed during open */ |
| 1393 | /* |
| 1394 | * FIXME: This check is not airtight, as the FCP channel does |
| 1395 | * not monitor closures of target port connections caused on |
| 1396 | * the remote side. Thus, they might miss out on invalidating |
| 1397 | * locally cached WWPNs (and other N_Port parameters) of gone |
| 1398 | * target ports. So, our heroic attempt to make things safe |
| 1399 | * could be undermined by 'open port' response data tagged with |
| 1400 | * obsolete WWPNs. Another reason to monitor potential |
| 1401 | * connection closures ourself at least (by interpreting |
| 1402 | * incoming ELS' and unsolicited status). It just crosses my |
| 1403 | * mind that one should be able to cross-check by means of |
| 1404 | * another GID_PN straight after a port has been opened. |
| 1405 | * Alternately, an ADISC/PDISC ELS should suffice, as well. |
| 1406 | */ |
Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 1407 | plogi = (struct fc_els_flogi *) req->qtcb->bottom.support.els; |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 1408 | if (req->qtcb->bottom.support.els1_length >= |
Christof Schmitt | 9d05ce2 | 2009-11-24 16:54:09 +0100 | [diff] [blame] | 1409 | FSF_PLOGI_MIN_LEN) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1410 | zfcp_fc_plogi_evaluate(port, plogi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1412 | case FSF_UNKNOWN_OP_SUBTYPE: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1413 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1414 | break; |
| 1415 | } |
Martin Petermann | a17c585 | 2009-05-15 13:18:19 +0200 | [diff] [blame] | 1416 | |
| 1417 | out: |
Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 1418 | put_device(&port->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1419 | } |
| 1420 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1421 | /** |
| 1422 | * zfcp_fsf_open_port - create and send open port request |
| 1423 | * @erp_action: pointer to struct zfcp_erp_action |
| 1424 | * Returns: 0 on success, error otherwise |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1425 | */ |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1426 | int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1427 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1428 | struct zfcp_qdio *qdio = erp_action->adapter->qdio; |
Martin Petermann | a17c585 | 2009-05-15 13:18:19 +0200 | [diff] [blame] | 1429 | struct zfcp_port *port = erp_action->port; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1430 | struct zfcp_fsf_req *req; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1431 | int retval = -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1432 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1433 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1434 | if (zfcp_qdio_sbal_get(qdio)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1437 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1438 | SBAL_FLAGS0_TYPE_READ, |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1439 | qdio->adapter->pool.erp_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1440 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1441 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1442 | retval = PTR_ERR(req); |
| 1443 | goto out; |
| 1444 | } |
| 1445 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1446 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1447 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1449 | req->handler = zfcp_fsf_open_port_handler; |
Christof Schmitt | 800c0ca | 2009-11-24 16:54:12 +0100 | [diff] [blame] | 1450 | hton24(req->qtcb->bottom.support.d_id, port->d_id); |
Martin Petermann | a17c585 | 2009-05-15 13:18:19 +0200 | [diff] [blame] | 1451 | req->data = port; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1452 | req->erp_action = erp_action; |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1453 | erp_action->fsf_req_id = req->req_id; |
Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 1454 | get_device(&port->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1455 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1456 | zfcp_fsf_start_erp_timer(req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1457 | retval = zfcp_fsf_req_send(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | if (retval) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1459 | zfcp_fsf_req_free(req); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1460 | erp_action->fsf_req_id = 0; |
Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 1461 | put_device(&port->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1463 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1464 | spin_unlock_bh(&qdio->req_q_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1465 | return retval; |
| 1466 | } |
| 1467 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1468 | static void zfcp_fsf_close_port_handler(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1470 | struct zfcp_port *port = req->data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1471 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1472 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 1473 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1475 | switch (req->qtcb->header.fsf_status) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1476 | case FSF_PORT_HANDLE_NOT_VALID: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1477 | zfcp_erp_adapter_reopen(port->adapter, 0, "fscph_1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1478 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1479 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1480 | case FSF_ADAPTER_STATUS_AVAILABLE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1481 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | case FSF_GOOD: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1483 | zfcp_erp_modify_port_status(port, "fscph_2", req, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1484 | ZFCP_STATUS_COMMON_OPEN, |
| 1485 | ZFCP_CLEAR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1486 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1487 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1488 | } |
| 1489 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1490 | /** |
| 1491 | * zfcp_fsf_close_port - create and send close port request |
| 1492 | * @erp_action: pointer to struct zfcp_erp_action |
| 1493 | * Returns: 0 on success, error otherwise |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1494 | */ |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1495 | int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1496 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1497 | struct zfcp_qdio *qdio = erp_action->adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1498 | struct zfcp_fsf_req *req; |
| 1499 | int retval = -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1500 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1501 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1502 | if (zfcp_qdio_sbal_get(qdio)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1503 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1505 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1506 | SBAL_FLAGS0_TYPE_READ, |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1507 | qdio->adapter->pool.erp_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1508 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1509 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1510 | retval = PTR_ERR(req); |
| 1511 | goto out; |
| 1512 | } |
| 1513 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1514 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1515 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1516 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1517 | req->handler = zfcp_fsf_close_port_handler; |
| 1518 | req->data = erp_action->port; |
| 1519 | req->erp_action = erp_action; |
| 1520 | req->qtcb->header.port_handle = erp_action->port->handle; |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1521 | erp_action->fsf_req_id = req->req_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1522 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1523 | zfcp_fsf_start_erp_timer(req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1524 | retval = zfcp_fsf_req_send(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1525 | if (retval) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1526 | zfcp_fsf_req_free(req); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1527 | erp_action->fsf_req_id = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1529 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1530 | spin_unlock_bh(&qdio->req_q_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1531 | return retval; |
| 1532 | } |
| 1533 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1534 | static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req) |
| 1535 | { |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 1536 | struct zfcp_fc_wka_port *wka_port = req->data; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1537 | struct fsf_qtcb_header *header = &req->qtcb->header; |
| 1538 | |
| 1539 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) { |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 1540 | wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1541 | goto out; |
| 1542 | } |
| 1543 | |
| 1544 | switch (header->fsf_status) { |
| 1545 | case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED: |
| 1546 | dev_warn(&req->adapter->ccw_device->dev, |
| 1547 | "Opening WKA port 0x%x failed\n", wka_port->d_id); |
Christof Schmitt | dceab65 | 2009-05-15 13:18:18 +0200 | [diff] [blame] | 1548 | /* fall through */ |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1549 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 1550 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Christof Schmitt | dceab65 | 2009-05-15 13:18:18 +0200 | [diff] [blame] | 1551 | /* fall through */ |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1552 | case FSF_ACCESS_DENIED: |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 1553 | wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1554 | break; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1555 | case FSF_GOOD: |
| 1556 | wka_port->handle = header->port_handle; |
Swen Schillig | 27f492c | 2009-07-13 15:06:13 +0200 | [diff] [blame] | 1557 | /* fall through */ |
| 1558 | case FSF_PORT_ALREADY_OPEN: |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 1559 | wka_port->status = ZFCP_FC_WKA_PORT_ONLINE; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1560 | } |
| 1561 | out: |
| 1562 | wake_up(&wka_port->completion_wq); |
| 1563 | } |
| 1564 | |
| 1565 | /** |
| 1566 | * zfcp_fsf_open_wka_port - create and send open wka-port request |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 1567 | * @wka_port: pointer to struct zfcp_fc_wka_port |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1568 | * Returns: 0 on success, error otherwise |
| 1569 | */ |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 1570 | int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1571 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1572 | struct zfcp_qdio *qdio = wka_port->adapter->qdio; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1573 | struct zfcp_fsf_req *req; |
| 1574 | int retval = -EIO; |
| 1575 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1576 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1577 | if (zfcp_qdio_sbal_get(qdio)) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1578 | goto out; |
| 1579 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1580 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1581 | SBAL_FLAGS0_TYPE_READ, |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1582 | qdio->adapter->pool.erp_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1583 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1584 | if (unlikely(IS_ERR(req))) { |
| 1585 | retval = PTR_ERR(req); |
| 1586 | goto out; |
| 1587 | } |
| 1588 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1589 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1590 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1591 | |
| 1592 | req->handler = zfcp_fsf_open_wka_port_handler; |
Christof Schmitt | 800c0ca | 2009-11-24 16:54:12 +0100 | [diff] [blame] | 1593 | hton24(req->qtcb->bottom.support.d_id, wka_port->d_id); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1594 | req->data = wka_port; |
| 1595 | |
| 1596 | zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); |
| 1597 | retval = zfcp_fsf_req_send(req); |
| 1598 | if (retval) |
| 1599 | zfcp_fsf_req_free(req); |
| 1600 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1601 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1602 | return retval; |
| 1603 | } |
| 1604 | |
| 1605 | static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req) |
| 1606 | { |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 1607 | struct zfcp_fc_wka_port *wka_port = req->data; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1608 | |
| 1609 | if (req->qtcb->header.fsf_status == FSF_PORT_HANDLE_NOT_VALID) { |
| 1610 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1611 | zfcp_erp_adapter_reopen(wka_port->adapter, 0, "fscwph1", req); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1612 | } |
| 1613 | |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 1614 | wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1615 | wake_up(&wka_port->completion_wq); |
| 1616 | } |
| 1617 | |
| 1618 | /** |
| 1619 | * zfcp_fsf_close_wka_port - create and send close wka port request |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 1620 | * @wka_port: WKA port to open |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1621 | * Returns: 0 on success, error otherwise |
| 1622 | */ |
Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 1623 | int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1624 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1625 | struct zfcp_qdio *qdio = wka_port->adapter->qdio; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1626 | struct zfcp_fsf_req *req; |
| 1627 | int retval = -EIO; |
| 1628 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1629 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1630 | if (zfcp_qdio_sbal_get(qdio)) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1631 | goto out; |
| 1632 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1633 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1634 | SBAL_FLAGS0_TYPE_READ, |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1635 | qdio->adapter->pool.erp_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1636 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1637 | if (unlikely(IS_ERR(req))) { |
| 1638 | retval = PTR_ERR(req); |
| 1639 | goto out; |
| 1640 | } |
| 1641 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1642 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1643 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1644 | |
| 1645 | req->handler = zfcp_fsf_close_wka_port_handler; |
| 1646 | req->data = wka_port; |
| 1647 | req->qtcb->header.port_handle = wka_port->handle; |
| 1648 | |
| 1649 | zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); |
| 1650 | retval = zfcp_fsf_req_send(req); |
| 1651 | if (retval) |
| 1652 | zfcp_fsf_req_free(req); |
| 1653 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1654 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 1655 | return retval; |
| 1656 | } |
| 1657 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1658 | static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1659 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1660 | struct zfcp_port *port = req->data; |
| 1661 | struct fsf_qtcb_header *header = &req->qtcb->header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1662 | struct zfcp_unit *unit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1663 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1664 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
Christof Schmitt | a5b11dd | 2009-03-02 13:08:54 +0100 | [diff] [blame] | 1665 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1666 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1667 | switch (header->fsf_status) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1668 | case FSF_PORT_HANDLE_NOT_VALID: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1669 | zfcp_erp_adapter_reopen(port->adapter, 0, "fscpph1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1670 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1671 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1672 | case FSF_ACCESS_DENIED: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1673 | zfcp_fsf_access_denied_port(req, port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1674 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1675 | case FSF_PORT_BOXED: |
Christof Schmitt | 5c815d1 | 2008-03-10 16:18:54 +0100 | [diff] [blame] | 1676 | /* can't use generic zfcp_erp_modify_port_status because |
| 1677 | * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */ |
| 1678 | atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1679 | read_lock(&port->unit_list_lock); |
| 1680 | list_for_each_entry(unit, &port->unit_list, list) |
Christof Schmitt | 5c815d1 | 2008-03-10 16:18:54 +0100 | [diff] [blame] | 1681 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, |
| 1682 | &unit->status); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1683 | read_unlock(&port->unit_list_lock); |
Swen Schillig | dfb3cf0 | 2009-07-13 15:06:02 +0200 | [diff] [blame] | 1684 | zfcp_erp_port_boxed(port, "fscpph2", req); |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 1685 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1686 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | case FSF_ADAPTER_STATUS_AVAILABLE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1688 | switch (header->fsf_status_qual.word[0]) { |
| 1689 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1690 | /* fall through */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1691 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1692 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1694 | } |
| 1695 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1696 | case FSF_GOOD: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1697 | /* can't use generic zfcp_erp_modify_port_status because |
| 1698 | * ZFCP_STATUS_COMMON_OPEN must not be reset for the port |
| 1699 | */ |
| 1700 | atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1701 | read_lock(&port->unit_list_lock); |
| 1702 | list_for_each_entry(unit, &port->unit_list, list) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1703 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, |
| 1704 | &unit->status); |
Swen Schillig | ecf0c77 | 2009-11-24 16:53:58 +0100 | [diff] [blame] | 1705 | read_unlock(&port->unit_list_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1706 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1707 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1708 | } |
| 1709 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1710 | /** |
| 1711 | * zfcp_fsf_close_physical_port - close physical port |
| 1712 | * @erp_action: pointer to struct zfcp_erp_action |
| 1713 | * Returns: 0 on success |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1714 | */ |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1715 | int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1716 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1717 | struct zfcp_qdio *qdio = erp_action->adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1718 | struct zfcp_fsf_req *req; |
| 1719 | int retval = -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1720 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1721 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1722 | if (zfcp_qdio_sbal_get(qdio)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1723 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1724 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1725 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PHYSICAL_PORT, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1726 | SBAL_FLAGS0_TYPE_READ, |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1727 | qdio->adapter->pool.erp_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1728 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1729 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1730 | retval = PTR_ERR(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1731 | goto out; |
| 1732 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1733 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1734 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1735 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1736 | |
| 1737 | req->data = erp_action->port; |
| 1738 | req->qtcb->header.port_handle = erp_action->port->handle; |
| 1739 | req->erp_action = erp_action; |
| 1740 | req->handler = zfcp_fsf_close_physical_port_handler; |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1741 | erp_action->fsf_req_id = req->req_id; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1742 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1743 | zfcp_fsf_start_erp_timer(req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1744 | retval = zfcp_fsf_req_send(req); |
| 1745 | if (retval) { |
| 1746 | zfcp_fsf_req_free(req); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1747 | erp_action->fsf_req_id = 0; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1748 | } |
| 1749 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1750 | spin_unlock_bh(&qdio->req_q_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1751 | return retval; |
| 1752 | } |
| 1753 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1754 | static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1755 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1756 | struct zfcp_adapter *adapter = req->adapter; |
| 1757 | struct zfcp_unit *unit = req->data; |
| 1758 | struct fsf_qtcb_header *header = &req->qtcb->header; |
| 1759 | struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support; |
| 1760 | struct fsf_queue_designator *queue_designator = |
| 1761 | &header->fsf_status_qual.fsf_queue_designator; |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 1762 | int exclusive, readwrite; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1763 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1764 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 1765 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1766 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1767 | atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | |
Heiko Carstens | b64ddf9 | 2007-05-08 11:19:57 +0200 | [diff] [blame] | 1768 | ZFCP_STATUS_COMMON_ACCESS_BOXED | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | ZFCP_STATUS_UNIT_SHARED | |
| 1770 | ZFCP_STATUS_UNIT_READONLY, |
| 1771 | &unit->status); |
| 1772 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1773 | switch (header->fsf_status) { |
| 1774 | |
| 1775 | case FSF_PORT_HANDLE_NOT_VALID: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1776 | zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fsouh_1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1777 | /* fall through */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1778 | case FSF_LUN_ALREADY_OPEN: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1779 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1780 | case FSF_ACCESS_DENIED: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1781 | zfcp_fsf_access_denied_unit(req, unit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1782 | atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status); |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 1783 | atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1785 | case FSF_PORT_BOXED: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1786 | zfcp_erp_port_boxed(unit->port, "fsouh_2", req); |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 1787 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1789 | case FSF_LUN_SHARING_VIOLATION: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1790 | if (header->fsf_status_qual.word[0]) |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 1791 | dev_warn(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1792 | "LUN 0x%Lx on port 0x%Lx is already in " |
| 1793 | "use by CSS%d, MIF Image ID %x\n", |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 1794 | (unsigned long long)unit->fcp_lun, |
| 1795 | (unsigned long long)unit->port->wwpn, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1796 | queue_designator->cssid, |
| 1797 | queue_designator->hla); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1798 | else |
Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 1799 | zfcp_act_eval_err(adapter, |
| 1800 | header->fsf_status_qual.word[2]); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1801 | zfcp_erp_unit_access_denied(unit, "fsouh_3", req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1802 | atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status); |
| 1803 | atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1804 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1805 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1806 | case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1807 | dev_warn(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1808 | "No handle is available for LUN " |
| 1809 | "0x%016Lx on port 0x%016Lx\n", |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 1810 | (unsigned long long)unit->fcp_lun, |
| 1811 | (unsigned long long)unit->port->wwpn); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1812 | zfcp_erp_unit_failed(unit, "fsouh_4", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1813 | /* fall through */ |
| 1814 | case FSF_INVALID_COMMAND_OPTION: |
| 1815 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1816 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1817 | case FSF_ADAPTER_STATUS_AVAILABLE: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1818 | switch (header->fsf_status_qual.word[0]) { |
| 1819 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 1820 | zfcp_fc_test_link(unit->port); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1821 | /* fall through */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1823 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1824 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1825 | } |
| 1826 | break; |
| 1827 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1828 | case FSF_GOOD: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1829 | unit->handle = header->lun_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1830 | atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 1831 | |
| 1832 | if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE) && |
| 1833 | (adapter->adapter_features & FSF_FEATURE_LUN_SHARING) && |
Christof Schmitt | 6fcf41d | 2009-05-15 13:18:21 +0200 | [diff] [blame] | 1834 | !zfcp_ccw_priv_sch(adapter)) { |
Maxim Shchetynin | aef4a98 | 2005-09-13 21:51:16 +0200 | [diff] [blame] | 1835 | exclusive = (bottom->lun_access_info & |
| 1836 | FSF_UNIT_ACCESS_EXCLUSIVE); |
| 1837 | readwrite = (bottom->lun_access_info & |
| 1838 | FSF_UNIT_ACCESS_OUTBOUND_TRANSFER); |
| 1839 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | if (!exclusive) |
| 1841 | atomic_set_mask(ZFCP_STATUS_UNIT_SHARED, |
| 1842 | &unit->status); |
| 1843 | |
| 1844 | if (!readwrite) { |
| 1845 | atomic_set_mask(ZFCP_STATUS_UNIT_READONLY, |
| 1846 | &unit->status); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1847 | dev_info(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1848 | "SCSI device at LUN 0x%016Lx on port " |
| 1849 | "0x%016Lx opened read-only\n", |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 1850 | (unsigned long long)unit->fcp_lun, |
| 1851 | (unsigned long long)unit->port->wwpn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1852 | } |
| 1853 | |
| 1854 | if (exclusive && !readwrite) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1855 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1856 | "Exclusive read-only access not " |
| 1857 | "supported (unit 0x%016Lx, " |
| 1858 | "port 0x%016Lx)\n", |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 1859 | (unsigned long long)unit->fcp_lun, |
| 1860 | (unsigned long long)unit->port->wwpn); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1861 | zfcp_erp_unit_failed(unit, "fsouh_5", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1862 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1863 | zfcp_erp_unit_shutdown(unit, 0, "fsouh_6", req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1864 | } else if (!exclusive && readwrite) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1865 | dev_err(&adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 1866 | "Shared read-write access not " |
| 1867 | "supported (unit 0x%016Lx, port " |
Christof Schmitt | 27c3f0a | 2008-12-19 16:56:52 +0100 | [diff] [blame] | 1868 | "0x%016Lx)\n", |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 1869 | (unsigned long long)unit->fcp_lun, |
| 1870 | (unsigned long long)unit->port->wwpn); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1871 | zfcp_erp_unit_failed(unit, "fsouh_7", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1872 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1873 | zfcp_erp_unit_shutdown(unit, 0, "fsouh_8", req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1874 | } |
| 1875 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1876 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1877 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1878 | } |
| 1879 | |
| 1880 | /** |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1881 | * zfcp_fsf_open_unit - open unit |
| 1882 | * @erp_action: pointer to struct zfcp_erp_action |
| 1883 | * Returns: 0 on success, error otherwise |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1884 | */ |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1885 | int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1886 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1887 | struct zfcp_adapter *adapter = erp_action->adapter; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1888 | struct zfcp_qdio *qdio = adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1889 | struct zfcp_fsf_req *req; |
| 1890 | int retval = -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1891 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1892 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1893 | if (zfcp_qdio_sbal_get(qdio)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1894 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1895 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1896 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_LUN, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1897 | SBAL_FLAGS0_TYPE_READ, |
Swen Schillig | a4623c4 | 2009-08-18 15:43:15 +0200 | [diff] [blame] | 1898 | adapter->pool.erp_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1899 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1900 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1901 | retval = PTR_ERR(req); |
| 1902 | goto out; |
Christof Schmitt | ba17242 | 2007-12-20 12:30:26 +0100 | [diff] [blame] | 1903 | } |
| 1904 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1905 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1906 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1907 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1908 | req->qtcb->header.port_handle = erp_action->port->handle; |
| 1909 | req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun; |
| 1910 | req->handler = zfcp_fsf_open_unit_handler; |
| 1911 | req->data = erp_action->unit; |
| 1912 | req->erp_action = erp_action; |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1913 | erp_action->fsf_req_id = req->req_id; |
Andreas Herrmann | 059c97d | 2005-09-13 21:47:52 +0200 | [diff] [blame] | 1914 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1915 | if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE)) |
| 1916 | req->qtcb->bottom.support.option = FSF_OPEN_LUN_SUPPRESS_BOXING; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1917 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1918 | zfcp_fsf_start_erp_timer(req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1919 | retval = zfcp_fsf_req_send(req); |
| 1920 | if (retval) { |
| 1921 | zfcp_fsf_req_free(req); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1922 | erp_action->fsf_req_id = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1923 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1924 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1925 | spin_unlock_bh(&qdio->req_q_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1926 | return retval; |
| 1927 | } |
| 1928 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1929 | static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1930 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1931 | struct zfcp_unit *unit = req->data; |
| 1932 | |
| 1933 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 1934 | return; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1935 | |
| 1936 | switch (req->qtcb->header.fsf_status) { |
| 1937 | case FSF_PORT_HANDLE_NOT_VALID: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1938 | zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fscuh_1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1939 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1940 | break; |
| 1941 | case FSF_LUN_HANDLE_NOT_VALID: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1942 | zfcp_erp_port_reopen(unit->port, 0, "fscuh_2", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1943 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1944 | break; |
| 1945 | case FSF_PORT_BOXED: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 1946 | zfcp_erp_port_boxed(unit->port, "fscuh_3", req); |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 1947 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1948 | break; |
| 1949 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 1950 | switch (req->qtcb->header.fsf_status_qual.word[0]) { |
| 1951 | case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: |
Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 1952 | zfcp_fc_test_link(unit->port); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1953 | /* fall through */ |
| 1954 | case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: |
| 1955 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 1956 | break; |
| 1957 | } |
| 1958 | break; |
| 1959 | case FSF_GOOD: |
| 1960 | atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); |
| 1961 | break; |
| 1962 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1963 | } |
| 1964 | |
| 1965 | /** |
| 1966 | * zfcp_fsf_close_unit - close zfcp unit |
| 1967 | * @erp_action: pointer to struct zfcp_unit |
| 1968 | * Returns: 0 on success, error otherwise |
| 1969 | */ |
| 1970 | int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) |
| 1971 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1972 | struct zfcp_qdio *qdio = erp_action->adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1973 | struct zfcp_fsf_req *req; |
| 1974 | int retval = -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1975 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1976 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 1977 | if (zfcp_qdio_sbal_get(qdio)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1978 | goto out; |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1979 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1980 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_LUN, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1981 | SBAL_FLAGS0_TYPE_READ, |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 1982 | qdio->adapter->pool.erp_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1983 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 1984 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1985 | retval = PTR_ERR(req); |
| 1986 | goto out; |
| 1987 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1988 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 1989 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 1990 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1991 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 1992 | req->qtcb->header.port_handle = erp_action->port->handle; |
| 1993 | req->qtcb->header.lun_handle = erp_action->unit->handle; |
| 1994 | req->handler = zfcp_fsf_close_unit_handler; |
| 1995 | req->data = erp_action->unit; |
| 1996 | req->erp_action = erp_action; |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 1997 | erp_action->fsf_req_id = req->req_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1998 | |
Christof Schmitt | 287ac01 | 2008-07-02 10:56:40 +0200 | [diff] [blame] | 1999 | zfcp_fsf_start_erp_timer(req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2000 | retval = zfcp_fsf_req_send(req); |
| 2001 | if (retval) { |
| 2002 | zfcp_fsf_req_free(req); |
Christof Schmitt | e60a6d6 | 2010-02-17 11:18:49 +0100 | [diff] [blame] | 2003 | erp_action->fsf_req_id = 0; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2004 | } |
| 2005 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2006 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2007 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2008 | } |
| 2009 | |
Christof Schmitt | c961585 | 2008-05-06 11:00:05 +0200 | [diff] [blame] | 2010 | static void zfcp_fsf_update_lat(struct fsf_latency_record *lat_rec, u32 lat) |
| 2011 | { |
| 2012 | lat_rec->sum += lat; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2013 | lat_rec->min = min(lat_rec->min, lat); |
| 2014 | lat_rec->max = max(lat_rec->max, lat); |
Christof Schmitt | c961585 | 2008-05-06 11:00:05 +0200 | [diff] [blame] | 2015 | } |
| 2016 | |
Christof Schmitt | d9742b4 | 2009-11-24 16:54:03 +0100 | [diff] [blame] | 2017 | static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi) |
Christof Schmitt | c961585 | 2008-05-06 11:00:05 +0200 | [diff] [blame] | 2018 | { |
Christof Schmitt | d9742b4 | 2009-11-24 16:54:03 +0100 | [diff] [blame] | 2019 | struct fsf_qual_latency_info *lat_in; |
| 2020 | struct latency_cont *lat = NULL; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2021 | struct zfcp_unit *unit = req->unit; |
Christof Schmitt | d9742b4 | 2009-11-24 16:54:03 +0100 | [diff] [blame] | 2022 | struct zfcp_blk_drv_data blktrc; |
| 2023 | int ticks = req->adapter->timer_ticks; |
Christof Schmitt | c961585 | 2008-05-06 11:00:05 +0200 | [diff] [blame] | 2024 | |
Christof Schmitt | d9742b4 | 2009-11-24 16:54:03 +0100 | [diff] [blame] | 2025 | lat_in = &req->qtcb->prefix.prot_status_qual.latency_info; |
Christof Schmitt | c961585 | 2008-05-06 11:00:05 +0200 | [diff] [blame] | 2026 | |
Christof Schmitt | d9742b4 | 2009-11-24 16:54:03 +0100 | [diff] [blame] | 2027 | blktrc.flags = 0; |
| 2028 | blktrc.magic = ZFCP_BLK_DRV_DATA_MAGIC; |
| 2029 | if (req->status & ZFCP_STATUS_FSFREQ_ERROR) |
| 2030 | blktrc.flags |= ZFCP_BLK_REQ_ERROR; |
Swen Schillig | 706eca4 | 2010-07-16 15:37:38 +0200 | [diff] [blame] | 2031 | blktrc.inb_usage = 0; |
Christof Schmitt | 34c2b71 | 2010-02-17 11:18:59 +0100 | [diff] [blame] | 2032 | blktrc.outb_usage = req->qdio_req.qdio_outb_usage; |
Christof Schmitt | d9742b4 | 2009-11-24 16:54:03 +0100 | [diff] [blame] | 2033 | |
Christof Schmitt | 5bbf297 | 2010-04-01 13:04:08 +0200 | [diff] [blame] | 2034 | if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA && |
| 2035 | !(req->status & ZFCP_STATUS_FSFREQ_ERROR)) { |
Christof Schmitt | d9742b4 | 2009-11-24 16:54:03 +0100 | [diff] [blame] | 2036 | blktrc.flags |= ZFCP_BLK_LAT_VALID; |
| 2037 | blktrc.channel_lat = lat_in->channel_lat * ticks; |
| 2038 | blktrc.fabric_lat = lat_in->fabric_lat * ticks; |
| 2039 | |
| 2040 | switch (req->qtcb->bottom.io.data_direction) { |
| 2041 | case FSF_DATADIR_READ: |
| 2042 | lat = &unit->latencies.read; |
| 2043 | break; |
| 2044 | case FSF_DATADIR_WRITE: |
| 2045 | lat = &unit->latencies.write; |
| 2046 | break; |
| 2047 | case FSF_DATADIR_CMND: |
| 2048 | lat = &unit->latencies.cmd; |
| 2049 | break; |
| 2050 | } |
| 2051 | |
| 2052 | if (lat) { |
| 2053 | spin_lock(&unit->latencies.lock); |
| 2054 | zfcp_fsf_update_lat(&lat->channel, lat_in->channel_lat); |
| 2055 | zfcp_fsf_update_lat(&lat->fabric, lat_in->fabric_lat); |
| 2056 | lat->counter++; |
| 2057 | spin_unlock(&unit->latencies.lock); |
| 2058 | } |
Christof Schmitt | c961585 | 2008-05-06 11:00:05 +0200 | [diff] [blame] | 2059 | } |
| 2060 | |
Christof Schmitt | d9742b4 | 2009-11-24 16:54:03 +0100 | [diff] [blame] | 2061 | blk_add_driver_data(scsi->request->q, scsi->request, &blktrc, |
| 2062 | sizeof(blktrc)); |
Christof Schmitt | c961585 | 2008-05-06 11:00:05 +0200 | [diff] [blame] | 2063 | } |
| 2064 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2065 | static void zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2066 | { |
Swen Schillig | 0ac55aa | 2008-11-26 18:07:39 +0100 | [diff] [blame] | 2067 | struct scsi_cmnd *scpnt; |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 2068 | struct fcp_resp_with_ext *fcp_rsp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2069 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2070 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2071 | read_lock_irqsave(&req->adapter->abort_lock, flags); |
| 2072 | |
Swen Schillig | 0ac55aa | 2008-11-26 18:07:39 +0100 | [diff] [blame] | 2073 | scpnt = req->data; |
| 2074 | if (unlikely(!scpnt)) { |
| 2075 | read_unlock_irqrestore(&req->adapter->abort_lock, flags); |
| 2076 | return; |
| 2077 | } |
| 2078 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2079 | if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) { |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 2080 | set_host_byte(scpnt, DID_TRANSPORT_DISRUPTED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2081 | goto skip_fsfstatus; |
| 2082 | } |
| 2083 | |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 2084 | fcp_rsp = (struct fcp_resp_with_ext *) &req->qtcb->bottom.io.fcp_rsp; |
| 2085 | zfcp_fc_eval_fcp_rsp(fcp_rsp, scpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2086 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2087 | skip_fsfstatus: |
Christof Schmitt | 5bbf297 | 2010-04-01 13:04:08 +0200 | [diff] [blame] | 2088 | zfcp_fsf_req_trace(req, scpnt); |
Christof Schmitt | ab72528 | 2010-02-17 11:18:57 +0100 | [diff] [blame] | 2089 | zfcp_dbf_scsi_result(req->adapter->dbf, scpnt, req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2090 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | scpnt->host_scribble = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2092 | (scpnt->scsi_done) (scpnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2093 | /* |
| 2094 | * We must hold this lock until scsi_done has been called. |
| 2095 | * Otherwise we may call scsi_done after abort regarding this |
| 2096 | * command has completed. |
| 2097 | * Note: scsi_done must not block! |
| 2098 | */ |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2099 | read_unlock_irqrestore(&req->adapter->abort_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2100 | } |
| 2101 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2102 | static void zfcp_fsf_send_fcp_ctm_handler(struct zfcp_fsf_req *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | { |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 2104 | struct fcp_resp_with_ext *fcp_rsp; |
| 2105 | struct fcp_resp_rsp_info *rsp_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2106 | |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 2107 | fcp_rsp = (struct fcp_resp_with_ext *) &req->qtcb->bottom.io.fcp_rsp; |
| 2108 | rsp_info = (struct fcp_resp_rsp_info *) &fcp_rsp[1]; |
| 2109 | |
| 2110 | if ((rsp_info->rsp_code != FCP_TMF_CMPL) || |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2111 | (req->status & ZFCP_STATUS_FSFREQ_ERROR)) |
| 2112 | req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | } |
| 2114 | |
| 2115 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2116 | static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req) |
| 2117 | { |
| 2118 | struct zfcp_unit *unit; |
| 2119 | struct fsf_qtcb_header *header = &req->qtcb->header; |
| 2120 | |
| 2121 | if (unlikely(req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)) |
| 2122 | unit = req->data; |
| 2123 | else |
| 2124 | unit = req->unit; |
| 2125 | |
| 2126 | if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) |
| 2127 | goto skip_fsfstatus; |
| 2128 | |
| 2129 | switch (header->fsf_status) { |
| 2130 | case FSF_HANDLE_MISMATCH: |
| 2131 | case FSF_PORT_HANDLE_NOT_VALID: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 2132 | zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fssfch1", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2133 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2134 | break; |
| 2135 | case FSF_FCPLUN_NOT_VALID: |
| 2136 | case FSF_LUN_HANDLE_NOT_VALID: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 2137 | zfcp_erp_port_reopen(unit->port, 0, "fssfch2", req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2138 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2139 | break; |
| 2140 | case FSF_SERVICE_CLASS_NOT_SUPPORTED: |
| 2141 | zfcp_fsf_class_not_supp(req); |
| 2142 | break; |
| 2143 | case FSF_ACCESS_DENIED: |
| 2144 | zfcp_fsf_access_denied_unit(req, unit); |
| 2145 | break; |
| 2146 | case FSF_DIRECTION_INDICATOR_NOT_VALID: |
| 2147 | dev_err(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 2148 | "Incorrect direction %d, unit 0x%016Lx on port " |
| 2149 | "0x%016Lx closed\n", |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2150 | req->qtcb->bottom.io.data_direction, |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 2151 | (unsigned long long)unit->fcp_lun, |
| 2152 | (unsigned long long)unit->port->wwpn); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 2153 | zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch3", |
| 2154 | req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2155 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2156 | break; |
| 2157 | case FSF_CMND_LENGTH_NOT_VALID: |
| 2158 | dev_err(&req->adapter->ccw_device->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 2159 | "Incorrect CDB length %d, unit 0x%016Lx on " |
| 2160 | "port 0x%016Lx closed\n", |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2161 | req->qtcb->bottom.io.fcp_cmnd_length, |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 2162 | (unsigned long long)unit->fcp_lun, |
| 2163 | (unsigned long long)unit->port->wwpn); |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 2164 | zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch4", |
| 2165 | req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2166 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2167 | break; |
| 2168 | case FSF_PORT_BOXED: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 2169 | zfcp_erp_port_boxed(unit->port, "fssfch5", req); |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 2170 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2171 | break; |
| 2172 | case FSF_LUN_BOXED: |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 2173 | zfcp_erp_unit_boxed(unit, "fssfch6", req); |
Christof Schmitt | 4c571c6 | 2009-11-24 16:54:15 +0100 | [diff] [blame] | 2174 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2175 | break; |
| 2176 | case FSF_ADAPTER_STATUS_AVAILABLE: |
| 2177 | if (header->fsf_status_qual.word[0] == |
| 2178 | FSF_SQ_INVOKE_LINK_TEST_PROCEDURE) |
Swen Schillig | 6f53a2d | 2009-08-18 15:43:23 +0200 | [diff] [blame] | 2179 | zfcp_fc_test_link(unit->port); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2180 | req->status |= ZFCP_STATUS_FSFREQ_ERROR; |
| 2181 | break; |
| 2182 | } |
| 2183 | skip_fsfstatus: |
| 2184 | if (req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) |
| 2185 | zfcp_fsf_send_fcp_ctm_handler(req); |
| 2186 | else { |
| 2187 | zfcp_fsf_send_fcp_command_task_handler(req); |
| 2188 | req->unit = NULL; |
Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 2189 | put_device(&unit->dev); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2190 | } |
| 2191 | } |
| 2192 | |
| 2193 | /** |
| 2194 | * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2195 | * @unit: unit where command is sent to |
| 2196 | * @scsi_cmnd: scsi command to be sent |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2197 | */ |
Christof Schmitt | 63caf36 | 2009-03-02 13:09:00 +0100 | [diff] [blame] | 2198 | int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit, |
| 2199 | struct scsi_cmnd *scsi_cmnd) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2200 | { |
| 2201 | struct zfcp_fsf_req *req; |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 2202 | struct fcp_cmnd *fcp_cmnd; |
Christof Schmitt | bc90c86 | 2009-05-15 13:18:17 +0200 | [diff] [blame] | 2203 | unsigned int sbtype = SBAL_FLAGS0_TYPE_READ; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2204 | int real_bytes, retval = -EIO; |
Christof Schmitt | 63caf36 | 2009-03-02 13:09:00 +0100 | [diff] [blame] | 2205 | struct zfcp_adapter *adapter = unit->port->adapter; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2206 | struct zfcp_qdio *qdio = adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2207 | |
| 2208 | if (unlikely(!(atomic_read(&unit->status) & |
| 2209 | ZFCP_STATUS_COMMON_UNBLOCKED))) |
| 2210 | return -EBUSY; |
| 2211 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2212 | spin_lock(&qdio->req_q_lock); |
Swen Schillig | 706eca4 | 2010-07-16 15:37:38 +0200 | [diff] [blame] | 2213 | if (atomic_read(&qdio->req_q_free) <= 0) { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2214 | atomic_inc(&qdio->req_q_full); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2215 | goto out; |
Christof Schmitt | 8fdf30d | 2009-03-02 13:09:01 +0100 | [diff] [blame] | 2216 | } |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 2217 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 2218 | if (scsi_cmnd->sc_data_direction == DMA_TO_DEVICE) |
| 2219 | sbtype = SBAL_FLAGS0_TYPE_WRITE; |
| 2220 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2221 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 2222 | sbtype, adapter->pool.scsi_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 2223 | |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 2224 | if (IS_ERR(req)) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2225 | retval = PTR_ERR(req); |
| 2226 | goto out; |
| 2227 | } |
| 2228 | |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 2229 | req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2230 | req->unit = unit; |
| 2231 | req->data = scsi_cmnd; |
| 2232 | req->handler = zfcp_fsf_send_fcp_command_handler; |
| 2233 | req->qtcb->header.lun_handle = unit->handle; |
| 2234 | req->qtcb->header.port_handle = unit->port->handle; |
| 2235 | req->qtcb->bottom.io.service_class = FSF_CLASS_3; |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 2236 | req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2237 | |
| 2238 | scsi_cmnd->host_scribble = (unsigned char *) req->req_id; |
| 2239 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2240 | /* |
| 2241 | * set depending on data direction: |
| 2242 | * data direction bits in SBALE (SB Type) |
| 2243 | * data direction bits in QTCB |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2244 | */ |
| 2245 | switch (scsi_cmnd->sc_data_direction) { |
| 2246 | case DMA_NONE: |
| 2247 | req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2248 | break; |
| 2249 | case DMA_FROM_DEVICE: |
| 2250 | req->qtcb->bottom.io.data_direction = FSF_DATADIR_READ; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2251 | break; |
| 2252 | case DMA_TO_DEVICE: |
| 2253 | req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2254 | break; |
| 2255 | case DMA_BIDIRECTIONAL: |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2256 | goto failed_scsi_cmnd; |
| 2257 | } |
| 2258 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 2259 | get_device(&unit->dev); |
| 2260 | |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 2261 | fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; |
| 2262 | zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2263 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 2264 | real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, |
Swen Schillig | 01b0475 | 2010-07-16 15:37:37 +0200 | [diff] [blame] | 2265 | scsi_sglist(scsi_cmnd)); |
| 2266 | if (unlikely(real_bytes < 0)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2267 | goto failed_scsi_cmnd; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2268 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2269 | retval = zfcp_fsf_req_send(req); |
| 2270 | if (unlikely(retval)) |
| 2271 | goto failed_scsi_cmnd; |
| 2272 | |
| 2273 | goto out; |
| 2274 | |
| 2275 | failed_scsi_cmnd: |
Christof Schmitt | 615f59e | 2010-02-17 11:18:56 +0100 | [diff] [blame] | 2276 | put_device(&unit->dev); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2277 | zfcp_fsf_req_free(req); |
| 2278 | scsi_cmnd->host_scribble = NULL; |
| 2279 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2280 | spin_unlock(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2281 | return retval; |
| 2282 | } |
| 2283 | |
| 2284 | /** |
| 2285 | * zfcp_fsf_send_fcp_ctm - send SCSI task management command |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2286 | * @unit: pointer to struct zfcp_unit |
| 2287 | * @tm_flags: unsigned byte for task management flags |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2288 | * Returns: on success pointer to struct fsf_req, NULL otherwise |
| 2289 | */ |
Christof Schmitt | 63caf36 | 2009-03-02 13:09:00 +0100 | [diff] [blame] | 2290 | struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2291 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2292 | struct zfcp_fsf_req *req = NULL; |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 2293 | struct fcp_cmnd *fcp_cmnd; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2294 | struct zfcp_qdio *qdio = unit->port->adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2295 | |
| 2296 | if (unlikely(!(atomic_read(&unit->status) & |
| 2297 | ZFCP_STATUS_COMMON_UNBLOCKED))) |
| 2298 | return NULL; |
| 2299 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2300 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 2301 | if (zfcp_qdio_sbal_get(qdio)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2302 | goto out; |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 2303 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2304 | req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND, |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 2305 | SBAL_FLAGS0_TYPE_WRITE, |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2306 | qdio->adapter->pool.scsi_req); |
Swen Schillig | 09a46c6 | 2009-08-18 15:43:16 +0200 | [diff] [blame] | 2307 | |
Swen Schillig | 633528c | 2008-11-26 18:07:37 +0100 | [diff] [blame] | 2308 | if (IS_ERR(req)) { |
| 2309 | req = NULL; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2310 | goto out; |
Swen Schillig | 633528c | 2008-11-26 18:07:37 +0100 | [diff] [blame] | 2311 | } |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2312 | |
| 2313 | req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT; |
| 2314 | req->data = unit; |
| 2315 | req->handler = zfcp_fsf_send_fcp_command_handler; |
| 2316 | req->qtcb->header.lun_handle = unit->handle; |
| 2317 | req->qtcb->header.port_handle = unit->port->handle; |
| 2318 | req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND; |
| 2319 | req->qtcb->bottom.io.service_class = FSF_CLASS_3; |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 2320 | req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2321 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 2322 | zfcp_qdio_set_sbale_last(qdio, &req->qdio_req); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2323 | |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 2324 | fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; |
| 2325 | zfcp_fc_fcp_tm(fcp_cmnd, unit->device, tm_flags); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2326 | |
| 2327 | zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT); |
| 2328 | if (!zfcp_fsf_req_send(req)) |
| 2329 | goto out; |
| 2330 | |
| 2331 | zfcp_fsf_req_free(req); |
| 2332 | req = NULL; |
| 2333 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2334 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2335 | return req; |
| 2336 | } |
| 2337 | |
| 2338 | static void zfcp_fsf_control_file_handler(struct zfcp_fsf_req *req) |
| 2339 | { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2340 | } |
| 2341 | |
| 2342 | /** |
| 2343 | * zfcp_fsf_control_file - control file upload/download |
| 2344 | * @adapter: pointer to struct zfcp_adapter |
| 2345 | * @fsf_cfdc: pointer to struct zfcp_fsf_cfdc |
| 2346 | * Returns: on success pointer to struct zfcp_fsf_req, NULL otherwise |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2347 | */ |
Christof Schmitt | 45633fd | 2008-06-10 18:20:55 +0200 | [diff] [blame] | 2348 | struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter, |
| 2349 | struct zfcp_fsf_cfdc *fsf_cfdc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2350 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2351 | struct zfcp_qdio *qdio = adapter->qdio; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2352 | struct zfcp_fsf_req *req = NULL; |
| 2353 | struct fsf_qtcb_bottom_support *bottom; |
| 2354 | int direction, retval = -EIO, bytes; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2355 | |
Christof Schmitt | 45633fd | 2008-06-10 18:20:55 +0200 | [diff] [blame] | 2356 | if (!(adapter->adapter_features & FSF_FEATURE_CFDC)) |
| 2357 | return ERR_PTR(-EOPNOTSUPP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2358 | |
Christof Schmitt | 45633fd | 2008-06-10 18:20:55 +0200 | [diff] [blame] | 2359 | switch (fsf_cfdc->command) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2360 | case FSF_QTCB_DOWNLOAD_CONTROL_FILE: |
| 2361 | direction = SBAL_FLAGS0_TYPE_WRITE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2362 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2363 | case FSF_QTCB_UPLOAD_CONTROL_FILE: |
| 2364 | direction = SBAL_FLAGS0_TYPE_READ; |
| 2365 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2366 | default: |
Christof Schmitt | 45633fd | 2008-06-10 18:20:55 +0200 | [diff] [blame] | 2367 | return ERR_PTR(-EINVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2368 | } |
| 2369 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2370 | spin_lock_bh(&qdio->req_q_lock); |
Christof Schmitt | 6b9e152 | 2010-04-30 18:09:35 +0200 | [diff] [blame] | 2371 | if (zfcp_qdio_sbal_get(qdio)) |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2372 | goto out; |
| 2373 | |
Christof Schmitt | 1674b40 | 2010-04-30 18:09:34 +0200 | [diff] [blame] | 2374 | req = zfcp_fsf_req_create(qdio, fsf_cfdc->command, direction, NULL); |
Hirofumi Nakagawa | 025270f | 2008-08-21 13:43:37 +0200 | [diff] [blame] | 2375 | if (IS_ERR(req)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2376 | retval = -EPERM; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2377 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2378 | } |
| 2379 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2380 | req->handler = zfcp_fsf_control_file_handler; |
| 2381 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2382 | bottom = &req->qtcb->bottom.support; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE; |
Christof Schmitt | 45633fd | 2008-06-10 18:20:55 +0200 | [diff] [blame] | 2384 | bottom->option = fsf_cfdc->option; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2385 | |
Swen Schillig | 01b0475 | 2010-07-16 15:37:37 +0200 | [diff] [blame] | 2386 | bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, fsf_cfdc->sg); |
| 2387 | |
Christof Schmitt | 45633fd | 2008-06-10 18:20:55 +0200 | [diff] [blame] | 2388 | if (bytes != ZFCP_CFDC_MAX_SIZE) { |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2389 | zfcp_fsf_req_free(req); |
| 2390 | goto out; |
Christof Schmitt | 45633fd | 2008-06-10 18:20:55 +0200 | [diff] [blame] | 2391 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2392 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2393 | zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); |
| 2394 | retval = zfcp_fsf_req_send(req); |
| 2395 | out: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2396 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2397 | |
| 2398 | if (!retval) { |
Swen Schillig | 058b864 | 2009-08-18 15:43:14 +0200 | [diff] [blame] | 2399 | wait_for_completion(&req->completion); |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 2400 | return req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2401 | } |
Christof Schmitt | 45633fd | 2008-06-10 18:20:55 +0200 | [diff] [blame] | 2402 | return ERR_PTR(retval); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | } |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 2404 | |
| 2405 | /** |
| 2406 | * zfcp_fsf_reqid_check - validate req_id contained in SBAL returned by QDIO |
| 2407 | * @adapter: pointer to struct zfcp_adapter |
| 2408 | * @sbal_idx: response queue index of SBAL to be processed |
| 2409 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2410 | void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx) |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 2411 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 2412 | struct zfcp_adapter *adapter = qdio->adapter; |
Swen Schillig | 706eca4 | 2010-07-16 15:37:38 +0200 | [diff] [blame] | 2413 | struct qdio_buffer *sbal = qdio->res_q[sbal_idx]; |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 2414 | struct qdio_buffer_element *sbale; |
| 2415 | struct zfcp_fsf_req *fsf_req; |
Christof Schmitt | b6bd2fb | 2010-02-17 11:18:50 +0100 | [diff] [blame] | 2416 | unsigned long req_id; |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 2417 | int idx; |
| 2418 | |
| 2419 | for (idx = 0; idx < QDIO_MAX_ELEMENTS_PER_BUFFER; idx++) { |
| 2420 | |
| 2421 | sbale = &sbal->element[idx]; |
| 2422 | req_id = (unsigned long) sbale->addr; |
Christof Schmitt | b6bd2fb | 2010-02-17 11:18:50 +0100 | [diff] [blame] | 2423 | fsf_req = zfcp_reqlist_find_rm(adapter->req_list, req_id); |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 2424 | |
| 2425 | if (!fsf_req) |
| 2426 | /* |
| 2427 | * Unknown request means that we have potentially memory |
| 2428 | * corruption and must stop the machine immediately. |
| 2429 | */ |
| 2430 | panic("error: unknown req_id (%lx) on adapter %s.\n", |
| 2431 | req_id, dev_name(&adapter->ccw_device->dev)); |
| 2432 | |
Christof Schmitt | 34c2b71 | 2010-02-17 11:18:59 +0100 | [diff] [blame] | 2433 | fsf_req->qdio_req.sbal_response = sbal_idx; |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 2434 | zfcp_fsf_req_complete(fsf_req); |
| 2435 | |
| 2436 | if (likely(sbale->flags & SBAL_FLAGS_LAST_ENTRY)) |
| 2437 | break; |
| 2438 | } |
| 2439 | } |