diff options
author | Olof Johansson <olof@lixom.net> | 2007-09-26 17:25:06 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:53:44 -0400 |
commit | 928773c23a4cf053a34ad480439448f75efa350c (patch) | |
tree | 1a3cc4c364616220363bfa794455b09bf48b6724 /drivers/net/pasemi_mac.c | |
parent | 36033766533176d61ba15793d8ef219775499c2f (diff) |
pasemi_mac: pass in count of buffers to replenish rx ring with
pasemi_mac: pass in count of buffers to replenish rx ring with
Refactor replenish_rx_ring to take an argument for how many entries to
fill. Since it's normally available from where it's called anyway, this
is just simpler. It also removes the awkward logic to try to figure out
if we're filling for the first time or not.
Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/pasemi_mac.c')
-rw-r--r-- | drivers/net/pasemi_mac.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c index 643fce860e5c..c2d34a804d40 100644 --- a/drivers/net/pasemi_mac.c +++ b/drivers/net/pasemi_mac.c | |||
@@ -370,23 +370,18 @@ static void pasemi_mac_free_rx_resources(struct net_device *dev) | |||
370 | mac->rx = NULL; | 370 | mac->rx = NULL; |
371 | } | 371 | } |
372 | 372 | ||
373 | static void pasemi_mac_replenish_rx_ring(struct net_device *dev) | 373 | static void pasemi_mac_replenish_rx_ring(struct net_device *dev, int limit) |
374 | { | 374 | { |
375 | struct pasemi_mac *mac = netdev_priv(dev); | 375 | struct pasemi_mac *mac = netdev_priv(dev); |
376 | unsigned int i; | 376 | unsigned int i; |
377 | int start = mac->rx->next_to_fill; | 377 | int start = mac->rx->next_to_fill; |
378 | unsigned int limit, count; | 378 | int count; |
379 | |||
380 | limit = RING_AVAIL(mac->rx); | ||
381 | /* Check to see if we're doing first-time setup */ | ||
382 | if (unlikely(mac->rx->next_to_clean == 0 && mac->rx->next_to_fill == 0)) | ||
383 | limit = RX_RING_SIZE; | ||
384 | 379 | ||
385 | if (limit <= 0) | 380 | if (limit <= 0) |
386 | return; | 381 | return; |
387 | 382 | ||
388 | i = start; | 383 | i = start; |
389 | for (count = limit; count; count--) { | 384 | for (count = 0; count < limit; count++) { |
390 | struct pasemi_mac_buffer *info = &RX_DESC_INFO(mac, i); | 385 | struct pasemi_mac_buffer *info = &RX_DESC_INFO(mac, i); |
391 | u64 *buff = &RX_BUFF(mac, i); | 386 | u64 *buff = &RX_BUFF(mac, i); |
392 | struct sk_buff *skb; | 387 | struct sk_buff *skb; |
@@ -417,10 +412,10 @@ static void pasemi_mac_replenish_rx_ring(struct net_device *dev) | |||
417 | 412 | ||
418 | wmb(); | 413 | wmb(); |
419 | 414 | ||
420 | write_dma_reg(mac, PAS_DMA_RXCHAN_INCR(mac->dma_rxch), limit - count); | 415 | write_dma_reg(mac, PAS_DMA_RXCHAN_INCR(mac->dma_rxch), count); |
421 | write_dma_reg(mac, PAS_DMA_RXINT_INCR(mac->dma_if), limit - count); | 416 | write_dma_reg(mac, PAS_DMA_RXINT_INCR(mac->dma_if), count); |
422 | 417 | ||
423 | mac->rx->next_to_fill += limit - count; | 418 | mac->rx->next_to_fill += count; |
424 | } | 419 | } |
425 | 420 | ||
426 | static void pasemi_mac_restart_rx_intr(struct pasemi_mac *mac) | 421 | static void pasemi_mac_restart_rx_intr(struct pasemi_mac *mac) |
@@ -538,7 +533,7 @@ static int pasemi_mac_clean_rx(struct pasemi_mac *mac, int limit) | |||
538 | } | 533 | } |
539 | 534 | ||
540 | mac->rx->next_to_clean += limit - count; | 535 | mac->rx->next_to_clean += limit - count; |
541 | pasemi_mac_replenish_rx_ring(mac->netdev); | 536 | pasemi_mac_replenish_rx_ring(mac->netdev, limit-count); |
542 | 537 | ||
543 | spin_unlock(&mac->rx->lock); | 538 | spin_unlock(&mac->rx->lock); |
544 | 539 | ||
@@ -825,7 +820,7 @@ static int pasemi_mac_open(struct net_device *dev) | |||
825 | write_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch), | 820 | write_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch), |
826 | PAS_DMA_TXCHAN_TCMDSTA_EN); | 821 | PAS_DMA_TXCHAN_TCMDSTA_EN); |
827 | 822 | ||
828 | pasemi_mac_replenish_rx_ring(dev); | 823 | pasemi_mac_replenish_rx_ring(dev, RX_RING_SIZE); |
829 | 824 | ||
830 | flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PE | | 825 | flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PE | |
831 | PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE; | 826 | PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE; |