19 #include <sys/ioctl.h> 28 #include <linux/virtio_net.h> 29 #include <linux/vhost.h> 55 else if (
unformat (line_input,
"host-mac-addr %U",
60 else if (
unformat (line_input,
"host-ip4-addr %U/%d",
64 else if (
unformat (line_input,
"host-ip6-addr %U/%d",
72 else if (
unformat (line_input,
"hw-addr %U",
101 .path =
"create tap",
102 .short_help =
"create tap {id <if-id>} [hw-addr <mac-address>] " 103 "[rx-ring-size <size>] [tx-ring-size <size>] [host-ns <netns>] " 104 "[host-bridge <bridge-name>] [host-ip4-addr <ip4addr/mask>] " 105 "[host-ip6-addr <ip6-addr] [host-if-name <name>]",
115 u32 sw_if_index = ~0;
125 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
136 if (sw_if_index == ~0)
138 "please specify interface name or sw_if_index");
141 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
152 .path =
"delete tap",
153 .short_help =
"delete tap {<interface> | sw_if_index <sw_idx>}",
167 u32 hw_if_index, *hw_if_indices = 0;
175 struct feat_struct *feat_entry;
177 static struct feat_struct feat_array[] = {
178 #define _(s,b) { .str = #s, .bit = b, }, 184 struct feat_struct *flag_entry;
185 static struct feat_struct flags_array[] = {
186 #define _(b,e,s) { .bit = b, .str = s, }, 196 vec_add1 (hw_if_indices, hw_if_index);
197 else if (
unformat (input,
"descriptors"))
207 if (
vec_len (hw_if_indices) == 0)
216 for (hw_if_index = 0; hw_if_index <
vec_len (hw_if_indices); hw_if_index++)
228 flag_entry = (
struct feat_struct *) &flags_array;
229 while (flag_entry->str)
231 if (vif->
flags & (1ULL << flag_entry->bit))
239 feat_entry = (
struct feat_struct *) &feat_array;
240 while (feat_entry->str)
242 if (vif->
features & (1ULL << feat_entry->bit))
248 feat_entry = (
struct feat_struct *) &feat_array;
249 while (feat_entry->str)
265 " avail.flags 0x%x avail.idx %d used.flags 0x%x used.idx %d",
267 vring->
used->flags, vring->
used->idx);
274 " id addr len flags next user_addr\n");
276 " ===== ================== ===== ====== ===== ==================\n");
278 for (j = 0; j < vring->
size; j++)
280 struct vring_desc *desc = &vring->
desc[j];
282 " %-5d 0x%016lx %-5d 0x%04x %-5d 0x%016lx\n",
285 desc->flags, desc->next, desc->addr);
298 .short_help =
"show tap {<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
ip4_address_t host_ip4_addr
vnet_main_t * vnet_get_main(void)
static clib_error_t * tap_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define foreach_virtio_net_features
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).
unformat_function_t unformat_vnet_sw_interface
format_function_t format_vnet_sw_if_index_name
clib_error_t * tap_cli_init(vlib_main_t *vm)
static clib_error_t * tap_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
struct vring_avail * avail
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
int tap_delete_if(vlib_main_t *vm, u32 sw_if_index)
#define clib_error_return(e, args...)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
ip6_address_t host_ip6_addr
#define vec_free(V)
Free vector's memory (no header).
static clib_error_t * tap_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_CLI_COMMAND(x,...)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
virtio_main_t virtio_main
void tap_create_if(vlib_main_t *vm, tap_create_if_args_t *args)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)