53 #ifdef CLIB_HAVE_VEC128 70 for (l = p->leaves_as_u32x4;
71 l < p->leaves_as_u32x4 +
ARRAY_LEN (p->leaves_as_u32x4); l += 4)
103 ply_init (p, init_leaf, prefix_len);
181 uword new_leaf_dst_address_bits)
198 new_leaf_dst_address_bits);
202 else if (new_leaf_dst_address_bits >=
205 __sync_val_compare_and_swap (&ply->
leaves[i], old_leaf, new_leaf);
216 u32 old_ply_index,
u32 dst_address_byte_index)
219 i32 n_dst_bits_next_plies;
225 n_dst_bits_next_plies =
231 if (n_dst_bits_next_plies <= 0)
233 uword i, n_dst_bits_this_ply, old_leaf_is_terminal;
235 n_dst_bits_this_ply = -n_dst_bits_next_plies;
239 for (i = dst_byte; i < dst_byte + (1 << n_dst_bits_this_ply); i++)
253 if (old_leaf_is_terminal)
257 __sync_val_compare_and_swap (&old_ply->
leaves[i], old_leaf,
275 else if (!old_leaf_is_terminal)
279 dst_address_byte_index + 1);
288 old_leaf = old_ply->
leaves[dst_byte];
299 __sync_val_compare_and_swap (&old_ply->
leaves[dst_byte], old_leaf,
324 i32 n_dst_bits_next_plies;
325 i32 i, n_dst_bits_this_ply, old_leaf_is_terminal;
331 n_dst_bits_next_plies =
335 if (n_dst_bits_next_plies < 0)
336 dst_byte &= ~
pow2_mask (-n_dst_bits_next_plies);
338 n_dst_bits_this_ply =
339 n_dst_bits_next_plies <= 0 ? -n_dst_bits_next_plies : 0;
340 n_dst_bits_this_ply =
clib_min (8, n_dst_bits_this_ply);
344 for (i = dst_byte; i < dst_byte + (1 << n_dst_bits_this_ply); i++)
349 if (old_leaf == del_leaf
350 || (!old_leaf_is_terminal
352 dst_address_byte_index + 1)))
379 memset (m, 0,
sizeof (m[0]));
389 u32 dst_address_length,
390 u32 adj_index,
u32 is_del)
409 if (dst_address_length == 0)
416 if (dst_address_length == 0)
427 for (i = dst_address_length - 1; i >= 1; i--)
470 bytes =
sizeof (p[0]);
499 u32 base_address = va_arg (*va,
u32);
500 u32 ply_index = va_arg (*va,
u32);
501 u32 dst_address_byte_index = va_arg (*va,
u32);
508 format (s,
"ply index %d, %d non-empty leaves", ply_index,
519 a = base_address + (i << (24 - 8 * dst_address_byte_index));
520 ia.
as_u32 = clib_host_to_net_u32 (a);
524 ia_length = 8 * (1 + dst_address_byte_index);
525 s =
format (s,
"\n%U%20U %U",
535 dst_address_byte_index + 1);
547 s =
format (s,
"%d plies, memory usage %U",
u8 dst_address_bits_of_leaves[256]
sll srl srl sll sra u16x4 i
static u32 ip4_fib_mtrie_leaf_get_next_ply_index(ip4_fib_mtrie_leaf_t n)
static ip4_fib_mtrie_ply_t * get_next_ply_for_leaf(ip4_fib_mtrie_t *m, ip4_fib_mtrie_leaf_t l)
static void ply_free(ip4_fib_mtrie_t *m, ip4_fib_mtrie_ply_t *p)
const dpo_id_t * fib_entry_contribute_ip_forwarding(fib_node_index_t fib_entry_index)
static u32 ip4_fib_mtrie_leaf_is_next_ply(ip4_fib_mtrie_leaf_t n)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
add_epi add_epi sub_epi sub_epi adds_epu subs_epu i16x8 y
static ip4_fib_mtrie_leaf_t ip4_fib_mtrie_leaf_set_next_ply_index(u32 i)
#define IP4_FIB_MTRIE_LEAF_EMPTY
void ip4_fib_free(ip4_fib_mtrie_t *m)
ip4_fib_mtrie_ply_t * ply_pool
static uword pow2_mask(uword x)
void ip4_fib_mtrie_add_del_route(ip4_fib_t *fib, ip4_address_t dst_address, u32 dst_address_length, u32 adj_index, u32 is_del)
static u32 ip4_fib_mtrie_leaf_get_adj_index(ip4_fib_mtrie_leaf_t n)
void ip4_mtrie_init(ip4_fib_mtrie_t *m)
static u8 * format_ip4_fib_mtrie_leaf(u8 *s, va_list *va)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
uword * fib_entry_by_dst_address[33]
static void ply_init(ip4_fib_mtrie_ply_t *p, ip4_fib_mtrie_leaf_t init, uword prefix_len)
static uword unset_leaf(ip4_fib_mtrie_t *m, ip4_fib_mtrie_set_unset_leaf_args_t *a, ip4_fib_mtrie_ply_t *old_ply, u32 dst_address_byte_index)
u8 * format_ip4_fib_mtrie(u8 *s, va_list *va)
#define pool_put(P, E)
Free an object E in pool P.
static void set_leaf(ip4_fib_mtrie_t *m, ip4_fib_mtrie_set_unset_leaf_args_t *a, u32 old_ply_index, u32 dst_address_byte_index)
ip4_address_t dst_address
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
static void set_ply_with_more_specific_leaf(ip4_fib_mtrie_t *m, ip4_fib_mtrie_ply_t *ply, ip4_fib_mtrie_leaf_t new_leaf, uword new_leaf_dst_address_bits)
static ip4_fib_mtrie_leaf_t ip4_fib_mtrie_leaf_set_adj_index(u32 adj_index)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static uword mtrie_memory_usage(ip4_fib_mtrie_t *m, ip4_fib_mtrie_ply_t *p)
ip4_fib_mtrie_leaf_t leaves[256]
static ip4_fib_mtrie_leaf_t ply_create(ip4_fib_mtrie_t *m, ip4_fib_mtrie_leaf_t init_leaf, uword prefix_len)
static u32 ip4_fib_mtrie_leaf_is_non_empty(ip4_fib_mtrie_leaf_t n)
index_t dpoi_index
the index of objects of that type
static u32 ip4_fib_mtrie_leaf_is_empty(ip4_fib_mtrie_leaf_t n)
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
u32 ip4_mtrie_lookup_address(ip4_fib_mtrie_t *m, ip4_address_t dst)
ip4_main_t ip4_main
Global ip4 main structure.
static u8 * format_ip4_fib_mtrie_ply(u8 *s, va_list *va)
static u32 ip4_fib_mtrie_leaf_is_terminal(ip4_fib_mtrie_leaf_t n)
ip4_fib_mtrie_leaf_t default_leaf
static uword pool_elts(void *v)
Number of active elements in a pool.