bfi.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. /*
  2. * Linux network driver for Brocade Converged Network Adapter.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License (GPL) Version 2 as
  6. * published by the Free Software Foundation
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. */
  13. /*
  14. * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  15. * All rights reserved
  16. * www.brocade.com
  17. */
  18. #ifndef __BFI_H__
  19. #define __BFI_H__
  20. #include "bfa_defs.h"
  21. #pragma pack(1)
  22. /**
  23. * BFI FW image type
  24. */
  25. #define BFI_FLASH_CHUNK_SZ 256 /*!< Flash chunk size */
  26. #define BFI_FLASH_CHUNK_SZ_WORDS (BFI_FLASH_CHUNK_SZ/sizeof(u32))
  27. enum {
  28. BFI_IMAGE_CB_FC,
  29. BFI_IMAGE_CT_FC,
  30. BFI_IMAGE_CT_CNA,
  31. BFI_IMAGE_MAX,
  32. };
  33. /**
  34. * Msg header common to all msgs
  35. */
  36. struct bfi_mhdr {
  37. u8 msg_class; /*!< @ref enum bfi_mclass */
  38. u8 msg_id; /*!< msg opcode with in the class */
  39. union {
  40. struct {
  41. u8 rsvd;
  42. u8 lpu_id; /*!< msg destination */
  43. } h2i;
  44. u16 i2htok; /*!< token in msgs to host */
  45. } mtag;
  46. };
  47. #define bfi_h2i_set(_mh, _mc, _op, _lpuid) do { \
  48. (_mh).msg_class = (_mc); \
  49. (_mh).msg_id = (_op); \
  50. (_mh).mtag.h2i.lpu_id = (_lpuid); \
  51. } while (0)
  52. #define bfi_i2h_set(_mh, _mc, _op, _i2htok) do { \
  53. (_mh).msg_class = (_mc); \
  54. (_mh).msg_id = (_op); \
  55. (_mh).mtag.i2htok = (_i2htok); \
  56. } while (0)
  57. /*
  58. * Message opcodes: 0-127 to firmware, 128-255 to host
  59. */
  60. #define BFI_I2H_OPCODE_BASE 128
  61. #define BFA_I2HM(_x) ((_x) + BFI_I2H_OPCODE_BASE)
  62. /**
  63. ****************************************************************************
  64. *
  65. * Scatter Gather Element and Page definition
  66. *
  67. ****************************************************************************
  68. */
  69. #define BFI_SGE_INLINE 1
  70. #define BFI_SGE_INLINE_MAX (BFI_SGE_INLINE + 1)
  71. /**
  72. * SG Flags
  73. */
  74. enum {
  75. BFI_SGE_DATA = 0, /*!< data address, not last */
  76. BFI_SGE_DATA_CPL = 1, /*!< data addr, last in current page */
  77. BFI_SGE_DATA_LAST = 3, /*!< data address, last */
  78. BFI_SGE_LINK = 2, /*!< link address */
  79. BFI_SGE_PGDLEN = 2, /*!< cumulative data length for page */
  80. };
  81. /**
  82. * DMA addresses
  83. */
  84. union bfi_addr_u {
  85. struct {
  86. u32 addr_lo;
  87. u32 addr_hi;
  88. } a32;
  89. };
  90. /**
  91. * Scatter Gather Element
  92. */
  93. struct bfi_sge {
  94. #ifdef __BIGENDIAN
  95. u32 flags:2,
  96. rsvd:2,
  97. sg_len:28;
  98. #else
  99. u32 sg_len:28,
  100. rsvd:2,
  101. flags:2;
  102. #endif
  103. union bfi_addr_u sga;
  104. };
  105. /**
  106. * Scatter Gather Page
  107. */
  108. #define BFI_SGPG_DATA_SGES 7
  109. #define BFI_SGPG_SGES_MAX (BFI_SGPG_DATA_SGES + 1)
  110. #define BFI_SGPG_RSVD_WD_LEN 8
  111. struct bfi_sgpg {
  112. struct bfi_sge sges[BFI_SGPG_SGES_MAX];
  113. u32 rsvd[BFI_SGPG_RSVD_WD_LEN];
  114. };
  115. /*
  116. * Large Message structure - 128 Bytes size Msgs
  117. */
  118. #define BFI_LMSG_SZ 128
  119. #define BFI_LMSG_PL_WSZ \
  120. ((BFI_LMSG_SZ - sizeof(struct bfi_mhdr)) / 4)
  121. struct bfi_msg {
  122. struct bfi_mhdr mhdr;
  123. u32 pl[BFI_LMSG_PL_WSZ];
  124. };
  125. /**
  126. * Mailbox message structure
  127. */
  128. #define BFI_MBMSG_SZ 7
  129. struct bfi_mbmsg {
  130. struct bfi_mhdr mh;
  131. u32 pl[BFI_MBMSG_SZ];
  132. };
  133. /**
  134. * Message Classes
  135. */
  136. enum bfi_mclass {
  137. BFI_MC_IOC = 1, /*!< IO Controller (IOC) */
  138. BFI_MC_DIAG = 2, /*!< Diagnostic Msgs */
  139. BFI_MC_FLASH = 3, /*!< Flash message class */
  140. BFI_MC_CEE = 4, /*!< CEE */
  141. BFI_MC_FCPORT = 5, /*!< FC port */
  142. BFI_MC_IOCFC = 6, /*!< FC - IO Controller (IOC) */
  143. BFI_MC_LL = 7, /*!< Link Layer */
  144. BFI_MC_UF = 8, /*!< Unsolicited frame receive */
  145. BFI_MC_FCXP = 9, /*!< FC Transport */
  146. BFI_MC_LPS = 10, /*!< lport fc login services */
  147. BFI_MC_RPORT = 11, /*!< Remote port */
  148. BFI_MC_ITNIM = 12, /*!< I-T nexus (Initiator mode) */
  149. BFI_MC_IOIM_READ = 13, /*!< read IO (Initiator mode) */
  150. BFI_MC_IOIM_WRITE = 14, /*!< write IO (Initiator mode) */
  151. BFI_MC_IOIM_IO = 15, /*!< IO (Initiator mode) */
  152. BFI_MC_IOIM = 16, /*!< IO (Initiator mode) */
  153. BFI_MC_IOIM_IOCOM = 17, /*!< good IO completion */
  154. BFI_MC_TSKIM = 18, /*!< Initiator Task management */
  155. BFI_MC_SBOOT = 19, /*!< SAN boot services */
  156. BFI_MC_IPFC = 20, /*!< IP over FC Msgs */
  157. BFI_MC_PORT = 21, /*!< Physical port */
  158. BFI_MC_SFP = 22, /*!< SFP module */
  159. BFI_MC_MSGQ = 23, /*!< MSGQ */
  160. BFI_MC_ENET = 24, /*!< ENET commands/responses */
  161. BFI_MC_MAX = 32
  162. };
  163. #define BFI_IOC_MAX_CQS 4
  164. #define BFI_IOC_MAX_CQS_ASIC 8
  165. #define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */
  166. #define BFI_BOOT_TYPE_OFF 8
  167. #define BFI_BOOT_PARAM_OFF 12
  168. #define BFI_BOOT_TYPE_NORMAL 0 /* param is device id */
  169. #define BFI_BOOT_TYPE_FLASH 1
  170. #define BFI_BOOT_TYPE_MEMTEST 2
  171. #define BFI_BOOT_MEMTEST_RES_ADDR 0x900
  172. #define BFI_BOOT_MEMTEST_RES_SIG 0xA0A1A2A3
  173. /**
  174. *----------------------------------------------------------------------
  175. * IOC
  176. *----------------------------------------------------------------------
  177. */
  178. enum bfi_ioc_h2i_msgs {
  179. BFI_IOC_H2I_ENABLE_REQ = 1,
  180. BFI_IOC_H2I_DISABLE_REQ = 2,
  181. BFI_IOC_H2I_GETATTR_REQ = 3,
  182. BFI_IOC_H2I_DBG_SYNC = 4,
  183. BFI_IOC_H2I_DBG_DUMP = 5,
  184. };
  185. enum bfi_ioc_i2h_msgs {
  186. BFI_IOC_I2H_ENABLE_REPLY = BFA_I2HM(1),
  187. BFI_IOC_I2H_DISABLE_REPLY = BFA_I2HM(2),
  188. BFI_IOC_I2H_GETATTR_REPLY = BFA_I2HM(3),
  189. BFI_IOC_I2H_READY_EVENT = BFA_I2HM(4),
  190. BFI_IOC_I2H_HBEAT = BFA_I2HM(5),
  191. };
  192. /**
  193. * BFI_IOC_H2I_GETATTR_REQ message
  194. */
  195. struct bfi_ioc_getattr_req {
  196. struct bfi_mhdr mh;
  197. union bfi_addr_u attr_addr;
  198. };
  199. struct bfi_ioc_attr {
  200. u64 mfg_pwwn; /*!< Mfg port wwn */
  201. u64 mfg_nwwn; /*!< Mfg node wwn */
  202. mac_t mfg_mac; /*!< Mfg mac */
  203. u16 rsvd_a;
  204. u64 pwwn;
  205. u64 nwwn;
  206. mac_t mac; /*!< PBC or Mfg mac */
  207. u16 rsvd_b;
  208. mac_t fcoe_mac;
  209. u16 rsvd_c;
  210. char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
  211. u8 pcie_gen;
  212. u8 pcie_lanes_orig;
  213. u8 pcie_lanes;
  214. u8 rx_bbcredit; /*!< receive buffer credits */
  215. u32 adapter_prop; /*!< adapter properties */
  216. u16 maxfrsize; /*!< max receive frame size */
  217. char asic_rev;
  218. u8 rsvd_d;
  219. char fw_version[BFA_VERSION_LEN];
  220. char optrom_version[BFA_VERSION_LEN];
  221. struct bfa_mfg_vpd vpd;
  222. u32 card_type; /*!< card type */
  223. };
  224. /**
  225. * BFI_IOC_I2H_GETATTR_REPLY message
  226. */
  227. struct bfi_ioc_getattr_reply {
  228. struct bfi_mhdr mh; /*!< Common msg header */
  229. u8 status; /*!< cfg reply status */
  230. u8 rsvd[3];
  231. };
  232. /**
  233. * Firmware memory page offsets
  234. */
  235. #define BFI_IOC_SMEM_PG0_CB (0x40)
  236. #define BFI_IOC_SMEM_PG0_CT (0x180)
  237. /**
  238. * Firmware statistic offset
  239. */
  240. #define BFI_IOC_FWSTATS_OFF (0x6B40)
  241. #define BFI_IOC_FWSTATS_SZ (4096)
  242. /**
  243. * Firmware trace offset
  244. */
  245. #define BFI_IOC_TRC_OFF (0x4b00)
  246. #define BFI_IOC_TRC_ENTS 256
  247. #define BFI_IOC_FW_SIGNATURE (0xbfadbfad)
  248. #define BFI_IOC_MD5SUM_SZ 4
  249. struct bfi_ioc_image_hdr {
  250. u32 signature; /*!< constant signature */
  251. u32 rsvd_a;
  252. u32 exec; /*!< exec vector */
  253. u32 param; /*!< parameters */
  254. u32 rsvd_b[4];
  255. u32 md5sum[BFI_IOC_MD5SUM_SZ];
  256. };
  257. /**
  258. * BFI_IOC_I2H_READY_EVENT message
  259. */
  260. struct bfi_ioc_rdy_event {
  261. struct bfi_mhdr mh; /*!< common msg header */
  262. u8 init_status; /*!< init event status */
  263. u8 rsvd[3];
  264. };
  265. struct bfi_ioc_hbeat {
  266. struct bfi_mhdr mh; /*!< common msg header */
  267. u32 hb_count; /*!< current heart beat count */
  268. };
  269. /**
  270. * IOC hardware/firmware state
  271. */
  272. enum bfi_ioc_state {
  273. BFI_IOC_UNINIT = 0, /*!< not initialized */
  274. BFI_IOC_INITING = 1, /*!< h/w is being initialized */
  275. BFI_IOC_HWINIT = 2, /*!< h/w is initialized */
  276. BFI_IOC_CFG = 3, /*!< IOC configuration in progress */
  277. BFI_IOC_OP = 4, /*!< IOC is operational */
  278. BFI_IOC_DISABLING = 5, /*!< IOC is being disabled */
  279. BFI_IOC_DISABLED = 6, /*!< IOC is disabled */
  280. BFI_IOC_CFG_DISABLED = 7, /*!< IOC is being disabled;transient */
  281. BFI_IOC_FAIL = 8, /*!< IOC heart-beat failure */
  282. BFI_IOC_MEMTEST = 9, /*!< IOC is doing memtest */
  283. };
  284. #define BFI_IOC_ENDIAN_SIG 0x12345678
  285. enum {
  286. BFI_ADAPTER_TYPE_FC = 0x01, /*!< FC adapters */
  287. BFI_ADAPTER_TYPE_MK = 0x0f0000, /*!< adapter type mask */
  288. BFI_ADAPTER_TYPE_SH = 16, /*!< adapter type shift */
  289. BFI_ADAPTER_NPORTS_MK = 0xff00, /*!< number of ports mask */
  290. BFI_ADAPTER_NPORTS_SH = 8, /*!< number of ports shift */
  291. BFI_ADAPTER_SPEED_MK = 0xff, /*!< adapter speed mask */
  292. BFI_ADAPTER_SPEED_SH = 0, /*!< adapter speed shift */
  293. BFI_ADAPTER_PROTO = 0x100000, /*!< prototype adapaters */
  294. BFI_ADAPTER_TTV = 0x200000, /*!< TTV debug capable */
  295. BFI_ADAPTER_UNSUPP = 0x400000, /*!< unknown adapter type */
  296. };
  297. #define BFI_ADAPTER_GETP(__prop, __adap_prop) \
  298. (((__adap_prop) & BFI_ADAPTER_ ## __prop ## _MK) >> \
  299. BFI_ADAPTER_ ## __prop ## _SH)
  300. #define BFI_ADAPTER_SETP(__prop, __val) \
  301. ((__val) << BFI_ADAPTER_ ## __prop ## _SH)
  302. #define BFI_ADAPTER_IS_PROTO(__adap_type) \
  303. ((__adap_type) & BFI_ADAPTER_PROTO)
  304. #define BFI_ADAPTER_IS_TTV(__adap_type) \
  305. ((__adap_type) & BFI_ADAPTER_TTV)
  306. #define BFI_ADAPTER_IS_UNSUPP(__adap_type) \
  307. ((__adap_type) & BFI_ADAPTER_UNSUPP)
  308. #define BFI_ADAPTER_IS_SPECIAL(__adap_type) \
  309. ((__adap_type) & (BFI_ADAPTER_TTV | BFI_ADAPTER_PROTO | \
  310. BFI_ADAPTER_UNSUPP))
  311. /**
  312. * BFI_IOC_H2I_ENABLE_REQ & BFI_IOC_H2I_DISABLE_REQ messages
  313. */
  314. struct bfi_ioc_ctrl_req {
  315. struct bfi_mhdr mh;
  316. u8 ioc_class;
  317. u8 rsvd[3];
  318. u32 tv_sec;
  319. };
  320. /**
  321. * BFI_IOC_I2H_ENABLE_REPLY & BFI_IOC_I2H_DISABLE_REPLY messages
  322. */
  323. struct bfi_ioc_ctrl_reply {
  324. struct bfi_mhdr mh; /*!< Common msg header */
  325. u8 status; /*!< enable/disable status */
  326. u8 rsvd[3];
  327. };
  328. #define BFI_IOC_MSGSZ 8
  329. /**
  330. * H2I Messages
  331. */
  332. union bfi_ioc_h2i_msg_u {
  333. struct bfi_mhdr mh;
  334. struct bfi_ioc_ctrl_req enable_req;
  335. struct bfi_ioc_ctrl_req disable_req;
  336. struct bfi_ioc_getattr_req getattr_req;
  337. u32 mboxmsg[BFI_IOC_MSGSZ];
  338. };
  339. /**
  340. * I2H Messages
  341. */
  342. union bfi_ioc_i2h_msg_u {
  343. struct bfi_mhdr mh;
  344. struct bfi_ioc_rdy_event rdy_event;
  345. u32 mboxmsg[BFI_IOC_MSGSZ];
  346. };
  347. #pragma pack()
  348. #endif /* __BFI_H__ */