DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: "Bruce Richardson" <bruce.richardson@intel.com>,
	"Morten Brørup" <mb@smartsharesystems.com>,
	"Tyler Retzlaff" <roretzla@linux.microsoft.com>,
	"Ciara Power" <ciara.power@intel.com>
Subject: [PATCH v2 4/9] telemetry: add uint type as alias for u64
Date: Thu, 12 Jan 2023 10:58:58 +0000	[thread overview]
Message-ID: <20230112105903.46341-5-bruce.richardson@intel.com> (raw)
In-Reply-To: <20230112105903.46341-1-bruce.richardson@intel.com>

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.

Suggested-by: Morten Brørup <mb@smartsharesystems.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

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

diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index c2ad65effe..73a0511807 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -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().
  *
diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 916a0a4604..89bdde8422 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -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 =
diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c
index d4345908d5..9a180937fd 100644
--- a/lib/telemetry/telemetry_data.c
+++ b/lib/telemetry/telemetry_data.c
@@ -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))
diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h
index 79c916bd7e..8db6875a81 100644
--- a/lib/telemetry/telemetry_data.h
+++ b/lib/telemetry/telemetry_data.h
@@ -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;
 };
 
diff --git a/lib/telemetry/version.map b/lib/telemetry/version.map
index 9794f9ea20..0f70d82dfc 100644
--- a/lib/telemetry/version.map
+++ b/lib/telemetry/version.map
@@ -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;
-- 
2.37.2


  parent reply	other threads:[~2023-01-12 10:59 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 18:27 [RFC PATCH 0/7] Standardize telemetry int types Bruce Richardson
2022-12-13 18:27 ` [RFC PATCH 1/7] telemetry: rename unsigned 64-bit enum value to uint Bruce Richardson
2022-12-14 17:30   ` Tyler Retzlaff
2022-12-15  9:41     ` Bruce Richardson
2022-12-15 17:53       ` Tyler Retzlaff
2022-12-13 18:27 ` [RFC PATCH 2/7] telemetry: add uint type as alias for u64 Bruce Richardson
2022-12-14 17:38   ` Tyler Retzlaff
2022-12-15  9:44     ` Bruce Richardson
2022-12-15 13:36       ` Thomas Monjalon
2022-12-15 13:58         ` Bruce Richardson
2022-12-19 10:37           ` Thomas Monjalon
2022-12-19 13:22             ` Bruce Richardson
2022-12-15 17:58       ` Tyler Retzlaff
2022-12-15  1:49   ` lihuisong (C)
2022-12-15  9:42     ` Bruce Richardson
2022-12-15 18:02       ` Tyler Retzlaff
2022-12-13 18:27 ` [RFC PATCH 3/7] telemetry: remove RTE prefix from internal enum values Bruce Richardson
2022-12-13 18:27 ` [RFC PATCH 4/7] telemetry: make array initialization more robust Bruce Richardson
2022-12-14 17:50   ` Tyler Retzlaff
2023-01-09 12:16     ` Bruce Richardson
2023-01-09 17:49       ` Tyler Retzlaff
2023-01-10  9:11         ` Ferruh Yigit
2022-12-13 18:27 ` [RFC PATCH 5/7] telemetry: update json functions to use int/uint in names Bruce Richardson
2022-12-13 18:27 ` [RFC PATCH 6/7] telemetry: make internal int representation 64-bits Bruce Richardson
2022-12-13 18:27 ` [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values Bruce Richardson
2022-12-13 20:19   ` Morten Brørup
2022-12-14 17:53     ` Tyler Retzlaff
2022-12-15  2:39       ` lihuisong (C)
2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson
2023-01-12 10:58   ` [PATCH v2 1/9] telemetry: remove RTE prefix from internal enum values Bruce Richardson
2023-01-12 10:58   ` [PATCH v2 2/9] telemetry: make array initialization more robust Bruce Richardson
2023-01-12 10:58   ` [PATCH v2 3/9] telemetry: rename unsigned 64-bit enum value to uint Bruce Richardson
2023-01-12 10:58   ` Bruce Richardson [this message]
2023-01-12 10:58   ` [PATCH v2 5/9] global: rename telemetry functions to newer versions Bruce Richardson
2023-01-12 10:59   ` [PATCH v2 6/9] telemetry: mark old names of renamed fns as deprecated Bruce Richardson
2023-01-12 10:59   ` [PATCH v2 7/9] telemetry: update json functions to use int/uint in names Bruce Richardson
2023-01-12 10:59   ` [PATCH v2 8/9] telemetry: make internal int representation 64-bits Bruce Richardson
2023-01-12 10:59   ` [PATCH v2 9/9] telemetry: change public API to use 64-bit signed values Bruce Richardson
2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson
2023-01-12 17:41   ` [PATCH v3 1/9] telemetry: remove RTE prefix from internal enum values Bruce Richardson
2023-01-12 17:41   ` [PATCH v3 2/9] telemetry: make array initialization more robust Bruce Richardson
2023-01-12 17:41   ` [PATCH v3 3/9] telemetry: rename unsigned 64-bit enum value to uint Bruce Richardson
2023-01-12 17:41   ` [PATCH v3 4/9] telemetry: add uint type as alias for u64 Bruce Richardson
2023-01-12 17:41   ` [PATCH v3 5/9] global: rename telemetry functions to newer versions Bruce Richardson
2023-01-12 17:41   ` [PATCH v3 6/9] telemetry: mark old names of renamed fns as deprecated Bruce Richardson
2023-01-12 17:41   ` [PATCH v3 7/9] telemetry: update json functions to use int/uint in names Bruce Richardson
2023-01-12 17:41   ` [PATCH v3 8/9] telemetry: make internal int representation 64-bits Bruce Richardson
2023-01-12 17:41   ` [PATCH v3 9/9] telemetry: change public API to use 64-bit signed values Bruce Richardson
2023-02-05 22:55     ` Thomas Monjalon
2023-01-13 16:39   ` [PATCH v3 0/9] Standardize telemetry int types Power, Ciara
2023-02-05 23:15     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230112105903.46341-5-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=ciara.power@intel.com \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.com \
    --cc=roretzla@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).