diff options
Diffstat (limited to 'drivers/net/e1000e/netdev.c')
-rw-r--r-- | drivers/net/e1000e/netdev.c | 117 |
1 files changed, 79 insertions, 38 deletions
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index 1c18f26b0812..5b916b01805f 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -900,8 +900,6 @@ next_desc: | |||
900 | 900 | ||
901 | adapter->total_rx_bytes += total_rx_bytes; | 901 | adapter->total_rx_bytes += total_rx_bytes; |
902 | adapter->total_rx_packets += total_rx_packets; | 902 | adapter->total_rx_packets += total_rx_packets; |
903 | netdev->stats.rx_bytes += total_rx_bytes; | ||
904 | netdev->stats.rx_packets += total_rx_packets; | ||
905 | return cleaned; | 903 | return cleaned; |
906 | } | 904 | } |
907 | 905 | ||
@@ -1057,8 +1055,6 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) | |||
1057 | } | 1055 | } |
1058 | adapter->total_tx_bytes += total_tx_bytes; | 1056 | adapter->total_tx_bytes += total_tx_bytes; |
1059 | adapter->total_tx_packets += total_tx_packets; | 1057 | adapter->total_tx_packets += total_tx_packets; |
1060 | netdev->stats.tx_bytes += total_tx_bytes; | ||
1061 | netdev->stats.tx_packets += total_tx_packets; | ||
1062 | return count < tx_ring->count; | 1058 | return count < tx_ring->count; |
1063 | } | 1059 | } |
1064 | 1060 | ||
@@ -1245,8 +1241,6 @@ next_desc: | |||
1245 | 1241 | ||
1246 | adapter->total_rx_bytes += total_rx_bytes; | 1242 | adapter->total_rx_bytes += total_rx_bytes; |
1247 | adapter->total_rx_packets += total_rx_packets; | 1243 | adapter->total_rx_packets += total_rx_packets; |
1248 | netdev->stats.rx_bytes += total_rx_bytes; | ||
1249 | netdev->stats.rx_packets += total_rx_packets; | ||
1250 | return cleaned; | 1244 | return cleaned; |
1251 | } | 1245 | } |
1252 | 1246 | ||
@@ -1426,8 +1420,6 @@ next_desc: | |||
1426 | 1420 | ||
1427 | adapter->total_rx_bytes += total_rx_bytes; | 1421 | adapter->total_rx_bytes += total_rx_bytes; |
1428 | adapter->total_rx_packets += total_rx_packets; | 1422 | adapter->total_rx_packets += total_rx_packets; |
1429 | netdev->stats.rx_bytes += total_rx_bytes; | ||
1430 | netdev->stats.rx_packets += total_rx_packets; | ||
1431 | return cleaned; | 1423 | return cleaned; |
1432 | } | 1424 | } |
1433 | 1425 | ||
@@ -2728,7 +2720,6 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) | |||
2728 | { | 2720 | { |
2729 | struct e1000_hw *hw = &adapter->hw; | 2721 | struct e1000_hw *hw = &adapter->hw; |
2730 | u32 rctl, rfctl; | 2722 | u32 rctl, rfctl; |
2731 | u32 psrctl = 0; | ||
2732 | u32 pages = 0; | 2723 | u32 pages = 0; |
2733 | 2724 | ||
2734 | /* Workaround Si errata on 82579 - configure jumbo frame flow */ | 2725 | /* Workaround Si errata on 82579 - configure jumbo frame flow */ |
@@ -2827,6 +2818,8 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter) | |||
2827 | adapter->rx_ps_pages = 0; | 2818 | adapter->rx_ps_pages = 0; |
2828 | 2819 | ||
2829 | if (adapter->rx_ps_pages) { | 2820 | if (adapter->rx_ps_pages) { |
2821 | u32 psrctl = 0; | ||
2822 | |||
2830 | /* Configure extra packet-split registers */ | 2823 | /* Configure extra packet-split registers */ |
2831 | rfctl = er32(RFCTL); | 2824 | rfctl = er32(RFCTL); |
2832 | rfctl |= E1000_RFCTL_EXTEN; | 2825 | rfctl |= E1000_RFCTL_EXTEN; |
@@ -3028,7 +3021,6 @@ static void e1000_set_multi(struct net_device *netdev) | |||
3028 | struct netdev_hw_addr *ha; | 3021 | struct netdev_hw_addr *ha; |
3029 | u8 *mta_list; | 3022 | u8 *mta_list; |
3030 | u32 rctl; | 3023 | u32 rctl; |
3031 | int i; | ||
3032 | 3024 | ||
3033 | /* Check for Promiscuous and All Multicast modes */ | 3025 | /* Check for Promiscuous and All Multicast modes */ |
3034 | 3026 | ||
@@ -3051,12 +3043,13 @@ static void e1000_set_multi(struct net_device *netdev) | |||
3051 | ew32(RCTL, rctl); | 3043 | ew32(RCTL, rctl); |
3052 | 3044 | ||
3053 | if (!netdev_mc_empty(netdev)) { | 3045 | if (!netdev_mc_empty(netdev)) { |
3046 | int i = 0; | ||
3047 | |||
3054 | mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); | 3048 | mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); |
3055 | if (!mta_list) | 3049 | if (!mta_list) |
3056 | return; | 3050 | return; |
3057 | 3051 | ||
3058 | /* prepare a packed array of only addresses. */ | 3052 | /* prepare a packed array of only addresses. */ |
3059 | i = 0; | ||
3060 | netdev_for_each_mc_addr(ha, netdev) | 3053 | netdev_for_each_mc_addr(ha, netdev) |
3061 | memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN); | 3054 | memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN); |
3062 | 3055 | ||
@@ -3338,6 +3331,8 @@ int e1000e_up(struct e1000_adapter *adapter) | |||
3338 | return 0; | 3331 | return 0; |
3339 | } | 3332 | } |
3340 | 3333 | ||
3334 | static void e1000e_update_stats(struct e1000_adapter *adapter); | ||
3335 | |||
3341 | void e1000e_down(struct e1000_adapter *adapter) | 3336 | void e1000e_down(struct e1000_adapter *adapter) |
3342 | { | 3337 | { |
3343 | struct net_device *netdev = adapter->netdev; | 3338 | struct net_device *netdev = adapter->netdev; |
@@ -3372,6 +3367,11 @@ void e1000e_down(struct e1000_adapter *adapter) | |||
3372 | del_timer_sync(&adapter->phy_info_timer); | 3367 | del_timer_sync(&adapter->phy_info_timer); |
3373 | 3368 | ||
3374 | netif_carrier_off(netdev); | 3369 | netif_carrier_off(netdev); |
3370 | |||
3371 | spin_lock(&adapter->stats64_lock); | ||
3372 | e1000e_update_stats(adapter); | ||
3373 | spin_unlock(&adapter->stats64_lock); | ||
3374 | |||
3375 | adapter->link_speed = 0; | 3375 | adapter->link_speed = 0; |
3376 | adapter->link_duplex = 0; | 3376 | adapter->link_duplex = 0; |
3377 | 3377 | ||
@@ -3413,6 +3413,8 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter) | |||
3413 | adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; | 3413 | adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; |
3414 | adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; | 3414 | adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; |
3415 | 3415 | ||
3416 | spin_lock_init(&adapter->stats64_lock); | ||
3417 | |||
3416 | e1000e_set_interrupt_capability(adapter); | 3418 | e1000e_set_interrupt_capability(adapter); |
3417 | 3419 | ||
3418 | if (e1000_alloc_queues(adapter)) | 3420 | if (e1000_alloc_queues(adapter)) |
@@ -3886,7 +3888,7 @@ release: | |||
3886 | * e1000e_update_stats - Update the board statistics counters | 3888 | * e1000e_update_stats - Update the board statistics counters |
3887 | * @adapter: board private structure | 3889 | * @adapter: board private structure |
3888 | **/ | 3890 | **/ |
3889 | void e1000e_update_stats(struct e1000_adapter *adapter) | 3891 | static void e1000e_update_stats(struct e1000_adapter *adapter) |
3890 | { | 3892 | { |
3891 | struct net_device *netdev = adapter->netdev; | 3893 | struct net_device *netdev = adapter->netdev; |
3892 | struct e1000_hw *hw = &adapter->hw; | 3894 | struct e1000_hw *hw = &adapter->hw; |
@@ -3998,10 +4000,11 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter) | |||
3998 | { | 4000 | { |
3999 | struct e1000_hw *hw = &adapter->hw; | 4001 | struct e1000_hw *hw = &adapter->hw; |
4000 | struct e1000_phy_regs *phy = &adapter->phy_regs; | 4002 | struct e1000_phy_regs *phy = &adapter->phy_regs; |
4001 | int ret_val; | ||
4002 | 4003 | ||
4003 | if ((er32(STATUS) & E1000_STATUS_LU) && | 4004 | if ((er32(STATUS) & E1000_STATUS_LU) && |
4004 | (adapter->hw.phy.media_type == e1000_media_type_copper)) { | 4005 | (adapter->hw.phy.media_type == e1000_media_type_copper)) { |
4006 | int ret_val; | ||
4007 | |||
4005 | ret_val = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr); | 4008 | ret_val = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr); |
4006 | ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr); | 4009 | ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr); |
4007 | ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise); | 4010 | ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise); |
@@ -4147,7 +4150,6 @@ static void e1000_watchdog_task(struct work_struct *work) | |||
4147 | struct e1000_ring *tx_ring = adapter->tx_ring; | 4150 | struct e1000_ring *tx_ring = adapter->tx_ring; |
4148 | struct e1000_hw *hw = &adapter->hw; | 4151 | struct e1000_hw *hw = &adapter->hw; |
4149 | u32 link, tctl; | 4152 | u32 link, tctl; |
4150 | int tx_pending = 0; | ||
4151 | 4153 | ||
4152 | link = e1000e_has_link(adapter); | 4154 | link = e1000e_has_link(adapter); |
4153 | if ((netif_carrier_ok(netdev)) && link) { | 4155 | if ((netif_carrier_ok(netdev)) && link) { |
@@ -4285,7 +4287,9 @@ static void e1000_watchdog_task(struct work_struct *work) | |||
4285 | } | 4287 | } |
4286 | 4288 | ||
4287 | link_up: | 4289 | link_up: |
4290 | spin_lock(&adapter->stats64_lock); | ||
4288 | e1000e_update_stats(adapter); | 4291 | e1000e_update_stats(adapter); |
4292 | spin_unlock(&adapter->stats64_lock); | ||
4289 | 4293 | ||
4290 | mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old; | 4294 | mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old; |
4291 | adapter->tpt_old = adapter->stats.tpt; | 4295 | adapter->tpt_old = adapter->stats.tpt; |
@@ -4299,21 +4303,18 @@ link_up: | |||
4299 | 4303 | ||
4300 | e1000e_update_adaptive(&adapter->hw); | 4304 | e1000e_update_adaptive(&adapter->hw); |
4301 | 4305 | ||
4302 | if (!netif_carrier_ok(netdev)) { | 4306 | if (!netif_carrier_ok(netdev) && |
4303 | tx_pending = (e1000_desc_unused(tx_ring) + 1 < | 4307 | (e1000_desc_unused(tx_ring) + 1 < tx_ring->count)) { |
4304 | tx_ring->count); | 4308 | /* |
4305 | if (tx_pending) { | 4309 | * We've lost link, so the controller stops DMA, |
4306 | /* | 4310 | * but we've got queued Tx work that's never going |
4307 | * We've lost link, so the controller stops DMA, | 4311 | * to get done, so reset controller to flush Tx. |
4308 | * but we've got queued Tx work that's never going | 4312 | * (Do the reset outside of interrupt context). |
4309 | * to get done, so reset controller to flush Tx. | 4313 | */ |
4310 | * (Do the reset outside of interrupt context). | 4314 | adapter->tx_timeout_count++; |
4311 | */ | 4315 | schedule_work(&adapter->reset_task); |
4312 | adapter->tx_timeout_count++; | 4316 | /* return immediately since reset is imminent */ |
4313 | schedule_work(&adapter->reset_task); | 4317 | return; |
4314 | /* return immediately since reset is imminent */ | ||
4315 | return; | ||
4316 | } | ||
4317 | } | 4318 | } |
4318 | 4319 | ||
4319 | /* Simple mode for Interrupt Throttle Rate (ITR) */ | 4320 | /* Simple mode for Interrupt Throttle Rate (ITR) */ |
@@ -4384,13 +4385,13 @@ static int e1000_tso(struct e1000_adapter *adapter, | |||
4384 | u32 cmd_length = 0; | 4385 | u32 cmd_length = 0; |
4385 | u16 ipcse = 0, tucse, mss; | 4386 | u16 ipcse = 0, tucse, mss; |
4386 | u8 ipcss, ipcso, tucss, tucso, hdr_len; | 4387 | u8 ipcss, ipcso, tucss, tucso, hdr_len; |
4387 | int err; | ||
4388 | 4388 | ||
4389 | if (!skb_is_gso(skb)) | 4389 | if (!skb_is_gso(skb)) |
4390 | return 0; | 4390 | return 0; |
4391 | 4391 | ||
4392 | if (skb_header_cloned(skb)) { | 4392 | if (skb_header_cloned(skb)) { |
4393 | err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); | 4393 | int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); |
4394 | |||
4394 | if (err) | 4395 | if (err) |
4395 | return err; | 4396 | return err; |
4396 | } | 4397 | } |
@@ -4897,16 +4898,55 @@ static void e1000_reset_task(struct work_struct *work) | |||
4897 | } | 4898 | } |
4898 | 4899 | ||
4899 | /** | 4900 | /** |
4900 | * e1000_get_stats - Get System Network Statistics | 4901 | * e1000_get_stats64 - Get System Network Statistics |
4901 | * @netdev: network interface device structure | 4902 | * @netdev: network interface device structure |
4903 | * @stats: rtnl_link_stats64 pointer | ||
4902 | * | 4904 | * |
4903 | * Returns the address of the device statistics structure. | 4905 | * Returns the address of the device statistics structure. |
4904 | * The statistics are actually updated from the timer callback. | ||
4905 | **/ | 4906 | **/ |
4906 | static struct net_device_stats *e1000_get_stats(struct net_device *netdev) | 4907 | struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev, |
4908 | struct rtnl_link_stats64 *stats) | ||
4907 | { | 4909 | { |
4908 | /* only return the current stats */ | 4910 | struct e1000_adapter *adapter = netdev_priv(netdev); |
4909 | return &netdev->stats; | 4911 | |
4912 | memset(stats, 0, sizeof(struct rtnl_link_stats64)); | ||
4913 | spin_lock(&adapter->stats64_lock); | ||
4914 | e1000e_update_stats(adapter); | ||
4915 | /* Fill out the OS statistics structure */ | ||
4916 | stats->rx_bytes = adapter->stats.gorc; | ||
4917 | stats->rx_packets = adapter->stats.gprc; | ||
4918 | stats->tx_bytes = adapter->stats.gotc; | ||
4919 | stats->tx_packets = adapter->stats.gptc; | ||
4920 | stats->multicast = adapter->stats.mprc; | ||
4921 | stats->collisions = adapter->stats.colc; | ||
4922 | |||
4923 | /* Rx Errors */ | ||
4924 | |||
4925 | /* | ||
4926 | * RLEC on some newer hardware can be incorrect so build | ||
4927 | * our own version based on RUC and ROC | ||
4928 | */ | ||
4929 | stats->rx_errors = adapter->stats.rxerrc + | ||
4930 | adapter->stats.crcerrs + adapter->stats.algnerrc + | ||
4931 | adapter->stats.ruc + adapter->stats.roc + | ||
4932 | adapter->stats.cexterr; | ||
4933 | stats->rx_length_errors = adapter->stats.ruc + | ||
4934 | adapter->stats.roc; | ||
4935 | stats->rx_crc_errors = adapter->stats.crcerrs; | ||
4936 | stats->rx_frame_errors = adapter->stats.algnerrc; | ||
4937 | stats->rx_missed_errors = adapter->stats.mpc; | ||
4938 | |||
4939 | /* Tx Errors */ | ||
4940 | stats->tx_errors = adapter->stats.ecol + | ||
4941 | adapter->stats.latecol; | ||
4942 | stats->tx_aborted_errors = adapter->stats.ecol; | ||
4943 | stats->tx_window_errors = adapter->stats.latecol; | ||
4944 | stats->tx_carrier_errors = adapter->stats.tncrs; | ||
4945 | |||
4946 | /* Tx Dropped needs to be maintained elsewhere */ | ||
4947 | |||
4948 | spin_unlock(&adapter->stats64_lock); | ||
4949 | return stats; | ||
4910 | } | 4950 | } |
4911 | 4951 | ||
4912 | /** | 4952 | /** |
@@ -5476,9 +5516,10 @@ static irqreturn_t e1000_intr_msix(int irq, void *data) | |||
5476 | { | 5516 | { |
5477 | struct net_device *netdev = data; | 5517 | struct net_device *netdev = data; |
5478 | struct e1000_adapter *adapter = netdev_priv(netdev); | 5518 | struct e1000_adapter *adapter = netdev_priv(netdev); |
5479 | int vector, msix_irq; | ||
5480 | 5519 | ||
5481 | if (adapter->msix_entries) { | 5520 | if (adapter->msix_entries) { |
5521 | int vector, msix_irq; | ||
5522 | |||
5482 | vector = 0; | 5523 | vector = 0; |
5483 | msix_irq = adapter->msix_entries[vector].vector; | 5524 | msix_irq = adapter->msix_entries[vector].vector; |
5484 | disable_irq(msix_irq); | 5525 | disable_irq(msix_irq); |
@@ -5675,7 +5716,7 @@ static const struct net_device_ops e1000e_netdev_ops = { | |||
5675 | .ndo_open = e1000_open, | 5716 | .ndo_open = e1000_open, |
5676 | .ndo_stop = e1000_close, | 5717 | .ndo_stop = e1000_close, |
5677 | .ndo_start_xmit = e1000_xmit_frame, | 5718 | .ndo_start_xmit = e1000_xmit_frame, |
5678 | .ndo_get_stats = e1000_get_stats, | 5719 | .ndo_get_stats64 = e1000e_get_stats64, |
5679 | .ndo_set_multicast_list = e1000_set_multi, | 5720 | .ndo_set_multicast_list = e1000_set_multi, |
5680 | .ndo_set_mac_address = e1000_set_mac, | 5721 | .ndo_set_mac_address = e1000_set_mac, |
5681 | .ndo_change_mtu = e1000_change_mtu, | 5722 | .ndo_change_mtu = e1000_change_mtu, |