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