netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Optimize cxgb3 xmit path (a bit)
@ 2008-01-30  7:00 Krishna Kumar
  2008-01-30  7:05 ` Krishna Kumar2
  2008-01-31  0:04 ` Divy Le Ray
  0 siblings, 2 replies; 3+ messages in thread
From: Krishna Kumar @ 2008-01-30  7:00 UTC (permalink / raw)
  To: jeff; +Cc: netdev, davem, Krishna Kumar

Changes:
	1. Add common code for stopping queue.
	2. No need to call netif_stop_queue followed by netif_wake_queue (and
	   infact a netif_start_queue could have been used instead), instead
	   call stop_queue if required, and remove code under USE_GTS macro.
	3. There is no need to check for netif_queue_stopped, as the network
	   core guarantees that for us (I am sure every driver could remove
	   that check, eg e1000 - I have tested that path a few billion times
	   with about a few hundred thousand qstops but the condition never
	   hit even once).

Thanks,

- KK

Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
---
 sge.c |   35 +++++++++++++++--------------------
 1 files changed, 15 insertions(+), 20 deletions(-)

diff -ruNp a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
--- a/drivers/net/cxgb3/sge.c	2008-01-30 11:42:39.000000000 +0530
+++ b/drivers/net/cxgb3/sge.c	2008-01-30 12:15:28.000000000 +0530
@@ -1059,6 +1059,14 @@ static void write_tx_pkt_wr(struct adapt
 			 htonl(V_WR_TID(q->token)));
 }
 
