DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: support the imissed counter on Windows
@ 2021-12-24  6:46 Tal Shnaiderman
  2022-01-09 11:57 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Tal Shnaiderman @ 2021-12-24  6:46 UTC (permalink / raw)
  To: dev; +Cc: thomas, matan, viacheslavo, asafp, khot

Add support for the imissed counter using the DevX API on Windows.

imissed is queried by creating a queue counter for the port, attaching
it to all created RQs and querying the "out_of_buffer" field.

If the counter cannot be created, imissed will always report 0.

Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/common/mlx5/version.map           |  4 ++--
 drivers/net/mlx5/windows/mlx5_ethdev_os.c | 11 ++++++++++-
 drivers/net/mlx5/windows/mlx5_os.c        | 29 ++++++++++++++++++++++++-----
 3 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map
index 34e86004a0..462b7cea5e 100644
--- a/drivers/common/mlx5/version.map
+++ b/drivers/common/mlx5/version.map
@@ -55,8 +55,8 @@ INTERNAL {
 	mlx5_devx_cmd_query_parse_samples;
 	mlx5_devx_cmd_query_virtio_q_counters; # WINDOWS_NO_EXPORT
 	mlx5_devx_cmd_query_virtq;
-	mlx5_devx_cmd_queue_counter_alloc; # WINDOWS_NO_EXPORT
-	mlx5_devx_cmd_queue_counter_query; # WINDOWS_NO_EXPORT
+	mlx5_devx_cmd_queue_counter_alloc;
+	mlx5_devx_cmd_queue_counter_query;
 	mlx5_devx_cmd_register_read;
 	mlx5_devx_cmd_register_write;
 	mlx5_devx_cmd_wq_query; # WINDOWS_NO_EXPORT
diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
index 359f73df7c..c6315ce368 100644
--- a/drivers/net/mlx5/windows/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
@@ -203,7 +203,16 @@ mlx5_os_get_stats_n(struct rte_eth_dev *dev)
 void
 mlx5_os_stats_init(struct rte_eth_dev *dev)
 {
-	RTE_SET_USED(dev);
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_stats_ctrl *stats_ctrl = &priv->stats_ctrl;
+	int ret;
+
+	/* Copy to base at first time. */
+	ret = mlx5_os_read_dev_stat(priv, "out_of_buffer", &stats_ctrl->imissed_base);
+	if (ret)
+		DRV_LOG(ERR, "port %u cannot read device counters: %s",
+			dev->data->port_id, strerror(rte_errno));
+	stats_ctrl->imissed = 0;
 }
 
 /**
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index dec4b923d0..0e31aba892 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -72,6 +72,22 @@ static struct mlx5_indexed_pool_config icfg[] = {
 	},
 };
 
+static void
+mlx5_queue_counter_id_prepare(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	void *ctx = priv->sh->cdev->ctx;
+
+	priv->q_counters = mlx5_devx_cmd_queue_counter_alloc(ctx);
+	if (!priv->q_counters) {
+		DRV_LOG(ERR, "Port %d queue counter object cannot be created "
+			"by DevX - imissed counter will be unavailable",
+			dev->data->port_id);
+		return;
+	}
+	priv->counter_set_id = priv->q_counters->id;
+}
+
 /**
  * Initialize shared data between primary and secondary process.
  *
@@ -655,6 +671,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 		goto error;
 	}
 	mlx5_flow_counter_mode_config(eth_dev);
+	mlx5_queue_counter_id_prepare(eth_dev);
 	return eth_dev;
 error:
 	if (priv) {
@@ -718,7 +735,8 @@ mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh)
  * @param[out] stat
  *   Pointer to read statistic value.
  * @return
- *   0 on success and stat is valud, 1 if failed to read the value
+ *   0 on success and stat is valid, non-zero if failed to read the value
+ *   or counter is not supported.
  *   rte_errno is set.
  *
  */
@@ -726,10 +744,11 @@ int
 mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
 		      uint64_t *stat)
 {
-	RTE_SET_USED(priv);
-	RTE_SET_USED(ctr_name);
-	RTE_SET_USED(stat);
-	DRV_LOG(WARNING, "%s: is not supported", __func__);
+	if (priv->q_counters != NULL && strcmp(ctr_name, "out_of_buffer") == 0)
+		return mlx5_devx_cmd_queue_counter_query
+				(priv->q_counters, 0, (uint32_t *)stat);
+	DRV_LOG(WARNING, "%s: is not supported for the %s counter",
+		__func__, ctr_name);
 	return -ENOTSUP;
 }
 
-- 
2.16.1.windows.4


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

* RE: [PATCH] net/mlx5: support the imissed counter on Windows
  2021-12-24  6:46 [PATCH] net/mlx5: support the imissed counter on Windows Tal Shnaiderman
@ 2022-01-09 11:57 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2022-01-09 11:57 UTC (permalink / raw)
  To: Tal Shnaiderman, dev
  Cc: NBU-Contact-Thomas Monjalon (EXTERNAL),
	Matan Azrad, Slava Ovsiienko, Asaf Penso, Khoa To

Hi,

> -----Original Message-----
> From: Tal Shnaiderman <talshn@nvidia.com>
> Sent: Friday, December 24, 2021 8:47 AM
> To: dev@dpdk.org
> Cc: NBU-Contact-Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>;
> Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Asaf Penso <asafp@nvidia.com>; Khoa To
> <khot@microsoft.com>
> Subject: [PATCH] net/mlx5: support the imissed counter on Windows
> 
> Add support for the imissed counter using the DevX API on Windows.
> 
> imissed is queried by creating a queue counter for the port, attaching
> it to all created RQs and querying the "out_of_buffer" field.
> 
> If the counter cannot be created, imissed will always report 0.
> 
> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2022-01-09 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-24  6:46 [PATCH] net/mlx5: support the imissed counter on Windows Tal Shnaiderman
2022-01-09 11:57 ` Raslan Darawsheh

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