fc_disc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /*
  2. * Copyright(c) 2007 - 2008 Intel Corporation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. * Maintained at www.Open-FCoE.org
  18. */
  19. /*
  20. * Target Discovery
  21. *
  22. * This block discovers all FC-4 remote ports, including FCP initiators. It
  23. * also handles RSCN events and re-discovery if necessary.
  24. */
  25. /*
  26. * DISC LOCKING
  27. *
  28. * The disc mutex is can be locked when acquiring rport locks, but may not
  29. * be held when acquiring the lport lock. Refer to fc_lport.c for more
  30. * details.
  31. */
  32. #include <linux/timer.h>
  33. #include <linux/err.h>
  34. #include <asm/unaligned.h>
  35. #include <scsi/fc/fc_gs.h>
  36. #include <scsi/libfc.h>
  37. #define FC_DISC_RETRY_LIMIT 3 /* max retries */
  38. #define FC_DISC_RETRY_DELAY 500UL /* (msecs) delay */
  39. static void fc_disc_gpn_ft_req(struct fc_disc *);
  40. static void fc_disc_gpn_ft_resp(struct fc_seq *, struct fc_frame *, void *);
  41. static void fc_disc_done(struct fc_disc *, enum fc_disc_event);
  42. static void fc_disc_timeout(struct work_struct *);
  43. static void fc_disc_single(struct fc_disc *, struct fc_disc_port *);
  44. static void fc_disc_restart(struct fc_disc *);
  45. /**
  46. * fc_disc_stop_rports() - delete all the remote ports associated with the lport
  47. * @disc: The discovery job to stop rports on
  48. *
  49. * Locking Note: This function expects that the lport mutex is locked before
  50. * calling it.
  51. */
  52. void fc_disc_stop_rports(struct fc_disc *disc)
  53. {
  54. struct fc_lport *lport;
  55. struct fc_rport_priv *rdata, *next;
  56. lport = disc->lport;
  57. mutex_lock(&disc->disc_mutex);
  58. list_for_each_entry_safe(rdata, next, &disc->rports, peers)
  59. lport->tt.rport_logoff(rdata);
  60. mutex_unlock(&disc->disc_mutex);
  61. }
  62. /**
  63. * fc_disc_recv_rscn_req() - Handle Registered State Change Notification (RSCN)
  64. * @sp: Current sequence of the RSCN exchange
  65. * @fp: RSCN Frame
  66. * @lport: Fibre Channel host port instance
  67. *
  68. * Locking Note: This function expects that the disc_mutex is locked
  69. * before it is called.
  70. */
  71. static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
  72. struct fc_disc *disc)
  73. {
  74. struct fc_lport *lport;
  75. struct fc_rport_priv *rdata;
  76. struct fc_els_rscn *rp;
  77. struct fc_els_rscn_page *pp;
  78. struct fc_seq_els_data rjt_data;
  79. unsigned int len;
  80. int redisc = 0;
  81. enum fc_els_rscn_ev_qual ev_qual;
  82. enum fc_els_rscn_addr_fmt fmt;
  83. LIST_HEAD(disc_ports);
  84. struct fc_disc_port *dp, *next;
  85. lport = disc->lport;
  86. FC_DISC_DBG(disc, "Received an RSCN event\n");
  87. /* make sure the frame contains an RSCN message */
  88. rp = fc_frame_payload_get(fp, sizeof(*rp));
  89. if (!rp)
  90. goto reject;
  91. /* make sure the page length is as expected (4 bytes) */
  92. if (rp->rscn_page_len != sizeof(*pp))
  93. goto reject;
  94. /* get the RSCN payload length */
  95. len = ntohs(rp->rscn_plen);
  96. if (len < sizeof(*rp))
  97. goto reject;
  98. /* make sure the frame contains the expected payload */
  99. rp = fc_frame_payload_get(fp, len);
  100. if (!rp)
  101. goto reject;
  102. /* payload must be a multiple of the RSCN page size */
  103. len -= sizeof(*rp);
  104. if (len % sizeof(*pp))
  105. goto reject;
  106. for (pp = (void *)(rp + 1); len > 0; len -= sizeof(*pp), pp++) {
  107. ev_qual = pp->rscn_page_flags >> ELS_RSCN_EV_QUAL_BIT;
  108. ev_qual &= ELS_RSCN_EV_QUAL_MASK;
  109. fmt = pp->rscn_page_flags >> ELS_RSCN_ADDR_FMT_BIT;
  110. fmt &= ELS_RSCN_ADDR_FMT_MASK;
  111. /*
  112. * if we get an address format other than port
  113. * (area, domain, fabric), then do a full discovery
  114. */
  115. switch (fmt) {
  116. case ELS_ADDR_FMT_PORT:
  117. FC_DISC_DBG(disc, "Port address format for port "
  118. "(%6x)\n", ntoh24(pp->rscn_fid));
  119. dp = kzalloc(sizeof(*dp), GFP_KERNEL);
  120. if (!dp) {
  121. redisc = 1;
  122. break;
  123. }
  124. dp->lp = lport;
  125. dp->port_id = ntoh24(pp->rscn_fid);
  126. list_add_tail(&dp->peers, &disc_ports);
  127. break;
  128. case ELS_ADDR_FMT_AREA:
  129. case ELS_ADDR_FMT_DOM:
  130. case ELS_ADDR_FMT_FAB:
  131. default:
  132. FC_DISC_DBG(disc, "Address format is (%d)\n", fmt);
  133. redisc = 1;
  134. break;
  135. }
  136. }
  137. lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL);
  138. if (redisc) {
  139. FC_DISC_DBG(disc, "RSCN received: rediscovering\n");
  140. fc_disc_restart(disc);
  141. } else {
  142. FC_DISC_DBG(disc, "RSCN received: not rediscovering. "
  143. "redisc %d state %d in_prog %d\n",
  144. redisc, lport->state, disc->pending);
  145. list_for_each_entry_safe(dp, next, &disc_ports, peers) {
  146. list_del(&dp->peers);
  147. rdata = lport->tt.rport_lookup(lport, dp->port_id);
  148. if (rdata) {
  149. lport->tt.rport_logoff(rdata);
  150. }
  151. fc_disc_single(disc, dp);
  152. }
  153. }
  154. fc_frame_free(fp);
  155. return;
  156. reject:
  157. FC_DISC_DBG(disc, "Received a bad RSCN frame\n");
  158. rjt_data.fp = NULL;
  159. rjt_data.reason = ELS_RJT_LOGIC;
  160. rjt_data.explan = ELS_EXPL_NONE;
  161. lport->tt.seq_els_rsp_send(sp, ELS_LS_RJT, &rjt_data);
  162. fc_frame_free(fp);
  163. }
  164. /**
  165. * fc_disc_recv_req() - Handle incoming requests
  166. * @sp: Current sequence of the request exchange
  167. * @fp: The frame
  168. * @lport: The FC local port
  169. *
  170. * Locking Note: This function is called from the EM and will lock
  171. * the disc_mutex before calling the handler for the
  172. * request.
  173. */
  174. static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp,
  175. struct fc_lport *lport)
  176. {
  177. u8 op;
  178. struct fc_disc *disc = &lport->disc;
  179. op = fc_frame_payload_op(fp);
  180. switch (op) {
  181. case ELS_RSCN:
  182. mutex_lock(&disc->disc_mutex);
  183. fc_disc_recv_rscn_req(sp, fp, disc);
  184. mutex_unlock(&disc->disc_mutex);
  185. break;
  186. default:
  187. FC_DISC_DBG(disc, "Received an unsupported request, "
  188. "the opcode is (%x)\n", op);
  189. break;
  190. }
  191. }
  192. /**
  193. * fc_disc_restart() - Restart discovery
  194. * @lport: FC discovery context
  195. *
  196. * Locking Note: This function expects that the disc mutex
  197. * is already locked.
  198. */
  199. static void fc_disc_restart(struct fc_disc *disc)
  200. {
  201. if (!disc->disc_callback)
  202. return;
  203. FC_DISC_DBG(disc, "Restarting discovery\n");
  204. disc->requested = 1;
  205. if (disc->pending)
  206. return;
  207. /*
  208. * Advance disc_id. This is an arbitrary non-zero number that will
  209. * match the value in the fc_rport_priv after discovery for all
  210. * freshly-discovered remote ports. Avoid wrapping to zero.
  211. */
  212. disc->disc_id = (disc->disc_id + 2) | 1;
  213. disc->retry_count = 0;
  214. fc_disc_gpn_ft_req(disc);
  215. }
  216. /**
  217. * fc_disc_start() - Fibre Channel Target discovery
  218. * @lport: FC local port
  219. * @disc_callback: function to be called when discovery is complete
  220. */
  221. static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
  222. enum fc_disc_event),
  223. struct fc_lport *lport)
  224. {
  225. struct fc_disc *disc = &lport->disc;
  226. /*
  227. * At this point we may have a new disc job or an existing
  228. * one. Either way, let's lock when we make changes to it
  229. * and send the GPN_FT request.
  230. */
  231. mutex_lock(&disc->disc_mutex);
  232. disc->disc_callback = disc_callback;
  233. fc_disc_restart(disc);
  234. mutex_unlock(&disc->disc_mutex);
  235. }
  236. /**
  237. * fc_disc_done() - Discovery has been completed
  238. * @disc: FC discovery context
  239. * @event: discovery completion status
  240. *
  241. * Locking Note: This function expects that the disc mutex is locked before
  242. * it is called. The discovery callback is then made with the lock released,
  243. * and the lock is re-taken before returning from this function
  244. */
  245. static void fc_disc_done(struct fc_disc *disc, enum fc_disc_event event)
  246. {
  247. struct fc_lport *lport = disc->lport;
  248. struct fc_rport_priv *rdata;
  249. FC_DISC_DBG(disc, "Discovery complete\n");
  250. disc->pending = 0;
  251. if (disc->requested) {
  252. fc_disc_restart(disc);
  253. return;
  254. }
  255. /*
  256. * Go through all remote ports. If they were found in the latest
  257. * discovery, reverify or log them in. Otherwise, log them out.
  258. * Skip ports which were never discovered. These are the dNS port
  259. * and ports which were created by PLOGI.
  260. */
  261. list_for_each_entry(rdata, &disc->rports, peers) {
  262. if (!rdata->disc_id)
  263. continue;
  264. if (rdata->disc_id == disc->disc_id)
  265. lport->tt.rport_login(rdata);
  266. else
  267. lport->tt.rport_logoff(rdata);
  268. }
  269. mutex_unlock(&disc->disc_mutex);
  270. disc->disc_callback(lport, event);
  271. mutex_lock(&disc->disc_mutex);
  272. }
  273. /**
  274. * fc_disc_error() - Handle error on dNS request
  275. * @disc: FC discovery context
  276. * @fp: The frame pointer
  277. */
  278. static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp)
  279. {
  280. struct fc_lport *lport = disc->lport;
  281. unsigned long delay = 0;
  282. FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n",
  283. PTR_ERR(fp), disc->retry_count,
  284. FC_DISC_RETRY_LIMIT);
  285. if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) {
  286. /*
  287. * Memory allocation failure, or the exchange timed out,
  288. * retry after delay.
  289. */
  290. if (disc->retry_count < FC_DISC_RETRY_LIMIT) {
  291. /* go ahead and retry */
  292. if (!fp)
  293. delay = msecs_to_jiffies(FC_DISC_RETRY_DELAY);
  294. else {
  295. delay = msecs_to_jiffies(lport->e_d_tov);
  296. /* timeout faster first time */
  297. if (!disc->retry_count)
  298. delay /= 4;
  299. }
  300. disc->retry_count++;
  301. schedule_delayed_work(&disc->disc_work, delay);
  302. } else
  303. fc_disc_done(disc, DISC_EV_FAILED);
  304. }
  305. }
  306. /**
  307. * fc_disc_gpn_ft_req() - Send Get Port Names by FC-4 type (GPN_FT) request
  308. * @lport: FC discovery context
  309. *
  310. * Locking Note: This function expects that the disc_mutex is locked
  311. * before it is called.
  312. */
  313. static void fc_disc_gpn_ft_req(struct fc_disc *disc)
  314. {
  315. struct fc_frame *fp;
  316. struct fc_lport *lport = disc->lport;
  317. WARN_ON(!fc_lport_test_ready(lport));
  318. disc->pending = 1;
  319. disc->requested = 0;
  320. disc->buf_len = 0;
  321. disc->seq_count = 0;
  322. fp = fc_frame_alloc(lport,
  323. sizeof(struct fc_ct_hdr) +
  324. sizeof(struct fc_ns_gid_ft));
  325. if (!fp)
  326. goto err;
  327. if (lport->tt.elsct_send(lport, 0, fp,
  328. FC_NS_GPN_FT,
  329. fc_disc_gpn_ft_resp,
  330. disc, lport->e_d_tov))
  331. return;
  332. err:
  333. fc_disc_error(disc, fp);
  334. }
  335. /**
  336. * fc_disc_gpn_ft_parse() - Parse the body of the dNS GPN_FT response.
  337. * @lport: Fibre Channel host port instance
  338. * @buf: GPN_FT response buffer
  339. * @len: size of response buffer
  340. *
  341. * Goes through the list of IDs and names resulting from a request.
  342. */
  343. static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
  344. {
  345. struct fc_lport *lport;
  346. struct fc_gpn_ft_resp *np;
  347. char *bp;
  348. size_t plen;
  349. size_t tlen;
  350. int error = 0;
  351. struct fc_rport_identifiers ids;
  352. struct fc_rport_priv *rdata;
  353. lport = disc->lport;
  354. disc->seq_count++;
  355. /*
  356. * Handle partial name record left over from previous call.
  357. */
  358. bp = buf;
  359. plen = len;
  360. np = (struct fc_gpn_ft_resp *)bp;
  361. tlen = disc->buf_len;
  362. disc->buf_len = 0;
  363. if (tlen) {
  364. WARN_ON(tlen >= sizeof(*np));
  365. plen = sizeof(*np) - tlen;
  366. WARN_ON(plen <= 0);
  367. WARN_ON(plen >= sizeof(*np));
  368. if (plen > len)
  369. plen = len;
  370. np = &disc->partial_buf;
  371. memcpy((char *)np + tlen, bp, plen);
  372. /*
  373. * Set bp so that the loop below will advance it to the
  374. * first valid full name element.
  375. */
  376. bp -= tlen;
  377. len += tlen;
  378. plen += tlen;
  379. disc->buf_len = (unsigned char) plen;
  380. if (plen == sizeof(*np))
  381. disc->buf_len = 0;
  382. }
  383. /*
  384. * Handle full name records, including the one filled from above.
  385. * Normally, np == bp and plen == len, but from the partial case above,
  386. * bp, len describe the overall buffer, and np, plen describe the
  387. * partial buffer, which if would usually be full now.
  388. * After the first time through the loop, things return to "normal".
  389. */
  390. while (plen >= sizeof(*np)) {
  391. ids.port_id = ntoh24(np->fp_fid);
  392. ids.port_name = ntohll(np->fp_wwpn);
  393. if (ids.port_id != fc_host_port_id(lport->host) &&
  394. ids.port_name != lport->wwpn) {
  395. rdata = lport->tt.rport_create(lport, ids.port_id);
  396. if (rdata) {
  397. rdata->ids.port_name = ids.port_name;
  398. rdata->disc_id = disc->disc_id;
  399. } else {
  400. printk(KERN_WARNING "libfc: Failed to allocate "
  401. "memory for the newly discovered port "
  402. "(%6x)\n", ids.port_id);
  403. error = -ENOMEM;
  404. }
  405. }
  406. if (np->fp_flags & FC_NS_FID_LAST) {
  407. fc_disc_done(disc, DISC_EV_SUCCESS);
  408. len = 0;
  409. break;
  410. }
  411. len -= sizeof(*np);
  412. bp += sizeof(*np);
  413. np = (struct fc_gpn_ft_resp *)bp;
  414. plen = len;
  415. }
  416. /*
  417. * Save any partial record at the end of the buffer for next time.
  418. */
  419. if (error == 0 && len > 0 && len < sizeof(*np)) {
  420. if (np != &disc->partial_buf) {
  421. FC_DISC_DBG(disc, "Partial buffer remains "
  422. "for discovery\n");
  423. memcpy(&disc->partial_buf, np, len);
  424. }
  425. disc->buf_len = (unsigned char) len;
  426. }
  427. return error;
  428. }
  429. /**
  430. * fc_disc_timeout() - Retry handler for the disc component
  431. * @work: Structure holding disc obj that needs retry discovery
  432. *
  433. * Handle retry of memory allocation for remote ports.
  434. */
  435. static void fc_disc_timeout(struct work_struct *work)
  436. {
  437. struct fc_disc *disc = container_of(work,
  438. struct fc_disc,
  439. disc_work.work);
  440. mutex_lock(&disc->disc_mutex);
  441. fc_disc_gpn_ft_req(disc);
  442. mutex_unlock(&disc->disc_mutex);
  443. }
  444. /**
  445. * fc_disc_gpn_ft_resp() - Handle a response frame from Get Port Names (GPN_FT)
  446. * @sp: Current sequence of GPN_FT exchange
  447. * @fp: response frame
  448. * @lp_arg: Fibre Channel host port instance
  449. *
  450. * Locking Note: This function is called without disc mutex held, and
  451. * should do all its processing with the mutex held
  452. */
  453. static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
  454. void *disc_arg)
  455. {
  456. struct fc_disc *disc = disc_arg;
  457. struct fc_ct_hdr *cp;
  458. struct fc_frame_header *fh;
  459. enum fc_disc_event event = DISC_EV_NONE;
  460. unsigned int seq_cnt;
  461. unsigned int len;
  462. int error = 0;
  463. mutex_lock(&disc->disc_mutex);
  464. FC_DISC_DBG(disc, "Received a GPN_FT response\n");
  465. if (IS_ERR(fp)) {
  466. fc_disc_error(disc, fp);
  467. mutex_unlock(&disc->disc_mutex);
  468. return;
  469. }
  470. WARN_ON(!fc_frame_is_linear(fp)); /* buffer must be contiguous */
  471. fh = fc_frame_header_get(fp);
  472. len = fr_len(fp) - sizeof(*fh);
  473. seq_cnt = ntohs(fh->fh_seq_cnt);
  474. if (fr_sof(fp) == FC_SOF_I3 && seq_cnt == 0 && disc->seq_count == 0) {
  475. cp = fc_frame_payload_get(fp, sizeof(*cp));
  476. if (!cp) {
  477. FC_DISC_DBG(disc, "GPN_FT response too short, len %d\n",
  478. fr_len(fp));
  479. event = DISC_EV_FAILED;
  480. } else if (ntohs(cp->ct_cmd) == FC_FS_ACC) {
  481. /* Accepted, parse the response. */
  482. len -= sizeof(*cp);
  483. error = fc_disc_gpn_ft_parse(disc, cp + 1, len);
  484. } else if (ntohs(cp->ct_cmd) == FC_FS_RJT) {
  485. FC_DISC_DBG(disc, "GPN_FT rejected reason %x exp %x "
  486. "(check zoning)\n", cp->ct_reason,
  487. cp->ct_explan);
  488. event = DISC_EV_FAILED;
  489. if (cp->ct_reason == FC_FS_RJT_UNABL &&
  490. cp->ct_explan == FC_FS_EXP_FTNR)
  491. event = DISC_EV_SUCCESS;
  492. } else {
  493. FC_DISC_DBG(disc, "GPN_FT unexpected response code "
  494. "%x\n", ntohs(cp->ct_cmd));
  495. event = DISC_EV_FAILED;
  496. }
  497. } else if (fr_sof(fp) == FC_SOF_N3 && seq_cnt == disc->seq_count) {
  498. error = fc_disc_gpn_ft_parse(disc, fh + 1, len);
  499. } else {
  500. FC_DISC_DBG(disc, "GPN_FT unexpected frame - out of sequence? "
  501. "seq_cnt %x expected %x sof %x eof %x\n",
  502. seq_cnt, disc->seq_count, fr_sof(fp), fr_eof(fp));
  503. event = DISC_EV_FAILED;
  504. }
  505. if (error)
  506. fc_disc_error(disc, fp);
  507. else if (event != DISC_EV_NONE)
  508. fc_disc_done(disc, event);
  509. fc_frame_free(fp);
  510. mutex_unlock(&disc->disc_mutex);
  511. }
  512. /**
  513. * fc_disc_single() - Discover the directory information for a single target
  514. * @lport: FC local port
  515. * @dp: The port to rediscover
  516. *
  517. * Locking Note: This function expects that the disc_mutex is locked
  518. * before it is called.
  519. */
  520. static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp)
  521. {
  522. struct fc_lport *lport;
  523. struct fc_rport_priv *rdata;
  524. lport = disc->lport;
  525. if (dp->port_id == fc_host_port_id(lport->host))
  526. goto out;
  527. rdata = lport->tt.rport_create(lport, dp->port_id);
  528. if (rdata) {
  529. rdata->disc_id = disc->disc_id;
  530. kfree(dp);
  531. lport->tt.rport_login(rdata);
  532. }
  533. return;
  534. out:
  535. kfree(dp);
  536. }
  537. /**
  538. * fc_disc_stop() - Stop discovery for a given lport
  539. * @lport: The lport that discovery should stop for
  540. */
  541. void fc_disc_stop(struct fc_lport *lport)
  542. {
  543. struct fc_disc *disc = &lport->disc;
  544. if (disc) {
  545. cancel_delayed_work_sync(&disc->disc_work);
  546. fc_disc_stop_rports(disc);
  547. }
  548. }
  549. /**
  550. * fc_disc_stop_final() - Stop discovery for a given lport
  551. * @lport: The lport that discovery should stop for
  552. *
  553. * This function will block until discovery has been
  554. * completely stopped and all rports have been deleted.
  555. */
  556. void fc_disc_stop_final(struct fc_lport *lport)
  557. {
  558. fc_disc_stop(lport);
  559. lport->tt.rport_flush_queue();
  560. }
  561. /**
  562. * fc_disc_init() - Initialize the discovery block
  563. * @lport: FC local port
  564. */
  565. int fc_disc_init(struct fc_lport *lport)
  566. {
  567. struct fc_disc *disc;
  568. if (!lport->tt.disc_start)
  569. lport->tt.disc_start = fc_disc_start;
  570. if (!lport->tt.disc_stop)
  571. lport->tt.disc_stop = fc_disc_stop;
  572. if (!lport->tt.disc_stop_final)
  573. lport->tt.disc_stop_final = fc_disc_stop_final;
  574. if (!lport->tt.disc_recv_req)
  575. lport->tt.disc_recv_req = fc_disc_recv_req;
  576. disc = &lport->disc;
  577. INIT_DELAYED_WORK(&disc->disc_work, fc_disc_timeout);
  578. mutex_init(&disc->disc_mutex);
  579. INIT_LIST_HEAD(&disc->rports);
  580. disc->lport = lport;
  581. return 0;
  582. }
  583. EXPORT_SYMBOL(fc_disc_init);