27 #define RTE_LPM_NAMESIZE 32 30 #define RTE_LPM_MAX_DEPTH 32 33 #define RTE_LPM_TBL24_NUM_ENTRIES (1 << 24) 36 #define RTE_LPM_TBL8_GROUP_NUM_ENTRIES 256 39 #define RTE_LPM_MAX_TBL8_NUM_GROUPS (1 << 24) 42 #define RTE_LPM_TBL8_NUM_GROUPS 256 45 #define RTE_LPM_TBL8_NUM_ENTRIES (RTE_LPM_TBL8_NUM_GROUPS * \ 46 RTE_LPM_TBL8_GROUP_NUM_ENTRIES) 49 #if defined(RTE_LIBRTE_LPM_DEBUG) 50 #define RTE_LPM_RETURN_IF_TRUE(cond, retval) do { \ 51 if (cond) return (retval); \ 54 #define RTE_LPM_RETURN_IF_TRUE(cond, retval) 58 #define RTE_LPM_VALID_EXT_ENTRY_BITMASK 0x03000000 61 #define RTE_LPM_LOOKUP_SUCCESS 0x01000000 64 #define RTE_LPM_RCU_DQ_RECLAIM_MAX 16 74 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN 77 struct rte_lpm_tbl_entry {
83 uint32_t next_hop :24;
93 uint32_t valid_group :1;
100 struct rte_lpm_tbl_entry {
102 uint32_t valid_group :1;
104 uint32_t next_hop :24;
120 struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
122 struct rte_lpm_tbl_entry *tbl8;
127 struct rte_rcu_qsbr *v;
135 uint32_t reclaim_thd;
136 uint32_t reclaim_max;
225 rte_lpm_add(
struct rte_lpm *lpm, uint32_t ip, uint8_t depth, uint32_t next_hop);
285 unsigned tbl24_index = (ip >> 8);
287 const uint32_t *ptbl;
290 RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (next_hop == NULL)), -EINVAL);
293 ptbl = (
const uint32_t *)(&lpm->tbl24[tbl24_index]);
301 if (
unlikely((tbl_entry & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
302 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
304 unsigned tbl8_index = (uint8_t)ip +
305 (((uint32_t)tbl_entry & 0x00FFFFFF) *
306 RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
308 ptbl = (
const uint32_t *)&lpm->tbl8[tbl8_index];
312 *next_hop = ((uint32_t)tbl_entry & 0x00FFFFFF);
336 #define rte_lpm_lookup_bulk(lpm, ips, next_hops, n) \ 337 rte_lpm_lookup_bulk_func(lpm, ips, next_hops, n) 340 rte_lpm_lookup_bulk_func(
const struct rte_lpm *lpm,
const uint32_t *ips,
341 uint32_t *next_hops,
const unsigned n)
344 unsigned tbl24_indexes[n];
345 const uint32_t *ptbl;
348 RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (ips == NULL) ||
349 (next_hops == NULL)), -EINVAL);
351 for (i = 0; i < n; i++) {
352 tbl24_indexes[i] = ips[i] >> 8;
355 for (i = 0; i < n; i++) {
357 ptbl = (
const uint32_t *)&lpm->tbl24[tbl24_indexes[i]];
358 next_hops[i] = *ptbl;
361 if (
unlikely((next_hops[i] & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
362 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
364 unsigned tbl8_index = (uint8_t)ips[i] +
365 (((uint32_t)next_hops[i] & 0x00FFFFFF) *
366 RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
368 ptbl = (
const uint32_t *)&lpm->tbl8[tbl8_index];
369 next_hops[i] = *ptbl;
376 #define RTE_LPM_MASKX4_RES UINT64_C(0x00ffffff00ffffff) 401 #if defined(RTE_ARCH_ARM) 402 #ifdef RTE_HAS_SVE_ACLE 403 #include "rte_lpm_sve.h" 405 #include "rte_lpm_neon.h" 407 #elif defined(RTE_ARCH_PPC_64) 408 #include "rte_lpm_altivec.h" 409 #elif defined(RTE_ARCH_X86) 410 #include "rte_lpm_sse.h" 412 #include "rte_lpm_scalar.h"
void rte_lpm_free(struct rte_lpm *lpm)
__rte_experimental int rte_lpm_rcu_qsbr_add(struct rte_lpm *lpm, struct rte_lpm_rcu_config *cfg)
struct rte_lpm * rte_lpm_create(const char *name, int socket_id, const struct rte_lpm_config *config)
void rte_lpm_delete_all(struct rte_lpm *lpm)
static int rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
static void rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], uint32_t defv)
int rte_lpm_delete(struct rte_lpm *lpm, uint32_t ip, uint8_t depth)
#define RTE_LPM_LOOKUP_SUCCESS
int rte_lpm_add(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, uint32_t next_hop)
int rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, uint32_t *next_hop)
struct rte_lpm * rte_lpm_find_existing(const char *name)