00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 FILE_LICENCE ( GPL2_OR_LATER );
00030
00031 #ifndef _E1000_HW_H_
00032 #define _E1000_HW_H_
00033
00034 #include "e1000_osdep.h"
00035 #include "e1000_regs.h"
00036 #include "e1000_defines.h"
00037
00038 struct e1000_hw;
00039
00040 #define E1000_DEV_ID_82542 0x1000
00041 #define E1000_DEV_ID_82543GC_FIBER 0x1001
00042 #define E1000_DEV_ID_82543GC_COPPER 0x1004
00043 #define E1000_DEV_ID_82544EI_COPPER 0x1008
00044 #define E1000_DEV_ID_82544EI_FIBER 0x1009
00045 #define E1000_DEV_ID_82544GC_COPPER 0x100C
00046 #define E1000_DEV_ID_82544GC_LOM 0x100D
00047 #define E1000_DEV_ID_82540EM 0x100E
00048 #define E1000_DEV_ID_82540EM_LOM 0x1015
00049 #define E1000_DEV_ID_82540EP_LOM 0x1016
00050 #define E1000_DEV_ID_82540EP 0x1017
00051 #define E1000_DEV_ID_82540EP_LP 0x101E
00052 #define E1000_DEV_ID_82545EM_COPPER 0x100F
00053 #define E1000_DEV_ID_82545EM_FIBER 0x1011
00054 #define E1000_DEV_ID_82545GM_COPPER 0x1026
00055 #define E1000_DEV_ID_82545GM_FIBER 0x1027
00056 #define E1000_DEV_ID_82545GM_SERDES 0x1028
00057 #define E1000_DEV_ID_82546EB_COPPER 0x1010
00058 #define E1000_DEV_ID_82546EB_FIBER 0x1012
00059 #define E1000_DEV_ID_82546EB_QUAD_COPPER 0x101D
00060 #define E1000_DEV_ID_82546GB_COPPER 0x1079
00061 #define E1000_DEV_ID_82546GB_FIBER 0x107A
00062 #define E1000_DEV_ID_82546GB_SERDES 0x107B
00063 #define E1000_DEV_ID_82546GB_PCIE 0x108A
00064 #define E1000_DEV_ID_82546GB_QUAD_COPPER 0x1099
00065 #define E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3 0x10B5
00066 #define E1000_DEV_ID_82541EI 0x1013
00067 #define E1000_DEV_ID_82541EI_MOBILE 0x1018
00068 #define E1000_DEV_ID_82541ER_LOM 0x1014
00069 #define E1000_DEV_ID_82541ER 0x1078
00070 #define E1000_DEV_ID_82541GI 0x1076
00071 #define E1000_DEV_ID_82541GI_LF 0x107C
00072 #define E1000_DEV_ID_82541GI_MOBILE 0x1077
00073 #define E1000_DEV_ID_82547EI 0x1019
00074 #define E1000_DEV_ID_82547EI_MOBILE 0x101A
00075 #define E1000_DEV_ID_82547GI 0x1075
00076 #define E1000_REVISION_0 0
00077 #define E1000_REVISION_1 1
00078 #define E1000_REVISION_2 2
00079 #define E1000_REVISION_3 3
00080 #define E1000_REVISION_4 4
00081
00082 #define E1000_FUNC_0 0
00083 #define E1000_FUNC_1 1
00084
00085 #define E1000_ALT_MAC_ADDRESS_OFFSET_LAN0 0
00086 #define E1000_ALT_MAC_ADDRESS_OFFSET_LAN1 3
00087
00088 enum e1000_mac_type {
00089 e1000_undefined = 0,
00090 e1000_82542,
00091 e1000_82543,
00092 e1000_82544,
00093 e1000_82540,
00094 e1000_82545,
00095 e1000_82545_rev_3,
00096 e1000_82546,
00097 e1000_82546_rev_3,
00098 e1000_82541,
00099 e1000_82541_rev_2,
00100 e1000_82547,
00101 e1000_82547_rev_2,
00102 e1000_num_macs
00103 };
00104
00105 enum e1000_media_type {
00106 e1000_media_type_unknown = 0,
00107 e1000_media_type_copper = 1,
00108 e1000_media_type_fiber = 2,
00109 e1000_media_type_internal_serdes = 3,
00110 e1000_num_media_types
00111 };
00112
00113 enum e1000_nvm_type {
00114 e1000_nvm_unknown = 0,
00115 e1000_nvm_none,
00116 e1000_nvm_eeprom_spi,
00117 e1000_nvm_eeprom_microwire,
00118 e1000_nvm_flash_hw,
00119 e1000_nvm_flash_sw
00120 };
00121
00122 enum e1000_nvm_override {
00123 e1000_nvm_override_none = 0,
00124 e1000_nvm_override_spi_small,
00125 e1000_nvm_override_spi_large,
00126 e1000_nvm_override_microwire_small,
00127 e1000_nvm_override_microwire_large
00128 };
00129
00130 enum e1000_phy_type {
00131 e1000_phy_unknown = 0,
00132 e1000_phy_none,
00133 e1000_phy_m88,
00134 e1000_phy_igp,
00135 e1000_phy_igp_2,
00136 e1000_phy_gg82563,
00137 e1000_phy_igp_3,
00138 e1000_phy_ife,
00139 };
00140
00141 enum e1000_bus_type {
00142 e1000_bus_type_unknown = 0,
00143 e1000_bus_type_pci,
00144 e1000_bus_type_pcix,
00145 e1000_bus_type_pci_express,
00146 e1000_bus_type_reserved
00147 };
00148
00149 enum e1000_bus_speed {
00150 e1000_bus_speed_unknown = 0,
00151 e1000_bus_speed_33,
00152 e1000_bus_speed_66,
00153 e1000_bus_speed_100,
00154 e1000_bus_speed_120,
00155 e1000_bus_speed_133,
00156 e1000_bus_speed_2500,
00157 e1000_bus_speed_5000,
00158 e1000_bus_speed_reserved
00159 };
00160
00161 enum e1000_bus_width {
00162 e1000_bus_width_unknown = 0,
00163 e1000_bus_width_pcie_x1,
00164 e1000_bus_width_pcie_x2,
00165 e1000_bus_width_pcie_x4 = 4,
00166 e1000_bus_width_pcie_x8 = 8,
00167 e1000_bus_width_32,
00168 e1000_bus_width_64,
00169 e1000_bus_width_reserved
00170 };
00171
00172 enum e1000_1000t_rx_status {
00173 e1000_1000t_rx_status_not_ok = 0,
00174 e1000_1000t_rx_status_ok,
00175 e1000_1000t_rx_status_undefined = 0xFF
00176 };
00177
00178 enum e1000_rev_polarity {
00179 e1000_rev_polarity_normal = 0,
00180 e1000_rev_polarity_reversed,
00181 e1000_rev_polarity_undefined = 0xFF
00182 };
00183
00184 enum e1000_fc_mode {
00185 e1000_fc_none = 0,
00186 e1000_fc_rx_pause,
00187 e1000_fc_tx_pause,
00188 e1000_fc_full,
00189 e1000_fc_default = 0xFF
00190 };
00191
00192 enum e1000_ffe_config {
00193 e1000_ffe_config_enabled = 0,
00194 e1000_ffe_config_active,
00195 e1000_ffe_config_blocked
00196 };
00197
00198 enum e1000_dsp_config {
00199 e1000_dsp_config_disabled = 0,
00200 e1000_dsp_config_enabled,
00201 e1000_dsp_config_activated,
00202 e1000_dsp_config_undefined = 0xFF
00203 };
00204
00205 enum e1000_ms_type {
00206 e1000_ms_hw_default = 0,
00207 e1000_ms_force_master,
00208 e1000_ms_force_slave,
00209 e1000_ms_auto
00210 };
00211
00212 enum e1000_smart_speed {
00213 e1000_smart_speed_default = 0,
00214 e1000_smart_speed_on,
00215 e1000_smart_speed_off
00216 };
00217
00218 enum e1000_serdes_link_state {
00219 e1000_serdes_link_down = 0,
00220 e1000_serdes_link_autoneg_progress,
00221 e1000_serdes_link_autoneg_complete,
00222 e1000_serdes_link_forced_up
00223 };
00224
00225
00226 struct e1000_rx_desc {
00227 __le64 buffer_addr;
00228 __le16 length;
00229 __le16 csum;
00230 u8 status;
00231 u8 errors;
00232 __le16 special;
00233 };
00234
00235
00236 union e1000_rx_desc_extended {
00237 struct {
00238 __le64 buffer_addr;
00239 __le64 reserved;
00240 } read;
00241 struct {
00242 struct {
00243 __le32 mrq;
00244 union {
00245 __le32 rss;
00246 struct {
00247 __le16 ip_id;
00248 __le16 csum;
00249 } csum_ip;
00250 } hi_dword;
00251 } lower;
00252 struct {
00253 __le32 status_error;
00254 __le16 length;
00255 __le16 vlan;
00256 } upper;
00257 } wb;
00258 };
00259
00260 #define MAX_PS_BUFFERS 4
00261
00262 union e1000_rx_desc_packet_split {
00263 struct {
00264
00265 __le64 buffer_addr[MAX_PS_BUFFERS];
00266 } read;
00267 struct {
00268 struct {
00269 __le32 mrq;
00270 union {
00271 __le32 rss;
00272 struct {
00273 __le16 ip_id;
00274 __le16 csum;
00275 } csum_ip;
00276 } hi_dword;
00277 } lower;
00278 struct {
00279 __le32 status_error;
00280 __le16 length0;
00281 __le16 vlan;
00282 } middle;
00283 struct {
00284 __le16 header_status;
00285 __le16 length[3];
00286 } upper;
00287 __le64 reserved;
00288 } wb;
00289 };
00290
00291
00292 struct e1000_tx_desc {
00293 __le64 buffer_addr;
00294 union {
00295 __le32 data;
00296 struct {
00297 __le16 length;
00298 u8 cso;
00299 u8 cmd;
00300 } flags;
00301 } lower;
00302 union {
00303 __le32 data;
00304 struct {
00305 u8 status;
00306 u8 css;
00307 __le16 special;
00308 } fields;
00309 } upper;
00310 };
00311
00312
00313 struct e1000_context_desc {
00314 union {
00315 __le32 ip_config;
00316 struct {
00317 u8 ipcss;
00318 u8 ipcso;
00319 __le16 ipcse;
00320 } ip_fields;
00321 } lower_setup;
00322 union {
00323 __le32 tcp_config;
00324 struct {
00325 u8 tucss;
00326 u8 tucso;
00327 __le16 tucse;
00328 } tcp_fields;
00329 } upper_setup;
00330 __le32 cmd_and_length;
00331 union {
00332 __le32 data;
00333 struct {
00334 u8 status;
00335 u8 hdr_len;
00336 __le16 mss;
00337 } fields;
00338 } tcp_seg_setup;
00339 };
00340
00341
00342 struct e1000_data_desc {
00343 __le64 buffer_addr;
00344 union {
00345 __le32 data;
00346 struct {
00347 __le16 length;
00348 u8 typ_len_ext;
00349 u8 cmd;
00350 } flags;
00351 } lower;
00352 union {
00353 __le32 data;
00354 struct {
00355 u8 status;
00356 u8 popts;
00357 __le16 special;
00358 } fields;
00359 } upper;
00360 };
00361
00362
00363 struct e1000_hw_stats {
00364 u64 crcerrs;
00365 u64 algnerrc;
00366 u64 symerrs;
00367 u64 rxerrc;
00368 u64 mpc;
00369 u64 scc;
00370 u64 ecol;
00371 u64 mcc;
00372 u64 latecol;
00373 u64 colc;
00374 u64 dc;
00375 u64 tncrs;
00376 u64 sec;
00377 u64 cexterr;
00378 u64 rlec;
00379 u64 xonrxc;
00380 u64 xontxc;
00381 u64 xoffrxc;
00382 u64 xofftxc;
00383 u64 fcruc;
00384 u64 prc64;
00385 u64 prc127;
00386 u64 prc255;
00387 u64 prc511;
00388 u64 prc1023;
00389 u64 prc1522;
00390 u64 gprc;
00391 u64 bprc;
00392 u64 mprc;
00393 u64 gptc;
00394 u64 gorc;
00395 u64 gotc;
00396 u64 rnbc;
00397 u64 ruc;
00398 u64 rfc;
00399 u64 roc;
00400 u64 rjc;
00401 u64 mgprc;
00402 u64 mgpdc;
00403 u64 mgptc;
00404 u64 tor;
00405 u64 tot;
00406 u64 tpr;
00407 u64 tpt;
00408 u64 ptc64;
00409 u64 ptc127;
00410 u64 ptc255;
00411 u64 ptc511;
00412 u64 ptc1023;
00413 u64 ptc1522;
00414 u64 mptc;
00415 u64 bptc;
00416 u64 tsctc;
00417 u64 tsctfc;
00418 u64 iac;
00419 u64 icrxptc;
00420 u64 icrxatc;
00421 u64 ictxptc;
00422 u64 ictxatc;
00423 u64 ictxqec;
00424 u64 ictxqmtc;
00425 u64 icrxdmtc;
00426 u64 icrxoc;
00427 u64 cbtmpc;
00428 u64 htdpmc;
00429 u64 cbrdpc;
00430 u64 cbrmpc;
00431 u64 rpthc;
00432 u64 hgptc;
00433 u64 htcbdpc;
00434 u64 hgorc;
00435 u64 hgotc;
00436 u64 lenerrs;
00437 u64 scvpc;
00438 u64 hrmpc;
00439 u64 doosync;
00440 };
00441
00442
00443 struct e1000_phy_stats {
00444 u32 idle_errors;
00445 u32 receive_errors;
00446 };
00447
00448 struct e1000_host_mng_dhcp_cookie {
00449 u32 signature;
00450 u8 status;
00451 u8 reserved0;
00452 u16 vlan_id;
00453 u32 reserved1;
00454 u16 reserved2;
00455 u8 reserved3;
00456 u8 checksum;
00457 };
00458
00459
00460 struct e1000_host_command_header {
00461 u8 command_id;
00462 u8 command_length;
00463 u8 command_options;
00464 u8 checksum;
00465 };
00466
00467 #define E1000_HI_MAX_DATA_LENGTH 252
00468 struct e1000_host_command_info {
00469 struct e1000_host_command_header command_header;
00470 u8 command_data[E1000_HI_MAX_DATA_LENGTH];
00471 };
00472
00473
00474 struct e1000_host_mng_command_header {
00475 u8 command_id;
00476 u8 checksum;
00477 u16 reserved1;
00478 u16 reserved2;
00479 u16 command_length;
00480 };
00481
00482 #define E1000_HI_MAX_MNG_DATA_LENGTH 0x6F8
00483 struct e1000_host_mng_command_info {
00484 struct e1000_host_mng_command_header command_header;
00485 u8 command_data[E1000_HI_MAX_MNG_DATA_LENGTH];
00486 };
00487
00488 #include "e1000_mac.h"
00489 #include "e1000_phy.h"
00490 #include "e1000_nvm.h"
00491 #include "e1000_manage.h"
00492
00493 struct e1000_mac_operations {
00494
00495 s32 (*init_params)(struct e1000_hw *);
00496 s32 (*id_led_init)(struct e1000_hw *);
00497 s32 (*blink_led)(struct e1000_hw *);
00498 s32 (*check_for_link)(struct e1000_hw *);
00499 bool (*check_mng_mode)(struct e1000_hw *hw);
00500 s32 (*cleanup_led)(struct e1000_hw *);
00501 void (*clear_hw_cntrs)(struct e1000_hw *);
00502 void (*clear_vfta)(struct e1000_hw *);
00503 s32 (*get_bus_info)(struct e1000_hw *);
00504 void (*set_lan_id)(struct e1000_hw *);
00505 s32 (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
00506 s32 (*led_on)(struct e1000_hw *);
00507 s32 (*led_off)(struct e1000_hw *);
00508 void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
00509 s32 (*reset_hw)(struct e1000_hw *);
00510 s32 (*init_hw)(struct e1000_hw *);
00511 s32 (*setup_link)(struct e1000_hw *);
00512 s32 (*setup_physical_interface)(struct e1000_hw *);
00513 s32 (*setup_led)(struct e1000_hw *);
00514 void (*write_vfta)(struct e1000_hw *, u32, u32);
00515 void (*mta_set)(struct e1000_hw *, u32);
00516 void (*config_collision_dist)(struct e1000_hw *);
00517 void (*rar_set)(struct e1000_hw *, u8*, u32);
00518 s32 (*read_mac_addr)(struct e1000_hw *);
00519 s32 (*validate_mdi_setting)(struct e1000_hw *);
00520 s32 (*mng_host_if_write)(struct e1000_hw *, u8*, u16, u16, u8*);
00521 s32 (*mng_write_cmd_header)(struct e1000_hw *hw,
00522 struct e1000_host_mng_command_header*);
00523 s32 (*mng_enable_host_if)(struct e1000_hw *);
00524 s32 (*wait_autoneg)(struct e1000_hw *);
00525 };
00526
00527 struct e1000_phy_operations {
00528 s32 (*init_params)(struct e1000_hw *);
00529 s32 (*acquire)(struct e1000_hw *);
00530 s32 (*check_polarity)(struct e1000_hw *);
00531 s32 (*check_reset_block)(struct e1000_hw *);
00532 s32 (*commit)(struct e1000_hw *);
00533 #if 0
00534 s32 (*force_speed_duplex)(struct e1000_hw *);
00535 #endif
00536 s32 (*get_cfg_done)(struct e1000_hw *hw);
00537 #if 0
00538 s32 (*get_cable_length)(struct e1000_hw *);
00539 #endif
00540 s32 (*get_info)(struct e1000_hw *);
00541 s32 (*read_reg)(struct e1000_hw *, u32, u16 *);
00542 void (*release)(struct e1000_hw *);
00543 s32 (*reset)(struct e1000_hw *);
00544 s32 (*set_d0_lplu_state)(struct e1000_hw *, bool);
00545 s32 (*set_d3_lplu_state)(struct e1000_hw *, bool);
00546 s32 (*write_reg)(struct e1000_hw *, u32, u16);
00547 void (*power_up)(struct e1000_hw *);
00548 void (*power_down)(struct e1000_hw *);
00549 };
00550
00551 struct e1000_nvm_operations {
00552 s32 (*init_params)(struct e1000_hw *);
00553 s32 (*acquire)(struct e1000_hw *);
00554 s32 (*read)(struct e1000_hw *, u16, u16, u16 *);
00555 void (*release)(struct e1000_hw *);
00556 void (*reload)(struct e1000_hw *);
00557 s32 (*update)(struct e1000_hw *);
00558 s32 (*valid_led_default)(struct e1000_hw *, u16 *);
00559 s32 (*validate)(struct e1000_hw *);
00560 s32 (*write)(struct e1000_hw *, u16, u16, u16 *);
00561 };
00562
00563 struct e1000_mac_info {
00564 struct e1000_mac_operations ops;
00565 u8 addr[6];
00566 u8 perm_addr[6];
00567
00568 enum e1000_mac_type type;
00569
00570 u32 collision_delta;
00571 u32 ledctl_default;
00572 u32 ledctl_mode1;
00573 u32 ledctl_mode2;
00574 u32 mc_filter_type;
00575 u32 tx_packet_delta;
00576 u32 txcw;
00577
00578 u16 current_ifs_val;
00579 u16 ifs_max_val;
00580 u16 ifs_min_val;
00581 u16 ifs_ratio;
00582 u16 ifs_step_size;
00583 u16 mta_reg_count;
00584
00585
00586 #define MAX_MTA_REG 128
00587 u32 mta_shadow[MAX_MTA_REG];
00588 u16 rar_entry_count;
00589
00590 u8 forced_speed_duplex;
00591
00592 bool adaptive_ifs;
00593 bool arc_subsystem_valid;
00594 bool asf_firmware_present;
00595 bool autoneg;
00596 bool autoneg_failed;
00597 bool get_link_status;
00598 bool in_ifs_mode;
00599 bool report_tx_early;
00600 enum e1000_serdes_link_state serdes_link_state;
00601 bool serdes_has_link;
00602 bool tx_pkt_filtering;
00603 };
00604
00605 struct e1000_phy_info {
00606 struct e1000_phy_operations ops;
00607 enum e1000_phy_type type;
00608
00609 enum e1000_1000t_rx_status local_rx;
00610 enum e1000_1000t_rx_status remote_rx;
00611 enum e1000_ms_type ms_type;
00612 enum e1000_ms_type original_ms_type;
00613 enum e1000_rev_polarity cable_polarity;
00614 enum e1000_smart_speed smart_speed;
00615
00616 u32 addr;
00617 u32 id;
00618 u32 reset_delay_us;
00619 u32 revision;
00620
00621 enum e1000_media_type media_type;
00622
00623 u16 autoneg_advertised;
00624 u16 autoneg_mask;
00625 u16 cable_length;
00626 u16 max_cable_length;
00627 u16 min_cable_length;
00628
00629 u8 mdix;
00630
00631 bool disable_polarity_correction;
00632 bool is_mdix;
00633 bool polarity_correction;
00634 bool reset_disable;
00635 bool speed_downgraded;
00636 bool autoneg_wait_to_complete;
00637 };
00638
00639 struct e1000_nvm_info {
00640 struct e1000_nvm_operations ops;
00641 enum e1000_nvm_type type;
00642 enum e1000_nvm_override override;
00643
00644 u32 flash_bank_size;
00645 u32 flash_base_addr;
00646
00647 u16 word_size;
00648 u16 delay_usec;
00649 u16 address_bits;
00650 u16 opcode_bits;
00651 u16 page_size;
00652 };
00653
00654 struct e1000_bus_info {
00655 enum e1000_bus_type type;
00656 enum e1000_bus_speed speed;
00657 enum e1000_bus_width width;
00658
00659 u16 func;
00660 u16 pci_cmd_word;
00661 };
00662
00663 struct e1000_fc_info {
00664 u32 high_water;
00665 u32 low_water;
00666 u16 pause_time;
00667 bool send_xon;
00668 bool strict_ieee;
00669 enum e1000_fc_mode current_mode;
00670 enum e1000_fc_mode requested_mode;
00671 };
00672
00673 struct e1000_dev_spec_82541 {
00674 enum e1000_dsp_config dsp_config;
00675 enum e1000_ffe_config ffe_config;
00676 u16 spd_default;
00677 bool phy_init_script;
00678 };
00679
00680 struct e1000_dev_spec_82542 {
00681 bool dma_fairness;
00682 };
00683
00684 struct e1000_dev_spec_82543 {
00685 u32 tbi_compatibility;
00686 bool dma_fairness;
00687 bool init_phy_disabled;
00688 };
00689
00690 struct e1000_hw {
00691 void *back;
00692
00693 u8 __iomem *hw_addr;
00694 u8 __iomem *flash_address;
00695 unsigned long io_base;
00696
00697 struct e1000_mac_info mac;
00698 struct e1000_fc_info fc;
00699 struct e1000_phy_info phy;
00700 struct e1000_nvm_info nvm;
00701 struct e1000_bus_info bus;
00702 struct e1000_host_mng_dhcp_cookie mng_cookie;
00703
00704 union {
00705 struct e1000_dev_spec_82541 _82541;
00706 struct e1000_dev_spec_82542 _82542;
00707 struct e1000_dev_spec_82543 _82543;
00708 } dev_spec;
00709
00710 u16 device_id;
00711 u16 subsystem_vendor_id;
00712 u16 subsystem_device_id;
00713 u16 vendor_id;
00714
00715 u8 revision_id;
00716 };
00717
00718 #include "e1000_82541.h"
00719 #include "e1000_82543.h"
00720
00721
00722 void e1000_pci_clear_mwi(struct e1000_hw *hw);
00723 void e1000_pci_set_mwi(struct e1000_hw *hw);
00724 s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
00725 void e1000_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value);
00726 void e1000_write_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value);
00727
00728 #endif