68 #define _(a,b) case VNET_LINK_##a: type = ETHERNET_TYPE_##b; break 81 h->
type = clib_host_to_net_u16 (type);
99 return (&pipe_main.
pipes[sw_if_index]);
106 u32 *result = va_arg (*args,
u32 *);
117 *result = hw_if_index;
123 #define VNET_PIPE_TX_NEXT_ETHERNET_INPUT VNET_INTERFACE_TX_N_NEXT 132 u32 n_left_from, n_left_to_next, n_copy, *from, *to_next;
135 u32 n_pkts = 0, n_bytes = 0;
145 while (n_left_from > 0)
149 n_copy =
clib_min (n_left_from, n_left_to_next);
151 clib_memcpy (to_next, from, n_copy *
sizeof (from[0]));
152 n_left_to_next -= n_copy;
153 n_left_from -= n_copy;
176 thread_index, sw_if_index, n_pkts,
186 u32 dev_instance = va_arg (*args,
u32);
187 return format (s,
"pipe%d", dev_instance);
204 vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
220 #define foreach_pipe_rx_next \ 221 _ (DROP, "error-drop") 225 #define _(s,n) PIPE_RX_NEXT_##s, 262 else if (type0 == ETHERNET_TYPE_IP4)
266 else if (type0 == ETHERNET_TYPE_IP6)
270 else if (type0 == ETHERNET_TYPE_MPLS)
291 *next0 = PIPE_RX_NEXT_DROP;
300 u32 n_left_from, next_index, *from, *to_next;
315 while (n_left_from > 0)
319 while (n_left_from >= 4 && n_left_to_next >= 2)
321 u32 bi0, sw_if_index0, bi1, sw_if_index1;
357 type0 = clib_net_to_host_u16 (e0->
type);
358 type1 = clib_net_to_host_u16 (e1->
type);
359 pipe0 = &pipe_main.
pipes[sw_if_index0];
360 pipe1 = &pipe_main.
pipes[sw_if_index1];
366 b0->
flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
367 b1->
flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
392 to_next, n_left_to_next,
393 bi0, bi1, next0, next1);
395 while (n_left_from > 0 && n_left_to_next > 0)
397 u32 bi0, sw_if_index0;
416 type0 = clib_net_to_host_u16 (e0->
type);
417 pipe0 = &pipe_main.
pipes[sw_if_index0];
421 b0->
flags |= VNET_BUFFER_F_L3_HDR_OFFSET_VALID;
436 to_next, n_left_to_next,
451 .vector_size =
sizeof (
u32),
454 .sibling_of =
"ethernet-input",
461 #define PIPE_MAX_INSTANCE (16 * 1024) 529 memset (&
template, 0,
sizeof (
template));
533 template.sub.id = sub_id;
536 &
template, sw_if_index));
542 u32 * parent_sw_if_index,
u32 pipe_sw_if_index[2])
557 ASSERT (parent_sw_if_index);
559 memset (address, 0,
sizeof (address));
568 return VNET_API_ERROR_INVALID_REGISTRATION;
574 address[5] = instance;
577 instance, address, &hw_if_index,
582 rv = VNET_API_ERROR_INVALID_REGISTRATION;
647 pipe_sw_if_index[id] = sw_if_index;
676 u32 pipe_sw_if_index[2];
678 u32 user_instance = 0;
682 if (
unformat (input,
"instance %d", &user_instance))
689 &sw_if_index, pipe_sw_if_index);
710 .path =
"pipe create",
711 .short_help =
"pipe create [instance <instance>]",
726 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
735 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
741 vnet_delete_sub_interface(sw_if_index);
742 pipe_main.pipes[sw_if_index] = PIPE_INVALID;
768 if (sw_if_index == ~0)
790 .path =
"pipe delete",
791 .short_help =
"pipe delete <interface>",
unformat_function_t unformat_vnet_hw_interface
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define hash_set(h, key, value)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
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.
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t * vnet_get_main(void)
vnet_interface_main_t interface_main
uword vlib_node_add_named_next_with_slot(vlib_main_t *vm, uword node, char *name, uword slot)
pipe_t * pipes
the per-swif-index array of pipes.
static clib_error_t * create_pipe_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
VNET_DEVICE_CLASS(pipe_device_class)
struct pipe_main_t_ pipe_main_t
Various 'module' lavel variables.
static walk_rc_t pipe_hw_walk(vnet_main_t *vnm, u32 hw_if_index, void *args)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
static clib_error_t * delete_pipe_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword * instances
Allocated pipe instances.
#define VNET_PIPE_TX_NEXT_ETHERNET_INPUT
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
uword * sub_interface_sw_if_index_by_id
unformat_function_t unformat_vnet_sw_interface
#define VNET_HW_INTERFACE_FLAG_LINK_UP
static int pipe_instance_free(u32 instance)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static uword pipe_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
format_function_t format_vnet_sw_if_index_name
walk_rc_t(* pipe_cb_fn_t)(u32 parent_sw_if_index, u32 pipe_sw_if_index[2], u32 instance, void *ctx)
Call back function when walking all the pipes.
enum walk_rc_t_ walk_rc_t
Walk return code.
ethernet_main_t ethernet_main
represenation of a pipe interface
memset(h->entries, 0, sizeof(h->entries[0])*entries)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define static_always_inline
vlib_combined_counter_main_t * combined_sw_if_counters
#define hash_foreach(key_var, value_var, h, body)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
#define clib_error_return(e, args...)
VNET_HW_INTERFACE_CLASS(pipe_hw_interface_class)
void pipe_walk(pipe_cb_fn_t fn, void *ctx)
Walk all the of pipe interfaces.
static u32 pipe_instance_alloc(u8 is_specified, u32 want)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static clib_error_t * pipe_create_sub_interface(vnet_hw_interface_t *hi, u32 sub_id, u32 *sw_if_index)
u32 sw_if_index
the SW if_index of the other end of the pipe
#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).
uword unformat_pipe_interface(unformat_input_t *input, va_list *args)
enum pipe_rx_next_t_ pipe_rx_next_t
struct pipe_hw_walk_ctx_t_ pipe_hw_walk_ctx_t
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
int vnet_delete_pipe_interface(u32 sw_if_index)
#define clib_memcpy(a, b, c)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
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.
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
static u8 * format_pipe_rx_trace(u8 *s, va_list *va)
#define VLIB_CLI_COMMAND(x,...)
static u8 * pipe_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
static uword sparse_vec_index(void *v, uword sparse_index)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
u8 * format_ethernet_header(u8 *s, va_list *args)
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
#define PIPE_MAX_INSTANCE
#define foreach_pipe_rx_next
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
#define clib_error_report(e)
static void * vlib_frame_args(vlib_frame_t *f)
Get pointer to frame scalar data.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
struct pipe_rx_trace_t_ pipe_rx_trace_t
static u8 * format_pipe_name(u8 *s, va_list *args)
static vlib_main_t * vlib_get_main(void)
#define vec_elt(v, i)
Get vector value at index i.
subint_config_t subint
Sub-interface config.
static pipe_main_t pipe_main
void vlib_trace_frame_buffers_only(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, uword n_buffers, uword next_buffer_stride, uword n_buffer_data_bytes_in_trace)
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
void vnet_hw_interface_walk(vnet_main_t *vnm, vnet_hw_interface_walk_t fn, void *ctx)
Walk all the HW interface.
static_always_inline uword pipe_rx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
pipe_t * pipe_get(u32 sw_if_index)
Get the pipe instnace based on one end.
vnet_sw_interface_t * sw_interfaces
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
a point 2 point interface
int vnet_create_pipe_interface(u8 is_specified, u32 user_instance, u32 *parent_sw_if_index, u32 pipe_sw_if_index[2])
Create a new pipe interface.
static clib_error_t * pipe_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
u16 flags
Copy of main node flags.
next_by_ethertype_t l3_next
Various 'module' lavel variables.
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
static_always_inline void pipe_determine_next_node(ethernet_main_t *em, u32 is_l20, u32 type0, vlib_buffer_t *b0, pipe_rx_next_t *next0)
#define VLIB_NODE_FLAG_TRACE
static uword clib_bitmap_first_clear(uword *ai)
Return the lowest numbered clear bit in a bitmap.
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
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.
vlib_node_registration_t pipe_rx_node
(constructor) VLIB_REGISTER_NODE (pipe_rx_node)