Skip to contentSkip to conversation

Standardize telemetry int types

RFC PATCH Superseded Bruce Richardson 7 participants 51 messages Dec 13, 2022 – Feb 5, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Standardize telemetry int types

Rather than having 64-bit unsigned types and 32-bit signed types supported by the telemetry lib, we should support 64-bit values for both types. On the naming side, since both are 64-bit, we should no longer call the unsigned value u64 - "uint" is better.

This patchset implements these changes as far as is possible while still keeping API and ABI compatibility.

* Internal structures and functions are updated to use 64-bit ints
* Internal functions are renamed from u64 to uint
* Public enum values are renamed from u64 to uint, and a macro is added to ensure that older code still compiles
* The public add_*_int functions are changed to take a 64-bit value rather than a 32-bit one. Since this would be an ABI break, we use function versioning to ensure older code still calls into a wrapper function which takes a 32-bit value.

Finally, the patchset also contains a couple of other small cleanups to the telemetry code that were seen in passing when making these changes.

Bruce Richardson (7):
telemetry: rename unsigned 64-bit enum value to uint
telemetry: add uint type as alias for u64
telemetry: remove RTE prefix from internal enum values
telemetry: make array initialization more robust
telemetry: update json functions to use int/uint in names
telemetry: make internal int representation 64-bits
telemetry: change public API to use 64-bit signed values

 app/test/test_telemetry_data.c               | 10 +--
 app/test/test_telemetry_json.c               |  9 +-
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c |  4 +-
 drivers/net/cnxk/cnxk_ethdev_telemetry.c     |  2 +-
 lib/cryptodev/rte_cryptodev.c                |  2 +-
 lib/ethdev/rte_ethdev.c                      |  2 +-
 lib/ethdev/sff_telemetry.c                   |  2 +-
 lib/ipsec/ipsec_telemetry.c                  |  2 +-
 lib/security/rte_security.c                  |  4 +-
 lib/telemetry/meson.build                    |  1 +
 lib/telemetry/rte_telemetry.h                | 46 +++++++++-
 lib/telemetry/telemetry.c                    | 56 ++++++------
 lib/telemetry/telemetry_data.c               | 95 ++++++++++++++------
 lib/telemetry/telemetry_data.h               | 24 +++--
 lib/telemetry/telemetry_json.h               | 16 ++--
 lib/telemetry/version.map                    | 14 +++
 16 files changed, 192 insertions(+), 97 deletions(-)

--
2.34.1

#1 lore raw

RFC PATCH 1/7 telemetry: rename unsigned 64-bit enum value to uint

For telemetry data, rather than having unsigned 64-bit values and signed 32-bit values, we want to just have unsigned and signed values, each stored with the max bit-width i.e. 64-bits. To that end, we rename the U64 enum entry to "UINT" to have a more generic name

For backward API-level compatibility, we can use a macro to alias the old name to the new.

---
 app/test/test_telemetry_data.c               | 10 +++++-----
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c |  4 ++--
 drivers/net/cnxk/cnxk_ethdev_telemetry.c     |  2 +-
 lib/cryptodev/rte_cryptodev.c                |  2 +-
 lib/ethdev/rte_ethdev.c                      |  2 +-
 lib/ipsec/ipsec_telemetry.c                  |  2 +-
 lib/security/rte_security.c                  |  4 ++--
 lib/telemetry/rte_telemetry.h                |  6 ++++--
 lib/telemetry/telemetry.c                    |  4 ++--
 lib/telemetry/telemetry_data.c               |  4 ++--
 10 files changed, 21 insertions(+), 19 deletions(-)
app/test/test_telemetry_data.c +5 -5
index d92667a527..24a2035b61 100644
@@ -283,7 +283,7 @@ test_case_array_u64(void)
 {
 	int i;
 
-	rte_tel_data_start_array(&response_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(&response_data, RTE_TEL_UINT_VAL);
 	for (i = 0; i < 5; i++)
 		rte_tel_data_add_array_u64(&response_data, i);
 	return CHECK_OUTPUT("[0,1,2,3,4]");
@@ -310,10 +310,10 @@ test_dict_with_array_u64_values(void)
 	int i;
 
 	struct rte_tel_data *child_data = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data, RTE_TEL_UINT_VAL);
 
 	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data2, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data2, RTE_TEL_UINT_VAL);
 
 	rte_tel_data_start_dict(&response_data);
 
@@ -336,10 +336,10 @@ test_array_with_array_u64_values(void)
 	int i;
 
 	struct rte_tel_data *child_data = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data, RTE_TEL_UINT_VAL);
 
 	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data2, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data2, RTE_TEL_UINT_VAL);
 
 	rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER);
 
drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c +2 -2
index 8e6277cbcd..59f0cce5ab 100644
@@ -94,7 +94,7 @@ copy_outb_sa_10k(struct rte_tel_data *d, uint32_t i, void *sa)
 		return -ENOMEM;
 	}
 
