28 #define TRIE_TBL24_NUM_ENT (1 << 24)
30 #define TRIE_MAX_DEPTH 128
32 #define TRIE_TBL8_GRP_NUM_ENT 256ULL
34 #define TRIE_TBL8_NUM_GROUPS 65536
36 #define TRIE_EXT_ENT 1
38 #define BITMAP_SLAB_BIT_SIZE_LOG2 6
39 #define BITMAP_SLAB_BIT_SIZE (1ULL << BITMAP_SLAB_BIT_SIZE_LOG2)
40 #define BITMAP_SLAB_BITMASK (BITMAP_SLAB_BIT_SIZE - 1)
43 uint32_t number_tbl8s;
50 uint32_t tbl8_pool_pos;
55 static inline uint32_t
56 get_tbl24_idx(
const uint8_t *ip)
58 return ip[0] << 16 | ip[1] << 8 | ip[2];
62 get_tbl24_p(
struct cne_trie_tbl *dp,
const uint8_t *ip, uint8_t nh_sz)
66 tbl24_idx = get_tbl24_idx(ip);
67 return (
void *)&((uint8_t *)dp->tbl24)[tbl24_idx << nh_sz];
71 bits_in_nh(uint8_t nh_sz)
73 return 8 * (1 << nh_sz);
76 static inline uint64_t
77 get_max_nh(uint8_t nh_sz)
79 return ((1ULL << (bits_in_nh(nh_sz) - 1)) - 1);
82 static inline uint64_t
83 lookup_msk(uint8_t nh_sz)
85 return ((1ULL << ((1 << (nh_sz + 3)) - 1)) << 1) - 1;
89 get_psd_idx(uint32_t val, uint8_t nh_sz)
91 return val & ((1 << (3 - nh_sz)) - 1);
94 static inline uint32_t
95 get_tbl_pos(uint32_t val, uint8_t nh_sz)
97 return val >> (3 - nh_sz);
100 static inline uint64_t
101 get_tbl_val_by_idx(uint64_t *tbl, uint32_t idx, uint8_t nh_sz)
103 return ((tbl[get_tbl_pos(idx, nh_sz)] >> (get_psd_idx(idx, nh_sz) * bits_in_nh(nh_sz))) &
108 get_tbl_p_by_idx(uint64_t *tbl, uint64_t idx, uint8_t nh_sz)
110 return (uint8_t *)tbl + (idx << nh_sz);
114 is_entry_extended(uint64_t ent)
116 return (ent & TRIE_EXT_ENT) == TRIE_EXT_ENT;
119 #define LOOKUP_FUNC(suffix, type, nh_sz) \
120 static inline void cne_trie_lookup_bulk_##suffix(void *p, \
121 uint8_t ips[][CNE_FIB6_IPV6_ADDR_SIZE], \
122 uint64_t *next_hops, const unsigned int n) \
124 struct cne_trie_tbl *dp = (struct cne_trie_tbl *)p; \
128 for (i = 0; i < n; i++) { \
129 tmp = ((type *)dp->tbl24)[get_tbl24_idx(&ips[i][0])]; \
131 while (is_entry_extended(tmp)) { \
132 tmp = ((type *)dp->tbl8)[ips[i][j++] + ((tmp >> 1) * TRIE_TBL8_GRP_NUM_ENT)]; \
134 next_hops[i] = tmp >> 1; \
137 LOOKUP_FUNC(2b, uint16_t, 1)
138 LOOKUP_FUNC(4b, uint32_t, 2)
139 LOOKUP_FUNC(8b, uint64_t, 3)
141 void *trie_create(const
char *name, struct
cne_fib6_conf *conf);
143 void trie_free(
void *p);
148 uint64_t next_hop,
int op);
#define __cne_cache_aligned
#define CNE_FIB6_IPV6_ADDR_SIZE
void(* cne_fib6_lookup_fn_t)(void *fib, uint8_t ips[][CNE_FIB6_IPV6_ADDR_SIZE], uint64_t *next_hops, const unsigned int n)