netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net-next] net: socionext: netsec: fix xdp stats accounting
@ 2019-10-17 12:28 Lorenzo Bianconi
  2019-10-17 12:30 ` Ilias Apalodimas
  2019-10-17 19:03 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2019-10-17 12:28 UTC (permalink / raw)
  To: davem; +Cc: netdev, ilias.apalodimas, lorenzo.bianconi

Increment netdev rx counters even for XDP_DROP verdict. Report even
tx bytes for xdp buffers (TYPE_NETSEC_XDP_TX or TYPE_NETSEC_XDP_NDO).
Moreover account pending buffer length in netsec_xdp_queue_one as it is
done for skb counterpart

Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
Changes since v1:
- fix BQL accounting
- target the patch to next-next
---
 drivers/net/ethernet/socionext/netsec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index f9e6744d8fd6..c40294470bfa 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -252,7 +252,6 @@
 #define NETSEC_XDP_CONSUMED      BIT(0)
 #define NETSEC_XDP_TX            BIT(1)
 #define NETSEC_XDP_REDIR         BIT(2)
-#define NETSEC_XDP_RX_OK (NETSEC_XDP_PASS | NETSEC_XDP_TX | NETSEC_XDP_REDIR)
 
 enum ring_id {
 	NETSEC_RING_TX = 0,
@@ -661,6 +660,7 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
 			bytes += desc->skb->len;
 			dev_kfree_skb(desc->skb);
 		} else {
+			bytes += desc->xdpf->len;
 			xdp_return_frame(desc->xdpf);
 		}
 next:
@@ -858,6 +858,7 @@ static u32 netsec_xdp_queue_one(struct netsec_priv *priv,
 	tx_desc.addr = xdpf->data;
 	tx_desc.len = xdpf->len;
 
+	netdev_sent_queue(priv->ndev, xdpf->len);
 	netsec_set_tx_de(priv, tx_ring, &tx_ctrl, &tx_desc, xdpf);
 
 	return NETSEC_XDP_TX;
@@ -1030,7 +1031,7 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
 
 next:
 		if ((skb && napi_gro_receive(&priv->napi, skb) != GRO_DROP) ||
-		    xdp_result & NETSEC_XDP_RX_OK) {
+		    xdp_result) {
 			ndev->stats.rx_packets++;
 			ndev->stats.rx_bytes += xdp.data_end - xdp.data;
 		}
-- 
2.21.0


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

* Re: [PATCH v2 net-next] net: socionext: netsec: fix xdp stats accounting
  2019-10-17 12:28 [PATCH v2 net-next] net: socionext: netsec: fix xdp stats accounting Lorenzo Bianconi
@ 2019-10-17 12:30 ` Ilias Apalodimas
  2019-10-17 19:03 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Ilias Apalodimas @ 2019-10-17 12:30 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: davem, netdev, lorenzo.bianconi

Thanks Lorenzo,

On Thu, Oct 17, 2019 at 02:28:32PM +0200, Lorenzo Bianconi wrote:
> Increment netdev rx counters even for XDP_DROP verdict. Report even
> tx bytes for xdp buffers (TYPE_NETSEC_XDP_TX or TYPE_NETSEC_XDP_NDO).
> Moreover account pending buffer length in netsec_xdp_queue_one as it is
> done for skb counterpart
> 
> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> Changes since v1:
> - fix BQL accounting
> - target the patch to next-next
> ---
>  drivers/net/ethernet/socionext/netsec.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
> index f9e6744d8fd6..c40294470bfa 100644
> --- a/drivers/net/ethernet/socionext/netsec.c
> +++ b/drivers/net/ethernet/socionext/netsec.c
> @@ -252,7 +252,6 @@
>  #define NETSEC_XDP_CONSUMED      BIT(0)
>  #define NETSEC_XDP_TX            BIT(1)
>  #define NETSEC_XDP_REDIR         BIT(2)
> -#define NETSEC_XDP_RX_OK (NETSEC_XDP_PASS | NETSEC_XDP_TX | NETSEC_XDP_REDIR)
>  
>  enum ring_id {
>  	NETSEC_RING_TX = 0,
> @@ -661,6 +660,7 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
>  			bytes += desc->skb->len;
>  			dev_kfree_skb(desc->skb);
>  		} else {
> +			bytes += desc->xdpf->len;
>  			xdp_return_frame(desc->xdpf);
>  		}
>  next:
> @@ -858,6 +858,7 @@ static u32 netsec_xdp_queue_one(struct netsec_priv *priv,
>  	tx_desc.addr = xdpf->data;
>  	tx_desc.len = xdpf->len;
>  
> +	netdev_sent_queue(priv->ndev, xdpf->len);
>  	netsec_set_tx_de(priv, tx_ring, &tx_ctrl, &tx_desc, xdpf);
>  
>  	return NETSEC_XDP_TX;
> @@ -1030,7 +1031,7 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
>  
>  next:
>  		if ((skb && napi_gro_receive(&priv->napi, skb) != GRO_DROP) ||
> -		    xdp_result & NETSEC_XDP_RX_OK) {
> +		    xdp_result) {
>  			ndev->stats.rx_packets++;
>  			ndev->stats.rx_bytes += xdp.data_end - xdp.data;
>  		}
> -- 
> 2.21.0
> 

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

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

* Re: [PATCH v2 net-next] net: socionext: netsec: fix xdp stats accounting
  2019-10-17 12:28 [PATCH v2 net-next] net: socionext: netsec: fix xdp stats accounting Lorenzo Bianconi
  2019-10-17 12:30 ` Ilias Apalodimas
@ 2019-10-17 19:03 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-10-17 19:03 UTC (permalink / raw)
  To: lorenzo; +Cc: netdev, ilias.apalodimas, lorenzo.bianconi

From: Lorenzo Bianconi <lorenzo@kernel.org>
Date: Thu, 17 Oct 2019 14:28:32 +0200

> Increment netdev rx counters even for XDP_DROP verdict. Report even
> tx bytes for xdp buffers (TYPE_NETSEC_XDP_TX or TYPE_NETSEC_XDP_NDO).
> Moreover account pending buffer length in netsec_xdp_queue_one as it is
> done for skb counterpart
> 
> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> Changes since v1:
> - fix BQL accounting
> - target the patch to next-next

Applied, thanks.

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

end of thread, other threads:[~2019-10-17 19:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-17 12:28 [PATCH v2 net-next] net: socionext: netsec: fix xdp stats accounting Lorenzo Bianconi
2019-10-17 12:30 ` Ilias Apalodimas
2019-10-17 19:03 ` 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).