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.c825
1 files changed, 152 insertions, 673 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index c66dd4f9437c..bcd192ca47b0 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -31,7 +31,7 @@
31 31
32char e1000_driver_name[] = "e1000"; 32char e1000_driver_name[] = "e1000";
33static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; 33static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
34#define DRV_VERSION "7.3.21-k3-NAPI" 34#define DRV_VERSION "7.3.21-k5-NAPI"
35const char e1000_driver_version[] = DRV_VERSION; 35const char e1000_driver_version[] = DRV_VERSION;
36static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 36static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
37 37
@@ -131,7 +131,6 @@ static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
131static int e1000_change_mtu(struct net_device *netdev, int new_mtu); 131static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
132static int e1000_set_mac(struct net_device *netdev, void *p); 132static int e1000_set_mac(struct net_device *netdev, void *p);
133static irqreturn_t e1000_intr(int irq, void *data); 133static irqreturn_t e1000_intr(int irq, void *data);
134static irqreturn_t e1000_intr_msi(int irq, void *data);
135static bool e1000_clean_tx_irq(struct e1000_adapter *adapter, 134static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
136 struct e1000_tx_ring *tx_ring); 135 struct e1000_tx_ring *tx_ring);
137static int e1000_clean(struct napi_struct *napi, int budget); 136static int e1000_clean(struct napi_struct *napi, int budget);
@@ -258,25 +257,14 @@ module_exit(e1000_exit_module);
258 257
259static int e1000_request_irq(struct e1000_adapter *adapter) 258static int e1000_request_irq(struct e1000_adapter *adapter)
260{ 259{
261 struct e1000_hw *hw = &adapter->hw;
262 struct net_device *netdev = adapter->netdev; 260 struct net_device *netdev = adapter->netdev;
263 irq_handler_t handler = e1000_intr; 261 irq_handler_t handler = e1000_intr;
264 int irq_flags = IRQF_SHARED; 262 int irq_flags = IRQF_SHARED;
265 int err; 263 int err;
266 264
267 if (hw->mac_type >= e1000_82571) {
268 adapter->have_msi = !pci_enable_msi(adapter->pdev);
269 if (adapter->have_msi) {
270 handler = e1000_intr_msi;
271 irq_flags = 0;
272 }
273 }
274
275 err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name, 265 err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
276 netdev); 266 netdev);
277 if (err) { 267 if (err) {
278 if (adapter->have_msi)
279 pci_disable_msi(adapter->pdev);
280 DPRINTK(PROBE, ERR, 268 DPRINTK(PROBE, ERR,
281 "Unable to allocate interrupt Error: %d\n", err); 269 "Unable to allocate interrupt Error: %d\n", err);
282 } 270 }
@@ -289,9 +277,6 @@ static void e1000_free_irq(struct e1000_adapter *adapter)
289 struct net_device *netdev = adapter->netdev; 277 struct net_device *netdev = adapter->netdev;
290 278
291 free_irq(adapter->pdev->irq, netdev); 279 free_irq(adapter->pdev->irq, netdev);
292
293 if (adapter->have_msi)
294 pci_disable_msi(adapter->pdev);
295} 280}
296 281
297/** 282/**
@@ -345,76 +330,6 @@ static void e1000_update_mng_vlan(struct e1000_adapter *adapter)
345 } 330 }
346} 331}
347 332
348/**
349 * e1000_release_hw_control - release control of the h/w to f/w
350 * @adapter: address of board private structure
351 *
352 * e1000_release_hw_control resets {CTRL_EXT|FWSM}:DRV_LOAD bit.
353 * For ASF and Pass Through versions of f/w this means that the
354 * driver is no longer loaded. For AMT version (only with 82573) i
355 * of the f/w this means that the network i/f is closed.
356 *
357 **/
358
359static void e1000_release_hw_control(struct e1000_adapter *adapter)
360{
361 u32 ctrl_ext;
362 u32 swsm;
363 struct e1000_hw *hw = &adapter->hw;
364
365 /* Let firmware taken over control of h/w */
366 switch (hw->mac_type) {
367 case e1000_82573:
368 swsm = er32(SWSM);
369 ew32(SWSM, swsm & ~E1000_SWSM_DRV_LOAD);
370 break;
371 case e1000_82571:
372 case e1000_82572:
373 case e1000_80003es2lan:
374 case e1000_ich8lan:
375 ctrl_ext = er32(CTRL_EXT);
376 ew32(CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
377 break;
378 default:
379 break;
380 }
381}
382
383/**
384 * e1000_get_hw_control - get control of the h/w from f/w
385 * @adapter: address of board private structure
386 *
387 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit.
388 * For ASF and Pass Through versions of f/w this means that
389 * the driver is loaded. For AMT version (only with 82573)
390 * of the f/w this means that the network i/f is open.
391 *
392 **/
393
394static void e1000_get_hw_control(struct e1000_adapter *adapter)
395{
396 u32 ctrl_ext;
397 u32 swsm;
398 struct e1000_hw *hw = &adapter->hw;
399
400 /* Let firmware know the driver has taken over */
401 switch (hw->mac_type) {
402 case e1000_82573:
403 swsm = er32(SWSM);
404 ew32(SWSM, swsm | E1000_SWSM_DRV_LOAD);
405 break;
406 case e1000_82571:
407 case e1000_82572:
408 case e1000_80003es2lan:
409 case e1000_ich8lan:
410 ctrl_ext = er32(CTRL_EXT);
411 ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
412 break;
413 default:
414 break;
415 }
416}
417
418static void e1000_init_manageability(struct e1000_adapter *adapter) 333static void e1000_init_manageability(struct e1000_adapter *adapter)
419{ 334{
420 struct e1000_hw *hw = &adapter->hw; 335 struct e1000_hw *hw = &adapter->hw;
@@ -425,20 +340,6 @@ static void e1000_init_manageability(struct e1000_adapter *adapter)
425 /* disable hardware interception of ARP */ 340 /* disable hardware interception of ARP */
426 manc &= ~(E1000_MANC_ARP_EN); 341 manc &= ~(E1000_MANC_ARP_EN);
427 342
428 /* enable receiving management packets to the host */
429 /* this will probably generate destination unreachable messages
430 * from the host OS, but the packets will be handled on SMBUS */
431 if (hw->has_manc2h) {
432 u32 manc2h = er32(MANC2H);
433
434 manc |= E1000_MANC_EN_MNG2HOST;
435#define E1000_MNG2HOST_PORT_623 (1 << 5)
436#define E1000_MNG2HOST_PORT_664 (1 << 6)
437 manc2h |= E1000_MNG2HOST_PORT_623;
438 manc2h |= E1000_MNG2HOST_PORT_664;
439 ew32(MANC2H, manc2h);
440 }
441
442 ew32(MANC, manc); 343 ew32(MANC, manc);
443 } 344 }
444} 345}
@@ -453,12 +354,6 @@ static void e1000_release_manageability(struct e1000_adapter *adapter)
453 /* re-enable hardware interception of ARP */ 354 /* re-enable hardware interception of ARP */
454 manc |= E1000_MANC_ARP_EN; 355 manc |= E1000_MANC_ARP_EN;
455 356
456 if (hw->has_manc2h)
457 manc &= ~E1000_MANC_EN_MNG2HOST;
458
459 /* don't explicitly have to mess with MANC2H since
460 * MANC has an enable disable that gates MANC2H */
461
462 ew32(MANC, manc); 357 ew32(MANC, manc);
463 } 358 }
464} 359}
@@ -563,15 +458,6 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter)
563 if (er32(MANC) & E1000_MANC_SMBUS_EN) 458 if (er32(MANC) & E1000_MANC_SMBUS_EN)
564 goto out; 459 goto out;
565 break; 460 break;
566 case e1000_82571:
567 case e1000_82572:
568 case e1000_82573:
569 case e1000_80003es2lan:
570 case e1000_ich8lan:
571 if (e1000_check_mng_mode(hw) ||
572 e1000_check_phy_reset_block(hw))
573 goto out;
574 break;
575 default: 461 default:
576 goto out; 462 goto out;
577 } 463 }
@@ -599,8 +485,7 @@ void e1000_down(struct e1000_adapter *adapter)
599 ew32(RCTL, rctl & ~E1000_RCTL_EN); 485 ew32(RCTL, rctl & ~E1000_RCTL_EN);
600 /* flush and sleep below */ 486 /* flush and sleep below */
601 487
602 /* can be netif_tx_disable when NETIF_F_LLTX is removed */ 488 netif_tx_disable(netdev);
603 netif_stop_queue(netdev);
604 489
605 /* disable transmits in the hardware */ 490 /* disable transmits in the hardware */
606 tctl = er32(TCTL); 491 tctl = er32(TCTL);
@@ -671,16 +556,6 @@ void e1000_reset(struct e1000_adapter *adapter)
671 legacy_pba_adjust = true; 556 legacy_pba_adjust = true;
672 pba = E1000_PBA_30K; 557 pba = E1000_PBA_30K;
673 break; 558 break;
674 case e1000_82571:
675 case e1000_82572:
676 case e1000_80003es2lan:
677 pba = E1000_PBA_38K;
678 break;
679 case e1000_82573:
680 pba = E1000_PBA_20K;
681 break;
682 case e1000_ich8lan:
683 pba = E1000_PBA_8K;
684 case e1000_undefined: 559 case e1000_undefined:
685 case e1000_num_macs: 560 case e1000_num_macs:
686 break; 561 break;
@@ -744,16 +619,8 @@ void e1000_reset(struct e1000_adapter *adapter)
744 619
745 /* if short on rx space, rx wins and must trump tx 620 /* if short on rx space, rx wins and must trump tx
746 * adjustment or use Early Receive if available */ 621 * adjustment or use Early Receive if available */
747 if (pba < min_rx_space) { 622 if (pba < min_rx_space)
748 switch (hw->mac_type) { 623 pba = min_rx_space;
749 case e1000_82573:
750 /* ERT enabled in e1000_configure_rx */
751 break;
752 default:
753 pba = min_rx_space;
754 break;
755 }
756 }
757 } 624 }
758 } 625 }
759 626
@@ -789,7 +656,6 @@ void e1000_reset(struct e1000_adapter *adapter)
789 656
790 /* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */ 657 /* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */
791 if (hw->mac_type >= e1000_82544 && 658 if (hw->mac_type >= e1000_82544 &&
792 hw->mac_type <= e1000_82547_rev_2 &&
793 hw->autoneg == 1 && 659 hw->autoneg == 1 &&
794 hw->autoneg_advertised == ADVERTISE_1000_FULL) { 660 hw->autoneg_advertised == ADVERTISE_1000_FULL) {
795 u32 ctrl = er32(CTRL); 661 u32 ctrl = er32(CTRL);
@@ -806,20 +672,6 @@ void e1000_reset(struct e1000_adapter *adapter)
806 e1000_reset_adaptive(hw); 672 e1000_reset_adaptive(hw);
807 e1000_phy_get_info(hw, &adapter->phy_info); 673 e1000_phy_get_info(hw, &adapter->phy_info);
808 674
809 if (!adapter->smart_power_down &&
810 (hw->mac_type == e1000_82571 ||
811 hw->mac_type == e1000_82572)) {
812 u16 phy_data = 0;
813 /* speed up time to link by disabling smart power down, ignore
814 * the return value of this function because there is nothing
815 * different we would do if it failed */
816 e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
817 &phy_data);
818 phy_data &= ~IGP02E1000_PM_SPD;
819 e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
820 phy_data);
821 }
822
823 e1000_release_manageability(adapter); 675 e1000_release_manageability(adapter);
824} 676}
825 677
@@ -1046,17 +898,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1046 goto err_sw_init; 898 goto err_sw_init;
1047 899
1048 err = -EIO; 900 err = -EIO;
1049 /* Flash BAR mapping must happen after e1000_sw_init
1050 * because it depends on mac_type */
1051 if ((hw->mac_type == e1000_ich8lan) &&
1052 (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
1053 hw->flash_address = pci_ioremap_bar(pdev, 1);
1054 if (!hw->flash_address)
1055 goto err_flashmap;
1056 }
1057
1058 if (e1000_check_phy_reset_block(hw))
1059 DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
1060 901
1061 if (hw->mac_type >= e1000_82543) { 902 if (hw->mac_type >= e1000_82543) {
1062 netdev->features = NETIF_F_SG | 903 netdev->features = NETIF_F_SG |
@@ -1064,21 +905,16 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1064 NETIF_F_HW_VLAN_TX | 905 NETIF_F_HW_VLAN_TX |
1065 NETIF_F_HW_VLAN_RX | 906 NETIF_F_HW_VLAN_RX |
1066 NETIF_F_HW_VLAN_FILTER; 907 NETIF_F_HW_VLAN_FILTER;
1067 if (hw->mac_type == e1000_ich8lan)
1068 netdev->features &= ~NETIF_F_HW_VLAN_FILTER;
1069 } 908 }
1070 909
1071 if ((hw->mac_type >= e1000_82544) && 910 if ((hw->mac_type >= e1000_82544) &&
1072 (hw->mac_type != e1000_82547)) 911 (hw->mac_type != e1000_82547))
1073 netdev->features |= NETIF_F_TSO; 912 netdev->features |= NETIF_F_TSO;
1074 913
1075 if (hw->mac_type > e1000_82547_rev_2)
1076 netdev->features |= NETIF_F_TSO6;
1077 if (pci_using_dac) 914 if (pci_using_dac)
1078 netdev->features |= NETIF_F_HIGHDMA; 915 netdev->features |= NETIF_F_HIGHDMA;
1079 916
1080 netdev->vlan_features |= NETIF_F_TSO; 917 netdev->vlan_features |= NETIF_F_TSO;
1081 netdev->vlan_features |= NETIF_F_TSO6;
1082 netdev->vlan_features |= NETIF_F_HW_CSUM; 918 netdev->vlan_features |= NETIF_F_HW_CSUM;
1083 netdev->vlan_features |= NETIF_F_SG; 919 netdev->vlan_features |= NETIF_F_SG;
1084 920
@@ -1153,15 +989,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1153 EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data); 989 EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
1154 eeprom_apme_mask = E1000_EEPROM_82544_APM; 990 eeprom_apme_mask = E1000_EEPROM_82544_APM;
1155 break; 991 break;
1156 case e1000_ich8lan:
1157 e1000_read_eeprom(hw,
1158 EEPROM_INIT_CONTROL1_REG, 1, &eeprom_data);
1159 eeprom_apme_mask = E1000_EEPROM_ICH8_APME;
1160 break;
1161 case e1000_82546: 992 case e1000_82546:
1162 case e1000_82546_rev_3: 993 case e1000_82546_rev_3:
1163 case e1000_82571:
1164 case e1000_80003es2lan:
1165 if (er32(STATUS) & E1000_STATUS_FUNC_1){ 994 if (er32(STATUS) & E1000_STATUS_FUNC_1){
1166 e1000_read_eeprom(hw, 995 e1000_read_eeprom(hw,
1167 EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data); 996 EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
@@ -1185,17 +1014,12 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1185 break; 1014 break;
1186 case E1000_DEV_ID_82546EB_FIBER: 1015 case E1000_DEV_ID_82546EB_FIBER:
1187 case E1000_DEV_ID_82546GB_FIBER: 1016 case E1000_DEV_ID_82546GB_FIBER:
1188 case E1000_DEV_ID_82571EB_FIBER:
1189 /* Wake events only supported on port A for dual fiber 1017 /* Wake events only supported on port A for dual fiber
1190 * regardless of eeprom setting */ 1018 * regardless of eeprom setting */
1191 if (er32(STATUS) & E1000_STATUS_FUNC_1) 1019 if (er32(STATUS) & E1000_STATUS_FUNC_1)
1192 adapter->eeprom_wol = 0; 1020 adapter->eeprom_wol = 0;
1193 break; 1021 break;
1194 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: 1022 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
1195 case E1000_DEV_ID_82571EB_QUAD_COPPER:
1196 case E1000_DEV_ID_82571EB_QUAD_FIBER:
1197 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
1198 case E1000_DEV_ID_82571PT_QUAD_COPPER:
1199 /* if quad port adapter, disable WoL on all but port A */ 1023 /* if quad port adapter, disable WoL on all but port A */
1200 if (global_quad_port_a != 0) 1024 if (global_quad_port_a != 0)
1201 adapter->eeprom_wol = 0; 1025 adapter->eeprom_wol = 0;
@@ -1213,39 +1037,18 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1213 1037
1214 /* print bus type/speed/width info */ 1038 /* print bus type/speed/width info */
1215 DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ", 1039 DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ",
1216 ((hw->bus_type == e1000_bus_type_pcix) ? "-X" : 1040 ((hw->bus_type == e1000_bus_type_pcix) ? "-X" : ""),
1217 (hw->bus_type == e1000_bus_type_pci_express ? " Express":"")), 1041 ((hw->bus_speed == e1000_bus_speed_133) ? "133MHz" :
1218 ((hw->bus_speed == e1000_bus_speed_2500) ? "2.5Gb/s" :
1219 (hw->bus_speed == e1000_bus_speed_133) ? "133MHz" :
1220 (hw->bus_speed == e1000_bus_speed_120) ? "120MHz" : 1042 (hw->bus_speed == e1000_bus_speed_120) ? "120MHz" :
1221 (hw->bus_speed == e1000_bus_speed_100) ? "100MHz" : 1043 (hw->bus_speed == e1000_bus_speed_100) ? "100MHz" :
1222 (hw->bus_speed == e1000_bus_speed_66) ? "66MHz" : "33MHz"), 1044 (hw->bus_speed == e1000_bus_speed_66) ? "66MHz" : "33MHz"),
1223 ((hw->bus_width == e1000_bus_width_64) ? "64-bit" : 1045 ((hw->bus_width == e1000_bus_width_64) ? "64-bit" : "32-bit"));
1224 (hw->bus_width == e1000_bus_width_pciex_4) ? "Width x4" :
1225 (hw->bus_width == e1000_bus_width_pciex_1) ? "Width x1" :
1226 "32-bit"));
1227 1046
1228 printk("%pM\n", netdev->dev_addr); 1047 printk("%pM\n", netdev->dev_addr);
1229 1048
1230 if (hw->bus_type == e1000_bus_type_pci_express) {
1231 DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no "
1232 "longer be supported by this driver in the future.\n",
1233 pdev->vendor, pdev->device);
1234 DPRINTK(PROBE, WARNING, "please use the \"e1000e\" "
1235 "driver instead.\n");
1236 }
1237
1238 /* reset the hardware with the new settings */ 1049 /* reset the hardware with the new settings */
1239 e1000_reset(adapter); 1050 e1000_reset(adapter);
1240 1051
1241 /* If the controller is 82573 and f/w is AMT, do not set
1242 * DRV_LOAD until the interface is up. For all other cases,
1243 * let the f/w know that the h/w is now under the control
1244 * of the driver. */
1245 if (hw->mac_type != e1000_82573 ||
1246 !e1000_check_mng_mode(hw))
1247 e1000_get_hw_control(adapter);
1248
1249 strcpy(netdev->name, "eth%d"); 1052 strcpy(netdev->name, "eth%d");
1250 err = register_netdev(netdev); 1053 err = register_netdev(netdev);
1251 if (err) 1054 if (err)
@@ -1260,14 +1063,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1260 return 0; 1063 return 0;
1261 1064
1262err_register: 1065err_register:
1263 e1000_release_hw_control(adapter);
1264err_eeprom: 1066err_eeprom:
1265 if (!e1000_check_phy_reset_block(hw)) 1067 e1000_phy_hw_reset(hw);
1266 e1000_phy_hw_reset(hw);
1267 1068
1268 if (hw->flash_address) 1069 if (hw->flash_address)
1269 iounmap(hw->flash_address); 1070 iounmap(hw->flash_address);
1270err_flashmap:
1271 kfree(adapter->tx_ring); 1071 kfree(adapter->tx_ring);
1272 kfree(adapter->rx_ring); 1072 kfree(adapter->rx_ring);
1273err_sw_init: 1073err_sw_init:
@@ -1298,18 +1098,18 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
1298 struct e1000_adapter *adapter = netdev_priv(netdev); 1098 struct e1000_adapter *adapter = netdev_priv(netdev);
1299 struct e1000_hw *hw = &adapter->hw; 1099 struct e1000_hw *hw = &adapter->hw;
1300 1100
1101 set_bit(__E1000_DOWN, &adapter->flags);
1102 del_timer_sync(&adapter->tx_fifo_stall_timer);
1103 del_timer_sync(&adapter->watchdog_timer);
1104 del_timer_sync(&adapter->phy_info_timer);
1105
1301 cancel_work_sync(&adapter->reset_task); 1106 cancel_work_sync(&adapter->reset_task);
1302 1107
1303 e1000_release_manageability(adapter); 1108 e1000_release_manageability(adapter);
1304 1109
1305 /* Release control of h/w to f/w. If f/w is AMT enabled, this
1306 * would have already happened in close and is redundant. */
1307 e1000_release_hw_control(adapter);
1308
1309 unregister_netdev(netdev); 1110 unregister_netdev(netdev);
1310 1111
1311 if (!e1000_check_phy_reset_block(hw)) 1112 e1000_phy_hw_reset(hw);
1312 e1000_phy_hw_reset(hw);
1313 1113
1314 kfree(adapter->tx_ring); 1114 kfree(adapter->tx_ring);
1315 kfree(adapter->rx_ring); 1115 kfree(adapter->rx_ring);
@@ -1472,12 +1272,6 @@ static int e1000_open(struct net_device *netdev)
1472 e1000_update_mng_vlan(adapter); 1272 e1000_update_mng_vlan(adapter);
1473 } 1273 }
1474 1274
1475 /* If AMT is enabled, let the firmware know that the network
1476 * interface is now open */
1477 if (hw->mac_type == e1000_82573 &&
1478 e1000_check_mng_mode(hw))
1479 e1000_get_hw_control(adapter);
1480
1481 /* before we allocate an interrupt, we must be ready to handle it. 1275 /* before we allocate an interrupt, we must be ready to handle it.
1482 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt 1276 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
1483 * as soon as we call pci_request_irq, so we have to setup our 1277 * as soon as we call pci_request_irq, so we have to setup our
@@ -1503,7 +1297,6 @@ static int e1000_open(struct net_device *netdev)
1503 return E1000_SUCCESS; 1297 return E1000_SUCCESS;
1504 1298
1505err_req_irq: 1299err_req_irq:
1506 e1000_release_hw_control(adapter);
1507 e1000_power_down_phy(adapter); 1300 e1000_power_down_phy(adapter);
1508 e1000_free_all_rx_resources(adapter); 1301 e1000_free_all_rx_resources(adapter);
1509err_setup_rx: 1302err_setup_rx:
@@ -1548,12 +1341,6 @@ static int e1000_close(struct net_device *netdev)
1548 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id); 1341 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
1549 } 1342 }
1550 1343
1551 /* If AMT is enabled, let the firmware know that the network
1552 * interface is now closed */
1553 if (hw->mac_type == e1000_82573 &&
1554 e1000_check_mng_mode(hw))
1555 e1000_release_hw_control(adapter);
1556
1557 return 0; 1344 return 0;
1558} 1345}
1559 1346
@@ -1692,7 +1479,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
1692{ 1479{
1693 u64 tdba; 1480 u64 tdba;
1694 struct e1000_hw *hw = &adapter->hw; 1481 struct e1000_hw *hw = &adapter->hw;
1695 u32 tdlen, tctl, tipg, tarc; 1482 u32 tdlen, tctl, tipg;
1696 u32 ipgr1, ipgr2; 1483 u32 ipgr1, ipgr2;
1697 1484
1698 /* Setup the HW Tx Head and Tail descriptor pointers */ 1485 /* Setup the HW Tx Head and Tail descriptor pointers */
@@ -1714,8 +1501,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
1714 } 1501 }
1715 1502
1716 /* Set the default values for the Tx Inter Packet Gap timer */ 1503 /* Set the default values for the Tx Inter Packet Gap timer */
1717 if (hw->mac_type <= e1000_82547_rev_2 && 1504 if ((hw->media_type == e1000_media_type_fiber ||
1718 (hw->media_type == e1000_media_type_fiber ||
1719 hw->media_type == e1000_media_type_internal_serdes)) 1505 hw->media_type == e1000_media_type_internal_serdes))
1720 tipg = DEFAULT_82543_TIPG_IPGT_FIBER; 1506 tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
1721 else 1507 else
@@ -1728,10 +1514,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
1728 ipgr1 = DEFAULT_82542_TIPG_IPGR1; 1514 ipgr1 = DEFAULT_82542_TIPG_IPGR1;
1729 ipgr2 = DEFAULT_82542_TIPG_IPGR2; 1515 ipgr2 = DEFAULT_82542_TIPG_IPGR2;
1730 break; 1516 break;
1731 case e1000_80003es2lan:
1732 ipgr1 = DEFAULT_82543_TIPG_IPGR1;
1733 ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2;
1734 break;
1735 default: 1517 default:
1736 ipgr1 = DEFAULT_82543_TIPG_IPGR1; 1518 ipgr1 = DEFAULT_82543_TIPG_IPGR1;
1737 ipgr2 = DEFAULT_82543_TIPG_IPGR2; 1519 ipgr2 = DEFAULT_82543_TIPG_IPGR2;
@@ -1754,21 +1536,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
1754 tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC | 1536 tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
1755 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT); 1537 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
1756 1538
1757 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) {
1758 tarc = er32(TARC0);
1759 /* set the speed mode bit, we'll clear it if we're not at
1760 * gigabit link later */
1761 tarc |= (1 << 21);
1762 ew32(TARC0, tarc);
1763 } else if (hw->mac_type == e1000_80003es2lan) {
1764 tarc = er32(TARC0);
1765 tarc |= 1;
1766 ew32(TARC0, tarc);
1767 tarc = er32(TARC1);
1768 tarc |= 1;
1769 ew32(TARC1, tarc);
1770 }
1771
1772 e1000_config_collision_dist(hw); 1539 e1000_config_collision_dist(hw);
1773 1540
1774 /* Setup Transmit Descriptor Settings for eop descriptor */ 1541 /* Setup Transmit Descriptor Settings for eop descriptor */
@@ -1804,7 +1571,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
1804static int e1000_setup_rx_resources(struct e1000_adapter *adapter, 1571static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
1805 struct e1000_rx_ring *rxdr) 1572 struct e1000_rx_ring *rxdr)
1806{ 1573{
1807 struct e1000_hw *hw = &adapter->hw;
1808 struct pci_dev *pdev = adapter->pdev; 1574 struct pci_dev *pdev = adapter->pdev;
1809 int size, desc_len; 1575 int size, desc_len;
1810 1576
@@ -1817,10 +1583,7 @@ static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
1817 } 1583 }
1818 memset(rxdr->buffer_info, 0, size); 1584 memset(rxdr->buffer_info, 0, size);
1819 1585
1820 if (hw->mac_type <= e1000_82547_rev_2) 1586 desc_len = sizeof(struct e1000_rx_desc);
1821 desc_len = sizeof(struct e1000_rx_desc);
1822 else
1823 desc_len = sizeof(union e1000_rx_desc_packet_split);
1824 1587
1825 /* Round up to nearest 4K */ 1588 /* Round up to nearest 4K */
1826 1589
@@ -1977,7 +1740,7 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
1977{ 1740{
1978 u64 rdba; 1741 u64 rdba;
1979 struct e1000_hw *hw = &adapter->hw; 1742 struct e1000_hw *hw = &adapter->hw;
1980 u32 rdlen, rctl, rxcsum, ctrl_ext; 1743 u32 rdlen, rctl, rxcsum;
1981 1744
1982 if (adapter->netdev->mtu > ETH_DATA_LEN) { 1745 if (adapter->netdev->mtu > ETH_DATA_LEN) {
1983 rdlen = adapter->rx_ring[0].count * 1746 rdlen = adapter->rx_ring[0].count *
@@ -2004,17 +1767,6 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
2004 ew32(ITR, 1000000000 / (adapter->itr * 256)); 1767 ew32(ITR, 1000000000 / (adapter->itr * 256));
2005 } 1768 }
2006 1769
2007 if (hw->mac_type >= e1000_82571) {
2008 ctrl_ext = er32(CTRL_EXT);
2009 /* Reset delay timers after every interrupt */
2010 ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR;
2011 /* Auto-Mask interrupts upon ICR access */
2012 ctrl_ext |= E1000_CTRL_EXT_IAME;
2013 ew32(IAM, 0xffffffff);
2014 ew32(CTRL_EXT, ctrl_ext);
2015 E1000_WRITE_FLUSH();
2016 }
2017
2018 /* Setup the HW Rx Head and Tail Descriptor Pointers and 1770 /* Setup the HW Rx Head and Tail Descriptor Pointers and
2019 * the Base and Length of the Rx Descriptor Ring */ 1771 * the Base and Length of the Rx Descriptor Ring */
2020 switch (adapter->num_rx_queues) { 1772 switch (adapter->num_rx_queues) {
@@ -2329,22 +2081,6 @@ static int e1000_set_mac(struct net_device *netdev, void *p)
2329 2081
2330 e1000_rar_set(hw, hw->mac_addr, 0); 2082 e1000_rar_set(hw, hw->mac_addr, 0);
2331 2083
2332 /* With 82571 controllers, LAA may be overwritten (with the default)
2333 * due to controller reset from the other port. */
2334 if (hw->mac_type == e1000_82571) {
2335 /* activate the work around */
2336 hw->laa_is_present = 1;
2337
2338 /* Hold a copy of the LAA in RAR[14] This is done so that
2339 * between the time RAR[0] gets clobbered and the time it
2340 * gets fixed (in e1000_watchdog), the actual LAA is in one
2341 * of the RARs and no incoming packets directed to this port
2342 * are dropped. Eventaully the LAA will be in RAR[0] and
2343 * RAR[14] */
2344 e1000_rar_set(hw, hw->mac_addr,
2345 E1000_RAR_ENTRIES - 1);
2346 }
2347
2348 if (hw->mac_type == e1000_82542_rev2_0) 2084 if (hw->mac_type == e1000_82542_rev2_0)
2349 e1000_leave_82542_rst(adapter); 2085 e1000_leave_82542_rst(adapter);
2350 2086
@@ -2371,9 +2107,7 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2371 u32 rctl; 2107 u32 rctl;
2372 u32 hash_value; 2108 u32 hash_value;
2373 int i, rar_entries = E1000_RAR_ENTRIES; 2109 int i, rar_entries = E1000_RAR_ENTRIES;
2374 int mta_reg_count = (hw->mac_type == e1000_ich8lan) ? 2110 int mta_reg_count = E1000_NUM_MTA_REGISTERS;
2375 E1000_NUM_MTA_REGISTERS_ICH8LAN :
2376 E1000_NUM_MTA_REGISTERS;
2377 u32 *mcarray = kcalloc(mta_reg_count, sizeof(u32), GFP_ATOMIC); 2111 u32 *mcarray = kcalloc(mta_reg_count, sizeof(u32), GFP_ATOMIC);
2378 2112
2379 if (!mcarray) { 2113 if (!mcarray) {
@@ -2381,13 +2115,6 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2381 return; 2115 return;
2382 } 2116 }
2383 2117
2384 if (hw->mac_type == e1000_ich8lan)
2385 rar_entries = E1000_RAR_ENTRIES_ICH8LAN;
2386
2387 /* reserve RAR[14] for LAA over-write work-around */
2388 if (hw->mac_type == e1000_82571)
2389 rar_entries--;
2390
2391 /* Check for Promiscuous and All Multicast modes */ 2118 /* Check for Promiscuous and All Multicast modes */
2392 2119
2393 rctl = er32(RCTL); 2120 rctl = er32(RCTL);
@@ -2396,15 +2123,13 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2396 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); 2123 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
2397 rctl &= ~E1000_RCTL_VFE; 2124 rctl &= ~E1000_RCTL_VFE;
2398 } else { 2125 } else {
2399 if (netdev->flags & IFF_ALLMULTI) { 2126 if (netdev->flags & IFF_ALLMULTI)
2400 rctl |= E1000_RCTL_MPE; 2127 rctl |= E1000_RCTL_MPE;
2401 } else { 2128 else
2402 rctl &= ~E1000_RCTL_MPE; 2129 rctl &= ~E1000_RCTL_MPE;
2403 } 2130 /* Enable VLAN filter if there is a VLAN */
2404 if (adapter->hw.mac_type != e1000_ich8lan) 2131 if (adapter->vlgrp)
2405 /* Enable VLAN filter if there is a VLAN */ 2132 rctl |= E1000_RCTL_VFE;
2406 if (adapter->vlgrp)
2407 rctl |= E1000_RCTL_VFE;
2408 } 2133 }
2409 2134
2410 if (netdev->uc.count > rar_entries - 1) { 2135 if (netdev->uc.count > rar_entries - 1) {
@@ -2427,7 +2152,6 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2427 * 2152 *
2428 * RAR 0 is used for the station MAC adddress 2153 * RAR 0 is used for the station MAC adddress
2429 * if there are not 14 addresses, go ahead and clear the filters 2154 * if there are not 14 addresses, go ahead and clear the filters
2430 * -- with 82571 controllers only 0-13 entries are filled here
2431 */ 2155 */
2432 i = 1; 2156 i = 1;
2433 if (use_uc) 2157 if (use_uc)
@@ -2521,12 +2245,46 @@ static void e1000_82547_tx_fifo_stall(unsigned long data)
2521 adapter->tx_fifo_head = 0; 2245 adapter->tx_fifo_head = 0;
2522 atomic_set(&adapter->tx_fifo_stall, 0); 2246 atomic_set(&adapter->tx_fifo_stall, 0);
2523 netif_wake_queue(netdev); 2247 netif_wake_queue(netdev);
2524 } else { 2248 } else if (!test_bit(__E1000_DOWN, &adapter->flags)) {
2525 mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1); 2249 mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
2526 } 2250 }
2527 } 2251 }
2528} 2252}
2529 2253
2254static bool e1000_has_link(struct e1000_adapter *adapter)
2255{
2256 struct e1000_hw *hw = &adapter->hw;
2257 bool link_active = false;
2258
2259 /* get_link_status is set on LSC (link status) interrupt or
2260 * rx sequence error interrupt. get_link_status will stay
2261 * false until the e1000_check_for_link establishes link
2262 * for copper adapters ONLY
2263 */
2264 switch (hw->media_type) {
2265 case e1000_media_type_copper:
2266 if (hw->get_link_status) {
2267 e1000_check_for_link(hw);
2268 link_active = !hw->get_link_status;
2269 } else {
2270 link_active = true;
2271 }
2272 break;
2273 case e1000_media_type_fiber:
2274 e1000_check_for_link(hw);
2275 link_active = !!(er32(STATUS) & E1000_STATUS_LU);
2276 break;
2277 case e1000_media_type_internal_serdes:
2278 e1000_check_for_link(hw);
2279 link_active = hw->serdes_has_link;
2280 break;
2281 default:
2282 break;
2283 }
2284
2285 return link_active;
2286}
2287
2530/** 2288/**
2531 * e1000_watchdog - Timer Call-back 2289 * e1000_watchdog - Timer Call-back
2532 * @data: pointer to adapter cast into an unsigned long 2290 * @data: pointer to adapter cast into an unsigned long
@@ -2538,33 +2296,16 @@ static void e1000_watchdog(unsigned long data)
2538 struct net_device *netdev = adapter->netdev; 2296 struct net_device *netdev = adapter->netdev;
2539 struct e1000_tx_ring *txdr = adapter->tx_ring; 2297 struct e1000_tx_ring *txdr = adapter->tx_ring;
2540 u32 link, tctl; 2298 u32 link, tctl;
2541 s32 ret_val;
2542
2543 ret_val = e1000_check_for_link(hw);
2544 if ((ret_val == E1000_ERR_PHY) &&
2545 (hw->phy_type == e1000_phy_igp_3) &&
2546 (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
2547 /* See e1000_kumeran_lock_loss_workaround() */
2548 DPRINTK(LINK, INFO,
2549 "Gigabit has been disabled, downgrading speed\n");
2550 }
2551 2299
2552 if (hw->mac_type == e1000_82573) { 2300 link = e1000_has_link(adapter);
2553 e1000_enable_tx_pkt_filtering(hw); 2301 if ((netif_carrier_ok(netdev)) && link)
2554 if (adapter->mng_vlan_id != hw->mng_cookie.vlan_id) 2302 goto link_up;
2555 e1000_update_mng_vlan(adapter);
2556 }
2557
2558 if ((hw->media_type == e1000_media_type_internal_serdes) &&
2559 !(er32(TXCW) & E1000_TXCW_ANE))
2560 link = !hw->serdes_link_down;
2561 else
2562 link = er32(STATUS) & E1000_STATUS_LU;
2563 2303
2564 if (link) { 2304 if (link) {
2565 if (!netif_carrier_ok(netdev)) { 2305 if (!netif_carrier_ok(netdev)) {
2566 u32 ctrl; 2306 u32 ctrl;
2567 bool txb2b = true; 2307 bool txb2b = true;
2308 /* update snapshot of PHY registers on LSC */
2568 e1000_get_speed_and_duplex(hw, 2309 e1000_get_speed_and_duplex(hw,
2569 &adapter->link_speed, 2310 &adapter->link_speed,
2570 &adapter->link_duplex); 2311 &adapter->link_duplex);
@@ -2589,7 +2330,7 @@ static void e1000_watchdog(unsigned long data)
2589 case SPEED_10: 2330 case SPEED_10:
2590 txb2b = false; 2331 txb2b = false;
2591 netdev->tx_queue_len = 10; 2332 netdev->tx_queue_len = 10;
2592 adapter->tx_timeout_factor = 8; 2333 adapter->tx_timeout_factor = 16;
2593 break; 2334 break;
2594 case SPEED_100: 2335 case SPEED_100:
2595 txb2b = false; 2336 txb2b = false;
@@ -2598,52 +2339,16 @@ static void e1000_watchdog(unsigned long data)
2598 break; 2339 break;
2599 } 2340 }
2600 2341
2601 if ((hw->mac_type == e1000_82571 || 2342 /* enable transmits in the hardware */
2602 hw->mac_type == e1000_82572) &&
2603 !txb2b) {
2604 u32 tarc0;
2605 tarc0 = er32(TARC0);
2606 tarc0 &= ~(1 << 21);
2607 ew32(TARC0, tarc0);
2608 }
2609
2610 /* disable TSO for pcie and 10/100 speeds, to avoid
2611 * some hardware issues */
2612 if (!adapter->tso_force &&
2613 hw->bus_type == e1000_bus_type_pci_express){
2614 switch (adapter->link_speed) {
2615 case SPEED_10:
2616 case SPEED_100:
2617 DPRINTK(PROBE,INFO,
2618 "10/100 speed: disabling TSO\n");
2619 netdev->features &= ~NETIF_F_TSO;
2620 netdev->features &= ~NETIF_F_TSO6;
2621 break;
2622 case SPEED_1000:
2623 netdev->features |= NETIF_F_TSO;
2624 netdev->features |= NETIF_F_TSO6;
2625 break;
2626 default:
2627 /* oops */
2628 break;
2629 }
2630 }
2631
2632 /* enable transmits in the hardware, need to do this
2633 * after setting TARC0 */
2634 tctl = er32(TCTL); 2343 tctl = er32(TCTL);
2635 tctl |= E1000_TCTL_EN; 2344 tctl |= E1000_TCTL_EN;
2636 ew32(TCTL, tctl); 2345 ew32(TCTL, tctl);
2637 2346
2638 netif_carrier_on(netdev); 2347 netif_carrier_on(netdev);
2639 mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ)); 2348 if (!test_bit(__E1000_DOWN, &adapter->flags))
2349 mod_timer(&adapter->phy_info_timer,
2350 round_jiffies(jiffies + 2 * HZ));
2640 adapter->smartspeed = 0; 2351 adapter->smartspeed = 0;
2641 } else {
2642 /* make sure the receive unit is started */
2643 if (hw->rx_needs_kicking) {
2644 u32 rctl = er32(RCTL);
2645 ew32(RCTL, rctl | E1000_RCTL_EN);
2646 }
2647 } 2352 }
2648 } else { 2353 } else {
2649 if (netif_carrier_ok(netdev)) { 2354 if (netif_carrier_ok(netdev)) {
@@ -2652,21 +2357,16 @@ static void e1000_watchdog(unsigned long data)
2652 printk(KERN_INFO "e1000: %s NIC Link is Down\n", 2357 printk(KERN_INFO "e1000: %s NIC Link is Down\n",
2653 netdev->name); 2358 netdev->name);
2654 netif_carrier_off(netdev); 2359 netif_carrier_off(netdev);
2655 mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ)); 2360
2656 2361 if (!test_bit(__E1000_DOWN, &adapter->flags))
2657 /* 80003ES2LAN workaround-- 2362 mod_timer(&adapter->phy_info_timer,
2658 * For packet buffer work-around on link down event; 2363 round_jiffies(jiffies + 2 * HZ));
2659 * disable receives in the ISR and
2660 * reset device here in the watchdog
2661 */
2662 if (hw->mac_type == e1000_80003es2lan)
2663 /* reset device */
2664 schedule_work(&adapter->reset_task);
2665 } 2364 }
2666 2365
2667 e1000_smartspeed(adapter); 2366 e1000_smartspeed(adapter);
2668 } 2367 }
2669 2368
2369link_up:
2670 e1000_update_stats(adapter); 2370 e1000_update_stats(adapter);
2671 2371
2672 hw->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old; 2372 hw->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
@@ -2700,13 +2400,10 @@ static void e1000_watchdog(unsigned long data)
2700 /* Force detection of hung controller every watchdog period */ 2400 /* Force detection of hung controller every watchdog period */
2701 adapter->detect_tx_hung = true; 2401 adapter->detect_tx_hung = true;
2702 2402
2703 /* With 82571 controllers, LAA may be overwritten due to controller
2704 * reset from the other port. Set the appropriate LAA in RAR[0] */
2705 if (hw->mac_type == e1000_82571 && hw->laa_is_present)
2706 e1000_rar_set(hw, hw->mac_addr, 0);
2707
2708 /* Reset the timer */ 2403 /* Reset the timer */
2709 mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ)); 2404 if (!test_bit(__E1000_DOWN, &adapter->flags))
2405 mod_timer(&adapter->watchdog_timer,
2406 round_jiffies(jiffies + 2 * HZ));
2710} 2407}
2711 2408
2712enum latency_range { 2409enum latency_range {
@@ -2718,6 +2415,11 @@ enum latency_range {
2718 2415
2719/** 2416/**
2720 * e1000_update_itr - update the dynamic ITR value based on statistics 2417 * e1000_update_itr - update the dynamic ITR value based on statistics
2418 * @adapter: pointer to adapter
2419 * @itr_setting: current adapter->itr
2420 * @packets: the number of packets during this measurement interval
2421 * @bytes: the number of bytes during this measurement interval
2422 *
2721 * Stores a new ITR value based on packets and byte 2423 * Stores a new ITR value based on packets and byte
2722 * counts during the last interrupt. The advantage of per interrupt 2424 * counts during the last interrupt. The advantage of per interrupt
2723 * computation is faster updates and more accurate ITR for the current 2425 * computation is faster updates and more accurate ITR for the current
@@ -2727,10 +2429,6 @@ enum latency_range {
2727 * while increasing bulk throughput. 2429 * while increasing bulk throughput.
2728 * this functionality is controlled by the InterruptThrottleRate module 2430 * this functionality is controlled by the InterruptThrottleRate module
2729 * parameter (see e1000_param.c) 2431 * parameter (see e1000_param.c)
2730 * @adapter: pointer to adapter
2731 * @itr_setting: current adapter->itr
2732 * @packets: the number of packets during this measurement interval
2733 * @bytes: the number of bytes during this measurement interval
2734 **/ 2432 **/
2735static unsigned int e1000_update_itr(struct e1000_adapter *adapter, 2433static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
2736 u16 itr_setting, int packets, int bytes) 2434 u16 itr_setting, int packets, int bytes)
@@ -3035,8 +2733,9 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
3035 size -= 4; 2733 size -= 4;
3036 2734
3037 buffer_info->length = size; 2735 buffer_info->length = size;
3038 buffer_info->dma = skb_shinfo(skb)->dma_head + offset; 2736 /* set time_stamp *before* dma to help avoid a possible race */
3039 buffer_info->time_stamp = jiffies; 2737 buffer_info->time_stamp = jiffies;
2738 buffer_info->dma = skb_shinfo(skb)->dma_head + offset;
3040 buffer_info->next_to_watch = i; 2739 buffer_info->next_to_watch = i;
3041 2740
3042 len -= size; 2741 len -= size;
@@ -3071,13 +2770,14 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
3071 * Avoid terminating buffers within evenly-aligned 2770 * Avoid terminating buffers within evenly-aligned
3072 * dwords. */ 2771 * dwords. */
3073 if (unlikely(adapter->pcix_82544 && 2772 if (unlikely(adapter->pcix_82544 &&
3074 !((unsigned long)(frag->page+offset+size-1) & 4) && 2773 !((unsigned long)(page_to_phys(frag->page) + offset
3075 size > 4)) 2774 + size - 1) & 4) &&
2775 size > 4))
3076 size -= 4; 2776 size -= 4;
3077 2777
3078 buffer_info->length = size; 2778 buffer_info->length = size;
3079 buffer_info->dma = map[f] + offset;
3080 buffer_info->time_stamp = jiffies; 2779 buffer_info->time_stamp = jiffies;
2780 buffer_info->dma = map[f] + offset;
3081 buffer_info->next_to_watch = i; 2781 buffer_info->next_to_watch = i;
3082 2782
3083 len -= size; 2783 len -= size;
@@ -3186,41 +2886,6 @@ no_fifo_stall_required:
3186 return 0; 2886 return 0;
3187} 2887}
3188 2888
3189#define MINIMUM_DHCP_PACKET_SIZE 282
3190static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
3191 struct sk_buff *skb)
3192{
3193 struct e1000_hw *hw = &adapter->hw;
3194 u16 length, offset;
3195 if (vlan_tx_tag_present(skb)) {
3196 if (!((vlan_tx_tag_get(skb) == hw->mng_cookie.vlan_id) &&
3197 ( hw->mng_cookie.status &
3198 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
3199 return 0;
3200 }
3201 if (skb->len > MINIMUM_DHCP_PACKET_SIZE) {
3202 struct ethhdr *eth = (struct ethhdr *)skb->data;
3203 if ((htons(ETH_P_IP) == eth->h_proto)) {
3204 const struct iphdr *ip =
3205 (struct iphdr *)((u8 *)skb->data+14);
3206 if (IPPROTO_UDP == ip->protocol) {
3207 struct udphdr *udp =
3208 (struct udphdr *)((u8 *)ip +
3209 (ip->ihl << 2));
3210 if (ntohs(udp->dest) == 67) {
3211 offset = (u8 *)udp + 8 - skb->data;
3212 length = skb->len - offset;
3213
3214 return e1000_mng_write_dhcp_info(hw,
3215 (u8 *)udp + 8,
3216 length);
3217 }
3218 }
3219 }
3220 }
3221 return 0;
3222}
3223
3224static int __e1000_maybe_stop_tx(struct net_device *netdev, int size) 2889static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
3225{ 2890{
3226 struct e1000_adapter *adapter = netdev_priv(netdev); 2891 struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -3279,11 +2944,6 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
3279 return NETDEV_TX_OK; 2944 return NETDEV_TX_OK;
3280 } 2945 }
3281 2946
3282 /* 82571 and newer doesn't need the workaround that limited descriptor
3283 * length to 4kB */
3284 if (hw->mac_type >= e1000_82571)
3285 max_per_txd = 8192;
3286
3287 mss = skb_shinfo(skb)->gso_size; 2947 mss = skb_shinfo(skb)->gso_size;
3288 /* The controller does a simple calculation to 2948 /* The controller does a simple calculation to
3289 * make sure there is enough room in the FIFO before 2949 * make sure there is enough room in the FIFO before
@@ -3296,9 +2956,6 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
3296 max_per_txd = min(mss << 2, max_per_txd); 2956 max_per_txd = min(mss << 2, max_per_txd);
3297 max_txd_pwr = fls(max_per_txd) - 1; 2957 max_txd_pwr = fls(max_per_txd) - 1;
3298 2958
3299 /* TSO Workaround for 82571/2/3 Controllers -- if skb->data
3300 * points to just header, pull a few bytes of payload from
3301 * frags into skb->data */
3302 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 2959 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
3303 if (skb->data_len && hdr_len == len) { 2960 if (skb->data_len && hdr_len == len) {
3304 switch (hw->mac_type) { 2961 switch (hw->mac_type) {
@@ -3313,10 +2970,6 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
3313 if ((unsigned long)(skb_tail_pointer(skb) - 1) & 4) 2970 if ((unsigned long)(skb_tail_pointer(skb) - 1) & 4)
3314 break; 2971 break;
3315 /* fall through */ 2972 /* fall through */
3316 case e1000_82571:
3317 case e1000_82572:
3318 case e1000_82573:
3319 case e1000_ich8lan:
3320 pull_size = min((unsigned int)4, skb->data_len); 2973 pull_size = min((unsigned int)4, skb->data_len);
3321 if (!__pskb_pull_tail(skb, pull_size)) { 2974 if (!__pskb_pull_tail(skb, pull_size)) {
3322 DPRINTK(DRV, ERR, 2975 DPRINTK(DRV, ERR,
@@ -3361,11 +3014,6 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
3361 if (adapter->pcix_82544) 3014 if (adapter->pcix_82544)
3362 count += nr_frags; 3015 count += nr_frags;
3363 3016
3364
3365 if (hw->tx_pkt_filtering &&
3366 (hw->mac_type == e1000_82573))
3367 e1000_transfer_dhcp_info(adapter, skb);
3368
3369 /* need: count + 2 desc gap to keep tail from touching 3017 /* need: count + 2 desc gap to keep tail from touching
3370 * head, otherwise try next time */ 3018 * head, otherwise try next time */
3371 if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2))) 3019 if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2)))
@@ -3374,7 +3022,9 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
3374 if (unlikely(hw->mac_type == e1000_82547)) { 3022 if (unlikely(hw->mac_type == e1000_82547)) {
3375 if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) { 3023 if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) {
3376 netif_stop_queue(netdev); 3024 netif_stop_queue(netdev);
3377 mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1); 3025 if (!test_bit(__E1000_DOWN, &adapter->flags))
3026 mod_timer(&adapter->tx_fifo_stall_timer,
3027 jiffies + 1);
3378 return NETDEV_TX_BUSY; 3028 return NETDEV_TX_BUSY;
3379 } 3029 }
3380 } 3030 }
@@ -3393,14 +3043,12 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
3393 } 3043 }
3394 3044
3395 if (likely(tso)) { 3045 if (likely(tso)) {
3396 tx_ring->last_tx_tso = 1; 3046 if (likely(hw->mac_type != e1000_82544))
3047 tx_ring->last_tx_tso = 1;
3397 tx_flags |= E1000_TX_FLAGS_TSO; 3048 tx_flags |= E1000_TX_FLAGS_TSO;
3398 } else if (likely(e1000_tx_csum(adapter, tx_ring, skb))) 3049 } else if (likely(e1000_tx_csum(adapter, tx_ring, skb)))
3399 tx_flags |= E1000_TX_FLAGS_CSUM; 3050 tx_flags |= E1000_TX_FLAGS_CSUM;
3400 3051
3401 /* Old method was to assume IPv4 packet by default if TSO was enabled.
3402 * 82571 hardware supports TSO capabilities for IPv6 as well...
3403 * no longer assume, we must. */
3404 if (likely(skb->protocol == htons(ETH_P_IP))) 3052 if (likely(skb->protocol == htons(ETH_P_IP)))
3405 tx_flags |= E1000_TX_FLAGS_IPV4; 3053 tx_flags |= E1000_TX_FLAGS_IPV4;
3406 3054
@@ -3472,7 +3120,6 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3472 struct e1000_adapter *adapter = netdev_priv(netdev); 3120 struct e1000_adapter *adapter = netdev_priv(netdev);
3473 struct e1000_hw *hw = &adapter->hw; 3121 struct e1000_hw *hw = &adapter->hw;
3474 int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; 3122 int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
3475 u16 eeprom_data = 0;
3476 3123
3477 if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) || 3124 if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
3478 (max_frame > MAX_JUMBO_FRAME_SIZE)) { 3125 (max_frame > MAX_JUMBO_FRAME_SIZE)) {
@@ -3483,44 +3130,23 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3483 /* Adapter-specific max frame size limits. */ 3130 /* Adapter-specific max frame size limits. */
3484 switch (hw->mac_type) { 3131 switch (hw->mac_type) {
3485 case e1000_undefined ... e1000_82542_rev2_1: 3132 case e1000_undefined ... e1000_82542_rev2_1:
3486 case e1000_ich8lan:
3487 if (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)) { 3133 if (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)) {
3488 DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n"); 3134 DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n");
3489 return -EINVAL; 3135 return -EINVAL;
3490 } 3136 }
3491 break; 3137 break;
3492 case e1000_82573:
3493 /* Jumbo Frames not supported if:
3494 * - this is not an 82573L device
3495 * - ASPM is enabled in any way (0x1A bits 3:2) */
3496 e1000_read_eeprom(hw, EEPROM_INIT_3GIO_3, 1,
3497 &eeprom_data);
3498 if ((hw->device_id != E1000_DEV_ID_82573L) ||
3499 (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) {
3500 if (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)) {
3501 DPRINTK(PROBE, ERR,
3502 "Jumbo Frames not supported.\n");
3503 return -EINVAL;
3504 }
3505 break;
3506 }
3507 /* ERT will be enabled later to enable wire speed receives */
3508
3509 /* fall through to get support */
3510 case e1000_82571:
3511 case e1000_82572:
3512 case e1000_80003es2lan:
3513#define MAX_STD_JUMBO_FRAME_SIZE 9234
3514 if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
3515 DPRINTK(PROBE, ERR, "MTU > 9216 not supported.\n");
3516 return -EINVAL;
3517 }
3518 break;
3519 default: 3138 default:
3520 /* Capable of supporting up to MAX_JUMBO_FRAME_SIZE limit. */ 3139 /* Capable of supporting up to MAX_JUMBO_FRAME_SIZE limit. */
3521 break; 3140 break;
3522 } 3141 }
3523 3142
3143 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
3144 msleep(1);
3145 /* e1000_down has a dependency on max_frame_size */
3146 hw->max_frame_size = max_frame;
3147 if (netif_running(netdev))
3148 e1000_down(adapter);
3149
3524 /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN 3150 /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
3525 * means we reserve 2 more, this pushes us to allocate from the next 3151 * means we reserve 2 more, this pushes us to allocate from the next
3526 * larger slab size. 3152 * larger slab size.
@@ -3549,11 +3175,16 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3549 (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE))) 3175 (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE)))
3550 adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE; 3176 adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
3551 3177
3178 printk(KERN_INFO "e1000: %s changing MTU from %d to %d\n",
3179 netdev->name, netdev->mtu, new_mtu);
3552 netdev->mtu = new_mtu; 3180 netdev->mtu = new_mtu;
3553 hw->max_frame_size = max_frame;
3554 3181
3555 if (netif_running(netdev)) 3182 if (netif_running(netdev))
3556 e1000_reinit_locked(adapter); 3183 e1000_up(adapter);
3184 else
3185 e1000_reset(adapter);
3186
3187 clear_bit(__E1000_RESETTING, &adapter->flags);
3557 3188
3558 return 0; 3189 return 0;
3559} 3190}
@@ -3596,14 +3227,12 @@ void e1000_update_stats(struct e1000_adapter *adapter)
3596 adapter->stats.mprc += er32(MPRC); 3227 adapter->stats.mprc += er32(MPRC);
3597 adapter->stats.roc += er32(ROC); 3228 adapter->stats.roc += er32(ROC);
3598 3229
3599 if (hw->mac_type != e1000_ich8lan) { 3230 adapter->stats.prc64 += er32(PRC64);
3600 adapter->stats.prc64 += er32(PRC64); 3231 adapter->stats.prc127 += er32(PRC127);
3601 adapter->stats.prc127 += er32(PRC127); 3232 adapter->stats.prc255 += er32(PRC255);
3602 adapter->stats.prc255 += er32(PRC255); 3233 adapter->stats.prc511 += er32(PRC511);
3603 adapter->stats.prc511 += er32(PRC511); 3234 adapter->stats.prc1023 += er32(PRC1023);
3604 adapter->stats.prc1023 += er32(PRC1023); 3235 adapter->stats.prc1522 += er32(PRC1522);
3605 adapter->stats.prc1522 += er32(PRC1522);
3606 }
3607 3236
3608 adapter->stats.symerrs += er32(SYMERRS); 3237 adapter->stats.symerrs += er32(SYMERRS);
3609 adapter->stats.mpc += er32(MPC); 3238 adapter->stats.mpc += er32(MPC);
@@ -3632,14 +3261,12 @@ void e1000_update_stats(struct e1000_adapter *adapter)
3632 adapter->stats.toth += er32(TOTH); 3261 adapter->stats.toth += er32(TOTH);
3633 adapter->stats.tpr += er32(TPR); 3262 adapter->stats.tpr += er32(TPR);
3634 3263
3635 if (hw->mac_type != e1000_ich8lan) { 3264 adapter->stats.ptc64 += er32(PTC64);
3636 adapter->stats.ptc64 += er32(PTC64); 3265 adapter->stats.ptc127 += er32(PTC127);
3637 adapter->stats.ptc127 += er32(PTC127); 3266 adapter->stats.ptc255 += er32(PTC255);
3638 adapter->stats.ptc255 += er32(PTC255); 3267 adapter->stats.ptc511 += er32(PTC511);
3639 adapter->stats.ptc511 += er32(PTC511); 3268 adapter->stats.ptc1023 += er32(PTC1023);
3640 adapter->stats.ptc1023 += er32(PTC1023); 3269 adapter->stats.ptc1522 += er32(PTC1522);
3641 adapter->stats.ptc1522 += er32(PTC1522);
3642 }
3643 3270
3644 adapter->stats.mptc += er32(MPTC); 3271 adapter->stats.mptc += er32(MPTC);
3645 adapter->stats.bptc += er32(BPTC); 3272 adapter->stats.bptc += er32(BPTC);
@@ -3659,20 +3286,6 @@ void e1000_update_stats(struct e1000_adapter *adapter)
3659 adapter->stats.tsctc += er32(TSCTC); 3286 adapter->stats.tsctc += er32(TSCTC);
3660 adapter->stats.tsctfc += er32(TSCTFC); 3287 adapter->stats.tsctfc += er32(TSCTFC);
3661 } 3288 }
3662 if (hw->mac_type > e1000_82547_rev_2) {
3663 adapter->stats.iac += er32(IAC);
3664 adapter->stats.icrxoc += er32(ICRXOC);
3665
3666 if (hw->mac_type != e1000_ich8lan) {
3667 adapter->stats.icrxptc += er32(ICRXPTC);
3668 adapter->stats.icrxatc += er32(ICRXATC);
3669 adapter->stats.ictxptc += er32(ICTXPTC);
3670 adapter->stats.ictxatc += er32(ICTXATC);
3671 adapter->stats.ictxqec += er32(ICTXQEC);
3672 adapter->stats.ictxqmtc += er32(ICTXQMTC);
3673 adapter->stats.icrxdmtc += er32(ICRXDMTC);
3674 }
3675 }
3676 3289
3677 /* Fill out the OS statistics structure */ 3290 /* Fill out the OS statistics structure */
3678 adapter->net_stats.multicast = adapter->stats.mprc; 3291 adapter->net_stats.multicast = adapter->stats.mprc;
@@ -3731,49 +3344,6 @@ void e1000_update_stats(struct e1000_adapter *adapter)
3731} 3344}
3732 3345
3733/** 3346/**
3734 * e1000_intr_msi - Interrupt Handler
3735 * @irq: interrupt number
3736 * @data: pointer to a network interface device structure
3737 **/
3738
3739static irqreturn_t e1000_intr_msi(int irq, void *data)
3740{
3741 struct net_device *netdev = data;
3742 struct e1000_adapter *adapter = netdev_priv(netdev);
3743 struct e1000_hw *hw = &adapter->hw;
3744 u32 icr = er32(ICR);
3745
3746 /* in NAPI mode read ICR disables interrupts using IAM */
3747
3748 if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
3749 hw->get_link_status = 1;
3750 /* 80003ES2LAN workaround-- For packet buffer work-around on
3751 * link down event; disable receives here in the ISR and reset
3752 * adapter in watchdog */
3753 if (netif_carrier_ok(netdev) &&
3754 (hw->mac_type == e1000_80003es2lan)) {
3755 /* disable receives */
3756 u32 rctl = er32(RCTL);
3757 ew32(RCTL, rctl & ~E1000_RCTL_EN);
3758 }
3759 /* guard against interrupt when we're going down */
3760 if (!test_bit(__E1000_DOWN, &adapter->flags))
3761 mod_timer(&adapter->watchdog_timer, jiffies + 1);
3762 }
3763
3764 if (likely(napi_schedule_prep(&adapter->napi))) {
3765 adapter->total_tx_bytes = 0;
3766 adapter->total_tx_packets = 0;
3767 adapter->total_rx_bytes = 0;
3768 adapter->total_rx_packets = 0;
3769 __napi_schedule(&adapter->napi);
3770 } else
3771 e1000_irq_enable(adapter);
3772
3773 return IRQ_HANDLED;
3774}
3775
3776/**
3777 * e1000_intr - Interrupt Handler 3347 * e1000_intr - Interrupt Handler
3778 * @irq: interrupt number 3348 * @irq: interrupt number
3779 * @data: pointer to a network interface device structure 3349 * @data: pointer to a network interface device structure
@@ -3784,43 +3354,22 @@ static irqreturn_t e1000_intr(int irq, void *data)
3784 struct net_device *netdev = data; 3354 struct net_device *netdev = data;
3785 struct e1000_adapter *adapter = netdev_priv(netdev); 3355 struct e1000_adapter *adapter = netdev_priv(netdev);
3786 struct e1000_hw *hw = &adapter->hw; 3356 struct e1000_hw *hw = &adapter->hw;
3787 u32 rctl, icr = er32(ICR); 3357 u32 icr = er32(ICR);
3788 3358
3789 if (unlikely((!icr) || test_bit(__E1000_DOWN, &adapter->flags))) 3359 if (unlikely((!icr) || test_bit(__E1000_DOWN, &adapter->flags)))
3790 return IRQ_NONE; /* Not our interrupt */ 3360 return IRQ_NONE; /* Not our interrupt */
3791 3361
3792 /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
3793 * not set, then the adapter didn't send an interrupt */
3794 if (unlikely(hw->mac_type >= e1000_82571 &&
3795 !(icr & E1000_ICR_INT_ASSERTED)))
3796 return IRQ_NONE;
3797
3798 /* Interrupt Auto-Mask...upon reading ICR, interrupts are masked. No
3799 * need for the IMC write */
3800
3801 if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) { 3362 if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
3802 hw->get_link_status = 1; 3363 hw->get_link_status = 1;
3803 /* 80003ES2LAN workaround--
3804 * For packet buffer work-around on link down event;
3805 * disable receives here in the ISR and
3806 * reset adapter in watchdog
3807 */
3808 if (netif_carrier_ok(netdev) &&
3809 (hw->mac_type == e1000_80003es2lan)) {
3810 /* disable receives */
3811 rctl = er32(RCTL);
3812 ew32(RCTL, rctl & ~E1000_RCTL_EN);
3813 }
3814 /* guard against interrupt when we're going down */ 3364 /* guard against interrupt when we're going down */
3815 if (!test_bit(__E1000_DOWN, &adapter->flags)) 3365 if (!test_bit(__E1000_DOWN, &adapter->flags))
3816 mod_timer(&adapter->watchdog_timer, jiffies + 1); 3366 mod_timer(&adapter->watchdog_timer, jiffies + 1);
3817 } 3367 }
3818 3368
3819 if (unlikely(hw->mac_type < e1000_82571)) { 3369 /* disable interrupts, without the synchronize_irq bit */
3820 /* disable interrupts, without the synchronize_irq bit */ 3370 ew32(IMC, ~0);
3821 ew32(IMC, ~0); 3371 E1000_WRITE_FLUSH();
3822 E1000_WRITE_FLUSH(); 3372
3823 }
3824 if (likely(napi_schedule_prep(&adapter->napi))) { 3373 if (likely(napi_schedule_prep(&adapter->napi))) {
3825 adapter->total_tx_bytes = 0; 3374 adapter->total_tx_bytes = 0;
3826 adapter->total_tx_packets = 0; 3375 adapter->total_tx_packets = 0;
@@ -3844,17 +3393,13 @@ static irqreturn_t e1000_intr(int irq, void *data)
3844static int e1000_clean(struct napi_struct *napi, int budget) 3393static int e1000_clean(struct napi_struct *napi, int budget)
3845{ 3394{
3846 struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi); 3395 struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
3847 struct net_device *poll_dev = adapter->netdev; 3396 int tx_clean_complete = 0, work_done = 0;
3848 int tx_cleaned = 0, work_done = 0;
3849
3850 adapter = netdev_priv(poll_dev);
3851 3397
3852 tx_cleaned = e1000_clean_tx_irq(adapter, &adapter->tx_ring[0]); 3398 tx_clean_complete = e1000_clean_tx_irq(adapter, &adapter->tx_ring[0]);
3853 3399
3854 adapter->clean_rx(adapter, &adapter->rx_ring[0], 3400 adapter->clean_rx(adapter, &adapter->rx_ring[0], &work_done, budget);
3855 &work_done, budget);
3856 3401
3857 if (!tx_cleaned) 3402 if (!tx_clean_complete)
3858 work_done = budget; 3403 work_done = budget;
3859 3404
3860 /* If budget not fully consumed, exit the polling mode */ 3405 /* If budget not fully consumed, exit the polling mode */
@@ -3925,7 +3470,9 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
3925 * sees the new next_to_clean. 3470 * sees the new next_to_clean.
3926 */ 3471 */
3927 smp_mb(); 3472 smp_mb();
3928 if (netif_queue_stopped(netdev)) { 3473
3474 if (netif_queue_stopped(netdev) &&
3475 !(test_bit(__E1000_DOWN, &adapter->flags))) {
3929 netif_wake_queue(netdev); 3476 netif_wake_queue(netdev);
3930 ++adapter->restart_queue; 3477 ++adapter->restart_queue;
3931 } 3478 }
@@ -3935,8 +3482,8 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
3935 /* Detect a transmit hang in hardware, this serializes the 3482 /* Detect a transmit hang in hardware, this serializes the
3936 * check with the clearing of time_stamp and movement of i */ 3483 * check with the clearing of time_stamp and movement of i */
3937 adapter->detect_tx_hung = false; 3484 adapter->detect_tx_hung = false;
3938 if (tx_ring->buffer_info[i].time_stamp && 3485 if (tx_ring->buffer_info[eop].time_stamp &&
3939 time_after(jiffies, tx_ring->buffer_info[i].time_stamp + 3486 time_after(jiffies, tx_ring->buffer_info[eop].time_stamp +
3940 (adapter->tx_timeout_factor * HZ)) 3487 (adapter->tx_timeout_factor * HZ))
3941 && !(er32(STATUS) & E1000_STATUS_TXOFF)) { 3488 && !(er32(STATUS) & E1000_STATUS_TXOFF)) {
3942 3489
@@ -3958,7 +3505,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
3958 readl(hw->hw_addr + tx_ring->tdt), 3505 readl(hw->hw_addr + tx_ring->tdt),
3959 tx_ring->next_to_use, 3506 tx_ring->next_to_use,
3960 tx_ring->next_to_clean, 3507 tx_ring->next_to_clean,
3961 tx_ring->buffer_info[i].time_stamp, 3508 tx_ring->buffer_info[eop].time_stamp,
3962 eop, 3509 eop,
3963 jiffies, 3510 jiffies,
3964 eop_desc->upper.fields.status); 3511 eop_desc->upper.fields.status);
@@ -3999,25 +3546,13 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
3999 return; 3546 return;
4000 } 3547 }
4001 /* TCP/UDP Checksum has not been calculated */ 3548 /* TCP/UDP Checksum has not been calculated */
4002 if (hw->mac_type <= e1000_82547_rev_2) { 3549 if (!(status & E1000_RXD_STAT_TCPCS))
4003 if (!(status & E1000_RXD_STAT_TCPCS)) 3550 return;
4004 return; 3551
4005 } else {
4006 if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
4007 return;
4008 }
4009 /* It must be a TCP or UDP packet with a valid checksum */ 3552 /* It must be a TCP or UDP packet with a valid checksum */
4010 if (likely(status & E1000_RXD_STAT_TCPCS)) { 3553 if (likely(status & E1000_RXD_STAT_TCPCS)) {
4011 /* TCP checksum is good */ 3554 /* TCP checksum is good */
4012 skb->ip_summed = CHECKSUM_UNNECESSARY; 3555 skb->ip_summed = CHECKSUM_UNNECESSARY;
4013 } else if (hw->mac_type > e1000_82547_rev_2) {
4014 /* IP fragment with UDP payload */
4015 /* Hardware complements the payload checksum, so we undo it
4016 * and then put the value in host order for further stack use.
4017 */
4018 __sum16 sum = (__force __sum16)htons(csum);
4019 skb->csum = csum_unfold(~sum);
4020 skb->ip_summed = CHECKSUM_COMPLETE;
4021 } 3556 }
4022 adapter->hw_csum_good++; 3557 adapter->hw_csum_good++;
4023} 3558}
@@ -4814,20 +4349,6 @@ void e1000_pcix_set_mmrbc(struct e1000_hw *hw, int mmrbc)
4814 pcix_set_mmrbc(adapter->pdev, mmrbc); 4349 pcix_set_mmrbc(adapter->pdev, mmrbc);
4815} 4350}
4816 4351
4817s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
4818{
4819 struct e1000_adapter *adapter = hw->back;
4820 u16 cap_offset;
4821
4822 cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
4823 if (!cap_offset)
4824 return -E1000_ERR_CONFIG;
4825
4826 pci_read_config_word(adapter->pdev, cap_offset + reg, value);
4827
4828 return E1000_SUCCESS;
4829}
4830
4831void e1000_io_write(struct e1000_hw *hw, unsigned long port, u32 value) 4352void e1000_io_write(struct e1000_hw *hw, unsigned long port, u32 value)
4832{ 4353{
4833 outl(value, port); 4354 outl(value, port);
@@ -4850,33 +4371,27 @@ static void e1000_vlan_rx_register(struct net_device *netdev,
4850 ctrl |= E1000_CTRL_VME; 4371 ctrl |= E1000_CTRL_VME;
4851 ew32(CTRL, ctrl); 4372 ew32(CTRL, ctrl);
4852 4373
4853 if (adapter->hw.mac_type != e1000_ich8lan) { 4374 /* enable VLAN receive filtering */
4854 /* enable VLAN receive filtering */ 4375 rctl = er32(RCTL);
4855 rctl = er32(RCTL); 4376 rctl &= ~E1000_RCTL_CFIEN;
4856 rctl &= ~E1000_RCTL_CFIEN; 4377 if (!(netdev->flags & IFF_PROMISC))
4857 if (!(netdev->flags & IFF_PROMISC)) 4378 rctl |= E1000_RCTL_VFE;
4858 rctl |= E1000_RCTL_VFE; 4379 ew32(RCTL, rctl);
4859 ew32(RCTL, rctl); 4380 e1000_update_mng_vlan(adapter);
4860 e1000_update_mng_vlan(adapter);
4861 }
4862 } else { 4381 } else {
4863 /* disable VLAN tag insert/strip */ 4382 /* disable VLAN tag insert/strip */
4864 ctrl = er32(CTRL); 4383 ctrl = er32(CTRL);
4865 ctrl &= ~E1000_CTRL_VME; 4384 ctrl &= ~E1000_CTRL_VME;
4866 ew32(CTRL, ctrl); 4385 ew32(CTRL, ctrl);
4867 4386
4868 if (adapter->hw.mac_type != e1000_ich8lan) { 4387 /* disable VLAN receive filtering */
4869 /* disable VLAN receive filtering */ 4388 rctl = er32(RCTL);
4870 rctl = er32(RCTL); 4389 rctl &= ~E1000_RCTL_VFE;
4871 rctl &= ~E1000_RCTL_VFE; 4390 ew32(RCTL, rctl);
4872 ew32(RCTL, rctl);
4873 4391
4874 if (adapter->mng_vlan_id != 4392 if (adapter->mng_vlan_id != (u16)E1000_MNG_VLAN_NONE) {
4875 (u16)E1000_MNG_VLAN_NONE) { 4393 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
4876 e1000_vlan_rx_kill_vid(netdev, 4394 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
4877 adapter->mng_vlan_id);
4878 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
4879 }
4880 } 4395 }
4881 } 4396 }
4882 4397
@@ -4913,14 +4428,6 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
4913 if (!test_bit(__E1000_DOWN, &adapter->flags)) 4428 if (!test_bit(__E1000_DOWN, &adapter->flags))
4914 e1000_irq_enable(adapter); 4429 e1000_irq_enable(adapter);
4915 4430
4916 if ((hw->mng_cookie.status &
4917 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
4918 (vid == adapter->mng_vlan_id)) {
4919 /* release control to f/w */
4920 e1000_release_hw_control(adapter);
4921 return;
4922 }
4923
4924 /* remove VID from filter table */ 4431 /* remove VID from filter table */
4925 index = (vid >> 5) & 0x7F; 4432 index = (vid >> 5) & 0x7F;
4926 vfta = E1000_READ_REG_ARRAY(hw, VFTA, index); 4433 vfta = E1000_READ_REG_ARRAY(hw, VFTA, index);
@@ -5031,16 +4538,13 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
5031 } 4538 }
5032 4539
5033 if (hw->media_type == e1000_media_type_fiber || 4540 if (hw->media_type == e1000_media_type_fiber ||
5034 hw->media_type == e1000_media_type_internal_serdes) { 4541 hw->media_type == e1000_media_type_internal_serdes) {
5035 /* keep the laser running in D3 */ 4542 /* keep the laser running in D3 */
5036 ctrl_ext = er32(CTRL_EXT); 4543 ctrl_ext = er32(CTRL_EXT);
5037 ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA; 4544 ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
5038 ew32(CTRL_EXT, ctrl_ext); 4545 ew32(CTRL_EXT, ctrl_ext);
5039 } 4546 }
5040 4547
5041 /* Allow time for pending master requests to run */
5042 e1000_disable_pciex_master(hw);
5043
5044 ew32(WUC, E1000_WUC_PME_EN); 4548 ew32(WUC, E1000_WUC_PME_EN);
5045 ew32(WUFC, wufc); 4549 ew32(WUFC, wufc);
5046 } else { 4550 } else {
@@ -5056,16 +4560,9 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
5056 if (adapter->en_mng_pt) 4560 if (adapter->en_mng_pt)
5057 *enable_wake = true; 4561 *enable_wake = true;
5058 4562
5059 if (hw->phy_type == e1000_phy_igp_3)
5060 e1000_phy_powerdown_workaround(hw);
5061
5062 if (netif_running(netdev)) 4563 if (netif_running(netdev))
5063 e1000_free_irq(adapter); 4564 e1000_free_irq(adapter);
5064 4565
5065 /* Release control of h/w to f/w. If f/w is AMT enabled, this
5066 * would have already happened in close and is redundant. */
5067 e1000_release_hw_control(adapter);
5068
5069 pci_disable_device(pdev); 4566 pci_disable_device(pdev);
5070 4567
5071 return 0; 4568 return 0;
@@ -5131,14 +4628,6 @@ static int e1000_resume(struct pci_dev *pdev)
5131 4628
5132 netif_device_attach(netdev); 4629 netif_device_attach(netdev);
5133 4630
5134 /* If the controller is 82573 and f/w is AMT, do not set
5135 * DRV_LOAD until the interface is up. For all other cases,
5136 * let the f/w know that the h/w is now under the control
5137 * of the driver. */
5138 if (hw->mac_type != e1000_82573 ||
5139 !e1000_check_mng_mode(hw))
5140 e1000_get_hw_control(adapter);
5141
5142 return 0; 4631 return 0;
5143} 4632}
5144#endif 4633#endif
@@ -5174,7 +4663,7 @@ static void e1000_netpoll(struct net_device *netdev)
5174/** 4663/**
5175 * e1000_io_error_detected - called when PCI error is detected 4664 * e1000_io_error_detected - called when PCI error is detected
5176 * @pdev: Pointer to PCI device 4665 * @pdev: Pointer to PCI device
5177 * @state: The current pci conneection state 4666 * @state: The current pci connection state
5178 * 4667 *
5179 * This function is called after a PCI bus error affecting 4668 * This function is called after a PCI bus error affecting
5180 * this device has been detected. 4669 * this device has been detected.
@@ -5243,7 +4732,6 @@ static void e1000_io_resume(struct pci_dev *pdev)
5243{ 4732{
5244 struct net_device *netdev = pci_get_drvdata(pdev); 4733 struct net_device *netdev = pci_get_drvdata(pdev);
5245 struct e1000_adapter *adapter = netdev_priv(netdev); 4734 struct e1000_adapter *adapter = netdev_priv(netdev);
5246 struct e1000_hw *hw = &adapter->hw;
5247 4735
5248 e1000_init_manageability(adapter); 4736 e1000_init_manageability(adapter);
5249 4737
@@ -5255,15 +4743,6 @@ static void e1000_io_resume(struct pci_dev *pdev)
5255 } 4743 }
5256 4744
5257 netif_device_attach(netdev); 4745 netif_device_attach(netdev);
5258
5259 /* If the controller is 82573 and f/w is AMT, do not set
5260 * DRV_LOAD until the interface is up. For all other cases,
5261 * let the f/w know that the h/w is now under the control
5262 * of the driver. */
5263 if (hw->mac_type != e1000_82573 ||
5264 !e1000_check_mng_mode(hw))
5265 e1000_get_hw_control(adapter);
5266
5267} 4746}
5268 4747
5269/* e1000_main.c */ 4748/* e1000_main.c */