Skip to contentSkip to conversation

Added hairpin out of buffer counters

PATCH In review Shani Peretz 2 participants 4 messages Jul 1, 2024 – Jul 2, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

cover Added hairpin out of buffer counters

Added global hairpin out of buffer counter (from ethtool) Also added port-level hairpin out of buffer counter.

Shani Peretz (2):
net/mlx5: add global hairpin out of buffer counter net/mlx5: add hairpin out of buffer counter

 doc/guides/nics/mlx5.rst                |  3 ++
 doc/guides/rel_notes/release_24_07.rst  |  2 +
 drivers/net/mlx5/linux/mlx5_ethdev_os.c |  9 +++++
 drivers/net/mlx5/linux/mlx5_os.c        | 14 ++++++-
 drivers/net/mlx5/mlx5.c                 |  4 ++
 drivers/net/mlx5/mlx5.h                 |  4 ++
 drivers/net/mlx5/mlx5_devx.c            | 54 ++++++++++++++++++++++++-
 drivers/net/mlx5/windows/mlx5_os.c      |  1 +
 8 files changed, 89 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 net/mlx5: add global hairpin out of buffer counter

Exposing ethtool dev_internal_queue_oob counter which counts the number of hairpin dropped packets in xstats.

---
 doc/guides/rel_notes/release_24_07.rst  | 1 +
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 4 ++++
 2 files changed, 5 insertions(+)
doc/guides/rel_notes/release_24_07.rst +1 -0
index d4efb5be84..c3e4fa5038 100644
@@ -98,6 +98,7 @@ New Features
   * Added match with external Tx queue.
   * Added match with E-Switch manager.
   * Added flow item and actions validation to async flow API.
+  * Added global out of buffer counter for hairpin queues.
 
 * **Updated TAP driver.**
 
drivers/net/mlx5/linux/mlx5_ethdev_os.c +4 -0
index 70bba6c8e0..7995ac6bbc 100644
@@ -1420,6 +1420,10 @@ static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
 		.ctr_name = "out_of_buffer",
 		.dev = 1,
 	},
