qlcnic_83xx_hw.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /*
  2. * QLogic qlcnic NIC Driver
  3. * Copyright (c) 2009-2013 QLogic Corporation
  4. *
  5. * See LICENSE.qlcnic for copyright and licensing details.
  6. */
  7. #ifndef __QLCNIC_83XX_HW_H
  8. #define __QLCNIC_83XX_HW_H
  9. #include <linux/types.h>
  10. #include <linux/etherdevice.h>
  11. #include "qlcnic_hw.h"
  12. #define QLCNIC_83XX_BAR0_LENGTH 0x4000
  13. /* Directly mapped registers */
  14. #define QLC_83XX_CRB_WIN_BASE 0x3800
  15. #define QLC_83XX_CRB_WIN_FUNC(f) (QLC_83XX_CRB_WIN_BASE+((f)*4))
  16. #define QLC_83XX_SEM_LOCK_BASE 0x3840
  17. #define QLC_83XX_SEM_UNLOCK_BASE 0x3844
  18. #define QLC_83XX_SEM_LOCK_FUNC(f) (QLC_83XX_SEM_LOCK_BASE+((f)*8))
  19. #define QLC_83XX_SEM_UNLOCK_FUNC(f) (QLC_83XX_SEM_UNLOCK_BASE+((f)*8))
  20. #define QLC_83XX_LINK_STATE(f) (0x3698+((f) > 7 ? 4 : 0))
  21. #define QLC_83XX_LINK_SPEED(f) (0x36E0+(((f) >> 2) * 4))
  22. #define QLC_83XX_LINK_SPEED_FACTOR 10
  23. #define QLC_83xx_FUNC_VAL(v, f) ((v) & (1 << (f * 4)))
  24. #define QLC_83XX_INTX_PTR 0x38C0
  25. #define QLC_83XX_INTX_TRGR 0x38C4
  26. #define QLC_83XX_INTX_MASK 0x38C8
  27. #define QLC_83XX_DRV_LOCK_WAIT_COUNTER 100
  28. #define QLC_83XX_DRV_LOCK_WAIT_DELAY 20
  29. #define QLC_83XX_NEED_DRV_LOCK_RECOVERY 1
  30. #define QLC_83XX_DRV_LOCK_RECOVERY_IN_PROGRESS 2
  31. #define QLC_83XX_MAX_DRV_LOCK_RECOVERY_ATTEMPT 3
  32. #define QLC_83XX_DRV_LOCK_RECOVERY_DELAY 200
  33. #define QLC_83XX_DRV_LOCK_RECOVERY_STATUS_MASK 0x3
  34. #define QLC_83XX_LB_WAIT_COUNT 250
  35. #define QLC_83XX_LB_MSLEEP_COUNT 20
  36. #define QLC_83XX_NO_NIC_RESOURCE 0x5
  37. #define QLC_83XX_MAC_PRESENT 0xC
  38. #define QLC_83XX_MAC_ABSENT 0xD
  39. #define QLC_83XX_FLASH_SECTOR_SIZE (64 * 1024)
  40. /* PEG status definitions */
  41. #define QLC_83XX_CMDPEG_COMPLETE 0xff01
  42. #define QLC_83XX_VALID_INTX_BIT30(val) ((val) & BIT_30)
  43. #define QLC_83XX_VALID_INTX_BIT31(val) ((val) & BIT_31)
  44. #define QLC_83XX_INTX_FUNC(val) ((val) & 0xFF)
  45. #define QLC_83XX_LEGACY_INTX_MAX_RETRY 100
  46. #define QLC_83XX_LEGACY_INTX_DELAY 4
  47. #define QLC_83XX_REG_DESC 1
  48. #define QLC_83XX_LRO_DESC 2
  49. #define QLC_83XX_CTRL_DESC 3
  50. #define QLC_83XX_FW_CAPABILITY_TSO BIT_6
  51. #define QLC_83XX_FW_CAP_LRO_MSS BIT_17
  52. #define QLC_83XX_HOST_RDS_MODE_UNIQUE 0
  53. #define QLC_83XX_HOST_SDS_MBX_IDX 8
  54. #define QLCNIC_HOST_RDS_MBX_IDX 88
  55. #define QLCNIC_MAX_RING_SETS 8
  56. /* Pause control registers */
  57. #define QLC_83XX_SRE_SHIM_REG 0x0D200284
  58. #define QLC_83XX_PORT0_THRESHOLD 0x0B2003A4
  59. #define QLC_83XX_PORT1_THRESHOLD 0x0B2013A4
  60. #define QLC_83XX_PORT0_TC_MC_REG 0x0B200388
  61. #define QLC_83XX_PORT1_TC_MC_REG 0x0B201388
  62. #define QLC_83XX_PORT0_TC_STATS 0x0B20039C
  63. #define QLC_83XX_PORT1_TC_STATS 0x0B20139C
  64. #define QLC_83XX_PORT2_IFB_THRESHOLD 0x0B200704
  65. #define QLC_83XX_PORT3_IFB_THRESHOLD 0x0B201704
  66. /* Peg PC status registers */
  67. #define QLC_83XX_CRB_PEG_NET_0 0x3400003c
  68. #define QLC_83XX_CRB_PEG_NET_1 0x3410003c
  69. #define QLC_83XX_CRB_PEG_NET_2 0x3420003c
  70. #define QLC_83XX_CRB_PEG_NET_3 0x3430003c
  71. #define QLC_83XX_CRB_PEG_NET_4 0x34b0003c
  72. /* Firmware image definitions */
  73. #define QLC_83XX_BOOTLOADER_FLASH_ADDR 0x10000
  74. #define QLC_83XX_FW_FILE_NAME "83xx_fw.bin"
  75. #define QLC_84XX_FW_FILE_NAME "84xx_fw.bin"
  76. #define QLC_83XX_BOOT_FROM_FLASH 0
  77. #define QLC_83XX_BOOT_FROM_FILE 0x12345678
  78. #define QLC_FW_FILE_NAME_LEN 20
  79. #define QLC_83XX_MAX_RESET_SEQ_ENTRIES 16
  80. #define QLC_83XX_MBX_POST_BC_OP 0x1
  81. #define QLC_83XX_MBX_COMPLETION 0x0
  82. #define QLC_83XX_MBX_REQUEST 0x1
  83. #define QLC_83XX_MBX_TIMEOUT (5 * HZ)
  84. #define QLC_83XX_MBX_CMD_LOOP 5000000
  85. /* status descriptor mailbox data
  86. * @phy_addr_{low|high}: physical address of buffer
  87. * @sds_ring_size: buffer size
  88. * @intrpt_id: interrupt id
  89. * @intrpt_val: source of interrupt
  90. */
  91. struct qlcnic_sds_mbx {
  92. u32 phy_addr_low;
  93. u32 phy_addr_high;
  94. u32 rsvd1[4];
  95. #if defined(__LITTLE_ENDIAN)
  96. u16 sds_ring_size;
  97. u16 rsvd2;
  98. u16 rsvd3[2];
  99. u16 intrpt_id;
  100. u8 intrpt_val;
  101. u8 rsvd4;
  102. #elif defined(__BIG_ENDIAN)
  103. u16 rsvd2;
  104. u16 sds_ring_size;
  105. u16 rsvd3[2];
  106. u8 rsvd4;
  107. u8 intrpt_val;
  108. u16 intrpt_id;
  109. #endif
  110. u32 rsvd5;
  111. } __packed;
  112. /* receive descriptor buffer data
  113. * phy_addr_reg_{low|high}: physical address of regular buffer
  114. * phy_addr_jmb_{low|high}: physical address of jumbo buffer
  115. * reg_ring_sz: size of regular buffer
  116. * reg_ring_len: no. of entries in regular buffer
  117. * jmb_ring_len: no. of entries in jumbo buffer
  118. * jmb_ring_sz: size of jumbo buffer
  119. */
  120. struct qlcnic_rds_mbx {
  121. u32 phy_addr_reg_low;
  122. u32 phy_addr_reg_high;
  123. u32 phy_addr_jmb_low;
  124. u32 phy_addr_jmb_high;
  125. #if defined(__LITTLE_ENDIAN)
  126. u16 reg_ring_sz;
  127. u16 reg_ring_len;
  128. u16 jmb_ring_sz;
  129. u16 jmb_ring_len;
  130. #elif defined(__BIG_ENDIAN)
  131. u16 reg_ring_len;
  132. u16 reg_ring_sz;
  133. u16 jmb_ring_len;
  134. u16 jmb_ring_sz;
  135. #endif
  136. } __packed;
  137. /* host producers for regular and jumbo rings */
  138. struct __host_producer_mbx {
  139. u32 reg_buf;
  140. u32 jmb_buf;
  141. } __packed;
  142. /* Receive context mailbox data outbox registers
  143. * @state: state of the context
  144. * @vport_id: virtual port id
  145. * @context_id: receive context id
  146. * @num_pci_func: number of pci functions of the port
  147. * @phy_port: physical port id
  148. */
  149. struct qlcnic_rcv_mbx_out {
  150. #if defined(__LITTLE_ENDIAN)
  151. u8 rcv_num;
  152. u8 sts_num;
  153. u16 ctx_id;
  154. u8 state;
  155. u8 num_pci_func;
  156. u8 phy_port;
  157. u8 vport_id;
  158. #elif defined(__BIG_ENDIAN)
  159. u16 ctx_id;
  160. u8 sts_num;
  161. u8 rcv_num;
  162. u8 vport_id;
  163. u8 phy_port;
  164. u8 num_pci_func;
  165. u8 state;
  166. #endif
  167. u32 host_csmr[QLCNIC_MAX_RING_SETS];
  168. struct __host_producer_mbx host_prod[QLCNIC_MAX_RING_SETS];
  169. } __packed;
  170. struct qlcnic_add_rings_mbx_out {
  171. #if defined(__LITTLE_ENDIAN)
  172. u8 rcv_num;
  173. u8 sts_num;
  174. u16 ctx_id;
  175. #elif defined(__BIG_ENDIAN)
  176. u16 ctx_id;
  177. u8 sts_num;
  178. u8 rcv_num;
  179. #endif
  180. u32 host_csmr[QLCNIC_MAX_RING_SETS];
  181. struct __host_producer_mbx host_prod[QLCNIC_MAX_RING_SETS];
  182. } __packed;
  183. /* Transmit context mailbox inbox registers
  184. * @phys_addr_{low|high}: DMA address of the transmit buffer
  185. * @cnsmr_index_{low|high}: host consumer index
  186. * @size: legth of transmit buffer ring
  187. * @intr_id: interrput id
  188. * @src: src of interrupt
  189. */
  190. struct qlcnic_tx_mbx {
  191. u32 phys_addr_low;
  192. u32 phys_addr_high;
  193. u32 cnsmr_index_low;
  194. u32 cnsmr_index_high;
  195. #if defined(__LITTLE_ENDIAN)
  196. u16 size;
  197. u16 intr_id;
  198. u8 src;
  199. u8 rsvd[3];
  200. #elif defined(__BIG_ENDIAN)
  201. u16 intr_id;
  202. u16 size;
  203. u8 rsvd[3];
  204. u8 src;
  205. #endif
  206. } __packed;
  207. /* Transmit context mailbox outbox registers
  208. * @host_prod: host producer index
  209. * @ctx_id: transmit context id
  210. * @state: state of the transmit context
  211. */
  212. struct qlcnic_tx_mbx_out {
  213. u32 host_prod;
  214. #if defined(__LITTLE_ENDIAN)
  215. u16 ctx_id;
  216. u8 state;
  217. u8 rsvd;
  218. #elif defined(__BIG_ENDIAN)
  219. u8 rsvd;
  220. u8 state;
  221. u16 ctx_id;
  222. #endif
  223. } __packed;
  224. struct qlcnic_intrpt_config {
  225. u8 type;
  226. u8 enabled;
  227. u16 id;
  228. u32 src;
  229. };
  230. struct qlcnic_macvlan_mbx {
  231. #if defined(__LITTLE_ENDIAN)
  232. u8 mac_addr0;
  233. u8 mac_addr1;
  234. u8 mac_addr2;
  235. u8 mac_addr3;
  236. u8 mac_addr4;
  237. u8 mac_addr5;
  238. u16 vlan;
  239. #elif defined(__BIG_ENDIAN)
  240. u8 mac_addr3;
  241. u8 mac_addr2;
  242. u8 mac_addr1;
  243. u8 mac_addr0;
  244. u16 vlan;
  245. u8 mac_addr5;
  246. u8 mac_addr4;
  247. #endif
  248. };
  249. struct qlc_83xx_fw_info {
  250. const struct firmware *fw;
  251. u16 major_fw_version;
  252. u8 minor_fw_version;
  253. u8 sub_fw_version;
  254. u8 fw_build_num;
  255. u8 load_from_file;
  256. };
  257. struct qlc_83xx_reset {
  258. struct qlc_83xx_reset_hdr *hdr;
  259. int seq_index;
  260. int seq_error;
  261. int array_index;
  262. u32 array[QLC_83XX_MAX_RESET_SEQ_ENTRIES];
  263. u8 *buff;
  264. u8 *stop_offset;
  265. u8 *start_offset;
  266. u8 *init_offset;
  267. u8 seq_end;
  268. u8 template_end;
  269. };
  270. #define QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY 0x1
  271. #define QLC_83XX_IDC_GRACEFULL_RESET 0x2
  272. #define QLC_83XX_IDC_TIMESTAMP 0
  273. #define QLC_83XX_IDC_DURATION 1
  274. #define QLC_83XX_IDC_INIT_TIMEOUT_SECS 30
  275. #define QLC_83XX_IDC_RESET_ACK_TIMEOUT_SECS 10
  276. #define QLC_83XX_IDC_RESET_TIMEOUT_SECS 10
  277. #define QLC_83XX_IDC_QUIESCE_ACK_TIMEOUT_SECS 20
  278. #define QLC_83XX_IDC_FW_POLL_DELAY (1 * HZ)
  279. #define QLC_83XX_IDC_FW_FAIL_THRESH 2
  280. #define QLC_83XX_IDC_MAX_FUNC_PER_PARTITION_INFO 8
  281. #define QLC_83XX_IDC_MAX_CNA_FUNCTIONS 16
  282. #define QLC_83XX_IDC_MAJOR_VERSION 1
  283. #define QLC_83XX_IDC_MINOR_VERSION 0
  284. #define QLC_83XX_IDC_FLASH_PARAM_ADDR 0x3e8020
  285. struct qlcnic_adapter;
  286. struct qlc_83xx_idc {
  287. int (*state_entry) (struct qlcnic_adapter *);
  288. u64 sec_counter;
  289. u64 delay;
  290. unsigned long status;
  291. int err_code;
  292. int collect_dump;
  293. u8 curr_state;
  294. u8 prev_state;
  295. u8 vnic_state;
  296. u8 vnic_wait_limit;
  297. u8 quiesce_req;
  298. u8 delay_reset;
  299. char **name;
  300. };
  301. /* Device States */
  302. enum qlcnic_83xx_states {
  303. QLC_83XX_IDC_DEV_UNKNOWN,
  304. QLC_83XX_IDC_DEV_COLD,
  305. QLC_83XX_IDC_DEV_INIT,
  306. QLC_83XX_IDC_DEV_READY,
  307. QLC_83XX_IDC_DEV_NEED_RESET,
  308. QLC_83XX_IDC_DEV_NEED_QUISCENT,
  309. QLC_83XX_IDC_DEV_FAILED,
  310. QLC_83XX_IDC_DEV_QUISCENT
  311. };
  312. #define QLCNIC_MBX_RSP(reg) LSW(reg)
  313. #define QLCNIC_MBX_NUM_REGS(reg) (MSW(reg) & 0x1FF)
  314. #define QLCNIC_MBX_STATUS(reg) (((reg) >> 25) & 0x7F)
  315. #define QLCNIC_MBX_HOST(ahw, i) ((ahw)->pci_base0 + ((i) * 4))
  316. #define QLCNIC_MBX_FW(ahw, i) ((ahw)->pci_base0 + 0x800 + ((i) * 4))
  317. /* Mailbox process AEN count */
  318. #define QLC_83XX_IDC_COMP_AEN 3
  319. #define QLC_83XX_MBX_AEN_CNT 5
  320. #define QLC_83XX_MODULE_LOADED 1
  321. #define QLC_83XX_MBX_READY 2
  322. #define QLC_83XX_MBX_AEN_ACK 3
  323. #define QLC_83XX_SFP_PRESENT(data) ((data) & 3)
  324. #define QLC_83XX_SFP_ERR(data) (((data) >> 2) & 3)
  325. #define QLC_83XX_SFP_MODULE_TYPE(data) (((data) >> 4) & 0x1F)
  326. #define QLC_83XX_SFP_CU_LENGTH(data) (LSB((data) >> 16))
  327. #define QLC_83XX_SFP_TX_FAULT(data) ((data) & BIT_10)
  328. #define QLC_83XX_SFP_10G_CAPABLE(data) ((data) & BIT_11)
  329. #define QLC_83XX_LINK_STATS(data) ((data) & BIT_0)
  330. #define QLC_83XX_CURRENT_LINK_SPEED(data) (((data) >> 3) & 7)
  331. #define QLC_83XX_LINK_PAUSE(data) (((data) >> 6) & 3)
  332. #define QLC_83XX_LINK_LB(data) (((data) >> 8) & 7)
  333. #define QLC_83XX_LINK_FEC(data) ((data) & BIT_12)
  334. #define QLC_83XX_LINK_EEE(data) ((data) & BIT_13)
  335. #define QLC_83XX_DCBX(data) (((data) >> 28) & 7)
  336. #define QLC_83XX_AUTONEG(data) ((data) & BIT_15)
  337. #define QLC_83XX_CFG_STD_PAUSE (1 << 5)
  338. #define QLC_83XX_CFG_STD_TX_PAUSE (1 << 20)
  339. #define QLC_83XX_CFG_STD_RX_PAUSE (2 << 20)
  340. #define QLC_83XX_CFG_STD_TX_RX_PAUSE (3 << 20)
  341. #define QLC_83XX_ENABLE_AUTONEG (1 << 15)
  342. #define QLC_83XX_CFG_LOOPBACK_HSS (2 << 1)
  343. #define QLC_83XX_CFG_LOOPBACK_PHY (3 << 1)
  344. #define QLC_83XX_CFG_LOOPBACK_EXT (4 << 1)
  345. /* LED configuration settings */
  346. #define QLC_83XX_ENABLE_BEACON 0xe
  347. #define QLC_83XX_LED_RATE 0xff
  348. #define QLC_83XX_LED_ACT (1 << 10)
  349. #define QLC_83XX_LED_MOD (0 << 13)
  350. #define QLC_83XX_LED_CONFIG (QLC_83XX_LED_RATE | QLC_83XX_LED_ACT | \
  351. QLC_83XX_LED_MOD)
  352. #define QLC_83XX_10M_LINK 1
  353. #define QLC_83XX_100M_LINK 2
  354. #define QLC_83XX_1G_LINK 3
  355. #define QLC_83XX_10G_LINK 4
  356. #define QLC_83XX_STAT_TX 3
  357. #define QLC_83XX_STAT_RX 2
  358. #define QLC_83XX_STAT_MAC 1
  359. #define QLC_83XX_TX_STAT_REGS 14
  360. #define QLC_83XX_RX_STAT_REGS 40
  361. #define QLC_83XX_MAC_STAT_REGS 94
  362. #define QLC_83XX_GET_FUNC_PRIVILEGE(VAL, FN) (0x3 & ((VAL) >> (FN * 2)))
  363. #define QLC_83XX_SET_FUNC_OPMODE(VAL, FN) ((VAL) << (FN * 2))
  364. #define QLC_83XX_DEFAULT_OPMODE 0x55555555
  365. #define QLC_83XX_PRIVLEGED_FUNC 0x1
  366. #define QLC_83XX_VIRTUAL_FUNC 0x2
  367. #define QLC_83XX_LB_MAX_FILTERS 2048
  368. #define QLC_83XX_LB_BUCKET_SIZE 256
  369. #define QLC_83XX_MINIMUM_VECTOR 3
  370. #define QLC_83XX_MAX_MC_COUNT 38
  371. #define QLC_83XX_MAX_UC_COUNT 4096
  372. #define QLC_83XX_PVID_STRIP_CAPABILITY BIT_22
  373. #define QLC_83XX_GET_FUNC_MODE_FROM_NPAR_INFO(val) (val & 0x80000000)
  374. #define QLC_83XX_GET_LRO_CAPABILITY(val) (val & 0x20)
  375. #define QLC_83XX_GET_LSO_CAPABILITY(val) (val & 0x40)
  376. #define QLC_83XX_GET_LSO_CAPABILITY(val) (val & 0x40)
  377. #define QLC_83XX_GET_HW_LRO_CAPABILITY(val) (val & 0x400)
  378. #define QLC_83XX_GET_VLAN_ALIGN_CAPABILITY(val) (val & 0x4000)
  379. #define QLC_83XX_GET_FW_LRO_MSS_CAPABILITY(val) (val & 0x20000)
  380. #define QLC_83XX_VIRTUAL_NIC_MODE 0xFF
  381. #define QLC_83XX_DEFAULT_MODE 0x0
  382. #define QLC_83XX_SRIOV_MODE 0x1
  383. #define QLCNIC_BRDTYPE_83XX_10G 0x0083
  384. #define QLC_83XX_FLASH_SPI_STATUS 0x2808E010
  385. #define QLC_83XX_FLASH_SPI_CONTROL 0x2808E014
  386. #define QLC_83XX_FLASH_STATUS 0x42100004
  387. #define QLC_83XX_FLASH_CONTROL 0x42110004
  388. #define QLC_83XX_FLASH_ADDR 0x42110008
  389. #define QLC_83XX_FLASH_WRDATA 0x4211000C
  390. #define QLC_83XX_FLASH_RDDATA 0x42110018
  391. #define QLC_83XX_FLASH_DIRECT_WINDOW 0x42110030
  392. #define QLC_83XX_FLASH_DIRECT_DATA(DATA) (0x42150000 | (0x0000FFFF&DATA))
  393. #define QLC_83XX_FLASH_SECTOR_ERASE_CMD 0xdeadbeef
  394. #define QLC_83XX_FLASH_WRITE_CMD 0xdacdacda
  395. #define QLC_83XX_FLASH_BULK_WRITE_CMD 0xcadcadca
  396. #define QLC_83XX_FLASH_READ_RETRY_COUNT 5000
  397. #define QLC_83XX_FLASH_STATUS_READY 0x6
  398. #define QLC_83XX_FLASH_WRITE_MIN 2
  399. #define QLC_83XX_FLASH_WRITE_MAX 64
  400. #define QLC_83XX_FLASH_STATUS_REG_POLL_DELAY 1
  401. #define QLC_83XX_ERASE_MODE 1
  402. #define QLC_83XX_WRITE_MODE 2
  403. #define QLC_83XX_BULK_WRITE_MODE 3
  404. #define QLC_83XX_FLASH_FDT_WRITE_DEF_SIG 0xFD0100
  405. #define QLC_83XX_FLASH_FDT_ERASE_DEF_SIG 0xFD0300
  406. #define QLC_83XX_FLASH_FDT_READ_MFG_ID_VAL 0xFD009F
  407. #define QLC_83XX_FLASH_OEM_ERASE_SIG 0xFD03D8
  408. #define QLC_83XX_FLASH_OEM_WRITE_SIG 0xFD0101
  409. #define QLC_83XX_FLASH_OEM_READ_SIG 0xFD0005
  410. #define QLC_83XX_FLASH_ADDR_TEMP_VAL 0x00800000
  411. #define QLC_83XX_FLASH_ADDR_SECOND_TEMP_VAL 0x00800001
  412. #define QLC_83XX_FLASH_WRDATA_DEF 0x0
  413. #define QLC_83XX_FLASH_READ_CTRL 0x3F
  414. #define QLC_83XX_FLASH_SPI_CTRL 0x4
  415. #define QLC_83XX_FLASH_FIRST_ERASE_MS_VAL 0x2
  416. #define QLC_83XX_FLASH_SECOND_ERASE_MS_VAL 0x5
  417. #define QLC_83XX_FLASH_LAST_ERASE_MS_VAL 0x3D
  418. #define QLC_83XX_FLASH_FIRST_MS_PATTERN 0x43
  419. #define QLC_83XX_FLASH_SECOND_MS_PATTERN 0x7F
  420. #define QLC_83XX_FLASH_LAST_MS_PATTERN 0x7D
  421. #define QLC_83xx_FLASH_MAX_WAIT_USEC 100
  422. #define QLC_83XX_FLASH_LOCK_TIMEOUT 10000
  423. enum qlc_83xx_mbx_cmd_type {
  424. QLC_83XX_MBX_CMD_WAIT = 0,
  425. QLC_83XX_MBX_CMD_NO_WAIT,
  426. QLC_83XX_MBX_CMD_BUSY_WAIT,
  427. };
  428. enum qlc_83xx_mbx_response_states {
  429. QLC_83XX_MBX_RESPONSE_WAIT = 0,
  430. QLC_83XX_MBX_RESPONSE_ARRIVED,
  431. };
  432. #define QLC_83XX_MBX_RESPONSE_FAILED 0x2
  433. #define QLC_83XX_MBX_RESPONSE_UNKNOWN 0x3
  434. /* Additional registers in 83xx */
  435. enum qlc_83xx_ext_regs {
  436. QLCNIC_GLOBAL_RESET = 0,
  437. QLCNIC_WILDCARD,
  438. QLCNIC_INFORMANT,
  439. QLCNIC_HOST_MBX_CTRL,
  440. QLCNIC_FW_MBX_CTRL,
  441. QLCNIC_BOOTLOADER_ADDR,
  442. QLCNIC_BOOTLOADER_SIZE,
  443. QLCNIC_FW_IMAGE_ADDR,
  444. QLCNIC_MBX_INTR_ENBL,
  445. QLCNIC_DEF_INT_MASK,
  446. QLCNIC_DEF_INT_ID,
  447. QLC_83XX_IDC_MAJ_VERSION,
  448. QLC_83XX_IDC_DEV_STATE,
  449. QLC_83XX_IDC_DRV_PRESENCE,
  450. QLC_83XX_IDC_DRV_ACK,
  451. QLC_83XX_IDC_CTRL,
  452. QLC_83XX_IDC_DRV_AUDIT,
  453. QLC_83XX_IDC_MIN_VERSION,
  454. QLC_83XX_RECOVER_DRV_LOCK,
  455. QLC_83XX_IDC_PF_0,
  456. QLC_83XX_IDC_PF_1,
  457. QLC_83XX_IDC_PF_2,
  458. QLC_83XX_IDC_PF_3,
  459. QLC_83XX_IDC_PF_4,
  460. QLC_83XX_IDC_PF_5,
  461. QLC_83XX_IDC_PF_6,
  462. QLC_83XX_IDC_PF_7,
  463. QLC_83XX_IDC_PF_8,
  464. QLC_83XX_IDC_PF_9,
  465. QLC_83XX_IDC_PF_10,
  466. QLC_83XX_IDC_PF_11,
  467. QLC_83XX_IDC_PF_12,
  468. QLC_83XX_IDC_PF_13,
  469. QLC_83XX_IDC_PF_14,
  470. QLC_83XX_IDC_PF_15,
  471. QLC_83XX_IDC_DEV_PARTITION_INFO_1,
  472. QLC_83XX_IDC_DEV_PARTITION_INFO_2,
  473. QLC_83XX_DRV_OP_MODE,
  474. QLC_83XX_VNIC_STATE,
  475. QLC_83XX_DRV_LOCK,
  476. QLC_83XX_DRV_UNLOCK,
  477. QLC_83XX_DRV_LOCK_ID,
  478. QLC_83XX_ASIC_TEMP,
  479. };
  480. /* 83xx funcitons */
  481. int qlcnic_83xx_get_fw_version(struct qlcnic_adapter *);
  482. int qlcnic_83xx_issue_cmd(struct qlcnic_adapter *, struct qlcnic_cmd_args *);
  483. int qlcnic_83xx_setup_intr(struct qlcnic_adapter *, u8, int);
  484. void qlcnic_83xx_get_func_no(struct qlcnic_adapter *);
  485. int qlcnic_83xx_cam_lock(struct qlcnic_adapter *);
  486. void qlcnic_83xx_cam_unlock(struct qlcnic_adapter *);
  487. int qlcnic_send_ctrl_op(struct qlcnic_adapter *, struct qlcnic_cmd_args *, u32);
  488. void qlcnic_83xx_add_sysfs(struct qlcnic_adapter *);
  489. void qlcnic_83xx_remove_sysfs(struct qlcnic_adapter *);
  490. void qlcnic_83xx_write_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
  491. void qlcnic_83xx_read_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
  492. int qlcnic_83xx_rd_reg_indirect(struct qlcnic_adapter *, ulong, int *);
  493. int qlcnic_83xx_wrt_reg_indirect(struct qlcnic_adapter *, ulong, u32);
  494. void qlcnic_83xx_process_rcv_diag(struct qlcnic_adapter *, int, u64 []);
  495. int qlcnic_83xx_nic_set_promisc(struct qlcnic_adapter *, u32);
  496. int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *, u8);
  497. int qlcnic_83xx_clear_lb_mode(struct qlcnic_adapter *, u8);
  498. int qlcnic_83xx_config_hw_lro(struct qlcnic_adapter *, int);
  499. int qlcnic_83xx_config_rss(struct qlcnic_adapter *, int);
  500. int qlcnic_83xx_config_intr_coalesce(struct qlcnic_adapter *);
  501. void qlcnic_83xx_change_l2_filter(struct qlcnic_adapter *, u64 *, u16);
  502. int qlcnic_83xx_get_pci_info(struct qlcnic_adapter *, struct qlcnic_pci_info *);
  503. int qlcnic_83xx_set_nic_info(struct qlcnic_adapter *, struct qlcnic_info *);
  504. void qlcnic_83xx_register_nic_idc_func(struct qlcnic_adapter *, int);
  505. int qlcnic_83xx_napi_add(struct qlcnic_adapter *, struct net_device *);
  506. void qlcnic_83xx_napi_del(struct qlcnic_adapter *);
  507. void qlcnic_83xx_napi_enable(struct qlcnic_adapter *);
  508. void qlcnic_83xx_napi_disable(struct qlcnic_adapter *);
  509. int qlcnic_83xx_config_led(struct qlcnic_adapter *, u32, u32);
  510. void qlcnic_ind_wr(struct qlcnic_adapter *, u32, u32);
  511. int qlcnic_ind_rd(struct qlcnic_adapter *, u32);
  512. int qlcnic_83xx_create_rx_ctx(struct qlcnic_adapter *);
  513. int qlcnic_83xx_create_tx_ctx(struct qlcnic_adapter *,
  514. struct qlcnic_host_tx_ring *, int);
  515. void qlcnic_83xx_del_rx_ctx(struct qlcnic_adapter *);
  516. void qlcnic_83xx_del_tx_ctx(struct qlcnic_adapter *,
  517. struct qlcnic_host_tx_ring *);
  518. int qlcnic_83xx_get_nic_info(struct qlcnic_adapter *, struct qlcnic_info *, u8);
  519. int qlcnic_83xx_setup_link_event(struct qlcnic_adapter *, int);
  520. void qlcnic_83xx_process_rcv_ring_diag(struct qlcnic_host_sds_ring *);
  521. int qlcnic_83xx_config_intrpt(struct qlcnic_adapter *, bool);
  522. int qlcnic_83xx_sre_macaddr_change(struct qlcnic_adapter *, u8 *, u16, u8);
  523. int qlcnic_83xx_get_mac_address(struct qlcnic_adapter *, u8 *);
  524. void qlcnic_83xx_configure_mac(struct qlcnic_adapter *, u8 *, u8,
  525. struct qlcnic_cmd_args *);
  526. int qlcnic_83xx_alloc_mbx_args(struct qlcnic_cmd_args *,
  527. struct qlcnic_adapter *, u32);
  528. void qlcnic_free_mbx_args(struct qlcnic_cmd_args *);
  529. void qlcnic_set_npar_data(struct qlcnic_adapter *, const struct qlcnic_info *,
  530. struct qlcnic_info *);
  531. void qlcnic_83xx_config_intr_coal(struct qlcnic_adapter *);
  532. irqreturn_t qlcnic_83xx_handle_aen(int, void *);
  533. int qlcnic_83xx_get_port_info(struct qlcnic_adapter *);
  534. void qlcnic_83xx_enable_mbx_interrupt(struct qlcnic_adapter *);
  535. void qlcnic_83xx_disable_mbx_intr(struct qlcnic_adapter *);
  536. irqreturn_t qlcnic_83xx_clear_legacy_intr(struct qlcnic_adapter *);
  537. irqreturn_t qlcnic_83xx_intr(int, void *);
  538. irqreturn_t qlcnic_83xx_tmp_intr(int, void *);
  539. void qlcnic_83xx_enable_intr(struct qlcnic_adapter *,
  540. struct qlcnic_host_sds_ring *);
  541. void qlcnic_83xx_disable_intr(struct qlcnic_adapter *,
  542. struct qlcnic_host_sds_ring *);
  543. void qlcnic_83xx_check_vf(struct qlcnic_adapter *,
  544. const struct pci_device_id *);
  545. void __qlcnic_83xx_process_aen(struct qlcnic_adapter *);
  546. int qlcnic_83xx_get_port_config(struct qlcnic_adapter *);
  547. int qlcnic_83xx_set_port_config(struct qlcnic_adapter *);
  548. int qlcnic_enable_eswitch(struct qlcnic_adapter *, u8, u8);
  549. int qlcnic_83xx_get_nic_configuration(struct qlcnic_adapter *);
  550. int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *);
  551. int qlcnic_83xx_setup_mbx_intr(struct qlcnic_adapter *);
  552. void qlcnic_83xx_free_mbx_intr(struct qlcnic_adapter *);
  553. void qlcnic_83xx_register_map(struct qlcnic_hardware_context *);
  554. void qlcnic_83xx_idc_aen_work(struct work_struct *);
  555. void qlcnic_83xx_config_ipaddr(struct qlcnic_adapter *, __be32, int);
  556. int qlcnic_83xx_erase_flash_sector(struct qlcnic_adapter *, u32);
  557. int qlcnic_83xx_flash_bulk_write(struct qlcnic_adapter *, u32, u32 *, int);
  558. int qlcnic_83xx_flash_write32(struct qlcnic_adapter *, u32, u32 *);
  559. int qlcnic_83xx_lock_flash(struct qlcnic_adapter *);
  560. void qlcnic_83xx_unlock_flash(struct qlcnic_adapter *);
  561. int qlcnic_83xx_save_flash_status(struct qlcnic_adapter *);
  562. int qlcnic_83xx_restore_flash_status(struct qlcnic_adapter *, int);
  563. int qlcnic_83xx_read_flash_mfg_id(struct qlcnic_adapter *);
  564. int qlcnic_83xx_read_flash_descriptor_table(struct qlcnic_adapter *);
  565. int qlcnic_83xx_flash_read32(struct qlcnic_adapter *, u32, u8 *, int);
  566. int qlcnic_83xx_lockless_flash_read32(struct qlcnic_adapter *,
  567. u32, u8 *, int);
  568. int qlcnic_83xx_init(struct qlcnic_adapter *, int);
  569. int qlcnic_83xx_idc_ready_state_entry(struct qlcnic_adapter *);
  570. int qlcnic_83xx_check_hw_status(struct qlcnic_adapter *p_dev);
  571. void qlcnic_83xx_idc_poll_dev_state(struct work_struct *);
  572. int qlcnic_83xx_get_reset_instruction_template(struct qlcnic_adapter *);
  573. void qlcnic_83xx_idc_exit(struct qlcnic_adapter *);
  574. void qlcnic_83xx_idc_request_reset(struct qlcnic_adapter *, u32);
  575. int qlcnic_83xx_lock_driver(struct qlcnic_adapter *);
  576. void qlcnic_83xx_unlock_driver(struct qlcnic_adapter *);
  577. int qlcnic_83xx_set_default_offload_settings(struct qlcnic_adapter *);
  578. int qlcnic_83xx_ms_mem_write128(struct qlcnic_adapter *, u64, u32 *, u32);
  579. int qlcnic_83xx_idc_vnic_pf_entry(struct qlcnic_adapter *);
  580. int qlcnic_83xx_enable_vnic_mode(struct qlcnic_adapter *, int);
  581. int qlcnic_83xx_disable_vnic_mode(struct qlcnic_adapter *, int);
  582. int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *);
  583. int qlcnic_83xx_get_vnic_vport_info(struct qlcnic_adapter *,
  584. struct qlcnic_info *, u8);
  585. int qlcnic_83xx_get_vnic_pf_info(struct qlcnic_adapter *, struct qlcnic_info *);
  586. void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *);
  587. void qlcnic_83xx_get_stats(struct qlcnic_adapter *adapter, u64 *data);
  588. int qlcnic_83xx_get_settings(struct qlcnic_adapter *, struct ethtool_cmd *);
  589. int qlcnic_83xx_set_settings(struct qlcnic_adapter *, struct ethtool_cmd *);
  590. void qlcnic_83xx_get_pauseparam(struct qlcnic_adapter *,
  591. struct ethtool_pauseparam *);
  592. int qlcnic_83xx_set_pauseparam(struct qlcnic_adapter *,
  593. struct ethtool_pauseparam *);
  594. int qlcnic_83xx_test_link(struct qlcnic_adapter *);
  595. int qlcnic_83xx_reg_test(struct qlcnic_adapter *);
  596. int qlcnic_83xx_get_regs_len(struct qlcnic_adapter *);
  597. int qlcnic_83xx_get_registers(struct qlcnic_adapter *, u32 *);
  598. int qlcnic_83xx_loopback_test(struct net_device *, u8);
  599. int qlcnic_83xx_interrupt_test(struct net_device *);
  600. int qlcnic_83xx_set_led(struct net_device *, enum ethtool_phys_id_state);
  601. int qlcnic_83xx_flash_test(struct qlcnic_adapter *);
  602. int qlcnic_83xx_enable_flash_write(struct qlcnic_adapter *);
  603. int qlcnic_83xx_disable_flash_write(struct qlcnic_adapter *);
  604. void qlcnic_83xx_enable_mbx_poll(struct qlcnic_adapter *);
  605. void qlcnic_83xx_disable_mbx_poll(struct qlcnic_adapter *);
  606. void qlcnic_83xx_set_mac_filter_count(struct qlcnic_adapter *);
  607. int qlcnic_83xx_shutdown(struct pci_dev *);
  608. int qlcnic_83xx_resume(struct qlcnic_adapter *);
  609. int qlcnic_83xx_idc_init(struct qlcnic_adapter *);
  610. int qlcnic_83xx_idc_reattach_driver(struct qlcnic_adapter *);
  611. int qlcnic_83xx_set_vnic_opmode(struct qlcnic_adapter *);
  612. int qlcnic_83xx_check_vnic_state(struct qlcnic_adapter *);
  613. #endif