From: Jeff Kirsher Date: Fri, 28 Mar 2008 16:15:16 +0000 (-0700) Subject: e1000e: reorganize PHY and flow control interface X-Git-Tag: v2.6.26-rc1~1138^2~270^2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=318a94d68979cbe9cc98a3050b4b7be2f08513c8;p=linux-2.6 e1000e: reorganize PHY and flow control interface This reorganization moves the PHY status into a separate struct. Flow Control setup is moved into this struct as well and frame size away from here into the adapter struct where its inly use is. The post-link-up code is now a separate function and moved out of the watchdog function itself. This allows us to track the es2lan restart issue a bit easier. Signed-off-by: Jeff Kirsher Signed-off-by: Bruce Allan Signed-off-by: Jesse Brandeburg Signed-off-by: Auke Kok Signed-off-by: Jeff Garzik --- diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c index f5a4d40000..f7e1619b97 100644 --- a/drivers/net/e1000e/82571.c +++ b/drivers/net/e1000e/82571.c @@ -75,7 +75,7 @@ static s32 e1000_init_phy_params_82571(struct e1000_hw *hw) struct e1000_phy_info *phy = &hw->phy; s32 ret_val; - if (hw->media_type != e1000_media_type_copper) { + if (hw->phy.media_type != e1000_media_type_copper) { phy->type = e1000_phy_none; return 0; } @@ -195,16 +195,16 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) case E1000_DEV_ID_82571EB_FIBER: case E1000_DEV_ID_82572EI_FIBER: case E1000_DEV_ID_82571EB_QUAD_FIBER: - hw->media_type = e1000_media_type_fiber; + hw->phy.media_type = e1000_media_type_fiber; break; case E1000_DEV_ID_82571EB_SERDES: case E1000_DEV_ID_82572EI_SERDES: case E1000_DEV_ID_82571EB_SERDES_DUAL: case E1000_DEV_ID_82571EB_SERDES_QUAD: - hw->media_type = e1000_media_type_internal_serdes; + hw->phy.media_type = e1000_media_type_internal_serdes; break; default: - hw->media_type = e1000_media_type_copper; + hw->phy.media_type = e1000_media_type_copper; break; } @@ -216,7 +216,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) mac->arc_subsystem_valid = (er32(FWSM) & E1000_FWSM_MODE_MASK) ? 1 : 0; /* check for link */ - switch (hw->media_type) { + switch (hw->phy.media_type) { case e1000_media_type_copper: func->setup_physical_interface = e1000_setup_copper_link_82571; func->check_for_link = e1000e_check_for_copper_link; @@ -1015,7 +1015,7 @@ static s32 e1000_setup_link_82571(struct e1000_hw *hw) * set it to full. */ if (hw->mac.type == e1000_82573) - hw->mac.fc = e1000_fc_full; + hw->fc.type = e1000_fc_full; return e1000e_setup_link(hw); } diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h index 499adb26dc..b941a6b509 100644 --- a/drivers/net/e1000e/e1000.h +++ b/drivers/net/e1000e/e1000.h @@ -234,6 +234,8 @@ struct e1000_adapter { unsigned int rx_ps_pages; u16 rx_ps_bsize0; + u32 max_frame_size; + u32 min_frame_size; /* OS defined structs */ struct net_device *netdev; @@ -258,7 +260,7 @@ struct e1000_adapter { u32 wol; u32 pba; - u8 fc_autoneg; + bool fc_autoneg; unsigned long led_status; @@ -305,6 +307,7 @@ struct e1000_info { #define FLAG_MSI_ENABLED (1 << 27) #define FLAG_RX_CSUM_ENABLED (1 << 28) #define FLAG_TSO_FORCE (1 << 29) +#define FLAG_RX_RESTART_NOW (1 << 30) #define E1000_RX_DESC_PS(R, i) \ (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c index df27824739..e3f4aeefea 100644 --- a/drivers/net/e1000e/es2lan.c +++ b/drivers/net/e1000e/es2lan.c @@ -119,7 +119,7 @@ static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw) struct e1000_phy_info *phy = &hw->phy; s32 ret_val; - if (hw->media_type != e1000_media_type_copper) { + if (hw->phy.media_type != e1000_media_type_copper) { phy->type = e1000_phy_none; return 0; } @@ -198,10 +198,10 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter) /* Set media type */ switch (adapter->pdev->device) { case E1000_DEV_ID_80003ES2LAN_SERDES_DPT: - hw->media_type = e1000_media_type_internal_serdes; + hw->phy.media_type = e1000_media_type_internal_serdes; break; default: - hw->media_type = e1000_media_type_copper; + hw->phy.media_type = e1000_media_type_copper; break; } @@ -213,7 +213,7 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter) mac->arc_subsystem_valid = (er32(FWSM) & E1000_FWSM_MODE_MASK) ? 1 : 0; /* check for link */ - switch (hw->media_type) { + switch (hw->phy.media_type) { case e1000_media_type_copper: func->setup_physical_interface = e1000_setup_copper_link_80003es2lan; func->check_for_link = e1000e_check_for_copper_link; @@ -591,7 +591,7 @@ static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw) udelay(1); - if (hw->phy.wait_for_link) { + if (hw->phy.autoneg_wait_to_complete) { hw_dbg(hw, "Waiting for forced speed/duplex link " "on GG82563 phy.\n"); @@ -682,7 +682,7 @@ static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed, { s32 ret_val; - if (hw->media_type == e1000_media_type_copper) { + if (hw->phy.media_type == e1000_media_type_copper) { ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex); @@ -854,7 +854,7 @@ static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw) /* Transmit Arbitration Control 0 */ reg = er32(TARC0); reg &= ~(0xF << 27); /* 30:27 */ - if (hw->media_type != e1000_media_type_copper) + if (hw->phy.media_type != e1000_media_type_copper) reg &= ~(1 << 20); ew32(TARC0, reg); diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c index 3b94a87b52..4ae00567bb 100644 --- a/drivers/net/e1000e/ethtool.c +++ b/drivers/net/e1000e/ethtool.c @@ -111,7 +111,7 @@ static int e1000_get_settings(struct net_device *netdev, struct e1000_hw *hw = &adapter->hw; u32 status; - if (hw->media_type == e1000_media_type_copper) { + if (hw->phy.media_type == e1000_media_type_copper) { ecmd->supported = (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | @@ -165,7 +165,7 @@ static int e1000_get_settings(struct net_device *netdev, ecmd->duplex = -1; } - ecmd->autoneg = ((hw->media_type == e1000_media_type_fiber) || + ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) || hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE; return 0; } @@ -187,7 +187,7 @@ static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx) mac->autoneg = 0; /* Fiber NICs only allow 1000 gbps Full duplex */ - if ((adapter->hw.media_type == e1000_media_type_fiber) && + if ((adapter->hw.phy.media_type == e1000_media_type_fiber) && spddplx != (SPEED_1000 + DUPLEX_FULL)) { ndev_err(adapter->netdev, "Unsupported Speed/Duplex " "configuration\n"); @@ -241,7 +241,7 @@ static int e1000_set_settings(struct net_device *netdev, if (ecmd->autoneg == AUTONEG_ENABLE) { hw->mac.autoneg = 1; - if (hw->media_type == e1000_media_type_fiber) + if (hw->phy.media_type == e1000_media_type_fiber) hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full | ADVERTISED_FIBRE | ADVERTISED_Autoneg; @@ -250,6 +250,8 @@ static int e1000_set_settings(struct net_device *netdev, ADVERTISED_TP | ADVERTISED_Autoneg; ecmd->advertising = hw->phy.autoneg_advertised; + if (adapter->fc_autoneg) + hw->fc.original_type = e1000_fc_default; } else { if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { clear_bit(__E1000_RESETTING, &adapter->state); @@ -279,11 +281,11 @@ static void e1000_get_pauseparam(struct net_device *netdev, pause->autoneg = (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); - if (hw->mac.fc == e1000_fc_rx_pause) { + if (hw->fc.type == e1000_fc_rx_pause) { pause->rx_pause = 1; - } else if (hw->mac.fc == e1000_fc_tx_pause) { + } else if (hw->fc.type == e1000_fc_tx_pause) { pause->tx_pause = 1; - } else if (hw->mac.fc == e1000_fc_full) { + } else if (hw->fc.type == e1000_fc_full) { pause->rx_pause = 1; pause->tx_pause = 1; } @@ -302,18 +304,18 @@ static int e1000_set_pauseparam(struct net_device *netdev, msleep(1); if (pause->rx_pause && pause->tx_pause) - hw->mac.fc = e1000_fc_full; + hw->fc.type = e1000_fc_full; else if (pause->rx_pause && !pause->tx_pause) - hw->mac.fc = e1000_fc_rx_pause; + hw->fc.type = e1000_fc_rx_pause; else if (!pause->rx_pause && pause->tx_pause) - hw->mac.fc = e1000_fc_tx_pause; + hw->fc.type = e1000_fc_tx_pause; else if (!pause->rx_pause && !pause->tx_pause) - hw->mac.fc = e1000_fc_none; + hw->fc.type = e1000_fc_none; - hw->mac.original_fc = hw->mac.fc; + hw->fc.original_type = hw->fc.type; if (adapter->fc_autoneg == AUTONEG_ENABLE) { - hw->mac.fc = e1000_fc_default; + hw->fc.type = e1000_fc_default; if (netif_running(adapter->netdev)) { e1000e_down(adapter); e1000e_up(adapter); @@ -321,7 +323,7 @@ static int e1000_set_pauseparam(struct net_device *netdev, e1000e_reset(adapter); } } else { - retval = ((hw->media_type == e1000_media_type_fiber) ? + retval = ((hw->phy.media_type == e1000_media_type_fiber) ? hw->mac.ops.setup_link(hw) : e1000e_force_mac_fc(hw)); } @@ -1187,21 +1189,21 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) u32 ctrl_reg = 0; u32 stat_reg = 0; - adapter->hw.mac.autoneg = 0; + hw->mac.autoneg = 0; - if (adapter->hw.phy.type == e1000_phy_m88) { + if (hw->phy.type == e1000_phy_m88) { /* Auto-MDI/MDIX Off */ e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, 0x0808); /* reset to update Auto-MDI/MDIX */ e1e_wphy(hw, PHY_CONTROL, 0x9140); /* autoneg off */ e1e_wphy(hw, PHY_CONTROL, 0x8140); - } else if (adapter->hw.phy.type == e1000_phy_gg82563) + } else if (hw->phy.type == e1000_phy_gg82563) e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x1CC); ctrl_reg = er32(CTRL); - if (adapter->hw.phy.type == e1000_phy_ife) { + if (hw->phy.type == e1000_phy_ife) { /* force 100, set loopback */ e1e_wphy(hw, PHY_CONTROL, 0x6100); @@ -1224,8 +1226,8 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) E1000_CTRL_FD); /* Force Duplex to FULL */ } - if (adapter->hw.media_type == e1000_media_type_copper && - adapter->hw.phy.type == e1000_phy_m88) { + if (hw->phy.media_type == e1000_media_type_copper && + hw->phy.type == e1000_phy_m88) { ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */ } else { /* @@ -1243,7 +1245,7 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) * Disable the receiver on the PHY so when a cable is plugged in, the * PHY does not begin to autoneg when a cable is reconnected to the NIC. */ - if (adapter->hw.phy.type == e1000_phy_m88) + if (hw->phy.type == e1000_phy_m88) e1000_phy_disable_receiver(adapter); udelay(500); @@ -1333,8 +1335,8 @@ static int e1000_setup_loopback_test(struct e1000_adapter *adapter) struct e1000_hw *hw = &adapter->hw; u32 rctl; - if (hw->media_type == e1000_media_type_fiber || - hw->media_type == e1000_media_type_internal_serdes) { + if (hw->phy.media_type == e1000_media_type_fiber || + hw->phy.media_type == e1000_media_type_internal_serdes) { switch (hw->mac.type) { case e1000_80003es2lan: return e1000_set_es2lan_mac_loopback(adapter); @@ -1349,7 +1351,7 @@ static int e1000_setup_loopback_test(struct e1000_adapter *adapter) ew32(RCTL, rctl); return 0; } - } else if (hw->media_type == e1000_media_type_copper) { + } else if (hw->phy.media_type == e1000_media_type_copper) { return e1000_integrated_phy_loopback(adapter); } @@ -1368,8 +1370,8 @@ static void e1000_loopback_cleanup(struct e1000_adapter *adapter) switch (hw->mac.type) { case e1000_80003es2lan: - if (hw->media_type == e1000_media_type_fiber || - hw->media_type == e1000_media_type_internal_serdes) { + if (hw->phy.media_type == e1000_media_type_fiber || + hw->phy.media_type == e1000_media_type_internal_serdes) { /* restore CTRL_EXT, stealing space from tx_fifo_head */ ew32(CTRL_EXT, adapter->tx_fifo_head); adapter->tx_fifo_head = 0; @@ -1377,8 +1379,8 @@ static void e1000_loopback_cleanup(struct e1000_adapter *adapter) /* fall through */ case e1000_82571: case e1000_82572: - if (hw->media_type == e1000_media_type_fiber || - hw->media_type == e1000_media_type_internal_serdes) { + if (hw->phy.media_type == e1000_media_type_fiber || + hw->phy.media_type == e1000_media_type_internal_serdes) { #define E1000_SERDES_LB_OFF 0x400 ew32(SCTL, E1000_SERDES_LB_OFF); msleep(10); @@ -1528,7 +1530,7 @@ static int e1000_link_test(struct e1000_adapter *adapter, u64 *data) struct e1000_hw *hw = &adapter->hw; *data = 0; - if (hw->media_type == e1000_media_type_internal_serdes) { + if (hw->phy.media_type == e1000_media_type_internal_serdes) { int i = 0; hw->mac.serdes_has_link = 0; @@ -1624,9 +1626,9 @@ static void e1000_diag_test(struct net_device *netdev, adapter->hw.mac.autoneg = autoneg; /* force this routine to wait until autoneg complete/timeout */ - adapter->hw.phy.wait_for_link = 1; + adapter->hw.phy.autoneg_wait_to_complete = 1; e1000e_reset(adapter); - adapter->hw.phy.wait_for_link = 0; + adapter->hw.phy.autoneg_wait_to_complete = 0; clear_bit(__E1000_TESTING, &adapter->state); if (if_running) diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h index b582d78f05..0b4145a732 100644 --- a/drivers/net/e1000e/hw.h +++ b/drivers/net/e1000e/hw.h @@ -400,7 +400,7 @@ enum e1000_rev_polarity{ e1000_rev_polarity_undefined = 0xFF }; -enum e1000_fc_mode { +enum e1000_fc_type { e1000_fc_none = 0, e1000_fc_rx_pause, e1000_fc_tx_pause, @@ -727,16 +727,12 @@ struct e1000_mac_info { u8 perm_addr[6]; enum e1000_mac_type type; - enum e1000_fc_mode fc; - enum e1000_fc_mode original_fc; u32 collision_delta; u32 ledctl_default; u32 ledctl_mode1; u32 ledctl_mode2; - u32 max_frame_size; u32 mc_filter_type; - u32 min_frame_size; u32 tx_packet_delta; u32 txcw; @@ -747,9 +743,6 @@ struct e1000_mac_info { u16 ifs_step_size; u16 mta_reg_count; u16 rar_entry_count; - u16 fc_high_water; - u16 fc_low_water; - u16 fc_pause_time; u8 forced_speed_duplex; @@ -779,6 +772,8 @@ struct e1000_phy_info { u32 reset_delay_us; /* in usec */ u32 revision; + enum e1000_media_type media_type; + u16 autoneg_advertised; u16 autoneg_mask; u16 cable_length; @@ -791,7 +786,7 @@ struct e1000_phy_info { bool is_mdix; bool polarity_correction; bool speed_downgraded; - bool wait_for_link; + bool autoneg_wait_to_complete; }; struct e1000_nvm_info { @@ -816,6 +811,16 @@ struct e1000_bus_info { u16 func; }; +struct e1000_fc_info { + u32 high_water; /* Flow control high-water mark */ + u32 low_water; /* Flow control low-water mark */ + u16 pause_time; /* Flow control pause timer */ + bool send_xon; /* Flow control send XON */ + bool strict_ieee; /* Strict IEEE mode */ + enum e1000_fc_type type; /* Type of flow control */ + enum e1000_fc_type original_type; +}; + struct e1000_dev_spec_82571 { bool laa_is_present; bool alt_mac_addr_is_present; @@ -840,6 +845,7 @@ struct e1000_hw { u8 __iomem *flash_address; struct e1000_mac_info mac; + struct e1000_fc_info fc; struct e1000_phy_info phy; struct e1000_nvm_info nvm; struct e1000_bus_info bus; @@ -849,8 +855,6 @@ struct e1000_hw { struct e1000_dev_spec_82571 e82571; struct e1000_dev_spec_ich8lan ich8lan; } dev_spec; - - enum e1000_media_type media_type; }; #ifdef DEBUG diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c index eed1b44969..e358a773e6 100644 --- a/drivers/net/e1000e/ich8lan.c +++ b/drivers/net/e1000e/ich8lan.c @@ -298,7 +298,7 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter) struct e1000_mac_info *mac = &hw->mac; /* Set media type function pointer */ - hw->media_type = e1000_media_type_copper; + hw->phy.media_type = e1000_media_type_copper; /* Set mta register count */ mac->mta_reg_count = 32; @@ -453,7 +453,7 @@ static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw) udelay(1); - if (phy->wait_for_link) { + if (phy->autoneg_wait_to_complete) { hw_dbg(hw, "Waiting for forced speed/duplex link on IFE phy.\n"); ret_val = e1000e_phy_has_link_generic(hw, @@ -1852,7 +1852,6 @@ static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw) **/ static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw) { - struct e1000_mac_info *mac = &hw->mac; s32 ret_val; if (e1000_check_reset_block(hw)) @@ -1863,19 +1862,19 @@ static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw) * the default flow control setting, so we explicitly * set it to full. */ - if (mac->fc == e1000_fc_default) - mac->fc = e1000_fc_full; + if (hw->fc.type == e1000_fc_default) + hw->fc.type = e1000_fc_full; - mac->original_fc = mac->fc; + hw->fc.original_type = hw->fc.type; - hw_dbg(hw, "After fix-ups FlowControl is now = %x\n", mac->fc); + hw_dbg(hw, "After fix-ups FlowControl is now = %x\n", hw->fc.type); /* Continue to configure the copper link. */ ret_val = e1000_setup_copper_link_ich8lan(hw); if (ret_val) return ret_val; - ew32(FCTTV, mac->fc_pause_time); + ew32(FCTTV, hw->fc.pause_time); return e1000e_set_fc_watermarks(hw); } diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c index 9c3ce719e8..ea3ff6369c 100644 --- a/drivers/net/e1000e/lib.c +++ b/drivers/net/e1000e/lib.c @@ -603,7 +603,6 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw) **/ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) { - struct e1000_mac_info *mac = &hw->mac; s32 ret_val; u16 nvm_data; @@ -624,12 +623,12 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) } if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0) - mac->fc = e1000_fc_none; + hw->fc.type = e1000_fc_none; else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == NVM_WORD0F_ASM_DIR) - mac->fc = e1000_fc_tx_pause; + hw->fc.type = e1000_fc_tx_pause; else - mac->fc = e1000_fc_full; + hw->fc.type = e1000_fc_full; return 0; } @@ -660,7 +659,7 @@ s32 e1000e_setup_link(struct e1000_hw *hw) * If flow control is set to default, set flow control based on * the EEPROM flow control settings. */ - if (mac->fc == e1000_fc_default) { + if (hw->fc.type == e1000_fc_default) { ret_val = e1000_set_default_fc_generic(hw); if (ret_val) return ret_val; @@ -671,9 +670,9 @@ s32 e1000e_setup_link(struct e1000_hw *hw) * in case we get disconnected and then reconnected into a different * hub or switch with different Flow Control capabilities. */ - mac->original_fc = mac->fc; + hw->fc.original_type = hw->fc.type; - hw_dbg(hw, "After fix-ups FlowControl is now = %x\n", mac->fc); + hw_dbg(hw, "After fix-ups FlowControl is now = %x\n", hw->fc.type); /* Call the necessary media_type subroutine to configure the link. */ ret_val = mac->ops.setup_physical_interface(hw); @@ -691,7 +690,7 @@ s32 e1000e_setup_link(struct e1000_hw *hw) ew32(FCAH, FLOW_CONTROL_ADDRESS_HIGH); ew32(FCAL, FLOW_CONTROL_ADDRESS_LOW); - ew32(FCTTV, mac->fc_pause_time); + ew32(FCTTV, hw->fc.pause_time); return e1000e_set_fc_watermarks(hw); } @@ -725,7 +724,7 @@ static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw) * do not support receiving pause frames). * 3: Both Rx and Tx flow control (symmetric) are enabled. */ - switch (mac->fc) { + switch (hw->fc.type) { case e1000_fc_none: /* Flow control completely disabled by a software over-ride. */ txcw = (E1000_TXCW_ANE | E1000_TXCW_FD); @@ -857,7 +856,7 @@ s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw) * detect a signal. If we have a signal, then poll for a "Link-Up" * indication. */ - if (hw->media_type == e1000_media_type_internal_serdes || + if (hw->phy.media_type == e1000_media_type_internal_serdes || (er32(CTRL) & E1000_CTRL_SWDPIN1)) { ret_val = e1000_poll_fiber_serdes_link_generic(hw); } else { @@ -898,7 +897,6 @@ void e1000e_config_collision_dist(struct e1000_hw *hw) **/ s32 e1000e_set_fc_watermarks(struct e1000_hw *hw) { - struct e1000_mac_info *mac = &hw->mac; u32 fcrtl = 0, fcrth = 0; /* @@ -908,15 +906,15 @@ s32 e1000e_set_fc_watermarks(struct e1000_hw *hw) * ability to transmit pause frames is not enabled, then these * registers will be set to 0. */ - if (mac->fc & e1000_fc_tx_pause) { + if (hw->fc.type & e1000_fc_tx_pause) { /* * We need to set up the Receive Threshold high and low water * marks as well as (optionally) enabling the transmission of * XON frames. */ - fcrtl = mac->fc_low_water; + fcrtl = hw->fc.low_water; fcrtl |= E1000_FCRTL_XONE; - fcrth = mac->fc_high_water; + fcrth = hw->fc.high_water; } ew32(FCRTL, fcrtl); ew32(FCRTH, fcrth); @@ -936,7 +934,6 @@ s32 e1000e_set_fc_watermarks(struct e1000_hw *hw) **/ s32 e1000e_force_mac_fc(struct e1000_hw *hw) { - struct e1000_mac_info *mac = &hw->mac; u32 ctrl; ctrl = er32(CTRL); @@ -948,7 +945,7 @@ s32 e1000e_force_mac_fc(struct e1000_hw *hw) * receive flow control. * * The "Case" statement below enables/disable flow control - * according to the "mac->fc" parameter. + * according to the "hw->fc.type" parameter. * * The possible values of the "fc" parameter are: * 0: Flow control is completely disabled @@ -959,9 +956,9 @@ s32 e1000e_force_mac_fc(struct e1000_hw *hw) * 3: Both Rx and Tx flow control (symmetric) is enabled. * other: No other values should be possible at this point. */ - hw_dbg(hw, "mac->fc = %u\n", mac->fc); + hw_dbg(hw, "hw->fc.type = %u\n", hw->fc.type); - switch (mac->fc) { + switch (hw->fc.type) { case e1000_fc_none: ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE)); break; @@ -1009,11 +1006,11 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) * configuration of the MAC to match the "fc" parameter. */ if (mac->autoneg_failed) { - if (hw->media_type == e1000_media_type_fiber || - hw->media_type == e1000_media_type_internal_serdes) + if (hw->phy.media_type == e1000_media_type_fiber || + hw->phy.media_type == e1000_media_type_internal_serdes) ret_val = e1000e_force_mac_fc(hw); } else { - if (hw->media_type == e1000_media_type_copper) + if (hw->phy.media_type == e1000_media_type_copper) ret_val = e1000e_force_mac_fc(hw); } @@ -1028,7 +1025,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) * has completed, and if so, how the PHY and link partner has * flow control configured. */ - if ((hw->media_type == e1000_media_type_copper) && mac->autoneg) { + if ((hw->phy.media_type == e1000_media_type_copper) && mac->autoneg) { /* * Read the MII Status Register and check to see if AutoNeg * has completed. We read this twice because this reg has @@ -1105,11 +1102,11 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) * ONLY. Hence, we must now check to see if we need to * turn OFF the TRANSMISSION of PAUSE frames. */ - if (mac->original_fc == e1000_fc_full) { - mac->fc = e1000_fc_full; + if (hw->fc.original_type == e1000_fc_full) { + hw->fc.type = e1000_fc_full; hw_dbg(hw, "Flow Control = FULL.\r\n"); } else { - mac->fc = e1000_fc_rx_pause; + hw->fc.type = e1000_fc_rx_pause; hw_dbg(hw, "Flow Control = " "RX PAUSE frames only.\r\n"); } @@ -1127,8 +1124,8 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { - mac->fc = e1000_fc_tx_pause; - hw_dbg(hw, "Flow Control = TX PAUSE frames only.\r\n"); + hw->fc.type = e1000_fc_tx_pause; + hw_dbg(hw, "Flow Control = Tx PAUSE frames only.\r\n"); } /* * For transmitting PAUSE frames ONLY. @@ -1143,14 +1140,14 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { - mac->fc = e1000_fc_rx_pause; - hw_dbg(hw, "Flow Control = RX PAUSE frames only.\r\n"); + hw->fc.type = e1000_fc_rx_pause; + hw_dbg(hw, "Flow Control = Rx PAUSE frames only.\r\n"); } else { /* * Per the IEEE spec, at this point flow control * should be disabled. */ - mac->fc = e1000_fc_none; + hw->fc.type = e1000_fc_none; hw_dbg(hw, "Flow Control = NONE.\r\n"); } @@ -1166,7 +1163,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) } if (duplex == HALF_DUPLEX) - mac->fc = e1000_fc_none; + hw->fc.type = e1000_fc_none; /* * Now we call a subroutine to actually force the MAC @@ -1436,7 +1433,7 @@ s32 e1000e_blink_led(struct e1000_hw *hw) u32 ledctl_blink = 0; u32 i; - if (hw->media_type == e1000_media_type_fiber) { + if (hw->phy.media_type == e1000_media_type_fiber) { /* always blink LED0 for PCI-E fiber */ ledctl_blink = E1000_LEDCTL_LED0_BLINK | (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT); @@ -1468,7 +1465,7 @@ s32 e1000e_led_on_generic(struct e1000_hw *hw) { u32 ctrl; - switch (hw->media_type) { + switch (hw->phy.media_type) { case e1000_media_type_fiber: ctrl = er32(CTRL); ctrl &= ~E1000_CTRL_SWDPIN0; @@ -1495,7 +1492,7 @@ s32 e1000e_led_off_generic(struct e1000_hw *hw) { u32 ctrl; - switch (hw->media_type) { + switch (hw->phy.media_type) { case e1000_media_type_fiber: ctrl = er32(CTRL); ctrl |= E1000_CTRL_SWDPIN0; diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index 2e07534c35..d70bde0361 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c @@ -878,6 +878,7 @@ static irqreturn_t e1000_intr_msi(int irq, void *data) /* disable receives */ u32 rctl = er32(RCTL); ew32(RCTL, rctl & ~E1000_RCTL_EN); + adapter->flags |= FLAG_RX_RESTART_NOW; } /* guard against interrupt when we're going down */ if (!test_bit(__E1000_DOWN, &adapter->state)) @@ -944,6 +945,7 @@ static irqreturn_t e1000_intr(int irq, void *data) /* disable receives */ rctl = er32(RCTL); ew32(RCTL, rctl & ~E1000_RCTL_EN); + adapter->flags |= FLAG_RX_RESTART_NOW; } /* guard against interrupt when we're going down */ if (!test_bit(__E1000_DOWN, &adapter->state)) @@ -1794,6 +1796,8 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) } ew32(RCTL, rctl); + /* just started the receive unit, no need to restart */ + adapter->flags &= ~FLAG_RX_RESTART_NOW; } /** @@ -2003,7 +2007,7 @@ void e1000e_power_up_phy(struct e1000_adapter *adapter) u16 mii_reg = 0; /* Just clear the power down bit to wake the phy back up */ - if (adapter->hw.media_type == e1000_media_type_copper) { + if (adapter->hw.phy.media_type == e1000_media_type_copper) { /* * According to the manual, the phy will retain its * settings across a power-down/up cycle @@ -2032,7 +2036,7 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter) return; /* non-copper PHY? */ - if (adapter->hw.media_type != e1000_media_type_copper) + if (adapter->hw.phy.media_type != e1000_media_type_copper) return; /* reset is blocked because of a SoL/IDER session */ @@ -2061,15 +2065,16 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter) void e1000e_reset(struct e1000_adapter *adapter) { struct e1000_mac_info *mac = &adapter->hw.mac; + struct e1000_fc_info *fc = &adapter->hw.fc; struct e1000_hw *hw = &adapter->hw; u32 tx_space, min_tx_space, min_rx_space; - u32 pba; + u32 pba = adapter->pba; u16 hwm; /* reset Packet Buffer Allocation to default */ - ew32(PBA, adapter->pba); + ew32(PBA, pba); - if (mac->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN ) { + if (adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) { /* * To maintain wire speed transmits, the Tx FIFO should be * large enough to accommodate two full transmit packets, @@ -2086,13 +2091,14 @@ void e1000e_reset(struct e1000_adapter *adapter) /* * the Tx fifo also stores 16 bytes of information about the tx * but don't include ethernet FCS because hardware appends it - */ min_tx_space = (mac->max_frame_size + + */ + min_tx_space = (adapter->max_frame_size + sizeof(struct e1000_tx_desc) - ETH_FCS_LEN) * 2; min_tx_space = ALIGN(min_tx_space, 1024); min_tx_space >>= 10; /* software strips receive CRC, so leave room for it */ - min_rx_space = mac->max_frame_size; + min_rx_space = adapter->max_frame_size; min_rx_space = ALIGN(min_rx_space, 1024); min_rx_space >>= 10; @@ -2131,20 +2137,21 @@ void e1000e_reset(struct e1000_adapter *adapter) * - the full Rx FIFO size minus one full frame */ if (adapter->flags & FLAG_HAS_ERT) - hwm = min(((adapter->pba << 10) * 9 / 10), - ((adapter->pba << 10) - (E1000_ERT_2048 << 3))); + hwm = min(((pba << 10) * 9 / 10), + ((pba << 10) - (E1000_ERT_2048 << 3))); else - hwm = min(((adapter->pba << 10) * 9 / 10), - ((adapter->pba << 10) - mac->max_frame_size)); + hwm = min(((pba << 10) * 9 / 10), + ((pba << 10) - adapter->max_frame_size)); - mac->fc_high_water = hwm & 0xFFF8; /* 8-byte granularity */ - mac->fc_low_water = mac->fc_high_water - 8; + fc->high_water = hwm & 0xFFF8; /* 8-byte granularity */ + fc->low_water = fc->high_water - 8; if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME) - mac->fc_pause_time = 0xFFFF; + fc->pause_time = 0xFFFF; else - mac->fc_pause_time = E1000_FC_PAUSE_TIME; - mac->fc = mac->original_fc; + fc->pause_time = E1000_FC_PAUSE_TIME; + fc->send_xon = 1; + fc->type = fc->original_type; /* Allow time for pending master requests to run */ mac->ops.reset_hw(hw); @@ -2259,13 +2266,12 @@ void e1000e_reinit_locked(struct e1000_adapter *adapter) **/ static int __devinit e1000_sw_init(struct e1000_adapter *adapter) { - struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN; adapter->rx_ps_bsize0 = 128; - hw->mac.max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; - hw->mac.min_frame_size = ETH_ZLEN + ETH_FCS_LEN; + adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; + adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); if (!adapter->tx_ring) @@ -2611,7 +2617,7 @@ void e1000e_update_stats(struct e1000_adapter *adapter) /* Tx Dropped needs to be maintained elsewhere */ /* Phy Stats */ - if (hw->media_type == e1000_media_type_copper) { + if (hw->phy.media_type == e1000_media_type_copper) { if ((adapter->link_speed == SPEED_1000) && (!e1e_rphy(hw, PHY_1000T_STATUS, &phy_tmp))) { phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK; @@ -2629,8 +2635,8 @@ void e1000e_update_stats(struct e1000_adapter *adapter) static void e1000_print_link_info(struct e1000_adapter *adapter) { - struct net_device *netdev = adapter->netdev; struct e1000_hw *hw = &adapter->hw; + struct net_device *netdev = adapter->netdev; u32 ctrl = er32(CTRL); ndev_info(netdev, @@ -2644,6 +2650,62 @@ static void e1000_print_link_info(struct e1000_adapter *adapter) ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" ))); } +static bool e1000_has_link(struct e1000_adapter *adapter) +{ + struct e1000_hw *hw = &adapter->hw; + bool link_active = 0; + s32 ret_val = 0; + + /* + * get_link_status is set on LSC (link status) interrupt or + * Rx sequence error interrupt. get_link_status will stay + * false until the check_for_link establishes link + * for copper adapters ONLY + */ + switch (hw->phy.media_type) { + case e1000_media_type_copper: + if (hw->mac.get_link_status) { + ret_val = hw->mac.ops.check_for_link(hw); + link_active = !hw->mac.get_link_status; + } else { + link_active = 1; + } + break; + case e1000_media_type_fiber: + ret_val = hw->mac.ops.check_for_link(hw); + link_active = !!(er32(STATUS) & E1000_STATUS_LU); + break; + case e1000_media_type_internal_serdes: + ret_val = hw->mac.ops.check_for_link(hw); + link_active = adapter->hw.mac.serdes_has_link; + break; + default: + case e1000_media_type_unknown: + break; + } + + if ((ret_val == E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) && + (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) { + /* See e1000_kmrn_lock_loss_workaround_ich8lan() */ + ndev_info(adapter->netdev, + "Gigabit has been disabled, downgrading speed\n"); + } + + return link_active; +} + +static void e1000e_enable_receives(struct e1000_adapter *adapter) +{ + /* make sure the receive unit is started */ + if ((adapter->flags & FLAG_RX_NEEDS_RESTART) && + (adapter->flags & FLAG_RX_RESTART_NOW)) { + struct e1000_hw *hw = &adapter->hw; + u32 rctl = er32(RCTL); + ew32(RCTL, rctl | E1000_RCTL_EN); + adapter->flags &= ~FLAG_RX_RESTART_NOW; + } +} + /** * e1000_watchdog - Timer Call-back * @data: pointer to adapter cast into an unsigned long @@ -2662,42 +2724,27 @@ static void e1000_watchdog_task(struct work_struct *work) { struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, watchdog_task); - struct net_device *netdev = adapter->netdev; struct e1000_mac_info *mac = &adapter->hw.mac; struct e1000_ring *tx_ring = adapter->tx_ring; struct e1000_hw *hw = &adapter->hw; u32 link, tctl; - s32 ret_val; int tx_pending = 0; - if ((netif_carrier_ok(netdev)) && - (er32(STATUS) & E1000_STATUS_LU)) + link = e1000_has_link(adapter); + if ((netif_carrier_ok(netdev)) && link) { + e1000e_enable_receives(adapter); goto link_up; - - ret_val = mac->ops.check_for_link(hw); - if ((ret_val == E1000_ERR_PHY) && - (adapter->hw.phy.type == e1000_phy_igp_3) && - (er32(CTRL) & - E1000_PHY_CTRL_GBE_DISABLE)) { - /* See e1000_kmrn_lock_loss_workaround_ich8lan() */ - ndev_info(netdev, - "Gigabit has been disabled, downgrading speed\n"); } if ((e1000e_enable_tx_pkt_filtering(hw)) && (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id)) e1000_update_mng_vlan(adapter); - if ((adapter->hw.media_type == e1000_media_type_internal_serdes) && - !(er32(TXCW) & E1000_TXCW_ANE)) - link = adapter->hw.mac.serdes_has_link; - else - link = er32(STATUS) & E1000_STATUS_LU; - if (link) { if (!netif_carrier_ok(netdev)) { bool txb2b = 1; + /* update snapshot of PHY registers on LSC */ mac->ops.get_link_up_info(&adapter->hw, &adapter->link_speed, &adapter->link_duplex); @@ -2770,13 +2817,6 @@ static void e1000_watchdog_task(struct work_struct *work) if (!test_bit(__E1000_DOWN, &adapter->state)) mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ)); - } else { - /* make sure the receive unit is started */ - if (adapter->flags & FLAG_RX_NEEDS_RESTART) { - u32 rctl = er32(RCTL); - ew32(RCTL, rctl | - E1000_RCTL_EN); - } } } else { if (netif_carrier_ok(netdev)) { @@ -3413,7 +3453,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) msleep(1); /* e1000e_down has a dependency on max_frame_size */ - adapter->hw.mac.max_frame_size = max_frame; + adapter->max_frame_size = max_frame; if (netif_running(netdev)) e1000e_down(adapter); @@ -3462,7 +3502,7 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, struct mii_ioctl_data *data = if_mii(ifr); unsigned long irq_flags; - if (adapter->hw.media_type != e1000_media_type_copper) + if (adapter->hw.phy.media_type != e1000_media_type_copper) return -EOPNOTSUPP; switch (cmd) { @@ -3544,8 +3584,9 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state) E1000_CTRL_EN_PHY_PWR_MGMT; ew32(CTRL, ctrl); - if (adapter->hw.media_type == e1000_media_type_fiber || - adapter->hw.media_type == e1000_media_type_internal_serdes) { + if (adapter->hw.phy.media_type == e1000_media_type_fiber || + adapter->hw.phy.media_type == + e1000_media_type_internal_serdes) { /* keep the laser running in D3 */ ctrl_ext = er32(CTRL_EXT); ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA; @@ -3939,10 +3980,10 @@ static int __devinit e1000_probe(struct pci_dev *pdev, hw->mac.ops.get_bus_info(&adapter->hw); - adapter->hw.phy.wait_for_link = 0; + adapter->hw.phy.autoneg_wait_to_complete = 0; /* Copper options */ - if (adapter->hw.media_type == e1000_media_type_copper) { + if (adapter->hw.phy.media_type == e1000_media_type_copper) { adapter->hw.phy.mdix = AUTO_ALL_MODES; adapter->hw.phy.disable_polarity_correction = 0; adapter->hw.phy.ms_type = e1000_ms_hw_default; @@ -4028,8 +4069,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev, /* Initialize link parameters. User can change them with ethtool */ adapter->hw.mac.autoneg = 1; adapter->fc_autoneg = 1; - adapter->hw.mac.original_fc = e1000_fc_default; - adapter->hw.mac.fc = e1000_fc_default; + adapter->hw.fc.original_type = e1000_fc_default; + adapter->hw.fc.type = e1000_fc_default; adapter->hw.phy.autoneg_advertised = 0x2f; /* ring size defaults */ diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c index a2da1c4223..3a4574caa7 100644 --- a/drivers/net/e1000e/phy.c +++ b/drivers/net/e1000e/phy.c @@ -714,7 +714,7 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw) * other: No software override. The flow control configuration * in the EEPROM is used. */ - switch (hw->mac.fc) { + switch (hw->fc.type) { case e1000_fc_none: /* * Flow control (Rx & Tx) is completely disabled by a @@ -822,7 +822,7 @@ static s32 e1000_copper_link_autoneg(struct e1000_hw *hw) * Does the user want to wait for Auto-Neg to complete here, or * check at a later time (for example, callback routine). */ - if (phy->wait_for_link) { + if (phy->autoneg_wait_to_complete) { ret_val = e1000_wait_autoneg(hw); if (ret_val) { hw_dbg(hw, "Error while waiting for " @@ -937,7 +937,7 @@ s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw) udelay(1); - if (phy->wait_for_link) { + if (phy->autoneg_wait_to_complete) { hw_dbg(hw, "Waiting for forced speed/duplex link on IGP phy.\n"); ret_val = e1000e_phy_has_link_generic(hw, @@ -1009,7 +1009,7 @@ s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw) udelay(1); - if (phy->wait_for_link) { + if (phy->autoneg_wait_to_complete) { hw_dbg(hw, "Waiting for forced speed/duplex link on M88 phy.\n"); ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, @@ -1084,7 +1084,7 @@ void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl) u32 ctrl; /* Turn off flow control when forcing speed/duplex */ - mac->fc = e1000_fc_none; + hw->fc.type = e1000_fc_none; /* Force speed/duplex on the mac */ ctrl = er32(CTRL); @@ -1508,7 +1508,7 @@ s32 e1000e_get_phy_info_m88(struct e1000_hw *hw) u16 phy_data; bool link; - if (hw->media_type != e1000_media_type_copper) { + if (hw->phy.media_type != e1000_media_type_copper) { hw_dbg(hw, "Phy info is only valid for copper media\n"); return -E1000_ERR_CONFIG; }