DPDK  22.11.1
rte_lpm_sve.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2020 Arm Limited
3  */
4 
5 #ifndef _RTE_LPM_SVE_H_
6 #define _RTE_LPM_SVE_H_
7 
8 #include <rte_compat.h>
9 #include <rte_vect.h>
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 __rte_internal
16 static void
17 __rte_lpm_lookup_vec(const struct rte_lpm *lpm, const uint32_t *ips,
18  uint32_t *__rte_restrict next_hops, const uint32_t n)
19 {
20  uint32_t i = 0;
21  svuint32_t v_ip, v_idx, v_tbl24, v_tbl8, v_hop;
22  svuint32_t v_mask_xv, v_mask_v, v_mask_hop;
23  svbool_t pg = svwhilelt_b32(i, n);
24  svbool_t pv;
25 
26  do {
27  v_ip = svld1(pg, &ips[i]);
28  /* Get indices for tbl24[] */
29  v_idx = svlsr_x(pg, v_ip, 8);
30  /* Extract values from tbl24[] */
31  v_tbl24 = svld1_gather_index(pg, (const uint32_t *)lpm->tbl24,
32  v_idx);
33 
34  /* Create mask with valid set */
35  v_mask_v = svdup_u32_z(pg, RTE_LPM_LOOKUP_SUCCESS);
36  /* Create mask with valid and valid_group set */
37  v_mask_xv = svdup_u32_z(pg, RTE_LPM_VALID_EXT_ENTRY_BITMASK);
38  /* Create predicate for tbl24 entries: (valid && !valid_group) */
39  pv = svcmpeq(pg, svand_z(pg, v_tbl24, v_mask_xv), v_mask_v);
40  /* Create mask for next_hop in table entry */
41  v_mask_hop = svdup_u32_z(pg, 0x00ffffff);
42  /* Extract next_hop and write back */
43  v_hop = svand_x(pv, v_tbl24, v_mask_hop);
44  svst1(pv, &next_hops[i], v_hop);
45 
46  /* Update predicate for tbl24 entries: (valid && valid_group) */
47  pv = svcmpeq(pg, svand_z(pg, v_tbl24, v_mask_xv), v_mask_xv);
48  /* Compute tbl8 index */
49  v_idx = svand_x(pv, v_tbl24, svdup_u32_z(pv, 0xffffff));
50  v_idx = svmul_x(pv, v_idx, RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
51  v_idx = svadd_x(pv, svand_x(pv, v_ip, svdup_u32_z(pv, 0xff)),
52  v_idx);
53  /* Extract values from tbl8[] */
54  v_tbl8 = svld1_gather_index(pv, (const uint32_t *)lpm->tbl8,
55  v_idx);
56  /* Update predicate for tbl8 entries: (valid) */
57  pv = svcmpeq(pv, svand_z(pv, v_tbl8, v_mask_v), v_mask_v);
58  /* Extract next_hop and write back */
59  v_hop = svand_x(pv, v_tbl8, v_mask_hop);
60  svst1(pv, &next_hops[i], v_hop);
61 
62  i += svlen(v_ip);
63  pg = svwhilelt_b32(i, n);
64  } while (svptest_any(svptrue_b32(), pg));
65 }
66 
67 static inline void
68 rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4],
69  uint32_t defv)
70 {
71  uint32_t i, ips[4];
72 
73  vst1q_s32((int32_t *)ips, ip);
74  for (i = 0; i < 4; i++)
75  hop[i] = defv;
76 
77  __rte_lpm_lookup_vec(lpm, ips, hop, 4);
78 }
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif /* _RTE_LPM_SVE_H_ */
static void rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], uint32_t defv)
#define __rte_restrict
Definition: rte_common.h:126
#define RTE_LPM_LOOKUP_SUCCESS
Definition: rte_lpm.h:62