54
54
((void *)((struct bfi_msg_s *)((__bfa)->iocfc.req_cq_ba[__reqq].kva) \
55
55
+ bfa_reqq_pi((__bfa), (__reqq)))))
57
#define bfa_reqq_produce(__bfa, __reqq) do { \
57
#define bfa_reqq_produce(__bfa, __reqq, __mh) do { \
58
(__mh).mtag.h2i.qid = (__bfa)->iocfc.hw_qid[__reqq];\
58
59
(__bfa)->iocfc.req_cq_pi[__reqq]++; \
59
60
(__bfa)->iocfc.req_cq_pi[__reqq] &= \
60
61
((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1); \
129
120
#define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
133
* Generic BFA callback element.
143
122
#define bfa_cb_queue(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
144
123
(__hcb_qe)->cbfn = (__cbfn); \
145
124
(__hcb_qe)->cbarg = (__cbarg); \
125
(__hcb_qe)->pre_rmv = BFA_FALSE; \
146
126
list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
140
#define bfa_cb_queue_status(__bfa, __hcb_qe, __status) do { \
141
(__hcb_qe)->fw_status = (__status); \
142
list_add_tail(&(__hcb_qe)->qe, &(__bfa)->comp_q); \
160
145
#define bfa_cb_queue_done(__hcb_qe) do { \
161
146
(__hcb_qe)->once = BFA_FALSE; \
173
158
extern char bfa_version[];
176
* BFA memory resources
179
BFA_MEM_TYPE_KVA = 1, /* Kernel Virtual Memory *(non-dma-able) */
180
BFA_MEM_TYPE_DMA = 2, /* DMA-able memory */
181
BFA_MEM_TYPE_MAX = BFA_MEM_TYPE_DMA,
184
struct bfa_mem_elem_s {
185
enum bfa_mem_type mem_type; /* see enum bfa_mem_type */
186
u32 mem_len; /* Total Length in Bytes */
187
u8 *kva; /* kernel virtual address */
188
u64 dma; /* dma address if DMA memory */
189
u8 *kva_curp; /* kva allocation cursor */
190
u64 dma_curp; /* dma allocation cursor */
193
struct bfa_meminfo_s {
194
struct bfa_mem_elem_s meminfo[BFA_MEM_TYPE_MAX];
196
#define bfa_meminfo_kva(_m) \
197
((_m)->meminfo[BFA_MEM_TYPE_KVA - 1].kva_curp)
198
#define bfa_meminfo_dma_virt(_m) \
199
((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].kva_curp)
200
#define bfa_meminfo_dma_phys(_m) \
201
((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].dma_curp)
203
160
struct bfa_iocfc_regs_s {
204
161
void __iomem *intr_status;
205
162
void __iomem *intr_mask;
206
163
void __iomem *cpe_q_pi[BFI_IOC_MAX_CQS];
207
164
void __iomem *cpe_q_ci[BFI_IOC_MAX_CQS];
208
void __iomem *cpe_q_depth[BFI_IOC_MAX_CQS];
209
165
void __iomem *cpe_q_ctrl[BFI_IOC_MAX_CQS];
210
166
void __iomem *rme_q_ci[BFI_IOC_MAX_CQS];
211
167
void __iomem *rme_q_pi[BFI_IOC_MAX_CQS];
212
void __iomem *rme_q_depth[BFI_IOC_MAX_CQS];
213
168
void __iomem *rme_q_ctrl[BFI_IOC_MAX_CQS];
229
184
struct bfa_hwif_s {
230
185
void (*hw_reginit)(struct bfa_s *bfa);
231
186
void (*hw_reqq_ack)(struct bfa_s *bfa, int reqq);
232
void (*hw_rspq_ack)(struct bfa_s *bfa, int rspq);
187
void (*hw_rspq_ack)(struct bfa_s *bfa, int rspq, u32 ci);
233
188
void (*hw_msix_init)(struct bfa_s *bfa, int nvecs);
234
void (*hw_msix_install)(struct bfa_s *bfa);
189
void (*hw_msix_ctrl_install)(struct bfa_s *bfa);
190
void (*hw_msix_queue_install)(struct bfa_s *bfa);
235
191
void (*hw_msix_uninstall)(struct bfa_s *bfa);
236
192
void (*hw_isr_mode_set)(struct bfa_s *bfa, bfa_boolean_t msix);
237
193
void (*hw_msix_getvecs)(struct bfa_s *bfa, u32 *vecmap,
238
194
u32 *nvecs, u32 *maxvec);
239
195
void (*hw_msix_get_rme_range) (struct bfa_s *bfa, u32 *start,
242
200
typedef void (*bfa_cb_iocfc_t) (void *cbarg, enum bfa_status status);
202
struct bfa_faa_cbfn_s {
203
bfa_cb_iocfc_t faa_cbfn;
207
#define BFA_FAA_ENABLED 1
208
#define BFA_FAA_DISABLED 2
213
struct bfa_faa_attr_s {
220
struct bfa_faa_args_s {
221
struct bfa_faa_attr_s *faa_attr;
222
struct bfa_faa_cbfn_s faa_cb;
244
227
struct bfa_iocfc_s {
245
228
struct bfa_s *bfa;
246
229
struct bfa_iocfc_cfg_s cfg;
248
231
u32 req_cq_pi[BFI_IOC_MAX_CQS];
249
232
u32 rsp_cq_ci[BFI_IOC_MAX_CQS];
233
u8 hw_qid[BFI_IOC_MAX_CQS];
250
234
struct bfa_cb_qe_s init_hcb_qe;
251
235
struct bfa_cb_qe_s stop_hcb_qe;
252
236
struct bfa_cb_qe_s dis_hcb_qe;
237
struct bfa_cb_qe_s en_hcb_qe;
253
238
struct bfa_cb_qe_s stats_hcb_qe;
254
239
bfa_boolean_t cfgdone;
257
242
struct bfi_iocfc_cfg_s *cfginfo;
258
243
struct bfa_dma_s cfgrsp_dma;
259
244
struct bfi_iocfc_cfgrsp_s *cfgrsp;
260
struct bfi_iocfc_cfg_reply_s *cfg_reply;
261
245
struct bfa_dma_s req_cq_ba[BFI_IOC_MAX_CQS];
262
246
struct bfa_dma_s req_cq_shadow_ci[BFI_IOC_MAX_CQS];
263
247
struct bfa_dma_s rsp_cq_ba[BFI_IOC_MAX_CQS];
267
251
bfa_cb_iocfc_t updateq_cbfn; /* bios callback function */
268
252
void *updateq_cbarg; /* bios callback arg */
254
struct bfa_faa_args_s faa_args;
255
struct bfa_mem_dma_s ioc_dma;
256
struct bfa_mem_dma_s iocfc_dma;
257
struct bfa_mem_dma_s reqq_dma[BFI_IOC_MAX_CQS];
258
struct bfa_mem_dma_s rspq_dma[BFI_IOC_MAX_CQS];
259
struct bfa_mem_kva_s kva_seg;
272
#define bfa_lpuid(__bfa) \
273
bfa_ioc_portid(&(__bfa)->ioc)
262
#define BFA_MEM_IOC_DMA(_bfa) (&((_bfa)->iocfc.ioc_dma))
263
#define BFA_MEM_IOCFC_DMA(_bfa) (&((_bfa)->iocfc.iocfc_dma))
264
#define BFA_MEM_REQQ_DMA(_bfa, _qno) (&((_bfa)->iocfc.reqq_dma[(_qno)]))
265
#define BFA_MEM_RSPQ_DMA(_bfa, _qno) (&((_bfa)->iocfc.rspq_dma[(_qno)]))
266
#define BFA_MEM_IOCFC_KVA(_bfa) (&((_bfa)->iocfc.kva_seg))
268
#define bfa_fn_lpu(__bfa) \
269
bfi_fn_lpu(bfa_ioc_pcifn(&(__bfa)->ioc), bfa_ioc_portid(&(__bfa)->ioc))
274
270
#define bfa_msix_init(__bfa, __nvecs) \
275
271
((__bfa)->iocfc.hwif.hw_msix_init(__bfa, __nvecs))
276
#define bfa_msix_install(__bfa) \
277
((__bfa)->iocfc.hwif.hw_msix_install(__bfa))
272
#define bfa_msix_ctrl_install(__bfa) \
273
((__bfa)->iocfc.hwif.hw_msix_ctrl_install(__bfa))
274
#define bfa_msix_queue_install(__bfa) \
275
((__bfa)->iocfc.hwif.hw_msix_queue_install(__bfa))
278
276
#define bfa_msix_uninstall(__bfa) \
279
277
((__bfa)->iocfc.hwif.hw_msix_uninstall(__bfa))
280
#define bfa_isr_mode_set(__bfa, __msix) \
281
((__bfa)->iocfc.hwif.hw_isr_mode_set(__bfa, __msix))
278
#define bfa_isr_rspq_ack(__bfa, __queue, __ci) \
279
((__bfa)->iocfc.hwif.hw_rspq_ack(__bfa, __queue, __ci))
280
#define bfa_isr_reqq_ack(__bfa, __queue) do { \
281
if ((__bfa)->iocfc.hwif.hw_reqq_ack) \
282
(__bfa)->iocfc.hwif.hw_reqq_ack(__bfa, __queue); \
284
#define bfa_isr_mode_set(__bfa, __msix) do { \
285
if ((__bfa)->iocfc.hwif.hw_isr_mode_set) \
286
(__bfa)->iocfc.hwif.hw_isr_mode_set(__bfa, __msix); \
282
288
#define bfa_msix_getvecs(__bfa, __vecmap, __nvecs, __maxvec) \
283
289
((__bfa)->iocfc.hwif.hw_msix_getvecs(__bfa, __vecmap, \
284
290
__nvecs, __maxvec))
291
297
* FC specific IOC functions.
293
void bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg, u32 *km_len,
299
void bfa_iocfc_meminfo(struct bfa_iocfc_cfg_s *cfg,
300
struct bfa_meminfo_s *meminfo,
295
302
void bfa_iocfc_attach(struct bfa_s *bfa, void *bfad,
296
303
struct bfa_iocfc_cfg_s *cfg,
297
struct bfa_meminfo_s *meminfo,
298
304
struct bfa_pcidev_s *pcidev);
299
305
void bfa_iocfc_init(struct bfa_s *bfa);
300
306
void bfa_iocfc_start(struct bfa_s *bfa);
301
307
void bfa_iocfc_stop(struct bfa_s *bfa);
302
308
void bfa_iocfc_isr(void *bfa, struct bfi_mbmsg_s *msg);
303
void bfa_iocfc_set_snsbase(struct bfa_s *bfa, u64 snsbase_pa);
309
void bfa_iocfc_set_snsbase(struct bfa_s *bfa, int seg_no, u64 snsbase_pa);
304
310
bfa_boolean_t bfa_iocfc_is_operational(struct bfa_s *bfa);
305
311
void bfa_iocfc_reset_queues(struct bfa_s *bfa);
310
316
void bfa_msix_lpu_err(struct bfa_s *bfa, int vec);
312
318
void bfa_hwcb_reginit(struct bfa_s *bfa);
313
void bfa_hwcb_reqq_ack(struct bfa_s *bfa, int rspq);
314
void bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq);
319
void bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq, u32 ci);
315
320
void bfa_hwcb_msix_init(struct bfa_s *bfa, int nvecs);
316
void bfa_hwcb_msix_install(struct bfa_s *bfa);
321
void bfa_hwcb_msix_ctrl_install(struct bfa_s *bfa);
322
void bfa_hwcb_msix_queue_install(struct bfa_s *bfa);
317
323
void bfa_hwcb_msix_uninstall(struct bfa_s *bfa);
318
324
void bfa_hwcb_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
319
325
void bfa_hwcb_msix_getvecs(struct bfa_s *bfa, u32 *vecmap, u32 *nvecs,
321
327
void bfa_hwcb_msix_get_rme_range(struct bfa_s *bfa, u32 *start,
323
329
void bfa_hwct_reginit(struct bfa_s *bfa);
330
void bfa_hwct2_reginit(struct bfa_s *bfa);
324
331
void bfa_hwct_reqq_ack(struct bfa_s *bfa, int rspq);
325
void bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq);
332
void bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq, u32 ci);
333
void bfa_hwct2_rspq_ack(struct bfa_s *bfa, int rspq, u32 ci);
326
334
void bfa_hwct_msix_init(struct bfa_s *bfa, int nvecs);
327
void bfa_hwct_msix_install(struct bfa_s *bfa);
335
void bfa_hwct_msix_ctrl_install(struct bfa_s *bfa);
336
void bfa_hwct_msix_queue_install(struct bfa_s *bfa);
328
337
void bfa_hwct_msix_uninstall(struct bfa_s *bfa);
329
338
void bfa_hwct_isr_mode_set(struct bfa_s *bfa, bfa_boolean_t msix);
330
339
void bfa_hwct_msix_getvecs(struct bfa_s *bfa, u32 *vecmap, u32 *nvecs,
373
382
#define bfa_get_fw_clock_res(__bfa) \
374
383
((__bfa)->iocfc.cfgrsp->fwcfg.fw_tick_res)
386
* lun mask macros return NULL when min cfg is enabled and there is
387
* no memory allocated for lunmask.
389
#define bfa_get_lun_mask(__bfa) \
390
((&(__bfa)->modules.dconf_mod)->min_cfg) ? NULL : \
391
(&(BFA_DCONF_MOD(__bfa)->dconf->lun_mask))
393
#define bfa_get_lun_mask_list(_bfa) \
394
((&(_bfa)->modules.dconf_mod)->min_cfg) ? NULL : \
395
(bfa_get_lun_mask(_bfa)->lun_list)
397
#define bfa_get_lun_mask_status(_bfa) \
398
(((&(_bfa)->modules.dconf_mod)->min_cfg) \
399
? BFA_LUNMASK_MINCFG : ((bfa_get_lun_mask(_bfa))->status))
376
401
void bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids);
377
402
void bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg);
378
403
void bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg);
379
404
void bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg,
380
struct bfa_meminfo_s *meminfo);
405
struct bfa_meminfo_s *meminfo,
381
407
void bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
382
408
struct bfa_meminfo_s *meminfo,
383
409
struct bfa_pcidev_s *pcidev);
403
429
void bfa_iocfc_enable(struct bfa_s *bfa);
404
430
void bfa_iocfc_disable(struct bfa_s *bfa);
431
void bfa_iocfc_cb_dconf_modinit(struct bfa_s *bfa, bfa_status_t status);
405
432
#define bfa_timer_start(_bfa, _timer, _timercb, _arg, _timeout) \
406
433
bfa_timer_begin(&(_bfa)->timer_mod, _timer, _timercb, _arg, _timeout)
435
struct bfa_cb_pending_q_s {
436
struct bfa_cb_qe_s hcb_qe;
437
void *data; /* Driver buffer */
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); \
408
449
#endif /* __BFA_H__ */