+	{
+		.dpdk_name = "dev_internal_queue_oob",
+		.ctr_name = "dev_internal_queue_oob",
+	},
 	{
 		.dpdk_name = "tx_phy_packets",
 		.ctr_name = "tx_packets_phy",
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 net/mlx5: add hairpin out of buffer counter

In reply to Shani Peretz

Currently mlx5 PMD exposes rx_out_of_buffer counter that tracks packets dropped when Rx queue was full.

To provide more granular statistics, this patch splits the rx_out_of_buffer counter into two separate counters:
1. hairpin_out_of_buffer - This counter specifically tracks packets dropped by the device's hairpin Rx queues.
2. rx_out_of_buffer - This counter tracks packets dropped by the device's Rx queues, excluding the hairpin Rx queues.

Two hardware counter objects will be created per device, and all the Rx queues will be assigned to these counters during the configuration phase.

The hairpin_out_of_buffer counter will be created only if there is at least one hairpin Rx queue present on the device.

---
 doc/guides/nics/mlx5.rst                |  3 ++
 doc/guides/rel_notes/release_24_07.rst  |  1 +
 drivers/net/mlx5/linux/mlx5_ethdev_os.c |  5 +++
 drivers/net/mlx5/linux/mlx5_os.c        | 14 ++++++-
 drivers/net/mlx5/mlx5.c                 |  4 ++
 drivers/net/mlx5/mlx5.h                 |  4 ++
 drivers/net/mlx5/mlx5_devx.c            | 54 ++++++++++++++++++++++++-
 drivers/net/mlx5/windows/mlx5_os.c      |  1 +
 8 files changed, 84 insertions(+), 2 deletions(-)
doc/guides/nics/mlx5.rst +3 -0
index 304c6770af..caacc9f62d 100644
@@ -750,6 +750,9 @@ Limitations
 
   - Hairpin between two ports could only manual binding and explicit Tx flow mode. For single port hairpin, all the combinations of auto/manual binding and explicit/implicit Tx flow mode could be supported.
   - Hairpin in switchdev SR-IOV mode is not supported till now.
+  - "out_of_buffer" statistics are not available on:
+     - NICs older than ConnectX-7.
+     - DPUs older than BlueField-3.
 
 - Quota:
 
doc/guides/rel_notes/release_24_07.rst +1 -0
index c3e4fa5038..b9aec2d999 100644
@@ -99,6 +99,7 @@ New Features
   * Added match with E-Switch manager.
   * Added flow item and actions validation to async flow API.
   * Added global out of buffer counter for hairpin queues.
+  * Added port out of buffer counter for hairpin queues.
 
 * **Updated TAP driver.**
 
drivers/net/mlx5/linux/mlx5_ethdev_os.c +5 -0
index 7995ac6bbc..82f651f2f3 100644
@@ -1420,6 +1420,11 @@ static const struct mlx5_counter_ctrl mlx5_counters_init[] = {
 		.ctr_name = "out_of_buffer",
 		.dev = 1,
 	},
+	{
+		.dpdk_name = "hairpin_out_of_buffer",
+		.ctr_name = "hairpin_out_of_buffer",
+		.dev = 1,
+	},
 	{
 		.dpdk_name = "dev_internal_queue_oob",
 		.ctr_name = "dev_internal_queue_oob",
drivers/net/mlx5/linux/mlx5_os.c +13 -1
index 50f4810bff..5e950e9be1 100644
@@ -964,6 +964,8 @@ mlx5_queue_counter_id_prepare(struct rte_eth_dev *dev)
 		DRV_LOG(DEBUG, "Port %d queue counter object cannot be created "
 			"by DevX - fall-back to use the kernel driver global "
 			"queue counter.", dev->data->port_id);
+		priv->q_counters_allocation_failure = 1;
+
 		/* Create WQ by kernel and query its queue counter ID. */
 		if (cq) {
 			wq = mlx5_glue->create_wq(ctx,
@@ -3037,13 +3039,23 @@ mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
 		if (priv->q_counters != NULL &&
 		    strcmp(ctr_name, "out_of_buffer") == 0) {
 			if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
-				DRV_LOG(WARNING, "Devx out_of_buffer counter is not supported in the secondary process");
+				DRV_LOG(WARNING, "DevX out_of_buffer counter is not supported in the secondary process");
 				rte_errno = ENOTSUP;
 				return 1;
 			}
 			return mlx5_devx_cmd_queue_counter_query
 					(priv->q_counters, 0, (uint32_t *)stat);
 		}
+		if (priv->q_counters_hairpin != NULL &&
+		    strcmp(ctr_name, "hairpin_out_of_buffer") == 0) {
+			if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+				DRV_LOG(WARNING, "DevX out_of_buffer counter is not supported in the secondary process");
+				rte_errno = ENOTSUP;
+				return 1;
+			}
+			return mlx5_devx_cmd_queue_counter_query
+					(priv->q_counters_hairpin, 0, (uint32_t *)stat);
+		}
 		MKSTR(path, "%s/ports/%d/hw_counters/%s",
 		      priv->sh->ibdev_path,
 		      priv->dev_port,
drivers/net/mlx5/mlx5.c +4 -0
index e482f7f0e5..8d266b0e64 100644
@@ -2394,6 +2394,10 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 		mlx5_devx_cmd_destroy(priv->q_counters);
 		priv->q_counters = NULL;
 	}
+	if (priv->q_counters_hairpin) {
+		mlx5_devx_cmd_destroy(priv->q_counters_hairpin);
+		priv->q_counters_hairpin = NULL;
+	}
 	mlx5_mprq_free_mp(dev);
 	mlx5_os_free_shared_dr(priv);
 #ifdef HAVE_MLX5_HWS_SUPPORT
drivers/net/mlx5/mlx5.h +4 -0
index bd149b43e5..75a1e170af 100644
@@ -1986,8 +1986,12 @@ struct mlx5_priv {
 	LIST_HEAD(fdir, mlx5_fdir_flow) fdir_flows; /* fdir flows. */
 	rte_spinlock_t shared_act_sl; /* Shared actions spinlock. */
 	uint32_t rss_shared_actions; /* RSS shared actions. */
+	/* If true, indicates that we failed to allocate a q counter in the past. */
+	bool q_counters_allocation_failure;
 	struct mlx5_devx_obj *q_counters; /* DevX queue counter object. */
 	uint32_t counter_set_id; /* Queue counter ID to set in DevX objects. */
+	/* DevX queue counter object for all hairpin queues of the port. */
+	struct mlx5_devx_obj *q_counters_hairpin;
 	uint32_t lag_affinity_idx; /* LAG mode queue 0 affinity starting. */
 	rte_spinlock_t flex_item_sl; /* Flex item list spinlock. */
 	struct mlx5_flex_item flex_item[MLX5_PORT_FLEX_ITEM_NUM];
drivers/net/mlx5/mlx5_devx.c +53 -1

66 lines not on this page · raw message

drivers/net/mlx5/windows/mlx5_os.c +1 -0
index 98022ed3c7..0ebd233595 100644
@@ -83,6 +83,7 @@ mlx5_queue_counter_id_prepare(struct rte_eth_dev *dev)
 		DRV_LOG(ERR, "Port %d queue counter object cannot be created "
 			"by DevX - imissed counter will be unavailable",
 			dev->data->port_id);
+		priv->q_counters_allocation_failure = 1;
 		return;
 	}
 	priv->counter_set_id = priv->q_counters->id;
Signature · 1 line
2.34.1
#3 lore raw
In reply to Shani Peretz

Hi,

From: Shani Peretz <[email protected]>
Sent: Monday, July 1, 2024 9:12 PM
To: [email protected]
Cc: Shani Peretz; Maayan Kashani; Raslan Darawsheh; Dariusz Sosnowski
Subject: [PATCH 0/2] Added hairpin out of buffer counters

Added global hairpin out of buffer counter (from ethtool) Also added port-level hairpin out of buffer counter.

Shani Peretz (2):
net/mlx5: add global hairpin out of buffer counter net/mlx5: add hairpin out of buffer counter

 doc/guides/nics/mlx5.rst                |  3 ++
 doc/guides/rel_notes/release_24_07.rst  |  2 +
 drivers/net/mlx5/linux/mlx5_ethdev_os.c |  9 +++++
 drivers/net/mlx5/linux/mlx5_os.c        | 14 ++++++-
 drivers/net/mlx5/mlx5.c                 |  4 ++
 drivers/net/mlx5/mlx5.h                 |  4 ++
 drivers/net/mlx5/mlx5_devx.c            | 54 ++++++++++++++++++++++++-
 drivers/net/mlx5/windows/mlx5_os.c      |  1 +
 8 files changed, 89 insertions(+), 2 deletions(-)

--
2.34.1

series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh