[v10,3/4] mempool/cnxk: add telemetry endpoints mempool

Message ID d6e1bf6348bee98b6d7c91565758d86c4bbe906a.1634642657.git.gmuthukrishn@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series cnxk: enable telemetry endpoints |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Gowrishankar Muthukrishnan Oct. 19, 2021, 11:27 a.m. UTC
  Adding telemetry endpoints to cnxk mempool driver.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Reviewed-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/mempool/cnxk/cnxk_mempool_telemetry.c | 57 +++++++++++++++++++
 drivers/mempool/cnxk/meson.build              |  1 +
 2 files changed, 58 insertions(+)
 create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c
  

Patch

diff --git a/drivers/mempool/cnxk/cnxk_mempool_telemetry.c b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
new file mode 100644
index 0000000000..c71798d7fd
--- /dev/null
+++ b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
@@ -0,0 +1,57 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_mempool.h>
+#include <rte_memzone.h>
+#include <rte_telemetry.h>
+
+#include <roc_api.h>
+
+#include "cnxk_mempool.h"
+#include "cnxk_telemetry.h"
+
+struct mempool_info_cb_arg {
+	char *pool_name;
+	struct rte_tel_data *d;
+};
+
+static void
+mempool_info_cb(struct rte_mempool *mp, void *arg)
+{
+	struct mempool_info_cb_arg *info = (struct mempool_info_cb_arg *)arg;
+	int aura_id;
+
+	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+		return;
+
+	aura_id = roc_npa_aura_handle_to_aura(mp->pool_id);
+	rte_tel_data_add_dict_int(info->d, "aura_id", aura_id);
+}
+
+static int
+mempool_tel_handle_info(const char *cmd __rte_unused, const char *params,
+			struct rte_tel_data *d)
+{
+	struct mempool_info_cb_arg mp_arg;
+	char name[RTE_MEMZONE_NAMESIZE];
+
+	if (params == NULL || strlen(params) == 0)
+		return -EINVAL;
+
+	rte_strlcpy(name, params, RTE_MEMZONE_NAMESIZE);
+
+	rte_tel_data_start_dict(d);
+	mp_arg.pool_name = name;
+	mp_arg.d = d;
+	rte_mempool_walk(mempool_info_cb, &mp_arg);
+
+	return 0;
+}
+
+RTE_INIT(cnxk_mempool_init_telemetry)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/mempool/info", mempool_tel_handle_info,
+		"Returns mempool info. Parameters: pool_name");
+}
diff --git a/drivers/mempool/cnxk/meson.build b/drivers/mempool/cnxk/meson.build
index e28a9e044d..d5d1978569 100644
--- a/drivers/mempool/cnxk/meson.build
+++ b/drivers/mempool/cnxk/meson.build
@@ -11,6 +11,7 @@  endif
 sources = files(
         'cnxk_mempool.c',
         'cnxk_mempool_ops.c',
+        'cnxk_mempool_telemetry.c',
         'cn9k_mempool_ops.c',
         'cn10k_mempool_ops.c',
 )