e1000e: use alternate MAC address on ESB2 if available
Subsystems (2)
PATCH 1/3 e1000e: use alternate MAC address on ESB2 if available
From: Bruce Allan <[email protected]>
Similar to 82571/2/3 parts that already do this, if ESB2/80003es2lan parts have an alternate MAC address provided in the EEPROM use it instead of the default MAC address. This patch makes the the actual code that does this generic so that it can be better used by both MAC families.
---
drivers/net/e1000e/82571.c | 33 ++++++++++- drivers/net/e1000e/defines.h | 2 + drivers/net/e1000e/e1000.h | 11 +++- drivers/net/e1000e/es2lan.c | 28 +++++++++ drivers/net/e1000e/hw.h | 5 +- drivers/net/e1000e/lib.c | 124 +++++++++++++++++++++++++----------------- drivers/net/e1000e/netdev.c | 2 - 7 files changed, 147 insertions(+), 58 deletions(-)
drivers/net/e1000e/82571.c +30 -3
@@ -922,9 +922,12 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)ew32 (IMC ,0xffffffff ); icr =er32 (ICR ); -if (hw->mac.type == e1000_82571 && - hw->dev_spec.e82571.alt_mac_addr_is_present) -e1000e_set_laa_state_82571 (hw, true); +/* Install any alternate MAC address into RAR0 */ + ret_val =e1000_check_alt_mac_addr_generic (hw); +if (ret_val) +return ret_val; + +e1000e_set_laa_state_82571 (hw, true);/* Reinitialize the 82571 serdes link state machine */ if (hw->phy.media_type == e1000_media_type_internal_serdes)
@@ -1621,6 +1624,29 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw) }/** +* e1000_read_mac_addr_82571 - Read device MAC address +* @hw: pointer to the HW structure +**/ +static s32 e1000_read_mac_addr_82571 (struct e1000_hw *hw) +{ +s32 ret_val =0 ; + +/* +* If there's an alternate MAC address place it in RAR0 +* so that it will override the Si installed default perm +* address. +*/ + ret_val =e1000_check_alt_mac_addr_generic (hw); +if (ret_val) + goto out; + + ret_val =e1000_read_mac_addr_generic (hw); + +out: +return ret_val; +} + +/** * e1000_power_down_phy_copper_82571 - Remove link during PHY power down * @hw: pointer to the HW structure *
@@ -1706,6 +1732,7 @@ static struct e1000_mac_operations e82571_mac_ops = { .setup_link = e1000_setup_link_82571, /* .setup_physical_interface: media type dependent */ .setup_led = e1000e_setup_led_generic, + .read_mac_addr = e1000_read_mac_addr_82571, };static struct e1000_phy_operations e82_phy_ops_igp = {
drivers/net/e1000e/defines.h +2 -0
@@ -460,6 +460,8 @@*/ #define E1000_RAR_ENTRIES 15#define E1000_RAH_AV 0x80000000/* Receive descriptor valid */ +#define E1000_RAL_MAC_ADDR_LEN 4 +#define E1000_RAH_MAC_ADDR_LEN 2/* Error Codes */ #define E1000_ERR_NVM 1
drivers/net/e1000e/e1000.h +10 -1
@@ -529,6 +529,7 @@ extern s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw);extern s32 e1000e_force_mac_fc (struct e1000_hw *hw);extern s32 e1000e_blink_led (struct e1000_hw *hw);extern void e1000_write_vfta_generic (struct e1000_hw *hw,u32 offset,u32 value); +extern s32 e1000_check_alt_mac_addr_generic (struct e1000_hw *hw);extern void e1000e_reset_adaptive (struct e1000_hw *hw);extern void e1000e_update_adaptive (struct e1000_hw *hw);
@@ -628,7 +629,15 @@ extern s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16extern s32 e1000e_validate_nvm_checksum_generic (struct e1000_hw *hw);extern void e1000e_release_nvm (struct e1000_hw *hw);extern void e1000e_reload_nvm (struct e1000_hw *hw); -extern s32 e1000e_read_mac_addr (struct e1000_hw *hw); +extern s32 e1000_read_mac_addr_generic (struct e1000_hw *hw); + +static inline s32 e1000e_read_mac_addr (struct e1000_hw *hw) +{ +if (hw->mac.ops.read_mac_addr) +return hw->mac.ops.read_mac_addr (hw); + +return e1000_read_mac_addr_generic (hw); +}static inline s32 e1000_validate_nvm_checksum (struct e1000_hw *hw) {
drivers/net/e1000e/es2lan.c +27 -1
@@ -814,7 +814,9 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)ew32 (IMC ,0xffffffff ); icr =er32 (ICR ); -return 0 ; + ret_val =e1000_check_alt_mac_addr_generic (hw); + +return ret_val; }/**
@@ -1340,6 +1342,29 @@ static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, }/** +* e1000_read_mac_addr_80003es2lan - Read device MAC address +* @hw: pointer to the HW structure +**/ +static s32 e1000_read_mac_addr_80003es2lan (struct e1000_hw *hw) +{ +s32 ret_val =0 ; + +/* +* If there's an alternate MAC address place it in RAR0 +* so that it will override the Si installed default perm +* address. +*/ + ret_val =e1000_check_alt_mac_addr_generic (hw); +if (ret_val) + goto out; + + ret_val =e1000_read_mac_addr_generic (hw); + +out: +return ret_val; +} + +/** * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down * @hw: pointer to the HW structure *
@@ -1403,6 +1428,7 @@ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw) }static struct e1000_mac_operations es2_mac_ops = { + .read_mac_addr = e1000_read_mac_addr_80003es2lan, .id_led_init = e1000e_id_led_init, .check_mng_mode = e1000e_check_mng_mode_generic,/* check_for_link dependent on media type */
drivers/net/e1000e/hw.h +4 -1
@@ -389,6 +389,9 @@ enum e1e_registers {#define E1000_FUNC_1 1 +#define E1000_ALT_MAC_ADDRESS_OFFSET_LAN0 0 +#define E1000_ALT_MAC_ADDRESS_OFFSET_LAN1 3 +enum e1000_mac_type { e1000_82571, e1000_82572,
@@ -756,6 +759,7 @@ struct e1000_mac_operations {s32 (*setup_physical_interface)(struct e1000_hw *);s32 (*setup_led)(struct e1000_hw *);void (*write_vfta)(struct e1000_hw *,u32 ,u32 ); +s32 (*read_mac_addr)(struct e1000_hw *); };/* Function pointers for the PHY. */
@@ -897,7 +901,6 @@ struct e1000_fc_info {struct e1000_dev_spec_82571 {bool laa_is_present; -bool alt_mac_addr_is_present;u32 smb_counter; };
drivers/net/e1000e/lib.c +73 -51
146 lines not on this page · raw message
drivers/net/e1000e/netdev.c +1 -1
@@ -5135,7 +5135,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,e1000_eeprom_checks (adapter); -/* copy the MAC address out of the NVM */ +/* copy the MAC address */ if (e1000e_read_mac_addr (&adapter->hw))e_err ("NVM Read Error while reading MAC address\n" );
PATCH 2/3 e1000e: provide MAC-family-specific function to set LAN ID
From: Bruce Allan <[email protected]>
Provide MAC-specific function pointer to determine the LAN ID (PCI func). The LAN ID is used internally by the driver to determine which h/w lock to use to protect accessing the PHY on ESB2 as well as help to determine the alternate MAC address on some parts.
---
drivers/net/e1000e/82571.c | 7 ++++++ drivers/net/e1000e/e1000.h | 2 ++ drivers/net/e1000e/es2lan.c | 4 ++++ drivers/net/e1000e/hw.h | 1 + drivers/net/e1000e/ich8lan.c | 1 + drivers/net/e1000e/lib.c | 48 ++++++++++++++++++++++++++++++++---------- 6 files changed, 52 insertions(+), 11 deletions(-)
drivers/net/e1000e/82571.c +7 -0
@@ -267,8 +267,14 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) }switch (hw->mac.type) { +case e1000_82573: + func->set_lan_id = e1000_set_lan_id_single_port; + func->check_mng_mode = e1000e_check_mng_mode_generic; + func->led_on = e1000e_led_on_generic; +break ;case e1000_82574:case e1000_82583: + func->set_lan_id = e1000_set_lan_id_single_port; func->check_mng_mode = e1000_check_mng_mode_82574; func->led_on = e1000_led_on_82574;break ;
@@ -1721,6 +1727,7 @@ static struct e1000_mac_operations e82571_mac_ops = { .cleanup_led = e1000e_cleanup_led_generic, .clear_hw_cntrs = e1000_clear_hw_cntrs_82571, .get_bus_info = e1000e_get_bus_info_pcie, + .set_lan_id = e1000_set_lan_id_multi_port_pcie,/* .get_link_up_info: media type dependent */ /* .led_on: mac type dependent */ .led_off = e1000e_led_off_generic,
drivers/net/e1000e/e1000.h +2 -0
@@ -502,6 +502,8 @@ extern s32 e1000e_cleanup_led_generic(struct e1000_hw *hw);extern s32 e1000e_led_on_generic (struct e1000_hw *hw);extern s32 e1000e_led_off_generic (struct e1000_hw *hw);extern s32 e1000e_get_bus_info_pcie (struct e1000_hw *hw); +extern void e1000_set_lan_id_multi_port_pcie (struct e1000_hw *hw); +extern void e1000_set_lan_id_single_port (struct e1000_hw *hw);extern s32 e1000e_get_speed_and_duplex_copper (struct e1000_hw *hw,u16 *speed,u16 *duplex);extern s32 e1000e_get_speed_and_duplex_fiber_serdes (struct e1000_hw *hw,u16 *speed,u16 *duplex);extern s32 e1000e_disable_pcie_master (struct e1000_hw *hw);
drivers/net/e1000e/es2lan.c +4 -0
@@ -246,6 +246,9 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)break ; } +/* set lan id for port to determine which phy lock to use */ + hw->mac.ops.set_lan_id (hw); +return 0 ; }
@@ -1435,6 +1438,7 @@ static struct e1000_mac_operations es2_mac_ops = { .cleanup_led = e1000e_cleanup_led_generic, .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan, .get_bus_info = e1000e_get_bus_info_pcie, + .set_lan_id = e1000_set_lan_id_multi_port_pcie, .get_link_up_info = e1000_get_link_up_info_80003es2lan, .led_on = e1000e_led_on_generic, .led_off = e1000e_led_off_generic,
drivers/net/e1000e/hw.h +1 -0
@@ -749,6 +749,7 @@ struct e1000_mac_operations {void (*clear_hw_cntrs)(struct e1000_hw *);void (*clear_vfta)(struct e1000_hw *);s32 (*get_bus_info)(struct e1000_hw *); +void (*set_lan_id)(struct e1000_hw *);s32 (*get_link_up_info)(struct e1000_hw *,u16 *,u16 *);s32 (*led_on)(struct e1000_hw *);s32 (*led_off)(struct e1000_hw *);
drivers/net/e1000e/ich8lan.c +1 -0
@@ -3368,6 +3368,7 @@ static struct e1000_mac_operations ich8_mac_ops = {/* cleanup_led dependent on mac type */ .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan, .get_bus_info = e1000_get_bus_info_ich8lan, + .set_lan_id = e1000_set_lan_id_single_port, .get_link_up_info = e1000_get_link_up_info_ich8lan,/* led_on dependent on mac type */ /* led_off dependent on mac type */
drivers/net/e1000e/lib.c +37 -11
67 lines not on this page · raw message
PATCH 3/3 e1000e: genericize the update multicast address list
In reply to Jeff KirsherFrom: Bruce Allan <[email protected]>
Make updating the multicast address list generic for all families and enforce the requirement to update the entire multicast table array all at once instead of piecemeal which causes problems on some parts.
---
drivers/net/e1000e/82571.c | 28 +-------------------- drivers/net/e1000e/e1000.h | 4 +-- drivers/net/e1000e/hw.h | 6 ++++ drivers/net/e1000e/lib.c | 58 +++++++++++-------------------------------- drivers/net/e1000e/netdev.c | 20 ++++----------- 5 files changed, 27 insertions(+), 89 deletions(-)
drivers/net/e1000e/82571.c +1 -27
@@ -1234,32 +1234,6 @@ static s32 e1000_led_on_82574(struct e1000_hw *hw) }/** -* e1000_update_mc_addr_list_82571 - Update Multicast addresses -* @hw: pointer to the HW structure -* @mc_addr_list: array of multicast addresses to program -* @mc_addr_count: number of multicast addresses to program -* @rar_used_count: the first RAR register free to program -* @rar_count: total number of supported Receive Address Registers -* -* Updates the Receive Address Registers and Multicast Table Array. -* The caller must have a packed mc_addr_list of multicast addresses. -* The parameter rar_count will usually be hw->mac.rar_entry_count -* unless there are workarounds that change this. -**/ -static void e1000_update_mc_addr_list_82571 (struct e1000_hw *hw, -u8 *mc_addr_list, -u32 mc_addr_count, -u32 rar_used_count, -u32 rar_count) -{ -if (e1000e_get_laa_state_82571 (hw)) - rar_count--; - -e1000e_update_mc_addr_list_generic (hw, mc_addr_list, mc_addr_count, - rar_used_count, rar_count); -} - -/** * e1000_setup_link_82571 - Setup flow control and link settings * @hw: pointer to the HW structure *
@@ -1731,7 +1705,7 @@ static struct e1000_mac_operations e82571_mac_ops = {/* .get_link_up_info: media type dependent */ /* .led_on: mac type dependent */ .led_off = e1000e_led_off_generic, - .update_mc_addr_list = e1000_update_mc_addr_list_82571, + .update_mc_addr_list = e1000e_update_mc_addr_list_generic, .write_vfta = e1000_write_vfta_generic, .clear_vfta = e1000_clear_vfta_82571, .reset_hw = e1000_reset_hw_82571,
drivers/net/e1000e/e1000.h +1 -3
@@ -518,9 +518,7 @@ extern void e1000_clear_vfta_generic(struct e1000_hw *hw);extern void e1000e_init_rx_addrs (struct e1000_hw *hw,u16 rar_count);extern void e1000e_update_mc_addr_list_generic (struct e1000_hw *hw,u8 *mc_addr_list, -u32 mc_addr_count, -u32 rar_used_count, -u32 rar_count); +u32 mc_addr_count);extern void e1000e_rar_set (struct e1000_hw *hw,u8 *addr,u32 index);extern s32 e1000e_set_fc_watermarks (struct e1000_hw *hw);extern void e1000e_set_pcie_no_snoop (struct e1000_hw *hw,u32 no_snoop);
drivers/net/e1000e/hw.h +5 -1
@@ -753,7 +753,7 @@ struct e1000_mac_operations {s32 (*get_link_up_info)(struct e1000_hw *,u16 *,u16 *);s32 (*led_on)(struct e1000_hw *);s32 (*led_off)(struct e1000_hw *); -void (*update_mc_addr_list)(struct e1000_hw *,u8 *,u32 ,u32 ,u32 ); +void (*update_mc_addr_list)(struct e1000_hw *,u8 *,u32 );s32 (*reset_hw)(struct e1000_hw *);s32 (*init_hw)(struct e1000_hw *);s32 (*setup_link)(struct e1000_hw *);
@@ -819,6 +819,10 @@ struct e1000_mac_info {u16 ifs_ratio;u16 ifs_step_size;u16 mta_reg_count; + +/* Maximum size of the MTA register table in all supported adapters */ +#define MAX_MTA_REG 128 +u32 mta_shadow[MAX_MTA_REG ];u16 rar_entry_count;u8 forced_speed_duplex;
drivers/net/e1000e/lib.c +15 -43
77 lines not on this page · raw message
drivers/net/e1000e/netdev.c +5 -15
@@ -2536,22 +2536,14 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)* @hw: pointer to the HW structure * @mc_addr_list: array of multicast addresses to program * @mc_addr_count: number of multicast addresses to program -* @rar_used_count: the first RAR register free to program -* @rar_count: total number of supported Receive Address Registers * -* Updates the Receive Address Registers and Multicast Table Array. +* Updates the Multicast Table Array. * The caller must have a packed mc_addr_list of multicast addresses. -* The parameter rar_count will usually be hw->mac.rar_entry_count -* unless there are workarounds that change this. Currently no func pointer -* exists and all implementations are handled in the generic version of this -* function. **/ static void e1000_update_mc_addr_list (struct e1000_hw *hw,u8 *mc_addr_list, -u32 mc_addr_count,u32 rar_used_count, -u32 rar_count) +u32 mc_addr_count) { - hw->mac.ops.update_mc_addr_list (hw, mc_addr_list, mc_addr_count, - rar_used_count, rar_count); + hw->mac.ops.update_mc_addr_list (hw, mc_addr_list, mc_addr_count); }/**
@@ -2567,7 +2559,6 @@ static void e1000_set_multi(struct net_device *netdev) {struct e1000_adapter *adapter =netdev_priv (netdev);struct e1000_hw *hw = &adapter->hw; -struct e1000_mac_info *mac = &hw->mac;struct dev_mc_list *mc_ptr;u8 *mta_list;u32 rctl;
@@ -2609,15 +2600,14 @@ static void e1000_set_multi(struct net_device *netdev) mc_ptr = mc_ptr->next; } -e1000_update_mc_addr_list (hw, mta_list, i,1 , - mac->rar_entry_count); +e1000_update_mc_addr_list (hw, mta_list, i);kfree (mta_list); }else {/* * if we're called from probe, we might not have * anything to do here, so clear out the list */ -e1000_update_mc_addr_list (hw,NULL ,0 ,1 , mac->rar_entry_count); +e1000_update_mc_addr_list (hw,NULL ,0 ); } }
From: Jeff Kirsher <[email protected]>
Date: Wed, 13 Jan 2010 04:04:58 -0800
Quoted 9 lines
From: Bruce Allan <[email protected]>
Similar to 82571/2/3 parts that already do this, if ESB2/80003es2lan parts have an alternate MAC address provided in the EEPROM use it instead of the default MAC address. This patch makes the the actual code that does this generic so that it can be better used by both MAC families.
Signed-off-by Bruce Allan <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
Re: [net-next-2.6 PATCH 2/3] e1000e: provide MAC-family-specific function to set LAN ID
In reply to Jeff KirsherFrom: Jeff Kirsher <[email protected]>
Date: Wed, 13 Jan 2010 04:05:18 -0800
Quoted 9 lines
From: Bruce Allan <[email protected]>
Provide MAC-specific function pointer to determine the LAN ID (PCI func). The LAN ID is used internally by the driver to determine which h/w lock to use to protect accessing the PHY on ESB2 as well as help to determine the alternate MAC address on some parts.
Signed-off-by Bruce Allan <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.
Re: [net-next-2.6 PATCH 3/3] e1000e: genericize the update multicast address list
In reply to Jeff KirsherFrom: Jeff Kirsher <[email protected]>
Date: Wed, 13 Jan 2010 04:05:38 -0800
Quoted 8 lines
From: Bruce Allan <[email protected]>
Make updating the multicast address list generic for all families and enforce the requirement to update the entire multicast table array all at once instead of piecemeal which causes problems on some parts.
Signed-off-by Bruce Allan <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Applied.