lpm: add scalar version of lookupx4
[dpdk.git] / lib / lpm / rte_lpm_scalar.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2022 StarFive
3  * Copyright(c) 2022 SiFive
4  * Copyright(c) 2022 Semihalf
5  */
6
7 #ifndef _RTE_LPM_SCALAR_H_
8 #define _RTE_LPM_SCALAR_H_
9
10 #include <rte_vect.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 static inline void
17 rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4],
18                 uint32_t defv)
19 {
20         uint32_t nh;
21         int ret;
22
23         ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[0], &nh);
24         hop[0] = (ret == 0) ? nh : defv;
25         ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[1], &nh);
26         hop[1] = (ret == 0) ? nh : defv;
27         ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[2], &nh);
28         hop[2] = (ret == 0) ? nh : defv;
29         ret = rte_lpm_lookup(lpm, ((rte_xmm_t)ip).u32[3], &nh);
30         hop[3] = (ret == 0) ? nh : defv;
31 }
32
33 #ifdef __cplusplus
34 }
35 #endif
36
37 #endif /* _RTE_LPM_SCALAR_H_ */