qlcnic_83xx_hw.h 22 KB

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