From 48c33e8ceeaf323976b0d26ee976f43829acfb43 Mon Sep 17 00:00:00 2001 From: Sivaprasad Tummala Date: Thu, 10 Aug 2023 23:07:55 -0700 Subject: [PATCH] eal: remove number of cpuflags from API The RTE_CPUFLAG_NUMFLAGS enum value was mainly a canary for internal use. Yet, it could be passed by an application to rte_cpu_get_flag_enabled() / rte_cpu_get_flag_name(). So, even though passing this value to those functions is debattable, changing its meaning (by adding a new CPU feature for example) would impact ABI compatibility. This patch removes RTE_CPUFLAG_NUMFLAGS to avoid such future ABI compatibility issue. Signed-off-by: Sivaprasad Tummala Signed-off-by: David Marchand --- app/test/test_cpuflags.c | 10 ---------- doc/guides/rel_notes/deprecation.rst | 3 --- doc/guides/rel_notes/release_23_11.rst | 3 +++ lib/eal/arm/include/rte_cpuflags_32.h | 2 -- lib/eal/arm/include/rte_cpuflags_64.h | 2 -- lib/eal/arm/rte_cpuflags.c | 4 ++-- lib/eal/loongarch/include/rte_cpuflags.h | 2 -- lib/eal/loongarch/rte_cpuflags.c | 4 ++-- lib/eal/ppc/include/rte_cpuflags.h | 2 -- lib/eal/ppc/rte_cpuflags.c | 4 ++-- lib/eal/riscv/include/rte_cpuflags.h | 2 -- lib/eal/riscv/rte_cpuflags.c | 4 ++-- lib/eal/x86/include/rte_cpuflags.h | 3 --- lib/eal/x86/rte_cpuflags.c | 4 ++-- 14 files changed, 13 insertions(+), 36 deletions(-) diff --git a/app/test/test_cpuflags.c b/app/test/test_cpuflags.c index 4de06983d92..a0ff74720c8 100644 --- a/app/test/test_cpuflags.c +++ b/app/test/test_cpuflags.c @@ -42,7 +42,6 @@ cpu_flag_result(int result) * =========== * * - Check flags from different registers with rte_cpu_get_flag_enabled() - * - Check if register and CPUID functions fail properly */ static int @@ -322,15 +321,6 @@ test_cpuflags(void) CHECK_FOR_FLAG(RTE_CPUFLAG_LBT_MIPS); #endif - /* - * Check if invalid data is handled properly - */ - printf("\nCheck for invalid flag:\t"); - result = rte_cpu_get_flag_enabled(RTE_CPUFLAG_NUMFLAGS); - printf("%s\n", cpu_flag_result(result)); - if (result != -ENOENT) - return -1; - return 0; } diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 9c3abcc77bd..1c56514f0f0 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -29,9 +29,6 @@ Deprecation Notices 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. -* eal: ``RTE_CPUFLAG_NUMFLAGS`` will be removed in DPDK 23.11 release. - This is to allow new CPU features to be added without ABI breakage. - * rte_atomicNN_xxx: These APIs do not take memory order parameter. This does not allow for writing optimized code for all the CPU architectures supported in DPDK. DPDK has adopted the atomic operations from diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index 9319c86cd83..eaa1d58f326 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -139,6 +139,9 @@ API Changes except ``rte_thread_setname()`` and ``rte_ctrl_thread_create()`` which are replaced with ``rte_thread_set_name()`` and ``rte_thread_create_control()``. +* eal: Removed ``RTE_CPUFLAG_NUMFLAGS`` to avoid misusage and theoretical ABI + compatibility issue when adding new cpuflags. + * bonding: Replaced master/slave to main/member. The data structure ``struct rte_eth_bond_8023ad_slave_info`` was renamed to ``struct rte_eth_bond_8023ad_member_info`` in DPDK 23.11. diff --git a/lib/eal/arm/include/rte_cpuflags_32.h b/lib/eal/arm/include/rte_cpuflags_32.h index 4e254428a2a..770b09b99d9 100644 --- a/lib/eal/arm/include/rte_cpuflags_32.h +++ b/lib/eal/arm/include/rte_cpuflags_32.h @@ -42,8 +42,6 @@ enum rte_cpu_flag_t { RTE_CPUFLAG_CRC32, RTE_CPUFLAG_V7L, RTE_CPUFLAG_V8L, - /* The last item */ - RTE_CPUFLAG_NUMFLAGS,/**< This should always be the last! */ }; #include "generic/rte_cpuflags.h" diff --git a/lib/eal/arm/include/rte_cpuflags_64.h b/lib/eal/arm/include/rte_cpuflags_64.h index aa7a56d4915..afe70209c38 100644 --- a/lib/eal/arm/include/rte_cpuflags_64.h +++ b/lib/eal/arm/include/rte_cpuflags_64.h @@ -36,8 +36,6 @@ enum rte_cpu_flag_t { RTE_CPUFLAG_SVEF64MM, RTE_CPUFLAG_SVEBF16, RTE_CPUFLAG_AARCH64, - /* The last item */ - RTE_CPUFLAG_NUMFLAGS,/**< This should always be the last! */ }; #include "generic/rte_cpuflags.h" diff --git a/lib/eal/arm/rte_cpuflags.c b/lib/eal/arm/rte_cpuflags.c index 56e7b2e6890..7ba4f8ba973 100644 --- a/lib/eal/arm/rte_cpuflags.c +++ b/lib/eal/arm/rte_cpuflags.c @@ -140,7 +140,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) const struct feature_entry *feat; hwcap_registers_t regs = {0}; - if (feature >= RTE_CPUFLAG_NUMFLAGS) + if ((unsigned int)feature >= RTE_DIM(rte_cpu_feature_table)) return -ENOENT; feat = &rte_cpu_feature_table[feature]; @@ -154,7 +154,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) const char * rte_cpu_get_flag_name(enum rte_cpu_flag_t feature) { - if (feature >= RTE_CPUFLAG_NUMFLAGS) + if ((unsigned int)feature >= RTE_DIM(rte_cpu_feature_table)) return NULL; return rte_cpu_feature_table[feature].name; } diff --git a/lib/eal/loongarch/include/rte_cpuflags.h b/lib/eal/loongarch/include/rte_cpuflags.h index 1c80779262c..6b592c147cd 100644 --- a/lib/eal/loongarch/include/rte_cpuflags.h +++ b/lib/eal/loongarch/include/rte_cpuflags.h @@ -26,8 +26,6 @@ enum rte_cpu_flag_t { RTE_CPUFLAG_LBT_X86, RTE_CPUFLAG_LBT_ARM, RTE_CPUFLAG_LBT_MIPS, - /* The last item */ - RTE_CPUFLAG_NUMFLAGS /**< This should always be the last! */ }; #include "generic/rte_cpuflags.h" diff --git a/lib/eal/loongarch/rte_cpuflags.c b/lib/eal/loongarch/rte_cpuflags.c index 0a75ca58d42..db9e28ef209 100644 --- a/lib/eal/loongarch/rte_cpuflags.c +++ b/lib/eal/loongarch/rte_cpuflags.c @@ -67,7 +67,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) const struct feature_entry *feat; hwcap_registers_t regs = {0}; - if (feature >= RTE_CPUFLAG_NUMFLAGS) + if ((unsigned int)feature >= RTE_DIM(rte_cpu_feature_table)) return -ENOENT; feat = &rte_cpu_feature_table[feature]; @@ -81,7 +81,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) const char * rte_cpu_get_flag_name(enum rte_cpu_flag_t feature) { - if (feature >= RTE_CPUFLAG_NUMFLAGS) + if ((unsigned int)feature >= RTE_DIM(rte_cpu_feature_table)) return NULL; return rte_cpu_feature_table[feature].name; } diff --git a/lib/eal/ppc/include/rte_cpuflags.h b/lib/eal/ppc/include/rte_cpuflags.h index a88355d170b..dedc1ab4691 100644 --- a/lib/eal/ppc/include/rte_cpuflags.h +++ b/lib/eal/ppc/include/rte_cpuflags.h @@ -48,8 +48,6 @@ enum rte_cpu_flag_t { RTE_CPUFLAG_DSCR, RTE_CPUFLAG_HTM, RTE_CPUFLAG_ARCH_2_07, - /* The last item */ - RTE_CPUFLAG_NUMFLAGS,/**< This should always be the last! */ }; #include "generic/rte_cpuflags.h" diff --git a/lib/eal/ppc/rte_cpuflags.c b/lib/eal/ppc/rte_cpuflags.c index 61db5c216d7..d276c2cf88f 100644 --- a/lib/eal/ppc/rte_cpuflags.c +++ b/lib/eal/ppc/rte_cpuflags.c @@ -91,7 +91,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) const struct feature_entry *feat; hwcap_registers_t regs = {0}; - if (feature >= RTE_CPUFLAG_NUMFLAGS) + if ((unsigned int)feature >= RTE_DIM(rte_cpu_feature_table)) return -ENOENT; feat = &rte_cpu_feature_table[feature]; @@ -105,7 +105,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) const char * rte_cpu_get_flag_name(enum rte_cpu_flag_t feature) { - if (feature >= RTE_CPUFLAG_NUMFLAGS) + if ((unsigned int)feature >= RTE_DIM(rte_cpu_feature_table)) return NULL; return rte_cpu_feature_table[feature].name; } diff --git a/lib/eal/riscv/include/rte_cpuflags.h b/lib/eal/riscv/include/rte_cpuflags.h index 66e787f8983..d742efc40ff 100644 --- a/lib/eal/riscv/include/rte_cpuflags.h +++ b/lib/eal/riscv/include/rte_cpuflags.h @@ -42,8 +42,6 @@ enum rte_cpu_flag_t { RTE_CPUFLAG_RISCV_ISA_X, /* Non-standard extension present */ RTE_CPUFLAG_RISCV_ISA_Y, /* Reserved */ RTE_CPUFLAG_RISCV_ISA_Z, /* Reserved */ - /* The last item */ - RTE_CPUFLAG_NUMFLAGS,/**< This should always be the last! */ }; #include "generic/rte_cpuflags.h" diff --git a/lib/eal/riscv/rte_cpuflags.c b/lib/eal/riscv/rte_cpuflags.c index 4f6d29b9477..eb4105c18be 100644 --- a/lib/eal/riscv/rte_cpuflags.c +++ b/lib/eal/riscv/rte_cpuflags.c @@ -96,7 +96,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) const struct feature_entry *feat; hwcap_registers_t regs = {0}; - if (feature >= RTE_CPUFLAG_NUMFLAGS) + if ((unsigned int)feature >= RTE_DIM(rte_cpu_feature_table)) return -ENOENT; feat = &rte_cpu_feature_table[feature]; @@ -110,7 +110,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) const char * rte_cpu_get_flag_name(enum rte_cpu_flag_t feature) { - if (feature >= RTE_CPUFLAG_NUMFLAGS) + if ((unsigned int)feature >= RTE_DIM(rte_cpu_feature_table)) return NULL; return rte_cpu_feature_table[feature].name; } diff --git a/lib/eal/x86/include/rte_cpuflags.h b/lib/eal/x86/include/rte_cpuflags.h index 92e90fb6e0f..d95bf33a165 100644 --- a/lib/eal/x86/include/rte_cpuflags.h +++ b/lib/eal/x86/include/rte_cpuflags.h @@ -133,9 +133,6 @@ enum rte_cpu_flag_t { RTE_CPUFLAG_AVX512VP2INTERSECT, /**< AVX512 Two Register Intersection */ RTE_CPUFLAG_WAITPKG, /**< UMONITOR/UMWAIT/TPAUSE */ - - /* The last item */ - RTE_CPUFLAG_NUMFLAGS, /**< This should always be the last! */ }; #include "generic/rte_cpuflags.h" diff --git a/lib/eal/x86/rte_cpuflags.c b/lib/eal/x86/rte_cpuflags.c index 8a30f79b441..3fb1cb9bab1 100644 --- a/lib/eal/x86/rte_cpuflags.c +++ b/lib/eal/x86/rte_cpuflags.c @@ -150,7 +150,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) cpuid_registers_t regs; unsigned int maxleaf; - if (feature >= RTE_CPUFLAG_NUMFLAGS) + if ((unsigned int)feature >= RTE_DIM(rte_cpu_feature_table)) /* Flag does not match anything in the feature tables */ return -ENOENT; @@ -180,7 +180,7 @@ rte_cpu_get_flag_enabled(enum rte_cpu_flag_t feature) const char * rte_cpu_get_flag_name(enum rte_cpu_flag_t feature) { - if (feature >= RTE_CPUFLAG_NUMFLAGS) + if ((unsigned int)feature >= RTE_DIM(rte_cpu_feature_table)) return NULL; return rte_cpu_feature_table[feature].name; }