Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * zfcp device driver |
| 3 | * |
| 4 | * Fibre Channel related functions for the zfcp device driver. |
| 5 | * |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame^] | 6 | * Copyright IBM Corporation 2008, 2009 |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [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 | |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 12 | #include "zfcp_ext.h" |
| 13 | |
Christof Schmitt | e0d7fcb | 2008-12-19 16:56:58 +0100 | [diff] [blame] | 14 | enum rscn_address_format { |
| 15 | RSCN_PORT_ADDRESS = 0x0, |
| 16 | RSCN_AREA_ADDRESS = 0x1, |
| 17 | RSCN_DOMAIN_ADDRESS = 0x2, |
| 18 | RSCN_FABRIC_ADDRESS = 0x3, |
| 19 | }; |
| 20 | |
| 21 | static u32 rscn_range_mask[] = { |
| 22 | [RSCN_PORT_ADDRESS] = 0xFFFFFF, |
| 23 | [RSCN_AREA_ADDRESS] = 0xFFFF00, |
| 24 | [RSCN_DOMAIN_ADDRESS] = 0xFF0000, |
| 25 | [RSCN_FABRIC_ADDRESS] = 0x000000, |
| 26 | }; |
| 27 | |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 28 | struct ct_iu_gpn_ft_req { |
| 29 | struct ct_hdr header; |
| 30 | u8 flags; |
| 31 | u8 domain_id_scope; |
| 32 | u8 area_id_scope; |
| 33 | u8 fc4_type; |
| 34 | } __attribute__ ((packed)); |
| 35 | |
| 36 | struct gpn_ft_resp_acc { |
| 37 | u8 control; |
| 38 | u8 port_id[3]; |
| 39 | u8 reserved[4]; |
| 40 | u64 wwpn; |
| 41 | } __attribute__ ((packed)); |
| 42 | |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 43 | #define ZFCP_CT_SIZE_ONE_PAGE (PAGE_SIZE - sizeof(struct ct_hdr)) |
| 44 | #define ZFCP_GPN_FT_ENTRIES (ZFCP_CT_SIZE_ONE_PAGE \ |
| 45 | / sizeof(struct gpn_ft_resp_acc)) |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 46 | #define ZFCP_GPN_FT_BUFFERS 4 |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 47 | #define ZFCP_GPN_FT_MAX_SIZE (ZFCP_GPN_FT_BUFFERS * PAGE_SIZE \ |
| 48 | - sizeof(struct ct_hdr)) |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 49 | #define ZFCP_GPN_FT_MAX_ENTRIES ZFCP_GPN_FT_BUFFERS * (ZFCP_GPN_FT_ENTRIES + 1) |
| 50 | |
| 51 | struct ct_iu_gpn_ft_resp { |
| 52 | struct ct_hdr header; |
| 53 | struct gpn_ft_resp_acc accept[ZFCP_GPN_FT_ENTRIES]; |
| 54 | } __attribute__ ((packed)); |
| 55 | |
| 56 | struct zfcp_gpn_ft { |
| 57 | struct zfcp_send_ct ct; |
| 58 | struct scatterlist sg_req; |
| 59 | struct scatterlist sg_resp[ZFCP_GPN_FT_BUFFERS]; |
| 60 | }; |
| 61 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 62 | struct zfcp_fc_ns_handler_data { |
| 63 | struct completion done; |
| 64 | void (*handler)(unsigned long); |
| 65 | unsigned long handler_data; |
| 66 | }; |
| 67 | |
| 68 | static int zfcp_wka_port_get(struct zfcp_wka_port *wka_port) |
| 69 | { |
| 70 | if (mutex_lock_interruptible(&wka_port->mutex)) |
| 71 | return -ERESTARTSYS; |
| 72 | |
Christof Schmitt | 1c1cba1 | 2008-11-26 18:07:36 +0100 | [diff] [blame] | 73 | if (wka_port->status == ZFCP_WKA_PORT_OFFLINE || |
| 74 | wka_port->status == ZFCP_WKA_PORT_CLOSING) { |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 75 | wka_port->status = ZFCP_WKA_PORT_OPENING; |
| 76 | if (zfcp_fsf_open_wka_port(wka_port)) |
| 77 | wka_port->status = ZFCP_WKA_PORT_OFFLINE; |
| 78 | } |
| 79 | |
| 80 | mutex_unlock(&wka_port->mutex); |
| 81 | |
| 82 | wait_event_timeout( |
| 83 | wka_port->completion_wq, |
| 84 | wka_port->status == ZFCP_WKA_PORT_ONLINE || |
| 85 | wka_port->status == ZFCP_WKA_PORT_OFFLINE, |
| 86 | HZ >> 1); |
| 87 | |
| 88 | if (wka_port->status == ZFCP_WKA_PORT_ONLINE) { |
| 89 | atomic_inc(&wka_port->refcount); |
| 90 | return 0; |
| 91 | } |
| 92 | return -EIO; |
| 93 | } |
| 94 | |
| 95 | static void zfcp_wka_port_offline(struct work_struct *work) |
| 96 | { |
| 97 | struct delayed_work *dw = container_of(work, struct delayed_work, work); |
| 98 | struct zfcp_wka_port *wka_port = |
| 99 | container_of(dw, struct zfcp_wka_port, work); |
| 100 | |
| 101 | wait_event(wka_port->completion_wq, |
| 102 | atomic_read(&wka_port->refcount) == 0); |
| 103 | |
| 104 | mutex_lock(&wka_port->mutex); |
| 105 | if ((atomic_read(&wka_port->refcount) != 0) || |
| 106 | (wka_port->status != ZFCP_WKA_PORT_ONLINE)) |
| 107 | goto out; |
| 108 | |
| 109 | wka_port->status = ZFCP_WKA_PORT_CLOSING; |
| 110 | if (zfcp_fsf_close_wka_port(wka_port)) { |
| 111 | wka_port->status = ZFCP_WKA_PORT_OFFLINE; |
| 112 | wake_up(&wka_port->completion_wq); |
| 113 | } |
| 114 | out: |
| 115 | mutex_unlock(&wka_port->mutex); |
| 116 | } |
| 117 | |
| 118 | static void zfcp_wka_port_put(struct zfcp_wka_port *wka_port) |
| 119 | { |
| 120 | if (atomic_dec_return(&wka_port->refcount) != 0) |
| 121 | return; |
| 122 | /* wait 10 miliseconds, other reqs might pop in */ |
| 123 | schedule_delayed_work(&wka_port->work, HZ / 100); |
| 124 | } |
| 125 | |
| 126 | void zfcp_fc_nameserver_init(struct zfcp_adapter *adapter) |
| 127 | { |
| 128 | struct zfcp_wka_port *wka_port = &adapter->nsp; |
| 129 | |
| 130 | init_waitqueue_head(&wka_port->completion_wq); |
| 131 | |
| 132 | wka_port->adapter = adapter; |
| 133 | wka_port->d_id = ZFCP_DID_DIRECTORY_SERVICE; |
| 134 | |
| 135 | wka_port->status = ZFCP_WKA_PORT_OFFLINE; |
| 136 | atomic_set(&wka_port->refcount, 0); |
| 137 | mutex_init(&wka_port->mutex); |
| 138 | INIT_DELAYED_WORK(&wka_port->work, zfcp_wka_port_offline); |
| 139 | } |
| 140 | |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 141 | static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range, |
| 142 | struct fcp_rscn_element *elem) |
| 143 | { |
| 144 | unsigned long flags; |
| 145 | struct zfcp_port *port; |
| 146 | |
| 147 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
Swen Schillig | 2409549 | 2009-03-02 13:09:07 +0100 | [diff] [blame] | 148 | list_for_each_entry(port, &fsf_req->adapter->port_list_head, list) |
| 149 | if ((port->d_id & range) == (elem->nport_did & range)) |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 150 | zfcp_test_link(port); |
Swen Schillig | 2409549 | 2009-03-02 13:09:07 +0100 | [diff] [blame] | 151 | |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 152 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
| 153 | } |
| 154 | |
| 155 | static void zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req) |
| 156 | { |
| 157 | struct fsf_status_read_buffer *status_buffer = (void *)fsf_req->data; |
| 158 | struct fcp_rscn_head *fcp_rscn_head; |
| 159 | struct fcp_rscn_element *fcp_rscn_element; |
| 160 | u16 i; |
| 161 | u16 no_entries; |
| 162 | u32 range_mask; |
| 163 | |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 164 | fcp_rscn_head = (struct fcp_rscn_head *) status_buffer->payload.data; |
| 165 | fcp_rscn_element = (struct fcp_rscn_element *) fcp_rscn_head; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 166 | |
| 167 | /* see FC-FS */ |
| 168 | no_entries = fcp_rscn_head->payload_len / |
| 169 | sizeof(struct fcp_rscn_element); |
| 170 | |
| 171 | for (i = 1; i < no_entries; i++) { |
| 172 | /* skip head and start with 1st element */ |
| 173 | fcp_rscn_element++; |
Christof Schmitt | e0d7fcb | 2008-12-19 16:56:58 +0100 | [diff] [blame] | 174 | range_mask = rscn_range_mask[fcp_rscn_element->addr_format]; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 175 | _zfcp_fc_incoming_rscn(fsf_req, range_mask, fcp_rscn_element); |
| 176 | } |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 177 | schedule_work(&fsf_req->adapter->scan_work); |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 178 | } |
| 179 | |
Swen Schillig | 7ba58c9 | 2008-10-01 12:42:18 +0200 | [diff] [blame] | 180 | static void zfcp_fc_incoming_wwpn(struct zfcp_fsf_req *req, u64 wwpn) |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 181 | { |
| 182 | struct zfcp_adapter *adapter = req->adapter; |
| 183 | struct zfcp_port *port; |
| 184 | unsigned long flags; |
| 185 | |
| 186 | read_lock_irqsave(&zfcp_data.config_lock, flags); |
| 187 | list_for_each_entry(port, &adapter->port_list_head, list) |
| 188 | if (port->wwpn == wwpn) |
| 189 | break; |
| 190 | read_unlock_irqrestore(&zfcp_data.config_lock, flags); |
| 191 | |
| 192 | if (port && (port->wwpn == wwpn)) |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 193 | zfcp_erp_port_forced_reopen(port, 0, "fciwwp1", req); |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | static void zfcp_fc_incoming_plogi(struct zfcp_fsf_req *req) |
| 197 | { |
| 198 | struct fsf_status_read_buffer *status_buffer = |
| 199 | (struct fsf_status_read_buffer *)req->data; |
| 200 | struct fsf_plogi *els_plogi = |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 201 | (struct fsf_plogi *) status_buffer->payload.data; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 202 | |
| 203 | zfcp_fc_incoming_wwpn(req, els_plogi->serv_param.wwpn); |
| 204 | } |
| 205 | |
| 206 | static void zfcp_fc_incoming_logo(struct zfcp_fsf_req *req) |
| 207 | { |
| 208 | struct fsf_status_read_buffer *status_buffer = |
| 209 | (struct fsf_status_read_buffer *)req->data; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 210 | struct fcp_logo *els_logo = |
| 211 | (struct fcp_logo *) status_buffer->payload.data; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 212 | |
| 213 | zfcp_fc_incoming_wwpn(req, els_logo->nport_wwpn); |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * zfcp_fc_incoming_els - handle incoming ELS |
| 218 | * @fsf_req - request which contains incoming ELS |
| 219 | */ |
| 220 | void zfcp_fc_incoming_els(struct zfcp_fsf_req *fsf_req) |
| 221 | { |
| 222 | struct fsf_status_read_buffer *status_buffer = |
| 223 | (struct fsf_status_read_buffer *) fsf_req->data; |
Swen Schillig | c41f8cb | 2008-07-02 10:56:39 +0200 | [diff] [blame] | 224 | unsigned int els_type = status_buffer->payload.data[0]; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 225 | |
| 226 | zfcp_san_dbf_event_incoming_els(fsf_req); |
| 227 | if (els_type == LS_PLOGI) |
| 228 | zfcp_fc_incoming_plogi(fsf_req); |
| 229 | else if (els_type == LS_LOGO) |
| 230 | zfcp_fc_incoming_logo(fsf_req); |
| 231 | else if (els_type == LS_RSCN) |
| 232 | zfcp_fc_incoming_rscn(fsf_req); |
| 233 | } |
| 234 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 235 | static void zfcp_fc_ns_handler(unsigned long data) |
| 236 | { |
| 237 | struct zfcp_fc_ns_handler_data *compl_rec = |
| 238 | (struct zfcp_fc_ns_handler_data *) data; |
| 239 | |
| 240 | if (compl_rec->handler) |
| 241 | compl_rec->handler(compl_rec->handler_data); |
| 242 | |
| 243 | complete(&compl_rec->done); |
| 244 | } |
| 245 | |
| 246 | static void zfcp_fc_ns_gid_pn_eval(unsigned long data) |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 247 | { |
| 248 | struct zfcp_gid_pn_data *gid_pn = (struct zfcp_gid_pn_data *) data; |
| 249 | struct zfcp_send_ct *ct = &gid_pn->ct; |
| 250 | struct ct_iu_gid_pn_req *ct_iu_req = sg_virt(ct->req); |
| 251 | struct ct_iu_gid_pn_resp *ct_iu_resp = sg_virt(ct->resp); |
| 252 | struct zfcp_port *port = gid_pn->port; |
| 253 | |
| 254 | if (ct->status) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 255 | return; |
Christof Schmitt | a5b11dd | 2009-03-02 13:08:54 +0100 | [diff] [blame] | 256 | if (ct_iu_resp->header.cmd_rsp_code != ZFCP_CT_ACCEPT) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 257 | return; |
Christof Schmitt | a5b11dd | 2009-03-02 13:08:54 +0100 | [diff] [blame] | 258 | |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 259 | /* paranoia */ |
| 260 | if (ct_iu_req->wwpn != port->wwpn) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 261 | return; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 262 | /* looks like a valid d_id */ |
| 263 | port->d_id = ct_iu_resp->d_id & ZFCP_DID_MASK; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 264 | } |
| 265 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 266 | int static zfcp_fc_ns_gid_pn_request(struct zfcp_erp_action *erp_action, |
| 267 | struct zfcp_gid_pn_data *gid_pn) |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 268 | { |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 269 | struct zfcp_adapter *adapter = erp_action->adapter; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 270 | struct zfcp_fc_ns_handler_data compl_rec; |
| 271 | int ret; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 272 | |
| 273 | /* setup parameters for send generic command */ |
| 274 | gid_pn->port = erp_action->port; |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 275 | gid_pn->ct.wka_port = &adapter->nsp; |
| 276 | gid_pn->ct.handler = zfcp_fc_ns_handler; |
| 277 | gid_pn->ct.handler_data = (unsigned long) &compl_rec; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 278 | gid_pn->ct.timeout = ZFCP_NS_GID_PN_TIMEOUT; |
| 279 | gid_pn->ct.req = &gid_pn->req; |
| 280 | gid_pn->ct.resp = &gid_pn->resp; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 281 | sg_init_one(&gid_pn->req, &gid_pn->ct_iu_req, |
| 282 | sizeof(struct ct_iu_gid_pn_req)); |
| 283 | sg_init_one(&gid_pn->resp, &gid_pn->ct_iu_resp, |
| 284 | sizeof(struct ct_iu_gid_pn_resp)); |
| 285 | |
| 286 | /* setup nameserver request */ |
| 287 | gid_pn->ct_iu_req.header.revision = ZFCP_CT_REVISION; |
| 288 | gid_pn->ct_iu_req.header.gs_type = ZFCP_CT_DIRECTORY_SERVICE; |
| 289 | gid_pn->ct_iu_req.header.gs_subtype = ZFCP_CT_NAME_SERVER; |
| 290 | gid_pn->ct_iu_req.header.options = ZFCP_CT_SYNCHRONOUS; |
| 291 | gid_pn->ct_iu_req.header.cmd_rsp_code = ZFCP_CT_GID_PN; |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 292 | gid_pn->ct_iu_req.header.max_res_size = ZFCP_CT_SIZE_ONE_PAGE / 4; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 293 | gid_pn->ct_iu_req.wwpn = erp_action->port->wwpn; |
| 294 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 295 | init_completion(&compl_rec.done); |
| 296 | compl_rec.handler = zfcp_fc_ns_gid_pn_eval; |
| 297 | compl_rec.handler_data = (unsigned long) gid_pn; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 298 | ret = zfcp_fsf_send_ct(&gid_pn->ct, adapter->pool.fsf_req_erp, |
| 299 | erp_action); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 300 | if (!ret) |
| 301 | wait_for_completion(&compl_rec.done); |
| 302 | return ret; |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * zfcp_fc_ns_gid_pn_request - initiate GID_PN nameserver request |
| 307 | * @erp_action: pointer to zfcp_erp_action where GID_PN request is needed |
| 308 | * return: -ENOMEM on error, 0 otherwise |
| 309 | */ |
| 310 | int zfcp_fc_ns_gid_pn(struct zfcp_erp_action *erp_action) |
| 311 | { |
| 312 | int ret; |
| 313 | struct zfcp_gid_pn_data *gid_pn; |
| 314 | struct zfcp_adapter *adapter = erp_action->adapter; |
| 315 | |
| 316 | gid_pn = mempool_alloc(adapter->pool.data_gid_pn, GFP_ATOMIC); |
| 317 | if (!gid_pn) |
| 318 | return -ENOMEM; |
| 319 | |
| 320 | memset(gid_pn, 0, sizeof(*gid_pn)); |
| 321 | |
| 322 | ret = zfcp_wka_port_get(&adapter->nsp); |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 323 | if (ret) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 324 | goto out; |
| 325 | |
| 326 | ret = zfcp_fc_ns_gid_pn_request(erp_action, gid_pn); |
| 327 | |
| 328 | zfcp_wka_port_put(&adapter->nsp); |
| 329 | out: |
| 330 | mempool_free(gid_pn, adapter->pool.data_gid_pn); |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 331 | return ret; |
| 332 | } |
| 333 | |
| 334 | /** |
| 335 | * zfcp_fc_plogi_evaluate - evaluate PLOGI playload |
| 336 | * @port: zfcp_port structure |
| 337 | * @plogi: plogi payload |
| 338 | * |
| 339 | * Evaluate PLOGI playload and copy important fields into zfcp_port structure |
| 340 | */ |
| 341 | void zfcp_fc_plogi_evaluate(struct zfcp_port *port, struct fsf_plogi *plogi) |
| 342 | { |
| 343 | port->maxframe_size = plogi->serv_param.common_serv_param[7] | |
| 344 | ((plogi->serv_param.common_serv_param[6] & 0x0F) << 8); |
| 345 | if (plogi->serv_param.class1_serv_param[0] & 0x80) |
| 346 | port->supported_classes |= FC_COS_CLASS1; |
| 347 | if (plogi->serv_param.class2_serv_param[0] & 0x80) |
| 348 | port->supported_classes |= FC_COS_CLASS2; |
| 349 | if (plogi->serv_param.class3_serv_param[0] & 0x80) |
| 350 | port->supported_classes |= FC_COS_CLASS3; |
| 351 | if (plogi->serv_param.class4_serv_param[0] & 0x80) |
| 352 | port->supported_classes |= FC_COS_CLASS4; |
| 353 | } |
| 354 | |
| 355 | struct zfcp_els_adisc { |
| 356 | struct zfcp_send_els els; |
| 357 | struct scatterlist req; |
| 358 | struct scatterlist resp; |
| 359 | struct zfcp_ls_adisc ls_adisc; |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 360 | struct zfcp_ls_adisc ls_adisc_acc; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 361 | }; |
| 362 | |
| 363 | static void zfcp_fc_adisc_handler(unsigned long data) |
| 364 | { |
| 365 | struct zfcp_els_adisc *adisc = (struct zfcp_els_adisc *) data; |
| 366 | struct zfcp_port *port = adisc->els.port; |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 367 | struct zfcp_ls_adisc *ls_adisc = &adisc->ls_adisc_acc; |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 368 | |
Christof Schmitt | 3968ce8 | 2008-07-02 10:56:32 +0200 | [diff] [blame] | 369 | if (adisc->els.status) { |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 370 | /* request rejected or timed out */ |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 371 | zfcp_erp_port_forced_reopen(port, 0, "fcadh_1", NULL); |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 372 | goto out; |
| 373 | } |
| 374 | |
| 375 | if (!port->wwnn) |
| 376 | port->wwnn = ls_adisc->wwnn; |
| 377 | |
Swen Schillig | 2409549 | 2009-03-02 13:09:07 +0100 | [diff] [blame] | 378 | if ((port->wwpn != ls_adisc->wwpn) || |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame^] | 379 | !(atomic_read(&port->status) & ZFCP_STATUS_COMMON_OPEN)) { |
Swen Schillig | 2409549 | 2009-03-02 13:09:07 +0100 | [diff] [blame] | 380 | zfcp_erp_port_reopen(port, ZFCP_STATUS_COMMON_ERP_FAILED, |
| 381 | "fcadh_2", NULL); |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame^] | 382 | goto out; |
| 383 | } |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 384 | |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame^] | 385 | /* port is good, unblock rport without going through erp */ |
| 386 | zfcp_scsi_schedule_rport_register(port); |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 387 | out: |
| 388 | zfcp_port_put(port); |
| 389 | kfree(adisc); |
| 390 | } |
| 391 | |
| 392 | static int zfcp_fc_adisc(struct zfcp_port *port) |
| 393 | { |
| 394 | struct zfcp_els_adisc *adisc; |
| 395 | struct zfcp_adapter *adapter = port->adapter; |
| 396 | |
| 397 | adisc = kzalloc(sizeof(struct zfcp_els_adisc), GFP_ATOMIC); |
| 398 | if (!adisc) |
| 399 | return -ENOMEM; |
| 400 | |
| 401 | adisc->els.req = &adisc->req; |
| 402 | adisc->els.resp = &adisc->resp; |
| 403 | sg_init_one(adisc->els.req, &adisc->ls_adisc, |
| 404 | sizeof(struct zfcp_ls_adisc)); |
| 405 | sg_init_one(adisc->els.resp, &adisc->ls_adisc_acc, |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 406 | sizeof(struct zfcp_ls_adisc)); |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 407 | |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 408 | adisc->els.adapter = adapter; |
| 409 | adisc->els.port = port; |
| 410 | adisc->els.d_id = port->d_id; |
| 411 | adisc->els.handler = zfcp_fc_adisc_handler; |
| 412 | adisc->els.handler_data = (unsigned long) adisc; |
| 413 | adisc->els.ls_code = adisc->ls_adisc.code = ZFCP_LS_ADISC; |
| 414 | |
| 415 | /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports |
| 416 | without FC-AL-2 capability, so we don't set it */ |
| 417 | adisc->ls_adisc.wwpn = fc_host_port_name(adapter->scsi_host); |
| 418 | adisc->ls_adisc.wwnn = fc_host_node_name(adapter->scsi_host); |
| 419 | adisc->ls_adisc.nport_id = fc_host_port_id(adapter->scsi_host); |
| 420 | |
| 421 | return zfcp_fsf_send_els(&adisc->els); |
| 422 | } |
| 423 | |
Christof Schmitt | 8fdf30d | 2009-03-02 13:09:01 +0100 | [diff] [blame] | 424 | void zfcp_fc_link_test_work(struct work_struct *work) |
| 425 | { |
| 426 | struct zfcp_port *port = |
| 427 | container_of(work, struct zfcp_port, test_link_work); |
| 428 | int retval; |
| 429 | |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame^] | 430 | if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_UNBLOCKED)) { |
| 431 | zfcp_port_put(port); |
| 432 | return; /* port erp is running and will update rport status */ |
| 433 | } |
| 434 | |
| 435 | zfcp_port_get(port); |
| 436 | port->rport_task = RPORT_DEL; |
| 437 | zfcp_scsi_rport_work(&port->rport_work); |
| 438 | |
Christof Schmitt | 8fdf30d | 2009-03-02 13:09:01 +0100 | [diff] [blame] | 439 | retval = zfcp_fc_adisc(port); |
| 440 | if (retval == 0) |
| 441 | return; |
| 442 | |
| 443 | /* send of ADISC was not possible */ |
Christof Schmitt | a2fa0ae | 2009-03-02 13:09:08 +0100 | [diff] [blame^] | 444 | zfcp_erp_port_forced_reopen(port, 0, "fcltwk1", NULL); |
| 445 | |
Christof Schmitt | 8fdf30d | 2009-03-02 13:09:01 +0100 | [diff] [blame] | 446 | zfcp_port_put(port); |
Christof Schmitt | 8fdf30d | 2009-03-02 13:09:01 +0100 | [diff] [blame] | 447 | } |
| 448 | |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 449 | /** |
| 450 | * zfcp_test_link - lightweight link test procedure |
| 451 | * @port: port to be tested |
| 452 | * |
| 453 | * Test status of a link to a remote port using the ELS command ADISC. |
| 454 | * If there is a problem with the remote port, error recovery steps |
| 455 | * will be triggered. |
| 456 | */ |
| 457 | void zfcp_test_link(struct zfcp_port *port) |
| 458 | { |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 459 | zfcp_port_get(port); |
Christof Schmitt | 8fdf30d | 2009-03-02 13:09:01 +0100 | [diff] [blame] | 460 | if (!queue_work(zfcp_data.work_queue, &port->test_link_work)) |
| 461 | zfcp_port_put(port); |
Christof Schmitt | 24073b4 | 2008-06-10 18:20:54 +0200 | [diff] [blame] | 462 | } |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 463 | |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 464 | static void zfcp_free_sg_env(struct zfcp_gpn_ft *gpn_ft, int buf_num) |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 465 | { |
| 466 | struct scatterlist *sg = &gpn_ft->sg_req; |
| 467 | |
| 468 | kfree(sg_virt(sg)); /* free request buffer */ |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 469 | zfcp_sg_free_table(gpn_ft->sg_resp, buf_num); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 470 | |
| 471 | kfree(gpn_ft); |
| 472 | } |
| 473 | |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 474 | static struct zfcp_gpn_ft *zfcp_alloc_sg_env(int buf_num) |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 475 | { |
| 476 | struct zfcp_gpn_ft *gpn_ft; |
| 477 | struct ct_iu_gpn_ft_req *req; |
| 478 | |
| 479 | gpn_ft = kzalloc(sizeof(*gpn_ft), GFP_KERNEL); |
| 480 | if (!gpn_ft) |
| 481 | return NULL; |
| 482 | |
| 483 | req = kzalloc(sizeof(struct ct_iu_gpn_ft_req), GFP_KERNEL); |
| 484 | if (!req) { |
| 485 | kfree(gpn_ft); |
| 486 | gpn_ft = NULL; |
| 487 | goto out; |
| 488 | } |
| 489 | sg_init_one(&gpn_ft->sg_req, req, sizeof(*req)); |
| 490 | |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 491 | if (zfcp_sg_setup_table(gpn_ft->sg_resp, buf_num)) { |
| 492 | zfcp_free_sg_env(gpn_ft, buf_num); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 493 | gpn_ft = NULL; |
| 494 | } |
| 495 | out: |
| 496 | return gpn_ft; |
| 497 | } |
| 498 | |
| 499 | |
| 500 | static int zfcp_scan_issue_gpn_ft(struct zfcp_gpn_ft *gpn_ft, |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 501 | struct zfcp_adapter *adapter, |
| 502 | int max_bytes) |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 503 | { |
| 504 | struct zfcp_send_ct *ct = &gpn_ft->ct; |
| 505 | struct ct_iu_gpn_ft_req *req = sg_virt(&gpn_ft->sg_req); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 506 | struct zfcp_fc_ns_handler_data compl_rec; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 507 | int ret; |
| 508 | |
| 509 | /* prepare CT IU for GPN_FT */ |
| 510 | req->header.revision = ZFCP_CT_REVISION; |
| 511 | req->header.gs_type = ZFCP_CT_DIRECTORY_SERVICE; |
| 512 | req->header.gs_subtype = ZFCP_CT_NAME_SERVER; |
| 513 | req->header.options = ZFCP_CT_SYNCHRONOUS; |
| 514 | req->header.cmd_rsp_code = ZFCP_CT_GPN_FT; |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 515 | req->header.max_res_size = max_bytes / 4; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 516 | req->flags = 0; |
| 517 | req->domain_id_scope = 0; |
| 518 | req->area_id_scope = 0; |
| 519 | req->fc4_type = ZFCP_CT_SCSI_FCP; |
| 520 | |
| 521 | /* prepare zfcp_send_ct */ |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 522 | ct->wka_port = &adapter->nsp; |
| 523 | ct->handler = zfcp_fc_ns_handler; |
| 524 | ct->handler_data = (unsigned long)&compl_rec; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 525 | ct->timeout = 10; |
| 526 | ct->req = &gpn_ft->sg_req; |
| 527 | ct->resp = gpn_ft->sg_resp; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 528 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 529 | init_completion(&compl_rec.done); |
| 530 | compl_rec.handler = NULL; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 531 | ret = zfcp_fsf_send_ct(ct, NULL, NULL); |
| 532 | if (!ret) |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 533 | wait_for_completion(&compl_rec.done); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 534 | return ret; |
| 535 | } |
| 536 | |
| 537 | static void zfcp_validate_port(struct zfcp_port *port) |
| 538 | { |
| 539 | struct zfcp_adapter *adapter = port->adapter; |
| 540 | |
| 541 | atomic_clear_mask(ZFCP_STATUS_COMMON_NOESC, &port->status); |
| 542 | |
Christof Schmitt | 0406289 | 2008-10-01 12:42:20 +0200 | [diff] [blame] | 543 | if ((port->supported_classes != 0) || |
| 544 | !list_empty(&port->unit_list_head)) { |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 545 | zfcp_port_put(port); |
| 546 | return; |
| 547 | } |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 548 | zfcp_erp_port_shutdown(port, 0, "fcpval1", NULL); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 549 | zfcp_erp_wait(adapter); |
| 550 | zfcp_port_put(port); |
| 551 | zfcp_port_dequeue(port); |
| 552 | } |
| 553 | |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 554 | static int zfcp_scan_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries) |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 555 | { |
| 556 | struct zfcp_send_ct *ct = &gpn_ft->ct; |
| 557 | struct scatterlist *sg = gpn_ft->sg_resp; |
| 558 | struct ct_hdr *hdr = sg_virt(sg); |
| 559 | struct gpn_ft_resp_acc *acc = sg_virt(sg); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 560 | struct zfcp_adapter *adapter = ct->wka_port->adapter; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 561 | struct zfcp_port *port, *tmp; |
| 562 | u32 d_id; |
Christof Schmitt | 47f7bba | 2008-08-21 13:43:33 +0200 | [diff] [blame] | 563 | int ret = 0, x, last = 0; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 564 | |
| 565 | if (ct->status) |
| 566 | return -EIO; |
| 567 | |
| 568 | if (hdr->cmd_rsp_code != ZFCP_CT_ACCEPT) { |
| 569 | if (hdr->reason_code == ZFCP_CT_UNABLE_TO_PERFORM_CMD) |
| 570 | return -EAGAIN; /* might be a temporary condition */ |
| 571 | return -EIO; |
| 572 | } |
| 573 | |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 574 | if (hdr->max_res_size) { |
| 575 | dev_warn(&adapter->ccw_device->dev, |
| 576 | "The name server reported %d words residual data\n", |
| 577 | hdr->max_res_size); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 578 | return -E2BIG; |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 579 | } |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 580 | |
| 581 | down(&zfcp_data.config_sema); |
| 582 | |
| 583 | /* first entry is the header */ |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 584 | for (x = 1; x < max_entries && !last; x++) { |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 585 | if (x % (ZFCP_GPN_FT_ENTRIES + 1)) |
| 586 | acc++; |
| 587 | else |
| 588 | acc = sg_virt(++sg); |
| 589 | |
Christof Schmitt | 47f7bba | 2008-08-21 13:43:33 +0200 | [diff] [blame] | 590 | last = acc->control & 0x80; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 591 | d_id = acc->port_id[0] << 16 | acc->port_id[1] << 8 | |
| 592 | acc->port_id[2]; |
| 593 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 594 | /* don't attach ports with a well known address */ |
| 595 | if ((d_id & ZFCP_DID_WKA) == ZFCP_DID_WKA) |
| 596 | continue; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 597 | /* skip the adapter's port and known remote ports */ |
Swen Schillig | 9528539 | 2008-08-21 13:43:35 +0200 | [diff] [blame] | 598 | if (acc->wwpn == fc_host_port_name(adapter->scsi_host)) |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 599 | continue; |
Swen Schillig | 9528539 | 2008-08-21 13:43:35 +0200 | [diff] [blame] | 600 | port = zfcp_get_port_by_wwpn(adapter, acc->wwpn); |
| 601 | if (port) { |
| 602 | zfcp_port_get(port); |
| 603 | continue; |
| 604 | } |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 605 | |
| 606 | port = zfcp_port_enqueue(adapter, acc->wwpn, |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 607 | ZFCP_STATUS_COMMON_NOESC, d_id); |
Swen Schillig | 317e6b6 | 2008-07-02 10:56:37 +0200 | [diff] [blame] | 608 | if (IS_ERR(port)) |
| 609 | ret = PTR_ERR(port); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 610 | else |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 611 | zfcp_erp_port_reopen(port, 0, "fcegpf1", NULL); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | zfcp_erp_wait(adapter); |
| 615 | list_for_each_entry_safe(port, tmp, &adapter->port_list_head, list) |
| 616 | zfcp_validate_port(port); |
| 617 | up(&zfcp_data.config_sema); |
| 618 | return ret; |
| 619 | } |
| 620 | |
| 621 | /** |
| 622 | * zfcp_scan_ports - scan remote ports and attach new ports |
| 623 | * @adapter: pointer to struct zfcp_adapter |
| 624 | */ |
| 625 | int zfcp_scan_ports(struct zfcp_adapter *adapter) |
| 626 | { |
| 627 | int ret, i; |
| 628 | struct zfcp_gpn_ft *gpn_ft; |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 629 | int chain, max_entries, buf_num, max_bytes; |
| 630 | |
| 631 | chain = adapter->adapter_features & FSF_FEATURE_ELS_CT_CHAINED_SBALS; |
| 632 | buf_num = chain ? ZFCP_GPN_FT_BUFFERS : 1; |
| 633 | max_entries = chain ? ZFCP_GPN_FT_MAX_ENTRIES : ZFCP_GPN_FT_ENTRIES; |
| 634 | max_bytes = chain ? ZFCP_GPN_FT_MAX_SIZE : ZFCP_CT_SIZE_ONE_PAGE; |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 635 | |
| 636 | if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT) |
| 637 | return 0; |
| 638 | |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 639 | ret = zfcp_wka_port_get(&adapter->nsp); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 640 | if (ret) |
| 641 | return ret; |
| 642 | |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 643 | gpn_ft = zfcp_alloc_sg_env(buf_num); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 644 | if (!gpn_ft) { |
| 645 | ret = -ENOMEM; |
| 646 | goto out; |
| 647 | } |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 648 | |
| 649 | for (i = 0; i < 3; i++) { |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 650 | ret = zfcp_scan_issue_gpn_ft(gpn_ft, adapter, max_bytes); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 651 | if (!ret) { |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 652 | ret = zfcp_scan_eval_gpn_ft(gpn_ft, max_entries); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 653 | if (ret == -EAGAIN) |
| 654 | ssleep(1); |
| 655 | else |
| 656 | break; |
| 657 | } |
| 658 | } |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 659 | zfcp_free_sg_env(gpn_ft, buf_num); |
Swen Schillig | 5ab944f | 2008-10-01 12:42:17 +0200 | [diff] [blame] | 660 | out: |
| 661 | zfcp_wka_port_put(&adapter->nsp); |
Swen Schillig | cc8c282 | 2008-06-10 18:21:00 +0200 | [diff] [blame] | 662 | return ret; |
| 663 | } |
| 664 | |
| 665 | |
| 666 | void _zfcp_scan_ports_later(struct work_struct *work) |
| 667 | { |
| 668 | zfcp_scan_ports(container_of(work, struct zfcp_adapter, scan_work)); |
| 669 | } |