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