All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olof Johansson <olof@lixom.net>
To: jgarzik@pobox.com
Cc: netdev@vger.kernel.org
Subject: [PATCH] [6/6] pasemi_mac: pass in count of buffers to replenish rx ring with
Date: Wed, 26 Sep 2007 16:25:06 -0500	[thread overview]
Message-ID: <20070926212506.GG24168@lixom.net> (raw)
In-Reply-To: <20070926212200.GA24168@lixom.net>

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>

Index: k.org/drivers/net/pasemi_mac.c
===================================================================
--- k.org.orig/drivers/net/pasemi_mac.c
+++ k.org/drivers/net/pasemi_mac.c
@@ -375,23 +375,18 @@ static void pasemi_mac_free_rx_resources
 	mac->rx = NULL;
 }
 
-static void pasemi_mac_replenish_rx_ring(struct net_device *dev)
+static void pasemi_mac_replenish_rx_ring(struct net_device *dev, int limit)
 {
 	struct pasemi_mac *mac = netdev_priv(dev);
 	unsigned int i;
 	int start = mac->rx->next_to_fill;
-	unsigned int limit, count;
-
-	limit = RING_AVAIL(mac->rx);
-	/* Check to see if we're doing first-time setup */
-	if (unlikely(mac->rx->next_to_clean == 0 && mac->rx->next_to_fill == 0))
-		limit = RX_RING_SIZE;
+	int count;
 
 	if (limit <= 0)
 		return;
 
 	i = start;
-	for (count = limit; count; count--) {
+	for (count = 0; count < limit; count++) {
 		struct pasemi_mac_buffer *info = &RX_DESC_INFO(mac, i);
 		u64 *buff = &RX_BUFF(mac, i);
 		struct sk_buff *skb;
@@ -422,10 +417,10 @@ static void pasemi_mac_replenish_rx_ring
 
 	wmb();
 
-	write_dma_reg(mac, PAS_DMA_RXCHAN_INCR(mac->dma_rxch), limit - count);
-	write_dma_reg(mac, PAS_DMA_RXINT_INCR(mac->dma_if), limit - count);
+	write_dma_reg(mac, PAS_DMA_RXCHAN_INCR(mac->dma_rxch), count);
+	write_dma_reg(mac, PAS_DMA_RXINT_INCR(mac->dma_if), count);
 
-	mac->rx->next_to_fill += limit - count;
+	mac->rx->next_to_fill += count;
 }
 
 static void pasemi_mac_restart_rx_intr(struct pasemi_mac *mac)
@@ -543,7 +538,7 @@ static int pasemi_mac_clean_rx(struct pa
 	}
 
 	mac->rx->next_to_clean += limit - count;
-	pasemi_mac_replenish_rx_ring(mac->netdev);
+	pasemi_mac_replenish_rx_ring(mac->netdev, limit-count);
 
 	spin_unlock(&mac->rx->lock);
 
@@ -830,7 +825,7 @@ static int pasemi_mac_open(struct net_de
 	write_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch),
 			   PAS_DMA_TXCHAN_TCMDSTA_EN);
 
-	pasemi_mac_replenish_rx_ring(dev);
+	pasemi_mac_replenish_rx_ring(dev, RX_RING_SIZE);
 
 	flags = PAS_MAC_CFG_PCFG_S1 | PAS_MAC_CFG_PCFG_PE |
 		PAS_MAC_CFG_PCFG_PR | PAS_MAC_CFG_PCFG_CE;

  parent reply	other threads:[~2007-09-26 21:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26 21:22 [PATCH] [0/6] Bugfixes for pasemi_mac Olof Johansson
2007-09-26 21:22 ` [PATCH] [1/6] pasemi_mac: fix build break in pasemi_mac_probe() Olof Johansson
2007-09-26 21:22   ` David Miller
2007-09-26 21:23 ` [PATCH] [2/6] pasemi_mac: fix build break in pasemi_mac_clean_rx() Olof Johansson
2007-09-26 21:24   ` David Miller
2007-09-26 21:23 ` [PATCH] [3/6] pasemi_mac: set interface speed correctly on XAUI ports Olof Johansson
2007-09-29  4:45   ` Jeff Garzik
2007-09-26 21:23 ` [PATCH] [5/6] pasemi_mac: flags as passed to spin_*_irqsave() should be unsigned long Olof Johansson
2007-09-26 21:24 ` [PATCH] [5/6] pasemi_mac: don't enable rx before there are buffers on the ring Olof Johansson
2007-09-26 21:25 ` Olof Johansson [this message]
2007-09-26 21:26 ` [PATCH] [0/6] Bugfixes for pasemi_mac David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070926212506.GG24168@lixom.net \
    --to=olof@lixom.net \
    --cc=jgarzik@pobox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.