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.c162
1 files changed, 92 insertions, 70 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 17f5867b5d9b..8d9269d12a67 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -790,6 +790,70 @@ static const struct net_device_ops e1000_netdev_ops = {
790}; 790};
791 791
792/** 792/**
793 * e1000_init_hw_struct - initialize members of hw struct
794 * @adapter: board private struct
795 * @hw: structure used by e1000_hw.c
796 *
797 * Factors out initialization of the e1000_hw struct to its own function
798 * that can be called very early at init (just after struct allocation).
799 * Fields are initialized based on PCI device information and
800 * OS network device settings (MTU size).
801 * Returns negative error codes if MAC type setup fails.
802 */
803static int e1000_init_hw_struct(struct e1000_adapter *adapter,
804 struct e1000_hw *hw)
805{
806 struct pci_dev *pdev = adapter->pdev;
807
808 /* PCI config space info */
809 hw->vendor_id = pdev->vendor;
810 hw->device_id = pdev->device;
811 hw->subsystem_vendor_id = pdev->subsystem_vendor;
812 hw->subsystem_id = pdev->subsystem_device;
813 hw->revision_id = pdev->revision;
814
815 pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
816
817 hw->max_frame_size = adapter->netdev->mtu +
818 ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
819 hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
820
821 /* identify the MAC */
822 if (e1000_set_mac_type(hw)) {
823 e_err(probe, "Unknown MAC Type\n");
824 return -EIO;
825 }
826
827 switch (hw->mac_type) {
828 default:
829 break;
830 case e1000_82541:
831 case e1000_82547:
832 case e1000_82541_rev_2:
833 case e1000_82547_rev_2:
834 hw->phy_init_script = 1;
835 break;
836 }
837
838 e1000_set_media_type(hw);
839 e1000_get_bus_info(hw);
840
841 hw->wait_autoneg_complete = false;
842 hw->tbi_compatibility_en = true;
843 hw->adaptive_ifs = true;
844
845 /* Copper options */
846
847 if (hw->media_type == e1000_media_type_copper) {
848 hw->mdix = AUTO_ALL_MODES;
849 hw->disable_polarity_correction = false;
850 hw->master_slave = E1000_MASTER_SLAVE;
851 }
852
853 return 0;
854}
855
856/**
793 * e1000_probe - Device Initialization Routine 857 * e1000_probe - Device Initialization Routine
794 * @pdev: PCI device information struct 858 * @pdev: PCI device information struct
795 * @ent: entry in e1000_pci_tbl 859 * @ent: entry in e1000_pci_tbl
@@ -826,22 +890,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
826 if (err) 890 if (err)
827 return err; 891 return err;
828 892
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); 893 err = pci_request_selected_regions(pdev, bars, e1000_driver_name);
846 if (err) 894 if (err)
847 goto err_pci_reg; 895 goto err_pci_reg;
@@ -885,6 +933,32 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
885 } 933 }
886 } 934 }
887 935
936 /* make ready for any if (hw->...) below */
937 err = e1000_init_hw_struct(adapter, hw);
938 if (err)
939 goto err_sw_init;
940
941 /*
942 * there is a workaround being applied below that limits
943 * 64-bit DMA addresses to 64-bit hardware. There are some
944 * 32-bit adapters that Tx hang when given 64-bit DMA addresses
945 */
946 pci_using_dac = 0;
947 if ((hw->bus_type == e1000_bus_type_pcix) &&
948 !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
949 /*
950 * according to DMA-API-HOWTO, coherent calls will always
951 * succeed if the set call did
952 */
953 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
954 pci_using_dac = 1;
955 } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
956 dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
957 } else {
958 pr_err("No usable DMA config, aborting\n");
959 goto err_dma;
960 }
961
888 netdev->netdev_ops = &e1000_netdev_ops; 962 netdev->netdev_ops = &e1000_netdev_ops;
889 e1000_set_ethtool_ops(netdev); 963 e1000_set_ethtool_ops(netdev);
890 netdev->watchdog_timeo = 5 * HZ; 964 netdev->watchdog_timeo = 5 * HZ;
@@ -959,8 +1033,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
959 if (!is_valid_ether_addr(netdev->perm_addr)) 1033 if (!is_valid_ether_addr(netdev->perm_addr))
960 e_err(probe, "Invalid MAC Address\n"); 1034 e_err(probe, "Invalid MAC Address\n");
961 1035
962 e1000_get_bus_info(hw);
963
964 init_timer(&adapter->tx_fifo_stall_timer); 1036 init_timer(&adapter->tx_fifo_stall_timer);
965 adapter->tx_fifo_stall_timer.function = e1000_82547_tx_fifo_stall; 1037 adapter->tx_fifo_stall_timer.function = e1000_82547_tx_fifo_stall;
966 adapter->tx_fifo_stall_timer.data = (unsigned long)adapter; 1038 adapter->tx_fifo_stall_timer.data = (unsigned long)adapter;
@@ -1072,6 +1144,7 @@ err_eeprom:
1072 iounmap(hw->flash_address); 1144 iounmap(hw->flash_address);
1073 kfree(adapter->tx_ring); 1145 kfree(adapter->tx_ring);
1074 kfree(adapter->rx_ring); 1146 kfree(adapter->rx_ring);
1147err_dma:
1075err_sw_init: 1148err_sw_init:
1076 iounmap(hw->hw_addr); 1149 iounmap(hw->hw_addr);
1077err_ioremap: 1150err_ioremap:
@@ -1079,7 +1152,6 @@ err_ioremap:
1079err_alloc_etherdev: 1152err_alloc_etherdev:
1080 pci_release_selected_regions(pdev, bars); 1153 pci_release_selected_regions(pdev, bars);
1081err_pci_reg: 1154err_pci_reg:
1082err_dma:
1083 pci_disable_device(pdev); 1155 pci_disable_device(pdev);
1084 return err; 1156 return err;
1085} 1157}
@@ -1131,62 +1203,12 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
1131 * @adapter: board private structure to initialize 1203 * @adapter: board private structure to initialize
1132 * 1204 *
1133 * e1000_sw_init initializes the Adapter private data structure. 1205 * e1000_sw_init initializes the Adapter private data structure.
1134 * Fields are initialized based on PCI device information and 1206 * e1000_init_hw_struct MUST be called before this function
1135 * OS network device settings (MTU size).
1136 **/ 1207 **/
1137 1208
1138static int __devinit e1000_sw_init(struct e1000_adapter *adapter) 1209static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
1139{ 1210{
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; 1211 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 1212
1191 adapter->num_tx_queues = 1; 1213 adapter->num_tx_queues = 1;
1192 adapter->num_rx_queues = 1; 1214 adapter->num_rx_queues = 1;