All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] net: stmmac: add BQL support
@ 2015-01-21 18:07 Beniamino Galvani
  2015-01-21 18:37 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Beniamino Galvani @ 2015-01-21 18:07 UTC (permalink / raw)
  To: David S. Miller
  Cc: Giuseppe Cavallaro, Florian Fainelli, Dave Taht, netdev,
	linux-kernel, Beniamino Galvani

Add support for Byte Queue Limits to the STMicro MAC driver.

Tested on a Amlogic S802 quad Cortex-A9 board, where the use of BQL
decreases the latency of a high priority ping from ~12ms to ~1ms when
the 100Mbit link is saturated by 20 TCP streams.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
---
Changes since v1:
 - don't access skb->len after the start of DMA transmission in
   stmmac_xmit(), to avoid potential use after free in case tx_lock is
   removed in the future

 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 118a427..1d74313 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1097,6 +1097,7 @@ static int init_dma_desc_rings(struct net_device *dev, gfp_t flags)
 
 	priv->dirty_tx = 0;
 	priv->cur_tx = 0;
+	netdev_reset_queue(priv->dev);
 
 	stmmac_clear_descriptors(priv);
 
@@ -1300,6 +1301,7 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
 static void stmmac_tx_clean(struct stmmac_priv *priv)
 {
 	unsigned int txsize = priv->dma_tx_size;
+	unsigned int bytes_compl = 0, pkts_compl = 0;
 
 	spin_lock(&priv->tx_lock);
 
@@ -1356,6 +1358,8 @@ static void stmmac_tx_clean(struct stmmac_priv *priv)
 		priv->hw->mode->clean_desc3(priv, p);
 
 		if (likely(skb != NULL)) {
+			pkts_compl++;
+			bytes_compl += skb->len;
 			dev_consume_skb_any(skb);
 			priv->tx_skbuff[entry] = NULL;
 		}
@@ -1364,6 +1368,9 @@ static void stmmac_tx_clean(struct stmmac_priv *priv)
 
 		priv->dirty_tx++;
 	}
+
+	netdev_completed_queue(priv->dev, pkts_compl, bytes_compl);
+
 	if (unlikely(netif_queue_stopped(priv->dev) &&
 		     stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv))) {
 		netif_tx_lock(priv->dev);
@@ -1418,6 +1425,7 @@ static void stmmac_tx_err(struct stmmac_priv *priv)
 						     (i == txsize - 1));
 	priv->dirty_tx = 0;
 	priv->cur_tx = 0;
+	netdev_reset_queue(priv->dev);
 	priv->hw->dma->start_tx(priv->ioaddr);
 
 	priv->dev->stats.tx_errors++;
@@ -2048,6 +2056,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 	if (!priv->hwts_tx_en)
 		skb_tx_timestamp(skb);
 
+	netdev_sent_queue(dev, skb->len);
 	priv->hw->dma->enable_dma_transmission(priv->ioaddr);
 
 	spin_unlock(&priv->tx_lock);
-- 
2.1.4


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

* Re: [PATCH v2] net: stmmac: add BQL support
  2015-01-21 18:07 [PATCH v2] net: stmmac: add BQL support Beniamino Galvani
@ 2015-01-21 18:37 ` Eric Dumazet
  2015-01-22 11:58 ` Giuseppe CAVALLARO
  2015-01-26 23:22 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2015-01-21 18:37 UTC (permalink / raw)
  To: Beniamino Galvani
  Cc: David S. Miller, Giuseppe Cavallaro, Florian Fainelli, Dave Taht,
	netdev, linux-kernel

On Wed, 2015-01-21 at 19:07 +0100, Beniamino Galvani wrote:
> Add support for Byte Queue Limits to the STMicro MAC driver.
> 
> Tested on a Amlogic S802 quad Cortex-A9 board, where the use of BQL
> decreases the latency of a high priority ping from ~12ms to ~1ms when
> the 100Mbit link is saturated by 20 TCP streams.
> 
> Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
> ---
> Changes since v1:
>  - don't access skb->len after the start of DMA transmission in
>    stmmac_xmit(), to avoid potential use after free in case tx_lock is
>    removed in the future
> 
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++++++++
>  1 file changed, 9 insertions(+)

Reviewed-by: Eric Dumazet <edumazet@google.com>

Thanks !



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

