GNU Linux-libre 4.14.265-gnu1
[releases.git] / drivers / scsi / bfa / bfa_ioc.h
1 /*
2  * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
3  * Copyright (c) 2014- QLogic Corporation.
4  * All rights reserved
5  * www.qlogic.com
6  *
7  * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License (GPL) Version 2 as
11  * published by the Free Software Foundation
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  */
18
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  * BFA timer declarations
33  */
34 typedef void (*bfa_timer_cbfn_t)(void *);
35
36 /*
37  * BFA timer data structure
38  */
39 struct bfa_timer_s {
40         struct list_head        qe;
41         bfa_timer_cbfn_t timercb;
42         void            *arg;
43         int             timeout;        /* in millisecs */
44 };
45
46 /*
47  * Timer module structure
48  */
49 struct bfa_timer_mod_s {
50         struct list_head timer_q;
51 };
52
53 #define BFA_TIMER_FREQ 200 /* specified in millisecs */
54
55 void bfa_timer_beat(struct bfa_timer_mod_s *mod);
56 void 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);
59 void bfa_timer_stop(struct bfa_timer_s *timer);
60
61 /*
62  * Generic Scatter Gather Element used by driver
63  */
64 struct 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  * BFA memory resources
90  */
91 struct bfa_mem_dma_s {
92         struct list_head qe;            /* Queue of DMA elements */
93         u32             mem_len;        /* Total Length in Bytes */
94         u8              *kva;           /* kernel virtual address */
95         u64             dma;            /* dma address if DMA memory */
96         u8              *kva_curp;      /* kva allocation cursor */
97         u64             dma_curp;       /* dma allocation cursor */
98 };
99 #define bfa_mem_dma_t struct bfa_mem_dma_s
100
101 struct bfa_mem_kva_s {
102         struct list_head qe;            /* Queue of KVA elements */
103         u32             mem_len;        /* Total Length in Bytes */
104         u8              *kva;           /* kernel virtual address */
105         u8              *kva_curp;      /* kva allocation cursor */
106 };
107 #define bfa_mem_kva_t struct bfa_mem_kva_s
108
109 struct bfa_meminfo_s {
110         struct bfa_mem_dma_s dma_info;
111         struct bfa_mem_kva_s kva_info;
112 };
113
114 /* BFA memory segment setup helpers */
115 static 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
124 static 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 /* BFA dma memory segments iterator */
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 /* Get the corresponding dma buf kva for a req - from the tag */
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 /* Get the corresponding dma buf pa for a req - from the tag */
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  * PCI device information required by IOC
156  */
157 struct 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  * Structure used to remember the DMA-able memory block's KVA and Physical
167  * Address
168  */
169 struct bfa_dma_s {
170         void            *kva;   /* ! Kernel virtual address     */
171         u64     pa;     /* ! Physical address           */
172 };
173
174 #define BFA_DMA_ALIGN_SZ        256
175 #define BFA_ROUNDUP(_l, _s)     (((_l) + ((_s) - 1)) & ~((_s) - 1))
176
177 /*
178  * smem size for Crossbow and Catapult
179  */
180 #define BFI_SMEM_CB_SIZE        0x200000U       /* ! 2MB for crossbow   */
181 #define BFI_SMEM_CT_SIZE        0x280000U       /* ! 2.5MB for catapult */
182
183 #define bfa_dma_be_addr_set(dma_addr, pa)       \
184                 __bfa_dma_be_addr_set(&dma_addr, (u64)pa)
185 static 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
195 static 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
202 struct 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  * IOC Mailbox structures
235  */
236 struct bfa_mbox_cmd_s {
237         struct list_head        qe;
238         u32     msg[BFI_IOC_MSGSZ];
239 };
240
241 /*
242  * IOC mailbox module
243  */
244 typedef void (*bfa_ioc_mbox_mcfunc_t)(void *cbarg, struct bfi_mbmsg_s *m);
245 struct bfa_ioc_mbox_mod_s {
246         struct list_head                cmd_q;  /*  pending mbox queue  */
247         int                     nmclass;        /*  number of handlers */
248         struct {
249                 bfa_ioc_mbox_mcfunc_t   cbfn;   /*  message handlers    */
250                 void                    *cbarg;
251         } mbhdlr[BFI_MC_MAX];
252 };
253
254 /*
255  * IOC callback function interfaces
256  */
257 typedef void (*bfa_ioc_enable_cbfn_t)(void *bfa, enum bfa_status status);
258 typedef void (*bfa_ioc_disable_cbfn_t)(void *bfa);
259 typedef void (*bfa_ioc_hbfail_cbfn_t)(void *bfa);
260 typedef void (*bfa_ioc_reset_cbfn_t)(void *bfa);
261 struct 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  * IOC event notification mechanism.
270  */
271 enum bfa_ioc_event_e {
272         BFA_IOC_E_ENABLED       = 1,
273         BFA_IOC_E_DISABLED      = 2,
274         BFA_IOC_E_FAILED        = 3,
275 };
276
277 typedef void (*bfa_ioc_notify_cbfn_t)(void *, enum bfa_ioc_event_e);
278
279 struct bfa_ioc_notify_s {
280         struct list_head                qe;
281         bfa_ioc_notify_cbfn_t   cbfn;
282         void                    *cbarg;
283 };
284
285 /*
286  * Initialize a IOC event notification structure
287  */
288 #define bfa_ioc_notify_init(__notify, __cbfn, __cbarg) do {     \
289         (__notify)->cbfn = (__cbfn);      \
290         (__notify)->cbarg = (__cbarg);      \
291 } while (0)
292
293 struct 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
301 struct 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;     /*  outstanding stats */
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;      /* adapter cap bit mask */
334         u8                      port_mode_cfg;  /* config port mode */
335         int                     ioc_aen_seq;
336 };
337
338 struct 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  * Queue element to wait for room in request queue. FIFO order is
364  * maintained when fullfilling requests.
365  */
366 struct bfa_reqq_wait_s {
367         struct list_head        qe;
368         void    (*qresume) (void *cbarg);
369         void    *cbarg;
370 };
371
372 typedef void    (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete);
373
374 /*
375  * Generic BFA callback element.
376  */
377 struct 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;        /* set for stack based qe(s) */
382         bfa_status_t    fw_status;      /* to access fw status in comp proc */
383         void            *cbarg;
384 };
385
386 /*
387  * IOCFC state machine definitions/declarations
388  */
389 enum iocfc_event {
390         IOCFC_E_INIT            = 1,    /* IOCFC init request           */
391         IOCFC_E_START           = 2,    /* IOCFC mod start request      */
392         IOCFC_E_STOP            = 3,    /* IOCFC stop request           */
393         IOCFC_E_ENABLE          = 4,    /* IOCFC enable request         */
394         IOCFC_E_DISABLE         = 5,    /* IOCFC disable request        */
395         IOCFC_E_IOC_ENABLED     = 6,    /* IOC enabled message          */
396         IOCFC_E_IOC_DISABLED    = 7,    /* IOC disabled message         */
397         IOCFC_E_IOC_FAILED      = 8,    /* failure notice by IOC sm     */
398         IOCFC_E_DCONF_DONE      = 9,    /* dconf read/write done        */
399         IOCFC_E_CFG_DONE        = 10,   /* IOCFC config complete        */
400 };
401
402 /*
403  * ASIC block configurtion related
404  */
405
406 typedef void (*bfa_ablk_cbfn_t)(void *, enum bfa_status);
407
408 struct 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  *      SFP module specific
424  */
425 typedef void    (*bfa_cb_sfp_t) (void *cbarg, bfa_status_t status);
426
427 struct 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; /* mem access type   */
435         u32                     status;
436         struct bfa_mbox_cmd_s   mbcmd;
437         u8                      *dbuf_kva; /* dma buf virtual address */
438         u64                     dbuf_pa;   /* dma buf physical address */
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; /* data in dbuf is valid */
446         u8                      state;      /* sfp state  */
447         u8                      state_query_lock;
448         struct bfa_mem_dma_s    sfp_dma;
449         u8                      is_elb;     /* eloopback  */
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
455 u32     bfa_sfp_meminfo(void);
456
457 void    bfa_sfp_attach(struct bfa_sfp_s *sfp, struct bfa_ioc_s *ioc,
458                         void *dev, struct bfa_trc_mod_s *trcmod);
459
460 void    bfa_sfp_memclaim(struct bfa_sfp_s *diag, u8 *dm_kva, u64 dm_pa);
461 void    bfa_sfp_intr(void *bfaarg, struct bfi_mbmsg_s *msg);
462
463 bfa_status_t    bfa_sfp_show(struct bfa_sfp_s *sfp, struct sfp_mem_s *sfpmem,
464                              bfa_cb_sfp_t cbfn, void *cbarg);
465
466 bfa_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
470 bfa_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  *      Flash module specific
476  */
477 typedef void    (*bfa_cb_flash_t) (void *cbarg, bfa_status_t status);
478
479 struct bfa_flash_s {
480         struct bfa_ioc_s *ioc;          /* back pointer to ioc */
481         struct bfa_trc_mod_s *trcmod;
482         u32             type;           /* partition type */
483         u8              instance;       /* partition instance */
484         u8              rsv[3];
485         u32             op_busy;        /*  operation busy flag */
486         u32             residue;        /*  residual length */
487         u32             offset;         /*  offset */
488         bfa_status_t    status;         /*  status */
489         u8              *dbuf_kva;      /*  dma buf virtual address */
490         u64             dbuf_pa;        /*  dma buf physical address */
491         struct bfa_reqq_wait_s  reqq_wait; /*  to wait for room in reqq */
492         bfa_cb_flash_t  cbfn;           /*  user callback function */
493         void            *cbarg;         /*  user callback arg */
494         u8              *ubuf;          /*  user supplied buffer */
495         struct bfa_cb_qe_s      hcb_qe; /*  comp: BFA callback qelem */
496         u32             addr_off;       /*  partition address offset */
497         struct bfa_mbox_cmd_s   mb;       /*  mailbox */
498         struct bfa_ioc_notify_s ioc_notify; /*  ioc event 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
505 bfa_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);
508 bfa_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);
511 bfa_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);
515 bfa_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);
518 u32     bfa_flash_meminfo(bfa_boolean_t mincfg);
519 void 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);
521 void bfa_flash_memclaim(struct bfa_flash_s *flash,
522                 u8 *dm_kva, u64 dm_pa, bfa_boolean_t mincfg);
523 bfa_status_t    bfa_flash_raw_read(void __iomem *pci_bar_kva,
524                                 u32 offset, char *buf, u32 len);
525
526 /*
527  *      DIAG module specific
528  */
529
530 typedef void (*bfa_cb_diag_t) (void *cbarg, bfa_status_t status);
531 typedef void (*bfa_cb_diag_beacon_t) (void *dev, bfa_boolean_t beacon,
532                         bfa_boolean_t link_e2e_beacon);
533
534 /*
535  *      Firmware ping test results
536  */
537 struct bfa_diag_results_fwping {
538         u32     data;   /* store the corrupted data */
539         u32     status;
540         u32     dmastatus;
541         u8      rsvd[4];
542 };
543
544 struct bfa_diag_qtest_result_s {
545         u32     status;
546         u16     count;  /* successful queue test count */
547         u8      queue;
548         u8      rsvd;   /* 64-bit align */
549 };
550
551 /*
552  * Firmware ping test results
553  */
554 struct 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;      /* dma buf virtual address */
565         u64             dbuf_pa;        /* dma buf physical address */
566 };
567
568 /*
569  *      Temperature sensor query results
570  */
571 struct bfa_diag_results_tempsensor_s {
572         u32     status;
573         u16     temp;           /* 10-bit A/D value */
574         u16     brd_temp;       /* 9-bit board temp */
575         u8      ts_junc;        /* show junction tempsensor   */
576         u8      ts_brd;         /* show board tempsensor      */
577         u8      rsvd[6];        /* keep 8 bytes alignment     */
578 };
579
580 struct 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
590 struct 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;      /* dma buf virtual address */
600         u64     dbuf_pa;        /* dma buf physical address */
601 };
602
603 struct bfa_diag_led_s {
604         struct bfa_mbox_cmd_s   mbcmd;
605         bfa_boolean_t   lock;   /* 1: ledtest is operating */
606 };
607
608 struct bfa_diag_beacon_s {
609         struct bfa_mbox_cmd_s   mbcmd;
610         bfa_boolean_t   state;          /* port beacon state */
611         bfa_boolean_t   link_e2e;       /* link beacon state */
612 };
613
614 struct 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
639 u32     bfa_diag_meminfo(void);
640 void bfa_diag_memclaim(struct bfa_diag_s *diag, u8 *dm_kva, u64 dm_pa);
641 void 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);
644 bfa_status_t    bfa_diag_reg_read(struct bfa_diag_s *diag, u32 offset,
645                         u32 len, u32 *buf, u32 force);
646 bfa_status_t    bfa_diag_reg_write(struct bfa_diag_s *diag, u32 offset,
647                         u32 len, u32 value, u32 force);
648 bfa_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);
651 bfa_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);
654 bfa_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);
657 bfa_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);
661 bfa_status_t    bfa_diag_ledtest(struct bfa_diag_s *diag,
662                         struct bfa_diag_ledtest_s *ledtest);
663 bfa_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  *      PHY module specific
669  */
670 typedef void (*bfa_cb_phy_t) (void *cbarg, bfa_status_t status);
671
672 struct bfa_phy_s {
673         struct bfa_ioc_s *ioc;          /* back pointer to ioc */
674         struct bfa_trc_mod_s *trcmod;   /* trace module */
675         u8      instance;       /* port instance */
676         u8      op_busy;        /* operation busy flag */
677         u8      rsv[2];
678         u32     residue;        /* residual length */
679         u32     offset;         /* offset */
680         bfa_status_t    status;         /* status */
681         u8      *dbuf_kva;      /* dma buf virtual address */
682         u64     dbuf_pa;        /* dma buf physical address */
683         struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
684         bfa_cb_phy_t    cbfn;           /* user callback function */
685         void            *cbarg;         /* user callback arg */
686         u8              *ubuf;          /* user supplied buffer */
687         struct bfa_cb_qe_s      hcb_qe; /* comp: BFA callback qelem */
688         u32     addr_off;       /* phy address offset */
689         struct bfa_mbox_cmd_s   mb;       /* mailbox */
690         struct bfa_ioc_notify_s ioc_notify; /* ioc event 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
696 bfa_boolean_t bfa_phy_busy(struct bfa_ioc_s *ioc);
697 bfa_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);
700 bfa_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);
703 bfa_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);
706 bfa_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
710 u32     bfa_phy_meminfo(bfa_boolean_t mincfg);
711 void 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);
713 void bfa_phy_memclaim(struct bfa_phy_s *phy,
714                 u8 *dm_kva, u64 dm_pa, bfa_boolean_t mincfg);
715 void bfa_phy_intr(void *phyarg, struct bfi_mbmsg_s *msg);
716
717 /*
718  * FRU module specific
719  */
720 typedef void (*bfa_cb_fru_t) (void *cbarg, bfa_status_t status);
721
722 struct bfa_fru_s {
723         struct bfa_ioc_s *ioc;          /* back pointer to ioc */
724         struct bfa_trc_mod_s *trcmod;   /* trace module */
725         u8              op_busy;        /* operation busy flag */
726         u8              rsv[3];
727         u32             residue;        /* residual length */
728         u32             offset;         /* offset */
729         bfa_status_t    status;         /* status */
730         u8              *dbuf_kva;      /* dma buf virtual address */
731         u64             dbuf_pa;        /* dma buf physical address */
732         struct bfa_reqq_wait_s reqq_wait; /* to wait for room in reqq */
733         bfa_cb_fru_t    cbfn;           /* user callback function */
734         void            *cbarg;         /* user callback arg */
735         u8              *ubuf;          /* user supplied buffer */
736         struct bfa_cb_qe_s      hcb_qe; /* comp: BFA callback qelem */
737         u32             addr_off;       /* fru address offset */
738         struct bfa_mbox_cmd_s mb;       /* mailbox */
739         struct bfa_ioc_notify_s ioc_notify; /* ioc event 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
747 bfa_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);
750 bfa_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);
753 bfa_status_t bfa_fruvpd_get_max_size(struct bfa_fru_s *fru, u32 *max_size);
754 bfa_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);
757 bfa_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);
760 u32     bfa_fru_meminfo(bfa_boolean_t mincfg);
761 void 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);
763 void bfa_fru_memclaim(struct bfa_fru_s *fru,
764                 u8 *dm_kva, u64 dm_pa, bfa_boolean_t mincfg);
765 void bfa_fru_intr(void *fruarg, struct bfi_mbmsg_s *msg);
766
767 /*
768  * Driver Config( dconf) specific
769  */
770 #define BFI_DCONF_SIGNATURE     0xabcdabcd
771 #define BFI_DCONF_VERSION       1
772
773 #pragma pack(1)
774 struct bfa_dconf_hdr_s {
775         u32     signature;
776         u32     version;
777 };
778
779 struct 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
786 struct 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    /* memtest timeout in msec */
805 #define bfa_dconf_get_min_cfg(__bfa)    \
806         (BFA_DCONF_MOD(__bfa)->min_cfg)
807
808 void    bfa_dconf_modinit(struct bfa_s *bfa);
809 void    bfa_dconf_modexit(struct bfa_s *bfa);
810 bfa_status_t    bfa_dconf_update(struct bfa_s *bfa);
811
812 /*
813  *      IOC specfic macros
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  * IOC mailbox interface
846  */
847 void bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd);
848 void bfa_ioc_mbox_register(struct bfa_ioc_s *ioc,
849                 bfa_ioc_mbox_mcfunc_t *mcfuncs);
850 void bfa_ioc_mbox_isr(struct bfa_ioc_s *ioc);
851 void bfa_ioc_mbox_send(struct bfa_ioc_s *ioc, void *ioc_msg, int len);
852 bfa_boolean_t bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg);
853 void 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  * IOC interfaces
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
864 bfa_status_t bfa_ioc_pll_init(struct bfa_ioc_s *ioc);
865 bfa_status_t bfa_ioc_cb_pll_init(void __iomem *rb, enum bfi_asic_mode mode);
866 bfa_status_t bfa_ioc_ct_pll_init(void __iomem *rb, enum bfi_asic_mode mode);
867 bfa_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
881 void bfa_ioc_set_cb_hwif(struct bfa_ioc_s *ioc);
882 void bfa_ioc_set_ct_hwif(struct bfa_ioc_s *ioc);
883 void bfa_ioc_set_ct2_hwif(struct bfa_ioc_s *ioc);
884 void bfa_ioc_ct2_poweron(struct bfa_ioc_s *ioc);
885
886 void bfa_ioc_attach(struct bfa_ioc_s *ioc, void *bfa,
887                 struct bfa_ioc_cbfn_s *cbfn, struct bfa_timer_mod_s *timer_mod);
888 void bfa_ioc_auto_recover(bfa_boolean_t auto_recover);
889 void bfa_ioc_detach(struct bfa_ioc_s *ioc);
890 void bfa_ioc_suspend(struct bfa_ioc_s *ioc);
891 void bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev,
892                 enum bfi_pcifn_class clscode);
893 void bfa_ioc_mem_claim(struct bfa_ioc_s *ioc,  u8 *dm_kva, u64 dm_pa);
894 void bfa_ioc_enable(struct bfa_ioc_s *ioc);
895 void bfa_ioc_disable(struct bfa_ioc_s *ioc);
896 bfa_boolean_t bfa_ioc_intx_claim(struct bfa_ioc_s *ioc);
897
898 bfa_status_t bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type,
899                 u32 boot_env);
900 void bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *msg);
901 void bfa_ioc_error_isr(struct bfa_ioc_s *ioc);
902 bfa_boolean_t bfa_ioc_is_operational(struct bfa_ioc_s *ioc);
903 bfa_boolean_t bfa_ioc_is_initialized(struct bfa_ioc_s *ioc);
904 bfa_boolean_t bfa_ioc_is_disabled(struct bfa_ioc_s *ioc);
905 bfa_boolean_t bfa_ioc_is_acq_addr(struct bfa_ioc_s *ioc);
906 bfa_boolean_t bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc);
907 bfa_boolean_t bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc);
908 void bfa_ioc_reset_fwstate(struct bfa_ioc_s *ioc);
909 enum bfa_ioc_type_e bfa_ioc_get_type(struct bfa_ioc_s *ioc);
910 void bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num);
911 void bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver);
912 void bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver);
913 void bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model);
914 void bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc,
915                 char *manufacturer);
916 void bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev);
917 enum bfa_ioc_state bfa_ioc_get_state(struct bfa_ioc_s *ioc);
918
919 void bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr);
920 void bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
921                 struct bfa_adapter_attr_s *ad_attr);
922 void bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave);
923 bfa_status_t bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata,
924                 int *trclen);
925 bfa_status_t bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata,
926                                  int *trclen);
927 bfa_status_t bfa_ioc_debug_fwcore(struct bfa_ioc_s *ioc, void *buf,
928         u32 *offset, int *buflen);
929 bfa_status_t bfa_ioc_fwsig_invalidate(struct bfa_ioc_s *ioc);
930 bfa_boolean_t bfa_ioc_sem_get(void __iomem *sem_reg);
931 void bfa_ioc_fwver_get(struct bfa_ioc_s *ioc,
932                         struct bfi_ioc_image_hdr_s *fwhdr);
933 bfa_boolean_t bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc,
934                         struct bfi_ioc_image_hdr_s *fwhdr);
935 void bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event);
936 bfa_status_t bfa_ioc_fw_stats_get(struct bfa_ioc_s *ioc, void *stats);
937 bfa_status_t bfa_ioc_fw_stats_clear(struct bfa_ioc_s *ioc);
938 void bfa_ioc_debug_save_ftrc(struct bfa_ioc_s *ioc);
939
940 /*
941  * asic block configuration related APIs
942  */
943 u32     bfa_ablk_meminfo(void);
944 void bfa_ablk_memclaim(struct bfa_ablk_s *ablk, u8 *dma_kva, u64 dma_pa);
945 void bfa_ablk_attach(struct bfa_ablk_s *ablk, struct bfa_ioc_s *ioc);
946 bfa_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);
949 bfa_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);
952 bfa_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);
955 bfa_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);
958 bfa_status_t bfa_ablk_pf_delete(struct bfa_ablk_s *ablk, int pcifn,
959                 bfa_ablk_cbfn_t cbfn, void *cbarg);
960 bfa_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);
962 bfa_status_t bfa_ablk_optrom_en(struct bfa_ablk_s *ablk,
963                 bfa_ablk_cbfn_t cbfn, void *cbarg);
964 bfa_status_t bfa_ablk_optrom_dis(struct bfa_ablk_s *ablk,
965                 bfa_ablk_cbfn_t cbfn, void *cbarg);
966
967 bfa_status_t bfa_ioc_flash_img_get_chnk(struct bfa_ioc_s *ioc, u32 off,
968                                 u32 *fwimg);
969 /*
970  * bfa mfg wwn API functions
971  */
972 mac_t bfa_ioc_get_mac(struct bfa_ioc_s *ioc);
973 mac_t bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc);
974
975 /*
976  * F/W Image Size & Chunk
977  */
978 extern u32 bfi_image_cb_size;
979 extern u32 bfi_image_ct_size;
980 extern u32 bfi_image_ct2_size;
981 extern u32 *bfi_image_cb;
982 extern u32 *bfi_image_ct;
983 extern u32 *bfi_image_ct2;
984
985 static inline u32 *
986 bfi_image_cb_get_chunk(u32 off)
987 {
988         return (u32 *)(bfi_image_cb + off);
989 }
990
991 static inline u32 *
992 bfi_image_ct_get_chunk(u32 off)
993 {
994         return (u32 *)(bfi_image_ct + off);
995 }
996
997 static inline u32 *
998 bfi_image_ct2_get_chunk(u32 off)
999 {
1000         return (u32 *)(bfi_image_ct2 + off);
1001 }
1002
1003 static inline u32*
1004 bfa_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
1021 static inline u32
1022 bfa_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  * CNA TRCMOD declaration
1041  */
1042 /*
1043  * !!! Only append to the enums defined here to avoid any versioning
1044  * !!! needed between trace utility and driver version
1045  */
1046 enum {
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 /* __BFA_IOC_H__ */