aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/netdev.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-16 19:29:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-16 19:29:25 -0400
commit7a6362800cb7d1d618a697a650c7aaed3eb39320 (patch)
tree087f9bc6c13ef1fad4b392c5cf9325cd28fa8523 /drivers/net/e1000e/netdev.c
parent6445ced8670f37cfc2c5e24a9de9b413dbfc788d (diff)
parentceda86a108671294052cbf51660097b6534672f5 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1480 commits) bonding: enable netpoll without checking link status xfrm: Refcount destination entry on xfrm_lookup net: introduce rx_handler results and logic around that bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag bonding: wrap slave state work net: get rid of multiple bond-related netdevice->priv_flags bonding: register slave pointer for rx_handler be2net: Bump up the version number be2net: Copyright notice change. Update to Emulex instead of ServerEngines e1000e: fix kconfig for crc32 dependency netfilter ebtables: fix xt_AUDIT to work with ebtables xen network backend driver bonding: Improve syslog message at device creation time bonding: Call netif_carrier_off after register_netdevice bonding: Incorrect TX queue offset net_sched: fix ip_tos2prio xfrm: fix __xfrm_route_forward() be2net: Fix UDP packet detected status in RX compl Phonet: fix aligned-mode pipe socket buffer header reserve netxen: support for GbE port settings ... Fix up conflicts in drivers/staging/brcm80211/brcmsmac/wl_mac80211.c with the staging updates.
Diffstat (limited to 'drivers/net/e1000e/netdev.c')
-rw-r--r--drivers/net/e1000e/netdev.c129
1 files changed, 87 insertions, 42 deletions
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 6d513a383340..a39d4a4d871c 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -54,7 +54,7 @@
54 54
55#define DRV_EXTRAVERSION "-k2" 55#define DRV_EXTRAVERSION "-k2"
56 56
57#define DRV_VERSION "1.2.20" DRV_EXTRAVERSION 57#define DRV_VERSION "1.3.10" DRV_EXTRAVERSION
58char e1000e_driver_name[] = "e1000e"; 58char e1000e_driver_name[] = "e1000e";
59const char e1000e_driver_version[] = DRV_VERSION; 59const char e1000e_driver_version[] = DRV_VERSION;
60 60
@@ -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
@@ -1060,8 +1058,6 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
1060 } 1058 }
1061 adapter->total_tx_bytes += total_tx_bytes; 1059 adapter->total_tx_bytes += total_tx_bytes;
1062 adapter->total_tx_packets += total_tx_packets; 1060 adapter->total_tx_packets += total_tx_packets;
1063 netdev->stats.tx_bytes += total_tx_bytes;
1064 netdev->stats.tx_packets += total_tx_packets;
1065 return count < tx_ring->count; 1061 return count < tx_ring->count;
1066} 1062}
1067 1063
@@ -1248,8 +1244,6 @@ next_desc:
1248 1244
1249 adapter->total_rx_bytes += total_rx_bytes; 1245 adapter->total_rx_bytes += total_rx_bytes;
1250 adapter->total_rx_packets += total_rx_packets; 1246 adapter->total_rx_packets += total_rx_packets;
1251 netdev->stats.rx_bytes += total_rx_bytes;
1252 netdev->stats.rx_packets += total_rx_packets;
1253 return cleaned; 1247 return cleaned;
1254} 1248}
1255 1249
@@ -1328,7 +1322,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
1328 /* an error means any chain goes out the window 1322 /* an error means any chain goes out the window
1329 * too */ 1323 * too */
1330 if (rx_ring->rx_skb_top) 1324 if (rx_ring->rx_skb_top)
1331 dev_kfree_skb(rx_ring->rx_skb_top); 1325 dev_kfree_skb_irq(rx_ring->rx_skb_top);
1332 rx_ring->rx_skb_top = NULL; 1326 rx_ring->rx_skb_top = NULL;
1333 goto next_desc; 1327 goto next_desc;
1334 } 1328 }
@@ -1401,7 +1395,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
1401 /* eth type trans needs skb->data to point to something */ 1395 /* eth type trans needs skb->data to point to something */
1402 if (!pskb_may_pull(skb, ETH_HLEN)) { 1396 if (!pskb_may_pull(skb, ETH_HLEN)) {
1403 e_err("pskb_may_pull failed.\n"); 1397 e_err("pskb_may_pull failed.\n");
1404 dev_kfree_skb(skb); 1398 dev_kfree_skb_irq(skb);
1405 goto next_desc; 1399 goto next_desc;
1406 } 1400 }
1407 1401
@@ -1429,8 +1423,6 @@ next_desc:
1429 1423
1430 adapter->total_rx_bytes += total_rx_bytes; 1424 adapter->total_rx_bytes += total_rx_bytes;
1431 adapter->total_rx_packets += total_rx_packets; 1425 adapter->total_rx_packets += total_rx_packets;
1432 netdev->stats.rx_bytes += total_rx_bytes;
1433 netdev->stats.rx_packets += total_rx_packets;
1434 return cleaned; 1426 return cleaned;
1435} 1427}
1436 1428
@@ -1857,7 +1849,9 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
1857 int err = 0, vector = 0; 1849 int err = 0, vector = 0;
1858 1850
1859 if (strlen(netdev->name) < (IFNAMSIZ - 5)) 1851 if (strlen(netdev->name) < (IFNAMSIZ - 5))
1860 sprintf(adapter->rx_ring->name, "%s-rx-0", netdev->name); 1852 snprintf(adapter->rx_ring->name,
1853 sizeof(adapter->rx_ring->name) - 1,
1854 "%s-rx-0", netdev->name);
1861 else 1855 else
1862 memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ); 1856 memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
1863 err = request_irq(adapter->msix_entries[vector].vector, 1857 err = request_irq(adapter->msix_entries[vector].vector,
@@ -1870,7 +1864,9 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
1870 vector++; 1864 vector++;
1871 1865
1872 if (strlen(netdev->name) < (IFNAMSIZ - 5)) 1866 if (strlen(netdev->name) < (IFNAMSIZ - 5))
1873 sprintf(adapter->tx_ring->name, "%s-tx-0", netdev->name); 1867 snprintf(adapter->tx_ring->name,
1868 sizeof(adapter->tx_ring->name) - 1,
1869 "%s-tx-0", netdev->name);
1874 else 1870 else
1875 memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ); 1871 memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
1876 err = request_irq(adapter->msix_entries[vector].vector, 1872 err = request_irq(adapter->msix_entries[vector].vector,
@@ -2734,7 +2730,6 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
2734{ 2730{
2735 struct e1000_hw *hw = &adapter->hw; 2731 struct e1000_hw *hw = &adapter->hw;
2736 u32 rctl, rfctl; 2732 u32 rctl, rfctl;
2737 u32 psrctl = 0;
2738 u32 pages = 0; 2733 u32 pages = 0;
2739 2734
2740 /* Workaround Si errata on 82579 - configure jumbo frame flow */ 2735 /* Workaround Si errata on 82579 - configure jumbo frame flow */
@@ -2833,6 +2828,8 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
2833 adapter->rx_ps_pages = 0; 2828 adapter->rx_ps_pages = 0;
2834 2829
2835 if (adapter->rx_ps_pages) { 2830 if (adapter->rx_ps_pages) {
2831 u32 psrctl = 0;
2832
2836 /* Configure extra packet-split registers */ 2833 /* Configure extra packet-split registers */
2837 rfctl = er32(RFCTL); 2834 rfctl = er32(RFCTL);
2838 rfctl |= E1000_RFCTL_EXTEN; 2835 rfctl |= E1000_RFCTL_EXTEN;
@@ -3034,7 +3031,6 @@ static void e1000_set_multi(struct net_device *netdev)
3034 struct netdev_hw_addr *ha; 3031 struct netdev_hw_addr *ha;
3035 u8 *mta_list; 3032 u8 *mta_list;
3036 u32 rctl; 3033 u32 rctl;
3037 int i;
3038 3034
3039 /* Check for Promiscuous and All Multicast modes */ 3035 /* Check for Promiscuous and All Multicast modes */
3040 3036
@@ -3057,12 +3053,13 @@ static void e1000_set_multi(struct net_device *netdev)
3057 ew32(RCTL, rctl); 3053 ew32(RCTL, rctl);
3058 3054
3059 if (!netdev_mc_empty(netdev)) { 3055 if (!netdev_mc_empty(netdev)) {
3056 int i = 0;
3057
3060 mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); 3058 mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
3061 if (!mta_list) 3059 if (!mta_list)
3062 return; 3060 return;
3063 3061
3064 /* prepare a packed array of only addresses. */ 3062 /* prepare a packed array of only addresses. */
3065 i = 0;
3066 netdev_for_each_mc_addr(ha, netdev) 3063 netdev_for_each_mc_addr(ha, netdev)
3067 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN); 3064 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
3068 3065
@@ -3359,6 +3356,8 @@ static void e1000e_flush_descriptors(struct e1000_adapter *adapter)
3359 e1e_flush(); 3356 e1e_flush();
3360} 3357}
3361 3358
3359static void e1000e_update_stats(struct e1000_adapter *adapter);
3360
3362void e1000e_down(struct e1000_adapter *adapter) 3361void e1000e_down(struct e1000_adapter *adapter)
3363{ 3362{
3364 struct net_device *netdev = adapter->netdev; 3363 struct net_device *netdev = adapter->netdev;
@@ -3393,6 +3392,11 @@ void e1000e_down(struct e1000_adapter *adapter)
3393 del_timer_sync(&adapter->phy_info_timer); 3392 del_timer_sync(&adapter->phy_info_timer);
3394 3393
3395 netif_carrier_off(netdev); 3394 netif_carrier_off(netdev);
3395
3396 spin_lock(&adapter->stats64_lock);
3397 e1000e_update_stats(adapter);
3398 spin_unlock(&adapter->stats64_lock);
3399
3396 adapter->link_speed = 0; 3400 adapter->link_speed = 0;
3397 adapter->link_duplex = 0; 3401 adapter->link_duplex = 0;
3398 3402
@@ -3437,6 +3441,8 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
3437 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; 3441 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
3438 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; 3442 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
3439 3443
3444 spin_lock_init(&adapter->stats64_lock);
3445
3440 e1000e_set_interrupt_capability(adapter); 3446 e1000e_set_interrupt_capability(adapter);
3441 3447
3442 if (e1000_alloc_queues(adapter)) 3448 if (e1000_alloc_queues(adapter))
@@ -3918,7 +3924,7 @@ release:
3918 * e1000e_update_stats - Update the board statistics counters 3924 * e1000e_update_stats - Update the board statistics counters
3919 * @adapter: board private structure 3925 * @adapter: board private structure
3920 **/ 3926 **/
3921void e1000e_update_stats(struct e1000_adapter *adapter) 3927static void e1000e_update_stats(struct e1000_adapter *adapter)
3922{ 3928{
3923 struct net_device *netdev = adapter->netdev; 3929 struct net_device *netdev = adapter->netdev;
3924 struct e1000_hw *hw = &adapter->hw; 3930 struct e1000_hw *hw = &adapter->hw;
@@ -4030,10 +4036,11 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter)
4030{ 4036{
4031 struct e1000_hw *hw = &adapter->hw; 4037 struct e1000_hw *hw = &adapter->hw;
4032 struct e1000_phy_regs *phy = &adapter->phy_regs; 4038 struct e1000_phy_regs *phy = &adapter->phy_regs;
4033 int ret_val;
4034 4039
4035 if ((er32(STATUS) & E1000_STATUS_LU) && 4040 if ((er32(STATUS) & E1000_STATUS_LU) &&
4036 (adapter->hw.phy.media_type == e1000_media_type_copper)) { 4041 (adapter->hw.phy.media_type == e1000_media_type_copper)) {
4042 int ret_val;
4043
4037 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr); 4044 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr);
4038 ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr); 4045 ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr);
4039 ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise); 4046 ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise);
@@ -4179,7 +4186,6 @@ static void e1000_watchdog_task(struct work_struct *work)
4179 struct e1000_ring *tx_ring = adapter->tx_ring; 4186 struct e1000_ring *tx_ring = adapter->tx_ring;
4180 struct e1000_hw *hw = &adapter->hw; 4187 struct e1000_hw *hw = &adapter->hw;
4181 u32 link, tctl; 4188 u32 link, tctl;
4182 int tx_pending = 0;
4183 4189
4184 if (test_bit(__E1000_DOWN, &adapter->state)) 4190 if (test_bit(__E1000_DOWN, &adapter->state))
4185 return; 4191 return;
@@ -4320,7 +4326,9 @@ static void e1000_watchdog_task(struct work_struct *work)
4320 } 4326 }
4321 4327
4322link_up: 4328link_up:
4329 spin_lock(&adapter->stats64_lock);
4323 e1000e_update_stats(adapter); 4330 e1000e_update_stats(adapter);
4331 spin_unlock(&adapter->stats64_lock);
4324 4332
4325 mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old; 4333 mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
4326 adapter->tpt_old = adapter->stats.tpt; 4334 adapter->tpt_old = adapter->stats.tpt;
@@ -4334,20 +4342,17 @@ link_up:
4334 4342
4335 e1000e_update_adaptive(&adapter->hw); 4343 e1000e_update_adaptive(&adapter->hw);
4336 4344
4337 if (!netif_carrier_ok(netdev)) { 4345 if (!netif_carrier_ok(netdev) &&
4338 tx_pending = (e1000_desc_unused(tx_ring) + 1 < 4346 (e1000_desc_unused(tx_ring) + 1 < tx_ring->count)) {
4339 tx_ring->count); 4347 /*
4340 if (tx_pending) { 4348 * We've lost link, so the controller stops DMA,
4341 /* 4349 * but we've got queued Tx work that's never going
4342 * We've lost link, so the controller stops DMA, 4350 * to get done, so reset controller to flush Tx.
4343 * but we've got queued Tx work that's never going 4351 * (Do the reset outside of interrupt context).
4344 * to get done, so reset controller to flush Tx. 4352 */
4345 * (Do the reset outside of interrupt context). 4353 schedule_work(&adapter->reset_task);
4346 */ 4354 /* return immediately since reset is imminent */
4347 schedule_work(&adapter->reset_task); 4355 return;
4348 /* return immediately since reset is imminent */
4349 return;
4350 }
4351 } 4356 }
4352 4357
4353 /* Simple mode for Interrupt Throttle Rate (ITR) */ 4358 /* Simple mode for Interrupt Throttle Rate (ITR) */
@@ -4411,13 +4416,13 @@ static int e1000_tso(struct e1000_adapter *adapter,
4411 u32 cmd_length = 0; 4416 u32 cmd_length = 0;
4412 u16 ipcse = 0, tucse, mss; 4417 u16 ipcse = 0, tucse, mss;
4413 u8 ipcss, ipcso, tucss, tucso, hdr_len; 4418 u8 ipcss, ipcso, tucss, tucso, hdr_len;
4414 int err;
4415 4419
4416 if (!skb_is_gso(skb)) 4420 if (!skb_is_gso(skb))
4417 return 0; 4421 return 0;
4418 4422
4419 if (skb_header_cloned(skb)) { 4423 if (skb_header_cloned(skb)) {
4420 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 4424 int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
4425
4421 if (err) 4426 if (err)
4422 return err; 4427 return err;
4423 } 4428 }
@@ -4928,16 +4933,55 @@ static void e1000_reset_task(struct work_struct *work)
4928} 4933}
4929 4934
4930/** 4935/**
4931 * e1000_get_stats - Get System Network Statistics 4936 * e1000_get_stats64 - Get System Network Statistics
4932 * @netdev: network interface device structure 4937 * @netdev: network interface device structure
4938 * @stats: rtnl_link_stats64 pointer
4933 * 4939 *
4934 * Returns the address of the device statistics structure. 4940 * Returns the address of the device statistics structure.
4935 * The statistics are actually updated from the timer callback.
4936 **/ 4941 **/
4937static struct net_device_stats *e1000_get_stats(struct net_device *netdev) 4942struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
4943 struct rtnl_link_stats64 *stats)
4938{ 4944{
4939 /* only return the current stats */ 4945 struct e1000_adapter *adapter = netdev_priv(netdev);
4940 return &netdev->stats; 4946
4947 memset(stats, 0, sizeof(struct rtnl_link_stats64));
4948 spin_lock(&adapter->stats64_lock);
4949 e1000e_update_stats(adapter);
4950 /* Fill out the OS statistics structure */
4951 stats->rx_bytes = adapter->stats.gorc;
4952 stats->rx_packets = adapter->stats.gprc;
4953 stats->tx_bytes = adapter->stats.gotc;
4954 stats->tx_packets = adapter->stats.gptc;
4955 stats->multicast = adapter->stats.mprc;
4956 stats->collisions = adapter->stats.colc;
4957
4958 /* Rx Errors */
4959
4960 /*
4961 * RLEC on some newer hardware can be incorrect so build
4962 * our own version based on RUC and ROC
4963 */
4964 stats->rx_errors = adapter->stats.rxerrc +
4965 adapter->stats.crcerrs + adapter->stats.algnerrc +
4966 adapter->stats.ruc + adapter->stats.roc +
4967 adapter->stats.cexterr;
4968 stats->rx_length_errors = adapter->stats.ruc +
4969 adapter->stats.roc;
4970 stats->rx_crc_errors = adapter->stats.crcerrs;
4971 stats->rx_frame_errors = adapter->stats.algnerrc;
4972 stats->rx_missed_errors = adapter->stats.mpc;
4973
4974 /* Tx Errors */
4975 stats->tx_errors = adapter->stats.ecol +
4976 adapter->stats.latecol;
4977 stats->tx_aborted_errors = adapter->stats.ecol;
4978 stats->tx_window_errors = adapter->stats.latecol;
4979 stats->tx_carrier_errors = adapter->stats.tncrs;
4980
4981 /* Tx Dropped needs to be maintained elsewhere */
4982
4983 spin_unlock(&adapter->stats64_lock);
4984 return stats;
4941} 4985}
4942 4986
4943/** 4987/**
@@ -5507,9 +5551,10 @@ static irqreturn_t e1000_intr_msix(int irq, void *data)
5507{ 5551{
5508 struct net_device *netdev = data; 5552 struct net_device *netdev = data;
5509 struct e1000_adapter *adapter = netdev_priv(netdev); 5553 struct e1000_adapter *adapter = netdev_priv(netdev);
5510 int vector, msix_irq;
5511 5554
5512 if (adapter->msix_entries) { 5555 if (adapter->msix_entries) {
5556 int vector, msix_irq;
5557
5513 vector = 0; 5558 vector = 0;
5514 msix_irq = adapter->msix_entries[vector].vector; 5559 msix_irq = adapter->msix_entries[vector].vector;
5515 disable_irq(msix_irq); 5560 disable_irq(msix_irq);
@@ -5706,7 +5751,7 @@ static const struct net_device_ops e1000e_netdev_ops = {
5706 .ndo_open = e1000_open, 5751 .ndo_open = e1000_open,
5707 .ndo_stop = e1000_close, 5752 .ndo_stop = e1000_close,
5708 .ndo_start_xmit = e1000_xmit_frame, 5753 .ndo_start_xmit = e1000_xmit_frame,
5709 .ndo_get_stats = e1000_get_stats, 5754 .ndo_get_stats64 = e1000e_get_stats64,
5710 .ndo_set_multicast_list = e1000_set_multi, 5755 .ndo_set_multicast_list = e1000_set_multi,
5711 .ndo_set_mac_address = e1000_set_mac, 5756 .ndo_set_mac_address = e1000_set_mac,
5712 .ndo_change_mtu = e1000_change_mtu, 5757 .ndo_change_mtu = e1000_change_mtu,