55 s =
format (s,
"L2_XCRW: next index %d tx_fib_index %d",
62 #ifndef CLIB_MARCH_VARIANT 67 #define _(sym,string) string, 75 u32 n_left_from, *from, *to_next;
83 n_left_from = frame->n_vectors;
84 next_index = node->cached_next_index;
86 while (n_left_from > 0)
92 while (n_left_from >= 4 && n_left_to_next >= 2)
97 u32 sw_if_index0, sw_if_index1;
115 to_next[0] = bi0 = from[0];
116 to_next[1] = bi1 = from[1];
131 next0 = adj0->rewrite_header.next_index;
133 adj0->rewrite_header.sw_if_index;
135 next1 = adj1->rewrite_header.next_index;
137 adj1->rewrite_header.sw_if_index;
139 em->
counters[node_counter_base_index + next1]++;
145 adj0->rewrite_header.data_bytes);
147 em->
counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
154 adj1->rewrite_header.data_bytes);
156 em->
counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
163 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
171 && (b1->
flags & VLIB_BUFFER_IS_TRACED)))
182 to_next, n_left_to_next,
183 bi0, bi1, next0, next1);
186 while (n_left_from > 0 && n_left_to_next > 0)
208 next0 = adj0->rewrite_header.next_index;
210 adj0->rewrite_header.sw_if_index;
216 adj0->rewrite_header.data_bytes);
218 em->
counters[node_counter_base_index + L2_XCRW_ERROR_FWD]++;
222 && (b0->
flags & VLIB_BUFFER_IS_TRACED)))
231 to_next, n_left_to_next,
238 return frame->n_vectors;
244 .vector_size =
sizeof (
u32),
260 #ifndef CLIB_MARCH_VARIANT 279 clib_warning (
"you shouldn't be here, leaking buffers...");
286 u32 dev_instance = va_arg (*args,
u32);
287 return format (s,
"xcrw%d", dev_instance);
315 (vnm, xcrw_device_class.index, instance++, address, &hw_if_index,
331 u32 l2_sw_if_index,
u32 tx_fib_index,
358 a->rewrite_header.sw_if_index = tx_fib_index;
364 a->rewrite_header.next_index =
380 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
408 u32 tx_fib_index = ~0;
409 u32 next_node_index = ~0;
430 if (
unformat (line_input,
"next %U",
433 else if (
unformat (line_input,
"tx-fib-id %d", &tx_fib_id))
435 else if (
unformat (line_input,
"del"))
437 else if (
unformat (line_input,
"ipv6"))
444 if (next_node_index == ~0)
470 rw, next_node_index, is_add);
478 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
481 vnm, l2_sw_if_index);
510 .path =
"set interface l2 xcrw",
512 "set interface l2 xcrw <interface> next <node-name>\n" 513 " [del] [tx-fib-id <id>] [ipv6] rw <hex-bytes>",
532 s =
format (s,
"%-25s%s",
"L2 interface",
"Tunnel Details");
536 s =
format (s,
"%-25U %U ",
542 s =
format (s,
"next %U ",
544 a->rewrite_header.next_index);
546 if (a->rewrite_header.sw_if_index != ~0)
547 s =
format (s,
"tx fib index %d ", a->rewrite_header.sw_if_index);
549 if (a->rewrite_header.data_bytes)
551 rewrite_string = (
u8 *) (a + 1);
552 rewrite_string -= a->rewrite_header.data_bytes;
553 s =
format (s,
"rewrite data: %U ",
555 a->rewrite_header.data_bytes);
583 vlib_cli_output (vm,
"%U", format_l2xcrw, vnm, t);
599 .path =
"show l2xcrw",
600 .short_help =
"show l2xcrw",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define vnet_rewrite_one_header(rw0, p0, most_likely_size)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
#define hash_set(h, key, value)
static char * l2_xcrw_error_strings[]
static uword dummy_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define hash_unset(h, key)
vnet_main_t * vnet_get_main(void)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define vnet_rewrite_set_data(rw, data, data_bytes)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
unformat_function_t unformat_vnet_sw_interface
#define VLIB_NODE_FN(node)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static clib_error_t * show_l2xcrw_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static u8 * format_l2xcrw(u8 *s, va_list *args)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static u8 * format_xcrw_name(u8 *s, va_list *args)
clib_error_t * l2_xcrw_init(vlib_main_t *vm)
#define clib_error_return(e, args...)
format_function_t format_vlib_next_node_name
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
l2_xcrw_tunnel_t * tunnels
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
vlib_error_main_t error_main
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define pool_put(P, E)
Free an object E in pool P.
#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).
int vnet_configure_l2_xcrw(vlib_main_t *vm, vnet_main_t *vnm, u32 l2_sw_if_index, u32 tx_fib_index, u8 *rewrite, u32 next_node_index, int is_add)
uword * fib_index_by_table_id
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
#define vec_free(V)
Free vector's memory (no header).
#define foreach_l2_xcrw_error
#define clib_warning(format, args...)
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.
#define VLIB_CLI_COMMAND(x,...)
#define hash_create(elts, value_bytes)
static u8 * format_l2_xcrw_trace(u8 *s, va_list *args)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static vlib_main_t * vlib_get_main(void)
VNET_DEVICE_CLASS(xcrw_device_class, static)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
vlib_node_registration_t l2_xcrw_node
(constructor) VLIB_REGISTER_NODE (l2_xcrw_node)
static u32 create_xcrw_interface(vlib_main_t *vm)
unformat_function_t unformat_vlib_node
ip4_main_t ip4_main
Global ip4 main structure.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES
l2_xcrw_adjacency_t * adj_by_sw_if_index
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
l2_xcrw_main_t l2_xcrw_main
uword * tunnel_index_by_l2_sw_if_index
static clib_error_t * set_l2_xcrw_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static uword pool_elts(void *v)
Number of active elements in a pool.