bfa_ioc.h 33 KB

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