|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
67 l = 1 + 2 * adj_index;
95 #define PLY_X4_SPLAT_INIT(init_x4, init) \
96 init_x4 = u32x4_splat (init);
98 #define PLY_X4_SPLAT_INIT(init_x4, init) \
101 y.as_u32[0] = init; \
102 y.as_u32[1] = init; \
103 y.as_u32[2] = init; \
104 y.as_u32[3] = init; \
105 init_x4 = y.as_u32x4; \
109 #ifdef CLIB_HAVE_VEC128
110 #define PLY_INIT_LEAVES(p) \
114 PLY_X4_SPLAT_INIT(init_x4, init); \
115 for (l = p->leaves_as_u32x4; \
116 l < p->leaves_as_u32x4 + ARRAY_LEN (p->leaves_as_u32x4); \
126 #define PLY_INIT_LEAVES(p) \
130 for (l = p->leaves; l < p->leaves + ARRAY_LEN (p->leaves); l += 4) \
140 #define PLY_INIT(p, init, prefix_len, ply_base_len) \
147 p->n_non_empty_leafs = (prefix_len > ply_base_len ? \
148 ARRAY_LEN (p->leaves) : 0); \
149 clib_memset (p->dst_address_bits_of_leaves, prefix_len, \
150 sizeof (p->dst_address_bits_of_leaves)); \
151 p->dst_address_bits_base = ply_base_len; \
154 PLY_INIT_LEAVES(p); \
180 ply_8_init (p, init_leaf, leaf_prefix_len, ply_base_len);
248 u32 dst_address_length;
250 u32 cover_address_length;
257 uword new_leaf_dst_address_bits)
273 new_leaf_dst_address_bits);
277 else if (new_leaf_dst_address_bits >=
289 u32 dst_address_byte_index)
292 i32 n_dst_bits_next_plies;
298 ASSERT (
a->dst_address_length <= 32);
302 n_dst_bits_next_plies =
303 a->dst_address_length -
BITS (
u8) * (dst_address_byte_index + 1);
305 dst_byte =
a->dst_address.as_u8[dst_address_byte_index];
308 if (n_dst_bits_next_plies <= 0)
311 uword old_leaf_is_terminal;
312 u32 i, n_dst_bits_this_ply;
315 n_dst_bits_this_ply =
clib_min (8, -n_dst_bits_next_plies);
316 ASSERT ((
a->dst_address.as_u8[dst_address_byte_index] &
321 for (
i = dst_byte;
i < dst_byte + (1 << n_dst_bits_this_ply);
i++)
334 if (old_leaf_is_terminal)
342 a->dst_address_length;
356 a->dst_address_length);
359 else if (!old_leaf_is_terminal)
380 ply_base_len = 8 * (dst_address_byte_index + 1);
382 old_leaf = old_ply->
leaves[dst_byte];
417 i32 n_dst_bits_next_plies;
422 ASSERT (
a->dst_address_length <= 32);
425 n_dst_bits_next_plies =
a->dst_address_length -
BITS (
u16);
427 dst_byte =
a->dst_address.as_u16[0];
430 if (n_dst_bits_next_plies <= 0)
433 uword old_leaf_is_terminal;
434 u32 i, n_dst_bits_this_ply;
437 n_dst_bits_this_ply = 16 -
a->dst_address_length;
438 ASSERT ((clib_host_to_net_u16 (
a->dst_address.as_u16[0]) &
443 for (
i = 0;
i < (1 << n_dst_bits_this_ply);
i++)
448 slot = clib_net_to_host_u16 (dst_byte);
455 if (
a->dst_address_length >=
462 if (old_leaf_is_terminal)
467 a->dst_address_length;
476 a->dst_address_length);
479 else if (!old_leaf_is_terminal)
502 old_leaf = old_ply->
leaves[dst_byte];
527 i32 n_dst_bits_next_plies;
528 i32 i, n_dst_bits_this_ply, old_leaf_is_terminal;
531 ASSERT (
a->dst_address_length <= 32);
534 n_dst_bits_next_plies =
535 a->dst_address_length -
BITS (
u8) * (dst_address_byte_index + 1);
537 dst_byte =
a->dst_address.as_u8[dst_address_byte_index];
538 if (n_dst_bits_next_plies < 0)
539 dst_byte &= ~
pow2_mask (-n_dst_bits_next_plies);
541 n_dst_bits_this_ply =
542 n_dst_bits_next_plies <= 0 ? -n_dst_bits_next_plies : 0;
543 n_dst_bits_this_ply =
clib_min (8, n_dst_bits_this_ply);
547 for (
i = dst_byte;
i < dst_byte + (1 << n_dst_bits_this_ply);
i++)
552 if (old_leaf == del_leaf ||
553 (!old_leaf_is_terminal &&
555 dst_address_byte_index + 1)))
576 else if (dst_address_byte_index)
597 i32 n_dst_bits_next_plies;
598 i32 i, n_dst_bits_this_ply, old_leaf_is_terminal;
602 ASSERT (
a->dst_address_length <= 32);
605 n_dst_bits_next_plies =
a->dst_address_length -
BITS (
u16);
607 dst_byte =
a->dst_address.as_u16[0];
609 n_dst_bits_this_ply = (n_dst_bits_next_plies <= 0 ?
610 (16 -
a->dst_address_length) : 0);
616 for (
i = 0;
i < (1 << n_dst_bits_this_ply);
i++)
620 slot = clib_net_to_host_u16 (dst_byte);
627 if (old_leaf == del_leaf ||
628 (!old_leaf_is_terminal &&
641 u32 dst_address_length,
u32 adj_index)
647 a.dst_address.as_u32 = (dst_address->
as_u32 &
648 im->fib_masks[dst_address_length]);
649 a.dst_address_length = dst_address_length;
650 a.adj_index = adj_index;
657 u32 dst_address_length,
u32 adj_index)
663 a.dst_address.as_u32 =
664 (dst_address->
as_u32 &
im->fib_masks[dst_address_length]);
665 a.dst_address_length = dst_address_length;
666 a.adj_index = adj_index;
675 u32 dst_address_length,
u32 adj_index,
676 u32 cover_address_length,
u32 cover_adj_index)
682 a.dst_address.as_u32 = (dst_address->
as_u32 &
683 im->fib_masks[dst_address_length]);
684 a.dst_address_length = dst_address_length;
685 a.adj_index = adj_index;
686 a.cover_adj_index = cover_adj_index;
687 a.cover_address_length = cover_address_length;
695 u32 dst_address_length,
u32 adj_index,
696 u32 cover_address_length,
u32 cover_adj_index)
702 .dst_address.as_u32 =
703 (dst_address->
as_u32 &
im->fib_masks[dst_address_length]),
704 .dst_address_length = dst_address_length,
705 .adj_index = adj_index,
706 .cover_adj_index = cover_adj_index,
707 .cover_address_length = cover_address_length,
722 bytes =
sizeof (p[0]);
778 #define FORMAT_PLY(s, _p, _a, _i, _base_address, _ply_max_len, _indent) \
782 ip4_mtrie_leaf_t _l = (_p)->leaves[(_i)]; \
784 a = (_base_address) + ((_a) << (32 - (_ply_max_len))); \
785 ia.as_u32 = clib_host_to_net_u32 (a); \
786 ia_length = (_p)->dst_address_bits_of_leaves[(_i)]; \
787 s = format (s, "\n%U%U %U", format_white_space, (_indent) + 4, \
788 format_ip4_address_and_length, &ia, ia_length, \
789 format_ip4_mtrie_leaf, _l); \
791 if (ip4_mtrie_leaf_is_next_ply (_l)) \
792 s = format (s, "\n%U", format_ip4_mtrie_ply, m, a, (_indent) + 8, \
793 ip4_mtrie_leaf_get_next_ply_index (_l)); \
801 u32 base_address = va_arg (*va,
u32);
802 u32 indent = va_arg (*va,
u32);
803 u32 ply_index = va_arg (*va,
u32);
808 s =
format (s,
"%Uply index %d, %d non-empty leaves",
827 int verbose = va_arg (*va,
int);
829 u32 base_address = 0;
839 s =
format (s,
"root-ply");
846 slot = clib_host_to_net_u16 (
i);
862 int verbose = va_arg (*va,
int);
864 u32 base_address = 0;
869 s =
format (s,
"8-8-8-8; %d plies, memory usage %U\n",
875 s =
format (s,
"root-ply");
890 #define IP4_FIB_DEFAULT_MTRIE_HEAP_SIZE (32<<20)
891 #ifndef MAP_HUGE_SHIFT
892 #define MAP_HUGE_SHIFT 26
u8 * format_ip4_mtrie_16(u8 *s, va_list *va)
ip4_mtrie_leaf_t leaves[256]
vnet_interface_main_t * im
static uword unset_leaf(const ip4_mtrie_set_unset_leaf_args_t *a, ip4_mtrie_8_ply_t *old_ply, u32 dst_address_byte_index)
void ip4_mtrie_16_init(ip4_mtrie_16_t *m)
Initialise an mtrie.
#define PLY_INIT_LEAVES(p)
void ip4_mtrie_8_init(ip4_mtrie_8_t *m)
ip4_main_t ip4_main
Global ip4 main structure.
static uword pow2_mask(uword x)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static u8 * format_ip4_mtrie_leaf(u8 *s, va_list *va)
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
The mutiway-TRIE with a 8-8-8-8 stride.
void ip4_mtrie_8_free(ip4_mtrie_8_t *m)
static uword mtrie_ply_memory_usage(ip4_mtrie_8_ply_t *p)
#define pool_put(P, E)
Free an object E in pool P.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
void ip4_mtrie_16_free(ip4_mtrie_16_t *m)
Free an mtrie, It must be empty when free'd.
static u32 ip4_mtrie_leaf_get_adj_index(ip4_mtrie_leaf_t n)
From the stored slot value extract the LB index value.
i32 n_non_empty_leafs
Number of non-empty leafs (whether terminal or not).
#define PLY_INIT(p, init, prefix_len, ply_base_len)
#define FORMAT_PLY(s, _p, _a, _i, _base_address, _ply_max_len, _indent)
void ip4_mtrie_8_route_del(ip4_mtrie_8_t *m, const ip4_address_t *dst_address, u32 dst_address_length, u32 adj_index, u32 cover_address_length, u32 cover_adj_index)
One ply of the 4 ply mtrie fib.
#define IP4_MTRIE_LEAF_EMPTY
static void set_root_leaf(ip4_mtrie_16_t *m, const ip4_mtrie_set_unset_leaf_args_t *a)
static clib_error_t * ip4_mtrie_module_init(vlib_main_t *vm)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static u32 ip4_mtrie_leaf_is_non_empty(ip4_mtrie_8_ply_t *p, u8 dst_byte)
#define CLIB_CACHE_LINE_BYTES
u8 dst_address_bits_of_leaves[PLY_16_SIZE]
Prefix length for terminal leaves.
ip4_mtrie_8_ply_t * ip4_ply_pool
Global pool of IPv4 8bit PLYs.
static u32 ip4_mtrie_leaf_get_next_ply_index(ip4_mtrie_leaf_t n)
static void unset_root_leaf(ip4_mtrie_16_t *m, const ip4_mtrie_set_unset_leaf_args_t *a)
static void set_ply_with_more_specific_leaf(ip4_mtrie_8_ply_t *ply, ip4_mtrie_leaf_t new_leaf, uword new_leaf_dst_address_bits)
i32 dst_address_bits_base
The length of the ply's covering prefix.
ip4_mtrie_leaf_t leaves[PLY_16_SIZE]
void ip4_mtrie_16_route_del(ip4_mtrie_16_t *m, const ip4_address_t *dst_address, u32 dst_address_length, u32 adj_index, u32 cover_address_length, u32 cover_adj_index)
remove a route/entry to the mtrie
description fragment has unexpected format
ip4_mtrie_16_ply_t root_ply
Embed the PLY with the mtrie struct.
u8 * format_ip4_mtrie_8(u8 *s, va_list *va)
void ip4_mtrie_8_route_add(ip4_mtrie_8_t *m, const ip4_address_t *dst_address, u32 dst_address_length, u32 adj_index)
static ip4_mtrie_leaf_t ip4_mtrie_leaf_set_adj_index(u32 adj_index)
#define VLIB_INIT_FUNCTION(x)
static u32 ip4_mtrie_leaf_is_next_ply(ip4_mtrie_leaf_t n)
uword ip4_mtrie_16_memory_usage(ip4_mtrie_16_t *m)
return the memory used by the table
static void ply_16_init(ip4_mtrie_16_ply_t *p, ip4_mtrie_leaf_t init, uword prefix_len)
static ip4_mtrie_leaf_t ply_create(ip4_mtrie_leaf_t init_leaf, u32 leaf_prefix_len, u32 ply_base_len)
static uword pool_elts(void *v)
Number of active elements in a pool.
static ip4_mtrie_leaf_t ip4_mtrie_leaf_set_next_ply_index(u32 i)
static u8 * format_ip4_mtrie_ply(u8 *s, va_list *va)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void set_leaf(const ip4_mtrie_set_unset_leaf_args_t *a, u32 old_ply_index, u32 dst_address_byte_index)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
static void ply_8_init(ip4_mtrie_8_ply_t *p, ip4_mtrie_leaf_t init, uword prefix_len, u32 ply_base_len)
void ip4_mtrie_16_route_add(ip4_mtrie_16_t *m, const ip4_address_t *dst_address, u32 dst_address_length, u32 adj_index)
Add a route/entry to the mtrie.
uword ip4_mtrie_8_memory_usage(ip4_mtrie_8_t *m)
The mutiway-TRIE with a 16-8-8 stride.
#define clib_atomic_store_rel_n(a, b)
u8 dst_address_bits_of_leaves[256]
Prefix length for leaves/ply.
static u32 ip4_mtrie_leaf_is_terminal(ip4_mtrie_leaf_t n)
Is the leaf terminal (i.e.
static ip4_mtrie_8_ply_t * get_next_ply_for_leaf(ip4_mtrie_leaf_t l)