mempool/cnxk: support telemetry
authorGowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Tue, 19 Oct 2021 11:27:26 +0000 (16:57 +0530)
committerJerin Jacob <jerinj@marvell.com>
Tue, 19 Oct 2021 16:37:15 +0000 (18:37 +0200)
Adding telemetry endpoints to cnxk mempool driver.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Reviewed-by: Harman Kalra <hkalra@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
drivers/mempool/cnxk/cnxk_mempool_telemetry.c [new file with mode: 0644]
drivers/mempool/cnxk/meson.build

diff --git a/drivers/mempool/cnxk/cnxk_mempool_telemetry.c b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
new file mode 100644 (file)
index 0000000..c71798d
--- /dev/null
@@ -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");
+}
index e28a9e0..d5d1978 100644 (file)
@@ -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',
 )