bfa_ioc.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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. ((_x) << 32) | ((_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. * PCI device information required by IOC
  77. */
  78. struct bfa_pcidev_s {
  79. int pci_slot;
  80. u8 pci_func;
  81. u16 device_id;
  82. u16 ssid;
  83. void __iomem *pci_bar_kva;
  84. };
  85. /*
  86. * Structure used to remember the DMA-able memory block's KVA and Physical
  87. * Address
  88. */
  89. struct bfa_dma_s {
  90. void *kva; /* ! Kernel virtual address */
  91. u64 pa; /* ! Physical address */
  92. };
  93. #define BFA_DMA_ALIGN_SZ 256
  94. #define BFA_ROUNDUP(_l, _s) (((_l) + ((_s) - 1)) & ~((_s) - 1))
  95. /*
  96. * smem size for Crossbow and Catapult
  97. */
  98. #define BFI_SMEM_CB_SIZE 0x200000U /* ! 2MB for crossbow */
  99. #define BFI_SMEM_CT_SIZE 0x280000U /* ! 2.5MB for catapult */
  100. #define bfa_dma_be_addr_set(dma_addr, pa) \
  101. __bfa_dma_be_addr_set(&dma_addr, (u64)pa)
  102. static inline void
  103. __bfa_dma_be_addr_set(union bfi_addr_u *dma_addr, u64 pa)
  104. {
  105. dma_addr->a32.addr_lo = cpu_to_be32(pa);
  106. dma_addr->a32.addr_hi = cpu_to_be32(pa >> 32);
  107. }
  108. #define bfa_alen_set(__alen, __len, __pa) \
  109. __bfa_alen_set(__alen, __len, (u64)__pa)
  110. static inline void
  111. __bfa_alen_set(struct bfi_alen_s *alen, u32 len, u64 pa)
  112. {
  113. alen->al_len = cpu_to_be32(len);
  114. bfa_dma_be_addr_set(alen->al_addr, pa);
  115. }
  116. struct bfa_ioc_regs_s {
  117. void __iomem *hfn_mbox_cmd;
  118. void __iomem *hfn_mbox;
  119. void __iomem *lpu_mbox_cmd;
  120. void __iomem *lpu_mbox;
  121. void __iomem *lpu_read_stat;
  122. void __iomem *pss_ctl_reg;
  123. void __iomem *pss_err_status_reg;
  124. void __iomem *app_pll_fast_ctl_reg;
  125. void __iomem *app_pll_slow_ctl_reg;
  126. void __iomem *ioc_sem_reg;
  127. void __iomem *ioc_usage_sem_reg;
  128. void __iomem *ioc_init_sem_reg;
  129. void __iomem *ioc_usage_reg;
  130. void __iomem *host_page_num_fn;
  131. void __iomem *heartbeat;
  132. void __iomem *ioc_fwstate;
  133. void __iomem *alt_ioc_fwstate;
  134. void __iomem *ll_halt;
  135. void __iomem *alt_ll_halt;
  136. void __iomem *err_set;
  137. void __iomem *ioc_fail_sync;
  138. void __iomem *shirq_isr_next;
  139. void __iomem *shirq_msk_next;
  140. void __iomem *smem_page_start;
  141. u32 smem_pg0;
  142. };
  143. #define bfa_mem_read(_raddr, _off) swab32(readl(((_raddr) + (_off))))
  144. #define bfa_mem_write(_raddr, _off, _val) \
  145. writel(swab32((_val)), ((_raddr) + (_off)))
  146. /*
  147. * IOC Mailbox structures
  148. */
  149. struct bfa_mbox_cmd_s {
  150. struct list_head qe;
  151. u32 msg[BFI_IOC_MSGSZ];
  152. };
  153. /*
  154. * IOC mailbox module
  155. */
  156. typedef void (*bfa_ioc_mbox_mcfunc_t)(void *cbarg, struct bfi_mbmsg_s *m);
  157. struct bfa_ioc_mbox_mod_s {
  158. struct list_head cmd_q; /* pending mbox queue */
  159. int nmclass; /* number of handlers */
  160. struct {
  161. bfa_ioc_mbox_mcfunc_t cbfn; /* message handlers */
  162. void *cbarg;
  163. } mbhdlr[BFI_MC_MAX];
  164. };
  165. /*
  166. * IOC callback function interfaces
  167. */
  168. typedef void (*bfa_ioc_enable_cbfn_t)(void *bfa, enum bfa_status status);
  169. typedef void (*bfa_ioc_disable_cbfn_t)(void *bfa);
  170. typedef void (*bfa_ioc_hbfail_cbfn_t)(void *bfa);
  171. typedef void (*bfa_ioc_reset_cbfn_t)(void *bfa);
  172. struct bfa_ioc_cbfn_s {
  173. bfa_ioc_enable_cbfn_t enable_cbfn;
  174. bfa_ioc_disable_cbfn_t disable_cbfn;
  175. bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
  176. bfa_ioc_reset_cbfn_t reset_cbfn;
  177. };
  178. /*
  179. * IOC event notification mechanism.
  180. */
  181. enum bfa_ioc_event_e {
  182. BFA_IOC_E_ENABLED = 1,
  183. BFA_IOC_E_DISABLED = 2,
  184. BFA_IOC_E_FAILED = 3,
  185. };
  186. typedef void (*bfa_ioc_notify_cbfn_t)(void *, enum bfa_ioc_event_e);
  187. struct bfa_ioc_notify_s {
  188. struct list_head qe;
  189. bfa_ioc_notify_cbfn_t cbfn;
  190. void *cbarg;
  191. };
  192. /*
  193. * Initialize a IOC event notification structure
  194. */
  195. #define bfa_ioc_notify_init(__notify, __cbfn, __cbarg) do { \
  196. (__notify)->cbfn = (__cbfn); \
  197. (__notify)->cbarg = (__cbarg); \
  198. } while (0)
  199. struct bfa_iocpf_s {
  200. bfa_fsm_t fsm;
  201. struct bfa_ioc_s *ioc;
  202. bfa_boolean_t fw_mismatch_notified;
  203. bfa_boolean_t auto_recover;
  204. u32 poll_time;
  205. };
  206. struct bfa_ioc_s {
  207. bfa_fsm_t fsm;
  208. struct bfa_s *bfa;
  209. struct bfa_pcidev_s pcidev;
  210. struct bfa_timer_mod_s *timer_mod;
  211. struct bfa_timer_s ioc_timer;
  212. struct bfa_timer_s sem_timer;
  213. struct bfa_timer_s hb_timer;
  214. u32 hb_count;
  215. struct list_head notify_q;
  216. void *dbg_fwsave;
  217. int dbg_fwsave_len;
  218. bfa_boolean_t dbg_fwsave_once;
  219. enum bfi_pcifn_class clscode;
  220. struct bfa_ioc_regs_s ioc_regs;
  221. struct bfa_trc_mod_s *trcmod;
  222. struct bfa_ioc_drv_stats_s stats;
  223. bfa_boolean_t fcmode;
  224. bfa_boolean_t pllinit;
  225. bfa_boolean_t stats_busy; /* outstanding stats */
  226. u8 port_id;
  227. struct bfa_dma_s attr_dma;
  228. struct bfi_ioc_attr_s *attr;
  229. struct bfa_ioc_cbfn_s *cbfn;
  230. struct bfa_ioc_mbox_mod_s mbox_mod;
  231. struct bfa_ioc_hwif_s *ioc_hwif;
  232. struct bfa_iocpf_s iocpf;
  233. enum bfi_asic_gen asic_gen;
  234. enum bfi_asic_mode asic_mode;
  235. enum bfi_port_mode port0_mode;
  236. enum bfi_port_mode port1_mode;
  237. enum bfa_mode_s port_mode;
  238. u8 ad_cap_bm; /* adapter cap bit mask */
  239. u8 port_mode_cfg; /* config port mode */
  240. };
  241. struct bfa_ioc_hwif_s {
  242. bfa_status_t (*ioc_pll_init) (void __iomem *rb, enum bfi_asic_mode m);
  243. bfa_boolean_t (*ioc_firmware_lock) (struct bfa_ioc_s *ioc);
  244. void (*ioc_firmware_unlock) (struct bfa_ioc_s *ioc);
  245. void (*ioc_reg_init) (struct bfa_ioc_s *ioc);
  246. void (*ioc_map_port) (struct bfa_ioc_s *ioc);
  247. void (*ioc_isr_mode_set) (struct bfa_ioc_s *ioc,
  248. bfa_boolean_t msix);
  249. void (*ioc_notify_fail) (struct bfa_ioc_s *ioc);
  250. void (*ioc_ownership_reset) (struct bfa_ioc_s *ioc);
  251. bfa_boolean_t (*ioc_sync_start) (struct bfa_ioc_s *ioc);
  252. void (*ioc_sync_join) (struct bfa_ioc_s *ioc);
  253. void (*ioc_sync_leave) (struct bfa_ioc_s *ioc);
  254. void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
  255. bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
  256. bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
  257. };
  258. /*
  259. * ASIC block configurtion related
  260. */
  261. typedef void (*bfa_ablk_cbfn_t)(void *, enum bfa_status);
  262. struct bfa_ablk_s {
  263. struct bfa_ioc_s *ioc;
  264. struct bfa_ablk_cfg_s *cfg;
  265. u16 *pcifn;
  266. struct bfa_dma_s dma_addr;
  267. bfa_boolean_t busy;
  268. struct bfa_mbox_cmd_s mb;
  269. bfa_ablk_cbfn_t cbfn;
  270. void *cbarg;
  271. struct bfa_ioc_notify_s ioc_notify;
  272. };
  273. #define bfa_ioc_pcifn(__ioc) ((__ioc)->pcidev.pci_func)
  274. #define bfa_ioc_devid(__ioc) ((__ioc)->pcidev.device_id)
  275. #define bfa_ioc_bar0(__ioc) ((__ioc)->pcidev.pci_bar_kva)
  276. #define bfa_ioc_portid(__ioc) ((__ioc)->port_id)
  277. #define bfa_ioc_asic_gen(__ioc) ((__ioc)->asic_gen)
  278. #define bfa_ioc_is_cna(__ioc) \
  279. ((bfa_ioc_get_type(__ioc) == BFA_IOC_TYPE_FCoE) || \
  280. (bfa_ioc_get_type(__ioc) == BFA_IOC_TYPE_LL))
  281. #define bfa_ioc_fetch_stats(__ioc, __stats) \
  282. (((__stats)->drv_stats) = (__ioc)->stats)
  283. #define bfa_ioc_clr_stats(__ioc) \
  284. memset(&(__ioc)->stats, 0, sizeof((__ioc)->stats))
  285. #define bfa_ioc_maxfrsize(__ioc) ((__ioc)->attr->maxfrsize)
  286. #define bfa_ioc_rx_bbcredit(__ioc) ((__ioc)->attr->rx_bbcredit)
  287. #define bfa_ioc_speed_sup(__ioc) \
  288. BFI_ADAPTER_GETP(SPEED, (__ioc)->attr->adapter_prop)
  289. #define bfa_ioc_get_nports(__ioc) \
  290. BFI_ADAPTER_GETP(NPORTS, (__ioc)->attr->adapter_prop)
  291. #define bfa_ioc_stats(_ioc, _stats) ((_ioc)->stats._stats++)
  292. #define BFA_IOC_FWIMG_MINSZ (16 * 1024)
  293. #define BFA_IOC_FW_SMEM_SIZE(__ioc) \
  294. ((bfa_ioc_asic_gen(__ioc) == BFI_ASIC_GEN_CB) \
  295. ? BFI_SMEM_CB_SIZE : BFI_SMEM_CT_SIZE)
  296. #define BFA_IOC_FLASH_CHUNK_NO(off) (off / BFI_FLASH_CHUNK_SZ_WORDS)
  297. #define BFA_IOC_FLASH_OFFSET_IN_CHUNK(off) (off % BFI_FLASH_CHUNK_SZ_WORDS)
  298. #define BFA_IOC_FLASH_CHUNK_ADDR(chunkno) (chunkno * BFI_FLASH_CHUNK_SZ_WORDS)
  299. /*
  300. * IOC mailbox interface
  301. */
  302. void bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd);
  303. void bfa_ioc_mbox_register(struct bfa_ioc_s *ioc,
  304. bfa_ioc_mbox_mcfunc_t *mcfuncs);
  305. void bfa_ioc_mbox_isr(struct bfa_ioc_s *ioc);
  306. void bfa_ioc_mbox_send(struct bfa_ioc_s *ioc, void *ioc_msg, int len);
  307. bfa_boolean_t bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg);
  308. void bfa_ioc_mbox_regisr(struct bfa_ioc_s *ioc, enum bfi_mclass mc,
  309. bfa_ioc_mbox_mcfunc_t cbfn, void *cbarg);
  310. /*
  311. * IOC interfaces
  312. */
  313. #define bfa_ioc_pll_init_asic(__ioc) \
  314. ((__ioc)->ioc_hwif->ioc_pll_init((__ioc)->pcidev.pci_bar_kva, \
  315. (__ioc)->asic_mode))
  316. bfa_status_t bfa_ioc_pll_init(struct bfa_ioc_s *ioc);
  317. bfa_status_t bfa_ioc_cb_pll_init(void __iomem *rb, enum bfi_asic_mode mode);
  318. bfa_status_t bfa_ioc_ct_pll_init(void __iomem *rb, enum bfi_asic_mode mode);
  319. bfa_status_t bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode mode);
  320. #define bfa_ioc_isr_mode_set(__ioc, __msix) do { \
  321. if ((__ioc)->ioc_hwif->ioc_isr_mode_set) \
  322. ((__ioc)->ioc_hwif->ioc_isr_mode_set(__ioc, __msix)); \
  323. } while (0)
  324. #define bfa_ioc_ownership_reset(__ioc) \
  325. ((__ioc)->ioc_hwif->ioc_ownership_reset(__ioc))
  326. #define bfa_ioc_lpu_read_stat(__ioc) do { \
  327. if ((__ioc)->ioc_hwif->ioc_lpu_read_stat) \
  328. ((__ioc)->ioc_hwif->ioc_lpu_read_stat(__ioc)); \
  329. } while (0)
  330. void bfa_ioc_set_cb_hwif(struct bfa_ioc_s *ioc);
  331. void bfa_ioc_set_ct_hwif(struct bfa_ioc_s *ioc);
  332. void bfa_ioc_set_ct2_hwif(struct bfa_ioc_s *ioc);
  333. void bfa_ioc_ct2_poweron(struct bfa_ioc_s *ioc);
  334. void bfa_ioc_attach(struct bfa_ioc_s *ioc, void *bfa,
  335. struct bfa_ioc_cbfn_s *cbfn, struct bfa_timer_mod_s *timer_mod);
  336. void bfa_ioc_auto_recover(bfa_boolean_t auto_recover);
  337. void bfa_ioc_detach(struct bfa_ioc_s *ioc);
  338. void bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev,
  339. enum bfi_pcifn_class clscode);
  340. void bfa_ioc_mem_claim(struct bfa_ioc_s *ioc, u8 *dm_kva, u64 dm_pa);
  341. void bfa_ioc_enable(struct bfa_ioc_s *ioc);
  342. void bfa_ioc_disable(struct bfa_ioc_s *ioc);
  343. bfa_boolean_t bfa_ioc_intx_claim(struct bfa_ioc_s *ioc);
  344. void bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type,
  345. u32 boot_env);
  346. void bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *msg);
  347. void bfa_ioc_error_isr(struct bfa_ioc_s *ioc);
  348. bfa_boolean_t bfa_ioc_is_operational(struct bfa_ioc_s *ioc);
  349. bfa_boolean_t bfa_ioc_is_initialized(struct bfa_ioc_s *ioc);
  350. bfa_boolean_t bfa_ioc_is_disabled(struct bfa_ioc_s *ioc);
  351. bfa_boolean_t bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc);
  352. bfa_boolean_t bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc);
  353. void bfa_ioc_reset_fwstate(struct bfa_ioc_s *ioc);
  354. enum bfa_ioc_type_e bfa_ioc_get_type(struct bfa_ioc_s *ioc);
  355. void bfa_ioc_get_adapter_serial_num(struct bfa_ioc_s *ioc, char *serial_num);
  356. void bfa_ioc_get_adapter_fw_ver(struct bfa_ioc_s *ioc, char *fw_ver);
  357. void bfa_ioc_get_adapter_optrom_ver(struct bfa_ioc_s *ioc, char *optrom_ver);
  358. void bfa_ioc_get_adapter_model(struct bfa_ioc_s *ioc, char *model);
  359. void bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc,
  360. char *manufacturer);
  361. void bfa_ioc_get_pci_chip_rev(struct bfa_ioc_s *ioc, char *chip_rev);
  362. enum bfa_ioc_state bfa_ioc_get_state(struct bfa_ioc_s *ioc);
  363. void bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr);
  364. void bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
  365. struct bfa_adapter_attr_s *ad_attr);
  366. void bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave);
  367. bfa_status_t bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata,
  368. int *trclen);
  369. bfa_status_t bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata,
  370. int *trclen);
  371. bfa_status_t bfa_ioc_debug_fwcore(struct bfa_ioc_s *ioc, void *buf,
  372. u32 *offset, int *buflen);
  373. void bfa_ioc_set_fcmode(struct bfa_ioc_s *ioc);
  374. bfa_boolean_t bfa_ioc_get_fcmode(struct bfa_ioc_s *ioc);
  375. bfa_boolean_t bfa_ioc_sem_get(void __iomem *sem_reg);
  376. void bfa_ioc_fwver_get(struct bfa_ioc_s *ioc,
  377. struct bfi_ioc_image_hdr_s *fwhdr);
  378. bfa_boolean_t bfa_ioc_fwver_cmp(struct bfa_ioc_s *ioc,
  379. struct bfi_ioc_image_hdr_s *fwhdr);
  380. bfa_status_t bfa_ioc_fw_stats_get(struct bfa_ioc_s *ioc, void *stats);
  381. bfa_status_t bfa_ioc_fw_stats_clear(struct bfa_ioc_s *ioc);
  382. /*
  383. * asic block configuration related APIs
  384. */
  385. u32 bfa_ablk_meminfo(void);
  386. void bfa_ablk_memclaim(struct bfa_ablk_s *ablk, u8 *dma_kva, u64 dma_pa);
  387. void bfa_ablk_attach(struct bfa_ablk_s *ablk, struct bfa_ioc_s *ioc);
  388. bfa_status_t bfa_ablk_query(struct bfa_ablk_s *ablk,
  389. struct bfa_ablk_cfg_s *ablk_cfg,
  390. bfa_ablk_cbfn_t cbfn, void *cbarg);
  391. bfa_status_t bfa_ablk_adapter_config(struct bfa_ablk_s *ablk,
  392. enum bfa_mode_s mode, int max_pf, int max_vf,
  393. bfa_ablk_cbfn_t cbfn, void *cbarg);
  394. bfa_status_t bfa_ablk_port_config(struct bfa_ablk_s *ablk, int port,
  395. enum bfa_mode_s mode, int max_pf, int max_vf,
  396. bfa_ablk_cbfn_t cbfn, void *cbarg);
  397. bfa_status_t bfa_ablk_pf_create(struct bfa_ablk_s *ablk, u16 *pcifn,
  398. u8 port, enum bfi_pcifn_class personality, int bw,
  399. bfa_ablk_cbfn_t cbfn, void *cbarg);
  400. bfa_status_t bfa_ablk_pf_delete(struct bfa_ablk_s *ablk, int pcifn,
  401. bfa_ablk_cbfn_t cbfn, void *cbarg);
  402. bfa_status_t bfa_ablk_pf_update(struct bfa_ablk_s *ablk, int pcifn, int bw,
  403. bfa_ablk_cbfn_t cbfn, void *cbarg);
  404. bfa_status_t bfa_ablk_optrom_en(struct bfa_ablk_s *ablk,
  405. bfa_ablk_cbfn_t cbfn, void *cbarg);
  406. bfa_status_t bfa_ablk_optrom_dis(struct bfa_ablk_s *ablk,
  407. bfa_ablk_cbfn_t cbfn, void *cbarg);
  408. /*
  409. * bfa mfg wwn API functions
  410. */
  411. mac_t bfa_ioc_get_mac(struct bfa_ioc_s *ioc);
  412. mac_t bfa_ioc_get_mfg_mac(struct bfa_ioc_s *ioc);
  413. /*
  414. * F/W Image Size & Chunk
  415. */
  416. extern u32 bfi_image_cb_size;
  417. extern u32 bfi_image_ct_size;
  418. extern u32 bfi_image_ct2_size;
  419. extern u32 *bfi_image_cb;
  420. extern u32 *bfi_image_ct;
  421. extern u32 *bfi_image_ct2;
  422. static inline u32 *
  423. bfi_image_cb_get_chunk(u32 off)
  424. {
  425. return (u32 *)(bfi_image_cb + off);
  426. }
  427. static inline u32 *
  428. bfi_image_ct_get_chunk(u32 off)
  429. {
  430. return (u32 *)(bfi_image_ct + off);
  431. }
  432. static inline u32 *
  433. bfi_image_ct2_get_chunk(u32 off)
  434. {
  435. return (u32 *)(bfi_image_ct2 + off);
  436. }
  437. static inline u32*
  438. bfa_cb_image_get_chunk(enum bfi_asic_gen asic_gen, u32 off)
  439. {
  440. switch (asic_gen) {
  441. case BFI_ASIC_GEN_CB:
  442. return bfi_image_cb_get_chunk(off);
  443. break;
  444. case BFI_ASIC_GEN_CT:
  445. return bfi_image_ct_get_chunk(off);
  446. break;
  447. case BFI_ASIC_GEN_CT2:
  448. return bfi_image_ct2_get_chunk(off);
  449. break;
  450. default:
  451. return NULL;
  452. }
  453. }
  454. static inline u32
  455. bfa_cb_image_get_size(enum bfi_asic_gen asic_gen)
  456. {
  457. switch (asic_gen) {
  458. case BFI_ASIC_GEN_CB:
  459. return bfi_image_cb_size;
  460. break;
  461. case BFI_ASIC_GEN_CT:
  462. return bfi_image_ct_size;
  463. break;
  464. case BFI_ASIC_GEN_CT2:
  465. return bfi_image_ct2_size;
  466. break;
  467. default:
  468. return 0;
  469. }
  470. }
  471. /*
  472. * CNA TRCMOD declaration
  473. */
  474. /*
  475. * !!! Only append to the enums defined here to avoid any versioning
  476. * !!! needed between trace utility and driver version
  477. */
  478. enum {
  479. BFA_TRC_CNA_PORT = 1,
  480. BFA_TRC_CNA_IOC = 2,
  481. BFA_TRC_CNA_IOC_CB = 3,
  482. BFA_TRC_CNA_IOC_CT = 4,
  483. };
  484. #endif /* __BFA_IOC_H__ */