qlcnic_83xx_hw.h 22 KB

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