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