e1000_hw.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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. };
  119. enum e1000_bus_type {
  120. e1000_bus_type_unknown = 0,
  121. e1000_bus_type_pci,
  122. e1000_bus_type_pcix,
  123. e1000_bus_type_pci_express,
  124. e1000_bus_type_reserved
  125. };
  126. enum e1000_bus_speed {
  127. e1000_bus_speed_unknown = 0,
  128. e1000_bus_speed_33,
  129. e1000_bus_speed_66,
  130. e1000_bus_speed_100,
  131. e1000_bus_speed_120,
  132. e1000_bus_speed_133,
  133. e1000_bus_speed_2500,
  134. e1000_bus_speed_5000,
  135. e1000_bus_speed_reserved
  136. };
  137. enum e1000_bus_width {
  138. e1000_bus_width_unknown = 0,
  139. e1000_bus_width_pcie_x1,
  140. e1000_bus_width_pcie_x2,
  141. e1000_bus_width_pcie_x4 = 4,
  142. e1000_bus_width_pcie_x8 = 8,
  143. e1000_bus_width_32,
  144. e1000_bus_width_64,
  145. e1000_bus_width_reserved
  146. };
  147. enum e1000_1000t_rx_status {
  148. e1000_1000t_rx_status_not_ok = 0,
  149. e1000_1000t_rx_status_ok,
  150. e1000_1000t_rx_status_undefined = 0xFF
  151. };
  152. enum e1000_rev_polarity {
  153. e1000_rev_polarity_normal = 0,
  154. e1000_rev_polarity_reversed,
  155. e1000_rev_polarity_undefined = 0xFF
  156. };
  157. enum e1000_fc_mode {
  158. e1000_fc_none = 0,
  159. e1000_fc_rx_pause,
  160. e1000_fc_tx_pause,
  161. e1000_fc_full,
  162. e1000_fc_default = 0xFF
  163. };
  164. /* Statistics counters collected by the MAC */
  165. struct e1000_hw_stats {
  166. u64 crcerrs;
  167. u64 algnerrc;
  168. u64 symerrs;
  169. u64 rxerrc;
  170. u64 mpc;
  171. u64 scc;
  172. u64 ecol;
  173. u64 mcc;
  174. u64 latecol;
  175. u64 colc;
  176. u64 dc;
  177. u64 tncrs;
  178. u64 sec;
  179. u64 cexterr;
  180. u64 rlec;
  181. u64 xonrxc;
  182. u64 xontxc;
  183. u64 xoffrxc;
  184. u64 xofftxc;
  185. u64 fcruc;
  186. u64 prc64;
  187. u64 prc127;
  188. u64 prc255;
  189. u64 prc511;
  190. u64 prc1023;
  191. u64 prc1522;
  192. u64 gprc;
  193. u64 bprc;
  194. u64 mprc;
  195. u64 gptc;
  196. u64 gorc;
  197. u64 gotc;
  198. u64 rnbc;
  199. u64 ruc;
  200. u64 rfc;
  201. u64 roc;
  202. u64 rjc;
  203. u64 mgprc;
  204. u64 mgpdc;
  205. u64 mgptc;
  206. u64 tor;
  207. u64 tot;
  208. u64 tpr;
  209. u64 tpt;
  210. u64 ptc64;
  211. u64 ptc127;
  212. u64 ptc255;
  213. u64 ptc511;
  214. u64 ptc1023;
  215. u64 ptc1522;
  216. u64 mptc;
  217. u64 bptc;
  218. u64 tsctc;
  219. u64 tsctfc;
  220. u64 iac;
  221. u64 icrxptc;
  222. u64 icrxatc;
  223. u64 ictxptc;
  224. u64 ictxatc;
  225. u64 ictxqec;
  226. u64 ictxqmtc;
  227. u64 icrxdmtc;
  228. u64 icrxoc;
  229. u64 cbtmpc;
  230. u64 htdpmc;
  231. u64 cbrdpc;
  232. u64 cbrmpc;
  233. u64 rpthc;
  234. u64 hgptc;
  235. u64 htcbdpc;
  236. u64 hgorc;
  237. u64 hgotc;
  238. u64 lenerrs;
  239. u64 scvpc;
  240. u64 hrmpc;
  241. u64 doosync;
  242. u64 o2bgptc;
  243. u64 o2bspc;
  244. u64 b2ospc;
  245. u64 b2ogprc;
  246. };
  247. struct e1000_host_mng_dhcp_cookie {
  248. u32 signature;
  249. u8 status;
  250. u8 reserved0;
  251. u16 vlan_id;
  252. u32 reserved1;
  253. u16 reserved2;
  254. u8 reserved3;
  255. u8 checksum;
  256. };
  257. /* Host Interface "Rev 1" */
  258. struct e1000_host_command_header {
  259. u8 command_id;
  260. u8 command_length;
  261. u8 command_options;
  262. u8 checksum;
  263. };
  264. #define E1000_HI_MAX_DATA_LENGTH 252
  265. struct e1000_host_command_info {
  266. struct e1000_host_command_header command_header;
  267. u8 command_data[E1000_HI_MAX_DATA_LENGTH];
  268. };
  269. /* Host Interface "Rev 2" */
  270. struct e1000_host_mng_command_header {
  271. u8 command_id;
  272. u8 checksum;
  273. u16 reserved1;
  274. u16 reserved2;
  275. u16 command_length;
  276. };
  277. #define E1000_HI_MAX_MNG_DATA_LENGTH 0x6F8
  278. struct e1000_host_mng_command_info {
  279. struct e1000_host_mng_command_header command_header;
  280. u8 command_data[E1000_HI_MAX_MNG_DATA_LENGTH];
  281. };
  282. #include "e1000_mac.h"
  283. #include "e1000_phy.h"
  284. #include "e1000_nvm.h"
  285. #include "e1000_mbx.h"
  286. struct e1000_mac_operations {
  287. s32 (*check_for_link)(struct e1000_hw *);
  288. s32 (*reset_hw)(struct e1000_hw *);
  289. s32 (*init_hw)(struct e1000_hw *);
  290. bool (*check_mng_mode)(struct e1000_hw *);
  291. s32 (*setup_physical_interface)(struct e1000_hw *);
  292. void (*rar_set)(struct e1000_hw *, u8 *, u32);
  293. s32 (*read_mac_addr)(struct e1000_hw *);
  294. s32 (*get_speed_and_duplex)(struct e1000_hw *, u16 *, u16 *);
  295. s32 (*acquire_swfw_sync)(struct e1000_hw *, u16);
  296. void (*release_swfw_sync)(struct e1000_hw *, u16);
  297. #ifdef CONFIG_IGB_HWMON
  298. s32 (*get_thermal_sensor_data)(struct e1000_hw *);
  299. s32 (*init_thermal_sensor_thresh)(struct e1000_hw *);
  300. #endif
  301. void (*write_vfta)(struct e1000_hw *, u32, u32);
  302. };
  303. struct e1000_phy_operations {
  304. s32 (*acquire)(struct e1000_hw *);
  305. s32 (*check_polarity)(struct e1000_hw *);
  306. s32 (*check_reset_block)(struct e1000_hw *);
  307. s32 (*force_speed_duplex)(struct e1000_hw *);
  308. s32 (*get_cfg_done)(struct e1000_hw *hw);
  309. s32 (*get_cable_length)(struct e1000_hw *);
  310. s32 (*get_phy_info)(struct e1000_hw *);
  311. s32 (*read_reg)(struct e1000_hw *, u32, u16 *);
  312. void (*release)(struct e1000_hw *);
  313. s32 (*reset)(struct e1000_hw *);
  314. s32 (*set_d0_lplu_state)(struct e1000_hw *, bool);
  315. s32 (*set_d3_lplu_state)(struct e1000_hw *, bool);
  316. s32 (*write_reg)(struct e1000_hw *, u32, u16);
  317. s32 (*read_i2c_byte)(struct e1000_hw *, u8, u8, u8 *);
  318. s32 (*write_i2c_byte)(struct e1000_hw *, u8, u8, u8);
  319. };
  320. struct e1000_nvm_operations {
  321. s32 (*acquire)(struct e1000_hw *);
  322. s32 (*read)(struct e1000_hw *, u16, u16, u16 *);
  323. void (*release)(struct e1000_hw *);
  324. s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
  325. s32 (*update)(struct e1000_hw *);
  326. s32 (*validate)(struct e1000_hw *);
  327. s32 (*valid_led_default)(struct e1000_hw *, u16 *);
  328. };
  329. #define E1000_MAX_SENSORS 3
  330. struct e1000_thermal_diode_data {
  331. u8 location;
  332. u8 temp;
  333. u8 caution_thresh;
  334. u8 max_op_thresh;
  335. };
  336. struct e1000_thermal_sensor_data {
  337. struct e1000_thermal_diode_data sensor[E1000_MAX_SENSORS];
  338. };
  339. struct e1000_info {
  340. s32 (*get_invariants)(struct e1000_hw *);
  341. struct e1000_mac_operations *mac_ops;
  342. const struct e1000_phy_operations *phy_ops;
  343. struct e1000_nvm_operations *nvm_ops;
  344. };
  345. extern const struct e1000_info e1000_82575_info;
  346. struct e1000_mac_info {
  347. struct e1000_mac_operations ops;
  348. u8 addr[6];
  349. u8 perm_addr[6];
  350. enum e1000_mac_type type;
  351. u32 ledctl_default;
  352. u32 ledctl_mode1;
  353. u32 ledctl_mode2;
  354. u32 mc_filter_type;
  355. u32 txcw;
  356. u16 mta_reg_count;
  357. u16 uta_reg_count;
  358. /* Maximum size of the MTA register table in all supported adapters */
  359. #define MAX_MTA_REG 128
  360. u32 mta_shadow[MAX_MTA_REG];
  361. u16 rar_entry_count;
  362. u8 forced_speed_duplex;
  363. bool adaptive_ifs;
  364. bool arc_subsystem_valid;
  365. bool asf_firmware_present;
  366. bool autoneg;
  367. bool autoneg_failed;
  368. bool disable_hw_init_bits;
  369. bool get_link_status;
  370. bool ifs_params_forced;
  371. bool in_ifs_mode;
  372. bool report_tx_early;
  373. bool serdes_has_link;
  374. bool tx_pkt_filtering;
  375. struct e1000_thermal_sensor_data thermal_sensor_data;
  376. };
  377. struct e1000_phy_info {
  378. struct e1000_phy_operations ops;
  379. enum e1000_phy_type type;
  380. enum e1000_1000t_rx_status local_rx;
  381. enum e1000_1000t_rx_status remote_rx;
  382. enum e1000_ms_type ms_type;
  383. enum e1000_ms_type original_ms_type;
  384. enum e1000_rev_polarity cable_polarity;
  385. enum e1000_smart_speed smart_speed;
  386. u32 addr;
  387. u32 id;
  388. u32 reset_delay_us; /* in usec */
  389. u32 revision;
  390. enum e1000_media_type media_type;
  391. u16 autoneg_advertised;
  392. u16 autoneg_mask;
  393. u16 cable_length;
  394. u16 max_cable_length;
  395. u16 min_cable_length;
  396. u16 pair_length[4];
  397. u8 mdix;
  398. bool disable_polarity_correction;
  399. bool is_mdix;
  400. bool polarity_correction;
  401. bool reset_disable;
  402. bool speed_downgraded;
  403. bool autoneg_wait_to_complete;
  404. };
  405. struct e1000_nvm_info {
  406. struct e1000_nvm_operations ops;
  407. enum e1000_nvm_type type;
  408. enum e1000_nvm_override override;
  409. u32 flash_bank_size;
  410. u32 flash_base_addr;
  411. u16 word_size;
  412. u16 delay_usec;
  413. u16 address_bits;
  414. u16 opcode_bits;
  415. u16 page_size;
  416. };
  417. struct e1000_bus_info {
  418. enum e1000_bus_type type;
  419. enum e1000_bus_speed speed;
  420. enum e1000_bus_width width;
  421. u32 snoop;
  422. u16 func;
  423. u16 pci_cmd_word;
  424. };
  425. struct e1000_fc_info {
  426. u32 high_water; /* Flow control high-water mark */
  427. u32 low_water; /* Flow control low-water mark */
  428. u16 pause_time; /* Flow control pause timer */
  429. bool send_xon; /* Flow control send XON */
  430. bool strict_ieee; /* Strict IEEE mode */
  431. enum e1000_fc_mode current_mode; /* Type of flow control */
  432. enum e1000_fc_mode requested_mode;
  433. };
  434. struct e1000_mbx_operations {
  435. s32 (*init_params)(struct e1000_hw *hw);
  436. s32 (*read)(struct e1000_hw *, u32 *, u16, u16);
  437. s32 (*write)(struct e1000_hw *, u32 *, u16, u16);
  438. s32 (*read_posted)(struct e1000_hw *, u32 *, u16, u16);
  439. s32 (*write_posted)(struct e1000_hw *, u32 *, u16, u16);
  440. s32 (*check_for_msg)(struct e1000_hw *, u16);
  441. s32 (*check_for_ack)(struct e1000_hw *, u16);
  442. s32 (*check_for_rst)(struct e1000_hw *, u16);
  443. };
  444. struct e1000_mbx_stats {
  445. u32 msgs_tx;
  446. u32 msgs_rx;
  447. u32 acks;
  448. u32 reqs;
  449. u32 rsts;
  450. };
  451. struct e1000_mbx_info {
  452. struct e1000_mbx_operations ops;
  453. struct e1000_mbx_stats stats;
  454. u32 timeout;
  455. u32 usec_delay;
  456. u16 size;
  457. };
  458. struct e1000_dev_spec_82575 {
  459. bool sgmii_active;
  460. bool global_device_reset;
  461. bool eee_disable;
  462. bool clear_semaphore_once;
  463. struct e1000_sfp_flags eth_flags;
  464. bool module_plugged;
  465. u8 media_port;
  466. bool media_changed;
  467. bool mas_capable;
  468. };
  469. struct e1000_hw {
  470. void *back;
  471. u8 __iomem *hw_addr;
  472. u8 __iomem *flash_address;
  473. unsigned long io_base;
  474. struct e1000_mac_info mac;
  475. struct e1000_fc_info fc;
  476. struct e1000_phy_info phy;
  477. struct e1000_nvm_info nvm;
  478. struct e1000_bus_info bus;
  479. struct e1000_mbx_info mbx;
  480. struct e1000_host_mng_dhcp_cookie mng_cookie;
  481. union {
  482. struct e1000_dev_spec_82575 _82575;
  483. } dev_spec;
  484. u16 device_id;
  485. u16 subsystem_vendor_id;
  486. u16 subsystem_device_id;
  487. u16 vendor_id;
  488. u8 revision_id;
  489. };
  490. struct net_device *igb_get_hw_dev(struct e1000_hw *hw);
  491. #define hw_dbg(format, arg...) \
  492. netdev_dbg(igb_get_hw_dev(hw), format, ##arg)
  493. /* These functions must be implemented by drivers */
  494. s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
  495. s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
  496. void igb_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value);
  497. void igb_write_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value);
  498. #endif /* _E1000_HW_H_ */