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