aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/igb/igb_main.c
diff options
context:
space:
mode:
authorMitch Williams <mitch.a.williams@intel.com>2008-06-27 13:59:48 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-07-04 08:46:57 -0400
commit3b644cf6cef0324c595b86181220901b5bed0b99 (patch)
tree8b0215d0548e0aea2009e8acbabb0d7f7a965892 /drivers/net/igb/igb_main.c
parent5c3cad754cba4252f5b4e74fb217e3bdd0c03662 (diff)
igb: Remove adapter struct from these function call parameters
Simplify a bunch of calls to these functions by moving the adapter struct out of the function arguments since that is not needed. Signed-off-by: Mitch Williams <mitch.a.williams@intel.com> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/igb/igb_main.c')
-rw-r--r--drivers/net/igb/igb_main.c88
1 files changed, 40 insertions, 48 deletions
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 171d1fc1fbf8..e9acc61dace2 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -71,8 +71,8 @@ static int igb_setup_all_tx_resources(struct igb_adapter *);
71static int igb_setup_all_rx_resources(struct igb_adapter *); 71static int igb_setup_all_rx_resources(struct igb_adapter *);
72static void igb_free_all_tx_resources(struct igb_adapter *); 72static void igb_free_all_tx_resources(struct igb_adapter *);
73static void igb_free_all_rx_resources(struct igb_adapter *); 73static void igb_free_all_rx_resources(struct igb_adapter *);
74static void igb_free_tx_resources(struct igb_adapter *, struct igb_ring *); 74static void igb_free_tx_resources(struct igb_ring *);
75static void igb_free_rx_resources(struct igb_adapter *, struct igb_ring *); 75static void igb_free_rx_resources(struct igb_ring *);
76void igb_update_stats(struct igb_adapter *); 76void igb_update_stats(struct igb_adapter *);
77static int igb_probe(struct pci_dev *, const struct pci_device_id *); 77static int igb_probe(struct pci_dev *, const struct pci_device_id *);
78static void __devexit igb_remove(struct pci_dev *pdev); 78static void __devexit igb_remove(struct pci_dev *pdev);
@@ -84,8 +84,8 @@ static void igb_configure_rx(struct igb_adapter *);
84static void igb_setup_rctl(struct igb_adapter *); 84static void igb_setup_rctl(struct igb_adapter *);
85static void igb_clean_all_tx_rings(struct igb_adapter *); 85static void igb_clean_all_tx_rings(struct igb_adapter *);
86static void igb_clean_all_rx_rings(struct igb_adapter *); 86static void igb_clean_all_rx_rings(struct igb_adapter *);
87static void igb_clean_tx_ring(struct igb_adapter *, struct igb_ring *); 87static void igb_clean_tx_ring(struct igb_ring *);
88static void igb_clean_rx_ring(struct igb_adapter *, struct igb_ring *); 88static void igb_clean_rx_ring(struct igb_ring *);
89static void igb_set_multi(struct net_device *); 89static void igb_set_multi(struct net_device *);
90static void igb_update_phy_info(unsigned long); 90static void igb_update_phy_info(unsigned long);
91static void igb_watchdog(unsigned long); 91static void igb_watchdog(unsigned long);
@@ -102,12 +102,10 @@ static irqreturn_t igb_msix_other(int irq, void *);
102static irqreturn_t igb_msix_rx(int irq, void *); 102static irqreturn_t igb_msix_rx(int irq, void *);
103static irqreturn_t igb_msix_tx(int irq, void *); 103static irqreturn_t igb_msix_tx(int irq, void *);
104static int igb_clean_rx_ring_msix(struct napi_struct *, int); 104static int igb_clean_rx_ring_msix(struct napi_struct *, int);
105static bool igb_clean_tx_irq(struct igb_adapter *, struct igb_ring *); 105static bool igb_clean_tx_irq(struct igb_ring *);
106static int igb_clean(struct napi_struct *, int); 106static int igb_clean(struct napi_struct *, int);
107static bool igb_clean_rx_irq_adv(struct igb_adapter *, 107static bool igb_clean_rx_irq_adv(struct igb_ring *, int *, int);
108 struct igb_ring *, int *, int); 108static void igb_alloc_rx_buffers_adv(struct igb_ring *, int);
109static void igb_alloc_rx_buffers_adv(struct igb_adapter *,
110 struct igb_ring *, int);
111static int igb_ioctl(struct net_device *, struct ifreq *, int cmd); 109static int igb_ioctl(struct net_device *, struct ifreq *, int cmd);
112static void igb_tx_timeout(struct net_device *); 110static void igb_tx_timeout(struct net_device *);
113static void igb_reset_task(struct work_struct *); 111static void igb_reset_task(struct work_struct *);
@@ -637,7 +635,7 @@ static void igb_configure(struct igb_adapter *adapter)
637 * next_to_use != next_to_clean */ 635 * next_to_use != next_to_clean */
638 for (i = 0; i < adapter->num_rx_queues; i++) { 636 for (i = 0; i < adapter->num_rx_queues; i++) {
639 struct igb_ring *ring = &adapter->rx_ring[i]; 637 struct igb_ring *ring = &adapter->rx_ring[i];
640 igb_alloc_rx_buffers_adv(adapter, ring, IGB_DESC_UNUSED(ring)); 638 igb_alloc_rx_buffers_adv(ring, IGB_DESC_UNUSED(ring));
641 } 639 }
642 640
643 641
@@ -1423,8 +1421,7 @@ static int igb_setup_all_tx_resources(struct igb_adapter *adapter)
1423 dev_err(&adapter->pdev->dev, 1421 dev_err(&adapter->pdev->dev,
1424 "Allocation for Tx Queue %u failed\n", i); 1422 "Allocation for Tx Queue %u failed\n", i);
1425 for (i--; i >= 0; i--) 1423 for (i--; i >= 0; i--)
1426 igb_free_tx_resources(adapter, 1424 igb_free_tx_resources(&adapter->tx_ring[i]);
1427 &adapter->tx_ring[i]);
1428 break; 1425 break;
1429 } 1426 }
1430 } 1427 }
@@ -1567,8 +1564,7 @@ static int igb_setup_all_rx_resources(struct igb_adapter *adapter)
1567 dev_err(&adapter->pdev->dev, 1564 dev_err(&adapter->pdev->dev,
1568 "Allocation for Rx Queue %u failed\n", i); 1565 "Allocation for Rx Queue %u failed\n", i);
1569 for (i--; i >= 0; i--) 1566 for (i--; i >= 0; i--)
1570 igb_free_rx_resources(adapter, 1567 igb_free_rx_resources(&adapter->rx_ring[i]);
1571 &adapter->rx_ring[i]);
1572 break; 1568 break;
1573 } 1569 }
1574 } 1570 }
@@ -1796,12 +1792,11 @@ static void igb_configure_rx(struct igb_adapter *adapter)
1796 * 1792 *
1797 * Free all transmit software resources 1793 * Free all transmit software resources
1798 **/ 1794 **/
1799static void igb_free_tx_resources(struct igb_adapter *adapter, 1795static void igb_free_tx_resources(struct igb_ring *tx_ring)
1800 struct igb_ring *tx_ring)
1801{ 1796{
1802 struct pci_dev *pdev = adapter->pdev; 1797 struct pci_dev *pdev = tx_ring->adapter->pdev;
1803 1798
1804 igb_clean_tx_ring(adapter, tx_ring); 1799 igb_clean_tx_ring(tx_ring);
1805 1800
1806 vfree(tx_ring->buffer_info); 1801 vfree(tx_ring->buffer_info);
1807 tx_ring->buffer_info = NULL; 1802 tx_ring->buffer_info = NULL;
@@ -1822,7 +1817,7 @@ static void igb_free_all_tx_resources(struct igb_adapter *adapter)
1822 int i; 1817 int i;
1823 1818
1824 for (i = 0; i < adapter->num_tx_queues; i++) 1819 for (i = 0; i < adapter->num_tx_queues; i++)
1825 igb_free_tx_resources(adapter, &adapter->tx_ring[i]); 1820 igb_free_tx_resources(&adapter->tx_ring[i]);
1826} 1821}
1827 1822
1828static void igb_unmap_and_free_tx_resource(struct igb_adapter *adapter, 1823static void igb_unmap_and_free_tx_resource(struct igb_adapter *adapter,
@@ -1848,9 +1843,9 @@ static void igb_unmap_and_free_tx_resource(struct igb_adapter *adapter,
1848 * @adapter: board private structure 1843 * @adapter: board private structure
1849 * @tx_ring: ring to be cleaned 1844 * @tx_ring: ring to be cleaned
1850 **/ 1845 **/
1851static void igb_clean_tx_ring(struct igb_adapter *adapter, 1846static void igb_clean_tx_ring(struct igb_ring *tx_ring)
1852 struct igb_ring *tx_ring)
1853{ 1847{
1848 struct igb_adapter *adapter = tx_ring->adapter;
1854 struct igb_buffer *buffer_info; 1849 struct igb_buffer *buffer_info;
1855 unsigned long size; 1850 unsigned long size;
1856 unsigned int i; 1851 unsigned int i;
@@ -1887,7 +1882,7 @@ static void igb_clean_all_tx_rings(struct igb_adapter *adapter)
1887 int i; 1882 int i;
1888 1883
1889 for (i = 0; i < adapter->num_tx_queues; i++) 1884 for (i = 0; i < adapter->num_tx_queues; i++)
1890 igb_clean_tx_ring(adapter, &adapter->tx_ring[i]); 1885 igb_clean_tx_ring(&adapter->tx_ring[i]);
1891} 1886}
1892 1887
1893/** 1888/**
@@ -1897,12 +1892,11 @@ static void igb_clean_all_tx_rings(struct igb_adapter *adapter)
1897 * 1892 *
1898 * Free all receive software resources 1893 * Free all receive software resources
1899 **/ 1894 **/
1900static void igb_free_rx_resources(struct igb_adapter *adapter, 1895static void igb_free_rx_resources(struct igb_ring *rx_ring)
1901 struct igb_ring *rx_ring)
1902{ 1896{
1903 struct pci_dev *pdev = adapter->pdev; 1897 struct pci_dev *pdev = rx_ring->adapter->pdev;
1904 1898
1905 igb_clean_rx_ring(adapter, rx_ring); 1899 igb_clean_rx_ring(rx_ring);
1906 1900
1907 vfree(rx_ring->buffer_info); 1901 vfree(rx_ring->buffer_info);
1908 rx_ring->buffer_info = NULL; 1902 rx_ring->buffer_info = NULL;
@@ -1923,7 +1917,7 @@ static void igb_free_all_rx_resources(struct igb_adapter *adapter)
1923 int i; 1917 int i;
1924 1918
1925 for (i = 0; i < adapter->num_rx_queues; i++) 1919 for (i = 0; i < adapter->num_rx_queues; i++)
1926 igb_free_rx_resources(adapter, &adapter->rx_ring[i]); 1920 igb_free_rx_resources(&adapter->rx_ring[i]);
1927} 1921}
1928 1922
1929/** 1923/**
@@ -1931,9 +1925,9 @@ static void igb_free_all_rx_resources(struct igb_adapter *adapter)
1931 * @adapter: board private structure 1925 * @adapter: board private structure
1932 * @rx_ring: ring to free buffers from 1926 * @rx_ring: ring to free buffers from
1933 **/ 1927 **/
1934static void igb_clean_rx_ring(struct igb_adapter *adapter, 1928static void igb_clean_rx_ring(struct igb_ring *rx_ring)
1935 struct igb_ring *rx_ring)
1936{ 1929{
1930 struct igb_adapter *adapter = rx_ring->adapter;
1937 struct igb_buffer *buffer_info; 1931 struct igb_buffer *buffer_info;
1938 struct pci_dev *pdev = adapter->pdev; 1932 struct pci_dev *pdev = adapter->pdev;
1939 unsigned long size; 1933 unsigned long size;
@@ -1997,7 +1991,7 @@ static void igb_clean_all_rx_rings(struct igb_adapter *adapter)
1997 int i; 1991 int i;
1998 1992
1999 for (i = 0; i < adapter->num_rx_queues; i++) 1993 for (i = 0; i < adapter->num_rx_queues; i++)
2000 igb_clean_rx_ring(adapter, &adapter->rx_ring[i]); 1994 igb_clean_rx_ring(&adapter->rx_ring[i]);
2001} 1995}
2002 1996
2003/** 1997/**
@@ -3076,7 +3070,7 @@ static irqreturn_t igb_msix_tx(int irq, void *data)
3076 3070
3077 tx_ring->total_bytes = 0; 3071 tx_ring->total_bytes = 0;
3078 tx_ring->total_packets = 0; 3072 tx_ring->total_packets = 0;
3079 if (!igb_clean_tx_irq(adapter, tx_ring)) 3073 if (!igb_clean_tx_irq(tx_ring))
3080 /* Ring was not completely cleaned, so fire another interrupt */ 3074 /* Ring was not completely cleaned, so fire another interrupt */
3081 wr32(E1000_EICS, tx_ring->eims_value); 3075 wr32(E1000_EICS, tx_ring->eims_value);
3082 3076
@@ -3227,14 +3221,13 @@ static int igb_clean(struct napi_struct *napi, int budget)
3227 * the lock means tx_ring[i] is currently being cleaned anyway. */ 3221 * the lock means tx_ring[i] is currently being cleaned anyway. */
3228 for (i = 0; i < adapter->num_tx_queues; i++) { 3222 for (i = 0; i < adapter->num_tx_queues; i++) {
3229 if (spin_trylock(&adapter->tx_ring[i].tx_clean_lock)) { 3223 if (spin_trylock(&adapter->tx_ring[i].tx_clean_lock)) {
3230 tx_clean_complete &= igb_clean_tx_irq(adapter, 3224 tx_clean_complete &= igb_clean_tx_irq(&adapter->tx_ring[i]);
3231 &adapter->tx_ring[i]);
3232 spin_unlock(&adapter->tx_ring[i].tx_clean_lock); 3225 spin_unlock(&adapter->tx_ring[i].tx_clean_lock);
3233 } 3226 }
3234 } 3227 }
3235 3228
3236 for (i = 0; i < adapter->num_rx_queues; i++) 3229 for (i = 0; i < adapter->num_rx_queues; i++)
3237 igb_clean_rx_irq_adv(adapter, &adapter->rx_ring[i], &work_done, 3230 igb_clean_rx_irq_adv(&adapter->rx_ring[i], &work_done,
3238 adapter->rx_ring[i].napi.weight); 3231 adapter->rx_ring[i].napi.weight);
3239 3232
3240 /* If no Tx and not enough Rx work done, exit the polling mode */ 3233 /* If no Tx and not enough Rx work done, exit the polling mode */
@@ -3264,7 +3257,7 @@ static int igb_clean_rx_ring_msix(struct napi_struct *napi, int budget)
3264 if (!netif_carrier_ok(netdev)) 3257 if (!netif_carrier_ok(netdev))
3265 goto quit_polling; 3258 goto quit_polling;
3266 3259
3267 igb_clean_rx_irq_adv(adapter, rx_ring, &work_done, budget); 3260 igb_clean_rx_irq_adv(rx_ring, &work_done, budget);
3268 3261
3269 3262
3270 /* If not enough Rx work done, exit the polling mode */ 3263 /* If not enough Rx work done, exit the polling mode */
@@ -3299,11 +3292,11 @@ static inline u32 get_head(struct igb_ring *tx_ring)
3299 * @adapter: board private structure 3292 * @adapter: board private structure
3300 * returns true if ring is completely cleaned 3293 * returns true if ring is completely cleaned
3301 **/ 3294 **/
3302static bool igb_clean_tx_irq(struct igb_adapter *adapter, 3295static bool igb_clean_tx_irq(struct igb_ring *tx_ring)
3303 struct igb_ring *tx_ring)
3304{ 3296{
3305 struct net_device *netdev = adapter->netdev; 3297 struct igb_adapter *adapter = tx_ring->adapter;
3306 struct e1000_hw *hw = &adapter->hw; 3298 struct e1000_hw *hw = &adapter->hw;
3299 struct net_device *netdev = adapter->netdev;
3307 struct e1000_tx_desc *tx_desc; 3300 struct e1000_tx_desc *tx_desc;
3308 struct igb_buffer *buffer_info; 3301 struct igb_buffer *buffer_info;
3309 struct sk_buff *skb; 3302 struct sk_buff *skb;
@@ -3458,10 +3451,10 @@ static inline void igb_rx_checksum_adv(struct igb_adapter *adapter,
3458 adapter->hw_csum_good++; 3451 adapter->hw_csum_good++;
3459} 3452}
3460 3453
3461static bool igb_clean_rx_irq_adv(struct igb_adapter *adapter, 3454static bool igb_clean_rx_irq_adv(struct igb_ring *rx_ring,
3462 struct igb_ring *rx_ring, 3455 int *work_done, int budget)
3463 int *work_done, int budget)
3464{ 3456{
3457 struct igb_adapter *adapter = rx_ring->adapter;
3465 struct net_device *netdev = adapter->netdev; 3458 struct net_device *netdev = adapter->netdev;
3466 struct pci_dev *pdev = adapter->pdev; 3459 struct pci_dev *pdev = adapter->pdev;
3467 union e1000_adv_rx_desc *rx_desc , *next_rxd; 3460 union e1000_adv_rx_desc *rx_desc , *next_rxd;
@@ -3584,8 +3577,7 @@ next_desc:
3584 3577
3585 /* return some buffers to hardware, one at a time is too slow */ 3578 /* return some buffers to hardware, one at a time is too slow */
3586 if (cleaned_count >= IGB_RX_BUFFER_WRITE) { 3579 if (cleaned_count >= IGB_RX_BUFFER_WRITE) {
3587 igb_alloc_rx_buffers_adv(adapter, rx_ring, 3580 igb_alloc_rx_buffers_adv(rx_ring, cleaned_count);
3588 cleaned_count);
3589 cleaned_count = 0; 3581 cleaned_count = 0;
3590 } 3582 }
3591 3583
@@ -3600,7 +3592,7 @@ out:
3600 cleaned_count = IGB_DESC_UNUSED(rx_ring); 3592 cleaned_count = IGB_DESC_UNUSED(rx_ring);
3601 3593
3602 if (cleaned_count) 3594 if (cleaned_count)
3603 igb_alloc_rx_buffers_adv(adapter, rx_ring, cleaned_count); 3595 igb_alloc_rx_buffers_adv(rx_ring, cleaned_count);
3604 3596
3605 rx_ring->total_packets += total_packets; 3597 rx_ring->total_packets += total_packets;
3606 rx_ring->total_bytes += total_bytes; 3598 rx_ring->total_bytes += total_bytes;
@@ -3616,10 +3608,10 @@ out:
3616 * igb_alloc_rx_buffers_adv - Replace used receive buffers; packet split 3608 * igb_alloc_rx_buffers_adv - Replace used receive buffers; packet split
3617 * @adapter: address of board private structure 3609 * @adapter: address of board private structure
3618 **/ 3610 **/
3619static void igb_alloc_rx_buffers_adv(struct igb_adapter *adapter, 3611static void igb_alloc_rx_buffers_adv(struct igb_ring *rx_ring,
3620 struct igb_ring *rx_ring,
3621 int cleaned_count) 3612 int cleaned_count)
3622{ 3613{
3614 struct igb_adapter *adapter = rx_ring->adapter;
3623 struct net_device *netdev = adapter->netdev; 3615 struct net_device *netdev = adapter->netdev;
3624 struct pci_dev *pdev = adapter->pdev; 3616 struct pci_dev *pdev = adapter->pdev;
3625 union e1000_adv_rx_desc *rx_desc; 3617 union e1000_adv_rx_desc *rx_desc;
@@ -4062,10 +4054,10 @@ static void igb_netpoll(struct net_device *netdev)
4062 4054
4063 igb_irq_disable(adapter); 4055 igb_irq_disable(adapter);
4064 for (i = 0; i < adapter->num_tx_queues; i++) 4056 for (i = 0; i < adapter->num_tx_queues; i++)
4065 igb_clean_tx_irq(adapter, &adapter->tx_ring[i]); 4057 igb_clean_tx_irq(&adapter->tx_ring[i]);
4066 4058
4067 for (i = 0; i < adapter->num_rx_queues; i++) 4059 for (i = 0; i < adapter->num_rx_queues; i++)
4068 igb_clean_rx_irq_adv(adapter, &adapter->rx_ring[i], 4060 igb_clean_rx_irq_adv(&adapter->rx_ring[i],
4069 &work_done, 4061 &work_done,
4070 adapter->rx_ring[i].napi.weight); 4062 adapter->rx_ring[i].napi.weight);
4071 4063