aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/e1000_main.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/e1000/e1000_main.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/e1000/e1000_main.c')
-rw-r--r--drivers/net/e1000/e1000_main.c359
1 files changed, 238 insertions, 121 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 5cc39ed289c6..76e8af00d86d 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -28,10 +28,17 @@
28 28
29#include "e1000.h" 29#include "e1000.h"
30#include <net/ip6_checksum.h> 30#include <net/ip6_checksum.h>
31#include <linux/io.h>
32#include <linux/prefetch.h>
33
34/* Intel Media SOC GbE MDIO physical base address */
35static unsigned long ce4100_gbe_mdio_base_phy;
36/* Intel Media SOC GbE MDIO virtual base address */
37void __iomem *ce4100_gbe_mdio_base_virt;
31 38
32char e1000_driver_name[] = "e1000"; 39char e1000_driver_name[] = "e1000";
33static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; 40static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
34#define DRV_VERSION "7.3.21-k6-NAPI" 41#define DRV_VERSION "7.3.21-k8-NAPI"
35const char e1000_driver_version[] = DRV_VERSION; 42const char e1000_driver_version[] = DRV_VERSION;
36static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 43static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
37 44
@@ -79,6 +86,7 @@ static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
79 INTEL_E1000_ETHERNET_DEVICE(0x108A), 86 INTEL_E1000_ETHERNET_DEVICE(0x108A),
80 INTEL_E1000_ETHERNET_DEVICE(0x1099), 87 INTEL_E1000_ETHERNET_DEVICE(0x1099),
81 INTEL_E1000_ETHERNET_DEVICE(0x10B5), 88 INTEL_E1000_ETHERNET_DEVICE(0x10B5),
89 INTEL_E1000_ETHERNET_DEVICE(0x2E6E),
82 /* required last entry */ 90 /* required last entry */
83 {0,} 91 {0,}
84}; 92};
@@ -89,7 +97,6 @@ int e1000_up(struct e1000_adapter *adapter);
89void e1000_down(struct e1000_adapter *adapter); 97void e1000_down(struct e1000_adapter *adapter);
90void e1000_reinit_locked(struct e1000_adapter *adapter); 98void e1000_reinit_locked(struct e1000_adapter *adapter);
91void e1000_reset(struct e1000_adapter *adapter); 99void e1000_reset(struct e1000_adapter *adapter);
92int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
93int e1000_setup_all_tx_resources(struct e1000_adapter *adapter); 100int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
94int e1000_setup_all_rx_resources(struct e1000_adapter *adapter); 101int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
95void e1000_free_all_tx_resources(struct e1000_adapter *adapter); 102void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
@@ -123,8 +130,10 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
123 struct e1000_rx_ring *rx_ring); 130 struct e1000_rx_ring *rx_ring);
124static void e1000_set_rx_mode(struct net_device *netdev); 131static void e1000_set_rx_mode(struct net_device *netdev);
125static void e1000_update_phy_info(unsigned long data); 132static void e1000_update_phy_info(unsigned long data);
133static void e1000_update_phy_info_task(struct work_struct *work);
126static void e1000_watchdog(unsigned long data); 134static void e1000_watchdog(unsigned long data);
127static void e1000_82547_tx_fifo_stall(unsigned long data); 135static void e1000_82547_tx_fifo_stall(unsigned long data);
136static void e1000_82547_tx_fifo_stall_task(struct work_struct *work);
128static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, 137static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
129 struct net_device *netdev); 138 struct net_device *netdev);
130static struct net_device_stats * e1000_get_stats(struct net_device *netdev); 139static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
@@ -196,7 +205,7 @@ static struct pci_driver e1000_driver = {
196 .probe = e1000_probe, 205 .probe = e1000_probe,
197 .remove = __devexit_p(e1000_remove), 206 .remove = __devexit_p(e1000_remove),
198#ifdef CONFIG_PM 207#ifdef CONFIG_PM
199 /* Power Managment Hooks */ 208 /* Power Management Hooks */
200 .suspend = e1000_suspend, 209 .suspend = e1000_suspend,
201 .resume = e1000_resume, 210 .resume = e1000_resume,
202#endif 211#endif
@@ -457,6 +466,7 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter)
457 case e1000_82545: 466 case e1000_82545:
458 case e1000_82545_rev_3: 467 case e1000_82545_rev_3:
459 case e1000_82546: 468 case e1000_82546:
469 case e1000_ce4100:
460 case e1000_82546_rev_3: 470 case e1000_82546_rev_3:
461 case e1000_82541: 471 case e1000_82541:
462 case e1000_82541_rev_2: 472 case e1000_82541_rev_2:
@@ -483,9 +493,6 @@ void e1000_down(struct e1000_adapter *adapter)
483 struct net_device *netdev = adapter->netdev; 493 struct net_device *netdev = adapter->netdev;
484 u32 rctl, tctl; 494 u32 rctl, tctl;
485 495
486 /* signal that we're down so the interrupt handler does not
487 * reschedule our watchdog timer */
488 set_bit(__E1000_DOWN, &adapter->flags);
489 496
490 /* disable receives in the hardware */ 497 /* disable receives in the hardware */
491 rctl = er32(RCTL); 498 rctl = er32(RCTL);
@@ -506,6 +513,13 @@ void e1000_down(struct e1000_adapter *adapter)
506 513
507 e1000_irq_disable(adapter); 514 e1000_irq_disable(adapter);
508 515
516 /*
517 * Setting DOWN must be after irq_disable to prevent
518 * a screaming interrupt. Setting DOWN also prevents
519 * timers and tasks from rescheduling.
520 */
521 set_bit(__E1000_DOWN, &adapter->flags);
522
509 del_timer_sync(&adapter->tx_fifo_stall_timer); 523 del_timer_sync(&adapter->tx_fifo_stall_timer);
510 del_timer_sync(&adapter->watchdog_timer); 524 del_timer_sync(&adapter->watchdog_timer);
511 del_timer_sync(&adapter->phy_info_timer); 525 del_timer_sync(&adapter->phy_info_timer);
@@ -519,8 +533,21 @@ void e1000_down(struct e1000_adapter *adapter)
519 e1000_clean_all_rx_rings(adapter); 533 e1000_clean_all_rx_rings(adapter);
520} 534}
521 535
536static void e1000_reinit_safe(struct e1000_adapter *adapter)
537{
538 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
539 msleep(1);
540 rtnl_lock();
541 e1000_down(adapter);
542 e1000_up(adapter);
543 rtnl_unlock();
544 clear_bit(__E1000_RESETTING, &adapter->flags);
545}
546
522void e1000_reinit_locked(struct e1000_adapter *adapter) 547void e1000_reinit_locked(struct e1000_adapter *adapter)
523{ 548{
549 /* if rtnl_lock is not held the call path is bogus */
550 ASSERT_RTNL();
524 WARN_ON(in_interrupt()); 551 WARN_ON(in_interrupt());
525 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) 552 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
526 msleep(1); 553 msleep(1);
@@ -554,6 +581,7 @@ void e1000_reset(struct e1000_adapter *adapter)
554 case e1000_82545: 581 case e1000_82545:
555 case e1000_82545_rev_3: 582 case e1000_82545_rev_3:
556 case e1000_82546: 583 case e1000_82546:
584 case e1000_ce4100:
557 case e1000_82546_rev_3: 585 case e1000_82546_rev_3:
558 pba = E1000_PBA_48K; 586 pba = E1000_PBA_48K;
559 break; 587 break;
@@ -790,6 +818,70 @@ static const struct net_device_ops e1000_netdev_ops = {
790}; 818};
791 819
792/** 820/**
821 * e1000_init_hw_struct - initialize members of hw struct
822 * @adapter: board private struct
823 * @hw: structure used by e1000_hw.c
824 *
825 * Factors out initialization of the e1000_hw struct to its own function
826 * that can be called very early at init (just after struct allocation).
827 * Fields are initialized based on PCI device information and
828 * OS network device settings (MTU size).
829 * Returns negative error codes if MAC type setup fails.
830 */
831static int e1000_init_hw_struct(struct e1000_adapter *adapter,
832 struct e1000_hw *hw)
833{
834 struct pci_dev *pdev = adapter->pdev;
835
836 /* PCI config space info */
837 hw->vendor_id = pdev->vendor;
838 hw->device_id = pdev->device;
839 hw->subsystem_vendor_id = pdev->subsystem_vendor;
840 hw->subsystem_id = pdev->subsystem_device;
841 hw->revision_id = pdev->revision;
842
843 pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
844
845 hw->max_frame_size = adapter->netdev->mtu +
846 ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
847 hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
848
849 /* identify the MAC */
850 if (e1000_set_mac_type(hw)) {
851 e_err(probe, "Unknown MAC Type\n");
852 return -EIO;
853 }
854
855 switch (hw->mac_type) {
856 default:
857 break;
858 case e1000_82541:
859 case e1000_82547:
860 case e1000_82541_rev_2:
861 case e1000_82547_rev_2:
862 hw->phy_init_script = 1;
863 break;
864 }
865
866 e1000_set_media_type(hw);
867 e1000_get_bus_info(hw);
868
869 hw->wait_autoneg_complete = false;
870 hw->tbi_compatibility_en = true;
871 hw->adaptive_ifs = true;
872
873 /* Copper options */
874
875 if (hw->media_type == e1000_media_type_copper) {
876 hw->mdix = AUTO_ALL_MODES;
877 hw->disable_polarity_correction = false;
878 hw->master_slave = E1000_MASTER_SLAVE;
879 }
880
881 return 0;
882}
883
884/**
793 * e1000_probe - Device Initialization Routine 885 * e1000_probe - Device Initialization Routine
794 * @pdev: PCI device information struct 886 * @pdev: PCI device information struct
795 * @ent: entry in e1000_pci_tbl 887 * @ent: entry in e1000_pci_tbl
@@ -811,6 +903,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
811 static int global_quad_port_a = 0; /* global ksp3 port a indication */ 903 static int global_quad_port_a = 0; /* global ksp3 port a indication */
812 int i, err, pci_using_dac; 904 int i, err, pci_using_dac;
813 u16 eeprom_data = 0; 905 u16 eeprom_data = 0;
906 u16 tmp = 0;
814 u16 eeprom_apme_mask = E1000_EEPROM_APME; 907 u16 eeprom_apme_mask = E1000_EEPROM_APME;
815 int bars, need_ioport; 908 int bars, need_ioport;
816 909
@@ -826,22 +919,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
826 if (err) 919 if (err)
827 return err; 920 return err;
828 921
829 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
830 !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) {
831 pci_using_dac = 1;
832 } else {
833 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
834 if (err) {
835 err = dma_set_coherent_mask(&pdev->dev,
836 DMA_BIT_MASK(32));
837 if (err) {
838 pr_err("No usable DMA config, aborting\n");
839 goto err_dma;
840 }
841 }
842 pci_using_dac = 0;
843 }
844
845 err = pci_request_selected_regions(pdev, bars, e1000_driver_name); 922 err = pci_request_selected_regions(pdev, bars, e1000_driver_name);
846 if (err) 923 if (err)
847 goto err_pci_reg; 924 goto err_pci_reg;
@@ -885,6 +962,34 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
885 } 962 }
886 } 963 }
887 964
965 /* make ready for any if (hw->...) below */
966 err = e1000_init_hw_struct(adapter, hw);
967 if (err)
968 goto err_sw_init;
969
970 /*
971 * there is a workaround being applied below that limits
972 * 64-bit DMA addresses to 64-bit hardware. There are some
973 * 32-bit adapters that Tx hang when given 64-bit DMA addresses
974 */
975 pci_using_dac = 0;
976 if ((hw->bus_type == e1000_bus_type_pcix) &&
977 !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
978 /*
979 * according to DMA-API-HOWTO, coherent calls will always
980 * succeed if the set call did
981 */
982 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
983 pci_using_dac = 1;
984 } else {
985 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
986 if (err) {
987 pr_err("No usable DMA config, aborting\n");
988 goto err_dma;
989 }
990 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
991 }
992
888 netdev->netdev_ops = &e1000_netdev_ops; 993 netdev->netdev_ops = &e1000_netdev_ops;
889 e1000_set_ethtool_ops(netdev); 994 e1000_set_ethtool_ops(netdev);
890 netdev->watchdog_timeo = 5 * HZ; 995 netdev->watchdog_timeo = 5 * HZ;
@@ -901,6 +1006,14 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
901 goto err_sw_init; 1006 goto err_sw_init;
902 1007
903 err = -EIO; 1008 err = -EIO;
1009 if (hw->mac_type == e1000_ce4100) {
1010 ce4100_gbe_mdio_base_phy = pci_resource_start(pdev, BAR_1);
1011 ce4100_gbe_mdio_base_virt = ioremap(ce4100_gbe_mdio_base_phy,
1012 pci_resource_len(pdev, BAR_1));
1013
1014 if (!ce4100_gbe_mdio_base_virt)
1015 goto err_mdio_ioremap;
1016 }
904 1017
905 if (hw->mac_type >= e1000_82543) { 1018 if (hw->mac_type >= e1000_82543) {
906 netdev->features = NETIF_F_SG | 1019 netdev->features = NETIF_F_SG |
@@ -914,8 +1027,10 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
914 (hw->mac_type != e1000_82547)) 1027 (hw->mac_type != e1000_82547))
915 netdev->features |= NETIF_F_TSO; 1028 netdev->features |= NETIF_F_TSO;
916 1029
917 if (pci_using_dac) 1030 if (pci_using_dac) {
918 netdev->features |= NETIF_F_HIGHDMA; 1031 netdev->features |= NETIF_F_HIGHDMA;
1032 netdev->vlan_features |= NETIF_F_HIGHDMA;
1033 }
919 1034
920 netdev->vlan_features |= NETIF_F_TSO; 1035 netdev->vlan_features |= NETIF_F_TSO;
921 netdev->vlan_features |= NETIF_F_HW_CSUM; 1036 netdev->vlan_features |= NETIF_F_HW_CSUM;
@@ -959,21 +1074,21 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
959 if (!is_valid_ether_addr(netdev->perm_addr)) 1074 if (!is_valid_ether_addr(netdev->perm_addr))
960 e_err(probe, "Invalid MAC Address\n"); 1075 e_err(probe, "Invalid MAC Address\n");
961 1076
962 e1000_get_bus_info(hw);
963
964 init_timer(&adapter->tx_fifo_stall_timer); 1077 init_timer(&adapter->tx_fifo_stall_timer);
965 adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall; 1078 adapter->tx_fifo_stall_timer.function = e1000_82547_tx_fifo_stall;
966 adapter->tx_fifo_stall_timer.data = (unsigned long)adapter; 1079 adapter->tx_fifo_stall_timer.data = (unsigned long)adapter;
967 1080
968 init_timer(&adapter->watchdog_timer); 1081 init_timer(&adapter->watchdog_timer);
969 adapter->watchdog_timer.function = &e1000_watchdog; 1082 adapter->watchdog_timer.function = e1000_watchdog;
970 adapter->watchdog_timer.data = (unsigned long) adapter; 1083 adapter->watchdog_timer.data = (unsigned long) adapter;
971 1084
972 init_timer(&adapter->phy_info_timer); 1085 init_timer(&adapter->phy_info_timer);
973 adapter->phy_info_timer.function = &e1000_update_phy_info; 1086 adapter->phy_info_timer.function = e1000_update_phy_info;
974 adapter->phy_info_timer.data = (unsigned long)adapter; 1087 adapter->phy_info_timer.data = (unsigned long)adapter;
975 1088
1089 INIT_WORK(&adapter->fifo_stall_task, e1000_82547_tx_fifo_stall_task);
976 INIT_WORK(&adapter->reset_task, e1000_reset_task); 1090 INIT_WORK(&adapter->reset_task, e1000_reset_task);
1091 INIT_WORK(&adapter->phy_info_task, e1000_update_phy_info_task);
977 1092
978 e1000_check_options(adapter); 1093 e1000_check_options(adapter);
979 1094
@@ -1038,6 +1153,20 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1038 adapter->wol = adapter->eeprom_wol; 1153 adapter->wol = adapter->eeprom_wol;
1039 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); 1154 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1040 1155
1156 /* Auto detect PHY address */
1157 if (hw->mac_type == e1000_ce4100) {
1158 for (i = 0; i < 32; i++) {
1159 hw->phy_addr = i;
1160 e1000_read_phy_reg(hw, PHY_ID2, &tmp);
1161 if (tmp == 0 || tmp == 0xFF) {
1162 if (i == 31)
1163 goto err_eeprom;
1164 continue;
1165 } else
1166 break;
1167 }
1168 }
1169
1041 /* reset the hardware with the new settings */ 1170 /* reset the hardware with the new settings */
1042 e1000_reset(adapter); 1171 e1000_reset(adapter);
1043 1172
@@ -1072,14 +1201,16 @@ err_eeprom:
1072 iounmap(hw->flash_address); 1201 iounmap(hw->flash_address);
1073 kfree(adapter->tx_ring); 1202 kfree(adapter->tx_ring);
1074 kfree(adapter->rx_ring); 1203 kfree(adapter->rx_ring);
1204err_dma:
1075err_sw_init: 1205err_sw_init:
1206err_mdio_ioremap:
1207 iounmap(ce4100_gbe_mdio_base_virt);
1076 iounmap(hw->hw_addr); 1208 iounmap(hw->hw_addr);
1077err_ioremap: 1209err_ioremap:
1078 free_netdev(netdev); 1210 free_netdev(netdev);
1079err_alloc_etherdev: 1211err_alloc_etherdev:
1080 pci_release_selected_regions(pdev, bars); 1212 pci_release_selected_regions(pdev, bars);
1081err_pci_reg: 1213err_pci_reg:
1082err_dma:
1083 pci_disable_device(pdev); 1214 pci_disable_device(pdev);
1084 return err; 1215 return err;
1085} 1216}
@@ -1131,62 +1262,12 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
1131 * @adapter: board private structure to initialize 1262 * @adapter: board private structure to initialize
1132 * 1263 *
1133 * e1000_sw_init initializes the Adapter private data structure. 1264 * e1000_sw_init initializes the Adapter private data structure.
1134 * Fields are initialized based on PCI device information and 1265 * e1000_init_hw_struct MUST be called before this function
1135 * OS network device settings (MTU size).
1136 **/ 1266 **/
1137 1267
1138static int __devinit e1000_sw_init(struct e1000_adapter *adapter) 1268static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
1139{ 1269{
1140 struct e1000_hw *hw = &adapter->hw;
1141 struct net_device *netdev = adapter->netdev;
1142 struct pci_dev *pdev = adapter->pdev;
1143
1144 /* PCI config space info */
1145
1146 hw->vendor_id = pdev->vendor;
1147 hw->device_id = pdev->device;
1148 hw->subsystem_vendor_id = pdev->subsystem_vendor;
1149 hw->subsystem_id = pdev->subsystem_device;
1150 hw->revision_id = pdev->revision;
1151
1152 pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
1153
1154 adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE; 1270 adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
1155 hw->max_frame_size = netdev->mtu +
1156 ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
1157 hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
1158
1159 /* identify the MAC */
1160
1161 if (e1000_set_mac_type(hw)) {
1162 e_err(probe, "Unknown MAC Type\n");
1163 return -EIO;
1164 }
1165
1166 switch (hw->mac_type) {
1167 default:
1168 break;
1169 case e1000_82541:
1170 case e1000_82547:
1171 case e1000_82541_rev_2:
1172 case e1000_82547_rev_2:
1173 hw->phy_init_script = 1;
1174 break;
1175 }
1176
1177 e1000_set_media_type(hw);
1178
1179 hw->wait_autoneg_complete = false;
1180 hw->tbi_compatibility_en = true;
1181 hw->adaptive_ifs = true;
1182
1183 /* Copper options */
1184
1185 if (hw->media_type == e1000_media_type_copper) {
1186 hw->mdix = AUTO_ALL_MODES;
1187 hw->disable_polarity_correction = false;
1188 hw->master_slave = E1000_MASTER_SLAVE;
1189 }
1190 1271
1191 adapter->num_tx_queues = 1; 1272 adapter->num_tx_queues = 1;
1192 adapter->num_rx_queues = 1; 1273 adapter->num_rx_queues = 1;
@@ -1362,6 +1443,7 @@ static bool e1000_check_64k_bound(struct e1000_adapter *adapter, void *start,
1362 /* First rev 82545 and 82546 need to not allow any memory 1443 /* First rev 82545 and 82546 need to not allow any memory
1363 * write location to cross 64k boundary due to errata 23 */ 1444 * write location to cross 64k boundary due to errata 23 */
1364 if (hw->mac_type == e1000_82545 || 1445 if (hw->mac_type == e1000_82545 ||
1446 hw->mac_type == e1000_ce4100 ||
1365 hw->mac_type == e1000_82546) { 1447 hw->mac_type == e1000_82546) {
1366 return ((begin ^ (end - 1)) >> 16) != 0 ? false : true; 1448 return ((begin ^ (end - 1)) >> 16) != 0 ? false : true;
1367 } 1449 }
@@ -1384,13 +1466,12 @@ static int e1000_setup_tx_resources(struct e1000_adapter *adapter,
1384 int size; 1466 int size;
1385 1467
1386 size = sizeof(struct e1000_buffer) * txdr->count; 1468 size = sizeof(struct e1000_buffer) * txdr->count;
1387 txdr->buffer_info = vmalloc(size); 1469 txdr->buffer_info = vzalloc(size);
1388 if (!txdr->buffer_info) { 1470 if (!txdr->buffer_info) {
1389 e_err(probe, "Unable to allocate memory for the Tx descriptor " 1471 e_err(probe, "Unable to allocate memory for the Tx descriptor "
1390 "ring\n"); 1472 "ring\n");
1391 return -ENOMEM; 1473 return -ENOMEM;
1392 } 1474 }
1393 memset(txdr->buffer_info, 0, size);
1394 1475
1395 /* round up to nearest 4K */ 1476 /* round up to nearest 4K */
1396 1477
@@ -1580,13 +1661,12 @@ static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
1580 int size, desc_len; 1661 int size, desc_len;
1581 1662
1582 size = sizeof(struct e1000_buffer) * rxdr->count; 1663 size = sizeof(struct e1000_buffer) * rxdr->count;
1583 rxdr->buffer_info = vmalloc(size); 1664 rxdr->buffer_info = vzalloc(size);
1584 if (!rxdr->buffer_info) { 1665 if (!rxdr->buffer_info) {
1585 e_err(probe, "Unable to allocate memory for the Rx descriptor " 1666 e_err(probe, "Unable to allocate memory for the Rx descriptor "
1586 "ring\n"); 1667 "ring\n");
1587 return -ENOMEM; 1668 return -ENOMEM;
1588 } 1669 }
1589 memset(rxdr->buffer_info, 0, size);
1590 1670
1591 desc_len = sizeof(struct e1000_rx_desc); 1671 desc_len = sizeof(struct e1000_rx_desc);
1592 1672
@@ -2153,7 +2233,7 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2153 * addresses take precedence to avoid disabling unicast filtering 2233 * addresses take precedence to avoid disabling unicast filtering
2154 * when possible. 2234 * when possible.
2155 * 2235 *
2156 * RAR 0 is used for the station MAC adddress 2236 * RAR 0 is used for the station MAC address
2157 * if there are not 14 addresses, go ahead and clear the filters 2237 * if there are not 14 addresses, go ahead and clear the filters
2158 */ 2238 */
2159 i = 1; 2239 i = 1;
@@ -2210,22 +2290,45 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2210static void e1000_update_phy_info(unsigned long data) 2290static void e1000_update_phy_info(unsigned long data)
2211{ 2291{
2212 struct e1000_adapter *adapter = (struct e1000_adapter *)data; 2292 struct e1000_adapter *adapter = (struct e1000_adapter *)data;
2293 schedule_work(&adapter->phy_info_task);
2294}
2295
2296static void e1000_update_phy_info_task(struct work_struct *work)
2297{
2298 struct e1000_adapter *adapter = container_of(work,
2299 struct e1000_adapter,
2300 phy_info_task);
2213 struct e1000_hw *hw = &adapter->hw; 2301 struct e1000_hw *hw = &adapter->hw;
2302
2303 rtnl_lock();
2214 e1000_phy_get_info(hw, &adapter->phy_info); 2304 e1000_phy_get_info(hw, &adapter->phy_info);
2305 rtnl_unlock();
2215} 2306}
2216 2307
2217/** 2308/**
2218 * e1000_82547_tx_fifo_stall - Timer Call-back 2309 * e1000_82547_tx_fifo_stall - Timer Call-back
2219 * @data: pointer to adapter cast into an unsigned long 2310 * @data: pointer to adapter cast into an unsigned long
2220 **/ 2311 **/
2221
2222static void e1000_82547_tx_fifo_stall(unsigned long data) 2312static void e1000_82547_tx_fifo_stall(unsigned long data)
2223{ 2313{
2224 struct e1000_adapter *adapter = (struct e1000_adapter *)data; 2314 struct e1000_adapter *adapter = (struct e1000_adapter *)data;
2315 schedule_work(&adapter->fifo_stall_task);
2316}
2317
2318/**
2319 * e1000_82547_tx_fifo_stall_task - task to complete work
2320 * @work: work struct contained inside adapter struct
2321 **/
2322static void e1000_82547_tx_fifo_stall_task(struct work_struct *work)
2323{
2324 struct e1000_adapter *adapter = container_of(work,
2325 struct e1000_adapter,
2326 fifo_stall_task);
2225 struct e1000_hw *hw = &adapter->hw; 2327 struct e1000_hw *hw = &adapter->hw;
2226 struct net_device *netdev = adapter->netdev; 2328 struct net_device *netdev = adapter->netdev;
2227 u32 tctl; 2329 u32 tctl;
2228 2330
2331 rtnl_lock();
2229 if (atomic_read(&adapter->tx_fifo_stall)) { 2332 if (atomic_read(&adapter->tx_fifo_stall)) {
2230 if ((er32(TDT) == er32(TDH)) && 2333 if ((er32(TDT) == er32(TDH)) &&
2231 (er32(TDFT) == er32(TDFH)) && 2334 (er32(TDFT) == er32(TDFH)) &&
@@ -2246,6 +2349,7 @@ static void e1000_82547_tx_fifo_stall(unsigned long data)
2246 mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1); 2349 mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
2247 } 2350 }
2248 } 2351 }
2352 rtnl_unlock();
2249} 2353}
2250 2354
2251bool e1000_has_link(struct e1000_adapter *adapter) 2355bool e1000_has_link(struct e1000_adapter *adapter)
@@ -2657,7 +2761,7 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter,
2657 break; 2761 break;
2658 } 2762 }
2659 2763
2660 css = skb_transport_offset(skb); 2764 css = skb_checksum_start_offset(skb);
2661 2765
2662 i = tx_ring->next_to_use; 2766 i = tx_ring->next_to_use;
2663 buffer_info = &tx_ring->buffer_info[i]; 2767 buffer_info = &tx_ring->buffer_info[i];
@@ -3054,7 +3158,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
3054 } 3158 }
3055 } 3159 }
3056 3160
3057 if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) { 3161 if (unlikely(vlan_tx_tag_present(skb))) {
3058 tx_flags |= E1000_TX_FLAGS_VLAN; 3162 tx_flags |= E1000_TX_FLAGS_VLAN;
3059 tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT); 3163 tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
3060 } 3164 }
@@ -3113,7 +3217,7 @@ static void e1000_reset_task(struct work_struct *work)
3113 struct e1000_adapter *adapter = 3217 struct e1000_adapter *adapter =
3114 container_of(work, struct e1000_adapter, reset_task); 3218 container_of(work, struct e1000_adapter, reset_task);
3115 3219
3116 e1000_reinit_locked(adapter); 3220 e1000_reinit_safe(adapter);
3117} 3221}
3118 3222
3119/** 3223/**
@@ -3374,9 +3478,17 @@ static irqreturn_t e1000_intr(int irq, void *data)
3374 struct e1000_hw *hw = &adapter->hw; 3478 struct e1000_hw *hw = &adapter->hw;
3375 u32 icr = er32(ICR); 3479 u32 icr = er32(ICR);
3376 3480
3377 if (unlikely((!icr) || test_bit(__E1000_DOWN, &adapter->flags))) 3481 if (unlikely((!icr)))
3378 return IRQ_NONE; /* Not our interrupt */ 3482 return IRQ_NONE; /* Not our interrupt */
3379 3483
3484 /*
3485 * we might have caused the interrupt, but the above
3486 * read cleared it, and just in case the driver is
3487 * down there is nothing to do so return handled
3488 */
3489 if (unlikely(test_bit(__E1000_DOWN, &adapter->flags)))
3490 return IRQ_HANDLED;
3491
3380 if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) { 3492 if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
3381 hw->get_link_status = 1; 3493 hw->get_link_status = 1;
3382 /* guard against interrupt when we're going down */ 3494 /* guard against interrupt when we're going down */
@@ -3535,7 +3647,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
3535 adapter->total_tx_packets += total_tx_packets; 3647 adapter->total_tx_packets += total_tx_packets;
3536 netdev->stats.tx_bytes += total_tx_bytes; 3648 netdev->stats.tx_bytes += total_tx_bytes;
3537 netdev->stats.tx_packets += total_tx_packets; 3649 netdev->stats.tx_packets += total_tx_packets;
3538 return (count < tx_ring->count); 3650 return count < tx_ring->count;
3539} 3651}
3540 3652
3541/** 3653/**
@@ -3552,7 +3664,8 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
3552 struct e1000_hw *hw = &adapter->hw; 3664 struct e1000_hw *hw = &adapter->hw;
3553 u16 status = (u16)status_err; 3665 u16 status = (u16)status_err;
3554 u8 errors = (u8)(status_err >> 24); 3666 u8 errors = (u8)(status_err >> 24);
3555 skb->ip_summed = CHECKSUM_NONE; 3667
3668 skb_checksum_none_assert(skb);
3556 3669
3557 /* 82543 or newer only */ 3670 /* 82543 or newer only */
3558 if (unlikely(hw->mac_type < e1000_82543)) return; 3671 if (unlikely(hw->mac_type < e1000_82543)) return;
@@ -3598,13 +3711,14 @@ static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
3598static void e1000_receive_skb(struct e1000_adapter *adapter, u8 status, 3711static void e1000_receive_skb(struct e1000_adapter *adapter, u8 status,
3599 __le16 vlan, struct sk_buff *skb) 3712 __le16 vlan, struct sk_buff *skb)
3600{ 3713{
3601 if (unlikely(adapter->vlgrp && (status & E1000_RXD_STAT_VP))) { 3714 skb->protocol = eth_type_trans(skb, adapter->netdev);
3602 vlan_hwaccel_receive_skb(skb, adapter->vlgrp, 3715
3603 le16_to_cpu(vlan) & 3716 if ((unlikely(adapter->vlgrp && (status & E1000_RXD_STAT_VP))))
3604 E1000_RXD_SPC_VLAN_MASK); 3717 vlan_gro_receive(&adapter->napi, adapter->vlgrp,
3605 } else { 3718 le16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK,
3606 netif_receive_skb(skb); 3719 skb);
3607 } 3720 else
3721 napi_gro_receive(&adapter->napi, skb);
3608} 3722}
3609 3723
3610/** 3724/**
@@ -3762,8 +3876,6 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
3762 goto next_desc; 3876 goto next_desc;
3763 } 3877 }
3764 3878
3765 skb->protocol = eth_type_trans(skb, netdev);
3766
3767 e1000_receive_skb(adapter, status, rx_desc->special, skb); 3879 e1000_receive_skb(adapter, status, rx_desc->special, skb);
3768 3880
3769next_desc: 3881next_desc:
@@ -3926,8 +4038,6 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
3926 ((u32)(rx_desc->errors) << 24), 4038 ((u32)(rx_desc->errors) << 24),
3927 le16_to_cpu(rx_desc->csum), skb); 4039 le16_to_cpu(rx_desc->csum), skb);
3928 4040
3929 skb->protocol = eth_type_trans(skb, netdev);
3930
3931 e1000_receive_skb(adapter, status, rx_desc->special, skb); 4041 e1000_receive_skb(adapter, status, rx_desc->special, skb);
3932 4042
3933next_desc: 4043next_desc:
@@ -4275,7 +4385,6 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
4275 struct mii_ioctl_data *data = if_mii(ifr); 4385 struct mii_ioctl_data *data = if_mii(ifr);
4276 int retval; 4386 int retval;
4277 u16 mii_reg; 4387 u16 mii_reg;
4278 u16 spddplx;
4279 unsigned long flags; 4388 unsigned long flags;
4280 4389
4281 if (hw->media_type != e1000_media_type_copper) 4390 if (hw->media_type != e1000_media_type_copper)
@@ -4314,17 +4423,18 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
4314 hw->autoneg = 1; 4423 hw->autoneg = 1;
4315 hw->autoneg_advertised = 0x2F; 4424 hw->autoneg_advertised = 0x2F;
4316 } else { 4425 } else {
4426 u32 speed;
4317 if (mii_reg & 0x40) 4427 if (mii_reg & 0x40)
4318 spddplx = SPEED_1000; 4428 speed = SPEED_1000;
4319 else if (mii_reg & 0x2000) 4429 else if (mii_reg & 0x2000)
4320 spddplx = SPEED_100; 4430 speed = SPEED_100;
4321 else 4431 else
4322 spddplx = SPEED_10; 4432 speed = SPEED_10;
4323 spddplx += (mii_reg & 0x100) 4433 retval = e1000_set_spd_dplx(
4324 ? DUPLEX_FULL : 4434 adapter, speed,
4325 DUPLEX_HALF; 4435 ((mii_reg & 0x100)
4326 retval = e1000_set_spd_dplx(adapter, 4436 ? DUPLEX_FULL :
4327 spddplx); 4437 DUPLEX_HALF));
4328 if (retval) 4438 if (retval)
4329 return retval; 4439 return retval;
4330 } 4440 }
@@ -4478,7 +4588,7 @@ static void e1000_restore_vlan(struct e1000_adapter *adapter)
4478 4588
4479 if (adapter->vlgrp) { 4589 if (adapter->vlgrp) {
4480 u16 vid; 4590 u16 vid;
4481 for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) { 4591 for (vid = 0; vid < VLAN_N_VID; vid++) {
4482 if (!vlan_group_get_device(adapter->vlgrp, vid)) 4592 if (!vlan_group_get_device(adapter->vlgrp, vid))
4483 continue; 4593 continue;
4484 e1000_vlan_rx_add_vid(adapter->netdev, vid); 4594 e1000_vlan_rx_add_vid(adapter->netdev, vid);
@@ -4486,20 +4596,24 @@ static void e1000_restore_vlan(struct e1000_adapter *adapter)
4486 } 4596 }
4487} 4597}
4488 4598
4489int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx) 4599int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)
4490{ 4600{
4491 struct e1000_hw *hw = &adapter->hw; 4601 struct e1000_hw *hw = &adapter->hw;
4492 4602
4493 hw->autoneg = 0; 4603 hw->autoneg = 0;
4494 4604
4605 /* Make sure dplx is at most 1 bit and lsb of speed is not set
4606 * for the switch() below to work */
4607 if ((spd & 1) || (dplx & ~1))
4608 goto err_inval;
4609
4495 /* Fiber NICs only allow 1000 gbps Full duplex */ 4610 /* Fiber NICs only allow 1000 gbps Full duplex */
4496 if ((hw->media_type == e1000_media_type_fiber) && 4611 if ((hw->media_type == e1000_media_type_fiber) &&
4497 spddplx != (SPEED_1000 + DUPLEX_FULL)) { 4612 spd != SPEED_1000 &&
4498 e_err(probe, "Unsupported Speed/Duplex configuration\n"); 4613 dplx != DUPLEX_FULL)
4499 return -EINVAL; 4614 goto err_inval;
4500 }
4501 4615
4502 switch (spddplx) { 4616 switch (spd + dplx) {
4503 case SPEED_10 + DUPLEX_HALF: 4617 case SPEED_10 + DUPLEX_HALF:
4504 hw->forced_speed_duplex = e1000_10_half; 4618 hw->forced_speed_duplex = e1000_10_half;
4505 break; 4619 break;
@@ -4518,10 +4632,13 @@ int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
4518 break; 4632 break;
4519 case SPEED_1000 + DUPLEX_HALF: /* not supported */ 4633 case SPEED_1000 + DUPLEX_HALF: /* not supported */
4520 default: 4634 default:
4521 e_err(probe, "Unsupported Speed/Duplex configuration\n"); 4635 goto err_inval;
4522 return -EINVAL;
4523 } 4636 }
4524 return 0; 4637 return 0;
4638
4639err_inval:
4640 e_err(probe, "Unsupported Speed/Duplex configuration\n");
4641 return -EINVAL;
4525} 4642}
4526 4643
4527static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) 4644static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)