DPDK  25.11.0
rte_lpm_rvv.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2025 Institute of Software Chinese Academy of Sciences (ISCAS).
3  */
4 
5 #ifndef _RTE_LPM_RVV_H_
6 #define _RTE_LPM_RVV_H_
7 
8 #include <rte_vect.h>
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 #define RTE_LPM_LOOKUP_SUCCESS 0x01000000
15 #define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x03000000
16 
17 static inline void rte_lpm_lookupx4(
18  const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], uint32_t defv)
19 {
20  size_t vl = 4;
21 
22  const uint32_t *tbl24_p = (const uint32_t *)lpm->tbl24;
23  uint32_t tbl_entries[4] = {
24  tbl24_p[((uint32_t)ip[0]) >> 8],
25  tbl24_p[((uint32_t)ip[1]) >> 8],
26  tbl24_p[((uint32_t)ip[2]) >> 8],
27  tbl24_p[((uint32_t)ip[3]) >> 8],
28  };
29  vuint32m1_t vtbl_entry = __riscv_vle32_v_u32m1(tbl_entries, vl);
30 
31  vbool32_t mask = __riscv_vmseq_vx_u32m1_b32(
32  __riscv_vand_vx_u32m1(vtbl_entry, RTE_LPM_VALID_EXT_ENTRY_BITMASK, vl),
33  RTE_LPM_VALID_EXT_ENTRY_BITMASK, vl);
34 
35  vuint32m1_t vtbl8_index = __riscv_vsll_vx_u32m1(
36  __riscv_vadd_vv_u32m1(
37  __riscv_vsll_vx_u32m1(__riscv_vand_vx_u32m1(vtbl_entry, 0x00FFFFFF, vl), 8, vl),
38  __riscv_vand_vx_u32m1(
39  __riscv_vle32_v_u32m1((const uint32_t *)&ip, vl), 0x000000FF, vl),
40  vl),
41  2, vl);
42 
43  vtbl_entry = __riscv_vluxei32_v_u32m1_mu(
44  mask, vtbl_entry, (const uint32_t *)(lpm->tbl8), vtbl8_index, vl);
45 
46  vuint32m1_t vnext_hop = __riscv_vand_vx_u32m1(vtbl_entry, 0x00FFFFFF, vl);
47  mask = __riscv_vmseq_vx_u32m1_b32(
48  __riscv_vand_vx_u32m1(vtbl_entry, RTE_LPM_LOOKUP_SUCCESS, vl), 0, vl);
49 
50  vnext_hop = __riscv_vmerge_vxm_u32m1(vnext_hop, defv, mask, vl);
51 
52  __riscv_vse32_v_u32m1(hop, vnext_hop, vl);
53 }
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 
59 #endif /* _RTE_LPM_RVV_H_ */
static void rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], uint32_t defv)
#define RTE_LPM_LOOKUP_SUCCESS
Definition: rte_lpm.h:63