bfa_ioc.h 33 KB

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