28 #ifndef CLIB_MARCH_VARIANT 47 s =
format (s,
"MPLS: next [%d], lookup fib index %d, LB index %d hash %x " 62 u32 n_left_from, next_index, * from, * to_next;
67 n_left_from = from_frame->n_vectors;
68 next_index =
node->cached_next_index;
70 while (n_left_from > 0)
75 to_next, n_left_to_next);
77 while (n_left_from >= 8 && n_left_to_next >= 4)
79 u32 lbi0, next0, lfib_index0, bi0, hash_c0;
84 u32 lbi1, next1, lfib_index1, bi1, hash_c1;
89 u32 lbi2, next2, lfib_index2, bi2, hash_c2;
94 u32 lbi3, next3, lfib_index3, bi3, hash_c3;
120 bi0 = to_next[0] = from[0];
121 bi1 = to_next[1] = from[1];
122 bi2 = to_next[2] = from[2];
123 bi3 = to_next[3] = from[3];
187 (cm, thread_index, lbi0, 1,
219 (cm, thread_index, lbi1, 1,
251 (cm, thread_index, lbi2, 1,
283 (cm, thread_index, lbi3, 1,
294 vnet_buffer (b0)->mpls.exp = (((
char*)h0)[2] & 0xe) >> 1;
297 vnet_buffer (b1)->mpls.exp = (((
char*)h1)[2] & 0xe) >> 1;
300 vnet_buffer (b2)->mpls.exp = (((
char*)h2)[2] & 0xe) >> 1;
303 vnet_buffer (b3)->mpls.exp = (((
char*)h3)[2] & 0xe) >> 1;
359 to_next, n_left_to_next,
361 next0, next1, next2, next3);
364 while (n_left_from > 0 && n_left_to_next > 0)
366 u32 lbi0, next0, lfib_index0, bi0, hash_c0;
416 (cm, thread_index, lbi0, 1,
427 vnet_buffer (b0)->mpls.exp = (((
char*)h0)[2] & 0xe) >> 1;
447 to_next, n_left_to_next,
454 MPLS_ERROR_PKTS_DECAP, from_frame->n_vectors);
455 return from_frame->n_vectors;
459 #define mpls_error(n,s) s, 465 .name =
"mpls-lookup",
467 .vector_size =
sizeof (
u32),
471 .sibling_of =
"mpls-load-balance",
491 s =
format (s,
"MPLS: next [%d], LB index %d hash %d",
501 u32 n_left_from, n_left_to_next, * from, * to_next;
506 n_left_from =
frame->n_vectors;
507 next =
node->cached_next_index;
509 while (n_left_from > 0)
512 to_next, n_left_to_next);
515 while (n_left_from >= 4 && n_left_to_next >= 2)
519 u32 pi0, lbi0, hc0, pi1, lbi1, hc1, next0, next1;
537 pi0 = to_next[0] = from[0];
538 pi1 = to_next[1] = from[1];
605 (cm, thread_index, lbi0, 1,
608 (cm, thread_index, lbi1, 1,
621 to_next, n_left_to_next,
622 pi0, pi1, next0, next1);
625 while (n_left_from > 0 && n_left_to_next > 0)
629 u32 pi0, lbi0, hc0, next0;
669 (cm, thread_index, lbi0, 1,
673 to_next, n_left_to_next,
680 return frame->n_vectors;
684 .name =
"mpls-load-balance",
685 .vector_size =
sizeof (
u32),
696 #ifndef CLIB_MARCH_VARIANT
u16 lb_n_buckets
number of buckets in the load-balance.
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
vlib_combined_counter_main_t lbm_to_counters
format_function_t format_mpls_header
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
static uword vlib_node_add_named_next(vlib_main_t *vm, uword node, char *name)
u32 * fib_index_by_sw_if_index
flow_hash_config_t lb_hash_config
the hash config to use when selecting a bucket.
static const dpo_id_t * load_balance_get_fwd_bucket(const load_balance_t *lb, u16 bucket)
#define vlib_validate_buffer_enqueue_x4(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, next0, next1, next2, next3)
Finish enqueueing four buffers forward in the graph.
#define VLIB_NODE_FN(node)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
u16 lb_n_buckets_minus_1
number of buckets in the load-balance - 1.
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define MPLS_IS_REPLICATE
The top bit of the index, which is the result of the MPLS lookup is used to determine if the DPO is a...
#define vlib_call_init_function(vm, x)
vlib_node_registration_t mpls_lookup_node
(constructor) VLIB_REGISTER_NODE (mpls_lookup_node)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
static u32 mpls_compute_flow_hash(const mpls_unicast_header_t *hdr, flow_hash_config_t flow_hash_config)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u32 vnet_mpls_uc_get_label(mpls_label_t label_exp_s_ttl)
load_balance_main_t load_balance_main
The one instance of load-balance main.
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
u32 mpls_lookup_to_replicate_edge
The arc/edge from the MPLS lookup node to the MPLS replicate node.
#define VLIB_REGISTER_NODE(x,...)
static_always_inline uword vlib_get_thread_index(void)
#define CLIB_PREFETCH(addr, size, type)
unformat_function_t unformat_mpls_header
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
vlib_combined_counter_main_t lbm_via_counters
vlib_main_t vlib_node_runtime_t * node
static load_balance_t * load_balance_get(index_t lbi)
static char * mpls_error_strings[]
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static uword is_pow2(uword x)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static clib_error_t * mpls_init(vlib_main_t *vm)
#define vec_elt(v, i)
Get vector value at index i.
index_t dpoi_index
the index of objects of that type
static u32 vnet_mpls_uc_get_s(mpls_label_t label_exp_s_ttl)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
A collection of combined counters.
static index_t mpls_fib_table_forwarding_lookup(u32 mpls_fib_index, const mpls_unicast_header_t *hdr)
Lookup a label and EOS bit in the MPLS_FIB table to retrieve the load-balance index to be used for pa...
static u8 * format_mpls_load_balance_trace(u8 *s, va_list *args)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
u16 dpoi_next_node
The next VLIB node to follow.
static u8 * format_mpls_lookup_trace(u8 *s, va_list *args)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static clib_error_t * mpls_lookup_init(vlib_main_t *vm)
u32 mpls_lookup_node_index
vlib_node_registration_t mpls_load_balance_node
(constructor) VLIB_REGISTER_NODE (mpls_load_balance_node)