blob: 035c9d5caf01ce62453991dd46e62c35dd802863 [file] [log] [blame]
Jing Huang7725ccf2009-09-23 17:46:15 -07001/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07002 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
Jing Huang7725ccf2009-09-23 17:46:15 -07003 * 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
Maggie Zhangf16a1752010-12-09 19:12:32 -080018#include "bfad_drv.h"
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070019#include "bfa_modules.h"
Krishna Gudipati11189202011-06-13 15:50:35 -070020#include "bfi_reg.h"
Jing Huang7725ccf2009-09-23 17:46:15 -070021
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070022BFA_TRC_FILE(HAL, CORE);
Jing Huang7725ccf2009-09-23 17:46:15 -070023
Jing Huang5fbe25c2010-10-18 17:17:23 -070024/*
Maggie Zhangb77ee1f2010-12-09 19:09:26 -080025 * BFA module list terminated by NULL
26 */
27static struct bfa_module_s *hal_mods[] = {
Krishna Gudipati3d7fc662011-06-24 20:28:17 -070028 &hal_mod_fcdiag,
Maggie Zhangb77ee1f2010-12-09 19:09:26 -080029 &hal_mod_sgpg,
30 &hal_mod_fcport,
31 &hal_mod_fcxp,
32 &hal_mod_lps,
33 &hal_mod_uf,
34 &hal_mod_rport,
Krishna Gudipatie2187d72011-06-13 15:53:58 -070035 &hal_mod_fcp,
Krishna Gudipati45c5dc12011-07-20 17:03:46 -070036 &hal_mod_dconf,
Maggie Zhangb77ee1f2010-12-09 19:09:26 -080037 NULL
38};
39
40/*
41 * Message handlers for various modules.
42 */
43static bfa_isr_func_t bfa_isrs[BFI_MC_MAX] = {
44 bfa_isr_unhandled, /* NONE */
45 bfa_isr_unhandled, /* BFI_MC_IOC */
Krishna Gudipati3d7fc662011-06-24 20:28:17 -070046 bfa_fcdiag_intr, /* BFI_MC_DIAG */
Maggie Zhangb77ee1f2010-12-09 19:09:26 -080047 bfa_isr_unhandled, /* BFI_MC_FLASH */
48 bfa_isr_unhandled, /* BFI_MC_CEE */
49 bfa_fcport_isr, /* BFI_MC_FCPORT */
50 bfa_isr_unhandled, /* BFI_MC_IOCFC */
51 bfa_isr_unhandled, /* BFI_MC_LL */
52 bfa_uf_isr, /* BFI_MC_UF */
53 bfa_fcxp_isr, /* BFI_MC_FCXP */
54 bfa_lps_isr, /* BFI_MC_LPS */
55 bfa_rport_isr, /* BFI_MC_RPORT */
Krishna Gudipatie2187d72011-06-13 15:53:58 -070056 bfa_itn_isr, /* BFI_MC_ITN */
Maggie Zhangb77ee1f2010-12-09 19:09:26 -080057 bfa_isr_unhandled, /* BFI_MC_IOIM_READ */
58 bfa_isr_unhandled, /* BFI_MC_IOIM_WRITE */
59 bfa_isr_unhandled, /* BFI_MC_IOIM_IO */
60 bfa_ioim_isr, /* BFI_MC_IOIM */
61 bfa_ioim_good_comp_isr, /* BFI_MC_IOIM_IOCOM */
62 bfa_tskim_isr, /* BFI_MC_TSKIM */
63 bfa_isr_unhandled, /* BFI_MC_SBOOT */
64 bfa_isr_unhandled, /* BFI_MC_IPFC */
65 bfa_isr_unhandled, /* BFI_MC_PORT */
66 bfa_isr_unhandled, /* --------- */
67 bfa_isr_unhandled, /* --------- */
68 bfa_isr_unhandled, /* --------- */
69 bfa_isr_unhandled, /* --------- */
70 bfa_isr_unhandled, /* --------- */
71 bfa_isr_unhandled, /* --------- */
72 bfa_isr_unhandled, /* --------- */
73 bfa_isr_unhandled, /* --------- */
74 bfa_isr_unhandled, /* --------- */
75 bfa_isr_unhandled, /* --------- */
76};
77/*
78 * Message handlers for mailbox command classes
79 */
80static bfa_ioc_mbox_mcfunc_t bfa_mbox_isrs[BFI_MC_MAX] = {
81 NULL,
82 NULL, /* BFI_MC_IOC */
83 NULL, /* BFI_MC_DIAG */
84 NULL, /* BFI_MC_FLASH */
85 NULL, /* BFI_MC_CEE */
86 NULL, /* BFI_MC_PORT */
87 bfa_iocfc_isr, /* BFI_MC_IOCFC */
88 NULL,
89};
90
91
92
93static void
Krishna Gudipati45070252011-06-24 20:24:29 -070094bfa_com_port_attach(struct bfa_s *bfa)
Maggie Zhangb77ee1f2010-12-09 19:09:26 -080095{
96 struct bfa_port_s *port = &bfa->modules.port;
Krishna Gudipati45070252011-06-24 20:24:29 -070097 struct bfa_mem_dma_s *port_dma = BFA_MEM_PORT_DMA(bfa);
Maggie Zhangb77ee1f2010-12-09 19:09:26 -080098
Maggie Zhangb77ee1f2010-12-09 19:09:26 -080099 bfa_port_attach(port, &bfa->ioc, bfa, bfa->trcmod);
Krishna Gudipati45070252011-06-24 20:24:29 -0700100 bfa_port_mem_claim(port, port_dma->kva_curp, port_dma->dma_curp);
Maggie Zhangb77ee1f2010-12-09 19:09:26 -0800101}
102
103/*
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700104 * ablk module attach
105 */
106static void
Krishna Gudipati45070252011-06-24 20:24:29 -0700107bfa_com_ablk_attach(struct bfa_s *bfa)
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700108{
109 struct bfa_ablk_s *ablk = &bfa->modules.ablk;
Krishna Gudipati45070252011-06-24 20:24:29 -0700110 struct bfa_mem_dma_s *ablk_dma = BFA_MEM_ABLK_DMA(bfa);
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700111
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700112 bfa_ablk_attach(ablk, &bfa->ioc);
Krishna Gudipati45070252011-06-24 20:24:29 -0700113 bfa_ablk_memclaim(ablk, ablk_dma->kva_curp, ablk_dma->dma_curp);
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700114}
115
Krishna Gudipati148d6102011-06-24 20:25:36 -0700116static void
117bfa_com_cee_attach(struct bfa_s *bfa)
118{
119 struct bfa_cee_s *cee = &bfa->modules.cee;
120 struct bfa_mem_dma_s *cee_dma = BFA_MEM_CEE_DMA(bfa);
121
122 cee->trcmod = bfa->trcmod;
123 bfa_cee_attach(cee, &bfa->ioc, bfa);
124 bfa_cee_mem_claim(cee, cee_dma->kva_curp, cee_dma->dma_curp);
125}
126
Krishna Gudipati51e569a2011-06-24 20:26:25 -0700127static void
128bfa_com_sfp_attach(struct bfa_s *bfa)
129{
130 struct bfa_sfp_s *sfp = BFA_SFP_MOD(bfa);
131 struct bfa_mem_dma_s *sfp_dma = BFA_MEM_SFP_DMA(bfa);
132
133 bfa_sfp_attach(sfp, &bfa->ioc, bfa, bfa->trcmod);
134 bfa_sfp_memclaim(sfp, sfp_dma->kva_curp, sfp_dma->dma_curp);
135}
136
Krishna Gudipati5a54b1d2011-06-24 20:27:13 -0700137static void
138bfa_com_flash_attach(struct bfa_s *bfa, bfa_boolean_t mincfg)
139{
140 struct bfa_flash_s *flash = BFA_FLASH(bfa);
141 struct bfa_mem_dma_s *flash_dma = BFA_MEM_FLASH_DMA(bfa);
142
143 bfa_flash_attach(flash, &bfa->ioc, bfa, bfa->trcmod, mincfg);
144 bfa_flash_memclaim(flash, flash_dma->kva_curp,
145 flash_dma->dma_curp, mincfg);
146}
147
Krishna Gudipati3d7fc662011-06-24 20:28:17 -0700148static void
149bfa_com_diag_attach(struct bfa_s *bfa)
150{
151 struct bfa_diag_s *diag = BFA_DIAG_MOD(bfa);
152 struct bfa_mem_dma_s *diag_dma = BFA_MEM_DIAG_DMA(bfa);
153
154 bfa_diag_attach(diag, &bfa->ioc, bfa, bfa_fcport_beacon, bfa->trcmod);
155 bfa_diag_memclaim(diag, diag_dma->kva_curp, diag_dma->dma_curp);
156}
157
Krishna Gudipati3350d982011-06-24 20:28:37 -0700158static void
159bfa_com_phy_attach(struct bfa_s *bfa, bfa_boolean_t mincfg)
160{
161 struct bfa_phy_s *phy = BFA_PHY(bfa);
162 struct bfa_mem_dma_s *phy_dma = BFA_MEM_PHY_DMA(bfa);
163
164 bfa_phy_attach(phy, &bfa->ioc, bfa, bfa->trcmod, mincfg);
165 bfa_phy_memclaim(phy, phy_dma->kva_curp, phy_dma->dma_curp, mincfg);
166}
167
Krishna Gudipati1a4d8e12011-06-24 20:22:28 -0700168/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700169 * BFA IOC FC related definitions
170 */
171
Jing Huang5fbe25c2010-10-18 17:17:23 -0700172/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700173 * IOC local definitions
174 */
175#define BFA_IOCFC_TOV 5000 /* msecs */
176
177enum {
178 BFA_IOCFC_ACT_NONE = 0,
179 BFA_IOCFC_ACT_INIT = 1,
180 BFA_IOCFC_ACT_STOP = 2,
181 BFA_IOCFC_ACT_DISABLE = 3,
Krishna Gudipati60138062011-06-24 20:25:15 -0700182 BFA_IOCFC_ACT_ENABLE = 4,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700183};
184
185#define DEF_CFG_NUM_FABRICS 1
186#define DEF_CFG_NUM_LPORTS 256
187#define DEF_CFG_NUM_CQS 4
188#define DEF_CFG_NUM_IOIM_REQS (BFA_IOIM_MAX)
189#define DEF_CFG_NUM_TSKIM_REQS 128
190#define DEF_CFG_NUM_FCXP_REQS 64
191#define DEF_CFG_NUM_UF_BUFS 64
192#define DEF_CFG_NUM_RPORTS 1024
193#define DEF_CFG_NUM_ITNIMS (DEF_CFG_NUM_RPORTS)
194#define DEF_CFG_NUM_TINS 256
195
196#define DEF_CFG_NUM_SGPGS 2048
197#define DEF_CFG_NUM_REQQ_ELEMS 256
198#define DEF_CFG_NUM_RSPQ_ELEMS 64
199#define DEF_CFG_NUM_SBOOT_TGTS 16
200#define DEF_CFG_NUM_SBOOT_LUNS 16
201
Jing Huang5fbe25c2010-10-18 17:17:23 -0700202/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700203 * forward declaration for IOC FC functions
204 */
205static void bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status);
206static void bfa_iocfc_disable_cbfn(void *bfa_arg);
207static void bfa_iocfc_hbfail_cbfn(void *bfa_arg);
208static void bfa_iocfc_reset_cbfn(void *bfa_arg);
209static struct bfa_ioc_cbfn_s bfa_iocfc_cbfn;
210
Jing Huang5fbe25c2010-10-18 17:17:23 -0700211/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700212 * BFA Interrupt handling functions
213 */
214static void
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700215bfa_reqq_resume(struct bfa_s *bfa, int qid)
216{
217 struct list_head *waitq, *qe, *qen;
218 struct bfa_reqq_wait_s *wqe;
219
220 waitq = bfa_reqq(bfa, qid);
221 list_for_each_safe(qe, qen, waitq) {
Jing Huang5fbe25c2010-10-18 17:17:23 -0700222 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700223 * Callback only as long as there is room in request queue
224 */
225 if (bfa_reqq_full(bfa, qid))
226 break;
227
228 list_del(qe);
229 wqe = (struct bfa_reqq_wait_s *) qe;
230 wqe->qresume(wqe->cbarg);
231 }
232}
233
Krishna Gudipati1f670962012-03-13 17:38:15 -0700234bfa_boolean_t
Krishna Gudipati11189202011-06-13 15:50:35 -0700235bfa_isr_rspq(struct bfa_s *bfa, int qid)
236{
237 struct bfi_msg_s *m;
238 u32 pi, ci;
239 struct list_head *waitq;
Krishna Gudipati1f670962012-03-13 17:38:15 -0700240 bfa_boolean_t ret;
Krishna Gudipati11189202011-06-13 15:50:35 -0700241
Krishna Gudipati11189202011-06-13 15:50:35 -0700242 ci = bfa_rspq_ci(bfa, qid);
243 pi = bfa_rspq_pi(bfa, qid);
244
Krishna Gudipati1f670962012-03-13 17:38:15 -0700245 ret = (ci != pi);
246
Krishna Gudipati11189202011-06-13 15:50:35 -0700247 while (ci != pi) {
248 m = bfa_rspq_elem(bfa, qid, ci);
249 WARN_ON(m->mhdr.msg_class >= BFI_MC_MAX);
250
251 bfa_isrs[m->mhdr.msg_class] (bfa, m);
252 CQ_INCR(ci, bfa->iocfc.cfg.drvcfg.num_rspq_elems);
253 }
254
255 /*
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700256 * acknowledge RME completions and update CI
Krishna Gudipati11189202011-06-13 15:50:35 -0700257 */
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700258 bfa_isr_rspq_ack(bfa, qid, ci);
Krishna Gudipati11189202011-06-13 15:50:35 -0700259
260 /*
261 * Resume any pending requests in the corresponding reqq.
262 */
263 waitq = bfa_reqq(bfa, qid);
264 if (!list_empty(waitq))
265 bfa_reqq_resume(bfa, qid);
Krishna Gudipati1f670962012-03-13 17:38:15 -0700266
267 return ret;
Krishna Gudipati11189202011-06-13 15:50:35 -0700268}
269
270static inline void
271bfa_isr_reqq(struct bfa_s *bfa, int qid)
272{
273 struct list_head *waitq;
274
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700275 bfa_isr_reqq_ack(bfa, qid);
Krishna Gudipati11189202011-06-13 15:50:35 -0700276
277 /*
278 * Resume any pending requests in the corresponding reqq.
279 */
280 waitq = bfa_reqq(bfa, qid);
281 if (!list_empty(waitq))
282 bfa_reqq_resume(bfa, qid);
283}
284
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700285void
286bfa_msix_all(struct bfa_s *bfa, int vec)
287{
Krishna Gudipati10a07372011-06-24 20:23:38 -0700288 u32 intr, qintr;
289 int queue;
290
291 intr = readl(bfa->iocfc.bfa_regs.intr_status);
292 if (!intr)
293 return;
294
295 /*
296 * RME completion queue interrupt
297 */
298 qintr = intr & __HFN_INT_RME_MASK;
299 if (qintr && bfa->queue_process) {
300 for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++)
301 bfa_isr_rspq(bfa, queue);
302 }
303
304 intr &= ~qintr;
305 if (!intr)
306 return;
307
308 /*
309 * CPE completion queue interrupt
310 */
311 qintr = intr & __HFN_INT_CPE_MASK;
312 if (qintr && bfa->queue_process) {
313 for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++)
314 bfa_isr_reqq(bfa, queue);
315 }
316 intr &= ~qintr;
317 if (!intr)
318 return;
319
320 bfa_msix_lpu_err(bfa, intr);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700321}
322
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700323bfa_boolean_t
324bfa_intx(struct bfa_s *bfa)
325{
326 u32 intr, qintr;
327 int queue;
Krishna Gudipati1f670962012-03-13 17:38:15 -0700328 bfa_boolean_t rspq_comp = BFA_FALSE;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700329
Jing Huang53440262010-10-18 17:12:29 -0700330 intr = readl(bfa->iocfc.bfa_regs.intr_status);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700331
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700332 qintr = intr & (__HFN_INT_RME_MASK | __HFN_INT_CPE_MASK);
333 if (qintr)
334 writel(qintr, bfa->iocfc.bfa_regs.intr_status);
335
Jing Huang5fbe25c2010-10-18 17:17:23 -0700336 /*
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700337 * Unconditional RME completion queue interrupt
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700338 */
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700339 if (bfa->queue_process) {
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700340 for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++)
Krishna Gudipati1f670962012-03-13 17:38:15 -0700341 if (bfa_isr_rspq(bfa, queue))
342 rspq_comp = BFA_TRUE;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700343 }
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700344
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700345 if (!intr)
Krishna Gudipati1f670962012-03-13 17:38:15 -0700346 return (qintr | rspq_comp) ? BFA_TRUE : BFA_FALSE;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700347
Jing Huang5fbe25c2010-10-18 17:17:23 -0700348 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700349 * CPE completion queue interrupt
350 */
351 qintr = intr & __HFN_INT_CPE_MASK;
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700352 if (qintr && bfa->queue_process) {
353 for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++)
354 bfa_isr_reqq(bfa, queue);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700355 }
356 intr &= ~qintr;
357 if (!intr)
358 return BFA_TRUE;
359
360 bfa_msix_lpu_err(bfa, intr);
361
362 return BFA_TRUE;
363}
364
365void
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700366bfa_isr_enable(struct bfa_s *bfa)
367{
Krishna Gudipati11189202011-06-13 15:50:35 -0700368 u32 umsk;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700369 int pci_func = bfa_ioc_pcifn(&bfa->ioc);
370
371 bfa_trc(bfa, pci_func);
372
Krishna Gudipati775c7742011-06-13 15:52:12 -0700373 bfa_msix_ctrl_install(bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700374
Krishna Gudipati11189202011-06-13 15:50:35 -0700375 if (bfa_asic_id_ct2(bfa->ioc.pcidev.device_id)) {
376 umsk = __HFN_INT_ERR_MASK_CT2;
377 umsk |= pci_func == 0 ?
378 __HFN_INT_FN0_MASK_CT2 : __HFN_INT_FN1_MASK_CT2;
379 } else {
380 umsk = __HFN_INT_ERR_MASK;
381 umsk |= pci_func == 0 ? __HFN_INT_FN0_MASK : __HFN_INT_FN1_MASK;
382 }
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700383
Krishna Gudipati11189202011-06-13 15:50:35 -0700384 writel(umsk, bfa->iocfc.bfa_regs.intr_status);
385 writel(~umsk, bfa->iocfc.bfa_regs.intr_mask);
386 bfa->iocfc.intr_mask = ~umsk;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700387 bfa_isr_mode_set(bfa, bfa->msix.nvecs != 0);
388}
389
390void
391bfa_isr_disable(struct bfa_s *bfa)
392{
393 bfa_isr_mode_set(bfa, BFA_FALSE);
Jing Huang53440262010-10-18 17:12:29 -0700394 writel(-1L, bfa->iocfc.bfa_regs.intr_mask);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700395 bfa_msix_uninstall(bfa);
396}
397
398void
Krishna Gudipati11189202011-06-13 15:50:35 -0700399bfa_msix_reqq(struct bfa_s *bfa, int vec)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700400{
Krishna Gudipati11189202011-06-13 15:50:35 -0700401 bfa_isr_reqq(bfa, vec - bfa->iocfc.hwif.cpe_vec_q0);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700402}
403
404void
405bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m)
406{
407 bfa_trc(bfa, m->mhdr.msg_class);
408 bfa_trc(bfa, m->mhdr.msg_id);
409 bfa_trc(bfa, m->mhdr.mtag.i2htok);
Jing Huangd4b671c2010-12-26 21:46:35 -0800410 WARN_ON(1);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700411 bfa_trc_stop(bfa->trcmod);
412}
413
414void
Krishna Gudipati11189202011-06-13 15:50:35 -0700415bfa_msix_rspq(struct bfa_s *bfa, int vec)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700416{
Krishna Gudipati11189202011-06-13 15:50:35 -0700417 bfa_isr_rspq(bfa, vec - bfa->iocfc.hwif.rme_vec_q0);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700418}
419
420void
421bfa_msix_lpu_err(struct bfa_s *bfa, int vec)
422{
423 u32 intr, curr_value;
Krishna Gudipati11189202011-06-13 15:50:35 -0700424 bfa_boolean_t lpu_isr, halt_isr, pss_isr;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700425
Jing Huang53440262010-10-18 17:12:29 -0700426 intr = readl(bfa->iocfc.bfa_regs.intr_status);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700427
Krishna Gudipati11189202011-06-13 15:50:35 -0700428 if (bfa_asic_id_ct2(bfa->ioc.pcidev.device_id)) {
429 halt_isr = intr & __HFN_INT_CPQ_HALT_CT2;
430 pss_isr = intr & __HFN_INT_ERR_PSS_CT2;
431 lpu_isr = intr & (__HFN_INT_MBOX_LPU0_CT2 |
432 __HFN_INT_MBOX_LPU1_CT2);
433 intr &= __HFN_INT_ERR_MASK_CT2;
434 } else {
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700435 halt_isr = bfa_asic_id_ct(bfa->ioc.pcidev.device_id) ?
436 (intr & __HFN_INT_LL_HALT) : 0;
Krishna Gudipati11189202011-06-13 15:50:35 -0700437 pss_isr = intr & __HFN_INT_ERR_PSS;
438 lpu_isr = intr & (__HFN_INT_MBOX_LPU0 | __HFN_INT_MBOX_LPU1);
439 intr &= __HFN_INT_ERR_MASK;
440 }
441
442 if (lpu_isr)
Maggie Zhangda99dcc2010-12-09 19:13:20 -0800443 bfa_ioc_mbox_isr(&bfa->ioc);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700444
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700445 if (intr) {
Krishna Gudipati11189202011-06-13 15:50:35 -0700446 if (halt_isr) {
Jing Huang5fbe25c2010-10-18 17:17:23 -0700447 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700448 * If LL_HALT bit is set then FW Init Halt LL Port
449 * Register needs to be cleared as well so Interrupt
450 * Status Register will be cleared.
451 */
Jing Huang53440262010-10-18 17:12:29 -0700452 curr_value = readl(bfa->ioc.ioc_regs.ll_halt);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700453 curr_value &= ~__FW_INIT_HALT_P;
Jing Huang53440262010-10-18 17:12:29 -0700454 writel(curr_value, bfa->ioc.ioc_regs.ll_halt);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700455 }
456
Krishna Gudipati11189202011-06-13 15:50:35 -0700457 if (pss_isr) {
Jing Huang5fbe25c2010-10-18 17:17:23 -0700458 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700459 * ERR_PSS bit needs to be cleared as well in case
460 * interrups are shared so driver's interrupt handler is
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300461 * still called even though it is already masked out.
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700462 */
Jing Huang53440262010-10-18 17:12:29 -0700463 curr_value = readl(
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700464 bfa->ioc.ioc_regs.pss_err_status_reg);
Jing Huang53440262010-10-18 17:12:29 -0700465 writel(curr_value,
466 bfa->ioc.ioc_regs.pss_err_status_reg);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700467 }
468
Jing Huang53440262010-10-18 17:12:29 -0700469 writel(intr, bfa->iocfc.bfa_regs.intr_status);
Maggie Zhangf7f738122010-12-09 19:08:43 -0800470 bfa_ioc_error_isr(&bfa->ioc);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700471 }
472}
473
Jing Huang5fbe25c2010-10-18 17:17:23 -0700474/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700475 * BFA IOC FC related functions
476 */
477
Jing Huang5fbe25c2010-10-18 17:17:23 -0700478/*
Maggie Zhangdf0f1932010-12-09 19:07:46 -0800479 * BFA IOC private functions
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700480 */
481
Jing Huang5fbe25c2010-10-18 17:17:23 -0700482/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700483 * Use the Mailbox interface to send BFI_IOCFC_H2I_CFG_REQ
484 */
485static void
486bfa_iocfc_send_cfg(void *bfa_arg)
487{
488 struct bfa_s *bfa = bfa_arg;
489 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
490 struct bfi_iocfc_cfg_req_s cfg_req;
491 struct bfi_iocfc_cfg_s *cfg_info = iocfc->cfginfo;
492 struct bfa_iocfc_cfg_s *cfg = &iocfc->cfg;
493 int i;
494
Jing Huangd4b671c2010-12-26 21:46:35 -0800495 WARN_ON(cfg->fwcfg.num_cqs > BFI_IOC_MAX_CQS);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700496 bfa_trc(bfa, cfg->fwcfg.num_cqs);
497
498 bfa_iocfc_reset_queues(bfa);
499
Jing Huang5fbe25c2010-10-18 17:17:23 -0700500 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700501 * initialize IOC configuration info
502 */
Krishna Gudipati10a07372011-06-24 20:23:38 -0700503 cfg_info->single_msix_vec = 0;
504 if (bfa->msix.nvecs == 1)
505 cfg_info->single_msix_vec = 1;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700506 cfg_info->endian_sig = BFI_IOC_ENDIAN_SIG;
507 cfg_info->num_cqs = cfg->fwcfg.num_cqs;
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700508 cfg_info->num_ioim_reqs = cpu_to_be16(cfg->fwcfg.num_ioim_reqs);
509 cfg_info->num_fwtio_reqs = cpu_to_be16(cfg->fwcfg.num_fwtio_reqs);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700510
511 bfa_dma_be_addr_set(cfg_info->cfgrsp_addr, iocfc->cfgrsp_dma.pa);
Jing Huang5fbe25c2010-10-18 17:17:23 -0700512 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700513 * dma map REQ and RSP circular queues and shadow pointers
514 */
515 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
516 bfa_dma_be_addr_set(cfg_info->req_cq_ba[i],
517 iocfc->req_cq_ba[i].pa);
518 bfa_dma_be_addr_set(cfg_info->req_shadow_ci[i],
519 iocfc->req_cq_shadow_ci[i].pa);
520 cfg_info->req_cq_elems[i] =
Jing Huangba816ea2010-10-18 17:10:50 -0700521 cpu_to_be16(cfg->drvcfg.num_reqq_elems);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700522
523 bfa_dma_be_addr_set(cfg_info->rsp_cq_ba[i],
524 iocfc->rsp_cq_ba[i].pa);
525 bfa_dma_be_addr_set(cfg_info->rsp_shadow_pi[i],
526 iocfc->rsp_cq_shadow_pi[i].pa);
527 cfg_info->rsp_cq_elems[i] =
Jing Huangba816ea2010-10-18 17:10:50 -0700528 cpu_to_be16(cfg->drvcfg.num_rspq_elems);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700529 }
530
Jing Huang5fbe25c2010-10-18 17:17:23 -0700531 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700532 * Enable interrupt coalescing if it is driver init path
533 * and not ioc disable/enable path.
534 */
535 if (!iocfc->cfgdone)
536 cfg_info->intr_attr.coalesce = BFA_TRUE;
537
538 iocfc->cfgdone = BFA_FALSE;
539
Jing Huang5fbe25c2010-10-18 17:17:23 -0700540 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700541 * dma map IOC configuration itself
542 */
543 bfi_h2i_set(cfg_req.mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_CFG_REQ,
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700544 bfa_fn_lpu(bfa));
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700545 bfa_dma_be_addr_set(cfg_req.ioc_cfg_dma_addr, iocfc->cfg_info.pa);
546
547 bfa_ioc_mbox_send(&bfa->ioc, &cfg_req,
548 sizeof(struct bfi_iocfc_cfg_req_s));
549}
550
551static void
552bfa_iocfc_init_mem(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
553 struct bfa_pcidev_s *pcidev)
554{
555 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
556
557 bfa->bfad = bfad;
558 iocfc->bfa = bfa;
559 iocfc->action = BFA_IOCFC_ACT_NONE;
560
Jing Huang6a18b162010-10-18 17:08:54 -0700561 iocfc->cfg = *cfg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700562
Jing Huang5fbe25c2010-10-18 17:17:23 -0700563 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700564 * Initialize chip specific handlers.
565 */
Krishna Gudipati11189202011-06-13 15:50:35 -0700566 if (bfa_asic_id_ctc(bfa_ioc_devid(&bfa->ioc))) {
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700567 iocfc->hwif.hw_reginit = bfa_hwct_reginit;
568 iocfc->hwif.hw_reqq_ack = bfa_hwct_reqq_ack;
569 iocfc->hwif.hw_rspq_ack = bfa_hwct_rspq_ack;
570 iocfc->hwif.hw_msix_init = bfa_hwct_msix_init;
Krishna Gudipati775c7742011-06-13 15:52:12 -0700571 iocfc->hwif.hw_msix_ctrl_install = bfa_hwct_msix_ctrl_install;
572 iocfc->hwif.hw_msix_queue_install = bfa_hwct_msix_queue_install;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700573 iocfc->hwif.hw_msix_uninstall = bfa_hwct_msix_uninstall;
574 iocfc->hwif.hw_isr_mode_set = bfa_hwct_isr_mode_set;
575 iocfc->hwif.hw_msix_getvecs = bfa_hwct_msix_getvecs;
576 iocfc->hwif.hw_msix_get_rme_range = bfa_hwct_msix_get_rme_range;
Krishna Gudipati11189202011-06-13 15:50:35 -0700577 iocfc->hwif.rme_vec_q0 = BFI_MSIX_RME_QMIN_CT;
578 iocfc->hwif.cpe_vec_q0 = BFI_MSIX_CPE_QMIN_CT;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700579 } else {
580 iocfc->hwif.hw_reginit = bfa_hwcb_reginit;
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700581 iocfc->hwif.hw_reqq_ack = NULL;
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700582 iocfc->hwif.hw_rspq_ack = bfa_hwcb_rspq_ack;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700583 iocfc->hwif.hw_msix_init = bfa_hwcb_msix_init;
Krishna Gudipati775c7742011-06-13 15:52:12 -0700584 iocfc->hwif.hw_msix_ctrl_install = bfa_hwcb_msix_ctrl_install;
585 iocfc->hwif.hw_msix_queue_install = bfa_hwcb_msix_queue_install;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700586 iocfc->hwif.hw_msix_uninstall = bfa_hwcb_msix_uninstall;
587 iocfc->hwif.hw_isr_mode_set = bfa_hwcb_isr_mode_set;
588 iocfc->hwif.hw_msix_getvecs = bfa_hwcb_msix_getvecs;
589 iocfc->hwif.hw_msix_get_rme_range = bfa_hwcb_msix_get_rme_range;
Krishna Gudipati11189202011-06-13 15:50:35 -0700590 iocfc->hwif.rme_vec_q0 = BFI_MSIX_RME_QMIN_CB +
591 bfa_ioc_pcifn(&bfa->ioc) * BFI_IOC_MAX_CQS;
592 iocfc->hwif.cpe_vec_q0 = BFI_MSIX_CPE_QMIN_CB +
593 bfa_ioc_pcifn(&bfa->ioc) * BFI_IOC_MAX_CQS;
594 }
595
596 if (bfa_asic_id_ct2(bfa_ioc_devid(&bfa->ioc))) {
597 iocfc->hwif.hw_reginit = bfa_hwct2_reginit;
598 iocfc->hwif.hw_isr_mode_set = NULL;
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700599 iocfc->hwif.hw_rspq_ack = bfa_hwct2_rspq_ack;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700600 }
601
602 iocfc->hwif.hw_reginit(bfa);
603 bfa->msix.nvecs = 0;
604}
605
606static void
Krishna Gudipati45070252011-06-24 20:24:29 -0700607bfa_iocfc_mem_claim(struct bfa_s *bfa, struct bfa_iocfc_cfg_s *cfg)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700608{
Krishna Gudipati45070252011-06-24 20:24:29 -0700609 u8 *dm_kva = NULL;
610 u64 dm_pa = 0;
611 int i, per_reqq_sz, per_rspq_sz, dbgsz;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700612 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
Krishna Gudipati45070252011-06-24 20:24:29 -0700613 struct bfa_mem_dma_s *ioc_dma = BFA_MEM_IOC_DMA(bfa);
614 struct bfa_mem_dma_s *iocfc_dma = BFA_MEM_IOCFC_DMA(bfa);
615 struct bfa_mem_dma_s *reqq_dma, *rspq_dma;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700616
Krishna Gudipati45070252011-06-24 20:24:29 -0700617 /* First allocate dma memory for IOC */
618 bfa_ioc_mem_claim(&bfa->ioc, bfa_mem_dma_virt(ioc_dma),
619 bfa_mem_dma_phys(ioc_dma));
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700620
Krishna Gudipati45070252011-06-24 20:24:29 -0700621 /* Claim DMA-able memory for the request/response queues */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700622 per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ),
Krishna Gudipati45070252011-06-24 20:24:29 -0700623 BFA_DMA_ALIGN_SZ);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700624 per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ),
Krishna Gudipati45070252011-06-24 20:24:29 -0700625 BFA_DMA_ALIGN_SZ);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700626
627 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
Krishna Gudipati45070252011-06-24 20:24:29 -0700628 reqq_dma = BFA_MEM_REQQ_DMA(bfa, i);
629 iocfc->req_cq_ba[i].kva = bfa_mem_dma_virt(reqq_dma);
630 iocfc->req_cq_ba[i].pa = bfa_mem_dma_phys(reqq_dma);
631 memset(iocfc->req_cq_ba[i].kva, 0, per_reqq_sz);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700632
Krishna Gudipati45070252011-06-24 20:24:29 -0700633 rspq_dma = BFA_MEM_RSPQ_DMA(bfa, i);
634 iocfc->rsp_cq_ba[i].kva = bfa_mem_dma_virt(rspq_dma);
635 iocfc->rsp_cq_ba[i].pa = bfa_mem_dma_phys(rspq_dma);
636 memset(iocfc->rsp_cq_ba[i].kva, 0, per_rspq_sz);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700637 }
638
Krishna Gudipati45070252011-06-24 20:24:29 -0700639 /* Claim IOCFC dma memory - for shadow CI/PI */
640 dm_kva = bfa_mem_dma_virt(iocfc_dma);
641 dm_pa = bfa_mem_dma_phys(iocfc_dma);
642
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700643 for (i = 0; i < cfg->fwcfg.num_cqs; i++) {
644 iocfc->req_cq_shadow_ci[i].kva = dm_kva;
645 iocfc->req_cq_shadow_ci[i].pa = dm_pa;
646 dm_kva += BFA_CACHELINE_SZ;
647 dm_pa += BFA_CACHELINE_SZ;
648
649 iocfc->rsp_cq_shadow_pi[i].kva = dm_kva;
650 iocfc->rsp_cq_shadow_pi[i].pa = dm_pa;
651 dm_kva += BFA_CACHELINE_SZ;
652 dm_pa += BFA_CACHELINE_SZ;
653 }
654
Krishna Gudipati45070252011-06-24 20:24:29 -0700655 /* Claim IOCFC dma memory - for the config info page */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700656 bfa->iocfc.cfg_info.kva = dm_kva;
657 bfa->iocfc.cfg_info.pa = dm_pa;
658 bfa->iocfc.cfginfo = (struct bfi_iocfc_cfg_s *) dm_kva;
659 dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
660 dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
661
Krishna Gudipati45070252011-06-24 20:24:29 -0700662 /* Claim IOCFC dma memory - for the config response */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700663 bfa->iocfc.cfgrsp_dma.kva = dm_kva;
664 bfa->iocfc.cfgrsp_dma.pa = dm_pa;
665 bfa->iocfc.cfgrsp = (struct bfi_iocfc_cfgrsp_s *) dm_kva;
Krishna Gudipati45070252011-06-24 20:24:29 -0700666 dm_kva += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
667 BFA_CACHELINE_SZ);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700668 dm_pa += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
Krishna Gudipati45070252011-06-24 20:24:29 -0700669 BFA_CACHELINE_SZ);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700670
Krishna Gudipati45070252011-06-24 20:24:29 -0700671 /* Claim IOCFC kva memory */
Maggie Zhangf7f738122010-12-09 19:08:43 -0800672 dbgsz = (bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700673 if (dbgsz > 0) {
Krishna Gudipati45070252011-06-24 20:24:29 -0700674 bfa_ioc_debug_memclaim(&bfa->ioc, bfa_mem_kva_curp(iocfc));
675 bfa_mem_kva_curp(iocfc) += dbgsz;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700676 }
677}
678
Jing Huang5fbe25c2010-10-18 17:17:23 -0700679/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700680 * Start BFA submodules.
681 */
682static void
683bfa_iocfc_start_submod(struct bfa_s *bfa)
684{
685 int i;
686
Krishna Gudipati775c7742011-06-13 15:52:12 -0700687 bfa->queue_process = BFA_TRUE;
Krishna Gudipati11189202011-06-13 15:50:35 -0700688 for (i = 0; i < BFI_IOC_MAX_CQS; i++)
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700689 bfa_isr_rspq_ack(bfa, i, bfa_rspq_ci(bfa, i));
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700690
691 for (i = 0; hal_mods[i]; i++)
692 hal_mods[i]->start(bfa);
693}
694
Jing Huang5fbe25c2010-10-18 17:17:23 -0700695/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700696 * Disable BFA submodules.
697 */
698static void
699bfa_iocfc_disable_submod(struct bfa_s *bfa)
700{
701 int i;
702
703 for (i = 0; hal_mods[i]; i++)
704 hal_mods[i]->iocdisable(bfa);
705}
706
707static void
708bfa_iocfc_init_cb(void *bfa_arg, bfa_boolean_t complete)
709{
710 struct bfa_s *bfa = bfa_arg;
711
712 if (complete) {
Krishna Gudipati45c5dc12011-07-20 17:03:46 -0700713 if (bfa->iocfc.cfgdone && BFA_DCONF_MOD(bfa)->flashdone)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700714 bfa_cb_init(bfa->bfad, BFA_STATUS_OK);
715 else
716 bfa_cb_init(bfa->bfad, BFA_STATUS_FAILED);
717 } else {
718 if (bfa->iocfc.cfgdone)
719 bfa->iocfc.action = BFA_IOCFC_ACT_NONE;
720 }
721}
722
723static void
724bfa_iocfc_stop_cb(void *bfa_arg, bfa_boolean_t compl)
725{
726 struct bfa_s *bfa = bfa_arg;
727 struct bfad_s *bfad = bfa->bfad;
728
729 if (compl)
730 complete(&bfad->comp);
731 else
732 bfa->iocfc.action = BFA_IOCFC_ACT_NONE;
733}
734
735static void
Krishna Gudipati60138062011-06-24 20:25:15 -0700736bfa_iocfc_enable_cb(void *bfa_arg, bfa_boolean_t compl)
737{
738 struct bfa_s *bfa = bfa_arg;
739 struct bfad_s *bfad = bfa->bfad;
740
741 if (compl)
742 complete(&bfad->enable_comp);
743}
744
745static void
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700746bfa_iocfc_disable_cb(void *bfa_arg, bfa_boolean_t compl)
747{
748 struct bfa_s *bfa = bfa_arg;
749 struct bfad_s *bfad = bfa->bfad;
750
751 if (compl)
752 complete(&bfad->disable_comp);
753}
754
Krishna Gudipati11189202011-06-13 15:50:35 -0700755/**
756 * configure queue registers from firmware response
757 */
758static void
759bfa_iocfc_qreg(struct bfa_s *bfa, struct bfi_iocfc_qreg_s *qreg)
760{
761 int i;
762 struct bfa_iocfc_regs_s *r = &bfa->iocfc.bfa_regs;
763 void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
764
765 for (i = 0; i < BFI_IOC_MAX_CQS; i++) {
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700766 bfa->iocfc.hw_qid[i] = qreg->hw_qid[i];
Krishna Gudipati11189202011-06-13 15:50:35 -0700767 r->cpe_q_ci[i] = kva + be32_to_cpu(qreg->cpe_q_ci_off[i]);
768 r->cpe_q_pi[i] = kva + be32_to_cpu(qreg->cpe_q_pi_off[i]);
769 r->cpe_q_ctrl[i] = kva + be32_to_cpu(qreg->cpe_qctl_off[i]);
770 r->rme_q_ci[i] = kva + be32_to_cpu(qreg->rme_q_ci_off[i]);
771 r->rme_q_pi[i] = kva + be32_to_cpu(qreg->rme_q_pi_off[i]);
772 r->rme_q_ctrl[i] = kva + be32_to_cpu(qreg->rme_qctl_off[i]);
773 }
774}
775
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700776static void
777bfa_iocfc_res_recfg(struct bfa_s *bfa, struct bfa_iocfc_fwcfg_s *fwcfg)
778{
779 bfa_fcxp_res_recfg(bfa, fwcfg->num_fcxp_reqs);
780 bfa_uf_res_recfg(bfa, fwcfg->num_uf_bufs);
781 bfa_rport_res_recfg(bfa, fwcfg->num_rports);
782 bfa_fcp_res_recfg(bfa, fwcfg->num_ioim_reqs);
783 bfa_tskim_res_recfg(bfa, fwcfg->num_tskim_reqs);
784}
785
Jing Huang5fbe25c2010-10-18 17:17:23 -0700786/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700787 * Update BFA configuration from firmware configuration.
788 */
789static void
790bfa_iocfc_cfgrsp(struct bfa_s *bfa)
791{
792 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
793 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
794 struct bfa_iocfc_fwcfg_s *fwcfg = &cfgrsp->fwcfg;
795
796 fwcfg->num_cqs = fwcfg->num_cqs;
Jing Huangba816ea2010-10-18 17:10:50 -0700797 fwcfg->num_ioim_reqs = be16_to_cpu(fwcfg->num_ioim_reqs);
Krishna Gudipatie2187d72011-06-13 15:53:58 -0700798 fwcfg->num_fwtio_reqs = be16_to_cpu(fwcfg->num_fwtio_reqs);
Jing Huangba816ea2010-10-18 17:10:50 -0700799 fwcfg->num_tskim_reqs = be16_to_cpu(fwcfg->num_tskim_reqs);
800 fwcfg->num_fcxp_reqs = be16_to_cpu(fwcfg->num_fcxp_reqs);
801 fwcfg->num_uf_bufs = be16_to_cpu(fwcfg->num_uf_bufs);
802 fwcfg->num_rports = be16_to_cpu(fwcfg->num_rports);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700803
804 iocfc->cfgdone = BFA_TRUE;
805
Jing Huang5fbe25c2010-10-18 17:17:23 -0700806 /*
Krishna Gudipati11189202011-06-13 15:50:35 -0700807 * configure queue register offsets as learnt from firmware
808 */
809 bfa_iocfc_qreg(bfa, &cfgrsp->qreg);
810
811 /*
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700812 * Re-configure resources as learnt from Firmware
813 */
814 bfa_iocfc_res_recfg(bfa, fwcfg);
815
816 /*
Krishna Gudipati775c7742011-06-13 15:52:12 -0700817 * Install MSIX queue handlers
818 */
819 bfa_msix_queue_install(bfa);
820
821 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700822 * Configuration is complete - initialize/start submodules
823 */
824 bfa_fcport_init(bfa);
825
Krishna Gudipati45c5dc12011-07-20 17:03:46 -0700826 if (iocfc->action == BFA_IOCFC_ACT_INIT) {
827 if (BFA_DCONF_MOD(bfa)->flashdone == BFA_TRUE)
828 bfa_cb_queue(bfa, &iocfc->init_hcb_qe,
829 bfa_iocfc_init_cb, bfa);
830 } else {
Krishna Gudipati60138062011-06-24 20:25:15 -0700831 if (bfa->iocfc.action == BFA_IOCFC_ACT_ENABLE)
832 bfa_cb_queue(bfa, &bfa->iocfc.en_hcb_qe,
833 bfa_iocfc_enable_cb, bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700834 bfa_iocfc_start_submod(bfa);
Krishna Gudipati60138062011-06-24 20:25:15 -0700835 }
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700836}
837void
838bfa_iocfc_reset_queues(struct bfa_s *bfa)
839{
840 int q;
841
842 for (q = 0; q < BFI_IOC_MAX_CQS; q++) {
843 bfa_reqq_ci(bfa, q) = 0;
844 bfa_reqq_pi(bfa, q) = 0;
845 bfa_rspq_ci(bfa, q) = 0;
846 bfa_rspq_pi(bfa, q) = 0;
847 }
848}
849
Krishna Gudipatia7141342011-06-24 20:23:19 -0700850/* Fabric Assigned Address specific functions */
851
852/*
853 * Check whether IOC is ready before sending command down
854 */
855static bfa_status_t
856bfa_faa_validate_request(struct bfa_s *bfa)
857{
858 enum bfa_ioc_type_e ioc_type = bfa_get_type(bfa);
859 u32 card_type = bfa->ioc.attr->card_type;
860
861 if (bfa_ioc_is_operational(&bfa->ioc)) {
862 if ((ioc_type != BFA_IOC_TYPE_FC) || bfa_mfg_is_mezz(card_type))
863 return BFA_STATUS_FEATURE_NOT_SUPPORTED;
864 } else {
865 if (!bfa_ioc_is_acq_addr(&bfa->ioc))
866 return BFA_STATUS_IOC_NON_OP;
867 }
868
869 return BFA_STATUS_OK;
870}
871
872bfa_status_t
873bfa_faa_enable(struct bfa_s *bfa, bfa_cb_iocfc_t cbfn, void *cbarg)
874{
875 struct bfi_faa_en_dis_s faa_enable_req;
876 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
877 bfa_status_t status;
878
879 iocfc->faa_args.faa_cb.faa_cbfn = cbfn;
880 iocfc->faa_args.faa_cb.faa_cbarg = cbarg;
881
882 status = bfa_faa_validate_request(bfa);
883 if (status != BFA_STATUS_OK)
884 return status;
885
886 if (iocfc->faa_args.busy == BFA_TRUE)
887 return BFA_STATUS_DEVBUSY;
888
889 if (iocfc->faa_args.faa_state == BFA_FAA_ENABLED)
890 return BFA_STATUS_FAA_ENABLED;
891
892 if (bfa_fcport_is_trunk_enabled(bfa))
893 return BFA_STATUS_ERROR_TRUNK_ENABLED;
894
895 bfa_fcport_cfg_faa(bfa, BFA_FAA_ENABLED);
896 iocfc->faa_args.busy = BFA_TRUE;
897
898 memset(&faa_enable_req, 0, sizeof(struct bfi_faa_en_dis_s));
899 bfi_h2i_set(faa_enable_req.mh, BFI_MC_IOCFC,
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700900 BFI_IOCFC_H2I_FAA_ENABLE_REQ, bfa_fn_lpu(bfa));
Krishna Gudipatia7141342011-06-24 20:23:19 -0700901
902 bfa_ioc_mbox_send(&bfa->ioc, &faa_enable_req,
903 sizeof(struct bfi_faa_en_dis_s));
904
905 return BFA_STATUS_OK;
906}
907
908bfa_status_t
909bfa_faa_disable(struct bfa_s *bfa, bfa_cb_iocfc_t cbfn,
910 void *cbarg)
911{
912 struct bfi_faa_en_dis_s faa_disable_req;
913 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
914 bfa_status_t status;
915
916 iocfc->faa_args.faa_cb.faa_cbfn = cbfn;
917 iocfc->faa_args.faa_cb.faa_cbarg = cbarg;
918
919 status = bfa_faa_validate_request(bfa);
920 if (status != BFA_STATUS_OK)
921 return status;
922
923 if (iocfc->faa_args.busy == BFA_TRUE)
924 return BFA_STATUS_DEVBUSY;
925
926 if (iocfc->faa_args.faa_state == BFA_FAA_DISABLED)
927 return BFA_STATUS_FAA_DISABLED;
928
929 bfa_fcport_cfg_faa(bfa, BFA_FAA_DISABLED);
930 iocfc->faa_args.busy = BFA_TRUE;
931
932 memset(&faa_disable_req, 0, sizeof(struct bfi_faa_en_dis_s));
933 bfi_h2i_set(faa_disable_req.mh, BFI_MC_IOCFC,
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700934 BFI_IOCFC_H2I_FAA_DISABLE_REQ, bfa_fn_lpu(bfa));
Krishna Gudipatia7141342011-06-24 20:23:19 -0700935
936 bfa_ioc_mbox_send(&bfa->ioc, &faa_disable_req,
937 sizeof(struct bfi_faa_en_dis_s));
938
939 return BFA_STATUS_OK;
940}
941
942bfa_status_t
943bfa_faa_query(struct bfa_s *bfa, struct bfa_faa_attr_s *attr,
944 bfa_cb_iocfc_t cbfn, void *cbarg)
945{
946 struct bfi_faa_query_s faa_attr_req;
947 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
948 bfa_status_t status;
949
950 iocfc->faa_args.faa_attr = attr;
951 iocfc->faa_args.faa_cb.faa_cbfn = cbfn;
952 iocfc->faa_args.faa_cb.faa_cbarg = cbarg;
953
954 status = bfa_faa_validate_request(bfa);
955 if (status != BFA_STATUS_OK)
956 return status;
957
958 if (iocfc->faa_args.busy == BFA_TRUE)
959 return BFA_STATUS_DEVBUSY;
960
961 iocfc->faa_args.busy = BFA_TRUE;
962 memset(&faa_attr_req, 0, sizeof(struct bfi_faa_query_s));
963 bfi_h2i_set(faa_attr_req.mh, BFI_MC_IOCFC,
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700964 BFI_IOCFC_H2I_FAA_QUERY_REQ, bfa_fn_lpu(bfa));
Krishna Gudipatia7141342011-06-24 20:23:19 -0700965
966 bfa_ioc_mbox_send(&bfa->ioc, &faa_attr_req,
967 sizeof(struct bfi_faa_query_s));
968
969 return BFA_STATUS_OK;
970}
971
972/*
973 * FAA enable response
974 */
975static void
976bfa_faa_enable_reply(struct bfa_iocfc_s *iocfc,
977 struct bfi_faa_en_dis_rsp_s *rsp)
978{
979 void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg;
980 bfa_status_t status = rsp->status;
981
982 WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn);
983
984 iocfc->faa_args.faa_cb.faa_cbfn(cbarg, status);
985 iocfc->faa_args.busy = BFA_FALSE;
986}
987
988/*
989 * FAA disable response
990 */
991static void
992bfa_faa_disable_reply(struct bfa_iocfc_s *iocfc,
993 struct bfi_faa_en_dis_rsp_s *rsp)
994{
995 void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg;
996 bfa_status_t status = rsp->status;
997
998 WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn);
999
1000 iocfc->faa_args.faa_cb.faa_cbfn(cbarg, status);
1001 iocfc->faa_args.busy = BFA_FALSE;
1002}
1003
1004/*
1005 * FAA query response
1006 */
1007static void
1008bfa_faa_query_reply(struct bfa_iocfc_s *iocfc,
1009 bfi_faa_query_rsp_t *rsp)
1010{
1011 void *cbarg = iocfc->faa_args.faa_cb.faa_cbarg;
1012
1013 if (iocfc->faa_args.faa_attr) {
1014 iocfc->faa_args.faa_attr->faa = rsp->faa;
1015 iocfc->faa_args.faa_attr->faa_state = rsp->faa_status;
1016 iocfc->faa_args.faa_attr->pwwn_source = rsp->addr_source;
1017 }
1018
1019 WARN_ON(!iocfc->faa_args.faa_cb.faa_cbfn);
1020
1021 iocfc->faa_args.faa_cb.faa_cbfn(cbarg, BFA_STATUS_OK);
1022 iocfc->faa_args.busy = BFA_FALSE;
1023}
1024
Jing Huang5fbe25c2010-10-18 17:17:23 -07001025/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001026 * IOC enable request is complete
1027 */
1028static void
1029bfa_iocfc_enable_cbfn(void *bfa_arg, enum bfa_status status)
1030{
1031 struct bfa_s *bfa = bfa_arg;
1032
Krishna Gudipatia7141342011-06-24 20:23:19 -07001033 if (status == BFA_STATUS_FAA_ACQ_ADDR) {
1034 bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe,
1035 bfa_iocfc_init_cb, bfa);
1036 return;
1037 }
1038
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001039 if (status != BFA_STATUS_OK) {
1040 bfa_isr_disable(bfa);
1041 if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
1042 bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe,
1043 bfa_iocfc_init_cb, bfa);
Krishna Gudipati60138062011-06-24 20:25:15 -07001044 else if (bfa->iocfc.action == BFA_IOCFC_ACT_ENABLE)
1045 bfa_cb_queue(bfa, &bfa->iocfc.en_hcb_qe,
1046 bfa_iocfc_enable_cb, bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001047 return;
1048 }
1049
1050 bfa_iocfc_send_cfg(bfa);
Krishna Gudipati45c5dc12011-07-20 17:03:46 -07001051 bfa_dconf_modinit(bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001052}
1053
Jing Huang5fbe25c2010-10-18 17:17:23 -07001054/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001055 * IOC disable request is complete
1056 */
1057static void
1058bfa_iocfc_disable_cbfn(void *bfa_arg)
1059{
1060 struct bfa_s *bfa = bfa_arg;
1061
1062 bfa_isr_disable(bfa);
1063 bfa_iocfc_disable_submod(bfa);
1064
1065 if (bfa->iocfc.action == BFA_IOCFC_ACT_STOP)
1066 bfa_cb_queue(bfa, &bfa->iocfc.stop_hcb_qe, bfa_iocfc_stop_cb,
1067 bfa);
1068 else {
Jing Huangd4b671c2010-12-26 21:46:35 -08001069 WARN_ON(bfa->iocfc.action != BFA_IOCFC_ACT_DISABLE);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001070 bfa_cb_queue(bfa, &bfa->iocfc.dis_hcb_qe, bfa_iocfc_disable_cb,
1071 bfa);
1072 }
1073}
1074
Jing Huang5fbe25c2010-10-18 17:17:23 -07001075/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001076 * Notify sub-modules of hardware failure.
1077 */
1078static void
1079bfa_iocfc_hbfail_cbfn(void *bfa_arg)
1080{
1081 struct bfa_s *bfa = bfa_arg;
1082
Krishna Gudipati775c7742011-06-13 15:52:12 -07001083 bfa->queue_process = BFA_FALSE;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001084
1085 bfa_isr_disable(bfa);
1086 bfa_iocfc_disable_submod(bfa);
1087
1088 if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT)
1089 bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe, bfa_iocfc_init_cb,
1090 bfa);
1091}
1092
Jing Huang5fbe25c2010-10-18 17:17:23 -07001093/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001094 * Actions on chip-reset completion.
1095 */
1096static void
1097bfa_iocfc_reset_cbfn(void *bfa_arg)
1098{
1099 struct bfa_s *bfa = bfa_arg;
1100
1101 bfa_iocfc_reset_queues(bfa);
1102 bfa_isr_enable(bfa);
1103}
1104
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001105
Jing Huang5fbe25c2010-10-18 17:17:23 -07001106/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001107 * Query IOC memory requirement information.
1108 */
1109void
Krishna Gudipati45070252011-06-24 20:24:29 -07001110bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
1111 struct bfa_s *bfa)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001112{
Krishna Gudipati45070252011-06-24 20:24:29 -07001113 int q, per_reqq_sz, per_rspq_sz;
1114 struct bfa_mem_dma_s *ioc_dma = BFA_MEM_IOC_DMA(bfa);
1115 struct bfa_mem_dma_s *iocfc_dma = BFA_MEM_IOCFC_DMA(bfa);
1116 struct bfa_mem_kva_s *iocfc_kva = BFA_MEM_IOCFC_KVA(bfa);
1117 u32 dm_len = 0;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001118
Krishna Gudipati45070252011-06-24 20:24:29 -07001119 /* dma memory setup for IOC */
1120 bfa_mem_dma_setup(meminfo, ioc_dma,
1121 BFA_ROUNDUP(sizeof(struct bfi_ioc_attr_s), BFA_DMA_ALIGN_SZ));
1122
1123 /* dma memory setup for REQ/RSP queues */
1124 per_reqq_sz = BFA_ROUNDUP((cfg->drvcfg.num_reqq_elems * BFI_LMSG_SZ),
1125 BFA_DMA_ALIGN_SZ);
1126 per_rspq_sz = BFA_ROUNDUP((cfg->drvcfg.num_rspq_elems * BFI_LMSG_SZ),
1127 BFA_DMA_ALIGN_SZ);
1128
1129 for (q = 0; q < cfg->fwcfg.num_cqs; q++) {
1130 bfa_mem_dma_setup(meminfo, BFA_MEM_REQQ_DMA(bfa, q),
1131 per_reqq_sz);
1132 bfa_mem_dma_setup(meminfo, BFA_MEM_RSPQ_DMA(bfa, q),
1133 per_rspq_sz);
1134 }
1135
1136 /* IOCFC dma memory - calculate Shadow CI/PI size */
1137 for (q = 0; q < cfg->fwcfg.num_cqs; q++)
1138 dm_len += (2 * BFA_CACHELINE_SZ);
1139
1140 /* IOCFC dma memory - calculate config info / rsp size */
1141 dm_len += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfg_s), BFA_CACHELINE_SZ);
1142 dm_len += BFA_ROUNDUP(sizeof(struct bfi_iocfc_cfgrsp_s),
1143 BFA_CACHELINE_SZ);
1144
1145 /* dma memory setup for IOCFC */
1146 bfa_mem_dma_setup(meminfo, iocfc_dma, dm_len);
1147
1148 /* kva memory setup for IOCFC */
1149 bfa_mem_kva_setup(meminfo, iocfc_kva,
1150 ((bfa_auto_recover) ? BFA_DBG_FWTRC_LEN : 0));
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001151}
1152
Jing Huang5fbe25c2010-10-18 17:17:23 -07001153/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001154 * Query IOC memory requirement information.
1155 */
1156void
1157bfa_iocfc_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
Krishna Gudipati45070252011-06-24 20:24:29 -07001158 struct bfa_pcidev_s *pcidev)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001159{
1160 int i;
1161 struct bfa_ioc_s *ioc = &bfa->ioc;
1162
1163 bfa_iocfc_cbfn.enable_cbfn = bfa_iocfc_enable_cbfn;
1164 bfa_iocfc_cbfn.disable_cbfn = bfa_iocfc_disable_cbfn;
1165 bfa_iocfc_cbfn.hbfail_cbfn = bfa_iocfc_hbfail_cbfn;
1166 bfa_iocfc_cbfn.reset_cbfn = bfa_iocfc_reset_cbfn;
1167
1168 ioc->trcmod = bfa->trcmod;
1169 bfa_ioc_attach(&bfa->ioc, bfa, &bfa_iocfc_cbfn, &bfa->timer_mod);
1170
Krishna Gudipatid37779f2011-06-13 15:42:10 -07001171 bfa_ioc_pci_init(&bfa->ioc, pcidev, BFI_PCIFN_CLASS_FC);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001172 bfa_ioc_mbox_register(&bfa->ioc, bfa_mbox_isrs);
1173
1174 bfa_iocfc_init_mem(bfa, bfad, cfg, pcidev);
Krishna Gudipati45070252011-06-24 20:24:29 -07001175 bfa_iocfc_mem_claim(bfa, cfg);
Maggie Zhangf7f738122010-12-09 19:08:43 -08001176 INIT_LIST_HEAD(&bfa->timer_mod.timer_q);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001177
1178 INIT_LIST_HEAD(&bfa->comp_q);
1179 for (i = 0; i < BFI_IOC_MAX_CQS; i++)
1180 INIT_LIST_HEAD(&bfa->reqq_waitq[i]);
1181}
1182
Jing Huang5fbe25c2010-10-18 17:17:23 -07001183/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001184 * Query IOC memory requirement information.
1185 */
1186void
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001187bfa_iocfc_init(struct bfa_s *bfa)
1188{
1189 bfa->iocfc.action = BFA_IOCFC_ACT_INIT;
1190 bfa_ioc_enable(&bfa->ioc);
1191}
1192
Jing Huang5fbe25c2010-10-18 17:17:23 -07001193/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001194 * IOC start called from bfa_start(). Called to start IOC operations
1195 * at driver instantiation for this instance.
1196 */
1197void
1198bfa_iocfc_start(struct bfa_s *bfa)
1199{
1200 if (bfa->iocfc.cfgdone)
1201 bfa_iocfc_start_submod(bfa);
1202}
1203
Jing Huang5fbe25c2010-10-18 17:17:23 -07001204/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001205 * IOC stop called from bfa_stop(). Called only when driver is unloaded
1206 * for this instance.
1207 */
1208void
1209bfa_iocfc_stop(struct bfa_s *bfa)
1210{
1211 bfa->iocfc.action = BFA_IOCFC_ACT_STOP;
1212
Krishna Gudipati775c7742011-06-13 15:52:12 -07001213 bfa->queue_process = BFA_FALSE;
Krishna Gudipati45c5dc12011-07-20 17:03:46 -07001214 bfa_dconf_modexit(bfa);
1215 if (BFA_DCONF_MOD(bfa)->flashdone == BFA_TRUE)
1216 bfa_ioc_disable(&bfa->ioc);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001217}
1218
1219void
1220bfa_iocfc_isr(void *bfaarg, struct bfi_mbmsg_s *m)
1221{
1222 struct bfa_s *bfa = bfaarg;
1223 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
1224 union bfi_iocfc_i2h_msg_u *msg;
1225
1226 msg = (union bfi_iocfc_i2h_msg_u *) m;
1227 bfa_trc(bfa, msg->mh.msg_id);
1228
1229 switch (msg->mh.msg_id) {
1230 case BFI_IOCFC_I2H_CFG_REPLY:
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001231 bfa_iocfc_cfgrsp(bfa);
1232 break;
1233 case BFI_IOCFC_I2H_UPDATEQ_RSP:
1234 iocfc->updateq_cbfn(iocfc->updateq_cbarg, BFA_STATUS_OK);
1235 break;
Krishna Gudipatia7141342011-06-24 20:23:19 -07001236 case BFI_IOCFC_I2H_FAA_ENABLE_RSP:
1237 bfa_faa_enable_reply(iocfc,
1238 (struct bfi_faa_en_dis_rsp_s *)msg);
1239 break;
1240 case BFI_IOCFC_I2H_FAA_DISABLE_RSP:
1241 bfa_faa_disable_reply(iocfc,
1242 (struct bfi_faa_en_dis_rsp_s *)msg);
1243 break;
1244 case BFI_IOCFC_I2H_FAA_QUERY_RSP:
1245 bfa_faa_query_reply(iocfc, (bfi_faa_query_rsp_t *)msg);
1246 break;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001247 default:
Jing Huangd4b671c2010-12-26 21:46:35 -08001248 WARN_ON(1);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001249 }
1250}
1251
1252void
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001253bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr)
1254{
1255 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
1256
1257 attr->intr_attr.coalesce = iocfc->cfginfo->intr_attr.coalesce;
1258
1259 attr->intr_attr.delay = iocfc->cfginfo->intr_attr.delay ?
Jing Huangba816ea2010-10-18 17:10:50 -07001260 be16_to_cpu(iocfc->cfginfo->intr_attr.delay) :
1261 be16_to_cpu(iocfc->cfgrsp->intr_attr.delay);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001262
1263 attr->intr_attr.latency = iocfc->cfginfo->intr_attr.latency ?
Jing Huangba816ea2010-10-18 17:10:50 -07001264 be16_to_cpu(iocfc->cfginfo->intr_attr.latency) :
1265 be16_to_cpu(iocfc->cfgrsp->intr_attr.latency);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001266
1267 attr->config = iocfc->cfg;
1268}
1269
1270bfa_status_t
1271bfa_iocfc_israttr_set(struct bfa_s *bfa, struct bfa_iocfc_intr_attr_s *attr)
1272{
1273 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
1274 struct bfi_iocfc_set_intr_req_s *m;
1275
1276 iocfc->cfginfo->intr_attr.coalesce = attr->coalesce;
Jing Huangba816ea2010-10-18 17:10:50 -07001277 iocfc->cfginfo->intr_attr.delay = cpu_to_be16(attr->delay);
1278 iocfc->cfginfo->intr_attr.latency = cpu_to_be16(attr->latency);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001279
1280 if (!bfa_iocfc_is_operational(bfa))
1281 return BFA_STATUS_OK;
1282
1283 m = bfa_reqq_next(bfa, BFA_REQQ_IOC);
1284 if (!m)
1285 return BFA_STATUS_DEVBUSY;
1286
1287 bfi_h2i_set(m->mh, BFI_MC_IOCFC, BFI_IOCFC_H2I_SET_INTR_REQ,
Krishna Gudipati3fd45982011-06-24 20:24:08 -07001288 bfa_fn_lpu(bfa));
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001289 m->coalesce = iocfc->cfginfo->intr_attr.coalesce;
1290 m->delay = iocfc->cfginfo->intr_attr.delay;
1291 m->latency = iocfc->cfginfo->intr_attr.latency;
1292
1293 bfa_trc(bfa, attr->delay);
1294 bfa_trc(bfa, attr->latency);
1295
Krishna Gudipati3fd45982011-06-24 20:24:08 -07001296 bfa_reqq_produce(bfa, BFA_REQQ_IOC, m->mh);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001297 return BFA_STATUS_OK;
1298}
1299
1300void
Krishna Gudipati45070252011-06-24 20:24:29 -07001301bfa_iocfc_set_snsbase(struct bfa_s *bfa, int seg_no, u64 snsbase_pa)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001302{
1303 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
1304
1305 iocfc->cfginfo->sense_buf_len = (BFI_IOIM_SNSLEN - 1);
Krishna Gudipati45070252011-06-24 20:24:29 -07001306 bfa_dma_be_addr_set(iocfc->cfginfo->ioim_snsbase[seg_no], snsbase_pa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001307}
Jing Huang5fbe25c2010-10-18 17:17:23 -07001308/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001309 * Enable IOC after it is disabled.
1310 */
1311void
1312bfa_iocfc_enable(struct bfa_s *bfa)
1313{
1314 bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
1315 "IOC Enable");
Krishna Gudipati60138062011-06-24 20:25:15 -07001316 bfa->iocfc.action = BFA_IOCFC_ACT_ENABLE;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001317 bfa_ioc_enable(&bfa->ioc);
1318}
1319
1320void
1321bfa_iocfc_disable(struct bfa_s *bfa)
1322{
1323 bfa_plog_str(bfa->plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
1324 "IOC Disable");
1325 bfa->iocfc.action = BFA_IOCFC_ACT_DISABLE;
1326
Krishna Gudipati775c7742011-06-13 15:52:12 -07001327 bfa->queue_process = BFA_FALSE;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001328 bfa_ioc_disable(&bfa->ioc);
1329}
1330
1331
1332bfa_boolean_t
1333bfa_iocfc_is_operational(struct bfa_s *bfa)
1334{
1335 return bfa_ioc_is_operational(&bfa->ioc) && bfa->iocfc.cfgdone;
1336}
1337
Jing Huang5fbe25c2010-10-18 17:17:23 -07001338/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001339 * Return boot target port wwns -- read from boot information in flash.
1340 */
1341void
1342bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns)
1343{
1344 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
1345 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
1346 int i;
1347
1348 if (cfgrsp->pbc_cfg.boot_enabled && cfgrsp->pbc_cfg.nbluns) {
1349 bfa_trc(bfa, cfgrsp->pbc_cfg.nbluns);
1350 *nwwns = cfgrsp->pbc_cfg.nbluns;
1351 for (i = 0; i < cfgrsp->pbc_cfg.nbluns; i++)
1352 wwns[i] = cfgrsp->pbc_cfg.blun[i].tgt_pwwn;
1353
1354 return;
1355 }
1356
1357 *nwwns = cfgrsp->bootwwns.nwwns;
1358 memcpy(wwns, cfgrsp->bootwwns.wwn, sizeof(cfgrsp->bootwwns.wwn));
1359}
1360
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001361int
1362bfa_iocfc_get_pbc_vports(struct bfa_s *bfa, struct bfi_pbc_vport_s *pbc_vport)
1363{
1364 struct bfa_iocfc_s *iocfc = &bfa->iocfc;
1365 struct bfi_iocfc_cfgrsp_s *cfgrsp = iocfc->cfgrsp;
1366
1367 memcpy(pbc_vport, cfgrsp->pbc_cfg.vport, sizeof(cfgrsp->pbc_cfg.vport));
1368 return cfgrsp->pbc_cfg.nvports;
1369}
1370
Jing Huang7725ccf2009-09-23 17:46:15 -07001371
Jing Huang5fbe25c2010-10-18 17:17:23 -07001372/*
Jing Huang7725ccf2009-09-23 17:46:15 -07001373 * Use this function query the memory requirement of the BFA library.
1374 * This function needs to be called before bfa_attach() to get the
1375 * memory required of the BFA layer for a given driver configuration.
1376 *
1377 * This call will fail, if the cap is out of range compared to pre-defined
1378 * values within the BFA library
1379 *
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001380 * @param[in] cfg - pointer to bfa_ioc_cfg_t. Driver layer should indicate
1381 * its configuration in this structure.
Jing Huang7725ccf2009-09-23 17:46:15 -07001382 * The default values for struct bfa_iocfc_cfg_s can be
1383 * fetched using bfa_cfg_get_default() API.
1384 *
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001385 * If cap's boundary check fails, the library will use
Jing Huang7725ccf2009-09-23 17:46:15 -07001386 * the default bfa_cap_t values (and log a warning msg).
1387 *
1388 * @param[out] meminfo - pointer to bfa_meminfo_t. This content
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001389 * indicates the memory type (see bfa_mem_type_t) and
Jing Huang7725ccf2009-09-23 17:46:15 -07001390 * amount of memory required.
1391 *
1392 * Driver should allocate the memory, populate the
1393 * starting address for each block and provide the same
1394 * structure as input parameter to bfa_attach() call.
1395 *
Krishna Gudipati45070252011-06-24 20:24:29 -07001396 * @param[in] bfa - pointer to the bfa structure, used while fetching the
1397 * dma, kva memory information of the bfa sub-modules.
1398 *
Jing Huang7725ccf2009-09-23 17:46:15 -07001399 * @return void
1400 *
1401 * Special Considerations: @note
1402 */
1403void
Krishna Gudipati45070252011-06-24 20:24:29 -07001404bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
1405 struct bfa_s *bfa)
Jing Huang7725ccf2009-09-23 17:46:15 -07001406{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001407 int i;
Krishna Gudipati45070252011-06-24 20:24:29 -07001408 struct bfa_mem_dma_s *port_dma = BFA_MEM_PORT_DMA(bfa);
1409 struct bfa_mem_dma_s *ablk_dma = BFA_MEM_ABLK_DMA(bfa);
Krishna Gudipati148d6102011-06-24 20:25:36 -07001410 struct bfa_mem_dma_s *cee_dma = BFA_MEM_CEE_DMA(bfa);
Krishna Gudipati51e569a2011-06-24 20:26:25 -07001411 struct bfa_mem_dma_s *sfp_dma = BFA_MEM_SFP_DMA(bfa);
Krishna Gudipati5a54b1d2011-06-24 20:27:13 -07001412 struct bfa_mem_dma_s *flash_dma = BFA_MEM_FLASH_DMA(bfa);
Krishna Gudipati3d7fc662011-06-24 20:28:17 -07001413 struct bfa_mem_dma_s *diag_dma = BFA_MEM_DIAG_DMA(bfa);
Krishna Gudipati3350d982011-06-24 20:28:37 -07001414 struct bfa_mem_dma_s *phy_dma = BFA_MEM_PHY_DMA(bfa);
Jing Huang7725ccf2009-09-23 17:46:15 -07001415
Jing Huangd4b671c2010-12-26 21:46:35 -08001416 WARN_ON((cfg == NULL) || (meminfo == NULL));
Jing Huang7725ccf2009-09-23 17:46:15 -07001417
Jing Huang6a18b162010-10-18 17:08:54 -07001418 memset((void *)meminfo, 0, sizeof(struct bfa_meminfo_s));
Jing Huang7725ccf2009-09-23 17:46:15 -07001419
Krishna Gudipati45070252011-06-24 20:24:29 -07001420 /* Initialize the DMA & KVA meminfo queues */
1421 INIT_LIST_HEAD(&meminfo->dma_info.qe);
1422 INIT_LIST_HEAD(&meminfo->kva_info.qe);
1423
1424 bfa_iocfc_meminfo(cfg, meminfo, bfa);
Jing Huang7725ccf2009-09-23 17:46:15 -07001425
1426 for (i = 0; hal_mods[i]; i++)
Krishna Gudipati45070252011-06-24 20:24:29 -07001427 hal_mods[i]->meminfo(cfg, meminfo, bfa);
Jing Huang7725ccf2009-09-23 17:46:15 -07001428
Krishna Gudipati45070252011-06-24 20:24:29 -07001429 /* dma info setup */
1430 bfa_mem_dma_setup(meminfo, port_dma, bfa_port_meminfo());
1431 bfa_mem_dma_setup(meminfo, ablk_dma, bfa_ablk_meminfo());
Krishna Gudipati148d6102011-06-24 20:25:36 -07001432 bfa_mem_dma_setup(meminfo, cee_dma, bfa_cee_meminfo());
Krishna Gudipati51e569a2011-06-24 20:26:25 -07001433 bfa_mem_dma_setup(meminfo, sfp_dma, bfa_sfp_meminfo());
Krishna Gudipati5a54b1d2011-06-24 20:27:13 -07001434 bfa_mem_dma_setup(meminfo, flash_dma,
1435 bfa_flash_meminfo(cfg->drvcfg.min_cfg));
Krishna Gudipati3d7fc662011-06-24 20:28:17 -07001436 bfa_mem_dma_setup(meminfo, diag_dma, bfa_diag_meminfo());
Krishna Gudipati3350d982011-06-24 20:28:37 -07001437 bfa_mem_dma_setup(meminfo, phy_dma,
1438 bfa_phy_meminfo(cfg->drvcfg.min_cfg));
Jing Huang7725ccf2009-09-23 17:46:15 -07001439}
1440
Jing Huang5fbe25c2010-10-18 17:17:23 -07001441/*
Jing Huang7725ccf2009-09-23 17:46:15 -07001442 * Use this function to do attach the driver instance with the BFA
1443 * library. This function will not trigger any HW initialization
1444 * process (which will be done in bfa_init() call)
1445 *
1446 * This call will fail, if the cap is out of range compared to
1447 * pre-defined values within the BFA library
1448 *
1449 * @param[out] bfa Pointer to bfa_t.
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001450 * @param[in] bfad Opaque handle back to the driver's IOC structure
Jing Huang7725ccf2009-09-23 17:46:15 -07001451 * @param[in] cfg Pointer to bfa_ioc_cfg_t. Should be same structure
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001452 * that was used in bfa_cfg_get_meminfo().
1453 * @param[in] meminfo Pointer to bfa_meminfo_t. The driver should
1454 * use the bfa_cfg_get_meminfo() call to
1455 * find the memory blocks required, allocate the
1456 * required memory and provide the starting addresses.
1457 * @param[in] pcidev pointer to struct bfa_pcidev_s
Jing Huang7725ccf2009-09-23 17:46:15 -07001458 *
1459 * @return
1460 * void
1461 *
1462 * Special Considerations:
1463 *
1464 * @note
1465 *
1466 */
1467void
1468bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
1469 struct bfa_meminfo_s *meminfo, struct bfa_pcidev_s *pcidev)
1470{
Krishna Gudipati45070252011-06-24 20:24:29 -07001471 int i;
1472 struct bfa_mem_dma_s *dma_info, *dma_elem;
1473 struct bfa_mem_kva_s *kva_info, *kva_elem;
1474 struct list_head *dm_qe, *km_qe;
Jing Huang7725ccf2009-09-23 17:46:15 -07001475
1476 bfa->fcs = BFA_FALSE;
1477
Jing Huangd4b671c2010-12-26 21:46:35 -08001478 WARN_ON((cfg == NULL) || (meminfo == NULL));
Jing Huang7725ccf2009-09-23 17:46:15 -07001479
Krishna Gudipati45070252011-06-24 20:24:29 -07001480 /* Initialize memory pointers for iterative allocation */
1481 dma_info = &meminfo->dma_info;
1482 dma_info->kva_curp = dma_info->kva;
1483 dma_info->dma_curp = dma_info->dma;
1484
1485 kva_info = &meminfo->kva_info;
1486 kva_info->kva_curp = kva_info->kva;
1487
1488 list_for_each(dm_qe, &dma_info->qe) {
1489 dma_elem = (struct bfa_mem_dma_s *) dm_qe;
1490 dma_elem->kva_curp = dma_elem->kva;
1491 dma_elem->dma_curp = dma_elem->dma;
Jing Huang7725ccf2009-09-23 17:46:15 -07001492 }
1493
Krishna Gudipati45070252011-06-24 20:24:29 -07001494 list_for_each(km_qe, &kva_info->qe) {
1495 kva_elem = (struct bfa_mem_kva_s *) km_qe;
1496 kva_elem->kva_curp = kva_elem->kva;
1497 }
1498
1499 bfa_iocfc_attach(bfa, bfad, cfg, pcidev);
Jing Huang7725ccf2009-09-23 17:46:15 -07001500
1501 for (i = 0; hal_mods[i]; i++)
Krishna Gudipati45070252011-06-24 20:24:29 -07001502 hal_mods[i]->attach(bfa, bfad, cfg, pcidev);
Jing Huang7725ccf2009-09-23 17:46:15 -07001503
Krishna Gudipati45070252011-06-24 20:24:29 -07001504 bfa_com_port_attach(bfa);
1505 bfa_com_ablk_attach(bfa);
Krishna Gudipati148d6102011-06-24 20:25:36 -07001506 bfa_com_cee_attach(bfa);
Krishna Gudipati51e569a2011-06-24 20:26:25 -07001507 bfa_com_sfp_attach(bfa);
Krishna Gudipati5a54b1d2011-06-24 20:27:13 -07001508 bfa_com_flash_attach(bfa, cfg->drvcfg.min_cfg);
Krishna Gudipati3d7fc662011-06-24 20:28:17 -07001509 bfa_com_diag_attach(bfa);
Krishna Gudipati3350d982011-06-24 20:28:37 -07001510 bfa_com_phy_attach(bfa, cfg->drvcfg.min_cfg);
Jing Huang7725ccf2009-09-23 17:46:15 -07001511}
1512
Jing Huang5fbe25c2010-10-18 17:17:23 -07001513/*
Jing Huang7725ccf2009-09-23 17:46:15 -07001514 * Use this function to delete a BFA IOC. IOC should be stopped (by
1515 * calling bfa_stop()) before this function call.
1516 *
1517 * @param[in] bfa - pointer to bfa_t.
1518 *
1519 * @return
1520 * void
1521 *
1522 * Special Considerations:
1523 *
1524 * @note
1525 */
1526void
1527bfa_detach(struct bfa_s *bfa)
1528{
1529 int i;
1530
1531 for (i = 0; hal_mods[i]; i++)
1532 hal_mods[i]->detach(bfa);
Maggie Zhangf7f738122010-12-09 19:08:43 -08001533 bfa_ioc_detach(&bfa->ioc);
Jing Huang7725ccf2009-09-23 17:46:15 -07001534}
1535
1536void
1537bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q)
1538{
1539 INIT_LIST_HEAD(comp_q);
1540 list_splice_tail_init(&bfa->comp_q, comp_q);
1541}
1542
1543void
1544bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q)
1545{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001546 struct list_head *qe;
1547 struct list_head *qen;
1548 struct bfa_cb_qe_s *hcb_qe;
Krishna Gudipati37ea0552011-07-20 17:02:11 -07001549 bfa_cb_cbfn_status_t cbfn;
Jing Huang7725ccf2009-09-23 17:46:15 -07001550
1551 list_for_each_safe(qe, qen, comp_q) {
1552 hcb_qe = (struct bfa_cb_qe_s *) qe;
Krishna Gudipati37ea0552011-07-20 17:02:11 -07001553 if (hcb_qe->pre_rmv) {
1554 /* qe is invalid after return, dequeue before cbfn() */
1555 list_del(qe);
1556 cbfn = (bfa_cb_cbfn_status_t)(hcb_qe->cbfn);
1557 cbfn(hcb_qe->cbarg, hcb_qe->fw_status);
1558 } else
1559 hcb_qe->cbfn(hcb_qe->cbarg, BFA_TRUE);
Jing Huang7725ccf2009-09-23 17:46:15 -07001560 }
1561}
1562
1563void
1564bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q)
1565{
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001566 struct list_head *qe;
1567 struct bfa_cb_qe_s *hcb_qe;
Jing Huang7725ccf2009-09-23 17:46:15 -07001568
1569 while (!list_empty(comp_q)) {
1570 bfa_q_deq(comp_q, &qe);
1571 hcb_qe = (struct bfa_cb_qe_s *) qe;
Krishna Gudipati37ea0552011-07-20 17:02:11 -07001572 WARN_ON(hcb_qe->pre_rmv);
Jing Huang7725ccf2009-09-23 17:46:15 -07001573 hcb_qe->cbfn(hcb_qe->cbarg, BFA_FALSE);
1574 }
1575}
1576
Krishna Gudipati45c5dc12011-07-20 17:03:46 -07001577void
1578bfa_iocfc_cb_dconf_modinit(struct bfa_s *bfa, bfa_status_t status)
1579{
1580 if (bfa->iocfc.action == BFA_IOCFC_ACT_INIT) {
1581 if (bfa->iocfc.cfgdone == BFA_TRUE)
1582 bfa_cb_queue(bfa, &bfa->iocfc.init_hcb_qe,
1583 bfa_iocfc_init_cb, bfa);
1584 }
1585}
Jing Huang7725ccf2009-09-23 17:46:15 -07001586
Jing Huang5fbe25c2010-10-18 17:17:23 -07001587/*
Jing Huang7725ccf2009-09-23 17:46:15 -07001588 * Return the list of PCI vendor/device id lists supported by this
1589 * BFA instance.
1590 */
1591void
1592bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids)
1593{
1594 static struct bfa_pciid_s __pciids[] = {
1595 {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_FC_8G2P},
1596 {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_FC_8G1P},
1597 {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT},
Jing Huang293f82d2010-07-08 19:45:20 -07001598 {BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT_FC},
Jing Huang7725ccf2009-09-23 17:46:15 -07001599 };
1600
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001601 *npciids = sizeof(__pciids) / sizeof(__pciids[0]);
Jing Huang7725ccf2009-09-23 17:46:15 -07001602 *pciids = __pciids;
1603}
1604
Jing Huang5fbe25c2010-10-18 17:17:23 -07001605/*
Jing Huang7725ccf2009-09-23 17:46:15 -07001606 * Use this function query the default struct bfa_iocfc_cfg_s value (compiled
1607 * into BFA layer). The OS driver can then turn back and overwrite entries that
1608 * have been configured by the user.
1609 *
1610 * @param[in] cfg - pointer to bfa_ioc_cfg_t
1611 *
1612 * @return
1613 * void
1614 *
1615 * Special Considerations:
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001616 * note
Jing Huang7725ccf2009-09-23 17:46:15 -07001617 */
1618void
1619bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg)
1620{
1621 cfg->fwcfg.num_fabrics = DEF_CFG_NUM_FABRICS;
1622 cfg->fwcfg.num_lports = DEF_CFG_NUM_LPORTS;
1623 cfg->fwcfg.num_rports = DEF_CFG_NUM_RPORTS;
1624 cfg->fwcfg.num_ioim_reqs = DEF_CFG_NUM_IOIM_REQS;
1625 cfg->fwcfg.num_tskim_reqs = DEF_CFG_NUM_TSKIM_REQS;
1626 cfg->fwcfg.num_fcxp_reqs = DEF_CFG_NUM_FCXP_REQS;
1627 cfg->fwcfg.num_uf_bufs = DEF_CFG_NUM_UF_BUFS;
1628 cfg->fwcfg.num_cqs = DEF_CFG_NUM_CQS;
Krishna Gudipatie2187d72011-06-13 15:53:58 -07001629 cfg->fwcfg.num_fwtio_reqs = 0;
Jing Huang7725ccf2009-09-23 17:46:15 -07001630
1631 cfg->drvcfg.num_reqq_elems = DEF_CFG_NUM_REQQ_ELEMS;
1632 cfg->drvcfg.num_rspq_elems = DEF_CFG_NUM_RSPQ_ELEMS;
1633 cfg->drvcfg.num_sgpgs = DEF_CFG_NUM_SGPGS;
1634 cfg->drvcfg.num_sboot_tgts = DEF_CFG_NUM_SBOOT_TGTS;
1635 cfg->drvcfg.num_sboot_luns = DEF_CFG_NUM_SBOOT_LUNS;
1636 cfg->drvcfg.path_tov = BFA_FCPIM_PATHTOV_DEF;
1637 cfg->drvcfg.ioc_recover = BFA_FALSE;
1638 cfg->drvcfg.delay_comp = BFA_FALSE;
1639
1640}
1641
1642void
1643bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg)
1644{
1645 bfa_cfg_get_default(cfg);
1646 cfg->fwcfg.num_ioim_reqs = BFA_IOIM_MIN;
1647 cfg->fwcfg.num_tskim_reqs = BFA_TSKIM_MIN;
1648 cfg->fwcfg.num_fcxp_reqs = BFA_FCXP_MIN;
1649 cfg->fwcfg.num_uf_bufs = BFA_UF_MIN;
1650 cfg->fwcfg.num_rports = BFA_RPORT_MIN;
Krishna Gudipatie2187d72011-06-13 15:53:58 -07001651 cfg->fwcfg.num_fwtio_reqs = 0;
Jing Huang7725ccf2009-09-23 17:46:15 -07001652
1653 cfg->drvcfg.num_sgpgs = BFA_SGPG_MIN;
1654 cfg->drvcfg.num_reqq_elems = BFA_REQQ_NELEMS_MIN;
1655 cfg->drvcfg.num_rspq_elems = BFA_RSPQ_NELEMS_MIN;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001656 cfg->drvcfg.min_cfg = BFA_TRUE;
Jing Huang7725ccf2009-09-23 17:46:15 -07001657}