aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/e1000_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000/e1000_main.c')
-rw-r--r--drivers/net/e1000/e1000_main.c271
1 files changed, 174 insertions, 97 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 3f6a752700a1..7dca38fba6a1 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -1,25 +1,24 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms and conditions of the GNU General Public License,
8 Software Foundation; either version 2 of the License, or (at your option) 8 version 2, as published by the Free Software Foundation.
9 any later version. 9
10 10 This program is distributed in the hope it will be useful, but WITHOUT
11 This program is distributed in the hope that it will be useful, but WITHOUT 11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details. 13 more details.
15 14
16 You should have received a copy of the GNU General Public License along with 15 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc., 59 16 this program; if not, write to the Free Software Foundation, Inc.,
18 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 18
20 The full GNU General Public License is included in this distribution in the 19 The full GNU General Public License is included in this distribution in
21 file called LICENSE. 20 the file called "COPYING".
22 21
23 Contact Information: 22 Contact Information:
24 Linux NICS <linux.nics@intel.com> 23 Linux NICS <linux.nics@intel.com>
25 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
@@ -36,7 +35,7 @@ static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
36#else 35#else
37#define DRIVERNAPI "-NAPI" 36#define DRIVERNAPI "-NAPI"
38#endif 37#endif
39#define DRV_VERSION "7.2.7-k2"DRIVERNAPI 38#define DRV_VERSION "7.2.9-k2"DRIVERNAPI
40char e1000_driver_version[] = DRV_VERSION; 39char e1000_driver_version[] = DRV_VERSION;
41static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 40static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
42 41
@@ -110,16 +109,24 @@ static struct pci_device_id e1000_pci_tbl[] = {
110 109
111MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); 110MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
112 111
112int e1000_up(struct e1000_adapter *adapter);
113void e1000_down(struct e1000_adapter *adapter);
114void e1000_reinit_locked(struct e1000_adapter *adapter);
115void e1000_reset(struct e1000_adapter *adapter);
116int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
117int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
118int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
119void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
120void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
113static int e1000_setup_tx_resources(struct e1000_adapter *adapter, 121static int e1000_setup_tx_resources(struct e1000_adapter *adapter,
114 struct e1000_tx_ring *txdr); 122 struct e1000_tx_ring *txdr);
115static int e1000_setup_rx_resources(struct e1000_adapter *adapter, 123static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
116 struct e1000_rx_ring *rxdr); 124 struct e1000_rx_ring *rxdr);
117static void e1000_free_tx_resources(struct e1000_adapter *adapter, 125static void e1000_free_tx_resources(struct e1000_adapter *adapter,
118 struct e1000_tx_ring *tx_ring); 126 struct e1000_tx_ring *tx_ring);
119static void e1000_free_rx_resources(struct e1000_adapter *adapter, 127static void e1000_free_rx_resources(struct e1000_adapter *adapter,
120 struct e1000_rx_ring *rx_ring); 128 struct e1000_rx_ring *rx_ring);
121 129void e1000_update_stats(struct e1000_adapter *adapter);
122/* Local Function Prototypes */
123 130
124static int e1000_init_module(void); 131static int e1000_init_module(void);
125static void e1000_exit_module(void); 132static void e1000_exit_module(void);
@@ -172,6 +179,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
172static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); 179static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
173static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, 180static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
174 int cmd); 181 int cmd);
182void e1000_set_ethtool_ops(struct net_device *netdev);
175static void e1000_enter_82542_rst(struct e1000_adapter *adapter); 183static void e1000_enter_82542_rst(struct e1000_adapter *adapter);
176static void e1000_leave_82542_rst(struct e1000_adapter *adapter); 184static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
177static void e1000_tx_timeout(struct net_device *dev); 185static void e1000_tx_timeout(struct net_device *dev);
@@ -196,6 +204,8 @@ static void e1000_shutdown(struct pci_dev *pdev);
196static void e1000_netpoll (struct net_device *netdev); 204static void e1000_netpoll (struct net_device *netdev);
197#endif 205#endif
198 206
207extern void e1000_check_options(struct e1000_adapter *adapter);
208
199static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, 209static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
200 pci_channel_state_t state); 210 pci_channel_state_t state);
201static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev); 211static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev);
@@ -212,9 +222,9 @@ static struct pci_driver e1000_driver = {
212 .id_table = e1000_pci_tbl, 222 .id_table = e1000_pci_tbl,
213 .probe = e1000_probe, 223 .probe = e1000_probe,
214 .remove = __devexit_p(e1000_remove), 224 .remove = __devexit_p(e1000_remove),
225#ifdef CONFIG_PM
215 /* Power Managment Hooks */ 226 /* Power Managment Hooks */
216 .suspend = e1000_suspend, 227 .suspend = e1000_suspend,
217#ifdef CONFIG_PM
218 .resume = e1000_resume, 228 .resume = e1000_resume,
219#endif 229#endif
220 .shutdown = e1000_shutdown, 230 .shutdown = e1000_shutdown,
@@ -466,13 +476,14 @@ e1000_up(struct e1000_adapter *adapter)
466 476
467 adapter->tx_queue_len = netdev->tx_queue_len; 477 adapter->tx_queue_len = netdev->tx_queue_len;
468 478
469 mod_timer(&adapter->watchdog_timer, jiffies);
470
471#ifdef CONFIG_E1000_NAPI 479#ifdef CONFIG_E1000_NAPI
472 netif_poll_enable(netdev); 480 netif_poll_enable(netdev);
473#endif 481#endif
474 e1000_irq_enable(adapter); 482 e1000_irq_enable(adapter);
475 483
484 clear_bit(__E1000_DOWN, &adapter->flags);
485
486 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
476 return 0; 487 return 0;
477} 488}
478 489
@@ -502,25 +513,48 @@ void e1000_power_up_phy(struct e1000_adapter *adapter)
502 513
503static void e1000_power_down_phy(struct e1000_adapter *adapter) 514static void e1000_power_down_phy(struct e1000_adapter *adapter)
504{ 515{
505 boolean_t mng_mode_enabled = (adapter->hw.mac_type >= e1000_82571) && 516 /* Power down the PHY so no link is implied when interface is down *
506 e1000_check_mng_mode(&adapter->hw); 517 * The PHY cannot be powered down if any of the following is TRUE *
507 /* Power down the PHY so no link is implied when interface is down
508 * The PHY cannot be powered down if any of the following is TRUE
509 * (a) WoL is enabled 518 * (a) WoL is enabled
510 * (b) AMT is active 519 * (b) AMT is active
511 * (c) SoL/IDER session is active */ 520 * (c) SoL/IDER session is active */
512 if (!adapter->wol && adapter->hw.mac_type >= e1000_82540 && 521 if (!adapter->wol && adapter->hw.mac_type >= e1000_82540 &&
513 adapter->hw.mac_type != e1000_ich8lan && 522 adapter->hw.media_type == e1000_media_type_copper) {
514 adapter->hw.media_type == e1000_media_type_copper &&
515 !(E1000_READ_REG(&adapter->hw, MANC) & E1000_MANC_SMBUS_EN) &&
516 !mng_mode_enabled &&
517 !e1000_check_phy_reset_block(&adapter->hw)) {
518 uint16_t mii_reg = 0; 523 uint16_t mii_reg = 0;
524
525 switch (adapter->hw.mac_type) {
526 case e1000_82540:
527 case e1000_82545:
528 case e1000_82545_rev_3:
529 case e1000_82546:
530 case e1000_82546_rev_3:
531 case e1000_82541:
532 case e1000_82541_rev_2:
533 case e1000_82547:
534 case e1000_82547_rev_2:
535 if (E1000_READ_REG(&adapter->hw, MANC) &
536 E1000_MANC_SMBUS_EN)
537 goto out;
538 break;
539 case e1000_82571:
540 case e1000_82572:
541 case e1000_82573:
542 case e1000_80003es2lan:
543 case e1000_ich8lan:
544 if (e1000_check_mng_mode(&adapter->hw) ||
545 e1000_check_phy_reset_block(&adapter->hw))
546 goto out;
547 break;
548 default:
549 goto out;
550 }
519 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); 551 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
520 mii_reg |= MII_CR_POWER_DOWN; 552 mii_reg |= MII_CR_POWER_DOWN;
521 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg); 553 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
522 mdelay(1); 554 mdelay(1);
523 } 555 }
556out:
557 return;
524} 558}
525 559
526void 560void
@@ -528,6 +562,10 @@ e1000_down(struct e1000_adapter *adapter)
528{ 562{
529 struct net_device *netdev = adapter->netdev; 563 struct net_device *netdev = adapter->netdev;
530 564
565 /* signal that we're down so the interrupt handler does not
566 * reschedule our watchdog timer */
567 set_bit(__E1000_DOWN, &adapter->flags);
568
531 e1000_irq_disable(adapter); 569 e1000_irq_disable(adapter);
532 570
533 del_timer_sync(&adapter->tx_fifo_stall_timer); 571 del_timer_sync(&adapter->tx_fifo_stall_timer);
@@ -563,6 +601,9 @@ void
563e1000_reset(struct e1000_adapter *adapter) 601e1000_reset(struct e1000_adapter *adapter)
564{ 602{
565 uint32_t pba, manc; 603 uint32_t pba, manc;
604#ifdef DISABLE_MULR
605 uint32_t tctl;
606#endif
566 uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF; 607 uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF;
567 608
568 /* Repartition Pba for greater than 9k mtu 609 /* Repartition Pba for greater than 9k mtu
@@ -629,6 +670,12 @@ e1000_reset(struct e1000_adapter *adapter)
629 e1000_reset_hw(&adapter->hw); 670 e1000_reset_hw(&adapter->hw);
630 if (adapter->hw.mac_type >= e1000_82544) 671 if (adapter->hw.mac_type >= e1000_82544)
631 E1000_WRITE_REG(&adapter->hw, WUC, 0); 672 E1000_WRITE_REG(&adapter->hw, WUC, 0);
673#ifdef DISABLE_MULR
674 /* disable Multiple Reads in Transmit Control Register for debugging */
675 tctl = E1000_READ_REG(hw, TCTL);
676 E1000_WRITE_REG(hw, TCTL, tctl & ~E1000_TCTL_MULR);
677
678#endif
632 if (e1000_init_hw(&adapter->hw)) 679 if (e1000_init_hw(&adapter->hw))
633 DPRINTK(PROBE, ERR, "Hardware Error\n"); 680 DPRINTK(PROBE, ERR, "Hardware Error\n");
634 e1000_update_mng_vlan(adapter); 681 e1000_update_mng_vlan(adapter);
@@ -652,9 +699,7 @@ e1000_reset(struct e1000_adapter *adapter)
652 phy_data); 699 phy_data);
653 } 700 }
654 701
655 if (adapter->hw.mac_type < e1000_ich8lan) 702 if ((adapter->en_mng_pt) && (adapter->hw.mac_type < e1000_82571)) {
656 /* FIXME: this code is duplicate and wrong for PCI Express */
657 if (adapter->en_mng_pt) {
658 manc = E1000_READ_REG(&adapter->hw, MANC); 703 manc = E1000_READ_REG(&adapter->hw, MANC);
659 manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST); 704 manc |= (E1000_MANC_ARP_EN | E1000_MANC_EN_MNG2HOST);
660 E1000_WRITE_REG(&adapter->hw, MANC, manc); 705 E1000_WRITE_REG(&adapter->hw, MANC, manc);
@@ -760,7 +805,7 @@ e1000_probe(struct pci_dev *pdev,
760#ifdef CONFIG_NET_POLL_CONTROLLER 805#ifdef CONFIG_NET_POLL_CONTROLLER
761 netdev->poll_controller = e1000_netpoll; 806 netdev->poll_controller = e1000_netpoll;
762#endif 807#endif
763 strcpy(netdev->name, pci_name(pdev)); 808 strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
764 809
765 netdev->mem_start = mmio_start; 810 netdev->mem_start = mmio_start;
766 netdev->mem_end = mmio_start + mmio_len; 811 netdev->mem_end = mmio_start + mmio_len;
@@ -863,11 +908,6 @@ e1000_probe(struct pci_dev *pdev,
863 INIT_WORK(&adapter->reset_task, 908 INIT_WORK(&adapter->reset_task,
864 (void (*)(void *))e1000_reset_task, netdev); 909 (void (*)(void *))e1000_reset_task, netdev);
865 910
866 /* we're going to reset, so assume we have no link for now */
867
868 netif_carrier_off(netdev);
869 netif_stop_queue(netdev);
870
871 e1000_check_options(adapter); 911 e1000_check_options(adapter);
872 912
873 /* Initial Wake on LAN setting 913 /* Initial Wake on LAN setting
@@ -974,6 +1014,10 @@ e1000_probe(struct pci_dev *pdev,
974 if ((err = register_netdev(netdev))) 1014 if ((err = register_netdev(netdev)))
975 goto err_register; 1015 goto err_register;
976 1016
1017 /* tell the stack to leave us alone until e1000_open() is called */
1018 netif_carrier_off(netdev);
1019 netif_stop_queue(netdev);
1020
977 DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n"); 1021 DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
978 1022
979 cards_found++; 1023 cards_found++;
@@ -1032,8 +1076,7 @@ e1000_remove(struct pci_dev *pdev)
1032 1076
1033 flush_scheduled_work(); 1077 flush_scheduled_work();
1034 1078
1035 if (adapter->hw.mac_type >= e1000_82540 && 1079 if (adapter->hw.mac_type < e1000_82571 &&
1036 adapter->hw.mac_type != e1000_ich8lan &&
1037 adapter->hw.media_type == e1000_media_type_copper) { 1080 adapter->hw.media_type == e1000_media_type_copper) {
1038 manc = E1000_READ_REG(&adapter->hw, MANC); 1081 manc = E1000_READ_REG(&adapter->hw, MANC);
1039 if (manc & E1000_MANC_SMBUS_EN) { 1082 if (manc & E1000_MANC_SMBUS_EN) {
@@ -1161,6 +1204,8 @@ e1000_sw_init(struct e1000_adapter *adapter)
1161 atomic_set(&adapter->irq_sem, 1); 1204 atomic_set(&adapter->irq_sem, 1);
1162 spin_lock_init(&adapter->stats_lock); 1205 spin_lock_init(&adapter->stats_lock);
1163 1206
1207 set_bit(__E1000_DOWN, &adapter->flags);
1208
1164 return 0; 1209 return 0;
1165} 1210}
1166 1211
@@ -1226,7 +1271,7 @@ e1000_open(struct net_device *netdev)
1226 int err; 1271 int err;
1227 1272
1228 /* disallow open during test */ 1273 /* disallow open during test */
1229 if (test_bit(__E1000_DRIVER_TESTING, &adapter->flags)) 1274 if (test_bit(__E1000_TESTING, &adapter->flags))
1230 return -EBUSY; 1275 return -EBUSY;
1231 1276
1232 /* allocate transmit descriptors */ 1277 /* allocate transmit descriptors */
@@ -1299,8 +1344,12 @@ e1000_close(struct net_device *netdev)
1299 e1000_free_all_tx_resources(adapter); 1344 e1000_free_all_tx_resources(adapter);
1300 e1000_free_all_rx_resources(adapter); 1345 e1000_free_all_rx_resources(adapter);
1301 1346
1347 /* kill manageability vlan ID if supported, but not if a vlan with
1348 * the same ID is registered on the host OS (let 8021q kill it) */
1302 if ((adapter->hw.mng_cookie.status & 1349 if ((adapter->hw.mng_cookie.status &
1303 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) { 1350 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
1351 !(adapter->vlgrp &&
1352 adapter->vlgrp->vlan_devices[adapter->mng_vlan_id])) {
1304 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id); 1353 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
1305 } 1354 }
1306 1355
@@ -1510,27 +1559,14 @@ e1000_configure_tx(struct e1000_adapter *adapter)
1510 /* Program the Transmit Control Register */ 1559 /* Program the Transmit Control Register */
1511 1560
1512 tctl = E1000_READ_REG(hw, TCTL); 1561 tctl = E1000_READ_REG(hw, TCTL);
1513
1514 tctl &= ~E1000_TCTL_CT; 1562 tctl &= ~E1000_TCTL_CT;
1515 tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC | 1563 tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
1516 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT); 1564 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
1517 1565
1518#ifdef DISABLE_MULR
1519 /* disable Multiple Reads for debugging */
1520 tctl &= ~E1000_TCTL_MULR;
1521#endif
1522
1523 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) { 1566 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) {
1524 tarc = E1000_READ_REG(hw, TARC0); 1567 tarc = E1000_READ_REG(hw, TARC0);
1525 tarc |= ((1 << 25) | (1 << 21)); 1568 tarc |= (1 << 21);
1526 E1000_WRITE_REG(hw, TARC0, tarc); 1569 E1000_WRITE_REG(hw, TARC0, tarc);
1527 tarc = E1000_READ_REG(hw, TARC1);
1528 tarc |= (1 << 25);
1529 if (tctl & E1000_TCTL_MULR)
1530 tarc &= ~(1 << 28);
1531 else
1532 tarc |= (1 << 28);
1533 E1000_WRITE_REG(hw, TARC1, tarc);
1534 } else if (hw->mac_type == e1000_80003es2lan) { 1570 } else if (hw->mac_type == e1000_80003es2lan) {
1535 tarc = E1000_READ_REG(hw, TARC0); 1571 tarc = E1000_READ_REG(hw, TARC0);
1536 tarc |= 1; 1572 tarc |= 1;
@@ -2892,6 +2928,35 @@ e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)
2892 return 0; 2928 return 0;
2893} 2929}
2894 2930
2931static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
2932{
2933 struct e1000_adapter *adapter = netdev_priv(netdev);
2934 struct e1000_tx_ring *tx_ring = adapter->tx_ring;
2935
2936 netif_stop_queue(netdev);
2937 /* Herbert's original patch had:
2938 * smp_mb__after_netif_stop_queue();
2939 * but since that doesn't exist yet, just open code it. */
2940 smp_mb();
2941
2942 /* We need to check again in a case another CPU has just
2943 * made room available. */
2944 if (likely(E1000_DESC_UNUSED(tx_ring) < size))
2945 return -EBUSY;
2946
2947 /* A reprieve! */
2948 netif_start_queue(netdev);
2949 return 0;
2950}
2951
2952static int e1000_maybe_stop_tx(struct net_device *netdev,
2953 struct e1000_tx_ring *tx_ring, int size)
2954{
2955 if (likely(E1000_DESC_UNUSED(tx_ring) >= size))
2956 return 0;
2957 return __e1000_maybe_stop_tx(netdev, size);
2958}
2959
2895#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 ) 2960#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
2896static int 2961static int
2897e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) 2962e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
@@ -2910,6 +2975,10 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2910 unsigned int f; 2975 unsigned int f;
2911 len -= skb->data_len; 2976 len -= skb->data_len;
2912 2977
2978 /* This goes back to the question of how to logically map a tx queue
2979 * to a flow. Right now, performance is impacted slightly negatively
2980 * if using multiple tx queues. If the stack breaks away from a
2981 * single qdisc implementation, we can look at this again. */
2913 tx_ring = adapter->tx_ring; 2982 tx_ring = adapter->tx_ring;
2914 2983
2915 if (unlikely(skb->len <= 0)) { 2984 if (unlikely(skb->len <= 0)) {
@@ -3005,8 +3074,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3005 3074
3006 /* need: count + 2 desc gap to keep tail from touching 3075 /* need: count + 2 desc gap to keep tail from touching
3007 * head, otherwise try next time */ 3076 * head, otherwise try next time */
3008 if (unlikely(E1000_DESC_UNUSED(tx_ring) < count + 2)) { 3077 if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2))) {
3009 netif_stop_queue(netdev);
3010 spin_unlock_irqrestore(&tx_ring->tx_lock, flags); 3078 spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
3011 return NETDEV_TX_BUSY; 3079 return NETDEV_TX_BUSY;
3012 } 3080 }
@@ -3014,7 +3082,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3014 if (unlikely(adapter->hw.mac_type == e1000_82547)) { 3082 if (unlikely(adapter->hw.mac_type == e1000_82547)) {
3015 if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) { 3083 if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) {
3016 netif_stop_queue(netdev); 3084 netif_stop_queue(netdev);
3017 mod_timer(&adapter->tx_fifo_stall_timer, jiffies); 3085 mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
3018 spin_unlock_irqrestore(&tx_ring->tx_lock, flags); 3086 spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
3019 return NETDEV_TX_BUSY; 3087 return NETDEV_TX_BUSY;
3020 } 3088 }
@@ -3053,8 +3121,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3053 netdev->trans_start = jiffies; 3121 netdev->trans_start = jiffies;
3054 3122
3055 /* Make sure there is space in the ring for the next send. */ 3123 /* Make sure there is space in the ring for the next send. */
3056 if (unlikely(E1000_DESC_UNUSED(tx_ring) < MAX_SKB_FRAGS + 2)) 3124 e1000_maybe_stop_tx(netdev, tx_ring, MAX_SKB_FRAGS + 2);
3057 netif_stop_queue(netdev);
3058 3125
3059 spin_unlock_irqrestore(&tx_ring->tx_lock, flags); 3126 spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
3060 return NETDEV_TX_OK; 3127 return NETDEV_TX_OK;
@@ -3131,11 +3198,13 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu)
3131 } 3198 }
3132 break; 3199 break;
3133 case e1000_82573: 3200 case e1000_82573:
3134 /* only enable jumbo frames if ASPM is disabled completely 3201 /* Jumbo Frames not supported if:
3135 * this means both bits must be zero in 0x1A bits 3:2 */ 3202 * - this is not an 82573L device
3203 * - ASPM is enabled in any way (0x1A bits 3:2) */
3136 e1000_read_eeprom(&adapter->hw, EEPROM_INIT_3GIO_3, 1, 3204 e1000_read_eeprom(&adapter->hw, EEPROM_INIT_3GIO_3, 1,
3137 &eeprom_data); 3205 &eeprom_data);
3138 if (eeprom_data & EEPROM_WORD1A_ASPM_MASK) { 3206 if ((adapter->hw.device_id != E1000_DEV_ID_82573L) ||
3207 (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) {
3139 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { 3208 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
3140 DPRINTK(PROBE, ERR, 3209 DPRINTK(PROBE, ERR,
3141 "Jumbo Frames not supported.\n"); 3210 "Jumbo Frames not supported.\n");
@@ -3143,6 +3212,8 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu)
3143 } 3212 }
3144 break; 3213 break;
3145 } 3214 }
3215 /* ERT will be enabled later to enable wire speed receives */
3216
3146 /* fall through to get support */ 3217 /* fall through to get support */
3147 case e1000_82571: 3218 case e1000_82571:
3148 case e1000_82572: 3219 case e1000_82572:
@@ -3328,16 +3399,15 @@ e1000_update_stats(struct e1000_adapter *adapter)
3328 adapter->stats.crcerrs + adapter->stats.algnerrc + 3399 adapter->stats.crcerrs + adapter->stats.algnerrc +
3329 adapter->stats.ruc + adapter->stats.roc + 3400 adapter->stats.ruc + adapter->stats.roc +
3330 adapter->stats.cexterr; 3401 adapter->stats.cexterr;
3331 adapter->net_stats.rx_length_errors = adapter->stats.ruc + 3402 adapter->stats.rlerrc = adapter->stats.ruc + adapter->stats.roc;
3332 adapter->stats.roc; 3403 adapter->net_stats.rx_length_errors = adapter->stats.rlerrc;
3333 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs; 3404 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
3334 adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc; 3405 adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
3335 adapter->net_stats.rx_missed_errors = adapter->stats.mpc; 3406 adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
3336 3407
3337 /* Tx Errors */ 3408 /* Tx Errors */
3338 3409 adapter->stats.txerrc = adapter->stats.ecol + adapter->stats.latecol;
3339 adapter->net_stats.tx_errors = adapter->stats.ecol + 3410 adapter->net_stats.tx_errors = adapter->stats.txerrc;
3340 adapter->stats.latecol;
3341 adapter->net_stats.tx_aborted_errors = adapter->stats.ecol; 3411 adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
3342 adapter->net_stats.tx_window_errors = adapter->stats.latecol; 3412 adapter->net_stats.tx_window_errors = adapter->stats.latecol;
3343 adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs; 3413 adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
@@ -3408,7 +3478,9 @@ e1000_intr(int irq, void *data, struct pt_regs *regs)
3408 rctl = E1000_READ_REG(hw, RCTL); 3478 rctl = E1000_READ_REG(hw, RCTL);
3409 E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN); 3479 E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
3410 } 3480 }
3411 mod_timer(&adapter->watchdog_timer, jiffies); 3481 /* guard against interrupt when we're going down */
3482 if (!test_bit(__E1000_DOWN, &adapter->flags))
3483 mod_timer(&adapter->watchdog_timer, jiffies + 1);
3412 } 3484 }
3413 3485
3414#ifdef CONFIG_E1000_NAPI 3486#ifdef CONFIG_E1000_NAPI
@@ -3546,13 +3618,14 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3546 tx_ring->next_to_clean = i; 3618 tx_ring->next_to_clean = i;
3547 3619
3548#define TX_WAKE_THRESHOLD 32 3620#define TX_WAKE_THRESHOLD 32
3549 if (unlikely(cleaned && netif_queue_stopped(netdev) && 3621 if (unlikely(cleaned && netif_carrier_ok(netdev) &&
3550 netif_carrier_ok(netdev))) { 3622 E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) {
3551 spin_lock(&tx_ring->tx_lock); 3623 /* Make sure that anybody stopping the queue after this
3552 if (netif_queue_stopped(netdev) && 3624 * sees the new next_to_clean.
3553 (E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) 3625 */
3626 smp_mb();
3627 if (netif_queue_stopped(netdev))
3554 netif_wake_queue(netdev); 3628 netif_wake_queue(netdev);
3555 spin_unlock(&tx_ring->tx_lock);
3556 } 3629 }
3557 3630
3558 if (adapter->detect_tx_hung) { 3631 if (adapter->detect_tx_hung) {
@@ -4412,13 +4485,21 @@ e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
4412 pci_write_config_word(adapter->pdev, reg, *value); 4485 pci_write_config_word(adapter->pdev, reg, *value);
4413} 4486}
4414 4487
4415#if 0 4488int32_t
4416uint32_t 4489e1000_read_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
4417e1000_io_read(struct e1000_hw *hw, unsigned long port)
4418{ 4490{
4419 return inl(port); 4491 struct e1000_adapter *adapter = hw->back;
4492 uint16_t cap_offset;
4493
4494 cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
4495 if (!cap_offset)
4496 return -E1000_ERR_CONFIG;
4497
4498 pci_read_config_word(adapter->pdev, cap_offset + reg, value);
4499
4500 return E1000_SUCCESS;
4420} 4501}
4421#endif /* 0 */ 4502
4422 4503
4423void 4504void
4424e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value) 4505e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value)
@@ -4693,9 +4774,7 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4693 pci_enable_wake(pdev, PCI_D3cold, 0); 4774 pci_enable_wake(pdev, PCI_D3cold, 0);
4694 } 4775 }
4695 4776
4696 /* FIXME: this code is incorrect for PCI Express */ 4777 if (adapter->hw.mac_type < e1000_82571 &&
4697 if (adapter->hw.mac_type >= e1000_82540 &&
4698 adapter->hw.mac_type != e1000_ich8lan &&
4699 adapter->hw.media_type == e1000_media_type_copper) { 4778 adapter->hw.media_type == e1000_media_type_copper) {
4700 manc = E1000_READ_REG(&adapter->hw, MANC); 4779 manc = E1000_READ_REG(&adapter->hw, MANC);
4701 if (manc & E1000_MANC_SMBUS_EN) { 4780 if (manc & E1000_MANC_SMBUS_EN) {
@@ -4747,9 +4826,7 @@ e1000_resume(struct pci_dev *pdev)
4747 4826
4748 netif_device_attach(netdev); 4827 netif_device_attach(netdev);
4749 4828
4750 /* FIXME: this code is incorrect for PCI Express */ 4829 if (adapter->hw.mac_type < e1000_82571 &&
4751 if (adapter->hw.mac_type >= e1000_82540 &&
4752 adapter->hw.mac_type != e1000_ich8lan &&
4753 adapter->hw.media_type == e1000_media_type_copper) { 4830 adapter->hw.media_type == e1000_media_type_copper) {
4754 manc = E1000_READ_REG(&adapter->hw, MANC); 4831 manc = E1000_READ_REG(&adapter->hw, MANC);
4755 manc &= ~(E1000_MANC_ARP_EN); 4832 manc &= ~(E1000_MANC_ARP_EN);
@@ -4835,8 +4912,8 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4835 } 4912 }
4836 pci_set_master(pdev); 4913 pci_set_master(pdev);
4837 4914
4838 pci_enable_wake(pdev, 3, 0); 4915 pci_enable_wake(pdev, PCI_D3hot, 0);
4839 pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */ 4916 pci_enable_wake(pdev, PCI_D3cold, 0);
4840 4917
4841 /* Perform card reset only on one instance of the card */ 4918 /* Perform card reset only on one instance of the card */
4842 if (PCI_FUNC (pdev->devfn) != 0) 4919 if (PCI_FUNC (pdev->devfn) != 0)