19 #include <sys/ioctl.h> 49 if (
unformat (line_input,
"id %u", &socket_id))
51 else if (
unformat (line_input,
"filename %s", &socket_filename))
63 if (socket_id == 0 || socket_id == ~0)
69 if (!socket_filename || *socket_filename == 0)
83 case VNET_API_ERROR_INVALID_ARGUMENT:
85 case VNET_API_ERROR_SYSCALL_ERROR_1:
87 case VNET_API_ERROR_ENTRY_ALREADY_EXISTS:
89 case VNET_API_ERROR_UNEXPECTED_INTF_STATE:
101 .path =
"create memif socket",
102 .short_help =
"create memif socket [id <id>] [filename <path>]",
124 if (
unformat (line_input,
"id %u", &socket_id))
135 if (socket_id == 0 || socket_id == ~0)
146 case VNET_API_ERROR_INVALID_ARGUMENT:
148 case VNET_API_ERROR_SYSCALL_ERROR_1:
150 case VNET_API_ERROR_ENTRY_ALREADY_EXISTS:
152 case VNET_API_ERROR_UNEXPECTED_INTF_STATE:
164 .path =
"delete memif socket",
165 .short_help =
"delete memif socket [id <id>]",
196 else if (
unformat (line_input,
"ring-size %u", &ring_size))
198 else if (
unformat (line_input,
"rx-queues %u", &rx_queues))
200 else if (
unformat (line_input,
"tx-queues %u", &tx_queues))
204 else if (
unformat (line_input,
"master"))
206 else if (
unformat (line_input,
"slave"))
208 else if (
unformat (line_input,
"no-zero-copy"))
210 else if (
unformat (line_input,
"mode ip"))
212 else if (
unformat (line_input,
"hw-addr %U",
224 if (ring_size > 32768)
229 if (rx_queues > 255 || rx_queues < 1)
231 if (tx_queues > 255 || tx_queues < 1)
241 if (r <= VNET_API_ERROR_SYSCALL_ERROR_1
242 && r >= VNET_API_ERROR_SYSCALL_ERROR_10)
245 if (r == VNET_API_ERROR_INVALID_ARGUMENT)
248 if (r == VNET_API_ERROR_INVALID_INTERFACE)
251 if (r == VNET_API_ERROR_SUBIF_ALREADY_EXISTS)
259 .path =
"create interface memif",
260 .short_help =
"create interface memif [id <id>] [socket-id <socket-id>] " 261 "[ring-size <size>] [buffer-size <size>] " 262 "[hw-addr <mac-address>] " 263 "<master|slave> [rx-queues <number>] [tx-queues <number>] " 264 "[mode ip] [secret <string>]",
286 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
297 if (sw_if_index == ~0)
299 "please specify interface name or sw_if_index");
313 .path =
"delete interface memif",
314 .short_help =
"delete interface memif {<interface> | sw_if_index <sw_idx>}",
323 #define _(a,b,c) if ( flags & (1 << a)) s = format (s, " %s", c); 334 return format (s,
"ethernet");
338 return format (s,
"punt-inject");
339 return format (s,
"unknown mode (%u)", mif->
mode);;
349 s =
format (s,
"%U%s ring %u:\n",
352 "slave-to-master" :
"master-to-slave", i);
353 s =
format (s,
"%Uregion %u offset %u ring-size %u int-fd %d\n",
358 s =
format (s,
"%Uhead %u tail %u flags 0x%04x interrupts %u\n",
383 "%Uid flags len address offset user address\n",
387 "%U===== ===== ======== ================== ====== ==================\n",
389 for (slot = 0; slot < ring_size; slot++)
391 s =
format (s,
"%U%-5d %-5d %-7d 0x%016lx %-6d 0x%016lx\n",
417 u32 hw_if_index, *hw_if_indices = 0;
426 vec_add1 (hw_if_indices, hw_if_index);
427 else if (
unformat (input,
"descriptors"))
438 vlib_cli_output (vm,
" %-3s %-11s %s\n",
"id",
"listener",
"filename");
443 memif_socket_file_t *msf;
446 msf = pool_elt_at_index(mm->socket_files, msf_idx);
447 filename = msf->filename;
448 if (msf->is_listener)
449 s = format (s,
"yes (%u)", msf->ref_cnt);
451 s = format (s,
"no");
453 vlib_cli_output(vm,
" %-3u %-11v %s\n", sock_id, s, filename);
454 vec_reset_length (s);
461 if (
vec_len (hw_if_indices) == 0)
470 for (hw_if_index = 0; hw_if_index <
vec_len (hw_if_indices); hw_if_index++)
491 "buffer-size %u num-regions %u",
532 .path =
"show memif",
533 .short_help =
"show memif [<interface>] [descriptors]",
unformat_function_t unformat_vnet_hw_interface
#define vec_foreach_index(var, v)
Iterate over vector indices.
vnet_main_t * vnet_get_main(void)
memif_socket_file_t * socket_files
static clib_error_t * memif_socket_filename_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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 clib_error_t * memif_socket_filename_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
memif_log2_ring_size_t log2_ring_size
#define hash_foreach(key_var, value_var, h, body)
#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
struct memif_if_t::@544 run
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 vnet_hw_interface_t * vnet_get_sup_hw_interface_api_visible_or_null(vnet_main_t *vnm, u32 sw_if_index)
int memif_socket_filename_add_del(u8 is_add, u32 sock_id, u8 *sock_filename)
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
uword * socket_file_index_by_sock_id
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
memif_region_size_t region_size