zfcp_fc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. /*
  2. * zfcp device driver
  3. *
  4. * Fibre Channel related functions for the zfcp device driver.
  5. *
  6. * Copyright IBM Corporation 2008
  7. */
  8. #include "zfcp_ext.h"
  9. struct ct_iu_gpn_ft_req {
  10. struct ct_hdr header;
  11. u8 flags;
  12. u8 domain_id_scope;
  13. u8 area_id_scope;
  14. u8 fc4_type;
  15. } __attribute__ ((packed));
  16. struct gpn_ft_resp_acc {
  17. u8 control;
  18. u8 port_id[3];
  19. u8 reserved[4];
  20. u64 wwpn;
  21. } __attribute__ ((packed));
  22. #define ZFCP_GPN_FT_ENTRIES ((PAGE_SIZE - sizeof(struct ct_hdr)) \
  23. / sizeof(struct gpn_ft_resp_acc))
  24. #define ZFCP_GPN_FT_BUFFERS 4
  25. #define ZFCP_GPN_FT_MAX_ENTRIES ZFCP_GPN_FT_BUFFERS * (ZFCP_GPN_FT_ENTRIES + 1)
  26. struct ct_iu_gpn_ft_resp {
  27. struct ct_hdr header;
  28. struct gpn_ft_resp_acc accept[ZFCP_GPN_FT_ENTRIES];
  29. } __attribute__ ((packed));
  30. struct zfcp_gpn_ft {
  31. struct zfcp_send_ct ct;
  32. struct scatterlist sg_req;
  33. struct scatterlist sg_resp[ZFCP_GPN_FT_BUFFERS];
  34. };
  35. static struct zfcp_port *zfcp_get_port_by_did(struct zfcp_adapter *adapter,
  36. u32 d_id)
  37. {
  38. struct zfcp_port *port;
  39. list_for_each_entry(port, &adapter->port_list_head, list)
  40. if ((port->d_id == d_id) &&
  41. !atomic_test_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status))
  42. return port;
  43. return NULL;
  44. }
  45. static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range,
  46. struct fcp_rscn_element *elem)
  47. {
  48. unsigned long flags;
  49. struct zfcp_port *port;
  50. read_lock_irqsave(&zfcp_data.config_lock, flags);
  51. list_for_each_entry(port, &fsf_req->adapter->port_list_head, list) {
  52. if (atomic_test_mask(ZFCP_STATUS_PORT_WKA, &port->status))
  53. continue;
  54. /* FIXME: ZFCP_STATUS_PORT_DID_DID check is racy */
  55. if (!atomic_test_mask(ZFCP_STATUS_PORT_DID_DID, &port->status))
  56. /* Try to connect to unused ports anyway. */
  57. zfcp_erp_port_reopen(port,
  58. ZFCP_STATUS_COMMON_ERP_FAILED,
  59. 82, fsf_req);
  60. else if ((port->d_id & range) == (elem->nport_did & range))
  61. /* Check connection status for connected ports */
  62. zfcp_test_link(port);
  63. }
  64. read_unlock_irqrestore(&zfcp_data.config_lock, flags);
  65. }
  66. static void zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req)
  67. {
  68. struct fsf_status_read_buffer *status_buffer = (void *)fsf_req->data;
  69. struct fcp_rscn_head *fcp_rscn_head;
  70. struct fcp_rscn_element *fcp_rscn_element;
  71. u16 i;
  72. u16 no_entries;
  73. u32 range_mask;
  74. fcp_rscn_head = (struct fcp_rscn_head *) status_buffer->payload.data;
  75. fcp_rscn_element = (struct fcp_rscn_element *) fcp_rscn_head;
  76. /* see FC-FS */
  77. no_entries = fcp_rscn_head->payload_len /
  78. sizeof(struct fcp_rscn_element);
  79. for (i = 1; i < no_entries; i++) {
  80. /* skip head and start with 1st element */
  81. fcp_rscn_element++;
  82. switch (fcp_rscn_element->addr_format) {
  83. case ZFCP_PORT_ADDRESS:
  84. range_mask = ZFCP_PORTS_RANGE_PORT;
  85. break;
  86. case ZFCP_AREA_ADDRESS:
  87. range_mask = ZFCP_PORTS_RANGE_AREA;
  88. break;
  89. case ZFCP_DOMAIN_ADDRESS:
  90. range_mask = ZFCP_PORTS_RANGE_DOMAIN;
  91. break;
  92. case ZFCP_FABRIC_ADDRESS:
  93. range_mask = ZFCP_PORTS_RANGE_FABRIC;
  94. break;
  95. default:
  96. continue;
  97. }
  98. _zfcp_fc_incoming_rscn(fsf_req, range_mask, fcp_rscn_element);
  99. }
  100. schedule_work(&fsf_req->adapter->scan_work);
  101. }
  102. static void zfcp_fc_incoming_wwpn(struct zfcp_fsf_req *req, wwn_t wwpn)
  103. {
  104. struct zfcp_adapter *adapter = req->adapter;
  105. struct zfcp_port *port;
  106. unsigned long flags;
  107. read_lock_irqsave(&zfcp_data.config_lock, flags);
  108. list_for_each_entry(port, &adapter->port_list_head, list)
  109. if (port->wwpn == wwpn)
  110. break;
  111. read_unlock_irqrestore(&zfcp_data.config_lock, flags);
  112. if (port && (port->wwpn == wwpn))
  113. zfcp_erp_port_forced_reopen(port, 0, 83, req);
  114. }
  115. static void zfcp_fc_incoming_plogi(struct zfcp_fsf_req *req)
  116. {
  117. struct fsf_status_read_buffer *status_buffer =
  118. (struct fsf_status_read_buffer *)req->data;
  119. struct fsf_plogi *els_plogi =
  120. (struct fsf_plogi *) status_buffer->payload.data;
  121. zfcp_fc_incoming_wwpn(req, els_plogi->serv_param.wwpn);
  122. }
  123. static void zfcp_fc_incoming_logo(struct zfcp_fsf_req *req)
  124. {
  125. struct fsf_status_read_buffer *status_buffer =
  126. (struct fsf_status_read_buffer *)req->data;
  127. struct fcp_logo *els_logo =
  128. (struct fcp_logo *) status_buffer->payload.data;
  129. zfcp_fc_incoming_wwpn(req, els_logo->nport_wwpn);
  130. }
  131. /**
  132. * zfcp_fc_incoming_els - handle incoming ELS
  133. * @fsf_req - request which contains incoming ELS
  134. */
  135. void zfcp_fc_incoming_els(struct zfcp_fsf_req *fsf_req)
  136. {
  137. struct fsf_status_read_buffer *status_buffer =
  138. (struct fsf_status_read_buffer *) fsf_req->data;
  139. unsigned int els_type = status_buffer->payload.data[0];
  140. zfcp_san_dbf_event_incoming_els(fsf_req);
  141. if (els_type == LS_PLOGI)
  142. zfcp_fc_incoming_plogi(fsf_req);
  143. else if (els_type == LS_LOGO)
  144. zfcp_fc_incoming_logo(fsf_req);
  145. else if (els_type == LS_RSCN)
  146. zfcp_fc_incoming_rscn(fsf_req);
  147. }
  148. static void zfcp_ns_gid_pn_handler(unsigned long data)
  149. {
  150. struct zfcp_gid_pn_data *gid_pn = (struct zfcp_gid_pn_data *) data;
  151. struct zfcp_send_ct *ct = &gid_pn->ct;
  152. struct ct_iu_gid_pn_req *ct_iu_req = sg_virt(ct->req);
  153. struct ct_iu_gid_pn_resp *ct_iu_resp = sg_virt(ct->resp);
  154. struct zfcp_port *port = gid_pn->port;
  155. if (ct->status)
  156. goto out;
  157. if (ct_iu_resp->header.cmd_rsp_code != ZFCP_CT_ACCEPT) {
  158. atomic_set_mask(ZFCP_STATUS_PORT_INVALID_WWPN, &port->status);
  159. goto out;
  160. }
  161. /* paranoia */
  162. if (ct_iu_req->wwpn != port->wwpn)
  163. goto out;
  164. /* looks like a valid d_id */
  165. port->d_id = ct_iu_resp->d_id & ZFCP_DID_MASK;
  166. atomic_set_mask(ZFCP_STATUS_PORT_DID_DID, &port->status);
  167. out:
  168. mempool_free(gid_pn, port->adapter->pool.data_gid_pn);
  169. }
  170. /**
  171. * zfcp_fc_ns_gid_pn_request - initiate GID_PN nameserver request
  172. * @erp_action: pointer to zfcp_erp_action where GID_PN request is needed
  173. * return: -ENOMEM on error, 0 otherwise
  174. */
  175. int zfcp_fc_ns_gid_pn_request(struct zfcp_erp_action *erp_action)
  176. {
  177. int ret;
  178. struct zfcp_gid_pn_data *gid_pn;
  179. struct zfcp_adapter *adapter = erp_action->adapter;
  180. gid_pn = mempool_alloc(adapter->pool.data_gid_pn, GFP_ATOMIC);
  181. if (!gid_pn)
  182. return -ENOMEM;
  183. memset(gid_pn, 0, sizeof(*gid_pn));
  184. /* setup parameters for send generic command */
  185. gid_pn->port = erp_action->port;
  186. gid_pn->ct.port = adapter->nameserver_port;
  187. gid_pn->ct.handler = zfcp_ns_gid_pn_handler;
  188. gid_pn->ct.handler_data = (unsigned long) gid_pn;
  189. gid_pn->ct.timeout = ZFCP_NS_GID_PN_TIMEOUT;
  190. gid_pn->ct.req = &gid_pn->req;
  191. gid_pn->ct.resp = &gid_pn->resp;
  192. gid_pn->ct.req_count = 1;
  193. gid_pn->ct.resp_count = 1;
  194. sg_init_one(&gid_pn->req, &gid_pn->ct_iu_req,
  195. sizeof(struct ct_iu_gid_pn_req));
  196. sg_init_one(&gid_pn->resp, &gid_pn->ct_iu_resp,
  197. sizeof(struct ct_iu_gid_pn_resp));
  198. /* setup nameserver request */
  199. gid_pn->ct_iu_req.header.revision = ZFCP_CT_REVISION;
  200. gid_pn->ct_iu_req.header.gs_type = ZFCP_CT_DIRECTORY_SERVICE;
  201. gid_pn->ct_iu_req.header.gs_subtype = ZFCP_CT_NAME_SERVER;
  202. gid_pn->ct_iu_req.header.options = ZFCP_CT_SYNCHRONOUS;
  203. gid_pn->ct_iu_req.header.cmd_rsp_code = ZFCP_CT_GID_PN;
  204. gid_pn->ct_iu_req.header.max_res_size = ZFCP_CT_MAX_SIZE;
  205. gid_pn->ct_iu_req.wwpn = erp_action->port->wwpn;
  206. ret = zfcp_fsf_send_ct(&gid_pn->ct, adapter->pool.fsf_req_erp,
  207. erp_action);
  208. if (ret)
  209. mempool_free(gid_pn, adapter->pool.data_gid_pn);
  210. return ret;
  211. }
  212. /**
  213. * zfcp_fc_plogi_evaluate - evaluate PLOGI playload
  214. * @port: zfcp_port structure
  215. * @plogi: plogi payload
  216. *
  217. * Evaluate PLOGI playload and copy important fields into zfcp_port structure
  218. */
  219. void zfcp_fc_plogi_evaluate(struct zfcp_port *port, struct fsf_plogi *plogi)
  220. {
  221. port->maxframe_size = plogi->serv_param.common_serv_param[7] |
  222. ((plogi->serv_param.common_serv_param[6] & 0x0F) << 8);
  223. if (plogi->serv_param.class1_serv_param[0] & 0x80)
  224. port->supported_classes |= FC_COS_CLASS1;
  225. if (plogi->serv_param.class2_serv_param[0] & 0x80)
  226. port->supported_classes |= FC_COS_CLASS2;
  227. if (plogi->serv_param.class3_serv_param[0] & 0x80)
  228. port->supported_classes |= FC_COS_CLASS3;
  229. if (plogi->serv_param.class4_serv_param[0] & 0x80)
  230. port->supported_classes |= FC_COS_CLASS4;
  231. }
  232. struct zfcp_els_adisc {
  233. struct zfcp_send_els els;
  234. struct scatterlist req;
  235. struct scatterlist resp;
  236. struct zfcp_ls_adisc ls_adisc;
  237. struct zfcp_ls_adisc_acc ls_adisc_acc;
  238. };
  239. static void zfcp_fc_adisc_handler(unsigned long data)
  240. {
  241. struct zfcp_els_adisc *adisc = (struct zfcp_els_adisc *) data;
  242. struct zfcp_port *port = adisc->els.port;
  243. struct zfcp_ls_adisc_acc *ls_adisc = &adisc->ls_adisc_acc;
  244. if (adisc->els.status) {
  245. /* request rejected or timed out */
  246. zfcp_erp_port_forced_reopen(port, 0, 63, NULL);
  247. goto out;
  248. }
  249. if (!port->wwnn)
  250. port->wwnn = ls_adisc->wwnn;
  251. if (port->wwpn != ls_adisc->wwpn)
  252. zfcp_erp_port_reopen(port, 0, 64, NULL);
  253. out:
  254. zfcp_port_put(port);
  255. kfree(adisc);
  256. }
  257. static int zfcp_fc_adisc(struct zfcp_port *port)
  258. {
  259. struct zfcp_els_adisc *adisc;
  260. struct zfcp_adapter *adapter = port->adapter;
  261. adisc = kzalloc(sizeof(struct zfcp_els_adisc), GFP_ATOMIC);
  262. if (!adisc)
  263. return -ENOMEM;
  264. adisc->els.req = &adisc->req;
  265. adisc->els.resp = &adisc->resp;
  266. sg_init_one(adisc->els.req, &adisc->ls_adisc,
  267. sizeof(struct zfcp_ls_adisc));
  268. sg_init_one(adisc->els.resp, &adisc->ls_adisc_acc,
  269. sizeof(struct zfcp_ls_adisc_acc));
  270. adisc->els.req_count = 1;
  271. adisc->els.resp_count = 1;
  272. adisc->els.adapter = adapter;
  273. adisc->els.port = port;
  274. adisc->els.d_id = port->d_id;
  275. adisc->els.handler = zfcp_fc_adisc_handler;
  276. adisc->els.handler_data = (unsigned long) adisc;
  277. adisc->els.ls_code = adisc->ls_adisc.code = ZFCP_LS_ADISC;
  278. /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports
  279. without FC-AL-2 capability, so we don't set it */
  280. adisc->ls_adisc.wwpn = fc_host_port_name(adapter->scsi_host);
  281. adisc->ls_adisc.wwnn = fc_host_node_name(adapter->scsi_host);
  282. adisc->ls_adisc.nport_id = fc_host_port_id(adapter->scsi_host);
  283. return zfcp_fsf_send_els(&adisc->els);
  284. }
  285. /**
  286. * zfcp_test_link - lightweight link test procedure
  287. * @port: port to be tested
  288. *
  289. * Test status of a link to a remote port using the ELS command ADISC.
  290. * If there is a problem with the remote port, error recovery steps
  291. * will be triggered.
  292. */
  293. void zfcp_test_link(struct zfcp_port *port)
  294. {
  295. int retval;
  296. zfcp_port_get(port);
  297. retval = zfcp_fc_adisc(port);
  298. if (retval == 0 || retval == -EBUSY)
  299. return;
  300. /* send of ADISC was not possible */
  301. zfcp_port_put(port);
  302. zfcp_erp_port_forced_reopen(port, 0, 65, NULL);
  303. }
  304. static int zfcp_scan_get_nameserver(struct zfcp_adapter *adapter)
  305. {
  306. int ret;
  307. if (!adapter->nameserver_port)
  308. return -EINTR;
  309. if (!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
  310. &adapter->nameserver_port->status)) {
  311. ret = zfcp_erp_port_reopen(adapter->nameserver_port, 0, 148,
  312. NULL);
  313. if (ret)
  314. return ret;
  315. zfcp_erp_wait(adapter);
  316. zfcp_port_put(adapter->nameserver_port);
  317. }
  318. return !atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
  319. &adapter->nameserver_port->status);
  320. }
  321. static void zfcp_gpn_ft_handler(unsigned long _done)
  322. {
  323. complete((struct completion *)_done);
  324. }
  325. static void zfcp_free_sg_env(struct zfcp_gpn_ft *gpn_ft)
  326. {
  327. struct scatterlist *sg = &gpn_ft->sg_req;
  328. kfree(sg_virt(sg)); /* free request buffer */
  329. zfcp_sg_free_table(gpn_ft->sg_resp, ZFCP_GPN_FT_BUFFERS);
  330. kfree(gpn_ft);
  331. }
  332. static struct zfcp_gpn_ft *zfcp_alloc_sg_env(void)
  333. {
  334. struct zfcp_gpn_ft *gpn_ft;
  335. struct ct_iu_gpn_ft_req *req;
  336. gpn_ft = kzalloc(sizeof(*gpn_ft), GFP_KERNEL);
  337. if (!gpn_ft)
  338. return NULL;
  339. req = kzalloc(sizeof(struct ct_iu_gpn_ft_req), GFP_KERNEL);
  340. if (!req) {
  341. kfree(gpn_ft);
  342. gpn_ft = NULL;
  343. goto out;
  344. }
  345. sg_init_one(&gpn_ft->sg_req, req, sizeof(*req));
  346. if (zfcp_sg_setup_table(gpn_ft->sg_resp, ZFCP_GPN_FT_BUFFERS)) {
  347. zfcp_free_sg_env(gpn_ft);
  348. gpn_ft = NULL;
  349. }
  350. out:
  351. return gpn_ft;
  352. }
  353. static int zfcp_scan_issue_gpn_ft(struct zfcp_gpn_ft *gpn_ft,
  354. struct zfcp_adapter *adapter)
  355. {
  356. struct zfcp_send_ct *ct = &gpn_ft->ct;
  357. struct ct_iu_gpn_ft_req *req = sg_virt(&gpn_ft->sg_req);
  358. struct completion done;
  359. int ret;
  360. /* prepare CT IU for GPN_FT */
  361. req->header.revision = ZFCP_CT_REVISION;
  362. req->header.gs_type = ZFCP_CT_DIRECTORY_SERVICE;
  363. req->header.gs_subtype = ZFCP_CT_NAME_SERVER;
  364. req->header.options = ZFCP_CT_SYNCHRONOUS;
  365. req->header.cmd_rsp_code = ZFCP_CT_GPN_FT;
  366. req->header.max_res_size = (sizeof(struct gpn_ft_resp_acc) *
  367. (ZFCP_GPN_FT_MAX_ENTRIES - 1)) >> 2;
  368. req->flags = 0;
  369. req->domain_id_scope = 0;
  370. req->area_id_scope = 0;
  371. req->fc4_type = ZFCP_CT_SCSI_FCP;
  372. /* prepare zfcp_send_ct */
  373. ct->port = adapter->nameserver_port;
  374. ct->handler = zfcp_gpn_ft_handler;
  375. ct->handler_data = (unsigned long)&done;
  376. ct->timeout = 10;
  377. ct->req = &gpn_ft->sg_req;
  378. ct->resp = gpn_ft->sg_resp;
  379. ct->req_count = 1;
  380. ct->resp_count = ZFCP_GPN_FT_BUFFERS;
  381. init_completion(&done);
  382. ret = zfcp_fsf_send_ct(ct, NULL, NULL);
  383. if (!ret)
  384. wait_for_completion(&done);
  385. return ret;
  386. }
  387. static void zfcp_validate_port(struct zfcp_port *port)
  388. {
  389. struct zfcp_adapter *adapter = port->adapter;
  390. atomic_clear_mask(ZFCP_STATUS_COMMON_NOESC, &port->status);
  391. if (port == adapter->nameserver_port)
  392. return;
  393. if ((port->supported_classes != 0) || (port->units != 0)) {
  394. zfcp_port_put(port);
  395. return;
  396. }
  397. zfcp_erp_port_shutdown(port, 0, 151, NULL);
  398. zfcp_erp_wait(adapter);
  399. zfcp_port_put(port);
  400. zfcp_port_dequeue(port);
  401. }
  402. static int zfcp_scan_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft)
  403. {
  404. struct zfcp_send_ct *ct = &gpn_ft->ct;
  405. struct scatterlist *sg = gpn_ft->sg_resp;
  406. struct ct_hdr *hdr = sg_virt(sg);
  407. struct gpn_ft_resp_acc *acc = sg_virt(sg);
  408. struct zfcp_adapter *adapter = ct->port->adapter;
  409. struct zfcp_port *port, *tmp;
  410. u32 d_id;
  411. int ret = 0, x;
  412. if (ct->status)
  413. return -EIO;
  414. if (hdr->cmd_rsp_code != ZFCP_CT_ACCEPT) {
  415. if (hdr->reason_code == ZFCP_CT_UNABLE_TO_PERFORM_CMD)
  416. return -EAGAIN; /* might be a temporary condition */
  417. return -EIO;
  418. }
  419. if (hdr->max_res_size)
  420. return -E2BIG;
  421. down(&zfcp_data.config_sema);
  422. /* first entry is the header */
  423. for (x = 1; x < ZFCP_GPN_FT_MAX_ENTRIES; x++) {
  424. if (x % (ZFCP_GPN_FT_ENTRIES + 1))
  425. acc++;
  426. else
  427. acc = sg_virt(++sg);
  428. d_id = acc->port_id[0] << 16 | acc->port_id[1] << 8 |
  429. acc->port_id[2];
  430. /* skip the adapter's port and known remote ports */
  431. if (acc->wwpn == fc_host_port_name(adapter->scsi_host) ||
  432. zfcp_get_port_by_did(adapter, d_id))
  433. continue;
  434. port = zfcp_port_enqueue(adapter, acc->wwpn,
  435. ZFCP_STATUS_PORT_DID_DID |
  436. ZFCP_STATUS_COMMON_NOESC, d_id);
  437. if (IS_ERR(port))
  438. ret = PTR_ERR(port);
  439. else
  440. zfcp_erp_port_reopen(port, 0, 149, NULL);
  441. if (acc->control & 0x80) /* last entry */
  442. break;
  443. }
  444. zfcp_erp_wait(adapter);
  445. list_for_each_entry_safe(port, tmp, &adapter->port_list_head, list)
  446. zfcp_validate_port(port);
  447. up(&zfcp_data.config_sema);
  448. return ret;
  449. }
  450. /**
  451. * zfcp_scan_ports - scan remote ports and attach new ports
  452. * @adapter: pointer to struct zfcp_adapter
  453. */
  454. int zfcp_scan_ports(struct zfcp_adapter *adapter)
  455. {
  456. int ret, i;
  457. struct zfcp_gpn_ft *gpn_ft;
  458. zfcp_erp_wait(adapter); /* wait until adapter is finished with ERP */
  459. if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT)
  460. return 0;
  461. ret = zfcp_scan_get_nameserver(adapter);
  462. if (ret)
  463. return ret;
  464. gpn_ft = zfcp_alloc_sg_env();
  465. if (!gpn_ft)
  466. return -ENOMEM;
  467. for (i = 0; i < 3; i++) {
  468. ret = zfcp_scan_issue_gpn_ft(gpn_ft, adapter);
  469. if (!ret) {
  470. ret = zfcp_scan_eval_gpn_ft(gpn_ft);
  471. if (ret == -EAGAIN)
  472. ssleep(1);
  473. else
  474. break;
  475. }
  476. }
  477. zfcp_free_sg_env(gpn_ft);
  478. return ret;
  479. }
  480. void _zfcp_scan_ports_later(struct work_struct *work)
  481. {
  482. zfcp_scan_ports(container_of(work, struct zfcp_adapter, scan_work));
  483. }