bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: mlx4: Add XDP_REDIRECT statistics
       [not found] <8d7773a0-054a-84d5-e0b6-66a13509149e@gmail.com>
@ 2021-09-28 13:26 ` Joshua Roys
  2021-09-29 10:19   ` Tariq Toukan
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Joshua Roys @ 2021-09-28 13:26 UTC (permalink / raw)
  To: netdev
  Cc: Joshua Roys, ast, davem, hawk, john.fastabend, daniel, kuba, bpf,
	tariqt, linux-rdma

Address feedback for XDP_REDIRECT patch.

Signed-off-by: Joshua Roys <roysjosh@gmail.com>
---
 .../net/ethernet/mellanox/mlx4/en_ethtool.c    |  8 ++++++++
 drivers/net/ethernet/mellanox/mlx4/en_port.c   | 18 +++++++++++-------
 drivers/net/ethernet/mellanox/mlx4/en_rx.c     |  4 +++-
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h   |  2 ++
 .../net/ethernet/mellanox/mlx4/mlx4_stats.h    |  4 +++-
 5 files changed, 27 insertions(+), 9 deletions(-)

Tested with VPP 21.06 on Fedora 34.

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index ef518b1040f7..66c8ae29bc7a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -197,6 +197,8 @@ static const char main_strings[][ETH_GSTRING_LEN] = {
 
 	/* xdp statistics */
 	"rx_xdp_drop",
+	"rx_xdp_redirect",
+	"rx_xdp_redirect_fail",
 	"rx_xdp_tx",
 	"rx_xdp_tx_full",
 
@@ -428,6 +430,8 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
 		data[index++] = priv->rx_ring[i]->bytes;
 		data[index++] = priv->rx_ring[i]->dropped;
 		data[index++] = priv->rx_ring[i]->xdp_drop;
+		data[index++] = priv->rx_ring[i]->xdp_redirect;
+		data[index++] = priv->rx_ring[i]->xdp_redirect_fail;
 		data[index++] = priv->rx_ring[i]->xdp_tx;
 		data[index++] = priv->rx_ring[i]->xdp_tx_full;
 	}
@@ -519,6 +523,10 @@ static void mlx4_en_get_strings(struct net_device *dev,
 				"rx%d_dropped", i);
 			sprintf(data + (index++) * ETH_GSTRING_LEN,
 				"rx%d_xdp_drop", i);
