e1000_hw.h 13 KB

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