aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/e1000_main.c
diff options
context:
space:
mode:
authorJeff Kirsher <jeffrey.t.kirsher@intel.com>2006-01-12 19:50:39 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-01-17 07:40:11 -0500
commitf56799ea39a85a6f3760a134aa0e6d1c17eea369 (patch)
tree5d7ed643eb04aed2a7d5c129dd997e1f7d3cf76c /drivers/net/e1000/e1000_main.c
parentd8c2bd3d3aa49e18ffebb999979b976f04280284 (diff)
[PATCH] e1000: Fix adapter structure and prepare for multique fix
Fix adapter structure to handle multiple queues and prepping the driver for full multiple queue support, some changes are ifdef'd our unless you define CONFIG_E1000_MQ. Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Signed-off-by: John Ronciak <john.ronciak@intel.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/net/e1000/e1000_main.c')
-rw-r--r--drivers/net/e1000/e1000_main.c76
1 files changed, 44 insertions, 32 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 5f848b3a3a4d..540c8561fc24 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -411,8 +411,9 @@ e1000_up(struct e1000_adapter *adapter)
411 e1000_configure_tx(adapter); 411 e1000_configure_tx(adapter);
412 e1000_setup_rctl(adapter); 412 e1000_setup_rctl(adapter);
413 e1000_configure_rx(adapter); 413 e1000_configure_rx(adapter);
414 for (i = 0; i < adapter->num_queues; i++) 414 for (i = 0; i < adapter->num_rx_queues; i++) {
415 adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i]); 415 adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i]);
416 }
416 417
417#ifdef CONFIG_PCI_MSI 418#ifdef CONFIG_PCI_MSI
418 if(adapter->hw.mac_type > e1000_82547_rev_2) { 419 if(adapter->hw.mac_type > e1000_82547_rev_2) {
@@ -867,7 +868,7 @@ e1000_remove(struct pci_dev *pdev)
867 868
868 unregister_netdev(netdev); 869 unregister_netdev(netdev);
869#ifdef CONFIG_E1000_NAPI 870#ifdef CONFIG_E1000_NAPI
870 for (i = 0; i < adapter->num_queues; i++) 871 for (i = 0; i < adapter->num_rx_queues; i++)
871 __dev_put(&adapter->polling_netdev[i]); 872 __dev_put(&adapter->polling_netdev[i]);
872#endif 873#endif
873 874
@@ -972,15 +973,25 @@ e1000_sw_init(struct e1000_adapter *adapter)
972 switch (hw->mac_type) { 973 switch (hw->mac_type) {
973 case e1000_82571: 974 case e1000_82571:
974 case e1000_82572: 975 case e1000_82572:
975 adapter->num_queues = 2; 976 /* These controllers support 2 tx queues, but with a single
977 * qdisc implementation, multiple tx queues aren't quite as
978 * interesting. If we can find a logical way of mapping
979 * flows to a queue, then perhaps we can up the num_tx_queue
980 * count back to its default. Until then, we run the risk of
981 * terrible performance due to SACK overload. */
982 adapter->num_tx_queues = 1;
983 adapter->num_rx_queues = 2;
976 break; 984 break;
977 default: 985 default:
978 adapter->num_queues = 1; 986 adapter->num_tx_queues = 1;
987 adapter->num_rx_queues = 1;
979 break; 988 break;
980 } 989 }
981 adapter->num_queues = min(adapter->num_queues, num_online_cpus()); 990 adapter->num_rx_queues = min(adapter->num_rx_queues, num_online_cpus());
991 adapter->num_tx_queues = min(adapter->num_tx_queues, num_online_cpus());
982#else 992#else
983 adapter->num_queues = 1; 993 adapter->num_tx_queues = 1;
994 adapter->num_rx_queues = 1;
984#endif 995#endif
985 996
986 if (e1000_alloc_queues(adapter)) { 997 if (e1000_alloc_queues(adapter)) {
@@ -989,7 +1000,7 @@ e1000_sw_init(struct e1000_adapter *adapter)
989 } 1000 }
990 1001
991#ifdef CONFIG_E1000_NAPI 1002#ifdef CONFIG_E1000_NAPI
992 for (i = 0; i < adapter->num_queues; i++) { 1003 for (i = 0; i < adapter->num_rx_queues; i++) {
993 adapter->polling_netdev[i].priv = adapter; 1004 adapter->polling_netdev[i].priv = adapter;
994 adapter->polling_netdev[i].poll = &e1000_clean; 1005 adapter->polling_netdev[i].poll = &e1000_clean;
995 adapter->polling_netdev[i].weight = 64; 1006 adapter->polling_netdev[i].weight = 64;
@@ -1022,13 +1033,13 @@ e1000_alloc_queues(struct e1000_adapter *adapter)
1022{ 1033{
1023 int size; 1034 int size;
1024 1035
1025 size = sizeof(struct e1000_tx_ring) * adapter->num_queues; 1036 size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues;
1026 adapter->tx_ring = kmalloc(size, GFP_KERNEL); 1037 adapter->tx_ring = kmalloc(size, GFP_KERNEL);
1027 if (!adapter->tx_ring) 1038 if (!adapter->tx_ring)
1028 return -ENOMEM; 1039 return -ENOMEM;
1029 memset(adapter->tx_ring, 0, size); 1040 memset(adapter->tx_ring, 0, size);
1030 1041
1031 size = sizeof(struct e1000_rx_ring) * adapter->num_queues; 1042 size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues;
1032 adapter->rx_ring = kmalloc(size, GFP_KERNEL); 1043 adapter->rx_ring = kmalloc(size, GFP_KERNEL);
1033 if (!adapter->rx_ring) { 1044 if (!adapter->rx_ring) {
1034 kfree(adapter->tx_ring); 1045 kfree(adapter->tx_ring);
@@ -1037,7 +1048,7 @@ e1000_alloc_queues(struct e1000_adapter *adapter)
1037 memset(adapter->rx_ring, 0, size); 1048 memset(adapter->rx_ring, 0, size);
1038 1049
1039#ifdef CONFIG_E1000_NAPI 1050#ifdef CONFIG_E1000_NAPI
1040 size = sizeof(struct net_device) * adapter->num_queues; 1051 size = sizeof(struct net_device) * adapter->num_rx_queues;
1041 adapter->polling_netdev = kmalloc(size, GFP_KERNEL); 1052 adapter->polling_netdev = kmalloc(size, GFP_KERNEL);
1042 if (!adapter->polling_netdev) { 1053 if (!adapter->polling_netdev) {
1043 kfree(adapter->tx_ring); 1054 kfree(adapter->tx_ring);
@@ -1066,12 +1077,12 @@ e1000_setup_queue_mapping(struct e1000_adapter *adapter)
1066 lock_cpu_hotplug(); 1077 lock_cpu_hotplug();
1067 i = 0; 1078 i = 0;
1068 for_each_online_cpu(cpu) { 1079 for_each_online_cpu(cpu) {
1069 *per_cpu_ptr(adapter->cpu_tx_ring, cpu) = &adapter->tx_ring[i % adapter->num_queues]; 1080 *per_cpu_ptr(adapter->cpu_tx_ring, cpu) = &adapter->tx_ring[i % adapter->num_tx_queues];
1070 /* This is incomplete because we'd like to assign separate 1081 /* This is incomplete because we'd like to assign separate
1071 * physical cpus to these netdev polling structures and 1082 * physical cpus to these netdev polling structures and
1072 * avoid saturating a subset of cpus. 1083 * avoid saturating a subset of cpus.
1073 */ 1084 */
1074 if (i < adapter->num_queues) { 1085 if (i < adapter->num_rx_queues) {
1075 *per_cpu_ptr(adapter->cpu_netdev, cpu) = &adapter->polling_netdev[i]; 1086 *per_cpu_ptr(adapter->cpu_netdev, cpu) = &adapter->polling_netdev[i];
1076 adapter->cpu_for_queue[i] = cpu; 1087 adapter->cpu_for_queue[i] = cpu;
1077 } else 1088 } else
@@ -1291,7 +1302,7 @@ e1000_setup_all_tx_resources(struct e1000_adapter *adapter)
1291{ 1302{
1292 int i, err = 0; 1303 int i, err = 0;
1293 1304
1294 for (i = 0; i < adapter->num_queues; i++) { 1305 for (i = 0; i < adapter->num_tx_queues; i++) {
1295 err = e1000_setup_tx_resources(adapter, &adapter->tx_ring[i]); 1306 err = e1000_setup_tx_resources(adapter, &adapter->tx_ring[i]);
1296 if (err) { 1307 if (err) {
1297 DPRINTK(PROBE, ERR, 1308 DPRINTK(PROBE, ERR,
@@ -1319,7 +1330,7 @@ e1000_configure_tx(struct e1000_adapter *adapter)
1319 1330
1320 /* Setup the HW Tx Head and Tail descriptor pointers */ 1331 /* Setup the HW Tx Head and Tail descriptor pointers */
1321 1332
1322 switch (adapter->num_queues) { 1333 switch (adapter->num_tx_queues) {
1323 case 2: 1334 case 2:
1324 tdba = adapter->tx_ring[1].dma; 1335 tdba = adapter->tx_ring[1].dma;
1325 tdlen = adapter->tx_ring[1].count * 1336 tdlen = adapter->tx_ring[1].count *
@@ -1537,7 +1548,7 @@ e1000_setup_all_rx_resources(struct e1000_adapter *adapter)
1537{ 1548{
1538 int i, err = 0; 1549 int i, err = 0;
1539 1550
1540 for (i = 0; i < adapter->num_queues; i++) { 1551 for (i = 0; i < adapter->num_rx_queues; i++) {
1541 err = e1000_setup_rx_resources(adapter, &adapter->rx_ring[i]); 1552 err = e1000_setup_rx_resources(adapter, &adapter->rx_ring[i]);
1542 if (err) { 1553 if (err) {
1543 DPRINTK(PROBE, ERR, 1554 DPRINTK(PROBE, ERR,
@@ -1709,7 +1720,7 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1709 1720
1710 /* Setup the HW Rx Head and Tail Descriptor Pointers and 1721 /* Setup the HW Rx Head and Tail Descriptor Pointers and
1711 * the Base and Length of the Rx Descriptor Ring */ 1722 * the Base and Length of the Rx Descriptor Ring */
1712 switch (adapter->num_queues) { 1723 switch (adapter->num_rx_queues) {
1713#ifdef CONFIG_E1000_MQ 1724#ifdef CONFIG_E1000_MQ
1714 case 2: 1725 case 2:
1715 rdba = adapter->rx_ring[1].dma; 1726 rdba = adapter->rx_ring[1].dma;
@@ -1736,7 +1747,7 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1736 } 1747 }
1737 1748
1738#ifdef CONFIG_E1000_MQ 1749#ifdef CONFIG_E1000_MQ
1739 if (adapter->num_queues > 1) { 1750 if (adapter->num_rx_queues > 1) {
1740 uint32_t random[10]; 1751 uint32_t random[10];
1741 1752
1742 get_random_bytes(&random[0], 40); 1753 get_random_bytes(&random[0], 40);
@@ -1746,7 +1757,7 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1746 E1000_WRITE_REG(hw, RSSIM, 0); 1757 E1000_WRITE_REG(hw, RSSIM, 0);
1747 } 1758 }
1748 1759
1749 switch (adapter->num_queues) { 1760 switch (adapter->num_rx_queues) {
1750 case 2: 1761 case 2:
1751 default: 1762 default:
1752 reta = 0x00800080; 1763 reta = 0x00800080;
@@ -1838,7 +1849,7 @@ e1000_free_all_tx_resources(struct e1000_adapter *adapter)
1838{ 1849{
1839 int i; 1850 int i;
1840 1851
1841 for (i = 0; i < adapter->num_queues; i++) 1852 for (i = 0; i < adapter->num_tx_queues; i++)
1842 e1000_free_tx_resources(adapter, &adapter->tx_ring[i]); 1853 e1000_free_tx_resources(adapter, &adapter->tx_ring[i]);
1843} 1854}
1844 1855
@@ -1905,7 +1916,7 @@ e1000_clean_all_tx_rings(struct e1000_adapter *adapter)
1905{ 1916{
1906 int i; 1917 int i;
1907 1918
1908 for (i = 0; i < adapter->num_queues; i++) 1919 for (i = 0; i < adapter->num_tx_queues; i++)
1909 e1000_clean_tx_ring(adapter, &adapter->tx_ring[i]); 1920 e1000_clean_tx_ring(adapter, &adapter->tx_ring[i]);
1910} 1921}
1911 1922
@@ -1949,7 +1960,7 @@ e1000_free_all_rx_resources(struct e1000_adapter *adapter)
1949{ 1960{
1950 int i; 1961 int i;
1951 1962
1952 for (i = 0; i < adapter->num_queues; i++) 1963 for (i = 0; i < adapter->num_rx_queues; i++)
1953 e1000_free_rx_resources(adapter, &adapter->rx_ring[i]); 1964 e1000_free_rx_resources(adapter, &adapter->rx_ring[i]);
1954} 1965}
1955 1966
@@ -2025,7 +2036,7 @@ e1000_clean_all_rx_rings(struct e1000_adapter *adapter)
2025{ 2036{
2026 int i; 2037 int i;
2027 2038
2028 for (i = 0; i < adapter->num_queues; i++) 2039 for (i = 0; i < adapter->num_rx_queues; i++)
2029 e1000_clean_rx_ring(adapter, &adapter->rx_ring[i]); 2040 e1000_clean_rx_ring(adapter, &adapter->rx_ring[i]);
2030} 2041}
2031 2042
@@ -2325,7 +2336,10 @@ e1000_watchdog_task(struct e1000_adapter *adapter)
2325 2336
2326 e1000_update_adaptive(&adapter->hw); 2337 e1000_update_adaptive(&adapter->hw);
2327 2338
2328 if (adapter->num_queues == 1 && !netif_carrier_ok(netdev)) { 2339#ifdef CONFIG_E1000_MQ
2340 txdr = *per_cpu_ptr(adapter->cpu_tx_ring, smp_processor_id());
2341#endif
2342 if (!netif_carrier_ok(netdev)) {
2329 if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) { 2343 if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) {
2330 /* We've lost link, so the controller stops DMA, 2344 /* We've lost link, so the controller stops DMA,
2331 * but we've got queued Tx work that's never going 2345 * but we've got queued Tx work that's never going
@@ -3197,14 +3211,12 @@ e1000_intr(int irq, void *data, struct pt_regs *regs)
3197 E1000_WRITE_FLUSH(hw); 3211 E1000_WRITE_FLUSH(hw);
3198#ifdef CONFIG_E1000_MQ 3212#ifdef CONFIG_E1000_MQ
3199 if (atomic_read(&adapter->rx_sched_call_data.count) == 0) { 3213 if (atomic_read(&adapter->rx_sched_call_data.count) == 0) {
3200 cpu_set(adapter->cpu_for_queue[0], 3214 /* We must setup the cpumask once count == 0 since
3201 adapter->rx_sched_call_data.cpumask); 3215 * each cpu bit is cleared when the work is done. */
3202 for (i = 1; i < adapter->num_queues; i++) { 3216 adapter->rx_sched_call_data.cpumask = adapter->cpumask;
3203 cpu_set(adapter->cpu_for_queue[i], 3217 atomic_add(adapter->num_rx_queues - 1, &adapter->irq_sem);
3204 adapter->rx_sched_call_data.cpumask); 3218 atomic_set(&adapter->rx_sched_call_data.count,
3205 atomic_inc(&adapter->irq_sem); 3219 adapter->num_rx_queues);
3206 }
3207 atomic_set(&adapter->rx_sched_call_data.count, i);
3208 smp_call_async_mask(&adapter->rx_sched_call_data); 3220 smp_call_async_mask(&adapter->rx_sched_call_data);
3209 } else { 3221 } else {
3210 printk("call_data.count == %u\n", atomic_read(&adapter->rx_sched_call_data.count)); 3222 printk("call_data.count == %u\n", atomic_read(&adapter->rx_sched_call_data.count));
@@ -3267,7 +3279,7 @@ e1000_clean(struct net_device *poll_dev, int *budget)
3267 3279
3268 while (poll_dev != &adapter->polling_netdev[i]) { 3280 while (poll_dev != &adapter->polling_netdev[i]) {
3269 i++; 3281 i++;
3270 if (unlikely(i == adapter->num_queues)) 3282 if (unlikely(i == adapter->num_rx_queues))
3271 BUG(); 3283 BUG();
3272 } 3284 }
3273 3285