From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B46A6423B9; Thu, 12 Jan 2023 18:42:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2474242DCF; Thu, 12 Jan 2023 18:42:16 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 1DC9942DD2 for ; Thu, 12 Jan 2023 18:42:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673545335; x=1705081335; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l3PjSvXq1OyIVzUGA8CakUncJZvu8ZjjMEiXYThDxwA=; b=QmhNiB9/IMbkDBGhAm9jjfZWTrp7WGrfZv0SaE4/mjvv7ypgrvXEo3YV /mYnzm2gPwb/z5Uk1+zug4CP102bsQt6cCZBJ7xIUJqpaItkxG8EDejeB LYv233fIdjdUMt3ehO/JAQR6n54Kh7oVg0ohCKfgIUAb0JLJ1mx3nCyUh Fq498fVP12hmsGGgGaHNXqOMGntXo9HSlkvf75nn3KK5FhzbX5y8TiTTe A9QQMobghoJSQc13dHj0dGAaQ6aT1Ttg7jpScUOol/WNHzbpdVX8mO0nw Gh5fhoQuKkgL0JdNC6/lpNlgvloHIaVilrLKWi3jH3e6yNVTYbVG6Nd67 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="388264953" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="388264953" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 09:42:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="986678247" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="986678247" Received: from silpixa00401385.ir.intel.com ([10.237.214.166]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 09:42:13 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Tyler Retzlaff , Ciara Power Subject: [PATCH v3 9/9] telemetry: change public API to use 64-bit signed values Date: Thu, 12 Jan 2023 17:41:16 +0000 Message-Id: <20230112174116.2105237-10-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230112174116.2105237-1-bruce.richardson@intel.com> References: <20221213182730.97065-1-bruce.richardson@intel.com> <20230112174116.2105237-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Signed-off-by: Bruce Richardson Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- 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 +#include #include #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