* Re: [PATCH v2] net: stmmac: add BQL support
  2015-01-21 18:07 [PATCH v2] net: stmmac: add BQL support Beniamino Galvani
  2015-01-21 18:37 ` Eric Dumazet
@ 2015-01-22 11:58 ` Giuseppe CAVALLARO
  2015-01-26 23:22 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Giuseppe CAVALLARO @ 2015-01-22 11:58 UTC (permalink / raw)
  To: Beniamino Galvani, David S. Miller
  Cc: Florian Fainelli, Dave Taht, netdev, linux-kernel

On 1/21/2015 7:07 PM, Beniamino Galvani wrote:
> Add support for Byte Queue Limits to the STMicro MAC driver.
>
> Tested on a Amlogic S802 quad Cortex-A9 board, where the use of BQL
> decreases the latency of a high priority ping from ~12ms to ~1ms when
> the 100Mbit link is saturated by 20 TCP streams.
>
> Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>


Ciao Beniamino

thx for the patch, I also see some improvements on my side

Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

> ---
> Changes since v1:
>   - don't access skb->len after the start of DMA transmission in
>     stmmac_xmit(), to avoid potential use after free in case tx_lock is
>     removed in the future
>
>   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 118a427..1d74313 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1097,6 +1097,7 @@ static int init_dma_desc_rings(struct net_device *dev, gfp_t flags)
>
>   	priv->dirty_tx = 0;
>   	priv->cur_tx = 0;
> +	netdev_reset_queue(priv->dev);
>
>   	stmmac_clear_descriptors(priv);
>
> @@ -1300,6 +1301,7 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
>   static void stmmac_tx_clean(struct stmmac_priv *priv)
>   {
>   	unsigned int txsize = priv->dma_tx_size;
> +	unsigned int bytes_compl = 0, pkts_compl = 0;
>
>   	spin_lock(&priv->tx_lock);
>
> @@ -1356,6 +1358,8 @@ static void stmmac_tx_clean(struct stmmac_priv *priv)
>   		priv->hw->mode->clean_desc3(priv, p);
>
>   		if (likely(skb != NULL)) {
> +			pkts_compl++;
> +			bytes_compl += skb->len;
>   			dev_consume_skb_any(skb);
>   			priv->tx_skbuff[entry] = NULL;
>   		}
> @@ -1364,6 +1368,9 @@ static void stmmac_tx_clean(struct stmmac_priv *priv)
>
>   		priv->dirty_tx++;
>   	}
> +
> +	netdev_completed_queue(priv->dev, pkts_compl, bytes_compl);
> +
>   	if (unlikely(netif_queue_stopped(priv->dev) &&
>   		     stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv))) {
>   		netif_tx_lock(priv->dev);
> @@ -1418,6 +1425,7 @@ static void stmmac_tx_err(struct stmmac_priv *priv)
>   						     (i == txsize - 1));
>   	priv->dirty_tx = 0;
>   	priv->cur_tx = 0;
> +	netdev_reset_queue(priv->dev);
>   	priv->hw->dma->start_tx(priv->ioaddr);
>
>   	priv->dev->stats.tx_errors++;
> @@ -2048,6 +2056,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
>   	if (!priv->hwts_tx_en)
>   		skb_tx_timestamp(skb);
>
> +	netdev_sent_queue(dev, skb->len);
>   	priv->hw->dma->enable_dma_transmission(priv->ioaddr);
>
>   	spin_unlock(&priv->tx_lock);
>


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

* Re: [PATCH v2] net: stmmac: add BQL support
  2015-01-21 18:07 [PATCH v2] net: stmmac: add BQL support Beniamino Galvani
  2015-01-21 18:37 ` Eric Dumazet
  2015-01-22 11:58 ` Giuseppe CAVALLARO
@ 2015-01-26 23:22 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-01-26 23:22 UTC (permalink / raw)
  To: b.galvani; +Cc: peppe.cavallaro, f.fainelli, dave.taht, netdev, linux-kernel

From: Beniamino Galvani <b.galvani@gmail.com>
Date: Wed, 21 Jan 2015 19:07:27 +0100

> Add support for Byte Queue Limits to the STMicro MAC driver.
> 
> Tested on a Amlogic S802 quad Cortex-A9 board, where the use of BQL
> decreases the latency of a high priority ping from ~12ms to ~1ms when
> the 100Mbit link is saturated by 20 TCP streams.
> 
> Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>

Applied.

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

end of thread, other threads:[~2015-01-27  0:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-21 18:07 [PATCH v2] net: stmmac: add BQL support Beniamino Galvani
2015-01-21 18:37 ` Eric Dumazet
2015-01-22 11:58 ` Giuseppe CAVALLARO
2015-01-26 23:22 ` David Miller

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.