19 #include <sys/ioctl.h> 53 else if (
unformat (line_input,
"ring-size %u", &ring_size))
55 else if (
unformat (line_input,
"rx-queues %u", &rx_queues))
57 else if (
unformat (line_input,
"tx-queues %u", &tx_queues))
61 else if (
unformat (line_input,
"master"))
63 else if (
unformat (line_input,
"slave"))
65 else if (
unformat (line_input,
"mode ip"))
67 else if (
unformat (line_input,
"hw-addr %U",
79 if (ring_size > 32768)
84 if (rx_queues > 255 || rx_queues < 1)
86 if (tx_queues > 255 || tx_queues < 1)
97 if (r <= VNET_API_ERROR_SYSCALL_ERROR_1
98 && r >= VNET_API_ERROR_SYSCALL_ERROR_10)
101 if (r == VNET_API_ERROR_INVALID_INTERFACE)
104 if (r == VNET_API_ERROR_SUBIF_ALREADY_EXISTS)
112 .path =
"create memif",
113 .short_help =
"create memif [id <id>] [socket <path>] " 114 "[ring-size <size>] [buffer-size <size>] [hw-addr <mac-address>] " 115 "<master|slave> [rx-queues <number>] [tx-queues <number>] " 116 "[mode ip] [secret <string>]",
126 u32 sw_if_index = ~0;
138 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
149 if (sw_if_index == ~0)
151 "please specify interface name or sw_if_index");
165 .path =
"delete memif",
166 .short_help =
"delete memif {<interface> | sw_if_index <sw_idx>}",
175 #define _(a,b,c) if ( flags & (1 << a)) s = format (s, " %s", c); 186 return format (s,
"ethernet");
190 return format (s,
"punt-inject");
191 return format (s,
"unknown mode (%u)", mif->
mode);;
202 s =
format (s,
"%U%s ring %u:\n",
204 (mif->
flags & MEMIF_IF_FLAG_IS_SLAVE) ?
205 "slave-to-master" :
"master-to-slave", i);
206 s =
format (s,
"%Uregion %u offset %u ring-size %u int-fd %d\n",
211 s =
format (s,
"%Uhead %u tail %u flags 0x%04x interrupts %u\n",
236 "%Uid flags buf len desc len address offset user address\n",
240 "%U===== ===== ======= ======== ================== ====== ==================\n",
242 for (slot = 0; slot < ring_size; slot++)
244 s =
format (s,
"%U%-5d %-5d %-7d %-7d 0x%016lx %-6d 0x%016lx\n",
269 u32 hw_if_index, *hw_if_indices = 0;
275 vec_add1 (hw_if_indices, hw_if_index);
276 else if (
unformat (input,
"descriptors"))
286 if (
vec_len (hw_if_indices) == 0)
295 for (hw_if_index = 0; hw_if_index <
vec_len (hw_if_indices); hw_if_index++)
316 " num-s2m-rings %u num-m2s-rings %u buffer-size %u",
349 .path =
"show memif",
350 .short_help =
"show memif {<interface>] [descriptors]",
unformat_function_t unformat_vnet_hw_interface
#define vec_foreach_index(var, v)
Iterate over vector indices.
sll srl srl sll sra u16x4 i
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
memif_socket_file_t * socket_files
struct memif_if_t::@366 run
static clib_error_t * memif_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static u8 * format_memif_if_flags(u8 *s, va_list *args)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
memif_interface_mode_t mode
unformat_function_t unformat_vnet_sw_interface
format_function_t format_vnet_sw_if_index_name
static uword min_log2(uword x)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
memif_log2_ring_size_t log2_ring_size
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
vnet_device_class_t memif_device_class
#define clib_error_return(e, args...)
memif_region_offset_t offset
memif_region_index_t region
static clib_error_t * memif_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static clib_error_t * memif_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int memif_delete_if(vlib_main_t *vm, memif_if_t *mif)
int memif_create_if(vlib_main_t *vm, memif_create_if_args_t *args)
#define MEMIF_DEFAULT_TX_QUEUES
memif_queue_t * tx_queues
#define vec_free(V)
Free vector's memory (no header).
static u8 * format_memif_if_mode(u8 *s, va_list *args)
#define MEMIF_DEFAULT_BUFFER_SIZE
#define VLIB_CLI_COMMAND(x,...)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
static_always_inline void * memif_get_buffer(memif_if_t *mif, memif_ring_t *ring, u16 slot)
#define MEMIF_DEFAULT_RX_QUEUES
static uword is_pow2(uword x)
memif_region_offset_t offset
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * memif_cli_init(vlib_main_t *vm)
memif_log2_ring_size_t log2_ring_size
static u8 * format_memif_descriptor(u8 *s, va_list *args)
#define MEMIF_DEFAULT_RING_SIZE
memif_queue_t * rx_queues
static u8 * format_memif_queue(u8 *s, va_list *args)
memif_region_index_t region
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
memif_interface_mode_t mode