+static inline void t3_stop_queue(struct net_device *dev, struct sge_qset *qs,
+				 struct sge_txq *q)
+{
+	netif_stop_queue(dev);
+	set_bit(TXQ_ETH, &qs->txq_stopped);
+	q->stops++;
+}
+
 /**
  *	eth_xmit - add a packet to the Ethernet Tx queue
  *	@skb: the packet
@@ -1090,31 +1098,18 @@ int t3_eth_xmit(struct sk_buff *skb, str
 	ndesc = calc_tx_descs(skb);
 
 	if (unlikely(credits < ndesc)) {
-		if (!netif_queue_stopped(dev)) {
-			netif_stop_queue(dev);
-			set_bit(TXQ_ETH, &qs->txq_stopped);
-			q->stops++;
-			dev_err(&adap->pdev->dev,
-				"%s: Tx ring %u full while queue awake!\n",
-				dev->name, q->cntxt_id & 7);
-		}
+		t3_stop_queue(dev, qs, q);
+		dev_err(&adap->pdev->dev,
+			"%s: Tx ring %u full while queue awake!\n",
+			dev->name, q->cntxt_id & 7);
 		spin_unlock(&q->lock);
 		return NETDEV_TX_BUSY;
 	}
 
 	q->in_use += ndesc;
-	if (unlikely(credits - ndesc < q->stop_thres)) {
-		q->stops++;
-		netif_stop_queue(dev);
-		set_bit(TXQ_ETH, &qs->txq_stopped);
-#if !USE_GTS
-		if (should_restart_tx(q) &&
-		    test_and_clear_bit(TXQ_ETH, &qs->txq_stopped)) {
-			q->restarts++;
-			netif_wake_queue(dev);
-		}
-#endif
-	}
+	if (unlikely(credits - ndesc < q->stop_thres))
+		if (USE_GTS || !should_restart_tx(q))
+			t3_stop_queue(dev, qs, q);
 
 	gen = q->gen;
 	q->unacked += ndesc;

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

* Re: [PATCH] Optimize cxgb3 xmit path (a bit)
  2008-01-30  7:00 [PATCH] Optimize cxgb3 xmit path (a bit) Krishna Kumar
@ 2008-01-30  7:05 ` Krishna Kumar2
  2008-01-31  0:04 ` Divy Le Ray
  1 sibling, 0 replies; 3+ messages in thread
From: Krishna Kumar2 @ 2008-01-30  7:05 UTC (permalink / raw)
  To: jeff; +Cc: davem, netdev

I forgot to mention but the patch is only compile tested as I don't have
hardware to test it.

Krishna Kumar2/India/IBM@IBMIN wrote on 01/30/2008 12:30:16 PM:

> Changes:
>    1. Add common code for stopping queue.
>    2. No need to call netif_stop_queue followed by netif_wake_queue (and
>       infact a netif_start_queue could have been used instead), instead
>       call stop_queue if required, and remove code under USE_GTS macro.
>    3. There is no need to check for netif_queue_stopped, as the network
>       core guarantees that for us (I am sure every driver could remove
>       that check, eg e1000 - I have tested that path a few billion times
>       with about a few hundred thousand qstops but the condition never
>       hit even once).
>
> Thanks,
>
> - KK
>
> Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
> ---
>  sge.c |   35 +++++++++++++++--------------------
>  1 files changed, 15 insertions(+), 20 deletions(-)
>
> diff -ruNp a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
> --- a/drivers/net/cxgb3/sge.c   2008-01-30 11:42:39.000000000 +0530
> +++ b/drivers/net/cxgb3/sge.c   2008-01-30 12:15:28.000000000 +0530
> @@ -1059,6 +1059,14 @@ static void write_tx_pkt_wr(struct adapt
>            htonl(V_WR_TID(q->token)));
>  }
>
> +static inline void t3_stop_queue(struct net_device *dev, struct sge_qset
*qs,
> +             struct sge_txq *q)
> +{
> +   netif_stop_queue(dev);
> +   set_bit(TXQ_ETH, &qs->txq_stopped);
> +   q->stops++;
> +}
> +
>  /**
>   *   eth_xmit - add a packet to the Ethernet Tx queue
>   *   @skb: the packet
> @@ -1090,31 +1098,18 @@ int t3_eth_xmit(struct sk_buff *skb, str
>     ndesc = calc_tx_descs(skb);
>
>     if (unlikely(credits < ndesc)) {
> -      if (!netif_queue_stopped(dev)) {
> -         netif_stop_queue(dev);
> -         set_bit(TXQ_ETH, &qs->txq_stopped);
> -         q->stops++;
> -         dev_err(&adap->pdev->dev,
> -            "%s: Tx ring %u full while queue awake!\n",
> -            dev->name, q->cntxt_id & 7);
> -      }
> +      t3_stop_queue(dev, qs, q);
> +      dev_err(&adap->pdev->dev,
> +         "%s: Tx ring %u full while queue awake!\n",
> +         dev->name, q->cntxt_id & 7);
>        spin_unlock(&q->lock);
>        return NETDEV_TX_BUSY;
>     }
>
>     q->in_use += ndesc;
> -   if (unlikely(credits - ndesc < q->stop_thres)) {
> -      q->stops++;
> -      netif_stop_queue(dev);
> -      set_bit(TXQ_ETH, &qs->txq_stopped);
> -#if !USE_GTS
> -      if (should_restart_tx(q) &&
> -          test_and_clear_bit(TXQ_ETH, &qs->txq_stopped)) {
> -         q->restarts++;
> -         netif_wake_queue(dev);
> -      }
> -#endif
> -   }
> +   if (unlikely(credits - ndesc < q->stop_thres))
> +      if (USE_GTS || !should_restart_tx(q))
> +         t3_stop_queue(dev, qs, q);
>
>     gen = q->gen;
>     q->unacked += ndesc;


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

* Re: [PATCH] Optimize cxgb3 xmit path (a bit)
  2008-01-30  7:00 [PATCH] Optimize cxgb3 xmit path (a bit) Krishna Kumar
  2008-01-30  7:05 ` Krishna Kumar2
@ 2008-01-31  0:04 ` Divy Le Ray
  1 sibling, 0 replies; 3+ messages in thread
From: Divy Le Ray @ 2008-01-31  0:04 UTC (permalink / raw)
  To: Krishna Kumar; +Cc: jeff, netdev, davem

Krishna Kumar wrote:
> Changes:
> 	1. Add common code for stopping queue.
> 	2. No need to call netif_stop_queue followed by netif_wake_queue (and
> 	   infact a netif_start_queue could have been used instead), instead
> 	   call stop_queue if required, and remove code under USE_GTS macro.
> 	3. There is no need to check for netif_queue_stopped, as the network
> 	   core guarantees that for us (I am sure every driver could remove
> 	   that check, eg e1000 - I have tested that path a few billion times
> 	   with about a few hundred thousand qstops but the condition never
> 	   hit even once).
>
> Thanks,
>   

Hi Krishna,

Thanks for the work.
There is however a bit more cleaning to do regarding the USE_GTS macro.
I'll post a patch soon that will take your points in account.

Cheers,
Divy

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

end of thread, other threads:[~2008-01-31  0:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-30  7:00 [PATCH] Optimize cxgb3 xmit path (a bit) Krishna Kumar
2008-01-30  7:05 ` Krishna Kumar2
2008-01-31  0:04 ` Divy Le Ray

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).