* [RFC PATCH 0/7] Standardize telemetry int types @ 2022-12-13 18:27 Bruce Richardson 2022-12-13 18:27 ` [RFC PATCH 1/7] telemetry: rename unsigned 64-bit enum value to uint Bruce Richardson ` (8 more replies) 0 siblings, 9 replies; 51+ messages in thread From: Bruce Richardson @ 2022-12-13 18:27 UTC (permalink / raw) To: dev; +Cc: 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. 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 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [RFC PATCH 1/7] telemetry: rename unsigned 64-bit enum value to uint 2022-12-13 18:27 [RFC PATCH 0/7] Standardize telemetry int types Bruce Richardson @ 2022-12-13 18:27 ` Bruce Richardson 2022-12-14 17:30 ` Tyler Retzlaff 2022-12-13 18:27 ` [RFC PATCH 2/7] telemetry: add uint type as alias for u64 Bruce Richardson ` (7 subsequent siblings) 8 siblings, 1 reply; 51+ messages in thread From: Bruce Richardson @ 2022-12-13 18:27 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup 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. Suggested-by: Morten Brørup <mb@smartsharesystems.com> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- 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(-) diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c index d92667a527..24a2035b61 100644 --- a/app/test/test_telemetry_data.c +++ b/app/test/test_telemetry_data.c @@ -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); diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c index 8e6277cbcd..59f0cce5ab 100644 --- a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c +++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c @@ -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, diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c index 180108ab9c..5db973d620 100644 --- a/drivers/net/cnxk/cnxk_ethdev_telemetry.c +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c @@ -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 */ diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 2165a0688c..79ea958db4 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -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) { diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 5d5e18db1e..28028e5de5 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -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); diff --git a/lib/ipsec/ipsec_telemetry.c b/lib/ipsec/ipsec_telemetry.c index cfebf454d6..b184e8df99 100644 --- a/lib/ipsec/ipsec_telemetry.c +++ b/lib/ipsec/ipsec_telemetry.c @@ -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; diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c index 29af5f3e4b..68063f6450 100644 --- a/lib/security/rte_security.c +++ b/lib/security/rte_security.c @@ -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) { diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index d9918c4e96..c2ad65effe 100644 --- a/lib/telemetry/rte_telemetry.h +++ b/lib/telemetry/rte_telemetry.h @@ -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 diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 8fbb4f3060..75957fe0b1 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -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); diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 34366ecee3..3c996484ec 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_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; -- 2.34.1 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 1/7] telemetry: rename unsigned 64-bit enum value to uint 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 0 siblings, 1 reply; 51+ messages in thread From: Tyler Retzlaff @ 2022-12-14 17:30 UTC (permalink / raw) To: Bruce Richardson; +Cc: dev, Morten Brørup On Tue, Dec 13, 2022 at 06:27:24PM +0000, Bruce Richardson wrote: > 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. > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > --- > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c > index 34366ecee3..3c996484ec 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_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? > 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; > -- > 2.34.1 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 1/7] telemetry: rename unsigned 64-bit enum value to uint 2022-12-14 17:30 ` Tyler Retzlaff @ 2022-12-15 9:41 ` Bruce Richardson 2022-12-15 17:53 ` Tyler Retzlaff 0 siblings, 1 reply; 51+ messages in thread From: Bruce Richardson @ 2022-12-15 9:41 UTC (permalink / raw) To: Tyler Retzlaff; +Cc: dev, Morten Brørup On Wed, Dec 14, 2022 at 09:30:05AM -0800, Tyler Retzlaff wrote: > On Tue, Dec 13, 2022 at 06:27:24PM +0000, Bruce Richardson wrote: > > 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. > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > --- > > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c > > index 34366ecee3..3c996484ec 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_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? > 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 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 1/7] telemetry: rename unsigned 64-bit enum value to uint 2022-12-15 9:41 ` Bruce Richardson @ 2022-12-15 17:53 ` Tyler Retzlaff 0 siblings, 0 replies; 51+ messages in thread From: Tyler Retzlaff @ 2022-12-15 17:53 UTC (permalink / raw) To: Bruce Richardson; +Cc: dev, Morten Brørup On Thu, Dec 15, 2022 at 09:41:38AM +0000, Bruce Richardson wrote: > On Wed, Dec 14, 2022 at 09:30:05AM -0800, Tyler Retzlaff wrote: > > On Tue, Dec 13, 2022 at 06:27:24PM +0000, Bruce Richardson wrote: > > > 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. > > > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > > --- > > > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c > > > index 34366ecee3..3c996484ec 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_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? > > > 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. > > /Bruce ^ permalink raw reply [flat|nested] 51+ messages in thread
* [RFC PATCH 2/7] telemetry: add uint type as alias for u64 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-13 18:27 ` Bruce Richardson 2022-12-14 17:38 ` Tyler Retzlaff 2022-12-15 1:49 ` lihuisong (C) 2022-12-13 18:27 ` [RFC PATCH 3/7] telemetry: remove RTE prefix from internal enum values Bruce Richardson ` (6 subsequent siblings) 8 siblings, 2 replies; 51+ messages in thread From: Bruce Richardson @ 2022-12-13 18:27 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup 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 Suggested-by: Morten Brørup <mb@smartsharesystems.com> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- 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(-) diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index c2ad65effe..60877dae0a 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,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(). * diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 75957fe0b1..fd8186383f 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 != 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 = diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 3c996484ec..077b0c4a6f 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_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)) diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h index 26aa28e72c..939deaa618 100644 --- a/lib/telemetry/telemetry_data.h +++ b/lib/telemetry/telemetry_data.h @@ -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; }; 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.34.1 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64 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 1:49 ` lihuisong (C) 1 sibling, 1 reply; 51+ messages in thread From: Tyler Retzlaff @ 2022-12-14 17:38 UTC (permalink / raw) To: Bruce Richardson; +Cc: dev, Morten Brørup On Tue, Dec 13, 2022 at 06:27:25PM +0000, Bruce Richardson wrote: > 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 > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > --- > 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(-) > > diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h > index c2ad65effe..60877dae0a 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); > > /** 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. ``` > + * 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); > + ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64 2022-12-14 17:38 ` Tyler Retzlaff @ 2022-12-15 9:44 ` Bruce Richardson 2022-12-15 13:36 ` Thomas Monjalon 2022-12-15 17:58 ` Tyler Retzlaff 0 siblings, 2 replies; 51+ messages in thread From: Bruce Richardson @ 2022-12-15 9:44 UTC (permalink / raw) To: Tyler Retzlaff; +Cc: dev, Morten Brørup, thomas, david.marchand On Wed, Dec 14, 2022 at 09:38:45AM -0800, Tyler Retzlaff wrote: > On Tue, Dec 13, 2022 at 06:27:25PM +0000, Bruce Richardson wrote: > > 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 > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > --- > > 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(-) > > > > diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h > > index c2ad65effe..60877dae0a 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); > > > > /** > > 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. > ``` > 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 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64 2022-12-15 9:44 ` Bruce Richardson @ 2022-12-15 13:36 ` Thomas Monjalon 2022-12-15 13:58 ` Bruce Richardson 2022-12-15 17:58 ` Tyler Retzlaff 1 sibling, 1 reply; 51+ messages in thread From: Thomas Monjalon @ 2022-12-15 13:36 UTC (permalink / raw) To: Tyler Retzlaff, Bruce Richardson; +Cc: dev, Morten Brørup, david.marchand 15/12/2022 10:44, Bruce Richardson: > On Wed, Dec 14, 2022 at 09:38:45AM -0800, Tyler Retzlaff wrote: > > On Tue, Dec 13, 2022 at 06:27:25PM +0000, Bruce Richardson wrote: > > > 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 > > > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > > --- > > > 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(-) > > > > > > diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h > > > index c2ad65effe..60877dae0a 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); > > > > > > /** > > > > 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. > > ``` > > > > 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. ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64 2022-12-15 13:36 ` Thomas Monjalon @ 2022-12-15 13:58 ` Bruce Richardson 2022-12-19 10:37 ` Thomas Monjalon 0 siblings, 1 reply; 51+ messages in thread From: Bruce Richardson @ 2022-12-15 13:58 UTC (permalink / raw) To: Thomas Monjalon; +Cc: Tyler Retzlaff, dev, Morten Brørup, david.marchand On Thu, Dec 15, 2022 at 02:36:51PM +0100, Thomas Monjalon wrote: > 15/12/2022 10:44, Bruce Richardson: > > On Wed, Dec 14, 2022 at 09:38:45AM -0800, Tyler Retzlaff wrote: > > > On Tue, Dec 13, 2022 at 06:27:25PM +0000, Bruce Richardson wrote: > > > > 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 > > > > > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > > > --- > > > > 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(-) > > > > > > > > diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h > > > > index c2ad65effe..60877dae0a 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); > > > > > > > > /** > > > > > > 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. > > > ``` > > > > > > > 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. > 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 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64 2022-12-15 13:58 ` Bruce Richardson @ 2022-12-19 10:37 ` Thomas Monjalon 2022-12-19 13:22 ` Bruce Richardson 0 siblings, 1 reply; 51+ messages in thread From: Thomas Monjalon @ 2022-12-19 10:37 UTC (permalink / raw) To: Bruce Richardson; +Cc: Tyler Retzlaff, dev, Morten Brørup, david.marchand 15/12/2022 14:58, Bruce Richardson: > On Thu, Dec 15, 2022 at 02:36:51PM +0100, Thomas Monjalon wrote: > > 15/12/2022 10:44, Bruce Richardson: > > > On Wed, Dec 14, 2022 at 09:38:45AM -0800, Tyler Retzlaff wrote: > > > > On Tue, Dec 13, 2022 at 06:27:25PM +0000, Bruce Richardson wrote: > > > > > 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 > > > > > > > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > > > > > > > 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. > > > > ``` > > > > > > > > > > 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. > > > 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? 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? ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64 2022-12-19 10:37 ` Thomas Monjalon @ 2022-12-19 13:22 ` Bruce Richardson 0 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2022-12-19 13:22 UTC (permalink / raw) To: Thomas Monjalon; +Cc: Tyler Retzlaff, dev, Morten Brørup, david.marchand On Mon, Dec 19, 2022 at 11:37:19AM +0100, Thomas Monjalon wrote: > 15/12/2022 14:58, Bruce Richardson: > > On Thu, Dec 15, 2022 at 02:36:51PM +0100, Thomas Monjalon wrote: > > > 15/12/2022 10:44, Bruce Richardson: > > > > On Wed, Dec 14, 2022 at 09:38:45AM -0800, Tyler Retzlaff wrote: > > > > > On Tue, Dec 13, 2022 at 06:27:25PM +0000, Bruce Richardson wrote: > > > > > > 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 > > > > > > > > > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > > > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > > > > > > > > > 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. > > > > > ``` > > > > > > > > > > > > > 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. > > > > > 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? > > 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 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64 2022-12-15 9:44 ` Bruce Richardson 2022-12-15 13:36 ` Thomas Monjalon @ 2022-12-15 17:58 ` Tyler Retzlaff 1 sibling, 0 replies; 51+ messages in thread From: Tyler Retzlaff @ 2022-12-15 17:58 UTC (permalink / raw) To: Bruce Richardson; +Cc: dev, Morten Brørup, thomas, david.marchand On Thu, Dec 15, 2022 at 09:44:49AM +0000, Bruce Richardson wrote: > On Wed, Dec 14, 2022 at 09:38:45AM -0800, Tyler Retzlaff wrote: > > On Tue, Dec 13, 2022 at 06:27:25PM +0000, Bruce Richardson wrote: > > > 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 > > > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > > --- > > > 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(-) > > > > > > diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h > > > index c2ad65effe..60877dae0a 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); > > > > > > /** > > > > 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. > > ``` > > > > 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. > > Adding Thomas and David on CC for their thoughts. > > /Bruce ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64 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 1:49 ` lihuisong (C) 2022-12-15 9:42 ` Bruce Richardson 1 sibling, 1 reply; 51+ messages in thread From: lihuisong (C) @ 2022-12-15 1:49 UTC (permalink / raw) To: Bruce Richardson, dev; +Cc: Morten Brørup 在 2022/12/14 2:27, 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 > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > --- > 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(-) > > diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h > index c2ad65effe..60877dae0a 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,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_experimental int Right? > +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 75957fe0b1..fd8186383f 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 != 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 = > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c > index 3c996484ec..077b0c4a6f 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_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)) > diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h > index 26aa28e72c..939deaa618 100644 > --- a/lib/telemetry/telemetry_data.h > +++ b/lib/telemetry/telemetry_data.h > @@ -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; > }; > > 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; ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64 2022-12-15 1:49 ` lihuisong (C) @ 2022-12-15 9:42 ` Bruce Richardson 2022-12-15 18:02 ` Tyler Retzlaff 0 siblings, 1 reply; 51+ messages in thread From: Bruce Richardson @ 2022-12-15 9:42 UTC (permalink / raw) To: lihuisong (C); +Cc: dev, Morten Brørup On Thu, Dec 15, 2022 at 09:49:06AM +0800, lihuisong (C) wrote: > > 在 2022/12/14 2:27, 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 > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > --- > > 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(-) > > > > diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h > > index c2ad65effe..60877dae0a 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,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_experimental > int > > Right? Yes, that is right. ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 2/7] telemetry: add uint type as alias for u64 2022-12-15 9:42 ` Bruce Richardson @ 2022-12-15 18:02 ` Tyler Retzlaff 0 siblings, 0 replies; 51+ messages in thread From: Tyler Retzlaff @ 2022-12-15 18:02 UTC (permalink / raw) To: Bruce Richardson; +Cc: lihuisong (C), dev, Morten Brørup On Thu, Dec 15, 2022 at 09:42:40AM +0000, Bruce Richardson wrote: > On Thu, Dec 15, 2022 at 09:49:06AM +0800, lihuisong (C) wrote: > > > > 在 2022/12/14 2:27, 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 > > > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > > --- > > > 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(-) > > > > > > diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h > > > index c2ad65effe..60877dae0a 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,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_experimental > > int > > > > 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. ^ permalink raw reply [flat|nested] 51+ messages in thread
* [RFC PATCH 3/7] telemetry: remove RTE prefix from internal enum values 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-13 18:27 ` [RFC PATCH 2/7] telemetry: add uint type as alias for u64 Bruce Richardson @ 2022-12-13 18:27 ` Bruce Richardson 2022-12-13 18:27 ` [RFC PATCH 4/7] telemetry: make array initialization more robust Bruce Richardson ` (5 subsequent siblings) 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2022-12-13 18:27 UTC (permalink / raw) To: dev; +Cc: 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. Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- 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(-) diff --git a/lib/ethdev/sff_telemetry.c b/lib/ethdev/sff_telemetry.c index ca6d196560..5923350424 100644 --- a/lib/ethdev/sff_telemetry.c +++ b/lib/ethdev/sff_telemetry.c @@ -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"); diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index fd8186383f..89bdde8422 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -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 * diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 077b0c4a6f..d51724e1f5 100644 --- a/lib/telemetry/telemetry_data.c +++ b/lib/telemetry/telemetry_data.c @@ -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; diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h index 939deaa618..8db6875a81 100644 --- a/lib/telemetry/telemetry_data.h +++ b/lib/telemetry/telemetry_data.h @@ -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 { -- 2.34.1 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [RFC PATCH 4/7] telemetry: make array initialization more robust 2022-12-13 18:27 [RFC PATCH 0/7] Standardize telemetry int types Bruce Richardson ` (2 preceding siblings ...) 2022-12-13 18:27 ` [RFC PATCH 3/7] telemetry: remove RTE prefix from internal enum values Bruce Richardson @ 2022-12-13 18:27 ` Bruce Richardson 2022-12-14 17:50 ` Tyler Retzlaff 2022-12-13 18:27 ` [RFC PATCH 5/7] telemetry: update json functions to use int/uint in names Bruce Richardson ` (4 subsequent siblings) 8 siblings, 1 reply; 51+ messages in thread From: Bruce Richardson @ 2022-12-13 18:27 UTC (permalink / raw) To: dev; +Cc: 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. Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- lib/telemetry/telemetry_data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index d51724e1f5..9a180937fd 100644 --- a/lib/telemetry/telemetry_data.c +++ b/lib/telemetry/telemetry_data.c @@ -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; -- 2.34.1 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 4/7] telemetry: make array initialization more robust 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 0 siblings, 1 reply; 51+ messages in thread From: Tyler Retzlaff @ 2022-12-14 17:50 UTC (permalink / raw) To: Bruce Richardson; +Cc: dev On Tue, Dec 13, 2022 at 06:27:27PM +0000, Bruce Richardson wrote: > 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. > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > --- > lib/telemetry/telemetry_data.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c > index d51724e1f5..9a180937fd 100644 > --- a/lib/telemetry/telemetry_data.c > +++ b/lib/telemetry/telemetry_data.c > @@ -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, > }; 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 > d->type = array_types[type]; > d->data_len = 0; > -- > 2.34.1 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 4/7] telemetry: make array initialization more robust 2022-12-14 17:50 ` Tyler Retzlaff @ 2023-01-09 12:16 ` Bruce Richardson 2023-01-09 17:49 ` Tyler Retzlaff 0 siblings, 1 reply; 51+ messages in thread From: Bruce Richardson @ 2023-01-09 12:16 UTC (permalink / raw) To: Tyler Retzlaff; +Cc: dev On Wed, Dec 14, 2022 at 09:50:33AM -0800, Tyler Retzlaff wrote: > On Tue, Dec 13, 2022 at 06:27:27PM +0000, Bruce Richardson wrote: > > 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. > > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > --- > > lib/telemetry/telemetry_data.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c > > index d51724e1f5..9a180937fd 100644 > > --- a/lib/telemetry/telemetry_data.c > > +++ b/lib/telemetry/telemetry_data.c > > @@ -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, > > }; > > 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 > 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 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 4/7] telemetry: make array initialization more robust 2023-01-09 12:16 ` Bruce Richardson @ 2023-01-09 17:49 ` Tyler Retzlaff 2023-01-10 9:11 ` Ferruh Yigit 0 siblings, 1 reply; 51+ messages in thread From: Tyler Retzlaff @ 2023-01-09 17:49 UTC (permalink / raw) To: Bruce Richardson; +Cc: dev On Mon, Jan 09, 2023 at 12:16:15PM +0000, Bruce Richardson wrote: > On Wed, Dec 14, 2022 at 09:50:33AM -0800, Tyler Retzlaff wrote: > > On Tue, Dec 13, 2022 at 06:27:27PM +0000, Bruce Richardson wrote: > > > 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. > > > > > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > > --- > > > lib/telemetry/telemetry_data.c | 8 ++++---- > > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > > > diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c > > > index d51724e1f5..9a180937fd 100644 > > > --- a/lib/telemetry/telemetry_data.c > > > +++ b/lib/telemetry/telemetry_data.c > > > @@ -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, > > > }; > > > > 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 > > > 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. > > /Bruce ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 4/7] telemetry: make array initialization more robust 2023-01-09 17:49 ` Tyler Retzlaff @ 2023-01-10 9:11 ` Ferruh Yigit 0 siblings, 0 replies; 51+ messages in thread From: Ferruh Yigit @ 2023-01-10 9:11 UTC (permalink / raw) To: Tyler Retzlaff, Bruce Richardson; +Cc: dev, techboard On 1/9/2023 5:49 PM, Tyler Retzlaff wrote: > On Mon, Jan 09, 2023 at 12:16:15PM +0000, Bruce Richardson wrote: >> On Wed, Dec 14, 2022 at 09:50:33AM -0800, Tyler Retzlaff wrote: >>> On Tue, Dec 13, 2022 at 06:27:27PM +0000, Bruce Richardson wrote: >>>> 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. >>>> >>>> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> >>>> --- >>>> lib/telemetry/telemetry_data.c | 8 ++++---- >>>> 1 file changed, 4 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c >>>> index d51724e1f5..9a180937fd 100644 >>>> --- a/lib/telemetry/telemetry_data.c >>>> +++ b/lib/telemetry/telemetry_data.c >>>> @@ -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, >>>> }; >>> >>> 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 >>> >> 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. ^ permalink raw reply [flat|nested] 51+ messages in thread
* [RFC PATCH 5/7] telemetry: update json functions to use int/uint in names 2022-12-13 18:27 [RFC PATCH 0/7] Standardize telemetry int types Bruce Richardson ` (3 preceding siblings ...) 2022-12-13 18:27 ` [RFC PATCH 4/7] telemetry: make array initialization more robust Bruce Richardson @ 2022-12-13 18:27 ` Bruce Richardson 2022-12-13 18:27 ` [RFC PATCH 6/7] telemetry: make internal int representation 64-bits Bruce Richardson ` (3 subsequent siblings) 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2022-12-13 18:27 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup 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. Suggested-by: Morten Brørup <mb@smartsharesystems.com> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- 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(-) diff --git a/app/test/test_telemetry_json.c b/app/test/test_telemetry_json.c index 184c3ba9f1..e81e3a8a98 100644 --- a/app/test/test_telemetry_json.c +++ b/app/test/test_telemetry_json.c @@ -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; diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 89bdde8422..655191bcf1 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -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) { diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h index e3fae7c30d..744bbfe053 100644 --- a/lib/telemetry/telemetry_json.h +++ b/lib/telemetry/telemetry_json.h @@ -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; } -- 2.34.1 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [RFC PATCH 6/7] telemetry: make internal int representation 64-bits 2022-12-13 18:27 [RFC PATCH 0/7] Standardize telemetry int types Bruce Richardson ` (4 preceding siblings ...) 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 ` Bruce Richardson 2022-12-13 18:27 ` [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values Bruce Richardson ` (2 subsequent siblings) 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2022-12-13 18:27 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup The internal storage for int values can be expanded from 32-bit to 64-bit without affecting the external ABI. Suggested-by: Morten Brørup <mb@smartsharesystems.com> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- lib/telemetry/telemetry_data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h index 8db6875a81..205509c5a2 100644 --- a/lib/telemetry/telemetry_data.h +++ b/lib/telemetry/telemetry_data.h @@ -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; }; -- 2.34.1 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values 2022-12-13 18:27 [RFC PATCH 0/7] Standardize telemetry int types Bruce Richardson ` (5 preceding siblings ...) 2022-12-13 18:27 ` [RFC PATCH 6/7] telemetry: make internal int representation 64-bits Bruce Richardson @ 2022-12-13 18:27 ` Bruce Richardson 2022-12-13 20:19 ` Morten Brørup 2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson 2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson 8 siblings, 1 reply; 51+ messages in thread From: Bruce Richardson @ 2022-12-13 18:27 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup 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. Suggested-by: Morten Brørup <mb@smartsharesystems.com> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- 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(-) diff --git a/lib/telemetry/meson.build b/lib/telemetry/meson.build index f84c9aa3be..73750d9ef4 100644 --- a/lib/telemetry/meson.build +++ b/lib/telemetry/meson.build @@ -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 diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index 60877dae0a..baa7b21f6b 100644 --- a/lib/telemetry/rte_telemetry.h +++ b/lib/telemetry/rte_telemetry.h @@ -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. diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 9a180937fd..ac7be795df 100644 --- a/lib/telemetry/telemetry_data.c +++ b/lib/telemetry/telemetry_data.c @@ -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) diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h index 205509c5a2..53e4cabea5 100644 --- a/lib/telemetry/telemetry_data.h +++ b/lib/telemetry/telemetry_data.h @@ -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 diff --git a/lib/telemetry/version.map b/lib/telemetry/version.map index 0f70d82dfc..85df19c4d8 100644 --- a/lib/telemetry/version.map +++ b/lib/telemetry/version.map @@ -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: -- 2.34.1 ^ permalink raw reply [flat|nested] 51+ messages in thread
* RE: [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values 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 0 siblings, 1 reply; 51+ messages in thread From: Morten Brørup @ 2022-12-13 20:19 UTC (permalink / raw) To: Bruce Richardson, dev > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > 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. > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > --- Excellent example of how to use function versioning for ABI compatibility. Series-acked-by: Morten Brørup <mb@smartsharesystems.com> ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values 2022-12-13 20:19 ` Morten Brørup @ 2022-12-14 17:53 ` Tyler Retzlaff 2022-12-15 2:39 ` lihuisong (C) 0 siblings, 1 reply; 51+ messages in thread From: Tyler Retzlaff @ 2022-12-14 17:53 UTC (permalink / raw) To: Morten Brørup; +Cc: Bruce Richardson, dev On Tue, Dec 13, 2022 at 09:19:45PM +0100, Morten Brørup wrote: > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > 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. > > > > Suggested-by: Morten Brørup <mb@smartsharesystems.com> > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> > > --- > > Excellent example of how to use function versioning for ABI compatibility. > > Series-acked-by: Morten Brørup <mb@smartsharesystems.com> > minor comments that can be optionally addressed. lgtm Series-acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com> ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values 2022-12-14 17:53 ` Tyler Retzlaff @ 2022-12-15 2:39 ` lihuisong (C) 0 siblings, 0 replies; 51+ messages in thread From: lihuisong (C) @ 2022-12-15 2:39 UTC (permalink / raw) To: dev 在 2022/12/15 1:53, Tyler Retzlaff 写道: > On Tue, Dec 13, 2022 at 09:19:45PM +0100, Morten Brørup wrote: >>> From: Bruce Richardson [mailto:bruce.richardson@intel.com] >>> 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. >>> >>> Suggested-by: Morten Brørup <mb@smartsharesystems.com> >>> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> >>> --- >> Excellent example of how to use function versioning for ABI compatibility. >> >> Series-acked-by: Morten Brørup <mb@smartsharesystems.com> >> > minor comments that can be optionally addressed. lgtm > > Series-acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com> > . LGTM Series-acked-by: Huisong Li <lihuisong@huawei.com> 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. ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v2 0/9] Standardize telemetry int types 2022-12-13 18:27 [RFC PATCH 0/7] Standardize telemetry int types Bruce Richardson ` (6 preceding siblings ...) 2022-12-13 18:27 ` [RFC PATCH 7/7] telemetry: change public API to use 64-bit signed values Bruce Richardson @ 2023-01-12 10:58 ` Bruce Richardson 2023-01-12 10:58 ` [PATCH v2 1/9] telemetry: remove RTE prefix from internal enum values Bruce Richardson ` (8 more replies) 2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson 8 siblings, 9 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 10:58 UTC (permalink / raw) To: dev; +Cc: 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 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v2 1/9] telemetry: remove RTE prefix from internal enum values 2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson @ 2023-01-12 10:58 ` Bruce Richardson 2023-01-12 10:58 ` [PATCH v2 2/9] telemetry: make array initialization more robust Bruce Richardson ` (7 subsequent siblings) 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 10:58 UTC (permalink / raw) To: dev Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, Ciara Power To better distinguish which values are public and which are internal remove the "RTE_" prefix off the internal enum defining the container types. 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> --- 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(-) diff --git a/lib/ethdev/sff_telemetry.c b/lib/ethdev/sff_telemetry.c index ca6d196560..5923350424 100644 --- a/lib/ethdev/sff_telemetry.c +++ b/lib/ethdev/sff_telemetry.c @@ -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"); diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 8fbb4f3060..792b4e12b6 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -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 * diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 34366ecee3..76fae720e3 100644 --- a/lib/telemetry/telemetry_data.c +++ b/lib/telemetry/telemetry_data.c @@ -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; diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h index 26aa28e72c..79c916bd7e 100644 --- a/lib/telemetry/telemetry_data.h +++ b/lib/telemetry/telemetry_data.h @@ -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 { -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v2 2/9] telemetry: make array initialization more robust 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 ` Bruce Richardson 2023-01-12 10:58 ` [PATCH v2 3/9] telemetry: rename unsigned 64-bit enum value to uint Bruce Richardson ` (6 subsequent siblings) 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 10:58 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power 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. 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> --- lib/telemetry/telemetry_data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 76fae720e3..3f5ef3979b 100644 --- a/lib/telemetry/telemetry_data.c +++ b/lib/telemetry/telemetry_data.c @@ -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; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v2 3/9] telemetry: rename unsigned 64-bit enum value to uint 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 ` Bruce Richardson 2023-01-12 10:58 ` [PATCH v2 4/9] telemetry: add uint type as alias for u64 Bruce Richardson ` (5 subsequent siblings) 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 10:58 UTC (permalink / raw) To: dev Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao, Akhil Goyal, Fan Zhang, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, Konstantin Ananyev, Vladimir Medvedkin 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. 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> --- 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(-) diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c index d92667a527..24a2035b61 100644 --- a/app/test/test_telemetry_data.c +++ b/app/test/test_telemetry_data.c @@ -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); diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c index 8e6277cbcd..59f0cce5ab 100644 --- a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c +++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c @@ -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, diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c index 180108ab9c..5db973d620 100644 --- a/drivers/net/cnxk/cnxk_ethdev_telemetry.c +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c @@ -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 */ diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 2165a0688c..79ea958db4 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -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) { diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 5d5e18db1e..28028e5de5 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -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); diff --git a/lib/ipsec/ipsec_telemetry.c b/lib/ipsec/ipsec_telemetry.c index cfebf454d6..b184e8df99 100644 --- a/lib/ipsec/ipsec_telemetry.c +++ b/lib/ipsec/ipsec_telemetry.c @@ -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; diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c index 29af5f3e4b..68063f6450 100644 --- a/lib/security/rte_security.c +++ b/lib/security/rte_security.c @@ -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) { diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index d9918c4e96..c2ad65effe 100644 --- a/lib/telemetry/rte_telemetry.h +++ b/lib/telemetry/rte_telemetry.h @@ -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 diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 792b4e12b6..916a0a4604 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -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); diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 3f5ef3979b..d4345908d5 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_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; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v2 4/9] telemetry: add uint type as alias for u64 2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson ` (2 preceding siblings ...) 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 2023-01-12 10:58 ` [PATCH v2 5/9] global: rename telemetry functions to newer versions Bruce Richardson ` (4 subsequent siblings) 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 10:58 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power 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 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v2 5/9] global: rename telemetry functions to newer versions 2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson ` (3 preceding siblings ...) 2023-01-12 10:58 ` [PATCH v2 4/9] telemetry: add uint type as alias for u64 Bruce Richardson @ 2023-01-12 10:58 ` Bruce Richardson 2023-01-12 10:59 ` [PATCH v2 6/9] telemetry: mark old names of renamed fns as deprecated Bruce Richardson ` (3 subsequent siblings) 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 10:58 UTC (permalink / raw) To: dev Cc: Bruce Richardson, Ciara Power, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao, Radu Nicolau, Akhil Goyal, David Hunt, Fan Zhang, Chengwen Feng, Kevin Laatz, Anatoly Burakov, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, Naga Harish K S V, Jerin Jacob, Erik Gabriel Carrillo, Konstantin Ananyev, Vladimir Medvedkin, Sachin Saxena, Hemant Agrawal 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. Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- 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(-) diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c index 24a2035b61..b00c148a57 100644 --- a/app/test/test_telemetry_data.c +++ b/app/test/test_telemetry_data.c @@ -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); diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h index 1a48ff3db4..b29f3e06f1 100644 --- a/drivers/common/cnxk/roc_platform.h +++ b/drivers/common/cnxk/roc_platform.h @@ -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 diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c index 59f0cce5ab..386278cfc9 100644 --- a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c +++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c @@ -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); diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c index 5db973d620..3027ca4735 100644 --- a/drivers/net/cnxk/cnxk_ethdev_telemetry.c +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c @@ -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++; } diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index a64a26c992..d2d9d85b4a 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -2588,14 +2588,12 @@ handle_telemetry_cmd_ipsec_secgw_stats(const char *cmd __rte_unused, } /* add telemetry key/values pairs */ - rte_tel_data_add_dict_u64(data, "packets received", - total_pkts_rx); + rte_tel_data_add_dict_uint(data, "packets received", total_pkts_rx); - rte_tel_data_add_dict_u64(data, "packets transmitted", - total_pkts_tx); + rte_tel_data_add_dict_uint(data, "packets transmitted", total_pkts_tx); - rte_tel_data_add_dict_u64(data, "packets dropped", - total_pkts_dropped); + rte_tel_data_add_dict_uint(data, "packets dropped", + total_pkts_dropped); return 0; @@ -2695,30 +2693,30 @@ handle_telemetry_cmd_ipsec_secgw_stats_outbound(const char *cmd __rte_unused, /* add spd 4 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(spd4_data, "protect", - total_stats.outbound.spd4.protect); - rte_tel_data_add_dict_u64(spd4_data, "bypass", - total_stats.outbound.spd4.bypass); - rte_tel_data_add_dict_u64(spd4_data, "discard", - total_stats.outbound.spd4.discard); + rte_tel_data_add_dict_uint(spd4_data, "protect", + total_stats.outbound.spd4.protect); + rte_tel_data_add_dict_uint(spd4_data, "bypass", + total_stats.outbound.spd4.bypass); + rte_tel_data_add_dict_uint(spd4_data, "discard", + total_stats.outbound.spd4.discard); rte_tel_data_add_dict_container(data, "spd4", spd4_data, 0); /* add spd 6 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(spd6_data, "protect", - total_stats.outbound.spd6.protect); - rte_tel_data_add_dict_u64(spd6_data, "bypass", - total_stats.outbound.spd6.bypass); - rte_tel_data_add_dict_u64(spd6_data, "discard", - total_stats.outbound.spd6.discard); + rte_tel_data_add_dict_uint(spd6_data, "protect", + total_stats.outbound.spd6.protect); + rte_tel_data_add_dict_uint(spd6_data, "bypass", + total_stats.outbound.spd6.bypass); + rte_tel_data_add_dict_uint(spd6_data, "discard", + total_stats.outbound.spd6.discard); rte_tel_data_add_dict_container(data, "spd6", spd6_data, 0); /* add sad telemetry key/values pairs */ - rte_tel_data_add_dict_u64(sad_data, "miss", - total_stats.outbound.sad.miss); + rte_tel_data_add_dict_uint(sad_data, "miss", + total_stats.outbound.sad.miss); rte_tel_data_add_dict_container(data, "sad", sad_data, 0); @@ -2769,30 +2767,30 @@ handle_telemetry_cmd_ipsec_secgw_stats_inbound(const char *cmd __rte_unused, /* add sad telemetry key/values pairs */ - rte_tel_data_add_dict_u64(sad_data, "miss", - total_stats.inbound.sad.miss); + rte_tel_data_add_dict_uint(sad_data, "miss", + total_stats.inbound.sad.miss); rte_tel_data_add_dict_container(data, "sad", sad_data, 0); /* add spd 4 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(spd4_data, "protect", - total_stats.inbound.spd4.protect); - rte_tel_data_add_dict_u64(spd4_data, "bypass", - total_stats.inbound.spd4.bypass); - rte_tel_data_add_dict_u64(spd4_data, "discard", - total_stats.inbound.spd4.discard); + rte_tel_data_add_dict_uint(spd4_data, "protect", + total_stats.inbound.spd4.protect); + rte_tel_data_add_dict_uint(spd4_data, "bypass", + total_stats.inbound.spd4.bypass); + rte_tel_data_add_dict_uint(spd4_data, "discard", + total_stats.inbound.spd4.discard); rte_tel_data_add_dict_container(data, "spd4", spd4_data, 0); /* add spd 6 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(spd6_data, "protect", - total_stats.inbound.spd6.protect); - rte_tel_data_add_dict_u64(spd6_data, "bypass", - total_stats.inbound.spd6.bypass); - rte_tel_data_add_dict_u64(spd6_data, "discard", - total_stats.inbound.spd6.discard); + rte_tel_data_add_dict_uint(spd6_data, "protect", + total_stats.inbound.spd6.protect); + rte_tel_data_add_dict_uint(spd6_data, "bypass", + total_stats.inbound.spd6.bypass); + rte_tel_data_add_dict_uint(spd6_data, "discard", + total_stats.inbound.spd6.discard); rte_tel_data_add_dict_container(data, "spd6", spd6_data, 0); @@ -2839,14 +2837,12 @@ handle_telemetry_cmd_ipsec_secgw_stats_routing(const char *cmd __rte_unused, update_statistics(&total_stats, coreid); /* add lpm 4 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(lpm4_data, "miss", - total_stats.lpm4.miss); + rte_tel_data_add_dict_uint(lpm4_data, "miss", total_stats.lpm4.miss); rte_tel_data_add_dict_container(data, "IPv4 LPM", lpm4_data, 0); /* add lpm 6 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(lpm6_data, "miss", - total_stats.lpm6.miss); + rte_tel_data_add_dict_uint(lpm6_data, "miss", total_stats.lpm6.miss); rte_tel_data_add_dict_container(data, "IPv6 LPM", lpm6_data, 0); diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index fd3ade330f..caf26b373e 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -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; } diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 79ea958db4..bc53aab100 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -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; diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index 4da653eec7..8c095e1f35 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -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, diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c index 688dc615d7..3d2fc8e98b 100644 --- a/lib/eal/common/eal_common_memory.c +++ b/lib/eal/common/eal_common_memory.c @@ -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; } diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 28028e5de5..4dd2968a01 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -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"); diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c index cf7bbd4d69..13d7163b79 100644 --- a/lib/eventdev/rte_event_eth_rx_adapter.c +++ b/lib/eventdev/rte_event_eth_rx_adapter.c @@ -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; diff --git a/lib/eventdev/rte_event_timer_adapter.c b/lib/eventdev/rte_event_timer_adapter.c index a0f14bf861..1c3f91605a 100644 --- a/lib/eventdev/rte_event_timer_adapter.c +++ b/lib/eventdev/rte_event_timer_adapter.c @@ -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; } diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c index b0414206d9..027e6a93ce 100644 --- a/lib/eventdev/rte_eventdev.c +++ b/lib/eventdev/rte_eventdev.c @@ -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); diff --git a/lib/ipsec/ipsec_telemetry.c b/lib/ipsec/ipsec_telemetry.c index b184e8df99..3b03ddee63 100644 --- a/lib/ipsec/ipsec_telemetry.c +++ b/lib/ipsec/ipsec_telemetry.c @@ -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", diff --git a/lib/rawdev/rte_rawdev.c b/lib/rawdev/rte_rawdev.c index 5fbdb94229..dacaa60e22 100644 --- a/lib/rawdev/rte_rawdev.c +++ b/lib/rawdev/rte_rawdev.c @@ -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; diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c index 68063f6450..e102c55e55 100644 --- a/lib/security/rte_security.c +++ b/lib/security/rte_security.c @@ -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; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v2 6/9] telemetry: mark old names of renamed fns as deprecated 2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson ` (4 preceding siblings ...) 2023-01-12 10:58 ` [PATCH v2 5/9] global: rename telemetry functions to newer versions Bruce Richardson @ 2023-01-12 10:59 ` Bruce Richardson 2023-01-12 10:59 ` [PATCH v2 7/9] telemetry: update json functions to use int/uint in names Bruce Richardson ` (2 subsequent siblings) 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 10:59 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Ciara Power 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. Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- 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(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index b9b02dcef0..98ad6baed5 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -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. diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index 73a0511807..4598303d5d 100644 --- a/lib/telemetry/rte_telemetry.h +++ b/lib/telemetry/rte_telemetry.h @@ -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 diff --git a/lib/telemetry/version.map b/lib/telemetry/version.map index 0f70d82dfc..d661180317 100644 --- a/lib/telemetry/version.map +++ b/lib/telemetry/version.map @@ -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; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v2 7/9] telemetry: update json functions to use int/uint in names 2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson ` (5 preceding siblings ...) 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 ` 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 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 10:59 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power 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. 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> --- 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(-) diff --git a/app/test/test_telemetry_json.c b/app/test/test_telemetry_json.c index 184c3ba9f1..e81e3a8a98 100644 --- a/app/test/test_telemetry_json.c +++ b/app/test/test_telemetry_json.c @@ -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; diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 89bdde8422..655191bcf1 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -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) { diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h index e3fae7c30d..744bbfe053 100644 --- a/lib/telemetry/telemetry_json.h +++ b/lib/telemetry/telemetry_json.h @@ -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; } -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v2 8/9] telemetry: make internal int representation 64-bits 2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson ` (6 preceding siblings ...) 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 ` Bruce Richardson 2023-01-12 10:59 ` [PATCH v2 9/9] telemetry: change public API to use 64-bit signed values Bruce Richardson 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 10:59 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power The internal storage for int values can be expanded from 32-bit to 64-bit without affecting the external ABI. 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> --- lib/telemetry/telemetry_data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h index 8db6875a81..205509c5a2 100644 --- a/lib/telemetry/telemetry_data.h +++ b/lib/telemetry/telemetry_data.h @@ -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; }; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v2 9/9] telemetry: change public API to use 64-bit signed values 2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson ` (7 preceding siblings ...) 2023-01-12 10:59 ` [PATCH v2 8/9] telemetry: make internal int representation 64-bits Bruce Richardson @ 2023-01-12 10:59 ` Bruce Richardson 8 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 10:59 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power 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. 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> --- 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(-) diff --git a/lib/telemetry/meson.build b/lib/telemetry/meson.build index f84c9aa3be..73750d9ef4 100644 --- a/lib/telemetry/meson.build +++ b/lib/telemetry/meson.build @@ -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 diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index 4598303d5d..b481c112dd 100644 --- a/lib/telemetry/rte_telemetry.h +++ b/lib/telemetry/rte_telemetry.h @@ -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. diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 9a180937fd..ac7be795df 100644 --- a/lib/telemetry/telemetry_data.c +++ b/lib/telemetry/telemetry_data.c @@ -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) diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h index 205509c5a2..53e4cabea5 100644 --- a/lib/telemetry/telemetry_data.h +++ b/lib/telemetry/telemetry_data.h @@ -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 diff --git a/lib/telemetry/version.map b/lib/telemetry/version.map index d661180317..accfad5011 100644 --- a/lib/telemetry/version.map +++ b/lib/telemetry/version.map @@ -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; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v3 0/9] Standardize telemetry int types 2022-12-13 18:27 [RFC PATCH 0/7] Standardize telemetry int types Bruce Richardson ` (7 preceding siblings ...) 2023-01-12 10:58 ` [PATCH v2 0/9] Standardize telemetry int types Bruce Richardson @ 2023-01-12 17:41 ` Bruce Richardson 2023-01-12 17:41 ` [PATCH v3 1/9] telemetry: remove RTE prefix from internal enum values Bruce Richardson ` (9 more replies) 8 siblings, 10 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 17:41 UTC (permalink / raw) To: dev; +Cc: 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 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v3 1/9] telemetry: remove RTE prefix from internal enum values 2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson @ 2023-01-12 17:41 ` Bruce Richardson 2023-01-12 17:41 ` [PATCH v3 2/9] telemetry: make array initialization more robust Bruce Richardson ` (8 subsequent siblings) 9 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 17:41 UTC (permalink / raw) To: dev Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, Ciara Power To better distinguish which values are public and which are internal remove the "RTE_" prefix off the internal enum defining the container types. 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> --- 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(-) diff --git a/lib/ethdev/sff_telemetry.c b/lib/ethdev/sff_telemetry.c index ca6d196560..5923350424 100644 --- a/lib/ethdev/sff_telemetry.c +++ b/lib/ethdev/sff_telemetry.c @@ -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"); diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 8fbb4f3060..792b4e12b6 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -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 * diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 34366ecee3..76fae720e3 100644 --- a/lib/telemetry/telemetry_data.c +++ b/lib/telemetry/telemetry_data.c @@ -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; diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h index 26aa28e72c..79c916bd7e 100644 --- a/lib/telemetry/telemetry_data.h +++ b/lib/telemetry/telemetry_data.h @@ -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 { -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v3 2/9] telemetry: make array initialization more robust 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 ` Bruce Richardson 2023-01-12 17:41 ` [PATCH v3 3/9] telemetry: rename unsigned 64-bit enum value to uint Bruce Richardson ` (7 subsequent siblings) 9 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 17:41 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power 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. 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> --- lib/telemetry/telemetry_data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 76fae720e3..3f5ef3979b 100644 --- a/lib/telemetry/telemetry_data.c +++ b/lib/telemetry/telemetry_data.c @@ -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; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v3 3/9] telemetry: rename unsigned 64-bit enum value to uint 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 ` Bruce Richardson 2023-01-12 17:41 ` [PATCH v3 4/9] telemetry: add uint type as alias for u64 Bruce Richardson ` (6 subsequent siblings) 9 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 17:41 UTC (permalink / raw) To: dev Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao, Akhil Goyal, Fan Zhang, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, Konstantin Ananyev, Vladimir Medvedkin 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. 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> --- 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(-) diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c index d92667a527..24a2035b61 100644 --- a/app/test/test_telemetry_data.c +++ b/app/test/test_telemetry_data.c @@ -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); diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c index 8e6277cbcd..59f0cce5ab 100644 --- a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c +++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c @@ -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, diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c index 180108ab9c..5db973d620 100644 --- a/drivers/net/cnxk/cnxk_ethdev_telemetry.c +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c @@ -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 */ diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 2165a0688c..79ea958db4 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -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) { diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 5d5e18db1e..28028e5de5 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -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); diff --git a/lib/ipsec/ipsec_telemetry.c b/lib/ipsec/ipsec_telemetry.c index cfebf454d6..b184e8df99 100644 --- a/lib/ipsec/ipsec_telemetry.c +++ b/lib/ipsec/ipsec_telemetry.c @@ -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; diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c index 29af5f3e4b..68063f6450 100644 --- a/lib/security/rte_security.c +++ b/lib/security/rte_security.c @@ -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) { diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index d9918c4e96..c2ad65effe 100644 --- a/lib/telemetry/rte_telemetry.h +++ b/lib/telemetry/rte_telemetry.h @@ -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 diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 792b4e12b6..916a0a4604 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -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); diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 3f5ef3979b..d4345908d5 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_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; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v3 4/9] telemetry: add uint type as alias for u64 2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson ` (2 preceding siblings ...) 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 ` Bruce Richardson 2023-01-12 17:41 ` [PATCH v3 5/9] global: rename telemetry functions to newer versions Bruce Richardson ` (5 subsequent siblings) 9 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 17:41 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power 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 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v3 5/9] global: rename telemetry functions to newer versions 2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson ` (3 preceding siblings ...) 2023-01-12 17:41 ` [PATCH v3 4/9] telemetry: add uint type as alias for u64 Bruce Richardson @ 2023-01-12 17:41 ` Bruce Richardson 2023-01-12 17:41 ` [PATCH v3 6/9] telemetry: mark old names of renamed fns as deprecated Bruce Richardson ` (4 subsequent siblings) 9 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 17:41 UTC (permalink / raw) To: dev Cc: Bruce Richardson, Ciara Power, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao, Radu Nicolau, Akhil Goyal, David Hunt, Fan Zhang, Chengwen Feng, Kevin Laatz, Anatoly Burakov, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, Naga Harish K S V, Jerin Jacob, Erik Gabriel Carrillo, Konstantin Ananyev, Vladimir Medvedkin, Sachin Saxena, Hemant Agrawal 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. Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- 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(-) diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c index 24a2035b61..b00c148a57 100644 --- a/app/test/test_telemetry_data.c +++ b/app/test/test_telemetry_data.c @@ -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); diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h index 1a48ff3db4..c151a3cc8e 100644 --- a/drivers/common/cnxk/roc_platform.h +++ b/drivers/common/cnxk/roc_platform.h @@ -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 */ diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c index 59f0cce5ab..386278cfc9 100644 --- a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c +++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c @@ -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); diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c index 5db973d620..3027ca4735 100644 --- a/drivers/net/cnxk/cnxk_ethdev_telemetry.c +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c @@ -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++; } diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index a64a26c992..d2d9d85b4a 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -2588,14 +2588,12 @@ handle_telemetry_cmd_ipsec_secgw_stats(const char *cmd __rte_unused, } /* add telemetry key/values pairs */ - rte_tel_data_add_dict_u64(data, "packets received", - total_pkts_rx); + rte_tel_data_add_dict_uint(data, "packets received", total_pkts_rx); - rte_tel_data_add_dict_u64(data, "packets transmitted", - total_pkts_tx); + rte_tel_data_add_dict_uint(data, "packets transmitted", total_pkts_tx); - rte_tel_data_add_dict_u64(data, "packets dropped", - total_pkts_dropped); + rte_tel_data_add_dict_uint(data, "packets dropped", + total_pkts_dropped); return 0; @@ -2695,30 +2693,30 @@ handle_telemetry_cmd_ipsec_secgw_stats_outbound(const char *cmd __rte_unused, /* add spd 4 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(spd4_data, "protect", - total_stats.outbound.spd4.protect); - rte_tel_data_add_dict_u64(spd4_data, "bypass", - total_stats.outbound.spd4.bypass); - rte_tel_data_add_dict_u64(spd4_data, "discard", - total_stats.outbound.spd4.discard); + rte_tel_data_add_dict_uint(spd4_data, "protect", + total_stats.outbound.spd4.protect); + rte_tel_data_add_dict_uint(spd4_data, "bypass", + total_stats.outbound.spd4.bypass); + rte_tel_data_add_dict_uint(spd4_data, "discard", + total_stats.outbound.spd4.discard); rte_tel_data_add_dict_container(data, "spd4", spd4_data, 0); /* add spd 6 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(spd6_data, "protect", - total_stats.outbound.spd6.protect); - rte_tel_data_add_dict_u64(spd6_data, "bypass", - total_stats.outbound.spd6.bypass); - rte_tel_data_add_dict_u64(spd6_data, "discard", - total_stats.outbound.spd6.discard); + rte_tel_data_add_dict_uint(spd6_data, "protect", + total_stats.outbound.spd6.protect); + rte_tel_data_add_dict_uint(spd6_data, "bypass", + total_stats.outbound.spd6.bypass); + rte_tel_data_add_dict_uint(spd6_data, "discard", + total_stats.outbound.spd6.discard); rte_tel_data_add_dict_container(data, "spd6", spd6_data, 0); /* add sad telemetry key/values pairs */ - rte_tel_data_add_dict_u64(sad_data, "miss", - total_stats.outbound.sad.miss); + rte_tel_data_add_dict_uint(sad_data, "miss", + total_stats.outbound.sad.miss); rte_tel_data_add_dict_container(data, "sad", sad_data, 0); @@ -2769,30 +2767,30 @@ handle_telemetry_cmd_ipsec_secgw_stats_inbound(const char *cmd __rte_unused, /* add sad telemetry key/values pairs */ - rte_tel_data_add_dict_u64(sad_data, "miss", - total_stats.inbound.sad.miss); + rte_tel_data_add_dict_uint(sad_data, "miss", + total_stats.inbound.sad.miss); rte_tel_data_add_dict_container(data, "sad", sad_data, 0); /* add spd 4 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(spd4_data, "protect", - total_stats.inbound.spd4.protect); - rte_tel_data_add_dict_u64(spd4_data, "bypass", - total_stats.inbound.spd4.bypass); - rte_tel_data_add_dict_u64(spd4_data, "discard", - total_stats.inbound.spd4.discard); + rte_tel_data_add_dict_uint(spd4_data, "protect", + total_stats.inbound.spd4.protect); + rte_tel_data_add_dict_uint(spd4_data, "bypass", + total_stats.inbound.spd4.bypass); + rte_tel_data_add_dict_uint(spd4_data, "discard", + total_stats.inbound.spd4.discard); rte_tel_data_add_dict_container(data, "spd4", spd4_data, 0); /* add spd 6 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(spd6_data, "protect", - total_stats.inbound.spd6.protect); - rte_tel_data_add_dict_u64(spd6_data, "bypass", - total_stats.inbound.spd6.bypass); - rte_tel_data_add_dict_u64(spd6_data, "discard", - total_stats.inbound.spd6.discard); + rte_tel_data_add_dict_uint(spd6_data, "protect", + total_stats.inbound.spd6.protect); + rte_tel_data_add_dict_uint(spd6_data, "bypass", + total_stats.inbound.spd6.bypass); + rte_tel_data_add_dict_uint(spd6_data, "discard", + total_stats.inbound.spd6.discard); rte_tel_data_add_dict_container(data, "spd6", spd6_data, 0); @@ -2839,14 +2837,12 @@ handle_telemetry_cmd_ipsec_secgw_stats_routing(const char *cmd __rte_unused, update_statistics(&total_stats, coreid); /* add lpm 4 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(lpm4_data, "miss", - total_stats.lpm4.miss); + rte_tel_data_add_dict_uint(lpm4_data, "miss", total_stats.lpm4.miss); rte_tel_data_add_dict_container(data, "IPv4 LPM", lpm4_data, 0); /* add lpm 6 telemetry key/values pairs */ - rte_tel_data_add_dict_u64(lpm6_data, "miss", - total_stats.lpm6.miss); + rte_tel_data_add_dict_uint(lpm6_data, "miss", total_stats.lpm6.miss); rte_tel_data_add_dict_container(data, "IPv6 LPM", lpm6_data, 0); diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index fd3ade330f..caf26b373e 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -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; } diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 79ea958db4..bc53aab100 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -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; diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index 4da653eec7..8c095e1f35 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -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, diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c index 688dc615d7..3d2fc8e98b 100644 --- a/lib/eal/common/eal_common_memory.c +++ b/lib/eal/common/eal_common_memory.c @@ -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; } diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 28028e5de5..4dd2968a01 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -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"); diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c index cf7bbd4d69..13d7163b79 100644 --- a/lib/eventdev/rte_event_eth_rx_adapter.c +++ b/lib/eventdev/rte_event_eth_rx_adapter.c @@ -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; diff --git a/lib/eventdev/rte_event_timer_adapter.c b/lib/eventdev/rte_event_timer_adapter.c index a0f14bf861..1c3f91605a 100644 --- a/lib/eventdev/rte_event_timer_adapter.c +++ b/lib/eventdev/rte_event_timer_adapter.c @@ -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; } diff --git a/lib/eventdev/rte_eventdev.c b/lib/eventdev/rte_eventdev.c index b0414206d9..027e6a93ce 100644 --- a/lib/eventdev/rte_eventdev.c +++ b/lib/eventdev/rte_eventdev.c @@ -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); diff --git a/lib/ipsec/ipsec_telemetry.c b/lib/ipsec/ipsec_telemetry.c index b184e8df99..90d4b67156 100644 --- a/lib/ipsec/ipsec_telemetry.c +++ b/lib/ipsec/ipsec_telemetry.c @@ -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", diff --git a/lib/rawdev/rte_rawdev.c b/lib/rawdev/rte_rawdev.c index 5fbdb94229..dacaa60e22 100644 --- a/lib/rawdev/rte_rawdev.c +++ b/lib/rawdev/rte_rawdev.c @@ -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; diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c index 68063f6450..e102c55e55 100644 --- a/lib/security/rte_security.c +++ b/lib/security/rte_security.c @@ -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; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v3 6/9] telemetry: mark old names of renamed fns as deprecated 2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson ` (4 preceding siblings ...) 2023-01-12 17:41 ` [PATCH v3 5/9] global: rename telemetry functions to newer versions Bruce Richardson @ 2023-01-12 17:41 ` Bruce Richardson 2023-01-12 17:41 ` [PATCH v3 7/9] telemetry: update json functions to use int/uint in names Bruce Richardson ` (3 subsequent siblings) 9 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 17:41 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Ciara Power 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. Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> --- 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(-) diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index b9b02dcef0..98ad6baed5 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -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. diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index 73a0511807..4598303d5d 100644 --- a/lib/telemetry/rte_telemetry.h +++ b/lib/telemetry/rte_telemetry.h @@ -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 diff --git a/lib/telemetry/version.map b/lib/telemetry/version.map index 0f70d82dfc..d661180317 100644 --- a/lib/telemetry/version.map +++ b/lib/telemetry/version.map @@ -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; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v3 7/9] telemetry: update json functions to use int/uint in names 2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson ` (5 preceding siblings ...) 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 ` Bruce Richardson 2023-01-12 17:41 ` [PATCH v3 8/9] telemetry: make internal int representation 64-bits Bruce Richardson ` (2 subsequent siblings) 9 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 17:41 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power 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. 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> --- 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(-) diff --git a/app/test/test_telemetry_json.c b/app/test/test_telemetry_json.c index 184c3ba9f1..e81e3a8a98 100644 --- a/app/test/test_telemetry_json.c +++ b/app/test/test_telemetry_json.c @@ -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; diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 89bdde8422..655191bcf1 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -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) { diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h index e3fae7c30d..744bbfe053 100644 --- a/lib/telemetry/telemetry_json.h +++ b/lib/telemetry/telemetry_json.h @@ -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; } -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v3 8/9] telemetry: make internal int representation 64-bits 2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson ` (6 preceding siblings ...) 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 ` Bruce Richardson 2023-01-12 17:41 ` [PATCH v3 9/9] telemetry: change public API to use 64-bit signed values Bruce Richardson 2023-01-13 16:39 ` [PATCH v3 0/9] Standardize telemetry int types Power, Ciara 9 siblings, 0 replies; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 17:41 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power The internal storage for int values can be expanded from 32-bit to 64-bit without affecting the external ABI. 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> --- lib/telemetry/telemetry_data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h index 8db6875a81..205509c5a2 100644 --- a/lib/telemetry/telemetry_data.h +++ b/lib/telemetry/telemetry_data.h @@ -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; }; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* [PATCH v3 9/9] telemetry: change public API to use 64-bit signed values 2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson ` (7 preceding siblings ...) 2023-01-12 17:41 ` [PATCH v3 8/9] telemetry: make internal int representation 64-bits Bruce Richardson @ 2023-01-12 17:41 ` Bruce Richardson 2023-02-05 22:55 ` Thomas Monjalon 2023-01-13 16:39 ` [PATCH v3 0/9] Standardize telemetry int types Power, Ciara 9 siblings, 1 reply; 51+ messages in thread From: Bruce Richardson @ 2023-01-12 17:41 UTC (permalink / raw) To: dev; +Cc: Bruce Richardson, Morten Brørup, Tyler Retzlaff, Ciara Power 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. 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> --- 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(-) diff --git a/lib/telemetry/meson.build b/lib/telemetry/meson.build index f84c9aa3be..73750d9ef4 100644 --- a/lib/telemetry/meson.build +++ b/lib/telemetry/meson.build @@ -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 diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h index 4598303d5d..b481c112dd 100644 --- a/lib/telemetry/rte_telemetry.h +++ b/lib/telemetry/rte_telemetry.h @@ -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. diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c index 9a180937fd..ac7be795df 100644 --- a/lib/telemetry/telemetry_data.c +++ b/lib/telemetry/telemetry_data.c @@ -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) diff --git a/lib/telemetry/telemetry_data.h b/lib/telemetry/telemetry_data.h index 205509c5a2..53e4cabea5 100644 --- a/lib/telemetry/telemetry_data.h +++ b/lib/telemetry/telemetry_data.h @@ -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 diff --git a/lib/telemetry/version.map b/lib/telemetry/version.map index d661180317..accfad5011 100644 --- a/lib/telemetry/version.map +++ b/lib/telemetry/version.map @@ -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; -- 2.37.2 ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH v3 9/9] telemetry: change public API to use 64-bit signed values 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 0 siblings, 0 replies; 51+ messages in thread From: Thomas Monjalon @ 2023-02-05 22:55 UTC (permalink / raw) To: Bruce Richardson Cc: dev, Morten Brørup, Tyler Retzlaff, Ciara Power, david.marchand 12/01/2023 18:41, 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 sized -> signed > 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. > > 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> [...] > --- a/lib/telemetry/version.map > +++ b/lib/telemetry/version.map > +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. ^ permalink raw reply [flat|nested] 51+ messages in thread
* RE: [PATCH v3 0/9] Standardize telemetry int types 2023-01-12 17:41 ` [PATCH v3 0/9] Standardize telemetry int types Bruce Richardson ` (8 preceding siblings ...) 2023-01-12 17:41 ` [PATCH v3 9/9] telemetry: change public API to use 64-bit signed values Bruce Richardson @ 2023-01-13 16:39 ` Power, Ciara 2023-02-05 23:15 ` Thomas Monjalon 9 siblings, 1 reply; 51+ messages in thread From: Power, Ciara @ 2023-01-13 16:39 UTC (permalink / raw) To: Richardson, Bruce, dev; +Cc: Richardson, Bruce Hi Bruce, > -----Original Message----- > From: Bruce Richardson <bruce.richardson@intel.com> > Sent: Thursday 12 January 2023 17:41 > To: dev@dpdk.org > Cc: Richardson, Bruce <bruce.richardson@intel.com> > 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(-) > > -- > 2.37.2 Series-Acked-by: Ciara Power <ciara.power@intel.com> ^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [PATCH v3 0/9] Standardize telemetry int types 2023-01-13 16:39 ` [PATCH v3 0/9] Standardize telemetry int types Power, Ciara @ 2023-02-05 23:15 ` Thomas Monjalon 0 siblings, 0 replies; 51+ messages in thread From: Thomas Monjalon @ 2023-02-05 23:15 UTC (permalink / raw) To: Richardson, Bruce; +Cc: dev, Power, Ciara, lihuisong, rjarry 13/01/2023 17:39, Power, Ciara: > > 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 > > Series-Acked-by: Ciara Power <ciara.power@intel.com> It required a bit of rebasing on top of Huisong's patches. Applied, thanks. ^ permalink raw reply [flat|nested] 51+ messages in thread
end of thread, other threads:[~2023-02-05 23:15 UTC | newest] Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 ` [PATCH v2 4/9] telemetry: add uint type as alias for u64 Bruce Richardson 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
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).