bfa_core.c 41 KB

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