netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/3] net: bcmgenet: cleanup for bcmgenet_xmit()
@ 2016-04-05  0:09 Petri Gynther
  2016-04-05  0:10 ` [PATCH net-next 2/3] net: bcmgenet: cleanup for bcmgenet_xmit_frag() Petri Gynther
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Petri Gynther @ 2016-04-05  0:09 UTC (permalink / raw)
  To: netdev; +Cc: davem, f.fainelli, jaedon.shin, Petri Gynther

1. Readability: Move nr_frags assignment a few lines down in order
   to bundle index -> ring -> txq calculations together.
2. Readability: Add parentheses around nr_frags + 1.
3. Minor fix: Stop the Tx queue and throw the error message only if
   the Tx queue hasn't already been stopped.

Signed-off-by: Petri Gynther <pgynther@google.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index cf6445d..7f85a84 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1447,15 +1447,19 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
 	else
 		index -= 1;
 
-	nr_frags = skb_shinfo(skb)->nr_frags;
 	ring = &priv->tx_rings[index];
 	txq = netdev_get_tx_queue(dev, ring->queue);
 
+	nr_frags = skb_shinfo(skb)->nr_frags;
+
 	spin_lock_irqsave(&ring->lock, flags);
-	if (ring->free_bds <= nr_frags + 1) {
-		netif_tx_stop_queue(txq);
-		netdev_err(dev, "%s: tx ring %d full when queue %d awake\n",
-			   __func__, index, ring->queue);
+	if (ring->free_bds <= (nr_frags + 1)) {
+		if (!netif_tx_queue_stopped(txq)) {
+			netif_tx_stop_queue(txq);
+			netdev_err(dev,
+				   "%s: tx ring %d full when queue %d awake\n",
+				   __func__, index, ring->queue);
+		}
 		ret = NETDEV_TX_BUSY;
 		goto out;
 	}
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-04-06 20:09 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-05  0:09 [PATCH net-next 1/3] net: bcmgenet: cleanup for bcmgenet_xmit() Petri Gynther
2016-04-05  0:10 ` [PATCH net-next 2/3] net: bcmgenet: cleanup for bcmgenet_xmit_frag() Petri Gynther
2016-04-05  1:00   ` Florian Fainelli
2016-04-06 20:09   ` David Miller
2016-04-05  0:10 ` [PATCH net-next 3/3] net: bcmgenet: fix dmadesc_set() Petri Gynther
2016-04-05  0:58   ` Florian Fainelli
2016-04-05  1:11     ` Petri Gynther
2016-04-05  1:27       ` Florian Fainelli
2016-04-06 20:09   ` David Miller
2016-04-05  0:58 ` [PATCH net-next 1/3] net: bcmgenet: cleanup for bcmgenet_xmit() Florian Fainelli
2016-04-06  8:57 ` David Laight
2016-04-06 19:09   ` Petri Gynther
2016-04-06 20:09 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).