qlcnic_83xx_hw.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  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. char fw_file_name[QLC_FW_FILE_NAME_LEN];
  252. };
  253. struct qlc_83xx_reset {
  254. struct qlc_83xx_reset_hdr *hdr;
  255. int seq_index;
  256. int seq_error;
  257. int array_index;
  258. u32 array[QLC_83XX_MAX_RESET_SEQ_ENTRIES];
  259. u8 *buff;
  260. u8 *stop_offset;
  261. u8 *start_offset;
  262. u8 *init_offset;
  263. u8 seq_end;
  264. u8 template_end;
  265. };
  266. #define QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY 0x1
  267. #define QLC_83XX_IDC_GRACEFULL_RESET 0x2
  268. #define QLC_83XX_IDC_DISABLE_FW_DUMP 0x4
  269. #define QLC_83XX_IDC_TIMESTAMP 0
  270. #define QLC_83XX_IDC_DURATION 1
  271. #define QLC_83XX_IDC_INIT_TIMEOUT_SECS 30
  272. #define QLC_83XX_IDC_RESET_ACK_TIMEOUT_SECS 10
  273. #define QLC_83XX_IDC_RESET_TIMEOUT_SECS 10
  274. #define QLC_83XX_IDC_QUIESCE_ACK_TIMEOUT_SECS 20
  275. #define QLC_83XX_IDC_FW_POLL_DELAY (1 * HZ)
  276. #define QLC_83XX_IDC_FW_FAIL_THRESH 2
  277. #define QLC_83XX_IDC_MAX_FUNC_PER_PARTITION_INFO 8
  278. #define QLC_83XX_IDC_MAX_CNA_FUNCTIONS 16
  279. #define QLC_83XX_IDC_MAJOR_VERSION 1
  280. #define QLC_83XX_IDC_MINOR_VERSION 0
  281. #define QLC_83XX_IDC_FLASH_PARAM_ADDR 0x3e8020
  282. struct qlcnic_adapter;
  283. struct qlc_83xx_idc {
  284. int (*state_entry) (struct qlcnic_adapter *);
  285. u64 sec_counter;
  286. u64 delay;
  287. unsigned long status;
  288. int err_code;
  289. int collect_dump;
  290. u8 curr_state;
  291. u8 prev_state;
  292. u8 vnic_state;
  293. u8 vnic_wait_limit;
  294. u8 quiesce_req;
  295. u8 delay_reset;
  296. char **name;
  297. };
  298. /* Device States */
  299. enum qlcnic_83xx_states {
  300. QLC_83XX_IDC_DEV_UNKNOWN,
  301. QLC_83XX_IDC_DEV_COLD,
  302. QLC_83XX_IDC_DEV_INIT,
  303. QLC_83XX_IDC_DEV_READY,
  304. QLC_83XX_IDC_DEV_NEED_RESET,
  305. QLC_83XX_IDC_DEV_NEED_QUISCENT,
  306. QLC_83XX_IDC_DEV_FAILED,
  307. QLC_83XX_IDC_DEV_QUISCENT
  308. };
  309. #define QLCNIC_MBX_RSP(reg) LSW(reg)
  310. #define QLCNIC_MBX_NUM_REGS(reg) (MSW(reg) & 0x1FF)
  311. #define QLCNIC_MBX_STATUS(reg) (((reg) >> 25) & 0x7F)
  312. #define QLCNIC_MBX_HOST(ahw, i) ((ahw)->pci_base0 + ((i) * 4))
  313. #define QLCNIC_MBX_FW(ahw, i) ((ahw)->pci_base0 + 0x800 + ((i) * 4))
  314. /* Mailbox process AEN count */
  315. #define QLC_83XX_IDC_COMP_AEN 3
  316. #define QLC_83XX_MBX_AEN_CNT 5
  317. #define QLC_83XX_MODULE_LOADED 1
  318. #define QLC_83XX_MBX_READY 2
  319. #define QLC_83XX_MBX_AEN_ACK 3
  320. #define QLC_83XX_SFP_PRESENT(data) ((data) & 3)
  321. #define QLC_83XX_SFP_ERR(data) (((data) >> 2) & 3)
  322. #define QLC_83XX_SFP_MODULE_TYPE(data) (((data) >> 4) & 0x1F)
  323. #define QLC_83XX_SFP_CU_LENGTH(data) (LSB((data) >> 16))
  324. #define QLC_83XX_SFP_TX_FAULT(data) ((data) & BIT_10)
  325. #define QLC_83XX_SFP_10G_CAPABLE(data) ((data) & BIT_11)
  326. #define QLC_83XX_LINK_STATS(data) ((data) & BIT_0)
  327. #define QLC_83XX_CURRENT_LINK_SPEED(data) (((data) >> 3) & 7)
  328. #define QLC_83XX_LINK_PAUSE(data) (((data) >> 6) & 3)
  329. #define QLC_83XX_LINK_LB(data) (((data) >> 8) & 7)
  330. #define QLC_83XX_LINK_FEC(data) ((data) & BIT_12)
  331. #define QLC_83XX_LINK_EEE(data) ((data) & BIT_13)
  332. #define QLC_83XX_DCBX(data) (((data) >> 28) & 7)
  333. #define QLC_83XX_AUTONEG(data) ((data) & BIT_15)
  334. #define QLC_83XX_CFG_STD_PAUSE (1 << 5)
  335. #define QLC_83XX_CFG_STD_TX_PAUSE (1 << 20)
  336. #define QLC_83XX_CFG_STD_RX_PAUSE (2 << 20)
  337. #define QLC_83XX_CFG_STD_TX_RX_PAUSE (3 << 20)
  338. #define QLC_83XX_ENABLE_AUTONEG (1 << 15)
  339. #define QLC_83XX_CFG_LOOPBACK_HSS (2 << 1)
  340. #define QLC_83XX_CFG_LOOPBACK_PHY (3 << 1)
  341. #define QLC_83XX_CFG_LOOPBACK_EXT (4 << 1)
  342. /* LED configuration settings */
  343. #define QLC_83XX_ENABLE_BEACON 0xe
  344. #define QLC_83XX_LED_RATE 0xff
  345. #define QLC_83XX_LED_ACT (1 << 10)
  346. #define QLC_83XX_LED_MOD (0 << 13)
  347. #define QLC_83XX_LED_CONFIG (QLC_83XX_LED_RATE | QLC_83XX_LED_ACT | \
  348. QLC_83XX_LED_MOD)
  349. #define QLC_83XX_10M_LINK 1
  350. #define QLC_83XX_100M_LINK 2
  351. #define QLC_83XX_1G_LINK 3
  352. #define QLC_83XX_10G_LINK 4
  353. #define QLC_83XX_STAT_TX 3
  354. #define QLC_83XX_STAT_RX 2
  355. #define QLC_83XX_STAT_MAC 1
  356. #define QLC_83XX_TX_STAT_REGS 14
  357. #define QLC_83XX_RX_STAT_REGS 40
  358. #define QLC_83XX_MAC_STAT_REGS 94
  359. #define QLC_83XX_GET_FUNC_PRIVILEGE(VAL, FN) (0x3 & ((VAL) >> (FN * 2)))
  360. #define QLC_83XX_SET_FUNC_OPMODE(VAL, FN) ((VAL) << (FN * 2))
  361. #define QLC_83XX_DEFAULT_OPMODE 0x55555555
  362. #define QLC_83XX_PRIVLEGED_FUNC 0x1
  363. #define QLC_83XX_VIRTUAL_FUNC 0x2
  364. #define QLC_83XX_LB_MAX_FILTERS 2048
  365. #define QLC_83XX_LB_BUCKET_SIZE 256
  366. #define QLC_83XX_MINIMUM_VECTOR 3
  367. #define QLC_83XX_MAX_MC_COUNT 38
  368. #define QLC_83XX_MAX_UC_COUNT 4096
  369. #define QLC_83XX_PVID_STRIP_CAPABILITY BIT_22
  370. #define QLC_83XX_GET_FUNC_MODE_FROM_NPAR_INFO(val) (val & 0x80000000)
  371. #define QLC_83XX_GET_LRO_CAPABILITY(val) (val & 0x20)
  372. #define QLC_83XX_GET_LSO_CAPABILITY(val) (val & 0x40)
  373. #define QLC_83XX_GET_LSO_CAPABILITY(val) (val & 0x40)
  374. #define QLC_83XX_GET_HW_LRO_CAPABILITY(val) (val & 0x400)
  375. #define QLC_83XX_GET_VLAN_ALIGN_CAPABILITY(val) (val & 0x4000)
  376. #define QLC_83XX_GET_FW_LRO_MSS_CAPABILITY(val) (val & 0x20000)
  377. #define QLC_83XX_ESWITCH_CAPABILITY BIT_23
  378. #define QLC_83XX_VIRTUAL_NIC_MODE 0xFF
  379. #define QLC_83XX_DEFAULT_MODE 0x0
  380. #define QLC_83XX_SRIOV_MODE 0x1
  381. #define QLCNIC_BRDTYPE_83XX_10G 0x0083
  382. #define QLC_83XX_FLASH_SPI_STATUS 0x2808E010
  383. #define QLC_83XX_FLASH_SPI_CONTROL 0x2808E014
  384. #define QLC_83XX_FLASH_STATUS 0x42100004
  385. #define QLC_83XX_FLASH_CONTROL 0x42110004
  386. #define QLC_83XX_FLASH_ADDR 0x42110008
  387. #define QLC_83XX_FLASH_WRDATA 0x4211000C
  388. #define QLC_83XX_FLASH_RDDATA 0x42110018
  389. #define QLC_83XX_FLASH_DIRECT_WINDOW 0x42110030
  390. #define QLC_83XX_FLASH_DIRECT_DATA(DATA) (0x42150000 | (0x0000FFFF&DATA))
  391. #define QLC_83XX_FLASH_SECTOR_ERASE_CMD 0xdeadbeef
  392. #define QLC_83XX_FLASH_WRITE_CMD 0xdacdacda
  393. #define QLC_83XX_FLASH_BULK_WRITE_CMD 0xcadcadca
  394. #define QLC_83XX_FLASH_READ_RETRY_COUNT 5000
  395. #define QLC_83XX_FLASH_STATUS_READY 0x6
  396. #define QLC_83XX_FLASH_WRITE_MIN 2
  397. #define QLC_83XX_FLASH_WRITE_MAX 64
  398. #define QLC_83XX_FLASH_STATUS_REG_POLL_DELAY 1
  399. #define QLC_83XX_ERASE_MODE 1
  400. #define QLC_83XX_WRITE_MODE 2
  401. #define QLC_83XX_BULK_WRITE_MODE 3
  402. #define QLC_83XX_FLASH_FDT_WRITE_DEF_SIG 0xFD0100
  403. #define QLC_83XX_FLASH_FDT_ERASE_DEF_SIG 0xFD0300
  404. #define QLC_83XX_FLASH_FDT_READ_MFG_ID_VAL 0xFD009F
  405. #define QLC_83XX_FLASH_OEM_ERASE_SIG 0xFD03D8
  406. #define QLC_83XX_FLASH_OEM_WRITE_SIG 0xFD0101
  407. #define QLC_83XX_FLASH_OEM_READ_SIG 0xFD0005
  408. #define QLC_83XX_FLASH_ADDR_TEMP_VAL 0x00800000
  409. #define QLC_83XX_FLASH_ADDR_SECOND_TEMP_VAL 0x00800001
  410. #define QLC_83XX_FLASH_WRDATA_DEF 0x0
  411. #define QLC_83XX_FLASH_READ_CTRL 0x3F
  412. #define QLC_83XX_FLASH_SPI_CTRL 0x4
  413. #define QLC_83XX_FLASH_FIRST_ERASE_MS_VAL 0x2
  414. #define QLC_83XX_FLASH_SECOND_ERASE_MS_VAL 0x5
  415. #define QLC_83XX_FLASH_LAST_ERASE_MS_VAL 0x3D
  416. #define QLC_83XX_FLASH_FIRST_MS_PATTERN 0x43
  417. #define QLC_83XX_FLASH_SECOND_MS_PATTERN 0x7F
  418. #define QLC_83XX_FLASH_LAST_MS_PATTERN 0x7D
  419. #define QLC_83xx_FLASH_MAX_WAIT_USEC 100
  420. #define QLC_83XX_FLASH_LOCK_TIMEOUT 10000
  421. enum qlc_83xx_mbx_cmd_type {
  422. QLC_83XX_MBX_CMD_WAIT = 0,
  423. QLC_83XX_MBX_CMD_NO_WAIT,
  424. QLC_83XX_MBX_CMD_BUSY_WAIT,
  425. };
  426. enum qlc_83xx_mbx_response_states {
  427. QLC_83XX_MBX_RESPONSE_WAIT = 0,
  428. QLC_83XX_MBX_RESPONSE_ARRIVED,
  429. };
  430. #define QLC_83XX_MBX_RESPONSE_FAILED 0x2
  431. #define QLC_83XX_MBX_RESPONSE_UNKNOWN 0x3
  432. /* Additional registers in 83xx */
  433. enum qlc_83xx_ext_regs {
  434. QLCNIC_GLOBAL_RESET = 0,
  435. QLCNIC_WILDCARD,
  436. QLCNIC_INFORMANT,
  437. QLCNIC_HOST_MBX_CTRL,
  438. QLCNIC_FW_MBX_CTRL,
  439. QLCNIC_BOOTLOADER_ADDR,
  440. QLCNIC_BOOTLOADER_SIZE,
  441. QLCNIC_FW_IMAGE_ADDR,
  442. QLCNIC_MBX_INTR_ENBL,
  443. QLCNIC_DEF_INT_MASK,
  444. QLCNIC_DEF_INT_ID,
  445. QLC_83XX_IDC_MAJ_VERSION,
  446. QLC_83XX_IDC_DEV_STATE,
  447. QLC_83XX_IDC_DRV_PRESENCE,
  448. QLC_83XX_IDC_DRV_ACK,
  449. QLC_83XX_IDC_CTRL,
  450. QLC_83XX_IDC_DRV_AUDIT,
  451. QLC_83XX_IDC_MIN_VERSION,
  452. QLC_83XX_RECOVER_DRV_LOCK,
  453. QLC_83XX_IDC_PF_0,
  454. QLC_83XX_IDC_PF_1,
  455. QLC_83XX_IDC_PF_2,
  456. QLC_83XX_IDC_PF_3,
  457. QLC_83XX_IDC_PF_4,
  458. QLC_83XX_IDC_PF_5,
  459. QLC_83XX_IDC_PF_6,
  460. QLC_83XX_IDC_PF_7,
  461. QLC_83XX_IDC_PF_8,
  462. QLC_83XX_IDC_PF_9,
  463. QLC_83XX_IDC_PF_10,
  464. QLC_83XX_IDC_PF_11,
  465. QLC_83XX_IDC_PF_12,
  466. QLC_83XX_IDC_PF_13,
  467. QLC_83XX_IDC_PF_14,
  468. QLC_83XX_IDC_PF_15,
  469. QLC_83XX_IDC_DEV_PARTITION_INFO_1,
  470. QLC_83XX_IDC_DEV_PARTITION_INFO_2,
  471. QLC_83XX_DRV_OP_MODE,
  472. QLC_83XX_VNIC_STATE,
  473. QLC_83XX_DRV_LOCK,
  474. QLC_83XX_DRV_UNLOCK,
  475. QLC_83XX_DRV_LOCK_ID,
  476. QLC_83XX_ASIC_TEMP,
  477. };
  478. /* 83xx funcitons */
  479. int qlcnic_83xx_get_fw_version(struct qlcnic_adapter *);
  480. int qlcnic_83xx_issue_cmd(struct qlcnic_adapter *, struct qlcnic_cmd_args *);
  481. int qlcnic_83xx_setup_intr(struct qlcnic_adapter *, u8, int);
  482. void qlcnic_83xx_get_func_no(struct qlcnic_adapter *);
  483. int qlcnic_83xx_cam_lock(struct qlcnic_adapter *);
  484. void qlcnic_83xx_cam_unlock(struct qlcnic_adapter *);
  485. int qlcnic_send_ctrl_op(struct qlcnic_adapter *, struct qlcnic_cmd_args *, u32);
  486. void qlcnic_83xx_add_sysfs(struct qlcnic_adapter *);
  487. void qlcnic_83xx_remove_sysfs(struct qlcnic_adapter *);
  488. void qlcnic_83xx_write_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
  489. void qlcnic_83xx_read_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
  490. int qlcnic_83xx_rd_reg_indirect(struct qlcnic_adapter *, ulong, int *);
  491. int qlcnic_83xx_wrt_reg_indirect(struct qlcnic_adapter *, ulong, u32);
  492. void qlcnic_83xx_process_rcv_diag(struct qlcnic_adapter *, int, u64 []);
  493. int qlcnic_83xx_nic_set_promisc(struct qlcnic_adapter *, u32);
  494. int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *, u8);
  495. int qlcnic_83xx_clear_lb_mode(struct qlcnic_adapter *, u8);
  496. int qlcnic_83xx_config_hw_lro(struct qlcnic_adapter *, int);
  497. int qlcnic_83xx_config_rss(struct qlcnic_adapter *, int);
  498. int qlcnic_83xx_config_intr_coalesce(struct qlcnic_adapter *);
  499. void qlcnic_83xx_change_l2_filter(struct qlcnic_adapter *, u64 *, u16);
  500. int qlcnic_83xx_get_pci_info(struct qlcnic_adapter *, struct qlcnic_pci_info *);
  501. int qlcnic_83xx_set_nic_info(struct qlcnic_adapter *, struct qlcnic_info *);
  502. void qlcnic_83xx_register_nic_idc_func(struct qlcnic_adapter *, int);
  503. int qlcnic_83xx_napi_add(struct qlcnic_adapter *, struct net_device *);
  504. void qlcnic_83xx_napi_del(struct qlcnic_adapter *);
  505. void qlcnic_83xx_napi_enable(struct qlcnic_adapter *);
  506. void qlcnic_83xx_napi_disable(struct qlcnic_adapter *);
  507. int qlcnic_83xx_config_led(struct qlcnic_adapter *, u32, u32);
  508. void qlcnic_ind_wr(struct qlcnic_adapter *, u32, u32);
  509. int qlcnic_ind_rd(struct qlcnic_adapter *, u32);
  510. int qlcnic_83xx_create_rx_ctx(struct qlcnic_adapter *);
  511. int qlcnic_83xx_create_tx_ctx(struct qlcnic_adapter *,
  512. struct qlcnic_host_tx_ring *, int);
  513. void qlcnic_83xx_del_rx_ctx(struct qlcnic_adapter *);
  514. void qlcnic_83xx_del_tx_ctx(struct qlcnic_adapter *,
  515. struct qlcnic_host_tx_ring *);
  516. int qlcnic_83xx_get_nic_info(struct qlcnic_adapter *, struct qlcnic_info *, u8);
  517. int qlcnic_83xx_setup_link_event(struct qlcnic_adapter *, int);
  518. void qlcnic_83xx_process_rcv_ring_diag(struct qlcnic_host_sds_ring *);
  519. int qlcnic_83xx_config_intrpt(struct qlcnic_adapter *, bool);
  520. int qlcnic_83xx_sre_macaddr_change(struct qlcnic_adapter *, u8 *, u16, u8);
  521. int qlcnic_83xx_get_mac_address(struct qlcnic_adapter *, u8 *, u8);
  522. void qlcnic_83xx_configure_mac(struct qlcnic_adapter *, u8 *, u8,
  523. struct qlcnic_cmd_args *);
  524. int qlcnic_83xx_alloc_mbx_args(struct qlcnic_cmd_args *,
  525. struct qlcnic_adapter *, u32);
  526. void qlcnic_free_mbx_args(struct qlcnic_cmd_args *);
  527. void qlcnic_set_npar_data(struct qlcnic_adapter *, const struct qlcnic_info *,
  528. struct qlcnic_info *);
  529. void qlcnic_83xx_config_intr_coal(struct qlcnic_adapter *);
  530. irqreturn_t qlcnic_83xx_handle_aen(int, void *);
  531. int qlcnic_83xx_get_port_info(struct qlcnic_adapter *);
  532. void qlcnic_83xx_enable_mbx_interrupt(struct qlcnic_adapter *);
  533. void qlcnic_83xx_disable_mbx_intr(struct qlcnic_adapter *);
  534. irqreturn_t qlcnic_83xx_clear_legacy_intr(struct qlcnic_adapter *);
  535. irqreturn_t qlcnic_83xx_intr(int, void *);
  536. irqreturn_t qlcnic_83xx_tmp_intr(int, void *);
  537. void qlcnic_83xx_enable_intr(struct qlcnic_adapter *,
  538. struct qlcnic_host_sds_ring *);
  539. void qlcnic_83xx_disable_intr(struct qlcnic_adapter *,
  540. struct qlcnic_host_sds_ring *);
  541. void qlcnic_83xx_check_vf(struct qlcnic_adapter *,
  542. const struct pci_device_id *);
  543. void __qlcnic_83xx_process_aen(struct qlcnic_adapter *);
  544. int qlcnic_83xx_get_port_config(struct qlcnic_adapter *);
  545. int qlcnic_83xx_set_port_config(struct qlcnic_adapter *);
  546. int qlcnic_enable_eswitch(struct qlcnic_adapter *, u8, u8);
  547. int qlcnic_83xx_get_nic_configuration(struct qlcnic_adapter *);
  548. int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *);
  549. int qlcnic_83xx_setup_mbx_intr(struct qlcnic_adapter *);
  550. void qlcnic_83xx_free_mbx_intr(struct qlcnic_adapter *);
  551. void qlcnic_83xx_register_map(struct qlcnic_hardware_context *);
  552. void qlcnic_83xx_idc_aen_work(struct work_struct *);
  553. void qlcnic_83xx_config_ipaddr(struct qlcnic_adapter *, __be32, int);
  554. int qlcnic_83xx_erase_flash_sector(struct qlcnic_adapter *, u32);
  555. int qlcnic_83xx_flash_bulk_write(struct qlcnic_adapter *, u32, u32 *, int);
  556. int qlcnic_83xx_flash_write32(struct qlcnic_adapter *, u32, u32 *);
  557. int qlcnic_83xx_lock_flash(struct qlcnic_adapter *);
  558. void qlcnic_83xx_unlock_flash(struct qlcnic_adapter *);
  559. int qlcnic_83xx_save_flash_status(struct qlcnic_adapter *);
  560. int qlcnic_83xx_restore_flash_status(struct qlcnic_adapter *, int);
  561. int qlcnic_83xx_read_flash_mfg_id(struct qlcnic_adapter *);
  562. int qlcnic_83xx_read_flash_descriptor_table(struct qlcnic_adapter *);
  563. int qlcnic_83xx_flash_read32(struct qlcnic_adapter *, u32, u8 *, int);
  564. int qlcnic_83xx_lockless_flash_read32(struct qlcnic_adapter *,
  565. u32, u8 *, int);
  566. int qlcnic_83xx_init(struct qlcnic_adapter *, int);
  567. int qlcnic_83xx_idc_ready_state_entry(struct qlcnic_adapter *);
  568. int qlcnic_83xx_check_hw_status(struct qlcnic_adapter *p_dev);
  569. void qlcnic_83xx_idc_poll_dev_state(struct work_struct *);
  570. int qlcnic_83xx_get_reset_instruction_template(struct qlcnic_adapter *);
  571. void qlcnic_83xx_idc_exit(struct qlcnic_adapter *);
  572. void qlcnic_83xx_idc_request_reset(struct qlcnic_adapter *, u32);
  573. int qlcnic_83xx_lock_driver(struct qlcnic_adapter *);
  574. void qlcnic_83xx_unlock_driver(struct qlcnic_adapter *);
  575. int qlcnic_83xx_set_default_offload_settings(struct qlcnic_adapter *);
  576. int qlcnic_83xx_ms_mem_write128(struct qlcnic_adapter *, u64, u32 *, u32);
  577. int qlcnic_83xx_idc_vnic_pf_entry(struct qlcnic_adapter *);
  578. int qlcnic_83xx_enable_vnic_mode(struct qlcnic_adapter *, int);
  579. int qlcnic_83xx_disable_vnic_mode(struct qlcnic_adapter *, int);
  580. int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *);
  581. int qlcnic_83xx_get_vnic_vport_info(struct qlcnic_adapter *,
  582. struct qlcnic_info *, u8);
  583. int qlcnic_83xx_get_vnic_pf_info(struct qlcnic_adapter *, struct qlcnic_info *);
  584. int qlcnic_83xx_enable_port_eswitch(struct qlcnic_adapter *, int);
  585. void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *);
  586. void qlcnic_83xx_get_stats(struct qlcnic_adapter *adapter, u64 *data);
  587. int qlcnic_83xx_get_settings(struct qlcnic_adapter *, struct ethtool_cmd *);
  588. int qlcnic_83xx_set_settings(struct qlcnic_adapter *, struct ethtool_cmd *);
  589. void qlcnic_83xx_get_pauseparam(struct qlcnic_adapter *,
  590. struct ethtool_pauseparam *);
  591. int qlcnic_83xx_set_pauseparam(struct qlcnic_adapter *,
  592. struct ethtool_pauseparam *);
  593. int qlcnic_83xx_test_link(struct qlcnic_adapter *);
  594. int qlcnic_83xx_reg_test(struct qlcnic_adapter *);
  595. int qlcnic_83xx_get_regs_len(struct qlcnic_adapter *);
  596. int qlcnic_83xx_get_registers(struct qlcnic_adapter *, u32 *);
  597. int qlcnic_83xx_loopback_test(struct net_device *, u8);
  598. int qlcnic_83xx_interrupt_test(struct net_device *);
  599. int qlcnic_83xx_set_led(struct net_device *, enum ethtool_phys_id_state);
  600. int qlcnic_83xx_flash_test(struct qlcnic_adapter *);
  601. int qlcnic_83xx_enable_flash_write(struct qlcnic_adapter *);
  602. int qlcnic_83xx_disable_flash_write(struct qlcnic_adapter *);
  603. void qlcnic_83xx_enable_mbx_poll(struct qlcnic_adapter *);
  604. void qlcnic_83xx_disable_mbx_poll(struct qlcnic_adapter *);
  605. void qlcnic_83xx_set_mac_filter_count(struct qlcnic_adapter *);
  606. int qlcnic_83xx_shutdown(struct pci_dev *);
  607. int qlcnic_83xx_resume(struct qlcnic_adapter *);
  608. int qlcnic_83xx_idc_init(struct qlcnic_adapter *);
  609. int qlcnic_83xx_idc_reattach_driver(struct qlcnic_adapter *);
  610. int qlcnic_83xx_set_vnic_opmode(struct qlcnic_adapter *);
  611. int qlcnic_83xx_check_vnic_state(struct qlcnic_adapter *);
  612. void qlcnic_83xx_aer_stop_poll_work(struct qlcnic_adapter *);
  613. int qlcnic_83xx_aer_reset(struct qlcnic_adapter *);
  614. void qlcnic_83xx_aer_start_poll_work(struct qlcnic_adapter *);
  615. pci_ers_result_t qlcnic_83xx_io_error_detected(struct pci_dev *,
  616. pci_channel_state_t);
  617. pci_ers_result_t qlcnic_83xx_io_slot_reset(struct pci_dev *);
  618. void qlcnic_83xx_io_resume(struct pci_dev *);
  619. #endif