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