All of lore.kernel.org
 help / color / mirror / Atom feed
* [dpdk-dev] [v1, 0/3] common/cnxk: enable npa telemetry
@ 2021-07-29 15:25 Gowrishankar Muthukrishnan
  2021-07-29 15:25 ` [dpdk-dev] [v1, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
                   ` (3 more replies)
  0 siblings, 4 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-07-29 15:25 UTC (permalink / raw)
  To: dev
  Cc: ciara.power, jerinj, kirankumark, ndabilpuram, skori, skoteshwar,
	Gowrishankar Muthukrishnan

This patch series enables telemetry in NPA LF of cnxk.

Gowrishankar Muthukrishnan (3):
  telemetry: enable storing pointer value
  test/telemetry: add unit tests for pointer value
  common/cnxk: add telemetry endpoints to npa

 app/test/test_telemetry_data.c           | 124 +++++++++++++
 app/test/test_telemetry_json.c           |  28 ++-
 drivers/common/cnxk/cnxk_telemetry.h     |  23 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 227 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   4 +
 drivers/common/cnxk/roc_platform.h       |   8 +
 lib/telemetry/rte_telemetry.h            |  37 +++-
 lib/telemetry/telemetry.c                |  21 ++-
 lib/telemetry/telemetry_data.c           |  40 +++-
 lib/telemetry/telemetry_data.h           |   2 +
 lib/telemetry/telemetry_json.h           |  31 ++++
 lib/telemetry/version.map                |   2 +
 12 files changed, 533 insertions(+), 14 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

-- 
2.25.1


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

* [dpdk-dev] [v1, 1/3] telemetry: enable storing pointer value
  2021-07-29 15:25 [dpdk-dev] [v1, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
@ 2021-07-29 15:25 ` Gowrishankar Muthukrishnan
  2021-07-29 15:48   ` Bruce Richardson
  2021-07-29 15:25 ` [dpdk-dev] [v1, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-07-29 15:25 UTC (permalink / raw)
  To: dev
  Cc: ciara.power, jerinj, kirankumark, ndabilpuram, skori, skoteshwar,
	Gowrishankar Muthukrishnan

At present, value of pointer variable or address can only be
stored in u64 type which is slightly not human readable, hence
this patch is. It adds telemetry support to store pointer value,
which is stringified.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 lib/telemetry/rte_telemetry.h  | 37 ++++++++++++++++++++++++++++++-
 lib/telemetry/telemetry.c      | 21 ++++++++++++++++--
 lib/telemetry/telemetry_data.c | 40 ++++++++++++++++++++++++++++++----
 lib/telemetry/telemetry_data.h |  2 ++
 lib/telemetry/telemetry_json.h | 31 ++++++++++++++++++++++++++
 lib/telemetry/version.map      |  2 ++
 6 files changed, 126 insertions(+), 7 deletions(-)

diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index 8776998b54..4c453d35d7 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -46,7 +46,8 @@ enum rte_tel_value_type {
 	RTE_TEL_STRING_VAL, /** a string value */
 	RTE_TEL_INT_VAL,    /** a signed 32-bit int value */
 	RTE_TEL_U64_VAL,    /** an unsigned 64-bit int value */
-	RTE_TEL_CONTAINER, /** a container struct */
+	RTE_TEL_CONTAINER,  /** a container struct */
+	RTE_TEL_PTR_VAL,    /** a pointer value */
 };
 
 /**
@@ -137,6 +138,22 @@ __rte_experimental
 int
 rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x);
 
+/**
+ * Add a pointer value to an array.
+ * The array must have been started by rte_tel_data_start_array() with
+ * RTE_TEL_PTR_VAL as the type parameter.
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param x
+ *   The pointer value to be returned in the array
+ * @return
+ *   0 on success, negative errno on error
+ */
+__rte_experimental
+int
+rte_tel_data_add_array_ptr(struct rte_tel_data *d, void *x);
+
 /**
  * Add a container to an array. A container is an existing telemetry data
  * array. The array the container is to be added to must have been started by
@@ -213,6 +230,24 @@ int
 rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 		const char *name, uint64_t val);
 
+/**
+ * Add a pointer value to a dictionary.
+ * The dict must have been started by rte_tel_data_start_dict().
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param name
+ *   The name the value is to be stored under in the dict
+ * @param val
+ *   The pointer value to be stored in the dict
+ * @return
+ *   0 on success, negative errno on error, E2BIG on string truncation of name.
+ */
+__rte_experimental
+int
+rte_tel_data_add_dict_ptr(struct rte_tel_data *d,
+		const char *name, void *ptr);
+
 /**
  * Add a container to a dictionary. A container is an existing telemetry data
  * array. The dict the container is to be added to must have been started by
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 8665db8d03..5842b28740 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -157,8 +157,10 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 	size_t used = 0;
 	unsigned int i;
 
-	if (d->type != RTE_TEL_ARRAY_U64 && d->type != RTE_TEL_ARRAY_INT
-			&& d->type != RTE_TEL_ARRAY_STRING)
+	if (d->type != RTE_TEL_ARRAY_U64
+		&& d->type != RTE_TEL_ARRAY_INT
+		&& d->type != RTE_TEL_ARRAY_PTR
+		&& d->type != RTE_TEL_ARRAY_STRING)
 		return snprintf(out_buf, buf_len, "null");
 
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
@@ -167,6 +169,11 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 			used = rte_tel_json_add_array_u64(out_buf,
 				buf_len, used,
 				d->data.array[i].u64val);
+	if (d->type == RTE_TEL_ARRAY_PTR)
+		for (i = 0; i < d->data_len; i++)
+			used = rte_tel_json_add_array_ptr(out_buf,
+				buf_len, used,
+				d->data.array[i].ptrval);
 	if (d->type == RTE_TEL_ARRAY_INT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_int(out_buf,
@@ -226,6 +233,11 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						buf_len, used,
 						v->name, v->value.u64val);
 				break;
+			case RTE_TEL_PTR_VAL:
+				used = rte_tel_json_add_obj_ptr(cb_data_buf,
+						buf_len, used,
+						v->name, v->value.ptrval);
+				break;
 			case RTE_TEL_CONTAINER:
 			{
 				char temp[buf_len];
@@ -248,6 +260,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 	case RTE_TEL_ARRAY_STRING:
 	case RTE_TEL_ARRAY_INT:
 	case RTE_TEL_ARRAY_U64:
+	case RTE_TEL_ARRAY_PTR:
 	case RTE_TEL_ARRAY_CONTAINER:
 		prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":",
 				MAX_CMD_LEN, cmd);
@@ -269,6 +282,10 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 				used = rte_tel_json_add_array_u64(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].u64val);
+			else if (d->type == RTE_TEL_ARRAY_PTR)
+				used = rte_tel_json_add_array_ptr(cb_data_buf,
+						buf_len, used,
+						d->data.array[i].ptrval);
 			else if (d->type == RTE_TEL_ARRAY_CONTAINER) {
 				char temp[buf_len];
 				const struct container *rec_data =
diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c
index 77b0fe09a5..9384f48589 100644
--- a/lib/telemetry/telemetry_data.c
+++ b/lib/telemetry/telemetry_data.c
@@ -15,6 +15,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 			RTE_TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
 			RTE_TEL_ARRAY_U64,    /* RTE_TEL_u64_VAL = 2 */
 			RTE_TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			RTE_TEL_ARRAY_PTR,    /* RTE_TEL_PTR_VAL = 4 */
 	};
 	d->type = array_types[type];
 	d->data_len = 0;
@@ -75,6 +76,17 @@ rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
 	return 0;
 }
 
+int
+rte_tel_data_add_array_ptr(struct rte_tel_data *d, void *x)
+{
+	if (d->type != RTE_TEL_ARRAY_PTR)
+		return -EINVAL;
+	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
+		return -ENOSPC;
+	d->data.array[d->data_len++].ptrval = x;
+	return 0;
+}
+
 int
 rte_tel_data_add_array_container(struct rte_tel_data *d,
 		struct rte_tel_data *val, int keep)
@@ -82,7 +94,8 @@ rte_tel_data_add_array_container(struct rte_tel_data *d,
 	if (d->type != RTE_TEL_ARRAY_CONTAINER ||
 			(val->type != RTE_TEL_ARRAY_U64
 			&& val->type != RTE_TEL_ARRAY_INT
-			&& val->type != RTE_TEL_ARRAY_STRING))
+			&& val->type != RTE_TEL_ARRAY_STRING
+			&& val->type != RTE_TEL_ARRAY_PTR))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -147,15 +160,34 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
 }
 
+int
+rte_tel_data_add_dict_ptr(struct rte_tel_data *d,
+		const char *name, void *ptr)
+{
+	struct tel_dict_entry *e = &d->data.dict[d->data_len];
+	if (d->type != RTE_TEL_DICT)
+		return -EINVAL;
+	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
+		return -ENOSPC;
+
+	d->data_len++;
+	e->type = RTE_TEL_PTR_VAL;
+	e->value.ptrval = ptr;
+	const size_t bytes = strlcpy(e->name, name, RTE_TEL_MAX_STRING_LEN);
+	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
+}
+
 int
 rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name,
 		struct rte_tel_data *val, int keep)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 
-	if (d->type != RTE_TEL_DICT || (val->type != RTE_TEL_ARRAY_U64
-			&& val->type != RTE_TEL_ARRAY_INT
-			&& val->type != RTE_TEL_ARRAY_STRING))
+	if (d->type != RTE_TEL_DICT ||
+		(val->type != RTE_TEL_ARRAY_U64
+		 && val->type != RTE_TEL_ARRAY_INT
+		 && val->type != RTE_TEL_ARRAY_STRING
+		 && val->type != RTE_TEL_ARRAY_PTR))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h
index adb84a09f1..bb361e3bcc 100644
--- a/lib/telemetry/telemetry_data.h
+++ b/lib/telemetry/telemetry_data.h
@@ -16,6 +16,7 @@ enum tel_container_types {
 	RTE_TEL_ARRAY_INT,    /** array of signed, 32-bit int values */
 	RTE_TEL_ARRAY_U64,    /** array of unsigned 64-bit int values */
 	RTE_TEL_ARRAY_CONTAINER, /** array of container structs */
+	RTE_TEL_ARRAY_PTR,    /** array of pointer values */
 };
 
 struct container {
@@ -31,6 +32,7 @@ union tel_value {
 	char sval[RTE_TEL_MAX_STRING_LEN];
 	int ival;
 	uint64_t u64val;
+	void *ptrval;
 	struct container container;
 };
 
diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index ad270b9b30..96762fc267 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -102,6 +102,19 @@ rte_tel_json_add_array_u64(char *buf, const int len, const int used,
 	return ret == 0 ? used : end + ret;
 }
 
+/* Appends a pointer value into the JSON array in the provided buffer. */
+static inline int
+rte_tel_json_add_array_ptr(char *buf, const int len, const int used,
+		void *ptr)
+{
+	int ret, end = used - 1; /* strip off final delimiter */
+	if (used <= 2) /* assume empty, since minimum is '[]' */
+		return __json_snprintf(buf, len, "[\"%p\"]", ptr);
+
+	ret = __json_snprintf(buf + end, len - end, ",\"%p\"]", ptr);
+	return ret == 0 ? used : end + ret;
+}
+
 /*
  * Add a new element with raw JSON value to the JSON array stored in the
  * provided buffer.
@@ -136,6 +149,24 @@ rte_tel_json_add_obj_u64(char *buf, const int len, const int used,
 	return ret == 0 ? used : end + ret;
 }
 
+/**
+ * Add a new element with uint64_t value to the JSON object stored in the
+ * provided buffer.
+ */
+static inline int
+rte_tel_json_add_obj_ptr(char *buf, const int len, const int used,
+		const char *name, void *ptr)
+{
+	int ret, end = used - 1;
+	if (used <= 2) /* assume empty, since minimum is '{}' */
+		return __json_snprintf(buf, len, "{\"%s\":\"%p\"}", name,
+				ptr);
+
+	ret = __json_snprintf(buf + end, len - end, ",\"%s\":\"%p\"}",
+			name, ptr);
+	return ret == 0 ? used : end + ret;
+}
+
 /**
  * Add a new element with int value to the JSON object stored in the
  * provided buffer.
diff --git a/lib/telemetry/version.map b/lib/telemetry/version.map
index bde80ce29b..d919340bc6 100644
--- a/lib/telemetry/version.map
+++ b/lib/telemetry/version.map
@@ -5,10 +5,12 @@ EXPERIMENTAL {
 	rte_tel_data_add_array_int;
 	rte_tel_data_add_array_string;
 	rte_tel_data_add_array_u64;
+	rte_tel_data_add_array_ptr;
 	rte_tel_data_add_dict_container;
 	rte_tel_data_add_dict_int;
 	rte_tel_data_add_dict_string;
 	rte_tel_data_add_dict_u64;
+	rte_tel_data_add_dict_ptr;
 	rte_tel_data_alloc;
 	rte_tel_data_free;
 	rte_tel_data_start_array;
-- 
2.25.1


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

* [dpdk-dev] [v1, 2/3] test/telemetry: add unit tests for pointer value
  2021-07-29 15:25 [dpdk-dev] [v1, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
  2021-07-29 15:25 ` [dpdk-dev] [v1, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
@ 2021-07-29 15:25 ` Gowrishankar Muthukrishnan
  2021-07-29 15:25 ` [dpdk-dev] [v1, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
  2021-08-01 17:37 ` [dpdk-dev] [v2, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-07-29 15:25 UTC (permalink / raw)
  To: dev
  Cc: ciara.power, jerinj, kirankumark, ndabilpuram, skori, skoteshwar,
	Gowrishankar Muthukrishnan

Adding tests to evaluate pointer value in array and dict.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 app/test/test_telemetry_data.c | 124 +++++++++++++++++++++++++++++++++
 app/test/test_telemetry_json.c |  28 ++++++--
 2 files changed, 145 insertions(+), 7 deletions(-)

diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c
index f34d691265..59f68f135a 100644
--- a/app/test/test_telemetry_data.c
+++ b/app/test/test_telemetry_data.c
@@ -301,6 +301,126 @@ test_array_with_array_u64_values(void)
 	return TEST_OUTPUT("{\"/test\":[[0,1,2,3,4],[0,1,2,3,4]]}");
 }
 
+static int
+test_case_array_ptr(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char exp[120];
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_array(&response_data, RTE_TEL_PTR_VAL);
+
+	i = sprintf(exp, "{\"/test\":[");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		i += sprintf(exp + i, "\"%p\",", p);
+		rte_tel_data_add_array_ptr(&response_data, p);
+	}
+
+	sprintf(exp + i - 1, "]}");
+	return TEST_OUTPUT(exp);
+}
+
+static int
+test_case_add_dict_ptr(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char name[8], exp[160];
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_dict(&response_data);
+
+	i = sprintf(exp, "{\"/test\":{");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		sprintf(name, "dict_%d", j);
+		i += sprintf(exp + i, "\"%s\":\"%p\",", name, p);
+		rte_tel_data_add_dict_ptr(&response_data, name, p);
+	}
+
+	sprintf(exp + i - 1, "}}");
+	return TEST_OUTPUT(exp);
+}
+
+static int
+test_dict_with_array_ptr_values(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char exp[256];
+
+	struct rte_tel_data *child_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data, RTE_TEL_PTR_VAL);
+
+	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data2, RTE_TEL_PTR_VAL);
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_dict(&response_data);
+
+	i = sprintf(exp, "{\"/test\":{\"dict_0\":[");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		i += sprintf(exp + i, "\"%p\",", p);
+		rte_tel_data_add_array_ptr(child_data, p);
+	}
+
+	i += sprintf(exp + i - 1, "],\"dict_1\":[");
+	for (j = 5; j > 0; j--) {
+		p = &a[j - 1];
+		i += sprintf(exp + i - 1, "\"%p\",", p);
+		rte_tel_data_add_array_ptr(child_data2, p);
+	}
+
+	sprintf(exp + i - 2, "]}}");
+	rte_tel_data_add_dict_container(&response_data, "dict_0",
+								child_data, 0);
+	rte_tel_data_add_dict_container(&response_data, "dict_1",
+								child_data2, 0);
+
+	return TEST_OUTPUT(exp);
+}
+
+static int
+test_array_with_array_ptr_values(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char exp[256];
+
+	struct rte_tel_data *child_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data, RTE_TEL_PTR_VAL);
+
+	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data2, RTE_TEL_PTR_VAL);
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER);
+
+	i = sprintf(exp, "{\"/test\":[[");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		i += sprintf(exp + i, "\"%p\",", p);
+		rte_tel_data_add_array_ptr(child_data, p);
+	}
+
+	i += sprintf(exp + i - 1, "],[");
+	for (j = 5; j > 0; j--) {
+		p = &a[j - 1];
+		i += sprintf(exp + i - 1, "\"%p\",", p);
+		rte_tel_data_add_array_ptr(child_data2, p);
+	}
+
+	sprintf(exp + i - 2, "]]}");
+
+	rte_tel_data_add_array_container(&response_data, child_data, 0);
+	rte_tel_data_add_array_container(&response_data, child_data2, 0);
+
+	return TEST_OUTPUT(exp);
+}
+
 static int
 connect_to_socket(void)
 {
@@ -350,13 +470,17 @@ test_telemetry_data(void)
 
 	test_case test_cases[] = {test_case_array_string,
 			test_case_array_int, test_case_array_u64,
+			test_case_array_ptr,
 			test_case_add_dict_int, test_case_add_dict_u64,
+			test_case_add_dict_ptr,
 			test_case_add_dict_string,
 			test_dict_with_array_int_values,
 			test_dict_with_array_u64_values,
+			test_dict_with_array_ptr_values,
 			test_dict_with_array_string_values,
 			test_array_with_array_int_values,
 			test_array_with_array_u64_values,
+			test_array_with_array_ptr_values,
 			test_array_with_array_string_values };
 
 	rte_telemetry_register_cmd(REQUEST_CMD, test_cb, "Test");
diff --git a/app/test/test_telemetry_json.c b/app/test/test_telemetry_json.c
index 790181d316..3e8e60638c 100644
--- a/app/test/test_telemetry_json.c
+++ b/app/test/test_telemetry_json.c
@@ -11,18 +11,22 @@
 static int
 test_basic_array(void)
 {
-	const char *expected = "[\"meaning of life\",42]";
-	char buf[1024];
-	int used = 0;
+	char buf[1024], expected[80];
+	int used = 0, n = 42, *p;
 
 	printf("%s: ", __func__);
 	used = rte_tel_json_empty_array(buf, sizeof(buf), used);
 	if (used != 2 || strcmp(buf, "[]"))
 		return -1;
 
+	p = &n;
+	memset(expected, 0, sizeof(expected));
+	sprintf(expected, "[\"meaning of life\",42,\"%p\"]", p);
+
 	used = rte_tel_json_add_array_string(buf, sizeof(buf), used,
 		"meaning of life");
-	used = rte_tel_json_add_array_int(buf, sizeof(buf), used, 42);
+	used = rte_tel_json_add_array_int(buf, sizeof(buf), used, n);
+	used = rte_tel_json_add_array_ptr(buf, sizeof(buf), used, p);
 
 	printf("buf = '%s', expected = '%s'\n", buf, expected);
 	if (used != (int)strlen(expected))
@@ -33,14 +37,24 @@ test_basic_array(void)
 static int
 test_basic_obj(void)
 {
-	const char *expected = "{\"weddings\":4,\"funerals\":1}";
-	char buf[1024];
-	int used = 0;
+	char buf[1024], expected[80];
+	int used = 0, n = 42, *p;
+
+	p = &n;
+	memset(expected, 0, sizeof(expected));
+	sprintf(expected,
+			"{\"weddings\":4,\"funerals\":1,"
+			"\"address\":\"%p\",\"reset\":\"(nil)\"}", p);
 
 	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
 		"weddings", 4);
 	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
 		"funerals", 1);
+	used = rte_tel_json_add_obj_ptr(buf, sizeof(buf), used,
+		"address", p);
+	p = NULL;
+	used = rte_tel_json_add_obj_ptr(buf, sizeof(buf), used,
+		"reset", p);
 
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
 	if (used != (int)strlen(expected))
-- 
2.25.1


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

* [dpdk-dev] [v1, 3/3] common/cnxk: add telemetry endpoints to npa
  2021-07-29 15:25 [dpdk-dev] [v1, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
  2021-07-29 15:25 ` [dpdk-dev] [v1, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
  2021-07-29 15:25 ` [dpdk-dev] [v1, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
@ 2021-07-29 15:25 ` Gowrishankar Muthukrishnan
  2021-08-01 17:37 ` [dpdk-dev] [v2, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-07-29 15:25 UTC (permalink / raw)
  To: dev
  Cc: ciara.power, jerinj, kirankumark, ndabilpuram, skori, skoteshwar,
	Gowrishankar Muthukrishnan

Add telemetry endpoints to npa.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry.h     |  23 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 227 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   4 +
 drivers/common/cnxk/roc_platform.h       |   8 +
 4 files changed, 262 insertions(+)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

diff --git a/drivers/common/cnxk/cnxk_telemetry.h b/drivers/common/cnxk/cnxk_telemetry.h
new file mode 100644
index 0000000000..9ac1487020
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Marvell.
+ */
+
+#ifndef __CNXK_TELEMETRY_H_
+#define __CNXK_TELEMETRY_H_
+
+#define CNXK_TEL_STR(s)		  #s
+#define CNXK_TEL_STR_PREFIX(s, p) CNXK_TEL_STR(p##s)
+#define CNXK_TEL_DICT_INT(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_int(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_PTR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(p)->s)
+#define CNXK_TEL_DICT_BF_PTR(d, p, s, ...)                                     \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(uint64_t)(p)->s)
+#define CNXK_TEL_DICT_U64(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_u64(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+
+#endif /* __CNXK_TELEMETRY_H_ */
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
new file mode 100644
index 0000000000..1c2c2cd106
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -0,0 +1,227 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+#include <rte_telemetry.h>
+
+static int
+cnxk_tel_npa(struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int aura_cnt = 0;
+	uint32_t i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	for (i = 0; i < lf->nr_pools; i++) {
+		if (plt_bitmap_get(lf->npa_bmp, i))
+			continue;
+		aura_cnt++;
+	}
+
+	plt_tel_data_add_dict_ptr(d, "npa", lf);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
+
+	CNXK_TEL_DICT_PTR(d, lf, pci_dev);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
+	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
+	CNXK_TEL_DICT_PTR(d, lf, intr_handle);
+	CNXK_TEL_DICT_PTR(d, lf, mbox);
+	CNXK_TEL_DICT_PTR(d, lf, base);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
+	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
+	CNXK_TEL_DICT_INT(d, lf, nr_pools);
+	CNXK_TEL_DICT_INT(d, lf, pf_func);
+	CNXK_TEL_DICT_INT(d, lf, aura_sz);
+	CNXK_TEL_DICT_INT(d, lf, qints);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
+{
+	__io struct npa_aura_s *aura;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (rte_bitmap_get(lf->npa_bmp, aura_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_AURA;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", aura_id);
+		return rc;
+	}
+
+	aura = &rsp->aura;
+	CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
+	CNXK_TEL_DICT_INT(d, aura, ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
+	CNXK_TEL_DICT_U64(d, aura, count, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
+	CNXK_TEL_DICT_U64(d, aura, limit, w3_);
+	CNXK_TEL_DICT_INT(d, aura, bp, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
+	CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
+	CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
+{
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (rte_bitmap_get(lf->npa_bmp, pool_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = pool_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", pool_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
+	CNXK_TEL_DICT_INT(d, pool, ena, w1_);
+	CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
+	CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
+	CNXK_TEL_DICT_INT(d, pool, shift, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
+	CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
+	CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
+	CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info(const char *cmd __rte_unused,
+			 const char *params __rte_unused,
+			 struct rte_tel_data *d)
+{
+	plt_tel_data_start_dict(d);
+	cnxk_tel_npa(d);
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
+			   struct rte_tel_data *d)
+{
+	int id, rc;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	id = atoi(params);
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "aura/info"))
+		rc = cnxk_tel_npa_aura(id, d);
+	else
+		rc = cnxk_tel_npa_pool(id, d);
+
+	return rc;
+}
+
+RTE_INIT(cnxk_telemetry_npa_init)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
+		"Returns npa information. Takes no parameters");
+
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa aura information. Parameters: aura_id");
+
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa pool information. Parameters: pool_id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index 6a7849f31c..3cc9a2ff37 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -60,5 +60,9 @@ sources = files(
 # Security common code
 sources += files('cnxk_security.c')
 
+# Telemetry common code
+sources += files('cnxk_telemetry_npa.c')
+
 includes += include_directories('../../bus/pci')
 includes += include_directories('../../../lib/net')
+includes += include_directories('../../../lib/telemetry')
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 285b24b82d..9fcaee8254 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -19,6 +19,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "roc_bits.h"
 
@@ -139,6 +140,13 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define plt_tel_data                 rte_tel_data
+#define plt_tel_data_start_dict      rte_tel_data_start_dict
+#define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
+#define plt_tel_data_add_dict_ptr    rte_tel_data_add_dict_ptr
+#define plt_tel_data_add_dict_string rte_tel_data_add_dict_string
+#define plt_tel_data_add_dict_u64    rte_tel_data_add_dict_u64
+
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
-- 
2.25.1


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

* Re: [dpdk-dev] [v1, 1/3] telemetry: enable storing pointer value
  2021-07-29 15:25 ` [dpdk-dev] [v1, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
@ 2021-07-29 15:48   ` Bruce Richardson
  2021-07-30 12:08     ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
  0 siblings, 1 reply; 121+ messages in thread
From: Bruce Richardson @ 2021-07-29 15:48 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan
  Cc: dev, ciara.power, jerinj, kirankumark, ndabilpuram, skori, skoteshwar

On Thu, Jul 29, 2021 at 08:55:35PM +0530, Gowrishankar Muthukrishnan wrote:
> At present, value of pointer variable or address can only be
> stored in u64 type which is slightly not human readable, hence
> this patch is. It adds telemetry support to store pointer value,
> which is stringified.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---

I'm a little curious as to the usefulness of having a pointer value in
telemetry output? How would a telemetry user be expected to use pointer
information returned? Printing pointers seems something more useful for a
debugging or tracing interface than a telemetry one.

Regards,
/Bruce

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

* Re: [dpdk-dev] [EXT] Re:  [v1, 1/3] telemetry: enable storing pointer value
  2021-07-29 15:48   ` Bruce Richardson
@ 2021-07-30 12:08     ` Gowrishankar Muthukrishnan
  2021-08-01 17:40       ` Gowrishankar Muthukrishnan
  0 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-07-30 12:08 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: dev, ciara.power, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda, Nithin Kumar Dabilpuram,
	Sunil Kumar Kori, Satha Koteswara Rao Kottidi

Hi Bruce,

> I'm a little curious as to the usefulness of having a pointer value in telemetry
> output? How would a telemetry user be expected to use pointer information
> returned? Printing pointers seems something more useful for a debugging or
> tracing interface than a telemetry one.
> 

Thanks for the quick review. I enabled _ptr API keeping few things in mind:

1. User need to explicitly type cast pointer value (ie address) to uint64_t
    which otherwise can cause compiler warning (Wint-conversion). Although
    u64 is large enough for holding address as value, type casting is problematic
    for non-64 bit machines (eg 32 bit). One other option is to use uintptr_t
    as a holder.

2. With this API, code walk could be easier as user can interpret the accessed
     data better (ie ptr is address value). _ptr API is meant for pointer variables,
     though it is up to user to choose.

3. Also while debugging telemetry date using script like usertools/dpdk-telemetry.py,
    perceiving address as hex is quicker than same as u64.

Answering on returned data, user needs to convert stringified hex to pointer value.

Regards,
Gowrishankar

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

* [dpdk-dev] [v2, 0/3] common/cnxk: enable npa telemetry
  2021-07-29 15:25 [dpdk-dev] [v1, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
                   ` (2 preceding siblings ...)
  2021-07-29 15:25 ` [dpdk-dev] [v1, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-08-01 17:37 ` Gowrishankar Muthukrishnan
  2021-08-01 17:37   ` [dpdk-dev] [v2, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
                     ` (3 more replies)
  3 siblings, 4 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-01 17:37 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, Gowrishankar Muthukrishnan

This patch series enables telemetry in NPA LF of cnxk.

v2:
  * using uintptr_t to encode pointer value in json.

*** BLURB HERE ***

Gowrishankar Muthukrishnan (3):
  telemetry: enable storing pointer value
  test/telemetry: add unit tests for pointer value
  common/cnxk: add telemetry endpoints to npa

 app/test/test_telemetry_data.c           | 124 +++++++++++++
 app/test/test_telemetry_json.c           |  28 ++-
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 227 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   4 +
 drivers/common/cnxk/roc_platform.h       |   8 +
 lib/telemetry/rte_telemetry.h            |  37 +++-
 lib/telemetry/telemetry.c                |  21 ++-
 lib/telemetry/telemetry_data.c           |  40 +++-
 lib/telemetry/telemetry_data.h           |   2 +
 lib/telemetry/telemetry_json.h           |  31 ++++
 lib/telemetry/version.map                |   2 +
 12 files changed, 536 insertions(+), 14 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

-- 
2.25.1


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

* [dpdk-dev] [v2, 1/3] telemetry: enable storing pointer value
  2021-08-01 17:37 ` [dpdk-dev] [v2, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
@ 2021-08-01 17:37   ` Gowrishankar Muthukrishnan
  2021-08-01 17:37   ` [dpdk-dev] [v2, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-01 17:37 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, Gowrishankar Muthukrishnan

At present, value of pointer variable or address is stored in
u64 type which may not properly work in non64 bit arch. Hence,
this patch adds new API to store it in void*. JSON encoding is
after converting to uintptr_t so, address value is correctly
casted as per arch as well. Once JSON5 support is available
at JSON clients, hex value of address can be encoded instead
of uintptr_t.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 lib/telemetry/rte_telemetry.h  | 37 ++++++++++++++++++++++++++++++-
 lib/telemetry/telemetry.c      | 21 ++++++++++++++++--
 lib/telemetry/telemetry_data.c | 40 ++++++++++++++++++++++++++++++----
 lib/telemetry/telemetry_data.h |  2 ++
 lib/telemetry/telemetry_json.h | 31 ++++++++++++++++++++++++++
 lib/telemetry/version.map      |  2 ++
 6 files changed, 126 insertions(+), 7 deletions(-)

diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index 8776998b54..6a420f918c 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -46,7 +46,8 @@ enum rte_tel_value_type {
 	RTE_TEL_STRING_VAL, /** a string value */
 	RTE_TEL_INT_VAL,    /** a signed 32-bit int value */
 	RTE_TEL_U64_VAL,    /** an unsigned 64-bit int value */
-	RTE_TEL_CONTAINER, /** a container struct */
+	RTE_TEL_CONTAINER,  /** a container struct */
+	RTE_TEL_PTR_VAL,    /** a pointer value */
 };
 
 /**
@@ -137,6 +138,22 @@ __rte_experimental
 int
 rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x);
 
+/**
+ * Add a pointer value to an array.
+ * The array must have been started by rte_tel_data_start_array() with
+ * RTE_TEL_PTR_VAL as the type parameter.
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param x
+ *   The pointer value to be returned in the array
+ * @return
+ *   0 on success, negative errno on error
+ */
+__rte_experimental
+int
+rte_tel_data_add_array_ptr(struct rte_tel_data *d, void *x);
+
 /**
  * Add a container to an array. A container is an existing telemetry data
  * array. The array the container is to be added to must have been started by
@@ -213,6 +230,24 @@ int
 rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 		const char *name, uint64_t val);
 
+/**
+ * Add a pointer value to a dictionary.
+ * The dict must have been started by rte_tel_data_start_dict().
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param name
+ *   The name the value is to be stored under in the dict
+ * @param ptr
+ *   The pointer value to be stored in the dict
+ * @return
+ *   0 on success, negative errno on error, E2BIG on string truncation of name.
+ */
+__rte_experimental
+int
+rte_tel_data_add_dict_ptr(struct rte_tel_data *d,
+		const char *name, void *ptr);
+
 /**
  * Add a container to a dictionary. A container is an existing telemetry data
  * array. The dict the container is to be added to must have been started by
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 8665db8d03..5842b28740 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -157,8 +157,10 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 	size_t used = 0;
 	unsigned int i;
 
-	if (d->type != RTE_TEL_ARRAY_U64 && d->type != RTE_TEL_ARRAY_INT
-			&& d->type != RTE_TEL_ARRAY_STRING)
+	if (d->type != RTE_TEL_ARRAY_U64
+		&& d->type != RTE_TEL_ARRAY_INT
+		&& d->type != RTE_TEL_ARRAY_PTR
+		&& d->type != RTE_TEL_ARRAY_STRING)
 		return snprintf(out_buf, buf_len, "null");
 
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
@@ -167,6 +169,11 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 			used = rte_tel_json_add_array_u64(out_buf,
 				buf_len, used,
 				d->data.array[i].u64val);
+	if (d->type == RTE_TEL_ARRAY_PTR)
+		for (i = 0; i < d->data_len; i++)
+			used = rte_tel_json_add_array_ptr(out_buf,
+				buf_len, used,
+				d->data.array[i].ptrval);
 	if (d->type == RTE_TEL_ARRAY_INT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_int(out_buf,
@@ -226,6 +233,11 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						buf_len, used,
 						v->name, v->value.u64val);
 				break;
+			case RTE_TEL_PTR_VAL:
+				used = rte_tel_json_add_obj_ptr(cb_data_buf,
+						buf_len, used,
+						v->name, v->value.ptrval);
+				break;
 			case RTE_TEL_CONTAINER:
 			{
 				char temp[buf_len];
@@ -248,6 +260,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 	case RTE_TEL_ARRAY_STRING:
 	case RTE_TEL_ARRAY_INT:
 	case RTE_TEL_ARRAY_U64:
+	case RTE_TEL_ARRAY_PTR:
 	case RTE_TEL_ARRAY_CONTAINER:
 		prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":",
 				MAX_CMD_LEN, cmd);
@@ -269,6 +282,10 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 				used = rte_tel_json_add_array_u64(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].u64val);
+			else if (d->type == RTE_TEL_ARRAY_PTR)
+				used = rte_tel_json_add_array_ptr(cb_data_buf,
+						buf_len, used,
+						d->data.array[i].ptrval);
 			else if (d->type == RTE_TEL_ARRAY_CONTAINER) {
 				char temp[buf_len];
 				const struct container *rec_data =
diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c
index 77b0fe09a5..9384f48589 100644
--- a/lib/telemetry/telemetry_data.c
+++ b/lib/telemetry/telemetry_data.c
@@ -15,6 +15,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 			RTE_TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
 			RTE_TEL_ARRAY_U64,    /* RTE_TEL_u64_VAL = 2 */
 			RTE_TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			RTE_TEL_ARRAY_PTR,    /* RTE_TEL_PTR_VAL = 4 */
 	};
 	d->type = array_types[type];
 	d->data_len = 0;
@@ -75,6 +76,17 @@ rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
 	return 0;
 }
 
+int
+rte_tel_data_add_array_ptr(struct rte_tel_data *d, void *x)
+{
+	if (d->type != RTE_TEL_ARRAY_PTR)
+		return -EINVAL;
+	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
+		return -ENOSPC;
+	d->data.array[d->data_len++].ptrval = x;
+	return 0;
+}
+
 int
 rte_tel_data_add_array_container(struct rte_tel_data *d,
 		struct rte_tel_data *val, int keep)
@@ -82,7 +94,8 @@ rte_tel_data_add_array_container(struct rte_tel_data *d,
 	if (d->type != RTE_TEL_ARRAY_CONTAINER ||
 			(val->type != RTE_TEL_ARRAY_U64
 			&& val->type != RTE_TEL_ARRAY_INT
-			&& val->type != RTE_TEL_ARRAY_STRING))
+			&& val->type != RTE_TEL_ARRAY_STRING
+			&& val->type != RTE_TEL_ARRAY_PTR))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -147,15 +160,34 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
 }
 
+int
+rte_tel_data_add_dict_ptr(struct rte_tel_data *d,
+		const char *name, void *ptr)
+{
+	struct tel_dict_entry *e = &d->data.dict[d->data_len];
+	if (d->type != RTE_TEL_DICT)
+		return -EINVAL;
+	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
+		return -ENOSPC;
+
+	d->data_len++;
+	e->type = RTE_TEL_PTR_VAL;
+	e->value.ptrval = ptr;
+	const size_t bytes = strlcpy(e->name, name, RTE_TEL_MAX_STRING_LEN);
+	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
+}
+
 int
 rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name,
 		struct rte_tel_data *val, int keep)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 
-	if (d->type != RTE_TEL_DICT || (val->type != RTE_TEL_ARRAY_U64
-			&& val->type != RTE_TEL_ARRAY_INT
-			&& val->type != RTE_TEL_ARRAY_STRING))
+	if (d->type != RTE_TEL_DICT ||
+		(val->type != RTE_TEL_ARRAY_U64
+		 && val->type != RTE_TEL_ARRAY_INT
+		 && val->type != RTE_TEL_ARRAY_STRING
+		 && val->type != RTE_TEL_ARRAY_PTR))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h
index adb84a09f1..bb361e3bcc 100644
--- a/lib/telemetry/telemetry_data.h
+++ b/lib/telemetry/telemetry_data.h
@@ -16,6 +16,7 @@ enum tel_container_types {
 	RTE_TEL_ARRAY_INT,    /** array of signed, 32-bit int values */
 	RTE_TEL_ARRAY_U64,    /** array of unsigned 64-bit int values */
 	RTE_TEL_ARRAY_CONTAINER, /** array of container structs */
+	RTE_TEL_ARRAY_PTR,    /** array of pointer values */
 };
 
 struct container {
@@ -31,6 +32,7 @@ union tel_value {
 	char sval[RTE_TEL_MAX_STRING_LEN];
 	int ival;
 	uint64_t u64val;
+	void *ptrval;
 	struct container container;
 };
 
diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index ad270b9b30..3e4f026b44 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -102,6 +102,19 @@ rte_tel_json_add_array_u64(char *buf, const int len, const int used,
 	return ret == 0 ? used : end + ret;
 }
 
+/* Appends a pointer value into the JSON array in the provided buffer. */
+static inline int
+rte_tel_json_add_array_ptr(char *buf, const int len, const int used,
+		void *ptr)
+{
+	int ret, end = used - 1; /* strip off final delimiter */
+	if (used <= 2) /* assume empty, since minimum is '[]' */
+		return __json_snprintf(buf, len, "[%ld]", (uintptr_t)ptr);
+
+	ret = __json_snprintf(buf + end, len - end, ",%ld]", (uintptr_t)ptr);
+	return ret == 0 ? used : end + ret;
+}
+
 /*
  * Add a new element with raw JSON value to the JSON array stored in the
  * provided buffer.
@@ -136,6 +149,24 @@ rte_tel_json_add_obj_u64(char *buf, const int len, const int used,
 	return ret == 0 ? used : end + ret;
 }
 
+/**
+ * Add a new element with uint64_t value to the JSON object stored in the
+ * provided buffer.
+ */
+static inline int
+rte_tel_json_add_obj_ptr(char *buf, const int len, const int used,
+		const char *name, void *ptr)
+{
+	int ret, end = used - 1;
+	if (used <= 2) /* assume empty, since minimum is '{}' */
+		return __json_snprintf(buf, len, "{\"%s\":%ld}", name,
+				(uintptr_t)ptr);
+
+	ret = __json_snprintf(buf + end, len - end, ",\"%s\":%ld}", name,
+				(uintptr_t)ptr);
+	return ret == 0 ? used : end + ret;
+}
+
 /**
  * Add a new element with int value to the JSON object stored in the
  * provided buffer.
diff --git a/lib/telemetry/version.map b/lib/telemetry/version.map
index bde80ce29b..d919340bc6 100644
--- a/lib/telemetry/version.map
+++ b/lib/telemetry/version.map
@@ -5,10 +5,12 @@ EXPERIMENTAL {
 	rte_tel_data_add_array_int;
 	rte_tel_data_add_array_string;
 	rte_tel_data_add_array_u64;
+	rte_tel_data_add_array_ptr;
 	rte_tel_data_add_dict_container;
 	rte_tel_data_add_dict_int;
 	rte_tel_data_add_dict_string;
 	rte_tel_data_add_dict_u64;
+	rte_tel_data_add_dict_ptr;
 	rte_tel_data_alloc;
 	rte_tel_data_free;
 	rte_tel_data_start_array;
-- 
2.25.1


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

* [dpdk-dev] [v2, 2/3] test/telemetry: add unit tests for pointer value
  2021-08-01 17:37 ` [dpdk-dev] [v2, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
  2021-08-01 17:37   ` [dpdk-dev] [v2, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
@ 2021-08-01 17:37   ` Gowrishankar Muthukrishnan
  2021-08-01 17:37   ` [dpdk-dev] [v2, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
  2021-08-03  8:05   ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-01 17:37 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, Gowrishankar Muthukrishnan

Adding tests to evaluate pointer value in array and dict.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 app/test/test_telemetry_data.c | 124 +++++++++++++++++++++++++++++++++
 app/test/test_telemetry_json.c |  28 ++++++--
 2 files changed, 145 insertions(+), 7 deletions(-)

diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c
index f34d691265..2823cd0984 100644
--- a/app/test/test_telemetry_data.c
+++ b/app/test/test_telemetry_data.c
@@ -301,6 +301,126 @@ test_array_with_array_u64_values(void)
 	return TEST_OUTPUT("{\"/test\":[[0,1,2,3,4],[0,1,2,3,4]]}");
 }
 
+static int
+test_case_array_ptr(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char exp[120];
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_array(&response_data, RTE_TEL_PTR_VAL);
+
+	i = sprintf(exp, "{\"/test\":[");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		i += sprintf(exp + i, "%ld,", (uintptr_t)p);
+		rte_tel_data_add_array_ptr(&response_data, p);
+	}
+
+	sprintf(exp + i - 1, "]}");
+	return TEST_OUTPUT(exp);
+}
+
+static int
+test_case_add_dict_ptr(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char name[8], exp[160];
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_dict(&response_data);
+
+	i = sprintf(exp, "{\"/test\":{");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		sprintf(name, "dict_%d", j);
+		i += sprintf(exp + i, "\"%s\":%ld,", name, (uintptr_t)p);
+		rte_tel_data_add_dict_ptr(&response_data, name, p);
+	}
+
+	sprintf(exp + i - 1, "}}");
+	return TEST_OUTPUT(exp);
+}
+
+static int
+test_dict_with_array_ptr_values(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char exp[256];
+
+	struct rte_tel_data *child_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data, RTE_TEL_PTR_VAL);
+
+	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data2, RTE_TEL_PTR_VAL);
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_dict(&response_data);
+
+	i = sprintf(exp, "{\"/test\":{\"dict_0\":[");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		i += sprintf(exp + i, "%ld,", (uintptr_t)p);
+		rte_tel_data_add_array_ptr(child_data, p);
+	}
+
+	i += sprintf(exp + i - 1, "],\"dict_1\":[");
+	for (j = 5; j > 0; j--) {
+		p = &a[j - 1];
+		i += sprintf(exp + i - 1, "%ld,", (uintptr_t)p);
+		rte_tel_data_add_array_ptr(child_data2, p);
+	}
+
+	sprintf(exp + i - 2, "]}}");
+	rte_tel_data_add_dict_container(&response_data, "dict_0",
+								child_data, 0);
+	rte_tel_data_add_dict_container(&response_data, "dict_1",
+								child_data2, 0);
+
+	return TEST_OUTPUT(exp);
+}
+
+static int
+test_array_with_array_ptr_values(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char exp[256];
+
+	struct rte_tel_data *child_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data, RTE_TEL_PTR_VAL);
+
+	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data2, RTE_TEL_PTR_VAL);
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER);
+
+	i = sprintf(exp, "{\"/test\":[[");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		i += sprintf(exp + i, "%ld,", (uintptr_t)p);
+		rte_tel_data_add_array_ptr(child_data, p);
+	}
+
+	i += sprintf(exp + i - 1, "],[");
+	for (j = 5; j > 0; j--) {
+		p = &a[j - 1];
+		i += sprintf(exp + i - 1, "%ld,", (uintptr_t)p);
+		rte_tel_data_add_array_ptr(child_data2, p);
+	}
+
+	sprintf(exp + i - 2, "]]}");
+
+	rte_tel_data_add_array_container(&response_data, child_data, 0);
+	rte_tel_data_add_array_container(&response_data, child_data2, 0);
+
+	return TEST_OUTPUT(exp);
+}
+
 static int
 connect_to_socket(void)
 {
@@ -350,13 +470,17 @@ test_telemetry_data(void)
 
 	test_case test_cases[] = {test_case_array_string,
 			test_case_array_int, test_case_array_u64,
+			test_case_array_ptr,
 			test_case_add_dict_int, test_case_add_dict_u64,
+			test_case_add_dict_ptr,
 			test_case_add_dict_string,
 			test_dict_with_array_int_values,
 			test_dict_with_array_u64_values,
+			test_dict_with_array_ptr_values,
 			test_dict_with_array_string_values,
 			test_array_with_array_int_values,
 			test_array_with_array_u64_values,
+			test_array_with_array_ptr_values,
 			test_array_with_array_string_values };
 
 	rte_telemetry_register_cmd(REQUEST_CMD, test_cb, "Test");
diff --git a/app/test/test_telemetry_json.c b/app/test/test_telemetry_json.c
index 790181d316..4177c77dd0 100644
--- a/app/test/test_telemetry_json.c
+++ b/app/test/test_telemetry_json.c
@@ -11,18 +11,22 @@
 static int
 test_basic_array(void)
 {
-	const char *expected = "[\"meaning of life\",42]";
-	char buf[1024];
-	int used = 0;
+	char buf[1024], expected[80];
+	int used = 0, n = 42, *p;
 
 	printf("%s: ", __func__);
 	used = rte_tel_json_empty_array(buf, sizeof(buf), used);
 	if (used != 2 || strcmp(buf, "[]"))
 		return -1;
 
+	p = &n;
+	memset(expected, 0, sizeof(expected));
+	sprintf(expected, "[\"meaning of life\",42,%ld]", (uintptr_t)p);
+
 	used = rte_tel_json_add_array_string(buf, sizeof(buf), used,
 		"meaning of life");
-	used = rte_tel_json_add_array_int(buf, sizeof(buf), used, 42);
+	used = rte_tel_json_add_array_int(buf, sizeof(buf), used, n);
+	used = rte_tel_json_add_array_ptr(buf, sizeof(buf), used, p);
 
 	printf("buf = '%s', expected = '%s'\n", buf, expected);
 	if (used != (int)strlen(expected))
@@ -33,14 +37,24 @@ test_basic_array(void)
 static int
 test_basic_obj(void)
 {
-	const char *expected = "{\"weddings\":4,\"funerals\":1}";
-	char buf[1024];
-	int used = 0;
+	char buf[1024], expected[80];
+	int used = 0, n = 42, *p;
+
+	p = &n;
+	memset(expected, 0, sizeof(expected));
+	sprintf(expected,
+			"{\"weddings\":4,\"funerals\":1,"
+			"\"address\":%ld,\"reset\":0}", (uintptr_t)p);
 
 	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
 		"weddings", 4);
 	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
 		"funerals", 1);
+	used = rte_tel_json_add_obj_ptr(buf, sizeof(buf), used,
+		"address", p);
+	p = NULL;
+	used = rte_tel_json_add_obj_ptr(buf, sizeof(buf), used,
+		"reset", p);
 
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
 	if (used != (int)strlen(expected))
-- 
2.25.1


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

* [dpdk-dev] [v2, 3/3] common/cnxk: add telemetry endpoints to npa
  2021-08-01 17:37 ` [dpdk-dev] [v2, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
  2021-08-01 17:37   ` [dpdk-dev] [v2, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
  2021-08-01 17:37   ` [dpdk-dev] [v2, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
@ 2021-08-01 17:37   ` Gowrishankar Muthukrishnan
  2021-08-03  8:05   ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-01 17:37 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, Gowrishankar Muthukrishnan

Add telemetry endpoints to npa.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 227 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   4 +
 drivers/common/cnxk/roc_platform.h       |   8 +
 4 files changed, 265 insertions(+)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

diff --git a/drivers/common/cnxk/cnxk_telemetry.h b/drivers/common/cnxk/cnxk_telemetry.h
new file mode 100644
index 0000000000..5e69f78d2e
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Marvell.
+ */
+
+#ifndef __CNXK_TELEMETRY_H_
+#define __CNXK_TELEMETRY_H_
+
+#define CNXK_TEL_STR(s)		  #s
+#define CNXK_TEL_STR_PREFIX(s, p) CNXK_TEL_STR(p##s)
+#define CNXK_TEL_DICT_INT(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_int(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_PTR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(p)->s)
+#define CNXK_TEL_DICT_BF_PTR(d, p, s, ...)                                     \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(uint64_t)(p)->s)
+#define CNXK_TEL_DICT_U64(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_u64(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_STR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_string(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),   \
+				  (p)->s)
+
+#endif /* __CNXK_TELEMETRY_H_ */
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
new file mode 100644
index 0000000000..1c2c2cd106
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -0,0 +1,227 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+#include <rte_telemetry.h>
+
+static int
+cnxk_tel_npa(struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int aura_cnt = 0;
+	uint32_t i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	for (i = 0; i < lf->nr_pools; i++) {
+		if (plt_bitmap_get(lf->npa_bmp, i))
+			continue;
+		aura_cnt++;
+	}
+
+	plt_tel_data_add_dict_ptr(d, "npa", lf);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
+
+	CNXK_TEL_DICT_PTR(d, lf, pci_dev);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
+	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
+	CNXK_TEL_DICT_PTR(d, lf, intr_handle);
+	CNXK_TEL_DICT_PTR(d, lf, mbox);
+	CNXK_TEL_DICT_PTR(d, lf, base);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
+	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
+	CNXK_TEL_DICT_INT(d, lf, nr_pools);
+	CNXK_TEL_DICT_INT(d, lf, pf_func);
+	CNXK_TEL_DICT_INT(d, lf, aura_sz);
+	CNXK_TEL_DICT_INT(d, lf, qints);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
+{
+	__io struct npa_aura_s *aura;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (rte_bitmap_get(lf->npa_bmp, aura_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_AURA;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", aura_id);
+		return rc;
+	}
+
+	aura = &rsp->aura;
+	CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
+	CNXK_TEL_DICT_INT(d, aura, ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
+	CNXK_TEL_DICT_U64(d, aura, count, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
+	CNXK_TEL_DICT_U64(d, aura, limit, w3_);
+	CNXK_TEL_DICT_INT(d, aura, bp, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
+	CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
+	CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
+{
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (rte_bitmap_get(lf->npa_bmp, pool_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = pool_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", pool_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
+	CNXK_TEL_DICT_INT(d, pool, ena, w1_);
+	CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
+	CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
+	CNXK_TEL_DICT_INT(d, pool, shift, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
+	CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
+	CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
+	CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info(const char *cmd __rte_unused,
+			 const char *params __rte_unused,
+			 struct rte_tel_data *d)
+{
+	plt_tel_data_start_dict(d);
+	cnxk_tel_npa(d);
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
+			   struct rte_tel_data *d)
+{
+	int id, rc;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	id = atoi(params);
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "aura/info"))
+		rc = cnxk_tel_npa_aura(id, d);
+	else
+		rc = cnxk_tel_npa_pool(id, d);
+
+	return rc;
+}
+
+RTE_INIT(cnxk_telemetry_npa_init)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
+		"Returns npa information. Takes no parameters");
+
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa aura information. Parameters: aura_id");
+
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa pool information. Parameters: pool_id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index 6a7849f31c..3cc9a2ff37 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -60,5 +60,9 @@ sources = files(
 # Security common code
 sources += files('cnxk_security.c')
 
+# Telemetry common code
+sources += files('cnxk_telemetry_npa.c')
+
 includes += include_directories('../../bus/pci')
 includes += include_directories('../../../lib/net')
+includes += include_directories('../../../lib/telemetry')
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 285b24b82d..9fcaee8254 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -19,6 +19,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "roc_bits.h"
 
@@ -139,6 +140,13 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define plt_tel_data                 rte_tel_data
+#define plt_tel_data_start_dict      rte_tel_data_start_dict
+#define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
+#define plt_tel_data_add_dict_ptr    rte_tel_data_add_dict_ptr
+#define plt_tel_data_add_dict_string rte_tel_data_add_dict_string
+#define plt_tel_data_add_dict_u64    rte_tel_data_add_dict_u64
+
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
-- 
2.25.1


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

* Re: [dpdk-dev] [EXT] Re:  [v1, 1/3] telemetry: enable storing pointer value
  2021-07-30 12:08     ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
@ 2021-08-01 17:40       ` Gowrishankar Muthukrishnan
  0 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-01 17:40 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: dev, ciara.power, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda, Nithin Kumar Dabilpuram,
	Sunil Kumar Kori, Satha Koteswara Rao Kottidi



> -----Original Message-----
> From: Gowrishankar Muthukrishnan
> Sent: Friday, July 30, 2021 5:38 PM
> To: Bruce Richardson <bruce.richardson@intel.com>
> Cc: dev@dpdk.org; ciara.power@intel.com; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; Kiran Kumar Kokkilagadda <kirankumark@marvell.com>;
> Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; Sunil Kumar Kori
> <skori@marvell.com>; Satha Koteswara Rao Kottidi
> <skoteshwar@marvell.com>
> Subject: RE: [EXT] Re: [dpdk-dev] [v1, 1/3] telemetry: enable storing pointer
> value
> 
> Hi Bruce,
> 
> > I'm a little curious as to the usefulness of having a pointer value in
> > telemetry output? How would a telemetry user be expected to use
> > pointer information returned? Printing pointers seems something more
> > useful for a debugging or tracing interface than a telemetry one.
> >
> 
> Thanks for the quick review. I enabled _ptr API keeping few things in mind:
> 
> 1. User need to explicitly type cast pointer value (ie address) to uint64_t
>     which otherwise can cause compiler warning (Wint-conversion). Although
>     u64 is large enough for holding address as value, type casting is problematic
>     for non-64 bit machines (eg 32 bit). One other option is to use uintptr_t
>     as a holder.
> 
Please check [v2].
I modified json encoding to uintptr instead of stringified hex as in current patch.
I think, this is better approach as pointer value is stored more correctly (void *)
as well as retrieved in JSON following uintptr_t cast. Also I think, this is architecture 
compliant approach rather than assuming pointer address is always 64 bit (and 
what if 128 bit comes alive - who knows when). Aim is to leave _ptr api 
architecture compliance anytime.

> 2. With this API, code walk could be easier as user can interpret the accessed
>      data better (ie ptr is address value). _ptr API is meant for pointer variables,
>      though it is up to user to choose.
> 
With above uintptr_t as encoded value, it does not change the client handling
as client would consume it as its architecture supported value (uint64_t).
One advantage of having this API is to support JSON5 compliance hex address
once decided so in future.

> 3. Also while debugging telemetry date using script like usertools/dpdk-
> telemetry.py,
>     perceiving address as hex is quicker than same as u64.
> 
> Answering on returned data, user needs to convert stringified hex to pointer
> value.
With uintptr_t value (in new patch), no change is needed in client side.

Please suggest.
Thanks,
Gowrishankar
> 
> Regards,
> Gowrishankar

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

* [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry
  2021-08-01 17:37 ` [dpdk-dev] [v2, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
                     ` (2 preceding siblings ...)
  2021-08-01 17:37   ` [dpdk-dev] [v2, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-08-03  8:05   ` Gowrishankar Muthukrishnan
  2021-08-03  8:05     ` [dpdk-dev] [v3, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
                       ` (4 more replies)
  3 siblings, 5 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-03  8:05 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, Gowrishankar Muthukrishnan

This patch series enables telemetry in NPA LF of cnxk.

v3:
 - fixed format specifier for uintptr_t

Gowrishankar Muthukrishnan (3):
  telemetry: enable storing pointer value
  test/telemetry: add unit tests for pointer value
  common/cnxk: add telemetry endpoints to npa

 app/test/test_telemetry_data.c           | 125 +++++++++++++
 app/test/test_telemetry_json.c           |  29 ++-
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 227 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   4 +
 drivers/common/cnxk/roc_platform.h       |   8 +
 lib/telemetry/rte_telemetry.h            |  37 +++-
 lib/telemetry/telemetry.c                |  21 ++-
 lib/telemetry/telemetry_data.c           |  40 +++-
 lib/telemetry/telemetry_data.h           |   2 +
 lib/telemetry/telemetry_json.h           |  32 ++++
 lib/telemetry/version.map                |   2 +
 12 files changed, 539 insertions(+), 14 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

-- 
2.25.1


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

* [dpdk-dev] [v3, 1/3] telemetry: enable storing pointer value
  2021-08-03  8:05   ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
@ 2021-08-03  8:05     ` Gowrishankar Muthukrishnan
  2021-08-03  8:05     ` [dpdk-dev] [v3, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-03  8:05 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, Gowrishankar Muthukrishnan

At present, value of pointer variable or address is stored in
u64 type which may not properly work in non64 bit arch. Hence,
this patch adds new API to store it in void*. JSON encoding is
after converting to uintptr_t so, address value is correctly
casted as per arch as well. Once JSON5 support is available
at JSON clients, hex value of address can be encoded instead
of uintptr_t.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 lib/telemetry/rte_telemetry.h  | 37 ++++++++++++++++++++++++++++++-
 lib/telemetry/telemetry.c      | 21 ++++++++++++++++--
 lib/telemetry/telemetry_data.c | 40 ++++++++++++++++++++++++++++++----
 lib/telemetry/telemetry_data.h |  2 ++
 lib/telemetry/telemetry_json.h | 32 +++++++++++++++++++++++++++
 lib/telemetry/version.map      |  2 ++
 6 files changed, 127 insertions(+), 7 deletions(-)

diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index 8776998b54..6a420f918c 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -46,7 +46,8 @@ enum rte_tel_value_type {
 	RTE_TEL_STRING_VAL, /** a string value */
 	RTE_TEL_INT_VAL,    /** a signed 32-bit int value */
 	RTE_TEL_U64_VAL,    /** an unsigned 64-bit int value */
-	RTE_TEL_CONTAINER, /** a container struct */
+	RTE_TEL_CONTAINER,  /** a container struct */
+	RTE_TEL_PTR_VAL,    /** a pointer value */
 };
 
 /**
@@ -137,6 +138,22 @@ __rte_experimental
 int
 rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x);
 
+/**
+ * Add a pointer value to an array.
+ * The array must have been started by rte_tel_data_start_array() with
+ * RTE_TEL_PTR_VAL as the type parameter.
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param x
+ *   The pointer value to be returned in the array
+ * @return
+ *   0 on success, negative errno on error
+ */
+__rte_experimental
+int
+rte_tel_data_add_array_ptr(struct rte_tel_data *d, void *x);
+
 /**
  * Add a container to an array. A container is an existing telemetry data
  * array. The array the container is to be added to must have been started by
@@ -213,6 +230,24 @@ int
 rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 		const char *name, uint64_t val);
 
+/**
+ * Add a pointer value to a dictionary.
+ * The dict must have been started by rte_tel_data_start_dict().
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param name
+ *   The name the value is to be stored under in the dict
+ * @param ptr
+ *   The pointer value to be stored in the dict
+ * @return
+ *   0 on success, negative errno on error, E2BIG on string truncation of name.
+ */
+__rte_experimental
+int
+rte_tel_data_add_dict_ptr(struct rte_tel_data *d,
+		const char *name, void *ptr);
+
 /**
  * Add a container to a dictionary. A container is an existing telemetry data
  * array. The dict the container is to be added to must have been started by
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 8665db8d03..5842b28740 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -157,8 +157,10 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 	size_t used = 0;
 	unsigned int i;
 
-	if (d->type != RTE_TEL_ARRAY_U64 && d->type != RTE_TEL_ARRAY_INT
-			&& d->type != RTE_TEL_ARRAY_STRING)
+	if (d->type != RTE_TEL_ARRAY_U64
+		&& d->type != RTE_TEL_ARRAY_INT
+		&& d->type != RTE_TEL_ARRAY_PTR
+		&& d->type != RTE_TEL_ARRAY_STRING)
 		return snprintf(out_buf, buf_len, "null");
 
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
@@ -167,6 +169,11 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 			used = rte_tel_json_add_array_u64(out_buf,
 				buf_len, used,
 				d->data.array[i].u64val);
+	if (d->type == RTE_TEL_ARRAY_PTR)
+		for (i = 0; i < d->data_len; i++)
+			used = rte_tel_json_add_array_ptr(out_buf,
+				buf_len, used,
+				d->data.array[i].ptrval);
 	if (d->type == RTE_TEL_ARRAY_INT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_int(out_buf,
@@ -226,6 +233,11 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						buf_len, used,
 						v->name, v->value.u64val);
 				break;
+			case RTE_TEL_PTR_VAL:
+				used = rte_tel_json_add_obj_ptr(cb_data_buf,
+						buf_len, used,
+						v->name, v->value.ptrval);
+				break;
 			case RTE_TEL_CONTAINER:
 			{
 				char temp[buf_len];
@@ -248,6 +260,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 	case RTE_TEL_ARRAY_STRING:
 	case RTE_TEL_ARRAY_INT:
 	case RTE_TEL_ARRAY_U64:
+	case RTE_TEL_ARRAY_PTR:
 	case RTE_TEL_ARRAY_CONTAINER:
 		prefix_used = snprintf(out_buf, sizeof(out_buf), "{\"%.*s\":",
 				MAX_CMD_LEN, cmd);
@@ -269,6 +282,10 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 				used = rte_tel_json_add_array_u64(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].u64val);
+			else if (d->type == RTE_TEL_ARRAY_PTR)
+				used = rte_tel_json_add_array_ptr(cb_data_buf,
+						buf_len, used,
+						d->data.array[i].ptrval);
 			else if (d->type == RTE_TEL_ARRAY_CONTAINER) {
 				char temp[buf_len];
 				const struct container *rec_data =
diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c
index 77b0fe09a5..9384f48589 100644
--- a/lib/telemetry/telemetry_data.c
+++ b/lib/telemetry/telemetry_data.c
@@ -15,6 +15,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 			RTE_TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
 			RTE_TEL_ARRAY_U64,    /* RTE_TEL_u64_VAL = 2 */
 			RTE_TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			RTE_TEL_ARRAY_PTR,    /* RTE_TEL_PTR_VAL = 4 */
 	};
 	d->type = array_types[type];
 	d->data_len = 0;
@@ -75,6 +76,17 @@ rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
 	return 0;
 }
 
+int
+rte_tel_data_add_array_ptr(struct rte_tel_data *d, void *x)
+{
+	if (d->type != RTE_TEL_ARRAY_PTR)
+		return -EINVAL;
+	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
+		return -ENOSPC;
+	d->data.array[d->data_len++].ptrval = x;
+	return 0;
+}
+
 int
 rte_tel_data_add_array_container(struct rte_tel_data *d,
 		struct rte_tel_data *val, int keep)
@@ -82,7 +94,8 @@ rte_tel_data_add_array_container(struct rte_tel_data *d,
 	if (d->type != RTE_TEL_ARRAY_CONTAINER ||
 			(val->type != RTE_TEL_ARRAY_U64
 			&& val->type != RTE_TEL_ARRAY_INT
-			&& val->type != RTE_TEL_ARRAY_STRING))
+			&& val->type != RTE_TEL_ARRAY_STRING
+			&& val->type != RTE_TEL_ARRAY_PTR))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -147,15 +160,34 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
 }
 
+int
+rte_tel_data_add_dict_ptr(struct rte_tel_data *d,
+		const char *name, void *ptr)
+{
+	struct tel_dict_entry *e = &d->data.dict[d->data_len];
+	if (d->type != RTE_TEL_DICT)
+		return -EINVAL;
+	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
+		return -ENOSPC;
+
+	d->data_len++;
+	e->type = RTE_TEL_PTR_VAL;
+	e->value.ptrval = ptr;
+	const size_t bytes = strlcpy(e->name, name, RTE_TEL_MAX_STRING_LEN);
+	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
+}
+
 int
 rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name,
 		struct rte_tel_data *val, int keep)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 
-	if (d->type != RTE_TEL_DICT || (val->type != RTE_TEL_ARRAY_U64
-			&& val->type != RTE_TEL_ARRAY_INT
-			&& val->type != RTE_TEL_ARRAY_STRING))
+	if (d->type != RTE_TEL_DICT ||
+		(val->type != RTE_TEL_ARRAY_U64
+		 && val->type != RTE_TEL_ARRAY_INT
+		 && val->type != RTE_TEL_ARRAY_STRING
+		 && val->type != RTE_TEL_ARRAY_PTR))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h
index adb84a09f1..bb361e3bcc 100644
--- a/lib/telemetry/telemetry_data.h
+++ b/lib/telemetry/telemetry_data.h
@@ -16,6 +16,7 @@ enum tel_container_types {
 	RTE_TEL_ARRAY_INT,    /** array of signed, 32-bit int values */
 	RTE_TEL_ARRAY_U64,    /** array of unsigned 64-bit int values */
 	RTE_TEL_ARRAY_CONTAINER, /** array of container structs */
+	RTE_TEL_ARRAY_PTR,    /** array of pointer values */
 };
 
 struct container {
@@ -31,6 +32,7 @@ union tel_value {
 	char sval[RTE_TEL_MAX_STRING_LEN];
 	int ival;
 	uint64_t u64val;
+	void *ptrval;
 	struct container container;
 };
 
diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index ad270b9b30..b41329902f 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -102,6 +102,20 @@ rte_tel_json_add_array_u64(char *buf, const int len, const int used,
 	return ret == 0 ? used : end + ret;
 }
 
+/* Appends a pointer value into the JSON array in the provided buffer. */
+static inline int
+rte_tel_json_add_array_ptr(char *buf, const int len, const int used, void *ptr)
+{
+	int ret, end = used - 1; /* strip off final delimiter */
+	if (used <= 2)		 /* assume empty, since minimum is '[]' */
+		return __json_snprintf(buf, len, "[%" PRIuPTR "]",
+				       (uintptr_t)ptr);
+
+	ret = __json_snprintf(buf + end, len - end, ",%" PRIuPTR "]",
+			      (uintptr_t)ptr);
+	return ret == 0 ? used : end + ret;
+}
+
 /*
  * Add a new element with raw JSON value to the JSON array stored in the
  * provided buffer.
@@ -136,6 +150,24 @@ rte_tel_json_add_obj_u64(char *buf, const int len, const int used,
 	return ret == 0 ? used : end + ret;
 }
 
+/**
+ * Add a new element with uint64_t value to the JSON object stored in the
+ * provided buffer.
+ */
+static inline int
+rte_tel_json_add_obj_ptr(char *buf, const int len, const int used,
+			 const char *name, void *ptr)
+{
+	int ret, end = used - 1;
+	if (used <= 2) /* assume empty, since minimum is '{}' */
+		return __json_snprintf(buf, len, "{\"%s\":%" PRIuPTR "}", name,
+				       (uintptr_t)ptr);
+
+	ret = __json_snprintf(buf + end, len - end, ",\"%s\":%" PRIuPTR "}",
+			      name, (uintptr_t)ptr);
+	return ret == 0 ? used : end + ret;
+}
+
 /**
  * Add a new element with int value to the JSON object stored in the
  * provided buffer.
diff --git a/lib/telemetry/version.map b/lib/telemetry/version.map
index bde80ce29b..d919340bc6 100644
--- a/lib/telemetry/version.map
+++ b/lib/telemetry/version.map
@@ -5,10 +5,12 @@ EXPERIMENTAL {
 	rte_tel_data_add_array_int;
 	rte_tel_data_add_array_string;
 	rte_tel_data_add_array_u64;
+	rte_tel_data_add_array_ptr;
 	rte_tel_data_add_dict_container;
 	rte_tel_data_add_dict_int;
 	rte_tel_data_add_dict_string;
 	rte_tel_data_add_dict_u64;
+	rte_tel_data_add_dict_ptr;
 	rte_tel_data_alloc;
 	rte_tel_data_free;
 	rte_tel_data_start_array;
-- 
2.25.1


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

* [dpdk-dev] [v3, 2/3] test/telemetry: add unit tests for pointer value
  2021-08-03  8:05   ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
  2021-08-03  8:05     ` [dpdk-dev] [v3, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
@ 2021-08-03  8:05     ` Gowrishankar Muthukrishnan
  2021-08-03  8:05     ` [dpdk-dev] [v3, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-03  8:05 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, Gowrishankar Muthukrishnan

Adding tests to evaluate pointer value in array and dict.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 app/test/test_telemetry_data.c | 125 +++++++++++++++++++++++++++++++++
 app/test/test_telemetry_json.c |  29 ++++++--
 2 files changed, 147 insertions(+), 7 deletions(-)

diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c
index f34d691265..2351ae5193 100644
--- a/app/test/test_telemetry_data.c
+++ b/app/test/test_telemetry_data.c
@@ -301,6 +301,127 @@ test_array_with_array_u64_values(void)
 	return TEST_OUTPUT("{\"/test\":[[0,1,2,3,4],[0,1,2,3,4]]}");
 }
 
+static int
+test_case_array_ptr(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char exp[120];
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_array(&response_data, RTE_TEL_PTR_VAL);
+
+	i = sprintf(exp, "{\"/test\":[");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		i += sprintf(exp + i, "%" PRIuPTR ",", (uintptr_t)p);
+		rte_tel_data_add_array_ptr(&response_data, p);
+	}
+
+	sprintf(exp + i - 1, "]}");
+	return TEST_OUTPUT(exp);
+}
+
+static int
+test_case_add_dict_ptr(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char name[8], exp[160];
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_dict(&response_data);
+
+	i = sprintf(exp, "{\"/test\":{");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		sprintf(name, "dict_%d", j);
+		i += sprintf(exp + i, "\"%s\":%" PRIuPTR ",", name,
+					 (uintptr_t)p);
+		rte_tel_data_add_dict_ptr(&response_data, name, p);
+	}
+
+	sprintf(exp + i - 1, "}}");
+	return TEST_OUTPUT(exp);
+}
+
+static int
+test_dict_with_array_ptr_values(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char exp[256];
+
+	struct rte_tel_data *child_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data, RTE_TEL_PTR_VAL);
+
+	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data2, RTE_TEL_PTR_VAL);
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_dict(&response_data);
+
+	i = sprintf(exp, "{\"/test\":{\"dict_0\":[");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		i += sprintf(exp + i, "%" PRIuPTR ",", (uintptr_t)p);
+		rte_tel_data_add_array_ptr(child_data, p);
+	}
+
+	i += sprintf(exp + i - 1, "],\"dict_1\":[");
+	for (j = 5; j > 0; j--) {
+		p = &a[j - 1];
+		i += sprintf(exp + i - 1, "%" PRIuPTR ",", (uintptr_t)p);
+		rte_tel_data_add_array_ptr(child_data2, p);
+	}
+
+	sprintf(exp + i - 2, "]}}");
+	rte_tel_data_add_dict_container(&response_data, "dict_0",
+								child_data, 0);
+	rte_tel_data_add_dict_container(&response_data, "dict_1",
+								child_data2, 0);
+
+	return TEST_OUTPUT(exp);
+}
+
+static int
+test_array_with_array_ptr_values(void)
+{
+	int *p, i, j, a[] = {1, 2, 3, 4, 5};
+	char exp[256];
+
+	struct rte_tel_data *child_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data, RTE_TEL_PTR_VAL);
+
+	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
+	rte_tel_data_start_array(child_data2, RTE_TEL_PTR_VAL);
+
+	memset(&response_data, 0, sizeof(response_data));
+	memset(exp, 0, sizeof(exp));
+	rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER);
+
+	i = sprintf(exp, "{\"/test\":[[");
+	for (j = 0; j < 5; j++) {
+		p = &a[j];
+		i += sprintf(exp + i, "%" PRIuPTR ",", (uintptr_t)p);
+		rte_tel_data_add_array_ptr(child_data, p);
+	}
+
+	i += sprintf(exp + i - 1, "],[");
+	for (j = 5; j > 0; j--) {
+		p = &a[j - 1];
+		i += sprintf(exp + i - 1, "%" PRIuPTR ",", (uintptr_t)p);
+		rte_tel_data_add_array_ptr(child_data2, p);
+	}
+
+	sprintf(exp + i - 2, "]]}");
+
+	rte_tel_data_add_array_container(&response_data, child_data, 0);
+	rte_tel_data_add_array_container(&response_data, child_data2, 0);
+
+	return TEST_OUTPUT(exp);
+}
+
 static int
 connect_to_socket(void)
 {
@@ -350,13 +471,17 @@ test_telemetry_data(void)
 
 	test_case test_cases[] = {test_case_array_string,
 			test_case_array_int, test_case_array_u64,
+			test_case_array_ptr,
 			test_case_add_dict_int, test_case_add_dict_u64,
+			test_case_add_dict_ptr,
 			test_case_add_dict_string,
 			test_dict_with_array_int_values,
 			test_dict_with_array_u64_values,
+			test_dict_with_array_ptr_values,
 			test_dict_with_array_string_values,
 			test_array_with_array_int_values,
 			test_array_with_array_u64_values,
+			test_array_with_array_ptr_values,
 			test_array_with_array_string_values };
 
 	rte_telemetry_register_cmd(REQUEST_CMD, test_cb, "Test");
diff --git a/app/test/test_telemetry_json.c b/app/test/test_telemetry_json.c
index 790181d316..68dc81c9cd 100644
--- a/app/test/test_telemetry_json.c
+++ b/app/test/test_telemetry_json.c
@@ -11,18 +11,23 @@
 static int
 test_basic_array(void)
 {
-	const char *expected = "[\"meaning of life\",42]";
-	char buf[1024];
-	int used = 0;
+	char buf[1024], expected[80];
+	int used = 0, n = 42, *p;
 
 	printf("%s: ", __func__);
 	used = rte_tel_json_empty_array(buf, sizeof(buf), used);
 	if (used != 2 || strcmp(buf, "[]"))
 		return -1;
 
+	p = &n;
+	memset(expected, 0, sizeof(expected));
+	sprintf(expected, "[\"meaning of life\",42,%" PRIuPTR "]",
+			(uintptr_t)p);
+
 	used = rte_tel_json_add_array_string(buf, sizeof(buf), used,
 		"meaning of life");
-	used = rte_tel_json_add_array_int(buf, sizeof(buf), used, 42);
+	used = rte_tel_json_add_array_int(buf, sizeof(buf), used, n);
+	used = rte_tel_json_add_array_ptr(buf, sizeof(buf), used, p);
 
 	printf("buf = '%s', expected = '%s'\n", buf, expected);
 	if (used != (int)strlen(expected))
@@ -33,14 +38,24 @@ test_basic_array(void)
 static int
 test_basic_obj(void)
 {
-	const char *expected = "{\"weddings\":4,\"funerals\":1}";
-	char buf[1024];
-	int used = 0;
+	char buf[1024], expected[80];
+	int used = 0, n = 42, *p;
+
+	p = &n;
+	memset(expected, 0, sizeof(expected));
+	sprintf(expected,
+			"{\"weddings\":4,\"funerals\":1,"
+			"\"address\":%" PRIuPTR ",\"reset\":0}", (uintptr_t)p);
 
 	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
 		"weddings", 4);
 	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
 		"funerals", 1);
+	used = rte_tel_json_add_obj_ptr(buf, sizeof(buf), used,
+		"address", p);
+	p = NULL;
+	used = rte_tel_json_add_obj_ptr(buf, sizeof(buf), used,
+		"reset", p);
 
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
 	if (used != (int)strlen(expected))
-- 
2.25.1


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

* [dpdk-dev] [v3, 3/3] common/cnxk: add telemetry endpoints to npa
  2021-08-03  8:05   ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
  2021-08-03  8:05     ` [dpdk-dev] [v3, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
  2021-08-03  8:05     ` [dpdk-dev] [v3, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
@ 2021-08-03  8:05     ` Gowrishankar Muthukrishnan
  2021-08-11 15:59     ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Power, Ciara
  2021-08-26 17:15     ` [dpdk-dev] [v4, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
  4 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-03  8:05 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, Gowrishankar Muthukrishnan

Add telemetry endpoints to npa.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 227 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   4 +
 drivers/common/cnxk/roc_platform.h       |   8 +
 4 files changed, 265 insertions(+)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

diff --git a/drivers/common/cnxk/cnxk_telemetry.h b/drivers/common/cnxk/cnxk_telemetry.h
new file mode 100644
index 0000000000..1461fd893f
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Marvell.
+ */
+
+#ifndef __CNXK_TELEMETRY_H_
+#define __CNXK_TELEMETRY_H_
+
+#define CNXK_TEL_STR(s)		  #s
+#define CNXK_TEL_STR_PREFIX(s, p) CNXK_TEL_STR(p##s)
+#define CNXK_TEL_DICT_INT(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_int(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_PTR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(p)->s)
+#define CNXK_TEL_DICT_BF_PTR(d, p, s, ...)                                     \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(uint64_t)(p)->s)
+#define CNXK_TEL_DICT_U64(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_u64(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_STR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_string(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),   \
+				     (p)->s)
+
+#endif /* __CNXK_TELEMETRY_H_ */
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
new file mode 100644
index 0000000000..1c2c2cd106
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -0,0 +1,227 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+#include <rte_telemetry.h>
+
+static int
+cnxk_tel_npa(struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int aura_cnt = 0;
+	uint32_t i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	for (i = 0; i < lf->nr_pools; i++) {
+		if (plt_bitmap_get(lf->npa_bmp, i))
+			continue;
+		aura_cnt++;
+	}
+
+	plt_tel_data_add_dict_ptr(d, "npa", lf);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
+
+	CNXK_TEL_DICT_PTR(d, lf, pci_dev);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
+	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
+	CNXK_TEL_DICT_PTR(d, lf, intr_handle);
+	CNXK_TEL_DICT_PTR(d, lf, mbox);
+	CNXK_TEL_DICT_PTR(d, lf, base);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
+	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
+	CNXK_TEL_DICT_INT(d, lf, nr_pools);
+	CNXK_TEL_DICT_INT(d, lf, pf_func);
+	CNXK_TEL_DICT_INT(d, lf, aura_sz);
+	CNXK_TEL_DICT_INT(d, lf, qints);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
+{
+	__io struct npa_aura_s *aura;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (rte_bitmap_get(lf->npa_bmp, aura_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_AURA;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", aura_id);
+		return rc;
+	}
+
+	aura = &rsp->aura;
+	CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
+	CNXK_TEL_DICT_INT(d, aura, ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
+	CNXK_TEL_DICT_U64(d, aura, count, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
+	CNXK_TEL_DICT_U64(d, aura, limit, w3_);
+	CNXK_TEL_DICT_INT(d, aura, bp, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
+	CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
+	CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
+{
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (rte_bitmap_get(lf->npa_bmp, pool_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = pool_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", pool_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
+	CNXK_TEL_DICT_INT(d, pool, ena, w1_);
+	CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
+	CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
+	CNXK_TEL_DICT_INT(d, pool, shift, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
+	CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
+	CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
+	CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info(const char *cmd __rte_unused,
+			 const char *params __rte_unused,
+			 struct rte_tel_data *d)
+{
+	plt_tel_data_start_dict(d);
+	cnxk_tel_npa(d);
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
+			   struct rte_tel_data *d)
+{
+	int id, rc;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	id = atoi(params);
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "aura/info"))
+		rc = cnxk_tel_npa_aura(id, d);
+	else
+		rc = cnxk_tel_npa_pool(id, d);
+
+	return rc;
+}
+
+RTE_INIT(cnxk_telemetry_npa_init)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
+		"Returns npa information. Takes no parameters");
+
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa aura information. Parameters: aura_id");
+
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa pool information. Parameters: pool_id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index 6a7849f31c..3cc9a2ff37 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -60,5 +60,9 @@ sources = files(
 # Security common code
 sources += files('cnxk_security.c')
 
+# Telemetry common code
+sources += files('cnxk_telemetry_npa.c')
+
 includes += include_directories('../../bus/pci')
 includes += include_directories('../../../lib/net')
+includes += include_directories('../../../lib/telemetry')
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 285b24b82d..ec17dac6fe 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -19,6 +19,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "roc_bits.h"
 
@@ -139,6 +140,13 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_dict	     rte_tel_data_start_dict
+#define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
+#define plt_tel_data_add_dict_ptr    rte_tel_data_add_dict_ptr
+#define plt_tel_data_add_dict_string rte_tel_data_add_dict_string
+#define plt_tel_data_add_dict_u64    rte_tel_data_add_dict_u64
+
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
-- 
2.25.1


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

* Re: [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry
  2021-08-03  8:05   ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
                       ` (2 preceding siblings ...)
  2021-08-03  8:05     ` [dpdk-dev] [v3, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-08-11 15:59     ` Power, Ciara
  2021-08-11 16:18       ` Gowrishankar Muthukrishnan
  2021-08-26 17:15     ` [dpdk-dev] [v4, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
  4 siblings, 1 reply; 121+ messages in thread
From: Power, Ciara @ 2021-08-11 15:59 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Richardson, Bruce, jerinj, kirankumark, ndabilpuram, skori, skoteshwar

Hi Gowrishankar,

>-----Original Message-----
>From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
>Sent: Tuesday 3 August 2021 09:06
>To: dev@dpdk.org
>Cc: Richardson, Bruce <bruce.richardson@intel.com>; Power, Ciara
><ciara.power@intel.com>; jerinj@marvell.com; kirankumark@marvell.com;
>ndabilpuram@marvell.com; skori@marvell.com; skoteshwar@marvell.com;
>Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
>Subject: [v3, 0/3] common/cnxk: enable npa telemetry
>
>This patch series enables telemetry in NPA LF of cnxk.
>
>v3:
> - fixed format specifier for uintptr_t
>
>Gowrishankar Muthukrishnan (3):
>  telemetry: enable storing pointer value
>  test/telemetry: add unit tests for pointer value
>  common/cnxk: add telemetry endpoints to npa
>
> app/test/test_telemetry_data.c           | 125 +++++++++++++
> app/test/test_telemetry_json.c           |  29 ++-
> drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
> drivers/common/cnxk/cnxk_telemetry_npa.c | 227
>+++++++++++++++++++++++
> drivers/common/cnxk/meson.build          |   4 +
> drivers/common/cnxk/roc_platform.h       |   8 +
> lib/telemetry/rte_telemetry.h            |  37 +++-
> lib/telemetry/telemetry.c                |  21 ++-
> lib/telemetry/telemetry_data.c           |  40 +++-
> lib/telemetry/telemetry_data.h           |   2 +
> lib/telemetry/telemetry_json.h           |  32 ++++
> lib/telemetry/version.map                |   2 +
> 12 files changed, 539 insertions(+), 14 deletions(-)  create mode 100644
>drivers/common/cnxk/cnxk_telemetry.h
> create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
>
>--
>2.25.1

I am still unsure exactly what the use case is here - why are we choosing to publish the pointer values through telemetry rather than using a debug log for example?
Maybe I am missing something here.

Thanks,
Ciara

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

* Re: [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry
  2021-08-11 15:59     ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Power, Ciara
@ 2021-08-11 16:18       ` Gowrishankar Muthukrishnan
  2021-08-24  8:53         ` Gowrishankar Muthukrishnan
  2021-08-25 10:09         ` Thomas Monjalon
  0 siblings, 2 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-11 16:18 UTC (permalink / raw)
  To: Power, Ciara, dev
  Cc: Richardson, Bruce, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda, Nithin Kumar Dabilpuram,
	Sunil Kumar Kori, Satha Koteswara Rao Kottidi

Hi Ciara,

> -----Original Message-----
> From: Power, Ciara <ciara.power@intel.com>
> Sent: Wednesday, August 11, 2021 9:30 PM
> To: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>; dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; Kiran Kumar Kokkilagadda <kirankumark@marvell.com>;
> Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; Sunil Kumar Kori
> <skori@marvell.com>; Satha Koteswara Rao Kottidi
> <skoteshwar@marvell.com>
> Subject: [EXT] RE: [v3, 0/3] common/cnxk: enable npa telemetry
> 
> External Email
> 
> ----------------------------------------------------------------------
> Hi Gowrishankar,
> 
> >-----Original Message-----
> >From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> >Sent: Tuesday 3 August 2021 09:06
> >To: dev@dpdk.org
> >Cc: Richardson, Bruce <bruce.richardson@intel.com>; Power, Ciara
> ><ciara.power@intel.com>; jerinj@marvell.com; kirankumark@marvell.com;
> >ndabilpuram@marvell.com; skori@marvell.com; skoteshwar@marvell.com;
> >Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> >Subject: [v3, 0/3] common/cnxk: enable npa telemetry
> >
> >This patch series enables telemetry in NPA LF of cnxk.
> >
> >v3:
> > - fixed format specifier for uintptr_t
> >
> >Gowrishankar Muthukrishnan (3):
> >  telemetry: enable storing pointer value
> >  test/telemetry: add unit tests for pointer value
> >  common/cnxk: add telemetry endpoints to npa
> >
> > app/test/test_telemetry_data.c           | 125 +++++++++++++
> > app/test/test_telemetry_json.c           |  29 ++-
> > drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
> > drivers/common/cnxk/cnxk_telemetry_npa.c | 227
> >+++++++++++++++++++++++
> > drivers/common/cnxk/meson.build          |   4 +
> > drivers/common/cnxk/roc_platform.h       |   8 +
> > lib/telemetry/rte_telemetry.h            |  37 +++-
> > lib/telemetry/telemetry.c                |  21 ++-
> > lib/telemetry/telemetry_data.c           |  40 +++-
> > lib/telemetry/telemetry_data.h           |   2 +
> > lib/telemetry/telemetry_json.h           |  32 ++++
> > lib/telemetry/version.map                |   2 +
> > 12 files changed, 539 insertions(+), 14 deletions(-)  create mode
> >100644 drivers/common/cnxk/cnxk_telemetry.h
> > create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
> >
> >--
> >2.25.1
> 
> I am still unsure exactly what the use case is here - why are we choosing to
> publish the pointer values through telemetry rather than using a debug log for
> example?

Pointer values are useful sometimes for more debugging through telemetry, hence this proposal.
As I mentioned in v1 thread, this is architecture compliant approach rather than assuming pointer 
value is always 64 bit, when there is need to use pointer value in current telemetry path.

Thanks,
Gowrishankar

> Maybe I am missing something here.
> 
> Thanks,
> Ciara

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

* Re: [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry
  2021-08-11 16:18       ` Gowrishankar Muthukrishnan
@ 2021-08-24  8:53         ` Gowrishankar Muthukrishnan
  2021-08-25 10:09         ` Thomas Monjalon
  1 sibling, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-24  8:53 UTC (permalink / raw)
  To: Power, Ciara, dev
  Cc: Richardson, Bruce, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda, Nithin Kumar Dabilpuram,
	Sunil Kumar Kori, Satha Koteswara Rao Kottidi

Hi,
Please let me know if any other info is required.

Thanks,
Gowrishankar

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Gowrishankar Muthukrishnan
> Sent: Wednesday, August 11, 2021 9:49 PM
> To: Power, Ciara <ciara.power@intel.com>; dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; Kiran Kumar Kokkilagadda <kirankumark@marvell.com>;
> Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; Sunil Kumar Kori
> <skori@marvell.com>; Satha Koteswara Rao Kottidi
> <skoteshwar@marvell.com>
> Subject: [EXT] Re: [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry
> 
> External Email
> 
> ----------------------------------------------------------------------
> Hi Ciara,
> 
> > -----Original Message-----
> > From: Power, Ciara <ciara.power@intel.com>
> > Sent: Wednesday, August 11, 2021 9:30 PM
> > To: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>;
> > dev@dpdk.org
> > Cc: Richardson, Bruce <bruce.richardson@intel.com>; Jerin Jacob
> > Kollanukkaran <jerinj@marvell.com>; Kiran Kumar Kokkilagadda
> > <kirankumark@marvell.com>; Nithin Kumar Dabilpuram
> > <ndabilpuram@marvell.com>; Sunil Kumar Kori <skori@marvell.com>; Satha
> > Koteswara Rao Kottidi <skoteshwar@marvell.com>
> > Subject: [EXT] RE: [v3, 0/3] common/cnxk: enable npa telemetry
> >
> > External Email
> >
> > ----------------------------------------------------------------------
> > Hi Gowrishankar,
> >
> > >-----Original Message-----
> > >From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > >Sent: Tuesday 3 August 2021 09:06
> > >To: dev@dpdk.org
> > >Cc: Richardson, Bruce <bruce.richardson@intel.com>; Power, Ciara
> > ><ciara.power@intel.com>; jerinj@marvell.com; kirankumark@marvell.com;
> > >ndabilpuram@marvell.com; skori@marvell.com; skoteshwar@marvell.com;
> > >Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > >Subject: [v3, 0/3] common/cnxk: enable npa telemetry
> > >
> > >This patch series enables telemetry in NPA LF of cnxk.
> > >
> > >v3:
> > > - fixed format specifier for uintptr_t
> > >
> > >Gowrishankar Muthukrishnan (3):
> > >  telemetry: enable storing pointer value
> > >  test/telemetry: add unit tests for pointer value
> > >  common/cnxk: add telemetry endpoints to npa
> > >
> > > app/test/test_telemetry_data.c           | 125 +++++++++++++
> > > app/test/test_telemetry_json.c           |  29 ++-
> > > drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
> > > drivers/common/cnxk/cnxk_telemetry_npa.c | 227
> > >+++++++++++++++++++++++
> > > drivers/common/cnxk/meson.build          |   4 +
> > > drivers/common/cnxk/roc_platform.h       |   8 +
> > > lib/telemetry/rte_telemetry.h            |  37 +++-
> > > lib/telemetry/telemetry.c                |  21 ++-
> > > lib/telemetry/telemetry_data.c           |  40 +++-
> > > lib/telemetry/telemetry_data.h           |   2 +
> > > lib/telemetry/telemetry_json.h           |  32 ++++
> > > lib/telemetry/version.map                |   2 +
> > > 12 files changed, 539 insertions(+), 14 deletions(-)  create mode
> > >100644 drivers/common/cnxk/cnxk_telemetry.h
> > > create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
> > >
> > >--
> > >2.25.1
> >
> > I am still unsure exactly what the use case is here - why are we
> > choosing to publish the pointer values through telemetry rather than
> > using a debug log for example?
> 
> Pointer values are useful sometimes for more debugging through telemetry,
> hence this proposal.
> As I mentioned in v1 thread, this is architecture compliant approach rather than
> assuming pointer value is always 64 bit, when there is need to use pointer value
> in current telemetry path.
> 
> Thanks,
> Gowrishankar
> 
> > Maybe I am missing something here.
> >
> > Thanks,
> > Ciara

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

* Re: [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry
  2021-08-11 16:18       ` Gowrishankar Muthukrishnan
  2021-08-24  8:53         ` Gowrishankar Muthukrishnan
@ 2021-08-25 10:09         ` Thomas Monjalon
  2021-08-25 14:38           ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
  1 sibling, 1 reply; 121+ messages in thread
From: Thomas Monjalon @ 2021-08-25 10:09 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan
  Cc: Power, Ciara, dev, Richardson, Bruce, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda, Nithin Kumar Dabilpuram,
	Sunil Kumar Kori, Satha Koteswara Rao Kottidi, david.marchand

11/08/2021 18:18, Gowrishankar Muthukrishnan:
> From: Power, Ciara <ciara.power@intel.com>
> > From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > >  telemetry: enable storing pointer value
[...]
> > I am still unsure exactly what the use case is here - why are we choosing to
> > publish the pointer values through telemetry rather than using a debug log for
> > example?
> 
> Pointer values are useful sometimes for more debugging through telemetry, hence this proposal.
> As I mentioned in v1 thread, this is architecture compliant approach rather than assuming pointer 
> value is always 64 bit, when there is need to use pointer value in current telemetry path.

Why using telemetry for debugging?
I agree with Ciara, debug log is more appropriate.
You can also use the tracing framework.



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

* Re: [dpdk-dev] [EXT] Re:  [v3, 0/3] common/cnxk: enable npa telemetry
  2021-08-25 10:09         ` Thomas Monjalon
@ 2021-08-25 14:38           ` Gowrishankar Muthukrishnan
  0 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-25 14:38 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Power, Ciara, dev, Richardson, Bruce, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda, Nithin Kumar Dabilpuram,
	Sunil Kumar Kori, Satha Koteswara Rao Kottidi, david.marchand

Hi Thomas,

> [...]
> > > I am still unsure exactly what the use case is here - why are we
> > > choosing to publish the pointer values through telemetry rather than
> > > using a debug log for example?
> >
> > Pointer values are useful sometimes for more debugging through telemetry,
> hence this proposal.
> > As I mentioned in v1 thread, this is architecture compliant approach
> > rather than assuming pointer value is always 64 bit, when there is need to use
> pointer value in current telemetry path.
> 
> Why using telemetry for debugging?
> I agree with Ciara, debug log is more appropriate.
> You can also use the tracing framework.
> 

In addition to getting status/stats, we are using this library for remote debugging as this is the only mechanism available in DPDK now. For an instance, accessing data from a pointer address through a root privileged tool. We can internally type cast them to u64 as well but thought of standardizing the conversion through library API instead in case it is useful in other platforms too.

If it does not seem more useful for now, I will take another approach on type casting the values internally in our driver (and avoiding library patch). Please share your thoughts.

Thanks,
Gowrishankar


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

* [dpdk-dev] [v4, 0/2] cnxk: enable npa and mempool telemetry
  2021-08-03  8:05   ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
                       ` (3 preceding siblings ...)
  2021-08-11 15:59     ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Power, Ciara
@ 2021-08-26 17:15     ` Gowrishankar Muthukrishnan
  2021-08-26 17:15       ` [dpdk-dev] [v4, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
                         ` (2 more replies)
  4 siblings, 3 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-26 17:15 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, thomas, jerinj, kirankumark,
	ndabilpuram, skori, skoteshwar, Gowrishankar Muthukrishnan

This patch series enables telemetry in NPA LF and mempool driver
of cnxk.

v4:
 - added mempool driver endpoints.
 - removed lib/telemetry changes to include _ptr api.

Gowrishankar Muthukrishnan (2):
  common/cnxk: add telemetry endpoints to npa
  mempool/cnxk: add telemetry end points

 drivers/common/cnxk/cnxk_telemetry.h          |  26 ++
 drivers/common/cnxk/cnxk_telemetry_npa.c      | 227 ++++++++++++++++++
 drivers/common/cnxk/meson.build               |   4 +
 drivers/common/cnxk/roc_platform.h            |   9 +
 drivers/mempool/cnxk/cnxk_mempool_telemetry.c | 100 ++++++++
 drivers/mempool/cnxk/meson.build              |   1 +
 6 files changed, 367 insertions(+)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
 create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c

-- 
2.25.1


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

* [dpdk-dev] [v4, 1/2] common/cnxk: add telemetry endpoints to npa
  2021-08-26 17:15     ` [dpdk-dev] [v4, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
@ 2021-08-26 17:15       ` Gowrishankar Muthukrishnan
  2021-08-26 18:06         ` Bruce Richardson
  2021-08-26 17:15       ` [dpdk-dev] [v4, 2/2] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
  2021-08-27  6:41       ` [dpdk-dev] [v5, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
  2 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-26 17:15 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, thomas, jerinj, kirankumark,
	ndabilpuram, skori, skoteshwar, Gowrishankar Muthukrishnan

Add telemetry endpoints to npa.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 227 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   4 +
 drivers/common/cnxk/roc_platform.h       |   9 +
 4 files changed, 266 insertions(+)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

diff --git a/drivers/common/cnxk/cnxk_telemetry.h b/drivers/common/cnxk/cnxk_telemetry.h
new file mode 100644
index 0000000000..1461fd893f
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Marvell.
+ */
+
+#ifndef __CNXK_TELEMETRY_H_
+#define __CNXK_TELEMETRY_H_
+
+#define CNXK_TEL_STR(s)		  #s
+#define CNXK_TEL_STR_PREFIX(s, p) CNXK_TEL_STR(p##s)
+#define CNXK_TEL_DICT_INT(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_int(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_PTR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(p)->s)
+#define CNXK_TEL_DICT_BF_PTR(d, p, s, ...)                                     \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(uint64_t)(p)->s)
+#define CNXK_TEL_DICT_U64(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_u64(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_STR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_string(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),   \
+				     (p)->s)
+
+#endif /* __CNXK_TELEMETRY_H_ */
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
new file mode 100644
index 0000000000..1c2c2cd106
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -0,0 +1,227 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+#include <rte_telemetry.h>
+
+static int
+cnxk_tel_npa(struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int aura_cnt = 0;
+	uint32_t i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	for (i = 0; i < lf->nr_pools; i++) {
+		if (plt_bitmap_get(lf->npa_bmp, i))
+			continue;
+		aura_cnt++;
+	}
+
+	plt_tel_data_add_dict_ptr(d, "npa", lf);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
+
+	CNXK_TEL_DICT_PTR(d, lf, pci_dev);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
+	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
+	CNXK_TEL_DICT_PTR(d, lf, intr_handle);
+	CNXK_TEL_DICT_PTR(d, lf, mbox);
+	CNXK_TEL_DICT_PTR(d, lf, base);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
+	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
+	CNXK_TEL_DICT_INT(d, lf, nr_pools);
+	CNXK_TEL_DICT_INT(d, lf, pf_func);
+	CNXK_TEL_DICT_INT(d, lf, aura_sz);
+	CNXK_TEL_DICT_INT(d, lf, qints);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
+{
+	__io struct npa_aura_s *aura;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (rte_bitmap_get(lf->npa_bmp, aura_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_AURA;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", aura_id);
+		return rc;
+	}
+
+	aura = &rsp->aura;
+	CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
+	CNXK_TEL_DICT_INT(d, aura, ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
+	CNXK_TEL_DICT_U64(d, aura, count, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
+	CNXK_TEL_DICT_U64(d, aura, limit, w3_);
+	CNXK_TEL_DICT_INT(d, aura, bp, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
+	CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
+	CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
+{
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (rte_bitmap_get(lf->npa_bmp, pool_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = pool_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", pool_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
+	CNXK_TEL_DICT_INT(d, pool, ena, w1_);
+	CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
+	CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
+	CNXK_TEL_DICT_INT(d, pool, shift, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
+	CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
+	CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
+	CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info(const char *cmd __rte_unused,
+			 const char *params __rte_unused,
+			 struct rte_tel_data *d)
+{
+	plt_tel_data_start_dict(d);
+	cnxk_tel_npa(d);
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
+			   struct rte_tel_data *d)
+{
+	int id, rc;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	id = atoi(params);
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "aura/info"))
+		rc = cnxk_tel_npa_aura(id, d);
+	else
+		rc = cnxk_tel_npa_pool(id, d);
+
+	return rc;
+}
+
+RTE_INIT(cnxk_telemetry_npa_init)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
+		"Returns npa information. Takes no parameters");
+
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa aura information. Parameters: aura_id");
+
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa pool information. Parameters: pool_id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index 6a7849f31c..3cc9a2ff37 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -60,5 +60,9 @@ sources = files(
 # Security common code
 sources += files('cnxk_security.c')
 
+# Telemetry common code
+sources += files('cnxk_telemetry_npa.c')
+
 includes += include_directories('../../bus/pci')
 includes += include_directories('../../../lib/net')
+includes += include_directories('../../../lib/telemetry')
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 285b24b82d..57b1229bb8 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -19,6 +19,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "roc_bits.h"
 
@@ -139,6 +140,14 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_dict	     rte_tel_data_start_dict
+#define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
+#define plt_tel_data_add_dict_ptr(d, n, v)			\
+	rte_tel_data_add_dict_u64(d, n, (uint64_t)v)
+#define plt_tel_data_add_dict_string rte_tel_data_add_dict_string
+#define plt_tel_data_add_dict_u64    rte_tel_data_add_dict_u64
+
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
-- 
2.25.1


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

* [dpdk-dev] [v4, 2/2] mempool/cnxk: add telemetry end points
  2021-08-26 17:15     ` [dpdk-dev] [v4, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
  2021-08-26 17:15       ` [dpdk-dev] [v4, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-08-26 17:15       ` Gowrishankar Muthukrishnan
  2021-08-27  6:41       ` [dpdk-dev] [v5, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
  2 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-26 17:15 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, thomas, jerinj, kirankumark,
	ndabilpuram, skori, skoteshwar, Gowrishankar Muthukrishnan

Adding telemetry end points to cnxk mempool driver.

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

diff --git a/drivers/mempool/cnxk/cnxk_mempool_telemetry.c b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
new file mode 100644
index 0000000000..690f557f62
--- /dev/null
+++ b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
@@ -0,0 +1,100 @@
+/* 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"
+
+static void
+mempool_list_cb(struct rte_mempool *mp, void *arg)
+{
+	struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+	rte_tel_data_add_array_string(d, mp->name);
+}
+
+static int
+mempool_tel_handle_list(const char *cmd __rte_unused,
+			const char *params __rte_unused, struct rte_tel_data *d)
+{
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+	rte_mempool_walk(mempool_list_cb, d);
+	return 0;
+}
+
+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;
+	const struct rte_memzone *mz;
+	int aura_id;
+
+	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+		return;
+
+	CNXK_TEL_DICT_STR(info->d, mp, name);
+	CNXK_TEL_DICT_INT(info->d, mp, pool_id);
+	CNXK_TEL_DICT_INT(info->d, mp, flags);
+	CNXK_TEL_DICT_INT(info->d, mp, socket_id);
+	CNXK_TEL_DICT_INT(info->d, mp, size);
+	CNXK_TEL_DICT_INT(info->d, mp, cache_size);
+	CNXK_TEL_DICT_INT(info->d, mp, elt_size);
+	CNXK_TEL_DICT_INT(info->d, mp, header_size);
+	CNXK_TEL_DICT_INT(info->d, mp, trailer_size);
+	CNXK_TEL_DICT_INT(info->d, mp, private_data_size);
+	CNXK_TEL_DICT_INT(info->d, mp, ops_index);
+	CNXK_TEL_DICT_INT(info->d, mp, populated_size);
+
+	aura_id = roc_npa_aura_handle_to_aura(mp->pool_id);
+	rte_tel_data_add_dict_int(info->d, "aura_id", aura_id);
+
+	mz = mp->mz;
+	CNXK_TEL_DICT_STR(info->d, mz, name, mz_);
+	CNXK_TEL_DICT_PTR(info->d, mz, iova, mz_);
+	CNXK_TEL_DICT_PTR(info->d, mz, addr, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, len, mz_);
+	CNXK_TEL_DICT_U64(info->d, mz, hugepage_sz, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, socket_id, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, flags, mz_);
+}
+
+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 -1;
+
+	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/list", mempool_tel_handle_list,
+		"Returns list of available mempools. Takes no parameters");
+	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',
 )
-- 
2.25.1


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

* Re: [dpdk-dev] [v4, 1/2] common/cnxk: add telemetry endpoints to npa
  2021-08-26 17:15       ` [dpdk-dev] [v4, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-08-26 18:06         ` Bruce Richardson
  2021-08-27  6:43           ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
  0 siblings, 1 reply; 121+ messages in thread
From: Bruce Richardson @ 2021-08-26 18:06 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan
  Cc: dev, ciara.power, thomas, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar

On Thu, Aug 26, 2021 at 10:45:10PM +0530, Gowrishankar Muthukrishnan wrote:
> Add telemetry endpoints to npa.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
>  drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
>  drivers/common/cnxk/cnxk_telemetry_npa.c | 227 +++++++++++++++++++++++
>  drivers/common/cnxk/meson.build          |   4 +
>  drivers/common/cnxk/roc_platform.h       |   9 +
>  4 files changed, 266 insertions(+)
>  create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
>  create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
> 
<snip>
> diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
> index 6a7849f31c..3cc9a2ff37 100644
> --- a/drivers/common/cnxk/meson.build
> +++ b/drivers/common/cnxk/meson.build
> @@ -60,5 +60,9 @@ sources = files(
>  # Security common code
>  sources += files('cnxk_security.c')
>  
> +# Telemetry common code
> +sources += files('cnxk_telemetry_npa.c')
> +
>  includes += include_directories('../../bus/pci')
>  includes += include_directories('../../../lib/net')
> +includes += include_directories('../../../lib/telemetry')

Rather than giving the include directories, I'd recommend using "deps"
variable to specify a direct dependency on those libraries. This should
probably be:

deps += ['bus_pci', 'net', 'telemetry']

Using these as dependencies means that the header paths will be added
automatically, and the libraries linked against too if any functions from
those are used by the code in this lib.

Regards,
/Bruce

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

* [dpdk-dev] [v5, 0/2] cnxk: enable npa and mempool telemetry
  2021-08-26 17:15     ` [dpdk-dev] [v4, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
  2021-08-26 17:15       ` [dpdk-dev] [v4, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
  2021-08-26 17:15       ` [dpdk-dev] [v4, 2/2] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
@ 2021-08-27  6:41       ` Gowrishankar Muthukrishnan
  2021-08-27  6:41         ` [dpdk-dev] [v5, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
                           ` (4 more replies)
  2 siblings, 5 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-27  6:41 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, thomas, jerinj, kirankumark,
	ndabilpuram, skori, skoteshwar, Gowrishankar Muthukrishnan

This patch series enables telemetry in NPA LF and mempool driver
of cnxk.

v5:
 - fixed meson.build files to use deps.

Gowrishankar Muthukrishnan (2):
  common/cnxk: add telemetry endpoints to npa
  mempool/cnxk: add telemetry end points

 drivers/common/cnxk/cnxk_telemetry.h          |  26 ++
 drivers/common/cnxk/cnxk_telemetry_npa.c      | 227 ++++++++++++++++++
 drivers/common/cnxk/meson.build               |   6 +-
 drivers/common/cnxk/roc_platform.h            |   9 +
 drivers/mempool/cnxk/cnxk_mempool_telemetry.c | 100 ++++++++
 drivers/mempool/cnxk/meson.build              |   3 +-
 6 files changed, 368 insertions(+), 3 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
 create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c

-- 
2.25.1


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

* [dpdk-dev] [v5, 1/2] common/cnxk: add telemetry endpoints to npa
  2021-08-27  6:41       ` [dpdk-dev] [v5, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
@ 2021-08-27  6:41         ` Gowrishankar Muthukrishnan
  2021-08-27  6:41         ` [dpdk-dev] [v5, 2/2] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
                           ` (3 subsequent siblings)
  4 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-27  6:41 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, thomas, jerinj, kirankumark,
	ndabilpuram, skori, skoteshwar, Gowrishankar Muthukrishnan

Add telemetry endpoints to npa.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 227 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   6 +-
 drivers/common/cnxk/roc_platform.h       |   9 +
 4 files changed, 266 insertions(+), 2 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

diff --git a/drivers/common/cnxk/cnxk_telemetry.h b/drivers/common/cnxk/cnxk_telemetry.h
new file mode 100644
index 0000000000..1461fd893f
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Marvell.
+ */
+
+#ifndef __CNXK_TELEMETRY_H_
+#define __CNXK_TELEMETRY_H_
+
+#define CNXK_TEL_STR(s)		  #s
+#define CNXK_TEL_STR_PREFIX(s, p) CNXK_TEL_STR(p##s)
+#define CNXK_TEL_DICT_INT(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_int(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_PTR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(p)->s)
+#define CNXK_TEL_DICT_BF_PTR(d, p, s, ...)                                     \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(uint64_t)(p)->s)
+#define CNXK_TEL_DICT_U64(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_u64(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_STR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_string(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),   \
+				     (p)->s)
+
+#endif /* __CNXK_TELEMETRY_H_ */
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
new file mode 100644
index 0000000000..1c2c2cd106
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -0,0 +1,227 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+#include <rte_telemetry.h>
+
+static int
+cnxk_tel_npa(struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int aura_cnt = 0;
+	uint32_t i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	for (i = 0; i < lf->nr_pools; i++) {
+		if (plt_bitmap_get(lf->npa_bmp, i))
+			continue;
+		aura_cnt++;
+	}
+
+	plt_tel_data_add_dict_ptr(d, "npa", lf);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
+
+	CNXK_TEL_DICT_PTR(d, lf, pci_dev);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
+	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
+	CNXK_TEL_DICT_PTR(d, lf, intr_handle);
+	CNXK_TEL_DICT_PTR(d, lf, mbox);
+	CNXK_TEL_DICT_PTR(d, lf, base);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
+	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
+	CNXK_TEL_DICT_INT(d, lf, nr_pools);
+	CNXK_TEL_DICT_INT(d, lf, pf_func);
+	CNXK_TEL_DICT_INT(d, lf, aura_sz);
+	CNXK_TEL_DICT_INT(d, lf, qints);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
+{
+	__io struct npa_aura_s *aura;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (rte_bitmap_get(lf->npa_bmp, aura_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_AURA;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", aura_id);
+		return rc;
+	}
+
+	aura = &rsp->aura;
+	CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
+	CNXK_TEL_DICT_INT(d, aura, ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
+	CNXK_TEL_DICT_U64(d, aura, count, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
+	CNXK_TEL_DICT_U64(d, aura, limit, w3_);
+	CNXK_TEL_DICT_INT(d, aura, bp, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
+	CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
+	CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
+{
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (rte_bitmap_get(lf->npa_bmp, pool_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = pool_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", pool_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
+	CNXK_TEL_DICT_INT(d, pool, ena, w1_);
+	CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
+	CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
+	CNXK_TEL_DICT_INT(d, pool, shift, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
+	CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
+	CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
+	CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info(const char *cmd __rte_unused,
+			 const char *params __rte_unused,
+			 struct rte_tel_data *d)
+{
+	plt_tel_data_start_dict(d);
+	cnxk_tel_npa(d);
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
+			   struct rte_tel_data *d)
+{
+	int id, rc;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	id = atoi(params);
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "aura/info"))
+		rc = cnxk_tel_npa_aura(id, d);
+	else
+		rc = cnxk_tel_npa_pool(id, d);
+
+	return rc;
+}
+
+RTE_INIT(cnxk_telemetry_npa_init)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
+		"Returns npa information. Takes no parameters");
+
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa aura information. Parameters: aura_id");
+
+	rte_telemetry_register_cmd(
+		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa pool information. Parameters: pool_id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index 6a7849f31c..6fdb5451cb 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -60,5 +60,7 @@ sources = files(
 # Security common code
 sources += files('cnxk_security.c')
 
-includes += include_directories('../../bus/pci')
-includes += include_directories('../../../lib/net')
+# Telemetry common code
+sources += files('cnxk_telemetry_npa.c')
+
+deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 285b24b82d..57b1229bb8 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -19,6 +19,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "roc_bits.h"
 
@@ -139,6 +140,14 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_dict	     rte_tel_data_start_dict
+#define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
+#define plt_tel_data_add_dict_ptr(d, n, v)			\
+	rte_tel_data_add_dict_u64(d, n, (uint64_t)v)
+#define plt_tel_data_add_dict_string rte_tel_data_add_dict_string
+#define plt_tel_data_add_dict_u64    rte_tel_data_add_dict_u64
+
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
-- 
2.25.1


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

* [dpdk-dev] [v5, 2/2] mempool/cnxk: add telemetry end points
  2021-08-27  6:41       ` [dpdk-dev] [v5, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
  2021-08-27  6:41         ` [dpdk-dev] [v5, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-08-27  6:41         ` Gowrishankar Muthukrishnan
  2021-09-04  3:25         ` [dpdk-dev] [v6, 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
                           ` (2 subsequent siblings)
  4 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-27  6:41 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, thomas, jerinj, kirankumark,
	ndabilpuram, skori, skoteshwar, Gowrishankar Muthukrishnan

Adding telemetry end points to cnxk mempool driver.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/mempool/cnxk/cnxk_mempool_telemetry.c | 100 ++++++++++++++++++
 drivers/mempool/cnxk/meson.build              |   3 +-
 2 files changed, 102 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c

diff --git a/drivers/mempool/cnxk/cnxk_mempool_telemetry.c b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
new file mode 100644
index 0000000000..690f557f62
--- /dev/null
+++ b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
@@ -0,0 +1,100 @@
+/* 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"
+
+static void
+mempool_list_cb(struct rte_mempool *mp, void *arg)
+{
+	struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+	rte_tel_data_add_array_string(d, mp->name);
+}
+
+static int
+mempool_tel_handle_list(const char *cmd __rte_unused,
+			const char *params __rte_unused, struct rte_tel_data *d)
+{
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+	rte_mempool_walk(mempool_list_cb, d);
+	return 0;
+}
+
+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;
+	const struct rte_memzone *mz;
+	int aura_id;
+
+	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+		return;
+
+	CNXK_TEL_DICT_STR(info->d, mp, name);
+	CNXK_TEL_DICT_INT(info->d, mp, pool_id);
+	CNXK_TEL_DICT_INT(info->d, mp, flags);
+	CNXK_TEL_DICT_INT(info->d, mp, socket_id);
+	CNXK_TEL_DICT_INT(info->d, mp, size);
+	CNXK_TEL_DICT_INT(info->d, mp, cache_size);
+	CNXK_TEL_DICT_INT(info->d, mp, elt_size);
+	CNXK_TEL_DICT_INT(info->d, mp, header_size);
+	CNXK_TEL_DICT_INT(info->d, mp, trailer_size);
+	CNXK_TEL_DICT_INT(info->d, mp, private_data_size);
+	CNXK_TEL_DICT_INT(info->d, mp, ops_index);
+	CNXK_TEL_DICT_INT(info->d, mp, populated_size);
+
+	aura_id = roc_npa_aura_handle_to_aura(mp->pool_id);
+	rte_tel_data_add_dict_int(info->d, "aura_id", aura_id);
+
+	mz = mp->mz;
+	CNXK_TEL_DICT_STR(info->d, mz, name, mz_);
+	CNXK_TEL_DICT_PTR(info->d, mz, iova, mz_);
+	CNXK_TEL_DICT_PTR(info->d, mz, addr, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, len, mz_);
+	CNXK_TEL_DICT_U64(info->d, mz, hugepage_sz, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, socket_id, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, flags, mz_);
+}
+
+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 -1;
+
+	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/list", mempool_tel_handle_list,
+		"Returns list of available mempools. Takes no parameters");
+	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..7834a19118 100644
--- a/drivers/mempool/cnxk/meson.build
+++ b/drivers/mempool/cnxk/meson.build
@@ -11,8 +11,9 @@ endif
 sources = files(
         'cnxk_mempool.c',
         'cnxk_mempool_ops.c',
+        'cnxk_mempool_telemetry.c',
         'cn9k_mempool_ops.c',
         'cn10k_mempool_ops.c',
 )
 
-deps += ['eal', 'mbuf', 'kvargs', 'bus_pci', 'common_cnxk', 'mempool']
+deps += ['eal', 'mbuf', 'kvargs', 'bus_pci', 'common_cnxk', 'mempool', 'telemetry']
-- 
2.25.1


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

* Re: [dpdk-dev] [EXT] Re: [v4, 1/2] common/cnxk: add telemetry endpoints to npa
  2021-08-26 18:06         ` Bruce Richardson
@ 2021-08-27  6:43           ` Gowrishankar Muthukrishnan
  0 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-08-27  6:43 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: dev, ciara.power, thomas, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda, Nithin Kumar Dabilpuram,
	Sunil Kumar Kori, Satha Koteswara Rao Kottidi

> >  includes += include_directories('../../bus/pci')
> >  includes += include_directories('../../../lib/net')
> > +includes += include_directories('../../../lib/telemetry')
> 
> Rather than giving the include directories, I'd recommend using "deps"
> variable to specify a direct dependency on those libraries. This should probably
> be:
> 
> deps += ['bus_pci', 'net', 'telemetry']
> 
> Using these as dependencies means that the header paths will be added
> automatically, and the libraries linked against too if any functions from those
> are used by the code in this lib.
> 

Ack. Thanks Bruce.

Regards,
Gowrishankar
> Regards,
> /Bruce

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

* [dpdk-dev] [v6, 0/4] cnxk: enable telemetry endpoints
  2021-08-27  6:41       ` [dpdk-dev] [v5, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
  2021-08-27  6:41         ` [dpdk-dev] [v5, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
  2021-08-27  6:41         ` [dpdk-dev] [v5, 2/2] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
@ 2021-09-04  3:25         ` Gowrishankar Muthukrishnan
  2021-09-04  3:25           ` [dpdk-dev] [v6, 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
                             ` (3 more replies)
  2021-09-08 17:03         ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  2021-09-21 10:52         ` [dpdk-dev] [v8, 0/4] cnxk: enable telemetry endpoints for mempool and ethdev Gowrishankar Muthukrishnan
  4 siblings, 4 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-04  3:25 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula,
	Gowrishankar Muthukrishnan

This patch series enables telemetry for cnxk in the following:
 - NPA LF
 - Mempool driver
 - NIX LF
 - Ethdev driver

Depends-on: series-18612 ("net/cnxk: support for inline ipsec")

v6:
 - Added nix and ethdev endpoints.

Gowrishankar Muthukrishnan (4):
  common/cnxk: add telemetry endpoints to npa
  mempool/cnxk: add telemetry end points
  common/cnxk: add telemetry endpoints to nix
  net/cnxk: add telemetry endpoing to ethdev

 drivers/common/cnxk/cnxk_telemetry.h          |  26 +
 drivers/common/cnxk/cnxk_telemetry_nix.c      | 852 ++++++++++++++++++
 drivers/common/cnxk/cnxk_telemetry_npa.c      | 225 +++++
 drivers/common/cnxk/meson.build               |   7 +-
 drivers/common/cnxk/roc_nix.c                 |   3 +
 drivers/common/cnxk/roc_nix_priv.h            |   9 +
 drivers/common/cnxk/roc_nix_queue.c           |  17 +-
 drivers/common/cnxk/roc_platform.h            |  15 +
 drivers/mempool/cnxk/cnxk_mempool_telemetry.c | 100 ++
 drivers/mempool/cnxk/meson.build              |   1 +
 drivers/net/cnxk/cnxk_ethdev_telemetry.c      | 148 +++
 drivers/net/cnxk/meson.build                  |   1 +
 12 files changed, 1398 insertions(+), 6 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
 create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c
 create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c

-- 
2.25.1


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

* [dpdk-dev] [v6, 1/4] common/cnxk: add telemetry endpoints to npa
  2021-09-04  3:25         ` [dpdk-dev] [v6, 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
@ 2021-09-04  3:25           ` Gowrishankar Muthukrishnan
  2021-09-04  3:25           ` [dpdk-dev] [v6, 2/4] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
                             ` (2 subsequent siblings)
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-04  3:25 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula,
	Gowrishankar Muthukrishnan

Add telemetry endpoints to npa.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 225 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   6 +-
 drivers/common/cnxk/roc_platform.h       |  12 ++
 4 files changed, 267 insertions(+), 2 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

diff --git a/drivers/common/cnxk/cnxk_telemetry.h b/drivers/common/cnxk/cnxk_telemetry.h
new file mode 100644
index 0000000000..1461fd893f
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Marvell.
+ */
+
+#ifndef __CNXK_TELEMETRY_H_
+#define __CNXK_TELEMETRY_H_
+
+#define CNXK_TEL_STR(s)		  #s
+#define CNXK_TEL_STR_PREFIX(s, p) CNXK_TEL_STR(p##s)
+#define CNXK_TEL_DICT_INT(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_int(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_PTR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(p)->s)
+#define CNXK_TEL_DICT_BF_PTR(d, p, s, ...)                                     \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(uint64_t)(p)->s)
+#define CNXK_TEL_DICT_U64(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_u64(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_STR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_string(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),   \
+				     (p)->s)
+
+#endif /* __CNXK_TELEMETRY_H_ */
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
new file mode 100644
index 0000000000..c88279409d
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -0,0 +1,225 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+static int
+cnxk_tel_npa(struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int aura_cnt = 0;
+	uint32_t i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	for (i = 0; i < lf->nr_pools; i++) {
+		if (plt_bitmap_get(lf->npa_bmp, i))
+			continue;
+		aura_cnt++;
+	}
+
+	plt_tel_data_add_dict_ptr(d, "npa", lf);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
+
+	CNXK_TEL_DICT_PTR(d, lf, pci_dev);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
+	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
+	CNXK_TEL_DICT_PTR(d, lf, intr_handle);
+	CNXK_TEL_DICT_PTR(d, lf, mbox);
+	CNXK_TEL_DICT_PTR(d, lf, base);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
+	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
+	CNXK_TEL_DICT_INT(d, lf, nr_pools);
+	CNXK_TEL_DICT_INT(d, lf, pf_func);
+	CNXK_TEL_DICT_INT(d, lf, aura_sz);
+	CNXK_TEL_DICT_INT(d, lf, qints);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
+{
+	__io struct npa_aura_s *aura;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (plt_bitmap_get(lf->npa_bmp, aura_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_AURA;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", aura_id);
+		return rc;
+	}
+
+	aura = &rsp->aura;
+	CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
+	CNXK_TEL_DICT_INT(d, aura, ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
+	CNXK_TEL_DICT_U64(d, aura, count, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
+	CNXK_TEL_DICT_U64(d, aura, limit, w3_);
+	CNXK_TEL_DICT_INT(d, aura, bp, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
+	CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
+	CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
+{
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (plt_bitmap_get(lf->npa_bmp, pool_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = pool_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", pool_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
+	CNXK_TEL_DICT_INT(d, pool, ena, w1_);
+	CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
+	CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
+	CNXK_TEL_DICT_INT(d, pool, shift, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
+	CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
+	CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
+	CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info(const char *cmd __plt_unused,
+			 const char *params __plt_unused,
+			 struct plt_tel_data *d)
+{
+	plt_tel_data_start_dict(d);
+	cnxk_tel_npa(d);
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
+			   struct plt_tel_data *d)
+{
+	int id, rc;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	id = atoi(params);
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "aura/info"))
+		rc = cnxk_tel_npa_aura(id, d);
+	else
+		rc = cnxk_tel_npa_pool(id, d);
+
+	return rc;
+}
+
+PLT_INIT(cnxk_telemetry_npa_init)
+{
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
+		"Returns npa information. Takes no parameters");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa aura information. Parameters: aura_id");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa pool information. Parameters: pool_id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index cd19ad29c1..f0a1c9f115 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -64,5 +64,7 @@ sources = files(
 # Security common code
 sources += files('cnxk_security.c')
 
-includes += include_directories('../../bus/pci')
-includes += include_directories('../../../lib/net')
+# Telemetry common code
+sources += files('cnxk_telemetry_npa.c')
+
+deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 241655b334..57073d62aa 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -19,6 +19,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "roc_bits.h"
 
@@ -51,6 +52,7 @@
 #define PLT_CACHE_LINE_SIZE      RTE_CACHE_LINE_SIZE
 #define BITMASK_ULL		 GENMASK_ULL
 #define PLT_ALIGN_CEIL		 RTE_ALIGN_CEIL
+#define PLT_INIT		 RTE_INIT
 
 /** Divide ceil */
 #define PLT_DIV_CEIL(x, y)			\
@@ -63,6 +65,7 @@
 #define __plt_cache_aligned __rte_cache_aligned
 #define __plt_always_inline __rte_always_inline
 #define __plt_packed	    __rte_packed
+#define __plt_unused	    __rte_unused
 #define __roc_api	    __rte_internal
 #define plt_iova_t	    rte_iova_t
 
@@ -142,6 +145,15 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_dict      rte_tel_data_start_dict
+#define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
+#define plt_tel_data_add_dict_ptr(d, n, v)			\
+	rte_tel_data_add_dict_u64(d, n, (uint64_t)v)
+#define plt_tel_data_add_dict_string rte_tel_data_add_dict_string
+#define plt_tel_data_add_dict_u64    rte_tel_data_add_dict_u64
+#define plt_telemetry_register_cmd   rte_telemetry_register_cmd
+
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
-- 
2.25.1


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

* [dpdk-dev] [v6, 2/4] mempool/cnxk: add telemetry end points
  2021-09-04  3:25         ` [dpdk-dev] [v6, 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  2021-09-04  3:25           ` [dpdk-dev] [v6, 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-09-04  3:25           ` Gowrishankar Muthukrishnan
  2021-09-04  3:25           ` [dpdk-dev] [v6, 3/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
  2021-09-04  3:25           ` [dpdk-dev] [v6, 4/4] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-04  3:25 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula,
	Gowrishankar Muthukrishnan

Adding telemetry end points to cnxk mempool driver.

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

diff --git a/drivers/mempool/cnxk/cnxk_mempool_telemetry.c b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
new file mode 100644
index 0000000000..690f557f62
--- /dev/null
+++ b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
@@ -0,0 +1,100 @@
+/* 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"
+
+static void
+mempool_list_cb(struct rte_mempool *mp, void *arg)
+{
+	struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+	rte_tel_data_add_array_string(d, mp->name);
+}
+
+static int
+mempool_tel_handle_list(const char *cmd __rte_unused,
+			const char *params __rte_unused, struct rte_tel_data *d)
+{
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+	rte_mempool_walk(mempool_list_cb, d);
+	return 0;
+}
+
+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;
+	const struct rte_memzone *mz;
+	int aura_id;
+
+	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+		return;
+
+	CNXK_TEL_DICT_STR(info->d, mp, name);
+	CNXK_TEL_DICT_INT(info->d, mp, pool_id);
+	CNXK_TEL_DICT_INT(info->d, mp, flags);
+	CNXK_TEL_DICT_INT(info->d, mp, socket_id);
+	CNXK_TEL_DICT_INT(info->d, mp, size);
+	CNXK_TEL_DICT_INT(info->d, mp, cache_size);
+	CNXK_TEL_DICT_INT(info->d, mp, elt_size);
+	CNXK_TEL_DICT_INT(info->d, mp, header_size);
+	CNXK_TEL_DICT_INT(info->d, mp, trailer_size);
+	CNXK_TEL_DICT_INT(info->d, mp, private_data_size);
+	CNXK_TEL_DICT_INT(info->d, mp, ops_index);
+	CNXK_TEL_DICT_INT(info->d, mp, populated_size);
+
+	aura_id = roc_npa_aura_handle_to_aura(mp->pool_id);
+	rte_tel_data_add_dict_int(info->d, "aura_id", aura_id);
+
+	mz = mp->mz;
+	CNXK_TEL_DICT_STR(info->d, mz, name, mz_);
+	CNXK_TEL_DICT_PTR(info->d, mz, iova, mz_);
+	CNXK_TEL_DICT_PTR(info->d, mz, addr, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, len, mz_);
+	CNXK_TEL_DICT_U64(info->d, mz, hugepage_sz, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, socket_id, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, flags, mz_);
+}
+
+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 -1;
+
+	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/list", mempool_tel_handle_list,
+		"Returns list of available mempools. Takes no parameters");
+	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',
 )
-- 
2.25.1


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

* [dpdk-dev] [v6, 3/4] common/cnxk: add telemetry endpoints to nix
  2021-09-04  3:25         ` [dpdk-dev] [v6, 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  2021-09-04  3:25           ` [dpdk-dev] [v6, 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
  2021-09-04  3:25           ` [dpdk-dev] [v6, 2/4] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
@ 2021-09-04  3:25           ` Gowrishankar Muthukrishnan
  2021-09-04  3:25           ` [dpdk-dev] [v6, 4/4] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-04  3:25 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula,
	Gowrishankar Muthukrishnan

Add telemetry endpoints to nix.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry_nix.c | 852 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   3 +-
 drivers/common/cnxk/roc_nix.c            |   3 +
 drivers/common/cnxk/roc_nix_priv.h       |   9 +
 drivers/common/cnxk/roc_nix_queue.c      |  17 +-
 drivers/common/cnxk/roc_platform.h       |   3 +
 6 files changed, 882 insertions(+), 5 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c

diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c b/drivers/common/cnxk/cnxk_telemetry_nix.c
new file mode 100644
index 0000000000..5f9e3f3a77
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_nix.c
@@ -0,0 +1,852 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+struct nix_tel_node {
+	TAILQ_ENTRY(nix_tel_node) node;
+	struct roc_nix *nix;
+	uint16_t n_rq;
+	uint16_t n_cq;
+	uint16_t n_sq;
+	struct roc_nix_rq **rqs;
+	struct roc_nix_cq **cqs;
+	struct roc_nix_sq **sqs;
+};
+
+TAILQ_HEAD(nix_tel_node_list, nix_tel_node);
+static struct nix_tel_node_list nix_list;
+
+static struct nix_tel_node *
+nix_tel_node_get(struct roc_nix *roc_nix)
+{
+	struct nix_tel_node *node, *roc_node = NULL;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (node->nix == roc_nix) {
+			roc_node = node;
+			break;
+		}
+	}
+
+	return roc_node;
+}
+
+int
+nix_tel_node_add(struct roc_nix *roc_nix)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(roc_nix);
+	if (node) {
+		if (nix->nb_rx_queues == node->n_rq &&
+		    nix->nb_tx_queues == node->n_sq)
+			return 0;
+
+		nix_tel_node_del(roc_nix);
+	}
+
+	node = plt_zmalloc(sizeof(struct nix_tel_node), 0);
+	if (!node)
+		return -1;
+
+	node->nix = roc_nix;
+	node->rqs =
+		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_rq *), 0);
+	node->cqs =
+		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_cq *), 0);
+	node->sqs =
+		plt_zmalloc(nix->nb_tx_queues * sizeof(struct roc_nix_sq *), 0);
+	TAILQ_INSERT_TAIL(&nix_list, node, node);
+
+	return 0;
+}
+
+void
+nix_tel_node_del(struct roc_nix *roc_nix)
+{
+	struct nix_tel_node *node;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (node->nix == roc_nix) {
+			plt_free(node->rqs);
+			plt_free(node->cqs);
+			plt_free(node->rqs);
+			TAILQ_REMOVE(&nix_list, node, node);
+		}
+	}
+
+	plt_free(node);
+}
+
+static struct nix_tel_node *
+nix_tel_node_get_by_pcidev_name(const char *name)
+{
+	struct nix_tel_node *node, *roc_node = NULL;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (!strncmp(node->nix->pci_dev->name, name,
+			     PCI_PRI_STR_SIZE)) {
+			roc_node = node;
+			break;
+		}
+	}
+
+	return roc_node;
+}
+
+int
+nix_tel_node_add_rq(struct roc_nix_rq *rq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(rq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->rqs[rq->qid] = rq;
+	node->n_rq++;
+	return 0;
+}
+
+int
+nix_tel_node_add_cq(struct roc_nix_cq *cq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(cq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->cqs[cq->qid] = cq;
+	node->n_cq++;
+	return 0;
+}
+
+int
+nix_tel_node_add_sq(struct roc_nix_sq *sq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(sq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->sqs[sq->qid] = sq;
+	node->n_sq++;
+	return 0;
+}
+
+static int
+cnxk_tel_nix(struct roc_nix *roc_nix, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+
+	struct dev *dev = &nix->dev;
+
+	plt_tel_data_add_dict_ptr(d, "nix", nix);
+	plt_tel_data_add_dict_int(d, "pf_func", dev->pf_func);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(dev->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(dev->pf_func));
+
+	CNXK_TEL_DICT_PTR(d, dev, bar2);
+	CNXK_TEL_DICT_PTR(d, dev, bar4);
+	CNXK_TEL_DICT_INT(d, roc_nix, port_id);
+	CNXK_TEL_DICT_INT(d, roc_nix, rss_tag_as_xor);
+	CNXK_TEL_DICT_INT(d, roc_nix, max_sqb_count);
+	CNXK_TEL_DICT_PTR(d, nix, pci_dev);
+	CNXK_TEL_DICT_PTR(d, nix, base);
+	CNXK_TEL_DICT_PTR(d, nix, lmt_base);
+	CNXK_TEL_DICT_INT(d, nix, reta_sz);
+	CNXK_TEL_DICT_INT(d, nix, tx_chan_base);
+	CNXK_TEL_DICT_INT(d, nix, rx_chan_base);
+	CNXK_TEL_DICT_INT(d, nix, nb_tx_queues);
+	CNXK_TEL_DICT_INT(d, nix, nb_rx_queues);
+	CNXK_TEL_DICT_INT(d, nix, lso_tsov6_idx);
+	CNXK_TEL_DICT_INT(d, nix, lso_tsov4_idx);
+
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v4",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v6",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v4",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v6",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v4v4",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v4v6",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v6v4",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v6v6",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+
+	CNXK_TEL_DICT_INT(d, nix, lf_tx_stats);
+	CNXK_TEL_DICT_INT(d, nix, lf_rx_stats);
+	CNXK_TEL_DICT_INT(d, nix, cgx_links);
+	CNXK_TEL_DICT_INT(d, nix, lbk_links);
+	CNXK_TEL_DICT_INT(d, nix, sdp_links);
+	CNXK_TEL_DICT_INT(d, nix, tx_link);
+	CNXK_TEL_DICT_INT(d, nix, sqb_size);
+	CNXK_TEL_DICT_INT(d, nix, msixoff);
+	CNXK_TEL_DICT_INT(d, nix, cints);
+	CNXK_TEL_DICT_INT(d, nix, qints);
+	CNXK_TEL_DICT_INT(d, nix, sdp_link);
+	CNXK_TEL_DICT_INT(d, nix, ptp_en);
+	CNXK_TEL_DICT_INT(d, nix, rss_alg_idx);
+	CNXK_TEL_DICT_INT(d, nix, tx_pause);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_rq(struct roc_nix_rq *rq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_rq", rq);
+	CNXK_TEL_DICT_INT(d, rq, qid);
+	CNXK_TEL_DICT_PTR(d, rq, aura_handle);
+	CNXK_TEL_DICT_INT(d, rq, ipsech_ena);
+	CNXK_TEL_DICT_INT(d, rq, first_skip);
+	CNXK_TEL_DICT_INT(d, rq, later_skip);
+	CNXK_TEL_DICT_INT(d, rq, lpb_size);
+	CNXK_TEL_DICT_INT(d, rq, sso_ena);
+	CNXK_TEL_DICT_INT(d, rq, tag_mask);
+	CNXK_TEL_DICT_INT(d, rq, flow_tag_width);
+	CNXK_TEL_DICT_INT(d, rq, tt);
+	CNXK_TEL_DICT_INT(d, rq, hwgrp);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_ena);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_first_skip);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_max_sz_exp);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_wait_tmo);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_aura_handle);
+	CNXK_TEL_DICT_PTR(d, rq, roc_nix);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_cq(struct roc_nix_cq *cq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_cq", cq);
+	CNXK_TEL_DICT_INT(d, cq, qid);
+	CNXK_TEL_DICT_INT(d, cq, nb_desc);
+	CNXK_TEL_DICT_PTR(d, cq, roc_nix);
+	CNXK_TEL_DICT_PTR(d, cq, door);
+	CNXK_TEL_DICT_PTR(d, cq, status);
+	CNXK_TEL_DICT_PTR(d, cq, wdata);
+	CNXK_TEL_DICT_PTR(d, cq, desc_base);
+	CNXK_TEL_DICT_INT(d, cq, qmask);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_sq(struct roc_nix_sq *sq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_sq", sq);
+	CNXK_TEL_DICT_INT(d, sq, qid);
+	CNXK_TEL_DICT_INT(d, sq, max_sqe_sz);
+	CNXK_TEL_DICT_INT(d, sq, nb_desc);
+	CNXK_TEL_DICT_INT(d, sq, sqes_per_sqb_log2);
+	CNXK_TEL_DICT_PTR(d, sq, roc_nix);
+	CNXK_TEL_DICT_PTR(d, sq, aura_handle);
+	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs_adj);
+	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs);
+	CNXK_TEL_DICT_PTR(d, sq, io_addr);
+	CNXK_TEL_DICT_PTR(d, sq, lmt_addr);
+	CNXK_TEL_DICT_PTR(d, sq, sqe_mem);
+	CNXK_TEL_DICT_PTR(d, sq, fc);
+
+	return 0;
+}
+
+static void
+nix_rq_ctx_cn9k(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_rq_ctx_s *ctx = (struct nix_rq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
+	CNXK_TEL_DICT_BF_PTR(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_);
+}
+
+static void
+nix_rq_ctx(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_cn10k_rq_ctx_s *ctx = (struct nix_cn10k_rq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_ol3_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_ol4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_il3_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_il4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, csum_ol4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, lenerr_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0);
+	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, chi_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsecd_drop_en, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_stashing, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, policer_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, band_prof_id, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_INT(d, ctx, vwqe_skip, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, max_vsize_exp, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, vtime_wait, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, vwqe_ena, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsec_vwqe, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_);
+}
+
+static int
+cnxk_tel_nix_rq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile void *qctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_RQ, n, &qctx);
+	if (rc) {
+		plt_err("Failed to get rq context");
+		return rc;
+	}
+
+	if (roc_model_is_cn9k())
+		nix_rq_ctx_cn9k(&qctx, d);
+	else
+		nix_rq_ctx(&qctx, d);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_cq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile struct nix_cq_ctx_s *ctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_CQ, n, (void *)&ctx);
+	if (rc) {
+		plt_err("Failed to get cq context");
+		return rc;
+	}
+
+	/* W0 */
+	CNXK_TEL_DICT_PTR(d, ctx, base, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_U64(d, ctx, wrptr, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cint_idx, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_err, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, bpid, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, bp_ena, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, update_time, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, avg_level, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, head, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, tail, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, cq_err_int_ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_err_int, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, qsize, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, caching, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, drop_ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, bp, w3_);
+
+	return 0;
+}
+
+static void
+nix_sq_ctx_cn9k(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_sq_ctx_s *ctx = (struct nix_sq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_quantum, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
+
+	/* W11 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
+
+	/* W12 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
+
+	/* W14 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
+
+	/* W15 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_);
+}
+
+static void
+nix_sq_ctx(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_cn10k_sq_ctx_s *ctx = (struct nix_cn10k_sq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_weight, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_ub, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_lb, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
+
+	/* W11 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
+
+	/* W12 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
+
+	/* W14 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
+
+	/* W15 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_);
+}
+
+static int
+cnxk_tel_nix_sq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile void *qctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_SQ, n, &qctx);
+	if (rc) {
+		plt_err("Failed to get rq context");
+		return rc;
+	}
+
+	if (roc_model_is_cn9k())
+		nix_sq_ctx_cn9k(&qctx, d);
+	else
+		nix_sq_ctx(&qctx, d);
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_list(const char *cmd __plt_unused,
+			 const char *params __plt_unused,
+			 struct plt_tel_data *d)
+{
+	struct nix_tel_node *node;
+	struct roc_nix *roc_nix;
+
+	plt_tel_data_start_array(d, PLT_TEL_STRING_VAL);
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		roc_nix = node->nix;
+		plt_tel_data_add_array_string(d, roc_nix->pci_dev->name);
+	}
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_info(const char *cmd __plt_unused, const char *params,
+			 struct plt_tel_data *d)
+{
+	char name[PCI_PRI_STR_SIZE];
+	struct nix_tel_node *node;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	plt_strlcpy(name, params, PCI_PRI_STR_SIZE);
+
+	node = nix_tel_node_get_by_pcidev_name(name);
+	if (!node)
+		return -1;
+
+	plt_tel_data_start_dict(d);
+	cnxk_tel_nix(node->nix, d);
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
+			   struct plt_tel_data *d)
+{
+	struct nix_tel_node *node;
+	char *name, *param;
+	char buf[1024];
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	plt_strlcpy(buf, params, PCI_PRI_STR_SIZE + 1);
+	name = strtok(buf, ",");
+	param = strtok(NULL, "\0");
+
+	node = nix_tel_node_get_by_pcidev_name(name);
+	if (!node)
+		return -1;
+
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "rq")) {
+		char *tok = strtok(param, ",");
+		int rq;
+
+		if (!tok)
+			goto exit;
+
+		rq = strtol(tok, NULL, 10);
+		if ((node->n_rq <= rq) || (rq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			cnxk_tel_nix_rq_ctx(node->nix, rq, d);
+		else
+			cnxk_tel_nix_rq(node->rqs[rq], d);
+
+	} else if (strstr(cmd, "cq")) {
+		char *tok = strtok(param, ",");
+		int cq;
+
+		if (!tok)
+			goto exit;
+
+		cq = strtol(tok, NULL, 10);
+		if ((node->n_cq <= cq) || (cq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			cnxk_tel_nix_cq_ctx(node->nix, cq, d);
+		else
+			cnxk_tel_nix_cq(node->cqs[cq], d);
+
+	} else if (strstr(cmd, "sq")) {
+		char *tok = strtok(param, ",");
+		int sq;
+
+		if (!tok)
+			goto exit;
+
+		sq = strtol(tok, NULL, 10);
+		if ((node->n_sq <= sq) || (sq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			cnxk_tel_nix_sq_ctx(node->nix, sq, d);
+		else
+			cnxk_tel_nix_sq(node->sqs[sq], d);
+	}
+
+	return 0;
+
+exit:
+	return -1;
+}
+
+PLT_INIT(cnxk_telemetry_nix_init)
+{
+	TAILQ_INIT(&nix_list);
+
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/list", cnxk_nix_tel_handle_list,
+		"Returns list of available NIX devices. Takes no parameters");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/info", cnxk_nix_tel_handle_info,
+		"Returns nix information. Parameters: pci id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/rq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix rq information. Parameters: pci id, rq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/rq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix rq context. Parameters: pci id, rq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/cq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix cq information. Parameters: pci id, cq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/cq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix cq context. Parameters: pci id, cq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/sq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix sq information. Parameters: pci id, sq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/sq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix sq context. Parameters: pci id, sq id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index f0a1c9f115..fe7a95b526 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -65,6 +65,7 @@ sources = files(
 sources += files('cnxk_security.c')
 
 # Telemetry common code
-sources += files('cnxk_telemetry_npa.c')
+sources += files('cnxk_telemetry_npa.c',
+                 'cnxk_telemetry_nix.c')
 
 deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_nix.c b/drivers/common/cnxk/roc_nix.c
index 3ab954e94d..17beb1a736 100644
--- a/drivers/common/cnxk/roc_nix.c
+++ b/drivers/common/cnxk/roc_nix.c
@@ -178,6 +178,8 @@ roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq, uint32_t nb_txq,
 	nix->sqs = plt_zmalloc(sizeof(struct roc_nix_sq *) * nb_txq, 0);
 	if (!nix->sqs)
 		return -ENOMEM;
+
+	nix_tel_node_add(roc_nix);
 fail:
 	return rc;
 }
@@ -413,6 +415,7 @@ roc_nix_dev_init(struct roc_nix *roc_nix)
 dev_fini:
 	rc |= dev_fini(dev, pci_dev);
 fail:
+	nix_tel_node_del(roc_nix);
 	return rc;
 }
 
diff --git a/drivers/common/cnxk/roc_nix_priv.h b/drivers/common/cnxk/roc_nix_priv.h
index 2cd5a72347..ba639791ce 100644
--- a/drivers/common/cnxk/roc_nix_priv.h
+++ b/drivers/common/cnxk/roc_nix_priv.h
@@ -424,4 +424,13 @@ int nix_lf_int_reg_dump(uintptr_t nix_lf_base, uint64_t *data, uint16_t qints,
 int nix_q_ctx_get(struct dev *dev, uint8_t ctype, uint16_t qid,
 		  __io void **ctx_p);
 
+/*
+ * Telemetry
+ */
+int nix_tel_node_add(struct roc_nix *roc_nix);
+void nix_tel_node_del(struct roc_nix *roc_nix);
+int nix_tel_node_add_rq(struct roc_nix_rq *rq);
+int nix_tel_node_add_cq(struct roc_nix_cq *cq);
+int nix_tel_node_add_sq(struct roc_nix_sq *sq);
+
 #endif /* _ROC_NIX_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_nix_queue.c b/drivers/common/cnxk/roc_nix_queue.c
index 8fbb13ecbd..3631a2004f 100644
--- a/drivers/common/cnxk/roc_nix_queue.c
+++ b/drivers/common/cnxk/roc_nix_queue.c
@@ -387,7 +387,12 @@ roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
 	if (rc)
 		return rc;
 
-	return mbox_process(mbox);
+	rc = mbox_process(mbox);
+	if (rc)
+		return rc;
+
+	return nix_tel_node_add_rq(rq);
+
 }
 
 int
@@ -415,7 +420,11 @@ roc_nix_rq_modify(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
 	if (rc)
 		return rc;
 
-	return mbox_process(mbox);
+	rc = mbox_process(mbox);
+	if (rc)
+		return rc;
+
+	return nix_tel_node_add_rq(rq);
 }
 
 int
@@ -504,7 +513,7 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq)
 	if (rc)
 		goto free_mem;
 
-	return 0;
+	return nix_tel_node_add_cq(cq);
 
 free_mem:
 	plt_free(cq->desc_base);
@@ -884,7 +893,7 @@ roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq)
 					((qid & RVU_CN9K_LMT_SLOT_MASK) << 12));
 	}
 
-	return rc;
+	return nix_tel_node_add_sq(sq);
 nomem:
 	plt_free(sq->fc);
 fail:
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 57073d62aa..b95af115f7 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -145,7 +145,10 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define PLT_TEL_STRING_VAL RTE_TEL_STRING_VAL
 #define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_array     rte_tel_data_start_array
+#define plt_tel_data_add_array_string rte_tel_data_add_array_string
 #define plt_tel_data_start_dict      rte_tel_data_start_dict
 #define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
 #define plt_tel_data_add_dict_ptr(d, n, v)			\
-- 
2.25.1


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

* [dpdk-dev] [v6, 4/4] net/cnxk: add telemetry endpoing to ethdev
  2021-09-04  3:25         ` [dpdk-dev] [v6, 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
                             ` (2 preceding siblings ...)
  2021-09-04  3:25           ` [dpdk-dev] [v6, 3/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
@ 2021-09-04  3:25           ` Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-04  3:25 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula,
	Gowrishankar Muthukrishnan

Add telemetry endpoint to ethdev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/net/cnxk/cnxk_ethdev_telemetry.c | 148 +++++++++++++++++++++++
 drivers/net/cnxk/meson.build             |   1 +
 2 files changed, 149 insertions(+)
 create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c

diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
new file mode 100644
index 0000000000..4d89151a90
--- /dev/null
+++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
@@ -0,0 +1,148 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell International Ltd.
+ */
+
+#include <rte_telemetry.h>
+
+#include "cnxk_ethdev.h"
+
+/* Macro to count no of words in eth_info_s size */
+#define ETH_INFO_SZ                                                            \
+	(RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) /         \
+	 sizeof(uint64_t))
+#define MACADDR_LEN 18
+
+static int
+ethdev_tel_handle_info(const char *cmd __rte_unused,
+		       const char *params __rte_unused, struct rte_tel_data *d)
+{
+	struct rte_eth_dev *eth_dev;
+	struct cnxk_eth_dev *dev;
+	union eth_info_u {
+		struct eth_info_s {
+			/** PF/VF information */
+			uint16_t pf_func;
+			/** No of rx queues */
+			uint16_t rx_queues;
+			/** No of tx queues */
+			uint16_t tx_queues;
+			/** Port ID */
+			uint16_t port_id;
+			/** MAC entries */
+			char mac_addr[MACADDR_LEN];
+			uint8_t max_mac_entries;
+			bool dmac_filter_ena;
+			uint8_t dmac_filter_count;
+			uint16_t flags;
+			uint8_t ptype_disable;
+			bool scalar_ena;
+			bool ptp_ena;
+			/* Offload capabilities */
+			uint64_t rx_offload_capa;
+			uint64_t tx_offload_capa;
+			uint32_t speed_capa;
+			/* Configured offloads */
+			uint64_t rx_offloads;
+			uint64_t tx_offloads;
+			/* Platform specific offload flags */
+			uint16_t rx_offload_flags;
+			uint16_t tx_offload_flags;
+			/* ETHDEV RSS HF bitmask */
+			uint64_t ethdev_rss_hf;
+		} info;
+		uint64_t val[ETH_INFO_SZ];
+	};
+	union eth_info_u *eth_info;
+	struct eth_info_s *info;
+	int n_ports, rc = 0;
+	int i, j = 0;
+
+	n_ports = rte_eth_dev_count_avail();
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_int(d, "n_ports", n_ports);
+
+	if (!n_ports) {
+		plt_err("No active ethernet ports found.");
+		goto exit;
+	}
+
+	/* Allocate memory for hw info structure */
+	eth_info = malloc(sizeof(struct eth_info_s) * n_ports);
+	if (!eth_info) {
+		plt_err("No space for HW info");
+		rc = -ENOMEM;
+		goto exit;
+	}
+
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+		/* Skip if port is unused */
+		if (!rte_eth_dev_is_valid_port(i))
+			continue;
+
+		eth_dev = &rte_eth_devices[i];
+		info = &eth_info[j].info;
+
+		if (eth_dev) {
+			dev = cnxk_eth_pmd_priv(eth_dev);
+			if (dev) {
+				info->pf_func = roc_nix_get_pf_func(&dev->nix);
+				memset(info->mac_addr, 0, MACADDR_LEN);
+				snprintf(info->mac_addr, MACADDR_LEN,
+					 "%02x:%02x:%02x:%02x:%02x:%02x",
+					 dev->mac_addr[0], dev->mac_addr[1],
+					 dev->mac_addr[2], dev->mac_addr[3],
+					 dev->mac_addr[4], dev->mac_addr[5]);
+				info->max_mac_entries = dev->max_mac_entries;
+				info->dmac_filter_ena = dev->dmac_filter_enable;
+				info->dmac_filter_count =
+					dev->dmac_filter_count;
+				info->flags = dev->flags;
+				info->ptype_disable = dev->ptype_disable;
+				info->scalar_ena = dev->scalar_ena;
+				info->ptp_ena = dev->ptp_en;
+				info->rx_offload_capa = dev->rx_offload_capa;
+				info->tx_offload_capa = dev->tx_offload_capa;
+				info->rx_offloads = dev->rx_offloads;
+				info->tx_offloads = dev->tx_offloads;
+				info->rx_offload_flags = dev->rx_offload_flags;
+				info->tx_offload_flags = dev->tx_offload_flags;
+				info->ethdev_rss_hf = dev->ethdev_rss_hf;
+			}
+
+			if (eth_dev->data) {
+				info->rx_queues = eth_dev->data->nb_rx_queues;
+				info->tx_queues = eth_dev->data->nb_tx_queues;
+				info->port_id = eth_dev->data->port_id;
+			}
+
+			j++;
+		}
+	}
+
+	/* Validating available count */
+	if (n_ports != j) {
+		rc = -EINVAL;
+		plt_err("Invalid available port count");
+		goto free;
+	}
+
+	struct rte_tel_data *i_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
+	for (i = 0; i < rte_eth_dev_count_avail(); i++) {
+		for (j = 0; j < (int)ETH_INFO_SZ; j++)
+			rte_tel_data_add_array_u64(i_data, eth_info[i].val[j]);
+	}
+	rte_tel_data_add_dict_container(d, "info", i_data, 0);
+
+free:
+	free(eth_info);
+exit:
+	return rc;
+}
+
+RTE_INIT(cnxk_ethdev_init_telemetry)
+{
+	rte_telemetry_register_cmd("/cnxk/ethdev/info", ethdev_tel_handle_info,
+				   "Returns ethdev device information");
+}
diff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build
index d1d4b4e15e..5b3b8422fb 100644
--- a/drivers/net/cnxk/meson.build
+++ b/drivers/net/cnxk/meson.build
@@ -13,6 +13,7 @@ sources = files(
         'cnxk_ethdev_devargs.c',
         'cnxk_ethdev_ops.c',
         'cnxk_ethdev_sec.c',
+        'cnxk_ethdev_telemetry.c',
         'cnxk_link.c',
         'cnxk_lookup.c',
         'cnxk_ptp.c',
-- 
2.25.1


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

* [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints
  2021-08-27  6:41       ` [dpdk-dev] [v5, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
                           ` (2 preceding siblings ...)
  2021-09-04  3:25         ` [dpdk-dev] [v6, 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
@ 2021-09-08 17:03         ` Gowrishankar Muthukrishnan
  2021-09-08 17:03           ` [dpdk-dev] [v7, 1/6] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
                             ` (6 more replies)
  2021-09-21 10:52         ` [dpdk-dev] [v8, 0/4] cnxk: enable telemetry endpoints for mempool and ethdev Gowrishankar Muthukrishnan
  4 siblings, 7 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-08 17:03 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula, anoobj, adwivedi,
	ktejasree, Gowrishankar Muthukrishnan

This patch series enables telemetry for cnxk in the following:
 - NPA LF
 - Mempool driver
 - NIX LF
 - Ethdev driver
 - Crypto driver

Depends-on: series-18612 ("net/cnxk: support for inline ipsec")

v7:
 - Added cryptodev endppoints.
 - minor cleanup in other patches.

Gowrishankar Muthukrishnan (6):
  common/cnxk: add telemetry endpoints to npa
  mempool/cnxk: add telemetry end points
  common/cnxk: add telemetry endpoints to nix
  net/cnxk: add telemetry endpoing to ethdev
  telemetry: fix json output buffer size
  crypto/cnxk: add telemetry endpoints to cryptodev

 drivers/common/cnxk/cnxk_telemetry.h          |  26 +
 drivers/common/cnxk/cnxk_telemetry_nix.c      | 849 ++++++++++++++++++
 drivers/common/cnxk/cnxk_telemetry_npa.c      | 224 +++++
 drivers/common/cnxk/meson.build               |   7 +-
 drivers/common/cnxk/roc_nix.c                 |   3 +
 drivers/common/cnxk/roc_nix_priv.h            |   9 +
 drivers/common/cnxk/roc_nix_queue.c           |  15 +-
 drivers/common/cnxk/roc_platform.h            |  15 +
 .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 154 ++++
 drivers/crypto/cnxk/meson.build               |   1 +
 drivers/mempool/cnxk/cnxk_mempool_telemetry.c | 100 +++
 drivers/mempool/cnxk/meson.build              |   1 +
 drivers/net/cnxk/cnxk_ethdev_telemetry.c      | 129 +++
 drivers/net/cnxk/meson.build                  |   1 +
 lib/telemetry/telemetry_json.h                |   7 +-
 15 files changed, 1534 insertions(+), 7 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
 create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c
 create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c

-- 
2.25.1


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

* [dpdk-dev] [v7, 1/6] common/cnxk: add telemetry endpoints to npa
  2021-09-08 17:03         ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
@ 2021-09-08 17:03           ` Gowrishankar Muthukrishnan
  2021-09-08 17:03           ` [dpdk-dev] [v7, 2/6] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
                             ` (5 subsequent siblings)
  6 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-08 17:03 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula, anoobj, adwivedi,
	ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to npa.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 224 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   6 +-
 drivers/common/cnxk/roc_platform.h       |  12 ++
 4 files changed, 266 insertions(+), 2 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

diff --git a/drivers/common/cnxk/cnxk_telemetry.h b/drivers/common/cnxk/cnxk_telemetry.h
new file mode 100644
index 0000000000..1461fd893f
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Marvell.
+ */
+
+#ifndef __CNXK_TELEMETRY_H_
+#define __CNXK_TELEMETRY_H_
+
+#define CNXK_TEL_STR(s)		  #s
+#define CNXK_TEL_STR_PREFIX(s, p) CNXK_TEL_STR(p##s)
+#define CNXK_TEL_DICT_INT(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_int(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_PTR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(p)->s)
+#define CNXK_TEL_DICT_BF_PTR(d, p, s, ...)                                     \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(uint64_t)(p)->s)
+#define CNXK_TEL_DICT_U64(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_u64(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_STR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_string(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),   \
+				     (p)->s)
+
+#endif /* __CNXK_TELEMETRY_H_ */
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
new file mode 100644
index 0000000000..37c5f2e961
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -0,0 +1,224 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+static int
+cnxk_tel_npa(struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int aura_cnt = 0;
+	uint32_t i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	for (i = 0; i < lf->nr_pools; i++) {
+		if (plt_bitmap_get(lf->npa_bmp, i))
+			continue;
+		aura_cnt++;
+	}
+
+	plt_tel_data_add_dict_ptr(d, "npa", lf);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
+
+	CNXK_TEL_DICT_PTR(d, lf, pci_dev);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
+	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
+	CNXK_TEL_DICT_PTR(d, lf, intr_handle);
+	CNXK_TEL_DICT_PTR(d, lf, mbox);
+	CNXK_TEL_DICT_PTR(d, lf, base);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
+	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
+	CNXK_TEL_DICT_INT(d, lf, nr_pools);
+	CNXK_TEL_DICT_INT(d, lf, pf_func);
+	CNXK_TEL_DICT_INT(d, lf, aura_sz);
+	CNXK_TEL_DICT_INT(d, lf, qints);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
+{
+	__io struct npa_aura_s *aura;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (plt_bitmap_get(lf->npa_bmp, aura_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_AURA;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", aura_id);
+		return rc;
+	}
+
+	aura = &rsp->aura;
+	CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
+	CNXK_TEL_DICT_INT(d, aura, ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
+	CNXK_TEL_DICT_U64(d, aura, count, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
+	CNXK_TEL_DICT_U64(d, aura, limit, w3_);
+	CNXK_TEL_DICT_INT(d, aura, bp, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
+	CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
+	CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
+{
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (plt_bitmap_get(lf->npa_bmp, pool_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = pool_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", pool_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
+	CNXK_TEL_DICT_INT(d, pool, ena, w1_);
+	CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
+	CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
+	CNXK_TEL_DICT_INT(d, pool, shift, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
+	CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
+	CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
+	CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info(const char *cmd __plt_unused,
+			 const char *params __plt_unused,
+			 struct plt_tel_data *d)
+{
+	plt_tel_data_start_dict(d);
+	return cnxk_tel_npa(d);
+}
+
+static int
+cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
+			   struct plt_tel_data *d)
+{
+	int id, rc;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	id = atoi(params);
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "aura/info"))
+		rc = cnxk_tel_npa_aura(id, d);
+	else
+		rc = cnxk_tel_npa_pool(id, d);
+
+	return rc;
+}
+
+PLT_INIT(cnxk_telemetry_npa_init)
+{
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
+		"Returns npa information. Takes no parameters");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa aura information. Parameters: aura_id");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa pool information. Parameters: pool_id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index cd19ad29c1..f0a1c9f115 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -64,5 +64,7 @@ sources = files(
 # Security common code
 sources += files('cnxk_security.c')
 
-includes += include_directories('../../bus/pci')
-includes += include_directories('../../../lib/net')
+# Telemetry common code
+sources += files('cnxk_telemetry_npa.c')
+
+deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 241655b334..57073d62aa 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -19,6 +19,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "roc_bits.h"
 
@@ -51,6 +52,7 @@
 #define PLT_CACHE_LINE_SIZE      RTE_CACHE_LINE_SIZE
 #define BITMASK_ULL		 GENMASK_ULL
 #define PLT_ALIGN_CEIL		 RTE_ALIGN_CEIL
+#define PLT_INIT		 RTE_INIT
 
 /** Divide ceil */
 #define PLT_DIV_CEIL(x, y)			\
@@ -63,6 +65,7 @@
 #define __plt_cache_aligned __rte_cache_aligned
 #define __plt_always_inline __rte_always_inline
 #define __plt_packed	    __rte_packed
+#define __plt_unused	    __rte_unused
 #define __roc_api	    __rte_internal
 #define plt_iova_t	    rte_iova_t
 
@@ -142,6 +145,15 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_dict      rte_tel_data_start_dict
+#define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
+#define plt_tel_data_add_dict_ptr(d, n, v)			\
+	rte_tel_data_add_dict_u64(d, n, (uint64_t)v)
+#define plt_tel_data_add_dict_string rte_tel_data_add_dict_string
+#define plt_tel_data_add_dict_u64    rte_tel_data_add_dict_u64
+#define plt_telemetry_register_cmd   rte_telemetry_register_cmd
+
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
-- 
2.25.1


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

* [dpdk-dev] [v7, 2/6] mempool/cnxk: add telemetry end points
  2021-09-08 17:03         ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  2021-09-08 17:03           ` [dpdk-dev] [v7, 1/6] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-09-08 17:03           ` Gowrishankar Muthukrishnan
  2021-09-08 17:03           ` [dpdk-dev] [v7, 3/6] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
                             ` (4 subsequent siblings)
  6 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-08 17:03 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula, anoobj, adwivedi,
	ktejasree, Gowrishankar Muthukrishnan

Adding telemetry end points to cnxk mempool driver.

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

diff --git a/drivers/mempool/cnxk/cnxk_mempool_telemetry.c b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
new file mode 100644
index 0000000000..690f557f62
--- /dev/null
+++ b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
@@ -0,0 +1,100 @@
+/* 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"
+
+static void
+mempool_list_cb(struct rte_mempool *mp, void *arg)
+{
+	struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+	rte_tel_data_add_array_string(d, mp->name);
+}
+
+static int
+mempool_tel_handle_list(const char *cmd __rte_unused,
+			const char *params __rte_unused, struct rte_tel_data *d)
+{
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+	rte_mempool_walk(mempool_list_cb, d);
+	return 0;
+}
+
+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;
+	const struct rte_memzone *mz;
+	int aura_id;
+
+	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+		return;
+
+	CNXK_TEL_DICT_STR(info->d, mp, name);
+	CNXK_TEL_DICT_INT(info->d, mp, pool_id);
+	CNXK_TEL_DICT_INT(info->d, mp, flags);
+	CNXK_TEL_DICT_INT(info->d, mp, socket_id);
+	CNXK_TEL_DICT_INT(info->d, mp, size);
+	CNXK_TEL_DICT_INT(info->d, mp, cache_size);
+	CNXK_TEL_DICT_INT(info->d, mp, elt_size);
+	CNXK_TEL_DICT_INT(info->d, mp, header_size);
+	CNXK_TEL_DICT_INT(info->d, mp, trailer_size);
+	CNXK_TEL_DICT_INT(info->d, mp, private_data_size);
+	CNXK_TEL_DICT_INT(info->d, mp, ops_index);
+	CNXK_TEL_DICT_INT(info->d, mp, populated_size);
+
+	aura_id = roc_npa_aura_handle_to_aura(mp->pool_id);
+	rte_tel_data_add_dict_int(info->d, "aura_id", aura_id);
+
+	mz = mp->mz;
+	CNXK_TEL_DICT_STR(info->d, mz, name, mz_);
+	CNXK_TEL_DICT_PTR(info->d, mz, iova, mz_);
+	CNXK_TEL_DICT_PTR(info->d, mz, addr, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, len, mz_);
+	CNXK_TEL_DICT_U64(info->d, mz, hugepage_sz, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, socket_id, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, flags, mz_);
+}
+
+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 -1;
+
+	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/list", mempool_tel_handle_list,
+		"Returns list of available mempools. Takes no parameters");
+	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',
 )
-- 
2.25.1


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

* [dpdk-dev] [v7, 3/6] common/cnxk: add telemetry endpoints to nix
  2021-09-08 17:03         ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  2021-09-08 17:03           ` [dpdk-dev] [v7, 1/6] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
  2021-09-08 17:03           ` [dpdk-dev] [v7, 2/6] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
@ 2021-09-08 17:03           ` Gowrishankar Muthukrishnan
  2021-09-08 17:03           ` [dpdk-dev] [v7, 4/6] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
                             ` (3 subsequent siblings)
  6 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-08 17:03 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula, anoobj, adwivedi,
	ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to nix.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry_nix.c | 849 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   3 +-
 drivers/common/cnxk/roc_nix.c            |   3 +
 drivers/common/cnxk/roc_nix_priv.h       |   9 +
 drivers/common/cnxk/roc_nix_queue.c      |  15 +-
 drivers/common/cnxk/roc_platform.h       |   3 +
 6 files changed, 878 insertions(+), 4 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c

diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c b/drivers/common/cnxk/cnxk_telemetry_nix.c
new file mode 100644
index 0000000000..ba54621fb6
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_nix.c
@@ -0,0 +1,849 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+struct nix_tel_node {
+	TAILQ_ENTRY(nix_tel_node) node;
+	struct roc_nix *nix;
+	uint16_t n_rq;
+	uint16_t n_cq;
+	uint16_t n_sq;
+	struct roc_nix_rq **rqs;
+	struct roc_nix_cq **cqs;
+	struct roc_nix_sq **sqs;
+};
+
+TAILQ_HEAD(nix_tel_node_list, nix_tel_node);
+static struct nix_tel_node_list nix_list;
+
+static struct nix_tel_node *
+nix_tel_node_get(struct roc_nix *roc_nix)
+{
+	struct nix_tel_node *node, *roc_node = NULL;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (node->nix == roc_nix) {
+			roc_node = node;
+			break;
+		}
+	}
+
+	return roc_node;
+}
+
+int
+nix_tel_node_add(struct roc_nix *roc_nix)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(roc_nix);
+	if (node) {
+		if (nix->nb_rx_queues == node->n_rq &&
+		    nix->nb_tx_queues == node->n_sq)
+			return 0;
+
+		nix_tel_node_del(roc_nix);
+	}
+
+	node = plt_zmalloc(sizeof(struct nix_tel_node), 0);
+	if (!node)
+		return -1;
+
+	node->nix = roc_nix;
+	node->rqs =
+		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_rq *), 0);
+	node->cqs =
+		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_cq *), 0);
+	node->sqs =
+		plt_zmalloc(nix->nb_tx_queues * sizeof(struct roc_nix_sq *), 0);
+	TAILQ_INSERT_TAIL(&nix_list, node, node);
+
+	return 0;
+}
+
+void
+nix_tel_node_del(struct roc_nix *roc_nix)
+{
+	struct nix_tel_node *node;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (node->nix == roc_nix) {
+			plt_free(node->rqs);
+			plt_free(node->cqs);
+			plt_free(node->rqs);
+			TAILQ_REMOVE(&nix_list, node, node);
+		}
+	}
+
+	plt_free(node);
+}
+
+static struct nix_tel_node *
+nix_tel_node_get_by_pcidev_name(const char *name)
+{
+	struct nix_tel_node *node, *roc_node = NULL;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (!strncmp(node->nix->pci_dev->name, name,
+			     PCI_PRI_STR_SIZE)) {
+			roc_node = node;
+			break;
+		}
+	}
+
+	return roc_node;
+}
+
+int
+nix_tel_node_add_rq(struct roc_nix_rq *rq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(rq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->rqs[rq->qid] = rq;
+	node->n_rq++;
+	return 0;
+}
+
+int
+nix_tel_node_add_cq(struct roc_nix_cq *cq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(cq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->cqs[cq->qid] = cq;
+	node->n_cq++;
+	return 0;
+}
+
+int
+nix_tel_node_add_sq(struct roc_nix_sq *sq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(sq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->sqs[sq->qid] = sq;
+	node->n_sq++;
+	return 0;
+}
+
+static int
+cnxk_tel_nix(struct roc_nix *roc_nix, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+
+	struct dev *dev = &nix->dev;
+
+	plt_tel_data_add_dict_ptr(d, "nix", nix);
+	plt_tel_data_add_dict_int(d, "pf_func", dev->pf_func);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(dev->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(dev->pf_func));
+
+	CNXK_TEL_DICT_PTR(d, dev, bar2);
+	CNXK_TEL_DICT_PTR(d, dev, bar4);
+	CNXK_TEL_DICT_INT(d, roc_nix, port_id);
+	CNXK_TEL_DICT_INT(d, roc_nix, rss_tag_as_xor);
+	CNXK_TEL_DICT_INT(d, roc_nix, max_sqb_count);
+	CNXK_TEL_DICT_PTR(d, nix, pci_dev);
+	CNXK_TEL_DICT_PTR(d, nix, base);
+	CNXK_TEL_DICT_PTR(d, nix, lmt_base);
+	CNXK_TEL_DICT_INT(d, nix, reta_sz);
+	CNXK_TEL_DICT_INT(d, nix, tx_chan_base);
+	CNXK_TEL_DICT_INT(d, nix, rx_chan_base);
+	CNXK_TEL_DICT_INT(d, nix, nb_tx_queues);
+	CNXK_TEL_DICT_INT(d, nix, nb_rx_queues);
+	CNXK_TEL_DICT_INT(d, nix, lso_tsov6_idx);
+	CNXK_TEL_DICT_INT(d, nix, lso_tsov4_idx);
+
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v4",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v6",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v4",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v6",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v4v4",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v4v6",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v6v4",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v6v6",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+
+	CNXK_TEL_DICT_INT(d, nix, lf_tx_stats);
+	CNXK_TEL_DICT_INT(d, nix, lf_rx_stats);
+	CNXK_TEL_DICT_INT(d, nix, cgx_links);
+	CNXK_TEL_DICT_INT(d, nix, lbk_links);
+	CNXK_TEL_DICT_INT(d, nix, sdp_links);
+	CNXK_TEL_DICT_INT(d, nix, tx_link);
+	CNXK_TEL_DICT_INT(d, nix, sqb_size);
+	CNXK_TEL_DICT_INT(d, nix, msixoff);
+	CNXK_TEL_DICT_INT(d, nix, cints);
+	CNXK_TEL_DICT_INT(d, nix, qints);
+	CNXK_TEL_DICT_INT(d, nix, sdp_link);
+	CNXK_TEL_DICT_INT(d, nix, ptp_en);
+	CNXK_TEL_DICT_INT(d, nix, rss_alg_idx);
+	CNXK_TEL_DICT_INT(d, nix, tx_pause);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_rq(struct roc_nix_rq *rq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_rq", rq);
+	CNXK_TEL_DICT_INT(d, rq, qid);
+	CNXK_TEL_DICT_PTR(d, rq, aura_handle);
+	CNXK_TEL_DICT_INT(d, rq, ipsech_ena);
+	CNXK_TEL_DICT_INT(d, rq, first_skip);
+	CNXK_TEL_DICT_INT(d, rq, later_skip);
+	CNXK_TEL_DICT_INT(d, rq, lpb_size);
+	CNXK_TEL_DICT_INT(d, rq, sso_ena);
+	CNXK_TEL_DICT_INT(d, rq, tag_mask);
+	CNXK_TEL_DICT_INT(d, rq, flow_tag_width);
+	CNXK_TEL_DICT_INT(d, rq, tt);
+	CNXK_TEL_DICT_INT(d, rq, hwgrp);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_ena);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_first_skip);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_max_sz_exp);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_wait_tmo);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_aura_handle);
+	CNXK_TEL_DICT_PTR(d, rq, roc_nix);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_cq(struct roc_nix_cq *cq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_cq", cq);
+	CNXK_TEL_DICT_INT(d, cq, qid);
+	CNXK_TEL_DICT_INT(d, cq, nb_desc);
+	CNXK_TEL_DICT_PTR(d, cq, roc_nix);
+	CNXK_TEL_DICT_PTR(d, cq, door);
+	CNXK_TEL_DICT_PTR(d, cq, status);
+	CNXK_TEL_DICT_PTR(d, cq, wdata);
+	CNXK_TEL_DICT_PTR(d, cq, desc_base);
+	CNXK_TEL_DICT_INT(d, cq, qmask);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_sq(struct roc_nix_sq *sq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_sq", sq);
+	CNXK_TEL_DICT_INT(d, sq, qid);
+	CNXK_TEL_DICT_INT(d, sq, max_sqe_sz);
+	CNXK_TEL_DICT_INT(d, sq, nb_desc);
+	CNXK_TEL_DICT_INT(d, sq, sqes_per_sqb_log2);
+	CNXK_TEL_DICT_PTR(d, sq, roc_nix);
+	CNXK_TEL_DICT_PTR(d, sq, aura_handle);
+	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs_adj);
+	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs);
+	CNXK_TEL_DICT_PTR(d, sq, io_addr);
+	CNXK_TEL_DICT_PTR(d, sq, lmt_addr);
+	CNXK_TEL_DICT_PTR(d, sq, sqe_mem);
+	CNXK_TEL_DICT_PTR(d, sq, fc);
+
+	return 0;
+}
+
+static void
+nix_rq_ctx_cn9k(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_rq_ctx_s *ctx = (struct nix_rq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
+	CNXK_TEL_DICT_BF_PTR(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_);
+}
+
+static void
+nix_rq_ctx(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_cn10k_rq_ctx_s *ctx = (struct nix_cn10k_rq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_ol3_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_ol4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_il3_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_il4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, csum_ol4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, lenerr_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0);
+	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, chi_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsecd_drop_en, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_stashing, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, policer_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, band_prof_id, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_INT(d, ctx, vwqe_skip, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, max_vsize_exp, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, vtime_wait, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, vwqe_ena, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsec_vwqe, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_);
+}
+
+static int
+cnxk_tel_nix_rq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile void *qctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_RQ, n, &qctx);
+	if (rc) {
+		plt_err("Failed to get rq context");
+		return rc;
+	}
+
+	if (roc_model_is_cn9k())
+		nix_rq_ctx_cn9k(&qctx, d);
+	else
+		nix_rq_ctx(&qctx, d);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_cq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile struct nix_cq_ctx_s *ctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_CQ, n, (void *)&ctx);
+	if (rc) {
+		plt_err("Failed to get cq context");
+		return rc;
+	}
+
+	/* W0 */
+	CNXK_TEL_DICT_PTR(d, ctx, base, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_U64(d, ctx, wrptr, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cint_idx, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_err, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, bpid, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, bp_ena, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, update_time, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, avg_level, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, head, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, tail, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, cq_err_int_ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_err_int, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, qsize, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, caching, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, drop_ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, bp, w3_);
+
+	return 0;
+}
+
+static void
+nix_sq_ctx_cn9k(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_sq_ctx_s *ctx = (struct nix_sq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_quantum, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
+
+	/* W11 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
+
+	/* W12 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
+
+	/* W14 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
+
+	/* W15 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_);
+}
+
+static void
+nix_sq_ctx(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_cn10k_sq_ctx_s *ctx = (struct nix_cn10k_sq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_weight, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_ub, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_lb, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
+
+	/* W11 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
+
+	/* W12 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
+
+	/* W14 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
+
+	/* W15 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_);
+}
+
+static int
+cnxk_tel_nix_sq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile void *qctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_SQ, n, &qctx);
+	if (rc) {
+		plt_err("Failed to get rq context");
+		return rc;
+	}
+
+	if (roc_model_is_cn9k())
+		nix_sq_ctx_cn9k(&qctx, d);
+	else
+		nix_sq_ctx(&qctx, d);
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_list(const char *cmd __plt_unused,
+			 const char *params __plt_unused,
+			 struct plt_tel_data *d)
+{
+	struct nix_tel_node *node;
+	struct roc_nix *roc_nix;
+
+	plt_tel_data_start_array(d, PLT_TEL_STRING_VAL);
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		roc_nix = node->nix;
+		plt_tel_data_add_array_string(d, roc_nix->pci_dev->name);
+	}
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_info(const char *cmd __plt_unused, const char *params,
+			 struct plt_tel_data *d)
+{
+	char name[PCI_PRI_STR_SIZE];
+	struct nix_tel_node *node;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	plt_strlcpy(name, params, PCI_PRI_STR_SIZE);
+
+	node = nix_tel_node_get_by_pcidev_name(name);
+	if (!node)
+		return -1;
+
+	plt_tel_data_start_dict(d);
+	return cnxk_tel_nix(node->nix, d);
+}
+
+static int
+cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
+			   struct plt_tel_data *d)
+{
+	struct nix_tel_node *node;
+	char *name, *param;
+	char buf[1024];
+	int rc = -1;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		goto exit;
+
+	plt_strlcpy(buf, params, PCI_PRI_STR_SIZE + 1);
+	name = strtok(buf, ",");
+	param = strtok(NULL, "\0");
+
+	node = nix_tel_node_get_by_pcidev_name(name);
+	if (!node)
+		goto exit;
+
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "rq")) {
+		char *tok = strtok(param, ",");
+		int rq;
+
+		if (!tok)
+			goto exit;
+
+		rq = strtol(tok, NULL, 10);
+		if ((node->n_rq <= rq) || (rq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_rq_ctx(node->nix, rq, d);
+		else
+			rc = cnxk_tel_nix_rq(node->rqs[rq], d);
+
+	} else if (strstr(cmd, "cq")) {
+		char *tok = strtok(param, ",");
+		int cq;
+
+		if (!tok)
+			goto exit;
+
+		cq = strtol(tok, NULL, 10);
+		if ((node->n_cq <= cq) || (cq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_cq_ctx(node->nix, cq, d);
+		else
+			rc = cnxk_tel_nix_cq(node->cqs[cq], d);
+
+	} else if (strstr(cmd, "sq")) {
+		char *tok = strtok(param, ",");
+		int sq;
+
+		if (!tok)
+			goto exit;
+
+		sq = strtol(tok, NULL, 10);
+		if ((node->n_sq <= sq) || (sq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_sq_ctx(node->nix, sq, d);
+		else
+			rc = cnxk_tel_nix_sq(node->sqs[sq], d);
+	}
+
+exit:
+	return rc;
+}
+
+PLT_INIT(cnxk_telemetry_nix_init)
+{
+	TAILQ_INIT(&nix_list);
+
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/list", cnxk_nix_tel_handle_list,
+		"Returns list of available NIX devices. Takes no parameters");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/info", cnxk_nix_tel_handle_info,
+		"Returns nix information. Parameters: pci id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/rq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix rq information. Parameters: pci id, rq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/rq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix rq context. Parameters: pci id, rq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/cq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix cq information. Parameters: pci id, cq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/cq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix cq context. Parameters: pci id, cq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/sq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix sq information. Parameters: pci id, sq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/sq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix sq context. Parameters: pci id, sq id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index f0a1c9f115..fe7a95b526 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -65,6 +65,7 @@ sources = files(
 sources += files('cnxk_security.c')
 
 # Telemetry common code
-sources += files('cnxk_telemetry_npa.c')
+sources += files('cnxk_telemetry_npa.c',
+                 'cnxk_telemetry_nix.c')
 
 deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_nix.c b/drivers/common/cnxk/roc_nix.c
index 3ab954e94d..17beb1a736 100644
--- a/drivers/common/cnxk/roc_nix.c
+++ b/drivers/common/cnxk/roc_nix.c
@@ -178,6 +178,8 @@ roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq, uint32_t nb_txq,
 	nix->sqs = plt_zmalloc(sizeof(struct roc_nix_sq *) * nb_txq, 0);
 	if (!nix->sqs)
 		return -ENOMEM;
+
+	nix_tel_node_add(roc_nix);
 fail:
 	return rc;
 }
@@ -413,6 +415,7 @@ roc_nix_dev_init(struct roc_nix *roc_nix)
 dev_fini:
 	rc |= dev_fini(dev, pci_dev);
 fail:
+	nix_tel_node_del(roc_nix);
 	return rc;
 }
 
diff --git a/drivers/common/cnxk/roc_nix_priv.h b/drivers/common/cnxk/roc_nix_priv.h
index 2cd5a72347..ba639791ce 100644
--- a/drivers/common/cnxk/roc_nix_priv.h
+++ b/drivers/common/cnxk/roc_nix_priv.h
@@ -424,4 +424,13 @@ int nix_lf_int_reg_dump(uintptr_t nix_lf_base, uint64_t *data, uint16_t qints,
 int nix_q_ctx_get(struct dev *dev, uint8_t ctype, uint16_t qid,
 		  __io void **ctx_p);
 
+/*
+ * Telemetry
+ */
+int nix_tel_node_add(struct roc_nix *roc_nix);
+void nix_tel_node_del(struct roc_nix *roc_nix);
+int nix_tel_node_add_rq(struct roc_nix_rq *rq);
+int nix_tel_node_add_cq(struct roc_nix_cq *cq);
+int nix_tel_node_add_sq(struct roc_nix_sq *sq);
+
 #endif /* _ROC_NIX_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_nix_queue.c b/drivers/common/cnxk/roc_nix_queue.c
index 8fbb13ecbd..f546fc83c5 100644
--- a/drivers/common/cnxk/roc_nix_queue.c
+++ b/drivers/common/cnxk/roc_nix_queue.c
@@ -387,7 +387,11 @@ roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
 	if (rc)
 		return rc;
 
-	return mbox_process(mbox);
+	rc = mbox_process(mbox);
+	if (rc)
+		return rc;
+
+	return nix_tel_node_add_rq(rq);
 }
 
 int
@@ -415,7 +419,11 @@ roc_nix_rq_modify(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
 	if (rc)
 		return rc;
 
-	return mbox_process(mbox);
+	rc = mbox_process(mbox);
+	if (rc)
+		return rc;
+
+	return nix_tel_node_add_rq(rq);
 }
 
 int
@@ -504,7 +512,7 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq)
 	if (rc)
 		goto free_mem;
 
-	return 0;
+	return nix_tel_node_add_cq(cq);
 
 free_mem:
 	plt_free(cq->desc_base);
@@ -884,6 +892,7 @@ roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq)
 					((qid & RVU_CN9K_LMT_SLOT_MASK) << 12));
 	}
 
+	rc = nix_tel_node_add_sq(sq);
 	return rc;
 nomem:
 	plt_free(sq->fc);
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 57073d62aa..b95af115f7 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -145,7 +145,10 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define PLT_TEL_STRING_VAL RTE_TEL_STRING_VAL
 #define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_array     rte_tel_data_start_array
+#define plt_tel_data_add_array_string rte_tel_data_add_array_string
 #define plt_tel_data_start_dict      rte_tel_data_start_dict
 #define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
 #define plt_tel_data_add_dict_ptr(d, n, v)			\
-- 
2.25.1


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

* [dpdk-dev] [v7, 4/6] net/cnxk: add telemetry endpoing to ethdev
  2021-09-08 17:03         ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
                             ` (2 preceding siblings ...)
  2021-09-08 17:03           ` [dpdk-dev] [v7, 3/6] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
@ 2021-09-08 17:03           ` Gowrishankar Muthukrishnan
  2021-09-08 17:03           ` [dpdk-dev] [v7, 5/6] telemetry: fix json output buffer size Gowrishankar Muthukrishnan
                             ` (2 subsequent siblings)
  6 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-08 17:03 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula, anoobj, adwivedi,
	ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoint to ethdev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/net/cnxk/cnxk_ethdev_telemetry.c | 129 +++++++++++++++++++++++
 drivers/net/cnxk/meson.build             |   1 +
 2 files changed, 130 insertions(+)
 create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c

diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
new file mode 100644
index 0000000000..de8c468670
--- /dev/null
+++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
@@ -0,0 +1,129 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell International Ltd.
+ */
+
+#include <rte_telemetry.h>
+
+#include "cnxk_ethdev.h"
+
+/* Macro to count no of words in eth_info_s size */
+#define ETH_INFO_SZ                                                            \
+	(RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) /         \
+	 sizeof(uint64_t))
+#define MACADDR_LEN 18
+
+static int
+ethdev_tel_handle_info(const char *cmd __rte_unused,
+		       const char *params __rte_unused, struct rte_tel_data *d)
+{
+	struct rte_eth_dev *eth_dev;
+	struct rte_tel_data *i_data;
+	struct cnxk_eth_dev *dev;
+	union eth_info_u {
+		struct eth_info_s {
+			/** PF/VF information */
+			uint16_t pf_func;
+			/** No of rx queues */
+			uint16_t rx_queues;
+			/** No of tx queues */
+			uint16_t tx_queues;
+			/** Port ID */
+			uint16_t port_id;
+			/** MAC entries */
+			char mac_addr[MACADDR_LEN];
+			uint8_t max_mac_entries;
+			bool dmac_filter_ena;
+			uint8_t dmac_filter_count;
+			uint16_t flags;
+			uint8_t ptype_disable;
+			bool scalar_ena;
+			bool ptp_ena;
+			/* Offload capabilities */
+			uint64_t rx_offload_capa;
+			uint64_t tx_offload_capa;
+			uint32_t speed_capa;
+			/* Configured offloads */
+			uint64_t rx_offloads;
+			uint64_t tx_offloads;
+			/* Platform specific offload flags */
+			uint16_t rx_offload_flags;
+			uint16_t tx_offload_flags;
+			/* ETHDEV RSS HF bitmask */
+			uint64_t ethdev_rss_hf;
+		} info;
+		uint64_t val[ETH_INFO_SZ];
+	} eth_info;
+	struct eth_info_s *info;
+	unsigned int i, j = 0;
+	int n_ports;
+
+	n_ports = rte_eth_dev_count_avail();
+	if (!n_ports) {
+		plt_err("No active ethernet ports found.");
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_int(d, "n_ports", n_ports);
+
+	i_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+		/* Skip if port is unused */
+		if (!rte_eth_dev_is_valid_port(i))
+			continue;
+
+		eth_dev = &rte_eth_devices[i];
+		if (eth_dev) {
+			memset(&eth_info, 0, sizeof(eth_info));
+			info = &eth_info.info;
+			dev = cnxk_eth_pmd_priv(eth_dev);
+			if (dev) {
+				info->pf_func = roc_nix_get_pf_func(&dev->nix);
+				memset(info->mac_addr, 0, MACADDR_LEN);
+				snprintf(info->mac_addr, MACADDR_LEN,
+					 "%02x:%02x:%02x:%02x:%02x:%02x",
+					 dev->mac_addr[0], dev->mac_addr[1],
+					 dev->mac_addr[2], dev->mac_addr[3],
+					 dev->mac_addr[4], dev->mac_addr[5]);
+				info->max_mac_entries = dev->max_mac_entries;
+				info->dmac_filter_ena = dev->dmac_filter_enable;
+				info->dmac_filter_count =
+					dev->dmac_filter_count;
+				info->flags = dev->flags;
+				info->ptype_disable = dev->ptype_disable;
+				info->scalar_ena = dev->scalar_ena;
+				info->ptp_ena = dev->ptp_en;
+				info->rx_offload_capa = dev->rx_offload_capa;
+				info->tx_offload_capa = dev->tx_offload_capa;
+				info->rx_offloads = dev->rx_offloads;
+				info->tx_offloads = dev->tx_offloads;
+				info->rx_offload_flags = dev->rx_offload_flags;
+				info->tx_offload_flags = dev->tx_offload_flags;
+				info->ethdev_rss_hf = dev->ethdev_rss_hf;
+			}
+
+			if (eth_dev->data) {
+				info->rx_queues = eth_dev->data->nb_rx_queues;
+				info->tx_queues = eth_dev->data->nb_tx_queues;
+				info->port_id = eth_dev->data->port_id;
+			}
+
+			for (j = 0; j < ETH_INFO_SZ; j++)
+				rte_tel_data_add_array_u64(i_data,
+							   eth_info.val[j]);
+
+			j++;
+		}
+	}
+
+	rte_tel_data_add_dict_container(d, "info", i_data, 0);
+	return 0;
+}
+
+RTE_INIT(cnxk_ethdev_init_telemetry)
+{
+	rte_telemetry_register_cmd("/cnxk/ethdev/info", ethdev_tel_handle_info,
+				   "Returns ethdev device information");
+}
diff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build
index d1d4b4e15e..5b3b8422fb 100644
--- a/drivers/net/cnxk/meson.build
+++ b/drivers/net/cnxk/meson.build
@@ -13,6 +13,7 @@ sources = files(
         'cnxk_ethdev_devargs.c',
         'cnxk_ethdev_ops.c',
         'cnxk_ethdev_sec.c',
+        'cnxk_ethdev_telemetry.c',
         'cnxk_link.c',
         'cnxk_lookup.c',
         'cnxk_ptp.c',
-- 
2.25.1


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

* [dpdk-dev] [v7, 5/6] telemetry: fix json output buffer size
  2021-09-08 17:03         ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
                             ` (3 preceding siblings ...)
  2021-09-08 17:03           ` [dpdk-dev] [v7, 4/6] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
@ 2021-09-08 17:03           ` Gowrishankar Muthukrishnan
  2021-09-21 11:02             ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
  2021-09-08 17:03           ` [dpdk-dev] [v7, 6/6] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
  2021-09-16  8:52           ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Jerin Jacob
  6 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-08 17:03 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula, anoobj, adwivedi,
	ktejasree, Gowrishankar Muthukrishnan

Fix json output buffer size for a single largest value.

Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Change-Id: Ida314114b654b5085244a659eb08b22969339856
---
 lib/telemetry/telemetry_json.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index ad270b9b30..ba2fde34cb 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -9,6 +9,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <rte_common.h>
+#include <rte_telemetry.h>
 
 /**
  * @file
@@ -23,13 +24,15 @@
  * @internal
  * Copies a value into a buffer if the buffer has enough available space.
  * Nothing written to buffer if an overflow ocurs.
- * This function is not for use for values larger than 1k.
+ * Size of buffer is (single largest value - 6), where at least 6 chars
+ * would have been used for creating json dict i.e '{"x": ... }'.
+ * This function is not for use for values larger than this buffer size.
  */
 __rte_format_printf(3, 4)
 static inline int
 __json_snprintf(char *buf, const int len, const char *format, ...)
 {
-	char tmp[1024];
+	char tmp[RTE_TEL_MAX_SINGLE_STRING_LEN - 6];
 	va_list ap;
 	int ret;
 
-- 
2.25.1


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

* [dpdk-dev] [v7, 6/6] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-09-08 17:03         ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
                             ` (4 preceding siblings ...)
  2021-09-08 17:03           ` [dpdk-dev] [v7, 5/6] telemetry: fix json output buffer size Gowrishankar Muthukrishnan
@ 2021-09-08 17:03           ` Gowrishankar Muthukrishnan
  2021-09-21 11:32             ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
  2021-09-16  8:52           ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Jerin Jacob
  6 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-08 17:03 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula, anoobj, adwivedi,
	ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to cryptodev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Change-Id: I7a0387fe11f383fca95169cfe2ec97bca46221ac
---
 .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 154 ++++++++++++++++++
 drivers/crypto/cnxk/meson.build               |   1 +
 2 files changed, 155 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
new file mode 100644
index 0000000000..4c754bc6c7
--- /dev/null
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
@@ -0,0 +1,154 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
+#include <rte_telemetry.h>
+
+#include <roc_api.h>
+
+#include "cnxk_cryptodev.h"
+#include "cnxk_telemetry.h"
+
+#define CRYPTO_CAPS_SZ                                                         \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities),             \
+			sizeof(uint64_t)) /                                    \
+	 sizeof(uint64_t))
+
+#define SEC_CAPS_SZ                                                            \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability),                \
+			sizeof(uint64_t)) /                                    \
+	 sizeof(uint64_t))
+
+static int
+cryptodev_tel_handle_list(const char *cmd __rte_unused,
+			  const char *params __rte_unused,
+			  struct rte_tel_data *d)
+{
+	struct rte_cryptodev *cryptodev;
+	unsigned int i;
+
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+
+	for (i = 0; i < RTE_CRYPTO_MAX_DEVS; i++) {
+		cryptodev = rte_cryptodev_pmd_get_dev(i);
+		if (cryptodev->attached != RTE_CRYPTODEV_ATTACHED)
+			continue;
+
+		rte_tel_data_add_array_string(d, cryptodev->data->name);
+	}
+
+	return 0;
+}
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  struct rte_cryptodev_capabilities *dev_caps,
+		  size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_cryptodev_capabilities dev_caps;
+		uint64_t val[CRYPTO_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		if (dev_caps[i].op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
+			break;
+
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+sec_caps_array(struct rte_tel_data *d, struct rte_security_capability *dev_caps,
+	       size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_security_capability dev_caps;
+		uint64_t val[SEC_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+cryptodev_tel_handle_info(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_tel_data *crypto_caps, *sec_crypto_caps, *sec_caps;
+	int crypto_caps_n, sec_crypto_caps_n, sec_caps_n;
+	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	rte_strlcpy(name, params, RTE_CRYPTODEV_NAME_LEN);
+	dev = rte_cryptodev_pmd_get_named_dev(name);
+	if (!dev) {
+		plt_err("No cryptodev of name %s available", name);
+		return -1;
+	}
+
+	vf = dev->data->dev_private;
+
+	rte_tel_data_start_dict(d);
+	CNXK_TEL_DICT_INT(d, dev->data, dev_id);
+	CNXK_TEL_DICT_INT(d, dev->data, socket_id);
+	CNXK_TEL_DICT_INT(d, dev->data, dev_started);
+
+	/* Crypto capabilities */
+	crypto_caps = rte_tel_data_alloc();
+	crypto_caps_n = crypto_caps_array(crypto_caps, vf->crypto_caps,
+					  CNXK_CPT_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
+
+	/* Security Crypto capabilities */
+	sec_crypto_caps = rte_tel_data_alloc();
+	sec_crypto_caps_n = crypto_caps_array(
+		sec_crypto_caps, vf->sec_crypto_caps, CNXK_SEC_CRYPTO_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_crypto_caps", sec_crypto_caps,
+					0);
+	rte_tel_data_add_dict_int(d, "sec_crypto_caps_n", sec_crypto_caps_n);
+
+	/* Security capabilities */
+	sec_caps = rte_tel_data_alloc();
+	sec_caps_n = sec_caps_array(sec_caps, vf->sec_caps, CNXK_SEC_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(cnxk_cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/cryptodev/list", cryptodev_tel_handle_list,
+		"Returns list of available cryptodev. Takes no parameters");
+	rte_telemetry_register_cmd(
+		"/cnxk/cryptodev/info", cryptodev_tel_handle_info,
+		"Returns cryptodev info. Parameters: pci id");
+}
diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build
index e076783629..14771925c1 100644
--- a/drivers/crypto/cnxk/meson.build
+++ b/drivers/crypto/cnxk/meson.build
@@ -18,6 +18,7 @@ sources = files(
         'cnxk_cryptodev_capabilities.c',
         'cnxk_cryptodev_ops.c',
         'cnxk_cryptodev_sec.c',
+        'cnxk_cryptodev_telemetry.c',
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev']
-- 
2.25.1


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

* Re: [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints
  2021-09-08 17:03         ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
                             ` (5 preceding siblings ...)
  2021-09-08 17:03           ` [dpdk-dev] [v7, 6/6] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
@ 2021-09-16  8:52           ` Jerin Jacob
  6 siblings, 0 replies; 121+ messages in thread
From: Jerin Jacob @ 2021-09-16  8:52 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan
  Cc: dpdk-dev, Richardson, Bruce, Ciara Power, Jerin Jacob,
	Kiran Kumar K, Nithin Dabilpuram, Sunil Kumar Kori,
	Satha Koteswara Rao Kottidi,
	Ashwin Sekhar Thalakalath Kottilveetil, Pavan Nikhilesh,
	Anoob Joseph, Ankur Dwivedi, Tejasree Kondoj, Thomas Monjalon,
	Akhil Goyal

On Wed, Sep 8, 2021 at 10:33 PM Gowrishankar Muthukrishnan
<gmuthukrishn@marvell.com> wrote:
>
> This patch series enables telemetry for cnxk in the following:
>  - NPA LF
>  - Mempool driver
>  - NIX LF
>  - Ethdev driver
>  - Crypto driver
>
> Depends-on: series-18612 ("net/cnxk: support for inline ipsec")

Please split the patches into three series,

1/6 - 4/6 - for next-net-mrvl and delegate to me
5/6 - for main tree and delegate to Thomas
6/6 - for crypto tree and delegate to Akill
and add appropriate Depends-on:


> v7:
>  - Added cryptodev endppoints.
>  - minor cleanup in other patches.
>
> Gowrishankar Muthukrishnan (6):
>   common/cnxk: add telemetry endpoints to npa
>   mempool/cnxk: add telemetry end points
>   common/cnxk: add telemetry endpoints to nix
>   net/cnxk: add telemetry endpoing to ethdev
>   telemetry: fix json output buffer size
>   crypto/cnxk: add telemetry endpoints to cryptodev
>
>  drivers/common/cnxk/cnxk_telemetry.h          |  26 +
>  drivers/common/cnxk/cnxk_telemetry_nix.c      | 849 ++++++++++++++++++
>  drivers/common/cnxk/cnxk_telemetry_npa.c      | 224 +++++
>  drivers/common/cnxk/meson.build               |   7 +-
>  drivers/common/cnxk/roc_nix.c                 |   3 +
>  drivers/common/cnxk/roc_nix_priv.h            |   9 +
>  drivers/common/cnxk/roc_nix_queue.c           |  15 +-
>  drivers/common/cnxk/roc_platform.h            |  15 +
>  .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 154 ++++
>  drivers/crypto/cnxk/meson.build               |   1 +
>  drivers/mempool/cnxk/cnxk_mempool_telemetry.c | 100 +++
>  drivers/mempool/cnxk/meson.build              |   1 +
>  drivers/net/cnxk/cnxk_ethdev_telemetry.c      | 129 +++
>  drivers/net/cnxk/meson.build                  |   1 +
>  lib/telemetry/telemetry_json.h                |   7 +-
>  15 files changed, 1534 insertions(+), 7 deletions(-)
>  create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
>  create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c
>  create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
>  create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
>  create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c
>  create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
>
> --
> 2.25.1
>

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

* [dpdk-dev] [v8, 0/4] cnxk: enable telemetry endpoints for mempool and ethdev
  2021-08-27  6:41       ` [dpdk-dev] [v5, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
                           ` (3 preceding siblings ...)
  2021-09-08 17:03         ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
@ 2021-09-21 10:52         ` Gowrishankar Muthukrishnan
  2021-09-21 10:52           ` [dpdk-dev] [v8, 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
                             ` (4 more replies)
  4 siblings, 5 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-21 10:52 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula,
	Gowrishankar Muthukrishnan

This patch series enables telemetry for cnxk in the following:
 - NPA LF
 - Mempool driver
 - NIX LF
 - Ethdev driver

Depends-on: series-18612 ("net/cnxk: support for inline ipsec")

v8:
 - removed lib telemetry and crypto patches for seperate series.

Gowrishankar Muthukrishnan (4):
  common/cnxk: add telemetry endpoints to npa
  mempool/cnxk: add telemetry end points
  common/cnxk: add telemetry endpoints to nix
  net/cnxk: add telemetry endpoing to ethdev

 drivers/common/cnxk/cnxk_telemetry.h          |  26 +
 drivers/common/cnxk/cnxk_telemetry_nix.c      | 849 ++++++++++++++++++
 drivers/common/cnxk/cnxk_telemetry_npa.c      | 224 +++++
 drivers/common/cnxk/meson.build               |   7 +-
 drivers/common/cnxk/roc_nix.c                 |   3 +
 drivers/common/cnxk/roc_nix_priv.h            |   9 +
 drivers/common/cnxk/roc_nix_queue.c           |  15 +-
 drivers/common/cnxk/roc_platform.h            |  15 +
 drivers/mempool/cnxk/cnxk_mempool_telemetry.c | 100 +++
 drivers/mempool/cnxk/meson.build              |   1 +
 drivers/net/cnxk/cnxk_ethdev_telemetry.c      | 129 +++
 drivers/net/cnxk/meson.build                  |   1 +
 12 files changed, 1374 insertions(+), 5 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
 create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c
 create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c

-- 
2.25.1


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

* [dpdk-dev] [v8, 1/4] common/cnxk: add telemetry endpoints to npa
  2021-09-21 10:52         ` [dpdk-dev] [v8, 0/4] cnxk: enable telemetry endpoints for mempool and ethdev Gowrishankar Muthukrishnan
@ 2021-09-21 10:52           ` Gowrishankar Muthukrishnan
  2021-09-21 10:52           ` [dpdk-dev] [v8, 2/4] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
                             ` (3 subsequent siblings)
  4 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-21 10:52 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula,
	Gowrishankar Muthukrishnan

Add telemetry endpoints to npa.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 224 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   6 +-
 drivers/common/cnxk/roc_platform.h       |  12 ++
 4 files changed, 266 insertions(+), 2 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

diff --git a/drivers/common/cnxk/cnxk_telemetry.h b/drivers/common/cnxk/cnxk_telemetry.h
new file mode 100644
index 0000000000..1461fd893f
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Marvell.
+ */
+
+#ifndef __CNXK_TELEMETRY_H_
+#define __CNXK_TELEMETRY_H_
+
+#define CNXK_TEL_STR(s)		  #s
+#define CNXK_TEL_STR_PREFIX(s, p) CNXK_TEL_STR(p##s)
+#define CNXK_TEL_DICT_INT(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_int(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_PTR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(p)->s)
+#define CNXK_TEL_DICT_BF_PTR(d, p, s, ...)                                     \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(uint64_t)(p)->s)
+#define CNXK_TEL_DICT_U64(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_u64(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_STR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_string(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),   \
+				     (p)->s)
+
+#endif /* __CNXK_TELEMETRY_H_ */
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
new file mode 100644
index 0000000000..37c5f2e961
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -0,0 +1,224 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+static int
+cnxk_tel_npa(struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int aura_cnt = 0;
+	uint32_t i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	for (i = 0; i < lf->nr_pools; i++) {
+		if (plt_bitmap_get(lf->npa_bmp, i))
+			continue;
+		aura_cnt++;
+	}
+
+	plt_tel_data_add_dict_ptr(d, "npa", lf);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
+
+	CNXK_TEL_DICT_PTR(d, lf, pci_dev);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
+	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
+	CNXK_TEL_DICT_PTR(d, lf, intr_handle);
+	CNXK_TEL_DICT_PTR(d, lf, mbox);
+	CNXK_TEL_DICT_PTR(d, lf, base);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
+	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
+	CNXK_TEL_DICT_INT(d, lf, nr_pools);
+	CNXK_TEL_DICT_INT(d, lf, pf_func);
+	CNXK_TEL_DICT_INT(d, lf, aura_sz);
+	CNXK_TEL_DICT_INT(d, lf, qints);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
+{
+	__io struct npa_aura_s *aura;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (plt_bitmap_get(lf->npa_bmp, aura_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_AURA;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", aura_id);
+		return rc;
+	}
+
+	aura = &rsp->aura;
+	CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
+	CNXK_TEL_DICT_INT(d, aura, ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
+	CNXK_TEL_DICT_U64(d, aura, count, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
+	CNXK_TEL_DICT_U64(d, aura, limit, w3_);
+	CNXK_TEL_DICT_INT(d, aura, bp, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
+	CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
+	CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
+{
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (plt_bitmap_get(lf->npa_bmp, pool_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = pool_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", pool_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
+	CNXK_TEL_DICT_INT(d, pool, ena, w1_);
+	CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
+	CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
+	CNXK_TEL_DICT_INT(d, pool, shift, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
+	CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
+	CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
+	CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info(const char *cmd __plt_unused,
+			 const char *params __plt_unused,
+			 struct plt_tel_data *d)
+{
+	plt_tel_data_start_dict(d);
+	return cnxk_tel_npa(d);
+}
+
+static int
+cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
+			   struct plt_tel_data *d)
+{
+	int id, rc;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	id = atoi(params);
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "aura/info"))
+		rc = cnxk_tel_npa_aura(id, d);
+	else
+		rc = cnxk_tel_npa_pool(id, d);
+
+	return rc;
+}
+
+PLT_INIT(cnxk_telemetry_npa_init)
+{
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
+		"Returns npa information. Takes no parameters");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa aura information. Parameters: aura_id");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa pool information. Parameters: pool_id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index cd19ad29c1..f0a1c9f115 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -64,5 +64,7 @@ sources = files(
 # Security common code
 sources += files('cnxk_security.c')
 
-includes += include_directories('../../bus/pci')
-includes += include_directories('../../../lib/net')
+# Telemetry common code
+sources += files('cnxk_telemetry_npa.c')
+
+deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 241655b334..57073d62aa 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -19,6 +19,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "roc_bits.h"
 
@@ -51,6 +52,7 @@
 #define PLT_CACHE_LINE_SIZE      RTE_CACHE_LINE_SIZE
 #define BITMASK_ULL		 GENMASK_ULL
 #define PLT_ALIGN_CEIL		 RTE_ALIGN_CEIL
+#define PLT_INIT		 RTE_INIT
 
 /** Divide ceil */
 #define PLT_DIV_CEIL(x, y)			\
@@ -63,6 +65,7 @@
 #define __plt_cache_aligned __rte_cache_aligned
 #define __plt_always_inline __rte_always_inline
 #define __plt_packed	    __rte_packed
+#define __plt_unused	    __rte_unused
 #define __roc_api	    __rte_internal
 #define plt_iova_t	    rte_iova_t
 
@@ -142,6 +145,15 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_dict      rte_tel_data_start_dict
+#define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
+#define plt_tel_data_add_dict_ptr(d, n, v)			\
+	rte_tel_data_add_dict_u64(d, n, (uint64_t)v)
+#define plt_tel_data_add_dict_string rte_tel_data_add_dict_string
+#define plt_tel_data_add_dict_u64    rte_tel_data_add_dict_u64
+#define plt_telemetry_register_cmd   rte_telemetry_register_cmd
+
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
-- 
2.25.1


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

* [dpdk-dev] [v8, 2/4] mempool/cnxk: add telemetry end points
  2021-09-21 10:52         ` [dpdk-dev] [v8, 0/4] cnxk: enable telemetry endpoints for mempool and ethdev Gowrishankar Muthukrishnan
  2021-09-21 10:52           ` [dpdk-dev] [v8, 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-09-21 10:52           ` Gowrishankar Muthukrishnan
  2021-09-29  6:40             ` [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info Gowrishankar Muthukrishnan
  2021-09-21 10:52           ` [dpdk-dev] [v8, 3/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
                             ` (2 subsequent siblings)
  4 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-21 10:52 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula,
	Gowrishankar Muthukrishnan

Adding telemetry end points to cnxk mempool driver.

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

diff --git a/drivers/mempool/cnxk/cnxk_mempool_telemetry.c b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
new file mode 100644
index 0000000000..690f557f62
--- /dev/null
+++ b/drivers/mempool/cnxk/cnxk_mempool_telemetry.c
@@ -0,0 +1,100 @@
+/* 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"
+
+static void
+mempool_list_cb(struct rte_mempool *mp, void *arg)
+{
+	struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+	rte_tel_data_add_array_string(d, mp->name);
+}
+
+static int
+mempool_tel_handle_list(const char *cmd __rte_unused,
+			const char *params __rte_unused, struct rte_tel_data *d)
+{
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+	rte_mempool_walk(mempool_list_cb, d);
+	return 0;
+}
+
+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;
+	const struct rte_memzone *mz;
+	int aura_id;
+
+	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+		return;
+
+	CNXK_TEL_DICT_STR(info->d, mp, name);
+	CNXK_TEL_DICT_INT(info->d, mp, pool_id);
+	CNXK_TEL_DICT_INT(info->d, mp, flags);
+	CNXK_TEL_DICT_INT(info->d, mp, socket_id);
+	CNXK_TEL_DICT_INT(info->d, mp, size);
+	CNXK_TEL_DICT_INT(info->d, mp, cache_size);
+	CNXK_TEL_DICT_INT(info->d, mp, elt_size);
+	CNXK_TEL_DICT_INT(info->d, mp, header_size);
+	CNXK_TEL_DICT_INT(info->d, mp, trailer_size);
+	CNXK_TEL_DICT_INT(info->d, mp, private_data_size);
+	CNXK_TEL_DICT_INT(info->d, mp, ops_index);
+	CNXK_TEL_DICT_INT(info->d, mp, populated_size);
+
+	aura_id = roc_npa_aura_handle_to_aura(mp->pool_id);
+	rte_tel_data_add_dict_int(info->d, "aura_id", aura_id);
+
+	mz = mp->mz;
+	CNXK_TEL_DICT_STR(info->d, mz, name, mz_);
+	CNXK_TEL_DICT_PTR(info->d, mz, iova, mz_);
+	CNXK_TEL_DICT_PTR(info->d, mz, addr, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, len, mz_);
+	CNXK_TEL_DICT_U64(info->d, mz, hugepage_sz, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, socket_id, mz_);
+	CNXK_TEL_DICT_INT(info->d, mz, flags, mz_);
+}
+
+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 -1;
+
+	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/list", mempool_tel_handle_list,
+		"Returns list of available mempools. Takes no parameters");
+	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',
 )
-- 
2.25.1


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

* [dpdk-dev] [v8, 3/4] common/cnxk: add telemetry endpoints to nix
  2021-09-21 10:52         ` [dpdk-dev] [v8, 0/4] cnxk: enable telemetry endpoints for mempool and ethdev Gowrishankar Muthukrishnan
  2021-09-21 10:52           ` [dpdk-dev] [v8, 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
  2021-09-21 10:52           ` [dpdk-dev] [v8, 2/4] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
@ 2021-09-21 10:52           ` Gowrishankar Muthukrishnan
  2021-09-21 10:52           ` [dpdk-dev] [v8, 4/4] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
  2021-09-29  6:54           ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  4 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-21 10:52 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula,
	Gowrishankar Muthukrishnan

Add telemetry endpoints to nix.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry_nix.c | 849 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   3 +-
 drivers/common/cnxk/roc_nix.c            |   3 +
 drivers/common/cnxk/roc_nix_priv.h       |   9 +
 drivers/common/cnxk/roc_nix_queue.c      |  15 +-
 drivers/common/cnxk/roc_platform.h       |   3 +
 6 files changed, 878 insertions(+), 4 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c

diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c b/drivers/common/cnxk/cnxk_telemetry_nix.c
new file mode 100644
index 0000000000..1175f68a51
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_nix.c
@@ -0,0 +1,849 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+struct nix_tel_node {
+	TAILQ_ENTRY(nix_tel_node) node;
+	struct roc_nix *nix;
+	uint16_t n_rq;
+	uint16_t n_cq;
+	uint16_t n_sq;
+	struct roc_nix_rq **rqs;
+	struct roc_nix_cq **cqs;
+	struct roc_nix_sq **sqs;
+};
+
+TAILQ_HEAD(nix_tel_node_list, nix_tel_node);
+static struct nix_tel_node_list nix_list;
+
+static struct nix_tel_node *
+nix_tel_node_get(struct roc_nix *roc_nix)
+{
+	struct nix_tel_node *node, *roc_node = NULL;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (node->nix == roc_nix) {
+			roc_node = node;
+			break;
+		}
+	}
+
+	return roc_node;
+}
+
+int
+nix_tel_node_add(struct roc_nix *roc_nix)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(roc_nix);
+	if (node) {
+		if (nix->nb_rx_queues == node->n_rq &&
+		    nix->nb_tx_queues == node->n_sq)
+			return 0;
+
+		nix_tel_node_del(roc_nix);
+	}
+
+	node = plt_zmalloc(sizeof(struct nix_tel_node), 0);
+	if (!node)
+		return -1;
+
+	node->nix = roc_nix;
+	node->rqs =
+		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_rq *), 0);
+	node->cqs =
+		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_cq *), 0);
+	node->sqs =
+		plt_zmalloc(nix->nb_tx_queues * sizeof(struct roc_nix_sq *), 0);
+	TAILQ_INSERT_TAIL(&nix_list, node, node);
+
+	return 0;
+}
+
+void
+nix_tel_node_del(struct roc_nix *roc_nix)
+{
+	struct nix_tel_node *node;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (node->nix == roc_nix) {
+			plt_free(node->rqs);
+			plt_free(node->cqs);
+			plt_free(node->sqs);
+			TAILQ_REMOVE(&nix_list, node, node);
+		}
+	}
+
+	plt_free(node);
+}
+
+static struct nix_tel_node *
+nix_tel_node_get_by_pcidev_name(const char *name)
+{
+	struct nix_tel_node *node, *roc_node = NULL;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (!strncmp(node->nix->pci_dev->name, name,
+			     PCI_PRI_STR_SIZE)) {
+			roc_node = node;
+			break;
+		}
+	}
+
+	return roc_node;
+}
+
+int
+nix_tel_node_add_rq(struct roc_nix_rq *rq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(rq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->rqs[rq->qid] = rq;
+	node->n_rq++;
+	return 0;
+}
+
+int
+nix_tel_node_add_cq(struct roc_nix_cq *cq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(cq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->cqs[cq->qid] = cq;
+	node->n_cq++;
+	return 0;
+}
+
+int
+nix_tel_node_add_sq(struct roc_nix_sq *sq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(sq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->sqs[sq->qid] = sq;
+	node->n_sq++;
+	return 0;
+}
+
+static int
+cnxk_tel_nix(struct roc_nix *roc_nix, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+
+	struct dev *dev = &nix->dev;
+
+	plt_tel_data_add_dict_ptr(d, "nix", nix);
+	plt_tel_data_add_dict_int(d, "pf_func", dev->pf_func);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(dev->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(dev->pf_func));
+
+	CNXK_TEL_DICT_PTR(d, dev, bar2);
+	CNXK_TEL_DICT_PTR(d, dev, bar4);
+	CNXK_TEL_DICT_INT(d, roc_nix, port_id);
+	CNXK_TEL_DICT_INT(d, roc_nix, rss_tag_as_xor);
+	CNXK_TEL_DICT_INT(d, roc_nix, max_sqb_count);
+	CNXK_TEL_DICT_PTR(d, nix, pci_dev);
+	CNXK_TEL_DICT_PTR(d, nix, base);
+	CNXK_TEL_DICT_PTR(d, nix, lmt_base);
+	CNXK_TEL_DICT_INT(d, nix, reta_sz);
+	CNXK_TEL_DICT_INT(d, nix, tx_chan_base);
+	CNXK_TEL_DICT_INT(d, nix, rx_chan_base);
+	CNXK_TEL_DICT_INT(d, nix, nb_tx_queues);
+	CNXK_TEL_DICT_INT(d, nix, nb_rx_queues);
+	CNXK_TEL_DICT_INT(d, nix, lso_tsov6_idx);
+	CNXK_TEL_DICT_INT(d, nix, lso_tsov4_idx);
+
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v4",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v6",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v4",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v6",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v4v4",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v4v6",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v6v4",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v6v6",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+
+	CNXK_TEL_DICT_INT(d, nix, lf_tx_stats);
+	CNXK_TEL_DICT_INT(d, nix, lf_rx_stats);
+	CNXK_TEL_DICT_INT(d, nix, cgx_links);
+	CNXK_TEL_DICT_INT(d, nix, lbk_links);
+	CNXK_TEL_DICT_INT(d, nix, sdp_links);
+	CNXK_TEL_DICT_INT(d, nix, tx_link);
+	CNXK_TEL_DICT_INT(d, nix, sqb_size);
+	CNXK_TEL_DICT_INT(d, nix, msixoff);
+	CNXK_TEL_DICT_INT(d, nix, cints);
+	CNXK_TEL_DICT_INT(d, nix, qints);
+	CNXK_TEL_DICT_INT(d, nix, sdp_link);
+	CNXK_TEL_DICT_INT(d, nix, ptp_en);
+	CNXK_TEL_DICT_INT(d, nix, rss_alg_idx);
+	CNXK_TEL_DICT_INT(d, nix, tx_pause);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_rq(struct roc_nix_rq *rq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_rq", rq);
+	CNXK_TEL_DICT_INT(d, rq, qid);
+	CNXK_TEL_DICT_PTR(d, rq, aura_handle);
+	CNXK_TEL_DICT_INT(d, rq, ipsech_ena);
+	CNXK_TEL_DICT_INT(d, rq, first_skip);
+	CNXK_TEL_DICT_INT(d, rq, later_skip);
+	CNXK_TEL_DICT_INT(d, rq, lpb_size);
+	CNXK_TEL_DICT_INT(d, rq, sso_ena);
+	CNXK_TEL_DICT_INT(d, rq, tag_mask);
+	CNXK_TEL_DICT_INT(d, rq, flow_tag_width);
+	CNXK_TEL_DICT_INT(d, rq, tt);
+	CNXK_TEL_DICT_INT(d, rq, hwgrp);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_ena);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_first_skip);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_max_sz_exp);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_wait_tmo);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_aura_handle);
+	CNXK_TEL_DICT_PTR(d, rq, roc_nix);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_cq(struct roc_nix_cq *cq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_cq", cq);
+	CNXK_TEL_DICT_INT(d, cq, qid);
+	CNXK_TEL_DICT_INT(d, cq, nb_desc);
+	CNXK_TEL_DICT_PTR(d, cq, roc_nix);
+	CNXK_TEL_DICT_PTR(d, cq, door);
+	CNXK_TEL_DICT_PTR(d, cq, status);
+	CNXK_TEL_DICT_PTR(d, cq, wdata);
+	CNXK_TEL_DICT_PTR(d, cq, desc_base);
+	CNXK_TEL_DICT_INT(d, cq, qmask);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_sq(struct roc_nix_sq *sq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_sq", sq);
+	CNXK_TEL_DICT_INT(d, sq, qid);
+	CNXK_TEL_DICT_INT(d, sq, max_sqe_sz);
+	CNXK_TEL_DICT_INT(d, sq, nb_desc);
+	CNXK_TEL_DICT_INT(d, sq, sqes_per_sqb_log2);
+	CNXK_TEL_DICT_PTR(d, sq, roc_nix);
+	CNXK_TEL_DICT_PTR(d, sq, aura_handle);
+	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs_adj);
+	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs);
+	CNXK_TEL_DICT_PTR(d, sq, io_addr);
+	CNXK_TEL_DICT_PTR(d, sq, lmt_addr);
+	CNXK_TEL_DICT_PTR(d, sq, sqe_mem);
+	CNXK_TEL_DICT_PTR(d, sq, fc);
+
+	return 0;
+}
+
+static void
+nix_rq_ctx_cn9k(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_rq_ctx_s *ctx = (struct nix_rq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
+	CNXK_TEL_DICT_BF_PTR(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_);
+}
+
+static void
+nix_rq_ctx(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_cn10k_rq_ctx_s *ctx = (struct nix_cn10k_rq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_ol3_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_ol4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_il3_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_il4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, csum_ol4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, lenerr_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0);
+	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, chi_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsecd_drop_en, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_stashing, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, policer_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, band_prof_id, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_INT(d, ctx, vwqe_skip, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, max_vsize_exp, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, vtime_wait, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, vwqe_ena, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsec_vwqe, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_);
+}
+
+static int
+cnxk_tel_nix_rq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile void *qctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_RQ, n, &qctx);
+	if (rc) {
+		plt_err("Failed to get rq context");
+		return rc;
+	}
+
+	if (roc_model_is_cn9k())
+		nix_rq_ctx_cn9k(&qctx, d);
+	else
+		nix_rq_ctx(&qctx, d);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_cq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile struct nix_cq_ctx_s *ctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_CQ, n, (void *)&ctx);
+	if (rc) {
+		plt_err("Failed to get cq context");
+		return rc;
+	}
+
+	/* W0 */
+	CNXK_TEL_DICT_PTR(d, ctx, base, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_U64(d, ctx, wrptr, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cint_idx, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_err, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, bpid, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, bp_ena, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, update_time, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, avg_level, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, head, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, tail, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, cq_err_int_ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_err_int, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, qsize, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, caching, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, drop_ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, bp, w3_);
+
+	return 0;
+}
+
+static void
+nix_sq_ctx_cn9k(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_sq_ctx_s *ctx = (struct nix_sq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_quantum, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
+
+	/* W11 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
+
+	/* W12 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
+
+	/* W14 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
+
+	/* W15 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_);
+}
+
+static void
+nix_sq_ctx(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_cn10k_sq_ctx_s *ctx = (struct nix_cn10k_sq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_weight, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_ub, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_lb, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
+
+	/* W11 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
+
+	/* W12 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
+
+	/* W14 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
+
+	/* W15 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_);
+}
+
+static int
+cnxk_tel_nix_sq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile void *qctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_SQ, n, &qctx);
+	if (rc) {
+		plt_err("Failed to get rq context");
+		return rc;
+	}
+
+	if (roc_model_is_cn9k())
+		nix_sq_ctx_cn9k(&qctx, d);
+	else
+		nix_sq_ctx(&qctx, d);
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_list(const char *cmd __plt_unused,
+			 const char *params __plt_unused,
+			 struct plt_tel_data *d)
+{
+	struct nix_tel_node *node;
+	struct roc_nix *roc_nix;
+
+	plt_tel_data_start_array(d, PLT_TEL_STRING_VAL);
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		roc_nix = node->nix;
+		plt_tel_data_add_array_string(d, roc_nix->pci_dev->name);
+	}
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_info(const char *cmd __plt_unused, const char *params,
+			 struct plt_tel_data *d)
+{
+	char name[PCI_PRI_STR_SIZE];
+	struct nix_tel_node *node;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	plt_strlcpy(name, params, PCI_PRI_STR_SIZE);
+
+	node = nix_tel_node_get_by_pcidev_name(name);
+	if (!node)
+		return -1;
+
+	plt_tel_data_start_dict(d);
+	return cnxk_tel_nix(node->nix, d);
+}
+
+static int
+cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
+			   struct plt_tel_data *d)
+{
+	struct nix_tel_node *node;
+	char *name, *param;
+	char buf[1024];
+	int rc = -1;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		goto exit;
+
+	plt_strlcpy(buf, params, PCI_PRI_STR_SIZE + 1);
+	name = strtok(buf, ",");
+	param = strtok(NULL, "\0");
+
+	node = nix_tel_node_get_by_pcidev_name(name);
+	if (!node)
+		goto exit;
+
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "rq")) {
+		char *tok = strtok(param, ",");
+		int rq;
+
+		if (!tok)
+			goto exit;
+
+		rq = strtol(tok, NULL, 10);
+		if ((node->n_rq <= rq) || (rq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_rq_ctx(node->nix, rq, d);
+		else
+			rc = cnxk_tel_nix_rq(node->rqs[rq], d);
+
+	} else if (strstr(cmd, "cq")) {
+		char *tok = strtok(param, ",");
+		int cq;
+
+		if (!tok)
+			goto exit;
+
+		cq = strtol(tok, NULL, 10);
+		if ((node->n_cq <= cq) || (cq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_cq_ctx(node->nix, cq, d);
+		else
+			rc = cnxk_tel_nix_cq(node->cqs[cq], d);
+
+	} else if (strstr(cmd, "sq")) {
+		char *tok = strtok(param, ",");
+		int sq;
+
+		if (!tok)
+			goto exit;
+
+		sq = strtol(tok, NULL, 10);
+		if ((node->n_sq <= sq) || (sq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_sq_ctx(node->nix, sq, d);
+		else
+			rc = cnxk_tel_nix_sq(node->sqs[sq], d);
+	}
+
+exit:
+	return rc;
+}
+
+PLT_INIT(cnxk_telemetry_nix_init)
+{
+	TAILQ_INIT(&nix_list);
+
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/list", cnxk_nix_tel_handle_list,
+		"Returns list of available NIX devices. Takes no parameters");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/info", cnxk_nix_tel_handle_info,
+		"Returns nix information. Parameters: pci id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/rq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix rq information. Parameters: pci id, rq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/rq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix rq context. Parameters: pci id, rq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/cq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix cq information. Parameters: pci id, cq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/cq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix cq context. Parameters: pci id, cq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/sq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix sq information. Parameters: pci id, sq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/sq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix sq context. Parameters: pci id, sq id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index f0a1c9f115..fe7a95b526 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -65,6 +65,7 @@ sources = files(
 sources += files('cnxk_security.c')
 
 # Telemetry common code
-sources += files('cnxk_telemetry_npa.c')
+sources += files('cnxk_telemetry_npa.c',
+                 'cnxk_telemetry_nix.c')
 
 deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_nix.c b/drivers/common/cnxk/roc_nix.c
index 3ab954e94d..17beb1a736 100644
--- a/drivers/common/cnxk/roc_nix.c
+++ b/drivers/common/cnxk/roc_nix.c
@@ -178,6 +178,8 @@ roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq, uint32_t nb_txq,
 	nix->sqs = plt_zmalloc(sizeof(struct roc_nix_sq *) * nb_txq, 0);
 	if (!nix->sqs)
 		return -ENOMEM;
+
+	nix_tel_node_add(roc_nix);
 fail:
 	return rc;
 }
@@ -413,6 +415,7 @@ roc_nix_dev_init(struct roc_nix *roc_nix)
 dev_fini:
 	rc |= dev_fini(dev, pci_dev);
 fail:
+	nix_tel_node_del(roc_nix);
 	return rc;
 }
 
diff --git a/drivers/common/cnxk/roc_nix_priv.h b/drivers/common/cnxk/roc_nix_priv.h
index 2cd5a72347..ba639791ce 100644
--- a/drivers/common/cnxk/roc_nix_priv.h
+++ b/drivers/common/cnxk/roc_nix_priv.h
@@ -424,4 +424,13 @@ int nix_lf_int_reg_dump(uintptr_t nix_lf_base, uint64_t *data, uint16_t qints,
 int nix_q_ctx_get(struct dev *dev, uint8_t ctype, uint16_t qid,
 		  __io void **ctx_p);
 
+/*
+ * Telemetry
+ */
+int nix_tel_node_add(struct roc_nix *roc_nix);
+void nix_tel_node_del(struct roc_nix *roc_nix);
+int nix_tel_node_add_rq(struct roc_nix_rq *rq);
+int nix_tel_node_add_cq(struct roc_nix_cq *cq);
+int nix_tel_node_add_sq(struct roc_nix_sq *sq);
+
 #endif /* _ROC_NIX_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_nix_queue.c b/drivers/common/cnxk/roc_nix_queue.c
index 8fbb13ecbd..f546fc83c5 100644
--- a/drivers/common/cnxk/roc_nix_queue.c
+++ b/drivers/common/cnxk/roc_nix_queue.c
@@ -387,7 +387,11 @@ roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
 	if (rc)
 		return rc;
 
-	return mbox_process(mbox);
+	rc = mbox_process(mbox);
+	if (rc)
+		return rc;
+
+	return nix_tel_node_add_rq(rq);
 }
 
 int
@@ -415,7 +419,11 @@ roc_nix_rq_modify(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
 	if (rc)
 		return rc;
 
-	return mbox_process(mbox);
+	rc = mbox_process(mbox);
+	if (rc)
+		return rc;
+
+	return nix_tel_node_add_rq(rq);
 }
 
 int
@@ -504,7 +512,7 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq)
 	if (rc)
 		goto free_mem;
 
-	return 0;
+	return nix_tel_node_add_cq(cq);
 
 free_mem:
 	plt_free(cq->desc_base);
@@ -884,6 +892,7 @@ roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq)
 					((qid & RVU_CN9K_LMT_SLOT_MASK) << 12));
 	}
 
+	rc = nix_tel_node_add_sq(sq);
 	return rc;
 nomem:
 	plt_free(sq->fc);
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 57073d62aa..b95af115f7 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -145,7 +145,10 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define PLT_TEL_STRING_VAL RTE_TEL_STRING_VAL
 #define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_array     rte_tel_data_start_array
+#define plt_tel_data_add_array_string rte_tel_data_add_array_string
 #define plt_tel_data_start_dict      rte_tel_data_start_dict
 #define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
 #define plt_tel_data_add_dict_ptr(d, n, v)			\
-- 
2.25.1


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

* [dpdk-dev] [v8, 4/4] net/cnxk: add telemetry endpoing to ethdev
  2021-09-21 10:52         ` [dpdk-dev] [v8, 0/4] cnxk: enable telemetry endpoints for mempool and ethdev Gowrishankar Muthukrishnan
                             ` (2 preceding siblings ...)
  2021-09-21 10:52           ` [dpdk-dev] [v8, 3/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
@ 2021-09-21 10:52           ` Gowrishankar Muthukrishnan
  2021-09-21 11:27             ` Jerin Jacob
  2021-09-29  4:25             ` [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info Gowrishankar Muthukrishnan
  2021-09-29  6:54           ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  4 siblings, 2 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-21 10:52 UTC (permalink / raw)
  To: dev
  Cc: bruce.richardson, ciara.power, jerinj, kirankumark, ndabilpuram,
	skori, skoteshwar, asekhar, pbhagavatula,
	Gowrishankar Muthukrishnan

Add telemetry endpoint to ethdev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/net/cnxk/cnxk_ethdev_telemetry.c | 129 +++++++++++++++++++++++
 drivers/net/cnxk/meson.build             |   1 +
 2 files changed, 130 insertions(+)
 create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c

diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
new file mode 100644
index 0000000000..de8c468670
--- /dev/null
+++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
@@ -0,0 +1,129 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell International Ltd.
+ */
+
+#include <rte_telemetry.h>
+
+#include "cnxk_ethdev.h"
+
+/* Macro to count no of words in eth_info_s size */
+#define ETH_INFO_SZ                                                            \
+	(RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) /         \
+	 sizeof(uint64_t))
+#define MACADDR_LEN 18
+
+static int
+ethdev_tel_handle_info(const char *cmd __rte_unused,
+		       const char *params __rte_unused, struct rte_tel_data *d)
+{
+	struct rte_eth_dev *eth_dev;
+	struct rte_tel_data *i_data;
+	struct cnxk_eth_dev *dev;
+	union eth_info_u {
+		struct eth_info_s {
+			/** PF/VF information */
+			uint16_t pf_func;
+			/** No of rx queues */
+			uint16_t rx_queues;
+			/** No of tx queues */
+			uint16_t tx_queues;
+			/** Port ID */
+			uint16_t port_id;
+			/** MAC entries */
+			char mac_addr[MACADDR_LEN];
+			uint8_t max_mac_entries;
+			bool dmac_filter_ena;
+			uint8_t dmac_filter_count;
+			uint16_t flags;
+			uint8_t ptype_disable;
+			bool scalar_ena;
+			bool ptp_ena;
+			/* Offload capabilities */
+			uint64_t rx_offload_capa;
+			uint64_t tx_offload_capa;
+			uint32_t speed_capa;
+			/* Configured offloads */
+			uint64_t rx_offloads;
+			uint64_t tx_offloads;
+			/* Platform specific offload flags */
+			uint16_t rx_offload_flags;
+			uint16_t tx_offload_flags;
+			/* ETHDEV RSS HF bitmask */
+			uint64_t ethdev_rss_hf;
+		} info;
+		uint64_t val[ETH_INFO_SZ];
+	} eth_info;
+	struct eth_info_s *info;
+	unsigned int i, j = 0;
+	int n_ports;
+
+	n_ports = rte_eth_dev_count_avail();
+	if (!n_ports) {
+		plt_err("No active ethernet ports found.");
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_int(d, "n_ports", n_ports);
+
+	i_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+		/* Skip if port is unused */
+		if (!rte_eth_dev_is_valid_port(i))
+			continue;
+
+		eth_dev = &rte_eth_devices[i];
+		if (eth_dev) {
+			memset(&eth_info, 0, sizeof(eth_info));
+			info = &eth_info.info;
+			dev = cnxk_eth_pmd_priv(eth_dev);
+			if (dev) {
+				info->pf_func = roc_nix_get_pf_func(&dev->nix);
+				memset(info->mac_addr, 0, MACADDR_LEN);
+				snprintf(info->mac_addr, MACADDR_LEN,
+					 "%02x:%02x:%02x:%02x:%02x:%02x",
+					 dev->mac_addr[0], dev->mac_addr[1],
+					 dev->mac_addr[2], dev->mac_addr[3],
+					 dev->mac_addr[4], dev->mac_addr[5]);
+				info->max_mac_entries = dev->max_mac_entries;
+				info->dmac_filter_ena = dev->dmac_filter_enable;
+				info->dmac_filter_count =
+					dev->dmac_filter_count;
+				info->flags = dev->flags;
+				info->ptype_disable = dev->ptype_disable;
+				info->scalar_ena = dev->scalar_ena;
+				info->ptp_ena = dev->ptp_en;
+				info->rx_offload_capa = dev->rx_offload_capa;
+				info->tx_offload_capa = dev->tx_offload_capa;
+				info->rx_offloads = dev->rx_offloads;
+				info->tx_offloads = dev->tx_offloads;
+				info->rx_offload_flags = dev->rx_offload_flags;
+				info->tx_offload_flags = dev->tx_offload_flags;
+				info->ethdev_rss_hf = dev->ethdev_rss_hf;
+			}
+
+			if (eth_dev->data) {
+				info->rx_queues = eth_dev->data->nb_rx_queues;
+				info->tx_queues = eth_dev->data->nb_tx_queues;
+				info->port_id = eth_dev->data->port_id;
+			}
+
+			for (j = 0; j < ETH_INFO_SZ; j++)
+				rte_tel_data_add_array_u64(i_data,
+							   eth_info.val[j]);
+
+			j++;
+		}
+	}
+
+	rte_tel_data_add_dict_container(d, "info", i_data, 0);
+	return 0;
+}
+
+RTE_INIT(cnxk_ethdev_init_telemetry)
+{
+	rte_telemetry_register_cmd("/cnxk/ethdev/info", ethdev_tel_handle_info,
+				   "Returns ethdev device information");
+}
diff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build
index d1d4b4e15e..5b3b8422fb 100644
--- a/drivers/net/cnxk/meson.build
+++ b/drivers/net/cnxk/meson.build
@@ -13,6 +13,7 @@ sources = files(
         'cnxk_ethdev_devargs.c',
         'cnxk_ethdev_ops.c',
         'cnxk_ethdev_sec.c',
+        'cnxk_ethdev_telemetry.c',
         'cnxk_link.c',
         'cnxk_lookup.c',
         'cnxk_ptp.c',
-- 
2.25.1


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

* [dpdk-dev] [v2] telemetry: fix json output buffer size
  2021-09-08 17:03           ` [dpdk-dev] [v7, 5/6] telemetry: fix json output buffer size Gowrishankar Muthukrishnan
@ 2021-09-21 11:02             ` Gowrishankar Muthukrishnan
  2021-09-22  9:21               ` Power, Ciara
  2021-09-23  6:21               ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
  0 siblings, 2 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-21 11:02 UTC (permalink / raw)
  To: dev; +Cc: ciara.power, Gowrishankar Muthukrishnan

Fix json output buffer size for a single largest value.

Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON")

v2:
 - split from series 18768 ("cnxk: enable telemetry endpoints").

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 lib/telemetry/telemetry_json.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index ad270b9b30..ba2fde34cb 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -9,6 +9,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <rte_common.h>
+#include <rte_telemetry.h>
 
 /**
  * @file
@@ -23,13 +24,15 @@
  * @internal
  * Copies a value into a buffer if the buffer has enough available space.
  * Nothing written to buffer if an overflow ocurs.
- * This function is not for use for values larger than 1k.
+ * Size of buffer is (single largest value - 6), where at least 6 chars
+ * would have been used for creating json dict i.e '{"x": ... }'.
+ * This function is not for use for values larger than this buffer size.
  */
 __rte_format_printf(3, 4)
 static inline int
 __json_snprintf(char *buf, const int len, const char *format, ...)
 {
-	char tmp[1024];
+	char tmp[RTE_TEL_MAX_SINGLE_STRING_LEN - 6];
 	va_list ap;
 	int ret;
 
-- 
2.25.1


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

* Re: [dpdk-dev] [v8, 4/4] net/cnxk: add telemetry endpoing to ethdev
  2021-09-21 10:52           ` [dpdk-dev] [v8, 4/4] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
@ 2021-09-21 11:27             ` Jerin Jacob
  2021-09-21 11:53               ` Bruce Richardson
  2021-09-29  4:25             ` [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info Gowrishankar Muthukrishnan
  1 sibling, 1 reply; 121+ messages in thread
From: Jerin Jacob @ 2021-09-21 11:27 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan
  Cc: dpdk-dev, Richardson, Bruce, Ciara Power, Jerin Jacob,
	Kiran Kumar K, Nithin Dabilpuram, Sunil Kumar Kori,
	Satha Koteswara Rao Kottidi,
	Ashwin Sekhar Thalakalath Kottilveetil, Pavan Nikhilesh,
	Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, Olivier Matz

On Tue, Sep 21, 2021 at 4:23 PM Gowrishankar Muthukrishnan
<gmuthukrishn@marvell.com> wrote:
>
> Add telemetry endpoint to ethdev.
>
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
>  drivers/net/cnxk/cnxk_ethdev_telemetry.c | 129 +++++++++++++++++++++++
>  drivers/net/cnxk/meson.build             |   1 +
>  2 files changed, 130 insertions(+)
>  create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
>
> diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> new file mode 100644
> index 0000000000..de8c468670
> --- /dev/null
> +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> @@ -0,0 +1,129 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2021 Marvell International Ltd.
> + */
> +
> +#include <rte_telemetry.h>
> +
> +#include "cnxk_ethdev.h"
> +
> +/* Macro to count no of words in eth_info_s size */
> +#define ETH_INFO_SZ                                                            \
> +       (RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) /         \
> +        sizeof(uint64_t))
> +#define MACADDR_LEN 18
> +
> +static int
> +ethdev_tel_handle_info(const char *cmd __rte_unused,
> +                      const char *params __rte_unused, struct rte_tel_data *d)
> +{
> +       struct rte_eth_dev *eth_dev;
> +       struct rte_tel_data *i_data;
> +       struct cnxk_eth_dev *dev;
> +       union eth_info_u {
> +               struct eth_info_s {
> +                       /** PF/VF information */
> +                       uint16_t pf_func;
> +                       /** No of rx queues */
> +                       uint16_t rx_queues;
> +                       /** No of tx queues */
> +                       uint16_t tx_queues;
> +                       /** Port ID */
> +                       uint16_t port_id;
> +                       /** MAC entries */
> +                       char mac_addr[MACADDR_LEN];
> +                       uint8_t max_mac_entries;
> +                       bool dmac_filter_ena;
> +                       uint8_t dmac_filter_count;
> +                       uint16_t flags;
> +                       uint8_t ptype_disable;
> +                       bool scalar_ena;
> +                       bool ptp_ena;
> +                       /* Offload capabilities */
> +                       uint64_t rx_offload_capa;
> +                       uint64_t tx_offload_capa;
> +                       uint32_t speed_capa;
> +                       /* Configured offloads */
> +                       uint64_t rx_offloads;
> +                       uint64_t tx_offloads;
> +                       /* Platform specific offload flags */
> +                       uint16_t rx_offload_flags;
> +                       uint16_t tx_offload_flags;
> +                       /* ETHDEV RSS HF bitmask */
> +                       uint64_t ethdev_rss_hf;

+ Ethdev, , mempool and telemetry maintainers

All of the above data except[1] is generic data that can be derived
from ethdev APIs or ethdev data from lib/ethdev itself,
IMO, We should avoid duplicating this in driver and make useful for
other driver/application by adding generic endpoint in ethdev.
Same comment for "[2/4] mempool/cnxk: add telemetry end points" for
mempool subsystem.

Thoughts from Maintainers?

[1]
  uint8_t ptype_disable;
  bool scalar_ena;
  bool ptp_ena;
  uint16_t flags;

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

* [dpdk-dev] [v2] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-09-08 17:03           ` [dpdk-dev] [v7, 6/6] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
@ 2021-09-21 11:32             ` Gowrishankar Muthukrishnan
  2021-09-29  6:45               ` [dpdk-dev] [v1] cryptodev: add telemetry endpoint for cryptodev info Gowrishankar Muthukrishnan
  2021-09-29  7:01               ` [dpdk-dev] [v3] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
  0 siblings, 2 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-21 11:32 UTC (permalink / raw)
  To: dev; +Cc: gakhil, anoobj, adwivedi, ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to cryptodev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: series-19052 ("cnxk: enable telemetry endpoints for mempool and ethdev")
Depends-on: patch-19054 ("telemetry: fix json output buffer size")

v2:
 - split from series 18768 ("cnxk: enable telemetry endpoints").
---
 .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 154 ++++++++++++++++++
 drivers/crypto/cnxk/meson.build               |   1 +
 2 files changed, 155 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
new file mode 100644
index 0000000000..4c754bc6c7
--- /dev/null
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
@@ -0,0 +1,154 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
+#include <rte_telemetry.h>
+
+#include <roc_api.h>
+
+#include "cnxk_cryptodev.h"
+#include "cnxk_telemetry.h"
+
+#define CRYPTO_CAPS_SZ                                                         \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities),             \
+			sizeof(uint64_t)) /                                    \
+	 sizeof(uint64_t))
+
+#define SEC_CAPS_SZ                                                            \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability),                \
+			sizeof(uint64_t)) /                                    \
+	 sizeof(uint64_t))
+
+static int
+cryptodev_tel_handle_list(const char *cmd __rte_unused,
+			  const char *params __rte_unused,
+			  struct rte_tel_data *d)
+{
+	struct rte_cryptodev *cryptodev;
+	unsigned int i;
+
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+
+	for (i = 0; i < RTE_CRYPTO_MAX_DEVS; i++) {
+		cryptodev = rte_cryptodev_pmd_get_dev(i);
+		if (cryptodev->attached != RTE_CRYPTODEV_ATTACHED)
+			continue;
+
+		rte_tel_data_add_array_string(d, cryptodev->data->name);
+	}
+
+	return 0;
+}
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  struct rte_cryptodev_capabilities *dev_caps,
+		  size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_cryptodev_capabilities dev_caps;
+		uint64_t val[CRYPTO_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		if (dev_caps[i].op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
+			break;
+
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+sec_caps_array(struct rte_tel_data *d, struct rte_security_capability *dev_caps,
+	       size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_security_capability dev_caps;
+		uint64_t val[SEC_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+cryptodev_tel_handle_info(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_tel_data *crypto_caps, *sec_crypto_caps, *sec_caps;
+	int crypto_caps_n, sec_crypto_caps_n, sec_caps_n;
+	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	rte_strlcpy(name, params, RTE_CRYPTODEV_NAME_LEN);
+	dev = rte_cryptodev_pmd_get_named_dev(name);
+	if (!dev) {
+		plt_err("No cryptodev of name %s available", name);
+		return -1;
+	}
+
+	vf = dev->data->dev_private;
+
+	rte_tel_data_start_dict(d);
+	CNXK_TEL_DICT_INT(d, dev->data, dev_id);
+	CNXK_TEL_DICT_INT(d, dev->data, socket_id);
+	CNXK_TEL_DICT_INT(d, dev->data, dev_started);
+
+	/* Crypto capabilities */
+	crypto_caps = rte_tel_data_alloc();
+	crypto_caps_n = crypto_caps_array(crypto_caps, vf->crypto_caps,
+					  CNXK_CPT_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
+
+	/* Security Crypto capabilities */
+	sec_crypto_caps = rte_tel_data_alloc();
+	sec_crypto_caps_n = crypto_caps_array(
+		sec_crypto_caps, vf->sec_crypto_caps, CNXK_SEC_CRYPTO_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_crypto_caps", sec_crypto_caps,
+					0);
+	rte_tel_data_add_dict_int(d, "sec_crypto_caps_n", sec_crypto_caps_n);
+
+	/* Security capabilities */
+	sec_caps = rte_tel_data_alloc();
+	sec_caps_n = sec_caps_array(sec_caps, vf->sec_caps, CNXK_SEC_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(cnxk_cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/cryptodev/list", cryptodev_tel_handle_list,
+		"Returns list of available cryptodev. Takes no parameters");
+	rte_telemetry_register_cmd(
+		"/cnxk/cryptodev/info", cryptodev_tel_handle_info,
+		"Returns cryptodev info. Parameters: pci id");
+}
diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build
index e40d132f80..0ce89f1c12 100644
--- a/drivers/crypto/cnxk/meson.build
+++ b/drivers/crypto/cnxk/meson.build
@@ -19,6 +19,7 @@ sources = files(
         'cnxk_cryptodev_capabilities.c',
         'cnxk_cryptodev_ops.c',
         'cnxk_cryptodev_sec.c',
+        'cnxk_cryptodev_telemetry.c',
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev']
-- 
2.25.1


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

* Re: [dpdk-dev] [v8, 4/4] net/cnxk: add telemetry endpoing to ethdev
  2021-09-21 11:27             ` Jerin Jacob
@ 2021-09-21 11:53               ` Bruce Richardson
  2021-09-21 12:16                 ` Olivier Matz
  0 siblings, 1 reply; 121+ messages in thread
From: Bruce Richardson @ 2021-09-21 11:53 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: Gowrishankar Muthukrishnan, dpdk-dev, Ciara Power, Jerin Jacob,
	Kiran Kumar K, Nithin Dabilpuram, Sunil Kumar Kori,
	Satha Koteswara Rao Kottidi,
	Ashwin Sekhar Thalakalath Kottilveetil, Pavan Nikhilesh,
	Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, Olivier Matz

On Tue, Sep 21, 2021 at 04:57:52PM +0530, Jerin Jacob wrote:
> On Tue, Sep 21, 2021 at 4:23 PM Gowrishankar Muthukrishnan
> <gmuthukrishn@marvell.com> wrote:
> >
> > Add telemetry endpoint to ethdev.
> >
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > ---
> >  drivers/net/cnxk/cnxk_ethdev_telemetry.c | 129 +++++++++++++++++++++++
> >  drivers/net/cnxk/meson.build             |   1 +
> >  2 files changed, 130 insertions(+)
> >  create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
> >
> > diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> > new file mode 100644
> > index 0000000000..de8c468670
> > --- /dev/null
> > +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> > @@ -0,0 +1,129 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(C) 2021 Marvell International Ltd.
> > + */
> > +
> > +#include <rte_telemetry.h>
> > +
> > +#include "cnxk_ethdev.h"
> > +
> > +/* Macro to count no of words in eth_info_s size */
> > +#define ETH_INFO_SZ                                                            \
> > +       (RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) /         \
> > +        sizeof(uint64_t))
> > +#define MACADDR_LEN 18
> > +
> > +static int
> > +ethdev_tel_handle_info(const char *cmd __rte_unused,
> > +                      const char *params __rte_unused, struct rte_tel_data *d)
> > +{
> > +       struct rte_eth_dev *eth_dev;
> > +       struct rte_tel_data *i_data;
> > +       struct cnxk_eth_dev *dev;
> > +       union eth_info_u {
> > +               struct eth_info_s {
> > +                       /** PF/VF information */
> > +                       uint16_t pf_func;
> > +                       /** No of rx queues */
> > +                       uint16_t rx_queues;
> > +                       /** No of tx queues */
> > +                       uint16_t tx_queues;
> > +                       /** Port ID */
> > +                       uint16_t port_id;
> > +                       /** MAC entries */
> > +                       char mac_addr[MACADDR_LEN];
> > +                       uint8_t max_mac_entries;
> > +                       bool dmac_filter_ena;
> > +                       uint8_t dmac_filter_count;
> > +                       uint16_t flags;
> > +                       uint8_t ptype_disable;
> > +                       bool scalar_ena;
> > +                       bool ptp_ena;
> > +                       /* Offload capabilities */
> > +                       uint64_t rx_offload_capa;
> > +                       uint64_t tx_offload_capa;
> > +                       uint32_t speed_capa;
> > +                       /* Configured offloads */
> > +                       uint64_t rx_offloads;
> > +                       uint64_t tx_offloads;
> > +                       /* Platform specific offload flags */
> > +                       uint16_t rx_offload_flags;
> > +                       uint16_t tx_offload_flags;
> > +                       /* ETHDEV RSS HF bitmask */
> > +                       uint64_t ethdev_rss_hf;
> 
> + Ethdev, , mempool and telemetry maintainers
> 
> All of the above data except[1] is generic data that can be derived
> from ethdev APIs or ethdev data from lib/ethdev itself,
> IMO, We should avoid duplicating this in driver and make useful for
> other driver/application by adding generic endpoint in ethdev.
> Same comment for "[2/4] mempool/cnxk: add telemetry end points" for
> mempool subsystem.
> 
> Thoughts from Maintainers?
> 
Not a maintainer of those libs, but +1 to making anything generic that can
be, save reimplementing things multiple times in drivers.

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

* Re: [dpdk-dev] [v8, 4/4] net/cnxk: add telemetry endpoing to ethdev
  2021-09-21 11:53               ` Bruce Richardson
@ 2021-09-21 12:16                 ` Olivier Matz
  0 siblings, 0 replies; 121+ messages in thread
From: Olivier Matz @ 2021-09-21 12:16 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: Jerin Jacob, Gowrishankar Muthukrishnan, dpdk-dev, Ciara Power,
	Jerin Jacob, Kiran Kumar K, Nithin Dabilpuram, Sunil Kumar Kori,
	Satha Koteswara Rao Kottidi,
	Ashwin Sekhar Thalakalath Kottilveetil, Pavan Nikhilesh,
	Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko

On Tue, Sep 21, 2021 at 12:53:53PM +0100, Bruce Richardson wrote:
> On Tue, Sep 21, 2021 at 04:57:52PM +0530, Jerin Jacob wrote:
> > On Tue, Sep 21, 2021 at 4:23 PM Gowrishankar Muthukrishnan
> > <gmuthukrishn@marvell.com> wrote:
> > >
> > > Add telemetry endpoint to ethdev.
> > >
> > > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > > ---
> > >  drivers/net/cnxk/cnxk_ethdev_telemetry.c | 129 +++++++++++++++++++++++
> > >  drivers/net/cnxk/meson.build             |   1 +
> > >  2 files changed, 130 insertions(+)
> > >  create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
> > >
> > > diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> > > new file mode 100644
> > > index 0000000000..de8c468670
> > > --- /dev/null
> > > +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> > > @@ -0,0 +1,129 @@
> > > +/* SPDX-License-Identifier: BSD-3-Clause
> > > + * Copyright(C) 2021 Marvell International Ltd.
> > > + */
> > > +
> > > +#include <rte_telemetry.h>
> > > +
> > > +#include "cnxk_ethdev.h"
> > > +
> > > +/* Macro to count no of words in eth_info_s size */
> > > +#define ETH_INFO_SZ                                                            \
> > > +       (RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) /         \
> > > +        sizeof(uint64_t))
> > > +#define MACADDR_LEN 18
> > > +
> > > +static int
> > > +ethdev_tel_handle_info(const char *cmd __rte_unused,
> > > +                      const char *params __rte_unused, struct rte_tel_data *d)
> > > +{
> > > +       struct rte_eth_dev *eth_dev;
> > > +       struct rte_tel_data *i_data;
> > > +       struct cnxk_eth_dev *dev;
> > > +       union eth_info_u {
> > > +               struct eth_info_s {
> > > +                       /** PF/VF information */
> > > +                       uint16_t pf_func;
> > > +                       /** No of rx queues */
> > > +                       uint16_t rx_queues;
> > > +                       /** No of tx queues */
> > > +                       uint16_t tx_queues;
> > > +                       /** Port ID */
> > > +                       uint16_t port_id;
> > > +                       /** MAC entries */
> > > +                       char mac_addr[MACADDR_LEN];
> > > +                       uint8_t max_mac_entries;
> > > +                       bool dmac_filter_ena;
> > > +                       uint8_t dmac_filter_count;
> > > +                       uint16_t flags;
> > > +                       uint8_t ptype_disable;
> > > +                       bool scalar_ena;
> > > +                       bool ptp_ena;
> > > +                       /* Offload capabilities */
> > > +                       uint64_t rx_offload_capa;
> > > +                       uint64_t tx_offload_capa;
> > > +                       uint32_t speed_capa;
> > > +                       /* Configured offloads */
> > > +                       uint64_t rx_offloads;
> > > +                       uint64_t tx_offloads;
> > > +                       /* Platform specific offload flags */
> > > +                       uint16_t rx_offload_flags;
> > > +                       uint16_t tx_offload_flags;
> > > +                       /* ETHDEV RSS HF bitmask */
> > > +                       uint64_t ethdev_rss_hf;
> > 
> > + Ethdev, , mempool and telemetry maintainers
> > 
> > All of the above data except[1] is generic data that can be derived
> > from ethdev APIs or ethdev data from lib/ethdev itself,
> > IMO, We should avoid duplicating this in driver and make useful for
> > other driver/application by adding generic endpoint in ethdev.
> > Same comment for "[2/4] mempool/cnxk: add telemetry end points" for
> > mempool subsystem.
> > 
> > Thoughts from Maintainers?
> > 
> Not a maintainer of those libs, but +1 to making anything generic that can
> be, save reimplementing things multiple times in drivers.

I agree, I feel it would make more sense to have most of the job done in the
mempool library in generic. A new ops could be added to fill driver-specific
info.

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

* Re: [dpdk-dev] [v2] telemetry: fix json output buffer size
  2021-09-21 11:02             ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
@ 2021-09-22  9:21               ` Power, Ciara
  2021-09-23  5:53                 ` Gowrishankar Muthukrishnan
  2021-09-23  6:21               ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
  1 sibling, 1 reply; 121+ messages in thread
From: Power, Ciara @ 2021-09-22  9:21 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev; +Cc: Richardson, Bruce

Hi Gowrishankar,


>-----Original Message-----
>From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
>Sent: Tuesday 21 September 2021 12:03
>To: dev@dpdk.org
>Cc: Power, Ciara <ciara.power@intel.com>; Gowrishankar Muthukrishnan
><gmuthukrishn@marvell.com>
>Subject: [v2] telemetry: fix json output buffer size
>
>Fix json output buffer size for a single largest value.
>
>Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON")
>
>v2:
> - split from series 18768 ("cnxk: enable telemetry endpoints").
>
>Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
>---
> lib/telemetry/telemetry_json.h | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
>diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
>index ad270b9b30..ba2fde34cb 100644
>--- a/lib/telemetry/telemetry_json.h
>+++ b/lib/telemetry/telemetry_json.h
>@@ -9,6 +9,7 @@
> #include <stdarg.h>
> #include <stdio.h>
> #include <rte_common.h>
>+#include <rte_telemetry.h>
>
> /**
>  * @file
>@@ -23,13 +24,15 @@
>  * @internal
>  * Copies a value into a buffer if the buffer has enough available space.
>  * Nothing written to buffer if an overflow ocurs.
>- * This function is not for use for values larger than 1k.
>+ * Size of buffer is (single largest value - 6), where at least 6 chars
>+ * would have been used for creating json dict i.e '{"x": ... }'.
>+ * This function is not for use for values larger than this buffer size.
>  */
> __rte_format_printf(3, 4)
> static inline int
> __json_snprintf(char *buf, const int len, const char *format, ...)  {
>-	char tmp[1024];
>+	char tmp[RTE_TEL_MAX_SINGLE_STRING_LEN - 6];
> 	va_list ap;
> 	int ret;
>
>--
>2.25.1

I am not sure about why we would want this to allow for "RTE_TEL_MAX_SINGLE_STRING_LEN - 6".
The RTE_TEL_MAX_SINGLE_STRING_LEN is used to represent the max size of a singular string value e.g. the response to client being   {"<cmd>" : "<string value here up to max size in length>" }

I wonder could we use the "len" parameter in some way here, that would be the available space to be filled of the "buf" being passed in, allowing the function to copy in the maximum amount to fill the buffer.

Thanks,
Ciara

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

* Re: [dpdk-dev] [v2] telemetry: fix json output buffer size
  2021-09-22  9:21               ` Power, Ciara
@ 2021-09-23  5:53                 ` Gowrishankar Muthukrishnan
  2021-09-30  8:47                   ` Power, Ciara
  0 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-23  5:53 UTC (permalink / raw)
  To: Power, Ciara, dev; +Cc: Richardson, Bruce

Hi Ciara,
> I am not sure about why we would want this to allow for
> "RTE_TEL_MAX_SINGLE_STRING_LEN - 6".
> The RTE_TEL_MAX_SINGLE_STRING_LEN is used to represent the max size of a
> singular string value e.g. the response to client being   {"<cmd>" : "<string value
> here up to max size in length>" }
> 
> I wonder could we use the "len" parameter in some way here, that would be the
> available space to be filled of the "buf" being passed in, allowing the function to
> copy in the maximum amount to fill the buffer.

Got it. Yeah, "len" is actual available space. I ll send next version based on this.

Also, I propose if we can have platform defined upper limits (esp MAX_CMD_LEN,
MAX_SINGLE_STRING_LEN etc) so that, we need not revisit lib/telemetry for
platform needs (and I don't think one size fits all platform, may be excess too).
Thoughts ?

Thanks,
Gowrishankar

> 
> Thanks,
> Ciara

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

* [dpdk-dev] [v3] telemetry: fix json output buffer size
  2021-09-21 11:02             ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
  2021-09-22  9:21               ` Power, Ciara
@ 2021-09-23  6:21               ` Gowrishankar Muthukrishnan
  2021-09-23  6:26                 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
  1 sibling, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-23  6:21 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, ciara.power, jerinj, Gowrishankar Muthukrishnan

Fix json output buffer size for a single largest value.
Also fix compile assertion for the size of output buffer.

Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v3:
 - use "len" param as buffer size.

---
 lib/telemetry/telemetry_json.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index ad270b9b30..f02a12f5b0 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -9,6 +9,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <rte_common.h>
+#include <rte_telemetry.h>
 
 /**
  * @file
@@ -23,13 +24,13 @@
  * @internal
  * Copies a value into a buffer if the buffer has enough available space.
  * Nothing written to buffer if an overflow ocurs.
- * This function is not for use for values larger than 1k.
+ * This function is not for use for values larger than given buffer length.
  */
 __rte_format_printf(3, 4)
 static inline int
 __json_snprintf(char *buf, const int len, const char *format, ...)
 {
-	char tmp[1024];
+	char tmp[len];
 	va_list ap;
 	int ret;
 
-- 
2.25.1


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

* [dpdk-dev] [v4] telemetry: fix json output buffer size
  2021-09-23  6:21               ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
@ 2021-09-23  6:26                 ` Gowrishankar Muthukrishnan
  2021-09-29  4:18                   ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
  0 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-23  6:26 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, ciara.power, jerinj, Gowrishankar Muthukrishnan

Fix json output buffer size for a single largest value.

Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v4:
 - corrected typo in commit message.
v3:
 - use "len" param as buffer size.
---
 lib/telemetry/telemetry_json.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index ad270b9b30..f02a12f5b0 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -9,6 +9,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <rte_common.h>
+#include <rte_telemetry.h>
 
 /**
  * @file
@@ -23,13 +24,13 @@
  * @internal
  * Copies a value into a buffer if the buffer has enough available space.
  * Nothing written to buffer if an overflow ocurs.
- * This function is not for use for values larger than 1k.
+ * This function is not for use for values larger than given buffer length.
  */
 __rte_format_printf(3, 4)
 static inline int
 __json_snprintf(char *buf, const int len, const char *format, ...)
 {
-	char tmp[1024];
+	char tmp[len];
 	va_list ap;
 	int ret;
 
-- 
2.25.1


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

* [dpdk-dev] [v5] telemetry: fix json output buffer size
  2021-09-23  6:26                 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
@ 2021-09-29  4:18                   ` Gowrishankar Muthukrishnan
  2021-10-06 17:38                     ` Thomas Monjalon
  2021-10-11 10:54                     ` [dpdk-dev] [v6] telemetry: remove limitation on JSON output buffer length Gowrishankar Muthukrishnan
  0 siblings, 2 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  4:18 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, ciara.power, jerinj, Gowrishankar Muthukrishnan

Fix json output buffer size for an actual data length.

Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 lib/telemetry/telemetry_json.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index ad270b9b30..f02a12f5b0 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -9,6 +9,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <rte_common.h>
+#include <rte_telemetry.h>
 
 /**
  * @file
@@ -23,13 +24,13 @@
  * @internal
  * Copies a value into a buffer if the buffer has enough available space.
  * Nothing written to buffer if an overflow ocurs.
- * This function is not for use for values larger than 1k.
+ * This function is not for use for values larger than given buffer length.
  */
 __rte_format_printf(3, 4)
 static inline int
 __json_snprintf(char *buf, const int len, const char *format, ...)
 {
-	char tmp[1024];
+	char tmp[len];
 	va_list ap;
 	int ret;
 
-- 
2.25.1


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

* [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info
  2021-09-21 10:52           ` [dpdk-dev] [v8, 4/4] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
  2021-09-21 11:27             ` Jerin Jacob
@ 2021-09-29  4:25             ` Gowrishankar Muthukrishnan
  2021-10-11 14:40               ` Ferruh Yigit
  2021-10-14 21:47               ` Ferruh Yigit
  1 sibling, 2 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  4:25 UTC (permalink / raw)
  To: dev
  Cc: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, jerinj,
	Gowrishankar Muthukrishnan

Add telemetry endpoint /ethdev/info for device info.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Change-Id: I3e6ee2bd1a80675473adf0bd884b194f98e28536
---
 lib/ethdev/rte_ethdev.c | 92 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index daf5ca9242..9b7bfa5f63 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6242,6 +6242,96 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused,
 	return 0;
 }
 
+static int
+eth_dev_handle_port_info(const char *cmd __rte_unused,
+		const char *params,
+		struct rte_tel_data *d)
+{
+	struct rte_tel_data *rxq_state, *txq_state;
+	char mac_addr[RTE_ETHER_ADDR_LEN];
+	struct rte_eth_dev *eth_dev;
+	char *end_param;
+	int port_id, i;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	port_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		RTE_ETHDEV_LOG(NOTICE,
+			"Extra parameters passed to ethdev telemetry command, ignoring");
+
+	if (!rte_eth_dev_is_valid_port(port_id))
+		return -EINVAL;
+
+	eth_dev = &rte_eth_devices[port_id];
+	if (!eth_dev)
+		return -EINVAL;
+
+	rxq_state = rte_tel_data_alloc();
+	if (!rxq_state)
+		return -ENOMEM;
+
+	txq_state = rte_tel_data_alloc();
+	if (!txq_state)
+		return -ENOMEM;
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
+	rte_tel_data_add_dict_int(d, "state", eth_dev->state);
+	rte_tel_data_add_dict_int(d, "nb_rx_queues",
+			eth_dev->data->nb_rx_queues);
+	rte_tel_data_add_dict_int(d, "nb_tx_queues",
+			eth_dev->data->nb_tx_queues);
+	rte_tel_data_add_dict_int(d, "port_id", eth_dev->data->port_id);
+	rte_tel_data_add_dict_int(d, "mtu", eth_dev->data->mtu);
+	rte_tel_data_add_dict_int(d, "rx_mbuf_size_min",
+			eth_dev->data->min_rx_buf_size);
+	rte_tel_data_add_dict_int(d, "rx_mbuf_alloc_fail",
+			eth_dev->data->rx_mbuf_alloc_failed);
+	snprintf(mac_addr, RTE_ETHER_ADDR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x",
+			 eth_dev->data->mac_addrs->addr_bytes[0],
+			 eth_dev->data->mac_addrs->addr_bytes[1],
+			 eth_dev->data->mac_addrs->addr_bytes[2],
+			 eth_dev->data->mac_addrs->addr_bytes[3],
+			 eth_dev->data->mac_addrs->addr_bytes[4],
+			 eth_dev->data->mac_addrs->addr_bytes[5]);
+	rte_tel_data_add_dict_string(d, "mac_addr", mac_addr);
+	rte_tel_data_add_dict_int(d, "promiscuous",
+			eth_dev->data->promiscuous);
+	rte_tel_data_add_dict_int(d, "scattered_rx",
+			eth_dev->data->scattered_rx);
+	rte_tel_data_add_dict_int(d, "all_multicast",
+			eth_dev->data->all_multicast);
+	rte_tel_data_add_dict_int(d, "dev_started", eth_dev->data->dev_started);
+	rte_tel_data_add_dict_int(d, "lro", eth_dev->data->lro);
+	rte_tel_data_add_dict_int(d, "dev_configured",
+			eth_dev->data->dev_configured);
+
+	rte_tel_data_start_array(rxq_state, RTE_TEL_INT_VAL);
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
+		rte_tel_data_add_array_int(rxq_state,
+				eth_dev->data->rx_queue_state[i]);
+
+	rte_tel_data_start_array(txq_state, RTE_TEL_INT_VAL);
+	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
+		rte_tel_data_add_array_int(txq_state,
+				eth_dev->data->tx_queue_state[i]);
+
+	rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0);
+	rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0);
+	rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node);
+	rte_tel_data_add_dict_int(d, "dev_flags", eth_dev->data->dev_flags);
+	rte_tel_data_add_dict_int(d, "rx_offloads",
+			eth_dev->data->dev_conf.rxmode.offloads);
+	rte_tel_data_add_dict_int(d, "tx_offloads",
+			eth_dev->data->dev_conf.txmode.offloads);
+	rte_tel_data_add_dict_int(d, "ethdev_rss_hf",
+			eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
+
+	return 0;
+}
+
 int
 rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
 				  struct rte_hairpin_peer_info *cur_info,
@@ -6323,4 +6413,6 @@ RTE_INIT(ethdev_init_telemetry)
 	rte_telemetry_register_cmd("/ethdev/link_status",
 			eth_dev_handle_port_link_status,
 			"Returns the link status for a port. Parameters: int port_id");
+	rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info,
+			"Returns the device info for a port. Parameters: int port_id");
 }
-- 
2.25.1


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

* [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info
  2021-09-21 10:52           ` [dpdk-dev] [v8, 2/4] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
@ 2021-09-29  6:40             ` Gowrishankar Muthukrishnan
  2021-10-13 15:21               ` Thomas Monjalon
                                 ` (3 more replies)
  0 siblings, 4 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  6:40 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, Andrew Rybchenko, jerinj, Gowrishankar Muthukrishnan

Add telemetry endpoint for mempool info.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 lib/mempool/rte_mempool.c | 84 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index 59a588425b..b8dad2997a 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -31,6 +31,7 @@
 #include <rte_spinlock.h>
 #include <rte_tailq.h>
 #include <rte_eal_paging.h>
+#include <rte_telemetry.h>
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
@@ -1343,3 +1344,86 @@ void rte_mempool_walk(void (*func)(struct rte_mempool *, void *),
 
 	rte_mcfg_mempool_read_unlock();
 }
+
+static void
+mempool_list_cb(struct rte_mempool *mp, void *arg)
+{
+	struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+	rte_tel_data_add_array_string(d, mp->name);
+}
+
+static int
+mempool_handle_list(const char *cmd __rte_unused,
+	const char *params __rte_unused, struct rte_tel_data *d)
+{
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+	rte_mempool_walk(mempool_list_cb, d);
+	return 0;
+}
+
+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;
+	const struct rte_memzone *mz;
+
+	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+		return;
+
+	rte_tel_data_add_dict_string(info->d, "name", mp->name);
+	rte_tel_data_add_dict_int(info->d, "pool_id", mp->pool_id);
+	rte_tel_data_add_dict_int(info->d, "flags", mp->flags);
+	rte_tel_data_add_dict_int(info->d, "socket_id", mp->socket_id);
+	rte_tel_data_add_dict_int(info->d, "size", mp->size);
+	rte_tel_data_add_dict_int(info->d, "cache_size", mp->cache_size);
+	rte_tel_data_add_dict_int(info->d, "elt_size", mp->elt_size);
+	rte_tel_data_add_dict_int(info->d, "header_size", mp->header_size);
+	rte_tel_data_add_dict_int(info->d, "trailer_size", mp->trailer_size);
+	rte_tel_data_add_dict_int(info->d, "private_data_size",
+			mp->private_data_size);
+	rte_tel_data_add_dict_int(info->d, "ops_index", mp->ops_index);
+	rte_tel_data_add_dict_int(info->d, "populated_size",
+			mp->populated_size);
+
+	mz = mp->mz;
+	rte_tel_data_add_dict_string(info->d, "mz_name", mz->name);
+	rte_tel_data_add_dict_int(info->d, "mz_len", mz->len);
+	rte_tel_data_add_dict_int(info->d, "mz_hugepage_sz",
+							  mz->hugepage_sz);
+	rte_tel_data_add_dict_int(info->d, "mz_socket_id", mz->socket_id);
+	rte_tel_data_add_dict_int(info->d, "mz_flags", mz->flags);
+}
+
+static int
+mempool_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(mempool_init_telemetry)
+{
+	rte_telemetry_register_cmd("/mempool/list", mempool_handle_list,
+		"Returns list of available mempool. Takes no parameters");
+	rte_telemetry_register_cmd("/mempool/info", mempool_handle_info,
+		"Returns mempool info. Parameters: pool_name");
+}
-- 
2.25.1


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

* [dpdk-dev] [v1] cryptodev: add telemetry endpoint for cryptodev info
  2021-09-21 11:32             ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
@ 2021-09-29  6:45               ` Gowrishankar Muthukrishnan
  2021-10-22 12:28                 ` [dpdk-dev] [v2] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
                                   ` (2 more replies)
  2021-09-29  7:01               ` [dpdk-dev] [v3] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
  1 sibling, 3 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  6:45 UTC (permalink / raw)
  To: dev; +Cc: Akhil Goyal, Declan Doherty, jerinj, Gowrishankar Muthukrishnan

Add telemetry endpoint for cryptodev info.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-18355 ("cryptodev: add telemetry callbacks")
Depends-on: patch-19247 ("telemetry: fix json output buffer size")
---
 lib/cryptodev/rte_cryptodev.c | 68 +++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 0823137465..365cf3ccc1 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -2481,6 +2481,72 @@ cryptodev_handle_dev_stats(const char *cmd __rte_unused,
 	return 0;
 }
 
+#define CRYPTO_CAPS_SZ                                                         \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities),             \
+			sizeof(uint64_t)) /                                    \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  const struct rte_cryptodev_capabilities *capabilities)
+{
+	const struct rte_cryptodev_capabilities *dev_caps;
+	union caps_u {
+		struct rte_cryptodev_capabilities dev_caps;
+		uint64_t val[CRYPTO_CAPS_SZ];
+	} caps;
+	unsigned int i = 0, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->op !=
+	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+cryptodev_handle_info(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+	struct rte_cryptodev_info dev_info;
+	struct rte_tel_data *crypto_caps;
+	struct rte_cryptodev *dev;
+	int crypto_caps_n;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	rte_strlcpy(name, params, RTE_CRYPTODEV_NAME_LEN);
+	dev = rte_cryptodev_pmd_get_named_dev(name);
+	if (!dev)
+		return -EINVAL;
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_int(d, "dev_id", dev->data->dev_id);
+	rte_tel_data_add_dict_int(d, "socket_id", dev->data->socket_id);
+	rte_tel_data_add_dict_int(d, "dev_started", dev->data->dev_started);
+
+	/* Crypto capabilities */
+	crypto_caps = rte_tel_data_alloc();
+	if (!crypto_caps)
+		return -ENOMEM;
+
+	rte_cryptodev_info_get(dev->data->dev_id, &dev_info);
+	crypto_caps_n = crypto_caps_array(crypto_caps, dev_info.capabilities);
+	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
+
+	return 0;
+}
+
 RTE_INIT(cryptodev_init_telemetry)
 {
 	rte_telemetry_register_cmd("/cryptodev/list", cryptodev_handle_dev_list,
@@ -2488,4 +2554,6 @@ RTE_INIT(cryptodev_init_telemetry)
 	rte_telemetry_register_cmd("/cryptodev/stats",
 			cryptodev_handle_dev_stats,
 			"Returns the stats for a cryptodev. Parameters: int dev_id");
+	rte_telemetry_register_cmd("/cryptodev/info", cryptodev_handle_info,
+		"Returns cryptodev info. Parameters: pci id");
 }
-- 
2.25.1


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

* [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints
  2021-09-21 10:52         ` [dpdk-dev] [v8, 0/4] cnxk: enable telemetry endpoints for mempool and ethdev Gowrishankar Muthukrishnan
                             ` (3 preceding siblings ...)
  2021-09-21 10:52           ` [dpdk-dev] [v8, 4/4] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
@ 2021-09-29  6:54           ` Gowrishankar Muthukrishnan
  2021-09-29  6:55             ` [dpdk-dev] [v9 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
                               ` (5 more replies)
  4 siblings, 6 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  6:54 UTC (permalink / raw)
  To: dev
  Cc: jerinj, kirankumark, ndabilpuram, skori, skoteshwar, asekhar,
	pbhagavatula, Gowrishankar Muthukrishnan

This patch series enables telemetry in cnxk for the following:
 - NPA LF
 - NIX LF
 - Mempool driver
 - Ethdev driver

Depends-on: series-18612 ("net/cnxk: support for inline ipsec")
Depends-on: patch-19248 ("ethdev: add telemetry endpoint for device info")
Depends-on: patch-19251 ("mempool: add telemetry endpoint for mempool info")

v9:
 - moved common info from drivers to lib endpoints.
 
Gowrishankar Muthukrishnan (4):
  common/cnxk: add telemetry endpoints to npa
  common/cnxk: add telemetry endpoints to nix
  mempool/cnxk: add telemetry endpoints mempool
  net/cnxk: add telemetry endpoints to ethdev

 drivers/common/cnxk/cnxk_telemetry.h          |  26 +
 drivers/common/cnxk/cnxk_telemetry_nix.c      | 849 ++++++++++++++++++
 drivers/common/cnxk/cnxk_telemetry_npa.c      | 224 +++++
 drivers/common/cnxk/meson.build               |   7 +-
 drivers/common/cnxk/roc_nix.c                 |   3 +
 drivers/common/cnxk/roc_nix_priv.h            |   9 +
 drivers/common/cnxk/roc_nix_queue.c           |  15 +-
 drivers/common/cnxk/roc_platform.h            |  15 +
 drivers/mempool/cnxk/cnxk_mempool_telemetry.c |  57 ++
 drivers/mempool/cnxk/meson.build              |   1 +
 drivers/net/cnxk/cnxk_ethdev_telemetry.c      |  93 ++
 drivers/net/cnxk/meson.build                  |   1 +
 12 files changed, 1295 insertions(+), 5 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
 create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c
 create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c

-- 
2.25.1


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

* [dpdk-dev] [v9 1/4] common/cnxk: add telemetry endpoints to npa
  2021-09-29  6:54           ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
@ 2021-09-29  6:55             ` Gowrishankar Muthukrishnan
  2021-10-14 15:22               ` [dpdk-dev] [EXT] " Harman Kalra
  2021-09-29  6:55             ` [dpdk-dev] [v9 2/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
                               ` (4 subsequent siblings)
  5 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  6:55 UTC (permalink / raw)
  To: dev
  Cc: jerinj, kirankumark, ndabilpuram, skori, skoteshwar, asekhar,
	pbhagavatula, Gowrishankar Muthukrishnan

Add telemetry endpoints to npa.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 224 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   6 +-
 drivers/common/cnxk/roc_platform.h       |  12 ++
 4 files changed, 266 insertions(+), 2 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

diff --git a/drivers/common/cnxk/cnxk_telemetry.h b/drivers/common/cnxk/cnxk_telemetry.h
new file mode 100644
index 0000000000..1461fd893f
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Marvell.
+ */
+
+#ifndef __CNXK_TELEMETRY_H_
+#define __CNXK_TELEMETRY_H_
+
+#define CNXK_TEL_STR(s)		  #s
+#define CNXK_TEL_STR_PREFIX(s, p) CNXK_TEL_STR(p##s)
+#define CNXK_TEL_DICT_INT(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_int(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_PTR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(p)->s)
+#define CNXK_TEL_DICT_BF_PTR(d, p, s, ...)                                     \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(uint64_t)(p)->s)
+#define CNXK_TEL_DICT_U64(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_u64(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_STR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_string(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),   \
+				     (p)->s)
+
+#endif /* __CNXK_TELEMETRY_H_ */
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
new file mode 100644
index 0000000000..37c5f2e961
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -0,0 +1,224 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+static int
+cnxk_tel_npa(struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int aura_cnt = 0;
+	uint32_t i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	for (i = 0; i < lf->nr_pools; i++) {
+		if (plt_bitmap_get(lf->npa_bmp, i))
+			continue;
+		aura_cnt++;
+	}
+
+	plt_tel_data_add_dict_ptr(d, "npa", lf);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
+
+	CNXK_TEL_DICT_PTR(d, lf, pci_dev);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
+	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
+	CNXK_TEL_DICT_PTR(d, lf, intr_handle);
+	CNXK_TEL_DICT_PTR(d, lf, mbox);
+	CNXK_TEL_DICT_PTR(d, lf, base);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
+	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
+	CNXK_TEL_DICT_INT(d, lf, nr_pools);
+	CNXK_TEL_DICT_INT(d, lf, pf_func);
+	CNXK_TEL_DICT_INT(d, lf, aura_sz);
+	CNXK_TEL_DICT_INT(d, lf, qints);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
+{
+	__io struct npa_aura_s *aura;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (plt_bitmap_get(lf->npa_bmp, aura_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_AURA;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", aura_id);
+		return rc;
+	}
+
+	aura = &rsp->aura;
+	CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
+	CNXK_TEL_DICT_INT(d, aura, ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
+	CNXK_TEL_DICT_U64(d, aura, count, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
+	CNXK_TEL_DICT_U64(d, aura, limit, w3_);
+	CNXK_TEL_DICT_INT(d, aura, bp, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
+	CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
+	CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
+{
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (plt_bitmap_get(lf->npa_bmp, pool_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = pool_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", pool_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
+	CNXK_TEL_DICT_INT(d, pool, ena, w1_);
+	CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
+	CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
+	CNXK_TEL_DICT_INT(d, pool, shift, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
+	CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
+	CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
+	CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info(const char *cmd __plt_unused,
+			 const char *params __plt_unused,
+			 struct plt_tel_data *d)
+{
+	plt_tel_data_start_dict(d);
+	return cnxk_tel_npa(d);
+}
+
+static int
+cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
+			   struct plt_tel_data *d)
+{
+	int id, rc;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	id = atoi(params);
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "aura/info"))
+		rc = cnxk_tel_npa_aura(id, d);
+	else
+		rc = cnxk_tel_npa_pool(id, d);
+
+	return rc;
+}
+
+PLT_INIT(cnxk_telemetry_npa_init)
+{
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
+		"Returns npa information. Takes no parameters");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa aura information. Parameters: aura_id");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa pool information. Parameters: pool_id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index cd19ad29c1..f0a1c9f115 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -64,5 +64,7 @@ sources = files(
 # Security common code
 sources += files('cnxk_security.c')
 
-includes += include_directories('../../bus/pci')
-includes += include_directories('../../../lib/net')
+# Telemetry common code
+sources += files('cnxk_telemetry_npa.c')
+
+deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 241655b334..57073d62aa 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -19,6 +19,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "roc_bits.h"
 
@@ -51,6 +52,7 @@
 #define PLT_CACHE_LINE_SIZE      RTE_CACHE_LINE_SIZE
 #define BITMASK_ULL		 GENMASK_ULL
 #define PLT_ALIGN_CEIL		 RTE_ALIGN_CEIL
+#define PLT_INIT		 RTE_INIT
 
 /** Divide ceil */
 #define PLT_DIV_CEIL(x, y)			\
@@ -63,6 +65,7 @@
 #define __plt_cache_aligned __rte_cache_aligned
 #define __plt_always_inline __rte_always_inline
 #define __plt_packed	    __rte_packed
+#define __plt_unused	    __rte_unused
 #define __roc_api	    __rte_internal
 #define plt_iova_t	    rte_iova_t
 
@@ -142,6 +145,15 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_dict      rte_tel_data_start_dict
+#define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
+#define plt_tel_data_add_dict_ptr(d, n, v)			\
+	rte_tel_data_add_dict_u64(d, n, (uint64_t)v)
+#define plt_tel_data_add_dict_string rte_tel_data_add_dict_string
+#define plt_tel_data_add_dict_u64    rte_tel_data_add_dict_u64
+#define plt_telemetry_register_cmd   rte_telemetry_register_cmd
+
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
-- 
2.25.1


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

* [dpdk-dev] [v9 2/4] common/cnxk: add telemetry endpoints to nix
  2021-09-29  6:54           ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  2021-09-29  6:55             ` [dpdk-dev] [v9 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-09-29  6:55             ` Gowrishankar Muthukrishnan
  2021-10-14 16:37               ` [dpdk-dev] [EXT] " Harman Kalra
  2021-09-29  6:55             ` [dpdk-dev] [v9 3/4] mempool/cnxk: add telemetry endpoints mempool Gowrishankar Muthukrishnan
                               ` (3 subsequent siblings)
  5 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  6:55 UTC (permalink / raw)
  To: dev
  Cc: jerinj, kirankumark, ndabilpuram, skori, skoteshwar, asekhar,
	pbhagavatula, Gowrishankar Muthukrishnan

Add telemetry endpoints to nix.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry_nix.c | 849 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   3 +-
 drivers/common/cnxk/roc_nix.c            |   3 +
 drivers/common/cnxk/roc_nix_priv.h       |   9 +
 drivers/common/cnxk/roc_nix_queue.c      |  15 +-
 drivers/common/cnxk/roc_platform.h       |   3 +
 6 files changed, 878 insertions(+), 4 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c

diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c b/drivers/common/cnxk/cnxk_telemetry_nix.c
new file mode 100644
index 0000000000..1175f68a51
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_nix.c
@@ -0,0 +1,849 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+struct nix_tel_node {
+	TAILQ_ENTRY(nix_tel_node) node;
+	struct roc_nix *nix;
+	uint16_t n_rq;
+	uint16_t n_cq;
+	uint16_t n_sq;
+	struct roc_nix_rq **rqs;
+	struct roc_nix_cq **cqs;
+	struct roc_nix_sq **sqs;
+};
+
+TAILQ_HEAD(nix_tel_node_list, nix_tel_node);
+static struct nix_tel_node_list nix_list;
+
+static struct nix_tel_node *
+nix_tel_node_get(struct roc_nix *roc_nix)
+{
+	struct nix_tel_node *node, *roc_node = NULL;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (node->nix == roc_nix) {
+			roc_node = node;
+			break;
+		}
+	}
+
+	return roc_node;
+}
+
+int
+nix_tel_node_add(struct roc_nix *roc_nix)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(roc_nix);
+	if (node) {
+		if (nix->nb_rx_queues == node->n_rq &&
+		    nix->nb_tx_queues == node->n_sq)
+			return 0;
+
+		nix_tel_node_del(roc_nix);
+	}
+
+	node = plt_zmalloc(sizeof(struct nix_tel_node), 0);
+	if (!node)
+		return -1;
+
+	node->nix = roc_nix;
+	node->rqs =
+		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_rq *), 0);
+	node->cqs =
+		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_cq *), 0);
+	node->sqs =
+		plt_zmalloc(nix->nb_tx_queues * sizeof(struct roc_nix_sq *), 0);
+	TAILQ_INSERT_TAIL(&nix_list, node, node);
+
+	return 0;
+}
+
+void
+nix_tel_node_del(struct roc_nix *roc_nix)
+{
+	struct nix_tel_node *node;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (node->nix == roc_nix) {
+			plt_free(node->rqs);
+			plt_free(node->cqs);
+			plt_free(node->sqs);
+			TAILQ_REMOVE(&nix_list, node, node);
+		}
+	}
+
+	plt_free(node);
+}
+
+static struct nix_tel_node *
+nix_tel_node_get_by_pcidev_name(const char *name)
+{
+	struct nix_tel_node *node, *roc_node = NULL;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (!strncmp(node->nix->pci_dev->name, name,
+			     PCI_PRI_STR_SIZE)) {
+			roc_node = node;
+			break;
+		}
+	}
+
+	return roc_node;
+}
+
+int
+nix_tel_node_add_rq(struct roc_nix_rq *rq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(rq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->rqs[rq->qid] = rq;
+	node->n_rq++;
+	return 0;
+}
+
+int
+nix_tel_node_add_cq(struct roc_nix_cq *cq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(cq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->cqs[cq->qid] = cq;
+	node->n_cq++;
+	return 0;
+}
+
+int
+nix_tel_node_add_sq(struct roc_nix_sq *sq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(sq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->sqs[sq->qid] = sq;
+	node->n_sq++;
+	return 0;
+}
+
+static int
+cnxk_tel_nix(struct roc_nix *roc_nix, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+
+	struct dev *dev = &nix->dev;
+
+	plt_tel_data_add_dict_ptr(d, "nix", nix);
+	plt_tel_data_add_dict_int(d, "pf_func", dev->pf_func);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(dev->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(dev->pf_func));
+
+	CNXK_TEL_DICT_PTR(d, dev, bar2);
+	CNXK_TEL_DICT_PTR(d, dev, bar4);
+	CNXK_TEL_DICT_INT(d, roc_nix, port_id);
+	CNXK_TEL_DICT_INT(d, roc_nix, rss_tag_as_xor);
+	CNXK_TEL_DICT_INT(d, roc_nix, max_sqb_count);
+	CNXK_TEL_DICT_PTR(d, nix, pci_dev);
+	CNXK_TEL_DICT_PTR(d, nix, base);
+	CNXK_TEL_DICT_PTR(d, nix, lmt_base);
+	CNXK_TEL_DICT_INT(d, nix, reta_sz);
+	CNXK_TEL_DICT_INT(d, nix, tx_chan_base);
+	CNXK_TEL_DICT_INT(d, nix, rx_chan_base);
+	CNXK_TEL_DICT_INT(d, nix, nb_tx_queues);
+	CNXK_TEL_DICT_INT(d, nix, nb_rx_queues);
+	CNXK_TEL_DICT_INT(d, nix, lso_tsov6_idx);
+	CNXK_TEL_DICT_INT(d, nix, lso_tsov4_idx);
+
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v4",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v6",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v4",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v6",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v4v4",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v4v6",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v6v4",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v6v6",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+
+	CNXK_TEL_DICT_INT(d, nix, lf_tx_stats);
+	CNXK_TEL_DICT_INT(d, nix, lf_rx_stats);
+	CNXK_TEL_DICT_INT(d, nix, cgx_links);
+	CNXK_TEL_DICT_INT(d, nix, lbk_links);
+	CNXK_TEL_DICT_INT(d, nix, sdp_links);
+	CNXK_TEL_DICT_INT(d, nix, tx_link);
+	CNXK_TEL_DICT_INT(d, nix, sqb_size);
+	CNXK_TEL_DICT_INT(d, nix, msixoff);
+	CNXK_TEL_DICT_INT(d, nix, cints);
+	CNXK_TEL_DICT_INT(d, nix, qints);
+	CNXK_TEL_DICT_INT(d, nix, sdp_link);
+	CNXK_TEL_DICT_INT(d, nix, ptp_en);
+	CNXK_TEL_DICT_INT(d, nix, rss_alg_idx);
+	CNXK_TEL_DICT_INT(d, nix, tx_pause);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_rq(struct roc_nix_rq *rq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_rq", rq);
+	CNXK_TEL_DICT_INT(d, rq, qid);
+	CNXK_TEL_DICT_PTR(d, rq, aura_handle);
+	CNXK_TEL_DICT_INT(d, rq, ipsech_ena);
+	CNXK_TEL_DICT_INT(d, rq, first_skip);
+	CNXK_TEL_DICT_INT(d, rq, later_skip);
+	CNXK_TEL_DICT_INT(d, rq, lpb_size);
+	CNXK_TEL_DICT_INT(d, rq, sso_ena);
+	CNXK_TEL_DICT_INT(d, rq, tag_mask);
+	CNXK_TEL_DICT_INT(d, rq, flow_tag_width);
+	CNXK_TEL_DICT_INT(d, rq, tt);
+	CNXK_TEL_DICT_INT(d, rq, hwgrp);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_ena);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_first_skip);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_max_sz_exp);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_wait_tmo);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_aura_handle);
+	CNXK_TEL_DICT_PTR(d, rq, roc_nix);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_cq(struct roc_nix_cq *cq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_cq", cq);
+	CNXK_TEL_DICT_INT(d, cq, qid);
+	CNXK_TEL_DICT_INT(d, cq, nb_desc);
+	CNXK_TEL_DICT_PTR(d, cq, roc_nix);
+	CNXK_TEL_DICT_PTR(d, cq, door);
+	CNXK_TEL_DICT_PTR(d, cq, status);
+	CNXK_TEL_DICT_PTR(d, cq, wdata);
+	CNXK_TEL_DICT_PTR(d, cq, desc_base);
+	CNXK_TEL_DICT_INT(d, cq, qmask);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_sq(struct roc_nix_sq *sq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_sq", sq);
+	CNXK_TEL_DICT_INT(d, sq, qid);
+	CNXK_TEL_DICT_INT(d, sq, max_sqe_sz);
+	CNXK_TEL_DICT_INT(d, sq, nb_desc);
+	CNXK_TEL_DICT_INT(d, sq, sqes_per_sqb_log2);
+	CNXK_TEL_DICT_PTR(d, sq, roc_nix);
+	CNXK_TEL_DICT_PTR(d, sq, aura_handle);
+	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs_adj);
+	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs);
+	CNXK_TEL_DICT_PTR(d, sq, io_addr);
+	CNXK_TEL_DICT_PTR(d, sq, lmt_addr);
+	CNXK_TEL_DICT_PTR(d, sq, sqe_mem);
+	CNXK_TEL_DICT_PTR(d, sq, fc);
+
+	return 0;
+}
+
+static void
+nix_rq_ctx_cn9k(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_rq_ctx_s *ctx = (struct nix_rq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
+	CNXK_TEL_DICT_BF_PTR(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_);
+}
+
+static void
+nix_rq_ctx(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_cn10k_rq_ctx_s *ctx = (struct nix_cn10k_rq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_ol3_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_ol4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_il3_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_il4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, csum_ol4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, lenerr_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0);
+	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, chi_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsecd_drop_en, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_stashing, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, policer_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, band_prof_id, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_INT(d, ctx, vwqe_skip, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, max_vsize_exp, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, vtime_wait, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, vwqe_ena, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsec_vwqe, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_);
+}
+
+static int
+cnxk_tel_nix_rq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile void *qctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_RQ, n, &qctx);
+	if (rc) {
+		plt_err("Failed to get rq context");
+		return rc;
+	}
+
+	if (roc_model_is_cn9k())
+		nix_rq_ctx_cn9k(&qctx, d);
+	else
+		nix_rq_ctx(&qctx, d);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_cq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile struct nix_cq_ctx_s *ctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_CQ, n, (void *)&ctx);
+	if (rc) {
+		plt_err("Failed to get cq context");
+		return rc;
+	}
+
+	/* W0 */
+	CNXK_TEL_DICT_PTR(d, ctx, base, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_U64(d, ctx, wrptr, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cint_idx, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_err, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, bpid, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, bp_ena, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, update_time, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, avg_level, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, head, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, tail, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, cq_err_int_ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_err_int, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, qsize, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, caching, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, drop_ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, bp, w3_);
+
+	return 0;
+}
+
+static void
+nix_sq_ctx_cn9k(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_sq_ctx_s *ctx = (struct nix_sq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_quantum, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
+
+	/* W11 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
+
+	/* W12 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
+
+	/* W14 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
+
+	/* W15 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_);
+}
+
+static void
+nix_sq_ctx(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_cn10k_sq_ctx_s *ctx = (struct nix_cn10k_sq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_weight, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_ub, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_lb, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
+
+	/* W11 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
+
+	/* W12 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
+
+	/* W14 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
+
+	/* W15 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_);
+}
+
+static int
+cnxk_tel_nix_sq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile void *qctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_SQ, n, &qctx);
+	if (rc) {
+		plt_err("Failed to get rq context");
+		return rc;
+	}
+
+	if (roc_model_is_cn9k())
+		nix_sq_ctx_cn9k(&qctx, d);
+	else
+		nix_sq_ctx(&qctx, d);
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_list(const char *cmd __plt_unused,
+			 const char *params __plt_unused,
+			 struct plt_tel_data *d)
+{
+	struct nix_tel_node *node;
+	struct roc_nix *roc_nix;
+
+	plt_tel_data_start_array(d, PLT_TEL_STRING_VAL);
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		roc_nix = node->nix;
+		plt_tel_data_add_array_string(d, roc_nix->pci_dev->name);
+	}
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_info(const char *cmd __plt_unused, const char *params,
+			 struct plt_tel_data *d)
+{
+	char name[PCI_PRI_STR_SIZE];
+	struct nix_tel_node *node;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	plt_strlcpy(name, params, PCI_PRI_STR_SIZE);
+
+	node = nix_tel_node_get_by_pcidev_name(name);
+	if (!node)
+		return -1;
+
+	plt_tel_data_start_dict(d);
+	return cnxk_tel_nix(node->nix, d);
+}
+
+static int
+cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
+			   struct plt_tel_data *d)
+{
+	struct nix_tel_node *node;
+	char *name, *param;
+	char buf[1024];
+	int rc = -1;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		goto exit;
+
+	plt_strlcpy(buf, params, PCI_PRI_STR_SIZE + 1);
+	name = strtok(buf, ",");
+	param = strtok(NULL, "\0");
+
+	node = nix_tel_node_get_by_pcidev_name(name);
+	if (!node)
+		goto exit;
+
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "rq")) {
+		char *tok = strtok(param, ",");
+		int rq;
+
+		if (!tok)
+			goto exit;
+
+		rq = strtol(tok, NULL, 10);
+		if ((node->n_rq <= rq) || (rq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_rq_ctx(node->nix, rq, d);
+		else
+			rc = cnxk_tel_nix_rq(node->rqs[rq], d);
+
+	} else if (strstr(cmd, "cq")) {
+		char *tok = strtok(param, ",");
+		int cq;
+
+		if (!tok)
+			goto exit;
+
+		cq = strtol(tok, NULL, 10);
+		if ((node->n_cq <= cq) || (cq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_cq_ctx(node->nix, cq, d);
+		else
+			rc = cnxk_tel_nix_cq(node->cqs[cq], d);
+
+	} else if (strstr(cmd, "sq")) {
+		char *tok = strtok(param, ",");
+		int sq;
+
+		if (!tok)
+			goto exit;
+
+		sq = strtol(tok, NULL, 10);
+		if ((node->n_sq <= sq) || (sq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_sq_ctx(node->nix, sq, d);
+		else
+			rc = cnxk_tel_nix_sq(node->sqs[sq], d);
+	}
+
+exit:
+	return rc;
+}
+
+PLT_INIT(cnxk_telemetry_nix_init)
+{
+	TAILQ_INIT(&nix_list);
+
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/list", cnxk_nix_tel_handle_list,
+		"Returns list of available NIX devices. Takes no parameters");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/info", cnxk_nix_tel_handle_info,
+		"Returns nix information. Parameters: pci id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/rq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix rq information. Parameters: pci id, rq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/rq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix rq context. Parameters: pci id, rq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/cq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix cq information. Parameters: pci id, cq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/cq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix cq context. Parameters: pci id, cq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/sq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix sq information. Parameters: pci id, sq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/sq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix sq context. Parameters: pci id, sq id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index f0a1c9f115..fe7a95b526 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -65,6 +65,7 @@ sources = files(
 sources += files('cnxk_security.c')
 
 # Telemetry common code
-sources += files('cnxk_telemetry_npa.c')
+sources += files('cnxk_telemetry_npa.c',
+                 'cnxk_telemetry_nix.c')
 
 deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_nix.c b/drivers/common/cnxk/roc_nix.c
index 3ab954e94d..17beb1a736 100644
--- a/drivers/common/cnxk/roc_nix.c
+++ b/drivers/common/cnxk/roc_nix.c
@@ -178,6 +178,8 @@ roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq, uint32_t nb_txq,
 	nix->sqs = plt_zmalloc(sizeof(struct roc_nix_sq *) * nb_txq, 0);
 	if (!nix->sqs)
 		return -ENOMEM;
+
+	nix_tel_node_add(roc_nix);
 fail:
 	return rc;
 }
@@ -413,6 +415,7 @@ roc_nix_dev_init(struct roc_nix *roc_nix)
 dev_fini:
 	rc |= dev_fini(dev, pci_dev);
 fail:
+	nix_tel_node_del(roc_nix);
 	return rc;
 }
 
diff --git a/drivers/common/cnxk/roc_nix_priv.h b/drivers/common/cnxk/roc_nix_priv.h
index 2cd5a72347..ba639791ce 100644
--- a/drivers/common/cnxk/roc_nix_priv.h
+++ b/drivers/common/cnxk/roc_nix_priv.h
@@ -424,4 +424,13 @@ int nix_lf_int_reg_dump(uintptr_t nix_lf_base, uint64_t *data, uint16_t qints,
 int nix_q_ctx_get(struct dev *dev, uint8_t ctype, uint16_t qid,
 		  __io void **ctx_p);
 
+/*
+ * Telemetry
+ */
+int nix_tel_node_add(struct roc_nix *roc_nix);
+void nix_tel_node_del(struct roc_nix *roc_nix);
+int nix_tel_node_add_rq(struct roc_nix_rq *rq);
+int nix_tel_node_add_cq(struct roc_nix_cq *cq);
+int nix_tel_node_add_sq(struct roc_nix_sq *sq);
+
 #endif /* _ROC_NIX_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_nix_queue.c b/drivers/common/cnxk/roc_nix_queue.c
index 8fbb13ecbd..f546fc83c5 100644
--- a/drivers/common/cnxk/roc_nix_queue.c
+++ b/drivers/common/cnxk/roc_nix_queue.c
@@ -387,7 +387,11 @@ roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
 	if (rc)
 		return rc;
 
-	return mbox_process(mbox);
+	rc = mbox_process(mbox);
+	if (rc)
+		return rc;
+
+	return nix_tel_node_add_rq(rq);
 }
 
 int
@@ -415,7 +419,11 @@ roc_nix_rq_modify(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
 	if (rc)
 		return rc;
 
-	return mbox_process(mbox);
+	rc = mbox_process(mbox);
+	if (rc)
+		return rc;
+
+	return nix_tel_node_add_rq(rq);
 }
 
 int
@@ -504,7 +512,7 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq)
 	if (rc)
 		goto free_mem;
 
-	return 0;
+	return nix_tel_node_add_cq(cq);
 
 free_mem:
 	plt_free(cq->desc_base);
@@ -884,6 +892,7 @@ roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq)
 					((qid & RVU_CN9K_LMT_SLOT_MASK) << 12));
 	}
 
+	rc = nix_tel_node_add_sq(sq);
 	return rc;
 nomem:
 	plt_free(sq->fc);
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 57073d62aa..b95af115f7 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -145,7 +145,10 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define PLT_TEL_STRING_VAL RTE_TEL_STRING_VAL
 #define plt_tel_data		     rte_tel_data
+#define plt_tel_data_start_array     rte_tel_data_start_array
+#define plt_tel_data_add_array_string rte_tel_data_add_array_string
 #define plt_tel_data_start_dict      rte_tel_data_start_dict
 #define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
 #define plt_tel_data_add_dict_ptr(d, n, v)			\
-- 
2.25.1


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

* [dpdk-dev] [v9 3/4] mempool/cnxk: add telemetry endpoints mempool
  2021-09-29  6:54           ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  2021-09-29  6:55             ` [dpdk-dev] [v9 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
  2021-09-29  6:55             ` [dpdk-dev] [v9 2/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
@ 2021-09-29  6:55             ` Gowrishankar Muthukrishnan
  2021-10-14 16:43               ` [dpdk-dev] [EXT] " Harman Kalra
  2021-09-29  6:55             ` [dpdk-dev] [v9 4/4] net/cnxk: add telemetry endpoints to ethdev Gowrishankar Muthukrishnan
                               ` (2 subsequent siblings)
  5 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  6:55 UTC (permalink / raw)
  To: dev
  Cc: jerinj, kirankumark, ndabilpuram, skori, skoteshwar, asekhar,
	pbhagavatula, Gowrishankar Muthukrishnan

Adding telemetry endpoints to cnxk mempool driver.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@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

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',
 )
-- 
2.25.1


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

* [dpdk-dev] [v9 4/4] net/cnxk: add telemetry endpoints to ethdev
  2021-09-29  6:54           ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
                               ` (2 preceding siblings ...)
  2021-09-29  6:55             ` [dpdk-dev] [v9 3/4] mempool/cnxk: add telemetry endpoints mempool Gowrishankar Muthukrishnan
@ 2021-09-29  6:55             ` Gowrishankar Muthukrishnan
  2021-10-14 16:47               ` [dpdk-dev] [EXT] " Harman Kalra
  2021-10-19 11:27             ` [dpdk-dev] [v10 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  2021-10-19 16:42             ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Jerin Jacob
  5 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  6:55 UTC (permalink / raw)
  To: dev
  Cc: jerinj, kirankumark, ndabilpuram, skori, skoteshwar, asekhar,
	pbhagavatula, Gowrishankar Muthukrishnan

Add telemetry endpoints to ethdev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/net/cnxk/cnxk_ethdev_telemetry.c | 93 ++++++++++++++++++++++++
 drivers/net/cnxk/meson.build             |  1 +
 2 files changed, 94 insertions(+)
 create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c

diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
new file mode 100644
index 0000000000..83bc65848c
--- /dev/null
+++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
@@ -0,0 +1,93 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell International Ltd.
+ */
+
+#include <rte_telemetry.h>
+
+#include "cnxk_ethdev.h"
+
+/* Macro to count no of words in eth_info_s size */
+#define ETH_INFO_SZ                                                            \
+	(RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) /         \
+	 sizeof(uint64_t))
+#define MACADDR_LEN 18
+
+static int
+ethdev_tel_handle_info(const char *cmd __rte_unused,
+		       const char *params __rte_unused, struct rte_tel_data *d)
+{
+	struct rte_eth_dev *eth_dev;
+	struct rte_tel_data *i_data;
+	struct cnxk_eth_dev *dev;
+	union eth_info_u {
+		struct eth_info_s {
+			/** PF/VF information */
+			uint16_t pf_func;
+			uint8_t max_mac_entries;
+			bool dmac_filter_ena;
+			uint8_t dmac_filter_count;
+			uint8_t ptype_disable;
+			bool scalar_ena;
+			bool ptp_ena;
+			/* Platform specific offload flags */
+			uint16_t rx_offload_flags;
+			uint16_t tx_offload_flags;
+		} info;
+		uint64_t val[ETH_INFO_SZ];
+	} eth_info;
+	struct eth_info_s *info;
+	unsigned int i, j = 0;
+	int n_ports;
+
+	n_ports = rte_eth_dev_count_avail();
+	if (!n_ports) {
+		plt_err("No active ethernet ports found.");
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_int(d, "n_ports", n_ports);
+
+	i_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+		/* Skip if port is unused */
+		if (!rte_eth_dev_is_valid_port(i))
+			continue;
+
+		eth_dev = &rte_eth_devices[i];
+		if (eth_dev) {
+			memset(&eth_info, 0, sizeof(eth_info));
+			info = &eth_info.info;
+			dev = cnxk_eth_pmd_priv(eth_dev);
+			if (dev) {
+				info->pf_func = roc_nix_get_pf_func(&dev->nix);
+				info->max_mac_entries = dev->max_mac_entries;
+				info->dmac_filter_ena = dev->dmac_filter_enable;
+				info->dmac_filter_count =
+					dev->dmac_filter_count;
+				info->ptype_disable = dev->ptype_disable;
+				info->scalar_ena = dev->scalar_ena;
+				info->ptp_ena = dev->ptp_en;
+				info->rx_offload_flags = dev->rx_offload_flags;
+				info->tx_offload_flags = dev->tx_offload_flags;
+			}
+
+			for (j = 0; j < ETH_INFO_SZ; j++)
+				rte_tel_data_add_array_u64(i_data,
+							   eth_info.val[j]);
+
+			j++;
+		}
+	}
+
+	rte_tel_data_add_dict_container(d, "info", i_data, 0);
+	return 0;
+}
+
+RTE_INIT(cnxk_ethdev_init_telemetry)
+{
+	rte_telemetry_register_cmd("/cnxk/ethdev/info", ethdev_tel_handle_info,
+				   "Returns ethdev device information");
+}
diff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build
index d1d4b4e15e..5b3b8422fb 100644
--- a/drivers/net/cnxk/meson.build
+++ b/drivers/net/cnxk/meson.build
@@ -13,6 +13,7 @@ sources = files(
         'cnxk_ethdev_devargs.c',
         'cnxk_ethdev_ops.c',
         'cnxk_ethdev_sec.c',
+        'cnxk_ethdev_telemetry.c',
         'cnxk_link.c',
         'cnxk_lookup.c',
         'cnxk_ptp.c',
-- 
2.25.1


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

* [dpdk-dev] [v3] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-09-21 11:32             ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
  2021-09-29  6:45               ` [dpdk-dev] [v1] cryptodev: add telemetry endpoint for cryptodev info Gowrishankar Muthukrishnan
@ 2021-09-29  7:01               ` Gowrishankar Muthukrishnan
  2021-09-29  8:56                 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
  1 sibling, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  7:01 UTC (permalink / raw)
  To: dev; +Cc: jerinj, anoobj, adwivedi, ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to cryptodev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-19252 ("cryptodev: add telemetry endpoint for cryptodev info")
Depends-on: series-19253 ("cnxk: enable telemetry endpoints")

v3:
 - common info moved to lib/cryptodev endpoint.
---
 .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 119 ++++++++++++++++++
 drivers/crypto/cnxk/meson.build               |   1 +
 2 files changed, 120 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
new file mode 100644
index 0000000000..657004e65a
--- /dev/null
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
@@ -0,0 +1,119 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_telemetry.h>
+#include <cryptodev_pmd.h>
+
+#include <roc_api.h>
+
+#include "cnxk_cryptodev.h"
+#include "cnxk_telemetry.h"
+
+#define CRYPTO_CAPS_SZ                                                         \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities),             \
+			sizeof(uint64_t)) /                                    \
+	 sizeof(uint64_t))
+
+#define SEC_CAPS_SZ                                                            \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability),                \
+			sizeof(uint64_t)) /                                    \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  struct rte_cryptodev_capabilities *dev_caps,
+		  size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_cryptodev_capabilities dev_caps;
+		uint64_t val[CRYPTO_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		if (dev_caps[i].op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
+			break;
+
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+sec_caps_array(struct rte_tel_data *d, struct rte_security_capability *dev_caps,
+	       size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_security_capability dev_caps;
+		uint64_t val[SEC_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+cryptodev_tel_handle_info(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_tel_data *sec_crypto_caps, *sec_caps;
+	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+	int sec_crypto_caps_n, sec_caps_n;
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	rte_strlcpy(name, params, RTE_CRYPTODEV_NAME_LEN);
+	dev = rte_cryptodev_pmd_get_named_dev(name);
+	if (!dev) {
+		plt_err("No cryptodev of name %s available", name);
+		return -EINVAL;
+	}
+
+	vf = dev->data->dev_private;
+	rte_tel_data_start_dict(d);
+
+	/* Security Crypto capabilities */
+	sec_crypto_caps = rte_tel_data_alloc();
+	sec_crypto_caps_n = crypto_caps_array(
+		sec_crypto_caps, vf->sec_crypto_caps, CNXK_SEC_CRYPTO_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_crypto_caps", sec_crypto_caps,
+					0);
+	rte_tel_data_add_dict_int(d, "sec_crypto_caps_n", sec_crypto_caps_n);
+
+	/* Security capabilities */
+	sec_caps = rte_tel_data_alloc();
+	sec_caps_n = sec_caps_array(sec_caps, vf->sec_caps, CNXK_SEC_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(cnxk_cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/cryptodev/info", cryptodev_tel_handle_info,
+		"Returns cryptodev info. Parameters: pci id");
+}
diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build
index 437d208b5a..4350928289 100644
--- a/drivers/crypto/cnxk/meson.build
+++ b/drivers/crypto/cnxk/meson.build
@@ -19,6 +19,7 @@ sources = files(
         'cnxk_cryptodev_capabilities.c',
         'cnxk_cryptodev_ops.c',
         'cnxk_cryptodev_sec.c',
+        'cnxk_cryptodev_telemetry.c',
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev']
-- 
2.25.1


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

* [dpdk-dev] [v4] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-09-29  7:01               ` [dpdk-dev] [v3] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
@ 2021-09-29  8:56                 ` Gowrishankar Muthukrishnan
  0 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-29  8:56 UTC (permalink / raw)
  To: dev; +Cc: jerinj, anoobj, adwivedi, ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to cryptodev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-19252 ("cryptodev: add telemetry endpoint for cryptodev info")
Depends-on: series-19253 ("cnxk: enable telemetry endpoints")

v4:
 - fix compilation issue.
---
 .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 119 ++++++++++++++++++
 drivers/crypto/cnxk/meson.build               |   1 +
 2 files changed, 120 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
new file mode 100644
index 0000000000..a9df7e49c3
--- /dev/null
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
@@ -0,0 +1,119 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_telemetry.h>
+#include <cryptodev_pmd.h>
+
+#include <cnxk_telemetry.h>
+#include <roc_api.h>
+
+#include "cnxk_cryptodev.h"
+
+#define CRYPTO_CAPS_SZ                                                         \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities),             \
+			sizeof(uint64_t)) /                                    \
+	 sizeof(uint64_t))
+
+#define SEC_CAPS_SZ                                                            \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability),                \
+			sizeof(uint64_t)) /                                    \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  struct rte_cryptodev_capabilities *dev_caps,
+		  size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_cryptodev_capabilities dev_caps;
+		uint64_t val[CRYPTO_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		if (dev_caps[i].op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
+			break;
+
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+sec_caps_array(struct rte_tel_data *d, struct rte_security_capability *dev_caps,
+	       size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_security_capability dev_caps;
+		uint64_t val[SEC_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+cryptodev_tel_handle_info(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_tel_data *sec_crypto_caps, *sec_caps;
+	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
+	int sec_crypto_caps_n, sec_caps_n;
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	rte_strlcpy(name, params, RTE_CRYPTODEV_NAME_LEN);
+	dev = rte_cryptodev_pmd_get_named_dev(name);
+	if (!dev) {
+		plt_err("No cryptodev of name %s available", name);
+		return -EINVAL;
+	}
+
+	vf = dev->data->dev_private;
+	rte_tel_data_start_dict(d);
+
+	/* Security Crypto capabilities */
+	sec_crypto_caps = rte_tel_data_alloc();
+	sec_crypto_caps_n = crypto_caps_array(
+		sec_crypto_caps, vf->sec_crypto_caps, CNXK_SEC_CRYPTO_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_crypto_caps", sec_crypto_caps,
+					0);
+	rte_tel_data_add_dict_int(d, "sec_crypto_caps_n", sec_crypto_caps_n);
+
+	/* Security capabilities */
+	sec_caps = rte_tel_data_alloc();
+	sec_caps_n = sec_caps_array(sec_caps, vf->sec_caps, CNXK_SEC_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(cnxk_cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/cryptodev/info", cryptodev_tel_handle_info,
+		"Returns cryptodev info. Parameters: pci id");
+}
diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build
index 437d208b5a..4350928289 100644
--- a/drivers/crypto/cnxk/meson.build
+++ b/drivers/crypto/cnxk/meson.build
@@ -19,6 +19,7 @@ sources = files(
         'cnxk_cryptodev_capabilities.c',
         'cnxk_cryptodev_ops.c',
         'cnxk_cryptodev_sec.c',
+        'cnxk_cryptodev_telemetry.c',
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev']
-- 
2.25.1


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

* Re: [dpdk-dev] [v2] telemetry: fix json output buffer size
  2021-09-23  5:53                 ` Gowrishankar Muthukrishnan
@ 2021-09-30  8:47                   ` Power, Ciara
  2021-09-30  9:00                     ` Gowrishankar Muthukrishnan
  0 siblings, 1 reply; 121+ messages in thread
From: Power, Ciara @ 2021-09-30  8:47 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev; +Cc: Richardson, Bruce

Hi Gowrishankar,

>-----Original Message-----
>From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
>Sent: Thursday 23 September 2021 06:53
>To: Power, Ciara <ciara.power@intel.com>; dev@dpdk.org
>Cc: Richardson, Bruce <bruce.richardson@intel.com>
>Subject: RE: [v2] telemetry: fix json output buffer size
>
>Hi Ciara,
>> I am not sure about why we would want this to allow for
>> "RTE_TEL_MAX_SINGLE_STRING_LEN - 6".
>> The RTE_TEL_MAX_SINGLE_STRING_LEN is used to represent the max size
>of a
>> singular string value e.g. the response to client being   {"<cmd>" : "<string
>value
>> here up to max size in length>" }
>>
>> I wonder could we use the "len" parameter in some way here, that would
>> be the available space to be filled of the "buf" being passed in,
>> allowing the function to copy in the maximum amount to fill the buffer.
>
>Got it. Yeah, "len" is actual available space. I ll send next version based on this.
>
>Also, I propose if we can have platform defined upper limits (esp
>MAX_CMD_LEN, MAX_SINGLE_STRING_LEN etc) so that, we need not revisit
>lib/telemetry for platform needs (and I don't think one size fits all platform,
>may be excess too).
>Thoughts ?

I am not sure why it is needed to have limits defined per platform - can you explain further about why it is necessary?

Thanks,
Ciara

>
>Thanks,
>Gowrishankar
>
>>
>> Thanks,
>> Ciara

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

* Re: [dpdk-dev] [v2] telemetry: fix json output buffer size
  2021-09-30  8:47                   ` Power, Ciara
@ 2021-09-30  9:00                     ` Gowrishankar Muthukrishnan
  2021-10-07  9:04                       ` Power, Ciara
  0 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-09-30  9:00 UTC (permalink / raw)
  To: Power, Ciara, dev; +Cc: Richardson, Bruce

> >Also, I propose if we can have platform defined upper limits (esp
> >MAX_CMD_LEN, MAX_SINGLE_STRING_LEN etc) so that, we need not revisit
> >lib/telemetry for platform needs (and I don't think one size fits all
> >platform, may be excess too).
> >Thoughts ?
> 
> I am not sure why it is needed to have limits defined per platform - can you
> explain further about why it is necessary?
> 

Mainly, for the endpoint in driver. In case, if the endpoint data is bigger than MAX_SINGLE_STRING_LEN
at the worst case, endpoint will not work correctly.

Thanks,
Gowrishankar

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

* Re: [dpdk-dev] [v5] telemetry: fix json output buffer size
  2021-09-29  4:18                   ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
@ 2021-10-06 17:38                     ` Thomas Monjalon
  2021-10-07  4:58                       ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
  2021-10-11 10:54                     ` [dpdk-dev] [v6] telemetry: remove limitation on JSON output buffer length Gowrishankar Muthukrishnan
  1 sibling, 1 reply; 121+ messages in thread
From: Thomas Monjalon @ 2021-10-06 17:38 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan; +Cc: dev, bruce.richardson, ciara.power, jerinj

29/09/2021 06:18, Gowrishankar Muthukrishnan:
> Fix json output buffer size for an actual data length.
> 
> Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON")

Please could you give a bit more explanations?
What was not working and why?

[...]
> - * This function is not for use for values larger than 1k.
> + * This function is not for use for values larger than given buffer length.
>   */
>  __rte_format_printf(3, 4)
>  static inline int
>  __json_snprintf(char *buf, const int len, const char *format, ...)
>  {
> -	char tmp[1024];
> +	char tmp[len];
>  	va_list ap;
>  	int ret;





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

* Re: [dpdk-dev] [EXT] Re: [v5] telemetry: fix json output buffer size
  2021-10-06 17:38                     ` Thomas Monjalon
@ 2021-10-07  4:58                       ` Gowrishankar Muthukrishnan
  2021-10-07  7:22                         ` Thomas Monjalon
  0 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-07  4:58 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, bruce.richardson, ciara.power, Jerin Jacob Kollanukkaran

Hi Thomas,

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Wednesday, October 6, 2021 11:09 PM
> To: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Cc: dev@dpdk.org; bruce.richardson@intel.com; ciara.power@intel.com; Jerin
> Jacob Kollanukkaran <jerinj@marvell.com>
> Subject: [EXT] Re: [dpdk-dev] [v5] telemetry: fix json output buffer size
> 
> External Email
> 
> ----------------------------------------------------------------------
> 29/09/2021 06:18, Gowrishankar Muthukrishnan:
> > Fix json output buffer size for an actual data length.
> >
> > Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating
> > JSON")
> 
> Please could you give a bit more explanations?
> What was not working and why?

Without this patch, our driver end point (crypto/cnxk) could not successfully deliver the requested info
due to its larger amount than the fixed buffer length of 1024 bytes as handled by __json_snprintf.
I think it is genuine bug too which we caught up here.

Thanks,
Gowrishankar
> 
> [...]
> > - * This function is not for use for values larger than 1k.
> > + * This function is not for use for values larger than given buffer length.
> >   */
> >  __rte_format_printf(3, 4)
> >  static inline int
> >  __json_snprintf(char *buf, const int len, const char *format, ...)  {
> > -	char tmp[1024];
> > +	char tmp[len];
> >  	va_list ap;
> >  	int ret;
> 
> 
> 


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

* Re: [dpdk-dev] [EXT] Re: [v5] telemetry: fix json output buffer size
  2021-10-07  4:58                       ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
@ 2021-10-07  7:22                         ` Thomas Monjalon
  2021-10-07  8:36                           ` Gowrishankar Muthukrishnan
  0 siblings, 1 reply; 121+ messages in thread
From: Thomas Monjalon @ 2021-10-07  7:22 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan
  Cc: dev, bruce.richardson, ciara.power, Jerin Jacob Kollanukkaran

07/10/2021 06:58, Gowrishankar Muthukrishnan:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 29/09/2021 06:18, Gowrishankar Muthukrishnan:
> > > Fix json output buffer size for an actual data length.
> > >
> > > Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating
> > > JSON")
> > 
> > Please could you give a bit more explanations?
> > What was not working and why?
> 
> Without this patch, our driver end point (crypto/cnxk) could not successfully deliver the requested info
> due to its larger amount than the fixed buffer length of 1024 bytes as handled by __json_snprintf.
> I think it is genuine bug too which we caught up here.

So the commit log should say the JSON message was limited to 1024,
and now you allow any specified length.

> > [...]
> > > - * This function is not for use for values larger than 1k.
> > > + * This function is not for use for values larger than given buffer length.
> > >   */
> > >  __rte_format_printf(3, 4)
> > >  static inline int
> > >  __json_snprintf(char *buf, const int len, const char *format, ...)  {
> > > -	char tmp[1024];
> > > +	char tmp[len];
> > >  	va_list ap;
> > >  	int ret;




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

* Re: [dpdk-dev] [EXT] Re: [v5] telemetry: fix json output buffer size
  2021-10-07  7:22                         ` Thomas Monjalon
@ 2021-10-07  8:36                           ` Gowrishankar Muthukrishnan
  0 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-07  8:36 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, bruce.richardson, ciara.power, Jerin Jacob Kollanukkaran

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Thursday, October 7, 2021 12:52 PM
> To: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Cc: dev@dpdk.org; bruce.richardson@intel.com; ciara.power@intel.com; Jerin
> Jacob Kollanukkaran <jerinj@marvell.com>
> Subject: Re: [EXT] Re: [dpdk-dev] [v5] telemetry: fix json output buffer size
> 
> 07/10/2021 06:58, Gowrishankar Muthukrishnan:
> > From: Thomas Monjalon <thomas@monjalon.net>
> > > 29/09/2021 06:18, Gowrishankar Muthukrishnan:
> > > > Fix json output buffer size for an actual data length.
> > > >
> > > > Fixes: 52af6ccb2b39 ("telemetry: add utility functions for
> > > > creating
> > > > JSON")
> > >
> > > Please could you give a bit more explanations?
> > > What was not working and why?
> >
> > Without this patch, our driver end point (crypto/cnxk) could not
> > successfully deliver the requested info due to its larger amount than the fixed
> buffer length of 1024 bytes as handled by __json_snprintf.
> > I think it is genuine bug too which we caught up here.
> 
> So the commit log should say the JSON message was limited to 1024, and now
> you allow any specified length.
> 

Ack. I'll send new version with this correction.

Thanks,
Gowrishankar
> > > [...]
> > > > - * This function is not for use for values larger than 1k.
> > > > + * This function is not for use for values larger than given buffer length.
> > > >   */
> > > >  __rte_format_printf(3, 4)
> > > >  static inline int
> > > >  __json_snprintf(char *buf, const int len, const char *format, ...)  {
> > > > -	char tmp[1024];
> > > > +	char tmp[len];
> > > >  	va_list ap;
> > > >  	int ret;
> 
> 


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

* Re: [dpdk-dev] [v2] telemetry: fix json output buffer size
  2021-09-30  9:00                     ` Gowrishankar Muthukrishnan
@ 2021-10-07  9:04                       ` Power, Ciara
  0 siblings, 0 replies; 121+ messages in thread
From: Power, Ciara @ 2021-10-07  9:04 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev; +Cc: Richardson, Bruce

Hi Gowrishankar,

>-----Original Message-----
>From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
>Sent: Thursday 30 September 2021 10:01
>To: Power, Ciara <ciara.power@intel.com>; dev@dpdk.org
>Cc: Richardson, Bruce <bruce.richardson@intel.com>
>Subject: RE: [v2] telemetry: fix json output buffer size
>
>> >Also, I propose if we can have platform defined upper limits (esp
>> >MAX_CMD_LEN, MAX_SINGLE_STRING_LEN etc) so that, we need not revisit
>> >lib/telemetry for platform needs (and I don't think one size fits all
>> >platform, may be excess too).
>> >Thoughts ?
>>
>> I am not sure why it is needed to have limits defined per platform -
>> can you explain further about why it is necessary?
>>
>
>Mainly, for the endpoint in driver. In case, if the endpoint data is bigger than
>MAX_SINGLE_STRING_LEN at the worst case, endpoint will not work correctly.
>

The MAX_SINGLE_STRING_LEN is currently 8192 - if a value is turning out to be bigger than that, maybe we should be looking at why the string is that long and if it needs to be - i.e. could it be broken down to be more consumable rather than modifying the lib to accept an extremely long string.
I don't see an issue with increasing the MAX_CMD_LEN a little in the lib - although it is currently 56, it probably doesn't need to be a huge increase, commands are easier used when concise.

Not sure having platform specific values here is necessary. 

Thanks,
Ciara

>Thanks,
>Gowrishankar

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

* [dpdk-dev] [v6] telemetry: remove limitation on JSON output buffer length
  2021-09-29  4:18                   ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
  2021-10-06 17:38                     ` Thomas Monjalon
@ 2021-10-11 10:54                     ` Gowrishankar Muthukrishnan
  2021-10-13 11:06                       ` Power, Ciara
  1 sibling, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-11 10:54 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, ciara.power, jerinj, Gowrishankar Muthukrishnan

Earlier, JSON message length was limited to 1024 which would not
allow data more than this size. Removed this limitation by creating
output buffer based on requested data length.

Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v6:
 - rephrased the commit header and message.
---
 lib/telemetry/telemetry_json.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index ad270b9b30..f02a12f5b0 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -9,6 +9,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <rte_common.h>
+#include <rte_telemetry.h>
 
 /**
  * @file
@@ -23,13 +24,13 @@
  * @internal
  * Copies a value into a buffer if the buffer has enough available space.
  * Nothing written to buffer if an overflow ocurs.
- * This function is not for use for values larger than 1k.
+ * This function is not for use for values larger than given buffer length.
  */
 __rte_format_printf(3, 4)
 static inline int
 __json_snprintf(char *buf, const int len, const char *format, ...)
 {
-	char tmp[1024];
+	char tmp[len];
 	va_list ap;
 	int ret;
 
-- 
2.25.1


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

* Re: [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info
  2021-09-29  4:25             ` [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info Gowrishankar Muthukrishnan
@ 2021-10-11 14:40               ` Ferruh Yigit
  2021-10-11 15:40                 ` Bruce Richardson
  2021-10-14 21:47               ` Ferruh Yigit
  1 sibling, 1 reply; 121+ messages in thread
From: Ferruh Yigit @ 2021-10-11 14:40 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Thomas Monjalon, Andrew Rybchenko, jerinj, Ciara Power, Bruce Richardson

On 9/29/2021 5:25 AM, Gowrishankar Muthukrishnan wrote:
> Add telemetry endpoint /ethdev/info for device info.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Change-Id: I3e6ee2bd1a80675473adf0bd884b194f98e28536
> ---
>   lib/ethdev/rte_ethdev.c | 92 +++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 92 insertions(+)
> 
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index daf5ca9242..9b7bfa5f63 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -6242,6 +6242,96 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused,
>   	return 0;
>   }
>   
> +static int
> +eth_dev_handle_port_info(const char *cmd __rte_unused,
> +		const char *params,
> +		struct rte_tel_data *d)
> +{
> +	struct rte_tel_data *rxq_state, *txq_state;
> +	char mac_addr[RTE_ETHER_ADDR_LEN];
> +	struct rte_eth_dev *eth_dev;
> +	char *end_param;
> +	int port_id, i;
> +
> +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> +		return -1;
> +
> +	port_id = strtoul(params, &end_param, 0);
> +	if (*end_param != '\0')
> +		RTE_ETHDEV_LOG(NOTICE,
> +			"Extra parameters passed to ethdev telemetry command, ignoring");
> +
> +	if (!rte_eth_dev_is_valid_port(port_id))
> +		return -EINVAL;
> +
> +	eth_dev = &rte_eth_devices[port_id];
> +	if (!eth_dev)
> +		return -EINVAL;
> +
> +	rxq_state = rte_tel_data_alloc();
> +	if (!rxq_state)
> +		return -ENOMEM;
> +
> +	txq_state = rte_tel_data_alloc();
> +	if (!txq_state)
> +		return -ENOMEM;
> +
> +	rte_tel_data_start_dict(d);
> +	rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
> +	rte_tel_data_add_dict_int(d, "state", eth_dev->state);
> +	rte_tel_data_add_dict_int(d, "nb_rx_queues",
> +			eth_dev->data->nb_rx_queues);
> +	rte_tel_data_add_dict_int(d, "nb_tx_queues",
> +			eth_dev->data->nb_tx_queues);
> +	rte_tel_data_add_dict_int(d, "port_id", eth_dev->data->port_id);
> +	rte_tel_data_add_dict_int(d, "mtu", eth_dev->data->mtu);
> +	rte_tel_data_add_dict_int(d, "rx_mbuf_size_min",
> +			eth_dev->data->min_rx_buf_size);
> +	rte_tel_data_add_dict_int(d, "rx_mbuf_alloc_fail",
> +			eth_dev->data->rx_mbuf_alloc_failed);
> +	snprintf(mac_addr, RTE_ETHER_ADDR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x",
> +			 eth_dev->data->mac_addrs->addr_bytes[0],
> +			 eth_dev->data->mac_addrs->addr_bytes[1],
> +			 eth_dev->data->mac_addrs->addr_bytes[2],
> +			 eth_dev->data->mac_addrs->addr_bytes[3],
> +			 eth_dev->data->mac_addrs->addr_bytes[4],
> +			 eth_dev->data->mac_addrs->addr_bytes[5]);
> +	rte_tel_data_add_dict_string(d, "mac_addr", mac_addr);
> +	rte_tel_data_add_dict_int(d, "promiscuous",
> +			eth_dev->data->promiscuous);
> +	rte_tel_data_add_dict_int(d, "scattered_rx",
> +			eth_dev->data->scattered_rx);
> +	rte_tel_data_add_dict_int(d, "all_multicast",
> +			eth_dev->data->all_multicast);
> +	rte_tel_data_add_dict_int(d, "dev_started", eth_dev->data->dev_started);
> +	rte_tel_data_add_dict_int(d, "lro", eth_dev->data->lro);
> +	rte_tel_data_add_dict_int(d, "dev_configured",
> +			eth_dev->data->dev_configured);
> +
> +	rte_tel_data_start_array(rxq_state, RTE_TEL_INT_VAL);
> +	for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
> +		rte_tel_data_add_array_int(rxq_state,
> +				eth_dev->data->rx_queue_state[i]);
> +
> +	rte_tel_data_start_array(txq_state, RTE_TEL_INT_VAL);
> +	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
> +		rte_tel_data_add_array_int(txq_state,
> +				eth_dev->data->tx_queue_state[i]);
> +
> +	rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0);
> +	rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0);
> +	rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node);
> +	rte_tel_data_add_dict_int(d, "dev_flags", eth_dev->data->dev_flags);
> +	rte_tel_data_add_dict_int(d, "rx_offloads",
> +			eth_dev->data->dev_conf.rxmode.offloads);
> +	rte_tel_data_add_dict_int(d, "tx_offloads",
> +			eth_dev->data->dev_conf.txmode.offloads);
> +	rte_tel_data_add_dict_int(d, "ethdev_rss_hf",
> +			eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
> +
> +	return 0;
> +}
> +
>   int
>   rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
>   				  struct rte_hairpin_peer_info *cur_info,
> @@ -6323,4 +6413,6 @@ RTE_INIT(ethdev_init_telemetry)
>   	rte_telemetry_register_cmd("/ethdev/link_status",
>   			eth_dev_handle_port_link_status,
>   			"Returns the link status for a port. Parameters: int port_id");
> +	rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info,
> +			"Returns the device info for a port. Parameters: int port_id");
>   }
> 

@Ciara, @Bruce, can you please review the set from telemetry perspective?

And overall looks like good idea to provide more ethdev information via telemetry,
but when we have this it becomes interface since applications may rely on it,
is extending it breaks the apps?
If so perhaps we should consider multiple small commands instead of one big 'info'
one, what do you think?


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

* Re: [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info
  2021-10-11 14:40               ` Ferruh Yigit
@ 2021-10-11 15:40                 ` Bruce Richardson
  2021-10-11 15:44                   ` Ferruh Yigit
  0 siblings, 1 reply; 121+ messages in thread
From: Bruce Richardson @ 2021-10-11 15:40 UTC (permalink / raw)
  To: Ferruh Yigit
  Cc: Gowrishankar Muthukrishnan, dev, Thomas Monjalon,
	Andrew Rybchenko, jerinj, Ciara Power

On Mon, Oct 11, 2021 at 03:40:58PM +0100, Ferruh Yigit wrote:
> On 9/29/2021 5:25 AM, Gowrishankar Muthukrishnan wrote:
> > Add telemetry endpoint /ethdev/info for device info.
> > 
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > Change-Id: I3e6ee2bd1a80675473adf0bd884b194f98e28536
> > ---
> >   lib/ethdev/rte_ethdev.c | 92 +++++++++++++++++++++++++++++++++++++++++
> >   1 file changed, 92 insertions(+)
> > 
> > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> > index daf5ca9242..9b7bfa5f63 100644
> > --- a/lib/ethdev/rte_ethdev.c
> > +++ b/lib/ethdev/rte_ethdev.c
> > @@ -6242,6 +6242,96 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused,
> >   	return 0;
> >   }
> > +static int
> > +eth_dev_handle_port_info(const char *cmd __rte_unused,
> > +		const char *params,
> > +		struct rte_tel_data *d)
> > +{
> > +	struct rte_tel_data *rxq_state, *txq_state;
> > +	char mac_addr[RTE_ETHER_ADDR_LEN];
> > +	struct rte_eth_dev *eth_dev;
> > +	char *end_param;
> > +	int port_id, i;
> > +
> > +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> > +		return -1;
> > +
> > +	port_id = strtoul(params, &end_param, 0);
> > +	if (*end_param != '\0')
> > +		RTE_ETHDEV_LOG(NOTICE,
> > +			"Extra parameters passed to ethdev telemetry command, ignoring");
> > +
> > +	if (!rte_eth_dev_is_valid_port(port_id))
> > +		return -EINVAL;
> > +
> > +	eth_dev = &rte_eth_devices[port_id];
> > +	if (!eth_dev)
> > +		return -EINVAL;
> > +
> > +	rxq_state = rte_tel_data_alloc();
> > +	if (!rxq_state)
> > +		return -ENOMEM;
> > +
> > +	txq_state = rte_tel_data_alloc();
> > +	if (!txq_state)
> > +		return -ENOMEM;
> > +
> > +	rte_tel_data_start_dict(d);
> > +	rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
> > +	rte_tel_data_add_dict_int(d, "state", eth_dev->state);
> > +	rte_tel_data_add_dict_int(d, "nb_rx_queues",
> > +			eth_dev->data->nb_rx_queues);
> > +	rte_tel_data_add_dict_int(d, "nb_tx_queues",
> > +			eth_dev->data->nb_tx_queues);
> > +	rte_tel_data_add_dict_int(d, "port_id", eth_dev->data->port_id);
> > +	rte_tel_data_add_dict_int(d, "mtu", eth_dev->data->mtu);
> > +	rte_tel_data_add_dict_int(d, "rx_mbuf_size_min",
> > +			eth_dev->data->min_rx_buf_size);
> > +	rte_tel_data_add_dict_int(d, "rx_mbuf_alloc_fail",
> > +			eth_dev->data->rx_mbuf_alloc_failed);
> > +	snprintf(mac_addr, RTE_ETHER_ADDR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x",
> > +			 eth_dev->data->mac_addrs->addr_bytes[0],
> > +			 eth_dev->data->mac_addrs->addr_bytes[1],
> > +			 eth_dev->data->mac_addrs->addr_bytes[2],
> > +			 eth_dev->data->mac_addrs->addr_bytes[3],
> > +			 eth_dev->data->mac_addrs->addr_bytes[4],
> > +			 eth_dev->data->mac_addrs->addr_bytes[5]);
> > +	rte_tel_data_add_dict_string(d, "mac_addr", mac_addr);
> > +	rte_tel_data_add_dict_int(d, "promiscuous",
> > +			eth_dev->data->promiscuous);
> > +	rte_tel_data_add_dict_int(d, "scattered_rx",
> > +			eth_dev->data->scattered_rx);
> > +	rte_tel_data_add_dict_int(d, "all_multicast",
> > +			eth_dev->data->all_multicast);
> > +	rte_tel_data_add_dict_int(d, "dev_started", eth_dev->data->dev_started);
> > +	rte_tel_data_add_dict_int(d, "lro", eth_dev->data->lro);
> > +	rte_tel_data_add_dict_int(d, "dev_configured",
> > +			eth_dev->data->dev_configured);
> > +
> > +	rte_tel_data_start_array(rxq_state, RTE_TEL_INT_VAL);
> > +	for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
> > +		rte_tel_data_add_array_int(rxq_state,
> > +				eth_dev->data->rx_queue_state[i]);
> > +
> > +	rte_tel_data_start_array(txq_state, RTE_TEL_INT_VAL);
> > +	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
> > +		rte_tel_data_add_array_int(txq_state,
> > +				eth_dev->data->tx_queue_state[i]);
> > +
> > +	rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0);
> > +	rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0);
> > +	rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node);
> > +	rte_tel_data_add_dict_int(d, "dev_flags", eth_dev->data->dev_flags);
> > +	rte_tel_data_add_dict_int(d, "rx_offloads",
> > +			eth_dev->data->dev_conf.rxmode.offloads);
> > +	rte_tel_data_add_dict_int(d, "tx_offloads",
> > +			eth_dev->data->dev_conf.txmode.offloads);
> > +	rte_tel_data_add_dict_int(d, "ethdev_rss_hf",
> > +			eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
> > +
> > +	return 0;
> > +}
> > +
> >   int
> >   rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
> >   				  struct rte_hairpin_peer_info *cur_info,
> > @@ -6323,4 +6413,6 @@ RTE_INIT(ethdev_init_telemetry)
> >   	rte_telemetry_register_cmd("/ethdev/link_status",
> >   			eth_dev_handle_port_link_status,
> >   			"Returns the link status for a port. Parameters: int port_id");
> > +	rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info,
> > +			"Returns the device info for a port. Parameters: int port_id");
> >   }
> > 
> 
> @Ciara, @Bruce, can you please review the set from telemetry perspective?
> 
> And overall looks like good idea to provide more ethdev information via telemetry,
> but when we have this it becomes interface since applications may rely on it,
> is extending it breaks the apps?
> If so perhaps we should consider multiple small commands instead of one big 'info'
> one, what do you think?
> 

I think the info command is fine enough granularity as it is. Since
(currently) the only output format used is json, we don't need to worry
about adding in extra info later, because AFAIK referencing json nodes is by
name, rather than by offset. For example, "response['tx_offloads']" should be
valid no matter how many extra fields are added into the response later on.

/Bruce

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

* Re: [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info
  2021-10-11 15:40                 ` Bruce Richardson
@ 2021-10-11 15:44                   ` Ferruh Yigit
  0 siblings, 0 replies; 121+ messages in thread
From: Ferruh Yigit @ 2021-10-11 15:44 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: Gowrishankar Muthukrishnan, dev, Thomas Monjalon,
	Andrew Rybchenko, jerinj, Ciara Power

On 10/11/2021 4:40 PM, Bruce Richardson wrote:
> On Mon, Oct 11, 2021 at 03:40:58PM +0100, Ferruh Yigit wrote:
>> On 9/29/2021 5:25 AM, Gowrishankar Muthukrishnan wrote:
>>> Add telemetry endpoint /ethdev/info for device info.
>>>
>>> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
>>> Change-Id: I3e6ee2bd1a80675473adf0bd884b194f98e28536
>>> ---
>>>    lib/ethdev/rte_ethdev.c | 92 +++++++++++++++++++++++++++++++++++++++++
>>>    1 file changed, 92 insertions(+)
>>>
>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
>>> index daf5ca9242..9b7bfa5f63 100644
>>> --- a/lib/ethdev/rte_ethdev.c
>>> +++ b/lib/ethdev/rte_ethdev.c
>>> @@ -6242,6 +6242,96 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused,
>>>    	return 0;
>>>    }
>>> +static int
>>> +eth_dev_handle_port_info(const char *cmd __rte_unused,
>>> +		const char *params,
>>> +		struct rte_tel_data *d)
>>> +{
>>> +	struct rte_tel_data *rxq_state, *txq_state;
>>> +	char mac_addr[RTE_ETHER_ADDR_LEN];
>>> +	struct rte_eth_dev *eth_dev;
>>> +	char *end_param;
>>> +	int port_id, i;
>>> +
>>> +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
>>> +		return -1;
>>> +
>>> +	port_id = strtoul(params, &end_param, 0);
>>> +	if (*end_param != '\0')
>>> +		RTE_ETHDEV_LOG(NOTICE,
>>> +			"Extra parameters passed to ethdev telemetry command, ignoring");
>>> +
>>> +	if (!rte_eth_dev_is_valid_port(port_id))
>>> +		return -EINVAL;
>>> +
>>> +	eth_dev = &rte_eth_devices[port_id];
>>> +	if (!eth_dev)
>>> +		return -EINVAL;
>>> +
>>> +	rxq_state = rte_tel_data_alloc();
>>> +	if (!rxq_state)
>>> +		return -ENOMEM;
>>> +
>>> +	txq_state = rte_tel_data_alloc();
>>> +	if (!txq_state)
>>> +		return -ENOMEM;
>>> +
>>> +	rte_tel_data_start_dict(d);
>>> +	rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
>>> +	rte_tel_data_add_dict_int(d, "state", eth_dev->state);
>>> +	rte_tel_data_add_dict_int(d, "nb_rx_queues",
>>> +			eth_dev->data->nb_rx_queues);
>>> +	rte_tel_data_add_dict_int(d, "nb_tx_queues",
>>> +			eth_dev->data->nb_tx_queues);
>>> +	rte_tel_data_add_dict_int(d, "port_id", eth_dev->data->port_id);
>>> +	rte_tel_data_add_dict_int(d, "mtu", eth_dev->data->mtu);
>>> +	rte_tel_data_add_dict_int(d, "rx_mbuf_size_min",
>>> +			eth_dev->data->min_rx_buf_size);
>>> +	rte_tel_data_add_dict_int(d, "rx_mbuf_alloc_fail",
>>> +			eth_dev->data->rx_mbuf_alloc_failed);
>>> +	snprintf(mac_addr, RTE_ETHER_ADDR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x",
>>> +			 eth_dev->data->mac_addrs->addr_bytes[0],
>>> +			 eth_dev->data->mac_addrs->addr_bytes[1],
>>> +			 eth_dev->data->mac_addrs->addr_bytes[2],
>>> +			 eth_dev->data->mac_addrs->addr_bytes[3],
>>> +			 eth_dev->data->mac_addrs->addr_bytes[4],
>>> +			 eth_dev->data->mac_addrs->addr_bytes[5]);
>>> +	rte_tel_data_add_dict_string(d, "mac_addr", mac_addr);
>>> +	rte_tel_data_add_dict_int(d, "promiscuous",
>>> +			eth_dev->data->promiscuous);
>>> +	rte_tel_data_add_dict_int(d, "scattered_rx",
>>> +			eth_dev->data->scattered_rx);
>>> +	rte_tel_data_add_dict_int(d, "all_multicast",
>>> +			eth_dev->data->all_multicast);
>>> +	rte_tel_data_add_dict_int(d, "dev_started", eth_dev->data->dev_started);
>>> +	rte_tel_data_add_dict_int(d, "lro", eth_dev->data->lro);
>>> +	rte_tel_data_add_dict_int(d, "dev_configured",
>>> +			eth_dev->data->dev_configured);
>>> +
>>> +	rte_tel_data_start_array(rxq_state, RTE_TEL_INT_VAL);
>>> +	for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
>>> +		rte_tel_data_add_array_int(rxq_state,
>>> +				eth_dev->data->rx_queue_state[i]);
>>> +
>>> +	rte_tel_data_start_array(txq_state, RTE_TEL_INT_VAL);
>>> +	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
>>> +		rte_tel_data_add_array_int(txq_state,
>>> +				eth_dev->data->tx_queue_state[i]);
>>> +
>>> +	rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0);
>>> +	rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0);
>>> +	rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node);
>>> +	rte_tel_data_add_dict_int(d, "dev_flags", eth_dev->data->dev_flags);
>>> +	rte_tel_data_add_dict_int(d, "rx_offloads",
>>> +			eth_dev->data->dev_conf.rxmode.offloads);
>>> +	rte_tel_data_add_dict_int(d, "tx_offloads",
>>> +			eth_dev->data->dev_conf.txmode.offloads);
>>> +	rte_tel_data_add_dict_int(d, "ethdev_rss_hf",
>>> +			eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
>>> +
>>> +	return 0;
>>> +}
>>> +
>>>    int
>>>    rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue,
>>>    				  struct rte_hairpin_peer_info *cur_info,
>>> @@ -6323,4 +6413,6 @@ RTE_INIT(ethdev_init_telemetry)
>>>    	rte_telemetry_register_cmd("/ethdev/link_status",
>>>    			eth_dev_handle_port_link_status,
>>>    			"Returns the link status for a port. Parameters: int port_id");
>>> +	rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info,
>>> +			"Returns the device info for a port. Parameters: int port_id");
>>>    }
>>>
>>
>> @Ciara, @Bruce, can you please review the set from telemetry perspective?
>>
>> And overall looks like good idea to provide more ethdev information via telemetry,
>> but when we have this it becomes interface since applications may rely on it,
>> is extending it breaks the apps?
>> If so perhaps we should consider multiple small commands instead of one big 'info'
>> one, what do you think?
>>
> 
> I think the info command is fine enough granularity as it is. Since
> (currently) the only output format used is json, we don't need to worry
> about adding in extra info later, because AFAIK referencing json nodes is by
> name, rather than by offset. For example, "response['tx_offloads']" should be
> valid no matter how many extra fields are added into the response later on.
> 

Thanks, so it is extendible, in that case agree to continue as it is.


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

* Re: [dpdk-dev] [v6] telemetry: remove limitation on JSON output buffer length
  2021-10-11 10:54                     ` [dpdk-dev] [v6] telemetry: remove limitation on JSON output buffer length Gowrishankar Muthukrishnan
@ 2021-10-13 11:06                       ` Power, Ciara
  2021-10-13 15:25                         ` Thomas Monjalon
  0 siblings, 1 reply; 121+ messages in thread
From: Power, Ciara @ 2021-10-13 11:06 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev; +Cc: Richardson, Bruce, jerinj

>-----Original Message-----
>From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
>Sent: Monday 11 October 2021 11:55
>To: dev@dpdk.org
>Cc: Richardson, Bruce <bruce.richardson@intel.com>; Power, Ciara
><ciara.power@intel.com>; jerinj@marvell.com; Gowrishankar Muthukrishnan
><gmuthukrishn@marvell.com>
>Subject: [v6] telemetry: remove limitation on JSON output buffer length
>
>Earlier, JSON message length was limited to 1024 which would not allow data
>more than this size. Removed this limitation by creating output buffer based
>on requested data length.
>
>Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON")
>
>Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
>---
<snip>

Thanks,

Acked-by: Ciara Power <ciara.power@intel.com>

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

* Re: [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info
  2021-09-29  6:40             ` [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info Gowrishankar Muthukrishnan
@ 2021-10-13 15:21               ` Thomas Monjalon
  2021-10-13 15:26                 ` Bruce Richardson
  2021-10-13 15:40               ` Bruce Richardson
                                 ` (2 subsequent siblings)
  3 siblings, 1 reply; 121+ messages in thread
From: Thomas Monjalon @ 2021-10-13 15:21 UTC (permalink / raw)
  To: Olivier Matz, Andrew Rybchenko, Gowrishankar Muthukrishnan
  Cc: dev, jerinj, ciara.power, kevin.laatz, bruce.richardson

Not sure review from who we should wait.
Cc'ing telemetry people


29/09/2021 08:40, Gowrishankar Muthukrishnan:
> Add telemetry endpoint for mempool info.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
>  lib/mempool/rte_mempool.c | 84 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 84 insertions(+)
> 
> diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
> index 59a588425b..b8dad2997a 100644
> --- a/lib/mempool/rte_mempool.c
> +++ b/lib/mempool/rte_mempool.c
> @@ -31,6 +31,7 @@
>  #include <rte_spinlock.h>
>  #include <rte_tailq.h>
>  #include <rte_eal_paging.h>
> +#include <rte_telemetry.h>
>  
>  #include "rte_mempool.h"
>  #include "rte_mempool_trace.h"
> @@ -1343,3 +1344,86 @@ void rte_mempool_walk(void (*func)(struct rte_mempool *, void *),
>  
>  	rte_mcfg_mempool_read_unlock();
>  }
> +
> +static void
> +mempool_list_cb(struct rte_mempool *mp, void *arg)
> +{
> +	struct rte_tel_data *d = (struct rte_tel_data *)arg;
> +
> +	rte_tel_data_add_array_string(d, mp->name);
> +}
> +
> +static int
> +mempool_handle_list(const char *cmd __rte_unused,
> +	const char *params __rte_unused, struct rte_tel_data *d)
> +{
> +	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
> +	rte_mempool_walk(mempool_list_cb, d);
> +	return 0;
> +}
> +
> +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;
> +	const struct rte_memzone *mz;
> +
> +	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
> +		return;
> +
> +	rte_tel_data_add_dict_string(info->d, "name", mp->name);
> +	rte_tel_data_add_dict_int(info->d, "pool_id", mp->pool_id);
> +	rte_tel_data_add_dict_int(info->d, "flags", mp->flags);
> +	rte_tel_data_add_dict_int(info->d, "socket_id", mp->socket_id);
> +	rte_tel_data_add_dict_int(info->d, "size", mp->size);
> +	rte_tel_data_add_dict_int(info->d, "cache_size", mp->cache_size);
> +	rte_tel_data_add_dict_int(info->d, "elt_size", mp->elt_size);
> +	rte_tel_data_add_dict_int(info->d, "header_size", mp->header_size);
> +	rte_tel_data_add_dict_int(info->d, "trailer_size", mp->trailer_size);
> +	rte_tel_data_add_dict_int(info->d, "private_data_size",
> +			mp->private_data_size);
> +	rte_tel_data_add_dict_int(info->d, "ops_index", mp->ops_index);
> +	rte_tel_data_add_dict_int(info->d, "populated_size",
> +			mp->populated_size);
> +
> +	mz = mp->mz;
> +	rte_tel_data_add_dict_string(info->d, "mz_name", mz->name);
> +	rte_tel_data_add_dict_int(info->d, "mz_len", mz->len);
> +	rte_tel_data_add_dict_int(info->d, "mz_hugepage_sz",
> +							  mz->hugepage_sz);
> +	rte_tel_data_add_dict_int(info->d, "mz_socket_id", mz->socket_id);
> +	rte_tel_data_add_dict_int(info->d, "mz_flags", mz->flags);
> +}
> +
> +static int
> +mempool_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(mempool_init_telemetry)
> +{
> +	rte_telemetry_register_cmd("/mempool/list", mempool_handle_list,
> +		"Returns list of available mempool. Takes no parameters");
> +	rte_telemetry_register_cmd("/mempool/info", mempool_handle_info,
> +		"Returns mempool info. Parameters: pool_name");
> +}
> 






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

* Re: [dpdk-dev] [v6] telemetry: remove limitation on JSON output buffer length
  2021-10-13 11:06                       ` Power, Ciara
@ 2021-10-13 15:25                         ` Thomas Monjalon
  0 siblings, 0 replies; 121+ messages in thread
From: Thomas Monjalon @ 2021-10-13 15:25 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan; +Cc: dev, Richardson, Bruce, jerinj, Power, Ciara

> >Earlier, JSON message length was limited to 1024 which would not allow data
> >more than this size. Removed this limitation by creating output buffer based
> >on requested data length.
> >
> >Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON")
> >
> >Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> >---
> <snip>
> 
> Thanks,
> 
> Acked-by: Ciara Power <ciara.power@intel.com>

Applied, thanks.



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

* Re: [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info
  2021-10-13 15:21               ` Thomas Monjalon
@ 2021-10-13 15:26                 ` Bruce Richardson
  0 siblings, 0 replies; 121+ messages in thread
From: Bruce Richardson @ 2021-10-13 15:26 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: Olivier Matz, Andrew Rybchenko, Gowrishankar Muthukrishnan, dev,
	jerinj, ciara.power, kevin.laatz

On Wed, Oct 13, 2021 at 05:21:32PM +0200, Thomas Monjalon wrote:
> Not sure review from who we should wait.
> Cc'ing telemetry people
> 
I'll give it a quick test and a look over.

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

* Re: [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info
  2021-09-29  6:40             ` [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info Gowrishankar Muthukrishnan
  2021-10-13 15:21               ` Thomas Monjalon
@ 2021-10-13 15:40               ` Bruce Richardson
  2021-10-22  3:28               ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
  2021-10-22 16:11               ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Bruce Richardson @ 2021-10-13 15:40 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan; +Cc: dev, Olivier Matz, Andrew Rybchenko, jerinj

On Wed, Sep 29, 2021 at 12:10:04PM +0530, Gowrishankar Muthukrishnan wrote:
> Add telemetry endpoint for mempool info.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>


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

* Re: [dpdk-dev] [EXT] [v9 1/4] common/cnxk: add telemetry endpoints to npa
  2021-09-29  6:55             ` [dpdk-dev] [v9 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-10-14 15:22               ` Harman Kalra
  0 siblings, 0 replies; 121+ messages in thread
From: Harman Kalra @ 2021-10-14 15:22 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Jerin Jacob Kollanukkaran, Kiran Kumar Kokkilagadda,
	Nithin Kumar Dabilpuram, Sunil Kumar Kori,
	Satha Koteswara Rao Kottidi,
	Ashwin Sekhar Thalakalath Kottilveetil,
	Pavan Nikhilesh Bhagavatula, Gowrishankar Muthukrishnan

Hi Gowrishankar,

Some comments inline.


> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Gowrishankar
> Muthukrishnan
> Sent: Wednesday, September 29, 2021 12:25 PM
> To: dev@dpdk.org
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Kiran Kumar
> Kokkilagadda <kirankumark@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpuram@marvell.com>; Sunil Kumar Kori <skori@marvell.com>; Satha
> Koteswara Rao Kottidi <skoteshwar@marvell.com>; Ashwin Sekhar
> Thalakalath Kottilveetil <asekhar@marvell.com>; Pavan Nikhilesh
> Bhagavatula <pbhagavatula@marvell.com>; Gowrishankar Muthukrishnan
> <gmuthukrishn@marvell.com>
> Subject: [EXT] [dpdk-dev] [v9 1/4] common/cnxk: add telemetry endpoints to
> npa
> 
> External Email
> 
> ----------------------------------------------------------------------
> Add telemetry endpoints to npa.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
>  drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
>  drivers/common/cnxk/cnxk_telemetry_npa.c | 224
> +++++++++++++++++++++++
>  drivers/common/cnxk/meson.build          |   6 +-
>  drivers/common/cnxk/roc_platform.h       |  12 ++
>  4 files changed, 266 insertions(+), 2 deletions(-)  create mode 100644
> drivers/common/cnxk/cnxk_telemetry.h
>  create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
> 

[...]

> +static int
> +cnxk_tel_npa(struct plt_tel_data *d)
> +{
> +	struct npa_lf *lf;
> +	int aura_cnt = 0;
> +	uint32_t i;
> +
> +	lf = idev_npa_obj_get();
> +	if (lf == NULL)
> +		return NPA_ERR_DEVICE_NOT_BOUNDED;
> +
> +	for (i = 0; i < lf->nr_pools; i++) {
> +		if (plt_bitmap_get(lf->npa_bmp, i))
> +			continue;
> +		aura_cnt++;
> +	}
> +
> +	plt_tel_data_add_dict_ptr(d, "npa", lf);
> +	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
> +	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
> +	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
> +
> +	CNXK_TEL_DICT_PTR(d, lf, pci_dev);

Can we print PCI BDF string in place of its handle.

> +	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
> +	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
> +	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
> +	CNXK_TEL_DICT_PTR(d, lf, intr_handle);

Handles can be avoided, just a suggestion no strong objection against it.

> +	CNXK_TEL_DICT_PTR(d, lf, mbox);
> +	CNXK_TEL_DICT_PTR(d, lf, base);
> +	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
> +	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
> +	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
> +	CNXK_TEL_DICT_INT(d, lf, nr_pools);
> +	CNXK_TEL_DICT_INT(d, lf, pf_func);
> +	CNXK_TEL_DICT_INT(d, lf, aura_sz);
> +	CNXK_TEL_DICT_INT(d, lf, qints);
> +
> +	return 0;
> +

[...]

> +static int
> +cnxk_npa_tel_handle_info(const char *cmd __plt_unused,
> +			 const char *params __plt_unused,
> +			 struct plt_tel_data *d)
> +{
> +	plt_tel_data_start_dict(d);
> +	return cnxk_tel_npa(d);
> +}
> +
> +static int
> +cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
> +			   struct plt_tel_data *d)
> +{
> +	int id, rc;
> +
> +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> +		return -1;
> +
> +	id = atoi(params);

Please avoid using atoi as it obsolete. atoi() function is subsumed by strtol(), problem with atoi is
it does not perform any error checking.


> +	plt_tel_data_start_dict(d);
> +
> +	if (strstr(cmd, "aura/info"))
> +		rc = cnxk_tel_npa_aura(id, d);
> +	else
> +		rc = cnxk_tel_npa_pool(id, d);
> +
> +	return rc;
> +}
> +
> +PLT_INIT(cnxk_telemetry_npa_init)
> +{
> +	plt_telemetry_register_cmd(
> +		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
> +		"Returns npa information. Takes no parameters");
> +
> +	plt_telemetry_register_cmd(
> +		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
> +		"Returns npa aura information. Parameters: aura_id");

Can we also add a list command "/cnxk/npa/aura/list" something similar to
"/ethdev/list" so its easy to know for what all aura ids  "/cnxk/npa/aura/info"
can be used.


> +
> +	plt_telemetry_register_cmd(
> +		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,

Same, pool/list if possible.


> +		"Returns npa pool information. Parameters: pool_id"); }
> diff --git a/drivers/common/cnxk/meson.build


Thanks
Harman

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

* Re: [dpdk-dev] [EXT] [v9 2/4] common/cnxk: add telemetry endpoints to nix
  2021-09-29  6:55             ` [dpdk-dev] [v9 2/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
@ 2021-10-14 16:37               ` Harman Kalra
  0 siblings, 0 replies; 121+ messages in thread
From: Harman Kalra @ 2021-10-14 16:37 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Jerin Jacob Kollanukkaran, Kiran Kumar Kokkilagadda,
	Nithin Kumar Dabilpuram, Sunil Kumar Kori,
	Satha Koteswara Rao Kottidi,
	Ashwin Sekhar Thalakalath Kottilveetil,
	Pavan Nikhilesh Bhagavatula, Gowrishankar Muthukrishnan



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Gowrishankar
> Muthukrishnan
> Sent: Wednesday, September 29, 2021 12:25 PM
> To: dev@dpdk.org
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Kiran Kumar
> Kokkilagadda <kirankumark@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpuram@marvell.com>; Sunil Kumar Kori <skori@marvell.com>; Satha
> Koteswara Rao Kottidi <skoteshwar@marvell.com>; Ashwin Sekhar
> Thalakalath Kottilveetil <asekhar@marvell.com>; Pavan Nikhilesh
> Bhagavatula <pbhagavatula@marvell.com>; Gowrishankar Muthukrishnan
> <gmuthukrishn@marvell.com>
> Subject: [EXT] [dpdk-dev] [v9 2/4] common/cnxk: add telemetry endpoints to
> nix
> 
> External Email
> 
> ----------------------------------------------------------------------
> Add telemetry endpoints to nix.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

Patch looks good to me.

Reviewed-by: Harman Kalra <hkalra@marvell.com>

Thanks
Harman


> ---
>  drivers/common/cnxk/cnxk_telemetry_nix.c | 849
> +++++++++++++++++++++++
>  drivers/common/cnxk/meson.build          |   3 +-
>  drivers/common/cnxk/roc_nix.c            |   3 +
>  drivers/common/cnxk/roc_nix_priv.h       |   9 +
>  drivers/common/cnxk/roc_nix_queue.c      |  15 +-
>  drivers/common/cnxk/roc_platform.h       |   3 +
>  6 files changed, 878 insertions(+), 4 deletions(-)  create mode 100644
> drivers/common/cnxk/cnxk_telemetry_nix.c
> 
> diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c
> b/drivers/common/cnxk/cnxk_telemetry_nix.c
> new file mode 100644
> index 0000000000..1175f68a51
> --- /dev/null
> +++ b/drivers/common/cnxk/cnxk_telemetry_nix.c
> @@ -0,0 +1,849 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2021 Marvell.
> + */
> +
> +#include "cnxk_telemetry.h"
> +#include "roc_api.h"
> +#include "roc_priv.h"
> +
> +struct nix_tel_node {
> +	TAILQ_ENTRY(nix_tel_node) node;
> +	struct roc_nix *nix;
> +	uint16_t n_rq;
> +	uint16_t n_cq;
> +	uint16_t n_sq;
> +	struct roc_nix_rq **rqs;
> +	struct roc_nix_cq **cqs;
> +	struct roc_nix_sq **sqs;
> +};
> +
> +TAILQ_HEAD(nix_tel_node_list, nix_tel_node); static struct
> +nix_tel_node_list nix_list;
> +
> +static struct nix_tel_node *
> +nix_tel_node_get(struct roc_nix *roc_nix) {
> +	struct nix_tel_node *node, *roc_node = NULL;
> +
> +	TAILQ_FOREACH(node, &nix_list, node) {
> +		if (node->nix == roc_nix) {
> +			roc_node = node;
> +			break;
> +		}
> +	}
> +
> +	return roc_node;
> +}
> +
> +int
> +nix_tel_node_add(struct roc_nix *roc_nix) {
> +	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
> +	struct nix_tel_node *node;
> +
> +	node = nix_tel_node_get(roc_nix);
> +	if (node) {
> +		if (nix->nb_rx_queues == node->n_rq &&
> +		    nix->nb_tx_queues == node->n_sq)
> +			return 0;
> +
> +		nix_tel_node_del(roc_nix);
> +	}
> +
> +	node = plt_zmalloc(sizeof(struct nix_tel_node), 0);
> +	if (!node)
> +		return -1;
> +
> +	node->nix = roc_nix;
> +	node->rqs =
> +		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_rq *),
> 0);
> +	node->cqs =
> +		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_cq *),
> 0);
> +	node->sqs =
> +		plt_zmalloc(nix->nb_tx_queues * sizeof(struct roc_nix_sq *),
> 0);
> +	TAILQ_INSERT_TAIL(&nix_list, node, node);
> +
> +	return 0;
> +}
> +
> +void
> +nix_tel_node_del(struct roc_nix *roc_nix) {
> +	struct nix_tel_node *node;
> +
> +	TAILQ_FOREACH(node, &nix_list, node) {
> +		if (node->nix == roc_nix) {
> +			plt_free(node->rqs);
> +			plt_free(node->cqs);
> +			plt_free(node->sqs);
> +			TAILQ_REMOVE(&nix_list, node, node);
> +		}
> +	}
> +
> +	plt_free(node);
> +}
> +
> +static struct nix_tel_node *
> +nix_tel_node_get_by_pcidev_name(const char *name) {
> +	struct nix_tel_node *node, *roc_node = NULL;
> +
> +	TAILQ_FOREACH(node, &nix_list, node) {
> +		if (!strncmp(node->nix->pci_dev->name, name,
> +			     PCI_PRI_STR_SIZE)) {
> +			roc_node = node;
> +			break;
> +		}
> +	}
> +
> +	return roc_node;
> +}
> +
> +int
> +nix_tel_node_add_rq(struct roc_nix_rq *rq) {
> +	struct nix_tel_node *node;
> +
> +	node = nix_tel_node_get(rq->roc_nix);
> +	if (!node)
> +		return -1;
> +
> +	node->rqs[rq->qid] = rq;
> +	node->n_rq++;
> +	return 0;
> +}
> +
> +int
> +nix_tel_node_add_cq(struct roc_nix_cq *cq) {
> +	struct nix_tel_node *node;
> +
> +	node = nix_tel_node_get(cq->roc_nix);
> +	if (!node)
> +		return -1;
> +
> +	node->cqs[cq->qid] = cq;
> +	node->n_cq++;
> +	return 0;
> +}
> +
> +int
> +nix_tel_node_add_sq(struct roc_nix_sq *sq) {
> +	struct nix_tel_node *node;
> +
> +	node = nix_tel_node_get(sq->roc_nix);
> +	if (!node)
> +		return -1;
> +
> +	node->sqs[sq->qid] = sq;
> +	node->n_sq++;
> +	return 0;
> +}
> +
> +static int
> +cnxk_tel_nix(struct roc_nix *roc_nix, struct plt_tel_data *d) {
> +	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
> +
> +	struct dev *dev = &nix->dev;
> +
> +	plt_tel_data_add_dict_ptr(d, "nix", nix);
> +	plt_tel_data_add_dict_int(d, "pf_func", dev->pf_func);
> +	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(dev->pf_func));
> +	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(dev->pf_func));
> +
> +	CNXK_TEL_DICT_PTR(d, dev, bar2);
> +	CNXK_TEL_DICT_PTR(d, dev, bar4);
> +	CNXK_TEL_DICT_INT(d, roc_nix, port_id);
> +	CNXK_TEL_DICT_INT(d, roc_nix, rss_tag_as_xor);
> +	CNXK_TEL_DICT_INT(d, roc_nix, max_sqb_count);
> +	CNXK_TEL_DICT_PTR(d, nix, pci_dev);
> +	CNXK_TEL_DICT_PTR(d, nix, base);
> +	CNXK_TEL_DICT_PTR(d, nix, lmt_base);
> +	CNXK_TEL_DICT_INT(d, nix, reta_sz);
> +	CNXK_TEL_DICT_INT(d, nix, tx_chan_base);
> +	CNXK_TEL_DICT_INT(d, nix, rx_chan_base);
> +	CNXK_TEL_DICT_INT(d, nix, nb_tx_queues);
> +	CNXK_TEL_DICT_INT(d, nix, nb_rx_queues);
> +	CNXK_TEL_DICT_INT(d, nix, lso_tsov6_idx);
> +	CNXK_TEL_DICT_INT(d, nix, lso_tsov4_idx);
> +
> +	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v4",
> +				  nix-
> >lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
> +	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v6",
> +				  nix-
> >lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
> +	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v4",
> +				  nix-
> >lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
> +	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v6",
> +				  nix-
> >lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
> +	plt_tel_data_add_dict_int(d, "lso_tun_v4v4",
> +				  nix-
> >lso_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
> +	plt_tel_data_add_dict_int(d, "lso_tun_v4v6",
> +				  nix-
> >lso_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
> +	plt_tel_data_add_dict_int(d, "lso_tun_v6v4",
> +				  nix-
> >lso_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
> +	plt_tel_data_add_dict_int(d, "lso_tun_v6v6",
> +				  nix-
> >lso_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
> +
> +	CNXK_TEL_DICT_INT(d, nix, lf_tx_stats);
> +	CNXK_TEL_DICT_INT(d, nix, lf_rx_stats);
> +	CNXK_TEL_DICT_INT(d, nix, cgx_links);
> +	CNXK_TEL_DICT_INT(d, nix, lbk_links);
> +	CNXK_TEL_DICT_INT(d, nix, sdp_links);
> +	CNXK_TEL_DICT_INT(d, nix, tx_link);
> +	CNXK_TEL_DICT_INT(d, nix, sqb_size);
> +	CNXK_TEL_DICT_INT(d, nix, msixoff);
> +	CNXK_TEL_DICT_INT(d, nix, cints);
> +	CNXK_TEL_DICT_INT(d, nix, qints);
> +	CNXK_TEL_DICT_INT(d, nix, sdp_link);
> +	CNXK_TEL_DICT_INT(d, nix, ptp_en);
> +	CNXK_TEL_DICT_INT(d, nix, rss_alg_idx);
> +	CNXK_TEL_DICT_INT(d, nix, tx_pause);
> +
> +	return 0;
> +}
> +
> +static int
> +cnxk_tel_nix_rq(struct roc_nix_rq *rq, struct plt_tel_data *d) {
> +	plt_tel_data_add_dict_ptr(d, "nix_rq", rq);
> +	CNXK_TEL_DICT_INT(d, rq, qid);
> +	CNXK_TEL_DICT_PTR(d, rq, aura_handle);
> +	CNXK_TEL_DICT_INT(d, rq, ipsech_ena);
> +	CNXK_TEL_DICT_INT(d, rq, first_skip);
> +	CNXK_TEL_DICT_INT(d, rq, later_skip);
> +	CNXK_TEL_DICT_INT(d, rq, lpb_size);
> +	CNXK_TEL_DICT_INT(d, rq, sso_ena);
> +	CNXK_TEL_DICT_INT(d, rq, tag_mask);
> +	CNXK_TEL_DICT_INT(d, rq, flow_tag_width);
> +	CNXK_TEL_DICT_INT(d, rq, tt);
> +	CNXK_TEL_DICT_INT(d, rq, hwgrp);
> +	CNXK_TEL_DICT_INT(d, rq, vwqe_ena);
> +	CNXK_TEL_DICT_INT(d, rq, vwqe_first_skip);
> +	CNXK_TEL_DICT_INT(d, rq, vwqe_max_sz_exp);
> +	CNXK_TEL_DICT_INT(d, rq, vwqe_wait_tmo);
> +	CNXK_TEL_DICT_INT(d, rq, vwqe_aura_handle);
> +	CNXK_TEL_DICT_PTR(d, rq, roc_nix);
> +
> +	return 0;
> +}
> +
> +static int
> +cnxk_tel_nix_cq(struct roc_nix_cq *cq, struct plt_tel_data *d) {
> +	plt_tel_data_add_dict_ptr(d, "nix_cq", cq);
> +	CNXK_TEL_DICT_INT(d, cq, qid);
> +	CNXK_TEL_DICT_INT(d, cq, nb_desc);
> +	CNXK_TEL_DICT_PTR(d, cq, roc_nix);
> +	CNXK_TEL_DICT_PTR(d, cq, door);
> +	CNXK_TEL_DICT_PTR(d, cq, status);
> +	CNXK_TEL_DICT_PTR(d, cq, wdata);
> +	CNXK_TEL_DICT_PTR(d, cq, desc_base);
> +	CNXK_TEL_DICT_INT(d, cq, qmask);
> +
> +	return 0;
> +}
> +
> +static int
> +cnxk_tel_nix_sq(struct roc_nix_sq *sq, struct plt_tel_data *d) {
> +	plt_tel_data_add_dict_ptr(d, "nix_sq", sq);
> +	CNXK_TEL_DICT_INT(d, sq, qid);
> +	CNXK_TEL_DICT_INT(d, sq, max_sqe_sz);
> +	CNXK_TEL_DICT_INT(d, sq, nb_desc);
> +	CNXK_TEL_DICT_INT(d, sq, sqes_per_sqb_log2);
> +	CNXK_TEL_DICT_PTR(d, sq, roc_nix);
> +	CNXK_TEL_DICT_PTR(d, sq, aura_handle);
> +	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs_adj);
> +	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs);
> +	CNXK_TEL_DICT_PTR(d, sq, io_addr);
> +	CNXK_TEL_DICT_PTR(d, sq, lmt_addr);
> +	CNXK_TEL_DICT_PTR(d, sq, sqe_mem);
> +	CNXK_TEL_DICT_PTR(d, sq, fc);
> +
> +	return 0;
> +}
> +
> +static void
> +nix_rq_ctx_cn9k(void *qctx, struct plt_tel_data *d) {
> +	struct nix_rq_ctx_s *ctx = (struct nix_rq_ctx_s *)qctx;
> +
> +	/* W0 */
> +	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, substream, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
> +
> +	/* W1 */
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
> +
> +	/* W2 */
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
> +
> +	/* W3 */
> +	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
> +
> +	/* W4 */
> +	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
> +
> +	/* W5 */
> +	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
> +
> +	/* W6 */
> +	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
> +
> +	/* W7 */
> +	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
> +
> +	/* W8 */
> +	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
> +
> +	/* W9 */
> +	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
> +
> +	/* W10 */
> +	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_); }
> +
> +static void
> +nix_rq_ctx(void *qctx, struct plt_tel_data *d) {
> +	struct nix_cn10k_rq_ctx_s *ctx = (struct nix_cn10k_rq_ctx_s *)qctx;
> +
> +	/* W0 */
> +	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, len_ol3_dis, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, len_ol4_dis, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, len_il3_dis, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, len_il4_dis, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, csum_ol4_dis, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, lenerr_dis, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0);
> +	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0);
> +	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0);
> +	CNXK_TEL_DICT_INT(d, ctx, ena, w0);
> +
> +	/* W1 */
> +	CNXK_TEL_DICT_INT(d, ctx, chi_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, ipsecd_drop_en, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, pb_stashing, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
> +
> +	/* W2 */
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, policer_ena, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, band_prof_id, w2_);
> +
> +	/* W3 */
> +	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
> +
> +	/* W4 */
> +	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
> +	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
> +
> +	/* W5 */
> +	CNXK_TEL_DICT_INT(d, ctx, vwqe_skip, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, max_vsize_exp, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, vtime_wait, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, vwqe_ena, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, ipsec_vwqe, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
> +	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
> +
> +	/* W6 */
> +	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
> +
> +	/* W7 */
> +	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
> +
> +	/* W8 */
> +	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
> +
> +	/* W9 */
> +	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
> +
> +	/* W10 */
> +	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_); }
> +
> +static int
> +cnxk_tel_nix_rq_ctx(struct roc_nix *roc_nix, uint8_t n, struct
> +plt_tel_data *d) {
> +	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
> +	struct dev *dev = &nix->dev;
> +	struct npa_lf *npa_lf;
> +	volatile void *qctx;
> +	int rc = -1;
> +
> +	npa_lf = idev_npa_obj_get();
> +	if (npa_lf == NULL)
> +		return NPA_ERR_DEVICE_NOT_BOUNDED;
> +
> +	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_RQ, n, &qctx);
> +	if (rc) {
> +		plt_err("Failed to get rq context");
> +		return rc;
> +	}
> +
> +	if (roc_model_is_cn9k())
> +		nix_rq_ctx_cn9k(&qctx, d);
> +	else
> +		nix_rq_ctx(&qctx, d);
> +
> +	return 0;
> +}
> +
> +static int
> +cnxk_tel_nix_cq_ctx(struct roc_nix *roc_nix, uint8_t n, struct
> +plt_tel_data *d) {
> +	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
> +	struct dev *dev = &nix->dev;
> +	struct npa_lf *npa_lf;
> +	volatile struct nix_cq_ctx_s *ctx;
> +	int rc = -1;
> +
> +	npa_lf = idev_npa_obj_get();
> +	if (npa_lf == NULL)
> +		return NPA_ERR_DEVICE_NOT_BOUNDED;
> +
> +	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_CQ, n, (void *)&ctx);
> +	if (rc) {
> +		plt_err("Failed to get cq context");
> +		return rc;
> +	}
> +
> +	/* W0 */
> +	CNXK_TEL_DICT_PTR(d, ctx, base, w0_);
> +
> +	/* W1 */
> +	CNXK_TEL_DICT_U64(d, ctx, wrptr, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, avg_con, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, cint_idx, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, cq_err, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, bpid, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, bp_ena, w1_);
> +
> +	/* W2 */
> +	CNXK_TEL_DICT_INT(d, ctx, update_time, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, avg_level, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, head, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, tail, w2_);
> +
> +	/* W3 */
> +	CNXK_TEL_DICT_INT(d, ctx, cq_err_int_ena, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, cq_err_int, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, qsize, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, caching, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, substream, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, ena, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, drop_ena, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, drop, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, bp, w3_);
> +
> +	return 0;
> +}
> +
> +static void
> +nix_sq_ctx_cn9k(void *qctx, struct plt_tel_data *d) {
> +	struct nix_sq_ctx_s *ctx = (struct nix_sq_ctx_s *)qctx;
> +
> +	/* W0 */
> +	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
> +
> +	/* W1 */
> +	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_rr_quantum, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
> +
> +	/* W2 */
> +	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count, w2_);
> +
> +	/* W3 */
> +	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
> +
> +	/* W4 */
> +	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
> +
> +	/* W5 */
> +	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
> +
> +	/* W6 */
> +	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
> +
> +	/* W7 */
> +	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
> +
> +	/* W8 */
> +	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
> +
> +	/* W9 */
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
> +
> +	/* W10 */
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
> +
> +	/* W11 */
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
> +
> +	/* W12 */
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
> +
> +	/* W14 */
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
> +
> +	/* W15 */
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_); }
> +
> +static void
> +nix_sq_ctx(void *qctx, struct plt_tel_data *d) {
> +	struct nix_cn10k_sq_ctx_s *ctx = (struct nix_cn10k_sq_ctx_s *)qctx;
> +
> +	/* W0 */
> +	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
> +	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
> +
> +	/* W1 */
> +	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_rr_weight, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
> +
> +	/* W2 */
> +	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_ub, w2_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_lb, w2_);
> +
> +	/* W3 */
> +	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
> +	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
> +
> +	/* W4 */
> +	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
> +
> +	/* W5 */
> +	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
> +
> +	/* W6 */
> +	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
> +
> +	/* W7 */
> +	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
> +
> +	/* W8 */
> +	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
> +
> +	/* W9 */
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
> +	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
> +
> +	/* W10 */
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
> +
> +	/* W11 */
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
> +
> +	/* W12 */
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
> +
> +	/* W14 */
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
> +
> +	/* W15 */
> +	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_); }
> +
> +static int
> +cnxk_tel_nix_sq_ctx(struct roc_nix *roc_nix, uint8_t n, struct
> +plt_tel_data *d) {
> +	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
> +	struct dev *dev = &nix->dev;
> +	struct npa_lf *npa_lf;
> +	volatile void *qctx;
> +	int rc = -1;
> +
> +	npa_lf = idev_npa_obj_get();
> +	if (npa_lf == NULL)
> +		return NPA_ERR_DEVICE_NOT_BOUNDED;
> +
> +	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_SQ, n, &qctx);
> +	if (rc) {
> +		plt_err("Failed to get rq context");
> +		return rc;
> +	}
> +
> +	if (roc_model_is_cn9k())
> +		nix_sq_ctx_cn9k(&qctx, d);
> +	else
> +		nix_sq_ctx(&qctx, d);
> +
> +	return 0;
> +}
> +
> +static int
> +cnxk_nix_tel_handle_list(const char *cmd __plt_unused,
> +			 const char *params __plt_unused,
> +			 struct plt_tel_data *d)
> +{
> +	struct nix_tel_node *node;
> +	struct roc_nix *roc_nix;
> +
> +	plt_tel_data_start_array(d, PLT_TEL_STRING_VAL);
> +
> +	TAILQ_FOREACH(node, &nix_list, node) {
> +		roc_nix = node->nix;
> +		plt_tel_data_add_array_string(d, roc_nix->pci_dev->name);
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +cnxk_nix_tel_handle_info(const char *cmd __plt_unused, const char
> *params,
> +			 struct plt_tel_data *d)
> +{
> +	char name[PCI_PRI_STR_SIZE];
> +	struct nix_tel_node *node;
> +
> +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> +		return -1;
> +
> +	plt_strlcpy(name, params, PCI_PRI_STR_SIZE);
> +
> +	node = nix_tel_node_get_by_pcidev_name(name);
> +	if (!node)
> +		return -1;
> +
> +	plt_tel_data_start_dict(d);
> +	return cnxk_tel_nix(node->nix, d);
> +}
> +
> +static int
> +cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
> +			   struct plt_tel_data *d)
> +{
> +	struct nix_tel_node *node;
> +	char *name, *param;
> +	char buf[1024];
> +	int rc = -1;
> +
> +	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> +		goto exit;
> +
> +	plt_strlcpy(buf, params, PCI_PRI_STR_SIZE + 1);
> +	name = strtok(buf, ",");
> +	param = strtok(NULL, "\0");
> +
> +	node = nix_tel_node_get_by_pcidev_name(name);
> +	if (!node)
> +		goto exit;
> +
> +	plt_tel_data_start_dict(d);
> +
> +	if (strstr(cmd, "rq")) {
> +		char *tok = strtok(param, ",");
> +		int rq;
> +
> +		if (!tok)
> +			goto exit;
> +
> +		rq = strtol(tok, NULL, 10);
> +		if ((node->n_rq <= rq) || (rq < 0))
> +			goto exit;
> +
> +		if (strstr(cmd, "ctx"))
> +			rc = cnxk_tel_nix_rq_ctx(node->nix, rq, d);
> +		else
> +			rc = cnxk_tel_nix_rq(node->rqs[rq], d);
> +
> +	} else if (strstr(cmd, "cq")) {
> +		char *tok = strtok(param, ",");
> +		int cq;
> +
> +		if (!tok)
> +			goto exit;
> +
> +		cq = strtol(tok, NULL, 10);
> +		if ((node->n_cq <= cq) || (cq < 0))
> +			goto exit;
> +
> +		if (strstr(cmd, "ctx"))
> +			rc = cnxk_tel_nix_cq_ctx(node->nix, cq, d);
> +		else
> +			rc = cnxk_tel_nix_cq(node->cqs[cq], d);
> +
> +	} else if (strstr(cmd, "sq")) {
> +		char *tok = strtok(param, ",");
> +		int sq;
> +
> +		if (!tok)
> +			goto exit;
> +
> +		sq = strtol(tok, NULL, 10);
> +		if ((node->n_sq <= sq) || (sq < 0))
> +			goto exit;
> +
> +		if (strstr(cmd, "ctx"))
> +			rc = cnxk_tel_nix_sq_ctx(node->nix, sq, d);
> +		else
> +			rc = cnxk_tel_nix_sq(node->sqs[sq], d);
> +	}
> +
> +exit:
> +	return rc;
> +}
> +
> +PLT_INIT(cnxk_telemetry_nix_init)
> +{
> +	TAILQ_INIT(&nix_list);
> +
> +	plt_telemetry_register_cmd(
> +		"/cnxk/nix/list", cnxk_nix_tel_handle_list,
> +		"Returns list of available NIX devices. Takes no parameters");
> +	plt_telemetry_register_cmd(
> +		"/cnxk/nix/info", cnxk_nix_tel_handle_info,
> +		"Returns nix information. Parameters: pci id");
> +	plt_telemetry_register_cmd(
> +		"/cnxk/nix/rq/info", cnxk_nix_tel_handle_info_x,
> +		"Returns nix rq information. Parameters: pci id, rq id");
> +	plt_telemetry_register_cmd(
> +		"/cnxk/nix/rq/ctx", cnxk_nix_tel_handle_info_x,
> +		"Returns nix rq context. Parameters: pci id, rq id");
> +	plt_telemetry_register_cmd(
> +		"/cnxk/nix/cq/info", cnxk_nix_tel_handle_info_x,
> +		"Returns nix cq information. Parameters: pci id, cq id");
> +	plt_telemetry_register_cmd(
> +		"/cnxk/nix/cq/ctx", cnxk_nix_tel_handle_info_x,
> +		"Returns nix cq context. Parameters: pci id, cq id");
> +	plt_telemetry_register_cmd(
> +		"/cnxk/nix/sq/info", cnxk_nix_tel_handle_info_x,
> +		"Returns nix sq information. Parameters: pci id, sq id");
> +	plt_telemetry_register_cmd(
> +		"/cnxk/nix/sq/ctx", cnxk_nix_tel_handle_info_x,
> +		"Returns nix sq context. Parameters: pci id, sq id"); }
> diff --git a/drivers/common/cnxk/meson.build
> b/drivers/common/cnxk/meson.build index f0a1c9f115..fe7a95b526 100644
> --- a/drivers/common/cnxk/meson.build
> +++ b/drivers/common/cnxk/meson.build
> @@ -65,6 +65,7 @@ sources = files(
>  sources += files('cnxk_security.c')
> 
>  # Telemetry common code
> -sources += files('cnxk_telemetry_npa.c')
> +sources += files('cnxk_telemetry_npa.c',
> +                 'cnxk_telemetry_nix.c')
> 
>  deps += ['bus_pci', 'net', 'telemetry'] diff --git
> a/drivers/common/cnxk/roc_nix.c b/drivers/common/cnxk/roc_nix.c index
> 3ab954e94d..17beb1a736 100644
> --- a/drivers/common/cnxk/roc_nix.c
> +++ b/drivers/common/cnxk/roc_nix.c
> @@ -178,6 +178,8 @@ roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t
> nb_rxq, uint32_t nb_txq,
>  	nix->sqs = plt_zmalloc(sizeof(struct roc_nix_sq *) * nb_txq, 0);
>  	if (!nix->sqs)
>  		return -ENOMEM;
> +
> +	nix_tel_node_add(roc_nix);
>  fail:
>  	return rc;
>  }
> @@ -413,6 +415,7 @@ roc_nix_dev_init(struct roc_nix *roc_nix)
>  dev_fini:
>  	rc |= dev_fini(dev, pci_dev);
>  fail:
> +	nix_tel_node_del(roc_nix);
>  	return rc;
>  }
> 
> diff --git a/drivers/common/cnxk/roc_nix_priv.h
> b/drivers/common/cnxk/roc_nix_priv.h
> index 2cd5a72347..ba639791ce 100644
> --- a/drivers/common/cnxk/roc_nix_priv.h
> +++ b/drivers/common/cnxk/roc_nix_priv.h
> @@ -424,4 +424,13 @@ int nix_lf_int_reg_dump(uintptr_t nix_lf_base,
> uint64_t *data, uint16_t qints,  int nix_q_ctx_get(struct dev *dev, uint8_t
> ctype, uint16_t qid,
>  		  __io void **ctx_p);
> 
> +/*
> + * Telemetry
> + */
> +int nix_tel_node_add(struct roc_nix *roc_nix); void
> +nix_tel_node_del(struct roc_nix *roc_nix); int
> +nix_tel_node_add_rq(struct roc_nix_rq *rq); int
> +nix_tel_node_add_cq(struct roc_nix_cq *cq); int
> +nix_tel_node_add_sq(struct roc_nix_sq *sq);
> +
>  #endif /* _ROC_NIX_PRIV_H_ */
> diff --git a/drivers/common/cnxk/roc_nix_queue.c
> b/drivers/common/cnxk/roc_nix_queue.c
> index 8fbb13ecbd..f546fc83c5 100644
> --- a/drivers/common/cnxk/roc_nix_queue.c
> +++ b/drivers/common/cnxk/roc_nix_queue.c
> @@ -387,7 +387,11 @@ roc_nix_rq_init(struct roc_nix *roc_nix, struct
> roc_nix_rq *rq, bool ena)
>  	if (rc)
>  		return rc;
> 
> -	return mbox_process(mbox);
> +	rc = mbox_process(mbox);
> +	if (rc)
> +		return rc;
> +
> +	return nix_tel_node_add_rq(rq);
>  }
> 
>  int
> @@ -415,7 +419,11 @@ roc_nix_rq_modify(struct roc_nix *roc_nix, struct
> roc_nix_rq *rq, bool ena)
>  	if (rc)
>  		return rc;
> 
> -	return mbox_process(mbox);
> +	rc = mbox_process(mbox);
> +	if (rc)
> +		return rc;
> +
> +	return nix_tel_node_add_rq(rq);
>  }
> 
>  int
> @@ -504,7 +512,7 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct
> roc_nix_cq *cq)
>  	if (rc)
>  		goto free_mem;
> 
> -	return 0;
> +	return nix_tel_node_add_cq(cq);
> 
>  free_mem:
>  	plt_free(cq->desc_base);
> @@ -884,6 +892,7 @@ roc_nix_sq_init(struct roc_nix *roc_nix, struct
> roc_nix_sq *sq)
>  					((qid & RVU_CN9K_LMT_SLOT_MASK)
> << 12));
>  	}
> 
> +	rc = nix_tel_node_add_sq(sq);
>  	return rc;
>  nomem:
>  	plt_free(sq->fc);
> diff --git a/drivers/common/cnxk/roc_platform.h
> b/drivers/common/cnxk/roc_platform.h
> index 57073d62aa..b95af115f7 100644
> --- a/drivers/common/cnxk/roc_platform.h
> +++ b/drivers/common/cnxk/roc_platform.h
> @@ -145,7 +145,10 @@
> 
>  #define plt_strlcpy rte_strlcpy
> 
> +#define PLT_TEL_STRING_VAL RTE_TEL_STRING_VAL
>  #define plt_tel_data		     rte_tel_data
> +#define plt_tel_data_start_array     rte_tel_data_start_array
> +#define plt_tel_data_add_array_string rte_tel_data_add_array_string
>  #define plt_tel_data_start_dict      rte_tel_data_start_dict
>  #define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
>  #define plt_tel_data_add_dict_ptr(d, n, v)			\
> --
> 2.25.1


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

* Re: [dpdk-dev] [EXT] [v9 3/4] mempool/cnxk: add telemetry endpoints mempool
  2021-09-29  6:55             ` [dpdk-dev] [v9 3/4] mempool/cnxk: add telemetry endpoints mempool Gowrishankar Muthukrishnan
@ 2021-10-14 16:43               ` Harman Kalra
  0 siblings, 0 replies; 121+ messages in thread
From: Harman Kalra @ 2021-10-14 16:43 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Jerin Jacob Kollanukkaran, Kiran Kumar Kokkilagadda,
	Nithin Kumar Dabilpuram, Sunil Kumar Kori,
	Satha Koteswara Rao Kottidi,
	Ashwin Sekhar Thalakalath Kottilveetil,
	Pavan Nikhilesh Bhagavatula, Gowrishankar Muthukrishnan



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Gowrishankar
> Muthukrishnan
> Sent: Wednesday, September 29, 2021 12:25 PM
> To: dev@dpdk.org
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Kiran Kumar
> Kokkilagadda <kirankumark@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpuram@marvell.com>; Sunil Kumar Kori <skori@marvell.com>; Satha
> Koteswara Rao Kottidi <skoteshwar@marvell.com>; Ashwin Sekhar
> Thalakalath Kottilveetil <asekhar@marvell.com>; Pavan Nikhilesh
> Bhagavatula <pbhagavatula@marvell.com>; Gowrishankar Muthukrishnan
> <gmuthukrishn@marvell.com>
> Subject: [EXT] [dpdk-dev] [v9 3/4] mempool/cnxk: add telemetry endpoints
> mempool
> 
> External Email
> 
> ----------------------------------------------------------------------
> Adding telemetry endpoints to cnxk mempool driver.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

LGTM

Reviewed-by: Harman Kalra <hkalra@marvell.com>

Thanks
Harman

> ---
>  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
> 
> 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',
>  )
> --
> 2.25.1


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

* Re: [dpdk-dev] [EXT] [v9 4/4] net/cnxk: add telemetry endpoints to ethdev
  2021-09-29  6:55             ` [dpdk-dev] [v9 4/4] net/cnxk: add telemetry endpoints to ethdev Gowrishankar Muthukrishnan
@ 2021-10-14 16:47               ` Harman Kalra
  0 siblings, 0 replies; 121+ messages in thread
From: Harman Kalra @ 2021-10-14 16:47 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Jerin Jacob Kollanukkaran, Kiran Kumar Kokkilagadda,
	Nithin Kumar Dabilpuram, Sunil Kumar Kori,
	Satha Koteswara Rao Kottidi,
	Ashwin Sekhar Thalakalath Kottilveetil,
	Pavan Nikhilesh Bhagavatula, Gowrishankar Muthukrishnan



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Gowrishankar
> Muthukrishnan
> Sent: Wednesday, September 29, 2021 12:25 PM
> To: dev@dpdk.org
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Kiran Kumar
> Kokkilagadda <kirankumark@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpuram@marvell.com>; Sunil Kumar Kori <skori@marvell.com>; Satha
> Koteswara Rao Kottidi <skoteshwar@marvell.com>; Ashwin Sekhar
> Thalakalath Kottilveetil <asekhar@marvell.com>; Pavan Nikhilesh
> Bhagavatula <pbhagavatula@marvell.com>; Gowrishankar Muthukrishnan
> <gmuthukrishn@marvell.com>
> Subject: [EXT] [dpdk-dev] [v9 4/4] net/cnxk: add telemetry endpoints to
> ethdev
> 
> External Email
> 
> ----------------------------------------------------------------------
> Add telemetry endpoints to ethdev.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

LGTM

Reviewed-by: Harman Kalra <hkalra@marvell.com>

Thanks
Harman

> ---
>  drivers/net/cnxk/cnxk_ethdev_telemetry.c | 93
> ++++++++++++++++++++++++
>  drivers/net/cnxk/meson.build             |  1 +
>  2 files changed, 94 insertions(+)
>  create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
> 
> diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> new file mode 100644
> index 0000000000..83bc65848c
> --- /dev/null
> +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
> @@ -0,0 +1,93 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2021 Marvell International Ltd.
> + */
> +
> +#include <rte_telemetry.h>
> +
> +#include "cnxk_ethdev.h"
> +
> +/* Macro to count no of words in eth_info_s size */
> +#define ETH_INFO_SZ                                                            \
> +	(RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) /         \
> +	 sizeof(uint64_t))
> +#define MACADDR_LEN 18
> +
> +static int
> +ethdev_tel_handle_info(const char *cmd __rte_unused,
> +		       const char *params __rte_unused, struct rte_tel_data *d)
> {
> +	struct rte_eth_dev *eth_dev;
> +	struct rte_tel_data *i_data;
> +	struct cnxk_eth_dev *dev;
> +	union eth_info_u {
> +		struct eth_info_s {
> +			/** PF/VF information */
> +			uint16_t pf_func;
> +			uint8_t max_mac_entries;
> +			bool dmac_filter_ena;
> +			uint8_t dmac_filter_count;
> +			uint8_t ptype_disable;
> +			bool scalar_ena;
> +			bool ptp_ena;
> +			/* Platform specific offload flags */
> +			uint16_t rx_offload_flags;
> +			uint16_t tx_offload_flags;
> +		} info;
> +		uint64_t val[ETH_INFO_SZ];
> +	} eth_info;
> +	struct eth_info_s *info;
> +	unsigned int i, j = 0;
> +	int n_ports;
> +
> +	n_ports = rte_eth_dev_count_avail();
> +	if (!n_ports) {
> +		plt_err("No active ethernet ports found.");
> +		return -1;
> +	}
> +
> +	rte_tel_data_start_dict(d);
> +	rte_tel_data_add_dict_int(d, "n_ports", n_ports);
> +
> +	i_data = rte_tel_data_alloc();
> +	rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
> +
> +	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
> +		/* Skip if port is unused */
> +		if (!rte_eth_dev_is_valid_port(i))
> +			continue;
> +
> +		eth_dev = &rte_eth_devices[i];
> +		if (eth_dev) {
> +			memset(&eth_info, 0, sizeof(eth_info));
> +			info = &eth_info.info;
> +			dev = cnxk_eth_pmd_priv(eth_dev);
> +			if (dev) {
> +				info->pf_func = roc_nix_get_pf_func(&dev-
> >nix);
> +				info->max_mac_entries = dev-
> >max_mac_entries;
> +				info->dmac_filter_ena = dev-
> >dmac_filter_enable;
> +				info->dmac_filter_count =
> +					dev->dmac_filter_count;
> +				info->ptype_disable = dev->ptype_disable;
> +				info->scalar_ena = dev->scalar_ena;
> +				info->ptp_ena = dev->ptp_en;
> +				info->rx_offload_flags = dev-
> >rx_offload_flags;
> +				info->tx_offload_flags = dev-
> >tx_offload_flags;
> +			}
> +
> +			for (j = 0; j < ETH_INFO_SZ; j++)
> +				rte_tel_data_add_array_u64(i_data,
> +							   eth_info.val[j]);
> +
> +			j++;
> +		}
> +	}
> +
> +	rte_tel_data_add_dict_container(d, "info", i_data, 0);
> +	return 0;
> +}
> +
> +RTE_INIT(cnxk_ethdev_init_telemetry)
> +{
> +	rte_telemetry_register_cmd("/cnxk/ethdev/info",
> ethdev_tel_handle_info,
> +				   "Returns ethdev device information"); }
> diff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build
> index d1d4b4e15e..5b3b8422fb 100644
> --- a/drivers/net/cnxk/meson.build
> +++ b/drivers/net/cnxk/meson.build
> @@ -13,6 +13,7 @@ sources = files(
>          'cnxk_ethdev_devargs.c',
>          'cnxk_ethdev_ops.c',
>          'cnxk_ethdev_sec.c',
> +        'cnxk_ethdev_telemetry.c',
>          'cnxk_link.c',
>          'cnxk_lookup.c',
>          'cnxk_ptp.c',
> --
> 2.25.1


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

* Re: [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info
  2021-09-29  4:25             ` [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info Gowrishankar Muthukrishnan
  2021-10-11 14:40               ` Ferruh Yigit
@ 2021-10-14 21:47               ` Ferruh Yigit
  1 sibling, 0 replies; 121+ messages in thread
From: Ferruh Yigit @ 2021-10-14 21:47 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev; +Cc: Thomas Monjalon, Andrew Rybchenko, jerinj

On 9/29/2021 5:25 AM, Gowrishankar Muthukrishnan wrote:
> Add telemetry endpoint /ethdev/info for device info.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.


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

* [dpdk-dev] [v10 0/4] cnxk: enable telemetry endpoints
  2021-09-29  6:54           ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
                               ` (3 preceding siblings ...)
  2021-09-29  6:55             ` [dpdk-dev] [v9 4/4] net/cnxk: add telemetry endpoints to ethdev Gowrishankar Muthukrishnan
@ 2021-10-19 11:27             ` Gowrishankar Muthukrishnan
  2021-10-19 11:27               ` [dpdk-dev] [v10 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
                                 ` (3 more replies)
  2021-10-19 16:42             ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Jerin Jacob
  5 siblings, 4 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-19 11:27 UTC (permalink / raw)
  To: dev
  Cc: jerinj, kirankumark, ndabilpuram, skori, skoteshwar, asekhar,
	pbhagavatula, hkalra, Gowrishankar Muthukrishnan

This patch series enables telemetry in cnxk for the following:
 - NPA LF
 - NIX LF
 - Mempool driver
 - Ethdev driver

Depends-on: series-18612 ("net/cnxk: support for inline ipsec")
Depends-on: patch-19248 ("ethdev: add telemetry endpoint for device info")
Depends-on: patch-19251 ("mempool: add telemetry endpoint for mempool info")

v10:
 - added list endpoints for pool and aura (npa)

Gowrishankar Muthukrishnan (4):
  common/cnxk: add telemetry endpoints to npa
  common/cnxk: add telemetry endpoints to nix
  mempool/cnxk: add telemetry endpoints mempool
  net/cnxk: add telemetry endpoints to ethdev

 drivers/common/cnxk/cnxk_telemetry.h          |  26 +
 drivers/common/cnxk/cnxk_telemetry_nix.c      | 849 ++++++++++++++++++
 drivers/common/cnxk/cnxk_telemetry_npa.c      | 260 ++++++
 drivers/common/cnxk/meson.build               |   6 +
 drivers/common/cnxk/roc_nix.c                 |   3 +
 drivers/common/cnxk/roc_nix_priv.h            |   9 +
 drivers/common/cnxk/roc_nix_queue.c           |  15 +-
 drivers/common/cnxk/roc_platform.h            |  17 +
 drivers/mempool/cnxk/cnxk_mempool_telemetry.c |  57 ++
 drivers/mempool/cnxk/meson.build              |   1 +
 drivers/net/cnxk/cnxk_ethdev_telemetry.c      |  93 ++
 drivers/net/cnxk/meson.build                  |   1 +
 12 files changed, 1334 insertions(+), 3 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
 create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c
 create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c

-- 
2.25.1


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

* [dpdk-dev] [v10 1/4] common/cnxk: add telemetry endpoints to npa
  2021-10-19 11:27             ` [dpdk-dev] [v10 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
@ 2021-10-19 11:27               ` Gowrishankar Muthukrishnan
  2021-10-19 11:27               ` [dpdk-dev] [v10 2/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
                                 ` (2 subsequent siblings)
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-19 11:27 UTC (permalink / raw)
  To: dev
  Cc: jerinj, kirankumark, ndabilpuram, skori, skoteshwar, asekhar,
	pbhagavatula, hkalra, Gowrishankar Muthukrishnan

Add telemetry endpoints to npa.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry.h     |  26 +++
 drivers/common/cnxk/cnxk_telemetry_npa.c | 260 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   5 +
 drivers/common/cnxk/roc_platform.h       |  15 ++
 4 files changed, 306 insertions(+)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c

diff --git a/drivers/common/cnxk/cnxk_telemetry.h b/drivers/common/cnxk/cnxk_telemetry.h
new file mode 100644
index 0000000000..1461fd893f
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2021 Marvell.
+ */
+
+#ifndef __CNXK_TELEMETRY_H_
+#define __CNXK_TELEMETRY_H_
+
+#define CNXK_TEL_STR(s)		  #s
+#define CNXK_TEL_STR_PREFIX(s, p) CNXK_TEL_STR(p##s)
+#define CNXK_TEL_DICT_INT(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_int(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_PTR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(p)->s)
+#define CNXK_TEL_DICT_BF_PTR(d, p, s, ...)                                     \
+	plt_tel_data_add_dict_ptr(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (void *)(uint64_t)(p)->s)
+#define CNXK_TEL_DICT_U64(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_u64(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),      \
+				  (p)->s)
+#define CNXK_TEL_DICT_STR(d, p, s, ...)                                        \
+	plt_tel_data_add_dict_string(d, CNXK_TEL_STR_PREFIX(s, __VA_ARGS__),   \
+				     (p)->s)
+
+#endif /* __CNXK_TELEMETRY_H_ */
diff --git a/drivers/common/cnxk/cnxk_telemetry_npa.c b/drivers/common/cnxk/cnxk_telemetry_npa.c
new file mode 100644
index 0000000000..ae515df84f
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_npa.c
@@ -0,0 +1,260 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+static int
+cnxk_tel_npa(struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int aura_cnt = 0;
+	uint32_t i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	for (i = 0; i < lf->nr_pools; i++) {
+		if (plt_bitmap_get(lf->npa_bmp, i))
+			continue;
+		aura_cnt++;
+	}
+
+	plt_tel_data_add_dict_ptr(d, "npa", lf);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
+	plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
+
+	CNXK_TEL_DICT_STR(d, lf->pci_dev, name, pcidev_);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
+	CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
+	CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
+	CNXK_TEL_DICT_PTR(d, lf, mbox);
+	CNXK_TEL_DICT_PTR(d, lf, base);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
+	CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
+	CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
+	CNXK_TEL_DICT_INT(d, lf, nr_pools);
+	CNXK_TEL_DICT_INT(d, lf, pf_func);
+	CNXK_TEL_DICT_INT(d, lf, aura_sz);
+	CNXK_TEL_DICT_INT(d, lf, qints);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
+{
+	__io struct npa_aura_s *aura;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (plt_bitmap_get(lf->npa_bmp, aura_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = aura_id;
+	req->ctype = NPA_AQ_CTYPE_AURA;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", aura_id);
+		return rc;
+	}
+
+	aura = &rsp->aura;
+	CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
+	CNXK_TEL_DICT_INT(d, aura, ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
+	CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
+	CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
+	CNXK_TEL_DICT_U64(d, aura, count, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
+	CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
+	CNXK_TEL_DICT_U64(d, aura, limit, w3_);
+	CNXK_TEL_DICT_INT(d, aura, bp, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
+	CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
+	CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
+	CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
+	CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
+	CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
+	CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
+
+	return 0;
+}
+
+static int
+cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
+{
+	__io struct npa_pool_s *pool;
+	struct npa_aq_enq_req *req;
+	struct npa_aq_enq_rsp *rsp;
+	struct npa_lf *lf;
+	int rc;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	if (plt_bitmap_get(lf->npa_bmp, pool_id))
+		return -1;
+
+	req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
+	if (!req) {
+		plt_err("Failed to alloc aq enq for npa");
+		return -1;
+	}
+
+	req->aura_id = pool_id;
+	req->ctype = NPA_AQ_CTYPE_POOL;
+	req->op = NPA_AQ_INSTOP_READ;
+
+	rc = mbox_process_msg(lf->mbox, (void *)&rsp);
+	if (rc) {
+		plt_err("Failed to get pool(%d) context", pool_id);
+		return rc;
+	}
+
+	pool = &rsp->pool;
+	CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
+	CNXK_TEL_DICT_INT(d, pool, ena, w1_);
+	CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
+	CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
+	CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
+	CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
+	CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
+	CNXK_TEL_DICT_INT(d, pool, shift, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
+	CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
+	CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
+	CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
+	CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
+	CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
+	CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
+	CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
+	CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_info(const char *cmd __plt_unused,
+			 const char *params __plt_unused,
+			 struct plt_tel_data *d)
+{
+	plt_tel_data_start_dict(d);
+	return cnxk_tel_npa(d);
+}
+
+static int
+cnxk_npa_tel_handle_aura_list(const char *cmd __plt_unused,
+			      const char *params __plt_unused,
+			      struct plt_tel_data *d)
+{
+	struct npa_lf *lf;
+	int i;
+
+	lf = idev_npa_obj_get();
+	if (lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	plt_tel_data_start_array(d, PLT_TEL_INT_VAL);
+
+	for (i = 0; i < (int)lf->nr_pools; i++)
+		if (!plt_bitmap_get(lf->npa_bmp, i))
+			rte_tel_data_add_array_int(d, i);
+
+	return 0;
+}
+
+static int
+cnxk_npa_tel_handle_pool_list(const char *cmd, const char *params,
+			      struct plt_tel_data *d)
+{
+	/* In current implementation, aura and pool ID mapped 1:1 */
+	return cnxk_npa_tel_handle_aura_list(cmd, params, d);
+}
+
+static int
+cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
+			   struct plt_tel_data *d)
+{
+	int id, rc;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	id = strtol(params, NULL, 10);
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "aura/info"))
+		rc = cnxk_tel_npa_aura(id, d);
+	else
+		rc = cnxk_tel_npa_pool(id, d);
+
+	return rc;
+}
+
+PLT_INIT(cnxk_telemetry_npa_init)
+{
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/info", cnxk_npa_tel_handle_info,
+		"Returns npa information. Takes no parameters");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/aura/list", cnxk_npa_tel_handle_aura_list,
+		"Returns list of npa aura id. Takes no parameters");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa aura information. Parameters: aura_id");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/pool/list", cnxk_npa_tel_handle_pool_list,
+		"Returns list of npa pool id. Takes no parameters");
+
+	plt_telemetry_register_cmd(
+		"/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
+		"Returns npa pool information. Parameters: pool_id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index 97db5f087b..d88cfbc7fa 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -71,3 +71,8 @@ includes += include_directories('../../bus/pci')
 includes += include_directories('../../../lib/net')
 includes += include_directories('../../../lib/ethdev')
 includes += include_directories('../../../lib/meter')
+
+# Telemetry common code
+sources += files('cnxk_telemetry_npa.c')
+
+deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 241655b334..59af6f4975 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -19,6 +19,7 @@
 #include <rte_pci.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "roc_bits.h"
 
@@ -51,6 +52,7 @@
 #define PLT_CACHE_LINE_SIZE      RTE_CACHE_LINE_SIZE
 #define BITMASK_ULL		 GENMASK_ULL
 #define PLT_ALIGN_CEIL		 RTE_ALIGN_CEIL
+#define PLT_INIT		 RTE_INIT
 
 /** Divide ceil */
 #define PLT_DIV_CEIL(x, y)			\
@@ -63,6 +65,7 @@
 #define __plt_cache_aligned __rte_cache_aligned
 #define __plt_always_inline __rte_always_inline
 #define __plt_packed	    __rte_packed
+#define __plt_unused	    __rte_unused
 #define __roc_api	    __rte_internal
 #define plt_iova_t	    rte_iova_t
 
@@ -142,6 +145,18 @@
 
 #define plt_strlcpy rte_strlcpy
 
+#define PLT_TEL_INT_VAL              RTE_TEL_INT_VAL
+#define plt_tel_data                 rte_tel_data
+#define plt_tel_data_start_array     rte_tel_data_start_array
+#define plt_tel_data_add_array_int   rte_tel_data_add_array_int
+#define plt_tel_data_start_dict      rte_tel_data_start_dict
+#define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
+#define plt_tel_data_add_dict_ptr(d, n, v)			\
+	rte_tel_data_add_dict_u64(d, n, (uint64_t)v)
+#define plt_tel_data_add_dict_string rte_tel_data_add_dict_string
+#define plt_tel_data_add_dict_u64    rte_tel_data_add_dict_u64
+#define plt_telemetry_register_cmd   rte_telemetry_register_cmd
+
 /* Log */
 extern int cnxk_logtype_base;
 extern int cnxk_logtype_mbox;
-- 
2.25.1


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

* [dpdk-dev] [v10 2/4] common/cnxk: add telemetry endpoints to nix
  2021-10-19 11:27             ` [dpdk-dev] [v10 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  2021-10-19 11:27               ` [dpdk-dev] [v10 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
@ 2021-10-19 11:27               ` Gowrishankar Muthukrishnan
  2021-10-19 11:27               ` [dpdk-dev] [v10 3/4] mempool/cnxk: add telemetry endpoints mempool Gowrishankar Muthukrishnan
  2021-10-19 11:27               ` [dpdk-dev] [v10 4/4] net/cnxk: add telemetry endpoints to ethdev Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-19 11:27 UTC (permalink / raw)
  To: dev
  Cc: jerinj, kirankumark, ndabilpuram, skori, skoteshwar, asekhar,
	pbhagavatula, hkalra, Gowrishankar Muthukrishnan

Add telemetry endpoints to nix.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Reviewed-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/common/cnxk/cnxk_telemetry_nix.c | 849 +++++++++++++++++++++++
 drivers/common/cnxk/meson.build          |   3 +-
 drivers/common/cnxk/roc_nix.c            |   3 +
 drivers/common/cnxk/roc_nix_priv.h       |   9 +
 drivers/common/cnxk/roc_nix_queue.c      |  15 +-
 drivers/common/cnxk/roc_platform.h       |   2 +
 6 files changed, 877 insertions(+), 4 deletions(-)
 create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c

diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c b/drivers/common/cnxk/cnxk_telemetry_nix.c
new file mode 100644
index 0000000000..1175f68a51
--- /dev/null
+++ b/drivers/common/cnxk/cnxk_telemetry_nix.c
@@ -0,0 +1,849 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include "cnxk_telemetry.h"
+#include "roc_api.h"
+#include "roc_priv.h"
+
+struct nix_tel_node {
+	TAILQ_ENTRY(nix_tel_node) node;
+	struct roc_nix *nix;
+	uint16_t n_rq;
+	uint16_t n_cq;
+	uint16_t n_sq;
+	struct roc_nix_rq **rqs;
+	struct roc_nix_cq **cqs;
+	struct roc_nix_sq **sqs;
+};
+
+TAILQ_HEAD(nix_tel_node_list, nix_tel_node);
+static struct nix_tel_node_list nix_list;
+
+static struct nix_tel_node *
+nix_tel_node_get(struct roc_nix *roc_nix)
+{
+	struct nix_tel_node *node, *roc_node = NULL;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (node->nix == roc_nix) {
+			roc_node = node;
+			break;
+		}
+	}
+
+	return roc_node;
+}
+
+int
+nix_tel_node_add(struct roc_nix *roc_nix)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(roc_nix);
+	if (node) {
+		if (nix->nb_rx_queues == node->n_rq &&
+		    nix->nb_tx_queues == node->n_sq)
+			return 0;
+
+		nix_tel_node_del(roc_nix);
+	}
+
+	node = plt_zmalloc(sizeof(struct nix_tel_node), 0);
+	if (!node)
+		return -1;
+
+	node->nix = roc_nix;
+	node->rqs =
+		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_rq *), 0);
+	node->cqs =
+		plt_zmalloc(nix->nb_rx_queues * sizeof(struct roc_nix_cq *), 0);
+	node->sqs =
+		plt_zmalloc(nix->nb_tx_queues * sizeof(struct roc_nix_sq *), 0);
+	TAILQ_INSERT_TAIL(&nix_list, node, node);
+
+	return 0;
+}
+
+void
+nix_tel_node_del(struct roc_nix *roc_nix)
+{
+	struct nix_tel_node *node;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (node->nix == roc_nix) {
+			plt_free(node->rqs);
+			plt_free(node->cqs);
+			plt_free(node->sqs);
+			TAILQ_REMOVE(&nix_list, node, node);
+		}
+	}
+
+	plt_free(node);
+}
+
+static struct nix_tel_node *
+nix_tel_node_get_by_pcidev_name(const char *name)
+{
+	struct nix_tel_node *node, *roc_node = NULL;
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		if (!strncmp(node->nix->pci_dev->name, name,
+			     PCI_PRI_STR_SIZE)) {
+			roc_node = node;
+			break;
+		}
+	}
+
+	return roc_node;
+}
+
+int
+nix_tel_node_add_rq(struct roc_nix_rq *rq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(rq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->rqs[rq->qid] = rq;
+	node->n_rq++;
+	return 0;
+}
+
+int
+nix_tel_node_add_cq(struct roc_nix_cq *cq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(cq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->cqs[cq->qid] = cq;
+	node->n_cq++;
+	return 0;
+}
+
+int
+nix_tel_node_add_sq(struct roc_nix_sq *sq)
+{
+	struct nix_tel_node *node;
+
+	node = nix_tel_node_get(sq->roc_nix);
+	if (!node)
+		return -1;
+
+	node->sqs[sq->qid] = sq;
+	node->n_sq++;
+	return 0;
+}
+
+static int
+cnxk_tel_nix(struct roc_nix *roc_nix, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+
+	struct dev *dev = &nix->dev;
+
+	plt_tel_data_add_dict_ptr(d, "nix", nix);
+	plt_tel_data_add_dict_int(d, "pf_func", dev->pf_func);
+	plt_tel_data_add_dict_int(d, "pf", dev_get_pf(dev->pf_func));
+	plt_tel_data_add_dict_int(d, "vf", dev_get_vf(dev->pf_func));
+
+	CNXK_TEL_DICT_PTR(d, dev, bar2);
+	CNXK_TEL_DICT_PTR(d, dev, bar4);
+	CNXK_TEL_DICT_INT(d, roc_nix, port_id);
+	CNXK_TEL_DICT_INT(d, roc_nix, rss_tag_as_xor);
+	CNXK_TEL_DICT_INT(d, roc_nix, max_sqb_count);
+	CNXK_TEL_DICT_PTR(d, nix, pci_dev);
+	CNXK_TEL_DICT_PTR(d, nix, base);
+	CNXK_TEL_DICT_PTR(d, nix, lmt_base);
+	CNXK_TEL_DICT_INT(d, nix, reta_sz);
+	CNXK_TEL_DICT_INT(d, nix, tx_chan_base);
+	CNXK_TEL_DICT_INT(d, nix, rx_chan_base);
+	CNXK_TEL_DICT_INT(d, nix, nb_tx_queues);
+	CNXK_TEL_DICT_INT(d, nix, nb_rx_queues);
+	CNXK_TEL_DICT_INT(d, nix, lso_tsov6_idx);
+	CNXK_TEL_DICT_INT(d, nix, lso_tsov4_idx);
+
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v4",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v4v6",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v4",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	plt_tel_data_add_dict_int(d, "lso_udp_tun_v6v6",
+				  nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v4v4",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V4]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v4v6",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V6]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v6v4",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V4]);
+	plt_tel_data_add_dict_int(d, "lso_tun_v6v6",
+				  nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V6]);
+
+	CNXK_TEL_DICT_INT(d, nix, lf_tx_stats);
+	CNXK_TEL_DICT_INT(d, nix, lf_rx_stats);
+	CNXK_TEL_DICT_INT(d, nix, cgx_links);
+	CNXK_TEL_DICT_INT(d, nix, lbk_links);
+	CNXK_TEL_DICT_INT(d, nix, sdp_links);
+	CNXK_TEL_DICT_INT(d, nix, tx_link);
+	CNXK_TEL_DICT_INT(d, nix, sqb_size);
+	CNXK_TEL_DICT_INT(d, nix, msixoff);
+	CNXK_TEL_DICT_INT(d, nix, cints);
+	CNXK_TEL_DICT_INT(d, nix, qints);
+	CNXK_TEL_DICT_INT(d, nix, sdp_link);
+	CNXK_TEL_DICT_INT(d, nix, ptp_en);
+	CNXK_TEL_DICT_INT(d, nix, rss_alg_idx);
+	CNXK_TEL_DICT_INT(d, nix, tx_pause);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_rq(struct roc_nix_rq *rq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_rq", rq);
+	CNXK_TEL_DICT_INT(d, rq, qid);
+	CNXK_TEL_DICT_PTR(d, rq, aura_handle);
+	CNXK_TEL_DICT_INT(d, rq, ipsech_ena);
+	CNXK_TEL_DICT_INT(d, rq, first_skip);
+	CNXK_TEL_DICT_INT(d, rq, later_skip);
+	CNXK_TEL_DICT_INT(d, rq, lpb_size);
+	CNXK_TEL_DICT_INT(d, rq, sso_ena);
+	CNXK_TEL_DICT_INT(d, rq, tag_mask);
+	CNXK_TEL_DICT_INT(d, rq, flow_tag_width);
+	CNXK_TEL_DICT_INT(d, rq, tt);
+	CNXK_TEL_DICT_INT(d, rq, hwgrp);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_ena);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_first_skip);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_max_sz_exp);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_wait_tmo);
+	CNXK_TEL_DICT_INT(d, rq, vwqe_aura_handle);
+	CNXK_TEL_DICT_PTR(d, rq, roc_nix);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_cq(struct roc_nix_cq *cq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_cq", cq);
+	CNXK_TEL_DICT_INT(d, cq, qid);
+	CNXK_TEL_DICT_INT(d, cq, nb_desc);
+	CNXK_TEL_DICT_PTR(d, cq, roc_nix);
+	CNXK_TEL_DICT_PTR(d, cq, door);
+	CNXK_TEL_DICT_PTR(d, cq, status);
+	CNXK_TEL_DICT_PTR(d, cq, wdata);
+	CNXK_TEL_DICT_PTR(d, cq, desc_base);
+	CNXK_TEL_DICT_INT(d, cq, qmask);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_sq(struct roc_nix_sq *sq, struct plt_tel_data *d)
+{
+	plt_tel_data_add_dict_ptr(d, "nix_sq", sq);
+	CNXK_TEL_DICT_INT(d, sq, qid);
+	CNXK_TEL_DICT_INT(d, sq, max_sqe_sz);
+	CNXK_TEL_DICT_INT(d, sq, nb_desc);
+	CNXK_TEL_DICT_INT(d, sq, sqes_per_sqb_log2);
+	CNXK_TEL_DICT_PTR(d, sq, roc_nix);
+	CNXK_TEL_DICT_PTR(d, sq, aura_handle);
+	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs_adj);
+	CNXK_TEL_DICT_INT(d, sq, nb_sqb_bufs);
+	CNXK_TEL_DICT_PTR(d, sq, io_addr);
+	CNXK_TEL_DICT_PTR(d, sq, lmt_addr);
+	CNXK_TEL_DICT_PTR(d, sq, sqe_mem);
+	CNXK_TEL_DICT_PTR(d, sq, fc);
+
+	return 0;
+}
+
+static void
+nix_rq_ctx_cn9k(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_rq_ctx_s *ctx = (struct nix_rq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
+	CNXK_TEL_DICT_BF_PTR(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_);
+}
+
+static void
+nix_rq_ctx(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_cn10k_rq_ctx_s *ctx = (struct nix_cn10k_rq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, wqe_aura, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_ol3_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_ol4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_il3_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, len_il4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, csum_ol4_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, lenerr_dis, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena_wqwd, w0);
+	CNXK_TEL_DICT_INT(d, ctx, ipsech_ena, w0);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w0);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, chi_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsecd_drop_en, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_stashing, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, pb_caching, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_tt, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_grp, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, xqe_hdr_split, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_copy, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_imm_size, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, later_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, first_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_skip, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_sizem1, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, policer_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, band_prof_id, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, spb_aura_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, wqe_pool_drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_pass, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, xqe_drop, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int_ena, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, rq_int, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_pool_drop, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_pass, w4_);
+	CNXK_TEL_DICT_INT(d, ctx, lpb_aura_drop, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_INT(d, ctx, vwqe_skip, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, max_vsize_exp, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, vtime_wait, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, vwqe_ena, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ipsec_vwqe, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, flow_tagw, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, bad_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, good_utag, w5_);
+	CNXK_TEL_DICT_INT(d, ctx, ltag, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_U64(d, ctx, octs, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_U64(d, ctx, pkts, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_octs, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_U64(d, ctx, drop_pkts, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_U64(d, ctx, re_pkts, w10_);
+}
+
+static int
+cnxk_tel_nix_rq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile void *qctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_RQ, n, &qctx);
+	if (rc) {
+		plt_err("Failed to get rq context");
+		return rc;
+	}
+
+	if (roc_model_is_cn9k())
+		nix_rq_ctx_cn9k(&qctx, d);
+	else
+		nix_rq_ctx(&qctx, d);
+
+	return 0;
+}
+
+static int
+cnxk_tel_nix_cq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile struct nix_cq_ctx_s *ctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_CQ, n, (void *)&ctx);
+	if (rc) {
+		plt_err("Failed to get cq context");
+		return rc;
+	}
+
+	/* W0 */
+	CNXK_TEL_DICT_PTR(d, ctx, base, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_U64(d, ctx, wrptr, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, avg_con, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cint_idx, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_err, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, bpid, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, bp_ena, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, update_time, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, avg_level, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, head, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, tail, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, cq_err_int_ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_err_int, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, qsize, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, caching, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, drop_ena, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, drop, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, bp, w3_);
+
+	return 0;
+}
+
+static void
+nix_sq_ctx_cn9k(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_sq_ctx_s *ctx = (struct nix_sq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_quantum, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
+
+	/* W11 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
+
+	/* W12 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
+
+	/* W14 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
+
+	/* W15 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_);
+}
+
+static void
+nix_sq_ctx(void *qctx, struct plt_tel_data *d)
+{
+	struct nix_cn10k_sq_ctx_s *ctx = (struct nix_cn10k_sq_ctx_s *)qctx;
+
+	/* W0 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_way_mask, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, cq, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, sdp_mcast, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, substream, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, qint_idx, w0_);
+	CNXK_TEL_DICT_INT(d, ctx, ena, w0_);
+
+	/* W1 */
+	CNXK_TEL_DICT_INT(d, ctx, sqb_count, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, default_chan, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_weight, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, sso_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, xoff, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_ena, w1_);
+	CNXK_TEL_DICT_INT(d, ctx, smq, w1_);
+
+	/* W2 */
+	CNXK_TEL_DICT_INT(d, ctx, sqe_stype, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int_ena, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sq_int, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, sqb_aura, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_ub, w2_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_rr_count_lb, w2_);
+
+	/* W3 */
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_pend, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_next_sqb_vld, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, head_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smenq_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, tail_offset, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_lso_segnum, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, smq_next_sq, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, mnq_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, lmt_dis, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, cq_limit, w3_);
+	CNXK_TEL_DICT_INT(d, ctx, max_sqe_size, w3_);
+
+	/* W4 */
+	CNXK_TEL_DICT_PTR(d, ctx, next_sqb, w4_);
+
+	/* W5 */
+	CNXK_TEL_DICT_PTR(d, ctx, tail_sqb, w5_);
+
+	/* W6 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_sqb, w6_);
+
+	/* W7 */
+	CNXK_TEL_DICT_PTR(d, ctx, smenq_next_sqb, w7_);
+
+	/* W8 */
+	CNXK_TEL_DICT_PTR(d, ctx, head_sqb, w8_);
+
+	/* W9 */
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vld, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan1_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_vlan0_ins_ena, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_mps, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sb, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_sizem1, w9_);
+	CNXK_TEL_DICT_INT(d, ctx, vfi_lso_total, w9_);
+
+	/* W10 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, scm_lso_rem, w10_);
+
+	/* W11 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, octs, w11_);
+
+	/* W12 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, pkts, w12_);
+
+	/* W14 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_octs, w14_);
+
+	/* W15 */
+	CNXK_TEL_DICT_BF_PTR(d, ctx, drop_pkts, w15_);
+}
+
+static int
+cnxk_tel_nix_sq_ctx(struct roc_nix *roc_nix, uint8_t n, struct plt_tel_data *d)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+	struct npa_lf *npa_lf;
+	volatile void *qctx;
+	int rc = -1;
+
+	npa_lf = idev_npa_obj_get();
+	if (npa_lf == NULL)
+		return NPA_ERR_DEVICE_NOT_BOUNDED;
+
+	rc = nix_q_ctx_get(dev, NIX_AQ_CTYPE_SQ, n, &qctx);
+	if (rc) {
+		plt_err("Failed to get rq context");
+		return rc;
+	}
+
+	if (roc_model_is_cn9k())
+		nix_sq_ctx_cn9k(&qctx, d);
+	else
+		nix_sq_ctx(&qctx, d);
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_list(const char *cmd __plt_unused,
+			 const char *params __plt_unused,
+			 struct plt_tel_data *d)
+{
+	struct nix_tel_node *node;
+	struct roc_nix *roc_nix;
+
+	plt_tel_data_start_array(d, PLT_TEL_STRING_VAL);
+
+	TAILQ_FOREACH(node, &nix_list, node) {
+		roc_nix = node->nix;
+		plt_tel_data_add_array_string(d, roc_nix->pci_dev->name);
+	}
+
+	return 0;
+}
+
+static int
+cnxk_nix_tel_handle_info(const char *cmd __plt_unused, const char *params,
+			 struct plt_tel_data *d)
+{
+	char name[PCI_PRI_STR_SIZE];
+	struct nix_tel_node *node;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -1;
+
+	plt_strlcpy(name, params, PCI_PRI_STR_SIZE);
+
+	node = nix_tel_node_get_by_pcidev_name(name);
+	if (!node)
+		return -1;
+
+	plt_tel_data_start_dict(d);
+	return cnxk_tel_nix(node->nix, d);
+}
+
+static int
+cnxk_nix_tel_handle_info_x(const char *cmd, const char *params,
+			   struct plt_tel_data *d)
+{
+	struct nix_tel_node *node;
+	char *name, *param;
+	char buf[1024];
+	int rc = -1;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		goto exit;
+
+	plt_strlcpy(buf, params, PCI_PRI_STR_SIZE + 1);
+	name = strtok(buf, ",");
+	param = strtok(NULL, "\0");
+
+	node = nix_tel_node_get_by_pcidev_name(name);
+	if (!node)
+		goto exit;
+
+	plt_tel_data_start_dict(d);
+
+	if (strstr(cmd, "rq")) {
+		char *tok = strtok(param, ",");
+		int rq;
+
+		if (!tok)
+			goto exit;
+
+		rq = strtol(tok, NULL, 10);
+		if ((node->n_rq <= rq) || (rq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_rq_ctx(node->nix, rq, d);
+		else
+			rc = cnxk_tel_nix_rq(node->rqs[rq], d);
+
+	} else if (strstr(cmd, "cq")) {
+		char *tok = strtok(param, ",");
+		int cq;
+
+		if (!tok)
+			goto exit;
+
+		cq = strtol(tok, NULL, 10);
+		if ((node->n_cq <= cq) || (cq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_cq_ctx(node->nix, cq, d);
+		else
+			rc = cnxk_tel_nix_cq(node->cqs[cq], d);
+
+	} else if (strstr(cmd, "sq")) {
+		char *tok = strtok(param, ",");
+		int sq;
+
+		if (!tok)
+			goto exit;
+
+		sq = strtol(tok, NULL, 10);
+		if ((node->n_sq <= sq) || (sq < 0))
+			goto exit;
+
+		if (strstr(cmd, "ctx"))
+			rc = cnxk_tel_nix_sq_ctx(node->nix, sq, d);
+		else
+			rc = cnxk_tel_nix_sq(node->sqs[sq], d);
+	}
+
+exit:
+	return rc;
+}
+
+PLT_INIT(cnxk_telemetry_nix_init)
+{
+	TAILQ_INIT(&nix_list);
+
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/list", cnxk_nix_tel_handle_list,
+		"Returns list of available NIX devices. Takes no parameters");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/info", cnxk_nix_tel_handle_info,
+		"Returns nix information. Parameters: pci id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/rq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix rq information. Parameters: pci id, rq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/rq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix rq context. Parameters: pci id, rq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/cq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix cq information. Parameters: pci id, cq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/cq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix cq context. Parameters: pci id, cq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/sq/info", cnxk_nix_tel_handle_info_x,
+		"Returns nix sq information. Parameters: pci id, sq id");
+	plt_telemetry_register_cmd(
+		"/cnxk/nix/sq/ctx", cnxk_nix_tel_handle_info_x,
+		"Returns nix sq context. Parameters: pci id, sq id");
+}
diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build
index d88cfbc7fa..7b8a4c6633 100644
--- a/drivers/common/cnxk/meson.build
+++ b/drivers/common/cnxk/meson.build
@@ -73,6 +73,7 @@ includes += include_directories('../../../lib/ethdev')
 includes += include_directories('../../../lib/meter')
 
 # Telemetry common code
-sources += files('cnxk_telemetry_npa.c')
+sources += files('cnxk_telemetry_npa.c',
+                 'cnxk_telemetry_nix.c')
 
 deps += ['bus_pci', 'net', 'telemetry']
diff --git a/drivers/common/cnxk/roc_nix.c b/drivers/common/cnxk/roc_nix.c
index b7ef843b4b..64156ceb19 100644
--- a/drivers/common/cnxk/roc_nix.c
+++ b/drivers/common/cnxk/roc_nix.c
@@ -184,6 +184,8 @@ roc_nix_lf_alloc(struct roc_nix *roc_nix, uint32_t nb_rxq, uint32_t nb_txq,
 	nix->sqs = plt_zmalloc(sizeof(struct roc_nix_sq *) * nb_txq, 0);
 	if (!nix->sqs)
 		return -ENOMEM;
+
+	nix_tel_node_add(roc_nix);
 fail:
 	return rc;
 }
@@ -419,6 +421,7 @@ roc_nix_dev_init(struct roc_nix *roc_nix)
 dev_fini:
 	rc |= dev_fini(dev, pci_dev);
 fail:
+	nix_tel_node_del(roc_nix);
 	return rc;
 }
 
diff --git a/drivers/common/cnxk/roc_nix_priv.h b/drivers/common/cnxk/roc_nix_priv.h
index 8beb5454b7..2f5eefd6ec 100644
--- a/drivers/common/cnxk/roc_nix_priv.h
+++ b/drivers/common/cnxk/roc_nix_priv.h
@@ -427,4 +427,13 @@ int nix_lf_int_reg_dump(uintptr_t nix_lf_base, uint64_t *data, uint16_t qints,
 int nix_q_ctx_get(struct dev *dev, uint8_t ctype, uint16_t qid,
 		  __io void **ctx_p);
 
+/*
+ * Telemetry
+ */
+int nix_tel_node_add(struct roc_nix *roc_nix);
+void nix_tel_node_del(struct roc_nix *roc_nix);
+int nix_tel_node_add_rq(struct roc_nix_rq *rq);
+int nix_tel_node_add_cq(struct roc_nix_cq *cq);
+int nix_tel_node_add_sq(struct roc_nix_sq *sq);
+
 #endif /* _ROC_NIX_PRIV_H_ */
diff --git a/drivers/common/cnxk/roc_nix_queue.c b/drivers/common/cnxk/roc_nix_queue.c
index 422eef124c..0510f9692e 100644
--- a/drivers/common/cnxk/roc_nix_queue.c
+++ b/drivers/common/cnxk/roc_nix_queue.c
@@ -387,7 +387,11 @@ roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
 	if (rc)
 		return rc;
 
-	return mbox_process(mbox);
+	rc = mbox_process(mbox);
+	if (rc)
+		return rc;
+
+	return nix_tel_node_add_rq(rq);
 }
 
 int
@@ -415,7 +419,11 @@ roc_nix_rq_modify(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
 	if (rc)
 		return rc;
 
-	return mbox_process(mbox);
+	rc = mbox_process(mbox);
+	if (rc)
+		return rc;
+
+	return nix_tel_node_add_rq(rq);
 }
 
 int
@@ -504,7 +512,7 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq)
 	if (rc)
 		goto free_mem;
 
-	return 0;
+	return nix_tel_node_add_cq(cq);
 
 free_mem:
 	plt_free(cq->desc_base);
@@ -888,6 +896,7 @@ roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq)
 					((qid & RVU_CN9K_LMT_SLOT_MASK) << 12));
 	}
 
+	rc = nix_tel_node_add_sq(sq);
 	return rc;
 nomem:
 	plt_free(sq->fc);
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 59af6f4975..731c5bc3b3 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -146,9 +146,11 @@
 #define plt_strlcpy rte_strlcpy
 
 #define PLT_TEL_INT_VAL              RTE_TEL_INT_VAL
+#define PLT_TEL_STRING_VAL           RTE_TEL_STRING_VAL
 #define plt_tel_data                 rte_tel_data
 #define plt_tel_data_start_array     rte_tel_data_start_array
 #define plt_tel_data_add_array_int   rte_tel_data_add_array_int
+#define plt_tel_data_add_array_string rte_tel_data_add_array_string
 #define plt_tel_data_start_dict      rte_tel_data_start_dict
 #define plt_tel_data_add_dict_int    rte_tel_data_add_dict_int
 #define plt_tel_data_add_dict_ptr(d, n, v)			\
-- 
2.25.1


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

* [dpdk-dev] [v10 3/4] mempool/cnxk: add telemetry endpoints mempool
  2021-10-19 11:27             ` [dpdk-dev] [v10 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
  2021-10-19 11:27               ` [dpdk-dev] [v10 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
  2021-10-19 11:27               ` [dpdk-dev] [v10 2/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
@ 2021-10-19 11:27               ` Gowrishankar Muthukrishnan
  2021-10-19 11:27               ` [dpdk-dev] [v10 4/4] net/cnxk: add telemetry endpoints to ethdev Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-19 11:27 UTC (permalink / raw)
  To: dev
  Cc: jerinj, kirankumark, ndabilpuram, skori, skoteshwar, asekhar,
	pbhagavatula, hkalra, Gowrishankar Muthukrishnan

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

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',
 )
-- 
2.25.1


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

* [dpdk-dev] [v10 4/4] net/cnxk: add telemetry endpoints to ethdev
  2021-10-19 11:27             ` [dpdk-dev] [v10 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
                                 ` (2 preceding siblings ...)
  2021-10-19 11:27               ` [dpdk-dev] [v10 3/4] mempool/cnxk: add telemetry endpoints mempool Gowrishankar Muthukrishnan
@ 2021-10-19 11:27               ` Gowrishankar Muthukrishnan
  3 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-19 11:27 UTC (permalink / raw)
  To: dev
  Cc: jerinj, kirankumark, ndabilpuram, skori, skoteshwar, asekhar,
	pbhagavatula, hkalra, Gowrishankar Muthukrishnan

Add telemetry endpoints to ethdev.

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

diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
new file mode 100644
index 0000000000..83bc65848c
--- /dev/null
+++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c
@@ -0,0 +1,93 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell International Ltd.
+ */
+
+#include <rte_telemetry.h>
+
+#include "cnxk_ethdev.h"
+
+/* Macro to count no of words in eth_info_s size */
+#define ETH_INFO_SZ                                                            \
+	(RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) /         \
+	 sizeof(uint64_t))
+#define MACADDR_LEN 18
+
+static int
+ethdev_tel_handle_info(const char *cmd __rte_unused,
+		       const char *params __rte_unused, struct rte_tel_data *d)
+{
+	struct rte_eth_dev *eth_dev;
+	struct rte_tel_data *i_data;
+	struct cnxk_eth_dev *dev;
+	union eth_info_u {
+		struct eth_info_s {
+			/** PF/VF information */
+			uint16_t pf_func;
+			uint8_t max_mac_entries;
+			bool dmac_filter_ena;
+			uint8_t dmac_filter_count;
+			uint8_t ptype_disable;
+			bool scalar_ena;
+			bool ptp_ena;
+			/* Platform specific offload flags */
+			uint16_t rx_offload_flags;
+			uint16_t tx_offload_flags;
+		} info;
+		uint64_t val[ETH_INFO_SZ];
+	} eth_info;
+	struct eth_info_s *info;
+	unsigned int i, j = 0;
+	int n_ports;
+
+	n_ports = rte_eth_dev_count_avail();
+	if (!n_ports) {
+		plt_err("No active ethernet ports found.");
+		return -1;
+	}
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_int(d, "n_ports", n_ports);
+
+	i_data = rte_tel_data_alloc();
+	rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
+		/* Skip if port is unused */
+		if (!rte_eth_dev_is_valid_port(i))
+			continue;
+
+		eth_dev = &rte_eth_devices[i];
+		if (eth_dev) {
+			memset(&eth_info, 0, sizeof(eth_info));
+			info = &eth_info.info;
+			dev = cnxk_eth_pmd_priv(eth_dev);
+			if (dev) {
+				info->pf_func = roc_nix_get_pf_func(&dev->nix);
+				info->max_mac_entries = dev->max_mac_entries;
+				info->dmac_filter_ena = dev->dmac_filter_enable;
+				info->dmac_filter_count =
+					dev->dmac_filter_count;
+				info->ptype_disable = dev->ptype_disable;
+				info->scalar_ena = dev->scalar_ena;
+				info->ptp_ena = dev->ptp_en;
+				info->rx_offload_flags = dev->rx_offload_flags;
+				info->tx_offload_flags = dev->tx_offload_flags;
+			}
+
+			for (j = 0; j < ETH_INFO_SZ; j++)
+				rte_tel_data_add_array_u64(i_data,
+							   eth_info.val[j]);
+
+			j++;
+		}
+	}
+
+	rte_tel_data_add_dict_container(d, "info", i_data, 0);
+	return 0;
+}
+
+RTE_INIT(cnxk_ethdev_init_telemetry)
+{
+	rte_telemetry_register_cmd("/cnxk/ethdev/info", ethdev_tel_handle_info,
+				   "Returns ethdev device information");
+}
diff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build
index d86188fed7..341ac99771 100644
--- a/drivers/net/cnxk/meson.build
+++ b/drivers/net/cnxk/meson.build
@@ -13,6 +13,7 @@ sources = files(
         'cnxk_ethdev_devargs.c',
         'cnxk_ethdev_ops.c',
         'cnxk_ethdev_sec.c',
+        'cnxk_ethdev_telemetry.c',
         'cnxk_link.c',
         'cnxk_lookup.c',
         'cnxk_ptp.c',
-- 
2.25.1


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

* Re: [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints
  2021-09-29  6:54           ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
                               ` (4 preceding siblings ...)
  2021-10-19 11:27             ` [dpdk-dev] [v10 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
@ 2021-10-19 16:42             ` Jerin Jacob
  2021-10-20 13:30               ` Ferruh Yigit
  5 siblings, 1 reply; 121+ messages in thread
From: Jerin Jacob @ 2021-10-19 16:42 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, Ferruh Yigit
  Cc: dpdk-dev, Jerin Jacob, Kiran Kumar K, Nithin Dabilpuram,
	Sunil Kumar Kori, Satha Koteswara Rao Kottidi,
	Ashwin Sekhar Thalakalath Kottilveetil, Pavan Nikhilesh

On Wed, Sep 29, 2021 at 12:25 PM Gowrishankar Muthukrishnan
<gmuthukrishn@marvell.com> wrote:
>
> This patch series enables telemetry in cnxk for the following:
>  - NPA LF
>  - NIX LF
>  - cnxk Mempool driver
>  - cnxk Ethdev driver
>


Series Acked-by: Jerin Jacob <jerinj@marvell.com>
Series applied to dpdk-next-net-mrvl/for-dpdk-main. Thanks.

>
> v9:
>  - moved common info from drivers to lib endpoints.
>
> Gowrishankar Muthukrishnan (4):
>   common/cnxk: add telemetry endpoints to npa
>   common/cnxk: add telemetry endpoints to nix
>   mempool/cnxk: add telemetry endpoints mempool
>   net/cnxk: add telemetry endpoints to ethdev
>
>  drivers/common/cnxk/cnxk_telemetry.h          |  26 +
>  drivers/common/cnxk/cnxk_telemetry_nix.c      | 849 ++++++++++++++++++
>  drivers/common/cnxk/cnxk_telemetry_npa.c      | 224 +++++
>  drivers/common/cnxk/meson.build               |   7 +-
>  drivers/common/cnxk/roc_nix.c                 |   3 +
>  drivers/common/cnxk/roc_nix_priv.h            |   9 +
>  drivers/common/cnxk/roc_nix_queue.c           |  15 +-
>  drivers/common/cnxk/roc_platform.h            |  15 +
>  drivers/mempool/cnxk/cnxk_mempool_telemetry.c |  57 ++
>  drivers/mempool/cnxk/meson.build              |   1 +
>  drivers/net/cnxk/cnxk_ethdev_telemetry.c      |  93 ++
>  drivers/net/cnxk/meson.build                  |   1 +
>  12 files changed, 1295 insertions(+), 5 deletions(-)
>  create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
>  create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c
>  create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
>  create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c
>  create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
>
> --
> 2.25.1
>

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

* Re: [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints
  2021-10-19 16:42             ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Jerin Jacob
@ 2021-10-20 13:30               ` Ferruh Yigit
  0 siblings, 0 replies; 121+ messages in thread
From: Ferruh Yigit @ 2021-10-20 13:30 UTC (permalink / raw)
  To: Jerin Jacob, Gowrishankar Muthukrishnan
  Cc: dpdk-dev, Jerin Jacob, Kiran Kumar K, Nithin Dabilpuram,
	Sunil Kumar Kori, Satha Koteswara Rao Kottidi,
	Ashwin Sekhar Thalakalath Kottilveetil, Pavan Nikhilesh

On 10/19/2021 5:42 PM, Jerin Jacob wrote:
> On Wed, Sep 29, 2021 at 12:25 PM Gowrishankar Muthukrishnan
> <gmuthukrishn@marvell.com> wrote:
>>
>> This patch series enables telemetry in cnxk for the following:
>>   - NPA LF
>>   - NIX LF
>>   - cnxk Mempool driver
>>   - cnxk Ethdev driver
>>
> 
> 
> Series Acked-by: Jerin Jacob <jerinj@marvell.com>
> Series applied to dpdk-next-net-mrvl/for-dpdk-main. Thanks.
> 

For record, v10 of this set seems merged according patchwork:
https://patches.dpdk.org/project/dpdk/list/?series=19788&state=*

>>
>> v9:
>>   - moved common info from drivers to lib endpoints.
>>
>> Gowrishankar Muthukrishnan (4):
>>    common/cnxk: add telemetry endpoints to npa
>>    common/cnxk: add telemetry endpoints to nix
>>    mempool/cnxk: add telemetry endpoints mempool
>>    net/cnxk: add telemetry endpoints to ethdev
>>
>>   drivers/common/cnxk/cnxk_telemetry.h          |  26 +
>>   drivers/common/cnxk/cnxk_telemetry_nix.c      | 849 ++++++++++++++++++
>>   drivers/common/cnxk/cnxk_telemetry_npa.c      | 224 +++++
>>   drivers/common/cnxk/meson.build               |   7 +-
>>   drivers/common/cnxk/roc_nix.c                 |   3 +
>>   drivers/common/cnxk/roc_nix_priv.h            |   9 +
>>   drivers/common/cnxk/roc_nix_queue.c           |  15 +-
>>   drivers/common/cnxk/roc_platform.h            |  15 +
>>   drivers/mempool/cnxk/cnxk_mempool_telemetry.c |  57 ++
>>   drivers/mempool/cnxk/meson.build              |   1 +
>>   drivers/net/cnxk/cnxk_ethdev_telemetry.c      |  93 ++
>>   drivers/net/cnxk/meson.build                  |   1 +
>>   12 files changed, 1295 insertions(+), 5 deletions(-)
>>   create mode 100644 drivers/common/cnxk/cnxk_telemetry.h
>>   create mode 100644 drivers/common/cnxk/cnxk_telemetry_nix.c
>>   create mode 100644 drivers/common/cnxk/cnxk_telemetry_npa.c
>>   create mode 100644 drivers/mempool/cnxk/cnxk_mempool_telemetry.c
>>   create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c
>>
>> --
>> 2.25.1
>>


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

* [dpdk-dev] [v2] mempool: add telemetry endpoint for mempool info
  2021-09-29  6:40             ` [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info Gowrishankar Muthukrishnan
  2021-10-13 15:21               ` Thomas Monjalon
  2021-10-13 15:40               ` Bruce Richardson
@ 2021-10-22  3:28               ` Gowrishankar Muthukrishnan
  2021-10-22  5:55                 ` David Marchand
  2021-10-22 16:11               ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
  3 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-22  3:28 UTC (permalink / raw)
  To: dev
  Cc: Olivier Matz, Andrew Rybchenko, jerinj, bruce.richardson,
	Gowrishankar Muthukrishnan

Add telemetry endpoint for mempool info.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
---
v2:
 - code alignments fixed

---
 lib/mempool/rte_mempool.c | 84 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index b75d26c82a..2d915e591d 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -31,6 +31,7 @@
 #include <rte_spinlock.h>
 #include <rte_tailq.h>
 #include <rte_eal_paging.h>
+#include <rte_telemetry.h>
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
@@ -1483,3 +1484,86 @@ rte_mempool_event_callback_unregister(rte_mempool_event_callback *func,
 	rte_errno = -ret;
 	return ret;
 }
+
+static void
+mempool_list_cb(struct rte_mempool *mp, void *arg)
+{
+	struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+	rte_tel_data_add_array_string(d, mp->name);
+}
+
+static int
+mempool_handle_list(const char *cmd __rte_unused,
+		    const char *params __rte_unused, struct rte_tel_data *d)
+{
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+	rte_mempool_walk(mempool_list_cb, d);
+	return 0;
+}
+
+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;
+	const struct rte_memzone *mz;
+
+	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+		return;
+
+	rte_tel_data_add_dict_string(info->d, "name", mp->name);
+	rte_tel_data_add_dict_int(info->d, "pool_id", mp->pool_id);
+	rte_tel_data_add_dict_int(info->d, "flags", mp->flags);
+	rte_tel_data_add_dict_int(info->d, "socket_id", mp->socket_id);
+	rte_tel_data_add_dict_int(info->d, "size", mp->size);
+	rte_tel_data_add_dict_int(info->d, "cache_size", mp->cache_size);
+	rte_tel_data_add_dict_int(info->d, "elt_size", mp->elt_size);
+	rte_tel_data_add_dict_int(info->d, "header_size", mp->header_size);
+	rte_tel_data_add_dict_int(info->d, "trailer_size", mp->trailer_size);
+	rte_tel_data_add_dict_int(info->d, "private_data_size",
+				  mp->private_data_size);
+	rte_tel_data_add_dict_int(info->d, "ops_index", mp->ops_index);
+	rte_tel_data_add_dict_int(info->d, "populated_size",
+				  mp->populated_size);
+
+	mz = mp->mz;
+	rte_tel_data_add_dict_string(info->d, "mz_name", mz->name);
+	rte_tel_data_add_dict_int(info->d, "mz_len", mz->len);
+	rte_tel_data_add_dict_int(info->d, "mz_hugepage_sz",
+				  mz->hugepage_sz);
+	rte_tel_data_add_dict_int(info->d, "mz_socket_id", mz->socket_id);
+	rte_tel_data_add_dict_int(info->d, "mz_flags", mz->flags);
+}
+
+static int
+mempool_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 || 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(mempool_init_telemetry)
+{
+	rte_telemetry_register_cmd("/mempool/list", mempool_handle_list,
+		"Returns list of available mempool. Takes no parameters");
+	rte_telemetry_register_cmd("/mempool/info", mempool_handle_info,
+		"Returns mempool info. Parameters: pool_name");
+}
-- 
2.25.1


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

* Re: [dpdk-dev] [v2] mempool: add telemetry endpoint for mempool info
  2021-10-22  3:28               ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
@ 2021-10-22  5:55                 ` David Marchand
  0 siblings, 0 replies; 121+ messages in thread
From: David Marchand @ 2021-10-22  5:55 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, Bruce Richardson
  Cc: dev, Olivier Matz, Andrew Rybchenko, Jerin Jacob Kollanukkaran

On Fri, Oct 22, 2021 at 5:28 AM Gowrishankar Muthukrishnan
<gmuthukrishn@marvell.com> wrote:
>
> Add telemetry endpoint for mempool info.
>
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>

Windows compilation is broken.

FAILED: lib/librte_mempool.a.p/mempool_rte_mempool.c.obj
"clang" "-Ilib\librte_mempool.a.p" "-Ilib" "-I..\lib" "-Ilib\mempool"
"-I..\lib\mempool" "-I." "-I.." "-Iconfig" "-I..\config"
"-Ilib\eal\include" "-I..\lib\eal\include" "-Ilib\eal\windows\include"
"-I..\lib\eal\windows\include" "-Ilib\eal\x86\include"
"-I..\lib\eal\x86\include" "-Ilib\eal\common" "-I..\lib\eal\common"
"-Ilib\eal" "-I..\lib\eal" "-Ilib\kvargs" "-I..\lib\kvargs"
"-Ilib\ring" "-I..\lib\ring" "-Xclang" "-fcolor-diagnostics" "-pipe"
"-D_FILE_OFFSET_BITS=64" "-Wall" "-Winvalid-pch" "-Werror" "-O3"
"-include" "rte_config.h" "-Wextra" "-Wcast-qual" "-Wdeprecated"
"-Wformat" "-Wformat-nonliteral" "-Wformat-security"
"-Wmissing-declarations" "-Wmissing-prototypes" "-Wnested-externs"
"-Wold-style-definition" "-Wpointer-arith" "-Wsign-compare"
"-Wstrict-prototypes" "-Wundef" "-Wwrite-strings"
"-Wno-address-of-packed-member" "-Wno-missing-field-initializers"
"-D_GNU_SOURCE" "-D_WIN32_WINNT=0x0A00" "-D_CRT_SECURE_NO_WARNINGS"
"-march=native" "-DALLOW_EXPERIMENTAL_API" "-DALLOW_INTERNAL_API"
"-DRTE_LOG_DEFAULT_LOGTYPE=lib.mempool" -MD -MQ
lib/librte_mempool.a.p/mempool_rte_mempool.c.obj -MF
"lib\librte_mempool.a.p\mempool_rte_mempool.c.obj.d" -o
lib/librte_mempool.a.p/mempool_rte_mempool.c.obj "-c"
../lib/mempool/rte_mempool.c
../lib/mempool/rte_mempool.c:34:10: fatal error: 'rte_telemetry.h'
file not found
#include <rte_telemetry.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.


Linux builds are fine, I checked locally:
[1/212] ccache cc -Ilib/librte_mempool.a.p -Ilib -I../lib
-Ilib/mempool -I../lib/mempool -I. -I.. -Iconfig -I../config
-Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include
-I../lib/eal/linux/include -Ilib/eal/x86/include
-I../lib/eal/x86/include -Ilib/eal/common -I../lib/eal/common
-Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/metrics
-I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/ring
-I../lib/ring -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror
-O2 -g -include rte_config.h -Wextra -Wcast-qual -Wdeprecated -Wformat
-Wformat-nonliteral -Wformat-security -Wmissing-declarations
-Wmissing-prototypes -Wnested-externs -Wold-style-definition
-Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef
-Wwrite-strings -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC
-march=native -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API
-DRTE_LOG_DEFAULT_LOGTYPE=lib.mempool -MD -MQ
lib/librte_mempool.a.p/mempool_rte_mempool.c.o -MF
lib/librte_mempool.a.p/mempool_rte_mempool.c.o.d -o
lib/librte_mempool.a.p/mempool_rte_mempool.c.o -c
../lib/mempool/rte_mempool.c

I guess there is an implicit dependency pulling telemetry for Linux.

mempool had no dependency to telemetry so far, you need to add en
explicit dependency in meson.build deps array.


-- 
David Marchand


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

* [dpdk-dev] [v2] cryptodev: add telemetry endpoint for cryptodev capabilities
  2021-09-29  6:45               ` [dpdk-dev] [v1] cryptodev: add telemetry endpoint for cryptodev info Gowrishankar Muthukrishnan
@ 2021-10-22 12:28                 ` Gowrishankar Muthukrishnan
  2021-10-22 12:37                   ` [dpdk-dev] [v5] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
  2021-10-22 12:59                   ` [dpdk-dev] [v6] " Gowrishankar Muthukrishnan
  2021-10-22 12:57                 ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
  2021-10-26 12:52                 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
  2 siblings, 2 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-22 12:28 UTC (permalink / raw)
  To: dev; +Cc: Akhil Goyal, Declan Doherty, jerinj, Gowrishankar Muthukrishnan

Add telemetry endpoint for cryptodev capabilities.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")

v2:
 - renamed endpoint as caps.

---
 lib/cryptodev/rte_cryptodev.c | 65 +++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 52066a953b..4cdadefa2f 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -2507,6 +2507,68 @@ cryptodev_handle_dev_stats(const char *cmd __rte_unused,
 	return 0;
 }
 
+#define CRYPTO_CAPS_SZ										   \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+					sizeof(uint64_t)) /						   \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+				  const struct rte_cryptodev_capabilities *capabilities)
+{
+	const struct rte_cryptodev_capabilities *dev_caps;
+	union caps_u {
+		struct rte_cryptodev_capabilities dev_caps;
+		uint64_t val[CRYPTO_CAPS_SZ];
+	} caps;
+	unsigned int i = 0, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->op !=
+	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+cryptodev_handle_dev_caps(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_cryptodev_info dev_info;
+	struct rte_tel_data *crypto_caps;
+	int crypto_caps_n;
+	char *end_param;
+	int dev_id;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	rte_tel_data_start_dict(d);
+	crypto_caps = rte_tel_data_alloc();
+	if (!crypto_caps)
+		return -ENOMEM;
+
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	crypto_caps_n = crypto_caps_array(crypto_caps, dev_info.capabilities);
+	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
+
+	return 0;
+}
+
 RTE_INIT(cryptodev_init_telemetry)
 {
 	rte_telemetry_register_cmd("/cryptodev/info", cryptodev_handle_dev_info,
@@ -2517,4 +2579,7 @@ RTE_INIT(cryptodev_init_telemetry)
 	rte_telemetry_register_cmd("/cryptodev/stats",
 			cryptodev_handle_dev_stats,
 			"Returns the stats for a cryptodev. Parameters: int dev_id");
+	rte_telemetry_register_cmd("/cryptodev/caps",
+			cryptodev_handle_dev_caps,
+			"Returns the capabilities for a cryptodev. Parameters: int dev_id");
 }
-- 
2.25.1


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

* [dpdk-dev] [v5] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-10-22 12:28                 ` [dpdk-dev] [v2] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
@ 2021-10-22 12:37                   ` Gowrishankar Muthukrishnan
  2021-10-22 12:59                   ` [dpdk-dev] [v6] " Gowrishankar Muthukrishnan
  1 sibling, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-22 12:37 UTC (permalink / raw)
  To: dev
  Cc: jerinj, gakhil, anoobj, adwivedi, ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to cryptodev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")
Depends-on: patch-19913 ("cryptodev: add telemetry endpoint for cryptodev capabilities")

v5:
 - endpoint renamed as caps.
---
 .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 122 ++++++++++++++++++
 drivers/crypto/cnxk/meson.build               |   1 +
 2 files changed, 123 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
new file mode 100644
index 0000000000..d10629ae58
--- /dev/null
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
@@ -0,0 +1,122 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_telemetry.h>
+#include <cryptodev_pmd.h>
+
+#include <cnxk_telemetry.h>
+#include <roc_api.h>
+
+#include "cnxk_cryptodev.h"
+
+#define CRYPTO_CAPS_SZ													\
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities),			\
+					sizeof(uint64_t)) /									\
+	 sizeof(uint64_t))
+
+#define SEC_CAPS_SZ														\
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability),				\
+					sizeof(uint64_t)) /									\
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  struct rte_cryptodev_capabilities *dev_caps,
+		  size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_cryptodev_capabilities dev_caps;
+		uint64_t val[CRYPTO_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		if (dev_caps[i].op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
+			break;
+
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+sec_caps_array(struct rte_tel_data *d, struct rte_security_capability *dev_caps,
+	       size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_security_capability dev_caps;
+		uint64_t val[SEC_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+cryptodev_tel_handle_caps(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_tel_data *sec_crypto_caps, *sec_caps;
+	int sec_crypto_caps_n, sec_caps_n;
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+	int dev_id;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtol(params, NULL, 10);
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (!dev) {
+		plt_err("No cryptodev for id %d available", dev_id);
+		return -EINVAL;
+	}
+
+	vf = dev->data->dev_private;
+	rte_tel_data_start_dict(d);
+
+	/* Security Crypto capabilities */
+	sec_crypto_caps = rte_tel_data_alloc();
+	sec_crypto_caps_n = crypto_caps_array(
+		sec_crypto_caps, vf->sec_crypto_caps, CNXK_SEC_CRYPTO_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_crypto_caps", sec_crypto_caps,
+					0);
+	rte_tel_data_add_dict_int(d, "sec_crypto_caps_n", sec_crypto_caps_n);
+
+	/* Security capabilities */
+	sec_caps = rte_tel_data_alloc();
+	sec_caps_n = sec_caps_array(sec_caps, vf->sec_caps, CNXK_SEC_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(cnxk_cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/cryptodev/caps", cryptodev_tel_handle_caps,
+		"Returns cryptodev capabilities. Parameters: int dev_id");
+}
diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build
index 024109f7e9..2d78757bba 100644
--- a/drivers/crypto/cnxk/meson.build
+++ b/drivers/crypto/cnxk/meson.build
@@ -20,6 +20,7 @@ sources = files(
         'cnxk_cryptodev_devargs.c',
         'cnxk_cryptodev_ops.c',
         'cnxk_cryptodev_sec.c',
+        'cnxk_cryptodev_telemetry.c',
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev']
-- 
2.25.1


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

* [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities
  2021-09-29  6:45               ` [dpdk-dev] [v1] cryptodev: add telemetry endpoint for cryptodev info Gowrishankar Muthukrishnan
  2021-10-22 12:28                 ` [dpdk-dev] [v2] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
@ 2021-10-22 12:57                 ` Gowrishankar Muthukrishnan
  2021-10-22 16:02                   ` [dpdk-dev] [v7] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
                                     ` (2 more replies)
  2021-10-26 12:52                 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
  2 siblings, 3 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-22 12:57 UTC (permalink / raw)
  To: dev; +Cc: Akhil Goyal, Declan Doherty, jerinj, Gowrishankar Muthukrishnan

Add telemetry endpoint for cryptodev capabilities.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")

v3:
 - checkpatch fixes.
 
---
 lib/cryptodev/rte_cryptodev.c | 65 +++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 52066a953b..01325ea863 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -2507,6 +2507,68 @@ cryptodev_handle_dev_stats(const char *cmd __rte_unused,
 	return 0;
 }
 
+#define CRYPTO_CAPS_SZ                                             \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+					sizeof(uint64_t)) /        \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  const struct rte_cryptodev_capabilities *capabilities)
+{
+	const struct rte_cryptodev_capabilities *dev_caps;
+	union caps_u {
+		struct rte_cryptodev_capabilities dev_caps;
+		uint64_t val[CRYPTO_CAPS_SZ];
+	} caps;
+	unsigned int i = 0, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->op !=
+	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+cryptodev_handle_dev_caps(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_cryptodev_info dev_info;
+	struct rte_tel_data *crypto_caps;
+	int crypto_caps_n;
+	char *end_param;
+	int dev_id;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	rte_tel_data_start_dict(d);
+	crypto_caps = rte_tel_data_alloc();
+	if (!crypto_caps)
+		return -ENOMEM;
+
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	crypto_caps_n = crypto_caps_array(crypto_caps, dev_info.capabilities);
+	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
+
+	return 0;
+}
+
 RTE_INIT(cryptodev_init_telemetry)
 {
 	rte_telemetry_register_cmd("/cryptodev/info", cryptodev_handle_dev_info,
@@ -2517,4 +2579,7 @@ RTE_INIT(cryptodev_init_telemetry)
 	rte_telemetry_register_cmd("/cryptodev/stats",
 			cryptodev_handle_dev_stats,
 			"Returns the stats for a cryptodev. Parameters: int dev_id");
+	rte_telemetry_register_cmd("/cryptodev/caps",
+			cryptodev_handle_dev_caps,
+			"Returns the capabilities for a cryptodev. Parameters: int dev_id");
 }
-- 
2.25.1


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

* [dpdk-dev] [v6] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-10-22 12:28                 ` [dpdk-dev] [v2] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
  2021-10-22 12:37                   ` [dpdk-dev] [v5] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
@ 2021-10-22 12:59                   ` Gowrishankar Muthukrishnan
  1 sibling, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-22 12:59 UTC (permalink / raw)
  To: dev
  Cc: jerinj, gakhil, anoobj, adwivedi, ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to cryptodev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")
Depends-on: patch-19915 ("cryptodev: add telemetry endpoint for cryptodev capabilities")

v6:
 - checkpatch fixes.
---
 .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 122 ++++++++++++++++++
 drivers/crypto/cnxk/meson.build               |   1 +
 2 files changed, 123 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
new file mode 100644
index 0000000000..d44dd82ea8
--- /dev/null
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
@@ -0,0 +1,122 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_telemetry.h>
+#include <cryptodev_pmd.h>
+
+#include <cnxk_telemetry.h>
+#include <roc_api.h>
+
+#include "cnxk_cryptodev.h"
+
+#define CRYPTO_CAPS_SZ                                             \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+					sizeof(uint64_t)) /        \
+	 sizeof(uint64_t))
+
+#define SEC_CAPS_SZ                                                \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability),    \
+					sizeof(uint64_t)) /        \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  struct rte_cryptodev_capabilities *dev_caps,
+		  size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_cryptodev_capabilities dev_caps;
+		uint64_t val[CRYPTO_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		if (dev_caps[i].op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
+			break;
+
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+sec_caps_array(struct rte_tel_data *d, struct rte_security_capability *dev_caps,
+	       size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_security_capability dev_caps;
+		uint64_t val[SEC_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+cryptodev_tel_handle_caps(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_tel_data *sec_crypto_caps, *sec_caps;
+	int sec_crypto_caps_n, sec_caps_n;
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+	int dev_id;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtol(params, NULL, 10);
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (!dev) {
+		plt_err("No cryptodev for id %d available", dev_id);
+		return -EINVAL;
+	}
+
+	vf = dev->data->dev_private;
+	rte_tel_data_start_dict(d);
+
+	/* Security Crypto capabilities */
+	sec_crypto_caps = rte_tel_data_alloc();
+	sec_crypto_caps_n = crypto_caps_array(
+		sec_crypto_caps, vf->sec_crypto_caps, CNXK_SEC_CRYPTO_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_crypto_caps", sec_crypto_caps,
+					0);
+	rte_tel_data_add_dict_int(d, "sec_crypto_caps_n", sec_crypto_caps_n);
+
+	/* Security capabilities */
+	sec_caps = rte_tel_data_alloc();
+	sec_caps_n = sec_caps_array(sec_caps, vf->sec_caps, CNXK_SEC_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(cnxk_cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/cryptodev/caps", cryptodev_tel_handle_caps,
+		"Returns cryptodev capabilities. Parameters: int dev_id");
+}
diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build
index 024109f7e9..2d78757bba 100644
--- a/drivers/crypto/cnxk/meson.build
+++ b/drivers/crypto/cnxk/meson.build
@@ -20,6 +20,7 @@ sources = files(
         'cnxk_cryptodev_devargs.c',
         'cnxk_cryptodev_ops.c',
         'cnxk_cryptodev_sec.c',
+        'cnxk_cryptodev_telemetry.c',
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev']
-- 
2.25.1


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

* [dpdk-dev] [v7] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-10-22 12:57                 ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
@ 2021-10-22 16:02                   ` Gowrishankar Muthukrishnan
  2021-10-26 13:44                     ` [dpdk-dev] [v8] " Gowrishankar Muthukrishnan
  2021-10-25  7:26                   ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Akhil Goyal
  2021-10-26 13:13                   ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
  2 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-22 16:02 UTC (permalink / raw)
  To: dev
  Cc: jerinj, gakhil, anoobj, adwivedi, ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to cryptodev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")
Depends-on: patch-19915 ("cryptodev: add telemetry endpoint for cryptodev capabilities")

v7:
 - compilation issue in CI fixed
---
 .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 121 ++++++++++++++++++
 drivers/crypto/cnxk/meson.build               |   1 +
 2 files changed, 122 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
new file mode 100644
index 0000000000..a1eccffe33
--- /dev/null
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
@@ -0,0 +1,121 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_telemetry.h>
+#include <cryptodev_pmd.h>
+
+#include <roc_api.h>
+
+#include "cnxk_cryptodev.h"
+
+#define CRYPTO_CAPS_SZ                                             \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+					sizeof(uint64_t)) /        \
+	 sizeof(uint64_t))
+
+#define SEC_CAPS_SZ                                                \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability),    \
+					sizeof(uint64_t)) /        \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  struct rte_cryptodev_capabilities *dev_caps,
+		  size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_cryptodev_capabilities dev_caps;
+		uint64_t val[CRYPTO_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		if (dev_caps[i].op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
+			break;
+
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+sec_caps_array(struct rte_tel_data *d, struct rte_security_capability *dev_caps,
+	       size_t dev_caps_n)
+{
+	union caps_u {
+		struct rte_security_capability dev_caps;
+		uint64_t val[SEC_CAPS_SZ];
+	} caps;
+	unsigned int i, j, n = 0;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		memset(&caps, 0, sizeof(caps));
+		rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps.val[j]);
+		++n;
+	}
+
+	return n;
+}
+
+static int
+cryptodev_tel_handle_caps(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_tel_data *sec_crypto_caps, *sec_caps;
+	int sec_crypto_caps_n, sec_caps_n;
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+	int dev_id;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtol(params, NULL, 10);
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (!dev) {
+		plt_err("No cryptodev for id %d available", dev_id);
+		return -EINVAL;
+	}
+
+	vf = dev->data->dev_private;
+	rte_tel_data_start_dict(d);
+
+	/* Security Crypto capabilities */
+	sec_crypto_caps = rte_tel_data_alloc();
+	sec_crypto_caps_n = crypto_caps_array(
+		sec_crypto_caps, vf->sec_crypto_caps, CNXK_SEC_CRYPTO_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_crypto_caps", sec_crypto_caps,
+					0);
+	rte_tel_data_add_dict_int(d, "sec_crypto_caps_n", sec_crypto_caps_n);
+
+	/* Security capabilities */
+	sec_caps = rte_tel_data_alloc();
+	sec_caps_n = sec_caps_array(sec_caps, vf->sec_caps, CNXK_SEC_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(cnxk_cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd(
+		"/cnxk/cryptodev/caps", cryptodev_tel_handle_caps,
+		"Returns cryptodev capabilities. Parameters: int dev_id");
+}
diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build
index 024109f7e9..2d78757bba 100644
--- a/drivers/crypto/cnxk/meson.build
+++ b/drivers/crypto/cnxk/meson.build
@@ -20,6 +20,7 @@ sources = files(
         'cnxk_cryptodev_devargs.c',
         'cnxk_cryptodev_ops.c',
         'cnxk_cryptodev_sec.c',
+        'cnxk_cryptodev_telemetry.c',
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev']
-- 
2.25.1


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

* [dpdk-dev] [v3] mempool: add telemetry endpoint for mempool info
  2021-09-29  6:40             ` [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info Gowrishankar Muthukrishnan
                                 ` (2 preceding siblings ...)
  2021-10-22  3:28               ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
@ 2021-10-22 16:11               ` Gowrishankar Muthukrishnan
  2021-10-22 20:38                 ` Thomas Monjalon
  3 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-22 16:11 UTC (permalink / raw)
  To: dev
  Cc: Olivier Matz, Andrew Rybchenko, jerinj, bruce.richardson,
	Gowrishankar Muthukrishnan

Add telemetry endpoint for mempool info.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
---
v3:
 - added explicit telemetry dependency in meson
---
 lib/mempool/meson.build   |  2 +-
 lib/mempool/rte_mempool.c | 84 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/lib/mempool/meson.build b/lib/mempool/meson.build
index e48bd6a14a..b8aaa00694 100644
--- a/lib/mempool/meson.build
+++ b/lib/mempool/meson.build
@@ -20,4 +20,4 @@ headers = files(
         'rte_mempool_trace.h',
         'rte_mempool_trace_fp.h',
 )
-deps += ['ring']
+deps += ['ring', 'telemetry']
diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
index b75d26c82a..2d915e591d 100644
--- a/lib/mempool/rte_mempool.c
+++ b/lib/mempool/rte_mempool.c
@@ -31,6 +31,7 @@
 #include <rte_spinlock.h>
 #include <rte_tailq.h>
 #include <rte_eal_paging.h>
+#include <rte_telemetry.h>
 
 #include "rte_mempool.h"
 #include "rte_mempool_trace.h"
@@ -1483,3 +1484,86 @@ rte_mempool_event_callback_unregister(rte_mempool_event_callback *func,
 	rte_errno = -ret;
 	return ret;
 }
+
+static void
+mempool_list_cb(struct rte_mempool *mp, void *arg)
+{
+	struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+	rte_tel_data_add_array_string(d, mp->name);
+}
+
+static int
+mempool_handle_list(const char *cmd __rte_unused,
+		    const char *params __rte_unused, struct rte_tel_data *d)
+{
+	rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+	rte_mempool_walk(mempool_list_cb, d);
+	return 0;
+}
+
+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;
+	const struct rte_memzone *mz;
+
+	if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+		return;
+
+	rte_tel_data_add_dict_string(info->d, "name", mp->name);
+	rte_tel_data_add_dict_int(info->d, "pool_id", mp->pool_id);
+	rte_tel_data_add_dict_int(info->d, "flags", mp->flags);
+	rte_tel_data_add_dict_int(info->d, "socket_id", mp->socket_id);
+	rte_tel_data_add_dict_int(info->d, "size", mp->size);
+	rte_tel_data_add_dict_int(info->d, "cache_size", mp->cache_size);
+	rte_tel_data_add_dict_int(info->d, "elt_size", mp->elt_size);
+	rte_tel_data_add_dict_int(info->d, "header_size", mp->header_size);
+	rte_tel_data_add_dict_int(info->d, "trailer_size", mp->trailer_size);
+	rte_tel_data_add_dict_int(info->d, "private_data_size",
+				  mp->private_data_size);
+	rte_tel_data_add_dict_int(info->d, "ops_index", mp->ops_index);
+	rte_tel_data_add_dict_int(info->d, "populated_size",
+				  mp->populated_size);
+
+	mz = mp->mz;
+	rte_tel_data_add_dict_string(info->d, "mz_name", mz->name);
+	rte_tel_data_add_dict_int(info->d, "mz_len", mz->len);
+	rte_tel_data_add_dict_int(info->d, "mz_hugepage_sz",
+				  mz->hugepage_sz);
+	rte_tel_data_add_dict_int(info->d, "mz_socket_id", mz->socket_id);
+	rte_tel_data_add_dict_int(info->d, "mz_flags", mz->flags);
+}
+
+static int
+mempool_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 || 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(mempool_init_telemetry)
+{
+	rte_telemetry_register_cmd("/mempool/list", mempool_handle_list,
+		"Returns list of available mempool. Takes no parameters");
+	rte_telemetry_register_cmd("/mempool/info", mempool_handle_info,
+		"Returns mempool info. Parameters: pool_name");
+}
-- 
2.25.1


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

* Re: [dpdk-dev] [v3] mempool: add telemetry endpoint for mempool info
  2021-10-22 16:11               ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
@ 2021-10-22 20:38                 ` Thomas Monjalon
  0 siblings, 0 replies; 121+ messages in thread
From: Thomas Monjalon @ 2021-10-22 20:38 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan
  Cc: dev, Olivier Matz, Andrew Rybchenko, jerinj, bruce.richardson

22/10/2021 18:11, Gowrishankar Muthukrishnan:
> Add telemetry endpoint for mempool info.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks.




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

* Re: [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities
  2021-10-22 12:57                 ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
  2021-10-22 16:02                   ` [dpdk-dev] [v7] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
@ 2021-10-25  7:26                   ` Akhil Goyal
  2021-10-26 13:13                   ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
  2 siblings, 0 replies; 121+ messages in thread
From: Akhil Goyal @ 2021-10-25  7:26 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Declan Doherty, Jerin Jacob Kollanukkaran, Gowrishankar Muthukrishnan

> +#define CRYPTO_CAPS_SZ                                             \
> +	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
> +					sizeof(uint64_t)) /        \
> +	 sizeof(uint64_t))
> +
> +static int
> +crypto_caps_array(struct rte_tel_data *d,
> +		  const struct rte_cryptodev_capabilities *capabilities)
> +{
> +	const struct rte_cryptodev_capabilities *dev_caps;
> +	union caps_u {
> +		struct rte_cryptodev_capabilities dev_caps;
> +		uint64_t val[CRYPTO_CAPS_SZ];
> +	} caps;
> +	unsigned int i = 0, j, n = 0;
> +
> +	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
> +
> +	while ((dev_caps = &capabilities[i++])->op !=
> +	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
> +		memset(&caps, 0, sizeof(caps));
> +		rte_memcpy(&caps.dev_caps, dev_caps,
> sizeof(capabilities[0]));
> +		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
> +			rte_tel_data_add_array_u64(d, caps.val[j]);
> +		++n;
> +	}
> +
> +	return n;
> +}

We do not need 2 iterators i and n. both are for same purpose.
Also, union is not required for caps. 

static int
crypto_caps_array(struct rte_tel_data *d,
                  const struct rte_cryptodev_capabilities *capabilities)
{
        const struct rte_cryptodev_capabilities *dev_caps;
        uint64_t caps_val[CRYPTO_CAPS_SZ];
        unsigned int j, n = 0;

        rte_tel_data_start_array(d, RTE_TEL_U64_VAL);

        while ((dev_caps = &capabilities[n++])->op !=
                        RTE_CRYPTO_OP_TYPE_UNDEFINED) {
                memset(&caps_val, 0, CRYPTO_CAPS_SZ * sizeof(uint64_t));
                rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
                for (j = 0; j < CRYPTO_CAPS_SZ; j++)
                        rte_tel_data_add_array_u64(d, caps_val[j]);
        }

        return n;
}

> +
> +static int
> +cryptodev_handle_dev_caps(const char *cmd __rte_unused, const char
> *params,
> +			  struct rte_tel_data *d)
> +{
> +	struct rte_cryptodev_info dev_info;
> +	struct rte_tel_data *crypto_caps;
> +	int crypto_caps_n;
> +	char *end_param;
> +	int dev_id;
> +
> +	if (!params || strlen(params) == 0 || !isdigit(*params))
> +		return -EINVAL;
> +
> +	dev_id = strtoul(params, &end_param, 0);
> +	if (*end_param != '\0')
> +		CDEV_LOG_ERR("Extra parameters passed to command,
> ignoring");
> +	if (!rte_cryptodev_is_valid_dev(dev_id))
> +		return -EINVAL;
> +
> +	rte_tel_data_start_dict(d);
> +	crypto_caps = rte_tel_data_alloc();
> +	if (!crypto_caps)
> +		return -ENOMEM;
> +
> +	rte_cryptodev_info_get(dev_id, &dev_info);
> +	crypto_caps_n = crypto_caps_array(crypto_caps,
> dev_info.capabilities);
> +	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
> +	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
> +
> +	return 0;
> +}
> +
>  RTE_INIT(cryptodev_init_telemetry)
>  {
>  	rte_telemetry_register_cmd("/cryptodev/info",
> cryptodev_handle_dev_info,
> @@ -2517,4 +2579,7 @@ RTE_INIT(cryptodev_init_telemetry)
>  	rte_telemetry_register_cmd("/cryptodev/stats",
>  			cryptodev_handle_dev_stats,
>  			"Returns the stats for a cryptodev. Parameters: int
> dev_id");
> +	rte_telemetry_register_cmd("/cryptodev/caps",
> +			cryptodev_handle_dev_caps,
> +			"Returns the capabilities for a cryptodev. Parameters:
> int dev_id");
>  }
> --
> 2.25.1


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

* [dpdk-dev] [v4] cryptodev: add telemetry endpoint for cryptodev capabilities
  2021-09-29  6:45               ` [dpdk-dev] [v1] cryptodev: add telemetry endpoint for cryptodev info Gowrishankar Muthukrishnan
  2021-10-22 12:28                 ` [dpdk-dev] [v2] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
  2021-10-22 12:57                 ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
@ 2021-10-26 12:52                 ` Gowrishankar Muthukrishnan
  2 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-26 12:52 UTC (permalink / raw)
  To: dev; +Cc: Akhil Goyal, Declan Doherty, jerinj, Gowrishankar Muthukrishnan

Add telemetry endpoint for cryptodev capabilities.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")

v4:
 - minor cleanup
 
---
 lib/cryptodev/rte_cryptodev.c | 61 +++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index f9e241c60a..e01f651cf9 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -2503,6 +2503,64 @@ cryptodev_handle_dev_stats(const char *cmd __rte_unused,
 	return 0;
 }
 
+#define CRYPTO_CAPS_SZ                                             \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+					sizeof(uint64_t)) /        \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  const struct rte_cryptodev_capabilities *capabilities)
+{
+	const struct rte_cryptodev_capabilities *dev_caps;
+	uint64_t caps_val[CRYPTO_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->op !=
+	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		memset(&caps_val, 0, sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+static int
+cryptodev_handle_dev_caps(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_cryptodev_info dev_info;
+	struct rte_tel_data *crypto_caps;
+	int crypto_caps_n;
+	char *end_param;
+	int dev_id;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	rte_tel_data_start_dict(d);
+	crypto_caps = rte_tel_data_alloc();
+	if (!crypto_caps)
+		return -ENOMEM;
+
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	crypto_caps_n = crypto_caps_array(crypto_caps, dev_info.capabilities);
+	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
+
+	return 0;
+}
+
 RTE_INIT(cryptodev_init_fp_ops)
 {
 	uint32_t i;
@@ -2522,4 +2580,7 @@ RTE_INIT(cryptodev_init_telemetry)
 	rte_telemetry_register_cmd("/cryptodev/stats",
 			cryptodev_handle_dev_stats,
 			"Returns the stats for a cryptodev. Parameters: int dev_id");
+	rte_telemetry_register_cmd("/cryptodev/caps",
+			cryptodev_handle_dev_caps,
+			"Returns the capabilities for a cryptodev. Parameters: int dev_id");
 }
-- 
2.25.1


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

* [dpdk-dev] [v5] cryptodev: add telemetry endpoint for cryptodev capabilities
  2021-10-22 12:57                 ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
  2021-10-22 16:02                   ` [dpdk-dev] [v7] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
  2021-10-25  7:26                   ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Akhil Goyal
@ 2021-10-26 13:13                   ` Gowrishankar Muthukrishnan
  2021-10-26 14:12                     ` Akhil Goyal
  2 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-26 13:13 UTC (permalink / raw)
  To: dev; +Cc: Akhil Goyal, Declan Doherty, jerinj, Gowrishankar Muthukrishnan

Add telemetry endpoint for cryptodev capabilities.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")

v5:
 - minor cleanup
---
 lib/cryptodev/rte_cryptodev.c | 61 +++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index f9e241c60a..35005f83af 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -2503,6 +2503,64 @@ cryptodev_handle_dev_stats(const char *cmd __rte_unused,
 	return 0;
 }
 
+#define CRYPTO_CAPS_SZ                                             \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+					sizeof(uint64_t)) /        \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  const struct rte_cryptodev_capabilities *capabilities)
+{
+	const struct rte_cryptodev_capabilities *dev_caps;
+	uint64_t caps_val[CRYPTO_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->op !=
+	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		memset(&caps_val, 0, CRYPTO_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+static int
+cryptodev_handle_dev_caps(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_cryptodev_info dev_info;
+	struct rte_tel_data *crypto_caps;
+	int crypto_caps_n;
+	char *end_param;
+	int dev_id;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	rte_tel_data_start_dict(d);
+	crypto_caps = rte_tel_data_alloc();
+	if (!crypto_caps)
+		return -ENOMEM;
+
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	crypto_caps_n = crypto_caps_array(crypto_caps, dev_info.capabilities);
+	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
+
+	return 0;
+}
+
 RTE_INIT(cryptodev_init_fp_ops)
 {
 	uint32_t i;
@@ -2522,4 +2580,7 @@ RTE_INIT(cryptodev_init_telemetry)
 	rte_telemetry_register_cmd("/cryptodev/stats",
 			cryptodev_handle_dev_stats,
 			"Returns the stats for a cryptodev. Parameters: int dev_id");
+	rte_telemetry_register_cmd("/cryptodev/caps",
+			cryptodev_handle_dev_caps,
+			"Returns the capabilities for a cryptodev. Parameters: int dev_id");
 }
-- 
2.25.1


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

* [dpdk-dev] [v8] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-10-22 16:02                   ` [dpdk-dev] [v7] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
@ 2021-10-26 13:44                     ` Gowrishankar Muthukrishnan
  2021-10-26 14:10                       ` Akhil Goyal
                                         ` (2 more replies)
  0 siblings, 3 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-26 13:44 UTC (permalink / raw)
  To: dev
  Cc: jerinj, gakhil, anoobj, adwivedi, ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to cryptodev.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")
Depends-on: patch-20006 ("cryptodev: add telemetry endpoint for cryptodev capabilities")

v8:
 - minor cleanup
 
---
 .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 114 ++++++++++++++++++
 drivers/crypto/cnxk/meson.build               |   1 +
 2 files changed, 115 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
new file mode 100644
index 0000000000..89e4ecaebd
--- /dev/null
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
@@ -0,0 +1,114 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_telemetry.h>
+#include <cryptodev_pmd.h>
+
+#include <roc_api.h>
+
+#include "cnxk_cryptodev.h"
+
+#define CRYPTO_CAPS_SZ                                             \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+					sizeof(uint64_t)) /        \
+	 sizeof(uint64_t))
+
+#define SEC_CAPS_SZ                                                \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability),    \
+					sizeof(uint64_t)) /        \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  struct rte_cryptodev_capabilities *dev_caps,
+		  size_t dev_caps_n)
+{
+	uint64_t caps_val[CRYPTO_CAPS_SZ];
+	unsigned int i, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		if (dev_caps[i].op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
+			break;
+
+		memset(&caps_val, 0, CRYPTO_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+static int
+sec_caps_array(struct rte_tel_data *d, struct rte_security_capability *dev_caps,
+	       size_t dev_caps_n)
+{
+	uint64_t caps_val[SEC_CAPS_SZ];
+	unsigned int i, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	for (i = 0; i < dev_caps_n; i++) {
+		memset(&caps_val, 0, SEC_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, &dev_caps[i], sizeof(dev_caps[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+static int
+cryptodev_tel_handle_caps(const char *cmd __rte_unused, const char *params,
+			  struct rte_tel_data *d)
+{
+	struct rte_tel_data *sec_crypto_caps, *sec_caps;
+	int sec_crypto_caps_n, sec_caps_n;
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+	int dev_id;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtol(params, NULL, 10);
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (!dev) {
+		plt_err("No cryptodev for id %d available", dev_id);
+		return -EINVAL;
+	}
+
+	vf = dev->data->dev_private;
+	rte_tel_data_start_dict(d);
+
+	/* Security Crypto capabilities */
+	sec_crypto_caps = rte_tel_data_alloc();
+	sec_crypto_caps_n = crypto_caps_array(sec_crypto_caps,
+					      vf->sec_crypto_caps,
+					      CNXK_SEC_CRYPTO_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_crypto_caps", sec_crypto_caps,
+					0);
+	rte_tel_data_add_dict_int(d, "sec_crypto_caps_n", sec_crypto_caps_n);
+
+	/* Security capabilities */
+	sec_caps = rte_tel_data_alloc();
+	sec_caps_n = sec_caps_array(sec_caps, vf->sec_caps, CNXK_SEC_MAX_CAPS);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(cnxk_cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd("/cnxk/cryptodev/caps",
+		cryptodev_tel_handle_caps,
+		"Returns cryptodev capabilities. Parameters: int dev_id");
+}
diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build
index 024109f7e9..2d78757bba 100644
--- a/drivers/crypto/cnxk/meson.build
+++ b/drivers/crypto/cnxk/meson.build
@@ -20,6 +20,7 @@ sources = files(
         'cnxk_cryptodev_devargs.c',
         'cnxk_cryptodev_ops.c',
         'cnxk_cryptodev_sec.c',
+        'cnxk_cryptodev_telemetry.c',
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev']
-- 
2.25.1


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

* Re: [dpdk-dev] [v8] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-10-26 13:44                     ` [dpdk-dev] [v8] " Gowrishankar Muthukrishnan
@ 2021-10-26 14:10                       ` Akhil Goyal
  2021-11-03  4:43                         ` Gowrishankar Muthukrishnan
  2021-10-30 17:41                       ` [dpdk-dev] [v9] " Gowrishankar Muthukrishnan
  2021-10-30 17:45                       ` [dpdk-dev] [v1] security: add telemetry endpoint for cryptodev security capabilities Gowrishankar Muthukrishnan
  2 siblings, 1 reply; 121+ messages in thread
From: Akhil Goyal @ 2021-10-26 14:10 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev, Anoob Joseph
  Cc: Jerin Jacob Kollanukkaran, Ankur Dwivedi, Tejasree Kondoj,
	Gowrishankar Muthukrishnan

> Subject: [v8] crypto/cnxk: add telemetry endpoints to cryptodev
> 
> Add telemetry endpoints to cryptodev.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
> Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")
> Depends-on: patch-20006 ("cryptodev: add telemetry endpoint for cryptodev
> capabilities")
> 
> v8:
>  - minor cleanup
> 
This patch is adding telemetry statistics for security capabilities similar to crypto caps.
Isn't it good to add it in rte_security itself so that it can be reused for other PMDs also.



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

* Re: [dpdk-dev] [v5] cryptodev: add telemetry endpoint for cryptodev capabilities
  2021-10-26 13:13                   ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
@ 2021-10-26 14:12                     ` Akhil Goyal
  2021-10-26 15:44                       ` Gowrishankar Muthukrishnan
  0 siblings, 1 reply; 121+ messages in thread
From: Akhil Goyal @ 2021-10-26 14:12 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Declan Doherty, Fan Zhang, Jerin Jacob Kollanukkaran,
	Gowrishankar Muthukrishnan, Rebecca Troy

> Subject: [v5] cryptodev: add telemetry endpoint for cryptodev capabilities
> 
> Add telemetry endpoint for cryptodev capabilities.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
> Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")
> 
> v5:
>  - minor cleanup
Please send a text to update in the documentation.
Will update it while merging the patch.

Acked-by: Akhil Goyal <gakhil@marvell.com>

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

* Re: [dpdk-dev] [v5] cryptodev: add telemetry endpoint for cryptodev capabilities
  2021-10-26 14:12                     ` Akhil Goyal
@ 2021-10-26 15:44                       ` Gowrishankar Muthukrishnan
  2021-10-26 18:34                         ` Akhil Goyal
  0 siblings, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-26 15:44 UTC (permalink / raw)
  To: Akhil Goyal, dev
  Cc: Declan Doherty, Fan Zhang, Jerin Jacob Kollanukkaran, Rebecca Troy


Hi Akhil,

> Please send a text to update in the documentation.
> Will update it while merging the patch.

diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst
index 25663e552e..223e933bf4 100644
--- a/doc/guides/prog_guide/cryptodev_lib.rst
+++ b/doc/guides/prog_guide/cryptodev_lib.rst
@@ -1308,5 +1308,9 @@ are shown below.
      {"/cryptodev/stats": {"enqueued_count": 0, "dequeued_count": 0,
      "enqueue_err_count": 0, "dequeue_err_count": 0}}

+#. Get the capabilities of a particular Crypto device::
+        --> /cryptodev/caps,0
+        {"/cryptodev/caps": {"crypto_caps": [<array of serialized bytes of
+        capabilities>], "crypto_caps_n": <number of capabilities>}}
 For more information on how to use the Telemetry interface, see
 the :doc:`../howto/telemetry`.

Thanks,
Gowrishankar
> 
> Acked-by: Akhil Goyal <gakhil@marvell.com>

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

* Re: [dpdk-dev] [v5] cryptodev: add telemetry endpoint for cryptodev capabilities
  2021-10-26 15:44                       ` Gowrishankar Muthukrishnan
@ 2021-10-26 18:34                         ` Akhil Goyal
  0 siblings, 0 replies; 121+ messages in thread
From: Akhil Goyal @ 2021-10-26 18:34 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Declan Doherty, Fan Zhang, Jerin Jacob Kollanukkaran, Rebecca Troy

> > Please send a text to update in the documentation.
> > Will update it while merging the patch.
> 
> diff --git a/doc/guides/prog_guide/cryptodev_lib.rst
> b/doc/guides/prog_guide/cryptodev_lib.rst
> index 25663e552e..223e933bf4 100644
> --- a/doc/guides/prog_guide/cryptodev_lib.rst
> +++ b/doc/guides/prog_guide/cryptodev_lib.rst
> @@ -1308,5 +1308,9 @@ are shown below.
>       {"/cryptodev/stats": {"enqueued_count": 0, "dequeued_count": 0,
>       "enqueue_err_count": 0, "dequeue_err_count": 0}}
> 
> +#. Get the capabilities of a particular Crypto device::
> +        --> /cryptodev/caps,0
> +        {"/cryptodev/caps": {"crypto_caps": [<array of serialized bytes of
> +        capabilities>], "crypto_caps_n": <number of capabilities>}}
>  For more information on how to use the Telemetry interface, see
>  the :doc:`../howto/telemetry`.
> 
Updated and applied to dpdk-next-crypto
Release notes also updated.
Thanks.


> > Acked-by: Akhil Goyal <gakhil@marvell.com>

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

* [dpdk-dev] [v9] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-10-26 13:44                     ` [dpdk-dev] [v8] " Gowrishankar Muthukrishnan
  2021-10-26 14:10                       ` Akhil Goyal
@ 2021-10-30 17:41                       ` Gowrishankar Muthukrishnan
  2021-10-30 17:45                       ` [dpdk-dev] [v1] security: add telemetry endpoint for cryptodev security capabilities Gowrishankar Muthukrishnan
  2 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-30 17:41 UTC (permalink / raw)
  To: dev
  Cc: jerinj, gakhil, anoobj, adwivedi, ktejasree, Gowrishankar Muthukrishnan

Add telemetry endpoints to cnxk secure cryptodev capabilities.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 v9:
  - moved rte_security_capability into rte_security lib telemetry.

---
 .../crypto/cnxk/cnxk_cryptodev_telemetry.c    | 81 +++++++++++++++++++
 drivers/crypto/cnxk/meson.build               |  1 +
 2 files changed, 82 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c

diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
new file mode 100644
index 0000000000..43cde55bfc
--- /dev/null
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#include <rte_cryptodev.h>
+#include <rte_telemetry.h>
+#include <cryptodev_pmd.h>
+
+#include <roc_api.h>
+
+#include "cnxk_cryptodev.h"
+
+#define CRYPTO_CAPS_SZ						   \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+					sizeof(uint64_t)) /        \
+	 sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  struct rte_cryptodev_capabilities *capabilities)
+{
+	const struct rte_cryptodev_capabilities *dev_caps;
+	uint64_t caps_val[CRYPTO_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->op !=
+		RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		memset(&caps_val, 0, CRYPTO_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+static int
+cryptodev_tel_handle_sec_caps(const char *cmd __rte_unused, const char *params,
+			      struct rte_tel_data *d)
+{
+	struct rte_tel_data *sec_crypto_caps;
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+	int sec_crypto_caps_n;
+	int dev_id;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtol(params, NULL, 10);
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (!dev) {
+		plt_err("No cryptodev for id %d available", dev_id);
+		return -EINVAL;
+	}
+
+	vf = dev->data->dev_private;
+	rte_tel_data_start_dict(d);
+
+	/* Secure Crypto capabilities */
+	sec_crypto_caps = rte_tel_data_alloc();
+	sec_crypto_caps_n = crypto_caps_array(sec_crypto_caps,
+					      vf->sec_crypto_caps);
+	rte_tel_data_add_dict_container(d, "sec_crypto_caps",
+					sec_crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_crypto_caps_n", sec_crypto_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(cnxk_cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd("/cnxk/cryptodev/sec_caps",
+		cryptodev_tel_handle_sec_caps,
+		"Returns cryptodev capabilities. Parameters: int dev_id");
+}
diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build
index 024109f7e9..2d78757bba 100644
--- a/drivers/crypto/cnxk/meson.build
+++ b/drivers/crypto/cnxk/meson.build
@@ -20,6 +20,7 @@ sources = files(
         'cnxk_cryptodev_devargs.c',
         'cnxk_cryptodev_ops.c',
         'cnxk_cryptodev_sec.c',
+        'cnxk_cryptodev_telemetry.c',
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev']
-- 
2.25.1


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

* [dpdk-dev] [v1] security: add telemetry endpoint for cryptodev security capabilities
  2021-10-26 13:44                     ` [dpdk-dev] [v8] " Gowrishankar Muthukrishnan
  2021-10-26 14:10                       ` Akhil Goyal
  2021-10-30 17:41                       ` [dpdk-dev] [v9] " Gowrishankar Muthukrishnan
@ 2021-10-30 17:45                       ` Gowrishankar Muthukrishnan
  2021-10-31  5:24                         ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
  2021-11-02 14:42                         ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
  2 siblings, 2 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-30 17:45 UTC (permalink / raw)
  To: dev; +Cc: jerinj, gakhil, anoobj, declan.doherty, Gowrishankar Muthukrishnan

Add telemetry endpoint for cryptodev security capabilities.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 v1:
  - forked from patch 20009 "crypto/cnxk: add telemetry endpoints to cryptodev"
    to integrate changes in lib/rte_security itself.

---
 lib/security/rte_security.c | 98 +++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)

diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c
index fe81ed3e4c..068d855d9b 100644
--- a/lib/security/rte_security.c
+++ b/lib/security/rte_security.c
@@ -4,8 +4,10 @@
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <rte_cryptodev.h>
 #include <rte_malloc.h>
 #include <rte_dev.h>
+#include <rte_telemetry.h>
 #include "rte_compat.h"
 #include "rte_security.h"
 #include "rte_security_driver.h"
@@ -203,3 +205,99 @@ rte_security_capability_get(struct rte_security_ctx *instance,
 
 	return NULL;
 }
+
+static int
+cryptodev_handle_dev_list(const char *cmd __rte_unused,
+			  const char *params __rte_unused,
+			  struct rte_tel_data *d)
+{
+	int dev_id;
+
+	if (rte_cryptodev_count() < 1)
+		return -1;
+
+	rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
+	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
+		if (rte_cryptodev_is_valid_dev(dev_id) &&
+			rte_cryptodev_get_sec_ctx(dev_id))
+			rte_tel_data_add_array_int(d, dev_id);
+
+	return 0;
+}
+
+#define SEC_CAPS_SZ						\
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability), \
+			sizeof(uint64_t)) /	sizeof(uint64_t))
+
+static int
+sec_caps_array(struct rte_tel_data *d,
+	       const struct rte_security_capability *capabilities)
+{
+	const struct rte_security_capability *dev_caps;
+	uint64_t caps_val[SEC_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->action !=
+	   RTE_SECURITY_ACTION_TYPE_NONE) {
+		memset(&caps_val, 0, SEC_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+static int
+security_handle_dev_caps(const char *cmd __rte_unused, const char *params,
+			 struct rte_tel_data *d)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_security_ctx *sec_ctx;
+	struct rte_tel_data *sec_caps;
+	int sec_caps_n;
+	char *end_param;
+	int dev_id;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	rte_tel_data_start_dict(d);
+	sec_caps = rte_tel_data_alloc();
+	if (!sec_caps)
+		return -ENOMEM;
+
+	sec_ctx = (struct rte_security_ctx *)rte_cryptodev_get_sec_ctx(dev_id);
+	if (!sec_ctx)
+		return -EINVAL;
+
+	capabilities = rte_security_capabilities_get(sec_ctx);
+	if (!capabilities)
+		return -EINVAL;
+
+	sec_caps_n = sec_caps_array(sec_caps, capabilities);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(security_init_telemetry)
+{
+	rte_telemetry_register_cmd("/security/list",
+		cryptodev_handle_dev_list,
+		"Returns list of available crypto devices by IDs. No parameters.");
+
+	rte_telemetry_register_cmd("/security/caps",
+		security_handle_dev_caps,
+		"Returns security capabilities for a cryptodev. Parameters: int dev_id");
+}
-- 
2.25.1


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

* [dpdk-dev] [v2] security: add telemetry endpoint for cryptodev security capabilities
  2021-10-30 17:45                       ` [dpdk-dev] [v1] security: add telemetry endpoint for cryptodev security capabilities Gowrishankar Muthukrishnan
@ 2021-10-31  5:24                         ` Gowrishankar Muthukrishnan
  2021-11-02 14:42                         ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
  1 sibling, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-10-31  5:24 UTC (permalink / raw)
  To: dev; +Cc: jerinj, gakhil, anoobj, declan.doherty, Gowrishankar Muthukrishnan

Add telemetry endpoint for cryptodev security capabilities.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v2:
 - updated doc and release notes
---
 doc/guides/prog_guide/rte_security.rst | 22 ++++++
 doc/guides/rel_notes/release_21_11.rst |  5 ++
 lib/security/rte_security.c            | 98 ++++++++++++++++++++++++++
 3 files changed, 125 insertions(+)

diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst
index 46c9b51d1b..dbc6ef0783 100644
--- a/doc/guides/prog_guide/rte_security.rst
+++ b/doc/guides/prog_guide/rte_security.rst
@@ -728,3 +728,25 @@ it is only valid to have a single flow to map to that security session.
         +-------+            +--------+    +-----+
         |  Eth  | ->  ... -> |   ESP  | -> | END |
         +-------+            +--------+    +-----+
+
+
+Telemetry support
+-----------------
+
+The Security library has support for displaying Crypto device information
+with respect to its Security capabilities. Telemetry commands that can be used
+are shown below.
+
+#. Get the list of available Crypto devices by ID, that supports Security features::
+
+     --> /security/list
+     {"/security/list": [0, 1, 2, 3]}
+
+#. Get the security capabilities of a Crypto device::
+
+     --> /security/caps,0
+	 {"/security/caps": {"sec_caps": [<array of serialized bytes of
+	 capabilities>], "sec_caps_n": <number of capabilities>}}
+
+For more information on how to use the Telemetry interface, see
+the :doc:`../howto/telemetry`.
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 47cd67131e..88834d91d8 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -197,6 +197,11 @@ New Features
   * Added port representors support on SN1000 SmartNICs
   * Added flow API transfer proxy support
 
+* **Added Telemetry callback to Security library.**
+
+  Added Telemetry callback function to query security capabilities of
+  Crypto device.
+
 * **Updated Marvell cnxk crypto PMD.**
 
   * Added AES-CBC SHA1-HMAC support in lookaside protocol (IPsec) for CN10K.
diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c
index fe81ed3e4c..068d855d9b 100644
--- a/lib/security/rte_security.c
+++ b/lib/security/rte_security.c
@@ -4,8 +4,10 @@
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <rte_cryptodev.h>
 #include <rte_malloc.h>
 #include <rte_dev.h>
+#include <rte_telemetry.h>
 #include "rte_compat.h"
 #include "rte_security.h"
 #include "rte_security_driver.h"
@@ -203,3 +205,99 @@ rte_security_capability_get(struct rte_security_ctx *instance,
 
 	return NULL;
 }
+
+static int
+cryptodev_handle_dev_list(const char *cmd __rte_unused,
+			  const char *params __rte_unused,
+			  struct rte_tel_data *d)
+{
+	int dev_id;
+
+	if (rte_cryptodev_count() < 1)
+		return -1;
+
+	rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
+	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
+		if (rte_cryptodev_is_valid_dev(dev_id) &&
+			rte_cryptodev_get_sec_ctx(dev_id))
+			rte_tel_data_add_array_int(d, dev_id);
+
+	return 0;
+}
+
+#define SEC_CAPS_SZ						\
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability), \
+			sizeof(uint64_t)) /	sizeof(uint64_t))
+
+static int
+sec_caps_array(struct rte_tel_data *d,
+	       const struct rte_security_capability *capabilities)
+{
+	const struct rte_security_capability *dev_caps;
+	uint64_t caps_val[SEC_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->action !=
+	   RTE_SECURITY_ACTION_TYPE_NONE) {
+		memset(&caps_val, 0, SEC_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+static int
+security_handle_dev_caps(const char *cmd __rte_unused, const char *params,
+			 struct rte_tel_data *d)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_security_ctx *sec_ctx;
+	struct rte_tel_data *sec_caps;
+	int sec_caps_n;
+	char *end_param;
+	int dev_id;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	rte_tel_data_start_dict(d);
+	sec_caps = rte_tel_data_alloc();
+	if (!sec_caps)
+		return -ENOMEM;
+
+	sec_ctx = (struct rte_security_ctx *)rte_cryptodev_get_sec_ctx(dev_id);
+	if (!sec_ctx)
+		return -EINVAL;
+
+	capabilities = rte_security_capabilities_get(sec_ctx);
+	if (!capabilities)
+		return -EINVAL;
+
+	sec_caps_n = sec_caps_array(sec_caps, capabilities);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(security_init_telemetry)
+{
+	rte_telemetry_register_cmd("/security/list",
+		cryptodev_handle_dev_list,
+		"Returns list of available crypto devices by IDs. No parameters.");
+
+	rte_telemetry_register_cmd("/security/caps",
+		security_handle_dev_caps,
+		"Returns security capabilities for a cryptodev. Parameters: int dev_id");
+}
-- 
2.25.1


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

* [dpdk-dev] [v3] security: add telemetry endpoint for cryptodev security capabilities
  2021-10-30 17:45                       ` [dpdk-dev] [v1] security: add telemetry endpoint for cryptodev security capabilities Gowrishankar Muthukrishnan
  2021-10-31  5:24                         ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
@ 2021-11-02 14:42                         ` Gowrishankar Muthukrishnan
  2021-11-02 14:52                           ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
  1 sibling, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-11-02 14:42 UTC (permalink / raw)
  To: dev; +Cc: jerinj, gakhil, anoobj, declan.doherty, Gowrishankar Muthukrishnan

Add telemetry endpoint for cryptodev security capabilities.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v3:
 - secure cryptodev capability endpoint is added and endpoints
   renamed.

---
 doc/guides/prog_guide/rte_security.rst |  28 ++++
 doc/guides/rel_notes/release_21_11.rst |   5 +
 lib/security/rte_security.c            | 182 +++++++++++++++++++++++++
 3 files changed, 215 insertions(+)

diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst
index 46c9b51d1b..72ca0bd330 100644
--- a/doc/guides/prog_guide/rte_security.rst
+++ b/doc/guides/prog_guide/rte_security.rst
@@ -728,3 +728,31 @@ it is only valid to have a single flow to map to that security session.
         +-------+            +--------+    +-----+
         |  Eth  | ->  ... -> |   ESP  | -> | END |
         +-------+            +--------+    +-----+
+
+
+Telemetry support
+-----------------
+
+The Security library has support for displaying Crypto device information
+with respect to its Security capabilities. Telemetry commands that can be used
+are shown below.
+
+#. Get the list of available Crypto devices by ID, that supports Security features::
+
+     --> /security/cryptodev/list
+     {"/security/cryptodev/list": [0, 1, 2, 3]}
+
+#. Get the security capabilities of a Crypto device::
+
+     --> /security/cryptodev/sec_caps,0
+	 {"/security/cryptodev/sec_caps": {"sec_caps": [<array of serialized bytes of
+	 capabilities>], "sec_caps_n": <number of capabilities>}}
+
+ #. Get the security crypto capabilities of a Crypto device::
+
+     --> /security/cryptodev/crypto_caps,0,0
+	 {"/security/cryptodev/crypto_caps": {"crypto_caps": [<array of serialized bytes of
+	 capabilities>], "crypto_caps_n": <number of capabilities>}}
+
+For more information on how to use the Telemetry interface, see
+the :doc:`../howto/telemetry`.
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 47cd67131e..df768bb1c8 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -197,6 +197,11 @@ New Features
   * Added port representors support on SN1000 SmartNICs
   * Added flow API transfer proxy support
 
+* **Added Telemetry callback to Security library.**
+
+  Added Telemetry callback functions to query security capabilities of
+  Crypto device.
+
 * **Updated Marvell cnxk crypto PMD.**
 
   * Added AES-CBC SHA1-HMAC support in lookaside protocol (IPsec) for CN10K.
diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c
index fe81ed3e4c..e92dbf518f 100644
--- a/lib/security/rte_security.c
+++ b/lib/security/rte_security.c
@@ -4,8 +4,10 @@
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <rte_cryptodev.h>
 #include <rte_malloc.h>
 #include <rte_dev.h>
+#include <rte_telemetry.h>
 #include "rte_compat.h"
 #include "rte_security.h"
 #include "rte_security_driver.h"
@@ -203,3 +205,183 @@ rte_security_capability_get(struct rte_security_ctx *instance,
 
 	return NULL;
 }
+
+static int
+security_handle_cryptodev_list(const char *cmd __rte_unused,
+			       const char *params __rte_unused,
+			       struct rte_tel_data *d)
+{
+	int dev_id;
+
+	if (rte_cryptodev_count() < 1)
+		return -1;
+
+	rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
+	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
+		if (rte_cryptodev_is_valid_dev(dev_id) &&
+		    rte_cryptodev_get_sec_ctx(dev_id))
+			rte_tel_data_add_array_int(d, dev_id);
+
+	return 0;
+}
+
+#define CRYPTO_CAPS_SZ                                             \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+			sizeof(uint64_t)) /	sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  const struct rte_cryptodev_capabilities *capabilities)
+{
+	const struct rte_cryptodev_capabilities *dev_caps;
+	uint64_t caps_val[CRYPTO_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->op !=
+	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		memset(&caps_val, 0, CRYPTO_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+#define SEC_CAPS_SZ						\
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability), \
+			sizeof(uint64_t)) /	sizeof(uint64_t))
+
+static int
+sec_caps_array(struct rte_tel_data *d,
+	       const struct rte_security_capability *capabilities)
+{
+	const struct rte_security_capability *dev_caps;
+	uint64_t caps_val[SEC_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->action !=
+	   RTE_SECURITY_ACTION_TYPE_NONE) {
+		memset(&caps_val, 0, SEC_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+static int
+security_capabilities_from_dev_id(int dev_id, const void **caps)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_security_ctx *sec_ctx;
+
+	if (rte_cryptodev_is_valid_dev(dev_id) == 0)
+		return -EINVAL;
+
+	sec_ctx = (struct rte_security_ctx *)rte_cryptodev_get_sec_ctx(dev_id);
+	RTE_PTR_OR_ERR_RET(sec_ctx, -EINVAL);
+
+	capabilities = rte_security_capabilities_get(sec_ctx);
+	RTE_PTR_OR_ERR_RET(capabilities, -EINVAL);
+
+	*caps = capabilities;
+	return 0;
+}
+
+static int
+security_handle_cryptodev_sec_caps(const char *cmd __rte_unused, const char *params,
+				   struct rte_tel_data *d)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_tel_data *sec_caps;
+	char *end_param;
+	int sec_caps_n;
+	int dev_id;
+	int rc;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+
+	rc = security_capabilities_from_dev_id(dev_id, (void *)&capabilities);
+	if (rc < 0)
+		return rc;
+
+	sec_caps = rte_tel_data_alloc();
+	RTE_PTR_OR_ERR_RET(sec_caps, -ENOMEM);
+
+	rte_tel_data_start_dict(d);
+	sec_caps_n = sec_caps_array(sec_caps, capabilities);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+static int
+security_handle_cryptodev_crypto_caps(const char *cmd __rte_unused, const char *params,
+				      struct rte_tel_data *d)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_tel_data *crypto_caps;
+	const char *capa_param;
+	int dev_id, capa_id;
+	int crypto_caps_n;
+	char *end_param;
+	int rc;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	capa_param = strtok(end_param, ",");
+	if (!capa_param || strlen(capa_param) == 0 || !isdigit(*capa_param))
+		return -EINVAL;
+
+	capa_id = strtoul(capa_param, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+
+	rc = security_capabilities_from_dev_id(dev_id, (void *)&capabilities);
+	if (rc < 0)
+		return rc;
+
+	crypto_caps = rte_tel_data_alloc();
+	RTE_PTR_OR_ERR_RET(crypto_caps, -ENOMEM);
+
+	rte_tel_data_start_dict(d);
+	crypto_caps_n = crypto_caps_array(crypto_caps, capabilities->crypto_capabilities);
+	if (capa_id >= crypto_caps_n) {
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+		return -EINVAL;
+	}
+
+	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(security_init_telemetry)
+{
+	rte_telemetry_register_cmd("/security/cryptodev/list",
+		security_handle_cryptodev_list,
+		"Returns list of available crypto devices by IDs. No parameters.");
+
+	rte_telemetry_register_cmd("/security/cryptodev/sec_caps",
+		security_handle_cryptodev_sec_caps,
+		"Returns security capabilities for a cryptodev. Parameters: int dev_id");
+
+	rte_telemetry_register_cmd("/security/cryptodev/crypto_caps",
+		security_handle_cryptodev_crypto_caps,
+		"Returns crypto capabilities for a secuity capability. Parameters: int dev_id, sec_cap_id");
+}
-- 
2.25.1


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

* [dpdk-dev] [v4] security: add telemetry endpoint for cryptodev security capabilities
  2021-11-02 14:42                         ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
@ 2021-11-02 14:52                           ` Gowrishankar Muthukrishnan
  2021-11-03 19:37                             ` Akhil Goyal
  2021-11-04  5:11                             ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
  0 siblings, 2 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-11-02 14:52 UTC (permalink / raw)
  To: dev; +Cc: jerinj, gakhil, anoobj, declan.doherty, Gowrishankar Muthukrishnan

Add telemetry endpoint for cryptodev security capabilities.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v4:
 - fixed typo in help.

---
 doc/guides/prog_guide/rte_security.rst |  28 ++++
 doc/guides/rel_notes/release_21_11.rst |   5 +
 lib/security/rte_security.c            | 182 +++++++++++++++++++++++++
 3 files changed, 215 insertions(+)

diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst
index 46c9b51d1b..72ca0bd330 100644
--- a/doc/guides/prog_guide/rte_security.rst
+++ b/doc/guides/prog_guide/rte_security.rst
@@ -728,3 +728,31 @@ it is only valid to have a single flow to map to that security session.
         +-------+            +--------+    +-----+
         |  Eth  | ->  ... -> |   ESP  | -> | END |
         +-------+            +--------+    +-----+
+
+
+Telemetry support
+-----------------
+
+The Security library has support for displaying Crypto device information
+with respect to its Security capabilities. Telemetry commands that can be used
+are shown below.
+
+#. Get the list of available Crypto devices by ID, that supports Security features::
+
+     --> /security/cryptodev/list
+     {"/security/cryptodev/list": [0, 1, 2, 3]}
+
+#. Get the security capabilities of a Crypto device::
+
+     --> /security/cryptodev/sec_caps,0
+	 {"/security/cryptodev/sec_caps": {"sec_caps": [<array of serialized bytes of
+	 capabilities>], "sec_caps_n": <number of capabilities>}}
+
+ #. Get the security crypto capabilities of a Crypto device::
+
+     --> /security/cryptodev/crypto_caps,0,0
+	 {"/security/cryptodev/crypto_caps": {"crypto_caps": [<array of serialized bytes of
+	 capabilities>], "crypto_caps_n": <number of capabilities>}}
+
+For more information on how to use the Telemetry interface, see
+the :doc:`../howto/telemetry`.
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 47cd67131e..df768bb1c8 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -197,6 +197,11 @@ New Features
   * Added port representors support on SN1000 SmartNICs
   * Added flow API transfer proxy support
 
+* **Added Telemetry callback to Security library.**
+
+  Added Telemetry callback functions to query security capabilities of
+  Crypto device.
+
 * **Updated Marvell cnxk crypto PMD.**
 
   * Added AES-CBC SHA1-HMAC support in lookaside protocol (IPsec) for CN10K.
diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c
index fe81ed3e4c..92aaf1bf76 100644
--- a/lib/security/rte_security.c
+++ b/lib/security/rte_security.c
@@ -4,8 +4,10 @@
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <rte_cryptodev.h>
 #include <rte_malloc.h>
 #include <rte_dev.h>
+#include <rte_telemetry.h>
 #include "rte_compat.h"
 #include "rte_security.h"
 #include "rte_security_driver.h"
@@ -203,3 +205,183 @@ rte_security_capability_get(struct rte_security_ctx *instance,
 
 	return NULL;
 }
+
+static int
+security_handle_cryptodev_list(const char *cmd __rte_unused,
+			       const char *params __rte_unused,
+			       struct rte_tel_data *d)
+{
+	int dev_id;
+
+	if (rte_cryptodev_count() < 1)
+		return -1;
+
+	rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
+	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
+		if (rte_cryptodev_is_valid_dev(dev_id) &&
+		    rte_cryptodev_get_sec_ctx(dev_id))
+			rte_tel_data_add_array_int(d, dev_id);
+
+	return 0;
+}
+
+#define CRYPTO_CAPS_SZ                                             \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+			sizeof(uint64_t)) /	sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  const struct rte_cryptodev_capabilities *capabilities)
+{
+	const struct rte_cryptodev_capabilities *dev_caps;
+	uint64_t caps_val[CRYPTO_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->op !=
+	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		memset(&caps_val, 0, CRYPTO_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+#define SEC_CAPS_SZ						\
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability), \
+			sizeof(uint64_t)) /	sizeof(uint64_t))
+
+static int
+sec_caps_array(struct rte_tel_data *d,
+	       const struct rte_security_capability *capabilities)
+{
+	const struct rte_security_capability *dev_caps;
+	uint64_t caps_val[SEC_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->action !=
+	   RTE_SECURITY_ACTION_TYPE_NONE) {
+		memset(&caps_val, 0, SEC_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i;
+}
+
+static int
+security_capabilities_from_dev_id(int dev_id, const void **caps)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_security_ctx *sec_ctx;
+
+	if (rte_cryptodev_is_valid_dev(dev_id) == 0)
+		return -EINVAL;
+
+	sec_ctx = (struct rte_security_ctx *)rte_cryptodev_get_sec_ctx(dev_id);
+	RTE_PTR_OR_ERR_RET(sec_ctx, -EINVAL);
+
+	capabilities = rte_security_capabilities_get(sec_ctx);
+	RTE_PTR_OR_ERR_RET(capabilities, -EINVAL);
+
+	*caps = capabilities;
+	return 0;
+}
+
+static int
+security_handle_cryptodev_sec_caps(const char *cmd __rte_unused, const char *params,
+				   struct rte_tel_data *d)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_tel_data *sec_caps;
+	char *end_param;
+	int sec_caps_n;
+	int dev_id;
+	int rc;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+
+	rc = security_capabilities_from_dev_id(dev_id, (void *)&capabilities);
+	if (rc < 0)
+		return rc;
+
+	sec_caps = rte_tel_data_alloc();
+	RTE_PTR_OR_ERR_RET(sec_caps, -ENOMEM);
+
+	rte_tel_data_start_dict(d);
+	sec_caps_n = sec_caps_array(sec_caps, capabilities);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+static int
+security_handle_cryptodev_crypto_caps(const char *cmd __rte_unused, const char *params,
+				      struct rte_tel_data *d)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_tel_data *crypto_caps;
+	const char *capa_param;
+	int dev_id, capa_id;
+	int crypto_caps_n;
+	char *end_param;
+	int rc;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	capa_param = strtok(end_param, ",");
+	if (!capa_param || strlen(capa_param) == 0 || !isdigit(*capa_param))
+		return -EINVAL;
+
+	capa_id = strtoul(capa_param, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+
+	rc = security_capabilities_from_dev_id(dev_id, (void *)&capabilities);
+	if (rc < 0)
+		return rc;
+
+	crypto_caps = rte_tel_data_alloc();
+	RTE_PTR_OR_ERR_RET(crypto_caps, -ENOMEM);
+
+	rte_tel_data_start_dict(d);
+	crypto_caps_n = crypto_caps_array(crypto_caps, capabilities->crypto_capabilities);
+	if (capa_id >= crypto_caps_n) {
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+		return -EINVAL;
+	}
+
+	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(security_init_telemetry)
+{
+	rte_telemetry_register_cmd("/security/cryptodev/list",
+		security_handle_cryptodev_list,
+		"Returns list of available crypto devices by IDs. No parameters.");
+
+	rte_telemetry_register_cmd("/security/cryptodev/sec_caps",
+		security_handle_cryptodev_sec_caps,
+		"Returns security capabilities for a cryptodev. Parameters: int dev_id");
+
+	rte_telemetry_register_cmd("/security/cryptodev/crypto_caps",
+		security_handle_cryptodev_crypto_caps,
+		"Returns crypto capabilities for a security capability. Parameters: int dev_id, sec_cap_id");
+}
-- 
2.25.1


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

* Re: [dpdk-dev] [v8] crypto/cnxk: add telemetry endpoints to cryptodev
  2021-10-26 14:10                       ` Akhil Goyal
@ 2021-11-03  4:43                         ` Gowrishankar Muthukrishnan
  0 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-11-03  4:43 UTC (permalink / raw)
  To: Akhil Goyal, dev, Anoob Joseph
  Cc: Jerin Jacob Kollanukkaran, Ankur Dwivedi, Tejasree Kondoj


Hi Akhil,

> > Subject: [v8] crypto/cnxk: add telemetry endpoints to cryptodev
> >
> > Add telemetry endpoints to cryptodev.
> >
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > ---
> > Depends-on: patch-19601 ("cryptodev: add telemetry callbacks")
> > Depends-on: patch-20006 ("cryptodev: add telemetry endpoint for cryptodev
> > capabilities")
> >
> > v8:
> >  - minor cleanup
> >
> This patch is adding telemetry statistics for security capabilities similar to crypto
> caps.
> Isn't it good to add it in rte_security itself so that it can be reused for other
> PMDs also.
> 

Thanks for the suggestion, I have created new end points for these info in
https://patches.dpdk.org/project/dpdk/patch/4d0648e0347e8c6a4b2b095acf568faf6df135ca.1635864621.git.gmuthukrishn@marvell.com/

This driver patch can be ignored.

Regards,
Gowrishankar

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

* Re: [dpdk-dev] [v4] security: add telemetry endpoint for cryptodev security capabilities
  2021-11-02 14:52                           ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
@ 2021-11-03 19:37                             ` Akhil Goyal
  2021-11-04  4:29                               ` Gowrishankar Muthukrishnan
  2021-11-04  5:11                             ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
  1 sibling, 1 reply; 121+ messages in thread
From: Akhil Goyal @ 2021-11-03 19:37 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Jerin Jacob Kollanukkaran, Anoob Joseph, declan.doherty,
	Gowrishankar Muthukrishnan

> +static int
> +security_handle_cryptodev_crypto_caps(const char *cmd __rte_unused,
> const char *params,
> +				      struct rte_tel_data *d)
> +{
> +	const struct rte_security_capability *capabilities;
> +	struct rte_tel_data *crypto_caps;
> +	const char *capa_param;
> +	int dev_id, capa_id;
> +	int crypto_caps_n;
> +	char *end_param;
> +	int rc;
> +
> +	if (!params || strlen(params) == 0 || !isdigit(*params))
> +		return -EINVAL;
> +
> +	dev_id = strtoul(params, &end_param, 0);
> +	capa_param = strtok(end_param, ",");
> +	if (!capa_param || strlen(capa_param) == 0 ||
> !isdigit(*capa_param))
> +		return -EINVAL;
> +
> +	capa_id = strtoul(capa_param, &end_param, 0);
> +	if (*end_param != '\0')
> +		CDEV_LOG_ERR("Extra parameters passed to command,
> ignoring");
> +
> +	rc = security_capabilities_from_dev_id(dev_id, (void *)&capabilities);
> +	if (rc < 0)
> +		return rc;
> +
> +	crypto_caps = rte_tel_data_alloc();
> +	RTE_PTR_OR_ERR_RET(crypto_caps, -ENOMEM);
> +
> +	rte_tel_data_start_dict(d);
> +	crypto_caps_n = crypto_caps_array(crypto_caps, capabilities-
> >crypto_capabilities);
> +	if (capa_id >= crypto_caps_n) {
> +		CDEV_LOG_ERR("Extra parameters passed to command,
> ignoring");
> +		return -EINVAL;
> +	}

Something is not correct here.
Capa_id is not getting used properly.
Security_capabilities should be traversed until capa_id and then extract
The corresponding crypto capabilities. Right?


> +
> +	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
> +	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
> +
> +	return 0;
> +}
> +
> +RTE_INIT(security_init_telemetry)
> +{
> +	rte_telemetry_register_cmd("/security/cryptodev/list",
> +		security_handle_cryptodev_list,
> +		"Returns list of available crypto devices by IDs. No
> parameters.");
> +
> +	rte_telemetry_register_cmd("/security/cryptodev/sec_caps",
> +		security_handle_cryptodev_sec_caps,
> +		"Returns security capabilities for a cryptodev. Parameters: int
> dev_id");
> +
> +	rte_telemetry_register_cmd("/security/cryptodev/crypto_caps",
> +		security_handle_cryptodev_crypto_caps,
> +		"Returns crypto capabilities for a security capability.
> Parameters: int dev_id, sec_cap_id");
> +}
> --
> 2.25.1


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

* Re: [dpdk-dev] [v4] security: add telemetry endpoint for cryptodev security capabilities
  2021-11-03 19:37                             ` Akhil Goyal
@ 2021-11-04  4:29                               ` Gowrishankar Muthukrishnan
  0 siblings, 0 replies; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-11-04  4:29 UTC (permalink / raw)
  To: Akhil Goyal, dev; +Cc: Jerin Jacob Kollanukkaran, Anoob Joseph, declan.doherty

> 
> > +static int
> > +security_handle_cryptodev_crypto_caps(const char *cmd __rte_unused,
> > const char *params,
> > +				      struct rte_tel_data *d)
> > +{
> > +	const struct rte_security_capability *capabilities;
> > +	struct rte_tel_data *crypto_caps;
> > +	const char *capa_param;
> > +	int dev_id, capa_id;
> > +	int crypto_caps_n;
> > +	char *end_param;
> > +	int rc;
> > +
> > +	if (!params || strlen(params) == 0 || !isdigit(*params))
> > +		return -EINVAL;
> > +
> > +	dev_id = strtoul(params, &end_param, 0);
> > +	capa_param = strtok(end_param, ",");
> > +	if (!capa_param || strlen(capa_param) == 0 ||
> > !isdigit(*capa_param))
> > +		return -EINVAL;
> > +
> > +	capa_id = strtoul(capa_param, &end_param, 0);
> > +	if (*end_param != '\0')
> > +		CDEV_LOG_ERR("Extra parameters passed to command,
> > ignoring");
> > +
> > +	rc = security_capabilities_from_dev_id(dev_id, (void *)&capabilities);
> > +	if (rc < 0)
> > +		return rc;
> > +
> > +	crypto_caps = rte_tel_data_alloc();
> > +	RTE_PTR_OR_ERR_RET(crypto_caps, -ENOMEM);
> > +
> > +	rte_tel_data_start_dict(d);
> > +	crypto_caps_n = crypto_caps_array(crypto_caps, capabilities-
> > >crypto_capabilities);
> > +	if (capa_id >= crypto_caps_n) {
> > +		CDEV_LOG_ERR("Extra parameters passed to command,
> > ignoring");
> > +		return -EINVAL;
> > +	}
> 
> Something is not correct here.
> Capa_id is not getting used properly.
> Security_capabilities should be traversed until capa_id and then extract The
> corresponding crypto capabilities. Right?
> 
Yeah right. Fixing it.

Thanks,
Gowrishankar
> 
> > +
> > +	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
> > +	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
> > +
> > +	return 0;
> > +}
> > +
> > +RTE_INIT(security_init_telemetry)
> > +{
> > +	rte_telemetry_register_cmd("/security/cryptodev/list",
> > +		security_handle_cryptodev_list,
> > +		"Returns list of available crypto devices by IDs. No
> > parameters.");
> > +
> > +	rte_telemetry_register_cmd("/security/cryptodev/sec_caps",
> > +		security_handle_cryptodev_sec_caps,
> > +		"Returns security capabilities for a cryptodev. Parameters: int
> > dev_id");
> > +
> > +	rte_telemetry_register_cmd("/security/cryptodev/crypto_caps",
> > +		security_handle_cryptodev_crypto_caps,
> > +		"Returns crypto capabilities for a security capability.
> > Parameters: int dev_id, sec_cap_id");
> > +}
> > --
> > 2.25.1


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

* [dpdk-dev] [v5] security: add telemetry endpoint for cryptodev security capabilities
  2021-11-02 14:52                           ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
  2021-11-03 19:37                             ` Akhil Goyal
@ 2021-11-04  5:11                             ` Gowrishankar Muthukrishnan
  2021-11-04 10:50                               ` Akhil Goyal
  1 sibling, 1 reply; 121+ messages in thread
From: Gowrishankar Muthukrishnan @ 2021-11-04  5:11 UTC (permalink / raw)
  To: dev; +Cc: jerinj, gakhil, anoobj, declan.doherty, Gowrishankar Muthukrishnan

Add telemetry endpoint for cryptodev security capabilities.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v5:
 - fixed parsing security capabilities for a requested index.

---
 doc/guides/prog_guide/rte_security.rst |  28 ++++
 doc/guides/rel_notes/release_21_11.rst |   5 +
 lib/security/rte_security.c            | 199 +++++++++++++++++++++++++
 3 files changed, 232 insertions(+)

diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst
index 46c9b51d1b..72ca0bd330 100644
--- a/doc/guides/prog_guide/rte_security.rst
+++ b/doc/guides/prog_guide/rte_security.rst
@@ -728,3 +728,31 @@ it is only valid to have a single flow to map to that security session.
         +-------+            +--------+    +-----+
         |  Eth  | ->  ... -> |   ESP  | -> | END |
         +-------+            +--------+    +-----+
+
+
+Telemetry support
+-----------------
+
+The Security library has support for displaying Crypto device information
+with respect to its Security capabilities. Telemetry commands that can be used
+are shown below.
+
+#. Get the list of available Crypto devices by ID, that supports Security features::
+
+     --> /security/cryptodev/list
+     {"/security/cryptodev/list": [0, 1, 2, 3]}
+
+#. Get the security capabilities of a Crypto device::
+
+     --> /security/cryptodev/sec_caps,0
+	 {"/security/cryptodev/sec_caps": {"sec_caps": [<array of serialized bytes of
+	 capabilities>], "sec_caps_n": <number of capabilities>}}
+
+ #. Get the security crypto capabilities of a Crypto device::
+
+     --> /security/cryptodev/crypto_caps,0,0
+	 {"/security/cryptodev/crypto_caps": {"crypto_caps": [<array of serialized bytes of
+	 capabilities>], "crypto_caps_n": <number of capabilities>}}
+
+For more information on how to use the Telemetry interface, see
+the :doc:`../howto/telemetry`.
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 763c1caca1..1cff823a43 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -197,6 +197,11 @@ New Features
   * Added port representors support on SN1000 SmartNICs
   * Added flow API transfer proxy support
 
+* **Added Telemetry callback to Security library.**
+
+  Added Telemetry callback functions to query security capabilities of
+  Crypto device.
+
 * **Updated Marvell cnxk crypto PMD.**
 
   * Added AES-CBC SHA1-HMAC support in lookaside protocol (IPsec) for CN10K.
diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c
index fe81ed3e4c..6e45a03fa0 100644
--- a/lib/security/rte_security.c
+++ b/lib/security/rte_security.c
@@ -4,8 +4,10 @@
  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
  */
 
+#include <rte_cryptodev.h>
 #include <rte_malloc.h>
 #include <rte_dev.h>
+#include <rte_telemetry.h>
 #include "rte_compat.h"
 #include "rte_security.h"
 #include "rte_security_driver.h"
@@ -203,3 +205,200 @@ rte_security_capability_get(struct rte_security_ctx *instance,
 
 	return NULL;
 }
+
+static int
+security_handle_cryptodev_list(const char *cmd __rte_unused,
+			       const char *params __rte_unused,
+			       struct rte_tel_data *d)
+{
+	int dev_id;
+
+	if (rte_cryptodev_count() < 1)
+		return -1;
+
+	rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
+	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
+		if (rte_cryptodev_is_valid_dev(dev_id) &&
+		    rte_cryptodev_get_sec_ctx(dev_id))
+			rte_tel_data_add_array_int(d, dev_id);
+
+	return 0;
+}
+
+#define CRYPTO_CAPS_SZ                                             \
+	(RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \
+			sizeof(uint64_t)) /	sizeof(uint64_t))
+
+static int
+crypto_caps_array(struct rte_tel_data *d,
+		  const struct rte_cryptodev_capabilities *capabilities)
+{
+	const struct rte_cryptodev_capabilities *dev_caps;
+	uint64_t caps_val[CRYPTO_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->op !=
+	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		memset(&caps_val, 0, CRYPTO_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < CRYPTO_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return (i - 1);
+}
+
+#define SEC_CAPS_SZ						\
+	(RTE_ALIGN_CEIL(sizeof(struct rte_security_capability), \
+			sizeof(uint64_t)) /	sizeof(uint64_t))
+
+static int
+sec_caps_array(struct rte_tel_data *d,
+	       const struct rte_security_capability *capabilities)
+{
+	const struct rte_security_capability *dev_caps;
+	uint64_t caps_val[SEC_CAPS_SZ];
+	unsigned int i = 0, j;
+
+	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+
+	while ((dev_caps = &capabilities[i++])->action !=
+	   RTE_SECURITY_ACTION_TYPE_NONE) {
+		memset(&caps_val, 0, SEC_CAPS_SZ * sizeof(caps_val[0]));
+		rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0]));
+		for (j = 0; j < SEC_CAPS_SZ; j++)
+			rte_tel_data_add_array_u64(d, caps_val[j]);
+	}
+
+	return i - 1;
+}
+
+static const struct rte_security_capability *
+security_capability_by_index(const struct rte_security_capability *capabilities,
+			     int index)
+{
+	const struct rte_security_capability *dev_caps = NULL;
+	int i = 0;
+
+	while ((dev_caps = &capabilities[i])->action !=
+	   RTE_SECURITY_ACTION_TYPE_NONE) {
+		if (i == index)
+			return dev_caps;
+
+		++i;
+	}
+
+	return NULL;
+}
+
+static int
+security_capabilities_from_dev_id(int dev_id, const void **caps)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_security_ctx *sec_ctx;
+
+	if (rte_cryptodev_is_valid_dev(dev_id) == 0)
+		return -EINVAL;
+
+	sec_ctx = (struct rte_security_ctx *)rte_cryptodev_get_sec_ctx(dev_id);
+	RTE_PTR_OR_ERR_RET(sec_ctx, -EINVAL);
+
+	capabilities = rte_security_capabilities_get(sec_ctx);
+	RTE_PTR_OR_ERR_RET(capabilities, -EINVAL);
+
+	*caps = capabilities;
+	return 0;
+}
+
+static int
+security_handle_cryptodev_sec_caps(const char *cmd __rte_unused, const char *params,
+				   struct rte_tel_data *d)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_tel_data *sec_caps;
+	char *end_param;
+	int sec_caps_n;
+	int dev_id;
+	int rc;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+
+	rc = security_capabilities_from_dev_id(dev_id, (void *)&capabilities);
+	if (rc < 0)
+		return rc;
+
+	sec_caps = rte_tel_data_alloc();
+	RTE_PTR_OR_ERR_RET(sec_caps, -ENOMEM);
+
+	rte_tel_data_start_dict(d);
+	sec_caps_n = sec_caps_array(sec_caps, capabilities);
+	rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0);
+	rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n);
+
+	return 0;
+}
+
+static int
+security_handle_cryptodev_crypto_caps(const char *cmd __rte_unused, const char *params,
+				      struct rte_tel_data *d)
+{
+	const struct rte_security_capability *capabilities;
+	struct rte_tel_data *crypto_caps;
+	const char *capa_param;
+	int dev_id, capa_id;
+	int crypto_caps_n;
+	char *end_param;
+	int rc;
+
+	if (!params || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	capa_param = strtok(end_param, ",");
+	if (!capa_param || strlen(capa_param) == 0 || !isdigit(*capa_param))
+		return -EINVAL;
+
+	capa_id = strtoul(capa_param, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+
+	rc = security_capabilities_from_dev_id(dev_id, (void *)&capabilities);
+	if (rc < 0)
+		return rc;
+
+	capabilities = security_capability_by_index(capabilities, capa_id);
+	RTE_PTR_OR_ERR_RET(capabilities, -EINVAL);
+
+	crypto_caps = rte_tel_data_alloc();
+	RTE_PTR_OR_ERR_RET(crypto_caps, -ENOMEM);
+
+	rte_tel_data_start_dict(d);
+	crypto_caps_n = crypto_caps_array(crypto_caps, capabilities->crypto_capabilities);
+
+	rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0);
+	rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n);
+
+	return 0;
+}
+
+RTE_INIT(security_init_telemetry)
+{
+	rte_telemetry_register_cmd("/security/cryptodev/list",
+		security_handle_cryptodev_list,
+		"Returns list of available crypto devices by IDs. No parameters.");
+
+	rte_telemetry_register_cmd("/security/cryptodev/sec_caps",
+		security_handle_cryptodev_sec_caps,
+		"Returns security capabilities for a cryptodev. Parameters: int dev_id");
+
+	rte_telemetry_register_cmd("/security/cryptodev/crypto_caps",
+		security_handle_cryptodev_crypto_caps,
+		"Returns crypto capabilities for a security capability. Parameters: int dev_id, sec_cap_id");
+}
-- 
2.25.1


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

* Re: [dpdk-dev] [v5] security: add telemetry endpoint for cryptodev security capabilities
  2021-11-04  5:11                             ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
@ 2021-11-04 10:50                               ` Akhil Goyal
  0 siblings, 0 replies; 121+ messages in thread
From: Akhil Goyal @ 2021-11-04 10:50 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Jerin Jacob Kollanukkaran, Anoob Joseph, declan.doherty,
	Gowrishankar Muthukrishnan

> 
> Add telemetry endpoint for cryptodev security capabilities.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
> v5:
>  - fixed parsing security capabilities for a requested index.
> 
Acked-by: Akhil Goyal <gakhil@marvell.com>

Applied to dpdk-next-crypto

Thanks.

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

end of thread, other threads:[~2021-11-04 10:51 UTC | newest]

Thread overview: 121+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29 15:25 [dpdk-dev] [v1, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
2021-07-29 15:25 ` [dpdk-dev] [v1, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
2021-07-29 15:48   ` Bruce Richardson
2021-07-30 12:08     ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
2021-08-01 17:40       ` Gowrishankar Muthukrishnan
2021-07-29 15:25 ` [dpdk-dev] [v1, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
2021-07-29 15:25 ` [dpdk-dev] [v1, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-08-01 17:37 ` [dpdk-dev] [v2, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
2021-08-01 17:37   ` [dpdk-dev] [v2, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
2021-08-01 17:37   ` [dpdk-dev] [v2, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
2021-08-01 17:37   ` [dpdk-dev] [v2, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-08-03  8:05   ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Gowrishankar Muthukrishnan
2021-08-03  8:05     ` [dpdk-dev] [v3, 1/3] telemetry: enable storing pointer value Gowrishankar Muthukrishnan
2021-08-03  8:05     ` [dpdk-dev] [v3, 2/3] test/telemetry: add unit tests for " Gowrishankar Muthukrishnan
2021-08-03  8:05     ` [dpdk-dev] [v3, 3/3] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-08-11 15:59     ` [dpdk-dev] [v3, 0/3] common/cnxk: enable npa telemetry Power, Ciara
2021-08-11 16:18       ` Gowrishankar Muthukrishnan
2021-08-24  8:53         ` Gowrishankar Muthukrishnan
2021-08-25 10:09         ` Thomas Monjalon
2021-08-25 14:38           ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
2021-08-26 17:15     ` [dpdk-dev] [v4, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
2021-08-26 17:15       ` [dpdk-dev] [v4, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-08-26 18:06         ` Bruce Richardson
2021-08-27  6:43           ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
2021-08-26 17:15       ` [dpdk-dev] [v4, 2/2] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
2021-08-27  6:41       ` [dpdk-dev] [v5, 0/2] cnxk: enable npa and mempool telemetry Gowrishankar Muthukrishnan
2021-08-27  6:41         ` [dpdk-dev] [v5, 1/2] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-08-27  6:41         ` [dpdk-dev] [v5, 2/2] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
2021-09-04  3:25         ` [dpdk-dev] [v6, 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
2021-09-04  3:25           ` [dpdk-dev] [v6, 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-09-04  3:25           ` [dpdk-dev] [v6, 2/4] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
2021-09-04  3:25           ` [dpdk-dev] [v6, 3/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
2021-09-04  3:25           ` [dpdk-dev] [v6, 4/4] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
2021-09-08 17:03         ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
2021-09-08 17:03           ` [dpdk-dev] [v7, 1/6] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-09-08 17:03           ` [dpdk-dev] [v7, 2/6] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
2021-09-08 17:03           ` [dpdk-dev] [v7, 3/6] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
2021-09-08 17:03           ` [dpdk-dev] [v7, 4/6] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
2021-09-08 17:03           ` [dpdk-dev] [v7, 5/6] telemetry: fix json output buffer size Gowrishankar Muthukrishnan
2021-09-21 11:02             ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
2021-09-22  9:21               ` Power, Ciara
2021-09-23  5:53                 ` Gowrishankar Muthukrishnan
2021-09-30  8:47                   ` Power, Ciara
2021-09-30  9:00                     ` Gowrishankar Muthukrishnan
2021-10-07  9:04                       ` Power, Ciara
2021-09-23  6:21               ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
2021-09-23  6:26                 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
2021-09-29  4:18                   ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
2021-10-06 17:38                     ` Thomas Monjalon
2021-10-07  4:58                       ` [dpdk-dev] [EXT] " Gowrishankar Muthukrishnan
2021-10-07  7:22                         ` Thomas Monjalon
2021-10-07  8:36                           ` Gowrishankar Muthukrishnan
2021-10-11 10:54                     ` [dpdk-dev] [v6] telemetry: remove limitation on JSON output buffer length Gowrishankar Muthukrishnan
2021-10-13 11:06                       ` Power, Ciara
2021-10-13 15:25                         ` Thomas Monjalon
2021-09-08 17:03           ` [dpdk-dev] [v7, 6/6] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
2021-09-21 11:32             ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
2021-09-29  6:45               ` [dpdk-dev] [v1] cryptodev: add telemetry endpoint for cryptodev info Gowrishankar Muthukrishnan
2021-10-22 12:28                 ` [dpdk-dev] [v2] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
2021-10-22 12:37                   ` [dpdk-dev] [v5] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
2021-10-22 12:59                   ` [dpdk-dev] [v6] " Gowrishankar Muthukrishnan
2021-10-22 12:57                 ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Gowrishankar Muthukrishnan
2021-10-22 16:02                   ` [dpdk-dev] [v7] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
2021-10-26 13:44                     ` [dpdk-dev] [v8] " Gowrishankar Muthukrishnan
2021-10-26 14:10                       ` Akhil Goyal
2021-11-03  4:43                         ` Gowrishankar Muthukrishnan
2021-10-30 17:41                       ` [dpdk-dev] [v9] " Gowrishankar Muthukrishnan
2021-10-30 17:45                       ` [dpdk-dev] [v1] security: add telemetry endpoint for cryptodev security capabilities Gowrishankar Muthukrishnan
2021-10-31  5:24                         ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
2021-11-02 14:42                         ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
2021-11-02 14:52                           ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
2021-11-03 19:37                             ` Akhil Goyal
2021-11-04  4:29                               ` Gowrishankar Muthukrishnan
2021-11-04  5:11                             ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
2021-11-04 10:50                               ` Akhil Goyal
2021-10-25  7:26                   ` [dpdk-dev] [v3] cryptodev: add telemetry endpoint for cryptodev capabilities Akhil Goyal
2021-10-26 13:13                   ` [dpdk-dev] [v5] " Gowrishankar Muthukrishnan
2021-10-26 14:12                     ` Akhil Goyal
2021-10-26 15:44                       ` Gowrishankar Muthukrishnan
2021-10-26 18:34                         ` Akhil Goyal
2021-10-26 12:52                 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
2021-09-29  7:01               ` [dpdk-dev] [v3] crypto/cnxk: add telemetry endpoints to cryptodev Gowrishankar Muthukrishnan
2021-09-29  8:56                 ` [dpdk-dev] [v4] " Gowrishankar Muthukrishnan
2021-09-16  8:52           ` [dpdk-dev] [v7, 0/6] cnxk: enable telemetry endpoints Jerin Jacob
2021-09-21 10:52         ` [dpdk-dev] [v8, 0/4] cnxk: enable telemetry endpoints for mempool and ethdev Gowrishankar Muthukrishnan
2021-09-21 10:52           ` [dpdk-dev] [v8, 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-09-21 10:52           ` [dpdk-dev] [v8, 2/4] mempool/cnxk: add telemetry end points Gowrishankar Muthukrishnan
2021-09-29  6:40             ` [dpdk-dev] [v1] mempool: add telemetry endpoint for mempool info Gowrishankar Muthukrishnan
2021-10-13 15:21               ` Thomas Monjalon
2021-10-13 15:26                 ` Bruce Richardson
2021-10-13 15:40               ` Bruce Richardson
2021-10-22  3:28               ` [dpdk-dev] [v2] " Gowrishankar Muthukrishnan
2021-10-22  5:55                 ` David Marchand
2021-10-22 16:11               ` [dpdk-dev] [v3] " Gowrishankar Muthukrishnan
2021-10-22 20:38                 ` Thomas Monjalon
2021-09-21 10:52           ` [dpdk-dev] [v8, 3/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
2021-09-21 10:52           ` [dpdk-dev] [v8, 4/4] net/cnxk: add telemetry endpoing to ethdev Gowrishankar Muthukrishnan
2021-09-21 11:27             ` Jerin Jacob
2021-09-21 11:53               ` Bruce Richardson
2021-09-21 12:16                 ` Olivier Matz
2021-09-29  4:25             ` [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info Gowrishankar Muthukrishnan
2021-10-11 14:40               ` Ferruh Yigit
2021-10-11 15:40                 ` Bruce Richardson
2021-10-11 15:44                   ` Ferruh Yigit
2021-10-14 21:47               ` Ferruh Yigit
2021-09-29  6:54           ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
2021-09-29  6:55             ` [dpdk-dev] [v9 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-10-14 15:22               ` [dpdk-dev] [EXT] " Harman Kalra
2021-09-29  6:55             ` [dpdk-dev] [v9 2/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
2021-10-14 16:37               ` [dpdk-dev] [EXT] " Harman Kalra
2021-09-29  6:55             ` [dpdk-dev] [v9 3/4] mempool/cnxk: add telemetry endpoints mempool Gowrishankar Muthukrishnan
2021-10-14 16:43               ` [dpdk-dev] [EXT] " Harman Kalra
2021-09-29  6:55             ` [dpdk-dev] [v9 4/4] net/cnxk: add telemetry endpoints to ethdev Gowrishankar Muthukrishnan
2021-10-14 16:47               ` [dpdk-dev] [EXT] " Harman Kalra
2021-10-19 11:27             ` [dpdk-dev] [v10 0/4] cnxk: enable telemetry endpoints Gowrishankar Muthukrishnan
2021-10-19 11:27               ` [dpdk-dev] [v10 1/4] common/cnxk: add telemetry endpoints to npa Gowrishankar Muthukrishnan
2021-10-19 11:27               ` [dpdk-dev] [v10 2/4] common/cnxk: add telemetry endpoints to nix Gowrishankar Muthukrishnan
2021-10-19 11:27               ` [dpdk-dev] [v10 3/4] mempool/cnxk: add telemetry endpoints mempool Gowrishankar Muthukrishnan
2021-10-19 11:27               ` [dpdk-dev] [v10 4/4] net/cnxk: add telemetry endpoints to ethdev Gowrishankar Muthukrishnan
2021-10-19 16:42             ` [dpdk-dev] [v9 0/4] cnxk: enable telemetry endpoints Jerin Jacob
2021-10-20 13:30               ` Ferruh Yigit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.