blob: 0e119d838e1b6cc569f2b6905d11d2acdbf6ce15 [file] [log] [blame]
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07001/*
Anil Gurumurthy889d0d42015-11-26 03:54:45 -05002 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
3 * Copyright (c) 2014- QLogic Corporation.
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07004 * All rights reserved
Anil Gurumurthy889d0d42015-11-26 03:54:45 -05005 * www.qlogic.com
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07006 *
Anil Gurumurthy31e1d562015-11-26 03:54:46 -05007 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
Krishna Gudipatia36c61f2010-09-15 11:50:55 -07008 *
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#ifndef __BFA_H__
19#define __BFA_H__
20
Maggie Zhangf16a1752010-12-09 19:12:32 -080021#include "bfad_drv.h"
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070022#include "bfa_cs.h"
23#include "bfa_plog.h"
24#include "bfa_defs_svc.h"
25#include "bfi.h"
26#include "bfa_ioc.h"
27
28struct bfa_s;
29
30typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m);
Krishna Gudipati37ea0552011-07-20 17:02:11 -070031typedef void (*bfa_cb_cbfn_status_t) (void *cbarg, bfa_status_t status);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070032
Jing Huangacdc79a2010-10-18 17:15:55 -070033/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070034 * Interrupt message handlers
35 */
36void bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070037
Jing Huangacdc79a2010-10-18 17:15:55 -070038/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070039 * Request and response queue related defines
40 */
41#define BFA_REQQ_NELEMS_MIN (4)
42#define BFA_RSPQ_NELEMS_MIN (4)
43
44#define bfa_reqq_pi(__bfa, __reqq) ((__bfa)->iocfc.req_cq_pi[__reqq])
45#define bfa_reqq_ci(__bfa, __reqq) \
46 (*(u32 *)((__bfa)->iocfc.req_cq_shadow_ci[__reqq].kva))
47
48#define bfa_reqq_full(__bfa, __reqq) \
49 (((bfa_reqq_pi(__bfa, __reqq) + 1) & \
50 ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1)) == \
51 bfa_reqq_ci(__bfa, __reqq))
52
53#define bfa_reqq_next(__bfa, __reqq) \
54 (bfa_reqq_full(__bfa, __reqq) ? NULL : \
55 ((void *)((struct bfi_msg_s *)((__bfa)->iocfc.req_cq_ba[__reqq].kva) \
56 + bfa_reqq_pi((__bfa), (__reqq)))))
57
Krishna Gudipati3fd45982011-06-24 20:24:08 -070058#define bfa_reqq_produce(__bfa, __reqq, __mh) do { \
59 (__mh).mtag.h2i.qid = (__bfa)->iocfc.hw_qid[__reqq];\
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070060 (__bfa)->iocfc.req_cq_pi[__reqq]++; \
61 (__bfa)->iocfc.req_cq_pi[__reqq] &= \
Jing Huangacdc79a2010-10-18 17:15:55 -070062 ((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1); \
63 writel((__bfa)->iocfc.req_cq_pi[__reqq], \
Jing Huang53440262010-10-18 17:12:29 -070064 (__bfa)->iocfc.bfa_regs.cpe_q_pi[__reqq]); \
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070065 mmiowb(); \
66 } while (0)
67
68#define bfa_rspq_pi(__bfa, __rspq) \
69 (*(u32 *)((__bfa)->iocfc.rsp_cq_shadow_pi[__rspq].kva))
70
71#define bfa_rspq_ci(__bfa, __rspq) ((__bfa)->iocfc.rsp_cq_ci[__rspq])
72#define bfa_rspq_elem(__bfa, __rspq, __ci) \
73 (&((struct bfi_msg_s *)((__bfa)->iocfc.rsp_cq_ba[__rspq].kva))[__ci])
74
75#define CQ_INCR(__index, __size) do { \
76 (__index)++; \
77 (__index) &= ((__size) - 1); \
78} while (0)
79
Jing Huangacdc79a2010-10-18 17:15:55 -070080/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070081 * Circular queue usage assignments
82 */
83enum {
84 BFA_REQQ_IOC = 0, /* all low-priority IOC msgs */
85 BFA_REQQ_FCXP = 0, /* all FCXP messages */
86 BFA_REQQ_LPS = 0, /* all lport service msgs */
87 BFA_REQQ_PORT = 0, /* all port messages */
88 BFA_REQQ_FLASH = 0, /* for flash module */
89 BFA_REQQ_DIAG = 0, /* for diag module */
90 BFA_REQQ_RPORT = 0, /* all port messages */
91 BFA_REQQ_SBOOT = 0, /* all san boot messages */
92 BFA_REQQ_QOS_LO = 1, /* all low priority IO */
93 BFA_REQQ_QOS_MD = 2, /* all medium priority IO */
94 BFA_REQQ_QOS_HI = 3, /* all high priority IO */
95};
96
97static inline void
98bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
99 void *cbarg)
100{
101 wqe->qresume = qresume;
102 wqe->cbarg = cbarg;
103}
104
105#define bfa_reqq(__bfa, __reqq) (&(__bfa)->reqq_waitq[__reqq])
106
Jing Huangacdc79a2010-10-18 17:15:55 -0700107/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700108 * static inline void
109 * bfa_reqq_wait(struct bfa_s *bfa, int reqq, struct bfa_reqq_wait_s *wqe)
110 */
111#define bfa_reqq_wait(__bfa, __reqq, __wqe) do { \
112 \
113 struct list_head *waitq = bfa_reqq(__bfa, __reqq); \
114 \
Jing Huangd4b671c2010-12-26 21:46:35 -0800115 WARN_ON(((__reqq) >= BFI_IOC_MAX_CQS)); \
116 WARN_ON(!((__wqe)->qresume && (__wqe)->cbarg)); \
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700117 \
118 list_add_tail(&(__wqe)->qe, waitq); \
119 } while (0)
120
121#define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
122
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700123#define bfa_cb_queue(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
124 (__hcb_qe)->cbfn = (__cbfn); \
125 (__hcb_qe)->cbarg = (__cbarg); \
Krishna Gudipati37ea0552011-07-20 17:02:11 -0700126 (__hcb_qe)->pre_rmv = BFA_FALSE; \
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700127 list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
128 } while (0)
129
130#define bfa_cb_dequeue(__hcb_qe) list_del(&(__hcb_qe)->qe)
131
132#define bfa_cb_queue_once(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
133 (__hcb_qe)->cbfn = (__cbfn); \
134 (__hcb_qe)->cbarg = (__cbarg); \
135 if (!(__hcb_qe)->once) { \
136 list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
137 (__hcb_qe)->once = BFA_TRUE; \
138 } \
139 } while (0)
140
Krishna Gudipati37ea0552011-07-20 17:02:11 -0700141#define bfa_cb_queue_status(__bfa, __hcb_qe, __status) do { \
142 (__hcb_qe)->fw_status = (__status); \
143 list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
144} while (0)
145
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700146#define bfa_cb_queue_done(__hcb_qe) do { \
147 (__hcb_qe)->once = BFA_FALSE; \
148 } while (0)
149
150
Jing Huangacdc79a2010-10-18 17:15:55 -0700151/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700152 * PCI devices supported by the current BFA
153 */
154struct bfa_pciid_s {
155 u16 device_id;
156 u16 vendor_id;
157};
158
159extern char bfa_version[];
160
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700161struct bfa_iocfc_regs_s {
Jing Huang53440262010-10-18 17:12:29 -0700162 void __iomem *intr_status;
Jing Huangacdc79a2010-10-18 17:15:55 -0700163 void __iomem *intr_mask;
Jing Huang53440262010-10-18 17:12:29 -0700164 void __iomem *cpe_q_pi[BFI_IOC_MAX_CQS];
165 void __iomem *cpe_q_ci[BFI_IOC_MAX_CQS];
Jing Huang53440262010-10-18 17:12:29 -0700166 void __iomem *cpe_q_ctrl[BFI_IOC_MAX_CQS];
167 void __iomem *rme_q_ci[BFI_IOC_MAX_CQS];
168 void __iomem *rme_q_pi[BFI_IOC_MAX_CQS];
Jing Huang53440262010-10-18 17:12:29 -0700169 void __iomem *rme_q_ctrl[BFI_IOC_MAX_CQS];
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700170};
171
Jing Huangacdc79a2010-10-18 17:15:55 -0700172/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700173 * MSIX vector handlers
174 */
175#define BFA_MSIX_MAX_VECTORS 22
176typedef void (*bfa_msix_handler_t)(struct bfa_s *bfa, int vec);
177struct bfa_msix_s {
178 int nvecs;
179 bfa_msix_handler_t handler[BFA_MSIX_MAX_VECTORS];
180};
181
Jing Huangacdc79a2010-10-18 17:15:55 -0700182/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700183 * Chip specific interfaces
184 */
185struct bfa_hwif_s {
186 void (*hw_reginit)(struct bfa_s *bfa);
187 void (*hw_reqq_ack)(struct bfa_s *bfa, int reqq);
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700188 void (*hw_rspq_ack)(struct bfa_s *bfa, int rspq, u32 ci);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700189 void (*hw_msix_init)(struct bfa_s *bfa, int nvecs);
Krishna Gudipati775c7742011-06-13 15:52:12 -0700190 void (*hw_msix_ctrl_install)(struct bfa_s *bfa);
191 void (*hw_msix_queue_install)(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700192 void (*hw_msix_uninstall)(struct bfa_s *bfa);
193 void (*hw_isr_mode_set)(struct bfa_s *bfa, bfa_boolean_t msix);
194 void (*hw_msix_getvecs)(struct bfa_s *bfa, u32 *vecmap,
195 u32 *nvecs, u32 *maxvec);
196 void (*hw_msix_get_rme_range) (struct bfa_s *bfa, u32 *start,
197 u32 *end);
Krishna Gudipati11189202011-06-13 15:50:35 -0700198 int cpe_vec_q0;
199 int rme_vec_q0;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700200};
201typedef void (*bfa_cb_iocfc_t) (void *cbarg, enum bfa_status status);
202
Krishna Gudipatia7141342011-06-24 20:23:19 -0700203struct bfa_faa_cbfn_s {
204 bfa_cb_iocfc_t faa_cbfn;
205 void *faa_cbarg;
206};
207
208#define BFA_FAA_ENABLED 1
209#define BFA_FAA_DISABLED 2
210
211/*
212 * FAA attributes
213 */
214struct bfa_faa_attr_s {
215 wwn_t faa;
216 u8 faa_state;
217 u8 pwwn_source;
218 u8 rsvd[6];
219};
220
221struct bfa_faa_args_s {
222 struct bfa_faa_attr_s *faa_attr;
223 struct bfa_faa_cbfn_s faa_cb;
224 u8 faa_state;
225 bfa_boolean_t busy;
226};
227
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700228struct bfa_iocfc_s {
Krishna Gudipatidb9d8a72012-03-13 17:39:36 -0700229 bfa_fsm_t fsm;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700230 struct bfa_s *bfa;
231 struct bfa_iocfc_cfg_s cfg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700232 u32 req_cq_pi[BFI_IOC_MAX_CQS];
233 u32 rsp_cq_ci[BFI_IOC_MAX_CQS];
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700234 u8 hw_qid[BFI_IOC_MAX_CQS];
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700235 struct bfa_cb_qe_s init_hcb_qe;
236 struct bfa_cb_qe_s stop_hcb_qe;
237 struct bfa_cb_qe_s dis_hcb_qe;
Krishna Gudipati60138062011-06-24 20:25:15 -0700238 struct bfa_cb_qe_s en_hcb_qe;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700239 struct bfa_cb_qe_s stats_hcb_qe;
Krishna Gudipatidb9d8a72012-03-13 17:39:36 -0700240 bfa_boolean_t submod_enabled;
241 bfa_boolean_t cb_reqd; /* Driver call back reqd */
242 bfa_status_t op_status; /* Status of bfa iocfc op */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700243
244 struct bfa_dma_s cfg_info;
245 struct bfi_iocfc_cfg_s *cfginfo;
246 struct bfa_dma_s cfgrsp_dma;
247 struct bfi_iocfc_cfgrsp_s *cfgrsp;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700248 struct bfa_dma_s req_cq_ba[BFI_IOC_MAX_CQS];
249 struct bfa_dma_s req_cq_shadow_ci[BFI_IOC_MAX_CQS];
250 struct bfa_dma_s rsp_cq_ba[BFI_IOC_MAX_CQS];
251 struct bfa_dma_s rsp_cq_shadow_pi[BFI_IOC_MAX_CQS];
252 struct bfa_iocfc_regs_s bfa_regs; /* BFA device registers */
253 struct bfa_hwif_s hwif;
254 bfa_cb_iocfc_t updateq_cbfn; /* bios callback function */
255 void *updateq_cbarg; /* bios callback arg */
256 u32 intr_mask;
Krishna Gudipatia7141342011-06-24 20:23:19 -0700257 struct bfa_faa_args_s faa_args;
Krishna Gudipati45070252011-06-24 20:24:29 -0700258 struct bfa_mem_dma_s ioc_dma;
259 struct bfa_mem_dma_s iocfc_dma;
260 struct bfa_mem_dma_s reqq_dma[BFI_IOC_MAX_CQS];
261 struct bfa_mem_dma_s rspq_dma[BFI_IOC_MAX_CQS];
262 struct bfa_mem_kva_s kva_seg;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700263};
264
Krishna Gudipati45070252011-06-24 20:24:29 -0700265#define BFA_MEM_IOC_DMA(_bfa) (&((_bfa)->iocfc.ioc_dma))
266#define BFA_MEM_IOCFC_DMA(_bfa) (&((_bfa)->iocfc.iocfc_dma))
267#define BFA_MEM_REQQ_DMA(_bfa, _qno) (&((_bfa)->iocfc.reqq_dma[(_qno)]))
268#define BFA_MEM_RSPQ_DMA(_bfa, _qno) (&((_bfa)->iocfc.rspq_dma[(_qno)]))
269#define BFA_MEM_IOCFC_KVA(_bfa) (&((_bfa)->iocfc.kva_seg))
270
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700271#define bfa_fn_lpu(__bfa) \
272 bfi_fn_lpu(bfa_ioc_pcifn(&(__bfa)->ioc), bfa_ioc_portid(&(__bfa)->ioc))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700273#define bfa_msix_init(__bfa, __nvecs) \
274 ((__bfa)->iocfc.hwif.hw_msix_init(__bfa, __nvecs))
Krishna Gudipati775c7742011-06-13 15:52:12 -0700275#define bfa_msix_ctrl_install(__bfa) \
276 ((__bfa)->iocfc.hwif.hw_msix_ctrl_install(__bfa))
277#define bfa_msix_queue_install(__bfa) \
278 ((__bfa)->iocfc.hwif.hw_msix_queue_install(__bfa))
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700279#define bfa_msix_uninstall(__bfa) \
280 ((__bfa)->iocfc.hwif.hw_msix_uninstall(__bfa))
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700281#define bfa_isr_rspq_ack(__bfa, __queue, __ci) \
282 ((__bfa)->iocfc.hwif.hw_rspq_ack(__bfa, __queue, __ci))
Krishna Gudipati3fd45982011-06-24 20:24:08 -0700283#define bfa_isr_reqq_ack(__bfa, __queue) do { \
284 if ((__bfa)->iocfc.hwif.hw_reqq_ack) \
285 (__bfa)->iocfc.hwif.hw_reqq_ack(__bfa, __queue); \
286} while (0)
Krishna Gudipati11189202011-06-13 15:50:35 -0700287#define bfa_isr_mode_set(__bfa, __msix) do { \
288 if ((__bfa)->iocfc.hwif.hw_isr_mode_set) \
289 (__bfa)->iocfc.hwif.hw_isr_mode_set(__bfa, __msix); \
290} while (0)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700291#define bfa_msix_getvecs(__bfa, __vecmap, __nvecs, __maxvec) \
292 ((__bfa)->iocfc.hwif.hw_msix_getvecs(__bfa, __vecmap, \
293 __nvecs, __maxvec))
294#define bfa_msix_get_rme_range(__bfa, __start, __end) \
295 ((__bfa)->iocfc.hwif.hw_msix_get_rme_range(__bfa, __start, __end))
296#define bfa_msix(__bfa, __vec) \
297 ((__bfa)->msix.handler[__vec](__bfa, __vec))
298
299/*
300 * FC specific IOC functions.
301 */
Krishna Gudipati45070252011-06-24 20:24:29 -0700302void bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg,
303 struct bfa_meminfo_s *meminfo,
304 struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700305void bfa_iocfc_attach(struct bfa_s *bfa, void *bfad,
306 struct bfa_iocfc_cfg_s *cfg,
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700307 struct bfa_pcidev_s *pcidev);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700308void bfa_iocfc_init(struct bfa_s *bfa);
309void bfa_iocfc_start(struct bfa_s *bfa);
310void bfa_iocfc_stop(struct bfa_s *bfa);
311void bfa_iocfc_isr(void *bfa, struct bfi_mbmsg_s *msg);
Krishna Gudipati45070252011-06-24 20:24:29 -0700312void bfa_iocfc_set_snsbase(struct bfa_s *bfa, int seg_no, u64 snsbase_pa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700313bfa_boolean_t bfa_iocfc_is_operational(struct bfa_s *bfa);
314void bfa_iocfc_reset_queues(struct bfa_s *bfa);
315
316void bfa_msix_all(struct bfa_s *bfa, int vec);
317void bfa_msix_reqq(struct bfa_s *bfa, int vec);
318void bfa_msix_rspq(struct bfa_s *bfa, int vec);
319void bfa_msix_lpu_err(struct bfa_s *bfa, int vec);
320
321void bfa_hwcb_reginit(struct bfa_s *bfa);
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700322void bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq, u32 ci);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700323void bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs);
Krishna Gudipati775c7742011-06-13 15:52:12 -0700324void bfa_hwcb_msix_ctrl_install(struct bfa_s *bfa);
325void bfa_hwcb_msix_queue_install(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700326void bfa_hwcb_msix_uninstall(struct bfa_s *bfa);
327void bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
328void bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *vecmap, u32 *nvecs,
329 u32 *maxvec);
330void bfa_hwcb_msix_get_rme_range(struct bfa_s *bfa, u32 *start,
331 u32 *end);
332void bfa_hwct_reginit(struct bfa_s *bfa);
Krishna Gudipati11189202011-06-13 15:50:35 -0700333void bfa_hwct2_reginit(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700334void bfa_hwct_reqq_ack(struct bfa_s *bfa, int rspq);
Krishna Gudipatica6e0ea2011-07-20 17:00:45 -0700335void bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq, u32 ci);
336void bfa_hwct2_rspq_ack(struct bfa_s *bfa, int rspq, u32 ci);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700337void bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs);
Krishna Gudipati775c7742011-06-13 15:52:12 -0700338void bfa_hwct_msix_ctrl_install(struct bfa_s *bfa);
339void bfa_hwct_msix_queue_install(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700340void bfa_hwct_msix_uninstall(struct bfa_s *bfa);
341void bfa_hwct_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
342void bfa_hwct_msix_getvecs(struct bfa_s *bfa, u32 *vecmap, u32 *nvecs,
343 u32 *maxvec);
344void bfa_hwct_msix_get_rme_range(struct bfa_s *bfa, u32 *start,
345 u32 *end);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700346void bfa_iocfc_get_bootwwns(struct bfa_s *bfa, u8 *nwwns, wwn_t *wwns);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700347int bfa_iocfc_get_pbc_vports(struct bfa_s *bfa,
348 struct bfi_pbc_vport_s *pbc_vport);
349
350
Jing Huangacdc79a2010-10-18 17:15:55 -0700351/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700352 *----------------------------------------------------------------------
353 * BFA public interfaces
354 *----------------------------------------------------------------------
355 */
356#define bfa_stats(_mod, _stats) ((_mod)->stats._stats++)
357#define bfa_ioc_get_stats(__bfa, __ioc_stats) \
358 bfa_ioc_fetch_stats(&(__bfa)->ioc, __ioc_stats)
359#define bfa_ioc_clear_stats(__bfa) \
360 bfa_ioc_clr_stats(&(__bfa)->ioc)
361#define bfa_get_nports(__bfa) \
362 bfa_ioc_get_nports(&(__bfa)->ioc)
363#define bfa_get_adapter_manufacturer(__bfa, __manufacturer) \
364 bfa_ioc_get_adapter_manufacturer(&(__bfa)->ioc, __manufacturer)
365#define bfa_get_adapter_model(__bfa, __model) \
366 bfa_ioc_get_adapter_model(&(__bfa)->ioc, __model)
367#define bfa_get_adapter_serial_num(__bfa, __serial_num) \
368 bfa_ioc_get_adapter_serial_num(&(__bfa)->ioc, __serial_num)
369#define bfa_get_adapter_fw_ver(__bfa, __fw_ver) \
370 bfa_ioc_get_adapter_fw_ver(&(__bfa)->ioc, __fw_ver)
371#define bfa_get_adapter_optrom_ver(__bfa, __optrom_ver) \
372 bfa_ioc_get_adapter_optrom_ver(&(__bfa)->ioc, __optrom_ver)
373#define bfa_get_pci_chip_rev(__bfa, __chip_rev) \
374 bfa_ioc_get_pci_chip_rev(&(__bfa)->ioc, __chip_rev)
375#define bfa_get_ioc_state(__bfa) \
376 bfa_ioc_get_state(&(__bfa)->ioc)
377#define bfa_get_type(__bfa) \
378 bfa_ioc_get_type(&(__bfa)->ioc)
379#define bfa_get_mac(__bfa) \
380 bfa_ioc_get_mac(&(__bfa)->ioc)
381#define bfa_get_mfg_mac(__bfa) \
382 bfa_ioc_get_mfg_mac(&(__bfa)->ioc)
383#define bfa_get_fw_clock_res(__bfa) \
384 ((__bfa)->iocfc.cfgrsp->fwcfg.fw_tick_res)
385
Krishna Gudipati83763d52011-07-20 17:04:03 -0700386/*
387 * lun mask macros return NULL when min cfg is enabled and there is
388 * no memory allocated for lunmask.
389 */
390#define bfa_get_lun_mask(__bfa) \
391 ((&(__bfa)->modules.dconf_mod)->min_cfg) ? NULL : \
392 (&(BFA_DCONF_MOD(__bfa)->dconf->lun_mask))
393
394#define bfa_get_lun_mask_list(_bfa) \
395 ((&(_bfa)->modules.dconf_mod)->min_cfg) ? NULL : \
396 (bfa_get_lun_mask(_bfa)->lun_list)
397
398#define bfa_get_lun_mask_status(_bfa) \
399 (((&(_bfa)->modules.dconf_mod)->min_cfg) \
400 ? BFA_LUNMASK_MINCFG : ((bfa_get_lun_mask(_bfa))->status))
401
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700402void bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids);
403void bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg);
404void bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg);
405void bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg,
Krishna Gudipati45070252011-06-24 20:24:29 -0700406 struct bfa_meminfo_s *meminfo,
407 struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700408void bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
409 struct bfa_meminfo_s *meminfo,
410 struct bfa_pcidev_s *pcidev);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700411void bfa_detach(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700412void bfa_cb_init(void *bfad, bfa_status_t status);
413void bfa_cb_updateq(void *bfad, bfa_status_t status);
414
415bfa_boolean_t bfa_intx(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700416void bfa_isr_enable(struct bfa_s *bfa);
417void bfa_isr_disable(struct bfa_s *bfa);
418
419void bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q);
420void bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q);
421void bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q);
422
423typedef void (*bfa_cb_ioc_t) (void *cbarg, enum bfa_status status);
424void bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700425
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700426
427bfa_status_t bfa_iocfc_israttr_set(struct bfa_s *bfa,
428 struct bfa_iocfc_intr_attr_s *attr);
429
430void bfa_iocfc_enable(struct bfa_s *bfa);
431void bfa_iocfc_disable(struct bfa_s *bfa);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700432#define bfa_timer_start(_bfa, _timer, _timercb, _arg, _timeout) \
433 bfa_timer_begin(&(_bfa)->timer_mod, _timer, _timercb, _arg, _timeout)
434
Krishna Gudipati37ea0552011-07-20 17:02:11 -0700435struct bfa_cb_pending_q_s {
436 struct bfa_cb_qe_s hcb_qe;
437 void *data; /* Driver buffer */
438};
439
440/* Common macros to operate on pending stats/attr apis */
441#define bfa_pending_q_init(__qe, __cbfn, __cbarg, __data) do { \
442 bfa_q_qe_init(&((__qe)->hcb_qe.qe)); \
443 (__qe)->hcb_qe.cbfn = (__cbfn); \
444 (__qe)->hcb_qe.cbarg = (__cbarg); \
445 (__qe)->hcb_qe.pre_rmv = BFA_TRUE; \
446 (__qe)->data = (__data); \
447} while (0)
448
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700449#endif /* __BFA_H__ */