bfa_core.c 51 KB

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