+			sprintf(data + (index++) * ETH_GSTRING_LEN,
+				"rx%d_xdp_redirect", i);
+			sprintf(data + (index++) * ETH_GSTRING_LEN,
+				"rx%d_xdp_redirect_fail", i);
 			sprintf(data + (index++) * ETH_GSTRING_LEN,
 				"rx%d_xdp_tx", i);
 			sprintf(data + (index++) * ETH_GSTRING_LEN,
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.c b/drivers/net/ethernet/mellanox/mlx4/en_port.c
index 0158b88bea5b..043cc9d75b3e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_port.c
@@ -239,13 +239,15 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
 
 	mlx4_en_fold_software_stats(dev);
 
-	priv->port_stats.rx_chksum_good = 0;
-	priv->port_stats.rx_chksum_none = 0;
-	priv->port_stats.rx_chksum_complete = 0;
-	priv->port_stats.rx_alloc_pages = 0;
-	priv->xdp_stats.rx_xdp_drop    = 0;
-	priv->xdp_stats.rx_xdp_tx      = 0;
-	priv->xdp_stats.rx_xdp_tx_full = 0;
+	priv->port_stats.rx_chksum_good      = 0;
+	priv->port_stats.rx_chksum_none      = 0;
+	priv->port_stats.rx_chksum_complete  = 0;
+	priv->port_stats.rx_alloc_pages      = 0;
+	priv->xdp_stats.rx_xdp_drop          = 0;
+	priv->xdp_stats.rx_xdp_redirect      = 0;
+	priv->xdp_stats.rx_xdp_redirect_fail = 0;
+	priv->xdp_stats.rx_xdp_tx            = 0;
+	priv->xdp_stats.rx_xdp_tx_full       = 0;
 	for (i = 0; i < priv->rx_ring_num; i++) {
 		const struct mlx4_en_rx_ring *ring = priv->rx_ring[i];
 
@@ -255,6 +257,8 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
 		priv->port_stats.rx_chksum_complete += READ_ONCE(ring->csum_complete);
 		priv->port_stats.rx_alloc_pages += READ_ONCE(ring->rx_alloc_pages);
 		priv->xdp_stats.rx_xdp_drop	+= READ_ONCE(ring->xdp_drop);
+		priv->xdp_stats.rx_xdp_redirect += READ_ONCE(ring->xdp_redirect);
+		priv->xdp_stats.rx_xdp_redirect_fail += READ_ONCE(ring->xdp_redirect_fail);
 		priv->xdp_stats.rx_xdp_tx	+= READ_ONCE(ring->xdp_tx);
 		priv->xdp_stats.rx_xdp_tx_full	+= READ_ONCE(ring->xdp_tx_full);
 	}
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 557d7daac2d3..8f09b1de4125 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -793,11 +793,13 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
 			case XDP_PASS:
 				break;
 			case XDP_REDIRECT:
-				if (xdp_do_redirect(dev, &xdp, xdp_prog) >= 0) {
+				if (!xdp_do_redirect(dev, &xdp, xdp_prog)) {
+					ring->xdp_redirect++;
 					xdp_redir_flush = true;
 					frags[0].page = NULL;
 					goto next;
 				}
+				ring->xdp_redirect_fail++;
 				trace_xdp_exception(dev, xdp_prog, act);
 				goto xdp_drop_no_cnt;
 			case XDP_TX:
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index f3d1a20201ef..f6c90e97b4cd 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -340,6 +340,8 @@ struct mlx4_en_rx_ring {
 	unsigned long csum_complete;
 	unsigned long rx_alloc_pages;
 	unsigned long xdp_drop;
+	unsigned long xdp_redirect;
+	unsigned long xdp_redirect_fail;
 	unsigned long xdp_tx;
 	unsigned long xdp_tx_full;
 	unsigned long dropped;
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
index 7b51ae8cf759..e9cd4bb6f83d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
@@ -42,9 +42,11 @@ struct mlx4_en_port_stats {
 
 struct mlx4_en_xdp_stats {
 	unsigned long rx_xdp_drop;
+	unsigned long rx_xdp_redirect;
+	unsigned long rx_xdp_redirect_fail;
 	unsigned long rx_xdp_tx;
 	unsigned long rx_xdp_tx_full;
-#define NUM_XDP_STATS		3
+#define NUM_XDP_STATS		5
 };
 
 struct mlx4_en_phy_stats {
-- 
2.31.1


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

* Re: [PATCH net-next] net: mlx4: Add XDP_REDIRECT statistics
  2021-09-28 13:26 ` [PATCH net-next] net: mlx4: Add XDP_REDIRECT statistics Joshua Roys
@ 2021-09-29 10:19   ` Tariq Toukan
  2021-09-30  2:17   ` [PATCH net-next v2] net/mlx4_en: " Joshua Roys
  2021-09-30  2:30   ` [PATCH net-next v3] " Joshua Roys
  2 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2021-09-29 10:19 UTC (permalink / raw)
  To: Joshua Roys, netdev
  Cc: ast, davem, hawk, john.fastabend, daniel, kuba, bpf, tariqt, linux-rdma


For changes in the mlx4 ethernet driver, please use "net/mlx4_en" prefix 
in patch subject.

On 9/28/2021 4:26 PM, Joshua Roys wrote:
> Address feedback for XDP_REDIRECT patch.
> 

Description is not helpful at all.
Please provide technical description of the content, motivation, why it 
is needed, etc...

> Signed-off-by: Joshua Roys <roysjosh@gmail.com>
> ---
>   .../net/ethernet/mellanox/mlx4/en_ethtool.c    |  8 ++++++++
>   drivers/net/ethernet/mellanox/mlx4/en_port.c   | 18 +++++++++++-------
>   drivers/net/ethernet/mellanox/mlx4/en_rx.c     |  4 +++-
>   drivers/net/ethernet/mellanox/mlx4/mlx4_en.h   |  2 ++
>   .../net/ethernet/mellanox/mlx4/mlx4_stats.h    |  4 +++-
>   5 files changed, 27 insertions(+), 9 deletions(-)
> 
> Tested with VPP 21.06 on Fedora 34.
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> index ef518b1040f7..66c8ae29bc7a 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> @@ -197,6 +197,8 @@ static const char main_strings[][ETH_GSTRING_LEN] = {
>   
>   	/* xdp statistics */
>   	"rx_xdp_drop",
> +	"rx_xdp_redirect",
> +	"rx_xdp_redirect_fail",
>   	"rx_xdp_tx",
>   	"rx_xdp_tx_full",
>   
> @@ -428,6 +430,8 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
>   		data[index++] = priv->rx_ring[i]->bytes;
>   		data[index++] = priv->rx_ring[i]->dropped;
>   		data[index++] = priv->rx_ring[i]->xdp_drop;
> +		data[index++] = priv->rx_ring[i]->xdp_redirect;
> +		data[index++] = priv->rx_ring[i]->xdp_redirect_fail;
>   		data[index++] = priv->rx_ring[i]->xdp_tx;
>   		data[index++] = priv->rx_ring[i]->xdp_tx_full;
>   	}
> @@ -519,6 +523,10 @@ static void mlx4_en_get_strings(struct net_device *dev,
>   				"rx%d_dropped", i);
>   			sprintf(data + (index++) * ETH_GSTRING_LEN,
>   				"rx%d_xdp_drop", i);
> +			sprintf(data + (index++) * ETH_GSTRING_LEN,
> +				"rx%d_xdp_redirect", i);
> +			sprintf(data + (index++) * ETH_GSTRING_LEN,
> +				"rx%d_xdp_redirect_fail", i);
>   			sprintf(data + (index++) * ETH_GSTRING_LEN,
>   				"rx%d_xdp_tx", i);
>   			sprintf(data + (index++) * ETH_GSTRING_LEN,
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.c b/drivers/net/ethernet/mellanox/mlx4/en_port.c
> index 0158b88bea5b..043cc9d75b3e 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_port.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_port.c
> @@ -239,13 +239,15 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
>   
>   	mlx4_en_fold_software_stats(dev);
>   
> -	priv->port_stats.rx_chksum_good = 0;
> -	priv->port_stats.rx_chksum_none = 0;
> -	priv->port_stats.rx_chksum_complete = 0;
> -	priv->port_stats.rx_alloc_pages = 0;
> -	priv->xdp_stats.rx_xdp_drop    = 0;
> -	priv->xdp_stats.rx_xdp_tx      = 0;
> -	priv->xdp_stats.rx_xdp_tx_full = 0;
> +	priv->port_stats.rx_chksum_good      = 0;
> +	priv->port_stats.rx_chksum_none      = 0;
> +	priv->port_stats.rx_chksum_complete  = 0;
> +	priv->port_stats.rx_alloc_pages      = 0;
> +	priv->xdp_stats.rx_xdp_drop          = 0;
> +	priv->xdp_stats.rx_xdp_redirect      = 0;
> +	priv->xdp_stats.rx_xdp_redirect_fail = 0;
> +	priv->xdp_stats.rx_xdp_tx            = 0;
> +	priv->xdp_stats.rx_xdp_tx_full       = 0;

No need to touch existing lines.
Add yours without fixing the existing indintations.

>   	for (i = 0; i < priv->rx_ring_num; i++) {
>   		const struct mlx4_en_rx_ring *ring = priv->rx_ring[i];
>   
> @@ -255,6 +257,8 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
>   		priv->port_stats.rx_chksum_complete += READ_ONCE(ring->csum_complete);
>   		priv->port_stats.rx_alloc_pages += READ_ONCE(ring->rx_alloc_pages);
>   		priv->xdp_stats.rx_xdp_drop	+= READ_ONCE(ring->xdp_drop);
> +		priv->xdp_stats.rx_xdp_redirect += READ_ONCE(ring->xdp_redirect);
> +		priv->xdp_stats.rx_xdp_redirect_fail += READ_ONCE(ring->xdp_redirect_fail);
>   		priv->xdp_stats.rx_xdp_tx	+= READ_ONCE(ring->xdp_tx);
>   		priv->xdp_stats.rx_xdp_tx_full	+= READ_ONCE(ring->xdp_tx_full);
>   	}
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> index 557d7daac2d3..8f09b1de4125 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> @@ -793,11 +793,13 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
>   			case XDP_PASS:
>   				break;
>   			case XDP_REDIRECT:
> -				if (xdp_do_redirect(dev, &xdp, xdp_prog) >= 0) {
> +				if (!xdp_do_redirect(dev, &xdp, xdp_prog)) {

use likely()

> +					ring->xdp_redirect++;
>   					xdp_redir_flush = true;
>   					frags[0].page = NULL;
>   					goto next;
>   				}
> +				ring->xdp_redirect_fail++;
>   				trace_xdp_exception(dev, xdp_prog, act);
>   				goto xdp_drop_no_cnt;
>   			case XDP_TX:
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> index f3d1a20201ef..f6c90e97b4cd 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> @@ -340,6 +340,8 @@ struct mlx4_en_rx_ring {
>   	unsigned long csum_complete;
>   	unsigned long rx_alloc_pages;
>   	unsigned long xdp_drop;
> +	unsigned long xdp_redirect;
> +	unsigned long xdp_redirect_fail;
>   	unsigned long xdp_tx;
>   	unsigned long xdp_tx_full;
>   	unsigned long dropped;
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
> index 7b51ae8cf759..e9cd4bb6f83d 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
> +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
> @@ -42,9 +42,11 @@ struct mlx4_en_port_stats {
>   
>   struct mlx4_en_xdp_stats {
>   	unsigned long rx_xdp_drop;
> +	unsigned long rx_xdp_redirect;
> +	unsigned long rx_xdp_redirect_fail;
>   	unsigned long rx_xdp_tx;
>   	unsigned long rx_xdp_tx_full;
> -#define NUM_XDP_STATS		3
> +#define NUM_XDP_STATS		5
>   };
>   
>   struct mlx4_en_phy_stats {
> 

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

* [PATCH net-next v2] net/mlx4_en: Add XDP_REDIRECT statistics
  2021-09-28 13:26 ` [PATCH net-next] net: mlx4: Add XDP_REDIRECT statistics Joshua Roys
  2021-09-29 10:19   ` Tariq Toukan
@ 2021-09-30  2:17   ` Joshua Roys
  2021-09-30  2:30   ` [PATCH net-next v3] " Joshua Roys
  2 siblings, 0 replies; 6+ messages in thread
From: Joshua Roys @ 2021-09-30  2:17 UTC (permalink / raw)
  To: netdev
  Cc: Joshua Roys, ast, davem, hawk, john.fastabend, daniel, kuba, bpf,
	tariqt, linux-rdma

Add counters for XDP REDIRECT success and failure. This brings the
redirect path in line with metrics gathered via the other XDP paths.

Signed-off-by: Joshua Roys <roysjosh@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 8 ++++++++
 drivers/net/ethernet/mellanox/mlx4/en_port.c    | 4 ++++
 drivers/net/ethernet/mellanox/mlx4/en_rx.c      | 4 +++-
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h    | 2 ++
 drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h | 4 +++-
 5 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index ef518b1040f7..66c8ae29bc7a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -197,6 +197,8 @@ static const char main_strings[][ETH_GSTRING_LEN] = {
 
 	/* xdp statistics */
 	"rx_xdp_drop",
+	"rx_xdp_redirect",
+	"rx_xdp_redirect_fail",
 	"rx_xdp_tx",
 	"rx_xdp_tx_full",
 
@@ -428,6 +430,8 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
 		data[index++] = priv->rx_ring[i]->bytes;
 		data[index++] = priv->rx_ring[i]->dropped;
 		data[index++] = priv->rx_ring[i]->xdp_drop;
+		data[index++] = priv->rx_ring[i]->xdp_redirect;
+		data[index++] = priv->rx_ring[i]->xdp_redirect_fail;
 		data[index++] = priv->rx_ring[i]->xdp_tx;
 		data[index++] = priv->rx_ring[i]->xdp_tx_full;
 	}
@@ -519,6 +523,10 @@ static void mlx4_en_get_strings(struct net_device *dev,
 				"rx%d_dropped", i);
 			sprintf(data + (index++) * ETH_GSTRING_LEN,
 				"rx%d_xdp_drop", i);
+			sprintf(data + (index++) * ETH_GSTRING_LEN,
+				"rx%d_xdp_redirect", i);
+			sprintf(data + (index++) * ETH_GSTRING_LEN,
+				"rx%d_xdp_redirect_fail", i);
 			sprintf(data + (index++) * ETH_GSTRING_LEN,
 				"rx%d_xdp_tx", i);
 			sprintf(data + (index++) * ETH_GSTRING_LEN,
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.c b/drivers/net/ethernet/mellanox/mlx4/en_port.c
index 0158b88bea5b..f25794a92241 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_port.c
@@ -244,6 +244,8 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
 	priv->port_stats.rx_chksum_complete = 0;
 	priv->port_stats.rx_alloc_pages = 0;
 	priv->xdp_stats.rx_xdp_drop    = 0;
+	priv->xdp_stats.rx_xdp_redirect = 0;
+	priv->xdp_stats.rx_xdp_redirect_full = 0;
 	priv->xdp_stats.rx_xdp_tx      = 0;
 	priv->xdp_stats.rx_xdp_tx_full = 0;
 	for (i = 0; i < priv->rx_ring_num; i++) {
@@ -255,6 +257,8 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
 		priv->port_stats.rx_chksum_complete += READ_ONCE(ring->csum_complete);
 		priv->port_stats.rx_alloc_pages += READ_ONCE(ring->rx_alloc_pages);
 		priv->xdp_stats.rx_xdp_drop	+= READ_ONCE(ring->xdp_drop);
+		priv->xdp_stats.rx_xdp_redirect += READ_ONCE(ring->xdp_redirect);
+		priv->xdp_stats.rx_xdp_redirect_fail += READ_ONCE(ring->xdp_redirect_fail);
 		priv->xdp_stats.rx_xdp_tx	+= READ_ONCE(ring->xdp_tx);
 		priv->xdp_stats.rx_xdp_tx_full	+= READ_ONCE(ring->xdp_tx_full);
 	}
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 557d7daac2d3..650e6a1844ae 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -793,11 +793,13 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
 			case XDP_PASS:
 				break;
 			case XDP_REDIRECT:
-				if (xdp_do_redirect(dev, &xdp, xdp_prog) >= 0) {
+				if (likely(!xdp_do_redirect(dev, &xdp, xdp_prog))) {
+					ring->xdp_redirect++;
 					xdp_redir_flush = true;
 					frags[0].page = NULL;
 					goto next;
 				}
+				ring->xdp_redirect_fail++;
 				trace_xdp_exception(dev, xdp_prog, act);
 				goto xdp_drop_no_cnt;
 			case XDP_TX:
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index f3d1a20201ef..f6c90e97b4cd 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -340,6 +340,8 @@ struct mlx4_en_rx_ring {
 	unsigned long csum_complete;
 	unsigned long rx_alloc_pages;
 	unsigned long xdp_drop;
+	unsigned long xdp_redirect;
+	unsigned long xdp_redirect_fail;
 	unsigned long xdp_tx;
 	unsigned long xdp_tx_full;
 	unsigned long dropped;
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
index 7b51ae8cf759..e9cd4bb6f83d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
@@ -42,9 +42,11 @@ struct mlx4_en_port_stats {
 
 struct mlx4_en_xdp_stats {
 	unsigned long rx_xdp_drop;
+	unsigned long rx_xdp_redirect;
+	unsigned long rx_xdp_redirect_fail;
 	unsigned long rx_xdp_tx;
 	unsigned long rx_xdp_tx_full;
-#define NUM_XDP_STATS		3
+#define NUM_XDP_STATS		5
 };
 
 struct mlx4_en_phy_stats {
-- 
2.31.1


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

* [PATCH net-next v3] net/mlx4_en: Add XDP_REDIRECT statistics
  2021-09-28 13:26 ` [PATCH net-next] net: mlx4: Add XDP_REDIRECT statistics Joshua Roys
  2021-09-29 10:19   ` Tariq Toukan
  2021-09-30  2:17   ` [PATCH net-next v2] net/mlx4_en: " Joshua Roys
@ 2021-09-30  2:30   ` Joshua Roys
  2021-09-30  7:19     ` Tariq Toukan
  2021-09-30 13:20     ` patchwork-bot+netdevbpf
  2 siblings, 2 replies; 6+ messages in thread
From: Joshua Roys @ 2021-09-30  2:30 UTC (permalink / raw)
  To: netdev
  Cc: Joshua Roys, ast, davem, hawk, john.fastabend, daniel, kuba, bpf,
	tariqt, linux-rdma

Add counters for XDP REDIRECT success and failure. This brings the
redirect path in line with metrics gathered via the other XDP paths.

Signed-off-by: Joshua Roys <roysjosh@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 8 ++++++++
 drivers/net/ethernet/mellanox/mlx4/en_port.c    | 4 ++++
 drivers/net/ethernet/mellanox/mlx4/en_rx.c      | 4 +++-
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h    | 2 ++
 drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h | 4 +++-
 5 files changed, 20 insertions(+), 2 deletions(-)

Sorry, this version fixes the full/fail typo.

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index ef518b1040f7..66c8ae29bc7a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -197,6 +197,8 @@ static const char main_strings[][ETH_GSTRING_LEN] = {
 
 	/* xdp statistics */
 	"rx_xdp_drop",
+	"rx_xdp_redirect",
+	"rx_xdp_redirect_fail",
 	"rx_xdp_tx",
 	"rx_xdp_tx_full",
 
@@ -428,6 +430,8 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
 		data[index++] = priv->rx_ring[i]->bytes;
 		data[index++] = priv->rx_ring[i]->dropped;
 		data[index++] = priv->rx_ring[i]->xdp_drop;
+		data[index++] = priv->rx_ring[i]->xdp_redirect;
+		data[index++] = priv->rx_ring[i]->xdp_redirect_fail;
 		data[index++] = priv->rx_ring[i]->xdp_tx;
 		data[index++] = priv->rx_ring[i]->xdp_tx_full;
 	}
@@ -519,6 +523,10 @@ static void mlx4_en_get_strings(struct net_device *dev,
 				"rx%d_dropped", i);
 			sprintf(data + (index++) * ETH_GSTRING_LEN,
 				"rx%d_xdp_drop", i);
+			sprintf(data + (index++) * ETH_GSTRING_LEN,
+				"rx%d_xdp_redirect", i);
+			sprintf(data + (index++) * ETH_GSTRING_LEN,
+				"rx%d_xdp_redirect_fail", i);
 			sprintf(data + (index++) * ETH_GSTRING_LEN,
 				"rx%d_xdp_tx", i);
 			sprintf(data + (index++) * ETH_GSTRING_LEN,
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.c b/drivers/net/ethernet/mellanox/mlx4/en_port.c
index 0158b88bea5b..f25794a92241 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_port.c
@@ -244,6 +244,8 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
 	priv->port_stats.rx_chksum_complete = 0;
 	priv->port_stats.rx_alloc_pages = 0;
 	priv->xdp_stats.rx_xdp_drop    = 0;
+	priv->xdp_stats.rx_xdp_redirect = 0;
+	priv->xdp_stats.rx_xdp_redirect_fail = 0;
 	priv->xdp_stats.rx_xdp_tx      = 0;
 	priv->xdp_stats.rx_xdp_tx_full = 0;
 	for (i = 0; i < priv->rx_ring_num; i++) {
@@ -255,6 +257,8 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
 		priv->port_stats.rx_chksum_complete += READ_ONCE(ring->csum_complete);
 		priv->port_stats.rx_alloc_pages += READ_ONCE(ring->rx_alloc_pages);
 		priv->xdp_stats.rx_xdp_drop	+= READ_ONCE(ring->xdp_drop);
+		priv->xdp_stats.rx_xdp_redirect += READ_ONCE(ring->xdp_redirect);
+		priv->xdp_stats.rx_xdp_redirect_fail += READ_ONCE(ring->xdp_redirect_fail);
 		priv->xdp_stats.rx_xdp_tx	+= READ_ONCE(ring->xdp_tx);
 		priv->xdp_stats.rx_xdp_tx_full	+= READ_ONCE(ring->xdp_tx_full);
 	}
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 557d7daac2d3..650e6a1844ae 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -793,11 +793,13 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
 			case XDP_PASS:
 				break;
 			case XDP_REDIRECT:
-				if (xdp_do_redirect(dev, &xdp, xdp_prog) >= 0) {
+				if (likely(!xdp_do_redirect(dev, &xdp, xdp_prog))) {
+					ring->xdp_redirect++;
 					xdp_redir_flush = true;
 					frags[0].page = NULL;
 					goto next;
 				}
+				ring->xdp_redirect_fail++;
 				trace_xdp_exception(dev, xdp_prog, act);
 				goto xdp_drop_no_cnt;
 			case XDP_TX:
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index f3d1a20201ef..f6c90e97b4cd 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -340,6 +340,8 @@ struct mlx4_en_rx_ring {
 	unsigned long csum_complete;
 	unsigned long rx_alloc_pages;
 	unsigned long xdp_drop;
+	unsigned long xdp_redirect;
+	unsigned long xdp_redirect_fail;
 	unsigned long xdp_tx;
 	unsigned long xdp_tx_full;
 	unsigned long dropped;
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
index 7b51ae8cf759..e9cd4bb6f83d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
@@ -42,9 +42,11 @@ struct mlx4_en_port_stats {
 
 struct mlx4_en_xdp_stats {
 	unsigned long rx_xdp_drop;
+	unsigned long rx_xdp_redirect;
+	unsigned long rx_xdp_redirect_fail;
 	unsigned long rx_xdp_tx;
 	unsigned long rx_xdp_tx_full;
-#define NUM_XDP_STATS		3
+#define NUM_XDP_STATS		5
 };
 
 struct mlx4_en_phy_stats {
-- 
2.31.1


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

* Re: [PATCH net-next v3] net/mlx4_en: Add XDP_REDIRECT statistics
  2021-09-30  2:30   ` [PATCH net-next v3] " Joshua Roys
@ 2021-09-30  7:19     ` Tariq Toukan
  2021-09-30 13:20     ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2021-09-30  7:19 UTC (permalink / raw)
  To: Joshua Roys, netdev
  Cc: ast, davem, hawk, john.fastabend, daniel, kuba, bpf, tariqt, linux-rdma



On 9/30/2021 5:30 AM, Joshua Roys wrote:
> Add counters for XDP REDIRECT success and failure. This brings the
> redirect path in line with metrics gathered via the other XDP paths.
> 
> Signed-off-by: Joshua Roys <roysjosh@gmail.com>
> ---
>   drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 8 ++++++++
>   drivers/net/ethernet/mellanox/mlx4/en_port.c    | 4 ++++
>   drivers/net/ethernet/mellanox/mlx4/en_rx.c      | 4 +++-
>   drivers/net/ethernet/mellanox/mlx4/mlx4_en.h    | 2 ++
>   drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h | 4 +++-
>   5 files changed, 20 insertions(+), 2 deletions(-)
> 
> Sorry, this version fixes the full/fail typo.
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> index ef518b1040f7..66c8ae29bc7a 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> @@ -197,6 +197,8 @@ static const char main_strings[][ETH_GSTRING_LEN] = {
>   
>   	/* xdp statistics */
>   	"rx_xdp_drop",
> +	"rx_xdp_redirect",
> +	"rx_xdp_redirect_fail",
>   	"rx_xdp_tx",
>   	"rx_xdp_tx_full",
>   
> @@ -428,6 +430,8 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
>   		data[index++] = priv->rx_ring[i]->bytes;
>   		data[index++] = priv->rx_ring[i]->dropped;
>   		data[index++] = priv->rx_ring[i]->xdp_drop;
> +		data[index++] = priv->rx_ring[i]->xdp_redirect;
> +		data[index++] = priv->rx_ring[i]->xdp_redirect_fail;
>   		data[index++] = priv->rx_ring[i]->xdp_tx;
>   		data[index++] = priv->rx_ring[i]->xdp_tx_full;
>   	}
> @@ -519,6 +523,10 @@ static void mlx4_en_get_strings(struct net_device *dev,
>   				"rx%d_dropped", i);
>   			sprintf(data + (index++) * ETH_GSTRING_LEN,
>   				"rx%d_xdp_drop", i);
> +			sprintf(data + (index++) * ETH_GSTRING_LEN,
> +				"rx%d_xdp_redirect", i);
> +			sprintf(data + (index++) * ETH_GSTRING_LEN,
> +				"rx%d_xdp_redirect_fail", i);
>   			sprintf(data + (index++) * ETH_GSTRING_LEN,
>   				"rx%d_xdp_tx", i);
>   			sprintf(data + (index++) * ETH_GSTRING_LEN,
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.c b/drivers/net/ethernet/mellanox/mlx4/en_port.c
> index 0158b88bea5b..f25794a92241 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_port.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_port.c
> @@ -244,6 +244,8 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
>   	priv->port_stats.rx_chksum_complete = 0;
>   	priv->port_stats.rx_alloc_pages = 0;
>   	priv->xdp_stats.rx_xdp_drop    = 0;
> +	priv->xdp_stats.rx_xdp_redirect = 0;
> +	priv->xdp_stats.rx_xdp_redirect_fail = 0;
>   	priv->xdp_stats.rx_xdp_tx      = 0;
>   	priv->xdp_stats.rx_xdp_tx_full = 0;
>   	for (i = 0; i < priv->rx_ring_num; i++) {
> @@ -255,6 +257,8 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
>   		priv->port_stats.rx_chksum_complete += READ_ONCE(ring->csum_complete);
>   		priv->port_stats.rx_alloc_pages += READ_ONCE(ring->rx_alloc_pages);
>   		priv->xdp_stats.rx_xdp_drop	+= READ_ONCE(ring->xdp_drop);
> +		priv->xdp_stats.rx_xdp_redirect += READ_ONCE(ring->xdp_redirect);
> +		priv->xdp_stats.rx_xdp_redirect_fail += READ_ONCE(ring->xdp_redirect_fail);
>   		priv->xdp_stats.rx_xdp_tx	+= READ_ONCE(ring->xdp_tx);
>   		priv->xdp_stats.rx_xdp_tx_full	+= READ_ONCE(ring->xdp_tx_full);
>   	}
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> index 557d7daac2d3..650e6a1844ae 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> @@ -793,11 +793,13 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
>   			case XDP_PASS:
>   				break;
>   			case XDP_REDIRECT:
> -				if (xdp_do_redirect(dev, &xdp, xdp_prog) >= 0) {
> +				if (likely(!xdp_do_redirect(dev, &xdp, xdp_prog))) {
> +					ring->xdp_redirect++;
>   					xdp_redir_flush = true;
>   					frags[0].page = NULL;
>   					goto next;
>   				}
> +				ring->xdp_redirect_fail++;
>   				trace_xdp_exception(dev, xdp_prog, act);
>   				goto xdp_drop_no_cnt;
>   			case XDP_TX:
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> index f3d1a20201ef..f6c90e97b4cd 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> @@ -340,6 +340,8 @@ struct mlx4_en_rx_ring {
>   	unsigned long csum_complete;
>   	unsigned long rx_alloc_pages;
>   	unsigned long xdp_drop;
> +	unsigned long xdp_redirect;
> +	unsigned long xdp_redirect_fail;
>   	unsigned long xdp_tx;
>   	unsigned long xdp_tx_full;
>   	unsigned long dropped;
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
> index 7b51ae8cf759..e9cd4bb6f83d 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
> +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h
> @@ -42,9 +42,11 @@ struct mlx4_en_port_stats {
>   
>   struct mlx4_en_xdp_stats {
>   	unsigned long rx_xdp_drop;
> +	unsigned long rx_xdp_redirect;
> +	unsigned long rx_xdp_redirect_fail;
>   	unsigned long rx_xdp_tx;
>   	unsigned long rx_xdp_tx_full;
> -#define NUM_XDP_STATS		3
> +#define NUM_XDP_STATS		5
>   };
>   
>   struct mlx4_en_phy_stats {
> 

Thanks for your patch.
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>

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

* Re: [PATCH net-next v3] net/mlx4_en: Add XDP_REDIRECT statistics
  2021-09-30  2:30   ` [PATCH net-next v3] " Joshua Roys
  2021-09-30  7:19     ` Tariq Toukan
@ 2021-09-30 13:20     ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-09-30 13:20 UTC (permalink / raw)
  To: Joshua Roys
  Cc: netdev, ast, davem, hawk, john.fastabend, daniel, kuba, bpf,
	tariqt, linux-rdma

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Wed, 29 Sep 2021 22:30:23 -0400 you wrote:
> Add counters for XDP REDIRECT success and failure. This brings the
> redirect path in line with metrics gathered via the other XDP paths.
> 
> Signed-off-by: Joshua Roys <roysjosh@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 8 ++++++++
>  drivers/net/ethernet/mellanox/mlx4/en_port.c    | 4 ++++
>  drivers/net/ethernet/mellanox/mlx4/en_rx.c      | 4 +++-
>  drivers/net/ethernet/mellanox/mlx4/mlx4_en.h    | 2 ++
>  drivers/net/ethernet/mellanox/mlx4/mlx4_stats.h | 4 +++-
>  5 files changed, 20 insertions(+), 2 deletions(-)
> 
> [...]

Here is the summary with links:
  - [net-next,v3] net/mlx4_en: Add XDP_REDIRECT statistics
    https://git.kernel.org/netdev/net-next/c/dee3b2d0fa4b

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-09-30 13:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <8d7773a0-054a-84d5-e0b6-66a13509149e@gmail.com>
2021-09-28 13:26 ` [PATCH net-next] net: mlx4: Add XDP_REDIRECT statistics Joshua Roys
2021-09-29 10:19   ` Tariq Toukan
2021-09-30  2:17   ` [PATCH net-next v2] net/mlx4_en: " Joshua Roys
2021-09-30  2:30   ` [PATCH net-next v3] " Joshua Roys
2021-09-30  7:19     ` Tariq Toukan
2021-09-30 13:20     ` patchwork-bot+netdevbpf

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