bfa_ioc.h 32 KB

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