From: Michal Mazurek Date: Wed, 1 Jun 2022 11:15:42 +0000 (+0200) Subject: lpm: add scalar version of lookupx4 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=406937f89ffd96b5de5d407b2a938e1664d2e82f;p=dpdk.git lpm: add scalar version of lookupx4 Add an implementation of the rte_lpm_lookupx4() function for platforms without support for vector operations. This will be useful in the upcoming RISC-V port as well as any platform which may want to start with a basic level of LPM support. Signed-off-by: Michal Mazurek Signed-off-by: Stanislaw Kardach Acked-by: Vladimir Medvedkin --- diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index 557eac4b33..ce43b262b2 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -113,6 +113,12 @@ New Features * ``RTE_EVENT_QUEUE_ATTR_WEIGHT`` * ``RTE_EVENT_QUEUE_ATTR_AFFINITY`` +* **Added scalar version of the LPM library.** + + Added scalar implementation of ``rte_lpm_lookupx4``. + This is a fall-back implementation for platforms that + don't support vector operations. + Removed Items ------------- diff --git a/lib/lpm/meson.build b/lib/lpm/meson.build index 78d91d3421..6b47361fce 100644 --- a/lib/lpm/meson.build +++ b/lib/lpm/meson.build @@ -14,6 +14,7 @@ headers = files('rte_lpm.h', 'rte_lpm6.h') indirect_headers += files( 'rte_lpm_altivec.h', 'rte_lpm_neon.h', + 'rte_lpm_scalar.h', 'rte_lpm_sse.h', 'rte_lpm_sve.h', ) diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index 1cf863a146..4f38864fde 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -405,8 +405,10 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], #endif #elif defined(RTE_ARCH_PPC_64) #include "rte_lpm_altivec.h" -#else +#elif defined(RTE_ARCH_X86) #include "rte_lpm_sse.h" +#else +#include "rte_lpm_scalar.h" #endif #ifdef __cplusplus diff --git a/lib/lpm/rte_lpm_scalar.h b/lib/lpm/rte_lpm_scalar.h new file mode 100644 index 0000000000..f0d9f37894 --- /dev/null +++ b/lib/lpm/rte_lpm_scalar.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2022 StarFive + * Copyright(c) 2022 SiFive + * Copyright(c) 2022 Semihalf + */ + +#ifndef _RTE_LPM_SCALAR_H_ +#define _RTE_LPM_SCALAR_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static inline void +rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], + uint32_t defv) +{ + uint32_t nh; + int ret; + + ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[0], &nh); + hop[0] = (ret == 0) ? nh : defv; + ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[1], &nh); + hop[1] = (ret == 0) ? nh : defv; + ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[2], &nh); + hop[2] = (ret == 0) ? nh : defv; + ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[3], &nh); + hop[3] = (ret == 0) ? nh : defv; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_LPM_SCALAR_H_ */