e1000_hw.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 2007 - 2018 Intel Corporation. */
  3. #ifndef _E1000_HW_H_
  4. #define _E1000_HW_H_
  5. #include <linux/types.h>
  6. #include <linux/delay.h>
  7. #include <linux/io.h>
  8. #include <linux/netdevice.h>
  9. #include "e1000_regs.h"
  10. #include "e1000_defines.h"
  11. struct e1000_hw;
  12. #define E1000_DEV_ID_82576 0x10C9
  13. #define E1000_DEV_ID_82576_FIBER 0x10E6
  14. #define E1000_DEV_ID_82576_SERDES 0x10E7
  15. #define E1000_DEV_ID_82576_QUAD_COPPER 0x10E8
  16. #define E1000_DEV_ID_82576_QUAD_COPPER_ET2 0x1526
  17. #define E1000_DEV_ID_82576_NS 0x150A
  18. #define E1000_DEV_ID_82576_NS_SERDES 0x1518
  19. #define E1000_DEV_ID_82576_SERDES_QUAD 0x150D
  20. #define E1000_DEV_ID_82575EB_COPPER 0x10A7
  21. #define E1000_DEV_ID_82575EB_FIBER_SERDES 0x10A9
  22. #define E1000_DEV_ID_82575GB_QUAD_COPPER 0x10D6
  23. #define E1000_DEV_ID_82580_COPPER 0x150E
  24. #define E1000_DEV_ID_82580_FIBER 0x150F
  25. #define E1000_DEV_ID_82580_SERDES 0x1510
  26. #define E1000_DEV_ID_82580_SGMII 0x1511
  27. #define E1000_DEV_ID_82580_COPPER_DUAL 0x1516
  28. #define E1000_DEV_ID_82580_QUAD_FIBER 0x1527
  29. #define E1000_DEV_ID_DH89XXCC_SGMII 0x0438
  30. #define E1000_DEV_ID_DH89XXCC_SERDES 0x043A
  31. #define E1000_DEV_ID_DH89XXCC_BACKPLANE 0x043C
  32. #define E1000_DEV_ID_DH89XXCC_SFP 0x0440
  33. #define E1000_DEV_ID_I350_COPPER 0x1521
  34. #define E1000_DEV_ID_I350_FIBER 0x1522
  35. #define E1000_DEV_ID_I350_SERDES 0x1523
  36. #define E1000_DEV_ID_I350_SGMII 0x1524
  37. #define E1000_DEV_ID_I210_COPPER 0x1533
  38. #define E1000_DEV_ID_I210_FIBER 0x1536
  39. #define E1000_DEV_ID_I210_SERDES 0x1537
  40. #define E1000_DEV_ID_I210_SGMII 0x1538
  41. #define E1000_DEV_ID_I210_COPPER_FLASHLESS 0x157B
  42. #define E1000_DEV_ID_I210_SERDES_FLASHLESS 0x157C
  43. #define E1000_DEV_ID_I211_COPPER 0x1539
  44. #define E1000_DEV_ID_I354_BACKPLANE_1GBPS 0x1F40
  45. #define E1000_DEV_ID_I354_SGMII 0x1F41
  46. #define E1000_DEV_ID_I354_BACKPLANE_2_5GBPS 0x1F45
  47. #define E1000_REVISION_2 2
  48. #define E1000_REVISION_4 4
  49. #define E1000_FUNC_0 0
  50. #define E1000_FUNC_1 1
  51. #define E1000_FUNC_2 2
  52. #define E1000_FUNC_3 3
  53. #define E1000_ALT_MAC_ADDRESS_OFFSET_LAN0 0
  54. #define E1000_ALT_MAC_ADDRESS_OFFSET_LAN1 3
  55. #define E1000_ALT_MAC_ADDRESS_OFFSET_LAN2 6
  56. #define E1000_ALT_MAC_ADDRESS_OFFSET_LAN3 9
  57. enum e1000_mac_type {
  58. e1000_undefined = 0,
  59. e1000_82575,
  60. e1000_82576,
  61. e1000_82580,
  62. e1000_i350,
  63. e1000_i354,
  64. e1000_i210,
  65. e1000_i211,
  66. e1000_num_macs /* List is 1-based, so subtract 1 for true count. */
  67. };
  68. enum e1000_media_type {
  69. e1000_media_type_unknown = 0,
  70. e1000_media_type_copper = 1,
  71. e1000_media_type_fiber = 2,
  72. e1000_media_type_internal_serdes = 3,
  73. e1000_num_media_types
  74. };
  75. enum e1000_nvm_type {
  76. e1000_nvm_unknown = 0,
  77. e1000_nvm_none,
  78. e1000_nvm_eeprom_spi,
  79. e1000_nvm_flash_hw,
  80. e1000_nvm_invm,
  81. e1000_nvm_flash_sw
  82. };
  83. enum e1000_nvm_override {
  84. e1000_nvm_override_none = 0,
  85. e1000_nvm_override_spi_small,
  86. e1000_nvm_override_spi_large,
  87. };
  88. enum e1000_phy_type {
  89. e1000_phy_unknown = 0,
  90. e1000_phy_none,
  91. e1000_phy_m88,
  92. e1000_phy_igp,
  93. e1000_phy_igp_2,
  94. e1000_phy_gg82563,
  95. e1000_phy_igp_3,
  96. e1000_phy_ife,
  97. e1000_phy_82580,
  98. e1000_phy_i210,
  99. e1000_phy_bcm54616,
  100. };
  101. enum e1000_bus_type {
  102. e1000_bus_type_unknown = 0,
  103. e1000_bus_type_pci,
  104. e1000_bus_type_pcix,
  105. e1000_bus_type_pci_express,
  106. e1000_bus_type_reserved
  107. };
  108. enum e1000_bus_speed {
  109. e1000_bus_speed_unknown = 0,
  110. e1000_bus_speed_33,
  111. e1000_bus_speed_66,
  112. e1000_bus_speed_100,
  113. e1000_bus_speed_120,
  114. e1000_bus_speed_133,
  115. e1000_bus_speed_2500,
  116. e1000_bus_speed_5000,
  117. e1000_bus_speed_reserved
  118. };
  119. enum e1000_bus_width {
  120. e1000_bus_width_unknown = 0,
  121. e1000_bus_width_pcie_x1,
  122. e1000_bus_width_pcie_x2,
  123. e1000_bus_width_pcie_x4 = 4,
  124. e1000_bus_width_pcie_x8 = 8,
  125. e1000_bus_width_32,
  126. e1000_bus_width_64,
  127. e1000_bus_width_reserved
  128. };
  129. enum e1000_1000t_rx_status {
  130. e1000_1000t_rx_status_not_ok = 0,
  131. e1000_1000t_rx_status_ok,
  132. e1000_1000t_rx_status_undefined = 0xFF
  133. };
  134. enum e1000_rev_polarity {
  135. e1000_rev_polarity_normal = 0,
  136. e1000_rev_polarity_reversed,
  137. e1000_rev_polarity_undefined = 0xFF
  138. };
  139. enum e1000_fc_mode {
  140. e1000_fc_none = 0,
  141. e1000_fc_rx_pause,
  142. e1000_fc_tx_pause,
  143. e1000_fc_full,
  144. e1000_fc_default = 0xFF
  145. };
  146. /* Statistics counters collected by the MAC */
  147. struct e1000_hw_stats {
  148. u64 crcerrs;
  149. u64 algnerrc;
  150. u64 symerrs;
  151. u64 rxerrc;
  152. u64 mpc;
  153. u64 scc;
  154. u64 ecol;
  155. u64 mcc;
  156. u64 latecol;
  157. u64 colc;
  158. u64 dc;
  159. u64 tncrs;
  160. u64 sec;
  161. u64 cexterr;
  162. u64 rlec;
  163. u64 xonrxc;
  164. u64 xontxc;
  165. u64 xoffrxc;
  166. u64 xofftxc;
  167. u64 fcruc;
  168. u64 prc64;
  169. u64 prc127;
  170. u64 prc255;
  171. u64 prc511;
  172. u64 prc1023;
  173. u64 prc1522;
  174. u64 gprc;
  175. u64 bprc;
  176. u64 mprc;
  177. u64 gptc;
  178. u64 gorc;
  179. u64 gotc;
  180. u64 rnbc;
  181. u64 ruc;
  182. u64 rfc;
  183. u64 roc;
  184. u64 rjc;
  185. u64 mgprc;
  186. u64 mgpdc;
  187. u64 mgptc;
  188. u64 tor;
  189. u64 tot;
  190. u64 tpr;
  191. u64 tpt;
  192. u64 ptc64;
  193. u64 ptc127;
  194. u64 ptc255;
  195. u64 ptc511;
  196. u64 ptc1023;
  197. u64 ptc1522;
  198. u64 mptc;
  199. u64 bptc;
  200. u64 tsctc;
  201. u64 tsctfc;
  202. u64 iac;
  203. u64 icrxptc;
  204. u64 icrxatc;
  205. u64 ictxptc;
  206. u64 ictxatc;
  207. u64 ictxqec;
  208. u64 ictxqmtc;
  209. u64 icrxdmtc;
  210. u64 icrxoc;
  211. u64 cbtmpc;
  212. u64 htdpmc;
  213. u64 cbrdpc;
  214. u64 cbrmpc;
  215. u64 rpthc;
  216. u64 hgptc;
  217. u64 htcbdpc;
  218. u64 hgorc;
  219. u64 hgotc;
  220. u64 lenerrs;
  221. u64 scvpc;
  222. u64 hrmpc;
  223. u64 doosync;
  224. u64 o2bgptc;
  225. u64 o2bspc;
  226. u64 b2ospc;
  227. u64 b2ogprc;
  228. };
  229. struct e1000_host_mng_dhcp_cookie {
  230. u32 signature;
  231. u8 status;
  232. u8 reserved0;
  233. u16 vlan_id;
  234. u32 reserved1;
  235. u16 reserved2;
  236. u8 reserved3;
  237. u8 checksum;
  238. };
  239. /* Host Interface "Rev 1" */
  240. struct e1000_host_command_header {
  241. u8 command_id;
  242. u8 command_length;
  243. u8 command_options;
  244. u8 checksum;
  245. };
  246. #define E1000_HI_MAX_DATA_LENGTH 252
  247. struct e1000_host_command_info {
  248. struct e1000_host_command_header command_header;
  249. u8 command_data[E1000_HI_MAX_DATA_LENGTH];
  250. };
  251. /* Host Interface "Rev 2" */
  252. struct e1000_host_mng_command_header {
  253. u8 command_id;
  254. u8 checksum;
  255. u16 reserved1;
  256. u16 reserved2;
  257. u16 command_length;
  258. };
  259. #define E1000_HI_MAX_MNG_DATA_LENGTH 0x6F8
  260. struct e1000_host_mng_command_info {
  261. struct e1000_host_mng_command_header command_header;
  262. u8 command_data[E1000_HI_MAX_MNG_DATA_LENGTH];
  263. };
  264. #include "e1000_mac.h"
  265. #include "e1000_phy.h"
  266. #include "e1000_nvm.h"
  267. #include "e1000_mbx.h"
  268. struct e1000_mac_operations {
  269. s32 (*check_for_link)(struct e1000_hw *);
  270. s32 (*reset_hw)(struct e1000_hw *);
  271. s32 (*init_hw)(struct e1000_hw *);
  272. bool (*check_mng_mode)(struct e1000_hw *);
  273. s32 (*setup_physical_interface)(struct e1000_hw *);
  274. void (*rar_set)(struct e1000_hw *, u8 *, u32);
  275. s32 (*read_mac_addr)(struct e1000_hw *);
  276. s32 (*get_speed_and_duplex)(struct e1000_hw *, u16 *, u16 *);
  277. s32 (*acquire_swfw_sync)(struct e1000_hw *, u16);
  278. void (*release_swfw_sync)(struct e1000_hw *, u16);
  279. #ifdef CONFIG_IGB_HWMON
  280. s32 (*get_thermal_sensor_data)(struct e1000_hw *);
  281. s32 (*init_thermal_sensor_thresh)(struct e1000_hw *);
  282. #endif
  283. void (*write_vfta)(struct e1000_hw *, u32, u32);
  284. };
  285. struct e1000_phy_operations {
  286. s32 (*acquire)(struct e1000_hw *);
  287. s32 (*check_polarity)(struct e1000_hw *);
  288. s32 (*check_reset_block)(struct e1000_hw *);
  289. s32 (*force_speed_duplex)(struct e1000_hw *);
  290. s32 (*get_cfg_done)(struct e1000_hw *hw);
  291. s32 (*get_cable_length)(struct e1000_hw *);
  292. s32 (*get_phy_info)(struct e1000_hw *);
  293. s32 (*read_reg)(struct e1000_hw *, u32, u16 *);
  294. void (*release)(struct e1000_hw *);
  295. s32 (*reset)(struct e1000_hw *);
  296. s32 (*set_d0_lplu_state)(struct e1000_hw *, bool);
  297. s32 (*set_d3_lplu_state)(struct e1000_hw *, bool);
  298. s32 (*write_reg)(struct e1000_hw *, u32, u16);
  299. s32 (*read_i2c_byte)(struct e1000_hw *, u8, u8, u8 *);
  300. s32 (*write_i2c_byte)(struct e1000_hw *, u8, u8, u8);
  301. };
  302. struct e1000_nvm_operations {
  303. s32 (*acquire)(struct e1000_hw *);
  304. s32 (*read)(struct e1000_hw *, u16, u16, u16 *);
  305. void (*release)(struct e1000_hw *);
  306. s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
  307. s32 (*update)(struct e1000_hw *);
  308. s32 (*validate)(struct e1000_hw *);
  309. s32 (*valid_led_default)(struct e1000_hw *, u16 *);
  310. };
  311. #define E1000_MAX_SENSORS 3
  312. struct e1000_thermal_diode_data {
  313. u8 location;
  314. u8 temp;
  315. u8 caution_thresh;
  316. u8 max_op_thresh;
  317. };
  318. struct e1000_thermal_sensor_data {
  319. struct e1000_thermal_diode_data sensor[E1000_MAX_SENSORS];
  320. };
  321. struct e1000_info {
  322. s32 (*get_invariants)(struct e1000_hw *);
  323. struct e1000_mac_operations *mac_ops;
  324. const struct e1000_phy_operations *phy_ops;
  325. struct e1000_nvm_operations *nvm_ops;
  326. };
  327. extern const struct e1000_info e1000_82575_info;
  328. struct e1000_mac_info {
  329. struct e1000_mac_operations ops;
  330. u8 addr[6];
  331. u8 perm_addr[6];
  332. enum e1000_mac_type type;
  333. u32 ledctl_default;
  334. u32 ledctl_mode1;
  335. u32 ledctl_mode2;
  336. u32 mc_filter_type;
  337. u32 txcw;
  338. u16 mta_reg_count;
  339. u16 uta_reg_count;
  340. /* Maximum size of the MTA register table in all supported adapters */
  341. #define MAX_MTA_REG 128
  342. u32 mta_shadow[MAX_MTA_REG];
  343. u16 rar_entry_count;
  344. u8 forced_speed_duplex;
  345. bool adaptive_ifs;
  346. bool arc_subsystem_valid;
  347. bool asf_firmware_present;
  348. bool autoneg;
  349. bool autoneg_failed;
  350. bool disable_hw_init_bits;
  351. bool get_link_status;
  352. bool ifs_params_forced;
  353. bool in_ifs_mode;
  354. bool report_tx_early;
  355. bool serdes_has_link;
  356. bool tx_pkt_filtering;
  357. struct e1000_thermal_sensor_data thermal_sensor_data;
  358. };
  359. struct e1000_phy_info {
  360. struct e1000_phy_operations ops;
  361. enum e1000_phy_type type;
  362. enum e1000_1000t_rx_status local_rx;
  363. enum e1000_1000t_rx_status remote_rx;
  364. enum e1000_ms_type ms_type;
  365. enum e1000_ms_type original_ms_type;
  366. enum e1000_rev_polarity cable_polarity;
  367. enum e1000_smart_speed smart_speed;
  368. u32 addr;
  369. u32 id;
  370. u32 reset_delay_us; /* in usec */
  371. u32 revision;
  372. enum e1000_media_type media_type;
  373. u16 autoneg_advertised;
  374. u16 autoneg_mask;
  375. u16 cable_length;
  376. u16 max_cable_length;
  377. u16 min_cable_length;
  378. u16 pair_length[4];
  379. u8 mdix;
  380. bool disable_polarity_correction;
  381. bool is_mdix;
  382. bool polarity_correction;
  383. bool reset_disable;
  384. bool speed_downgraded;
  385. bool autoneg_wait_to_complete;
  386. };
  387. struct e1000_nvm_info {
  388. struct e1000_nvm_operations ops;
  389. enum e1000_nvm_type type;
  390. enum e1000_nvm_override override;
  391. u32 flash_bank_size;
  392. u32 flash_base_addr;
  393. u16 word_size;
  394. u16 delay_usec;
  395. u16 address_bits;
  396. u16 opcode_bits;
  397. u16 page_size;
  398. };
  399. struct e1000_bus_info {
  400. enum e1000_bus_type type;
  401. enum e1000_bus_speed speed;
  402. enum e1000_bus_width width;
  403. u32 snoop;
  404. u16 func;
  405. u16 pci_cmd_word;
  406. };
  407. struct e1000_fc_info {
  408. u32 high_water; /* Flow control high-water mark */
  409. u32 low_water; /* Flow control low-water mark */
  410. u16 pause_time; /* Flow control pause timer */
  411. bool send_xon; /* Flow control send XON */
  412. bool strict_ieee; /* Strict IEEE mode */
  413. enum e1000_fc_mode current_mode; /* Type of flow control */
  414. enum e1000_fc_mode requested_mode;
  415. };
  416. struct e1000_mbx_operations {
  417. s32 (*init_params)(struct e1000_hw *hw);
  418. s32 (*read)(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id,
  419. bool unlock);
  420. s32 (*write)(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id);
  421. s32 (*read_posted)(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id);
  422. s32 (*write_posted)(struct e1000_hw *hw, u32 *msg, u16 size,
  423. u16 mbx_id);
  424. s32 (*check_for_msg)(struct e1000_hw *hw, u16 mbx_id);
  425. s32 (*check_for_ack)(struct e1000_hw *hw, u16 mbx_id);
  426. s32 (*check_for_rst)(struct e1000_hw *hw, u16 mbx_id);
  427. s32 (*unlock)(struct e1000_hw *hw, u16 mbx_id);
  428. };
  429. struct e1000_mbx_stats {
  430. u32 msgs_tx;
  431. u32 msgs_rx;
  432. u32 acks;
  433. u32 reqs;
  434. u32 rsts;
  435. };
  436. struct e1000_mbx_info {
  437. struct e1000_mbx_operations ops;
  438. struct e1000_mbx_stats stats;
  439. u32 timeout;
  440. u32 usec_delay;
  441. u16 size;
  442. };
  443. struct e1000_dev_spec_82575 {
  444. bool sgmii_active;
  445. bool global_device_reset;
  446. bool eee_disable;
  447. bool clear_semaphore_once;
  448. struct e1000_sfp_flags eth_flags;
  449. bool module_plugged;
  450. u8 media_port;
  451. bool media_changed;
  452. bool mas_capable;
  453. };
  454. struct e1000_hw {
  455. void *back;
  456. u8 __iomem *hw_addr;
  457. u8 __iomem *flash_address;
  458. unsigned long io_base;
  459. struct e1000_mac_info mac;
  460. struct e1000_fc_info fc;
  461. struct e1000_phy_info phy;
  462. struct e1000_nvm_info nvm;
  463. struct e1000_bus_info bus;
  464. struct e1000_mbx_info mbx;
  465. struct e1000_host_mng_dhcp_cookie mng_cookie;
  466. union {
  467. struct e1000_dev_spec_82575 _82575;
  468. } dev_spec;
  469. u16 device_id;
  470. u16 subsystem_vendor_id;
  471. u16 subsystem_device_id;
  472. u16 vendor_id;
  473. u8 revision_id;
  474. };
  475. struct net_device *igb_get_hw_dev(struct e1000_hw *hw);
  476. #define hw_dbg(format, arg...) \
  477. netdev_dbg(igb_get_hw_dev(hw), format, ##arg)
  478. /* These functions must be implemented by drivers */
  479. s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
  480. s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
  481. void igb_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value);
  482. void igb_write_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value);
  483. #endif /* _E1000_HW_H_ */