aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000e')
-rw-r--r--drivers/net/e1000e/82571.c68
-rw-r--r--drivers/net/e1000e/defines.h2
-rw-r--r--drivers/net/e1000e/e1000.h19
-rw-r--r--drivers/net/e1000e/es2lan.c32
-rw-r--r--drivers/net/e1000e/ethtool.c2
-rw-r--r--drivers/net/e1000e/hw.h12
-rw-r--r--drivers/net/e1000e/ich8lan.c1
-rw-r--r--drivers/net/e1000e/lib.c230
-rw-r--r--drivers/net/e1000e/netdev.c45
9 files changed, 237 insertions, 174 deletions
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index dc4eb87309c5..712ccc66ba25 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -267,8 +267,14 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
267 } 267 }
268 268
269 switch (hw->mac.type) { 269 switch (hw->mac.type) {
270 case e1000_82573:
271 func->set_lan_id = e1000_set_lan_id_single_port;
272 func->check_mng_mode = e1000e_check_mng_mode_generic;
273 func->led_on = e1000e_led_on_generic;
274 break;
270 case e1000_82574: 275 case e1000_82574:
271 case e1000_82583: 276 case e1000_82583:
277 func->set_lan_id = e1000_set_lan_id_single_port;
272 func->check_mng_mode = e1000_check_mng_mode_82574; 278 func->check_mng_mode = e1000_check_mng_mode_82574;
273 func->led_on = e1000_led_on_82574; 279 func->led_on = e1000_led_on_82574;
274 break; 280 break;
@@ -922,9 +928,12 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
922 ew32(IMC, 0xffffffff); 928 ew32(IMC, 0xffffffff);
923 icr = er32(ICR); 929 icr = er32(ICR);
924 930
925 if (hw->mac.type == e1000_82571 && 931 /* Install any alternate MAC address into RAR0 */
926 hw->dev_spec.e82571.alt_mac_addr_is_present) 932 ret_val = e1000_check_alt_mac_addr_generic(hw);
927 e1000e_set_laa_state_82571(hw, true); 933 if (ret_val)
934 return ret_val;
935
936 e1000e_set_laa_state_82571(hw, true);
928 937
929 /* Reinitialize the 82571 serdes link state machine */ 938 /* Reinitialize the 82571 serdes link state machine */
930 if (hw->phy.media_type == e1000_media_type_internal_serdes) 939 if (hw->phy.media_type == e1000_media_type_internal_serdes)
@@ -1225,32 +1234,6 @@ static s32 e1000_led_on_82574(struct e1000_hw *hw)
1225} 1234}
1226 1235
1227/** 1236/**
1228 * e1000_update_mc_addr_list_82571 - Update Multicast addresses
1229 * @hw: pointer to the HW structure
1230 * @mc_addr_list: array of multicast addresses to program
1231 * @mc_addr_count: number of multicast addresses to program
1232 * @rar_used_count: the first RAR register free to program
1233 * @rar_count: total number of supported Receive Address Registers
1234 *
1235 * Updates the Receive Address Registers and Multicast Table Array.
1236 * The caller must have a packed mc_addr_list of multicast addresses.
1237 * The parameter rar_count will usually be hw->mac.rar_entry_count
1238 * unless there are workarounds that change this.
1239 **/
1240static void e1000_update_mc_addr_list_82571(struct e1000_hw *hw,
1241 u8 *mc_addr_list,
1242 u32 mc_addr_count,
1243 u32 rar_used_count,
1244 u32 rar_count)
1245{
1246 if (e1000e_get_laa_state_82571(hw))
1247 rar_count--;
1248
1249 e1000e_update_mc_addr_list_generic(hw, mc_addr_list, mc_addr_count,
1250 rar_used_count, rar_count);
1251}
1252
1253/**
1254 * e1000_setup_link_82571 - Setup flow control and link settings 1237 * e1000_setup_link_82571 - Setup flow control and link settings
1255 * @hw: pointer to the HW structure 1238 * @hw: pointer to the HW structure
1256 * 1239 *
@@ -1621,6 +1604,29 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)
1621} 1604}
1622 1605
1623/** 1606/**
1607 * e1000_read_mac_addr_82571 - Read device MAC address
1608 * @hw: pointer to the HW structure
1609 **/
1610static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)
1611{
1612 s32 ret_val = 0;
1613
1614 /*
1615 * If there's an alternate MAC address place it in RAR0
1616 * so that it will override the Si installed default perm
1617 * address.
1618 */
1619 ret_val = e1000_check_alt_mac_addr_generic(hw);
1620 if (ret_val)
1621 goto out;
1622
1623 ret_val = e1000_read_mac_addr_generic(hw);
1624
1625out:
1626 return ret_val;
1627}
1628
1629/**
1624 * e1000_power_down_phy_copper_82571 - Remove link during PHY power down 1630 * e1000_power_down_phy_copper_82571 - Remove link during PHY power down
1625 * @hw: pointer to the HW structure 1631 * @hw: pointer to the HW structure
1626 * 1632 *
@@ -1695,10 +1701,11 @@ static struct e1000_mac_operations e82571_mac_ops = {
1695 .cleanup_led = e1000e_cleanup_led_generic, 1701 .cleanup_led = e1000e_cleanup_led_generic,
1696 .clear_hw_cntrs = e1000_clear_hw_cntrs_82571, 1702 .clear_hw_cntrs = e1000_clear_hw_cntrs_82571,
1697 .get_bus_info = e1000e_get_bus_info_pcie, 1703 .get_bus_info = e1000e_get_bus_info_pcie,
1704 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
1698 /* .get_link_up_info: media type dependent */ 1705 /* .get_link_up_info: media type dependent */
1699 /* .led_on: mac type dependent */ 1706 /* .led_on: mac type dependent */
1700 .led_off = e1000e_led_off_generic, 1707 .led_off = e1000e_led_off_generic,
1701 .update_mc_addr_list = e1000_update_mc_addr_list_82571, 1708 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
1702 .write_vfta = e1000_write_vfta_generic, 1709 .write_vfta = e1000_write_vfta_generic,
1703 .clear_vfta = e1000_clear_vfta_82571, 1710 .clear_vfta = e1000_clear_vfta_82571,
1704 .reset_hw = e1000_reset_hw_82571, 1711 .reset_hw = e1000_reset_hw_82571,
@@ -1706,6 +1713,7 @@ static struct e1000_mac_operations e82571_mac_ops = {
1706 .setup_link = e1000_setup_link_82571, 1713 .setup_link = e1000_setup_link_82571,
1707 /* .setup_physical_interface: media type dependent */ 1714 /* .setup_physical_interface: media type dependent */
1708 .setup_led = e1000e_setup_led_generic, 1715 .setup_led = e1000e_setup_led_generic,
1716 .read_mac_addr = e1000_read_mac_addr_82571,
1709}; 1717};
1710 1718
1711static struct e1000_phy_operations e82_phy_ops_igp = { 1719static struct e1000_phy_operations e82_phy_ops_igp = {
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index e02e38221ed4..db05ec355749 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -460,6 +460,8 @@
460 */ 460 */
461#define E1000_RAR_ENTRIES 15 461#define E1000_RAR_ENTRIES 15
462#define E1000_RAH_AV 0x80000000 /* Receive descriptor valid */ 462#define E1000_RAH_AV 0x80000000 /* Receive descriptor valid */
463#define E1000_RAL_MAC_ADDR_LEN 4
464#define E1000_RAH_MAC_ADDR_LEN 2
463 465
464/* Error Codes */ 466/* Error Codes */
465#define E1000_ERR_NVM 1 467#define E1000_ERR_NVM 1
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index d236efaf7478..c2ec095d2163 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -459,7 +459,7 @@ extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter);
459extern void e1000e_free_rx_resources(struct e1000_adapter *adapter); 459extern void e1000e_free_rx_resources(struct e1000_adapter *adapter);
460extern void e1000e_free_tx_resources(struct e1000_adapter *adapter); 460extern void e1000e_free_tx_resources(struct e1000_adapter *adapter);
461extern void e1000e_update_stats(struct e1000_adapter *adapter); 461extern void e1000e_update_stats(struct e1000_adapter *adapter);
462extern bool e1000_has_link(struct e1000_adapter *adapter); 462extern bool e1000e_has_link(struct e1000_adapter *adapter);
463extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter); 463extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
464extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter); 464extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
465 465
@@ -503,6 +503,8 @@ extern s32 e1000e_cleanup_led_generic(struct e1000_hw *hw);
503extern s32 e1000e_led_on_generic(struct e1000_hw *hw); 503extern s32 e1000e_led_on_generic(struct e1000_hw *hw);
504extern s32 e1000e_led_off_generic(struct e1000_hw *hw); 504extern s32 e1000e_led_off_generic(struct e1000_hw *hw);
505extern s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw); 505extern s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw);
506extern void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw);
507extern void e1000_set_lan_id_single_port(struct e1000_hw *hw);
506extern s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex); 508extern s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex);
507extern s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex); 509extern s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex);
508extern s32 e1000e_disable_pcie_master(struct e1000_hw *hw); 510extern s32 e1000e_disable_pcie_master(struct e1000_hw *hw);
@@ -517,9 +519,7 @@ extern void e1000_clear_vfta_generic(struct e1000_hw *hw);
517extern void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count); 519extern void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count);
518extern void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, 520extern void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw,
519 u8 *mc_addr_list, 521 u8 *mc_addr_list,
520 u32 mc_addr_count, 522 u32 mc_addr_count);
521 u32 rar_used_count,
522 u32 rar_count);
523extern void e1000e_rar_set(struct e1000_hw *hw, u8 *addr, u32 index); 523extern void e1000e_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
524extern s32 e1000e_set_fc_watermarks(struct e1000_hw *hw); 524extern s32 e1000e_set_fc_watermarks(struct e1000_hw *hw);
525extern void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop); 525extern void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop);
@@ -530,6 +530,7 @@ extern s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw);
530extern s32 e1000e_force_mac_fc(struct e1000_hw *hw); 530extern s32 e1000e_force_mac_fc(struct e1000_hw *hw);
531extern s32 e1000e_blink_led(struct e1000_hw *hw); 531extern s32 e1000e_blink_led(struct e1000_hw *hw);
532extern void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value); 532extern void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value);
533extern s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw);
533extern void e1000e_reset_adaptive(struct e1000_hw *hw); 534extern void e1000e_reset_adaptive(struct e1000_hw *hw);
534extern void e1000e_update_adaptive(struct e1000_hw *hw); 535extern void e1000e_update_adaptive(struct e1000_hw *hw);
535 536
@@ -629,7 +630,15 @@ extern s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16
629extern s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw); 630extern s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw);
630extern void e1000e_release_nvm(struct e1000_hw *hw); 631extern void e1000e_release_nvm(struct e1000_hw *hw);
631extern void e1000e_reload_nvm(struct e1000_hw *hw); 632extern void e1000e_reload_nvm(struct e1000_hw *hw);
632extern s32 e1000e_read_mac_addr(struct e1000_hw *hw); 633extern s32 e1000_read_mac_addr_generic(struct e1000_hw *hw);
634
635static inline s32 e1000e_read_mac_addr(struct e1000_hw *hw)
636{
637 if (hw->mac.ops.read_mac_addr)
638 return hw->mac.ops.read_mac_addr(hw);
639
640 return e1000_read_mac_addr_generic(hw);
641}
633 642
634static inline s32 e1000_validate_nvm_checksum(struct e1000_hw *hw) 643static inline s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
635{ 644{
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index e2aa3b788564..27d21589a69a 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -246,6 +246,9 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
246 break; 246 break;
247 } 247 }
248 248
249 /* set lan id for port to determine which phy lock to use */
250 hw->mac.ops.set_lan_id(hw);
251
249 return 0; 252 return 0;
250} 253}
251 254
@@ -814,7 +817,9 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
814 ew32(IMC, 0xffffffff); 817 ew32(IMC, 0xffffffff);
815 icr = er32(ICR); 818 icr = er32(ICR);
816 819
817 return 0; 820 ret_val = e1000_check_alt_mac_addr_generic(hw);
821
822 return ret_val;
818} 823}
819 824
820/** 825/**
@@ -1340,6 +1345,29 @@ static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1340} 1345}
1341 1346
1342/** 1347/**
1348 * e1000_read_mac_addr_80003es2lan - Read device MAC address
1349 * @hw: pointer to the HW structure
1350 **/
1351static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
1352{
1353 s32 ret_val = 0;
1354
1355 /*
1356 * If there's an alternate MAC address place it in RAR0
1357 * so that it will override the Si installed default perm
1358 * address.
1359 */
1360 ret_val = e1000_check_alt_mac_addr_generic(hw);
1361 if (ret_val)
1362 goto out;
1363
1364 ret_val = e1000_read_mac_addr_generic(hw);
1365
1366out:
1367 return ret_val;
1368}
1369
1370/**
1343 * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down 1371 * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down
1344 * @hw: pointer to the HW structure 1372 * @hw: pointer to the HW structure
1345 * 1373 *
@@ -1403,12 +1431,14 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
1403} 1431}
1404 1432
1405static struct e1000_mac_operations es2_mac_ops = { 1433static struct e1000_mac_operations es2_mac_ops = {
1434 .read_mac_addr = e1000_read_mac_addr_80003es2lan,
1406 .id_led_init = e1000e_id_led_init, 1435 .id_led_init = e1000e_id_led_init,
1407 .check_mng_mode = e1000e_check_mng_mode_generic, 1436 .check_mng_mode = e1000e_check_mng_mode_generic,
1408 /* check_for_link dependent on media type */ 1437 /* check_for_link dependent on media type */
1409 .cleanup_led = e1000e_cleanup_led_generic, 1438 .cleanup_led = e1000e_cleanup_led_generic,
1410 .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan, 1439 .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan,
1411 .get_bus_info = e1000e_get_bus_info_pcie, 1440 .get_bus_info = e1000e_get_bus_info_pcie,
1441 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
1412 .get_link_up_info = e1000_get_link_up_info_80003es2lan, 1442 .get_link_up_info = e1000_get_link_up_info_80003es2lan,
1413 .led_on = e1000e_led_on_generic, 1443 .led_on = e1000e_led_on_generic,
1414 .led_off = e1000e_led_off_generic, 1444 .led_off = e1000e_led_off_generic,
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 0aa50c229c79..b33e3cbe9ab0 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -202,7 +202,7 @@ static u32 e1000_get_link(struct net_device *netdev)
202 if (!netif_carrier_ok(netdev)) 202 if (!netif_carrier_ok(netdev))
203 mac->get_link_status = 1; 203 mac->get_link_status = 1;
204 204
205 return e1000_has_link(adapter); 205 return e1000e_has_link(adapter);
206} 206}
207 207
208static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx) 208static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index eccf29b75c41..8bdcd5f24eff 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -389,6 +389,9 @@ enum e1e_registers {
389 389
390#define E1000_FUNC_1 1 390#define E1000_FUNC_1 1
391 391
392#define E1000_ALT_MAC_ADDRESS_OFFSET_LAN0 0
393#define E1000_ALT_MAC_ADDRESS_OFFSET_LAN1 3
394
392enum e1000_mac_type { 395enum e1000_mac_type {
393 e1000_82571, 396 e1000_82571,
394 e1000_82572, 397 e1000_82572,
@@ -746,16 +749,18 @@ struct e1000_mac_operations {
746 void (*clear_hw_cntrs)(struct e1000_hw *); 749 void (*clear_hw_cntrs)(struct e1000_hw *);
747 void (*clear_vfta)(struct e1000_hw *); 750 void (*clear_vfta)(struct e1000_hw *);
748 s32 (*get_bus_info)(struct e1000_hw *); 751 s32 (*get_bus_info)(struct e1000_hw *);
752 void (*set_lan_id)(struct e1000_hw *);
749 s32 (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *); 753 s32 (*get_link_up_info)(struct e1000_hw *, u16 *, u16 *);
750 s32 (*led_on)(struct e1000_hw *); 754 s32 (*led_on)(struct e1000_hw *);
751 s32 (*led_off)(struct e1000_hw *); 755 s32 (*led_off)(struct e1000_hw *);
752 void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32, u32, u32); 756 void (*update_mc_addr_list)(struct e1000_hw *, u8 *, u32);
753 s32 (*reset_hw)(struct e1000_hw *); 757 s32 (*reset_hw)(struct e1000_hw *);
754 s32 (*init_hw)(struct e1000_hw *); 758 s32 (*init_hw)(struct e1000_hw *);
755 s32 (*setup_link)(struct e1000_hw *); 759 s32 (*setup_link)(struct e1000_hw *);
756 s32 (*setup_physical_interface)(struct e1000_hw *); 760 s32 (*setup_physical_interface)(struct e1000_hw *);
757 s32 (*setup_led)(struct e1000_hw *); 761 s32 (*setup_led)(struct e1000_hw *);
758 void (*write_vfta)(struct e1000_hw *, u32, u32); 762 void (*write_vfta)(struct e1000_hw *, u32, u32);
763 s32 (*read_mac_addr)(struct e1000_hw *);
759}; 764};
760 765
761/* Function pointers for the PHY. */ 766/* Function pointers for the PHY. */
@@ -814,6 +819,10 @@ struct e1000_mac_info {
814 u16 ifs_ratio; 819 u16 ifs_ratio;
815 u16 ifs_step_size; 820 u16 ifs_step_size;
816 u16 mta_reg_count; 821 u16 mta_reg_count;
822
823 /* Maximum size of the MTA register table in all supported adapters */
824 #define MAX_MTA_REG 128
825 u32 mta_shadow[MAX_MTA_REG];
817 u16 rar_entry_count; 826 u16 rar_entry_count;
818 827
819 u8 forced_speed_duplex; 828 u8 forced_speed_duplex;
@@ -897,7 +906,6 @@ struct e1000_fc_info {
897 906
898struct e1000_dev_spec_82571 { 907struct e1000_dev_spec_82571 {
899 bool laa_is_present; 908 bool laa_is_present;
900 bool alt_mac_addr_is_present;
901 u32 smb_counter; 909 u32 smb_counter;
902}; 910};
903 911
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 8b6ecd127889..54d03a0ce3ce 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -3368,6 +3368,7 @@ static struct e1000_mac_operations ich8_mac_ops = {
3368 /* cleanup_led dependent on mac type */ 3368 /* cleanup_led dependent on mac type */
3369 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan, 3369 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
3370 .get_bus_info = e1000_get_bus_info_ich8lan, 3370 .get_bus_info = e1000_get_bus_info_ich8lan,
3371 .set_lan_id = e1000_set_lan_id_single_port,
3371 .get_link_up_info = e1000_get_link_up_info_ich8lan, 3372 .get_link_up_info = e1000_get_link_up_info_ich8lan,
3372 /* led_on dependent on mac type */ 3373 /* led_on dependent on mac type */
3373 /* led_off dependent on mac type */ 3374 /* led_off dependent on mac type */
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 3af0b1b82832..a8b2c0de27c4 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -51,10 +51,10 @@ enum e1000_mng_mode {
51 **/ 51 **/
52s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw) 52s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw)
53{ 53{
54 struct e1000_mac_info *mac = &hw->mac;
54 struct e1000_bus_info *bus = &hw->bus; 55 struct e1000_bus_info *bus = &hw->bus;
55 struct e1000_adapter *adapter = hw->adapter; 56 struct e1000_adapter *adapter = hw->adapter;
56 u32 status; 57 u16 pcie_link_status, cap_offset;
57 u16 pcie_link_status, pci_header_type, cap_offset;
58 58
59 cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP); 59 cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
60 if (!cap_offset) { 60 if (!cap_offset) {
@@ -68,20 +68,46 @@ s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw)
68 PCIE_LINK_WIDTH_SHIFT); 68 PCIE_LINK_WIDTH_SHIFT);
69 } 69 }
70 70
71 pci_read_config_word(adapter->pdev, PCI_HEADER_TYPE_REGISTER, 71 mac->ops.set_lan_id(hw);
72 &pci_header_type);
73 if (pci_header_type & PCI_HEADER_TYPE_MULTIFUNC) {
74 status = er32(STATUS);
75 bus->func = (status & E1000_STATUS_FUNC_MASK)
76 >> E1000_STATUS_FUNC_SHIFT;
77 } else {
78 bus->func = 0;
79 }
80 72
81 return 0; 73 return 0;
82} 74}
83 75
84/** 76/**
77 * e1000_set_lan_id_multi_port_pcie - Set LAN id for PCIe multiple port devices
78 *
79 * @hw: pointer to the HW structure
80 *
81 * Determines the LAN function id by reading memory-mapped registers
82 * and swaps the port value if requested.
83 **/
84void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw)
85{
86 struct e1000_bus_info *bus = &hw->bus;
87 u32 reg;
88
89 /*
90 * The status register reports the correct function number
91 * for the device regardless of function swap state.
92 */
93 reg = er32(STATUS);
94 bus->func = (reg & E1000_STATUS_FUNC_MASK) >> E1000_STATUS_FUNC_SHIFT;
95}
96
97/**
98 * e1000_set_lan_id_single_port - Set LAN id for a single port device
99 * @hw: pointer to the HW structure
100 *
101 * Sets the LAN function id to zero for a single port device.
102 **/
103void e1000_set_lan_id_single_port(struct e1000_hw *hw)
104{
105 struct e1000_bus_info *bus = &hw->bus;
106
107 bus->func = 0;
108}
109
110/**
85 * e1000_clear_vfta_generic - Clear VLAN filter table 111 * e1000_clear_vfta_generic - Clear VLAN filter table
86 * @hw: pointer to the HW structure 112 * @hw: pointer to the HW structure
87 * 113 *
@@ -139,6 +165,68 @@ void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count)
139} 165}
140 166
141/** 167/**
168 * e1000_check_alt_mac_addr_generic - Check for alternate MAC addr
169 * @hw: pointer to the HW structure
170 *
171 * Checks the nvm for an alternate MAC address. An alternate MAC address
172 * can be setup by pre-boot software and must be treated like a permanent
173 * address and must override the actual permanent MAC address. If an
174 * alternate MAC address is found it is programmed into RAR0, replacing
175 * the permanent address that was installed into RAR0 by the Si on reset.
176 * This function will return SUCCESS unless it encounters an error while
177 * reading the EEPROM.
178 **/
179s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
180{
181 u32 i;
182 s32 ret_val = 0;
183 u16 offset, nvm_alt_mac_addr_offset, nvm_data;
184 u8 alt_mac_addr[ETH_ALEN];
185
186 ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1,
187 &nvm_alt_mac_addr_offset);
188 if (ret_val) {
189 e_dbg("NVM Read Error\n");
190 goto out;
191 }
192
193 if (nvm_alt_mac_addr_offset == 0xFFFF) {
194 /* There is no Alternate MAC Address */
195 goto out;
196 }
197
198 if (hw->bus.func == E1000_FUNC_1)
199 nvm_alt_mac_addr_offset += E1000_ALT_MAC_ADDRESS_OFFSET_LAN1;
200 for (i = 0; i < ETH_ALEN; i += 2) {
201 offset = nvm_alt_mac_addr_offset + (i >> 1);
202 ret_val = e1000_read_nvm(hw, offset, 1, &nvm_data);
203 if (ret_val) {
204 e_dbg("NVM Read Error\n");
205 goto out;
206 }
207
208 alt_mac_addr[i] = (u8)(nvm_data & 0xFF);
209 alt_mac_addr[i + 1] = (u8)(nvm_data >> 8);
210 }
211
212 /* if multicast bit is set, the alternate address will not be used */
213 if (alt_mac_addr[0] & 0x01) {
214 e_dbg("Ignoring Alternate Mac Address with MC bit set\n");
215 goto out;
216 }
217
218 /*
219 * We have a valid alternate MAC address, and we want to treat it the
220 * same as the normal permanent MAC address stored by the HW into the
221 * RAR. Do this by mapping this address into RAR0.
222 */
223 e1000e_rar_set(hw, alt_mac_addr, 0);
224
225out:
226 return ret_val;
227}
228
229/**
142 * e1000e_rar_set - Set receive address register 230 * e1000e_rar_set - Set receive address register
143 * @hw: pointer to the HW structure 231 * @hw: pointer to the HW structure
144 * @addr: pointer to the receive address 232 * @addr: pointer to the receive address
@@ -252,62 +340,34 @@ static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
252 * @hw: pointer to the HW structure 340 * @hw: pointer to the HW structure
253 * @mc_addr_list: array of multicast addresses to program 341 * @mc_addr_list: array of multicast addresses to program
254 * @mc_addr_count: number of multicast addresses to program 342 * @mc_addr_count: number of multicast addresses to program
255 * @rar_used_count: the first RAR register free to program
256 * @rar_count: total number of supported Receive Address Registers
257 * 343 *
258 * Updates the Receive Address Registers and Multicast Table Array. 344 * Updates entire Multicast Table Array.
259 * The caller must have a packed mc_addr_list of multicast addresses. 345 * The caller must have a packed mc_addr_list of multicast addresses.
260 * The parameter rar_count will usually be hw->mac.rar_entry_count
261 * unless there are workarounds that change this.
262 **/ 346 **/
263void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, 347void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw,
264 u8 *mc_addr_list, u32 mc_addr_count, 348 u8 *mc_addr_list, u32 mc_addr_count)
265 u32 rar_used_count, u32 rar_count)
266{ 349{
267 u32 i; 350 u32 hash_value, hash_bit, hash_reg;
268 u32 *mcarray = kzalloc(hw->mac.mta_reg_count * sizeof(u32), GFP_ATOMIC); 351 int i;
269 352
270 if (!mcarray) { 353 /* clear mta_shadow */
271 printk(KERN_ERR "multicast array memory allocation failed\n"); 354 memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow));
272 return;
273 }
274 355
275 /* 356 /* update mta_shadow from mc_addr_list */
276 * Load the first set of multicast addresses into the exact 357 for (i = 0; (u32) i < mc_addr_count; i++) {
277 * filters (RAR). If there are not enough to fill the RAR
278 * array, clear the filters.
279 */
280 for (i = rar_used_count; i < rar_count; i++) {
281 if (mc_addr_count) {
282 e1000e_rar_set(hw, mc_addr_list, i);
283 mc_addr_count--;
284 mc_addr_list += ETH_ALEN;
285 } else {
286 E1000_WRITE_REG_ARRAY(hw, E1000_RA, i << 1, 0);
287 e1e_flush();
288 E1000_WRITE_REG_ARRAY(hw, E1000_RA, (i << 1) + 1, 0);
289 e1e_flush();
290 }
291 }
292
293 /* Load any remaining multicast addresses into the hash table. */
294 for (; mc_addr_count > 0; mc_addr_count--) {
295 u32 hash_value, hash_reg, hash_bit, mta;
296 hash_value = e1000_hash_mc_addr(hw, mc_addr_list); 358 hash_value = e1000_hash_mc_addr(hw, mc_addr_list);
297 e_dbg("Hash value = 0x%03X\n", hash_value); 359
298 hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1); 360 hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1);
299 hash_bit = hash_value & 0x1F; 361 hash_bit = hash_value & 0x1F;
300 mta = (1 << hash_bit);
301 mcarray[hash_reg] |= mta;
302 mc_addr_list += ETH_ALEN;
303 }
304 362
305 /* write the hash table completely */ 363 hw->mac.mta_shadow[hash_reg] |= (1 << hash_bit);
306 for (i = 0; i < hw->mac.mta_reg_count; i++) 364 mc_addr_list += (ETH_ALEN);
307 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, mcarray[i]); 365 }
308 366
367 /* replace the entire MTA table */
368 for (i = hw->mac.mta_reg_count - 1; i >= 0; i--)
369 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, hw->mac.mta_shadow[i]);
309 e1e_flush(); 370 e1e_flush();
310 kfree(mcarray);
311} 371}
312 372
313/** 373/**
@@ -2072,67 +2132,27 @@ s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
2072} 2132}
2073 2133
2074/** 2134/**
2075 * e1000e_read_mac_addr - Read device MAC address 2135 * e1000_read_mac_addr_generic - Read device MAC address
2076 * @hw: pointer to the HW structure 2136 * @hw: pointer to the HW structure
2077 * 2137 *
2078 * Reads the device MAC address from the EEPROM and stores the value. 2138 * Reads the device MAC address from the EEPROM and stores the value.
2079 * Since devices with two ports use the same EEPROM, we increment the 2139 * Since devices with two ports use the same EEPROM, we increment the
2080 * last bit in the MAC address for the second port. 2140 * last bit in the MAC address for the second port.
2081 **/ 2141 **/
2082s32 e1000e_read_mac_addr(struct e1000_hw *hw) 2142s32 e1000_read_mac_addr_generic(struct e1000_hw *hw)
2083{ 2143{
2084 s32 ret_val; 2144 u32 rar_high;
2085 u16 offset, nvm_data, i; 2145 u32 rar_low;
2086 u16 mac_addr_offset = 0; 2146 u16 i;
2087
2088 if (hw->mac.type == e1000_82571) {
2089 /* Check for an alternate MAC address. An alternate MAC
2090 * address can be setup by pre-boot software and must be
2091 * treated like a permanent address and must override the
2092 * actual permanent MAC address.*/
2093 ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1,
2094 &mac_addr_offset);
2095 if (ret_val) {
2096 e_dbg("NVM Read Error\n");
2097 return ret_val;
2098 }
2099 if (mac_addr_offset == 0xFFFF)
2100 mac_addr_offset = 0;
2101
2102 if (mac_addr_offset) {
2103 if (hw->bus.func == E1000_FUNC_1)
2104 mac_addr_offset += ETH_ALEN/sizeof(u16);
2105
2106 /* make sure we have a valid mac address here
2107 * before using it */
2108 ret_val = e1000_read_nvm(hw, mac_addr_offset, 1,
2109 &nvm_data);
2110 if (ret_val) {
2111 e_dbg("NVM Read Error\n");
2112 return ret_val;
2113 }
2114 if (nvm_data & 0x0001)
2115 mac_addr_offset = 0;
2116 }
2117 2147
2118 if (mac_addr_offset) 2148 rar_high = er32(RAH(0));
2119 hw->dev_spec.e82571.alt_mac_addr_is_present = 1; 2149 rar_low = er32(RAL(0));
2120 }
2121 2150
2122 for (i = 0; i < ETH_ALEN; i += 2) { 2151 for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++)
2123 offset = mac_addr_offset + (i >> 1); 2152 hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8));
2124 ret_val = e1000_read_nvm(hw, offset, 1, &nvm_data);
2125 if (ret_val) {
2126 e_dbg("NVM Read Error\n");
2127 return ret_val;
2128 }
2129 hw->mac.perm_addr[i] = (u8)(nvm_data & 0xFF);
2130 hw->mac.perm_addr[i+1] = (u8)(nvm_data >> 8);
2131 }
2132 2153
2133 /* Flip last bit of mac address if we're on second port */ 2154 for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++)
2134 if (!mac_addr_offset && hw->bus.func == E1000_FUNC_1) 2155 hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8));
2135 hw->mac.perm_addr[5] ^= 1;
2136 2156
2137 for (i = 0; i < ETH_ALEN; i++) 2157 for (i = 0; i < ETH_ALEN; i++)
2138 hw->mac.addr[i] = hw->mac.perm_addr[i]; 2158 hw->mac.addr[i] = hw->mac.perm_addr[i];
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 57f149b75fbe..88d54d3efcef 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2541,22 +2541,14 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2541 * @hw: pointer to the HW structure 2541 * @hw: pointer to the HW structure
2542 * @mc_addr_list: array of multicast addresses to program 2542 * @mc_addr_list: array of multicast addresses to program
2543 * @mc_addr_count: number of multicast addresses to program 2543 * @mc_addr_count: number of multicast addresses to program
2544 * @rar_used_count: the first RAR register free to program
2545 * @rar_count: total number of supported Receive Address Registers
2546 * 2544 *
2547 * Updates the Receive Address Registers and Multicast Table Array. 2545 * Updates the Multicast Table Array.
2548 * The caller must have a packed mc_addr_list of multicast addresses. 2546 * The caller must have a packed mc_addr_list of multicast addresses.
2549 * The parameter rar_count will usually be hw->mac.rar_entry_count
2550 * unless there are workarounds that change this. Currently no func pointer
2551 * exists and all implementations are handled in the generic version of this
2552 * function.
2553 **/ 2547 **/
2554static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list, 2548static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
2555 u32 mc_addr_count, u32 rar_used_count, 2549 u32 mc_addr_count)
2556 u32 rar_count)
2557{ 2550{
2558 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count, 2551 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count);
2559 rar_used_count, rar_count);
2560} 2552}
2561 2553
2562/** 2554/**
@@ -2572,7 +2564,6 @@ static void e1000_set_multi(struct net_device *netdev)
2572{ 2564{
2573 struct e1000_adapter *adapter = netdev_priv(netdev); 2565 struct e1000_adapter *adapter = netdev_priv(netdev);
2574 struct e1000_hw *hw = &adapter->hw; 2566 struct e1000_hw *hw = &adapter->hw;
2575 struct e1000_mac_info *mac = &hw->mac;
2576 struct dev_mc_list *mc_ptr; 2567 struct dev_mc_list *mc_ptr;
2577 u8 *mta_list; 2568 u8 *mta_list;
2578 u32 rctl; 2569 u32 rctl;
@@ -2598,31 +2589,25 @@ static void e1000_set_multi(struct net_device *netdev)
2598 2589
2599 ew32(RCTL, rctl); 2590 ew32(RCTL, rctl);
2600 2591
2601 if (netdev->mc_count) { 2592 if (!netdev_mc_empty(netdev)) {
2602 mta_list = kmalloc(netdev->mc_count * 6, GFP_ATOMIC); 2593 mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
2603 if (!mta_list) 2594 if (!mta_list)
2604 return; 2595 return;
2605 2596
2606 /* prepare a packed array of only addresses. */ 2597 /* prepare a packed array of only addresses. */
2607 mc_ptr = netdev->mc_list; 2598 i = 0;
2608 2599 netdev_for_each_mc_addr(mc_ptr, netdev)
2609 for (i = 0; i < netdev->mc_count; i++) { 2600 memcpy(mta_list + (i++ * ETH_ALEN),
2610 if (!mc_ptr) 2601 mc_ptr->dmi_addr, ETH_ALEN);
2611 break;
2612 memcpy(mta_list + (i*ETH_ALEN), mc_ptr->dmi_addr,
2613 ETH_ALEN);
2614 mc_ptr = mc_ptr->next;
2615 }
2616 2602
2617 e1000_update_mc_addr_list(hw, mta_list, i, 1, 2603 e1000_update_mc_addr_list(hw, mta_list, i);
2618 mac->rar_entry_count);
2619 kfree(mta_list); 2604 kfree(mta_list);
2620 } else { 2605 } else {
2621 /* 2606 /*
2622 * if we're called from probe, we might not have 2607 * if we're called from probe, we might not have
2623 * anything to do here, so clear out the list 2608 * anything to do here, so clear out the list
2624 */ 2609 */
2625 e1000_update_mc_addr_list(hw, NULL, 0, 1, mac->rar_entry_count); 2610 e1000_update_mc_addr_list(hw, NULL, 0);
2626 } 2611 }
2627} 2612}
2628 2613
@@ -3482,7 +3467,7 @@ static void e1000_print_link_info(struct e1000_adapter *adapter)
3482 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" ))); 3467 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" )));
3483} 3468}
3484 3469
3485bool e1000_has_link(struct e1000_adapter *adapter) 3470bool e1000e_has_link(struct e1000_adapter *adapter)
3486{ 3471{
3487 struct e1000_hw *hw = &adapter->hw; 3472 struct e1000_hw *hw = &adapter->hw;
3488 bool link_active = 0; 3473 bool link_active = 0;
@@ -3563,7 +3548,7 @@ static void e1000_watchdog_task(struct work_struct *work)
3563 u32 link, tctl; 3548 u32 link, tctl;
3564 int tx_pending = 0; 3549 int tx_pending = 0;
3565 3550
3566 link = e1000_has_link(adapter); 3551 link = e1000e_has_link(adapter);
3567 if ((netif_carrier_ok(netdev)) && link) { 3552 if ((netif_carrier_ok(netdev)) && link) {
3568 e1000e_enable_receives(adapter); 3553 e1000e_enable_receives(adapter);
3569 goto link_up; 3554 goto link_up;
@@ -5134,7 +5119,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5134 5119
5135 e1000_eeprom_checks(adapter); 5120 e1000_eeprom_checks(adapter);
5136 5121
5137 /* copy the MAC address out of the NVM */ 5122 /* copy the MAC address */
5138 if (e1000e_read_mac_addr(&adapter->hw)) 5123 if (e1000e_read_mac_addr(&adapter->hw))
5139 e_err("NVM Read Error while reading MAC address\n"); 5124 e_err("NVM Read Error while reading MAC address\n");
5140 5125
@@ -5326,7 +5311,7 @@ static struct pci_error_handlers e1000_err_handler = {
5326 .resume = e1000_io_resume, 5311 .resume = e1000_io_resume,
5327}; 5312};
5328 5313
5329static struct pci_device_id e1000_pci_tbl[] = { 5314static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
5330 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_COPPER), board_82571 }, 5315 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_COPPER), board_82571 },
5331 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_FIBER), board_82571 }, 5316 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_FIBER), board_82571 },
5332 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER), board_82571 }, 5317 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82571EB_QUAD_COPPER), board_82571 },