aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-29 13:48:48 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-29 13:48:48 -0400
commite389f9aec689209724105ae80a6c91fd2e747bc9 (patch)
tree3cc88a3e785e4f2ffeaa9dad0da695cfa437d4fe /drivers/net/e1000
parentf73b0a08eae0e28c50db5dd5ab8245546918bfb6 (diff)
parentb4cf205846463a0a23a917bb18ad833bc9a8c0bb (diff)
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6: (107 commits) smc911x: fix compilation breakage wjen debug is on [netdrvr] eexpress: minor corrections add NAPI support to sb1250-mac.c ixgb: ROUND_UP macro cleanup in drivers/net/ixgb e1000: ROUND_UP macro cleanup in drivers/net/e1000 Generic HDLC sparse annotations e100: Optionally use I/O mode only to access register space e100: allow bad MAC address when running with invalid eeprom csum ehea: fix for dlpar support ehea: fix for sysfs entries 3C509: Remove unnecessary include of <linux/pm_legacy.h> NetXen: Fix for vmalloc issues NetXen: Fixes for Power PC architecture NetXen: Port swap feature for multi port cards NetXen: Removal of redundant macros NetXen: Multi PCI support for Quad cards NetXen: Removal of redundant argument passing NetXen: Use multiple PCI functions [netdrvr e100] experiment with doing RX in a similar manner to eepro100 [PATCH] ieee80211: add missing global needed by IEEE80211_DEBUG_XXXX ...
Diffstat (limited to 'drivers/net/e1000')
-rw-r--r--drivers/net/e1000/e1000.h3
-rw-r--r--drivers/net/e1000/e1000_ethtool.c34
-rw-r--r--drivers/net/e1000/e1000_main.c45
-rw-r--r--drivers/net/e1000/e1000_param.c4
4 files changed, 38 insertions, 48 deletions
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index dd4b728ac4b5..a9ea67e75c1b 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -155,9 +155,6 @@ struct e1000_adapter;
155/* Number of packet split data buffers (not including the header buffer) */ 155/* Number of packet split data buffers (not including the header buffer) */
156#define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1 156#define PS_PAGE_BUFFERS MAX_PS_BUFFERS-1
157 157
158/* only works for sizes that are powers of 2 */
159#define E1000_ROUNDUP(i, size) ((i) = (((i) + (size) - 1) & ~((size) - 1)))
160
161/* wrapper around a pointer to a socket buffer, 158/* wrapper around a pointer to a socket buffer,
162 * so a DMA handle can be stored along with the buffer */ 159 * so a DMA handle can be stored along with the buffer */
163struct e1000_buffer { 160struct e1000_buffer {
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 6777887295f5..bb08375b5f13 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -654,14 +654,11 @@ e1000_set_ringparam(struct net_device *netdev,
654 e1000_mac_type mac_type = adapter->hw.mac_type; 654 e1000_mac_type mac_type = adapter->hw.mac_type;
655 struct e1000_tx_ring *txdr, *tx_old; 655 struct e1000_tx_ring *txdr, *tx_old;
656 struct e1000_rx_ring *rxdr, *rx_old; 656 struct e1000_rx_ring *rxdr, *rx_old;
657 int i, err, tx_ring_size, rx_ring_size; 657 int i, err;
658 658
659 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 659 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
660 return -EINVAL; 660 return -EINVAL;
661 661
662 tx_ring_size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues;
663 rx_ring_size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues;
664
665 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) 662 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
666 msleep(1); 663 msleep(1);
667 664
@@ -672,11 +669,11 @@ e1000_set_ringparam(struct net_device *netdev,
672 rx_old = adapter->rx_ring; 669 rx_old = adapter->rx_ring;
673 670
674 err = -ENOMEM; 671 err = -ENOMEM;
675 txdr = kzalloc(tx_ring_size, GFP_KERNEL); 672 txdr = kcalloc(adapter->num_tx_queues, sizeof(struct e1000_tx_ring), GFP_KERNEL);
676 if (!txdr) 673 if (!txdr)
677 goto err_alloc_tx; 674 goto err_alloc_tx;
678 675
679 rxdr = kzalloc(rx_ring_size, GFP_KERNEL); 676 rxdr = kcalloc(adapter->num_rx_queues, sizeof(struct e1000_rx_ring), GFP_KERNEL);
680 if (!rxdr) 677 if (!rxdr)
681 goto err_alloc_rx; 678 goto err_alloc_rx;
682 679
@@ -686,12 +683,12 @@ e1000_set_ringparam(struct net_device *netdev,
686 rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD); 683 rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD);
687 rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ? 684 rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ?
688 E1000_MAX_RXD : E1000_MAX_82544_RXD)); 685 E1000_MAX_RXD : E1000_MAX_82544_RXD));
689 E1000_ROUNDUP(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE); 686 rxdr->count = ALIGN(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE);
690 687
691 txdr->count = max(ring->tx_pending,(uint32_t)E1000_MIN_TXD); 688 txdr->count = max(ring->tx_pending,(uint32_t)E1000_MIN_TXD);
692 txdr->count = min(txdr->count,(uint32_t)(mac_type < e1000_82544 ? 689 txdr->count = min(txdr->count,(uint32_t)(mac_type < e1000_82544 ?
693 E1000_MAX_TXD : E1000_MAX_82544_TXD)); 690 E1000_MAX_TXD : E1000_MAX_82544_TXD));
694 E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE); 691 txdr->count = ALIGN(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
695 692
696 for (i = 0; i < adapter->num_tx_queues; i++) 693 for (i = 0; i < adapter->num_tx_queues; i++)
697 txdr[i].count = txdr->count; 694 txdr[i].count = txdr->count;
@@ -742,7 +739,7 @@ err_setup:
742 uint32_t pat, value; \ 739 uint32_t pat, value; \
743 uint32_t test[] = \ 740 uint32_t test[] = \
744 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \ 741 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \
745 for (pat = 0; pat < sizeof(test)/sizeof(test[0]); pat++) { \ 742 for (pat = 0; pat < ARRAY_SIZE(test); pat++) { \
746 E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \ 743 E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \
747 value = E1000_READ_REG(&adapter->hw, R); \ 744 value = E1000_READ_REG(&adapter->hw, R); \
748 if (value != (test[pat] & W & M)) { \ 745 if (value != (test[pat] & W & M)) { \
@@ -1053,23 +1050,24 @@ e1000_setup_desc_rings(struct e1000_adapter *adapter)
1053 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring; 1050 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
1054 struct pci_dev *pdev = adapter->pdev; 1051 struct pci_dev *pdev = adapter->pdev;
1055 uint32_t rctl; 1052 uint32_t rctl;
1056 int size, i, ret_val; 1053 int i, ret_val;
1057 1054
1058 /* Setup Tx descriptor ring and Tx buffers */ 1055 /* Setup Tx descriptor ring and Tx buffers */
1059 1056
1060 if (!txdr->count) 1057 if (!txdr->count)
1061 txdr->count = E1000_DEFAULT_TXD; 1058 txdr->count = E1000_DEFAULT_TXD;
1062 1059
1063 size = txdr->count * sizeof(struct e1000_buffer); 1060 if (!(txdr->buffer_info = kcalloc(txdr->count,
1064 if (!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) { 1061 sizeof(struct e1000_buffer),
1062 GFP_KERNEL))) {
1065 ret_val = 1; 1063 ret_val = 1;
1066 goto err_nomem; 1064 goto err_nomem;
1067 } 1065 }
1068 memset(txdr->buffer_info, 0, size);
1069 1066
1070 txdr->size = txdr->count * sizeof(struct e1000_tx_desc); 1067 txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
1071 E1000_ROUNDUP(txdr->size, 4096); 1068 txdr->size = ALIGN(txdr->size, 4096);
1072 if (!(txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma))) { 1069 if (!(txdr->desc = pci_alloc_consistent(pdev, txdr->size,
1070 &txdr->dma))) {
1073 ret_val = 2; 1071 ret_val = 2;
1074 goto err_nomem; 1072 goto err_nomem;
1075 } 1073 }
@@ -1116,12 +1114,12 @@ e1000_setup_desc_rings(struct e1000_adapter *adapter)
1116 if (!rxdr->count) 1114 if (!rxdr->count)
1117 rxdr->count = E1000_DEFAULT_RXD; 1115 rxdr->count = E1000_DEFAULT_RXD;
1118 1116
1119 size = rxdr->count * sizeof(struct e1000_buffer); 1117 if (!(rxdr->buffer_info = kcalloc(rxdr->count,
1120 if (!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) { 1118 sizeof(struct e1000_buffer),
1119 GFP_KERNEL))) {
1121 ret_val = 4; 1120 ret_val = 4;
1122 goto err_nomem; 1121 goto err_nomem;
1123 } 1122 }
1124 memset(rxdr->buffer_info, 0, size);
1125 1123
1126 rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc); 1124 rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
1127 if (!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) { 1125 if (!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) {
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 9267f16b1b32..3a03a74c0609 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -748,9 +748,9 @@ e1000_reset(struct e1000_adapter *adapter)
748 VLAN_TAG_SIZE; 748 VLAN_TAG_SIZE;
749 min_tx_space = min_rx_space; 749 min_tx_space = min_rx_space;
750 min_tx_space *= 2; 750 min_tx_space *= 2;
751 E1000_ROUNDUP(min_tx_space, 1024); 751 min_tx_space = ALIGN(min_tx_space, 1024);
752 min_tx_space >>= 10; 752 min_tx_space >>= 10;
753 E1000_ROUNDUP(min_rx_space, 1024); 753 min_rx_space = ALIGN(min_rx_space, 1024);
754 min_rx_space >>= 10; 754 min_rx_space >>= 10;
755 755
756 /* If current Tx allocation is less than the min Tx FIFO size, 756 /* If current Tx allocation is less than the min Tx FIFO size,
@@ -1354,31 +1354,27 @@ e1000_sw_init(struct e1000_adapter *adapter)
1354static int __devinit 1354static int __devinit
1355e1000_alloc_queues(struct e1000_adapter *adapter) 1355e1000_alloc_queues(struct e1000_adapter *adapter)
1356{ 1356{
1357 int size; 1357 adapter->tx_ring = kcalloc(adapter->num_tx_queues,
1358 1358 sizeof(struct e1000_tx_ring), GFP_KERNEL);
1359 size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues;
1360 adapter->tx_ring = kmalloc(size, GFP_KERNEL);
1361 if (!adapter->tx_ring) 1359 if (!adapter->tx_ring)
1362 return -ENOMEM; 1360 return -ENOMEM;
1363 memset(adapter->tx_ring, 0, size);
1364 1361
1365 size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues; 1362 adapter->rx_ring = kcalloc(adapter->num_rx_queues,
1366 adapter->rx_ring = kmalloc(size, GFP_KERNEL); 1363 sizeof(struct e1000_rx_ring), GFP_KERNEL);
1367 if (!adapter->rx_ring) { 1364 if (!adapter->rx_ring) {
1368 kfree(adapter->tx_ring); 1365 kfree(adapter->tx_ring);
1369 return -ENOMEM; 1366 return -ENOMEM;
1370 } 1367 }
1371 memset(adapter->rx_ring, 0, size);
1372 1368
1373#ifdef CONFIG_E1000_NAPI 1369#ifdef CONFIG_E1000_NAPI
1374 size = sizeof(struct net_device) * adapter->num_rx_queues; 1370 adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
1375 adapter->polling_netdev = kmalloc(size, GFP_KERNEL); 1371 sizeof(struct net_device),
1372 GFP_KERNEL);
1376 if (!adapter->polling_netdev) { 1373 if (!adapter->polling_netdev) {
1377 kfree(adapter->tx_ring); 1374 kfree(adapter->tx_ring);
1378 kfree(adapter->rx_ring); 1375 kfree(adapter->rx_ring);
1379 return -ENOMEM; 1376 return -ENOMEM;
1380 } 1377 }
1381 memset(adapter->polling_netdev, 0, size);
1382#endif 1378#endif
1383 1379
1384 return E1000_SUCCESS; 1380 return E1000_SUCCESS;
@@ -1560,7 +1556,7 @@ e1000_setup_tx_resources(struct e1000_adapter *adapter,
1560 /* round up to nearest 4K */ 1556 /* round up to nearest 4K */
1561 1557
1562 txdr->size = txdr->count * sizeof(struct e1000_tx_desc); 1558 txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
1563 E1000_ROUNDUP(txdr->size, 4096); 1559 txdr->size = ALIGN(txdr->size, 4096);
1564 1560
1565 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma); 1561 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
1566 if (!txdr->desc) { 1562 if (!txdr->desc) {
@@ -1774,18 +1770,18 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter,
1774 } 1770 }
1775 memset(rxdr->buffer_info, 0, size); 1771 memset(rxdr->buffer_info, 0, size);
1776 1772
1777 size = sizeof(struct e1000_ps_page) * rxdr->count; 1773 rxdr->ps_page = kcalloc(rxdr->count, sizeof(struct e1000_ps_page),
1778 rxdr->ps_page = kmalloc(size, GFP_KERNEL); 1774 GFP_KERNEL);
1779 if (!rxdr->ps_page) { 1775 if (!rxdr->ps_page) {
1780 vfree(rxdr->buffer_info); 1776 vfree(rxdr->buffer_info);
1781 DPRINTK(PROBE, ERR, 1777 DPRINTK(PROBE, ERR,
1782 "Unable to allocate memory for the receive descriptor ring\n"); 1778 "Unable to allocate memory for the receive descriptor ring\n");
1783 return -ENOMEM; 1779 return -ENOMEM;
1784 } 1780 }
1785 memset(rxdr->ps_page, 0, size);
1786 1781
1787 size = sizeof(struct e1000_ps_page_dma) * rxdr->count; 1782 rxdr->ps_page_dma = kcalloc(rxdr->count,
1788 rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL); 1783 sizeof(struct e1000_ps_page_dma),
1784 GFP_KERNEL);
1789 if (!rxdr->ps_page_dma) { 1785 if (!rxdr->ps_page_dma) {
1790 vfree(rxdr->buffer_info); 1786 vfree(rxdr->buffer_info);
1791 kfree(rxdr->ps_page); 1787 kfree(rxdr->ps_page);
@@ -1793,7 +1789,6 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter,
1793 "Unable to allocate memory for the receive descriptor ring\n"); 1789 "Unable to allocate memory for the receive descriptor ring\n");
1794 return -ENOMEM; 1790 return -ENOMEM;
1795 } 1791 }
1796 memset(rxdr->ps_page_dma, 0, size);
1797 1792
1798 if (adapter->hw.mac_type <= e1000_82547_rev_2) 1793 if (adapter->hw.mac_type <= e1000_82547_rev_2)
1799 desc_len = sizeof(struct e1000_rx_desc); 1794 desc_len = sizeof(struct e1000_rx_desc);
@@ -1803,7 +1798,7 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter,
1803 /* Round up to nearest 4K */ 1798 /* Round up to nearest 4K */
1804 1799
1805 rxdr->size = rxdr->count * desc_len; 1800 rxdr->size = rxdr->count * desc_len;
1806 E1000_ROUNDUP(rxdr->size, 4096); 1801 rxdr->size = ALIGN(rxdr->size, 4096);
1807 1802
1808 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); 1803 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
1809 1804
@@ -2667,7 +2662,7 @@ e1000_watchdog(unsigned long data)
2667 2662
2668 netif_carrier_on(netdev); 2663 netif_carrier_on(netdev);
2669 netif_wake_queue(netdev); 2664 netif_wake_queue(netdev);
2670 mod_timer(&adapter->phy_info_timer, jiffies + 2 * HZ); 2665 mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
2671 adapter->smartspeed = 0; 2666 adapter->smartspeed = 0;
2672 } else { 2667 } else {
2673 /* make sure the receive unit is started */ 2668 /* make sure the receive unit is started */
@@ -2684,7 +2679,7 @@ e1000_watchdog(unsigned long data)
2684 DPRINTK(LINK, INFO, "NIC Link is Down\n"); 2679 DPRINTK(LINK, INFO, "NIC Link is Down\n");
2685 netif_carrier_off(netdev); 2680 netif_carrier_off(netdev);
2686 netif_stop_queue(netdev); 2681 netif_stop_queue(netdev);
2687 mod_timer(&adapter->phy_info_timer, jiffies + 2 * HZ); 2682 mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
2688 2683
2689 /* 80003ES2LAN workaround-- 2684 /* 80003ES2LAN workaround--
2690 * For packet buffer work-around on link down event; 2685 * For packet buffer work-around on link down event;
@@ -2736,7 +2731,7 @@ e1000_watchdog(unsigned long data)
2736 e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0); 2731 e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
2737 2732
2738 /* Reset the timer */ 2733 /* Reset the timer */
2739 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 2734 mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ));
2740} 2735}
2741 2736
2742enum latency_range { 2737enum latency_range {
@@ -3175,7 +3170,7 @@ e1000_82547_fifo_workaround(struct e1000_adapter *adapter, struct sk_buff *skb)
3175 uint32_t fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head; 3170 uint32_t fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
3176 uint32_t skb_fifo_len = skb->len + E1000_FIFO_HDR; 3171 uint32_t skb_fifo_len = skb->len + E1000_FIFO_HDR;
3177 3172
3178 E1000_ROUNDUP(skb_fifo_len, E1000_FIFO_HDR); 3173 skb_fifo_len = ALIGN(skb_fifo_len, E1000_FIFO_HDR);
3179 3174
3180 if (adapter->link_duplex != HALF_DUPLEX) 3175 if (adapter->link_duplex != HALF_DUPLEX)
3181 goto no_fifo_stall_required; 3176 goto no_fifo_stall_required;
diff --git a/drivers/net/e1000/e1000_param.c b/drivers/net/e1000/e1000_param.c
index f8862e203ac9..f485874a63f5 100644
--- a/drivers/net/e1000/e1000_param.c
+++ b/drivers/net/e1000/e1000_param.c
@@ -305,7 +305,7 @@ e1000_check_options(struct e1000_adapter *adapter)
305 if (num_TxDescriptors > bd) { 305 if (num_TxDescriptors > bd) {
306 tx_ring->count = TxDescriptors[bd]; 306 tx_ring->count = TxDescriptors[bd];
307 e1000_validate_option(&tx_ring->count, &opt, adapter); 307 e1000_validate_option(&tx_ring->count, &opt, adapter);
308 E1000_ROUNDUP(tx_ring->count, 308 tx_ring->count = ALIGN(tx_ring->count,
309 REQ_TX_DESCRIPTOR_MULTIPLE); 309 REQ_TX_DESCRIPTOR_MULTIPLE);
310 } else { 310 } else {
311 tx_ring->count = opt.def; 311 tx_ring->count = opt.def;
@@ -331,7 +331,7 @@ e1000_check_options(struct e1000_adapter *adapter)
331 if (num_RxDescriptors > bd) { 331 if (num_RxDescriptors > bd) {
332 rx_ring->count = RxDescriptors[bd]; 332 rx_ring->count = RxDescriptors[bd];
333 e1000_validate_option(&rx_ring->count, &opt, adapter); 333 e1000_validate_option(&rx_ring->count, &opt, adapter);
334 E1000_ROUNDUP(rx_ring->count, 334 rx_ring->count = ALIGN(rx_ring->count,
335 REQ_RX_DESCRIPTOR_MULTIPLE); 335 REQ_RX_DESCRIPTOR_MULTIPLE);
336 } else { 336 } else {
337 rx_ring->count = opt.def; 337 rx_ring->count = opt.def;