bfa_ioc.h 33 KB

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