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