aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/igb/igb_main.c
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2009-03-19 20:16:50 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-21 19:57:01 -0400
commitc493ea45a4251869fe7b820e0486b73b57df7c12 (patch)
treebf389756f06469dd3e15091046b0eace3f06152b /drivers/net/igb/igb_main.c
parentfa4a7ef36ec834fee1719636b30d2f28f4cb0166 (diff)
igb: remove IGB_DESC_UNUSED since it is better handled by a function call
This patch removes IGB_DESC_UNUSED and replaces it with a function call instead in order to cleanup some of the ugliness introduced by the macro. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/igb/igb_main.c')
-rw-r--r--drivers/net/igb/igb_main.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 39ac375487d6..3fd2efa91cb2 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -278,6 +278,17 @@ static char *igb_get_time_str(struct igb_adapter *adapter,
278#endif 278#endif
279 279
280/** 280/**
281 * igb_desc_unused - calculate if we have unused descriptors
282 **/
283static int igb_desc_unused(struct igb_ring *ring)
284{
285 if (ring->next_to_clean > ring->next_to_use)
286 return ring->next_to_clean - ring->next_to_use - 1;
287
288 return ring->count + ring->next_to_clean - ring->next_to_use - 1;
289}
290
291/**
281 * igb_init_module - Driver Registration Routine 292 * igb_init_module - Driver Registration Routine
282 * 293 *
283 * igb_init_module is the first routine called when the driver is 294 * igb_init_module is the first routine called when the driver is
@@ -873,12 +884,12 @@ static void igb_configure(struct igb_adapter *adapter)
873 884
874 igb_rx_fifo_flush_82575(&adapter->hw); 885 igb_rx_fifo_flush_82575(&adapter->hw);
875 886
876 /* call IGB_DESC_UNUSED which always leaves 887 /* call igb_desc_unused which always leaves
877 * at least 1 descriptor unused to make sure 888 * at least 1 descriptor unused to make sure
878 * next_to_use != next_to_clean */ 889 * next_to_use != next_to_clean */
879 for (i = 0; i < adapter->num_rx_queues; i++) { 890 for (i = 0; i < adapter->num_rx_queues; i++) {
880 struct igb_ring *ring = &adapter->rx_ring[i]; 891 struct igb_ring *ring = &adapter->rx_ring[i];
881 igb_alloc_rx_buffers_adv(ring, IGB_DESC_UNUSED(ring)); 892 igb_alloc_rx_buffers_adv(ring, igb_desc_unused(ring));
882 } 893 }
883 894
884 895
@@ -2661,7 +2672,7 @@ link_up:
2661 igb_update_adaptive(&adapter->hw); 2672 igb_update_adaptive(&adapter->hw);
2662 2673
2663 if (!netif_carrier_ok(netdev)) { 2674 if (!netif_carrier_ok(netdev)) {
2664 if (IGB_DESC_UNUSED(tx_ring) + 1 < tx_ring->count) { 2675 if (igb_desc_unused(tx_ring) + 1 < tx_ring->count) {
2665 /* We've lost link, so the controller stops DMA, 2676 /* We've lost link, so the controller stops DMA,
2666 * but we've got queued Tx work that's never going 2677 * but we've got queued Tx work that's never going
2667 * to get done, so reset controller to flush Tx. 2678 * to get done, so reset controller to flush Tx.
@@ -3199,7 +3210,7 @@ static int __igb_maybe_stop_tx(struct net_device *netdev,
3199 3210
3200 /* We need to check again in a case another CPU has just 3211 /* We need to check again in a case another CPU has just
3201 * made room available. */ 3212 * made room available. */
3202 if (IGB_DESC_UNUSED(tx_ring) < size) 3213 if (igb_desc_unused(tx_ring) < size)
3203 return -EBUSY; 3214 return -EBUSY;
3204 3215
3205 /* A reprieve! */ 3216 /* A reprieve! */
@@ -3211,7 +3222,7 @@ static int __igb_maybe_stop_tx(struct net_device *netdev,
3211static int igb_maybe_stop_tx(struct net_device *netdev, 3222static int igb_maybe_stop_tx(struct net_device *netdev,
3212 struct igb_ring *tx_ring, int size) 3223 struct igb_ring *tx_ring, int size)
3213{ 3224{
3214 if (IGB_DESC_UNUSED(tx_ring) >= size) 3225 if (igb_desc_unused(tx_ring) >= size)
3215 return 0; 3226 return 0;
3216 return __igb_maybe_stop_tx(netdev, tx_ring, size); 3227 return __igb_maybe_stop_tx(netdev, tx_ring, size);
3217} 3228}
@@ -4310,7 +4321,7 @@ static bool igb_clean_tx_irq(struct igb_ring *tx_ring)
4310 4321
4311 if (unlikely(count && 4322 if (unlikely(count &&
4312 netif_carrier_ok(netdev) && 4323 netif_carrier_ok(netdev) &&
4313 IGB_DESC_UNUSED(tx_ring) >= IGB_TX_QUEUE_WAKE)) { 4324 igb_desc_unused(tx_ring) >= IGB_TX_QUEUE_WAKE)) {
4314 /* Make sure that anybody stopping the queue after this 4325 /* Make sure that anybody stopping the queue after this
4315 * sees the new next_to_clean. 4326 * sees the new next_to_clean.
4316 */ 4327 */
@@ -4587,7 +4598,7 @@ next_desc:
4587 } 4598 }
4588 4599
4589 rx_ring->next_to_clean = i; 4600 rx_ring->next_to_clean = i;
4590 cleaned_count = IGB_DESC_UNUSED(rx_ring); 4601 cleaned_count = igb_desc_unused(rx_ring);
4591 4602
4592 if (cleaned_count) 4603 if (cleaned_count)
4593 igb_alloc_rx_buffers_adv(rx_ring, cleaned_count); 4604 igb_alloc_rx_buffers_adv(rx_ring, cleaned_count);