1 /*******************************************************************************
3 Intel(R) Gigabit Ethernet Linux driver
4 Copyright(c) 2007-2012 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
31 #include "e1000_osdep.h"
32 #include "e1000_regs.h"
33 #include "e1000_defines.h"
37 #define E1000_DEV_ID_82576 0x10C9
38 #define E1000_DEV_ID_82576_FIBER 0x10E6
39 #define E1000_DEV_ID_82576_SERDES 0x10E7
40 #define E1000_DEV_ID_82576_QUAD_COPPER 0x10E8
41 #define E1000_DEV_ID_82576_QUAD_COPPER_ET2 0x1526
42 #define E1000_DEV_ID_82576_NS 0x150A
43 #define E1000_DEV_ID_82576_NS_SERDES 0x1518
44 #define E1000_DEV_ID_82576_SERDES_QUAD 0x150D
45 #define E1000_DEV_ID_82575EB_COPPER 0x10A7
46 #define E1000_DEV_ID_82575EB_FIBER_SERDES 0x10A9
47 #define E1000_DEV_ID_82575GB_QUAD_COPPER 0x10D6
48 #define E1000_DEV_ID_82580_COPPER 0x150E
49 #define E1000_DEV_ID_82580_FIBER 0x150F
50 #define E1000_DEV_ID_82580_SERDES 0x1510
51 #define E1000_DEV_ID_82580_SGMII 0x1511
52 #define E1000_DEV_ID_82580_COPPER_DUAL 0x1516
53 #define E1000_DEV_ID_82580_QUAD_FIBER 0x1527
54 #define E1000_DEV_ID_I350_COPPER 0x1521
55 #define E1000_DEV_ID_I350_FIBER 0x1522
56 #define E1000_DEV_ID_I350_SERDES 0x1523
57 #define E1000_DEV_ID_I350_SGMII 0x1524
58 #define E1000_DEV_ID_I350_DA4 0x1546
59 #define E1000_DEV_ID_I354_BACKPLANE_1GBPS 0x1F40
60 #define E1000_DEV_ID_I354_SGMII 0x1F41
61 #define E1000_DEV_ID_I354_BACKPLANE_2_5GBPS 0x1F45
62 #define E1000_DEV_ID_DH89XXCC_SGMII 0x0438
63 #define E1000_DEV_ID_DH89XXCC_SERDES 0x043A
64 #define E1000_DEV_ID_DH89XXCC_BACKPLANE 0x043C
65 #define E1000_DEV_ID_DH89XXCC_SFP 0x0440
66 #define E1000_REVISION_0 0
67 #define E1000_REVISION_1 1
68 #define E1000_REVISION_2 2
69 #define E1000_REVISION_3 3
70 #define E1000_REVISION_4 4
72 #define E1000_FUNC_0 0
73 #define E1000_FUNC_1 1
74 #define E1000_FUNC_2 2
75 #define E1000_FUNC_3 3
77 #define E1000_ALT_MAC_ADDRESS_OFFSET_LAN0 0
78 #define E1000_ALT_MAC_ADDRESS_OFFSET_LAN1 3
79 #define E1000_ALT_MAC_ADDRESS_OFFSET_LAN2 6
80 #define E1000_ALT_MAC_ADDRESS_OFFSET_LAN3 9
89 e1000_num_macs /* List is 1-based, so subtract 1 for true count. */
92 enum e1000_media_type {
93 e1000_media_type_unknown = 0,
94 e1000_media_type_copper = 1,
95 e1000_media_type_fiber = 2,
96 e1000_media_type_internal_serdes = 3,
100 enum e1000_nvm_type {
101 e1000_nvm_unknown = 0,
103 e1000_nvm_eeprom_spi,
108 enum e1000_nvm_override {
109 e1000_nvm_override_none = 0,
110 e1000_nvm_override_spi_small,
111 e1000_nvm_override_spi_large,
114 enum e1000_phy_type {
115 e1000_phy_unknown = 0,
127 enum e1000_bus_type {
128 e1000_bus_type_unknown = 0,
131 e1000_bus_type_pci_express,
132 e1000_bus_type_reserved
135 enum e1000_bus_speed {
136 e1000_bus_speed_unknown = 0,
142 e1000_bus_speed_2500,
143 e1000_bus_speed_5000,
144 e1000_bus_speed_reserved
147 enum e1000_bus_width {
148 e1000_bus_width_unknown = 0,
149 e1000_bus_width_pcie_x1,
150 e1000_bus_width_pcie_x2,
151 e1000_bus_width_pcie_x4 = 4,
152 e1000_bus_width_pcie_x8 = 8,
155 e1000_bus_width_reserved
158 enum e1000_1000t_rx_status {
159 e1000_1000t_rx_status_not_ok = 0,
160 e1000_1000t_rx_status_ok,
161 e1000_1000t_rx_status_undefined = 0xFF
164 enum e1000_rev_polarity {
165 e1000_rev_polarity_normal = 0,
166 e1000_rev_polarity_reversed,
167 e1000_rev_polarity_undefined = 0xFF
175 e1000_fc_default = 0xFF
179 e1000_ms_hw_default = 0,
180 e1000_ms_force_master,
181 e1000_ms_force_slave,
185 enum e1000_smart_speed {
186 e1000_smart_speed_default = 0,
187 e1000_smart_speed_on,
188 e1000_smart_speed_off
191 enum e1000_serdes_link_state {
192 e1000_serdes_link_down = 0,
193 e1000_serdes_link_autoneg_progress,
194 e1000_serdes_link_autoneg_complete,
195 e1000_serdes_link_forced_up
207 /* Receive Descriptor */
208 struct e1000_rx_desc {
209 __le64 buffer_addr; /* Address of the descriptor's data buffer */
210 __le16 length; /* Length of data DMAed into data buffer */
211 __le16 csum; /* Packet checksum */
212 u8 status; /* Descriptor status */
213 u8 errors; /* Descriptor Errors */
217 /* Receive Descriptor - Extended */
218 union e1000_rx_desc_extended {
225 __le32 mrq; /* Multiple Rx Queues */
227 __le32 rss; /* RSS Hash */
229 __le16 ip_id; /* IP id */
230 __le16 csum; /* Packet Checksum */
235 __le32 status_error; /* ext status/error */
237 __le16 vlan; /* VLAN tag */
239 } wb; /* writeback */
242 #define MAX_PS_BUFFERS 4
243 /* Receive Descriptor - Packet Split */
244 union e1000_rx_desc_packet_split {
246 /* one buffer for protocol header(s), three data buffers */
247 __le64 buffer_addr[MAX_PS_BUFFERS];
251 __le32 mrq; /* Multiple Rx Queues */
253 __le32 rss; /* RSS Hash */
255 __le16 ip_id; /* IP id */
256 __le16 csum; /* Packet Checksum */
261 __le32 status_error; /* ext status/error */
262 __le16 length0; /* length of buffer 0 */
263 __le16 vlan; /* VLAN tag */
266 __le16 header_status;
267 __le16 length[3]; /* length of buffers 1-3 */
270 } wb; /* writeback */
273 /* Transmit Descriptor */
274 struct e1000_tx_desc {
275 __le64 buffer_addr; /* Address of the descriptor's data buffer */
279 __le16 length; /* Data buffer length */
280 u8 cso; /* Checksum offset */
281 u8 cmd; /* Descriptor control */
287 u8 status; /* Descriptor status */
288 u8 css; /* Checksum start */
294 /* Offload Context Descriptor */
295 struct e1000_context_desc {
299 u8 ipcss; /* IP checksum start */
300 u8 ipcso; /* IP checksum offset */
301 __le16 ipcse; /* IP checksum end */
307 u8 tucss; /* TCP checksum start */
308 u8 tucso; /* TCP checksum offset */
309 __le16 tucse; /* TCP checksum end */
312 __le32 cmd_and_length;
316 u8 status; /* Descriptor status */
317 u8 hdr_len; /* Header length */
318 __le16 mss; /* Maximum segment size */
323 /* Offload data descriptor */
324 struct e1000_data_desc {
325 __le64 buffer_addr; /* Address of the descriptor's buffer address */
329 __le16 length; /* Data buffer length */
337 u8 status; /* Descriptor status */
338 u8 popts; /* Packet Options */
344 /* Statistics counters collected by the MAC */
345 struct e1000_hw_stats {
429 struct e1000_phy_stats {
434 struct e1000_host_mng_dhcp_cookie {
445 /* Host Interface "Rev 1" */
446 struct e1000_host_command_header {
453 #define E1000_HI_MAX_DATA_LENGTH 252
454 struct e1000_host_command_info {
455 struct e1000_host_command_header command_header;
456 u8 command_data[E1000_HI_MAX_DATA_LENGTH];
459 /* Host Interface "Rev 2" */
460 struct e1000_host_mng_command_header {
468 #define E1000_HI_MAX_MNG_DATA_LENGTH 0x6F8
469 struct e1000_host_mng_command_info {
470 struct e1000_host_mng_command_header command_header;
471 u8 command_data[E1000_HI_MAX_MNG_DATA_LENGTH];
474 #include "e1000_mac.h"
475 #include "e1000_phy.h"
476 #include "e1000_nvm.h"
477 #include "e1000_manage.h"
478 #include "e1000_mbx.h"
480 struct e1000_mac_operations {
481 /* Function pointers for the MAC. */
482 s32 (*init_params)(struct e1000_hw *);
483 s32 (*id_led_init)(struct e1000_hw *);
484 s32 (*blink_led)(struct e1000_hw *);
485 s32 (*check_for_link)(struct e1000_hw *);
486 bool (*check_mng_mode)(struct e1000_hw *hw);
487 s32 (*cleanup_led)(struct e1000_hw *);
488 void (*clear_hw_cntrs)(struct e1000_hw *);
489 void (*clear_vfta)(struct e1000_hw *);
490 s32 (*get_bus_info)(struct e1000_hw *);
491 void (*set_lan_id)(struct e1000_hw *);
492 s32 (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
493 s32 (*led_on)(struct e1000_hw *);
494 s32 (*led_off)(struct e1000_hw *);
495 void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
496 s32 (*reset_hw)(struct e1000_hw *);
497 s32 (*init_hw)(struct e1000_hw *);
498 void (*shutdown_serdes)(struct e1000_hw *);
499 void (*power_up_serdes)(struct e1000_hw *);
500 s32 (*setup_link)(struct e1000_hw *);
501 s32 (*setup_physical_interface)(struct e1000_hw *);
502 s32 (*setup_led)(struct e1000_hw *);
503 void (*write_vfta)(struct e1000_hw *, u32, u32);
504 void (*config_collision_dist)(struct e1000_hw *);
505 void (*rar_set)(struct e1000_hw *, u8*, u32);
506 s32 (*read_mac_addr)(struct e1000_hw *);
507 s32 (*validate_mdi_setting)(struct e1000_hw *);
508 s32 (*mng_host_if_write)(struct e1000_hw *, u8*, u16, u16, u8*);
509 s32 (*mng_write_cmd_header)(struct e1000_hw *hw,
510 struct e1000_host_mng_command_header*);
511 s32 (*mng_enable_host_if)(struct e1000_hw *);
512 s32 (*wait_autoneg)(struct e1000_hw *);
513 s32 (*get_thermal_sensor_data)(struct e1000_hw *);
514 s32 (*init_thermal_sensor_thresh)(struct e1000_hw *);
515 s32 (*acquire_swfw_sync)(struct e1000_hw *, u16);
516 void (*release_swfw_sync)(struct e1000_hw *, u16);
520 * When to use various PHY register access functions:
523 * Function Does Does When to use
524 * ~~~~~~~~~~~~ ~~~~~ ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
525 * X_reg L,P,A n/a for simple PHY reg accesses
526 * X_reg_locked P,A L for multiple accesses of different regs
528 * X_reg_page A L,P for multiple accesses of different regs
531 * Where X=[read|write], L=locking, P=sets page, A=register access
534 struct e1000_phy_operations {
535 s32 (*init_params)(struct e1000_hw *);
536 s32 (*acquire)(struct e1000_hw *);
537 s32 (*check_polarity)(struct e1000_hw *);
538 s32 (*check_reset_block)(struct e1000_hw *);
539 s32 (*commit)(struct e1000_hw *);
540 s32 (*force_speed_duplex)(struct e1000_hw *);
541 s32 (*get_cfg_done)(struct e1000_hw *hw);
542 s32 (*get_cable_length)(struct e1000_hw *);
543 s32 (*get_info)(struct e1000_hw *);
544 s32 (*set_page)(struct e1000_hw *, u16);
545 s32 (*read_reg)(struct e1000_hw *, u32, u16 *);
546 s32 (*read_reg_locked)(struct e1000_hw *, u32, u16 *);
547 s32 (*read_reg_page)(struct e1000_hw *, u32, u16 *);
548 void (*release)(struct e1000_hw *);
549 s32 (*reset)(struct e1000_hw *);
550 s32 (*set_d0_lplu_state)(struct e1000_hw *, bool);
551 s32 (*set_d3_lplu_state)(struct e1000_hw *, bool);
552 s32 (*write_reg)(struct e1000_hw *, u32, u16);
553 s32 (*write_reg_locked)(struct e1000_hw *, u32, u16);
554 s32 (*write_reg_page)(struct e1000_hw *, u32, u16);
555 void (*power_up)(struct e1000_hw *);
556 void (*power_down)(struct e1000_hw *);
557 s32 (*read_i2c_byte)(struct e1000_hw *, u8, u8, u8 *);
558 s32 (*write_i2c_byte)(struct e1000_hw *, u8, u8, u8);
561 struct e1000_nvm_operations {
562 s32 (*init_params)(struct e1000_hw *);
563 s32 (*acquire)(struct e1000_hw *);
564 s32 (*read)(struct e1000_hw *, u16, u16, u16 *);
565 void (*release)(struct e1000_hw *);
566 void (*reload)(struct e1000_hw *);
567 s32 (*update)(struct e1000_hw *);
568 s32 (*valid_led_default)(struct e1000_hw *, u16 *);
569 s32 (*validate)(struct e1000_hw *);
570 s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
573 #define E1000_MAX_SENSORS 3
575 struct e1000_thermal_diode_data {
582 struct e1000_thermal_sensor_data {
583 struct e1000_thermal_diode_data sensor[E1000_MAX_SENSORS];
586 struct e1000_mac_info {
587 struct e1000_mac_operations ops;
588 u8 addr[ETH_ADDR_LEN];
589 u8 perm_addr[ETH_ADDR_LEN];
591 enum e1000_mac_type type;
609 /* Maximum size of the MTA register table in all supported adapters */
610 #define MAX_MTA_REG 128
611 u32 mta_shadow[MAX_MTA_REG];
614 u8 forced_speed_duplex;
618 bool arc_subsystem_valid;
619 bool asf_firmware_present;
622 bool get_link_status;
624 enum e1000_serdes_link_state serdes_link_state;
625 bool serdes_has_link;
626 bool tx_pkt_filtering;
627 struct e1000_thermal_sensor_data thermal_sensor_data;
630 struct e1000_phy_info {
631 struct e1000_phy_operations ops;
632 enum e1000_phy_type type;
634 enum e1000_1000t_rx_status local_rx;
635 enum e1000_1000t_rx_status remote_rx;
636 enum e1000_ms_type ms_type;
637 enum e1000_ms_type original_ms_type;
638 enum e1000_rev_polarity cable_polarity;
639 enum e1000_smart_speed smart_speed;
643 u32 reset_delay_us; /* in usec */
646 enum e1000_media_type media_type;
648 u16 autoneg_advertised;
651 u16 max_cable_length;
652 u16 min_cable_length;
656 bool disable_polarity_correction;
658 bool polarity_correction;
660 bool speed_downgraded;
661 bool autoneg_wait_to_complete;
664 struct e1000_nvm_info {
665 struct e1000_nvm_operations ops;
666 enum e1000_nvm_type type;
667 enum e1000_nvm_override override;
679 struct e1000_bus_info {
680 enum e1000_bus_type type;
681 enum e1000_bus_speed speed;
682 enum e1000_bus_width width;
688 struct e1000_fc_info {
689 u32 high_water; /* Flow control high-water mark */
690 u32 low_water; /* Flow control low-water mark */
691 u16 pause_time; /* Flow control pause timer */
692 u16 refresh_time; /* Flow control refresh timer */
693 bool send_xon; /* Flow control send XON */
694 bool strict_ieee; /* Strict IEEE mode */
695 enum e1000_fc_mode current_mode; /* FC mode in effect */
696 enum e1000_fc_mode requested_mode; /* FC mode requested by caller */
699 struct e1000_mbx_operations {
700 s32 (*init_params)(struct e1000_hw *hw);
701 s32 (*read)(struct e1000_hw *, u32 *, u16, u16);
702 s32 (*write)(struct e1000_hw *, u32 *, u16, u16);
703 s32 (*read_posted)(struct e1000_hw *, u32 *, u16, u16);
704 s32 (*write_posted)(struct e1000_hw *, u32 *, u16, u16);
705 s32 (*check_for_msg)(struct e1000_hw *, u16);
706 s32 (*check_for_ack)(struct e1000_hw *, u16);
707 s32 (*check_for_rst)(struct e1000_hw *, u16);
710 struct e1000_mbx_stats {
719 struct e1000_mbx_info {
720 struct e1000_mbx_operations ops;
721 struct e1000_mbx_stats stats;
727 struct e1000_dev_spec_82575 {
729 bool global_device_reset;
735 struct e1000_dev_spec_vf {
744 u8 __iomem *flash_address;
745 unsigned long io_base;
747 struct e1000_mac_info mac;
748 struct e1000_fc_info fc;
749 struct e1000_phy_info phy;
750 struct e1000_nvm_info nvm;
751 struct e1000_bus_info bus;
752 struct e1000_mbx_info mbx;
753 struct e1000_host_mng_dhcp_cookie mng_cookie;
756 struct e1000_dev_spec_82575 _82575;
757 struct e1000_dev_spec_vf vf;
761 u16 subsystem_vendor_id;
762 u16 subsystem_device_id;
768 #include "e1000_82575.h"
770 /* These functions must be implemented by drivers */
771 s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
772 s32 e1000_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);