e1000e: provide MAC-family-specific function to set LAN ID
authorBruce Allan <bruce.w.allan@intel.com>
Wed, 13 Jan 2010 02:05:18 +0000 (02:05 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 14 Jan 2010 04:31:57 +0000 (20:31 -0800)
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 <bruce.w.allan@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/e1000e/82571.c
drivers/net/e1000e/e1000.h
drivers/net/e1000e/es2lan.c
drivers/net/e1000e/hw.h
drivers/net/e1000e/ich8lan.c
drivers/net/e1000e/lib.c

index d1a45143c2aa933f813a104a36134e96be87b604..7674a91824bc0f7937cbc466cf7fe465264b85eb 100644 (file)
@@ -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,
index 7c91e4bdd36108dd5ba1e586a8231f35b588f7e5..8b311ce0400ec8daec00ea50e207d6ac66e43b00 100644 (file)
@@ -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);
index 4bb9d88ad97697502617d6eff9b47db65fdab462..27d21589a69afa128e7a6f0be459703a6e917053 100644 (file)
@@ -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,
index 127e6a226da19a816bded699f0b33dd939b9dbc9..9cac5d9b94b8ed4d9222d00a17cf8b547b5a3ea8 100644 (file)
@@ -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 *);
index ad08cf3f40c0ba830c350585b39dd8dae75df4fa..061cd100aac20e6be3bd60804ab19936e04b973a 100644 (file)
@@ -3302,6 +3302,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 */
index 547542428edccb7eacaab031045b204821706086..5f6b17148d34eb42908f3955a73ebd0021e7e6d4 100644 (file)
@@ -51,10 +51,10 @@ enum e1000_mng_mode {
  **/
 s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw)
 {
+       struct e1000_mac_info *mac = &hw->mac;
        struct e1000_bus_info *bus = &hw->bus;
        struct e1000_adapter *adapter = hw->adapter;
-       u32 status;
-       u16 pcie_link_status, pci_header_type, cap_offset;
+       u16 pcie_link_status, cap_offset;
 
        cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
        if (!cap_offset) {
@@ -68,19 +68,45 @@ s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw)
                                                    PCIE_LINK_WIDTH_SHIFT);
        }
 
-       pci_read_config_word(adapter->pdev, PCI_HEADER_TYPE_REGISTER,
-                            &pci_header_type);
-       if (pci_header_type & PCI_HEADER_TYPE_MULTIFUNC) {
-               status = er32(STATUS);
-               bus->func = (status & E1000_STATUS_FUNC_MASK)
-                           >> E1000_STATUS_FUNC_SHIFT;
-       } else {
-               bus->func = 0;
-       }
+       mac->ops.set_lan_id(hw);
 
        return 0;
 }
 
+/**
+ *  e1000_set_lan_id_multi_port_pcie - Set LAN id for PCIe multiple port devices
+ *
+ *  @hw: pointer to the HW structure
+ *
+ *  Determines the LAN function id by reading memory-mapped registers
+ *  and swaps the port value if requested.
+ **/
+void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw)
+{
+       struct e1000_bus_info *bus = &hw->bus;
+       u32 reg;
+
+       /*
+        * The status register reports the correct function number
+        * for the device regardless of function swap state.
+        */
+       reg = er32(STATUS);
+       bus->func = (reg & E1000_STATUS_FUNC_MASK) >> E1000_STATUS_FUNC_SHIFT;
+}
+
+/**
+ *  e1000_set_lan_id_single_port - Set LAN id for a single port device
+ *  @hw: pointer to the HW structure
+ *
+ *  Sets the LAN function id to zero for a single port device.
+ **/
+void e1000_set_lan_id_single_port(struct e1000_hw *hw)
+{
+       struct e1000_bus_info *bus = &hw->bus;
+
+       bus->func = 0;
+}
+
 /**
  *  e1000_clear_vfta_generic - Clear VLAN filter table
  *  @hw: pointer to the HW structure