bfa_defs.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*
  2. * Linux network driver for QLogic BR-series 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-2014 Brocade Communications Systems, Inc.
  15. * Copyright (c) 2014-2015 QLogic Corporation
  16. * All rights reserved
  17. * www.qlogic.com
  18. */
  19. #ifndef __BFA_DEFS_H__
  20. #define __BFA_DEFS_H__
  21. #include "cna.h"
  22. #include "bfa_defs_status.h"
  23. #include "bfa_defs_mfg_comm.h"
  24. #define BFA_VERSION_LEN 64
  25. /* ---------------------- adapter definitions ------------ */
  26. /* BFA adapter level attributes. */
  27. enum {
  28. BFA_ADAPTER_SERIAL_NUM_LEN = STRSZ(BFA_MFG_SERIALNUM_SIZE),
  29. /*
  30. *!< adapter serial num length
  31. */
  32. BFA_ADAPTER_MODEL_NAME_LEN = 16, /*!< model name length */
  33. BFA_ADAPTER_MODEL_DESCR_LEN = 128, /*!< model description length */
  34. BFA_ADAPTER_MFG_NAME_LEN = 8, /*!< manufacturer name length */
  35. BFA_ADAPTER_SYM_NAME_LEN = 64, /*!< adapter symbolic name length */
  36. BFA_ADAPTER_OS_TYPE_LEN = 64, /*!< adapter os type length */
  37. };
  38. struct bfa_adapter_attr {
  39. char manufacturer[BFA_ADAPTER_MFG_NAME_LEN];
  40. char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
  41. u32 card_type;
  42. char model[BFA_ADAPTER_MODEL_NAME_LEN];
  43. char model_descr[BFA_ADAPTER_MODEL_DESCR_LEN];
  44. u64 pwwn;
  45. char node_symname[FC_SYMNAME_MAX];
  46. char hw_ver[BFA_VERSION_LEN];
  47. char fw_ver[BFA_VERSION_LEN];
  48. char optrom_ver[BFA_VERSION_LEN];
  49. char os_type[BFA_ADAPTER_OS_TYPE_LEN];
  50. struct bfa_mfg_vpd vpd;
  51. u8 mac[ETH_ALEN];
  52. u8 nports;
  53. u8 max_speed;
  54. u8 prototype;
  55. char asic_rev;
  56. u8 pcie_gen;
  57. u8 pcie_lanes_orig;
  58. u8 pcie_lanes;
  59. u8 cna_capable;
  60. u8 is_mezz;
  61. u8 trunk_capable;
  62. };
  63. /* ---------------------- IOC definitions ------------ */
  64. enum {
  65. BFA_IOC_DRIVER_LEN = 16,
  66. BFA_IOC_CHIP_REV_LEN = 8,
  67. };
  68. /* Driver and firmware versions. */
  69. struct bfa_ioc_driver_attr {
  70. char driver[BFA_IOC_DRIVER_LEN]; /*!< driver name */
  71. char driver_ver[BFA_VERSION_LEN]; /*!< driver version */
  72. char fw_ver[BFA_VERSION_LEN]; /*!< firmware version */
  73. char bios_ver[BFA_VERSION_LEN]; /*!< bios version */
  74. char efi_ver[BFA_VERSION_LEN]; /*!< EFI version */
  75. char ob_ver[BFA_VERSION_LEN]; /*!< openboot version */
  76. };
  77. /* IOC PCI device attributes */
  78. struct bfa_ioc_pci_attr {
  79. u16 vendor_id; /*!< PCI vendor ID */
  80. u16 device_id; /*!< PCI device ID */
  81. u16 ssid; /*!< subsystem ID */
  82. u16 ssvid; /*!< subsystem vendor ID */
  83. u32 pcifn; /*!< PCI device function */
  84. u32 rsvd; /* padding */
  85. char chip_rev[BFA_IOC_CHIP_REV_LEN]; /*!< chip revision */
  86. };
  87. /* IOC states */
  88. enum bfa_ioc_state {
  89. BFA_IOC_UNINIT = 1, /*!< IOC is in uninit state */
  90. BFA_IOC_RESET = 2, /*!< IOC is in reset state */
  91. BFA_IOC_SEMWAIT = 3, /*!< Waiting for IOC h/w semaphore */
  92. BFA_IOC_HWINIT = 4, /*!< IOC h/w is being initialized */
  93. BFA_IOC_GETATTR = 5, /*!< IOC is being configured */
  94. BFA_IOC_OPERATIONAL = 6, /*!< IOC is operational */
  95. BFA_IOC_INITFAIL = 7, /*!< IOC hardware failure */
  96. BFA_IOC_FAIL = 8, /*!< IOC heart-beat failure */
  97. BFA_IOC_DISABLING = 9, /*!< IOC is being disabled */
  98. BFA_IOC_DISABLED = 10, /*!< IOC is disabled */
  99. BFA_IOC_FWMISMATCH = 11, /*!< IOC f/w different from drivers */
  100. BFA_IOC_ENABLING = 12, /*!< IOC is being enabled */
  101. BFA_IOC_HWFAIL = 13, /*!< PCI mapping doesn't exist */
  102. };
  103. /* IOC firmware stats */
  104. struct bfa_fw_ioc_stats {
  105. u32 enable_reqs;
  106. u32 disable_reqs;
  107. u32 get_attr_reqs;
  108. u32 dbg_sync;
  109. u32 dbg_dump;
  110. u32 unknown_reqs;
  111. };
  112. /* IOC driver stats */
  113. struct bfa_ioc_drv_stats {
  114. u32 ioc_isrs;
  115. u32 ioc_enables;
  116. u32 ioc_disables;
  117. u32 ioc_hbfails;
  118. u32 ioc_boots;
  119. u32 stats_tmos;
  120. u32 hb_count;
  121. u32 disable_reqs;
  122. u32 enable_reqs;
  123. u32 disable_replies;
  124. u32 enable_replies;
  125. u32 rsvd;
  126. };
  127. /* IOC statistics */
  128. struct bfa_ioc_stats {
  129. struct bfa_ioc_drv_stats drv_stats; /*!< driver IOC stats */
  130. struct bfa_fw_ioc_stats fw_stats; /*!< firmware IOC stats */
  131. };
  132. enum bfa_ioc_type {
  133. BFA_IOC_TYPE_FC = 1,
  134. BFA_IOC_TYPE_FCoE = 2,
  135. BFA_IOC_TYPE_LL = 3,
  136. };
  137. /* IOC attributes returned in queries */
  138. struct bfa_ioc_attr {
  139. enum bfa_ioc_type ioc_type;
  140. enum bfa_ioc_state state; /*!< IOC state */
  141. struct bfa_adapter_attr adapter_attr; /*!< HBA attributes */
  142. struct bfa_ioc_driver_attr driver_attr; /*!< driver attr */
  143. struct bfa_ioc_pci_attr pci_attr;
  144. u8 port_id; /*!< port number */
  145. u8 port_mode; /*!< enum bfa_mode */
  146. u8 cap_bm; /*!< capability */
  147. u8 port_mode_cfg; /*!< enum bfa_mode */
  148. u8 def_fn; /*!< 1 if default fn */
  149. u8 rsvd[3]; /*!< 64bit align */
  150. };
  151. /* Adapter capability mask definition */
  152. enum {
  153. BFA_CM_HBA = 0x01,
  154. BFA_CM_CNA = 0x02,
  155. BFA_CM_NIC = 0x04,
  156. };
  157. /* ---------------------- mfg definitions ------------ */
  158. /* Checksum size */
  159. #define BFA_MFG_CHKSUM_SIZE 16
  160. #define BFA_MFG_PARTNUM_SIZE 14
  161. #define BFA_MFG_SUPPLIER_ID_SIZE 10
  162. #define BFA_MFG_SUPPLIER_PARTNUM_SIZE 20
  163. #define BFA_MFG_SUPPLIER_SERIALNUM_SIZE 20
  164. #define BFA_MFG_SUPPLIER_REVISION_SIZE 4
  165. /* BFA adapter manufacturing block definition.
  166. *
  167. * All numerical fields are in big-endian format.
  168. */
  169. struct bfa_mfg_block {
  170. u8 version; /* manufacturing block version */
  171. u8 mfg_sig[3]; /* characters 'M', 'F', 'G' */
  172. u16 mfgsize; /* mfg block size */
  173. u16 u16_chksum; /* old u16 checksum */
  174. char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
  175. char brcd_partnum[STRSZ(BFA_MFG_PARTNUM_SIZE)];
  176. u8 mfg_day; /* manufacturing day */
  177. u8 mfg_month; /* manufacturing month */
  178. u16 mfg_year; /* manufacturing year */
  179. u64 mfg_wwn; /* wwn base for this adapter */
  180. u8 num_wwn; /* number of wwns assigned */
  181. u8 mfg_speeds; /* speeds allowed for this adapter */
  182. u8 rsv[2];
  183. char supplier_id[STRSZ(BFA_MFG_SUPPLIER_ID_SIZE)];
  184. char supplier_partnum[STRSZ(BFA_MFG_SUPPLIER_PARTNUM_SIZE)];
  185. char supplier_serialnum[STRSZ(BFA_MFG_SUPPLIER_SERIALNUM_SIZE)];
  186. char supplier_revision[STRSZ(BFA_MFG_SUPPLIER_REVISION_SIZE)];
  187. u8 mfg_mac[ETH_ALEN]; /* base mac address */
  188. u8 num_mac; /* number of mac addresses */
  189. u8 rsv2;
  190. u32 card_type; /* card type */
  191. char cap_nic; /* capability nic */
  192. char cap_cna; /* capability cna */
  193. char cap_hba; /* capability hba */
  194. char cap_fc16g; /* capability fc 16g */
  195. char cap_sriov; /* capability sriov */
  196. char cap_mezz; /* capability mezz */
  197. u8 rsv3;
  198. u8 mfg_nports; /* number of ports */
  199. char media[8]; /* xfi/xaui */
  200. char initial_mode[8]; /* initial mode: hba/cna/nic */
  201. u8 rsv4[84];
  202. u8 md5_chksum[BFA_MFG_CHKSUM_SIZE]; /* md5 checksum */
  203. } __packed;
  204. /* ---------------------- pci definitions ------------ */
  205. /*
  206. * PCI device ID information
  207. */
  208. enum {
  209. BFA_PCI_DEVICE_ID_CT2 = 0x22,
  210. };
  211. #define bfa_asic_id_ct(device) \
  212. ((device) == PCI_DEVICE_ID_BROCADE_CT || \
  213. (device) == PCI_DEVICE_ID_BROCADE_CT_FC)
  214. #define bfa_asic_id_ct2(device) \
  215. ((device) == BFA_PCI_DEVICE_ID_CT2)
  216. #define bfa_asic_id_ctc(device) \
  217. (bfa_asic_id_ct(device) || bfa_asic_id_ct2(device))
  218. /* PCI sub-system device and vendor ID information */
  219. enum {
  220. BFA_PCI_FCOE_SSDEVICE_ID = 0x14,
  221. BFA_PCI_CT2_SSID_FCoE = 0x22,
  222. BFA_PCI_CT2_SSID_ETH = 0x23,
  223. BFA_PCI_CT2_SSID_FC = 0x24,
  224. };
  225. enum bfa_mode {
  226. BFA_MODE_HBA = 1,
  227. BFA_MODE_CNA = 2,
  228. BFA_MODE_NIC = 3
  229. };
  230. /*
  231. * Flash module specific
  232. */
  233. #define BFA_FLASH_PART_ENTRY_SIZE 32 /* partition entry size */
  234. #define BFA_FLASH_PART_MAX 32 /* maximal # of partitions */
  235. #define BFA_TOTAL_FLASH_SIZE 0x400000
  236. #define BFA_FLASH_PART_FWIMG 2
  237. #define BFA_FLASH_PART_MFG 7
  238. /*
  239. * flash partition attributes
  240. */
  241. struct bfa_flash_part_attr {
  242. u32 part_type; /* partition type */
  243. u32 part_instance; /* partition instance */
  244. u32 part_off; /* partition offset */
  245. u32 part_size; /* partition size */
  246. u32 part_len; /* partition content length */
  247. u32 part_status; /* partition status */
  248. char rsv[BFA_FLASH_PART_ENTRY_SIZE - 24];
  249. };
  250. /*
  251. * flash attributes
  252. */
  253. struct bfa_flash_attr {
  254. u32 status; /* flash overall status */
  255. u32 npart; /* num of partitions */
  256. struct bfa_flash_part_attr part[BFA_FLASH_PART_MAX];
  257. };
  258. #endif /* __BFA_DEFS_H__ */