1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef __BFA_IOC_H__
20#define __BFA_IOC_H__
21
22#include "bfad_drv.h"
23#include "bfa_cs.h"
24#include "bfi.h"
25
26#define BFA_DBG_FWTRC_ENTS (BFI_IOC_TRC_ENTS)
27#define BFA_DBG_FWTRC_LEN \
28 (BFA_DBG_FWTRC_ENTS * sizeof(struct bfa_trc_s) + \
29 (sizeof(struct bfa_trc_mod_s) - \
30 BFA_TRC_MAX * sizeof(struct bfa_trc_s)))
31
32
33
34typedef void (*bfa_timer_cbfn_t)(void *);
35
36
37
38
39struct bfa_timer_s {
40 struct list_head qe;
41 bfa_timer_cbfn_t timercb;
42 void *arg;
43 int timeout;
44};
45
46
47
48
49struct bfa_timer_mod_s {
50 struct list_head timer_q;
51};
52
53#define BFA_TIMER_FREQ 200
54
55void bfa_timer_beat(struct bfa_timer_mod_s *mod);
56void bfa_timer_begin(struct bfa_timer_mod_s *mod, struct bfa_timer_s *timer,
57 bfa_timer_cbfn_t timercb, void *arg,
58 unsigned int timeout);
59void bfa_timer_stop(struct bfa_timer_s *timer);
60
61
62
63
64struct bfa_sge_s {
65 u32 sg_len;
66 void *sg_addr;
67};
68
69#define bfa_sge_word_swap(__sge) do { \
70 ((u32 *)(__sge))[0] = swab32(((u32 *)(__sge))[0]); \
71 ((u32 *)(__sge))[1] = swab32(((u32 *)(__sge))[1]); \
72 ((u32 *)(__sge))[2] = swab32(((u32 *)(__sge))[2]); \
73} while (0)
74
75#define bfa_swap_words(_x) ( \
76 ((u64)(_x) << 32) | ((u64)(_x) >> 32))
77
78#ifdef __BIG_ENDIAN
79#define bfa_sge_to_be(_x)
80#define bfa_sge_to_le(_x) bfa_sge_word_swap(_x)
81#define bfa_sgaddr_le(_x) bfa_swap_words(_x)
82#else
83#define bfa_sge_to_be(_x) bfa_sge_word_swap(_x)
84#define bfa_sge_to_le(_x)
85#define bfa_sgaddr_le(_x) (_x)
86#endif
87
88
89
90
91struct bfa_mem_dma_s {
92 struct list_head qe;
93 u32 mem_len;
94 u8 *kva;
95 u64 dma;
96 u8 *kva_curp;
97 u64 dma_curp;
98};
99#define bfa_mem_dma_t struct bfa_mem_dma_s
100
101struct bfa_mem_kva_s {
102 struct list_head qe;
103 u32 mem_len;
104 u8 *kva;
105 u8 *kva_curp;
106};
107#define bfa_mem_kva_t struct bfa_mem_kva_s
108
109struct bfa_meminfo_s {
110 struct bfa_mem_dma_s dma_info;
111 struct bfa_mem_kva_s kva_info;
112};
113
114
115static inline void bfa_mem_dma_setup(struct bfa_meminfo_s *meminfo,
116 struct bfa_mem_dma_s *dm_ptr,
117 size_t seg_sz)
118{
119 dm_ptr->mem_len = seg_sz;
120 if (seg_sz)
121 list_add_tail(&dm_ptr->qe, &meminfo->dma_info.qe);
122}
123
124static inline void bfa_mem_kva_setup(struct bfa_meminfo_s *meminfo,
125 struct bfa_mem_kva_s *kva_ptr,
126 size_t seg_sz)
127{
128 kva_ptr->mem_len = seg_sz;
129 if (seg_sz)
130 list_add_tail(&kva_ptr->qe, &meminfo->kva_info.qe);
131}
132
133
134#define bfa_mem_dma_sptr(_mod, _i) (&(_mod)->dma_seg[(_i)])
135#define bfa_mem_dma_seg_iter(_mod, _sptr, _nr, _i) \
136 for (_i = 0, _sptr = bfa_mem_dma_sptr(_mod, _i); _i < (_nr); \
137 _i++, _sptr = bfa_mem_dma_sptr(_mod, _i))
138
139#define bfa_mem_kva_curp(_mod) ((_mod)->kva_seg.kva_curp)
140#define bfa_mem_dma_virt(_sptr) ((_sptr)->kva_curp)
141#define bfa_mem_dma_phys(_sptr) ((_sptr)->dma_curp)
142#define bfa_mem_dma_len(_sptr) ((_sptr)->mem_len)
143
144
145#define bfa_mem_get_dmabuf_kva(_mod, _tag, _rqsz) \
146 (((u8 *)(_mod)->dma_seg[BFI_MEM_SEG_FROM_TAG(_tag, _rqsz)].kva_curp) +\
147 BFI_MEM_SEG_REQ_OFFSET(_tag, _rqsz) * (_rqsz))
148
149
150#define bfa_mem_get_dmabuf_pa(_mod, _tag, _rqsz) \
151 ((_mod)->dma_seg[BFI_MEM_SEG_FROM_TAG(_tag, _rqsz)].dma_curp + \
152 BFI_MEM_SEG_REQ_OFFSET(_tag, _rqsz) * (_rqsz))
153
154
155
156
157struct bfa_pcidev_s {
158 int pci_slot;
159 u8 pci_func;
160 u16 device_id;
161 u16 ssid;
162 void __iomem *pci_bar_kva;
163};
164
165
166
167
168
169struct bfa_dma_s {
170 void *kva;
171 u64 pa;
172};
173
174#define BFA_DMA_ALIGN_SZ 256
175#define BFA_ROUNDUP(_l, _s) (((_l) + ((_s) - 1)) & ~((_s) - 1))
176
177
178
179
180#define BFI_SMEM_CB_SIZE 0x200000U
181#define BFI_SMEM_CT_SIZE 0x280000U
182
183#define bfa_dma_be_addr_set(dma_addr, pa) \
184 __bfa_dma_be_addr_set(&dma_addr, (u64)pa)
185static inline void
186__bfa_dma_be_addr_set(union bfi_addr_u *dma_addr, u64 pa)
187{
188 dma_addr->a32.addr_lo = cpu_to_be32(pa);
189 dma_addr->a32.addr_hi = cpu_to_be32(pa >> 32);
190}
191
192#define bfa_alen_set(__alen, __len, __pa) \
193 __bfa_alen_set(__alen, __len, (u64)__pa)
194
195static inline void
196__bfa_alen_set(struct bfi_alen_s *alen, u32 len, u64 pa)
197{
198 alen->al_len = cpu_to_be32(len);
199 bfa_dma_be_addr_set(alen->al_addr, pa);
200}
201
202struct bfa_ioc_regs_s {
203 void __iomem *hfn_mbox_cmd;
204 void __iomem *hfn_mbox;
205 void __iomem *lpu_mbox_cmd;
206 void __iomem *lpu_mbox;
207 void __iomem *lpu_read_stat;
208 void __iomem *pss_ctl_reg;
209 void __iomem *pss_err_status_reg;
210 void __iomem *app_pll_fast_ctl_reg;
211 void __iomem *app_pll_slow_ctl_reg;
212 void __iomem *ioc_sem_reg;
213 void __iomem *ioc_usage_sem_reg;
214 void __iomem *ioc_init_sem_reg;
215 void __iomem *ioc_usage_reg;
216 void __iomem *host_page_num_fn;
217 void __iomem *heartbeat;
218 void __iomem *ioc_fwstate;
219 void __iomem *alt_ioc_fwstate;
220 void __iomem *ll_halt;
221 void __iomem *alt_ll_halt;
222 void __iomem *err_set;
223 void __iomem *ioc_fail_sync;
224 void __iomem *shirq_isr_next;
225 void __iomem *shirq_msk_next;
226 void __iomem *smem_page_start;
227 u32 smem_pg0;
228};
229
230#define bfa_mem_read(_raddr, _off) swab32(readl(((_raddr) + (_off))))
231#define bfa_mem_write(_raddr, _off, _val) \
232 writel(swab32((_val)), ((_raddr) + (_off)))
233
234
235
236struct bfa_mbox_cmd_s {
237 struct list_head qe;
238 u32 msg[BFI_IOC_MSGSZ];
239};
240
241
242
243
244typedef void (*bfa_ioc_mbox_mcfunc_t)(void *cbarg, struct bfi_mbmsg_s *m);
245struct bfa_ioc_mbox_mod_s {
246 struct list_head cmd_q;
247 int nmclass;
248 struct {
249 bfa_ioc_mbox_mcfunc_t cbfn;
250 void *cbarg;
251 } mbhdlr[BFI_MC_MAX];
252};
253
254
255
256
257typedef void (*bfa_ioc_enable_cbfn_t)(void *bfa, enum bfa_status status);
258typedef void (*bfa_ioc_disable_cbfn_t)(void *bfa);
259typedef void (*bfa_ioc_hbfail_cbfn_t)(void *bfa);
260typedef void (*bfa_ioc_reset_cbfn_t)(void *bfa);
261struct bfa_ioc_cbfn_s {
262 bfa_ioc_enable_cbfn_t enable_cbfn;
263 bfa_ioc_disable_cbfn_t disable_cbfn;
264 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
265 bfa_ioc_reset_cbfn_t reset_cbfn;
266};
267
268
269
270
271enum bfa_ioc_event_e {
272 BFA_IOC_E_ENABLED = 1,
273 BFA_IOC_E_DISABLED = 2,
274 BFA_IOC_E_FAILED = 3,
275};
276
277typedef void (*bfa_ioc_notify_cbfn_t)(void *, enum bfa_ioc_event_e);
278
279struct bfa_ioc_notify_s {
280 struct list_head qe;
281 bfa_ioc_notify_cbfn_t cbfn;
282 void *cbarg;
283};
284
285
286
287
288#define bfa_ioc_notify_init(__notify, __cbfn, __cbarg) do { \
289 (__notify)->cbfn = (__cbfn); \
290 (__notify)->cbarg = (__cbarg); \
291} while (0)
292
293struct bfa_iocpf_s {
294 bfa_fsm_t fsm;
295 struct bfa_ioc_s *ioc;
296 bfa_boolean_t fw_mismatch_notified;
297 bfa_boolean_t auto_recover;
298 u32 poll_time;
299};
300
301struct bfa_ioc_s {
302 bfa_fsm_t fsm;
303 struct bfa_s *bfa;
304 struct bfa_pcidev_s pcidev;
305 struct bfa_timer_mod_s *timer_mod;
306 struct bfa_timer_s ioc_timer;
307 struct bfa_timer_s sem_timer;
308 struct bfa_timer_s hb_timer;
309 u32 hb_count;
310 struct list_head notify_q;
311 void *dbg_fwsave;
312 int dbg_fwsave_len;
313 bfa_boolean_t dbg_fwsave_once;
314 enum bfi_pcifn_class clscode;
315 struct bfa_ioc_regs_s ioc_regs;
316 struct bfa_trc_mod_s *trcmod;
317 struct bfa_ioc_drv_stats_s stats;
318 bfa_boolean_t fcmode;
319 bfa_boolean_t pllinit;
320 bfa_boolean_t stats_busy;
321 u8 port_id;
322 struct bfa_dma_s attr_dma;
323 struct bfi_ioc_attr_s *attr;
324 struct bfa_ioc_cbfn_s *cbfn;
325 struct bfa_ioc_mbox_mod_s mbox_mod;
326 struct bfa_ioc_hwif_s *ioc_hwif;
327 struct bfa_iocpf_s iocpf;
328 enum bfi_asic_gen asic_gen;
329 enum bfi_asic_mode asic_mode;
330 enum bfi_port_mode port0_mode;
331 enum bfi_port_mode port1_mode;
332 enum bfa_mode_s port_mode;
333 u8 ad_cap_bm;
334 u8 port_mode_cfg;
335 int ioc_aen_seq;
336};
337
338struct bfa_ioc_hwif_s {
339 bfa_status_t (*ioc_pll_init) (void __iomem *rb, enum bfi_asic_mode m);
340 bfa_boolean_t (*ioc_firmware_lock) (struct bfa_ioc_s *ioc);
341 void (*ioc_firmware_unlock) (struct bfa_ioc_s *ioc);
342 void (*ioc_reg_init) (struct bfa_ioc_s *ioc);
343 void (*ioc_map_port) (struct bfa_ioc_s *ioc);
344 void (*ioc_isr_mode_set) (struct bfa_ioc_s *ioc,
345 bfa_boolean_t msix);
346 void (*ioc_notify_fail) (struct bfa_ioc_s *ioc);
347 void (*ioc_ownership_reset) (struct bfa_ioc_s *ioc);
348 bfa_boolean_t (*ioc_sync_start) (struct bfa_ioc_s *ioc);
349 void (*ioc_sync_join) (struct bfa_ioc_s *ioc);
350 void (*ioc_sync_leave) (struct bfa_ioc_s *ioc);
351 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
352 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
353 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
354 void (*ioc_set_fwstate) (struct bfa_ioc_s *ioc,
355 enum bfi_ioc_state fwstate);
356 enum bfi_ioc_state (*ioc_get_fwstate) (struct bfa_ioc_s *ioc);
357 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
358 enum bfi_ioc_state fwstate);
359 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
360};
361
362
363
364
365
366struct bfa_reqq_wait_s {
367 struct list_head qe;
368 void (*qresume) (void *cbarg);
369 void *cbarg;
370};
371
372typedef void (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete);
373
374
375
376
377struct bfa_cb_qe_s {
378 struct list_head qe;
379 bfa_cb_cbfn_t cbfn;
380 bfa_boolean_t once;
381 bfa_boolean_t pre_rmv;
382 bfa_status_t fw_status;
383 void *cbarg;
384};
385
386
387
388
389enum iocfc_event {
390 IOCFC_E_INIT = 1,
391 IOCFC_E_START = 2,
392 IOCFC_E_STOP = 3,
393 IOCFC_E_ENABLE = 4,
394 IOCFC_E_DISABLE = 5,
395 IOCFC_E_IOC_ENABLED = 6,
396 IOCFC_E_IOC_DISABLED = 7,
397 IOCFC_E_IOC_FAILED = 8,
398 IOCFC_E_DCONF_DONE = 9,
399 IOCFC_E_CFG_DONE = 10,
400};
401
402
403
404
405
406typedef void (*bfa_ablk_cbfn_t)(void *, enum bfa_status);
407
408struct bfa_ablk_s {
409 struct bfa_ioc_s *ioc;
410 struct bfa_ablk_cfg_s *cfg;
411 u16 *pcifn;
412 struct bfa_dma_s dma_addr;
413 bfa_boolean_t busy;
414 struct bfa_mbox_cmd_s mb;
415 bfa_ablk_cbfn_t cbfn;
416 void *cbarg;
417 struct bfa_ioc_notify_s ioc_notify;
418 struct bfa_mem_dma_s ablk_dma;
419};
420#define BFA_MEM_ABLK_DMA(__bfa) (&((__bfa)->modules.ablk.ablk_dma))
421
422
423
424
425typedef void (*bfa_cb_sfp_t) (void *cbarg, bfa_status_t status);
426
427struct bfa_sfp_s {
428 void *dev;
429 struct bfa_ioc_s *ioc;
430 struct bfa_trc_mod_s *trcmod;
431 struct sfp_mem_s *sfpmem;
432 bfa_cb_sfp_t cbfn;
433 void *cbarg;
434 enum bfi_sfp_mem_e memtype;
435 u32 status;
436 struct bfa_mbox_cmd_s mbcmd;
437 u8 *dbuf_kva;
438 u64 dbuf_pa;
439 struct bfa_ioc_notify_s ioc_notify;
440 enum bfa_defs_sfp_media_e *media;
441 enum bfa_port_speed portspeed;
442 bfa_cb_sfp_t state_query_cbfn;
443 void *state_query_cbarg;
444 u8 lock;
445 u8 data_valid;
446 u8 state;
447 u8 state_query_lock;
448 struct bfa_mem_dma_s sfp_dma;
449 u8 is_elb;
450};
451
452#define BFA_SFP_MOD(__bfa) (&(__bfa)->modules.sfp)
453#define BFA_MEM_SFP_DMA(__bfa) (&(BFA_SFP_MOD(__bfa)->sfp_dma))
454
455u32 bfa_sfp_meminfo(void);
456
457void bfa_sfp_attach(struct bfa_sfp_s *sfp, struct bfa_ioc_s *ioc,
458 void *dev, struct bfa_trc_mod_s *trcmod);
459
460void bfa_sfp_memclaim(struct bfa_sfp_s *diag, u8 *dm_kva, u64 dm_pa);
461void bfa_sfp_intr(void *bfaarg, struct bfi_mbmsg_s *msg);
462
463bfa_status_t bfa_sfp_show(struct bfa_sfp_s *sfp, struct sfp_mem_s *sfpmem,
464 bfa_cb_sfp_t cbfn, void *cbarg);
465
466bfa_status_t bfa_sfp_media(struct bfa_sfp_s *sfp,
467 enum bfa_defs_sfp_media_e *media,
468 bfa_cb_sfp_t cbfn, void *cbarg);
469
470bfa_status_t bfa_sfp_speed(struct bfa_sfp_s *sfp,
471 enum bfa_port_speed portspeed,
472 bfa_cb_sfp_t cbfn, void *cbarg);
473
474
475
476
477typedef void (*bfa_cb_flash_t) (void *cbarg, bfa_status_t status);
478
479struct bfa_flash_s {
480 struct bfa_ioc_s *ioc;
481 struct bfa_trc_mod_s *trcmod;
482 u32 type;
483 u8 instance;
484 u8 rsv[3];
485 u32 op_busy;
486 u32 residue;
487 u32 offset;
488 bfa_status_t status;
489 u8 *dbuf_kva;
490 u64 dbuf_pa;
491 struct bfa_reqq_wait_s reqq_wait;
492 bfa_cb_flash_t cbfn;
493 void *cbarg;
494 u8 *ubuf;
495 struct bfa_cb_qe_s hcb_qe;
496 u32 addr_off;
497 struct bfa_mbox_cmd_s mb;
498 struct bfa_ioc_notify_s ioc_notify;
499 struct bfa_mem_dma_s flash_dma;
500};
501
502#define BFA_FLASH(__bfa) (&(__bfa)->modules.flash)
503#define BFA_MEM_FLASH_DMA(__bfa) (&(BFA_FLASH(__bfa)->flash_dma))
504
505bfa_status_t bfa_flash_get_attr(struct bfa_flash_s *flash,
506 struct bfa_flash_attr_s *attr,
507 bfa_cb_flash_t cbfn, void *cbarg);
508bfa_status_t bfa_flash_erase_part(struct bfa_flash_s *flash,
509 enum bfa_flash_part_type type, u8 instance,
510 bfa_cb_flash_t cbfn, void *cbarg);
511bfa_status_t bfa_flash_update_part(struct bfa_flash_s *flash,
512 enum bfa_flash_part_type type, u8 instance,
513 void *buf, u32 len, u32 offset,
514 bfa_cb_flash_t cbfn, void *cbarg);
515bfa_status_t bfa_flash_read_part(struct bfa_flash_s *flash,
516 enum bfa_flash_part_type type, u8 instance, void *buf,
517 u32 len, u32 offset, bfa_cb_flash_t cbfn, void *cbarg);
518u32 bfa_flash_meminfo(bfa_boolean_t mincfg);
519void bfa_flash_attach(struct bfa_flash_s *flash, struct bfa_ioc_s *ioc,
520 void *dev, struct bfa_trc_mod_s *trcmod, bfa_boolean_t mincfg);
521void bfa_flash_memclaim(struct bfa_flash_s *flash,
522 u8 *dm_kva, u64 dm_pa, bfa_boolean_t mincfg);
523bfa_status_t bfa_flash_raw_read(void __iomem *pci_bar_kva,
524 u32 offset, char *buf, u32 len);
525
526
527
528
529
530typedef void (*bfa_cb_diag_t) (void *cbarg, bfa_status_t status);
531typedef void (*bfa_cb_diag_beacon_t) (void *dev, bfa_boolean_t beacon,
532 bfa_boolean_t link_e2e_beacon);
533
534
535
536
537struct bfa_diag_results_fwping {
538 u32 data;
539 u32 status;
540 u32 dmastatus;
541 u8 rsvd[4];
542};
543
544struct bfa_diag_qtest_result_s {
545 u32 status;
546 u16 count;
547 u8 queue;
548 u8 rsvd;
549};
550
551
552
553
554struct bfa_diag_fwping_s {
555 struct bfa_diag_results_fwping *result;
556 bfa_cb_diag_t cbfn;
557 void *cbarg;
558 u32 data;
559 u8 lock;
560 u8 rsv[3];
561 u32 status;
562 u32 count;
563 struct bfa_mbox_cmd_s mbcmd;
564 u8 *dbuf_kva;
565 u64 dbuf_pa;
566};
567
568
569
570
571struct bfa_diag_results_tempsensor_s {
572 u32 status;
573 u16 temp;
574 u16 brd_temp;
575 u8 ts_junc;
576 u8 ts_brd;
577 u8 rsvd[6];
578};
579
580struct bfa_diag_tsensor_s {
581 bfa_cb_diag_t cbfn;
582 void *cbarg;
583 struct bfa_diag_results_tempsensor_s *temp;
584 u8 lock;
585 u8 rsv[3];
586 u32 status;
587 struct bfa_mbox_cmd_s mbcmd;
588};
589
590struct bfa_diag_sfpshow_s {
591 struct sfp_mem_s *sfpmem;
592 bfa_cb_diag_t cbfn;
593 void *cbarg;
594 u8 lock;
595 u8 static_data;
596 u8 rsv[2];
597 u32 status;
598 struct bfa_mbox_cmd_s mbcmd;
599 u8 *dbuf_kva;
600 u64 dbuf_pa;
601};
602
603struct bfa_diag_led_s {
604 struct bfa_mbox_cmd_s mbcmd;
605 bfa_boolean_t lock;
606};
607
608struct bfa_diag_beacon_s {
609 struct bfa_mbox_cmd_s mbcmd;
610 bfa_boolean_t state;
611 bfa_boolean_t link_e2e;
612};
613
614struct bfa_diag_s {
615 void *dev;
616 struct bfa_ioc_s *ioc;
617 struct bfa_trc_mod_s *trcmod;
618 struct bfa_diag_fwping_s fwping;
619 struct bfa_diag_tsensor_s tsensor;
620 struct bfa_diag_sfpshow_s sfpshow;
621 struct bfa_diag_led_s ledtest;
622 struct bfa_diag_beacon_s beacon;
623 void *result;
624 struct bfa_timer_s timer;
625 bfa_cb_diag_beacon_t cbfn_beacon;
626 bfa_cb_diag_t cbfn;
627 void *cbarg;
628 u8 block;
629 u8 timer_active;
630 u8 rsvd[2];
631 u32 status;
632 struct bfa_ioc_notify_s ioc_notify;
633 struct bfa_mem_dma_s diag_dma;
634};
635
636#define BFA_DIAG_MOD(__bfa) (&(__bfa)->modules.diag_mod)
637#define BFA_MEM_DIAG_DMA(__bfa) (&(BFA_DIAG_MOD(__bfa)->diag_dma))
638
639u32 bfa_diag_meminfo(void);
640void bfa_diag_memclaim(struct bfa_diag_s *diag, u8 *dm_kva, u64 dm_pa);
641void bfa_diag_attach(struct bfa_diag_s *diag, struct bfa_ioc_s *ioc, void *dev,
642 bfa_cb_diag_beacon_t cbfn_beacon,
643 struct bfa_trc_mod_s *trcmod);
644bfa_status_t bfa_diag_reg_read(struct bfa_diag_s *diag, u32 offset,
645 u32 len, u32 *buf, u32 force);
646bfa_status_t bfa_diag_reg_write(struct bfa_diag_s *diag, u32 offset,
647 u32 len, u32 value, u32 force);
648bfa_status_t bfa_diag_tsensor_query(struct bfa_diag_s *diag,
649 struct bfa_diag_results_tempsensor_s *result,
650 bfa_cb_diag_t cbfn, void *cbarg);
651bfa_status_t bfa_diag_fwping(struct bfa_diag_s *diag, u32 cnt,
652 u32 pattern, struct bfa_diag_results_fwping *result,
653 bfa_cb_diag_t cbfn, void *cbarg);
654bfa_status_t bfa_diag_sfpshow(struct bfa_diag_s *diag,
655 struct sfp_mem_s *sfpmem, u8 static_data,
656 bfa_cb_diag_t cbfn, void *cbarg);
657bfa_status_t bfa_diag_memtest(struct bfa_diag_s *diag,
658 struct bfa_diag_memtest_s *memtest, u32 pattern,
659 struct bfa_diag_memtest_result *result,
660 bfa_cb_diag_t cbfn, void *cbarg);
661bfa_status_t bfa_diag_ledtest(struct bfa_diag_s *diag,
662 struct bfa_diag_ledtest_s *ledtest);
663bfa_status_t bfa_diag_beacon_port(struct bfa_diag_s *diag,
664 bfa_boolean_t beacon, bfa_boolean_t link_e2e_beacon,
665 u32 sec);
666
667
668
669
670typedef void (*bfa_cb_phy_t) (void *cbarg, bfa_status_t status);
671
672struct bfa_phy_s {
673 struct bfa_ioc_s *ioc;
674 struct bfa_trc_mod_s *trcmod;
675 u8 instance;
676 u8 op_busy;
677 u8 rsv[2];
678 u32 residue;
679 u32 offset;
680 bfa_status_t status;
681 u8 *dbuf_kva;
682 u64 dbuf_pa;
683 struct bfa_reqq_wait_s reqq_wait;
684 bfa_cb_phy_t cbfn;
685 void *cbarg;
686 u8 *ubuf;
687 struct bfa_cb_qe_s hcb_qe;
688 u32 addr_off;
689 struct bfa_mbox_cmd_s mb;
690 struct bfa_ioc_notify_s ioc_notify;
691 struct bfa_mem_dma_s phy_dma;
692};
693#define BFA_PHY(__bfa) (&(__bfa)->modules.phy)
694#define BFA_MEM_PHY_DMA(__bfa) (&(BFA_PHY(__bfa)->phy_dma))
695
696bfa_boolean_t bfa_phy_busy(struct bfa_ioc_s *ioc);
697bfa_status_t bfa_phy_get_attr(struct bfa_phy_s *phy, u8 instance,
698 struct bfa_phy_attr_s *attr,
699 bfa_cb_phy_t cbfn, void *cbarg);
700bfa_status_t bfa_phy_get_stats(struct bfa_phy_s *phy, u8 instance,
701 struct bfa_phy_stats_s *stats,
702 bfa_cb_phy_t cbfn, void *cbarg);
703bfa_status_t bfa_phy_update(struct bfa_phy_s *phy, u8 instance,
704 void *buf, u32 len, u32 offset,
705 bfa_cb_phy_t cbfn, void *cbarg);
706bfa_status_t bfa_phy_read(struct bfa_phy_s *phy, u8 instance,
707 void *buf, u32 len, u32 offset,
708 bfa_cb_phy_t cbfn, void *cbarg);
709
710u32 bfa_phy_meminfo(bfa_boolean_t mincfg);
711void bfa_phy_attach(struct bfa_phy_s *phy, struct bfa_ioc_s *ioc,
712 void *dev, struct bfa_trc_mod_s *trcmod, bfa_boolean_t mincfg);
713void bfa_phy_memclaim(struct bfa_phy_s *phy,
714 u8 *dm_kva, u64 dm_pa, bfa_boolean_t mincfg);
715void bfa_phy_intr(void *phyarg, struct bfi_mbmsg_s *msg);
716
717
718
719
720typedef void (*bfa_cb_fru_t) (void *cbarg, bfa_status_t status);
721
722struct bfa_fru_s {
723 struct bfa_ioc_s *ioc;
724 struct bfa_trc_mod_s *trcmod;
725 u8 op_busy;
726 u8 rsv[3];
727 u32 residue;
728 u32 offset;
729 bfa_status_t status;
730 u8 *dbuf_kva;
731 u64 dbuf_pa;
732 struct bfa_reqq_wait_s reqq_wait;
733 bfa_cb_fru_t cbfn;
734 void *cbarg;
735 u8 *ubuf;
736 struct bfa_cb_qe_s hcb_qe;
737 u32 addr_off;
738 struct bfa_mbox_cmd_s mb;
739 struct bfa_ioc_notify_s ioc_notify;
740 struct bfa_mem_dma_s fru_dma;
741 u8 trfr_cmpl;
742};
743
744#define BFA_FRU(__bfa) (&(__bfa)->modules.fru)
745#define BFA_MEM_FRU_DMA(__bfa) (&(BFA_FRU(__bfa)->fru_dma))
746
747bfa_status_t bfa_fruvpd_update(struct bfa_fru_s *fru,
748 void *buf, u32 len, u32 offset,
749 bfa_cb_fru_t cbfn, void *cbarg, u8 trfr_cmpl);
750bfa_status_t bfa_fruvpd_read(struct bfa_fru_s *fru,
751 void *buf, u32 len, u32 offset,
752 bfa_cb_fru_t cbfn, void *cbarg);
753bfa_status_t bfa_fruvpd_get_max_size(struct bfa_fru_s *fru, u32 *max_size);
754bfa_status_t bfa_tfru_write(struct bfa_fru_s *fru,
755 void *buf, u32 len, u32 offset,
756 bfa_cb_fru_t cbfn, void *cbarg);
757bfa_status_t bfa_tfru_read(struct bfa_fru_s *fru,
758 void *buf, u32 len, u32 offset,
759 bfa_cb_fru_t cbfn, void *cbarg);
760u32 bfa_fru_meminfo(bfa_boolean_t mincfg);
761void bfa_fru_attach(struct bfa_fru_s *fru, struct bfa_ioc_s *ioc,
762 void *dev, struct bfa_trc_mod_s *trcmod, bfa_boolean_t mincfg);
763void bfa_fru_memclaim(struct bfa_fru_s *fru,
764 u8 *dm_kva, u64 dm_pa, bfa_boolean_t mincfg);
765void bfa_fru_intr(void *fruarg, struct bfi_mbmsg_s *msg);
766
767
768
769
770#define BFI_DCONF_SIGNATURE 0xabcdabcd
771#define BFI_DCONF_VERSION 1
772
773#pragma pack(1)
774struct bfa_dconf_hdr_s {
775 u32 signature;
776 u32 version;
777};
778
779struct bfa_dconf_s {
780 struct bfa_dconf_hdr_s hdr;
781 struct bfa_lunmask_cfg_s lun_mask;
782 struct bfa_throttle_cfg_s throttle_cfg;
783};
784#pragma pack()
785
786struct bfa_dconf_mod_s {
787 bfa_sm_t sm;
788 u8 instance;
789 bfa_boolean_t read_data_valid;
790 bfa_boolean_t min_cfg;
791 struct bfa_timer_s timer;
792 struct bfa_s *bfa;
793 void *bfad;
794 void *trcmod;
795 struct bfa_dconf_s *dconf;
796 struct bfa_mem_kva_s kva_seg;
797};
798
799#define BFA_DCONF_MOD(__bfa) \
800 (&(__bfa)->modules.dconf_mod)
801#define BFA_MEM_DCONF_KVA(__bfa) (&(BFA_DCONF_MOD(__bfa)->kva_seg))
802#define bfa_dconf_read_data_valid(__bfa) \
803 (BFA_DCONF_MOD(__bfa)->read_data_valid)
804#define BFA_DCONF_UPDATE_TOV 5000
805#define bfa_dconf_get_min_cfg(__bfa) \
806 (BFA_DCONF_MOD(__bfa)->min_cfg)
807
808void bfa_dconf_modinit(struct bfa_s *bfa);
809void bfa_dconf_modexit(struct bfa_s *bfa);
810bfa_status_t bfa_dconf_update(struct bfa_s *bfa);
811
812
813
814
815#define bfa_ioc_pcifn(__ioc) ((__ioc)->pcidev.pci_func)
816#define bfa_ioc_devid(__ioc) ((__ioc)->pcidev.device_id)
817#define bfa_ioc_bar0(__ioc) ((__ioc)->pcidev.pci_bar_kva)
818#define bfa_ioc_portid(__ioc) ((__ioc)->port_id)
819#define bfa_ioc_asic_gen(__ioc) ((__ioc)->asic_gen)
820#define bfa_ioc_is_cna(__ioc) \
821 ((bfa_ioc_get_type(__ioc) == BFA_IOC_TYPE_FCoE) || \
822 (bfa_ioc_get_type(__ioc) == BFA_IOC_TYPE_LL))
823#define bfa_ioc_fetch_stats(__ioc, __stats) \
824 (((__stats)->drv_stats) = (__ioc)->stats)
825#define bfa_ioc_clr_stats(__ioc) \
826 memset(&(__ioc)->stats, 0, sizeof((__ioc)->stats))
827#define bfa_ioc_maxfrsize(__ioc) ((__ioc)->attr->maxfrsize)
828#define bfa_ioc_rx_bbcredit(__ioc) ((__ioc)->attr->rx_bbcredit)
829#define bfa_ioc_speed_sup(__ioc) \
830 ((bfa_ioc_is_cna(__ioc)) ? BFA_PORT_SPEED_10GBPS : \
831 BFI_ADAPTER_GETP(SPEED, (__ioc)->attr->adapter_prop))
832#define bfa_ioc_get_nports(__ioc) \
833 BFI_ADAPTER_GETP(NPORTS, (__ioc)->attr->adapter_prop)
834
835#define bfa_ioc_stats(_ioc, _stats) ((_ioc)->stats._stats++)
836#define BFA_IOC_FWIMG_MINSZ (16 * 1024)
837#define BFA_IOC_FW_SMEM_SIZE(__ioc) \
838 ((bfa_ioc_asic_gen(__ioc) == BFI_ASIC_GEN_CB) \
839 ? BFI_SMEM_CB_SIZE : BFI_SMEM_CT_SIZE)
840#define BFA_IOC_FLASH_CHUNK_NO(off) (off / BFI_FLASH_CHUNK_SZ_WORDS)
841#define BFA_IOC_FLASH_OFFSET_IN_CHUNK(off) (off % BFI_FLASH_CHUNK_SZ_WORDS)
842#define BFA_IOC_FLASH_CHUNK_ADDR(chunkno) (chunkno * BFI_FLASH_CHUNK_SZ_WORDS)
843
844
845
846
847void bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd);
848void bfa_ioc_mbox_register(struct bfa_ioc_s *ioc,
849 bfa_ioc_mbox_mcfunc_t *mcfuncs);
850void bfa_ioc_mbox_isr(struct bfa_ioc_s *ioc);
851void bfa_ioc_mbox_send(struct bfa_ioc_s *ioc, void *ioc_msg, int len);
852bfa_boolean_t bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg);
853void bfa_ioc_mbox_regisr(struct bfa_ioc_s *ioc, enum bfi_mclass mc,
854 bfa_ioc_mbox_mcfunc_t cbfn, void *cbarg);
855
856
857
858
859
860#define bfa_ioc_pll_init_asic(__ioc) \
861 ((__ioc)->ioc_hwif->ioc_pll_init((__ioc)->pcidev.pci_bar_kva, \
862 (__ioc)->asic_mode))
863
864bfa_status_t bfa_ioc_pll_init(struct bfa_ioc_s *ioc);
865bfa_status_t bfa_ioc_cb_pll_init(void __iomem *rb, enum bfi_asic_mode mode);
866bfa_status_t bfa_ioc_ct_pll_init(void __iomem *rb, enum bfi_asic_mode mode);
867bfa_status_t bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode mode);
868
869#define bfa_ioc_isr_mode_set(__ioc, __msix) do { \
870 if ((__ioc)->ioc_hwif->ioc_isr_mode_set) \
871 ((__ioc)->ioc_hwif->ioc_isr_mode_set(__ioc, __msix)); \
872} while (0)
873#define bfa_ioc_ownership_reset(__ioc) \
874 ((__ioc)->ioc_hwif->ioc_ownership_reset(__ioc))
875#define bfa_ioc_get_fcmode(__ioc) ((__ioc)->fcmode)
876#define bfa_ioc_lpu_read_stat(__ioc) do { \
877 if ((__ioc)->ioc_hwif->ioc_lpu_read_stat) \
878 ((__ioc)->ioc_hwif->ioc_lpu_read_stat(__ioc)); \
879} while (0)
880
881void bfa_ioc_set_cb_hwif(struct bfa_ioc_s *ioc);
882void bfa_ioc_set_ct_hwif(struct bfa_ioc_s *ioc);
883void bfa_ioc_set_ct2_hwif(struct bfa_ioc_s *ioc);
884void bfa_ioc_ct2_poweron(struct bfa_ioc_s *ioc);
885
886void bfa_ioc_attach(struct bfa_ioc_s *ioc, void *bfa,
887 struct bfa_ioc_cbfn_s *cbfn, struct bfa_timer_mod_s *timer_mod);
888void bfa_ioc_auto_recover(bfa_boolean_t auto_recover);
889void bfa_ioc_detach(struct bfa_ioc_s *ioc);
890void bfa_ioc_suspend(struct bfa_ioc_s *ioc);
891void bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev,
892 enum bfi_pcifn_class clscode);
893void bfa_ioc_mem_claim(struct bfa_ioc_s *ioc, u8 *dm_kva, u64 dm_pa);
894void bfa_ioc_enable(struct bfa_ioc_s *ioc);
895void bfa_ioc_disable(struct bfa_ioc_s *ioc);
896bfa_boolean_t bfa_ioc_intx_claim(struct bfa_ioc_s *ioc);
897
898bfa_status_t bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type,
899 u32 boot_env);
900void bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *msg);
901void bfa_ioc_error_isr(struct bfa_ioc_s *ioc);
902bfa_boolean_t bfa_ioc_is_operational(struct bfa_ioc_s *ioc);
903bfa_boolean_t bfa_ioc_is_initialized(struct bfa_ioc_s *ioc);
904bfa_boolean_t bfa_ioc_is_disabled(struct bfa_ioc_s *ioc);
905bfa_boolean_t bfa_ioc_is_acq_addr(struct bfa_ioc_s *ioc);
906bfa_boolean_t bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc);
907bfa_boolean_t bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc);
908void bfa_ioc_reset_fwstate(struct bfa_ioc_s *ioc);
909enum bfa_ioc_type_e bfa_ioc_get_type(struct bfa_ioc_s *ioc);
910void bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num);
911void bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver);
912void bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver);
913void bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model);
914void bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc,
915 char *manufacturer);
916void bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev);
917enum bfa_ioc_state bfa_ioc_get_state(struct bfa_ioc_s *ioc);
918
919void bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr);
920void bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
921 struct bfa_adapter_attr_s *ad_attr);
922void bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave);
923bfa_status_t bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata,
924 int *trclen);
925bfa_status_t bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata,
926 int *trclen);
927bfa_status_t bfa_ioc_debug_fwcore(struct bfa_ioc_s *ioc, void *buf,
928 u32 *offset, int *buflen);
929bfa_status_t bfa_ioc_fwsig_invalidate(struct bfa_ioc_s *ioc);
930bfa_boolean_t bfa_ioc_sem_get(void __iomem *sem_reg);
931void bfa_ioc_fwver_get(struct bfa_ioc_s *ioc,
932 struct bfi_ioc_image_hdr_s *fwhdr);
933bfa_boolean_t bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc,
934 struct bfi_ioc_image_hdr_s *fwhdr);
935void bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event);
936bfa_status_t bfa_ioc_fw_stats_get(struct bfa_ioc_s *ioc, void *stats);
937bfa_status_t bfa_ioc_fw_stats_clear(struct bfa_ioc_s *ioc);
938void bfa_ioc_debug_save_ftrc(struct bfa_ioc_s *ioc);
939
940
941
942
943u32 bfa_ablk_meminfo(void);
944void bfa_ablk_memclaim(struct bfa_ablk_s *ablk, u8 *dma_kva, u64 dma_pa);
945void bfa_ablk_attach(struct bfa_ablk_s *ablk, struct bfa_ioc_s *ioc);
946bfa_status_t bfa_ablk_query(struct bfa_ablk_s *ablk,
947 struct bfa_ablk_cfg_s *ablk_cfg,
948 bfa_ablk_cbfn_t cbfn, void *cbarg);
949bfa_status_t bfa_ablk_adapter_config(struct bfa_ablk_s *ablk,
950 enum bfa_mode_s mode, int max_pf, int max_vf,
951 bfa_ablk_cbfn_t cbfn, void *cbarg);
952bfa_status_t bfa_ablk_port_config(struct bfa_ablk_s *ablk, int port,
953 enum bfa_mode_s mode, int max_pf, int max_vf,
954 bfa_ablk_cbfn_t cbfn, void *cbarg);
955bfa_status_t bfa_ablk_pf_create(struct bfa_ablk_s *ablk, u16 *pcifn,
956 u8 port, enum bfi_pcifn_class personality,
957 u16 bw_min, u16 bw_max, bfa_ablk_cbfn_t cbfn, void *cbarg);
958bfa_status_t bfa_ablk_pf_delete(struct bfa_ablk_s *ablk, int pcifn,
959 bfa_ablk_cbfn_t cbfn, void *cbarg);
960bfa_status_t bfa_ablk_pf_update(struct bfa_ablk_s *ablk, int pcifn,
961 u16 bw_min, u16 bw_max, bfa_ablk_cbfn_t cbfn, void *cbarg);
962bfa_status_t bfa_ablk_optrom_en(struct bfa_ablk_s *ablk,
963 bfa_ablk_cbfn_t cbfn, void *cbarg);
964bfa_status_t bfa_ablk_optrom_dis(struct bfa_ablk_s *ablk,
965 bfa_ablk_cbfn_t cbfn, void *cbarg);
966
967bfa_status_t bfa_ioc_flash_img_get_chnk(struct bfa_ioc_s *ioc, u32 off,
968 u32 *fwimg);
969
970
971
972mac_t bfa_ioc_get_mac(struct bfa_ioc_s *ioc);
973mac_t bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc);
974
975
976
977
978extern u32 bfi_image_cb_size;
979extern u32 bfi_image_ct_size;
980extern u32 bfi_image_ct2_size;
981extern u32 *bfi_image_cb;
982extern u32 *bfi_image_ct;
983extern u32 *bfi_image_ct2;
984
985static inline u32 *
986bfi_image_cb_get_chunk(u32 off)
987{
988 return (u32 *)(bfi_image_cb + off);
989}
990
991static inline u32 *
992bfi_image_ct_get_chunk(u32 off)
993{
994 return (u32 *)(bfi_image_ct + off);
995}
996
997static inline u32 *
998bfi_image_ct2_get_chunk(u32 off)
999{
1000 return (u32 *)(bfi_image_ct2 + off);
1001}
1002
1003static inline u32*
1004bfa_cb_image_get_chunk(enum bfi_asic_gen asic_gen, u32 off)
1005{
1006 switch (asic_gen) {
1007 case BFI_ASIC_GEN_CB:
1008 return bfi_image_cb_get_chunk(off);
1009 break;
1010 case BFI_ASIC_GEN_CT:
1011 return bfi_image_ct_get_chunk(off);
1012 break;
1013 case BFI_ASIC_GEN_CT2:
1014 return bfi_image_ct2_get_chunk(off);
1015 break;
1016 default:
1017 return NULL;
1018 }
1019}
1020
1021static inline u32
1022bfa_cb_image_get_size(enum bfi_asic_gen asic_gen)
1023{
1024 switch (asic_gen) {
1025 case BFI_ASIC_GEN_CB:
1026 return bfi_image_cb_size;
1027 break;
1028 case BFI_ASIC_GEN_CT:
1029 return bfi_image_ct_size;
1030 break;
1031 case BFI_ASIC_GEN_CT2:
1032 return bfi_image_ct2_size;
1033 break;
1034 default:
1035 return 0;
1036 }
1037}
1038
1039
1040
1041
1042
1043
1044
1045
1046enum {
1047 BFA_TRC_CNA_PORT = 1,
1048 BFA_TRC_CNA_IOC = 2,
1049 BFA_TRC_CNA_IOC_CB = 3,
1050 BFA_TRC_CNA_IOC_CT = 4,
1051};
1052
1053#endif
1054