bfa_fcs.c 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714
  1. /*
  2. * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
  3. * Copyright (c) 2014- QLogic Corporation.
  4. * All rights reserved
  5. * www.qlogic.com
  6. *
  7. * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License (GPL) Version 2 as
  11. * published by the Free Software Foundation
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. */
  18. /*
  19. * bfa_fcs.c BFA FCS main
  20. */
  21. #include "bfad_drv.h"
  22. #include "bfad_im.h"
  23. #include "bfa_fcs.h"
  24. #include "bfa_fcbuild.h"
  25. BFA_TRC_FILE(FCS, FCS);
  26. /*
  27. * FCS sub-modules
  28. */
  29. struct bfa_fcs_mod_s {
  30. void (*attach) (struct bfa_fcs_s *fcs);
  31. void (*modinit) (struct bfa_fcs_s *fcs);
  32. void (*modexit) (struct bfa_fcs_s *fcs);
  33. };
  34. #define BFA_FCS_MODULE(_mod) { _mod ## _modinit, _mod ## _modexit }
  35. static struct bfa_fcs_mod_s fcs_modules[] = {
  36. { bfa_fcs_port_attach, NULL, NULL },
  37. { bfa_fcs_uf_attach, NULL, NULL },
  38. { bfa_fcs_fabric_attach, bfa_fcs_fabric_modinit,
  39. bfa_fcs_fabric_modexit },
  40. };
  41. /*
  42. * fcs_api BFA FCS API
  43. */
  44. static void
  45. bfa_fcs_exit_comp(void *fcs_cbarg)
  46. {
  47. struct bfa_fcs_s *fcs = fcs_cbarg;
  48. struct bfad_s *bfad = fcs->bfad;
  49. complete(&bfad->comp);
  50. }
  51. /*
  52. * fcs_api BFA FCS API
  53. */
  54. /*
  55. * fcs attach -- called once to initialize data structures at driver attach time
  56. */
  57. void
  58. bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad,
  59. bfa_boolean_t min_cfg)
  60. {
  61. int i;
  62. struct bfa_fcs_mod_s *mod;
  63. fcs->bfa = bfa;
  64. fcs->bfad = bfad;
  65. fcs->min_cfg = min_cfg;
  66. fcs->num_rport_logins = 0;
  67. bfa->fcs = BFA_TRUE;
  68. fcbuild_init();
  69. for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
  70. mod = &fcs_modules[i];
  71. if (mod->attach)
  72. mod->attach(fcs);
  73. }
  74. }
  75. /*
  76. * fcs initialization, called once after bfa initialization is complete
  77. */
  78. void
  79. bfa_fcs_init(struct bfa_fcs_s *fcs)
  80. {
  81. int i;
  82. struct bfa_fcs_mod_s *mod;
  83. for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
  84. mod = &fcs_modules[i];
  85. if (mod->modinit)
  86. mod->modinit(fcs);
  87. }
  88. }
  89. /*
  90. * FCS update cfg - reset the pwwn/nwwn of fabric base logical port
  91. * with values learned during bfa_init firmware GETATTR REQ.
  92. */
  93. void
  94. bfa_fcs_update_cfg(struct bfa_fcs_s *fcs)
  95. {
  96. struct bfa_fcs_fabric_s *fabric = &fcs->fabric;
  97. struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg;
  98. struct bfa_ioc_s *ioc = &fabric->fcs->bfa->ioc;
  99. port_cfg->nwwn = ioc->attr->nwwn;
  100. port_cfg->pwwn = ioc->attr->pwwn;
  101. }
  102. /*
  103. * Stop FCS operations.
  104. */
  105. void
  106. bfa_fcs_stop(struct bfa_fcs_s *fcs)
  107. {
  108. bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
  109. bfa_wc_up(&fcs->wc);
  110. bfa_fcs_fabric_modstop(fcs);
  111. bfa_wc_wait(&fcs->wc);
  112. }
  113. /*
  114. * fcs pbc vport initialization
  115. */
  116. void
  117. bfa_fcs_pbc_vport_init(struct bfa_fcs_s *fcs)
  118. {
  119. int i, npbc_vports;
  120. struct bfi_pbc_vport_s pbc_vports[BFI_PBC_MAX_VPORTS];
  121. /* Initialize pbc vports */
  122. if (!fcs->min_cfg) {
  123. npbc_vports =
  124. bfa_iocfc_get_pbc_vports(fcs->bfa, pbc_vports);
  125. for (i = 0; i < npbc_vports; i++)
  126. bfa_fcb_pbc_vport_create(fcs->bfa->bfad, pbc_vports[i]);
  127. }
  128. }
  129. /*
  130. * brief
  131. * FCS driver details initialization.
  132. *
  133. * param[in] fcs FCS instance
  134. * param[in] driver_info Driver Details
  135. *
  136. * return None
  137. */
  138. void
  139. bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
  140. struct bfa_fcs_driver_info_s *driver_info)
  141. {
  142. fcs->driver_info = *driver_info;
  143. bfa_fcs_fabric_psymb_init(&fcs->fabric);
  144. bfa_fcs_fabric_nsymb_init(&fcs->fabric);
  145. }
  146. /*
  147. * brief
  148. * FCS instance cleanup and exit.
  149. *
  150. * param[in] fcs FCS instance
  151. * return None
  152. */
  153. void
  154. bfa_fcs_exit(struct bfa_fcs_s *fcs)
  155. {
  156. struct bfa_fcs_mod_s *mod;
  157. int nmods, i;
  158. bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
  159. nmods = ARRAY_SIZE(fcs_modules);
  160. for (i = 0; i < nmods; i++) {
  161. mod = &fcs_modules[i];
  162. if (mod->modexit) {
  163. bfa_wc_up(&fcs->wc);
  164. mod->modexit(fcs);
  165. }
  166. }
  167. bfa_wc_wait(&fcs->wc);
  168. }
  169. /*
  170. * Fabric module implementation.
  171. */
  172. #define BFA_FCS_FABRIC_RETRY_DELAY (2000) /* Milliseconds */
  173. #define BFA_FCS_FABRIC_CLEANUP_DELAY (10000) /* Milliseconds */
  174. #define bfa_fcs_fabric_set_opertype(__fabric) do { \
  175. if (bfa_fcport_get_topology((__fabric)->fcs->bfa) \
  176. == BFA_PORT_TOPOLOGY_P2P) { \
  177. if (fabric->fab_type == BFA_FCS_FABRIC_SWITCHED) \
  178. (__fabric)->oper_type = BFA_PORT_TYPE_NPORT; \
  179. else \
  180. (__fabric)->oper_type = BFA_PORT_TYPE_P2P; \
  181. } else \
  182. (__fabric)->oper_type = BFA_PORT_TYPE_NLPORT; \
  183. } while (0)
  184. /*
  185. * forward declarations
  186. */
  187. static void bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric);
  188. static void bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric);
  189. static void bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric);
  190. static void bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric);
  191. static void bfa_fcs_fabric_delay(void *cbarg);
  192. static void bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric);
  193. static void bfa_fcs_fabric_delete_comp(void *cbarg);
  194. static void bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s *fabric);
  195. static void bfa_fcs_fabric_stop_comp(void *cbarg);
  196. static void bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric,
  197. struct fchs_s *fchs, u16 len);
  198. static void bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
  199. struct fchs_s *fchs, u16 len);
  200. static void bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric);
  201. static void bfa_fcs_fabric_flogiacc_comp(void *fcsarg,
  202. struct bfa_fcxp_s *fcxp, void *cbarg,
  203. bfa_status_t status,
  204. u32 rsp_len,
  205. u32 resid_len,
  206. struct fchs_s *rspfchs);
  207. static void bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
  208. enum bfa_fcs_fabric_event event);
  209. static void bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
  210. enum bfa_fcs_fabric_event event);
  211. static void bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
  212. enum bfa_fcs_fabric_event event);
  213. static void bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
  214. enum bfa_fcs_fabric_event event);
  215. static void bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
  216. enum bfa_fcs_fabric_event event);
  217. static void bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
  218. enum bfa_fcs_fabric_event event);
  219. static void bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
  220. enum bfa_fcs_fabric_event event);
  221. static void bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
  222. enum bfa_fcs_fabric_event event);
  223. static void bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
  224. enum bfa_fcs_fabric_event event);
  225. static void bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
  226. enum bfa_fcs_fabric_event event);
  227. static void bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
  228. enum bfa_fcs_fabric_event event);
  229. static void bfa_fcs_fabric_sm_stopping(struct bfa_fcs_fabric_s *fabric,
  230. enum bfa_fcs_fabric_event event);
  231. static void bfa_fcs_fabric_sm_cleanup(struct bfa_fcs_fabric_s *fabric,
  232. enum bfa_fcs_fabric_event event);
  233. /*
  234. * Beginning state before fabric creation.
  235. */
  236. static void
  237. bfa_fcs_fabric_sm_uninit(struct bfa_fcs_fabric_s *fabric,
  238. enum bfa_fcs_fabric_event event)
  239. {
  240. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  241. bfa_trc(fabric->fcs, event);
  242. switch (event) {
  243. case BFA_FCS_FABRIC_SM_CREATE:
  244. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
  245. bfa_fcs_fabric_init(fabric);
  246. bfa_fcs_lport_init(&fabric->bport, &fabric->bport.port_cfg);
  247. break;
  248. case BFA_FCS_FABRIC_SM_LINK_UP:
  249. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  250. break;
  251. default:
  252. bfa_sm_fault(fabric->fcs, event);
  253. }
  254. }
  255. /*
  256. * Beginning state before fabric creation.
  257. */
  258. static void
  259. bfa_fcs_fabric_sm_created(struct bfa_fcs_fabric_s *fabric,
  260. enum bfa_fcs_fabric_event event)
  261. {
  262. struct bfa_s *bfa = fabric->fcs->bfa;
  263. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  264. bfa_trc(fabric->fcs, event);
  265. switch (event) {
  266. case BFA_FCS_FABRIC_SM_START:
  267. if (!bfa_fcport_is_linkup(fabric->fcs->bfa)) {
  268. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
  269. break;
  270. }
  271. if (bfa_fcport_get_topology(bfa) ==
  272. BFA_PORT_TOPOLOGY_LOOP) {
  273. fabric->fab_type = BFA_FCS_FABRIC_LOOP;
  274. fabric->bport.pid = bfa_fcport_get_myalpa(bfa);
  275. fabric->bport.pid = bfa_hton3b(fabric->bport.pid);
  276. bfa_sm_set_state(fabric,
  277. bfa_fcs_fabric_sm_online);
  278. bfa_fcs_fabric_set_opertype(fabric);
  279. bfa_fcs_lport_online(&fabric->bport);
  280. } else {
  281. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
  282. bfa_fcs_fabric_login(fabric);
  283. }
  284. break;
  285. case BFA_FCS_FABRIC_SM_LINK_UP:
  286. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  287. break;
  288. case BFA_FCS_FABRIC_SM_DELETE:
  289. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
  290. bfa_fcs_fabric_delete(fabric);
  291. break;
  292. default:
  293. bfa_sm_fault(fabric->fcs, event);
  294. }
  295. }
  296. /*
  297. * Link is down, awaiting LINK UP event from port. This is also the
  298. * first state at fabric creation.
  299. */
  300. static void
  301. bfa_fcs_fabric_sm_linkdown(struct bfa_fcs_fabric_s *fabric,
  302. enum bfa_fcs_fabric_event event)
  303. {
  304. struct bfa_s *bfa = fabric->fcs->bfa;
  305. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  306. bfa_trc(fabric->fcs, event);
  307. switch (event) {
  308. case BFA_FCS_FABRIC_SM_LINK_UP:
  309. if (bfa_fcport_get_topology(bfa) != BFA_PORT_TOPOLOGY_LOOP) {
  310. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
  311. bfa_fcs_fabric_login(fabric);
  312. break;
  313. }
  314. fabric->fab_type = BFA_FCS_FABRIC_LOOP;
  315. fabric->bport.pid = bfa_fcport_get_myalpa(bfa);
  316. fabric->bport.pid = bfa_hton3b(fabric->bport.pid);
  317. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
  318. bfa_fcs_fabric_set_opertype(fabric);
  319. bfa_fcs_lport_online(&fabric->bport);
  320. break;
  321. case BFA_FCS_FABRIC_SM_RETRY_OP:
  322. case BFA_FCS_FABRIC_SM_LOOPBACK:
  323. break;
  324. case BFA_FCS_FABRIC_SM_DELETE:
  325. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
  326. bfa_fcs_fabric_delete(fabric);
  327. break;
  328. case BFA_FCS_FABRIC_SM_STOP:
  329. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_cleanup);
  330. bfa_fcs_fabric_stop(fabric);
  331. break;
  332. default:
  333. bfa_sm_fault(fabric->fcs, event);
  334. }
  335. }
  336. /*
  337. * FLOGI is in progress, awaiting FLOGI reply.
  338. */
  339. static void
  340. bfa_fcs_fabric_sm_flogi(struct bfa_fcs_fabric_s *fabric,
  341. enum bfa_fcs_fabric_event event)
  342. {
  343. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  344. bfa_trc(fabric->fcs, event);
  345. switch (event) {
  346. case BFA_FCS_FABRIC_SM_CONT_OP:
  347. bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
  348. fabric->bb_credit);
  349. fabric->fab_type = BFA_FCS_FABRIC_SWITCHED;
  350. if (fabric->auth_reqd && fabric->is_auth) {
  351. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth);
  352. bfa_trc(fabric->fcs, event);
  353. } else {
  354. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
  355. bfa_fcs_fabric_notify_online(fabric);
  356. }
  357. break;
  358. case BFA_FCS_FABRIC_SM_RETRY_OP:
  359. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi_retry);
  360. bfa_timer_start(fabric->fcs->bfa, &fabric->delay_timer,
  361. bfa_fcs_fabric_delay, fabric,
  362. BFA_FCS_FABRIC_RETRY_DELAY);
  363. break;
  364. case BFA_FCS_FABRIC_SM_LOOPBACK:
  365. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_loopback);
  366. bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
  367. bfa_fcs_fabric_set_opertype(fabric);
  368. break;
  369. case BFA_FCS_FABRIC_SM_NO_FABRIC:
  370. fabric->fab_type = BFA_FCS_FABRIC_N2N;
  371. bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
  372. fabric->bb_credit);
  373. bfa_fcs_fabric_notify_online(fabric);
  374. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_nofabric);
  375. break;
  376. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  377. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
  378. bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
  379. break;
  380. case BFA_FCS_FABRIC_SM_DELETE:
  381. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
  382. bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
  383. bfa_fcs_fabric_delete(fabric);
  384. break;
  385. default:
  386. bfa_sm_fault(fabric->fcs, event);
  387. }
  388. }
  389. static void
  390. bfa_fcs_fabric_sm_flogi_retry(struct bfa_fcs_fabric_s *fabric,
  391. enum bfa_fcs_fabric_event event)
  392. {
  393. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  394. bfa_trc(fabric->fcs, event);
  395. switch (event) {
  396. case BFA_FCS_FABRIC_SM_DELAYED:
  397. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_flogi);
  398. bfa_fcs_fabric_login(fabric);
  399. break;
  400. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  401. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
  402. bfa_timer_stop(&fabric->delay_timer);
  403. break;
  404. case BFA_FCS_FABRIC_SM_DELETE:
  405. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
  406. bfa_timer_stop(&fabric->delay_timer);
  407. bfa_fcs_fabric_delete(fabric);
  408. break;
  409. default:
  410. bfa_sm_fault(fabric->fcs, event);
  411. }
  412. }
  413. /*
  414. * Authentication is in progress, awaiting authentication results.
  415. */
  416. static void
  417. bfa_fcs_fabric_sm_auth(struct bfa_fcs_fabric_s *fabric,
  418. enum bfa_fcs_fabric_event event)
  419. {
  420. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  421. bfa_trc(fabric->fcs, event);
  422. switch (event) {
  423. case BFA_FCS_FABRIC_SM_AUTH_FAILED:
  424. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
  425. bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
  426. break;
  427. case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
  428. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_online);
  429. bfa_fcs_fabric_notify_online(fabric);
  430. break;
  431. case BFA_FCS_FABRIC_SM_PERF_EVFP:
  432. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp);
  433. break;
  434. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  435. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
  436. bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
  437. break;
  438. case BFA_FCS_FABRIC_SM_DELETE:
  439. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
  440. bfa_fcs_fabric_delete(fabric);
  441. break;
  442. default:
  443. bfa_sm_fault(fabric->fcs, event);
  444. }
  445. }
  446. /*
  447. * Authentication failed
  448. */
  449. void
  450. bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
  451. enum bfa_fcs_fabric_event event)
  452. {
  453. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  454. bfa_trc(fabric->fcs, event);
  455. switch (event) {
  456. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  457. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
  458. bfa_fcs_fabric_notify_offline(fabric);
  459. break;
  460. case BFA_FCS_FABRIC_SM_DELETE:
  461. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
  462. bfa_fcs_fabric_delete(fabric);
  463. break;
  464. default:
  465. bfa_sm_fault(fabric->fcs, event);
  466. }
  467. }
  468. /*
  469. * Port is in loopback mode.
  470. */
  471. void
  472. bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
  473. enum bfa_fcs_fabric_event event)
  474. {
  475. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  476. bfa_trc(fabric->fcs, event);
  477. switch (event) {
  478. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  479. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
  480. bfa_fcs_fabric_notify_offline(fabric);
  481. break;
  482. case BFA_FCS_FABRIC_SM_DELETE:
  483. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
  484. bfa_fcs_fabric_delete(fabric);
  485. break;
  486. default:
  487. bfa_sm_fault(fabric->fcs, event);
  488. }
  489. }
  490. /*
  491. * There is no attached fabric - private loop or NPort-to-NPort topology.
  492. */
  493. static void
  494. bfa_fcs_fabric_sm_nofabric(struct bfa_fcs_fabric_s *fabric,
  495. enum bfa_fcs_fabric_event event)
  496. {
  497. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  498. bfa_trc(fabric->fcs, event);
  499. switch (event) {
  500. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  501. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
  502. bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
  503. bfa_fcs_fabric_notify_offline(fabric);
  504. break;
  505. case BFA_FCS_FABRIC_SM_DELETE:
  506. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
  507. bfa_fcs_fabric_delete(fabric);
  508. break;
  509. case BFA_FCS_FABRIC_SM_NO_FABRIC:
  510. bfa_trc(fabric->fcs, fabric->bb_credit);
  511. bfa_fcport_set_tx_bbcredit(fabric->fcs->bfa,
  512. fabric->bb_credit);
  513. break;
  514. case BFA_FCS_FABRIC_SM_RETRY_OP:
  515. break;
  516. default:
  517. bfa_sm_fault(fabric->fcs, event);
  518. }
  519. }
  520. /*
  521. * Fabric is online - normal operating state.
  522. */
  523. void
  524. bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
  525. enum bfa_fcs_fabric_event event)
  526. {
  527. struct bfa_s *bfa = fabric->fcs->bfa;
  528. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  529. bfa_trc(fabric->fcs, event);
  530. switch (event) {
  531. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  532. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_linkdown);
  533. if (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP) {
  534. bfa_fcs_lport_offline(&fabric->bport);
  535. } else {
  536. bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
  537. bfa_fcs_fabric_notify_offline(fabric);
  538. }
  539. break;
  540. case BFA_FCS_FABRIC_SM_DELETE:
  541. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_deleting);
  542. bfa_fcs_fabric_delete(fabric);
  543. break;
  544. case BFA_FCS_FABRIC_SM_STOP:
  545. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_stopping);
  546. bfa_fcs_fabric_stop(fabric);
  547. break;
  548. case BFA_FCS_FABRIC_SM_AUTH_FAILED:
  549. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_auth_failed);
  550. bfa_sm_send_event(fabric->lps, BFA_LPS_SM_OFFLINE);
  551. break;
  552. case BFA_FCS_FABRIC_SM_AUTH_SUCCESS:
  553. break;
  554. default:
  555. bfa_sm_fault(fabric->fcs, event);
  556. }
  557. }
  558. /*
  559. * Exchanging virtual fabric parameters.
  560. */
  561. static void
  562. bfa_fcs_fabric_sm_evfp(struct bfa_fcs_fabric_s *fabric,
  563. enum bfa_fcs_fabric_event event)
  564. {
  565. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  566. bfa_trc(fabric->fcs, event);
  567. switch (event) {
  568. case BFA_FCS_FABRIC_SM_CONT_OP:
  569. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_evfp_done);
  570. break;
  571. case BFA_FCS_FABRIC_SM_ISOLATE:
  572. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_isolated);
  573. break;
  574. default:
  575. bfa_sm_fault(fabric->fcs, event);
  576. }
  577. }
  578. /*
  579. * EVFP exchange complete and VFT tagging is enabled.
  580. */
  581. static void
  582. bfa_fcs_fabric_sm_evfp_done(struct bfa_fcs_fabric_s *fabric,
  583. enum bfa_fcs_fabric_event event)
  584. {
  585. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  586. bfa_trc(fabric->fcs, event);
  587. }
  588. /*
  589. * Port is isolated after EVFP exchange due to VF_ID mismatch (N and F).
  590. */
  591. static void
  592. bfa_fcs_fabric_sm_isolated(struct bfa_fcs_fabric_s *fabric,
  593. enum bfa_fcs_fabric_event event)
  594. {
  595. struct bfad_s *bfad = (struct bfad_s *)fabric->fcs->bfad;
  596. char pwwn_ptr[BFA_STRING_32];
  597. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  598. bfa_trc(fabric->fcs, event);
  599. wwn2str(pwwn_ptr, fabric->bport.port_cfg.pwwn);
  600. BFA_LOG(KERN_INFO, bfad, bfa_log_level,
  601. "Port is isolated due to VF_ID mismatch. "
  602. "PWWN: %s Port VF_ID: %04x switch port VF_ID: %04x.",
  603. pwwn_ptr, fabric->fcs->port_vfid,
  604. fabric->event_arg.swp_vfid);
  605. }
  606. /*
  607. * Fabric is being deleted, awaiting vport delete completions.
  608. */
  609. static void
  610. bfa_fcs_fabric_sm_deleting(struct bfa_fcs_fabric_s *fabric,
  611. enum bfa_fcs_fabric_event event)
  612. {
  613. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  614. bfa_trc(fabric->fcs, event);
  615. switch (event) {
  616. case BFA_FCS_FABRIC_SM_DELCOMP:
  617. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
  618. bfa_wc_down(&fabric->fcs->wc);
  619. break;
  620. case BFA_FCS_FABRIC_SM_LINK_UP:
  621. break;
  622. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  623. bfa_fcs_fabric_notify_offline(fabric);
  624. break;
  625. default:
  626. bfa_sm_fault(fabric->fcs, event);
  627. }
  628. }
  629. /*
  630. * Fabric is being stopped, awaiting vport stop completions.
  631. */
  632. static void
  633. bfa_fcs_fabric_sm_stopping(struct bfa_fcs_fabric_s *fabric,
  634. enum bfa_fcs_fabric_event event)
  635. {
  636. struct bfa_s *bfa = fabric->fcs->bfa;
  637. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  638. bfa_trc(fabric->fcs, event);
  639. switch (event) {
  640. case BFA_FCS_FABRIC_SM_STOPCOMP:
  641. if (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP) {
  642. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
  643. } else {
  644. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_cleanup);
  645. bfa_sm_send_event(fabric->lps, BFA_LPS_SM_LOGOUT);
  646. }
  647. break;
  648. case BFA_FCS_FABRIC_SM_LINK_UP:
  649. break;
  650. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  651. if (bfa_fcport_get_topology(bfa) == BFA_PORT_TOPOLOGY_LOOP)
  652. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
  653. else
  654. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_cleanup);
  655. break;
  656. default:
  657. bfa_sm_fault(fabric->fcs, event);
  658. }
  659. }
  660. /*
  661. * Fabric is being stopped, cleanup without FLOGO
  662. */
  663. static void
  664. bfa_fcs_fabric_sm_cleanup(struct bfa_fcs_fabric_s *fabric,
  665. enum bfa_fcs_fabric_event event)
  666. {
  667. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  668. bfa_trc(fabric->fcs, event);
  669. switch (event) {
  670. case BFA_FCS_FABRIC_SM_STOPCOMP:
  671. case BFA_FCS_FABRIC_SM_LOGOCOMP:
  672. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_created);
  673. bfa_wc_down(&(fabric->fcs)->wc);
  674. break;
  675. case BFA_FCS_FABRIC_SM_LINK_DOWN:
  676. /*
  677. * Ignore - can get this event if we get notified about IOC down
  678. * before the fabric completion callbk is done.
  679. */
  680. break;
  681. default:
  682. bfa_sm_fault(fabric->fcs, event);
  683. }
  684. }
  685. /*
  686. * fcs_fabric_private fabric private functions
  687. */
  688. static void
  689. bfa_fcs_fabric_init(struct bfa_fcs_fabric_s *fabric)
  690. {
  691. struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg;
  692. port_cfg->roles = BFA_LPORT_ROLE_FCP_IM;
  693. port_cfg->nwwn = fabric->fcs->bfa->ioc.attr->nwwn;
  694. port_cfg->pwwn = fabric->fcs->bfa->ioc.attr->pwwn;
  695. }
  696. /*
  697. * Port Symbolic Name Creation for base port.
  698. */
  699. void
  700. bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
  701. {
  702. struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg;
  703. char model[BFA_ADAPTER_MODEL_NAME_LEN] = {0};
  704. struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info;
  705. bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
  706. /* Model name/number */
  707. strncpy((char *)&port_cfg->sym_name, model,
  708. BFA_FCS_PORT_SYMBNAME_MODEL_SZ);
  709. strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
  710. sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
  711. /* Driver Version */
  712. strncat((char *)&port_cfg->sym_name, (char *)driver_info->version,
  713. BFA_FCS_PORT_SYMBNAME_VERSION_SZ);
  714. strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
  715. sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
  716. /* Host machine name */
  717. strncat((char *)&port_cfg->sym_name,
  718. (char *)driver_info->host_machine_name,
  719. BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ);
  720. strncat((char *)&port_cfg->sym_name, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
  721. sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
  722. /*
  723. * Host OS Info :
  724. * If OS Patch Info is not there, do not truncate any bytes from the
  725. * OS name string and instead copy the entire OS info string (64 bytes).
  726. */
  727. if (driver_info->host_os_patch[0] == '\0') {
  728. strncat((char *)&port_cfg->sym_name,
  729. (char *)driver_info->host_os_name,
  730. BFA_FCS_OS_STR_LEN);
  731. strncat((char *)&port_cfg->sym_name,
  732. BFA_FCS_PORT_SYMBNAME_SEPARATOR,
  733. sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
  734. } else {
  735. strncat((char *)&port_cfg->sym_name,
  736. (char *)driver_info->host_os_name,
  737. BFA_FCS_PORT_SYMBNAME_OSINFO_SZ);
  738. strncat((char *)&port_cfg->sym_name,
  739. BFA_FCS_PORT_SYMBNAME_SEPARATOR,
  740. sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
  741. /* Append host OS Patch Info */
  742. strncat((char *)&port_cfg->sym_name,
  743. (char *)driver_info->host_os_patch,
  744. BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ);
  745. }
  746. /* null terminate */
  747. port_cfg->sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
  748. }
  749. /*
  750. * Node Symbolic Name Creation for base port and all vports
  751. */
  752. void
  753. bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric)
  754. {
  755. struct bfa_lport_cfg_s *port_cfg = &fabric->bport.port_cfg;
  756. char model[BFA_ADAPTER_MODEL_NAME_LEN] = {0};
  757. struct bfa_fcs_driver_info_s *driver_info = &fabric->fcs->driver_info;
  758. bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
  759. /* Model name/number */
  760. strncpy((char *)&port_cfg->node_sym_name, model,
  761. BFA_FCS_PORT_SYMBNAME_MODEL_SZ);
  762. strncat((char *)&port_cfg->node_sym_name,
  763. BFA_FCS_PORT_SYMBNAME_SEPARATOR,
  764. sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
  765. /* Driver Version */
  766. strncat((char *)&port_cfg->node_sym_name, (char *)driver_info->version,
  767. BFA_FCS_PORT_SYMBNAME_VERSION_SZ);
  768. strncat((char *)&port_cfg->node_sym_name,
  769. BFA_FCS_PORT_SYMBNAME_SEPARATOR,
  770. sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
  771. /* Host machine name */
  772. strncat((char *)&port_cfg->node_sym_name,
  773. (char *)driver_info->host_machine_name,
  774. BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ);
  775. strncat((char *)&port_cfg->node_sym_name,
  776. BFA_FCS_PORT_SYMBNAME_SEPARATOR,
  777. sizeof(BFA_FCS_PORT_SYMBNAME_SEPARATOR));
  778. /* null terminate */
  779. port_cfg->node_sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
  780. }
  781. /*
  782. * bfa lps login completion callback
  783. */
  784. void
  785. bfa_cb_lps_flogi_comp(void *bfad, void *uarg, bfa_status_t status)
  786. {
  787. struct bfa_fcs_fabric_s *fabric = uarg;
  788. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  789. bfa_trc(fabric->fcs, status);
  790. switch (status) {
  791. case BFA_STATUS_OK:
  792. fabric->stats.flogi_accepts++;
  793. break;
  794. case BFA_STATUS_INVALID_MAC:
  795. /* Only for CNA */
  796. fabric->stats.flogi_acc_err++;
  797. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
  798. return;
  799. case BFA_STATUS_EPROTOCOL:
  800. switch (fabric->lps->ext_status) {
  801. case BFA_EPROTO_BAD_ACCEPT:
  802. fabric->stats.flogi_acc_err++;
  803. break;
  804. case BFA_EPROTO_UNKNOWN_RSP:
  805. fabric->stats.flogi_unknown_rsp++;
  806. break;
  807. default:
  808. break;
  809. }
  810. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
  811. return;
  812. case BFA_STATUS_FABRIC_RJT:
  813. fabric->stats.flogi_rejects++;
  814. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
  815. return;
  816. default:
  817. fabric->stats.flogi_rsp_err++;
  818. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_RETRY_OP);
  819. return;
  820. }
  821. fabric->bb_credit = fabric->lps->pr_bbcred;
  822. bfa_trc(fabric->fcs, fabric->bb_credit);
  823. if (!(fabric->lps->brcd_switch))
  824. fabric->fabric_name = fabric->lps->pr_nwwn;
  825. /*
  826. * Check port type. It should be 1 = F-port.
  827. */
  828. if (fabric->lps->fport) {
  829. fabric->bport.pid = fabric->lps->lp_pid;
  830. fabric->is_npiv = fabric->lps->npiv_en;
  831. fabric->is_auth = fabric->lps->auth_req;
  832. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_CONT_OP);
  833. } else {
  834. /*
  835. * Nport-2-Nport direct attached
  836. */
  837. fabric->bport.port_topo.pn2n.rem_port_wwn =
  838. fabric->lps->pr_pwwn;
  839. fabric->fab_type = BFA_FCS_FABRIC_N2N;
  840. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
  841. }
  842. bfa_trc(fabric->fcs, fabric->bport.pid);
  843. bfa_trc(fabric->fcs, fabric->is_npiv);
  844. bfa_trc(fabric->fcs, fabric->is_auth);
  845. }
  846. /*
  847. * Allocate and send FLOGI.
  848. */
  849. static void
  850. bfa_fcs_fabric_login(struct bfa_fcs_fabric_s *fabric)
  851. {
  852. struct bfa_s *bfa = fabric->fcs->bfa;
  853. struct bfa_lport_cfg_s *pcfg = &fabric->bport.port_cfg;
  854. u8 alpa = 0;
  855. bfa_lps_flogi(fabric->lps, fabric, alpa, bfa_fcport_get_maxfrsize(bfa),
  856. pcfg->pwwn, pcfg->nwwn, fabric->auth_reqd);
  857. fabric->stats.flogi_sent++;
  858. }
  859. static void
  860. bfa_fcs_fabric_notify_online(struct bfa_fcs_fabric_s *fabric)
  861. {
  862. struct bfa_fcs_vport_s *vport;
  863. struct list_head *qe, *qen;
  864. bfa_trc(fabric->fcs, fabric->fabric_name);
  865. bfa_fcs_fabric_set_opertype(fabric);
  866. fabric->stats.fabric_onlines++;
  867. /*
  868. * notify online event to base and then virtual ports
  869. */
  870. bfa_fcs_lport_online(&fabric->bport);
  871. list_for_each_safe(qe, qen, &fabric->vport_q) {
  872. vport = (struct bfa_fcs_vport_s *) qe;
  873. bfa_fcs_vport_online(vport);
  874. }
  875. }
  876. static void
  877. bfa_fcs_fabric_notify_offline(struct bfa_fcs_fabric_s *fabric)
  878. {
  879. struct bfa_fcs_vport_s *vport;
  880. struct list_head *qe, *qen;
  881. bfa_trc(fabric->fcs, fabric->fabric_name);
  882. fabric->stats.fabric_offlines++;
  883. /*
  884. * notify offline event first to vports and then base port.
  885. */
  886. list_for_each_safe(qe, qen, &fabric->vport_q) {
  887. vport = (struct bfa_fcs_vport_s *) qe;
  888. bfa_fcs_vport_offline(vport);
  889. }
  890. bfa_fcs_lport_offline(&fabric->bport);
  891. fabric->fabric_name = 0;
  892. fabric->fabric_ip_addr[0] = 0;
  893. }
  894. static void
  895. bfa_fcs_fabric_delay(void *cbarg)
  896. {
  897. struct bfa_fcs_fabric_s *fabric = cbarg;
  898. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELAYED);
  899. }
  900. /*
  901. * Stop all vports and wait for vport stop completions.
  902. */
  903. static void
  904. bfa_fcs_fabric_stop(struct bfa_fcs_fabric_s *fabric)
  905. {
  906. struct bfa_fcs_vport_s *vport;
  907. struct list_head *qe, *qen;
  908. bfa_wc_init(&fabric->stop_wc, bfa_fcs_fabric_stop_comp, fabric);
  909. list_for_each_safe(qe, qen, &fabric->vport_q) {
  910. vport = (struct bfa_fcs_vport_s *) qe;
  911. bfa_wc_up(&fabric->stop_wc);
  912. bfa_fcs_vport_fcs_stop(vport);
  913. }
  914. bfa_wc_up(&fabric->stop_wc);
  915. bfa_fcs_lport_stop(&fabric->bport);
  916. bfa_wc_wait(&fabric->stop_wc);
  917. }
  918. /*
  919. * Delete all vports and wait for vport delete completions.
  920. */
  921. static void
  922. bfa_fcs_fabric_delete(struct bfa_fcs_fabric_s *fabric)
  923. {
  924. struct bfa_fcs_vport_s *vport;
  925. struct list_head *qe, *qen;
  926. list_for_each_safe(qe, qen, &fabric->vport_q) {
  927. vport = (struct bfa_fcs_vport_s *) qe;
  928. bfa_fcs_vport_fcs_delete(vport);
  929. }
  930. bfa_fcs_lport_delete(&fabric->bport);
  931. bfa_wc_wait(&fabric->wc);
  932. }
  933. static void
  934. bfa_fcs_fabric_delete_comp(void *cbarg)
  935. {
  936. struct bfa_fcs_fabric_s *fabric = cbarg;
  937. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELCOMP);
  938. }
  939. static void
  940. bfa_fcs_fabric_stop_comp(void *cbarg)
  941. {
  942. struct bfa_fcs_fabric_s *fabric = cbarg;
  943. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_STOPCOMP);
  944. }
  945. /*
  946. * fcs_fabric_public fabric public functions
  947. */
  948. /*
  949. * Attach time initialization.
  950. */
  951. void
  952. bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs)
  953. {
  954. struct bfa_fcs_fabric_s *fabric;
  955. fabric = &fcs->fabric;
  956. memset(fabric, 0, sizeof(struct bfa_fcs_fabric_s));
  957. /*
  958. * Initialize base fabric.
  959. */
  960. fabric->fcs = fcs;
  961. INIT_LIST_HEAD(&fabric->vport_q);
  962. INIT_LIST_HEAD(&fabric->vf_q);
  963. fabric->lps = bfa_lps_alloc(fcs->bfa);
  964. WARN_ON(!fabric->lps);
  965. /*
  966. * Initialize fabric delete completion handler. Fabric deletion is
  967. * complete when the last vport delete is complete.
  968. */
  969. bfa_wc_init(&fabric->wc, bfa_fcs_fabric_delete_comp, fabric);
  970. bfa_wc_up(&fabric->wc); /* For the base port */
  971. bfa_sm_set_state(fabric, bfa_fcs_fabric_sm_uninit);
  972. bfa_fcs_lport_attach(&fabric->bport, fabric->fcs, FC_VF_ID_NULL, NULL);
  973. }
  974. void
  975. bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs)
  976. {
  977. bfa_sm_send_event(&fcs->fabric, BFA_FCS_FABRIC_SM_CREATE);
  978. bfa_trc(fcs, 0);
  979. }
  980. /*
  981. * Module cleanup
  982. */
  983. void
  984. bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs)
  985. {
  986. struct bfa_fcs_fabric_s *fabric;
  987. bfa_trc(fcs, 0);
  988. /*
  989. * Cleanup base fabric.
  990. */
  991. fabric = &fcs->fabric;
  992. bfa_lps_delete(fabric->lps);
  993. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_DELETE);
  994. }
  995. /*
  996. * Fabric module stop -- stop FCS actions
  997. */
  998. void
  999. bfa_fcs_fabric_modstop(struct bfa_fcs_s *fcs)
  1000. {
  1001. struct bfa_fcs_fabric_s *fabric;
  1002. bfa_trc(fcs, 0);
  1003. fabric = &fcs->fabric;
  1004. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_STOP);
  1005. }
  1006. /*
  1007. * Fabric module start -- kick starts FCS actions
  1008. */
  1009. void
  1010. bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs)
  1011. {
  1012. struct bfa_fcs_fabric_s *fabric;
  1013. bfa_trc(fcs, 0);
  1014. fabric = &fcs->fabric;
  1015. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_START);
  1016. }
  1017. /*
  1018. * Link up notification from BFA physical port module.
  1019. */
  1020. void
  1021. bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric)
  1022. {
  1023. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  1024. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_UP);
  1025. }
  1026. /*
  1027. * Link down notification from BFA physical port module.
  1028. */
  1029. void
  1030. bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric)
  1031. {
  1032. bfa_trc(fabric->fcs, fabric->bport.port_cfg.pwwn);
  1033. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LINK_DOWN);
  1034. }
  1035. /*
  1036. * A child vport is being created in the fabric.
  1037. *
  1038. * Call from vport module at vport creation. A list of base port and vports
  1039. * belonging to a fabric is maintained to propagate link events.
  1040. *
  1041. * param[in] fabric - Fabric instance. This can be a base fabric or vf.
  1042. * param[in] vport - Vport being created.
  1043. *
  1044. * @return None (always succeeds)
  1045. */
  1046. void
  1047. bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
  1048. struct bfa_fcs_vport_s *vport)
  1049. {
  1050. /*
  1051. * - add vport to fabric's vport_q
  1052. */
  1053. bfa_trc(fabric->fcs, fabric->vf_id);
  1054. list_add_tail(&vport->qe, &fabric->vport_q);
  1055. fabric->num_vports++;
  1056. bfa_wc_up(&fabric->wc);
  1057. }
  1058. /*
  1059. * A child vport is being deleted from fabric.
  1060. *
  1061. * Vport is being deleted.
  1062. */
  1063. void
  1064. bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
  1065. struct bfa_fcs_vport_s *vport)
  1066. {
  1067. list_del(&vport->qe);
  1068. fabric->num_vports--;
  1069. bfa_wc_down(&fabric->wc);
  1070. }
  1071. /*
  1072. * Lookup for a vport within a fabric given its pwwn
  1073. */
  1074. struct bfa_fcs_vport_s *
  1075. bfa_fcs_fabric_vport_lookup(struct bfa_fcs_fabric_s *fabric, wwn_t pwwn)
  1076. {
  1077. struct bfa_fcs_vport_s *vport;
  1078. struct list_head *qe;
  1079. list_for_each(qe, &fabric->vport_q) {
  1080. vport = (struct bfa_fcs_vport_s *) qe;
  1081. if (bfa_fcs_lport_get_pwwn(&vport->lport) == pwwn)
  1082. return vport;
  1083. }
  1084. return NULL;
  1085. }
  1086. /*
  1087. * Get OUI of the attached switch.
  1088. *
  1089. * Note : Use of this function should be avoided as much as possible.
  1090. * This function should be used only if there is any requirement
  1091. * to check for FOS version below 6.3.
  1092. * To check if the attached fabric is a brocade fabric, use
  1093. * bfa_lps_is_brcd_fabric() which works for FOS versions 6.3
  1094. * or above only.
  1095. */
  1096. u16
  1097. bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric)
  1098. {
  1099. wwn_t fab_nwwn;
  1100. u8 *tmp;
  1101. u16 oui;
  1102. fab_nwwn = fabric->lps->pr_nwwn;
  1103. tmp = (u8 *)&fab_nwwn;
  1104. oui = (tmp[3] << 8) | tmp[4];
  1105. return oui;
  1106. }
  1107. /*
  1108. * Unsolicited frame receive handling.
  1109. */
  1110. void
  1111. bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs,
  1112. u16 len)
  1113. {
  1114. u32 pid = fchs->d_id;
  1115. struct bfa_fcs_vport_s *vport;
  1116. struct list_head *qe;
  1117. struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
  1118. struct fc_logi_s *flogi = (struct fc_logi_s *) els_cmd;
  1119. bfa_trc(fabric->fcs, len);
  1120. bfa_trc(fabric->fcs, pid);
  1121. /*
  1122. * Look for our own FLOGI frames being looped back. This means an
  1123. * external loopback cable is in place. Our own FLOGI frames are
  1124. * sometimes looped back when switch port gets temporarily bypassed.
  1125. */
  1126. if ((pid == bfa_ntoh3b(FC_FABRIC_PORT)) &&
  1127. (els_cmd->els_code == FC_ELS_FLOGI) &&
  1128. (flogi->port_name == bfa_fcs_lport_get_pwwn(&fabric->bport))) {
  1129. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LOOPBACK);
  1130. return;
  1131. }
  1132. /*
  1133. * FLOGI/EVFP exchanges should be consumed by base fabric.
  1134. */
  1135. if (fchs->d_id == bfa_hton3b(FC_FABRIC_PORT)) {
  1136. bfa_trc(fabric->fcs, pid);
  1137. bfa_fcs_fabric_process_uf(fabric, fchs, len);
  1138. return;
  1139. }
  1140. if (fabric->bport.pid == pid) {
  1141. /*
  1142. * All authentication frames should be routed to auth
  1143. */
  1144. bfa_trc(fabric->fcs, els_cmd->els_code);
  1145. if (els_cmd->els_code == FC_ELS_AUTH) {
  1146. bfa_trc(fabric->fcs, els_cmd->els_code);
  1147. return;
  1148. }
  1149. bfa_trc(fabric->fcs, *(u8 *) ((u8 *) fchs));
  1150. bfa_fcs_lport_uf_recv(&fabric->bport, fchs, len);
  1151. return;
  1152. }
  1153. /*
  1154. * look for a matching local port ID
  1155. */
  1156. list_for_each(qe, &fabric->vport_q) {
  1157. vport = (struct bfa_fcs_vport_s *) qe;
  1158. if (vport->lport.pid == pid) {
  1159. bfa_fcs_lport_uf_recv(&vport->lport, fchs, len);
  1160. return;
  1161. }
  1162. }
  1163. if (!bfa_fcs_fabric_is_switched(fabric))
  1164. bfa_fcs_lport_uf_recv(&fabric->bport, fchs, len);
  1165. bfa_trc(fabric->fcs, fchs->type);
  1166. }
  1167. /*
  1168. * Unsolicited frames to be processed by fabric.
  1169. */
  1170. static void
  1171. bfa_fcs_fabric_process_uf(struct bfa_fcs_fabric_s *fabric, struct fchs_s *fchs,
  1172. u16 len)
  1173. {
  1174. struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
  1175. bfa_trc(fabric->fcs, els_cmd->els_code);
  1176. switch (els_cmd->els_code) {
  1177. case FC_ELS_FLOGI:
  1178. bfa_fcs_fabric_process_flogi(fabric, fchs, len);
  1179. break;
  1180. default:
  1181. /*
  1182. * need to generate a LS_RJT
  1183. */
  1184. break;
  1185. }
  1186. }
  1187. /*
  1188. * Process incoming FLOGI
  1189. */
  1190. static void
  1191. bfa_fcs_fabric_process_flogi(struct bfa_fcs_fabric_s *fabric,
  1192. struct fchs_s *fchs, u16 len)
  1193. {
  1194. struct fc_logi_s *flogi = (struct fc_logi_s *) (fchs + 1);
  1195. struct bfa_fcs_lport_s *bport = &fabric->bport;
  1196. bfa_trc(fabric->fcs, fchs->s_id);
  1197. fabric->stats.flogi_rcvd++;
  1198. /*
  1199. * Check port type. It should be 0 = n-port.
  1200. */
  1201. if (flogi->csp.port_type) {
  1202. /*
  1203. * @todo: may need to send a LS_RJT
  1204. */
  1205. bfa_trc(fabric->fcs, flogi->port_name);
  1206. fabric->stats.flogi_rejected++;
  1207. return;
  1208. }
  1209. fabric->bb_credit = be16_to_cpu(flogi->csp.bbcred);
  1210. bport->port_topo.pn2n.rem_port_wwn = flogi->port_name;
  1211. bport->port_topo.pn2n.reply_oxid = fchs->ox_id;
  1212. /*
  1213. * Send a Flogi Acc
  1214. */
  1215. bfa_fcs_fabric_send_flogi_acc(fabric);
  1216. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_NO_FABRIC);
  1217. }
  1218. static void
  1219. bfa_fcs_fabric_send_flogi_acc(struct bfa_fcs_fabric_s *fabric)
  1220. {
  1221. struct bfa_lport_cfg_s *pcfg = &fabric->bport.port_cfg;
  1222. struct bfa_fcs_lport_n2n_s *n2n_port = &fabric->bport.port_topo.pn2n;
  1223. struct bfa_s *bfa = fabric->fcs->bfa;
  1224. struct bfa_fcxp_s *fcxp;
  1225. u16 reqlen;
  1226. struct fchs_s fchs;
  1227. fcxp = bfa_fcs_fcxp_alloc(fabric->fcs, BFA_FALSE);
  1228. /*
  1229. * Do not expect this failure -- expect remote node to retry
  1230. */
  1231. if (!fcxp)
  1232. return;
  1233. reqlen = fc_flogi_acc_build(&fchs, bfa_fcxp_get_reqbuf(fcxp),
  1234. bfa_hton3b(FC_FABRIC_PORT),
  1235. n2n_port->reply_oxid, pcfg->pwwn,
  1236. pcfg->nwwn,
  1237. bfa_fcport_get_maxfrsize(bfa),
  1238. bfa_fcport_get_rx_bbcredit(bfa), 0);
  1239. bfa_fcxp_send(fcxp, NULL, fabric->vf_id, fabric->lps->bfa_tag,
  1240. BFA_FALSE, FC_CLASS_3,
  1241. reqlen, &fchs, bfa_fcs_fabric_flogiacc_comp, fabric,
  1242. FC_MAX_PDUSZ, 0);
  1243. }
  1244. /*
  1245. * Flogi Acc completion callback.
  1246. */
  1247. static void
  1248. bfa_fcs_fabric_flogiacc_comp(void *fcsarg, struct bfa_fcxp_s *fcxp, void *cbarg,
  1249. bfa_status_t status, u32 rsp_len,
  1250. u32 resid_len, struct fchs_s *rspfchs)
  1251. {
  1252. struct bfa_fcs_fabric_s *fabric = cbarg;
  1253. bfa_trc(fabric->fcs, status);
  1254. }
  1255. /*
  1256. * Send AEN notification
  1257. */
  1258. static void
  1259. bfa_fcs_fabric_aen_post(struct bfa_fcs_lport_s *port,
  1260. enum bfa_port_aen_event event)
  1261. {
  1262. struct bfad_s *bfad = (struct bfad_s *)port->fabric->fcs->bfad;
  1263. struct bfa_aen_entry_s *aen_entry;
  1264. bfad_get_aen_entry(bfad, aen_entry);
  1265. if (!aen_entry)
  1266. return;
  1267. aen_entry->aen_data.port.pwwn = bfa_fcs_lport_get_pwwn(port);
  1268. aen_entry->aen_data.port.fwwn = bfa_fcs_lport_get_fabric_name(port);
  1269. /* Send the AEN notification */
  1270. bfad_im_post_vendor_event(aen_entry, bfad, ++port->fcs->fcs_aen_seq,
  1271. BFA_AEN_CAT_PORT, event);
  1272. }
  1273. /*
  1274. *
  1275. * @param[in] fabric - fabric
  1276. * @param[in] wwn_t - new fabric name
  1277. *
  1278. * @return - none
  1279. */
  1280. void
  1281. bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
  1282. wwn_t fabric_name)
  1283. {
  1284. struct bfad_s *bfad = (struct bfad_s *)fabric->fcs->bfad;
  1285. char pwwn_ptr[BFA_STRING_32];
  1286. char fwwn_ptr[BFA_STRING_32];
  1287. bfa_trc(fabric->fcs, fabric_name);
  1288. if (fabric->fabric_name == 0) {
  1289. /*
  1290. * With BRCD switches, we don't get Fabric Name in FLOGI.
  1291. * Don't generate a fabric name change event in this case.
  1292. */
  1293. fabric->fabric_name = fabric_name;
  1294. } else {
  1295. fabric->fabric_name = fabric_name;
  1296. wwn2str(pwwn_ptr, bfa_fcs_lport_get_pwwn(&fabric->bport));
  1297. wwn2str(fwwn_ptr,
  1298. bfa_fcs_lport_get_fabric_name(&fabric->bport));
  1299. BFA_LOG(KERN_WARNING, bfad, bfa_log_level,
  1300. "Base port WWN = %s Fabric WWN = %s\n",
  1301. pwwn_ptr, fwwn_ptr);
  1302. bfa_fcs_fabric_aen_post(&fabric->bport,
  1303. BFA_PORT_AEN_FABRIC_NAME_CHANGE);
  1304. }
  1305. }
  1306. void
  1307. bfa_cb_lps_flogo_comp(void *bfad, void *uarg)
  1308. {
  1309. struct bfa_fcs_fabric_s *fabric = uarg;
  1310. bfa_sm_send_event(fabric, BFA_FCS_FABRIC_SM_LOGOCOMP);
  1311. }
  1312. /*
  1313. * Returns FCS vf structure for a given vf_id.
  1314. *
  1315. * param[in] vf_id - VF_ID
  1316. *
  1317. * return
  1318. * If lookup succeeds, retuns fcs vf object, otherwise returns NULL
  1319. */
  1320. bfa_fcs_vf_t *
  1321. bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id)
  1322. {
  1323. bfa_trc(fcs, vf_id);
  1324. if (vf_id == FC_VF_ID_NULL)
  1325. return &fcs->fabric;
  1326. return NULL;
  1327. }
  1328. /*
  1329. * Return the list of local logical ports present in the given VF.
  1330. *
  1331. * @param[in] vf vf for which logical ports are returned
  1332. * @param[out] lpwwn returned logical port wwn list
  1333. * @param[in,out] nlports in:size of lpwwn list;
  1334. * out:total elements present,
  1335. * actual elements returned is limited by the size
  1336. */
  1337. void
  1338. bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t lpwwn[], int *nlports)
  1339. {
  1340. struct list_head *qe;
  1341. struct bfa_fcs_vport_s *vport;
  1342. int i = 0;
  1343. struct bfa_fcs_s *fcs;
  1344. if (vf == NULL || lpwwn == NULL || *nlports == 0)
  1345. return;
  1346. fcs = vf->fcs;
  1347. bfa_trc(fcs, vf->vf_id);
  1348. bfa_trc(fcs, (uint32_t) *nlports);
  1349. lpwwn[i++] = vf->bport.port_cfg.pwwn;
  1350. list_for_each(qe, &vf->vport_q) {
  1351. if (i >= *nlports)
  1352. break;
  1353. vport = (struct bfa_fcs_vport_s *) qe;
  1354. lpwwn[i++] = vport->lport.port_cfg.pwwn;
  1355. }
  1356. bfa_trc(fcs, i);
  1357. *nlports = i;
  1358. }
  1359. /*
  1360. * BFA FCS PPORT ( physical port)
  1361. */
  1362. static void
  1363. bfa_fcs_port_event_handler(void *cbarg, enum bfa_port_linkstate event)
  1364. {
  1365. struct bfa_fcs_s *fcs = cbarg;
  1366. bfa_trc(fcs, event);
  1367. switch (event) {
  1368. case BFA_PORT_LINKUP:
  1369. bfa_fcs_fabric_link_up(&fcs->fabric);
  1370. break;
  1371. case BFA_PORT_LINKDOWN:
  1372. bfa_fcs_fabric_link_down(&fcs->fabric);
  1373. break;
  1374. default:
  1375. WARN_ON(1);
  1376. }
  1377. }
  1378. void
  1379. bfa_fcs_port_attach(struct bfa_fcs_s *fcs)
  1380. {
  1381. bfa_fcport_event_register(fcs->bfa, bfa_fcs_port_event_handler, fcs);
  1382. }
  1383. /*
  1384. * BFA FCS UF ( Unsolicited Frames)
  1385. */
  1386. /*
  1387. * BFA callback for unsolicited frame receive handler.
  1388. *
  1389. * @param[in] cbarg callback arg for receive handler
  1390. * @param[in] uf unsolicited frame descriptor
  1391. *
  1392. * @return None
  1393. */
  1394. static void
  1395. bfa_fcs_uf_recv(void *cbarg, struct bfa_uf_s *uf)
  1396. {
  1397. struct bfa_fcs_s *fcs = (struct bfa_fcs_s *) cbarg;
  1398. struct fchs_s *fchs = bfa_uf_get_frmbuf(uf);
  1399. u16 len = bfa_uf_get_frmlen(uf);
  1400. struct fc_vft_s *vft;
  1401. struct bfa_fcs_fabric_s *fabric;
  1402. /*
  1403. * check for VFT header
  1404. */
  1405. if (fchs->routing == FC_RTG_EXT_HDR &&
  1406. fchs->cat_info == FC_CAT_VFT_HDR) {
  1407. bfa_stats(fcs, uf.tagged);
  1408. vft = bfa_uf_get_frmbuf(uf);
  1409. if (fcs->port_vfid == vft->vf_id)
  1410. fabric = &fcs->fabric;
  1411. else
  1412. fabric = bfa_fcs_vf_lookup(fcs, (u16) vft->vf_id);
  1413. /*
  1414. * drop frame if vfid is unknown
  1415. */
  1416. if (!fabric) {
  1417. WARN_ON(1);
  1418. bfa_stats(fcs, uf.vfid_unknown);
  1419. bfa_uf_free(uf);
  1420. return;
  1421. }
  1422. /*
  1423. * skip vft header
  1424. */
  1425. fchs = (struct fchs_s *) (vft + 1);
  1426. len -= sizeof(struct fc_vft_s);
  1427. bfa_trc(fcs, vft->vf_id);
  1428. } else {
  1429. bfa_stats(fcs, uf.untagged);
  1430. fabric = &fcs->fabric;
  1431. }
  1432. bfa_trc(fcs, ((u32 *) fchs)[0]);
  1433. bfa_trc(fcs, ((u32 *) fchs)[1]);
  1434. bfa_trc(fcs, ((u32 *) fchs)[2]);
  1435. bfa_trc(fcs, ((u32 *) fchs)[3]);
  1436. bfa_trc(fcs, ((u32 *) fchs)[4]);
  1437. bfa_trc(fcs, ((u32 *) fchs)[5]);
  1438. bfa_trc(fcs, len);
  1439. bfa_fcs_fabric_uf_recv(fabric, fchs, len);
  1440. bfa_uf_free(uf);
  1441. }
  1442. void
  1443. bfa_fcs_uf_attach(struct bfa_fcs_s *fcs)
  1444. {
  1445. bfa_uf_recv_register(fcs->bfa, bfa_fcs_uf_recv, fcs);
  1446. }