e1000_hw.h 13 KB

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