aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/netdev.c
diff options
context:
space:
mode:
authorJeff Kirsher <jeffrey.t.kirsher@intel.com>2008-03-28 12:15:16 -0400
committerJeff Garzik <jeff@garzik.org>2008-03-28 22:15:00 -0400
commit318a94d68979cbe9cc98a3050b4b7be2f08513c8 (patch)
tree32fdd0bd9f4a0c9dcc2a958b18820286a9acdcec /drivers/net/e1000e/netdev.c
parente2de3eb69c40c01739ce9b154c65e51d94d72966 (diff)
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 <jeffrey.t.kirsher@intel.com> Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/e1000e/netdev.c')
-rw-r--r--drivers/net/e1000e/netdev.c151
1 files changed, 96 insertions, 55 deletions
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 2e07534c35f..d70bde03619 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)
878 /* disable receives */ 878 /* disable receives */
879 u32 rctl = er32(RCTL); 879 u32 rctl = er32(RCTL);
880 ew32(RCTL, rctl & ~E1000_RCTL_EN); 880 ew32(RCTL, rctl & ~E1000_RCTL_EN);
881 adapter->flags |= FLAG_RX_RESTART_NOW;
881 } 882 }
882 /* guard against interrupt when we're going down */ 883 /* guard against interrupt when we're going down */
883 if (!test_bit(__E1000_DOWN, &adapter->state)) 884 if (!test_bit(__E1000_DOWN, &adapter->state))
@@ -944,6 +945,7 @@ static irqreturn_t e1000_intr(int irq, void *data)
944 /* disable receives */ 945 /* disable receives */
945 rctl = er32(RCTL); 946 rctl = er32(RCTL);
946 ew32(RCTL, rctl & ~E1000_RCTL_EN); 947 ew32(RCTL, rctl & ~E1000_RCTL_EN);
948 adapter->flags |= FLAG_RX_RESTART_NOW;
947 } 949 }
948 /* guard against interrupt when we're going down */ 950 /* guard against interrupt when we're going down */
949 if (!test_bit(__E1000_DOWN, &adapter->state)) 951 if (!test_bit(__E1000_DOWN, &adapter->state))
@@ -1794,6 +1796,8 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
1794 } 1796 }
1795 1797
1796 ew32(RCTL, rctl); 1798 ew32(RCTL, rctl);
1799 /* just started the receive unit, no need to restart */
1800 adapter->flags &= ~FLAG_RX_RESTART_NOW;
1797} 1801}
1798 1802
1799/** 1803/**
@@ -2003,7 +2007,7 @@ void e1000e_power_up_phy(struct e1000_adapter *adapter)
2003 u16 mii_reg = 0; 2007 u16 mii_reg = 0;
2004 2008
2005 /* Just clear the power down bit to wake the phy back up */ 2009 /* Just clear the power down bit to wake the phy back up */
2006 if (adapter->hw.media_type == e1000_media_type_copper) { 2010 if (adapter->hw.phy.media_type == e1000_media_type_copper) {
2007 /* 2011 /*
2008 * According to the manual, the phy will retain its 2012 * According to the manual, the phy will retain its
2009 * settings across a power-down/up cycle 2013 * settings across a power-down/up cycle
@@ -2032,7 +2036,7 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter)
2032 return; 2036 return;
2033 2037
2034 /* non-copper PHY? */ 2038 /* non-copper PHY? */
2035 if (adapter->hw.media_type != e1000_media_type_copper) 2039 if (adapter->hw.phy.media_type != e1000_media_type_copper)
2036 return; 2040 return;
2037 2041
2038 /* reset is blocked because of a SoL/IDER session */ 2042 /* reset is blocked because of a SoL/IDER session */
@@ -2061,15 +2065,16 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter)
2061void e1000e_reset(struct e1000_adapter *adapter) 2065void e1000e_reset(struct e1000_adapter *adapter)
2062{ 2066{
2063 struct e1000_mac_info *mac = &adapter->hw.mac; 2067 struct e1000_mac_info *mac = &adapter->hw.mac;
2068 struct e1000_fc_info *fc = &adapter->hw.fc;
2064 struct e1000_hw *hw = &adapter->hw; 2069 struct e1000_hw *hw = &adapter->hw;
2065 u32 tx_space, min_tx_space, min_rx_space; 2070 u32 tx_space, min_tx_space, min_rx_space;
2066 u32 pba; 2071 u32 pba = adapter->pba;
2067 u16 hwm; 2072 u16 hwm;
2068 2073
2069 /* reset Packet Buffer Allocation to default */ 2074 /* reset Packet Buffer Allocation to default */
2070 ew32(PBA, adapter->pba); 2075 ew32(PBA, pba);
2071 2076
2072 if (mac->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN ) { 2077 if (adapter->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) {
2073 /* 2078 /*
2074 * To maintain wire speed transmits, the Tx FIFO should be 2079 * To maintain wire speed transmits, the Tx FIFO should be
2075 * large enough to accommodate two full transmit packets, 2080 * large enough to accommodate two full transmit packets,
@@ -2086,13 +2091,14 @@ void e1000e_reset(struct e1000_adapter *adapter)
2086 /* 2091 /*
2087 * the Tx fifo also stores 16 bytes of information about the tx 2092 * the Tx fifo also stores 16 bytes of information about the tx
2088 * but don't include ethernet FCS because hardware appends it 2093 * but don't include ethernet FCS because hardware appends it
2089 */ min_tx_space = (mac->max_frame_size + 2094 */
2095 min_tx_space = (adapter->max_frame_size +
2090 sizeof(struct e1000_tx_desc) - 2096 sizeof(struct e1000_tx_desc) -
2091 ETH_FCS_LEN) * 2; 2097 ETH_FCS_LEN) * 2;
2092 min_tx_space = ALIGN(min_tx_space, 1024); 2098 min_tx_space = ALIGN(min_tx_space, 1024);
2093 min_tx_space >>= 10; 2099 min_tx_space >>= 10;
2094 /* software strips receive CRC, so leave room for it */ 2100 /* software strips receive CRC, so leave room for it */
2095 min_rx_space = mac->max_frame_size; 2101 min_rx_space = adapter->max_frame_size;
2096 min_rx_space = ALIGN(min_rx_space, 1024); 2102 min_rx_space = ALIGN(min_rx_space, 1024);
2097 min_rx_space >>= 10; 2103 min_rx_space >>= 10;
2098 2104
@@ -2131,20 +2137,21 @@ void e1000e_reset(struct e1000_adapter *adapter)
2131 * - the full Rx FIFO size minus one full frame 2137 * - the full Rx FIFO size minus one full frame
2132 */ 2138 */
2133 if (adapter->flags & FLAG_HAS_ERT) 2139 if (adapter->flags & FLAG_HAS_ERT)
2134 hwm = min(((adapter->pba << 10) * 9 / 10), 2140 hwm = min(((pba << 10) * 9 / 10),
2135 ((adapter->pba << 10) - (E1000_ERT_2048 << 3))); 2141 ((pba << 10) - (E1000_ERT_2048 << 3)));
2136 else 2142 else
2137 hwm = min(((adapter->pba << 10) * 9 / 10), 2143 hwm = min(((pba << 10) * 9 / 10),
2138 ((adapter->pba << 10) - mac->max_frame_size)); 2144 ((pba << 10) - adapter->max_frame_size));
2139 2145
2140 mac->fc_high_water = hwm & 0xFFF8; /* 8-byte granularity */ 2146 fc->high_water = hwm & 0xFFF8; /* 8-byte granularity */
2141 mac->fc_low_water = mac->fc_high_water - 8; 2147 fc->low_water = fc->high_water - 8;
2142 2148
2143 if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME) 2149 if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME)
2144 mac->fc_pause_time = 0xFFFF; 2150 fc->pause_time = 0xFFFF;
2145 else 2151 else
2146 mac->fc_pause_time = E1000_FC_PAUSE_TIME; 2152 fc->pause_time = E1000_FC_PAUSE_TIME;
2147 mac->fc = mac->original_fc; 2153 fc->send_xon = 1;
2154 fc->type = fc->original_type;
2148 2155
2149 /* Allow time for pending master requests to run */ 2156 /* Allow time for pending master requests to run */
2150 mac->ops.reset_hw(hw); 2157 mac->ops.reset_hw(hw);
@@ -2259,13 +2266,12 @@ void e1000e_reinit_locked(struct e1000_adapter *adapter)
2259 **/ 2266 **/
2260static int __devinit e1000_sw_init(struct e1000_adapter *adapter) 2267static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
2261{ 2268{
2262 struct e1000_hw *hw = &adapter->hw;
2263 struct net_device *netdev = adapter->netdev; 2269 struct net_device *netdev = adapter->netdev;
2264 2270
2265 adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN; 2271 adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN;
2266 adapter->rx_ps_bsize0 = 128; 2272 adapter->rx_ps_bsize0 = 128;
2267 hw->mac.max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; 2273 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
2268 hw->mac.min_frame_size = ETH_ZLEN + ETH_FCS_LEN; 2274 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
2269 2275
2270 adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); 2276 adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
2271 if (!adapter->tx_ring) 2277 if (!adapter->tx_ring)
@@ -2611,7 +2617,7 @@ void e1000e_update_stats(struct e1000_adapter *adapter)
2611 /* Tx Dropped needs to be maintained elsewhere */ 2617 /* Tx Dropped needs to be maintained elsewhere */
2612 2618
2613 /* Phy Stats */ 2619 /* Phy Stats */
2614 if (hw->media_type == e1000_media_type_copper) { 2620 if (hw->phy.media_type == e1000_media_type_copper) {
2615 if ((adapter->link_speed == SPEED_1000) && 2621 if ((adapter->link_speed == SPEED_1000) &&
2616 (!e1e_rphy(hw, PHY_1000T_STATUS, &phy_tmp))) { 2622 (!e1e_rphy(hw, PHY_1000T_STATUS, &phy_tmp))) {
2617 phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK; 2623 phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
@@ -2629,8 +2635,8 @@ void e1000e_update_stats(struct e1000_adapter *adapter)
2629 2635
2630static void e1000_print_link_info(struct e1000_adapter *adapter) 2636static void e1000_print_link_info(struct e1000_adapter *adapter)
2631{ 2637{
2632 struct net_device *netdev = adapter->netdev;
2633 struct e1000_hw *hw = &adapter->hw; 2638 struct e1000_hw *hw = &adapter->hw;
2639 struct net_device *netdev = adapter->netdev;
2634 u32 ctrl = er32(CTRL); 2640 u32 ctrl = er32(CTRL);
2635 2641
2636 ndev_info(netdev, 2642 ndev_info(netdev,
@@ -2644,6 +2650,62 @@ static void e1000_print_link_info(struct e1000_adapter *adapter)
2644 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" ))); 2650 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None" )));
2645} 2651}
2646 2652
2653static bool e1000_has_link(struct e1000_adapter *adapter)
2654{
2655 struct e1000_hw *hw = &adapter->hw;
2656 bool link_active = 0;
2657 s32 ret_val = 0;
2658
2659 /*
2660 * get_link_status is set on LSC (link status) interrupt or
2661 * Rx sequence error interrupt. get_link_status will stay
2662 * false until the check_for_link establishes link
2663 * for copper adapters ONLY
2664 */
2665 switch (hw->phy.media_type) {
2666 case e1000_media_type_copper:
2667 if (hw->mac.get_link_status) {
2668 ret_val = hw->mac.ops.check_for_link(hw);
2669 link_active = !hw->mac.get_link_status;
2670 } else {
2671 link_active = 1;
2672 }
2673 break;
2674 case e1000_media_type_fiber:
2675 ret_val = hw->mac.ops.check_for_link(hw);
2676 link_active = !!(er32(STATUS) & E1000_STATUS_LU);
2677 break;
2678 case e1000_media_type_internal_serdes:
2679 ret_val = hw->mac.ops.check_for_link(hw);
2680 link_active = adapter->hw.mac.serdes_has_link;
2681 break;
2682 default:
2683 case e1000_media_type_unknown:
2684 break;
2685 }
2686
2687 if ((ret_val == E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) &&
2688 (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
2689 /* See e1000_kmrn_lock_loss_workaround_ich8lan() */
2690 ndev_info(adapter->netdev,
2691 "Gigabit has been disabled, downgrading speed\n");
2692 }
2693
2694 return link_active;
2695}
2696
2697static void e1000e_enable_receives(struct e1000_adapter *adapter)
2698{
2699 /* make sure the receive unit is started */
2700 if ((adapter->flags & FLAG_RX_NEEDS_RESTART) &&
2701 (adapter->flags & FLAG_RX_RESTART_NOW)) {
2702 struct e1000_hw *hw = &adapter->hw;
2703 u32 rctl = er32(RCTL);
2704 ew32(RCTL, rctl | E1000_RCTL_EN);
2705 adapter->flags &= ~FLAG_RX_RESTART_NOW;
2706 }
2707}
2708
2647/** 2709/**
2648 * e1000_watchdog - Timer Call-back 2710 * e1000_watchdog - Timer Call-back
2649 * @data: pointer to adapter cast into an unsigned long 2711 * @data: pointer to adapter cast into an unsigned long
@@ -2662,42 +2724,27 @@ static void e1000_watchdog_task(struct work_struct *work)
2662{ 2724{
2663 struct e1000_adapter *adapter = container_of(work, 2725 struct e1000_adapter *adapter = container_of(work,
2664 struct e1000_adapter, watchdog_task); 2726 struct e1000_adapter, watchdog_task);
2665
2666 struct net_device *netdev = adapter->netdev; 2727 struct net_device *netdev = adapter->netdev;
2667 struct e1000_mac_info *mac = &adapter->hw.mac; 2728 struct e1000_mac_info *mac = &adapter->hw.mac;
2668 struct e1000_ring *tx_ring = adapter->tx_ring; 2729 struct e1000_ring *tx_ring = adapter->tx_ring;
2669 struct e1000_hw *hw = &adapter->hw; 2730 struct e1000_hw *hw = &adapter->hw;
2670 u32 link, tctl; 2731 u32 link, tctl;
2671 s32 ret_val;
2672 int tx_pending = 0; 2732 int tx_pending = 0;
2673 2733
2674 if ((netif_carrier_ok(netdev)) && 2734 link = e1000_has_link(adapter);
2675 (er32(STATUS) & E1000_STATUS_LU)) 2735 if ((netif_carrier_ok(netdev)) && link) {
2736 e1000e_enable_receives(adapter);
2676 goto link_up; 2737 goto link_up;
2677
2678 ret_val = mac->ops.check_for_link(hw);
2679 if ((ret_val == E1000_ERR_PHY) &&
2680 (adapter->hw.phy.type == e1000_phy_igp_3) &&
2681 (er32(CTRL) &
2682 E1000_PHY_CTRL_GBE_DISABLE)) {
2683 /* See e1000_kmrn_lock_loss_workaround_ich8lan() */
2684 ndev_info(netdev,
2685 "Gigabit has been disabled, downgrading speed\n");
2686 } 2738 }
2687 2739
2688 if ((e1000e_enable_tx_pkt_filtering(hw)) && 2740 if ((e1000e_enable_tx_pkt_filtering(hw)) &&
2689 (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id)) 2741 (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id))
2690 e1000_update_mng_vlan(adapter); 2742 e1000_update_mng_vlan(adapter);
2691 2743
2692 if ((adapter->hw.media_type == e1000_media_type_internal_serdes) &&
2693 !(er32(TXCW) & E1000_TXCW_ANE))
2694 link = adapter->hw.mac.serdes_has_link;
2695 else
2696 link = er32(STATUS) & E1000_STATUS_LU;
2697
2698 if (link) { 2744 if (link) {
2699 if (!netif_carrier_ok(netdev)) { 2745 if (!netif_carrier_ok(netdev)) {
2700 bool txb2b = 1; 2746 bool txb2b = 1;
2747 /* update snapshot of PHY registers on LSC */
2701 mac->ops.get_link_up_info(&adapter->hw, 2748 mac->ops.get_link_up_info(&adapter->hw,
2702 &adapter->link_speed, 2749 &adapter->link_speed,
2703 &adapter->link_duplex); 2750 &adapter->link_duplex);
@@ -2770,13 +2817,6 @@ static void e1000_watchdog_task(struct work_struct *work)
2770 if (!test_bit(__E1000_DOWN, &adapter->state)) 2817 if (!test_bit(__E1000_DOWN, &adapter->state))
2771 mod_timer(&adapter->phy_info_timer, 2818 mod_timer(&adapter->phy_info_timer,
2772 round_jiffies(jiffies + 2 * HZ)); 2819 round_jiffies(jiffies + 2 * HZ));
2773 } else {
2774 /* make sure the receive unit is started */
2775 if (adapter->flags & FLAG_RX_NEEDS_RESTART) {
2776 u32 rctl = er32(RCTL);
2777 ew32(RCTL, rctl |
2778 E1000_RCTL_EN);
2779 }
2780 } 2820 }
2781 } else { 2821 } else {
2782 if (netif_carrier_ok(netdev)) { 2822 if (netif_carrier_ok(netdev)) {
@@ -3413,7 +3453,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3413 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 3453 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
3414 msleep(1); 3454 msleep(1);
3415 /* e1000e_down has a dependency on max_frame_size */ 3455 /* e1000e_down has a dependency on max_frame_size */
3416 adapter->hw.mac.max_frame_size = max_frame; 3456 adapter->max_frame_size = max_frame;
3417 if (netif_running(netdev)) 3457 if (netif_running(netdev))
3418 e1000e_down(adapter); 3458 e1000e_down(adapter);
3419 3459
@@ -3462,7 +3502,7 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
3462 struct mii_ioctl_data *data = if_mii(ifr); 3502 struct mii_ioctl_data *data = if_mii(ifr);
3463 unsigned long irq_flags; 3503 unsigned long irq_flags;
3464 3504
3465 if (adapter->hw.media_type != e1000_media_type_copper) 3505 if (adapter->hw.phy.media_type != e1000_media_type_copper)
3466 return -EOPNOTSUPP; 3506 return -EOPNOTSUPP;
3467 3507
3468 switch (cmd) { 3508 switch (cmd) {
@@ -3544,8 +3584,9 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
3544 E1000_CTRL_EN_PHY_PWR_MGMT; 3584 E1000_CTRL_EN_PHY_PWR_MGMT;
3545 ew32(CTRL, ctrl); 3585 ew32(CTRL, ctrl);
3546 3586
3547 if (adapter->hw.media_type == e1000_media_type_fiber || 3587 if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
3548 adapter->hw.media_type == e1000_media_type_internal_serdes) { 3588 adapter->hw.phy.media_type ==
3589 e1000_media_type_internal_serdes) {
3549 /* keep the laser running in D3 */ 3590 /* keep the laser running in D3 */
3550 ctrl_ext = er32(CTRL_EXT); 3591 ctrl_ext = er32(CTRL_EXT);
3551 ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA; 3592 ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
@@ -3939,10 +3980,10 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
3939 3980
3940 hw->mac.ops.get_bus_info(&adapter->hw); 3981 hw->mac.ops.get_bus_info(&adapter->hw);
3941 3982
3942 adapter->hw.phy.wait_for_link = 0; 3983 adapter->hw.phy.autoneg_wait_to_complete = 0;
3943 3984
3944 /* Copper options */ 3985 /* Copper options */
3945 if (adapter->hw.media_type == e1000_media_type_copper) { 3986 if (adapter->hw.phy.media_type == e1000_media_type_copper) {
3946 adapter->hw.phy.mdix = AUTO_ALL_MODES; 3987 adapter->hw.phy.mdix = AUTO_ALL_MODES;
3947 adapter->hw.phy.disable_polarity_correction = 0; 3988 adapter->hw.phy.disable_polarity_correction = 0;
3948 adapter->hw.phy.ms_type = e1000_ms_hw_default; 3989 adapter->hw.phy.ms_type = e1000_ms_hw_default;
@@ -4028,8 +4069,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4028 /* Initialize link parameters. User can change them with ethtool */ 4069 /* Initialize link parameters. User can change them with ethtool */
4029 adapter->hw.mac.autoneg = 1; 4070 adapter->hw.mac.autoneg = 1;
4030 adapter->fc_autoneg = 1; 4071 adapter->fc_autoneg = 1;
4031 adapter->hw.mac.original_fc = e1000_fc_default; 4072 adapter->hw.fc.original_type = e1000_fc_default;
4032 adapter->hw.mac.fc = e1000_fc_default; 4073 adapter->hw.fc.type = e1000_fc_default;
4033 adapter->hw.phy.autoneg_advertised = 0x2f; 4074 adapter->hw.phy.autoneg_advertised = 0x2f;
4034 4075
4035 /* ring size defaults */ 4076 /* ring size defaults */