bfa_core.c 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627
  1. /*
  2. * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #include "bfad_drv.h"
  18. #include "bfa_modules.h"
  19. #include "bfi_reg.h"
  20. BFA_TRC_FILE(HAL, CORE);
  21. /*
  22. * BFA module list terminated by NULL
  23. */
  24. static struct bfa_module_s *hal_mods[] = {
  25. &hal_mod_fcdiag,
  26. &hal_mod_sgpg,
  27. &hal_mod_fcport,
  28. &hal_mod_fcxp,
  29. &hal_mod_lps,
  30. &hal_mod_uf,
  31. &hal_mod_rport,
  32. &hal_mod_fcp,
  33. NULL
  34. };
  35. /*
  36. * Message handlers for various modules.
  37. */
  38. static bfa_isr_func_t bfa_isrs[BFI_MC_MAX] = {
  39. bfa_isr_unhandled, /* NONE */
  40. bfa_isr_unhandled, /* BFI_MC_IOC */
  41. bfa_fcdiag_intr, /* BFI_MC_DIAG */
  42. bfa_isr_unhandled, /* BFI_MC_FLASH */
  43. bfa_isr_unhandled, /* BFI_MC_CEE */
  44. bfa_fcport_isr, /* BFI_MC_FCPORT */
  45. bfa_isr_unhandled, /* BFI_MC_IOCFC */
  46. bfa_isr_unhandled, /* BFI_MC_LL */
  47. bfa_uf_isr, /* BFI_MC_UF */
  48. bfa_fcxp_isr, /* BFI_MC_FCXP */
  49. bfa_lps_isr, /* BFI_MC_LPS */
  50. bfa_rport_isr, /* BFI_MC_RPORT */
  51. bfa_itn_isr, /* BFI_MC_ITN */
  52. bfa_isr_unhandled, /* BFI_MC_IOIM_READ */
  53. bfa_isr_unhandled, /* BFI_MC_IOIM_WRITE */
  54. bfa_isr_unhandled, /* BFI_MC_IOIM_IO */
  55. bfa_ioim_isr, /* BFI_MC_IOIM */
  56. bfa_ioim_good_comp_isr, /* BFI_MC_IOIM_IOCOM */
  57. bfa_tskim_isr, /* BFI_MC_TSKIM */
  58. bfa_isr_unhandled, /* BFI_MC_SBOOT */
  59. bfa_isr_unhandled, /* BFI_MC_IPFC */
  60. bfa_isr_unhandled, /* BFI_MC_PORT */
  61. bfa_isr_unhandled, /* --------- */
  62. bfa_isr_unhandled, /* --------- */
  63. bfa_isr_unhandled, /* --------- */
  64. bfa_isr_unhandled, /* --------- */
  65. bfa_isr_unhandled, /* --------- */
  66. bfa_isr_unhandled, /* --------- */
  67. bfa_isr_unhandled, /* --------- */
  68. bfa_isr_unhandled, /* --------- */
  69. bfa_isr_unhandled, /* --------- */
  70. bfa_isr_unhandled, /* --------- */
  71. };
  72. /*
  73. * Message handlers for mailbox command classes
  74. */
  75. static bfa_ioc_mbox_mcfunc_t bfa_mbox_isrs[BFI_MC_MAX] = {
  76. NULL,
  77. NULL, /* BFI_MC_IOC */
  78. NULL, /* BFI_MC_DIAG */
  79. NULL, /* BFI_MC_FLASH */
  80. NULL, /* BFI_MC_CEE */
  81. NULL, /* BFI_MC_PORT */
  82. bfa_iocfc_isr, /* BFI_MC_IOCFC */
  83. NULL,
  84. };
  85. static void
  86. bfa_com_port_attach(struct bfa_s *bfa)
  87. {
  88. struct bfa_port_s *port = &bfa->modules.port;
  89. struct bfa_mem_dma_s *port_dma = BFA_MEM_PORT_DMA(bfa);
  90. bfa_port_attach(port, &bfa->ioc, bfa, bfa->trcmod);
  91. bfa_port_mem_claim(port, port_dma->kva_curp, port_dma->dma_curp);
  92. }
  93. /*
  94. * ablk module attach
  95. */
  96. static void
  97. bfa_com_ablk_attach(struct bfa_s *bfa)
  98. {
  99. struct bfa_ablk_s *ablk = &bfa->modules.ablk;
  100. struct bfa_mem_dma_s *ablk_dma = BFA_MEM_ABLK_DMA(bfa);
  101. bfa_ablk_attach(ablk, &bfa->ioc);
  102. bfa_ablk_memclaim(ablk, ablk_dma->kva_curp, ablk_dma->dma_curp);
  103. }
  104. static void
  105. bfa_com_cee_attach(struct bfa_s *bfa)
  106. {
  107. struct bfa_cee_s *cee = &bfa->modules.cee;
  108. struct bfa_mem_dma_s *cee_dma = BFA_MEM_CEE_DMA(bfa);
  109. cee->trcmod = bfa->trcmod;
  110. bfa_cee_attach(cee, &bfa->ioc, bfa);
  111. bfa_cee_mem_claim(cee, cee_dma->kva_curp, cee_dma->dma_curp);
  112. }
  113. static void
  114. bfa_com_sfp_attach(struct bfa_s *bfa)
  115. {
  116. struct bfa_sfp_s *sfp = BFA_SFP_MOD(bfa);
  117. struct bfa_mem_dma_s *sfp_dma = BFA_MEM_SFP_DMA(bfa);
  118. bfa_sfp_attach(sfp, &bfa->ioc, bfa, bfa->trcmod);
  119. bfa_sfp_memclaim(sfp, sfp_dma->kva_curp, sfp_dma->dma_curp);
  120. }
  121. static void
  122. bfa_com_flash_attach(struct bfa_s *bfa, bfa_boolean_t mincfg)
  123. {
  124. struct bfa_flash_s *flash = BFA_FLASH(bfa);
  125. struct bfa_mem_dma_s *flash_dma = BFA_MEM_FLASH_DMA(bfa);
  126. bfa_flash_attach(flash, &bfa->ioc, bfa, bfa->trcmod, mincfg);
  127. bfa_flash_memclaim(flash, flash_dma->kva_curp,
  128. flash_dma->dma_curp, mincfg);
  129. }
  130. static void
  131. bfa_com_diag_attach(struct bfa_s *bfa)
  132. {
  133. struct bfa_diag_s *diag = BFA_DIAG_MOD(bfa);
  134. struct bfa_mem_dma_s *diag_dma = BFA_MEM_DIAG_DMA(bfa);
  135. bfa_diag_attach(diag, &bfa->ioc, bfa, bfa_fcport_beacon, bfa->trcmod);
  136. bfa_diag_memclaim(diag, diag_dma->kva_curp, diag_dma->dma_curp);
  137. }
  138. static void
  139. bfa_com_phy_attach(struct bfa_s *bfa, bfa_boolean_t mincfg)
  140. {
  141. struct bfa_phy_s *phy = BFA_PHY(bfa);
  142. struct bfa_mem_dma_s *phy_dma = BFA_MEM_PHY_DMA(bfa);
  143. bfa_phy_attach(phy, &bfa->ioc, bfa, bfa->trcmod, mincfg);
  144. bfa_phy_memclaim(phy, phy_dma->kva_curp, phy_dma->dma_curp, mincfg);
  145. }
  146. /*
  147. * BFA IOC FC related definitions
  148. */
  149. /*
  150. * IOC local definitions
  151. */
  152. #define BFA_IOCFC_TOV 5000 /* msecs */
  153. enum {
  154. BFA_IOCFC_ACT_NONE = 0,
  155. BFA_IOCFC_ACT_INIT = 1,
  156. BFA_IOCFC_ACT_STOP = 2,
  157. BFA_IOCFC_ACT_DISABLE = 3,
  158. BFA_IOCFC_ACT_ENABLE = 4,
  159. };
  160. #define DEF_CFG_NUM_FABRICS 1
  161. #define DEF_CFG_NUM_LPORTS 256
  162. #define DEF_CFG_NUM_CQS 4
  163. #define DEF_CFG_NUM_IOIM_REQS (BFA_IOIM_MAX)
  164. #define DEF_CFG_NUM_TSKIM_REQS 128
  165. #define DEF_CFG_NUM_FCXP_REQS 64
  166. #define DEF_CFG_NUM_UF_BUFS 64
  167. #define DEF_CFG_NUM_RPORTS 1024
  168. #define DEF_CFG_NUM_ITNIMS (DEF_CFG_NUM_RPORTS)
  169. #define DEF_CFG_NUM_TINS 256
  170. #define DEF_CFG_NUM_SGPGS 2048
  171. #define DEF_CFG_NUM_REQQ_ELEMS 256
  172. #define DEF_CFG_NUM_RSPQ_ELEMS 64
  173. #define DEF_CFG_NUM_SBOOT_TGTS 16
  174. #define DEF_CFG_NUM_SBOOT_LUNS 16
  175. /*
  176. * forward declaration for IOC FC functions
  177. */
  178. static void bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status);
  179. static void bfa_iocfc_disable_cbfn(void *bfa_arg);
  180. static void bfa_iocfc_hbfail_cbfn(void *bfa_arg);
  181. static void bfa_iocfc_reset_cbfn(void *bfa_arg);
  182. static struct bfa_ioc_cbfn_s bfa_iocfc_cbfn;
  183. /*
  184. * BFA Interrupt handling functions
  185. */
  186. static void
  187. bfa_reqq_resume(struct bfa_s *bfa, int qid)
  188. {
  189. struct list_head *waitq, *qe, *qen;
  190. struct bfa_reqq_wait_s *wqe;
  191. waitq = bfa_reqq(bfa, qid);
  192. list_for_each_safe(qe, qen, waitq) {
  193. /*
  194. * Callback only as long as there is room in request queue
  195. */
  196. if (bfa_reqq_full(bfa, qid))
  197. break;
  198. list_del(qe);
  199. wqe = (struct bfa_reqq_wait_s *) qe;
  200. wqe->qresume(wqe->cbarg);
  201. }
  202. }
  203. static inline void
  204. bfa_isr_rspq(struct bfa_s *bfa, int qid)
  205. {
  206. struct bfi_msg_s *m;
  207. u32 pi, ci;
  208. struct list_head *waitq;
  209. ci = bfa_rspq_ci(bfa, qid);
  210. pi = bfa_rspq_pi(bfa, qid);
  211. while (ci != pi) {
  212. m = bfa_rspq_elem(bfa, qid, ci);
  213. WARN_ON(m->mhdr.msg_class >= BFI_MC_MAX);
  214. bfa_isrs[m->mhdr.msg_class] (bfa, m);
  215. CQ_INCR(ci, bfa->iocfc.cfg.drvcfg.num_rspq_elems);
  216. }
  217. /*
  218. * acknowledge RME completions and update CI
  219. */
  220. bfa_isr_rspq_ack(bfa, qid, ci);
  221. /*
  222. * Resume any pending requests in the corresponding reqq.
  223. */
  224. waitq = bfa_reqq(bfa, qid);
  225. if (!list_empty(waitq))
  226. bfa_reqq_resume(bfa, qid);
  227. }
  228. static inline void
  229. bfa_isr_reqq(struct bfa_s *bfa, int qid)
  230. {
  231. struct list_head *waitq;
  232. bfa_isr_reqq_ack(bfa, qid);
  233. /*
  234. * Resume any pending requests in the corresponding reqq.
  235. */
  236. waitq = bfa_reqq(bfa, qid);
  237. if (!list_empty(waitq))
  238. bfa_reqq_resume(bfa, qid);
  239. }
  240. void
  241. bfa_msix_all(struct bfa_s *bfa, int vec)
  242. {
  243. u32 intr, qintr;
  244. int queue;
  245. intr = readl(bfa->iocfc.bfa_regs.intr_status);
  246. if (!intr)
  247. return;
  248. /*
  249. * RME completion queue interrupt
  250. */
  251. qintr = intr & __HFN_INT_RME_MASK;
  252. if (qintr && bfa->queue_process) {
  253. for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++)
  254. bfa_isr_rspq(bfa, queue);
  255. }
  256. intr &= ~qintr;
  257. if (!intr)
  258. return;
  259. /*
  260. * CPE completion queue interrupt
  261. */
  262. qintr = intr & __HFN_INT_CPE_MASK;
  263. if (qintr && bfa->queue_process) {
  264. for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++)
  265. bfa_isr_reqq(bfa, queue);
  266. }
  267. intr &= ~qintr;
  268. if (!intr)
  269. return;
  270. bfa_msix_lpu_err(bfa, intr);
  271. }
  272. bfa_boolean_t
  273. bfa_intx(struct bfa_s *bfa)
  274. {
  275. u32 intr, qintr;
  276. int queue;
  277. intr = readl(bfa->iocfc.bfa_regs.intr_status);
  278. qintr = intr & (__HFN_INT_RME_MASK | __HFN_INT_CPE_MASK);
  279. if (qintr)
  280. writel(qintr, bfa->iocfc.bfa_regs.intr_status);
  281. /*
  282. * Unconditional RME completion queue interrupt
  283. */
  284. if (bfa->queue_process) {
  285. for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++)
  286. bfa_isr_rspq(bfa, queue);
  287. }
  288. if (!intr)
  289. return BFA_TRUE;
  290. /*
  291. * CPE completion queue interrupt
  292. */
  293. qintr = intr & __HFN_INT_CPE_MASK;
  294. if (qintr && bfa->queue_process) {
  295. for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++)
  296. bfa_isr_reqq(bfa, queue);
  297. }
  298. intr &= ~qintr;
  299. if (!intr)
  300. return BFA_TRUE;
  301. bfa_msix_lpu_err(bfa, intr);
  302. return BFA_TRUE;
  303. }
  304. void
  305. bfa_isr_enable(struct bfa_s *bfa)
  306. {
  307. u32 umsk;
  308. int pci_func = bfa_ioc_pcifn(&bfa->ioc);
  309. bfa_trc(bfa, pci_func);
  310. bfa_msix_ctrl_install(bfa);
  311. if (bfa_asic_id_ct2(bfa->ioc.pcidev.device_id)) {
  312. umsk = __HFN_INT_ERR_MASK_CT2;
  313. umsk |= pci_func == 0 ?
  314. __HFN_INT_FN0_MASK_CT2 : __HFN_INT_FN1_MASK_CT2;
  315. } else {
  316. umsk = __HFN_INT_ERR_MASK;
  317. umsk |= pci_func == 0 ? __HFN_INT_FN0_MASK : __HFN_INT_FN1_MASK;
  318. }
  319. writel(umsk, bfa->iocfc.bfa_regs.intr_status);
  320. writel(~umsk, bfa->iocfc.bfa_regs.intr_mask);
  321. bfa->iocfc.intr_mask = ~umsk;
  322. bfa_isr_mode_set(bfa, bfa->msix.nvecs != 0);
  323. }
  324. void
  325. bfa_isr_disable(struct bfa_s *bfa)
  326. {
  327. bfa_isr_mode_set(bfa, BFA_FALSE);
  328. writel(-1L, bfa->iocfc.bfa_regs.intr_mask);
  329. bfa_msix_uninstall(bfa);
  330. }
  331. void
  332. bfa_msix_reqq(struct bfa_s *bfa, int vec)
  333. {
  334. bfa_isr_reqq(bfa, vec - bfa->iocfc.hwif.cpe_vec_q0);
  335. }
  336. void
  337. bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m)
  338. {
  339. bfa_trc(bfa, m->mhdr.msg_class);
  340. bfa_trc(bfa, m->mhdr.msg_id);
  341. bfa_trc(bfa, m->mhdr.mtag.i2htok);
  342. WARN_ON(1);
  343. bfa_trc_stop(bfa->trcmod);
  344. }
  345. void
  346. bfa_msix_rspq(struct bfa_s *bfa, int vec)
  347. {
  348. bfa_isr_rspq(bfa, vec - bfa->iocfc.hwif.rme_vec_q0);
  349. }
  350. void
  351. bfa_msix_lpu_err(struct bfa_s *bfa, int vec)
  352. {
  353. u32 intr, curr_value;
  354. bfa_boolean_t lpu_isr, halt_isr, pss_isr;
  355. intr = readl(bfa->iocfc.bfa_regs.intr_status);
  356. if (bfa_asic_id_ct2(bfa->ioc.pcidev.device_id)) {
  357. halt_isr = intr & __HFN_INT_CPQ_HALT_CT2;
  358. pss_isr = intr & __HFN_INT_ERR_PSS_CT2;
  359. lpu_isr = intr & (__HFN_INT_MBOX_LPU0_CT2 |
  360. __HFN_INT_MBOX_LPU1_CT2);
  361. intr &= __HFN_INT_ERR_MASK_CT2;
  362. } else {
  363. halt_isr = bfa_asic_id_ct(bfa->ioc.pcidev.device_id) ?
  364. (intr & __HFN_INT_LL_HALT) : 0;
  365. pss_isr = intr & __HFN_INT_ERR_PSS;
  366. lpu_isr = intr & (__HFN_INT_MBOX_LPU0 | __HFN_INT_MBOX_LPU1);
  367. intr &= __HFN_INT_ERR_MASK;
  368. }
  369. if (lpu_isr)
  370. bfa_ioc_mbox_isr(&bfa->ioc);
  371. if (intr) {
  372. if (halt_isr) {
  373. /*
  374. * If LL_HALT bit is set then FW Init Halt LL Port
  375. * Register needs to be cleared as well so Interrupt
  376. * Status Register will be cleared.
  377. */
  378. curr_value = readl(bfa->ioc.ioc_regs.ll_halt);
  379. curr_value &= ~__FW_INIT_HALT_P;
  380. writel(curr_value, bfa->ioc.ioc_regs.ll_halt);
  381. }
  382. if (pss_isr) {
  383. /*
  384. * ERR_PSS bit needs to be cleared as well in case
  385. * interrups are shared so driver's interrupt handler is
  386. * still called even though it is already masked out.
  387. */
  388. curr_value = readl(
  389. bfa->ioc.ioc_regs.pss_err_status_reg);
  390. writel(curr_value,
  391. bfa->ioc.ioc_regs.pss_err_status_reg);
  392. }
  393. writel(intr, bfa->iocfc.bfa_regs.intr_status);
  394. bfa_ioc_error_isr(&bfa->ioc);
  395. }
  396. }
  397. /*
  398. * BFA IOC FC related functions
  399. */
  400. /*
  401. * BFA IOC private functions
  402. */
  403. /*
  404. * Use the Mailbox interface to send BFI_IOCFC_H2I_CFG_REQ
  405. */
  406. static void
  407. bfa_iocfc_send_cfg(void *bfa_arg)
  408. {
  409. struct bfa_s *bfa = bfa_arg;
  410. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  411. struct bfi_iocfc_cfg_req_s cfg_req;
  412. struct bfi_iocfc_cfg_s *cfg_info = iocfc->cfginfo;
  413. struct bfa_iocfc_cfg_s *cfg = &iocfc->cfg;
  414. int i;
  415. WARN_ON(cfg->fwcfg.num_cqs > BFI_IOC_MAX_CQS);
  416. bfa_trc(bfa, cfg->fwcfg.num_cqs);
  417. bfa_iocfc_reset_queues(bfa);
  418. /*
  419. * initialize IOC configuration info
  420. */
  421. cfg_info->single_msix_vec = 0;
  422. if (bfa->msix.nvecs == 1)
  423. cfg_info->single_msix_vec = 1;
  424. cfg_info->endian_sig = BFI_IOC_ENDIAN_SIG;
  425. cfg_info->num_cqs = cfg->fwcfg.num_cqs;
  426. cfg_info->num_ioim_reqs = cpu_to_be16(cfg->fwcfg.num_ioim_reqs);
  427. cfg_info->num_fwtio_reqs = cpu_to_be16(cfg->fwcfg.num_fwtio_reqs);
  428. bfa_dma_be_addr_set(cfg_info->cfgrsp_addr, iocfc->cfgrsp_dma.pa);
  429. /*
  430. * dma map REQ and RSP circular queues and shadow pointers
  431. */
  432. for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
  433. bfa_dma_be_addr_set(cfg_info->req_cq_ba[i],
  434. iocfc->req_cq_ba[i].pa);
  435. bfa_dma_be_addr_set(cfg_info->req_shadow_ci[i],
  436. iocfc->req_cq_shadow_ci[i].pa);
  437. cfg_info->req_cq_elems[i] =
  438. cpu_to_be16(cfg->drvcfg.num_reqq_elems);
  439. bfa_dma_be_addr_set(cfg_info->rsp_cq_ba[i],
  440. iocfc->rsp_cq_ba[i].pa);
  441. bfa_dma_be_addr_set(cfg_info->rsp_shadow_pi[i],
  442. iocfc->rsp_cq_shadow_pi[i].pa);
  443. cfg_info->rsp_cq_elems[i] =
  444. cpu_to_be16(cfg->drvcfg.num_rspq_elems);
  445. }
  446. /*
  447. * Enable interrupt coalescing if it is driver init path
  448. * and not ioc disable/enable path.
  449. */
  450. if (!iocfc->cfgdone)
  451. cfg_info->intr_attr.coalesce = BFA_TRUE;
  452. iocfc->cfgdone = BFA_FALSE;
  453. /*
  454. * dma map IOC configuration itself
  455. */
  456. bfi_h2i_set(cfg_req.mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_CFG_REQ,
  457. bfa_fn_lpu(bfa));
  458. bfa_dma_be_addr_set(cfg_req.ioc_cfg_dma_addr, iocfc->cfg_info.pa);
  459. bfa_ioc_mbox_send(&bfa->ioc, &cfg_req,
  460. sizeof(struct bfi_iocfc_cfg_req_s));
  461. }
  462. static void
  463. bfa_iocfc_init_mem(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
  464. struct bfa_pcidev_s *pcidev)
  465. {
  466. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  467. bfa->bfad = bfad;
  468. iocfc->bfa = bfa;
  469. iocfc->action = BFA_IOCFC_ACT_NONE;
  470. iocfc->cfg = *cfg;
  471. /*
  472. * Initialize chip specific handlers.
  473. */
  474. if (bfa_asic_id_ctc(bfa_ioc_devid(&bfa->ioc))) {
  475. iocfc->hwif.hw_reginit = bfa_hwct_reginit;
  476. iocfc->hwif.hw_reqq_ack = bfa_hwct_reqq_ack;
  477. iocfc->hwif.hw_rspq_ack = bfa_hwct_rspq_ack;
  478. iocfc->hwif.hw_msix_init = bfa_hwct_msix_init;
  479. iocfc->hwif.hw_msix_ctrl_install = bfa_hwct_msix_ctrl_install;
  480. iocfc->hwif.hw_msix_queue_install = bfa_hwct_msix_queue_install;
  481. iocfc->hwif.hw_msix_uninstall = bfa_hwct_msix_uninstall;
  482. iocfc->hwif.hw_isr_mode_set = bfa_hwct_isr_mode_set;
  483. iocfc->hwif.hw_msix_getvecs = bfa_hwct_msix_getvecs;
  484. iocfc->hwif.hw_msix_get_rme_range = bfa_hwct_msix_get_rme_range;
  485. iocfc->hwif.rme_vec_q0 = BFI_MSIX_RME_QMIN_CT;
  486. iocfc->hwif.cpe_vec_q0 = BFI_MSIX_CPE_QMIN_CT;
  487. } else {
  488. iocfc->hwif.hw_reginit = bfa_hwcb_reginit;
  489. iocfc->hwif.hw_reqq_ack = NULL;
  490. iocfc->hwif.hw_rspq_ack = bfa_hwcb_rspq_ack;
  491. iocfc->hwif.hw_msix_init = bfa_hwcb_msix_init;
  492. iocfc->hwif.hw_msix_ctrl_install = bfa_hwcb_msix_ctrl_install;
  493. iocfc->hwif.hw_msix_queue_install = bfa_hwcb_msix_queue_install;
  494. iocfc->hwif.hw_msix_uninstall = bfa_hwcb_msix_uninstall;
  495. iocfc->hwif.hw_isr_mode_set = bfa_hwcb_isr_mode_set;
  496. iocfc->hwif.hw_msix_getvecs = bfa_hwcb_msix_getvecs;
  497. iocfc->hwif.hw_msix_get_rme_range = bfa_hwcb_msix_get_rme_range;
  498. iocfc->hwif.rme_vec_q0 = BFI_MSIX_RME_QMIN_CB +
  499. bfa_ioc_pcifn(&bfa->ioc) * BFI_IOC_MAX_CQS;
  500. iocfc->hwif.cpe_vec_q0 = BFI_MSIX_CPE_QMIN_CB +
  501. bfa_ioc_pcifn(&bfa->ioc) * BFI_IOC_MAX_CQS;
  502. }
  503. if (bfa_asic_id_ct2(bfa_ioc_devid(&bfa->ioc))) {
  504. iocfc->hwif.hw_reginit = bfa_hwct2_reginit;
  505. iocfc->hwif.hw_isr_mode_set = NULL;
  506. iocfc->hwif.hw_rspq_ack = bfa_hwct2_rspq_ack;
  507. }
  508. iocfc->hwif.hw_reginit(bfa);
  509. bfa->msix.nvecs = 0;
  510. }
  511. static void
  512. bfa_iocfc_mem_claim(struct bfa_s *bfa, struct bfa_iocfc_cfg_s *cfg)
  513. {
  514. u8 *dm_kva = NULL;
  515. u64 dm_pa = 0;
  516. int i, per_reqq_sz, per_rspq_sz, dbgsz;
  517. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  518. struct bfa_mem_dma_s *ioc_dma = BFA_MEM_IOC_DMA(bfa);
  519. struct bfa_mem_dma_s *iocfc_dma = BFA_MEM_IOCFC_DMA(bfa);
  520. struct bfa_mem_dma_s *reqq_dma, *rspq_dma;
  521. /* First allocate dma memory for IOC */
  522. bfa_ioc_mem_claim(&bfa->ioc, bfa_mem_dma_virt(ioc_dma),
  523. bfa_mem_dma_phys(ioc_dma));
  524. /* Claim DMA-able memory for the request/response queues */
  525. per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ),
  526. BFA_DMA_ALIGN_SZ);
  527. per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ),
  528. BFA_DMA_ALIGN_SZ);
  529. for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
  530. reqq_dma = BFA_MEM_REQQ_DMA(bfa, i);
  531. iocfc->req_cq_ba[i].kva = bfa_mem_dma_virt(reqq_dma);
  532. iocfc->req_cq_ba[i].pa = bfa_mem_dma_phys(reqq_dma);
  533. memset(iocfc->req_cq_ba[i].kva, 0, per_reqq_sz);
  534. rspq_dma = BFA_MEM_RSPQ_DMA(bfa, i);
  535. iocfc->rsp_cq_ba[i].kva = bfa_mem_dma_virt(rspq_dma);
  536. iocfc->rsp_cq_ba[i].pa = bfa_mem_dma_phys(rspq_dma);
  537. memset(iocfc->rsp_cq_ba[i].kva, 0, per_rspq_sz);
  538. }
  539. /* Claim IOCFC dma memory - for shadow CI/PI */
  540. dm_kva = bfa_mem_dma_virt(iocfc_dma);
  541. dm_pa = bfa_mem_dma_phys(iocfc_dma);
  542. for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
  543. iocfc->req_cq_shadow_ci[i].kva = dm_kva;
  544. iocfc->req_cq_shadow_ci[i].pa = dm_pa;
  545. dm_kva += BFA_CACHELINE_SZ;
  546. dm_pa += BFA_CACHELINE_SZ;
  547. iocfc->rsp_cq_shadow_pi[i].kva = dm_kva;
  548. iocfc->rsp_cq_shadow_pi[i].pa = dm_pa;
  549. dm_kva += BFA_CACHELINE_SZ;
  550. dm_pa += BFA_CACHELINE_SZ;
  551. }
  552. /* Claim IOCFC dma memory - for the config info page */
  553. bfa->iocfc.cfg_info.kva = dm_kva;
  554. bfa->iocfc.cfg_info.pa = dm_pa;
  555. bfa->iocfc.cfginfo = (struct bfi_iocfc_cfg_s *) dm_kva;
  556. dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
  557. dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
  558. /* Claim IOCFC dma memory - for the config response */
  559. bfa->iocfc.cfgrsp_dma.kva = dm_kva;
  560. bfa->iocfc.cfgrsp_dma.pa = dm_pa;
  561. bfa->iocfc.cfgrsp = (struct bfi_iocfc_cfgrsp_s *) dm_kva;
  562. dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
  563. BFA_CACHELINE_SZ);
  564. dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
  565. BFA_CACHELINE_SZ);
  566. /* Claim IOCFC kva memory */
  567. dbgsz = (bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0;
  568. if (dbgsz > 0) {
  569. bfa_ioc_debug_memclaim(&bfa->ioc, bfa_mem_kva_curp(iocfc));
  570. bfa_mem_kva_curp(iocfc) += dbgsz;
  571. }
  572. }
  573. /*
  574. * Start BFA submodules.
  575. */
  576. static void
  577. bfa_iocfc_start_submod(struct bfa_s *bfa)
  578. {
  579. int i;
  580. bfa->queue_process = BFA_TRUE;
  581. for (i = 0; i < BFI_IOC_MAX_CQS; i++)
  582. bfa_isr_rspq_ack(bfa, i, bfa_rspq_ci(bfa, i));
  583. for (i = 0; hal_mods[i]; i++)
  584. hal_mods[i]->start(bfa);
  585. }
  586. /*
  587. * Disable BFA submodules.
  588. */
  589. static void
  590. bfa_iocfc_disable_submod(struct bfa_s *bfa)
  591. {
  592. int i;
  593. for (i = 0; hal_mods[i]; i++)
  594. hal_mods[i]->iocdisable(bfa);
  595. }
  596. static void
  597. bfa_iocfc_init_cb(void *bfa_arg, bfa_boolean_t complete)
  598. {
  599. struct bfa_s *bfa = bfa_arg;
  600. if (complete) {
  601. if (bfa->iocfc.cfgdone)
  602. bfa_cb_init(bfa->bfad, BFA_STATUS_OK);
  603. else
  604. bfa_cb_init(bfa->bfad, BFA_STATUS_FAILED);
  605. } else {
  606. if (bfa->iocfc.cfgdone)
  607. bfa->iocfc.action = BFA_IOCFC_ACT_NONE;
  608. }
  609. }
  610. static void
  611. bfa_iocfc_stop_cb(void *bfa_arg, bfa_boolean_t compl)
  612. {
  613. struct bfa_s *bfa = bfa_arg;
  614. struct bfad_s *bfad = bfa->bfad;
  615. if (compl)
  616. complete(&bfad->comp);
  617. else
  618. bfa->iocfc.action = BFA_IOCFC_ACT_NONE;
  619. }
  620. static void
  621. bfa_iocfc_enable_cb(void *bfa_arg, bfa_boolean_t compl)
  622. {
  623. struct bfa_s *bfa = bfa_arg;
  624. struct bfad_s *bfad = bfa->bfad;
  625. if (compl)
  626. complete(&bfad->enable_comp);
  627. }
  628. static void
  629. bfa_iocfc_disable_cb(void *bfa_arg, bfa_boolean_t compl)
  630. {
  631. struct bfa_s *bfa = bfa_arg;
  632. struct bfad_s *bfad = bfa->bfad;
  633. if (compl)
  634. complete(&bfad->disable_comp);
  635. }
  636. /**
  637. * configure queue registers from firmware response
  638. */
  639. static void
  640. bfa_iocfc_qreg(struct bfa_s *bfa, struct bfi_iocfc_qreg_s *qreg)
  641. {
  642. int i;
  643. struct bfa_iocfc_regs_s *r = &bfa->iocfc.bfa_regs;
  644. void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
  645. for (i = 0; i < BFI_IOC_MAX_CQS; i++) {
  646. bfa->iocfc.hw_qid[i] = qreg->hw_qid[i];
  647. r->cpe_q_ci[i] = kva + be32_to_cpu(qreg->cpe_q_ci_off[i]);
  648. r->cpe_q_pi[i] = kva + be32_to_cpu(qreg->cpe_q_pi_off[i]);
  649. r->cpe_q_ctrl[i] = kva + be32_to_cpu(qreg->cpe_qctl_off[i]);
  650. r->rme_q_ci[i] = kva + be32_to_cpu(qreg->rme_q_ci_off[i]);
  651. r->rme_q_pi[i] = kva + be32_to_cpu(qreg->rme_q_pi_off[i]);
  652. r->rme_q_ctrl[i] = kva + be32_to_cpu(qreg->rme_qctl_off[i]);
  653. }
  654. }
  655. static void
  656. bfa_iocfc_res_recfg(struct bfa_s *bfa, struct bfa_iocfc_fwcfg_s *fwcfg)
  657. {
  658. bfa_fcxp_res_recfg(bfa, fwcfg->num_fcxp_reqs);
  659. bfa_uf_res_recfg(bfa, fwcfg->num_uf_bufs);
  660. bfa_rport_res_recfg(bfa, fwcfg->num_rports);
  661. bfa_fcp_res_recfg(bfa, fwcfg->num_ioim_reqs);
  662. bfa_tskim_res_recfg(bfa, fwcfg->num_tskim_reqs);
  663. }
  664. /*
  665. * Update BFA configuration from firmware configuration.
  666. */
  667. static void
  668. bfa_iocfc_cfgrsp(struct bfa_s *bfa)
  669. {
  670. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  671. struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
  672. struct bfa_iocfc_fwcfg_s *fwcfg = &cfgrsp->fwcfg;
  673. fwcfg->num_cqs = fwcfg->num_cqs;
  674. fwcfg->num_ioim_reqs = be16_to_cpu(fwcfg->num_ioim_reqs);
  675. fwcfg->num_fwtio_reqs = be16_to_cpu(fwcfg->num_fwtio_reqs);
  676. fwcfg->num_tskim_reqs = be16_to_cpu(fwcfg->num_tskim_reqs);
  677. fwcfg->num_fcxp_reqs = be16_to_cpu(fwcfg->num_fcxp_reqs);
  678. fwcfg->num_uf_bufs = be16_to_cpu(fwcfg->num_uf_bufs);
  679. fwcfg->num_rports = be16_to_cpu(fwcfg->num_rports);
  680. iocfc->cfgdone = BFA_TRUE;
  681. /*
  682. * configure queue register offsets as learnt from firmware
  683. */
  684. bfa_iocfc_qreg(bfa, &cfgrsp->qreg);
  685. /*
  686. * Re-configure resources as learnt from Firmware
  687. */
  688. bfa_iocfc_res_recfg(bfa, fwcfg);
  689. /*
  690. * Install MSIX queue handlers
  691. */
  692. bfa_msix_queue_install(bfa);
  693. /*
  694. * Configuration is complete - initialize/start submodules
  695. */
  696. bfa_fcport_init(bfa);
  697. if (iocfc->action == BFA_IOCFC_ACT_INIT)
  698. bfa_cb_queue(bfa, &iocfc->init_hcb_qe, bfa_iocfc_init_cb, bfa);
  699. else {
  700. if (bfa->iocfc.action == BFA_IOCFC_ACT_ENABLE)
  701. bfa_cb_queue(bfa, &bfa->iocfc.en_hcb_qe,
  702. bfa_iocfc_enable_cb, bfa);
  703. bfa_iocfc_start_submod(bfa);
  704. }
  705. }
  706. void
  707. bfa_iocfc_reset_queues(struct bfa_s *bfa)
  708. {
  709. int q;
  710. for (q = 0; q < BFI_IOC_MAX_CQS; q++) {
  711. bfa_reqq_ci(bfa, q) = 0;
  712. bfa_reqq_pi(bfa, q) = 0;
  713. bfa_rspq_ci(bfa, q) = 0;
  714. bfa_rspq_pi(bfa, q) = 0;
  715. }
  716. }
  717. /* Fabric Assigned Address specific functions */
  718. /*
  719. * Check whether IOC is ready before sending command down
  720. */
  721. static bfa_status_t
  722. bfa_faa_validate_request(struct bfa_s *bfa)
  723. {
  724. enum bfa_ioc_type_e ioc_type = bfa_get_type(bfa);
  725. u32 card_type = bfa->ioc.attr->card_type;
  726. if (bfa_ioc_is_operational(&bfa->ioc)) {
  727. if ((ioc_type != BFA_IOC_TYPE_FC) || bfa_mfg_is_mezz(card_type))
  728. return BFA_STATUS_FEATURE_NOT_SUPPORTED;
  729. } else {
  730. if (!bfa_ioc_is_acq_addr(&bfa->ioc))
  731. return BFA_STATUS_IOC_NON_OP;
  732. }
  733. return BFA_STATUS_OK;
  734. }
  735. bfa_status_t
  736. bfa_faa_enable(struct bfa_s *bfa, bfa_cb_iocfc_t cbfn, void *cbarg)
  737. {
  738. struct bfi_faa_en_dis_s faa_enable_req;
  739. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  740. bfa_status_t status;
  741. iocfc->faa_args.faa_cb.faa_cbfn = cbfn;
  742. iocfc->faa_args.faa_cb.faa_cbarg = cbarg;
  743. status = bfa_faa_validate_request(bfa);
  744. if (status != BFA_STATUS_OK)
  745. return status;
  746. if (iocfc->faa_args.busy == BFA_TRUE)
  747. return BFA_STATUS_DEVBUSY;
  748. if (iocfc->faa_args.faa_state == BFA_FAA_ENABLED)
  749. return BFA_STATUS_FAA_ENABLED;
  750. if (bfa_fcport_is_trunk_enabled(bfa))
  751. return BFA_STATUS_ERROR_TRUNK_ENABLED;
  752. bfa_fcport_cfg_faa(bfa, BFA_FAA_ENABLED);
  753. iocfc->faa_args.busy = BFA_TRUE;
  754. memset(&faa_enable_req, 0, sizeof(struct bfi_faa_en_dis_s));
  755. bfi_h2i_set(faa_enable_req.mh, BFI_MC_IOCFC,
  756. BFI_IOCFC_H2I_FAA_ENABLE_REQ, bfa_fn_lpu(bfa));
  757. bfa_ioc_mbox_send(&bfa->ioc, &faa_enable_req,
  758. sizeof(struct bfi_faa_en_dis_s));
  759. return BFA_STATUS_OK;
  760. }
  761. bfa_status_t
  762. bfa_faa_disable(struct bfa_s *bfa, bfa_cb_iocfc_t cbfn,
  763. void *cbarg)
  764. {
  765. struct bfi_faa_en_dis_s faa_disable_req;
  766. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  767. bfa_status_t status;
  768. iocfc->faa_args.faa_cb.faa_cbfn = cbfn;
  769. iocfc->faa_args.faa_cb.faa_cbarg = cbarg;
  770. status = bfa_faa_validate_request(bfa);
  771. if (status != BFA_STATUS_OK)
  772. return status;
  773. if (iocfc->faa_args.busy == BFA_TRUE)
  774. return BFA_STATUS_DEVBUSY;
  775. if (iocfc->faa_args.faa_state == BFA_FAA_DISABLED)
  776. return BFA_STATUS_FAA_DISABLED;
  777. bfa_fcport_cfg_faa(bfa, BFA_FAA_DISABLED);
  778. iocfc->faa_args.busy = BFA_TRUE;
  779. memset(&faa_disable_req, 0, sizeof(struct bfi_faa_en_dis_s));
  780. bfi_h2i_set(faa_disable_req.mh, BFI_MC_IOCFC,
  781. BFI_IOCFC_H2I_FAA_DISABLE_REQ, bfa_fn_lpu(bfa));
  782. bfa_ioc_mbox_send(&bfa->ioc, &faa_disable_req,
  783. sizeof(struct bfi_faa_en_dis_s));
  784. return BFA_STATUS_OK;
  785. }
  786. bfa_status_t
  787. bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr,
  788. bfa_cb_iocfc_t cbfn, void *cbarg)
  789. {
  790. struct bfi_faa_query_s faa_attr_req;
  791. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  792. bfa_status_t status;
  793. iocfc->faa_args.faa_attr = attr;
  794. iocfc->faa_args.faa_cb.faa_cbfn = cbfn;
  795. iocfc->faa_args.faa_cb.faa_cbarg = cbarg;
  796. status = bfa_faa_validate_request(bfa);
  797. if (status != BFA_STATUS_OK)
  798. return status;
  799. if (iocfc->faa_args.busy == BFA_TRUE)
  800. return BFA_STATUS_DEVBUSY;
  801. iocfc->faa_args.busy = BFA_TRUE;
  802. memset(&faa_attr_req, 0, sizeof(struct bfi_faa_query_s));
  803. bfi_h2i_set(faa_attr_req.mh, BFI_MC_IOCFC,
  804. BFI_IOCFC_H2I_FAA_QUERY_REQ, bfa_fn_lpu(bfa));
  805. bfa_ioc_mbox_send(&bfa->ioc, &faa_attr_req,
  806. sizeof(struct bfi_faa_query_s));
  807. return BFA_STATUS_OK;
  808. }
  809. /*
  810. * FAA enable response
  811. */
  812. static void
  813. bfa_faa_enable_reply(struct bfa_iocfc_s *iocfc,
  814. struct bfi_faa_en_dis_rsp_s *rsp)
  815. {
  816. void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg;
  817. bfa_status_t status = rsp->status;
  818. WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn);
  819. iocfc->faa_args.faa_cb.faa_cbfn(cbarg, status);
  820. iocfc->faa_args.busy = BFA_FALSE;
  821. }
  822. /*
  823. * FAA disable response
  824. */
  825. static void
  826. bfa_faa_disable_reply(struct bfa_iocfc_s *iocfc,
  827. struct bfi_faa_en_dis_rsp_s *rsp)
  828. {
  829. void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg;
  830. bfa_status_t status = rsp->status;
  831. WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn);
  832. iocfc->faa_args.faa_cb.faa_cbfn(cbarg, status);
  833. iocfc->faa_args.busy = BFA_FALSE;
  834. }
  835. /*
  836. * FAA query response
  837. */
  838. static void
  839. bfa_faa_query_reply(struct bfa_iocfc_s *iocfc,
  840. bfi_faa_query_rsp_t *rsp)
  841. {
  842. void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg;
  843. if (iocfc->faa_args.faa_attr) {
  844. iocfc->faa_args.faa_attr->faa = rsp->faa;
  845. iocfc->faa_args.faa_attr->faa_state = rsp->faa_status;
  846. iocfc->faa_args.faa_attr->pwwn_source = rsp->addr_source;
  847. }
  848. WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn);
  849. iocfc->faa_args.faa_cb.faa_cbfn(cbarg, BFA_STATUS_OK);
  850. iocfc->faa_args.busy = BFA_FALSE;
  851. }
  852. /*
  853. * IOC enable request is complete
  854. */
  855. static void
  856. bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status)
  857. {
  858. struct bfa_s *bfa = bfa_arg;
  859. if (status == BFA_STATUS_FAA_ACQ_ADDR) {
  860. bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe,
  861. bfa_iocfc_init_cb, bfa);
  862. return;
  863. }
  864. if (status != BFA_STATUS_OK) {
  865. bfa_isr_disable(bfa);
  866. if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
  867. bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe,
  868. bfa_iocfc_init_cb, bfa);
  869. else if (bfa->iocfc.action == BFA_IOCFC_ACT_ENABLE)
  870. bfa_cb_queue(bfa, &bfa->iocfc.en_hcb_qe,
  871. bfa_iocfc_enable_cb, bfa);
  872. return;
  873. }
  874. bfa_iocfc_send_cfg(bfa);
  875. }
  876. /*
  877. * IOC disable request is complete
  878. */
  879. static void
  880. bfa_iocfc_disable_cbfn(void *bfa_arg)
  881. {
  882. struct bfa_s *bfa = bfa_arg;
  883. bfa_isr_disable(bfa);
  884. bfa_iocfc_disable_submod(bfa);
  885. if (bfa->iocfc.action == BFA_IOCFC_ACT_STOP)
  886. bfa_cb_queue(bfa, &bfa->iocfc.stop_hcb_qe, bfa_iocfc_stop_cb,
  887. bfa);
  888. else {
  889. WARN_ON(bfa->iocfc.action != BFA_IOCFC_ACT_DISABLE);
  890. bfa_cb_queue(bfa, &bfa->iocfc.dis_hcb_qe, bfa_iocfc_disable_cb,
  891. bfa);
  892. }
  893. }
  894. /*
  895. * Notify sub-modules of hardware failure.
  896. */
  897. static void
  898. bfa_iocfc_hbfail_cbfn(void *bfa_arg)
  899. {
  900. struct bfa_s *bfa = bfa_arg;
  901. bfa->queue_process = BFA_FALSE;
  902. bfa_isr_disable(bfa);
  903. bfa_iocfc_disable_submod(bfa);
  904. if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
  905. bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, bfa_iocfc_init_cb,
  906. bfa);
  907. }
  908. /*
  909. * Actions on chip-reset completion.
  910. */
  911. static void
  912. bfa_iocfc_reset_cbfn(void *bfa_arg)
  913. {
  914. struct bfa_s *bfa = bfa_arg;
  915. bfa_iocfc_reset_queues(bfa);
  916. bfa_isr_enable(bfa);
  917. }
  918. /*
  919. * Query IOC memory requirement information.
  920. */
  921. void
  922. bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
  923. struct bfa_s *bfa)
  924. {
  925. int q, per_reqq_sz, per_rspq_sz;
  926. struct bfa_mem_dma_s *ioc_dma = BFA_MEM_IOC_DMA(bfa);
  927. struct bfa_mem_dma_s *iocfc_dma = BFA_MEM_IOCFC_DMA(bfa);
  928. struct bfa_mem_kva_s *iocfc_kva = BFA_MEM_IOCFC_KVA(bfa);
  929. u32 dm_len = 0;
  930. /* dma memory setup for IOC */
  931. bfa_mem_dma_setup(meminfo, ioc_dma,
  932. BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ));
  933. /* dma memory setup for REQ/RSP queues */
  934. per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ),
  935. BFA_DMA_ALIGN_SZ);
  936. per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ),
  937. BFA_DMA_ALIGN_SZ);
  938. for (q = 0; q < cfg->fwcfg.num_cqs; q++) {
  939. bfa_mem_dma_setup(meminfo, BFA_MEM_REQQ_DMA(bfa, q),
  940. per_reqq_sz);
  941. bfa_mem_dma_setup(meminfo, BFA_MEM_RSPQ_DMA(bfa, q),
  942. per_rspq_sz);
  943. }
  944. /* IOCFC dma memory - calculate Shadow CI/PI size */
  945. for (q = 0; q < cfg->fwcfg.num_cqs; q++)
  946. dm_len += (2 * BFA_CACHELINE_SZ);
  947. /* IOCFC dma memory - calculate config info / rsp size */
  948. dm_len += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
  949. dm_len += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
  950. BFA_CACHELINE_SZ);
  951. /* dma memory setup for IOCFC */
  952. bfa_mem_dma_setup(meminfo, iocfc_dma, dm_len);
  953. /* kva memory setup for IOCFC */
  954. bfa_mem_kva_setup(meminfo, iocfc_kva,
  955. ((bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0));
  956. }
  957. /*
  958. * Query IOC memory requirement information.
  959. */
  960. void
  961. bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
  962. struct bfa_pcidev_s *pcidev)
  963. {
  964. int i;
  965. struct bfa_ioc_s *ioc = &bfa->ioc;
  966. bfa_iocfc_cbfn.enable_cbfn = bfa_iocfc_enable_cbfn;
  967. bfa_iocfc_cbfn.disable_cbfn = bfa_iocfc_disable_cbfn;
  968. bfa_iocfc_cbfn.hbfail_cbfn = bfa_iocfc_hbfail_cbfn;
  969. bfa_iocfc_cbfn.reset_cbfn = bfa_iocfc_reset_cbfn;
  970. ioc->trcmod = bfa->trcmod;
  971. bfa_ioc_attach(&bfa->ioc, bfa, &bfa_iocfc_cbfn, &bfa->timer_mod);
  972. bfa_ioc_pci_init(&bfa->ioc, pcidev, BFI_PCIFN_CLASS_FC);
  973. bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs);
  974. bfa_iocfc_init_mem(bfa, bfad, cfg, pcidev);
  975. bfa_iocfc_mem_claim(bfa, cfg);
  976. INIT_LIST_HEAD(&bfa->timer_mod.timer_q);
  977. INIT_LIST_HEAD(&bfa->comp_q);
  978. for (i = 0; i < BFI_IOC_MAX_CQS; i++)
  979. INIT_LIST_HEAD(&bfa->reqq_waitq[i]);
  980. }
  981. /*
  982. * Query IOC memory requirement information.
  983. */
  984. void
  985. bfa_iocfc_init(struct bfa_s *bfa)
  986. {
  987. bfa->iocfc.action = BFA_IOCFC_ACT_INIT;
  988. bfa_ioc_enable(&bfa->ioc);
  989. }
  990. /*
  991. * IOC start called from bfa_start(). Called to start IOC operations
  992. * at driver instantiation for this instance.
  993. */
  994. void
  995. bfa_iocfc_start(struct bfa_s *bfa)
  996. {
  997. if (bfa->iocfc.cfgdone)
  998. bfa_iocfc_start_submod(bfa);
  999. }
  1000. /*
  1001. * IOC stop called from bfa_stop(). Called only when driver is unloaded
  1002. * for this instance.
  1003. */
  1004. void
  1005. bfa_iocfc_stop(struct bfa_s *bfa)
  1006. {
  1007. bfa->iocfc.action = BFA_IOCFC_ACT_STOP;
  1008. bfa->queue_process = BFA_FALSE;
  1009. bfa_ioc_disable(&bfa->ioc);
  1010. }
  1011. void
  1012. bfa_iocfc_isr(void *bfaarg, struct bfi_mbmsg_s *m)
  1013. {
  1014. struct bfa_s *bfa = bfaarg;
  1015. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  1016. union bfi_iocfc_i2h_msg_u *msg;
  1017. msg = (union bfi_iocfc_i2h_msg_u *) m;
  1018. bfa_trc(bfa, msg->mh.msg_id);
  1019. switch (msg->mh.msg_id) {
  1020. case BFI_IOCFC_I2H_CFG_REPLY:
  1021. bfa_iocfc_cfgrsp(bfa);
  1022. break;
  1023. case BFI_IOCFC_I2H_UPDATEQ_RSP:
  1024. iocfc->updateq_cbfn(iocfc->updateq_cbarg, BFA_STATUS_OK);
  1025. break;
  1026. case BFI_IOCFC_I2H_FAA_ENABLE_RSP:
  1027. bfa_faa_enable_reply(iocfc,
  1028. (struct bfi_faa_en_dis_rsp_s *)msg);
  1029. break;
  1030. case BFI_IOCFC_I2H_FAA_DISABLE_RSP:
  1031. bfa_faa_disable_reply(iocfc,
  1032. (struct bfi_faa_en_dis_rsp_s *)msg);
  1033. break;
  1034. case BFI_IOCFC_I2H_FAA_QUERY_RSP:
  1035. bfa_faa_query_reply(iocfc, (bfi_faa_query_rsp_t *)msg);
  1036. break;
  1037. default:
  1038. WARN_ON(1);
  1039. }
  1040. }
  1041. void
  1042. bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr)
  1043. {
  1044. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  1045. attr->intr_attr.coalesce = iocfc->cfginfo->intr_attr.coalesce;
  1046. attr->intr_attr.delay = iocfc->cfginfo->intr_attr.delay ?
  1047. be16_to_cpu(iocfc->cfginfo->intr_attr.delay) :
  1048. be16_to_cpu(iocfc->cfgrsp->intr_attr.delay);
  1049. attr->intr_attr.latency = iocfc->cfginfo->intr_attr.latency ?
  1050. be16_to_cpu(iocfc->cfginfo->intr_attr.latency) :
  1051. be16_to_cpu(iocfc->cfgrsp->intr_attr.latency);
  1052. attr->config = iocfc->cfg;
  1053. }
  1054. bfa_status_t
  1055. bfa_iocfc_israttr_set(struct bfa_s *bfa, struct bfa_iocfc_intr_attr_s *attr)
  1056. {
  1057. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  1058. struct bfi_iocfc_set_intr_req_s *m;
  1059. iocfc->cfginfo->intr_attr.coalesce = attr->coalesce;
  1060. iocfc->cfginfo->intr_attr.delay = cpu_to_be16(attr->delay);
  1061. iocfc->cfginfo->intr_attr.latency = cpu_to_be16(attr->latency);
  1062. if (!bfa_iocfc_is_operational(bfa))
  1063. return BFA_STATUS_OK;
  1064. m = bfa_reqq_next(bfa, BFA_REQQ_IOC);
  1065. if (!m)
  1066. return BFA_STATUS_DEVBUSY;
  1067. bfi_h2i_set(m->mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_SET_INTR_REQ,
  1068. bfa_fn_lpu(bfa));
  1069. m->coalesce = iocfc->cfginfo->intr_attr.coalesce;
  1070. m->delay = iocfc->cfginfo->intr_attr.delay;
  1071. m->latency = iocfc->cfginfo->intr_attr.latency;
  1072. bfa_trc(bfa, attr->delay);
  1073. bfa_trc(bfa, attr->latency);
  1074. bfa_reqq_produce(bfa, BFA_REQQ_IOC, m->mh);
  1075. return BFA_STATUS_OK;
  1076. }
  1077. void
  1078. bfa_iocfc_set_snsbase(struct bfa_s *bfa, int seg_no, u64 snsbase_pa)
  1079. {
  1080. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  1081. iocfc->cfginfo->sense_buf_len = (BFI_IOIM_SNSLEN - 1);
  1082. bfa_dma_be_addr_set(iocfc->cfginfo->ioim_snsbase[seg_no], snsbase_pa);
  1083. }
  1084. /*
  1085. * Enable IOC after it is disabled.
  1086. */
  1087. void
  1088. bfa_iocfc_enable(struct bfa_s *bfa)
  1089. {
  1090. bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
  1091. "IOC Enable");
  1092. bfa->iocfc.action = BFA_IOCFC_ACT_ENABLE;
  1093. bfa_ioc_enable(&bfa->ioc);
  1094. }
  1095. void
  1096. bfa_iocfc_disable(struct bfa_s *bfa)
  1097. {
  1098. bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
  1099. "IOC Disable");
  1100. bfa->iocfc.action = BFA_IOCFC_ACT_DISABLE;
  1101. bfa->queue_process = BFA_FALSE;
  1102. bfa_ioc_disable(&bfa->ioc);
  1103. }
  1104. bfa_boolean_t
  1105. bfa_iocfc_is_operational(struct bfa_s *bfa)
  1106. {
  1107. return bfa_ioc_is_operational(&bfa->ioc) && bfa->iocfc.cfgdone;
  1108. }
  1109. /*
  1110. * Return boot target port wwns -- read from boot information in flash.
  1111. */
  1112. void
  1113. bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns)
  1114. {
  1115. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  1116. struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
  1117. int i;
  1118. if (cfgrsp->pbc_cfg.boot_enabled && cfgrsp->pbc_cfg.nbluns) {
  1119. bfa_trc(bfa, cfgrsp->pbc_cfg.nbluns);
  1120. *nwwns = cfgrsp->pbc_cfg.nbluns;
  1121. for (i = 0; i < cfgrsp->pbc_cfg.nbluns; i++)
  1122. wwns[i] = cfgrsp->pbc_cfg.blun[i].tgt_pwwn;
  1123. return;
  1124. }
  1125. *nwwns = cfgrsp->bootwwns.nwwns;
  1126. memcpy(wwns, cfgrsp->bootwwns.wwn, sizeof(cfgrsp->bootwwns.wwn));
  1127. }
  1128. int
  1129. bfa_iocfc_get_pbc_vports(struct bfa_s *bfa, struct bfi_pbc_vport_s *pbc_vport)
  1130. {
  1131. struct bfa_iocfc_s *iocfc = &bfa->iocfc;
  1132. struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
  1133. memcpy(pbc_vport, cfgrsp->pbc_cfg.vport, sizeof(cfgrsp->pbc_cfg.vport));
  1134. return cfgrsp->pbc_cfg.nvports;
  1135. }
  1136. /*
  1137. * Use this function query the memory requirement of the BFA library.
  1138. * This function needs to be called before bfa_attach() to get the
  1139. * memory required of the BFA layer for a given driver configuration.
  1140. *
  1141. * This call will fail, if the cap is out of range compared to pre-defined
  1142. * values within the BFA library
  1143. *
  1144. * @param[in] cfg - pointer to bfa_ioc_cfg_t. Driver layer should indicate
  1145. * its configuration in this structure.
  1146. * The default values for struct bfa_iocfc_cfg_s can be
  1147. * fetched using bfa_cfg_get_default() API.
  1148. *
  1149. * If cap's boundary check fails, the library will use
  1150. * the default bfa_cap_t values (and log a warning msg).
  1151. *
  1152. * @param[out] meminfo - pointer to bfa_meminfo_t. This content
  1153. * indicates the memory type (see bfa_mem_type_t) and
  1154. * amount of memory required.
  1155. *
  1156. * Driver should allocate the memory, populate the
  1157. * starting address for each block and provide the same
  1158. * structure as input parameter to bfa_attach() call.
  1159. *
  1160. * @param[in] bfa - pointer to the bfa structure, used while fetching the
  1161. * dma, kva memory information of the bfa sub-modules.
  1162. *
  1163. * @return void
  1164. *
  1165. * Special Considerations: @note
  1166. */
  1167. void
  1168. bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
  1169. struct bfa_s *bfa)
  1170. {
  1171. int i;
  1172. struct bfa_mem_dma_s *port_dma = BFA_MEM_PORT_DMA(bfa);
  1173. struct bfa_mem_dma_s *ablk_dma = BFA_MEM_ABLK_DMA(bfa);
  1174. struct bfa_mem_dma_s *cee_dma = BFA_MEM_CEE_DMA(bfa);
  1175. struct bfa_mem_dma_s *sfp_dma = BFA_MEM_SFP_DMA(bfa);
  1176. struct bfa_mem_dma_s *flash_dma = BFA_MEM_FLASH_DMA(bfa);
  1177. struct bfa_mem_dma_s *diag_dma = BFA_MEM_DIAG_DMA(bfa);
  1178. struct bfa_mem_dma_s *phy_dma = BFA_MEM_PHY_DMA(bfa);
  1179. WARN_ON((cfg == NULL) || (meminfo == NULL));
  1180. memset((void *)meminfo, 0, sizeof(struct bfa_meminfo_s));
  1181. /* Initialize the DMA & KVA meminfo queues */
  1182. INIT_LIST_HEAD(&meminfo->dma_info.qe);
  1183. INIT_LIST_HEAD(&meminfo->kva_info.qe);
  1184. bfa_iocfc_meminfo(cfg, meminfo, bfa);
  1185. for (i = 0; hal_mods[i]; i++)
  1186. hal_mods[i]->meminfo(cfg, meminfo, bfa);
  1187. /* dma info setup */
  1188. bfa_mem_dma_setup(meminfo, port_dma, bfa_port_meminfo());
  1189. bfa_mem_dma_setup(meminfo, ablk_dma, bfa_ablk_meminfo());
  1190. bfa_mem_dma_setup(meminfo, cee_dma, bfa_cee_meminfo());
  1191. bfa_mem_dma_setup(meminfo, sfp_dma, bfa_sfp_meminfo());
  1192. bfa_mem_dma_setup(meminfo, flash_dma,
  1193. bfa_flash_meminfo(cfg->drvcfg.min_cfg));
  1194. bfa_mem_dma_setup(meminfo, diag_dma, bfa_diag_meminfo());
  1195. bfa_mem_dma_setup(meminfo, phy_dma,
  1196. bfa_phy_meminfo(cfg->drvcfg.min_cfg));
  1197. }
  1198. /*
  1199. * Use this function to do attach the driver instance with the BFA
  1200. * library. This function will not trigger any HW initialization
  1201. * process (which will be done in bfa_init() call)
  1202. *
  1203. * This call will fail, if the cap is out of range compared to
  1204. * pre-defined values within the BFA library
  1205. *
  1206. * @param[out] bfa Pointer to bfa_t.
  1207. * @param[in] bfad Opaque handle back to the driver's IOC structure
  1208. * @param[in] cfg Pointer to bfa_ioc_cfg_t. Should be same structure
  1209. * that was used in bfa_cfg_get_meminfo().
  1210. * @param[in] meminfo Pointer to bfa_meminfo_t. The driver should
  1211. * use the bfa_cfg_get_meminfo() call to
  1212. * find the memory blocks required, allocate the
  1213. * required memory and provide the starting addresses.
  1214. * @param[in] pcidev pointer to struct bfa_pcidev_s
  1215. *
  1216. * @return
  1217. * void
  1218. *
  1219. * Special Considerations:
  1220. *
  1221. * @note
  1222. *
  1223. */
  1224. void
  1225. bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
  1226. struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
  1227. {
  1228. int i;
  1229. struct bfa_mem_dma_s *dma_info, *dma_elem;
  1230. struct bfa_mem_kva_s *kva_info, *kva_elem;
  1231. struct list_head *dm_qe, *km_qe;
  1232. bfa->fcs = BFA_FALSE;
  1233. WARN_ON((cfg == NULL) || (meminfo == NULL));
  1234. /* Initialize memory pointers for iterative allocation */
  1235. dma_info = &meminfo->dma_info;
  1236. dma_info->kva_curp = dma_info->kva;
  1237. dma_info->dma_curp = dma_info->dma;
  1238. kva_info = &meminfo->kva_info;
  1239. kva_info->kva_curp = kva_info->kva;
  1240. list_for_each(dm_qe, &dma_info->qe) {
  1241. dma_elem = (struct bfa_mem_dma_s *) dm_qe;
  1242. dma_elem->kva_curp = dma_elem->kva;
  1243. dma_elem->dma_curp = dma_elem->dma;
  1244. }
  1245. list_for_each(km_qe, &kva_info->qe) {
  1246. kva_elem = (struct bfa_mem_kva_s *) km_qe;
  1247. kva_elem->kva_curp = kva_elem->kva;
  1248. }
  1249. bfa_iocfc_attach(bfa, bfad, cfg, pcidev);
  1250. for (i = 0; hal_mods[i]; i++)
  1251. hal_mods[i]->attach(bfa, bfad, cfg, pcidev);
  1252. bfa_com_port_attach(bfa);
  1253. bfa_com_ablk_attach(bfa);
  1254. bfa_com_cee_attach(bfa);
  1255. bfa_com_sfp_attach(bfa);
  1256. bfa_com_flash_attach(bfa, cfg->drvcfg.min_cfg);
  1257. bfa_com_diag_attach(bfa);
  1258. bfa_com_phy_attach(bfa, cfg->drvcfg.min_cfg);
  1259. }
  1260. /*
  1261. * Use this function to delete a BFA IOC. IOC should be stopped (by
  1262. * calling bfa_stop()) before this function call.
  1263. *
  1264. * @param[in] bfa - pointer to bfa_t.
  1265. *
  1266. * @return
  1267. * void
  1268. *
  1269. * Special Considerations:
  1270. *
  1271. * @note
  1272. */
  1273. void
  1274. bfa_detach(struct bfa_s *bfa)
  1275. {
  1276. int i;
  1277. for (i = 0; hal_mods[i]; i++)
  1278. hal_mods[i]->detach(bfa);
  1279. bfa_ioc_detach(&bfa->ioc);
  1280. }
  1281. void
  1282. bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q)
  1283. {
  1284. INIT_LIST_HEAD(comp_q);
  1285. list_splice_tail_init(&bfa->comp_q, comp_q);
  1286. }
  1287. void
  1288. bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q)
  1289. {
  1290. struct list_head *qe;
  1291. struct list_head *qen;
  1292. struct bfa_cb_qe_s *hcb_qe;
  1293. list_for_each_safe(qe, qen, comp_q) {
  1294. hcb_qe = (struct bfa_cb_qe_s *) qe;
  1295. hcb_qe->cbfn(hcb_qe->cbarg, BFA_TRUE);
  1296. }
  1297. }
  1298. void
  1299. bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q)
  1300. {
  1301. struct list_head *qe;
  1302. struct bfa_cb_qe_s *hcb_qe;
  1303. while (!list_empty(comp_q)) {
  1304. bfa_q_deq(comp_q, &qe);
  1305. hcb_qe = (struct bfa_cb_qe_s *) qe;
  1306. hcb_qe->cbfn(hcb_qe->cbarg, BFA_FALSE);
  1307. }
  1308. }
  1309. /*
  1310. * Return the list of PCI vendor/device id lists supported by this
  1311. * BFA instance.
  1312. */
  1313. void
  1314. bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids)
  1315. {
  1316. static struct bfa_pciid_s __pciids[] = {
  1317. {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_FC_8G2P},
  1318. {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_FC_8G1P},
  1319. {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT},
  1320. {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT_FC},
  1321. };
  1322. *npciids = sizeof(__pciids) / sizeof(__pciids[0]);
  1323. *pciids = __pciids;
  1324. }
  1325. /*
  1326. * Use this function query the default struct bfa_iocfc_cfg_s value (compiled
  1327. * into BFA layer). The OS driver can then turn back and overwrite entries that
  1328. * have been configured by the user.
  1329. *
  1330. * @param[in] cfg - pointer to bfa_ioc_cfg_t
  1331. *
  1332. * @return
  1333. * void
  1334. *
  1335. * Special Considerations:
  1336. * note
  1337. */
  1338. void
  1339. bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg)
  1340. {
  1341. cfg->fwcfg.num_fabrics = DEF_CFG_NUM_FABRICS;
  1342. cfg->fwcfg.num_lports = DEF_CFG_NUM_LPORTS;
  1343. cfg->fwcfg.num_rports = DEF_CFG_NUM_RPORTS;
  1344. cfg->fwcfg.num_ioim_reqs = DEF_CFG_NUM_IOIM_REQS;
  1345. cfg->fwcfg.num_tskim_reqs = DEF_CFG_NUM_TSKIM_REQS;
  1346. cfg->fwcfg.num_fcxp_reqs = DEF_CFG_NUM_FCXP_REQS;
  1347. cfg->fwcfg.num_uf_bufs = DEF_CFG_NUM_UF_BUFS;
  1348. cfg->fwcfg.num_cqs = DEF_CFG_NUM_CQS;
  1349. cfg->fwcfg.num_fwtio_reqs = 0;
  1350. cfg->drvcfg.num_reqq_elems = DEF_CFG_NUM_REQQ_ELEMS;
  1351. cfg->drvcfg.num_rspq_elems = DEF_CFG_NUM_RSPQ_ELEMS;
  1352. cfg->drvcfg.num_sgpgs = DEF_CFG_NUM_SGPGS;
  1353. cfg->drvcfg.num_sboot_tgts = DEF_CFG_NUM_SBOOT_TGTS;
  1354. cfg->drvcfg.num_sboot_luns = DEF_CFG_NUM_SBOOT_LUNS;
  1355. cfg->drvcfg.path_tov = BFA_FCPIM_PATHTOV_DEF;
  1356. cfg->drvcfg.ioc_recover = BFA_FALSE;
  1357. cfg->drvcfg.delay_comp = BFA_FALSE;
  1358. }
  1359. void
  1360. bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg)
  1361. {
  1362. bfa_cfg_get_default(cfg);
  1363. cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MIN;
  1364. cfg->fwcfg.num_tskim_reqs = BFA_TSKIM_MIN;
  1365. cfg->fwcfg.num_fcxp_reqs = BFA_FCXP_MIN;
  1366. cfg->fwcfg.num_uf_bufs = BFA_UF_MIN;
  1367. cfg->fwcfg.num_rports = BFA_RPORT_MIN;
  1368. cfg->fwcfg.num_fwtio_reqs = 0;
  1369. cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN;
  1370. cfg->drvcfg.num_reqq_elems = BFA_REQQ_NELEMS_MIN;
  1371. cfg->drvcfg.num_rspq_elems = BFA_RSPQ_NELEMS_MIN;
  1372. cfg->drvcfg.min_cfg = BFA_TRUE;
  1373. }