> From: Honnappa Nagarahalli [mailto:honnappa.nagaraha...@arm.com] > Sent: Thursday, 9 March 2023 05.58 > > Simple API to check if the lcore ID does not exceed the > maximum number of lcores configured. > > Signed-off-by: Honnappa Nagarahalli <honnappa.nagaraha...@arm.com> > Reviewed-by: Ruifeng Wang <ruifeng.w...@arm.com> > --- > lib/eal/include/rte_lcore.h | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h > index 6a355e9986..cf99919a02 100644 > --- a/lib/eal/include/rte_lcore.h > +++ b/lib/eal/include/rte_lcore.h > @@ -38,6 +38,20 @@ enum rte_lcore_role_t { > ROLE_NON_EAL, > }; > > +/** > + * Check if the lcore ID is valid > + * > + * @param lcore_id > + * The identifier of the lcore. > + * > + * @return > + * True if the given lcore ID is between 0 and RTE_MAX_LCORE-1. > + */ > +static inline int rte_lcore_id_is_valid(unsigned int lcore_id) > +{ > + return (lcore_id < RTE_MAX_LCORE); > +} > + > /** > * Get a lcore's role. > * > -- > 2.25.1 >
Isn't LCORE_ID_ANY considered valid in some contexts? I don't think this function adds any value; it only makes the lcore_id interpretation more opaque. Having this comparison, i.e. (lcore_id < RTE_MAX_LCORE), directly in the source code makes it more easily readable than a call to this function. So, NAK from me.