-	rte_tel_data_start_array(outer_hdr, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(outer_hdr, RTE_TEL_UINT_VAL);
 
 	for (j = 0; j < RTE_DIM(out_sa->outer_hdr.ipv6.src_addr); j++)
 		rte_tel_data_add_array_u64(outer_hdr,
@@ -167,7 +167,7 @@ copy_inb_sa_10k(struct rte_tel_data *d, uint32_t i, void *sa)
 		return -ENOMEM;
 	}
 
-	rte_tel_data_start_array(outer_hdr, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(outer_hdr, RTE_TEL_UINT_VAL);
 
 	for (j = 0; j < RTE_DIM(in_sa->outer_hdr.ipv6.src_addr); j++)
 		rte_tel_data_add_array_u64(outer_hdr,
drivers/net/cnxk/cnxk_ethdev_telemetry.c +1 -1
index 180108ab9c..5db973d620 100644
@@ -52,7 +52,7 @@ ethdev_tel_handle_info(const char *cmd __rte_unused,
 	i_data = rte_tel_data_alloc();
 	if (i_data == NULL)
 		return -ENOMEM;
-	rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(i_data, RTE_TEL_UINT_VAL);
 
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
 		/* Skip if port is unused */
lib/cryptodev/rte_cryptodev.c +1 -1
index 2165a0688c..79ea958db4 100644
@@ -2744,7 +2744,7 @@ crypto_caps_array(struct rte_tel_data *d,
 	uint64_t caps_val[CRYPTO_CAPS_SZ];
 	unsigned int i = 0, j;
 
-	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
 
 	while ((dev_caps = &capabilities[i++])->op !=
 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
lib/ethdev/rte_ethdev.c +1 -1
index 5d5e18db1e..28028e5de5 100644
@@ -5818,7 +5818,7 @@ eth_dev_add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats,
 	struct rte_tel_data *q_data = rte_tel_data_alloc();
 	if (q_data == NULL)
 		return;
-	rte_tel_data_start_array(q_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(q_data, RTE_TEL_UINT_VAL);
 	for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++)
 		rte_tel_data_add_array_u64(q_data, q_stats[q]);
 	rte_tel_data_add_dict_container(d, stat_name, q_data, 0);
lib/ipsec/ipsec_telemetry.c +1 -1
index cfebf454d6..b184e8df99 100644
@@ -22,7 +22,7 @@ handle_telemetry_cmd_ipsec_sa_list(const char *cmd __rte_unused,
 		struct rte_tel_data *data)
 {
 	struct ipsec_telemetry_entry *entry;
-	rte_tel_data_start_array(data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(data, RTE_TEL_UINT_VAL);
 
 	LIST_FOREACH(entry, &ipsec_telemetry_list, next) {
 		const struct rte_ipsec_sa *sa = entry->sa;
lib/security/rte_security.c +2 -2
index 29af5f3e4b..68063f6450 100644
@@ -316,7 +316,7 @@ crypto_caps_array(struct rte_tel_data *d,
 	uint64_t caps_val[CRYPTO_CAPS_SZ];
 	unsigned int i = 0, j;
 
-	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
 
 	while ((dev_caps = &capabilities[i++])->op !=
 	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
@@ -341,7 +341,7 @@ sec_caps_array(struct rte_tel_data *d,
 	uint64_t caps_val[SEC_CAPS_SZ];
 	unsigned int i = 0, j;
 
-	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
 
 	while ((dev_caps = &capabilities[i++])->action !=
 	   RTE_SECURITY_ACTION_TYPE_NONE) {
lib/telemetry/rte_telemetry.h +4 -2
index d9918c4e96..c2ad65effe 100644
@@ -43,10 +43,12 @@ struct rte_tel_data;
 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_UINT_VAL,  /** an unsigned 64-bit int value */
 	RTE_TEL_CONTAINER, /** a container struct */
 };
 
+#define RTE_TEL_U64_VAL RTE_TEL_UINT_VAL
+
 /**
  * Start an array of the specified type for returning from a callback
  *
@@ -121,7 +123,7 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 /**
  * Add a uint64_t to an array.
  * The array must have been started by rte_tel_data_start_array() with
- * RTE_TEL_U64_VAL as the type parameter.
+ * RTE_TEL_UINT_VAL as the type parameter.
  *
  * @param d
  *   The data structure passed to the callback
lib/telemetry/telemetry.c +2 -2
index 8fbb4f3060..75957fe0b1 100644
@@ -201,7 +201,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 						buf_len, used,
 						v->name, v->value.ival);
 				break;
-			case RTE_TEL_U64_VAL:
+			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(out_buf,
 						buf_len, used,
 						v->name, v->value.u64val);
@@ -268,7 +268,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						buf_len, used,
 						v->name, v->value.ival);
 				break;
-			case RTE_TEL_U64_VAL:
+			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(cb_data_buf,
 						buf_len, used,
 						v->name, v->value.u64val);
lib/telemetry/telemetry_data.c +2 -2
index 34366ecee3..3c996484ec 100644
@@ -18,7 +18,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 	enum tel_container_types array_types[] = {
 			RTE_TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
 			RTE_TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			RTE_TEL_ARRAY_U64,    /* RTE_TEL_u64_VAL = 2 */
+			RTE_TEL_ARRAY_U64,    /* RTE_TEL_UINT_VAL = 2 */
 			RTE_TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
 	};
 	d->type = array_types[type];
@@ -173,7 +173,7 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 		return -EINVAL;
 
 	d->data_len++;
-	e->type = RTE_TEL_U64_VAL;
+	e->type = RTE_TEL_UINT_VAL;
 	e->value.u64val = val;
 	const size_t bytes = strlcpy(e->name, name, RTE_TEL_MAX_STRING_LEN);
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
Signature · 1 line
2.34.1
#2 lore raw

Re: [RFC PATCH 1/7] telemetry: rename unsigned 64-bit enum value to uint

Quoted 16 lines · Bruce Richardson

For telemetry data, rather than having unsigned 64-bit values and signed 32-bit values, we want to just have unsigned and signed values, each stored with the max bit-width i.e. 64-bits. To that end, we rename the U64 enum entry to "UINT" to have a more generic name

For backward API-level compatibility, we can use a macro to alias the old name to the new.

---

lib/telemetry/telemetry_data.c +0 -0
index 34366ecee3..3c996484ec 100644

lib/telemetry/telemetry_data.c rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type) · line 21

Quoted 5 lines
lib/telemetry/telemetry_data.c +1 -1
@@ -18,7 +18,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 	enum tel_container_types array_types[] = {
 			RTE_TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
 			RTE_TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			RTE_TEL_ARRAY_U64,    /* RTE_TEL_u64_VAL = 2 */
+			RTE_TEL_ARRAY_U64,    /* RTE_TEL_UINT_VAL = 2 */
                        ^^^^^^^^^^^^^^^^^

is this supposed to be RTE_TEL_UINT_VAL?

Quoted 14 lines
lib/telemetry/telemetry_data.c +1 -1
 			RTE_TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
 	};
 	d->type = array_types[type];
@@ -173,7 +173,7 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 		return -EINVAL;
 
 	d->data_len++;
-	e->type = RTE_TEL_U64_VAL;
+	e->type = RTE_TEL_UINT_VAL;
 	e->value.u64val = val;
 	const size_t bytes = strlcpy(e->name, name, RTE_TEL_MAX_STRING_LEN);
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
Signature · 1 line
2.34.1
#3 lore raw

Re: [RFC PATCH 1/7] telemetry: rename unsigned 64-bit enum value to uint

Quoted 24 lines · Tyler Retzlaff
Quoted 16 lines · Bruce Richardson

For telemetry data, rather than having unsigned 64-bit values and signed 32-bit values, we want to just have unsigned and signed values, each stored with the max bit-width i.e. 64-bits. To that end, we rename the U64 enum entry to "UINT" to have a more generic name

For backward API-level compatibility, we can use a macro to alias the old name to the new.

---

lib/telemetry/telemetry_data.c +0 -0
index 34366ecee3..3c996484ec 100644

lib/telemetry/telemetry_data.c rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type) · line 21

Quoted 5 lines
lib/telemetry/telemetry_data.c +1 -1
@@ -18,7 +18,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 	enum tel_container_types array_types[] = {
 			RTE_TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
 			RTE_TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			RTE_TEL_ARRAY_U64,    /* RTE_TEL_u64_VAL = 2 */
+			RTE_TEL_ARRAY_U64,    /* RTE_TEL_UINT_VAL = 2 */
                        ^^^^^^^^^^^^^^^^^
Quoted 2 lines

is this supposed to be RTE_TEL_UINT_VAL?

No, only the comment is to be changed in this line. The ARRAY_ values are different and are internal only. Those are renamed by a later patch in the series.

/Bruce

#4 lore raw

Re: [RFC PATCH 1/7] telemetry: rename unsigned 64-bit enum value to uint

Quoted 25 lines · Bruce Richardson
Quoted 24 lines · Tyler Retzlaff
Quoted 16 lines · Bruce Richardson

For telemetry data, rather than having unsigned 64-bit values and signed 32-bit values, we want to just have unsigned and signed values, each stored with the max bit-width i.e. 64-bits. To that end, we rename the U64 enum entry to "UINT" to have a more generic name

For backward API-level compatibility, we can use a macro to alias the old name to the new.

---

lib/telemetry/telemetry_data.c +0 -0
index 34366ecee3..3c996484ec 100644

lib/telemetry/telemetry_data.c rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type) · line 21

Quoted 5 lines
lib/telemetry/telemetry_data.c +1 -1
@@ -18,7 +18,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 	enum tel_container_types array_types[] = {
 			RTE_TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
 			RTE_TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			RTE_TEL_ARRAY_U64,    /* RTE_TEL_u64_VAL = 2 */
+			RTE_TEL_ARRAY_U64,    /* RTE_TEL_UINT_VAL = 2 */
                        ^^^^^^^^^^^^^^^^^
Quoted 5 lines
Quoted 2 lines

is this supposed to be RTE_TEL_UINT_VAL?

No, only the comment is to be changed in this line. The ARRAY_ values are different and are internal only. Those are renamed by a later patch in the series.

yep, sorry about that i noticed it when i looked at later patches.

Quoted 2 lines

/Bruce

#5 lore raw

RFC PATCH 2/7 telemetry: add uint type as alias for u64

In reply to Bruce Richardson

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

---
 lib/telemetry/rte_telemetry.h  | 36 ++++++++++++++++++++++++++++++++++
 lib/telemetry/telemetry.c      | 16 +++++++--------
 lib/telemetry/telemetry_data.c | 28 ++++++++++++++++++--------
 lib/telemetry/telemetry_data.h |  4 ++--
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 73 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +36 -0
index c2ad65effe..60877dae0a 100644
@@ -8,6 +8,8 @@
 #ifndef _RTE_TELEMETRY_H_
 #define _RTE_TELEMETRY_H_
 
+#include <rte_compat.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -121,6 +123,22 @@ int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 
 /**
+ * Add an unsigned value to an array.
+ * The array must have been started by rte_tel_data_start_array() with
+ * RTE_TEL_UINT_VAL as the type parameter.
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param x
+ *   The number to be returned in the array
+ * @return
+ *   0 on success, negative errno on error
+ */
+__rte_experimental
+int
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
+
+ /**
  * Add a uint64_t to an array.
  * The array must have been started by rte_tel_data_start_array() with
  * RTE_TEL_UINT_VAL as the type parameter.
@@ -193,6 +211,24 @@ int
 rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
 
 /**
+ * Add an unsigned 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
+ *   Must contain only alphanumeric characters or the symbols: '_' or '/'
+ * @param val
+ *   The number to be stored in the dict
+ * @return
+ *   0 on success, negative errno on error, E2BIG on string truncation of name.
+ */
+int __rte_experimental
+rte_tel_data_add_dict_uint(struct rte_tel_data *d,
+		const char *name, uint64_t val);
+
+ /**
  * Add a uint64_t value to a dictionary.
  * The dict must have been started by rte_tel_data_start_dict().
  *
lib/telemetry/telemetry.c +8 -8
index 75957fe0b1..fd8186383f 100644
@@ -167,16 +167,16 @@ 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_DICT && d->type != RTE_TEL_ARRAY_U64 &&
+	if (d->type != RTE_TEL_DICT && d->type != RTE_TEL_ARRAY_UINT &&
 		d->type != RTE_TEL_ARRAY_INT && d->type != RTE_TEL_ARRAY_STRING)
 		return snprintf(out_buf, buf_len, "null");
 
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
-	if (d->type == RTE_TEL_ARRAY_U64)
+	if (d->type == RTE_TEL_ARRAY_UINT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_u64(out_buf,
 				buf_len, used,
-				d->data.array[i].u64val);
+				d->data.array[i].uval);
 	if (d->type == RTE_TEL_ARRAY_INT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_int(out_buf,
@@ -204,7 +204,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(out_buf,
 						buf_len, used,
-						v->name, v->value.u64val);
+						v->name, v->value.uval);
 				break;
 			case RTE_TEL_CONTAINER:
 			{
@@ -271,7 +271,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(cb_data_buf,
 						buf_len, used,
-						v->name, v->value.u64val);
+						v->name, v->value.uval);
 				break;
 			case RTE_TEL_CONTAINER:
 			{
@@ -293,7 +293,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_UINT:
 	case RTE_TEL_ARRAY_CONTAINER:
 		used = rte_tel_json_empty_array(cb_data_buf, buf_len, 0);
 		for (i = 0; i < d->data_len; i++)
@@ -306,10 +306,10 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 				used = rte_tel_json_add_array_int(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].ival);
-			else if (d->type == RTE_TEL_ARRAY_U64)
+			else if (d->type == RTE_TEL_ARRAY_UINT)
 				used = rte_tel_json_add_array_u64(cb_data_buf,
 						buf_len, used,
-						d->data.array[i].u64val);
+						d->data.array[i].uval);
 			else if (d->type == RTE_TEL_ARRAY_CONTAINER) {
 				char temp[buf_len];
 				const struct container *rec_data =
lib/telemetry/telemetry_data.c +20 -8
index 3c996484ec..077b0c4a6f 100644
@@ -18,7 +18,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 	enum tel_container_types array_types[] = {
 			RTE_TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
 			RTE_TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			RTE_TEL_ARRAY_U64,    /* RTE_TEL_UINT_VAL = 2 */
+			RTE_TEL_ARRAY_UINT,    /* RTE_TEL_UINT_VAL = 2 */
 			RTE_TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
 	};
 	d->type = array_types[type];
@@ -70,22 +70,28 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 }
 
 int
-rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x)
 {
-	if (d->type != RTE_TEL_ARRAY_U64)
+	if (d->type != RTE_TEL_ARRAY_UINT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
-	d->data.array[d->data_len++].u64val = x;
+	d->data.array[d->data_len++].uval = x;
 	return 0;
 }
 
+int
+rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
+{
+	return rte_tel_data_add_array_uint(d, x);
+}
+
 int
 rte_tel_data_add_array_container(struct rte_tel_data *d,
 		struct rte_tel_data *val, int keep)
 {
 	if (d->type != RTE_TEL_ARRAY_CONTAINER ||
-			(val->type != RTE_TEL_ARRAY_U64
+			(val->type != RTE_TEL_ARRAY_UINT
 			&& val->type != RTE_TEL_ARRAY_INT
 			&& val->type != RTE_TEL_ARRAY_STRING))
 		return -EINVAL;
@@ -160,7 +166,7 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
 }
 
 int
-rte_tel_data_add_dict_u64(struct rte_tel_data *d,
+rte_tel_data_add_dict_uint(struct rte_tel_data *d,
 		const char *name, uint64_t val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
@@ -174,18 +180,24 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 
 	d->data_len++;
 	e->type = RTE_TEL_UINT_VAL;
-	e->value.u64val = val;
+	e->value.uval = val;
 	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_u64(struct rte_tel_data *d, const char *name, uint64_t val)
+{
+	return rte_tel_data_add_dict_uint(d, name, val);
+}
+
 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
+	if (d->type != RTE_TEL_DICT || (val->type != RTE_TEL_ARRAY_UINT
 			&& val->type != RTE_TEL_ARRAY_INT
 			&& val->type != RTE_TEL_ARRAY_STRING
 			&& val->type != RTE_TEL_DICT))
lib/telemetry/telemetry_data.h +2 -2
index 26aa28e72c..939deaa618 100644
@@ -13,7 +13,7 @@ enum tel_container_types {
 	RTE_TEL_DICT,	      /** name-value pairs, of individual value type */
 	RTE_TEL_ARRAY_STRING, /** array of string values only */
 	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_UINT,   /** array of unsigned 64-bit int values */
 	RTE_TEL_ARRAY_CONTAINER, /** array of container structs */
 };
 
@@ -29,7 +29,7 @@ struct container {
 union tel_value {
 	char sval[RTE_TEL_MAX_STRING_LEN];
 	int ival;
-	uint64_t u64val;
+	uint64_t uval;
 	struct container container;
 };
 
lib/telemetry/version.map +7 -0
index 9794f9ea20..0f70d82dfc 100644
@@ -19,6 +19,13 @@ DPDK_23 {
 	local: *;
 };
 
+EXPERIMENTAL {
+	global:
+
+	rte_tel_data_add_array_uint;
+	rte_tel_data_add_dict_uint;
+};
+
 INTERNAL {
 	rte_telemetry_legacy_register;
 	rte_telemetry_init;
Signature · 1 line
2.34.1
#6 lore raw

Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64

Quoted 29 lines · Bruce Richardson

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

---
 lib/telemetry/rte_telemetry.h  | 36 ++++++++++++++++++++++++++++++++++
 lib/telemetry/telemetry.c      | 16 +++++++--------
 lib/telemetry/telemetry_data.c | 28 ++++++++++++++++++--------
 lib/telemetry/telemetry_data.h |  4 ++--
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 73 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +2 -0
index c2ad65effe..60877dae0a 100644
@@ -8,6 +8,8 @@
 #ifndef _RTE_TELEMETRY_H_
 #define _RTE_TELEMETRY_H_
 
+#include <rte_compat.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif

lib/telemetry/rte_telemetry.h int · line 125

Quoted 3 lines
lib/telemetry/rte_telemetry.h +0 -0
@@ -121,6 +123,22 @@ int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 
 /**

when adding __rte_experimental api i have been asked to add the following boilerplate documentation block. i'm not pushing it, just recalling it is what i get asked for, so in case it's something we do? see lib/eal/include/rte_thread.h as an example

```
 * @warning
 * @b EXPERIMENTAL: this API may change without prior notice.
```
Quoted 15 lines
lib/telemetry/rte_telemetry.h +15 -0
+ * Add an unsigned value to an array.
+ * The array must have been started by rte_tel_data_start_array() with
+ * RTE_TEL_UINT_VAL as the type parameter.
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param x
+ *   The number to be returned in the array
+ * @return
+ *   0 on success, negative errno on error
+ */
+__rte_experimental
+int
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
+
#7 lore raw

Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64

Quoted 40 lines · Tyler Retzlaff
Quoted 29 lines · Bruce Richardson

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

---
 lib/telemetry/rte_telemetry.h  | 36 ++++++++++++++++++++++++++++++++++
 lib/telemetry/telemetry.c      | 16 +++++++--------
 lib/telemetry/telemetry_data.c | 28 ++++++++++++++++++--------
 lib/telemetry/telemetry_data.h |  4 ++--
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 73 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +2 -0
index c2ad65effe..60877dae0a 100644
@@ -8,6 +8,8 @@
 #ifndef _RTE_TELEMETRY_H_
 #define _RTE_TELEMETRY_H_
 
+#include <rte_compat.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif

lib/telemetry/rte_telemetry.h int · line 125

Quoted 3 lines
lib/telemetry/rte_telemetry.h +0 -0
@@ -121,6 +123,22 @@ int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 
 /**

when adding __rte_experimental api i have been asked to add the following boilerplate documentation block. i'm not pushing it, just recalling it is what i get asked for, so in case it's something we do? see lib/eal/include/rte_thread.h as an example

Quoted 5 lines
```
 * @warning
 * @b EXPERIMENTAL: this API may change without prior notice.
```

Ok, thanks for the notice.

Actually, related to this, since we are adding these functions as aliases for existing stable functions, I would like to see these being added not as experimental. The reason for that, is that while they are experimental, we cannot feasibly mark the old function names as deprecated. :-(

Adding Thomas and David on CC for their thoughts.

/Bruce

#8 lore raw

Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64

15/12/2022 10:44, Bruce Richardson:

Quoted 47 lines · Tyler Retzlaff
Quoted 40 lines · Bruce Richardson
Quoted 29 lines

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

---
 lib/telemetry/rte_telemetry.h  | 36 ++++++++++++++++++++++++++++++++++
 lib/telemetry/telemetry.c      | 16 +++++++--------
 lib/telemetry/telemetry_data.c | 28 ++++++++++++++++++--------
 lib/telemetry/telemetry_data.h |  4 ++--
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 73 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +2 -0
index c2ad65effe..60877dae0a 100644
@@ -8,6 +8,8 @@
 #ifndef _RTE_TELEMETRY_H_
 #define _RTE_TELEMETRY_H_
 
+#include <rte_compat.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif

lib/telemetry/rte_telemetry.h int · line 125

Quoted 3 lines
lib/telemetry/rte_telemetry.h +0 -0
@@ -121,6 +123,22 @@ int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 
 /**

when adding __rte_experimental api i have been asked to add the following boilerplate documentation block. i'm not pushing it, just recalling it is what i get asked for, so in case it's something we do? see lib/eal/include/rte_thread.h as an example

Quoted 5 lines
```
 * @warning
 * @b EXPERIMENTAL: this API may change without prior notice.
```
Quoted 8 lines

Ok, thanks for the notice.

Actually, related to this, since we are adding these functions as aliases for existing stable functions, I would like to see these being added not as experimental. The reason for that, is that while they are experimental, we cannot feasibly mark the old function names as deprecated. :-(

Adding Thomas and David on CC for their thoughts.

Is it related to telemetry?

In general, yes we cannot deprecate something if there is no stable replacement. The recommended step is to introduce a new experimental API
and deprecate the old one when the new API is stable.

#9 lore raw

Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64

Quoted 55 lines · Thomas Monjalon

15/12/2022 10:44, Bruce Richardson:

Quoted 54 lines · Tyler Retzlaff
Quoted 40 lines · Bruce Richardson
Quoted 29 lines

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

---
 lib/telemetry/rte_telemetry.h  | 36 ++++++++++++++++++++++++++++++++++
 lib/telemetry/telemetry.c      | 16 +++++++--------
 lib/telemetry/telemetry_data.c | 28 ++++++++++++++++++--------
 lib/telemetry/telemetry_data.h |  4 ++--
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 73 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +2 -0
index c2ad65effe..60877dae0a 100644
@@ -8,6 +8,8 @@
 #ifndef _RTE_TELEMETRY_H_
 #define _RTE_TELEMETRY_H_
 
+#include <rte_compat.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif

lib/telemetry/rte_telemetry.h int · line 125

Quoted 3 lines
lib/telemetry/rte_telemetry.h +0 -0
@@ -121,6 +123,22 @@ int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 
 /**

when adding __rte_experimental api i have been asked to add the following boilerplate documentation block. i'm not pushing it, just recalling it is what i get asked for, so in case it's something we do? see lib/eal/include/rte_thread.h as an example

Quoted 5 lines
```
 * @warning
 * @b EXPERIMENTAL: this API may change without prior notice.
```

Ok, thanks for the notice.

Actually, related to this, since we are adding these functions as aliases for existing stable functions, I would like to see these being added not as experimental. The reason for that, is that while they are experimental, we cannot feasibly mark the old function names as deprecated. :-(

Quoted 8 lines
Quoted 1 line

Adding Thomas and David on CC for their thoughts.

Is it related to telemetry?

In general, yes we cannot deprecate something if there is no stable replacement. The recommended step is to introduce a new experimental API
and deprecate the old one when the new API is stable.

Yes, understood.
What we are really trying to do here is to rename an API, by process of adding the new API and then marking the old one as deprecated. The small issue is that adding the new one it is by default experimental, meaning we need to wait for deprecating old one. Ideally, as soon as the new API is added, we would like to point people to use that, but can't really do so while it is experimental.

---

By way of explicit detail, Morten pointed out the inconsistency in the telemetry APIs and types:

* we have add_*_int, which takes a 32-bit signed value
* we have add_*_u64 which takes 64-bit unsigned (as name suggests).

The ideal end-state is to always use 64-bit values (since there is no space saving from 32-bit as a union is used), and just name everything as "int" or "uint" for signed/unsigned. The two big steps here are:

* expanding type of the "int" functions to take 64-bit parameters - this is ABI change but not API one, since existing code will happily promote values on compile. Therefore, we just use ABI versioning to have a 32-bit version for older linked binaries.
* the rename of the rte_tel_data_add_array_u64 and rte_tel_data_add_dict_u64 to *_uint variants. Though keeping compatibility is easier, as we can just add new functions, the overall process is slower since the new functions technically should be added as experimental - hence the email. For the case of function renaming, do we still need to have the "renamed" versions as experimental initially?

Given where we are in the overall DPDK releases cycle, it's not a major issue either way, I just would like some clarity. My main concern with having it spread over a couple of releases, is that it's more likely a step will be missed/forgotten somewhere along the way!

/Bruce

#10 lore raw

Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64

15/12/2022 14:58, Bruce Richardson:

Quoted 59 lines · Thomas Monjalon
Quoted 30 lines

15/12/2022 10:44, Bruce Richardson:

Quoted 29 lines · Tyler Retzlaff
Quoted 15 lines · Bruce Richardson
Quoted 7 lines

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

when adding __rte_experimental api i have been asked to add the following boilerplate documentation block. i'm not pushing it, just recalling it is what i get asked for, so in case it's something we do? see lib/eal/include/rte_thread.h as an example

Quoted 5 lines
```
 * @warning
 * @b EXPERIMENTAL: this API may change without prior notice.
```

Ok, thanks for the notice.

Actually, related to this, since we are adding these functions as aliases for existing stable functions, I would like to see these being added not as experimental. The reason for that, is that while they are experimental, we cannot feasibly mark the old function names as deprecated. :-(

Quoted 8 lines
Quoted 1 line

Adding Thomas and David on CC for their thoughts.

Is it related to telemetry?

In general, yes we cannot deprecate something if there is no stable replacement. The recommended step is to introduce a new experimental API
and deprecate the old one when the new API is stable.

Yes, understood.
What we are really trying to do here is to rename an API, by process of adding the new API and then marking the old one as deprecated. The small issue is that adding the new one it is by default experimental, meaning we need to wait for deprecating old one. Ideally, as soon as the new API is added, we would like to point people to use that, but can't really do so while it is experimental.

---

By way of explicit detail, Morten pointed out the inconsistency in the telemetry APIs and types:

* we have add_*_int, which takes a 32-bit signed value
* we have add_*_u64 which takes 64-bit unsigned (as name suggests).

The ideal end-state is to always use 64-bit values (since there is no space saving from 32-bit as a union is used), and just name everything as "int" or "uint" for signed/unsigned. The two big steps here are:

Quoted 10 lines

* expanding type of the "int" functions to take 64-bit parameters - this is ABI change but not API one, since existing code will happily promote values on compile. Therefore, we just use ABI versioning to have a 32-bit version for older linked binaries.
* the rename of the rte_tel_data_add_array_u64 and rte_tel_data_add_dict_u64 to *_uint variants. Though keeping compatibility is easier, as we can just add new functions, the overall process is slower since the new functions technically should be added as experimental - hence the email. For the case of function renaming, do we still need to have the "renamed" versions as experimental initially?

If a function is simply renamed, I think there is no need for the experimental step. Would we keep an alias with the old name for some time?

#11 lore raw

Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64

Quoted 71 lines · Thomas Monjalon

15/12/2022 14:58, Bruce Richardson:

Quoted 59 lines · Thomas Monjalon
Quoted 30 lines

15/12/2022 10:44, Bruce Richardson:

Quoted 29 lines · Tyler Retzlaff
Quoted 15 lines · Bruce Richardson
Quoted 7 lines

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

when adding __rte_experimental api i have been asked to add the following boilerplate documentation block. i'm not pushing it, just recalling it is what i get asked for, so in case it's something we do? see lib/eal/include/rte_thread.h as an example

Quoted 5 lines
```
 * @warning
 * @b EXPERIMENTAL: this API may change without prior notice.
```

Ok, thanks for the notice.

Actually, related to this, since we are adding these functions as aliases for existing stable functions, I would like to see these being added not as experimental. The reason for that, is that while they are experimental, we cannot feasibly mark the old function names as deprecated. :-(

Quoted 8 lines
Quoted 1 line

Adding Thomas and David on CC for their thoughts.

Is it related to telemetry?

In general, yes we cannot deprecate something if there is no stable replacement. The recommended step is to introduce a new experimental API
and deprecate the old one when the new API is stable.

Yes, understood.
What we are really trying to do here is to rename an API, by process of adding the new API and then marking the old one as deprecated. The small issue is that adding the new one it is by default experimental, meaning we need to wait for deprecating old one. Ideally, as soon as the new API is added, we would like to point people to use that, but can't really do so while it is experimental.

---

By way of explicit detail, Morten pointed out the inconsistency in the telemetry APIs and types:

* we have add_*_int, which takes a 32-bit signed value
* we have add_*_u64 which takes 64-bit unsigned (as name suggests).

The ideal end-state is to always use 64-bit values (since there is no space saving from 32-bit as a union is used), and just name everything as "int" or "uint" for signed/unsigned. The two big steps here are:

Quoted 10 lines

* expanding type of the "int" functions to take 64-bit parameters - this is ABI change but not API one, since existing code will happily promote values on compile. Therefore, we just use ABI versioning to have a 32-bit version for older linked binaries.
* the rename of the rte_tel_data_add_array_u64 and rte_tel_data_add_dict_u64 to *_uint variants. Though keeping compatibility is easier, as we can just add new functions, the overall process is slower since the new functions technically should be added as experimental - hence the email. For the case of function renaming, do we still need to have the "renamed" versions as experimental initially?

Quoted 3 lines

If a function is simply renamed, I think there is no need for the experimental step. Would we keep an alias with the old name for some time?

Yes, the old name should go through the deprecation process. No hurry with removal.

/Bruce

#12 lore raw

Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64

In reply to Bruce Richardson
Quoted 47 lines · Bruce Richardson
Quoted 40 lines · Tyler Retzlaff
Quoted 29 lines · Bruce Richardson

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

---
 lib/telemetry/rte_telemetry.h  | 36 ++++++++++++++++++++++++++++++++++
 lib/telemetry/telemetry.c      | 16 +++++++--------
 lib/telemetry/telemetry_data.c | 28 ++++++++++++++++++--------
 lib/telemetry/telemetry_data.h |  4 ++--
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 73 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +2 -0
index c2ad65effe..60877dae0a 100644
@@ -8,6 +8,8 @@
 #ifndef _RTE_TELEMETRY_H_
 #define _RTE_TELEMETRY_H_
 
+#include <rte_compat.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif

lib/telemetry/rte_telemetry.h int · line 125

Quoted 3 lines
lib/telemetry/rte_telemetry.h +0 -0
@@ -121,6 +123,22 @@ int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 
 /**

when adding __rte_experimental api i have been asked to add the following boilerplate documentation block. i'm not pushing it, just recalling it is what i get asked for, so in case it's something we do? see lib/eal/include/rte_thread.h as an example

Quoted 5 lines
```
 * @warning
 * @b EXPERIMENTAL: this API may change without prior notice.
```
Quoted 6 lines

Ok, thanks for the notice.

Actually, related to this, since we are adding these functions as aliases for existing stable functions, I would like to see these being added not as experimental. The reason for that, is that while they are experimental, we cannot feasibly mark the old function names as deprecated. :-(

seems reasonable to me, if they're just aliases and they haven't churned then i don't see a reason why they need to spend time being experimental.

Quoted 4 lines

Adding Thomas and David on CC for their thoughts.

/Bruce

#13 lore raw

Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64

In reply to Bruce Richardson
Quoted 59 lines · Bruce Richardson

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

---
  lib/telemetry/rte_telemetry.h  | 36 ++++++++++++++++++++++++++++++++++
  lib/telemetry/telemetry.c      | 16 +++++++--------
  lib/telemetry/telemetry_data.c | 28 ++++++++++++++++++--------
  lib/telemetry/telemetry_data.h |  4 ++--
  lib/telemetry/version.map      |  7 +++++++
  5 files changed, 73 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +22 -0
index c2ad65effe..60877dae0a 100644
@@ -8,6 +8,8 @@
  #ifndef _RTE_TELEMETRY_H_
  #define _RTE_TELEMETRY_H_
 
+#include <rte_compat.h>
+
  #ifdef __cplusplus
  extern "C" {
  #endif
@@ -121,6 +123,22 @@ int
  rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 
  /**
+ * Add an unsigned value to an array.
+ * The array must have been started by rte_tel_data_start_array() with
+ * RTE_TEL_UINT_VAL as the type parameter.
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param x
+ *   The number to be returned in the array
+ * @return
+ *   0 on success, negative errno on error
+ */
+__rte_experimental
+int
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
+
+ /**
   * Add a uint64_t to an array.
   * The array must have been started by rte_tel_data_start_array() with
   * RTE_TEL_UINT_VAL as the type parameter.
@@ -193,6 +211,24 @@ int
  rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
 
  /**
+ * Add an unsigned value to a dictionary.
+ * The dict must have been started by rte_tel_data_start_dict().
+ *
+ * @param d

lib/telemetry/rte_telemetry.h int · line 227

Quoted 10 lines
lib/telemetry/rte_telemetry.h +10 -0
+ *   The data structure passed to the callback
+ * @param name
+ *   The name the value is to be stored under in the dict
+ *   Must contain only alphanumeric characters or the symbols: '_' or '/'
+ * @param val
+ *   The number to be stored in the dict
+ * @return
+ *   0 on success, negative errno on error, E2BIG on string truncation of name.
+ */
+int __rte_experimental

__rte_experimental
int

Right?

Quoted 193 lines
lib/telemetry/rte_telemetry.h +4 -0
+rte_tel_data_add_dict_uint(struct rte_tel_data *d,
+		const char *name, uint64_t val);
+
+ /**
   * Add a uint64_t value to a dictionary.
   * The dict must have been started by rte_tel_data_start_dict().
   *
lib/telemetry/telemetry.c +8 -8
index 75957fe0b1..fd8186383f 100644
@@ -167,16 +167,16 @@ 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_DICT && d->type != RTE_TEL_ARRAY_U64 &&
+	if (d->type != RTE_TEL_DICT && d->type != RTE_TEL_ARRAY_UINT &&
  		d->type != RTE_TEL_ARRAY_INT && d->type != RTE_TEL_ARRAY_STRING)
  		return snprintf(out_buf, buf_len, "null");
 
  	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
-	if (d->type == RTE_TEL_ARRAY_U64)
+	if (d->type == RTE_TEL_ARRAY_UINT)
  		for (i = 0; i < d->data_len; i++)
  			used = rte_tel_json_add_array_u64(out_buf,
  				buf_len, used,
-				d->data.array[i].u64val);
+				d->data.array[i].uval);
  	if (d->type == RTE_TEL_ARRAY_INT)
  		for (i = 0; i < d->data_len; i++)
  			used = rte_tel_json_add_array_int(out_buf,
@@ -204,7 +204,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
  			case RTE_TEL_UINT_VAL:
  				used = rte_tel_json_add_obj_u64(out_buf,
  						buf_len, used,
-						v->name, v->value.u64val);
+						v->name, v->value.uval);
  				break;
  			case RTE_TEL_CONTAINER:
  			{
@@ -271,7 +271,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
  			case RTE_TEL_UINT_VAL:
  				used = rte_tel_json_add_obj_u64(cb_data_buf,
  						buf_len, used,
-						v->name, v->value.u64val);
+						v->name, v->value.uval);
  				break;
  			case RTE_TEL_CONTAINER:
  			{
@@ -293,7 +293,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_UINT:
  	case RTE_TEL_ARRAY_CONTAINER:
  		used = rte_tel_json_empty_array(cb_data_buf, buf_len, 0);
  		for (i = 0; i < d->data_len; i++)
@@ -306,10 +306,10 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
  				used = rte_tel_json_add_array_int(cb_data_buf,
  						buf_len, used,
  						d->data.array[i].ival);
-			else if (d->type == RTE_TEL_ARRAY_U64)
+			else if (d->type == RTE_TEL_ARRAY_UINT)
  				used = rte_tel_json_add_array_u64(cb_data_buf,
  						buf_len, used,
-						d->data.array[i].u64val);
+						d->data.array[i].uval);
  			else if (d->type == RTE_TEL_ARRAY_CONTAINER) {
  				char temp[buf_len];
  				const struct container *rec_data =
lib/telemetry/telemetry_data.c +20 -8
index 3c996484ec..077b0c4a6f 100644
@@ -18,7 +18,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
  	enum tel_container_types array_types[] = {
  			RTE_TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
  			RTE_TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			RTE_TEL_ARRAY_U64,    /* RTE_TEL_UINT_VAL = 2 */
+			RTE_TEL_ARRAY_UINT,    /* RTE_TEL_UINT_VAL = 2 */
  			RTE_TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
  	};
  	d->type = array_types[type];
@@ -70,22 +70,28 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
  }
 
  int
-rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x)
  {
-	if (d->type != RTE_TEL_ARRAY_U64)
+	if (d->type != RTE_TEL_ARRAY_UINT)
  		return -EINVAL;
  	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
  		return -ENOSPC;
-	d->data.array[d->data_len++].u64val = x;
+	d->data.array[d->data_len++].uval = x;
  	return 0;
  }
 
+int
+rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
+{
+	return rte_tel_data_add_array_uint(d, x);
+}
+
  int
  rte_tel_data_add_array_container(struct rte_tel_data *d,
  		struct rte_tel_data *val, int keep)
  {
  	if (d->type != RTE_TEL_ARRAY_CONTAINER ||
-			(val->type != RTE_TEL_ARRAY_U64
+			(val->type != RTE_TEL_ARRAY_UINT
  			&& val->type != RTE_TEL_ARRAY_INT
  			&& val->type != RTE_TEL_ARRAY_STRING))
  		return -EINVAL;
@@ -160,7 +166,7 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
  }
 
  int
-rte_tel_data_add_dict_u64(struct rte_tel_data *d,
+rte_tel_data_add_dict_uint(struct rte_tel_data *d,
  		const char *name, uint64_t val)
  {
  	struct tel_dict_entry *e = &d->data.dict[d->data_len];
@@ -174,18 +180,24 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 
  	d->data_len++;
  	e->type = RTE_TEL_UINT_VAL;
-	e->value.u64val = val;
+	e->value.uval = val;
  	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_u64(struct rte_tel_data *d, const char *name, uint64_t val)
+{
+	return rte_tel_data_add_dict_uint(d, name, val);
+}
+
  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
+	if (d->type != RTE_TEL_DICT || (val->type != RTE_TEL_ARRAY_UINT
  			&& val->type != RTE_TEL_ARRAY_INT
  			&& val->type != RTE_TEL_ARRAY_STRING
  			&& val->type != RTE_TEL_DICT))
lib/telemetry/telemetry_data.h +2 -2
index 26aa28e72c..939deaa618 100644
@@ -13,7 +13,7 @@ enum tel_container_types {
  	RTE_TEL_DICT,	      /** name-value pairs, of individual value type */
  	RTE_TEL_ARRAY_STRING, /** array of string values only */
  	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_UINT,   /** array of unsigned 64-bit int values */
  	RTE_TEL_ARRAY_CONTAINER, /** array of container structs */
  };
 
@@ -29,7 +29,7 @@ struct container {
  union tel_value {
  	char sval[RTE_TEL_MAX_STRING_LEN];
  	int ival;
-	uint64_t u64val;
+	uint64_t uval;
  	struct container container;
  };
 
lib/telemetry/version.map +7 -0
index 9794f9ea20..0f70d82dfc 100644
@@ -19,6 +19,13 @@ DPDK_23 {
  	local: *;
  };
 
+EXPERIMENTAL {
+	global:
+
+	rte_tel_data_add_array_uint;
+	rte_tel_data_add_dict_uint;
+};
+
  INTERNAL {
  	rte_telemetry_legacy_register;
  	rte_telemetry_init;
#14 lore raw

Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64

Quoted 71 lines · lihuisong (C)
Quoted 56 lines · Bruce Richardson

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

---
  lib/telemetry/rte_telemetry.h  | 36 ++++++++++++++++++++++++++++++++++
  lib/telemetry/telemetry.c      | 16 +++++++--------
  lib/telemetry/telemetry_data.c | 28 ++++++++++++++++++--------
  lib/telemetry/telemetry_data.h |  4 ++--
  lib/telemetry/version.map      |  7 +++++++
  5 files changed, 73 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +22 -0
index c2ad65effe..60877dae0a 100644
@@ -8,6 +8,8 @@
  #ifndef _RTE_TELEMETRY_H_
  #define _RTE_TELEMETRY_H_
+#include <rte_compat.h>
+
  #ifdef __cplusplus
  extern "C" {
  #endif
@@ -121,6 +123,22 @@ int
  rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
  /**
+ * Add an unsigned value to an array.
+ * The array must have been started by rte_tel_data_start_array() with
+ * RTE_TEL_UINT_VAL as the type parameter.
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param x
+ *   The number to be returned in the array
+ * @return
+ *   0 on success, negative errno on error
+ */
+__rte_experimental
+int
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
+
+ /**
   * Add a uint64_t to an array.
   * The array must have been started by rte_tel_data_start_array() with
   * RTE_TEL_UINT_VAL as the type parameter.
@@ -193,6 +211,24 @@ int
  rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
  /**
+ * Add an unsigned value to a dictionary.
+ * The dict must have been started by rte_tel_data_start_dict().
+ *
+ * @param d

lib/telemetry/rte_telemetry.h int · line 226

Quoted 10 lines
lib/telemetry/rte_telemetry.h +10 -0
+ *   The data structure passed to the callback
+ * @param name
+ *   The name the value is to be stored under in the dict
+ *   Must contain only alphanumeric characters or the symbols: '_' or '/'
+ * @param val
+ *   The number to be stored in the dict
+ * @return
+ *   0 on success, negative errno on error, E2BIG on string truncation of name.
+ */
+int __rte_experimental

__rte_experimental
int

Quoted 1 line

Right?

Yes, that is right.

#15 lore raw

Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64

Quoted 72 lines · Bruce Richardson
Quoted 71 lines · lihuisong (C)
Quoted 56 lines · Bruce Richardson

For future standardization on the "uint" name for unsigned values rather than the existing "u64" one, we can for now:
* rename all internal values to use uint rather than u64
* add new function names to alias the existing u64 ones

---
  lib/telemetry/rte_telemetry.h  | 36 ++++++++++++++++++++++++++++++++++
  lib/telemetry/telemetry.c      | 16 +++++++--------
  lib/telemetry/telemetry_data.c | 28 ++++++++++++++++++--------
  lib/telemetry/telemetry_data.h |  4 ++--
  lib/telemetry/version.map      |  7 +++++++
  5 files changed, 73 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +22 -0
index c2ad65effe..60877dae0a 100644
@@ -8,6 +8,8 @@
  #ifndef _RTE_TELEMETRY_H_
  #define _RTE_TELEMETRY_H_
+#include <rte_compat.h>
+
  #ifdef __cplusplus
  extern "C" {
  #endif
@@ -121,6 +123,22 @@ int
  rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
  /**
+ * Add an unsigned value to an array.
+ * The array must have been started by rte_tel_data_start_array() with
+ * RTE_TEL_UINT_VAL as the type parameter.
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param x
+ *   The number to be returned in the array
+ * @return
+ *   0 on success, negative errno on error
+ */
+__rte_experimental
+int
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
+
+ /**
   * Add a uint64_t to an array.
   * The array must have been started by rte_tel_data_start_array() with
   * RTE_TEL_UINT_VAL as the type parameter.
@@ -193,6 +211,24 @@ int
  rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
  /**
+ * Add an unsigned value to a dictionary.
+ * The dict must have been started by rte_tel_data_start_dict().
+ *
+ * @param d

lib/telemetry/rte_telemetry.h int · line 226

Quoted 10 lines
lib/telemetry/rte_telemetry.h +10 -0
+ *   The data structure passed to the callback
+ * @param name
+ *   The name the value is to be stored under in the dict
+ *   Must contain only alphanumeric characters or the symbols: '_' or '/'
+ * @param val
+ *   The number to be stored in the dict
+ * @return
+ *   0 on success, negative errno on error, E2BIG on string truncation of name.
+ */
+int __rte_experimental

__rte_experimental
int

Quoted 3 lines
Quoted 1 line

Right?

Yes, that is right.

actually, it is consistent with how it is used in the rest of dpdk and most compilers accept it before the return type. but actually it applies to the symbol name.

this is not an argument to change the existing pattern, just pointing it out the details.

#16 lore raw

RFC PATCH 3/7 telemetry: remove RTE prefix from internal enum values

In reply to Bruce Richardson

To better distinguish which values are public and which are internal remove the "RTE_" prefix off the internal enum defining the container types.

---
 lib/ethdev/sff_telemetry.c     |  2 +-
 lib/telemetry/telemetry.c      | 36 +++++++++++++++---------------
 lib/telemetry/telemetry_data.c | 40 +++++++++++++++++-----------------
 lib/telemetry/telemetry_data.h | 14 ++++++------
 4 files changed, 46 insertions(+), 46 deletions(-)
lib/ethdev/sff_telemetry.c +1 -1
index ca6d196560..5923350424 100644
@@ -96,7 +96,7 @@ ssf_add_dict_string(struct rte_tel_data *d, const char *name_str, const char *va
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES) {
 		RTE_ETHDEV_LOG(ERR, "data_len has exceeded the maximum number of inserts\n");
lib/telemetry/telemetry.c +18 -18
index fd8186383f..89bdde8422 100644
@@ -167,27 +167,27 @@ 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_DICT && d->type != RTE_TEL_ARRAY_UINT &&
-		d->type != RTE_TEL_ARRAY_INT && d->type != RTE_TEL_ARRAY_STRING)
+	if (d->type != TEL_DICT && d->type != TEL_ARRAY_UINT &&
+		d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)
 		return snprintf(out_buf, buf_len, "null");
 
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
-	if (d->type == RTE_TEL_ARRAY_UINT)
+	if (d->type == TEL_ARRAY_UINT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_u64(out_buf,
 				buf_len, used,
 				d->data.array[i].uval);
-	if (d->type == RTE_TEL_ARRAY_INT)
+	if (d->type == TEL_ARRAY_INT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_int(out_buf,
 				buf_len, used,
 				d->data.array[i].ival);
-	if (d->type == RTE_TEL_ARRAY_STRING)
+	if (d->type == TEL_ARRAY_STRING)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_string(out_buf,
 				buf_len, used,
 				d->data.array[i].sval);
-	if (d->type == RTE_TEL_DICT)
+	if (d->type == TEL_DICT)
 		for (i = 0; i < d->data_len; i++) {
 			const struct tel_dict_entry *v = &d->data.dict[i];
 			switch (v->type) {
@@ -245,15 +245,15 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 	buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */
 
 	switch (d->type) {
-	case RTE_TEL_NULL:
+	case TEL_NULL:
 		used = strlcpy(cb_data_buf, "null", buf_len);
 		break;
 
-	case RTE_TEL_STRING:
+	case TEL_STRING:
 		used = rte_tel_json_str(cb_data_buf, buf_len, 0, d->data.str);
 		break;
 
-	case RTE_TEL_DICT:
+	case TEL_DICT:
 		used = rte_tel_json_empty_obj(cb_data_buf, buf_len, 0);
 		for (i = 0; i < d->data_len; i++) {
 			const struct tel_dict_entry *v = &d->data.dict[i];
@@ -291,26 +291,26 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 		}
 		break;
 
-	case RTE_TEL_ARRAY_STRING:
-	case RTE_TEL_ARRAY_INT:
-	case RTE_TEL_ARRAY_UINT:
-	case RTE_TEL_ARRAY_CONTAINER:
+	case TEL_ARRAY_STRING:
+	case TEL_ARRAY_INT:
+	case TEL_ARRAY_UINT:
+	case TEL_ARRAY_CONTAINER:
 		used = rte_tel_json_empty_array(cb_data_buf, buf_len, 0);
 		for (i = 0; i < d->data_len; i++)
-			if (d->type == RTE_TEL_ARRAY_STRING)
+			if (d->type == TEL_ARRAY_STRING)
 				used = rte_tel_json_add_array_string(
 						cb_data_buf,
 						buf_len, used,
 						d->data.array[i].sval);
-			else if (d->type == RTE_TEL_ARRAY_INT)
+			else if (d->type == TEL_ARRAY_INT)
 				used = rte_tel_json_add_array_int(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].ival);
-			else if (d->type == RTE_TEL_ARRAY_UINT)
+			else if (d->type == TEL_ARRAY_UINT)
 				used = rte_tel_json_add_array_u64(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].uval);
-			else if (d->type == RTE_TEL_ARRAY_CONTAINER) {
+			else if (d->type == TEL_ARRAY_CONTAINER) {
 				char temp[buf_len];
 				const struct container *rec_data =
 						&d->data.array[i].container;
@@ -351,7 +351,7 @@ static int
 unknown_command(const char *cmd __rte_unused, const char *params __rte_unused,
 		struct rte_tel_data *d)
 {
-	return d->type = RTE_TEL_NULL;
+	return d->type = TEL_NULL;
 }
 
 static void *
lib/telemetry/telemetry_data.c +20 -20
index 077b0c4a6f..d51724e1f5 100644
@@ -16,10 +16,10 @@ int
 rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 {
 	enum tel_container_types array_types[] = {
-			RTE_TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
-			RTE_TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			RTE_TEL_ARRAY_UINT,    /* RTE_TEL_UINT_VAL = 2 */
-			RTE_TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
+			TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
+			TEL_ARRAY_UINT,    /* RTE_TEL_UINT_VAL = 2 */
+			TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
 	};
 	d->type = array_types[type];
 	d->data_len = 0;
@@ -29,7 +29,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 int
 rte_tel_data_start_dict(struct rte_tel_data *d)
 {
-	d->type = RTE_TEL_DICT;
+	d->type = TEL_DICT;
 	d->data_len = 0;
 	return 0;
 }
@@ -37,7 +37,7 @@ rte_tel_data_start_dict(struct rte_tel_data *d)
 int
 rte_tel_data_string(struct rte_tel_data *d, const char *str)
 {
-	d->type = RTE_TEL_STRING;
+	d->type = TEL_STRING;
 	d->data_len = strlcpy(d->data.str, str, sizeof(d->data.str));
 	if (d->data_len >= RTE_TEL_MAX_SINGLE_STRING_LEN) {
 		d->data_len = RTE_TEL_MAX_SINGLE_STRING_LEN - 1;
@@ -49,7 +49,7 @@ rte_tel_data_string(struct rte_tel_data *d, const char *str)
 int
 rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str)
 {
-	if (d->type != RTE_TEL_ARRAY_STRING)
+	if (d->type != TEL_ARRAY_STRING)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -61,7 +61,7 @@ rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str)
 int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 {
-	if (d->type != RTE_TEL_ARRAY_INT)
+	if (d->type != TEL_ARRAY_INT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -72,7 +72,7 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 int
 rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x)
 {
-	if (d->type != RTE_TEL_ARRAY_UINT)
+	if (d->type != TEL_ARRAY_UINT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -90,10 +90,10 @@ int
 rte_tel_data_add_array_container(struct rte_tel_data *d,
 		struct rte_tel_data *val, int keep)
 {
-	if (d->type != RTE_TEL_ARRAY_CONTAINER ||
-			(val->type != RTE_TEL_ARRAY_UINT
-			&& val->type != RTE_TEL_ARRAY_INT
-			&& val->type != RTE_TEL_ARRAY_STRING))
+	if (d->type != TEL_ARRAY_CONTAINER ||
+			(val->type != TEL_ARRAY_UINT
+			&& val->type != TEL_ARRAY_INT
+			&& val->type != TEL_ARRAY_STRING))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -128,7 +128,7 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 	size_t nbytes, vbytes;
 
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
@@ -150,7 +150,7 @@ int
 rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
@@ -170,7 +170,7 @@ rte_tel_data_add_dict_uint(struct rte_tel_data *d,
 		const char *name, uint64_t val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
@@ -197,10 +197,10 @@ rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name,
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 
-	if (d->type != RTE_TEL_DICT || (val->type != RTE_TEL_ARRAY_UINT
-			&& val->type != RTE_TEL_ARRAY_INT
-			&& val->type != RTE_TEL_ARRAY_STRING
-			&& val->type != RTE_TEL_DICT))
+	if (d->type != TEL_DICT || (val->type != TEL_ARRAY_UINT
+			&& val->type != TEL_ARRAY_INT
+			&& val->type != TEL_ARRAY_STRING
+			&& val->type != TEL_DICT))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
lib/telemetry/telemetry_data.h +7 -7
index 939deaa618..8db6875a81 100644
@@ -8,13 +8,13 @@
 #include "rte_telemetry.h"
 
 enum tel_container_types {
-	RTE_TEL_NULL,	      /** null, used as error value */
-	RTE_TEL_STRING,	      /** basic string type, no included data */
-	RTE_TEL_DICT,	      /** name-value pairs, of individual value type */
-	RTE_TEL_ARRAY_STRING, /** array of string values only */
-	RTE_TEL_ARRAY_INT,    /** array of signed, 32-bit int values */
-	RTE_TEL_ARRAY_UINT,   /** array of unsigned 64-bit int values */
-	RTE_TEL_ARRAY_CONTAINER, /** array of container structs */
+	TEL_NULL,            /** null, used as error value */
+	TEL_STRING,          /** basic string type, no included data */
+	TEL_DICT,            /** name-value pairs, of individual value type */
+	TEL_ARRAY_STRING,    /** array of string values only */
+	TEL_ARRAY_INT,       /** array of signed, 32-bit int values */
+	TEL_ARRAY_UINT,      /** array of unsigned 64-bit int values */
+	TEL_ARRAY_CONTAINER, /** array of container structs */
 };
 
 struct container {
Signature · 1 line
2.34.1
#17 lore raw

RFC PATCH 4/7 telemetry: make array initialization more robust

In reply to Bruce Richardson

Rather than relying on a specific ordering of elements in the array matching that of elements in the enum definition, we can explicitly mark each array entry using the equivalent enum value as an index.

---
 lib/telemetry/telemetry_data.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/telemetry/telemetry_data.c +4 -4
index d51724e1f5..9a180937fd 100644
@@ -16,10 +16,10 @@ int
 rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 {
 	enum tel_container_types array_types[] = {
-			TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
-			TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			TEL_ARRAY_UINT,    /* RTE_TEL_UINT_VAL = 2 */
-			TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
+			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
+			[RTE_TEL_UINT_VAL] = TEL_ARRAY_UINT,
+			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};
 	d->type = array_types[type];
 	d->data_len = 0;
Signature · 1 line
2.34.1
#18 lore raw

Re: [RFC PATCH 4/7] telemetry: make array initialization more robust

Quoted 16 lines · Bruce Richardson

Rather than relying on a specific ordering of elements in the array matching that of elements in the enum definition, we can explicitly mark each array entry using the equivalent enum value as an index.

---
 lib/telemetry/telemetry_data.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/telemetry/telemetry_data.c +0 -0
index d51724e1f5..9a180937fd 100644
@@ -16,10 +16,10 @@ int
 rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 {

lib/telemetry/telemetry_data.c int · line 23

Quoted 10 lines
lib/telemetry/telemetry_data.c +4 -4
 	enum tel_container_types array_types[] = {
-			TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
-			TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			TEL_ARRAY_UINT,    /* RTE_TEL_UINT_VAL = 2 */
-			TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
+			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
+			[RTE_TEL_UINT_VAL] = TEL_ARRAY_UINT,
+			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};

i might be a bit fuzzy and didn't double check but doesn't doing this require C99?

though it would be great to move to a minimum of C99/C11

Quoted 4 lines
lib/telemetry/telemetry_data.c +0 -0
 	d->type = array_types[type];
 	d->data_len = 0;
Signature · 1 line
2.34.1
#19 lore raw

Re: [RFC PATCH 4/7] telemetry: make array initialization more robust

Quoted 31 lines · Tyler Retzlaff
Quoted 16 lines · Bruce Richardson

Rather than relying on a specific ordering of elements in the array matching that of elements in the enum definition, we can explicitly mark each array entry using the equivalent enum value as an index.

---
 lib/telemetry/telemetry_data.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/telemetry/telemetry_data.c +0 -0
index d51724e1f5..9a180937fd 100644
@@ -16,10 +16,10 @@ int
 rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 {

lib/telemetry/telemetry_data.c int · line 23

Quoted 10 lines
lib/telemetry/telemetry_data.c +4 -4
 	enum tel_container_types array_types[] = {
-			TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
-			TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			TEL_ARRAY_UINT,    /* RTE_TEL_UINT_VAL = 2 */
-			TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
+			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
+			[RTE_TEL_UINT_VAL] = TEL_ARRAY_UINT,
+			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};

i might be a bit fuzzy and didn't double check but doesn't doing this require C99?

Quoted 2 lines

though it would be great to move to a minimum of C99/C11

Yep, I agree on version bump.

For the specific array init - we actually already use this style of init elsewhere in telemetry lib, so I'm going to keep it here in V2, as I think it is the clearest way to initialize a lookup array like this.

/Bruce

#20 lore raw

Re: [RFC PATCH 4/7] telemetry: make array initialization more robust

Quoted 32 lines · Bruce Richardson
Quoted 31 lines · Tyler Retzlaff
Quoted 16 lines · Bruce Richardson

Rather than relying on a specific ordering of elements in the array matching that of elements in the enum definition, we can explicitly mark each array entry using the equivalent enum value as an index.

---
 lib/telemetry/telemetry_data.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/telemetry/telemetry_data.c +0 -0
index d51724e1f5..9a180937fd 100644
@@ -16,10 +16,10 @@ int
 rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 {

lib/telemetry/telemetry_data.c int · line 23

Quoted 10 lines
lib/telemetry/telemetry_data.c +4 -4
 	enum tel_container_types array_types[] = {
-			TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
-			TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			TEL_ARRAY_UINT,    /* RTE_TEL_UINT_VAL = 2 */
-			TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
+			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
+			[RTE_TEL_UINT_VAL] = TEL_ARRAY_UINT,
+			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};

i might be a bit fuzzy and didn't double check but doesn't doing this require C99?

Quoted 7 lines
Quoted 2 lines

though it would be great to move to a minimum of C99/C11

Yep, I agree on version bump.

For the specific array init - we actually already use this style of init elsewhere in telemetry lib, so I'm going to keep it here in V2, as I think it is the clearest way to initialize a lookup array like this.

sounds good given our other discussion about moving to C99 as a minimum.

Quoted 2 lines

/Bruce

#21 lore raw

Re: [RFC PATCH 4/7] telemetry: make array initialization more robust

Quoted 35 lines · Tyler Retzlaff
Quoted 34 lines · Bruce Richardson
Quoted 33 lines · Tyler Retzlaff
Quoted 16 lines · Bruce Richardson

Rather than relying on a specific ordering of elements in the array matching that of elements in the enum definition, we can explicitly mark each array entry using the equivalent enum value as an index.

---
 lib/telemetry/telemetry_data.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/telemetry/telemetry_data.c +0 -0
index d51724e1f5..9a180937fd 100644
@@ -16,10 +16,10 @@ int
 rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 {

lib/telemetry/telemetry_data.c int · line 23

Quoted 10 lines
lib/telemetry/telemetry_data.c +4 -4
 	enum tel_container_types array_types[] = {
-			TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
-			TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			TEL_ARRAY_UINT,    /* RTE_TEL_UINT_VAL = 2 */
-			TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
+			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
+			[RTE_TEL_UINT_VAL] = TEL_ARRAY_UINT,
+			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};

i might be a bit fuzzy and didn't double check but doesn't doing this require C99?

though it would be great to move to a minimum of C99/C11

Quoted 8 lines
Quoted 5 lines

Yep, I agree on version bump.

For the specific array init - we actually already use this style of init elsewhere in telemetry lib, so I'm going to keep it here in V2, as I think it is the clearest way to initialize a lookup array like this.

sounds good given our other discussion about moving to C99 as a minimum.

There were some drivers requiring C89/90 but as far as I know all updated at this stage,

+1 to move C99 support.

#22 lore raw

RFC PATCH 5/7 telemetry: update json functions to use int/uint in names

In reply to Bruce Richardson

Since we are standardizing on using uint in place of u64, and expanding the int values to 64-bit, we can update the internal json functions to use the new names and expanded signed type.

---
 app/test/test_telemetry_json.c |  9 ++++-----
 lib/telemetry/telemetry.c      |  8 ++++----
 lib/telemetry/telemetry_json.h | 16 ++++++++--------
 3 files changed, 16 insertions(+), 17 deletions(-)
app/test/test_telemetry_json.c +4 -5
index 184c3ba9f1..e81e3a8a98 100644
@@ -37,9 +37,9 @@ test_basic_obj(void)
 	char buf[1024];
 	int used = 0;
 
-	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
+	used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used,
 		"weddings", 4);
-	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
+	used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used,
 		"funerals", 1);
 
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
@@ -80,8 +80,7 @@ test_overflow_obj(void)
 	int i, used = 0;
 
 	for (i = 0; i < (int)RTE_DIM(names); i++)
-		used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
-				names[i], vals[i]);
+		used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used, names[i], vals[i]);
 
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
 	if (buf[used - 1] != '}')
@@ -117,7 +116,7 @@ test_large_obj_element(void)
 	char buf[sizeof(str) - 5] = "XYZ";
 	int used = 0;
 
-	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used, str, 0);
+	used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used, str, 0);
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
 	if (used != 0)
 		return -1;
lib/telemetry/telemetry.c +4 -4
index 89bdde8422..655191bcf1 100644
@@ -174,7 +174,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
 	if (d->type == TEL_ARRAY_UINT)
 		for (i = 0; i < d->data_len; i++)
-			used = rte_tel_json_add_array_u64(out_buf,
+			used = rte_tel_json_add_array_uint(out_buf,
 				buf_len, used,
 				d->data.array[i].uval);
 	if (d->type == TEL_ARRAY_INT)
@@ -202,7 +202,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 						v->name, v->value.ival);
 				break;
 			case RTE_TEL_UINT_VAL:
-				used = rte_tel_json_add_obj_u64(out_buf,
+				used = rte_tel_json_add_obj_uint(out_buf,
 						buf_len, used,
 						v->name, v->value.uval);
 				break;
@@ -269,7 +269,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						v->name, v->value.ival);
 				break;
 			case RTE_TEL_UINT_VAL:
-				used = rte_tel_json_add_obj_u64(cb_data_buf,
+				used = rte_tel_json_add_obj_uint(cb_data_buf,
 						buf_len, used,
 						v->name, v->value.uval);
 				break;
@@ -307,7 +307,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						buf_len, used,
 						d->data.array[i].ival);
 			else if (d->type == TEL_ARRAY_UINT)
-				used = rte_tel_json_add_array_u64(cb_data_buf,
+				used = rte_tel_json_add_array_uint(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].uval);
 			else if (d->type == TEL_ARRAY_CONTAINER) {
lib/telemetry/telemetry_json.h +8 -8
index e3fae7c30d..744bbfe053 100644
@@ -136,19 +136,19 @@ rte_tel_json_add_array_string(char *buf, const int len, const int used,
 
 /* Appends an integer into the JSON array in the provided buffer. */
 static inline int
-rte_tel_json_add_array_int(char *buf, const int len, const int used, int val)
+rte_tel_json_add_array_int(char *buf, const int len, const int used, int64_t val)
 {
 	int ret, end = used - 1; /* strip off final delimiter */
 	if (used <= 2) /* assume empty, since minimum is '[]' */
-		return __json_snprintf(buf, len, "[%d]", val);
+		return __json_snprintf(buf, len, "[%"PRId64"]", val);
 
-	ret = __json_snprintf(buf + end, len - end, ",%d]", val);
+	ret = __json_snprintf(buf + end, len - end, ",%"PRId64"]", val);
 	return ret == 0 ? used : end + ret;
 }
 
 /* Appends a uint64_t into the JSON array in the provided buffer. */
 static inline int
-rte_tel_json_add_array_u64(char *buf, const int len, const int used,
+rte_tel_json_add_array_uint(char *buf, const int len, const int used,
 		uint64_t val)
 {
 	int ret, end = used - 1; /* strip off final delimiter */
@@ -180,7 +180,7 @@ rte_tel_json_add_array_json(char *buf, const int len, const int used,
  * provided buffer.
  */
 static inline int
-rte_tel_json_add_obj_u64(char *buf, const int len, const int used,
+rte_tel_json_add_obj_uint(char *buf, const int len, const int used,
 		const char *name, uint64_t val)
 {
 	int ret, end = used - 1;
@@ -199,14 +199,14 @@ rte_tel_json_add_obj_u64(char *buf, const int len, const int used,
  */
 static inline int
 rte_tel_json_add_obj_int(char *buf, const int len, const int used,
-		const char *name, int val)
+		const char *name, int64_t val)
 {
 	int ret, end = used - 1;
 	if (used <= 2) /* assume empty, since minimum is '{}' */
-		return __json_snprintf(buf, len, "{\"%s\":%d}", name,
+		return __json_snprintf(buf, len, "{\"%s\":%"PRId64"}", name,
 				val);
 
-	ret = __json_snprintf(buf + end, len - end, ",\"%s\":%d}",
+	ret = __json_snprintf(buf + end, len - end, ",\"%s\":%"PRId64"}",
 			name, val);
 	return ret == 0 ? used : end + ret;
 }
Signature · 1 line
2.34.1
#23 lore raw

RFC PATCH 6/7 telemetry: make internal int representation 64-bits

In reply to Bruce Richardson

The internal storage for int values can be expanded from 32-bit to 64-bit without affecting the external ABI.

---
 lib/telemetry/telemetry_data.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/telemetry/telemetry_data.h +1 -1
index 8db6875a81..205509c5a2 100644
@@ -28,7 +28,7 @@ struct container {
  */
 union tel_value {
 	char sval[RTE_TEL_MAX_STRING_LEN];
-	int ival;
+	int64_t ival;
 	uint64_t uval;
 	struct container container;
 };
Signature · 1 line
2.34.1
#24 lore raw

RFC PATCH 7/7 telemetry: change public API to use 64-bit signed values

In reply to Bruce Richardson

While the unsigned values added to telemetry dicts/arrays were up to 64-bits in size, the sized values were only up to 32-bits. We can standardize the API by having both int and uint functions take 64-bit values. For ABI compatibility, we use function versioning to ensure older binaries can still use the older functions taking a 32-bit parameter.

---
 lib/telemetry/meson.build      |  1 +
 lib/telemetry/rte_telemetry.h  |  4 ++--
 lib/telemetry/telemetry_data.c | 33 +++++++++++++++++++++++++++++----
 lib/telemetry/telemetry_data.h |  6 ++++++
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 45 insertions(+), 6 deletions(-)
lib/telemetry/meson.build +1 -0
index f84c9aa3be..73750d9ef4 100644
@@ -6,3 +6,4 @@ includes = [global_inc]
 sources = files('telemetry.c', 'telemetry_data.c', 'telemetry_legacy.c')
 headers = files('rte_telemetry.h')
 includes += include_directories('../metrics')
+use_function_versioning = true
lib/telemetry/rte_telemetry.h +2 -2
index 60877dae0a..baa7b21f6b 100644
@@ -120,7 +120,7 @@ rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str);
  *   0 on success, negative errno on error
  */
 int
-rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
+rte_tel_data_add_array_int(struct rte_tel_data *d, int64_t x);
 
 /**
  * Add an unsigned value to an array.
@@ -208,7 +208,7 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
  *   0 on success, negative errno on error, E2BIG on string truncation of name.
  */
 int
-rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
+rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int64_t val);
 
 /**
  * Add an unsigned value to a dictionary.
lib/telemetry/telemetry_data.c +29 -4
index 9a180937fd..ac7be795df 100644
@@ -8,6 +8,7 @@
 #undef RTE_USE_LIBBSD
 #include <stdbool.h>
 
+#include <rte_function_versioning.h>
 #include <rte_string_fns.h>
 
 #include "telemetry_data.h"
@@ -58,8 +59,8 @@ rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str)
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
 }
 
-int
-rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
+int __vsym
+rte_tel_data_add_array_int_v24(struct rte_tel_data *d, int64_t x)
 {
 	if (d->type != TEL_ARRAY_INT)
 		return -EINVAL;
@@ -69,6 +70,18 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 	return 0;
 }
 
+int __vsym
+rte_tel_data_add_array_int_v23(struct rte_tel_data *d, int x)
+{
+	return rte_tel_data_add_array_int_v24(d, x);
+}
+
+/* mark the v23 function as the older version, and v24 as the default version */
+VERSION_SYMBOL(rte_tel_data_add_array_int, _v23, 23);
+BIND_DEFAULT_SYMBOL(rte_tel_data_add_array_int, _v24, 24);
+MAP_STATIC_SYMBOL(int rte_tel_data_add_array_int(struct rte_tel_data *d,
+		int64_t x), rte_tel_data_add_array_int_v24);
+
 int
 rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x)
 {
@@ -146,8 +159,8 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
 	return 0;
 }
 
-int
-rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
+int __vsym
+rte_tel_data_add_dict_int_v24(struct rte_tel_data *d, const char *name, int64_t val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 	if (d->type != TEL_DICT)
@@ -165,6 +178,18 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
 }
 
+int __vsym
+rte_tel_data_add_dict_int_v23(struct rte_tel_data *d, const char *name, int val)
+{
+	return rte_tel_data_add_dict_int_v24(d, name, val);
+}
+
+/* mark the v23 function as the older version, and v24 as the default version */
+VERSION_SYMBOL(rte_tel_data_add_dict_int, _v23, 23);
+BIND_DEFAULT_SYMBOL(rte_tel_data_add_dict_int, _v24, 24);
+MAP_STATIC_SYMBOL(int rte_tel_data_add_dict_int(struct rte_tel_data *d,
+		const char *name, int64_t val), rte_tel_data_add_dict_int_v24);
+
 int
 rte_tel_data_add_dict_uint(struct rte_tel_data *d,
 		const char *name, uint64_t val)
lib/telemetry/telemetry_data.h +6 -0
index 205509c5a2..53e4cabea5 100644
@@ -49,4 +49,10 @@ struct rte_tel_data {
 	} data; /* data container */
 };
 
+/* versioned functions */
+int rte_tel_data_add_array_int_v23(struct rte_tel_data *d, int val);
+int rte_tel_data_add_array_int_v24(struct rte_tel_data *d, int64_t val);
+int rte_tel_data_add_dict_int_v23(struct rte_tel_data *d, const char *name, int val);
+int rte_tel_data_add_dict_int_v24(struct rte_tel_data *d, const char *name, int64_t val);
+
 #endif
lib/telemetry/version.map +7 -0
index 0f70d82dfc..85df19c4d8 100644
@@ -19,6 +19,13 @@ DPDK_23 {
 	local: *;
 };
 
+DPDK_24 {
+	global:
+
+	rte_tel_data_add_array_int;
+	rte_tel_data_add_dict_int;
+} DPDK_23;
+
 EXPERIMENTAL {
 	global:
 
Signature · 1 line
2.34.1
#25 lore raw

RE: [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values

Quoted 10 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, 13 December 2022 19.28

While the unsigned values added to telemetry dicts/arrays were up to 64-bits in size, the sized values were only up to 32-bits. We can standardize the API by having both int and uint functions take 64-bit values. For ABI compatibility, we use function versioning to ensure older binaries can still use the older functions taking a 32-bit parameter.

Quoted 3 lines

---

Excellent example of how to use function versioning for ABI compatibility.

#26 lore raw

Re: [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values

Quoted 10 lines · Morten Brørup
Quoted 10 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, 13 December 2022 19.28

While the unsigned values added to telemetry dicts/arrays were up to 64-bits in size, the sized values were only up to 32-bits. We can standardize the API by having both int and uint functions take 64-bit values. For ABI compatibility, we use function versioning to ensure older binaries can still use the older functions taking a 32-bit parameter.

Quoted 8 lines
Quoted 3 lines

---

Excellent example of how to use function versioning for ABI compatibility.

minor comments that can be optionally addressed. lgtm

#27 lore raw

Re: [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values

Quoted 14 lines · Tyler Retzlaff
Quoted 13 lines · Morten Brørup
Quoted 13 lines

From: Bruce Richardson [mailto:[email protected]]
Sent: Tuesday, 13 December 2022 19.28

While the unsigned values added to telemetry dicts/arrays were up to 64-bits in size, the sized values were only up to 32-bits. We can standardize the API by having both int and uint functions take 64-bit values. For ABI compatibility, we use function versioning to ensure older binaries can still use the older functions taking a 32-bit parameter.

---

Quoted 8 lines
Quoted 4 lines

Excellent example of how to use function versioning for ABI compatibility.

minor comments that can be optionally addressed. lgtm

.

LGTM

But I feel this patchset needs to be applied after the following patchset:
http://patches.dpdk.org/project/dpdk/list/?series=26124
The above patchset fixes some problems about possible data truncation and conversion error, and will backport to stable branch.

#28 lore raw

v2 cover Standardize telemetry int types

In reply to Bruce Richardson

Rather than having 64-bit unsigned types and 32-bit signed types supported by the telemetry lib, we should support 64-bit values for both types. On the naming side, since both are 64-bit, we should no longer call the unsigned value u64 - "uint" is better.

This patchset implements these changes as far as is possible while still keeping API and ABI compatibility.

* Internal structures and functions are updated to use 64-bit ints
* Internal functions are renamed from u64 to uint
* Public enum values are renamed from u64 to uint, and a macro is added to ensure that older code still compiles
* The public add_*_int functions are changed to take a 64-bit value rather than a 32-bit one. Since this would be an ABI break, we use function versioning to ensure older code still calls into a wrapper function which takes a 32-bit value.

The patchset also contains a couple of other small cleanups to the telemetry code that were seen in passing when making these changes - removing RTE_ prefix on internal enums, and simplifying the init of the the array of data types.

NOTE: the renaming of the u64 functions to uint is split across 3 patches in this set - patches 4,5 and 6. This is to make it easier to review and to avoid warnings about new functions not being marked initially as experimental. Some/all of these 3 can be combined on merge if so desired.

V2:
- added additional patches to replace the old function calls within DPDK code, something missed in RFC version
- added new patch to make the renamed/new functions immediately public allowing us to mark the original named versions as deprecated
- re-ordered patches within the sit, so the extra cleanup changes come first

Bruce Richardson (9):
telemetry: remove RTE prefix from internal enum values
telemetry: make array initialization more robust
telemetry: rename unsigned 64-bit enum value to uint
telemetry: add uint type as alias for u64
global: rename telemetry functions to newer versions
telemetry: mark old names of renamed fns as deprecated
telemetry: update json functions to use int/uint in names
telemetry: make internal int representation 64-bits
telemetry: change public API to use 64-bit signed values

 app/test/test_telemetry_data.c               | 22 ++---
 app/test/test_telemetry_json.c               |  9 +-
 doc/guides/rel_notes/deprecation.rst         |  5 ++
 drivers/common/cnxk/roc_platform.h           |  2 +-
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c | 24 ++---
 drivers/net/cnxk/cnxk_ethdev_telemetry.c     |  6 +-
 examples/ipsec-secgw/ipsec-secgw.c           | 72 +++++++--------
 examples/l3fwd-power/main.c                  |  4 +-
 lib/cryptodev/rte_cryptodev.c                |  6 +-
 lib/dmadev/rte_dmadev.c                      |  2 +-
 lib/eal/common/eal_common_memory.c           | 19 ++--
 lib/ethdev/rte_ethdev.c                      | 12 +--
 lib/ethdev/sff_telemetry.c                   |  2 +-
 lib/eventdev/rte_event_eth_rx_adapter.c      | 22 ++---
 lib/eventdev/rte_event_timer_adapter.c       | 38 ++++----
 lib/eventdev/rte_eventdev.c                  |  5 +-
 lib/ipsec/ipsec_telemetry.c                  | 32 +++----
 lib/rawdev/rte_rawdev.c                      |  4 +-
 lib/security/rte_security.c                  |  8 +-
 lib/telemetry/meson.build                    |  1 +
 lib/telemetry/rte_telemetry.h                | 51 +++++++++--
 lib/telemetry/telemetry.c                    | 56 ++++++------
 lib/telemetry/telemetry_data.c               | 95 ++++++++++++++------
 lib/telemetry/telemetry_data.h               | 24 +++--
 lib/telemetry/telemetry_json.h               | 16 ++--
 lib/telemetry/version.map                    |  9 ++
 26 files changed, 323 insertions(+), 223 deletions(-)

--
2.37.2

#29 lore raw

PATCH v2 1/9 telemetry: remove RTE prefix from internal enum values

To better distinguish which values are public and which are internal remove the "RTE_" prefix off the internal enum defining the container types.

---
 lib/ethdev/sff_telemetry.c     |  2 +-
 lib/telemetry/telemetry.c      | 36 +++++++++++++++---------------
 lib/telemetry/telemetry_data.c | 40 +++++++++++++++++-----------------
 lib/telemetry/telemetry_data.h | 14 ++++++------
 4 files changed, 46 insertions(+), 46 deletions(-)
lib/ethdev/sff_telemetry.c +1 -1
index ca6d196560..5923350424 100644
@@ -96,7 +96,7 @@ ssf_add_dict_string(struct rte_tel_data *d, const char *name_str, const char *va
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES) {
 		RTE_ETHDEV_LOG(ERR, "data_len has exceeded the maximum number of inserts\n");
lib/telemetry/telemetry.c +18 -18
index 8fbb4f3060..792b4e12b6 100644
@@ -167,27 +167,27 @@ 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_DICT && d->type != RTE_TEL_ARRAY_U64 &&
-		d->type != RTE_TEL_ARRAY_INT && d->type != RTE_TEL_ARRAY_STRING)
+	if (d->type != TEL_DICT && d->type != TEL_ARRAY_U64 &&
+		d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)
 		return snprintf(out_buf, buf_len, "null");
 
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
-	if (d->type == RTE_TEL_ARRAY_U64)
+	if (d->type == TEL_ARRAY_U64)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_u64(out_buf,
 				buf_len, used,
 				d->data.array[i].u64val);
-	if (d->type == RTE_TEL_ARRAY_INT)
+	if (d->type == TEL_ARRAY_INT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_int(out_buf,
 				buf_len, used,
 				d->data.array[i].ival);
-	if (d->type == RTE_TEL_ARRAY_STRING)
+	if (d->type == TEL_ARRAY_STRING)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_string(out_buf,
 				buf_len, used,
 				d->data.array[i].sval);
-	if (d->type == RTE_TEL_DICT)
+	if (d->type == TEL_DICT)
 		for (i = 0; i < d->data_len; i++) {
 			const struct tel_dict_entry *v = &d->data.dict[i];
 			switch (v->type) {
@@ -245,15 +245,15 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 	buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */
 
 	switch (d->type) {
-	case RTE_TEL_NULL:
+	case TEL_NULL:
 		used = strlcpy(cb_data_buf, "null", buf_len);
 		break;
 
-	case RTE_TEL_STRING:
+	case TEL_STRING:
 		used = rte_tel_json_str(cb_data_buf, buf_len, 0, d->data.str);
 		break;
 
-	case RTE_TEL_DICT:
+	case TEL_DICT:
 		used = rte_tel_json_empty_obj(cb_data_buf, buf_len, 0);
 		for (i = 0; i < d->data_len; i++) {
 			const struct tel_dict_entry *v = &d->data.dict[i];
@@ -291,26 +291,26 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 		}
 		break;
 
-	case RTE_TEL_ARRAY_STRING:
-	case RTE_TEL_ARRAY_INT:
-	case RTE_TEL_ARRAY_U64:
-	case RTE_TEL_ARRAY_CONTAINER:
+	case TEL_ARRAY_STRING:
+	case TEL_ARRAY_INT:
+	case TEL_ARRAY_U64:
+	case TEL_ARRAY_CONTAINER:
 		used = rte_tel_json_empty_array(cb_data_buf, buf_len, 0);
 		for (i = 0; i < d->data_len; i++)
-			if (d->type == RTE_TEL_ARRAY_STRING)
+			if (d->type == TEL_ARRAY_STRING)
 				used = rte_tel_json_add_array_string(
 						cb_data_buf,
 						buf_len, used,
 						d->data.array[i].sval);
-			else if (d->type == RTE_TEL_ARRAY_INT)
+			else if (d->type == TEL_ARRAY_INT)
 				used = rte_tel_json_add_array_int(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].ival);
-			else if (d->type == RTE_TEL_ARRAY_U64)
+			else if (d->type == TEL_ARRAY_U64)
 				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_CONTAINER) {
+			else if (d->type == TEL_ARRAY_CONTAINER) {
 				char temp[buf_len];
 				const struct container *rec_data =
 						&d->data.array[i].container;
@@ -351,7 +351,7 @@ static int
 unknown_command(const char *cmd __rte_unused, const char *params __rte_unused,
 		struct rte_tel_data *d)
 {
-	return d->type = RTE_TEL_NULL;
+	return d->type = TEL_NULL;
 }
 
 static void *
lib/telemetry/telemetry_data.c +20 -20
index 34366ecee3..76fae720e3 100644
@@ -16,10 +16,10 @@ int
 rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 {
 	enum tel_container_types array_types[] = {
-			RTE_TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
-			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 */
+			TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
+			TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
+			TEL_ARRAY_U64,    /* RTE_TEL_U64_VAL = 2 */
+			TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
 	};
 	d->type = array_types[type];
 	d->data_len = 0;
@@ -29,7 +29,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 int
 rte_tel_data_start_dict(struct rte_tel_data *d)
 {
-	d->type = RTE_TEL_DICT;
+	d->type = TEL_DICT;
 	d->data_len = 0;
 	return 0;
 }
@@ -37,7 +37,7 @@ rte_tel_data_start_dict(struct rte_tel_data *d)
 int
 rte_tel_data_string(struct rte_tel_data *d, const char *str)
 {
-	d->type = RTE_TEL_STRING;
+	d->type = TEL_STRING;
 	d->data_len = strlcpy(d->data.str, str, sizeof(d->data.str));
 	if (d->data_len >= RTE_TEL_MAX_SINGLE_STRING_LEN) {
 		d->data_len = RTE_TEL_MAX_SINGLE_STRING_LEN - 1;
@@ -49,7 +49,7 @@ rte_tel_data_string(struct rte_tel_data *d, const char *str)
 int
 rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str)
 {
-	if (d->type != RTE_TEL_ARRAY_STRING)
+	if (d->type != TEL_ARRAY_STRING)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -61,7 +61,7 @@ rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str)
 int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 {
-	if (d->type != RTE_TEL_ARRAY_INT)
+	if (d->type != TEL_ARRAY_INT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -72,7 +72,7 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 int
 rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
 {
-	if (d->type != RTE_TEL_ARRAY_U64)
+	if (d->type != TEL_ARRAY_U64)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -84,10 +84,10 @@ int
 rte_tel_data_add_array_container(struct rte_tel_data *d,
 		struct rte_tel_data *val, int keep)
 {
-	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))
+	if (d->type != TEL_ARRAY_CONTAINER ||
+			(val->type != TEL_ARRAY_U64
+			&& val->type != TEL_ARRAY_INT
+			&& val->type != TEL_ARRAY_STRING))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -122,7 +122,7 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 	size_t nbytes, vbytes;
 
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
@@ -144,7 +144,7 @@ int
 rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
@@ -164,7 +164,7 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 		const char *name, uint64_t val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
@@ -185,10 +185,10 @@ rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name,
 {
 	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
-			&& val->type != RTE_TEL_DICT))
+	if (d->type != TEL_DICT || (val->type != TEL_ARRAY_U64
+			&& val->type != TEL_ARRAY_INT
+			&& val->type != TEL_ARRAY_STRING
+			&& val->type != TEL_DICT))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
lib/telemetry/telemetry_data.h +7 -7
index 26aa28e72c..79c916bd7e 100644
@@ -8,13 +8,13 @@
 #include "rte_telemetry.h"
 
 enum tel_container_types {
-	RTE_TEL_NULL,	      /** null, used as error value */
-	RTE_TEL_STRING,	      /** basic string type, no included data */
-	RTE_TEL_DICT,	      /** name-value pairs, of individual value type */
-	RTE_TEL_ARRAY_STRING, /** array of string values only */
-	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 */
+	TEL_NULL,            /** null, used as error value */
+	TEL_STRING,          /** basic string type, no included data */
+	TEL_DICT,            /** name-value pairs, of individual value type */
+	TEL_ARRAY_STRING,    /** array of string values only */
+	TEL_ARRAY_INT,       /** array of signed, 32-bit int values */
+	TEL_ARRAY_U64,      /** array of unsigned 64-bit int values */
+	TEL_ARRAY_CONTAINER, /** array of container structs */
 };
 
 struct container {
Signature · 1 line
2.37.2
#30 lore raw

PATCH v2 2/9 telemetry: make array initialization more robust

In reply to Bruce Richardson

Rather than relying on a specific ordering of elements in the array matching that of elements in the enum definition, we can explicitly mark each array entry using the equivalent enum value as an index.

---
 lib/telemetry/telemetry_data.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/telemetry/telemetry_data.c +4 -4
index 76fae720e3..3f5ef3979b 100644
@@ -16,10 +16,10 @@ int
 rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 {
 	enum tel_container_types array_types[] = {
-			TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
-			TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			TEL_ARRAY_U64,    /* RTE_TEL_U64_VAL = 2 */
-			TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
+			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
+			[RTE_TEL_U64_VAL] = TEL_ARRAY_U64,
+			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};
 	d->type = array_types[type];
 	d->data_len = 0;
Signature · 1 line
2.37.2
#31 lore raw

PATCH v2 3/9 telemetry: rename unsigned 64-bit enum value to uint

In reply to Bruce Richardson

For telemetry data, rather than having unsigned 64-bit values and signed 32-bit values, we want to just have unsigned and signed values, each stored with the max bit-width i.e. 64-bits. To that end, we rename the U64 enum entry to "UINT" to have a more generic name

For backward API-level compatibility, we can use a macro to alias the old name to the new.

---
 app/test/test_telemetry_data.c               | 10 +++++-----
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c |  4 ++--
 drivers/net/cnxk/cnxk_ethdev_telemetry.c     |  2 +-
 lib/cryptodev/rte_cryptodev.c                |  2 +-
 lib/ethdev/rte_ethdev.c                      |  2 +-
 lib/ipsec/ipsec_telemetry.c                  |  2 +-
 lib/security/rte_security.c                  |  4 ++--
 lib/telemetry/rte_telemetry.h                |  6 ++++--
 lib/telemetry/telemetry.c                    |  4 ++--
 lib/telemetry/telemetry_data.c               |  4 ++--
 10 files changed, 21 insertions(+), 19 deletions(-)
app/test/test_telemetry_data.c +5 -5
index d92667a527..24a2035b61 100644
@@ -283,7 +283,7 @@ test_case_array_u64(void)
 {
 	int i;
 
-	rte_tel_data_start_array(&response_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(&response_data, RTE_TEL_UINT_VAL);
 	for (i = 0; i < 5; i++)
 		rte_tel_data_add_array_u64(&response_data, i);
 	return CHECK_OUTPUT("[0,1,2,3,4]");
@@ -310,10 +310,10 @@ test_dict_with_array_u64_values(void)
 	int i;
 
 	struct rte_tel_data *child_data = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data, RTE_TEL_UINT_VAL);
 
 	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data2, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data2, RTE_TEL_UINT_VAL);
 
 	rte_tel_data_start_dict(&response_data);
 
@@ -336,10 +336,10 @@ test_array_with_array_u64_values(void)
 	int i;
 
 	struct rte_tel_data *child_data = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data, RTE_TEL_UINT_VAL);
 
 	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data2, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data2, RTE_TEL_UINT_VAL);
 
 	rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER);
 
drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c +2 -2
index 8e6277cbcd..59f0cce5ab 100644
@@ -94,7 +94,7 @@ copy_outb_sa_10k(struct rte_tel_data *d, uint32_t i, void *sa)
 		return -ENOMEM;
 	}
 
-	rte_tel_data_start_array(outer_hdr, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(outer_hdr, RTE_TEL_UINT_VAL);
 
 	for (j = 0; j < RTE_DIM(out_sa->outer_hdr.ipv6.src_addr); j++)
 		rte_tel_data_add_array_u64(outer_hdr,
@@ -167,7 +167,7 @@ copy_inb_sa_10k(struct rte_tel_data *d, uint32_t i, void *sa)
 		return -ENOMEM;
 	}
 
-	rte_tel_data_start_array(outer_hdr, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(outer_hdr, RTE_TEL_UINT_VAL);
 
 	for (j = 0; j < RTE_DIM(in_sa->outer_hdr.ipv6.src_addr); j++)
 		rte_tel_data_add_array_u64(outer_hdr,
drivers/net/cnxk/cnxk_ethdev_telemetry.c +1 -1
index 180108ab9c..5db973d620 100644
@@ -52,7 +52,7 @@ ethdev_tel_handle_info(const char *cmd __rte_unused,
 	i_data = rte_tel_data_alloc();
 	if (i_data == NULL)
 		return -ENOMEM;
-	rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(i_data, RTE_TEL_UINT_VAL);
 
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
 		/* Skip if port is unused */
lib/cryptodev/rte_cryptodev.c +1 -1
index 2165a0688c..79ea958db4 100644
@@ -2744,7 +2744,7 @@ crypto_caps_array(struct rte_tel_data *d,
 	uint64_t caps_val[CRYPTO_CAPS_SZ];
 	unsigned int i = 0, j;
 
-	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
 
 	while ((dev_caps = &capabilities[i++])->op !=
 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
lib/ethdev/rte_ethdev.c +1 -1
index 5d5e18db1e..28028e5de5 100644
@@ -5818,7 +5818,7 @@ eth_dev_add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats,
 	struct rte_tel_data *q_data = rte_tel_data_alloc();
 	if (q_data == NULL)
 		return;
-	rte_tel_data_start_array(q_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(q_data, RTE_TEL_UINT_VAL);
 	for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++)
 		rte_tel_data_add_array_u64(q_data, q_stats[q]);
 	rte_tel_data_add_dict_container(d, stat_name, q_data, 0);
lib/ipsec/ipsec_telemetry.c +1 -1
index cfebf454d6..b184e8df99 100644
@@ -22,7 +22,7 @@ handle_telemetry_cmd_ipsec_sa_list(const char *cmd __rte_unused,
 		struct rte_tel_data *data)
 {
 	struct ipsec_telemetry_entry *entry;
-	rte_tel_data_start_array(data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(data, RTE_TEL_UINT_VAL);
 
 	LIST_FOREACH(entry, &ipsec_telemetry_list, next) {
 		const struct rte_ipsec_sa *sa = entry->sa;
lib/security/rte_security.c +2 -2
index 29af5f3e4b..68063f6450 100644
@@ -316,7 +316,7 @@ crypto_caps_array(struct rte_tel_data *d,
 	uint64_t caps_val[CRYPTO_CAPS_SZ];
 	unsigned int i = 0, j;
 
-	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
 
 	while ((dev_caps = &capabilities[i++])->op !=
 	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
@@ -341,7 +341,7 @@ sec_caps_array(struct rte_tel_data *d,
 	uint64_t caps_val[SEC_CAPS_SZ];
 	unsigned int i = 0, j;
 
-	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
 
 	while ((dev_caps = &capabilities[i++])->action !=
 	   RTE_SECURITY_ACTION_TYPE_NONE) {
lib/telemetry/rte_telemetry.h +4 -2
index d9918c4e96..c2ad65effe 100644
@@ -43,10 +43,12 @@ struct rte_tel_data;
 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_UINT_VAL,  /** an unsigned 64-bit int value */
 	RTE_TEL_CONTAINER, /** a container struct */
 };
 
+#define RTE_TEL_U64_VAL RTE_TEL_UINT_VAL
+
 /**
  * Start an array of the specified type for returning from a callback
  *
@@ -121,7 +123,7 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 /**
  * Add a uint64_t to an array.
  * The array must have been started by rte_tel_data_start_array() with
- * RTE_TEL_U64_VAL as the type parameter.
+ * RTE_TEL_UINT_VAL as the type parameter.
  *
  * @param d
  *   The data structure passed to the callback
lib/telemetry/telemetry.c +2 -2
index 792b4e12b6..916a0a4604 100644
@@ -201,7 +201,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 						buf_len, used,
 						v->name, v->value.ival);
 				break;
-			case RTE_TEL_U64_VAL:
+			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(out_buf,
 						buf_len, used,
 						v->name, v->value.u64val);
@@ -268,7 +268,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						buf_len, used,
 						v->name, v->value.ival);
 				break;
-			case RTE_TEL_U64_VAL:
+			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(cb_data_buf,
 						buf_len, used,
 						v->name, v->value.u64val);
lib/telemetry/telemetry_data.c +2 -2
index 3f5ef3979b..d4345908d5 100644
@@ -18,7 +18,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 	enum tel_container_types array_types[] = {
 			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
 			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
-			[RTE_TEL_U64_VAL] = TEL_ARRAY_U64,
+			[RTE_TEL_UINT_VAL] = TEL_ARRAY_U64,
 			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};
 	d->type = array_types[type];
@@ -173,7 +173,7 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 		return -EINVAL;
 
 	d->data_len++;
-	e->type = RTE_TEL_U64_VAL;
+	e->type = RTE_TEL_UINT_VAL;
 	e->value.u64val = val;
 	const size_t bytes = strlcpy(e->name, name, RTE_TEL_MAX_STRING_LEN);
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
Signature · 1 line
2.37.2
#32 lore raw

PATCH v2 4/9 telemetry: add uint type as alias for u64

In reply to Bruce Richardson

To match the "_int" suffix for telemetry data functions taking signed values, we can add new functions with the "_uint" suffix for unsigned ones. While later patches will deprecate the old public functions, for now we can just add the new functions as aliases or duplicates of the older ones with the "u64" suffix.

Internal functions can be directly renamed, without any need for aliasing or deprecation.

---
NOTE: To avoid excessive checkpatch warnings, these functions are added initially as experimental. A later patch marks them as stable as part of the deprecation process for the old ones.

---
 lib/telemetry/rte_telemetry.h  | 37 ++++++++++++++++++++++++++++++++++
 lib/telemetry/telemetry.c      | 16 +++++++--------
 lib/telemetry/telemetry_data.c | 28 +++++++++++++++++--------
 lib/telemetry/telemetry_data.h |  4 ++--
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 74 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +37 -0
index c2ad65effe..73a0511807 100644
@@ -8,6 +8,8 @@
 #ifndef _RTE_TELEMETRY_H_
 #define _RTE_TELEMETRY_H_
 
+#include <rte_compat.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -121,6 +123,22 @@ int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 
 /**
+ * Add an unsigned value to an array.
+ * The array must have been started by rte_tel_data_start_array() with
+ * RTE_TEL_UINT_VAL as the type parameter.
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param x
+ *   The number to be returned in the array
+ * @return
+ *   0 on success, negative errno on error
+ */
+__rte_experimental
+int
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
+
+ /**
  * Add a uint64_t to an array.
  * The array must have been started by rte_tel_data_start_array() with
  * RTE_TEL_UINT_VAL as the type parameter.
@@ -193,6 +211,25 @@ int
 rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
 
 /**
+ * Add an unsigned 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
+ *   Must contain only alphanumeric characters or the symbols: '_' or '/'
+ * @param val
+ *   The number 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_uint(struct rte_tel_data *d,
+		const char *name, uint64_t val);
+
+ /**
  * Add a uint64_t value to a dictionary.
  * The dict must have been started by rte_tel_data_start_dict().
  *
lib/telemetry/telemetry.c +8 -8
index 916a0a4604..89bdde8422 100644
@@ -167,16 +167,16 @@ 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 != TEL_DICT && d->type != TEL_ARRAY_U64 &&
+	if (d->type != TEL_DICT && d->type != TEL_ARRAY_UINT &&
 		d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)
 		return snprintf(out_buf, buf_len, "null");
 
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
-	if (d->type == TEL_ARRAY_U64)
+	if (d->type == TEL_ARRAY_UINT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_u64(out_buf,
 				buf_len, used,
-				d->data.array[i].u64val);
+				d->data.array[i].uval);
 	if (d->type == TEL_ARRAY_INT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_int(out_buf,
@@ -204,7 +204,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(out_buf,
 						buf_len, used,
-						v->name, v->value.u64val);
+						v->name, v->value.uval);
 				break;
 			case RTE_TEL_CONTAINER:
 			{
@@ -271,7 +271,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(cb_data_buf,
 						buf_len, used,
-						v->name, v->value.u64val);
+						v->name, v->value.uval);
 				break;
 			case RTE_TEL_CONTAINER:
 			{
@@ -293,7 +293,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 
 	case TEL_ARRAY_STRING:
 	case TEL_ARRAY_INT:
-	case TEL_ARRAY_U64:
+	case TEL_ARRAY_UINT:
 	case TEL_ARRAY_CONTAINER:
 		used = rte_tel_json_empty_array(cb_data_buf, buf_len, 0);
 		for (i = 0; i < d->data_len; i++)
@@ -306,10 +306,10 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 				used = rte_tel_json_add_array_int(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].ival);
-			else if (d->type == TEL_ARRAY_U64)
+			else if (d->type == TEL_ARRAY_UINT)
 				used = rte_tel_json_add_array_u64(cb_data_buf,
 						buf_len, used,
-						d->data.array[i].u64val);
+						d->data.array[i].uval);
 			else if (d->type == TEL_ARRAY_CONTAINER) {
 				char temp[buf_len];
 				const struct container *rec_data =
lib/telemetry/telemetry_data.c +20 -8
index d4345908d5..9a180937fd 100644
@@ -18,7 +18,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 	enum tel_container_types array_types[] = {
 			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
 			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
-			[RTE_TEL_UINT_VAL] = TEL_ARRAY_U64,
+			[RTE_TEL_UINT_VAL] = TEL_ARRAY_UINT,
 			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};
 	d->type = array_types[type];
@@ -70,22 +70,28 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 }
 
 int
-rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x)
 {
-	if (d->type != TEL_ARRAY_U64)
+	if (d->type != TEL_ARRAY_UINT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
-	d->data.array[d->data_len++].u64val = x;
+	d->data.array[d->data_len++].uval = x;
 	return 0;
 }
 
+int
+rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
+{
+	return rte_tel_data_add_array_uint(d, x);
+}
+
 int
 rte_tel_data_add_array_container(struct rte_tel_data *d,
 		struct rte_tel_data *val, int keep)
 {
 	if (d->type != TEL_ARRAY_CONTAINER ||
-			(val->type != TEL_ARRAY_U64
+			(val->type != TEL_ARRAY_UINT
 			&& val->type != TEL_ARRAY_INT
 			&& val->type != TEL_ARRAY_STRING))
 		return -EINVAL;
@@ -160,7 +166,7 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
 }
 
 int
-rte_tel_data_add_dict_u64(struct rte_tel_data *d,
+rte_tel_data_add_dict_uint(struct rte_tel_data *d,
 		const char *name, uint64_t val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
@@ -174,18 +180,24 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 
 	d->data_len++;
 	e->type = RTE_TEL_UINT_VAL;
-	e->value.u64val = val;
+	e->value.uval = val;
 	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_u64(struct rte_tel_data *d, const char *name, uint64_t val)
+{
+	return rte_tel_data_add_dict_uint(d, name, val);
+}
+
 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 != TEL_DICT || (val->type != TEL_ARRAY_U64
+	if (d->type != TEL_DICT || (val->type != TEL_ARRAY_UINT
 			&& val->type != TEL_ARRAY_INT
 			&& val->type != TEL_ARRAY_STRING
 			&& val->type != TEL_DICT))
lib/telemetry/telemetry_data.h +2 -2
index 79c916bd7e..8db6875a81 100644
@@ -13,7 +13,7 @@ enum tel_container_types {
 	TEL_DICT,            /** name-value pairs, of individual value type */
 	TEL_ARRAY_STRING,    /** array of string values only */
 	TEL_ARRAY_INT,       /** array of signed, 32-bit int values */
-	TEL_ARRAY_U64,      /** array of unsigned 64-bit int values */
+	TEL_ARRAY_UINT,      /** array of unsigned 64-bit int values */
 	TEL_ARRAY_CONTAINER, /** array of container structs */
 };
 
@@ -29,7 +29,7 @@ struct container {
 union tel_value {
 	char sval[RTE_TEL_MAX_STRING_LEN];
 	int ival;
-	uint64_t u64val;
+	uint64_t uval;
 	struct container container;
 };
 
lib/telemetry/version.map +7 -0
index 9794f9ea20..0f70d82dfc 100644
@@ -19,6 +19,13 @@ DPDK_23 {
 	local: *;
 };
 
+EXPERIMENTAL {
+	global:
+
+	rte_tel_data_add_array_uint;
+	rte_tel_data_add_dict_uint;
+};
+
 INTERNAL {
 	rte_telemetry_legacy_register;
 	rte_telemetry_init;
Signature · 1 line
2.37.2
#33 lore raw

PATCH v2 5/9 global: rename telemetry functions to newer versions

In reply to Bruce Richardson

Within the DPDK code-base, replace all occurances of "rte_tel_data_add_array_u64" with "rte_tel_data_add_array_uint", and similarly replace all occurances of "rte_tel_data_add_dict_u64" with "rte_tel_data_add_dict_uint". This allows us to later mark the older functions as deprecated without hitting warnings.

---
 app/test/test_telemetry_data.c               | 12 ++--
 drivers/common/cnxk/roc_platform.h           |  2 +-
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c | 20 +++---
 drivers/net/cnxk/cnxk_ethdev_telemetry.c     |  4 +-
 examples/ipsec-secgw/ipsec-secgw.c           | 72 +++++++++-----------
 examples/l3fwd-power/main.c                  |  4 +-
 lib/cryptodev/rte_cryptodev.c                |  4 +-
 lib/dmadev/rte_dmadev.c                      |  2 +-
 lib/eal/common/eal_common_memory.c           | 19 +++---
 lib/ethdev/rte_ethdev.c                      | 10 +--
 lib/eventdev/rte_event_eth_rx_adapter.c      | 22 +++---
 lib/eventdev/rte_event_timer_adapter.c       | 38 +++++++----
 lib/eventdev/rte_eventdev.c                  |  5 +-
 lib/ipsec/ipsec_telemetry.c                  | 30 ++++----
 lib/rawdev/rte_rawdev.c                      |  4 +-
 lib/security/rte_security.c                  |  4 +-
 16 files changed, 128 insertions(+), 124 deletions(-)
app/test/test_telemetry_data.c +6 -6
index 24a2035b61..b00c148a57 100644
@@ -285,7 +285,7 @@ test_case_array_u64(void)
 
 	rte_tel_data_start_array(&response_data, RTE_TEL_UINT_VAL);
 	for (i = 0; i < 5; i++)
-		rte_tel_data_add_array_u64(&response_data, i);
+		rte_tel_data_add_array_uint(&response_data, i);
 	return CHECK_OUTPUT("[0,1,2,3,4]");
 }
 
@@ -299,7 +299,7 @@ test_case_add_dict_u64(void)
 
 	for (i = 0; i < 5; i++) {
 		sprintf(name_of_value, "dict_%d", i);
-		rte_tel_data_add_dict_u64(&response_data, name_of_value, i);
+		rte_tel_data_add_dict_uint(&response_data, name_of_value, i);
 	}
 	return CHECK_OUTPUT("{\"dict_0\":0,\"dict_1\":1,\"dict_2\":2,\"dict_3\":3,\"dict_4\":4}");
 }
@@ -318,8 +318,8 @@ test_dict_with_array_u64_values(void)
 	rte_tel_data_start_dict(&response_data);
 
 	for (i = 0; i < 10; i++) {
-		rte_tel_data_add_array_u64(child_data, i);
-		rte_tel_data_add_array_u64(child_data2, i);
+		rte_tel_data_add_array_uint(child_data, i);
+		rte_tel_data_add_array_uint(child_data2, i);
 	}
 
 	rte_tel_data_add_dict_container(&response_data, "dict_0",
@@ -344,8 +344,8 @@ test_array_with_array_u64_values(void)
 	rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER);
 
 	for (i = 0; i < 5; i++) {
-		rte_tel_data_add_array_u64(child_data, i);
-		rte_tel_data_add_array_u64(child_data2, i);
+		rte_tel_data_add_array_uint(child_data, i);
+		rte_tel_data_add_array_uint(child_data2, i);
 	}
 	rte_tel_data_add_array_container(&response_data, child_data, 0);
 	rte_tel_data_add_array_container(&response_data, child_data2, 0);
drivers/common/cnxk/roc_platform.h +1 -1
index 1a48ff3db4..b29f3e06f1 100644
@@ -224,7 +224,7 @@
 #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)
+	rte_tel_data_add_dict_uint(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
drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c +10 -10
index 59f0cce5ab..386278cfc9 100644
@@ -53,10 +53,10 @@ copy_inb_sa_9k(struct rte_tel_data *d, uint32_t i, void *sa)
 	rte_tel_data_add_dict_string(d, str, strw0);
 
 	snprintf(str, sizeof(str), "insa_esnh_%u", i);
-	rte_tel_data_add_dict_u64(d, str, in_sa->common_sa.seq_t.th);
+	rte_tel_data_add_dict_uint(d, str, in_sa->common_sa.seq_t.th);
 
 	snprintf(str, sizeof(str), "insa_esnl_%u", i);
-	rte_tel_data_add_dict_u64(d, str, in_sa->common_sa.seq_t.tl);
+	rte_tel_data_add_dict_uint(d, str, in_sa->common_sa.seq_t.tl);
 
 	return 0;
 }
@@ -97,12 +97,12 @@ copy_outb_sa_10k(struct rte_tel_data *d, uint32_t i, void *sa)
 	rte_tel_data_start_array(outer_hdr, RTE_TEL_UINT_VAL);
 
 	for (j = 0; j < RTE_DIM(out_sa->outer_hdr.ipv6.src_addr); j++)
-		rte_tel_data_add_array_u64(outer_hdr,
-					   out_sa->outer_hdr.ipv6.src_addr[j]);
+		rte_tel_data_add_array_uint(outer_hdr,
+					    out_sa->outer_hdr.ipv6.src_addr[j]);
 
 	for (j = 0; j < RTE_DIM(out_sa->outer_hdr.ipv6.dst_addr); j++)
-		rte_tel_data_add_array_u64(outer_hdr,
-					   out_sa->outer_hdr.ipv6.dst_addr[j]);
+		rte_tel_data_add_array_uint(outer_hdr,
+					    out_sa->outer_hdr.ipv6.dst_addr[j]);
 
 	snprintf(str, sizeof(str), "outsa_outer_hdr_%u", i);
 	rte_tel_data_add_dict_container(d, str, outer_hdr, 0);
@@ -170,12 +170,12 @@ copy_inb_sa_10k(struct rte_tel_data *d, uint32_t i, void *sa)
 	rte_tel_data_start_array(outer_hdr, RTE_TEL_UINT_VAL);
 
 	for (j = 0; j < RTE_DIM(in_sa->outer_hdr.ipv6.src_addr); j++)
-		rte_tel_data_add_array_u64(outer_hdr,
-					   in_sa->outer_hdr.ipv6.src_addr[j]);
+		rte_tel_data_add_array_uint(outer_hdr,
+					    in_sa->outer_hdr.ipv6.src_addr[j]);
 
 	for (j = 0; j < RTE_DIM(in_sa->outer_hdr.ipv6.dst_addr); j++)
-		rte_tel_data_add_array_u64(outer_hdr,
-					   in_sa->outer_hdr.ipv6.dst_addr[j]);
+		rte_tel_data_add_array_uint(outer_hdr,
+					    in_sa->outer_hdr.ipv6.dst_addr[j]);
 
 	snprintf(str, sizeof(str), "insa_outer_hdr_%u", i);
 	rte_tel_data_add_dict_container(d, str, outer_hdr, 0);
drivers/net/cnxk/cnxk_ethdev_telemetry.c +2 -2
index 5db973d620..3027ca4735 100644
@@ -80,8 +80,8 @@ ethdev_tel_handle_info(const char *cmd __rte_unused,
 			}
 
 			for (j = 0; j < ETH_INFO_SZ; j++)
-				rte_tel_data_add_array_u64(i_data,
-							   eth_info.val[j]);
+				rte_tel_data_add_array_uint(i_data,
+							    eth_info.val[j]);
 
 			j++;
 		}
examples/ipsec-secgw/ipsec-secgw.c +34 -38

122 lines not on this page · raw message

examples/l3fwd-power/main.c +2 -2
index fd3ade330f..caf26b373e 100644
@@ -2555,8 +2555,8 @@ handle_app_stats(const char *cmd __rte_unused,
 	rte_tel_data_start_dict(d);
 	get_current_stat_values(values);
 	for (i = 0; i < NUM_TELSTATS; i++)
-		rte_tel_data_add_dict_u64(d, telstats_strings[i].name,
-				values[i]);
+		rte_tel_data_add_dict_uint(d, telstats_strings[i].name,
+					   values[i]);
 	return 0;
 }
 
lib/cryptodev/rte_cryptodev.c +2 -2
index 79ea958db4..bc53aab100 100644
@@ -2698,7 +2698,7 @@ cryptodev_handle_dev_info(const char *cmd __rte_unused,
 	return 0;
 }
 
-#define ADD_DICT_STAT(s) rte_tel_data_add_dict_u64(d, #s, cryptodev_stats.s)
+#define ADD_DICT_STAT(s) rte_tel_data_add_dict_uint(d, #s, cryptodev_stats.s)
 
 static int
 cryptodev_handle_dev_stats(const char *cmd __rte_unused,
@@ -2751,7 +2751,7 @@ crypto_caps_array(struct rte_tel_data *d,
 		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]);
+			rte_tel_data_add_array_uint(d, caps_val[j]);
 	}
 
 	return i;
lib/dmadev/rte_dmadev.c +1 -1
index 4da653eec7..8c095e1f35 100644
@@ -944,7 +944,7 @@ dmadev_handle_dev_info(const char *cmd __rte_unused,
 	return 0;
 }
 
-#define ADD_DICT_STAT(s) rte_tel_data_add_dict_u64(d, #s, dma_stats.s)
+#define ADD_DICT_STAT(s) rte_tel_data_add_dict_uint(d, #s, dma_stats.s)
 
 static int
 dmadev_handle_dev_stats(const char *cmd __rte_unused,
lib/eal/common/eal_common_memory.c +10 -9
index 688dc615d7..3d2fc8e98b 100644
@@ -1141,15 +1141,16 @@ handle_eal_heap_info_request(const char *cmd __rte_unused, const char *params,
 	rte_tel_data_start_dict(d);
 	rte_tel_data_add_dict_int(d, "Head id", heap_id);
 	rte_tel_data_add_dict_string(d, "Name", heap->name);
-	rte_tel_data_add_dict_u64(d, "Heap_size",
-				  sock_stats.heap_totalsz_bytes);
-	rte_tel_data_add_dict_u64(d, "Free_size", sock_stats.heap_freesz_bytes);
-	rte_tel_data_add_dict_u64(d, "Alloc_size",
-				  sock_stats.heap_allocsz_bytes);
-	rte_tel_data_add_dict_u64(d, "Greatest_free_size",
-				  sock_stats.greatest_free_size);
-	rte_tel_data_add_dict_u64(d, "Alloc_count", sock_stats.alloc_count);
-	rte_tel_data_add_dict_u64(d, "Free_count", sock_stats.free_count);
+	rte_tel_data_add_dict_uint(d, "Heap_size",
+				   sock_stats.heap_totalsz_bytes);
+	rte_tel_data_add_dict_uint(d, "Free_size",
+				   sock_stats.heap_freesz_bytes);
+	rte_tel_data_add_dict_uint(d, "Alloc_size",
+				   sock_stats.heap_allocsz_bytes);
+	rte_tel_data_add_dict_uint(d, "Greatest_free_size",
+				   sock_stats.greatest_free_size);
+	rte_tel_data_add_dict_uint(d, "Alloc_count", sock_stats.alloc_count);
+	rte_tel_data_add_dict_uint(d, "Free_count", sock_stats.free_count);
 
 	return 0;
 }
lib/ethdev/rte_ethdev.c +5 -5
index 28028e5de5..4dd2968a01 100644
@@ -5820,11 +5820,11 @@ eth_dev_add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats,
 		return;
 	rte_tel_data_start_array(q_data, RTE_TEL_UINT_VAL);
 	for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++)
-		rte_tel_data_add_array_u64(q_data, q_stats[q]);
+		rte_tel_data_add_array_uint(q_data, q_stats[q]);
 	rte_tel_data_add_dict_container(d, stat_name, q_data, 0);
 }
 
-#define ADD_DICT_STAT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
+#define ADD_DICT_STAT(stats, s) rte_tel_data_add_dict_uint(d, #s, stats.s)
 
 static int
 eth_dev_handle_port_stats(const char *cmd __rte_unused,
@@ -5909,8 +5909,8 @@ eth_dev_handle_port_xstats(const char *cmd __rte_unused,
 
 	rte_tel_data_start_dict(d);
 	for (i = 0; i < num_xstats; i++)
-		rte_tel_data_add_dict_u64(d, xstat_names[i].name,
-				eth_xstats[i].value);
+		rte_tel_data_add_dict_uint(d, xstat_names[i].name,
+					   eth_xstats[i].value);
 	free(eth_xstats);
 	return 0;
 }
@@ -5987,7 +5987,7 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused,
 		return 0;
 	}
 	rte_tel_data_add_dict_string(d, status_str, "UP");
-	rte_tel_data_add_dict_u64(d, "speed", link.link_speed);
+	rte_tel_data_add_dict_uint(d, "speed", link.link_speed);
 	rte_tel_data_add_dict_string(d, "duplex",
 			(link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX) ?
 				"full-duplex" : "half-duplex");
lib/eventdev/rte_event_eth_rx_adapter.c +11 -11
index cf7bbd4d69..13d7163b79 100644
@@ -3433,7 +3433,7 @@ rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
 	return -EINVAL;
 }
 
-#define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
+#define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_uint(d, #s, stats.s)
 
 static int
 handle_rxa_stats(const char *cmd __rte_unused,
@@ -3458,7 +3458,7 @@ handle_rxa_stats(const char *cmd __rte_unused,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "rx_adapter_id", rx_adapter_id);
+	rte_tel_data_add_dict_uint(d, "rx_adapter_id", rx_adapter_id);
 	RXA_ADD_DICT(rx_adptr_stats, rx_packets);
 	RXA_ADD_DICT(rx_adptr_stats, rx_poll_count);
 	RXA_ADD_DICT(rx_adptr_stats, rx_dropped);
@@ -3552,9 +3552,9 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "rx_adapter_id", rx_adapter_id);
-	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
-	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_uint(d, "rx_adapter_id", rx_adapter_id);
+	rte_tel_data_add_dict_uint(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_uint(d, "rx_queue_id", rx_queue_id);
 	RXA_ADD_DICT(queue_conf, rx_queue_flags);
 	RXA_ADD_DICT(queue_conf, servicing_weight);
 	RXA_ADD_DICT(queue_conf.ev, queue_id);
@@ -3624,9 +3624,9 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "rx_adapter_id", rx_adapter_id);
-	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
-	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_uint(d, "rx_adapter_id", rx_adapter_id);
+	rte_tel_data_add_dict_uint(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_uint(d, "rx_queue_id", rx_queue_id);
 	RXA_ADD_DICT(q_stats, rx_event_buf_count);
 	RXA_ADD_DICT(q_stats, rx_event_buf_size);
 	RXA_ADD_DICT(q_stats, rx_poll_count);
@@ -3752,9 +3752,9 @@ handle_rxa_instance_get(const char *cmd __rte_unused,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
-	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
-	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+	rte_tel_data_add_dict_uint(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_uint(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_uint(d, "rxa_instance_id", instance_id);
 
 	return 0;
 
lib/eventdev/rte_event_timer_adapter.c +23 -15
index a0f14bf861..1c3f91605a 100644
@@ -1316,15 +1316,20 @@ handle_ta_info(const char *cmd __rte_unused, const char *params,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "timer_adapter_id", adapter_id);
-	rte_tel_data_add_dict_u64(d, "min_resolution_ns", adapter_info.min_resolution_ns);
-	rte_tel_data_add_dict_u64(d, "max_tmo_ns", adapter_info.max_tmo_ns);
-	rte_tel_data_add_dict_u64(d, "event_dev_id", adapter_info.conf.event_dev_id);
-	rte_tel_data_add_dict_u64(d, "socket_id", adapter_info.conf.socket_id);
-	rte_tel_data_add_dict_u64(d, "clk_src", adapter_info.conf.clk_src);
-	rte_tel_data_add_dict_u64(d, "timer_tick_ns", adapter_info.conf.timer_tick_ns);
-	rte_tel_data_add_dict_u64(d, "nb_timers", adapter_info.conf.nb_timers);
-	rte_tel_data_add_dict_u64(d, "flags", adapter_info.conf.flags);
+	rte_tel_data_add_dict_uint(d, "timer_adapter_id", adapter_id);
+	rte_tel_data_add_dict_uint(d, "min_resolution_ns",
+				   adapter_info.min_resolution_ns);
+	rte_tel_data_add_dict_uint(d, "max_tmo_ns", adapter_info.max_tmo_ns);
+	rte_tel_data_add_dict_uint(d, "event_dev_id",
+				   adapter_info.conf.event_dev_id);
+	rte_tel_data_add_dict_uint(d, "socket_id",
+				   adapter_info.conf.socket_id);
+	rte_tel_data_add_dict_uint(d, "clk_src", adapter_info.conf.clk_src);
+	rte_tel_data_add_dict_uint(d, "timer_tick_ns",
+				   adapter_info.conf.timer_tick_ns);
+	rte_tel_data_add_dict_uint(d, "nb_timers",
+				   adapter_info.conf.nb_timers);
+	rte_tel_data_add_dict_uint(d, "flags", adapter_info.conf.flags);
 
 	return 0;
 }
@@ -1357,12 +1362,15 @@ handle_ta_stats(const char *cmd __rte_unused, const char *params,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "timer_adapter_id", adapter_id);
-	rte_tel_data_add_dict_u64(d, "evtim_exp_count", stats.evtim_exp_count);
-	rte_tel_data_add_dict_u64(d, "ev_enq_count", stats.ev_enq_count);
-	rte_tel_data_add_dict_u64(d, "ev_inv_count", stats.ev_inv_count);
-	rte_tel_data_add_dict_u64(d, "evtim_retry_count", stats.evtim_retry_count);
-	rte_tel_data_add_dict_u64(d, "adapter_tick_count", stats.adapter_tick_count);
+	rte_tel_data_add_dict_uint(d, "timer_adapter_id", adapter_id);
+	rte_tel_data_add_dict_uint(d, "evtim_exp_count",
+				   stats.evtim_exp_count);
+	rte_tel_data_add_dict_uint(d, "ev_enq_count", stats.ev_enq_count);
+	rte_tel_data_add_dict_uint(d, "ev_inv_count", stats.ev_inv_count);
+	rte_tel_data_add_dict_uint(d, "evtim_retry_count",
+				   stats.evtim_retry_count);
+	rte_tel_data_add_dict_uint(d, "adapter_tick_count",
+				   stats.adapter_tick_count);
 
 	return 0;
 }
lib/eventdev/rte_eventdev.c +2 -3
index b0414206d9..027e6a93ce 100644
@@ -1645,7 +1645,7 @@ handle_queue_links(const char *cmd __rte_unused,
 		char qid_name[32];
 
 		snprintf(qid_name, 31, "qid_%u", queues[i]);
-		rte_tel_data_add_dict_u64(d, qid_name, priorities[i]);
+		rte_tel_data_add_dict_uint(d, qid_name, priorities[i]);
 	}
 
 	return 0;
@@ -1711,8 +1711,7 @@ eventdev_build_telemetry_data(int dev_id,
 
 	rte_tel_data_start_dict(d);
 	for (i = 0; i < num_xstats; i++)
-		rte_tel_data_add_dict_u64(d, xstat_names[i].name,
-					  values[i]);
+		rte_tel_data_add_dict_uint(d, xstat_names[i].name, values[i]);
 
 	free(xstat_names);
 	free(ids);
lib/ipsec/ipsec_telemetry.c +15 -15
index b184e8df99..3b03ddee63 100644
@@ -26,7 +26,7 @@ handle_telemetry_cmd_ipsec_sa_list(const char *cmd __rte_unused,
 
 	LIST_FOREACH(entry, &ipsec_telemetry_list, next) {
 		const struct rte_ipsec_sa *sa = entry->sa;
-		rte_tel_data_add_array_u64(data, rte_be_to_cpu_32(sa->spi));
+		rte_tel_data_add_array_uint(data, rte_be_to_cpu_32(sa->spi));
 	}
 
 	return 0;
@@ -80,15 +80,14 @@ handle_telemetry_cmd_ipsec_sa_stats(const char *cmd __rte_unused,
 		rte_tel_data_start_dict(sa_data);
 
 		/* add telemetry key/values pairs */
-		rte_tel_data_add_dict_u64(sa_data, name_pkt_cnt,
-					sa->statistics.count);
+		rte_tel_data_add_dict_uint(sa_data, name_pkt_cnt,
+					   sa->statistics.count);
 
-		rte_tel_data_add_dict_u64(sa_data, name_byte_cnt,
-					sa->statistics.bytes -
-					(sa->statistics.count * sa->hdr_len));
+		rte_tel_data_add_dict_uint(sa_data, name_byte_cnt,
+					   sa->statistics.bytes - (sa->statistics.count * sa->hdr_len));
 
-		rte_tel_data_add_dict_u64(sa_data, name_error_cnt,
-					sa->statistics.errors.count);
+		rte_tel_data_add_dict_uint(sa_data, name_error_cnt,
+					   sa->statistics.errors.count);
 
 		/* generate telemetry label */
 		snprintf(sa_name, sizeof(sa_name), "SA_SPI_%i",
@@ -177,15 +176,16 @@ handle_telemetry_cmd_ipsec_sa_details(const char *cmd __rte_unused,
 			RTE_IPSEC_SATP_DIR_IB)
 
 			if (sa->sqn.inb.rsn[sa->sqn.inb.rdidx])
-				rte_tel_data_add_dict_u64(data,
-				"sequence-number",
-				sa->sqn.inb.rsn[sa->sqn.inb.rdidx]->sqn);
+				rte_tel_data_add_dict_uint(data,
+							   "sequence-number",
+							   sa->sqn.inb.rsn[sa->sqn.inb.rdidx]->sqn);
 			else
-				rte_tel_data_add_dict_u64(data,
-					"sequence-number", 0);
+				rte_tel_data_add_dict_uint(data,
+							   "sequence-number",
+							   0);
 		else
-			rte_tel_data_add_dict_u64(data, "sequence-number",
-					sa->sqn.outb);
+			rte_tel_data_add_dict_uint(data, "sequence-number",
+						   sa->sqn.outb);
 
 		rte_tel_data_add_dict_string(data,
 				"explicit-congestion-notification",
lib/rawdev/rte_rawdev.c +2 -2
index 5fbdb94229..dacaa60e22 100644
@@ -631,8 +631,8 @@ handle_dev_xstats(const char *cmd __rte_unused,
 
 	rte_tel_data_start_dict(d);
 	for (i = 0; i < num_xstats; i++)
-		rte_tel_data_add_dict_u64(d, xstat_names[i].name,
-				rawdev_xstats[i]);
+		rte_tel_data_add_dict_uint(d, xstat_names[i].name,
+					   rawdev_xstats[i]);
 
 	free(rawdev_xstats);
 	return 0;
lib/security/rte_security.c +2 -2
index 68063f6450..e102c55e55 100644
@@ -323,7 +323,7 @@ crypto_caps_array(struct rte_tel_data *d,
 		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]);
+			rte_tel_data_add_array_uint(d, caps_val[j]);
 	}
 
 	return (i - 1);
@@ -348,7 +348,7 @@ sec_caps_array(struct rte_tel_data *d,
 		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]);
+			rte_tel_data_add_array_uint(d, caps_val[j]);
 	}
 
 	return i - 1;
Signature · 1 line
2.37.2
#34 lore raw

PATCH v2 6/9 telemetry: mark old names of renamed fns as deprecated

In reply to Bruce Richardson

Add a deprecation notice for the renaming of the telemetry data u64/uint functions, and point users to the newer versions of them when building. To do this, we also need to mark the renamed versions as stable, rather than experimental.

---
Note: This patch adds the deprecation macro *after* the function prototype rather than before, as adding it before - as with the experimental tag - causes doxygen to get confused and give errors:

.../lib/telemetry/rte_telemetry.h:141: warning: argument 'd' of command @param is not found in the argument list of __rte_deprecated_msg("use 'rte_tel_data_add_array_uint' instead") .../lib/telemetry/rte_telemetry.h:141: warning: argument 'x' of command @param is not found in the argument list of __rte_deprecated_msg("use 'rte_tel_data_add_array_uint' instead")

---
 doc/guides/rel_notes/deprecation.rst |  5 +++++
 lib/telemetry/rte_telemetry.h        | 10 +++++-----
 lib/telemetry/version.map            |  9 ++-------
 3 files changed, 12 insertions(+), 12 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index b9b02dcef0..98ad6baed5 100644
@@ -11,6 +11,11 @@ here.
 Deprecation Notices
 -------------------
 
+* telemetry: The functions ``rte_tel_data_add_array_u64`` and ``rte_tel_data_add_dict_u64``,
+  used by telemetry callbacks for adding unsigned integer values to be returned to the user,
+  are renamed to ``rte_tel_data_add_array_uint`` and ``rte_tel_data_add_dict_uint`` respectively.
+  As such, the old function names are deprecated and will be removed in a future release.
+
 * kvargs: The function ``rte_kvargs_process`` will get a new parameter
   for returning key match count. It will ease handling of no-match case.
 
lib/telemetry/rte_telemetry.h +5 -5
index 73a0511807..4598303d5d 100644
@@ -8,7 +8,7 @@
 #ifndef _RTE_TELEMETRY_H_
 #define _RTE_TELEMETRY_H_
 
-#include <rte_compat.h>
+#include <rte_common.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -134,7 +134,6 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
  * @return
  *   0 on success, negative errno on error
  */
-__rte_experimental
 int
 rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
 
@@ -151,7 +150,8 @@ rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
  *   0 on success, negative errno on error
  */
 int
-rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x);
+rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
+	__rte_deprecated_msg("use 'rte_tel_data_add_array_uint' instead");
 
 /**
  * Add a container to an array. A container is an existing telemetry data
@@ -224,7 +224,6 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
  * @return
  *   0 on success, negative errno on error, E2BIG on string truncation of name.
  */
-__rte_experimental
 int
 rte_tel_data_add_dict_uint(struct rte_tel_data *d,
 		const char *name, uint64_t val);
@@ -245,7 +244,8 @@ rte_tel_data_add_dict_uint(struct rte_tel_data *d,
  */
 int
 rte_tel_data_add_dict_u64(struct rte_tel_data *d,
-		const char *name, uint64_t val);
+		const char *name, uint64_t val)
+	__rte_deprecated_msg("use 'rte_tel_data_add_dict_uint' instead");
 
 /**
  * Add a container to a dictionary. A container is an existing telemetry data
lib/telemetry/version.map +2 -7
index 0f70d82dfc..d661180317 100644
@@ -5,10 +5,12 @@ DPDK_23 {
 	rte_tel_data_add_array_int;
 	rte_tel_data_add_array_string;
 	rte_tel_data_add_array_u64;
+	rte_tel_data_add_array_uint;
 	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_uint;
 	rte_tel_data_alloc;
 	rte_tel_data_free;
 	rte_tel_data_start_array;
@@ -19,13 +21,6 @@ DPDK_23 {
 	local: *;
 };
 
-EXPERIMENTAL {
-	global:
-
-	rte_tel_data_add_array_uint;
-	rte_tel_data_add_dict_uint;
-};
-
 INTERNAL {
 	rte_telemetry_legacy_register;
 	rte_telemetry_init;
Signature · 1 line
2.37.2
#35 lore raw

PATCH v2 7/9 telemetry: update json functions to use int/uint in names

In reply to Bruce Richardson

Since we are standardizing on using uint in place of u64, and expanding the int values to 64-bit, we can update the internal json functions to use the new names and expanded signed type.

---
 app/test/test_telemetry_json.c |  9 ++++-----
 lib/telemetry/telemetry.c      |  8 ++++----
 lib/telemetry/telemetry_json.h | 16 ++++++++--------
 3 files changed, 16 insertions(+), 17 deletions(-)
app/test/test_telemetry_json.c +4 -5
index 184c3ba9f1..e81e3a8a98 100644
@@ -37,9 +37,9 @@ test_basic_obj(void)
 	char buf[1024];
 	int used = 0;
 
-	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
+	used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used,
 		"weddings", 4);
-	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
+	used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used,
 		"funerals", 1);
 
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
@@ -80,8 +80,7 @@ test_overflow_obj(void)
 	int i, used = 0;
 
 	for (i = 0; i < (int)RTE_DIM(names); i++)
-		used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
-				names[i], vals[i]);
+		used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used, names[i], vals[i]);
 
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
 	if (buf[used - 1] != '}')
@@ -117,7 +116,7 @@ test_large_obj_element(void)
 	char buf[sizeof(str) - 5] = "XYZ";
 	int used = 0;
 
-	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used, str, 0);
+	used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used, str, 0);
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
 	if (used != 0)
 		return -1;
lib/telemetry/telemetry.c +4 -4
index 89bdde8422..655191bcf1 100644
@@ -174,7 +174,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
 	if (d->type == TEL_ARRAY_UINT)
 		for (i = 0; i < d->data_len; i++)
-			used = rte_tel_json_add_array_u64(out_buf,
+			used = rte_tel_json_add_array_uint(out_buf,
 				buf_len, used,
 				d->data.array[i].uval);
 	if (d->type == TEL_ARRAY_INT)
@@ -202,7 +202,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 						v->name, v->value.ival);
 				break;
 			case RTE_TEL_UINT_VAL:
-				used = rte_tel_json_add_obj_u64(out_buf,
+				used = rte_tel_json_add_obj_uint(out_buf,
 						buf_len, used,
 						v->name, v->value.uval);
 				break;
@@ -269,7 +269,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						v->name, v->value.ival);
 				break;
 			case RTE_TEL_UINT_VAL:
-				used = rte_tel_json_add_obj_u64(cb_data_buf,
+				used = rte_tel_json_add_obj_uint(cb_data_buf,
 						buf_len, used,
 						v->name, v->value.uval);
 				break;
@@ -307,7 +307,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						buf_len, used,
 						d->data.array[i].ival);
 			else if (d->type == TEL_ARRAY_UINT)
-				used = rte_tel_json_add_array_u64(cb_data_buf,
+				used = rte_tel_json_add_array_uint(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].uval);
 			else if (d->type == TEL_ARRAY_CONTAINER) {
lib/telemetry/telemetry_json.h +8 -8
index e3fae7c30d..744bbfe053 100644
@@ -136,19 +136,19 @@ rte_tel_json_add_array_string(char *buf, const int len, const int used,
 
 /* Appends an integer into the JSON array in the provided buffer. */
 static inline int
-rte_tel_json_add_array_int(char *buf, const int len, const int used, int val)
+rte_tel_json_add_array_int(char *buf, const int len, const int used, int64_t val)
 {
 	int ret, end = used - 1; /* strip off final delimiter */
 	if (used <= 2) /* assume empty, since minimum is '[]' */
-		return __json_snprintf(buf, len, "[%d]", val);
+		return __json_snprintf(buf, len, "[%"PRId64"]", val);
 
-	ret = __json_snprintf(buf + end, len - end, ",%d]", val);
+	ret = __json_snprintf(buf + end, len - end, ",%"PRId64"]", val);
 	return ret == 0 ? used : end + ret;
 }
 
 /* Appends a uint64_t into the JSON array in the provided buffer. */
 static inline int
-rte_tel_json_add_array_u64(char *buf, const int len, const int used,
+rte_tel_json_add_array_uint(char *buf, const int len, const int used,
 		uint64_t val)
 {
 	int ret, end = used - 1; /* strip off final delimiter */
@@ -180,7 +180,7 @@ rte_tel_json_add_array_json(char *buf, const int len, const int used,
  * provided buffer.
  */
 static inline int
-rte_tel_json_add_obj_u64(char *buf, const int len, const int used,
+rte_tel_json_add_obj_uint(char *buf, const int len, const int used,
 		const char *name, uint64_t val)
 {
 	int ret, end = used - 1;
@@ -199,14 +199,14 @@ rte_tel_json_add_obj_u64(char *buf, const int len, const int used,
  */
 static inline int
 rte_tel_json_add_obj_int(char *buf, const int len, const int used,
-		const char *name, int val)
+		const char *name, int64_t val)
 {
 	int ret, end = used - 1;
 	if (used <= 2) /* assume empty, since minimum is '{}' */
-		return __json_snprintf(buf, len, "{\"%s\":%d}", name,
+		return __json_snprintf(buf, len, "{\"%s\":%"PRId64"}", name,
 				val);
 
-	ret = __json_snprintf(buf + end, len - end, ",\"%s\":%d}",
+	ret = __json_snprintf(buf + end, len - end, ",\"%s\":%"PRId64"}",
 			name, val);
 	return ret == 0 ? used : end + ret;
 }
Signature · 1 line
2.37.2
#36 lore raw

PATCH v2 8/9 telemetry: make internal int representation 64-bits

In reply to Bruce Richardson

The internal storage for int values can be expanded from 32-bit to 64-bit without affecting the external ABI.

---
 lib/telemetry/telemetry_data.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/telemetry/telemetry_data.h +1 -1
index 8db6875a81..205509c5a2 100644
@@ -28,7 +28,7 @@ struct container {
  */
 union tel_value {
 	char sval[RTE_TEL_MAX_STRING_LEN];
-	int ival;
+	int64_t ival;
 	uint64_t uval;
 	struct container container;
 };
Signature · 1 line
2.37.2
#37 lore raw

PATCH v2 9/9 telemetry: change public API to use 64-bit signed values

In reply to Bruce Richardson

While the unsigned values added to telemetry dicts/arrays were up to 64-bits in size, the sized values were only up to 32-bits. We can standardize the API by having both int and uint functions take 64-bit values. For ABI compatibility, we use function versioning to ensure older binaries can still use the older functions taking a 32-bit parameter.

---
 lib/telemetry/meson.build      |  1 +
 lib/telemetry/rte_telemetry.h  |  4 ++--
 lib/telemetry/telemetry_data.c | 33 +++++++++++++++++++++++++++++----
 lib/telemetry/telemetry_data.h |  6 ++++++
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 45 insertions(+), 6 deletions(-)
lib/telemetry/meson.build +1 -0
index f84c9aa3be..73750d9ef4 100644
@@ -6,3 +6,4 @@ includes = [global_inc]
 sources = files('telemetry.c', 'telemetry_data.c', 'telemetry_legacy.c')
 headers = files('rte_telemetry.h')
 includes += include_directories('../metrics')
+use_function_versioning = true
lib/telemetry/rte_telemetry.h +2 -2
index 4598303d5d..b481c112dd 100644
@@ -120,7 +120,7 @@ rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str);
  *   0 on success, negative errno on error
  */
 int
-rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
+rte_tel_data_add_array_int(struct rte_tel_data *d, int64_t x);
 
 /**
  * Add an unsigned value to an array.
@@ -208,7 +208,7 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
  *   0 on success, negative errno on error, E2BIG on string truncation of name.
  */
 int
-rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
+rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int64_t val);
 
 /**
  * Add an unsigned value to a dictionary.
lib/telemetry/telemetry_data.c +29 -4
index 9a180937fd..ac7be795df 100644
@@ -8,6 +8,7 @@
 #undef RTE_USE_LIBBSD
 #include <stdbool.h>
 
+#include <rte_function_versioning.h>
 #include <rte_string_fns.h>
 
 #include "telemetry_data.h"
@@ -58,8 +59,8 @@ rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str)
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
 }
 
-int
-rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
+int __vsym
+rte_tel_data_add_array_int_v24(struct rte_tel_data *d, int64_t x)
 {
 	if (d->type != TEL_ARRAY_INT)
 		return -EINVAL;
@@ -69,6 +70,18 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 	return 0;
 }
 
+int __vsym
+rte_tel_data_add_array_int_v23(struct rte_tel_data *d, int x)
+{
+	return rte_tel_data_add_array_int_v24(d, x);
+}
+
+/* mark the v23 function as the older version, and v24 as the default version */
+VERSION_SYMBOL(rte_tel_data_add_array_int, _v23, 23);
+BIND_DEFAULT_SYMBOL(rte_tel_data_add_array_int, _v24, 24);
+MAP_STATIC_SYMBOL(int rte_tel_data_add_array_int(struct rte_tel_data *d,
+		int64_t x), rte_tel_data_add_array_int_v24);
+
 int
 rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x)
 {
@@ -146,8 +159,8 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
 	return 0;
 }
 
-int
-rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
+int __vsym
+rte_tel_data_add_dict_int_v24(struct rte_tel_data *d, const char *name, int64_t val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 	if (d->type != TEL_DICT)
@@ -165,6 +178,18 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
 }
 
+int __vsym
+rte_tel_data_add_dict_int_v23(struct rte_tel_data *d, const char *name, int val)
+{
+	return rte_tel_data_add_dict_int_v24(d, name, val);
+}
+
+/* mark the v23 function as the older version, and v24 as the default version */
+VERSION_SYMBOL(rte_tel_data_add_dict_int, _v23, 23);
+BIND_DEFAULT_SYMBOL(rte_tel_data_add_dict_int, _v24, 24);
+MAP_STATIC_SYMBOL(int rte_tel_data_add_dict_int(struct rte_tel_data *d,
+		const char *name, int64_t val), rte_tel_data_add_dict_int_v24);
+
 int
 rte_tel_data_add_dict_uint(struct rte_tel_data *d,
 		const char *name, uint64_t val)
lib/telemetry/telemetry_data.h +6 -0
index 205509c5a2..53e4cabea5 100644
@@ -49,4 +49,10 @@ struct rte_tel_data {
 	} data; /* data container */
 };
 
+/* versioned functions */
+int rte_tel_data_add_array_int_v23(struct rte_tel_data *d, int val);
+int rte_tel_data_add_array_int_v24(struct rte_tel_data *d, int64_t val);
+int rte_tel_data_add_dict_int_v23(struct rte_tel_data *d, const char *name, int val);
+int rte_tel_data_add_dict_int_v24(struct rte_tel_data *d, const char *name, int64_t val);
+
 #endif
lib/telemetry/version.map +7 -0
index d661180317..accfad5011 100644
@@ -21,6 +21,13 @@ DPDK_23 {
 	local: *;
 };
 
+DPDK_24 {
+	global:
+
+	rte_tel_data_add_array_int;
+	rte_tel_data_add_dict_int;
+} DPDK_23;
+
 INTERNAL {
 	rte_telemetry_legacy_register;
 	rte_telemetry_init;
Signature · 1 line
2.37.2
#38 lore raw

v3 cover Standardize telemetry int types

In reply to Bruce Richardson

Rather than having 64-bit unsigned types and 32-bit signed types supported by the telemetry lib, we should support 64-bit values for both types. On the naming side, since both are 64-bit, we should no longer call the unsigned value u64 - "uint" is better.

This patchset implements these changes as far as is possible while still keeping API and ABI compatibility.

* Internal structures and functions are updated to use 64-bit ints
* Internal functions are renamed from u64 to uint
* Public enum values are renamed from u64 to uint, and a macro is added to ensure that older code still compiles
* The public add_*_int functions are changed to take a 64-bit value rather than a 32-bit one. Since this would be an ABI break, we use function versioning to ensure older code still calls into a wrapper function which takes a 32-bit value.

The patchset also contains a couple of other small cleanups to the telemetry code that were seen in passing when making these changes - removing RTE_ prefix on internal enums, and simplifying the init of the the array of data types.

NOTE: the renaming of the u64 functions to uint is split across 3 patches in this set - patches 4,5 and 6. This is to make it easier to review and to avoid warnings about new functions not being marked initially as experimental. Some/all of these 3 can be combined on merge if so desired.

V3:
- fix build issues due to missing a driver code change
- fix spelling issue flagged by checkpatch

V2:
- added additional patches to replace the old function calls within DPDK code, something missed in RFC version
- added new patch to make the renamed/new functions immediately public allowing us to mark the original named versions as deprecated
- re-ordered patches within the sit, so the extra cleanup changes come first

Bruce Richardson (9):
telemetry: remove RTE prefix from internal enum values
telemetry: make array initialization more robust
telemetry: rename unsigned 64-bit enum value to uint
telemetry: add uint type as alias for u64
global: rename telemetry functions to newer versions
telemetry: mark old names of renamed fns as deprecated
telemetry: update json functions to use int/uint in names
telemetry: make internal int representation 64-bits
telemetry: change public API to use 64-bit signed values

 app/test/test_telemetry_data.c               | 22 ++---
 app/test/test_telemetry_json.c               |  9 +-
 doc/guides/rel_notes/deprecation.rst         |  5 ++
 drivers/common/cnxk/roc_platform.h           |  4 +-
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c | 24 ++---
 drivers/net/cnxk/cnxk_ethdev_telemetry.c     |  6 +-
 examples/ipsec-secgw/ipsec-secgw.c           | 72 +++++++--------
 examples/l3fwd-power/main.c                  |  4 +-
 lib/cryptodev/rte_cryptodev.c                |  6 +-
 lib/dmadev/rte_dmadev.c                      |  2 +-
 lib/eal/common/eal_common_memory.c           | 19 ++--
 lib/ethdev/rte_ethdev.c                      | 12 +--
 lib/ethdev/sff_telemetry.c                   |  2 +-
 lib/eventdev/rte_event_eth_rx_adapter.c      | 22 ++---
 lib/eventdev/rte_event_timer_adapter.c       | 38 ++++----
 lib/eventdev/rte_eventdev.c                  |  5 +-
 lib/ipsec/ipsec_telemetry.c                  | 33 +++----
 lib/rawdev/rte_rawdev.c                      |  4 +-
 lib/security/rte_security.c                  |  8 +-
 lib/telemetry/meson.build                    |  1 +
 lib/telemetry/rte_telemetry.h                | 51 +++++++++--
 lib/telemetry/telemetry.c                    | 56 ++++++------
 lib/telemetry/telemetry_data.c               | 95 ++++++++++++++------
 lib/telemetry/telemetry_data.h               | 24 +++--
 lib/telemetry/telemetry_json.h               | 16 ++--
 lib/telemetry/version.map                    |  9 ++
 26 files changed, 325 insertions(+), 224 deletions(-)

--
2.37.2

#39 lore raw

PATCH v3 1/9 telemetry: remove RTE prefix from internal enum values

To better distinguish which values are public and which are internal remove the "RTE_" prefix off the internal enum defining the container types.

---
 lib/ethdev/sff_telemetry.c     |  2 +-
 lib/telemetry/telemetry.c      | 36 +++++++++++++++---------------
 lib/telemetry/telemetry_data.c | 40 +++++++++++++++++-----------------
 lib/telemetry/telemetry_data.h | 14 ++++++------
 4 files changed, 46 insertions(+), 46 deletions(-)
lib/ethdev/sff_telemetry.c +1 -1
index ca6d196560..5923350424 100644
@@ -96,7 +96,7 @@ ssf_add_dict_string(struct rte_tel_data *d, const char *name_str, const char *va
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES) {
 		RTE_ETHDEV_LOG(ERR, "data_len has exceeded the maximum number of inserts\n");
lib/telemetry/telemetry.c +18 -18
index 8fbb4f3060..792b4e12b6 100644
@@ -167,27 +167,27 @@ 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_DICT && d->type != RTE_TEL_ARRAY_U64 &&
-		d->type != RTE_TEL_ARRAY_INT && d->type != RTE_TEL_ARRAY_STRING)
+	if (d->type != TEL_DICT && d->type != TEL_ARRAY_U64 &&
+		d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)
 		return snprintf(out_buf, buf_len, "null");
 
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
-	if (d->type == RTE_TEL_ARRAY_U64)
+	if (d->type == TEL_ARRAY_U64)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_u64(out_buf,
 				buf_len, used,
 				d->data.array[i].u64val);
-	if (d->type == RTE_TEL_ARRAY_INT)
+	if (d->type == TEL_ARRAY_INT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_int(out_buf,
 				buf_len, used,
 				d->data.array[i].ival);
-	if (d->type == RTE_TEL_ARRAY_STRING)
+	if (d->type == TEL_ARRAY_STRING)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_string(out_buf,
 				buf_len, used,
 				d->data.array[i].sval);
-	if (d->type == RTE_TEL_DICT)
+	if (d->type == TEL_DICT)
 		for (i = 0; i < d->data_len; i++) {
 			const struct tel_dict_entry *v = &d->data.dict[i];
 			switch (v->type) {
@@ -245,15 +245,15 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 	buf_len = sizeof(out_buf) - prefix_used - 1; /* space for '}' */
 
 	switch (d->type) {
-	case RTE_TEL_NULL:
+	case TEL_NULL:
 		used = strlcpy(cb_data_buf, "null", buf_len);
 		break;
 
-	case RTE_TEL_STRING:
+	case TEL_STRING:
 		used = rte_tel_json_str(cb_data_buf, buf_len, 0, d->data.str);
 		break;
 
-	case RTE_TEL_DICT:
+	case TEL_DICT:
 		used = rte_tel_json_empty_obj(cb_data_buf, buf_len, 0);
 		for (i = 0; i < d->data_len; i++) {
 			const struct tel_dict_entry *v = &d->data.dict[i];
@@ -291,26 +291,26 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 		}
 		break;
 
-	case RTE_TEL_ARRAY_STRING:
-	case RTE_TEL_ARRAY_INT:
-	case RTE_TEL_ARRAY_U64:
-	case RTE_TEL_ARRAY_CONTAINER:
+	case TEL_ARRAY_STRING:
+	case TEL_ARRAY_INT:
+	case TEL_ARRAY_U64:
+	case TEL_ARRAY_CONTAINER:
 		used = rte_tel_json_empty_array(cb_data_buf, buf_len, 0);
 		for (i = 0; i < d->data_len; i++)
-			if (d->type == RTE_TEL_ARRAY_STRING)
+			if (d->type == TEL_ARRAY_STRING)
 				used = rte_tel_json_add_array_string(
 						cb_data_buf,
 						buf_len, used,
 						d->data.array[i].sval);
-			else if (d->type == RTE_TEL_ARRAY_INT)
+			else if (d->type == TEL_ARRAY_INT)
 				used = rte_tel_json_add_array_int(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].ival);
-			else if (d->type == RTE_TEL_ARRAY_U64)
+			else if (d->type == TEL_ARRAY_U64)
 				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_CONTAINER) {
+			else if (d->type == TEL_ARRAY_CONTAINER) {
 				char temp[buf_len];
 				const struct container *rec_data =
 						&d->data.array[i].container;
@@ -351,7 +351,7 @@ static int
 unknown_command(const char *cmd __rte_unused, const char *params __rte_unused,
 		struct rte_tel_data *d)
 {
-	return d->type = RTE_TEL_NULL;
+	return d->type = TEL_NULL;
 }
 
 static void *
lib/telemetry/telemetry_data.c +20 -20
index 34366ecee3..76fae720e3 100644
@@ -16,10 +16,10 @@ int
 rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 {
 	enum tel_container_types array_types[] = {
-			RTE_TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
-			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 */
+			TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
+			TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
+			TEL_ARRAY_U64,    /* RTE_TEL_U64_VAL = 2 */
+			TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
 	};
 	d->type = array_types[type];
 	d->data_len = 0;
@@ -29,7 +29,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 int
 rte_tel_data_start_dict(struct rte_tel_data *d)
 {
-	d->type = RTE_TEL_DICT;
+	d->type = TEL_DICT;
 	d->data_len = 0;
 	return 0;
 }
@@ -37,7 +37,7 @@ rte_tel_data_start_dict(struct rte_tel_data *d)
 int
 rte_tel_data_string(struct rte_tel_data *d, const char *str)
 {
-	d->type = RTE_TEL_STRING;
+	d->type = TEL_STRING;
 	d->data_len = strlcpy(d->data.str, str, sizeof(d->data.str));
 	if (d->data_len >= RTE_TEL_MAX_SINGLE_STRING_LEN) {
 		d->data_len = RTE_TEL_MAX_SINGLE_STRING_LEN - 1;
@@ -49,7 +49,7 @@ rte_tel_data_string(struct rte_tel_data *d, const char *str)
 int
 rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str)
 {
-	if (d->type != RTE_TEL_ARRAY_STRING)
+	if (d->type != TEL_ARRAY_STRING)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -61,7 +61,7 @@ rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str)
 int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 {
-	if (d->type != RTE_TEL_ARRAY_INT)
+	if (d->type != TEL_ARRAY_INT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -72,7 +72,7 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 int
 rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
 {
-	if (d->type != RTE_TEL_ARRAY_U64)
+	if (d->type != TEL_ARRAY_U64)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -84,10 +84,10 @@ int
 rte_tel_data_add_array_container(struct rte_tel_data *d,
 		struct rte_tel_data *val, int keep)
 {
-	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))
+	if (d->type != TEL_ARRAY_CONTAINER ||
+			(val->type != TEL_ARRAY_U64
+			&& val->type != TEL_ARRAY_INT
+			&& val->type != TEL_ARRAY_STRING))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
@@ -122,7 +122,7 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 	size_t nbytes, vbytes;
 
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
@@ -144,7 +144,7 @@ int
 rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
@@ -164,7 +164,7 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 		const char *name, uint64_t val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
-	if (d->type != RTE_TEL_DICT)
+	if (d->type != TEL_DICT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
@@ -185,10 +185,10 @@ rte_tel_data_add_dict_container(struct rte_tel_data *d, const char *name,
 {
 	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
-			&& val->type != RTE_TEL_DICT))
+	if (d->type != TEL_DICT || (val->type != TEL_ARRAY_U64
+			&& val->type != TEL_ARRAY_INT
+			&& val->type != TEL_ARRAY_STRING
+			&& val->type != TEL_DICT))
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_DICT_ENTRIES)
 		return -ENOSPC;
lib/telemetry/telemetry_data.h +7 -7
index 26aa28e72c..79c916bd7e 100644
@@ -8,13 +8,13 @@
 #include "rte_telemetry.h"
 
 enum tel_container_types {
-	RTE_TEL_NULL,	      /** null, used as error value */
-	RTE_TEL_STRING,	      /** basic string type, no included data */
-	RTE_TEL_DICT,	      /** name-value pairs, of individual value type */
-	RTE_TEL_ARRAY_STRING, /** array of string values only */
-	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 */
+	TEL_NULL,            /** null, used as error value */
+	TEL_STRING,          /** basic string type, no included data */
+	TEL_DICT,            /** name-value pairs, of individual value type */
+	TEL_ARRAY_STRING,    /** array of string values only */
+	TEL_ARRAY_INT,       /** array of signed, 32-bit int values */
+	TEL_ARRAY_U64,      /** array of unsigned 64-bit int values */
+	TEL_ARRAY_CONTAINER, /** array of container structs */
 };
 
 struct container {
Signature · 1 line
2.37.2
#40 lore raw

PATCH v3 2/9 telemetry: make array initialization more robust

In reply to Bruce Richardson

Rather than relying on a specific ordering of elements in the array matching that of elements in the enum definition, we can explicitly mark each array entry using the equivalent enum value as an index.

---
 lib/telemetry/telemetry_data.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/telemetry/telemetry_data.c +4 -4
index 76fae720e3..3f5ef3979b 100644
@@ -16,10 +16,10 @@ int
 rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 {
 	enum tel_container_types array_types[] = {
-			TEL_ARRAY_STRING, /* RTE_TEL_STRING_VAL = 0 */
-			TEL_ARRAY_INT,    /* RTE_TEL_INT_VAL = 1 */
-			TEL_ARRAY_U64,    /* RTE_TEL_U64_VAL = 2 */
-			TEL_ARRAY_CONTAINER, /* RTE_TEL_CONTAINER = 3 */
+			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
+			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
+			[RTE_TEL_U64_VAL] = TEL_ARRAY_U64,
+			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};
 	d->type = array_types[type];
 	d->data_len = 0;
Signature · 1 line
2.37.2
#41 lore raw

PATCH v3 3/9 telemetry: rename unsigned 64-bit enum value to uint

In reply to Bruce Richardson

For telemetry data, rather than having unsigned 64-bit values and signed 32-bit values, we want to just have unsigned and signed values, each stored with the max bit-width i.e. 64-bits. To that end, we rename the U64 enum entry to "UINT" to have a more generic name

For backward API-level compatibility, we can use a macro to alias the old name to the new.

---
 app/test/test_telemetry_data.c               | 10 +++++-----
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c |  4 ++--
 drivers/net/cnxk/cnxk_ethdev_telemetry.c     |  2 +-
 lib/cryptodev/rte_cryptodev.c                |  2 +-
 lib/ethdev/rte_ethdev.c                      |  2 +-
 lib/ipsec/ipsec_telemetry.c                  |  2 +-
 lib/security/rte_security.c                  |  4 ++--
 lib/telemetry/rte_telemetry.h                |  6 ++++--
 lib/telemetry/telemetry.c                    |  4 ++--
 lib/telemetry/telemetry_data.c               |  4 ++--
 10 files changed, 21 insertions(+), 19 deletions(-)
app/test/test_telemetry_data.c +5 -5
index d92667a527..24a2035b61 100644
@@ -283,7 +283,7 @@ test_case_array_u64(void)
 {
 	int i;
 
-	rte_tel_data_start_array(&response_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(&response_data, RTE_TEL_UINT_VAL);
 	for (i = 0; i < 5; i++)
 		rte_tel_data_add_array_u64(&response_data, i);
 	return CHECK_OUTPUT("[0,1,2,3,4]");
@@ -310,10 +310,10 @@ test_dict_with_array_u64_values(void)
 	int i;
 
 	struct rte_tel_data *child_data = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data, RTE_TEL_UINT_VAL);
 
 	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data2, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data2, RTE_TEL_UINT_VAL);
 
 	rte_tel_data_start_dict(&response_data);
 
@@ -336,10 +336,10 @@ test_array_with_array_u64_values(void)
 	int i;
 
 	struct rte_tel_data *child_data = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data, RTE_TEL_UINT_VAL);
 
 	struct rte_tel_data *child_data2 = rte_tel_data_alloc();
-	rte_tel_data_start_array(child_data2, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(child_data2, RTE_TEL_UINT_VAL);
 
 	rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER);
 
drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c +2 -2
index 8e6277cbcd..59f0cce5ab 100644
@@ -94,7 +94,7 @@ copy_outb_sa_10k(struct rte_tel_data *d, uint32_t i, void *sa)
 		return -ENOMEM;
 	}
 
-	rte_tel_data_start_array(outer_hdr, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(outer_hdr, RTE_TEL_UINT_VAL);
 
 	for (j = 0; j < RTE_DIM(out_sa->outer_hdr.ipv6.src_addr); j++)
 		rte_tel_data_add_array_u64(outer_hdr,
@@ -167,7 +167,7 @@ copy_inb_sa_10k(struct rte_tel_data *d, uint32_t i, void *sa)
 		return -ENOMEM;
 	}
 
-	rte_tel_data_start_array(outer_hdr, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(outer_hdr, RTE_TEL_UINT_VAL);
 
 	for (j = 0; j < RTE_DIM(in_sa->outer_hdr.ipv6.src_addr); j++)
 		rte_tel_data_add_array_u64(outer_hdr,
drivers/net/cnxk/cnxk_ethdev_telemetry.c +1 -1
index 180108ab9c..5db973d620 100644
@@ -52,7 +52,7 @@ ethdev_tel_handle_info(const char *cmd __rte_unused,
 	i_data = rte_tel_data_alloc();
 	if (i_data == NULL)
 		return -ENOMEM;
-	rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(i_data, RTE_TEL_UINT_VAL);
 
 	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
 		/* Skip if port is unused */
lib/cryptodev/rte_cryptodev.c +1 -1
index 2165a0688c..79ea958db4 100644
@@ -2744,7 +2744,7 @@ crypto_caps_array(struct rte_tel_data *d,
 	uint64_t caps_val[CRYPTO_CAPS_SZ];
 	unsigned int i = 0, j;
 
-	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
 
 	while ((dev_caps = &capabilities[i++])->op !=
 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
lib/ethdev/rte_ethdev.c +1 -1
index 5d5e18db1e..28028e5de5 100644
@@ -5818,7 +5818,7 @@ eth_dev_add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats,
 	struct rte_tel_data *q_data = rte_tel_data_alloc();
 	if (q_data == NULL)
 		return;
-	rte_tel_data_start_array(q_data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(q_data, RTE_TEL_UINT_VAL);
 	for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++)
 		rte_tel_data_add_array_u64(q_data, q_stats[q]);
 	rte_tel_data_add_dict_container(d, stat_name, q_data, 0);
lib/ipsec/ipsec_telemetry.c +1 -1
index cfebf454d6..b184e8df99 100644
@@ -22,7 +22,7 @@ handle_telemetry_cmd_ipsec_sa_list(const char *cmd __rte_unused,
 		struct rte_tel_data *data)
 {
 	struct ipsec_telemetry_entry *entry;
-	rte_tel_data_start_array(data, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(data, RTE_TEL_UINT_VAL);
 
 	LIST_FOREACH(entry, &ipsec_telemetry_list, next) {
 		const struct rte_ipsec_sa *sa = entry->sa;
lib/security/rte_security.c +2 -2
index 29af5f3e4b..68063f6450 100644
@@ -316,7 +316,7 @@ crypto_caps_array(struct rte_tel_data *d,
 	uint64_t caps_val[CRYPTO_CAPS_SZ];
 	unsigned int i = 0, j;
 
-	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
 
 	while ((dev_caps = &capabilities[i++])->op !=
 	   RTE_CRYPTO_OP_TYPE_UNDEFINED) {
@@ -341,7 +341,7 @@ sec_caps_array(struct rte_tel_data *d,
 	uint64_t caps_val[SEC_CAPS_SZ];
 	unsigned int i = 0, j;
 
-	rte_tel_data_start_array(d, RTE_TEL_U64_VAL);
+	rte_tel_data_start_array(d, RTE_TEL_UINT_VAL);
 
 	while ((dev_caps = &capabilities[i++])->action !=
 	   RTE_SECURITY_ACTION_TYPE_NONE) {
lib/telemetry/rte_telemetry.h +4 -2
index d9918c4e96..c2ad65effe 100644
@@ -43,10 +43,12 @@ struct rte_tel_data;
 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_UINT_VAL,  /** an unsigned 64-bit int value */
 	RTE_TEL_CONTAINER, /** a container struct */
 };
 
+#define RTE_TEL_U64_VAL RTE_TEL_UINT_VAL
+
 /**
  * Start an array of the specified type for returning from a callback
  *
@@ -121,7 +123,7 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 /**
  * Add a uint64_t to an array.
  * The array must have been started by rte_tel_data_start_array() with
- * RTE_TEL_U64_VAL as the type parameter.
+ * RTE_TEL_UINT_VAL as the type parameter.
  *
  * @param d
  *   The data structure passed to the callback
lib/telemetry/telemetry.c +2 -2
index 792b4e12b6..916a0a4604 100644
@@ -201,7 +201,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 						buf_len, used,
 						v->name, v->value.ival);
 				break;
-			case RTE_TEL_U64_VAL:
+			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(out_buf,
 						buf_len, used,
 						v->name, v->value.u64val);
@@ -268,7 +268,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						buf_len, used,
 						v->name, v->value.ival);
 				break;
-			case RTE_TEL_U64_VAL:
+			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(cb_data_buf,
 						buf_len, used,
 						v->name, v->value.u64val);
lib/telemetry/telemetry_data.c +2 -2
index 3f5ef3979b..d4345908d5 100644
@@ -18,7 +18,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 	enum tel_container_types array_types[] = {
 			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
 			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
-			[RTE_TEL_U64_VAL] = TEL_ARRAY_U64,
+			[RTE_TEL_UINT_VAL] = TEL_ARRAY_U64,
 			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};
 	d->type = array_types[type];
@@ -173,7 +173,7 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 		return -EINVAL;
 
 	d->data_len++;
-	e->type = RTE_TEL_U64_VAL;
+	e->type = RTE_TEL_UINT_VAL;
 	e->value.u64val = val;
 	const size_t bytes = strlcpy(e->name, name, RTE_TEL_MAX_STRING_LEN);
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
Signature · 1 line
2.37.2
#42 lore raw

PATCH v3 4/9 telemetry: add uint type as alias for u64

In reply to Bruce Richardson

To match the "_int" suffix for telemetry data functions taking signed values, we can add new functions with the "_uint" suffix for unsigned ones. While later patches will deprecate the old public functions, for now we can just add the new functions as aliases or duplicates of the older ones with the "u64" suffix.

Internal functions can be directly renamed, without any need for aliasing or deprecation.

---
NOTE: To avoid excessive checkpatch warnings, these functions are added initially as experimental. A later patch marks them as stable as part of the deprecation process for the old ones.

---
 lib/telemetry/rte_telemetry.h  | 37 ++++++++++++++++++++++++++++++++++
 lib/telemetry/telemetry.c      | 16 +++++++--------
 lib/telemetry/telemetry_data.c | 28 +++++++++++++++++--------
 lib/telemetry/telemetry_data.h |  4 ++--
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 74 insertions(+), 18 deletions(-)
lib/telemetry/rte_telemetry.h +37 -0
index c2ad65effe..73a0511807 100644
@@ -8,6 +8,8 @@
 #ifndef _RTE_TELEMETRY_H_
 #define _RTE_TELEMETRY_H_
 
+#include <rte_compat.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -121,6 +123,22 @@ int
 rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
 
 /**
+ * Add an unsigned value to an array.
+ * The array must have been started by rte_tel_data_start_array() with
+ * RTE_TEL_UINT_VAL as the type parameter.
+ *
+ * @param d
+ *   The data structure passed to the callback
+ * @param x
+ *   The number to be returned in the array
+ * @return
+ *   0 on success, negative errno on error
+ */
+__rte_experimental
+int
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
+
+ /**
  * Add a uint64_t to an array.
  * The array must have been started by rte_tel_data_start_array() with
  * RTE_TEL_UINT_VAL as the type parameter.
@@ -193,6 +211,25 @@ int
 rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
 
 /**
+ * Add an unsigned 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
+ *   Must contain only alphanumeric characters or the symbols: '_' or '/'
+ * @param val
+ *   The number 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_uint(struct rte_tel_data *d,
+		const char *name, uint64_t val);
+
+ /**
  * Add a uint64_t value to a dictionary.
  * The dict must have been started by rte_tel_data_start_dict().
  *
lib/telemetry/telemetry.c +8 -8
index 916a0a4604..89bdde8422 100644
@@ -167,16 +167,16 @@ 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 != TEL_DICT && d->type != TEL_ARRAY_U64 &&
+	if (d->type != TEL_DICT && d->type != TEL_ARRAY_UINT &&
 		d->type != TEL_ARRAY_INT && d->type != TEL_ARRAY_STRING)
 		return snprintf(out_buf, buf_len, "null");
 
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
-	if (d->type == TEL_ARRAY_U64)
+	if (d->type == TEL_ARRAY_UINT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_u64(out_buf,
 				buf_len, used,
-				d->data.array[i].u64val);
+				d->data.array[i].uval);
 	if (d->type == TEL_ARRAY_INT)
 		for (i = 0; i < d->data_len; i++)
 			used = rte_tel_json_add_array_int(out_buf,
@@ -204,7 +204,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(out_buf,
 						buf_len, used,
-						v->name, v->value.u64val);
+						v->name, v->value.uval);
 				break;
 			case RTE_TEL_CONTAINER:
 			{
@@ -271,7 +271,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 			case RTE_TEL_UINT_VAL:
 				used = rte_tel_json_add_obj_u64(cb_data_buf,
 						buf_len, used,
-						v->name, v->value.u64val);
+						v->name, v->value.uval);
 				break;
 			case RTE_TEL_CONTAINER:
 			{
@@ -293,7 +293,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 
 	case TEL_ARRAY_STRING:
 	case TEL_ARRAY_INT:
-	case TEL_ARRAY_U64:
+	case TEL_ARRAY_UINT:
 	case TEL_ARRAY_CONTAINER:
 		used = rte_tel_json_empty_array(cb_data_buf, buf_len, 0);
 		for (i = 0; i < d->data_len; i++)
@@ -306,10 +306,10 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 				used = rte_tel_json_add_array_int(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].ival);
-			else if (d->type == TEL_ARRAY_U64)
+			else if (d->type == TEL_ARRAY_UINT)
 				used = rte_tel_json_add_array_u64(cb_data_buf,
 						buf_len, used,
-						d->data.array[i].u64val);
+						d->data.array[i].uval);
 			else if (d->type == TEL_ARRAY_CONTAINER) {
 				char temp[buf_len];
 				const struct container *rec_data =
lib/telemetry/telemetry_data.c +20 -8
index d4345908d5..9a180937fd 100644
@@ -18,7 +18,7 @@ rte_tel_data_start_array(struct rte_tel_data *d, enum rte_tel_value_type type)
 	enum tel_container_types array_types[] = {
 			[RTE_TEL_STRING_VAL] = TEL_ARRAY_STRING,
 			[RTE_TEL_INT_VAL] = TEL_ARRAY_INT,
-			[RTE_TEL_UINT_VAL] = TEL_ARRAY_U64,
+			[RTE_TEL_UINT_VAL] = TEL_ARRAY_UINT,
 			[RTE_TEL_CONTAINER] = TEL_ARRAY_CONTAINER,
 	};
 	d->type = array_types[type];
@@ -70,22 +70,28 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 }
 
 int
-rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
+rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x)
 {
-	if (d->type != TEL_ARRAY_U64)
+	if (d->type != TEL_ARRAY_UINT)
 		return -EINVAL;
 	if (d->data_len >= RTE_TEL_MAX_ARRAY_ENTRIES)
 		return -ENOSPC;
-	d->data.array[d->data_len++].u64val = x;
+	d->data.array[d->data_len++].uval = x;
 	return 0;
 }
 
+int
+rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
+{
+	return rte_tel_data_add_array_uint(d, x);
+}
+
 int
 rte_tel_data_add_array_container(struct rte_tel_data *d,
 		struct rte_tel_data *val, int keep)
 {
 	if (d->type != TEL_ARRAY_CONTAINER ||
-			(val->type != TEL_ARRAY_U64
+			(val->type != TEL_ARRAY_UINT
 			&& val->type != TEL_ARRAY_INT
 			&& val->type != TEL_ARRAY_STRING))
 		return -EINVAL;
@@ -160,7 +166,7 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
 }
 
 int
-rte_tel_data_add_dict_u64(struct rte_tel_data *d,
+rte_tel_data_add_dict_uint(struct rte_tel_data *d,
 		const char *name, uint64_t val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
@@ -174,18 +180,24 @@ rte_tel_data_add_dict_u64(struct rte_tel_data *d,
 
 	d->data_len++;
 	e->type = RTE_TEL_UINT_VAL;
-	e->value.u64val = val;
+	e->value.uval = val;
 	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_u64(struct rte_tel_data *d, const char *name, uint64_t val)
+{
+	return rte_tel_data_add_dict_uint(d, name, val);
+}
+
 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 != TEL_DICT || (val->type != TEL_ARRAY_U64
+	if (d->type != TEL_DICT || (val->type != TEL_ARRAY_UINT
 			&& val->type != TEL_ARRAY_INT
 			&& val->type != TEL_ARRAY_STRING
 			&& val->type != TEL_DICT))
lib/telemetry/telemetry_data.h +2 -2
index 79c916bd7e..8db6875a81 100644
@@ -13,7 +13,7 @@ enum tel_container_types {
 	TEL_DICT,            /** name-value pairs, of individual value type */
 	TEL_ARRAY_STRING,    /** array of string values only */
 	TEL_ARRAY_INT,       /** array of signed, 32-bit int values */
-	TEL_ARRAY_U64,      /** array of unsigned 64-bit int values */
+	TEL_ARRAY_UINT,      /** array of unsigned 64-bit int values */
 	TEL_ARRAY_CONTAINER, /** array of container structs */
 };
 
@@ -29,7 +29,7 @@ struct container {
 union tel_value {
 	char sval[RTE_TEL_MAX_STRING_LEN];
 	int ival;
-	uint64_t u64val;
+	uint64_t uval;
 	struct container container;
 };
 
lib/telemetry/version.map +7 -0
index 9794f9ea20..0f70d82dfc 100644
@@ -19,6 +19,13 @@ DPDK_23 {
 	local: *;
 };
 
+EXPERIMENTAL {
+	global:
+
+	rte_tel_data_add_array_uint;
+	rte_tel_data_add_dict_uint;
+};
+
 INTERNAL {
 	rte_telemetry_legacy_register;
 	rte_telemetry_init;
Signature · 1 line
2.37.2
#43 lore raw

PATCH v3 5/9 global: rename telemetry functions to newer versions

In reply to Bruce Richardson

Within the DPDK code-base, replace all occurences of "rte_tel_data_add_array_u64" with "rte_tel_data_add_array_uint", and similarly replace all occurences of "rte_tel_data_add_dict_u64" with "rte_tel_data_add_dict_uint". This allows us to later mark the older functions as deprecated without hitting warnings.

---
 app/test/test_telemetry_data.c               | 12 ++--
 drivers/common/cnxk/roc_platform.h           |  4 +-
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c | 20 +++---
 drivers/net/cnxk/cnxk_ethdev_telemetry.c     |  4 +-
 examples/ipsec-secgw/ipsec-secgw.c           | 72 +++++++++-----------
 examples/l3fwd-power/main.c                  |  4 +-
 lib/cryptodev/rte_cryptodev.c                |  4 +-
 lib/dmadev/rte_dmadev.c                      |  2 +-
 lib/eal/common/eal_common_memory.c           | 19 +++---
 lib/ethdev/rte_ethdev.c                      | 10 +--
 lib/eventdev/rte_event_eth_rx_adapter.c      | 22 +++---
 lib/eventdev/rte_event_timer_adapter.c       | 38 +++++++----
 lib/eventdev/rte_eventdev.c                  |  5 +-
 lib/ipsec/ipsec_telemetry.c                  | 31 +++++----
 lib/rawdev/rte_rawdev.c                      |  4 +-
 lib/security/rte_security.c                  |  4 +-
 16 files changed, 130 insertions(+), 125 deletions(-)
app/test/test_telemetry_data.c +6 -6
index 24a2035b61..b00c148a57 100644
@@ -285,7 +285,7 @@ test_case_array_u64(void)
 
 	rte_tel_data_start_array(&response_data, RTE_TEL_UINT_VAL);
 	for (i = 0; i < 5; i++)
-		rte_tel_data_add_array_u64(&response_data, i);
+		rte_tel_data_add_array_uint(&response_data, i);
 	return CHECK_OUTPUT("[0,1,2,3,4]");
 }
 
@@ -299,7 +299,7 @@ test_case_add_dict_u64(void)
 
 	for (i = 0; i < 5; i++) {
 		sprintf(name_of_value, "dict_%d", i);
-		rte_tel_data_add_dict_u64(&response_data, name_of_value, i);
+		rte_tel_data_add_dict_uint(&response_data, name_of_value, i);
 	}
 	return CHECK_OUTPUT("{\"dict_0\":0,\"dict_1\":1,\"dict_2\":2,\"dict_3\":3,\"dict_4\":4}");
 }
@@ -318,8 +318,8 @@ test_dict_with_array_u64_values(void)
 	rte_tel_data_start_dict(&response_data);
 
 	for (i = 0; i < 10; i++) {
-		rte_tel_data_add_array_u64(child_data, i);
-		rte_tel_data_add_array_u64(child_data2, i);
+		rte_tel_data_add_array_uint(child_data, i);
+		rte_tel_data_add_array_uint(child_data2, i);
 	}
 
 	rte_tel_data_add_dict_container(&response_data, "dict_0",
@@ -344,8 +344,8 @@ test_array_with_array_u64_values(void)
 	rte_tel_data_start_array(&response_data, RTE_TEL_CONTAINER);
 
 	for (i = 0; i < 5; i++) {
-		rte_tel_data_add_array_u64(child_data, i);
-		rte_tel_data_add_array_u64(child_data2, i);
+		rte_tel_data_add_array_uint(child_data, i);
+		rte_tel_data_add_array_uint(child_data2, i);
 	}
 	rte_tel_data_add_array_container(&response_data, child_data, 0);
 	rte_tel_data_add_array_container(&response_data, child_data2, 0);
drivers/common/cnxk/roc_platform.h +2 -2
index 1a48ff3db4..c151a3cc8e 100644
@@ -224,9 +224,9 @@
 #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)
+	rte_tel_data_add_dict_uint(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_tel_data_add_dict_u64    rte_tel_data_add_dict_uint
 #define plt_telemetry_register_cmd   rte_telemetry_register_cmd
 
 /* Log */
drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c +10 -10
index 59f0cce5ab..386278cfc9 100644
@@ -53,10 +53,10 @@ copy_inb_sa_9k(struct rte_tel_data *d, uint32_t i, void *sa)
 	rte_tel_data_add_dict_string(d, str, strw0);
 
 	snprintf(str, sizeof(str), "insa_esnh_%u", i);
-	rte_tel_data_add_dict_u64(d, str, in_sa->common_sa.seq_t.th);
+	rte_tel_data_add_dict_uint(d, str, in_sa->common_sa.seq_t.th);
 
 	snprintf(str, sizeof(str), "insa_esnl_%u", i);
-	rte_tel_data_add_dict_u64(d, str, in_sa->common_sa.seq_t.tl);
+	rte_tel_data_add_dict_uint(d, str, in_sa->common_sa.seq_t.tl);
 
 	return 0;
 }
@@ -97,12 +97,12 @@ copy_outb_sa_10k(struct rte_tel_data *d, uint32_t i, void *sa)
 	rte_tel_data_start_array(outer_hdr, RTE_TEL_UINT_VAL);
 
 	for (j = 0; j < RTE_DIM(out_sa->outer_hdr.ipv6.src_addr); j++)
-		rte_tel_data_add_array_u64(outer_hdr,
-					   out_sa->outer_hdr.ipv6.src_addr[j]);
+		rte_tel_data_add_array_uint(outer_hdr,
+					    out_sa->outer_hdr.ipv6.src_addr[j]);
 
 	for (j = 0; j < RTE_DIM(out_sa->outer_hdr.ipv6.dst_addr); j++)
-		rte_tel_data_add_array_u64(outer_hdr,
-					   out_sa->outer_hdr.ipv6.dst_addr[j]);
+		rte_tel_data_add_array_uint(outer_hdr,
+					    out_sa->outer_hdr.ipv6.dst_addr[j]);
 
 	snprintf(str, sizeof(str), "outsa_outer_hdr_%u", i);
 	rte_tel_data_add_dict_container(d, str, outer_hdr, 0);
@@ -170,12 +170,12 @@ copy_inb_sa_10k(struct rte_tel_data *d, uint32_t i, void *sa)
 	rte_tel_data_start_array(outer_hdr, RTE_TEL_UINT_VAL);
 
 	for (j = 0; j < RTE_DIM(in_sa->outer_hdr.ipv6.src_addr); j++)
-		rte_tel_data_add_array_u64(outer_hdr,
-					   in_sa->outer_hdr.ipv6.src_addr[j]);
+		rte_tel_data_add_array_uint(outer_hdr,
+					    in_sa->outer_hdr.ipv6.src_addr[j]);
 
 	for (j = 0; j < RTE_DIM(in_sa->outer_hdr.ipv6.dst_addr); j++)
-		rte_tel_data_add_array_u64(outer_hdr,
-					   in_sa->outer_hdr.ipv6.dst_addr[j]);
+		rte_tel_data_add_array_uint(outer_hdr,
+					    in_sa->outer_hdr.ipv6.dst_addr[j]);
 
 	snprintf(str, sizeof(str), "insa_outer_hdr_%u", i);
 	rte_tel_data_add_dict_container(d, str, outer_hdr, 0);
drivers/net/cnxk/cnxk_ethdev_telemetry.c +2 -2
index 5db973d620..3027ca4735 100644
@@ -80,8 +80,8 @@ ethdev_tel_handle_info(const char *cmd __rte_unused,
 			}
 
 			for (j = 0; j < ETH_INFO_SZ; j++)
-				rte_tel_data_add_array_u64(i_data,
-							   eth_info.val[j]);
+				rte_tel_data_add_array_uint(i_data,
+							    eth_info.val[j]);
 
 			j++;
 		}
examples/ipsec-secgw/ipsec-secgw.c +34 -38

122 lines not on this page · raw message

examples/l3fwd-power/main.c +2 -2
index fd3ade330f..caf26b373e 100644
@@ -2555,8 +2555,8 @@ handle_app_stats(const char *cmd __rte_unused,
 	rte_tel_data_start_dict(d);
 	get_current_stat_values(values);
 	for (i = 0; i < NUM_TELSTATS; i++)
-		rte_tel_data_add_dict_u64(d, telstats_strings[i].name,
-				values[i]);
+		rte_tel_data_add_dict_uint(d, telstats_strings[i].name,
+					   values[i]);
 	return 0;
 }
 
lib/cryptodev/rte_cryptodev.c +2 -2
index 79ea958db4..bc53aab100 100644
@@ -2698,7 +2698,7 @@ cryptodev_handle_dev_info(const char *cmd __rte_unused,
 	return 0;
 }
 
-#define ADD_DICT_STAT(s) rte_tel_data_add_dict_u64(d, #s, cryptodev_stats.s)
+#define ADD_DICT_STAT(s) rte_tel_data_add_dict_uint(d, #s, cryptodev_stats.s)
 
 static int
 cryptodev_handle_dev_stats(const char *cmd __rte_unused,
@@ -2751,7 +2751,7 @@ crypto_caps_array(struct rte_tel_data *d,
 		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]);
+			rte_tel_data_add_array_uint(d, caps_val[j]);
 	}
 
 	return i;
lib/dmadev/rte_dmadev.c +1 -1
index 4da653eec7..8c095e1f35 100644
@@ -944,7 +944,7 @@ dmadev_handle_dev_info(const char *cmd __rte_unused,
 	return 0;
 }
 
-#define ADD_DICT_STAT(s) rte_tel_data_add_dict_u64(d, #s, dma_stats.s)
+#define ADD_DICT_STAT(s) rte_tel_data_add_dict_uint(d, #s, dma_stats.s)
 
 static int
 dmadev_handle_dev_stats(const char *cmd __rte_unused,
lib/eal/common/eal_common_memory.c +10 -9
index 688dc615d7..3d2fc8e98b 100644
@@ -1141,15 +1141,16 @@ handle_eal_heap_info_request(const char *cmd __rte_unused, const char *params,
 	rte_tel_data_start_dict(d);
 	rte_tel_data_add_dict_int(d, "Head id", heap_id);
 	rte_tel_data_add_dict_string(d, "Name", heap->name);
-	rte_tel_data_add_dict_u64(d, "Heap_size",
-				  sock_stats.heap_totalsz_bytes);
-	rte_tel_data_add_dict_u64(d, "Free_size", sock_stats.heap_freesz_bytes);
-	rte_tel_data_add_dict_u64(d, "Alloc_size",
-				  sock_stats.heap_allocsz_bytes);
-	rte_tel_data_add_dict_u64(d, "Greatest_free_size",
-				  sock_stats.greatest_free_size);
-	rte_tel_data_add_dict_u64(d, "Alloc_count", sock_stats.alloc_count);
-	rte_tel_data_add_dict_u64(d, "Free_count", sock_stats.free_count);
+	rte_tel_data_add_dict_uint(d, "Heap_size",
+				   sock_stats.heap_totalsz_bytes);
+	rte_tel_data_add_dict_uint(d, "Free_size",
+				   sock_stats.heap_freesz_bytes);
+	rte_tel_data_add_dict_uint(d, "Alloc_size",
+				   sock_stats.heap_allocsz_bytes);
+	rte_tel_data_add_dict_uint(d, "Greatest_free_size",
+				   sock_stats.greatest_free_size);
+	rte_tel_data_add_dict_uint(d, "Alloc_count", sock_stats.alloc_count);
+	rte_tel_data_add_dict_uint(d, "Free_count", sock_stats.free_count);
 
 	return 0;
 }
lib/ethdev/rte_ethdev.c +5 -5
index 28028e5de5..4dd2968a01 100644
@@ -5820,11 +5820,11 @@ eth_dev_add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats,
 		return;
 	rte_tel_data_start_array(q_data, RTE_TEL_UINT_VAL);
 	for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++)
-		rte_tel_data_add_array_u64(q_data, q_stats[q]);
+		rte_tel_data_add_array_uint(q_data, q_stats[q]);
 	rte_tel_data_add_dict_container(d, stat_name, q_data, 0);
 }
 
-#define ADD_DICT_STAT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
+#define ADD_DICT_STAT(stats, s) rte_tel_data_add_dict_uint(d, #s, stats.s)
 
 static int
 eth_dev_handle_port_stats(const char *cmd __rte_unused,
@@ -5909,8 +5909,8 @@ eth_dev_handle_port_xstats(const char *cmd __rte_unused,
 
 	rte_tel_data_start_dict(d);
 	for (i = 0; i < num_xstats; i++)
-		rte_tel_data_add_dict_u64(d, xstat_names[i].name,
-				eth_xstats[i].value);
+		rte_tel_data_add_dict_uint(d, xstat_names[i].name,
+					   eth_xstats[i].value);
 	free(eth_xstats);
 	return 0;
 }
@@ -5987,7 +5987,7 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused,
 		return 0;
 	}
 	rte_tel_data_add_dict_string(d, status_str, "UP");
-	rte_tel_data_add_dict_u64(d, "speed", link.link_speed);
+	rte_tel_data_add_dict_uint(d, "speed", link.link_speed);
 	rte_tel_data_add_dict_string(d, "duplex",
 			(link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX) ?
 				"full-duplex" : "half-duplex");
lib/eventdev/rte_event_eth_rx_adapter.c +11 -11
index cf7bbd4d69..13d7163b79 100644
@@ -3433,7 +3433,7 @@ rte_event_eth_rx_adapter_instance_get(uint16_t eth_dev_id,
 	return -EINVAL;
 }
 
-#define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_u64(d, #s, stats.s)
+#define RXA_ADD_DICT(stats, s) rte_tel_data_add_dict_uint(d, #s, stats.s)
 
 static int
 handle_rxa_stats(const char *cmd __rte_unused,
@@ -3458,7 +3458,7 @@ handle_rxa_stats(const char *cmd __rte_unused,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "rx_adapter_id", rx_adapter_id);
+	rte_tel_data_add_dict_uint(d, "rx_adapter_id", rx_adapter_id);
 	RXA_ADD_DICT(rx_adptr_stats, rx_packets);
 	RXA_ADD_DICT(rx_adptr_stats, rx_poll_count);
 	RXA_ADD_DICT(rx_adptr_stats, rx_dropped);
@@ -3552,9 +3552,9 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "rx_adapter_id", rx_adapter_id);
-	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
-	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_uint(d, "rx_adapter_id", rx_adapter_id);
+	rte_tel_data_add_dict_uint(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_uint(d, "rx_queue_id", rx_queue_id);
 	RXA_ADD_DICT(queue_conf, rx_queue_flags);
 	RXA_ADD_DICT(queue_conf, servicing_weight);
 	RXA_ADD_DICT(queue_conf.ev, queue_id);
@@ -3624,9 +3624,9 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "rx_adapter_id", rx_adapter_id);
-	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
-	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_uint(d, "rx_adapter_id", rx_adapter_id);
+	rte_tel_data_add_dict_uint(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_uint(d, "rx_queue_id", rx_queue_id);
 	RXA_ADD_DICT(q_stats, rx_event_buf_count);
 	RXA_ADD_DICT(q_stats, rx_event_buf_size);
 	RXA_ADD_DICT(q_stats, rx_poll_count);
@@ -3752,9 +3752,9 @@ handle_rxa_instance_get(const char *cmd __rte_unused,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
-	rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
-	rte_tel_data_add_dict_u64(d, "rxa_instance_id", instance_id);
+	rte_tel_data_add_dict_uint(d, "eth_dev_id", eth_dev_id);
+	rte_tel_data_add_dict_uint(d, "rx_queue_id", rx_queue_id);
+	rte_tel_data_add_dict_uint(d, "rxa_instance_id", instance_id);
 
 	return 0;
 
lib/eventdev/rte_event_timer_adapter.c +23 -15
index a0f14bf861..1c3f91605a 100644
@@ -1316,15 +1316,20 @@ handle_ta_info(const char *cmd __rte_unused, const char *params,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "timer_adapter_id", adapter_id);
-	rte_tel_data_add_dict_u64(d, "min_resolution_ns", adapter_info.min_resolution_ns);
-	rte_tel_data_add_dict_u64(d, "max_tmo_ns", adapter_info.max_tmo_ns);
-	rte_tel_data_add_dict_u64(d, "event_dev_id", adapter_info.conf.event_dev_id);
-	rte_tel_data_add_dict_u64(d, "socket_id", adapter_info.conf.socket_id);
-	rte_tel_data_add_dict_u64(d, "clk_src", adapter_info.conf.clk_src);
-	rte_tel_data_add_dict_u64(d, "timer_tick_ns", adapter_info.conf.timer_tick_ns);
-	rte_tel_data_add_dict_u64(d, "nb_timers", adapter_info.conf.nb_timers);
-	rte_tel_data_add_dict_u64(d, "flags", adapter_info.conf.flags);
+	rte_tel_data_add_dict_uint(d, "timer_adapter_id", adapter_id);
+	rte_tel_data_add_dict_uint(d, "min_resolution_ns",
+				   adapter_info.min_resolution_ns);
+	rte_tel_data_add_dict_uint(d, "max_tmo_ns", adapter_info.max_tmo_ns);
+	rte_tel_data_add_dict_uint(d, "event_dev_id",
+				   adapter_info.conf.event_dev_id);
+	rte_tel_data_add_dict_uint(d, "socket_id",
+				   adapter_info.conf.socket_id);
+	rte_tel_data_add_dict_uint(d, "clk_src", adapter_info.conf.clk_src);
+	rte_tel_data_add_dict_uint(d, "timer_tick_ns",
+				   adapter_info.conf.timer_tick_ns);
+	rte_tel_data_add_dict_uint(d, "nb_timers",
+				   adapter_info.conf.nb_timers);
+	rte_tel_data_add_dict_uint(d, "flags", adapter_info.conf.flags);
 
 	return 0;
 }
@@ -1357,12 +1362,15 @@ handle_ta_stats(const char *cmd __rte_unused, const char *params,
 	}
 
 	rte_tel_data_start_dict(d);
-	rte_tel_data_add_dict_u64(d, "timer_adapter_id", adapter_id);
-	rte_tel_data_add_dict_u64(d, "evtim_exp_count", stats.evtim_exp_count);
-	rte_tel_data_add_dict_u64(d, "ev_enq_count", stats.ev_enq_count);
-	rte_tel_data_add_dict_u64(d, "ev_inv_count", stats.ev_inv_count);
-	rte_tel_data_add_dict_u64(d, "evtim_retry_count", stats.evtim_retry_count);
-	rte_tel_data_add_dict_u64(d, "adapter_tick_count", stats.adapter_tick_count);
+	rte_tel_data_add_dict_uint(d, "timer_adapter_id", adapter_id);
+	rte_tel_data_add_dict_uint(d, "evtim_exp_count",
+				   stats.evtim_exp_count);
+	rte_tel_data_add_dict_uint(d, "ev_enq_count", stats.ev_enq_count);
+	rte_tel_data_add_dict_uint(d, "ev_inv_count", stats.ev_inv_count);
+	rte_tel_data_add_dict_uint(d, "evtim_retry_count",
+				   stats.evtim_retry_count);
+	rte_tel_data_add_dict_uint(d, "adapter_tick_count",
+				   stats.adapter_tick_count);
 
 	return 0;
 }
lib/eventdev/rte_eventdev.c +2 -3
index b0414206d9..027e6a93ce 100644
@@ -1645,7 +1645,7 @@ handle_queue_links(const char *cmd __rte_unused,
 		char qid_name[32];
 
 		snprintf(qid_name, 31, "qid_%u", queues[i]);
-		rte_tel_data_add_dict_u64(d, qid_name, priorities[i]);
+		rte_tel_data_add_dict_uint(d, qid_name, priorities[i]);
 	}
 
 	return 0;
@@ -1711,8 +1711,7 @@ eventdev_build_telemetry_data(int dev_id,
 
 	rte_tel_data_start_dict(d);
 	for (i = 0; i < num_xstats; i++)
-		rte_tel_data_add_dict_u64(d, xstat_names[i].name,
-					  values[i]);
+		rte_tel_data_add_dict_uint(d, xstat_names[i].name, values[i]);
 
 	free(xstat_names);
 	free(ids);
lib/ipsec/ipsec_telemetry.c +16 -15
index b184e8df99..90d4b67156 100644
@@ -26,7 +26,7 @@ handle_telemetry_cmd_ipsec_sa_list(const char *cmd __rte_unused,
 
 	LIST_FOREACH(entry, &ipsec_telemetry_list, next) {
 		const struct rte_ipsec_sa *sa = entry->sa;
-		rte_tel_data_add_array_u64(data, rte_be_to_cpu_32(sa->spi));
+		rte_tel_data_add_array_uint(data, rte_be_to_cpu_32(sa->spi));
 	}
 
 	return 0;
@@ -80,15 +80,15 @@ handle_telemetry_cmd_ipsec_sa_stats(const char *cmd __rte_unused,
 		rte_tel_data_start_dict(sa_data);
 
 		/* add telemetry key/values pairs */
-		rte_tel_data_add_dict_u64(sa_data, name_pkt_cnt,
-					sa->statistics.count);
+		rte_tel_data_add_dict_uint(sa_data, name_pkt_cnt,
+					   sa->statistics.count);
 
-		rte_tel_data_add_dict_u64(sa_data, name_byte_cnt,
-					sa->statistics.bytes -
-					(sa->statistics.count * sa->hdr_len));
+		rte_tel_data_add_dict_uint(sa_data, name_byte_cnt,
+					   sa->statistics.bytes -
+					   (sa->statistics.count * sa->hdr_len));
 
-		rte_tel_data_add_dict_u64(sa_data, name_error_cnt,
-					sa->statistics.errors.count);
+		rte_tel_data_add_dict_uint(sa_data, name_error_cnt,
+					   sa->statistics.errors.count);
 
 		/* generate telemetry label */
 		snprintf(sa_name, sizeof(sa_name), "SA_SPI_%i",
@@ -177,15 +177,16 @@ handle_telemetry_cmd_ipsec_sa_details(const char *cmd __rte_unused,
 			RTE_IPSEC_SATP_DIR_IB)
 
 			if (sa->sqn.inb.rsn[sa->sqn.inb.rdidx])
-				rte_tel_data_add_dict_u64(data,
-				"sequence-number",
-				sa->sqn.inb.rsn[sa->sqn.inb.rdidx]->sqn);
+				rte_tel_data_add_dict_uint(data,
+							   "sequence-number",
+							   sa->sqn.inb.rsn[sa->sqn.inb.rdidx]->sqn);
 			else
-				rte_tel_data_add_dict_u64(data,
-					"sequence-number", 0);
+				rte_tel_data_add_dict_uint(data,
+							   "sequence-number",
+							   0);
 		else
-			rte_tel_data_add_dict_u64(data, "sequence-number",
-					sa->sqn.outb);
+			rte_tel_data_add_dict_uint(data, "sequence-number",
+						   sa->sqn.outb);
 
 		rte_tel_data_add_dict_string(data,
 				"explicit-congestion-notification",
lib/rawdev/rte_rawdev.c +2 -2
index 5fbdb94229..dacaa60e22 100644
@@ -631,8 +631,8 @@ handle_dev_xstats(const char *cmd __rte_unused,
 
 	rte_tel_data_start_dict(d);
 	for (i = 0; i < num_xstats; i++)
-		rte_tel_data_add_dict_u64(d, xstat_names[i].name,
-				rawdev_xstats[i]);
+		rte_tel_data_add_dict_uint(d, xstat_names[i].name,
+					   rawdev_xstats[i]);
 
 	free(rawdev_xstats);
 	return 0;
lib/security/rte_security.c +2 -2
index 68063f6450..e102c55e55 100644
@@ -323,7 +323,7 @@ crypto_caps_array(struct rte_tel_data *d,
 		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]);
+			rte_tel_data_add_array_uint(d, caps_val[j]);
 	}
 
 	return (i - 1);
@@ -348,7 +348,7 @@ sec_caps_array(struct rte_tel_data *d,
 		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]);
+			rte_tel_data_add_array_uint(d, caps_val[j]);
 	}
 
 	return i - 1;
Signature · 1 line
2.37.2
#44 lore raw

PATCH v3 6/9 telemetry: mark old names of renamed fns as deprecated

In reply to Bruce Richardson

Add a deprecation notice for the renaming of the telemetry data u64/uint functions, and point users to the newer versions of them when building. To do this, we also need to mark the renamed versions as stable, rather than experimental.

---
Note: This patch adds the deprecation macro *after* the function prototype rather than before, as adding it before - as with the experimental tag - causes doxygen to get confused and give errors:

.../lib/telemetry/rte_telemetry.h:141: warning: argument 'd' of command @param is not found in the argument list of __rte_deprecated_msg("use 'rte_tel_data_add_array_uint' instead") .../lib/telemetry/rte_telemetry.h:141: warning: argument 'x' of command @param is not found in the argument list of __rte_deprecated_msg("use 'rte_tel_data_add_array_uint' instead")

---
 doc/guides/rel_notes/deprecation.rst |  5 +++++
 lib/telemetry/rte_telemetry.h        | 10 +++++-----
 lib/telemetry/version.map            |  9 ++-------
 3 files changed, 12 insertions(+), 12 deletions(-)
doc/guides/rel_notes/deprecation.rst +5 -0
index b9b02dcef0..98ad6baed5 100644
@@ -11,6 +11,11 @@ here.
 Deprecation Notices
 -------------------
 
+* telemetry: The functions ``rte_tel_data_add_array_u64`` and ``rte_tel_data_add_dict_u64``,
+  used by telemetry callbacks for adding unsigned integer values to be returned to the user,
+  are renamed to ``rte_tel_data_add_array_uint`` and ``rte_tel_data_add_dict_uint`` respectively.
+  As such, the old function names are deprecated and will be removed in a future release.
+
 * kvargs: The function ``rte_kvargs_process`` will get a new parameter
   for returning key match count. It will ease handling of no-match case.
 
lib/telemetry/rte_telemetry.h +5 -5
index 73a0511807..4598303d5d 100644
@@ -8,7 +8,7 @@
 #ifndef _RTE_TELEMETRY_H_
 #define _RTE_TELEMETRY_H_
 
-#include <rte_compat.h>
+#include <rte_common.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -134,7 +134,6 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
  * @return
  *   0 on success, negative errno on error
  */
-__rte_experimental
 int
 rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
 
@@ -151,7 +150,8 @@ rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x);
  *   0 on success, negative errno on error
  */
 int
-rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x);
+rte_tel_data_add_array_u64(struct rte_tel_data *d, uint64_t x)
+	__rte_deprecated_msg("use 'rte_tel_data_add_array_uint' instead");
 
 /**
  * Add a container to an array. A container is an existing telemetry data
@@ -224,7 +224,6 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
  * @return
  *   0 on success, negative errno on error, E2BIG on string truncation of name.
  */
-__rte_experimental
 int
 rte_tel_data_add_dict_uint(struct rte_tel_data *d,
 		const char *name, uint64_t val);
@@ -245,7 +244,8 @@ rte_tel_data_add_dict_uint(struct rte_tel_data *d,
  */
 int
 rte_tel_data_add_dict_u64(struct rte_tel_data *d,
-		const char *name, uint64_t val);
+		const char *name, uint64_t val)
+	__rte_deprecated_msg("use 'rte_tel_data_add_dict_uint' instead");
 
 /**
  * Add a container to a dictionary. A container is an existing telemetry data
lib/telemetry/version.map +2 -7
index 0f70d82dfc..d661180317 100644
@@ -5,10 +5,12 @@ DPDK_23 {
 	rte_tel_data_add_array_int;
 	rte_tel_data_add_array_string;
 	rte_tel_data_add_array_u64;
+	rte_tel_data_add_array_uint;
 	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_uint;
 	rte_tel_data_alloc;
 	rte_tel_data_free;
 	rte_tel_data_start_array;
@@ -19,13 +21,6 @@ DPDK_23 {
 	local: *;
 };
 
-EXPERIMENTAL {
-	global:
-
-	rte_tel_data_add_array_uint;
-	rte_tel_data_add_dict_uint;
-};
-
 INTERNAL {
 	rte_telemetry_legacy_register;
 	rte_telemetry_init;
Signature · 1 line
2.37.2
#45 lore raw

PATCH v3 7/9 telemetry: update json functions to use int/uint in names

In reply to Bruce Richardson

Since we are standardizing on using uint in place of u64, and expanding the int values to 64-bit, we can update the internal json functions to use the new names and expanded signed type.

---
 app/test/test_telemetry_json.c |  9 ++++-----
 lib/telemetry/telemetry.c      |  8 ++++----
 lib/telemetry/telemetry_json.h | 16 ++++++++--------
 3 files changed, 16 insertions(+), 17 deletions(-)
app/test/test_telemetry_json.c +4 -5
index 184c3ba9f1..e81e3a8a98 100644
@@ -37,9 +37,9 @@ test_basic_obj(void)
 	char buf[1024];
 	int used = 0;
 
-	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
+	used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used,
 		"weddings", 4);
-	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
+	used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used,
 		"funerals", 1);
 
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
@@ -80,8 +80,7 @@ test_overflow_obj(void)
 	int i, used = 0;
 
 	for (i = 0; i < (int)RTE_DIM(names); i++)
-		used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used,
-				names[i], vals[i]);
+		used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used, names[i], vals[i]);
 
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
 	if (buf[used - 1] != '}')
@@ -117,7 +116,7 @@ test_large_obj_element(void)
 	char buf[sizeof(str) - 5] = "XYZ";
 	int used = 0;
 
-	used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used, str, 0);
+	used = rte_tel_json_add_obj_uint(buf, sizeof(buf), used, str, 0);
 	printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected);
 	if (used != 0)
 		return -1;
lib/telemetry/telemetry.c +4 -4
index 89bdde8422..655191bcf1 100644
@@ -174,7 +174,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 	used = rte_tel_json_empty_array(out_buf, buf_len, 0);
 	if (d->type == TEL_ARRAY_UINT)
 		for (i = 0; i < d->data_len; i++)
-			used = rte_tel_json_add_array_u64(out_buf,
+			used = rte_tel_json_add_array_uint(out_buf,
 				buf_len, used,
 				d->data.array[i].uval);
 	if (d->type == TEL_ARRAY_INT)
@@ -202,7 +202,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len)
 						v->name, v->value.ival);
 				break;
 			case RTE_TEL_UINT_VAL:
-				used = rte_tel_json_add_obj_u64(out_buf,
+				used = rte_tel_json_add_obj_uint(out_buf,
 						buf_len, used,
 						v->name, v->value.uval);
 				break;
@@ -269,7 +269,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						v->name, v->value.ival);
 				break;
 			case RTE_TEL_UINT_VAL:
-				used = rte_tel_json_add_obj_u64(cb_data_buf,
+				used = rte_tel_json_add_obj_uint(cb_data_buf,
 						buf_len, used,
 						v->name, v->value.uval);
 				break;
@@ -307,7 +307,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
 						buf_len, used,
 						d->data.array[i].ival);
 			else if (d->type == TEL_ARRAY_UINT)
-				used = rte_tel_json_add_array_u64(cb_data_buf,
+				used = rte_tel_json_add_array_uint(cb_data_buf,
 						buf_len, used,
 						d->data.array[i].uval);
 			else if (d->type == TEL_ARRAY_CONTAINER) {
lib/telemetry/telemetry_json.h +8 -8
index e3fae7c30d..744bbfe053 100644
@@ -136,19 +136,19 @@ rte_tel_json_add_array_string(char *buf, const int len, const int used,
 
 /* Appends an integer into the JSON array in the provided buffer. */
 static inline int
-rte_tel_json_add_array_int(char *buf, const int len, const int used, int val)
+rte_tel_json_add_array_int(char *buf, const int len, const int used, int64_t val)
 {
 	int ret, end = used - 1; /* strip off final delimiter */
 	if (used <= 2) /* assume empty, since minimum is '[]' */
-		return __json_snprintf(buf, len, "[%d]", val);
+		return __json_snprintf(buf, len, "[%"PRId64"]", val);
 
-	ret = __json_snprintf(buf + end, len - end, ",%d]", val);
+	ret = __json_snprintf(buf + end, len - end, ",%"PRId64"]", val);
 	return ret == 0 ? used : end + ret;
 }
 
 /* Appends a uint64_t into the JSON array in the provided buffer. */
 static inline int
-rte_tel_json_add_array_u64(char *buf, const int len, const int used,
+rte_tel_json_add_array_uint(char *buf, const int len, const int used,
 		uint64_t val)
 {
 	int ret, end = used - 1; /* strip off final delimiter */
@@ -180,7 +180,7 @@ rte_tel_json_add_array_json(char *buf, const int len, const int used,
  * provided buffer.
  */
 static inline int
-rte_tel_json_add_obj_u64(char *buf, const int len, const int used,
+rte_tel_json_add_obj_uint(char *buf, const int len, const int used,
 		const char *name, uint64_t val)
 {
 	int ret, end = used - 1;
@@ -199,14 +199,14 @@ rte_tel_json_add_obj_u64(char *buf, const int len, const int used,
  */
 static inline int
 rte_tel_json_add_obj_int(char *buf, const int len, const int used,
-		const char *name, int val)
+		const char *name, int64_t val)
 {
 	int ret, end = used - 1;
 	if (used <= 2) /* assume empty, since minimum is '{}' */
-		return __json_snprintf(buf, len, "{\"%s\":%d}", name,
+		return __json_snprintf(buf, len, "{\"%s\":%"PRId64"}", name,
 				val);
 
-	ret = __json_snprintf(buf + end, len - end, ",\"%s\":%d}",
+	ret = __json_snprintf(buf + end, len - end, ",\"%s\":%"PRId64"}",
 			name, val);
 	return ret == 0 ? used : end + ret;
 }
Signature · 1 line
2.37.2
#46 lore raw

PATCH v3 8/9 telemetry: make internal int representation 64-bits

In reply to Bruce Richardson

The internal storage for int values can be expanded from 32-bit to 64-bit without affecting the external ABI.

---
 lib/telemetry/telemetry_data.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/telemetry/telemetry_data.h +1 -1
index 8db6875a81..205509c5a2 100644
@@ -28,7 +28,7 @@ struct container {
  */
 union tel_value {
 	char sval[RTE_TEL_MAX_STRING_LEN];
-	int ival;
+	int64_t ival;
 	uint64_t uval;
 	struct container container;
 };
Signature · 1 line
2.37.2
#47 lore raw

PATCH v3 9/9 telemetry: change public API to use 64-bit signed values

In reply to Bruce Richardson

While the unsigned values added to telemetry dicts/arrays were up to 64-bits in size, the sized values were only up to 32-bits. We can standardize the API by having both int and uint functions take 64-bit values. For ABI compatibility, we use function versioning to ensure older binaries can still use the older functions taking a 32-bit parameter.

---
 lib/telemetry/meson.build      |  1 +
 lib/telemetry/rte_telemetry.h  |  4 ++--
 lib/telemetry/telemetry_data.c | 33 +++++++++++++++++++++++++++++----
 lib/telemetry/telemetry_data.h |  6 ++++++
 lib/telemetry/version.map      |  7 +++++++
 5 files changed, 45 insertions(+), 6 deletions(-)
lib/telemetry/meson.build +1 -0
index f84c9aa3be..73750d9ef4 100644
@@ -6,3 +6,4 @@ includes = [global_inc]
 sources = files('telemetry.c', 'telemetry_data.c', 'telemetry_legacy.c')
 headers = files('rte_telemetry.h')
 includes += include_directories('../metrics')
+use_function_versioning = true
lib/telemetry/rte_telemetry.h +2 -2
index 4598303d5d..b481c112dd 100644
@@ -120,7 +120,7 @@ rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str);
  *   0 on success, negative errno on error
  */
 int
-rte_tel_data_add_array_int(struct rte_tel_data *d, int x);
+rte_tel_data_add_array_int(struct rte_tel_data *d, int64_t x);
 
 /**
  * Add an unsigned value to an array.
@@ -208,7 +208,7 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
  *   0 on success, negative errno on error, E2BIG on string truncation of name.
  */
 int
-rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val);
+rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int64_t val);
 
 /**
  * Add an unsigned value to a dictionary.
lib/telemetry/telemetry_data.c +29 -4
index 9a180937fd..ac7be795df 100644
@@ -8,6 +8,7 @@
 #undef RTE_USE_LIBBSD
 #include <stdbool.h>
 
+#include <rte_function_versioning.h>
 #include <rte_string_fns.h>
 
 #include "telemetry_data.h"
@@ -58,8 +59,8 @@ rte_tel_data_add_array_string(struct rte_tel_data *d, const char *str)
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
 }
 
-int
-rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
+int __vsym
+rte_tel_data_add_array_int_v24(struct rte_tel_data *d, int64_t x)
 {
 	if (d->type != TEL_ARRAY_INT)
 		return -EINVAL;
@@ -69,6 +70,18 @@ rte_tel_data_add_array_int(struct rte_tel_data *d, int x)
 	return 0;
 }
 
+int __vsym
+rte_tel_data_add_array_int_v23(struct rte_tel_data *d, int x)
+{
+	return rte_tel_data_add_array_int_v24(d, x);
+}
+
+/* mark the v23 function as the older version, and v24 as the default version */
+VERSION_SYMBOL(rte_tel_data_add_array_int, _v23, 23);
+BIND_DEFAULT_SYMBOL(rte_tel_data_add_array_int, _v24, 24);
+MAP_STATIC_SYMBOL(int rte_tel_data_add_array_int(struct rte_tel_data *d,
+		int64_t x), rte_tel_data_add_array_int_v24);
+
 int
 rte_tel_data_add_array_uint(struct rte_tel_data *d, uint64_t x)
 {
@@ -146,8 +159,8 @@ rte_tel_data_add_dict_string(struct rte_tel_data *d, const char *name,
 	return 0;
 }
 
-int
-rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
+int __vsym
+rte_tel_data_add_dict_int_v24(struct rte_tel_data *d, const char *name, int64_t val)
 {
 	struct tel_dict_entry *e = &d->data.dict[d->data_len];
 	if (d->type != TEL_DICT)
@@ -165,6 +178,18 @@ rte_tel_data_add_dict_int(struct rte_tel_data *d, const char *name, int val)
 	return bytes < RTE_TEL_MAX_STRING_LEN ? 0 : E2BIG;
 }
 
+int __vsym
+rte_tel_data_add_dict_int_v23(struct rte_tel_data *d, const char *name, int val)
+{
+	return rte_tel_data_add_dict_int_v24(d, name, val);
+}
+
+/* mark the v23 function as the older version, and v24 as the default version */
+VERSION_SYMBOL(rte_tel_data_add_dict_int, _v23, 23);
+BIND_DEFAULT_SYMBOL(rte_tel_data_add_dict_int, _v24, 24);
+MAP_STATIC_SYMBOL(int rte_tel_data_add_dict_int(struct rte_tel_data *d,
+		const char *name, int64_t val), rte_tel_data_add_dict_int_v24);
+
 int
 rte_tel_data_add_dict_uint(struct rte_tel_data *d,
 		const char *name, uint64_t val)
lib/telemetry/telemetry_data.h +6 -0
index 205509c5a2..53e4cabea5 100644
@@ -49,4 +49,10 @@ struct rte_tel_data {
 	} data; /* data container */
 };
 
+/* versioned functions */
+int rte_tel_data_add_array_int_v23(struct rte_tel_data *d, int val);
+int rte_tel_data_add_array_int_v24(struct rte_tel_data *d, int64_t val);
+int rte_tel_data_add_dict_int_v23(struct rte_tel_data *d, const char *name, int val);
+int rte_tel_data_add_dict_int_v24(struct rte_tel_data *d, const char *name, int64_t val);
+
 #endif
lib/telemetry/version.map +7 -0
index d661180317..accfad5011 100644
@@ -21,6 +21,13 @@ DPDK_23 {
 	local: *;
 };
 
+DPDK_24 {
+	global:
+
+	rte_tel_data_add_array_int;
+	rte_tel_data_add_dict_int;
+} DPDK_23;
+
 INTERNAL {
 	rte_telemetry_legacy_register;
 	rte_telemetry_init;
Signature · 1 line
2.37.2
#48 lore raw

Re: [PATCH v3 9/9] telemetry: change public API to use 64-bit signed values

12/01/2023 18:41, Bruce Richardson:

Quoted 2 lines

While the unsigned values added to telemetry dicts/arrays were up to 64-bits in size, the sized values were only up to 32-bits. We can

sized -> signed

Quoted 9 lines

standardize the API by having both int and uint functions take 64-bit values. For ABI compatibility, we use function versioning to ensure older binaries can still use the older functions taking a 32-bit parameter.

[...]

lib/telemetry/version.map DPDK_23 { · line 29

Quoted 8 lines
lib/telemetry/version.map +6 -0
+DPDK_24 {
+	global:
+
+	rte_tel_data_add_array_int;
+	rte_tel_data_add_dict_int;
+} DPDK_23;

For the record, these are the versioned symbols.

#49 lore raw
In reply to Bruce Richardson

Hi Bruce,

Quoted 85 lines

-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Thursday 12 January 2023 17:41
To: [email protected]
Cc: Richardson, Bruce <[email protected]>
Subject: [PATCH v3 0/9] Standardize telemetry int types

Rather than having 64-bit unsigned types and 32-bit signed types supported by the telemetry lib, we should support 64-bit values for both types. On the naming side, since both are 64-bit, we should no longer call the unsigned value u64 - "uint" is better.

This patchset implements these changes as far as is possible while still keeping API and ABI compatibility.

* Internal structures and functions are updated to use 64-bit ints
* Internal functions are renamed from u64 to uint
* Public enum values are renamed from u64 to uint, and a macro is added to ensure that older code still compiles
* The public add_*_int functions are changed to take a 64-bit value rather than a 32-bit one. Since this would be an ABI break, we use function versioning to ensure older code still calls into a wrapper function which takes a 32-bit value.

The patchset also contains a couple of other small cleanups to the telemetry code that were seen in passing when making these changes - removing RTE_ prefix on internal enums, and simplifying the init of the the array of data types.

NOTE: the renaming of the u64 functions to uint is split across 3 patches in this set - patches 4,5 and 6. This is to make it easier to review and to avoid warnings about new functions not being marked initially as experimental. Some/all of these 3 can be combined on merge if so desired.

V3:
- fix build issues due to missing a driver code change
- fix spelling issue flagged by checkpatch

V2:
- added additional patches to replace the old function calls within DPDK code, something missed in RFC version
- added new patch to make the renamed/new functions immediately public allowing us to mark the original named versions as deprecated
- re-ordered patches within the sit, so the extra cleanup changes come first

Bruce Richardson (9):
telemetry: remove RTE prefix from internal enum values
telemetry: make array initialization more robust
telemetry: rename unsigned 64-bit enum value to uint
telemetry: add uint type as alias for u64
global: rename telemetry functions to newer versions
telemetry: mark old names of renamed fns as deprecated
telemetry: update json functions to use int/uint in names
telemetry: make internal int representation 64-bits
telemetry: change public API to use 64-bit signed values

 app/test/test_telemetry_data.c               | 22 ++---
 app/test/test_telemetry_json.c               |  9 +-
 doc/guides/rel_notes/deprecation.rst         |  5 ++
 drivers/common/cnxk/roc_platform.h           |  4 +-
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c | 24 ++---
 drivers/net/cnxk/cnxk_ethdev_telemetry.c     |  6 +-
 examples/ipsec-secgw/ipsec-secgw.c           | 72 +++++++--------
 examples/l3fwd-power/main.c                  |  4 +-
 lib/cryptodev/rte_cryptodev.c                |  6 +-
 lib/dmadev/rte_dmadev.c                      |  2 +-
 lib/eal/common/eal_common_memory.c           | 19 ++--
 lib/ethdev/rte_ethdev.c                      | 12 +--
 lib/ethdev/sff_telemetry.c                   |  2 +-
 lib/eventdev/rte_event_eth_rx_adapter.c      | 22 ++---
 lib/eventdev/rte_event_timer_adapter.c       | 38 ++++----
 lib/eventdev/rte_eventdev.c                  |  5 +-
 lib/ipsec/ipsec_telemetry.c                  | 33 +++----
 lib/rawdev/rte_rawdev.c                      |  4 +-
 lib/security/rte_security.c                  |  8 +-
 lib/telemetry/meson.build                    |  1 +
 lib/telemetry/rte_telemetry.h                | 51 +++++++++--
 lib/telemetry/telemetry.c                    | 56 ++++++------
 lib/telemetry/telemetry_data.c               | 95 ++++++++++++++------
 lib/telemetry/telemetry_data.h               | 24 +++--
 lib/telemetry/telemetry_json.h               | 16 ++--
 lib/telemetry/version.map                    |  9 ++
 26 files changed, 325 insertions(+), 224 deletions(-)
Quoted 2 lines

--
2.37.2

#50 lore raw

13/01/2023 17:39, Power, Ciara:

Quoted 11 lines
Quoted 10 lines

Bruce Richardson (9):
telemetry: remove RTE prefix from internal enum values
telemetry: make array initialization more robust
telemetry: rename unsigned 64-bit enum value to uint
telemetry: add uint type as alias for u64
global: rename telemetry functions to newer versions
telemetry: mark old names of renamed fns as deprecated
telemetry: update json functions to use int/uint in names
telemetry: make internal int representation 64-bits
telemetry: change public API to use 64-bit signed values

Quoted 1 line

It required a bit of rebasing on top of Huisong's patches.

Applied, thanks.