bfa_core.c 41 KB

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