19 #include <sys/ioctl.h> 28 #include <linux/virtio_net.h> 29 #include <linux/vhost.h> 59 else if (
unformat (line_input,
"host-mac-addr %U",
65 else if (
unformat (line_input,
"host-ip4-addr %U/%d",
69 else if (
unformat (line_input,
"host-ip4-gw %U",
72 else if (
unformat (line_input,
"host-ip6-addr %U/%d",
76 else if (
unformat (line_input,
"host-ip6-gw %U",
79 else if (
unformat (line_input,
"num-rx-queues %d", &tmp))
81 else if (
unformat (line_input,
"rx-ring-size %d", &tmp))
83 else if (
unformat (line_input,
"tx-ring-size %d", &tmp))
89 else if (
unformat (line_input,
"no-gso"))
91 else if (
unformat (line_input,
"gso"))
93 else if (
unformat (line_input,
"csum-offload"))
95 else if (
unformat (line_input,
"hw-addr %U",
128 .path =
"create tap",
129 .short_help =
"create tap {id <if-id>} [hw-addr <mac-address>] " 130 "[rx-ring-size <size>] [tx-ring-size <size>] [host-ns <netns>] " 131 "[host-bridge <bridge-name>] [host-ip4-addr <ip4addr/mask>] " 132 "[host-ip6-addr <ip6-addr>] [host-ip4-gw <ip4-addr>] " 133 "[host-ip6-gw <ip6-addr>] [host-mac-addr <host-mac-address>] " 134 "[host-if-name <name>] [host-mtu-size <size>] [no-gso|gso|csum-offload]",
154 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
165 if (sw_if_index == ~0)
167 "please specify interface name or sw_if_index");
170 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
181 .path =
"delete tap",
182 .short_help =
"delete tap {<interface> | sw_if_index <sw_idx>}",
194 int gso_enable = 0, gso_disable = 0;
195 int csum_offload_enable = 0, csum_offload_disable = 0;
204 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
209 else if (
unformat (line_input,
"gso-enable"))
211 else if (
unformat (line_input,
"gso-disable"))
213 else if (
unformat (line_input,
"csum-offload-enable"))
214 csum_offload_enable = 1;
215 else if (
unformat (line_input,
"csum-offload-disable"))
216 csum_offload_disable = 1;
223 if (sw_if_index == ~0)
225 "please specify interface name or sw_if_index");
229 else if (csum_offload_enable)
231 else if (gso_disable)
233 else if (csum_offload_disable)
236 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
247 .path =
"set tap offload",
248 .short_help =
"set tap offload {<interface> | sw_if_index <sw_idx>}" 249 " <gso-enable | gso-disable | csum-offload-enable | csum-offload-disable>",
263 u32 hw_if_index, *hw_if_indices = 0;
269 vec_add1 (hw_if_indices, hw_if_index);
270 else if (
unformat (input,
"descriptors"))
280 if (
vec_len (hw_if_indices) == 0)
299 .short_help =
"show tap {<interface>] [descriptors]",
unformat_function_t unformat_vnet_hw_interface
void virtio_show(vlib_main_t *vm, u32 *hw_if_indices, u8 show_descr, u32 type)
ip4_address_t host_ip4_addr
vnet_main_t * vnet_get_main(void)
int tap_gso_enable_disable(vlib_main_t *vm, u32 sw_if_index, int enable_disable)
static clib_error_t * tap_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
unformat_function_t unformat_vnet_sw_interface
int tap_csum_offload_enable_disable(vlib_main_t *vm, u32 sw_if_index, int enable_disable)
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)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
int tap_delete_if(vlib_main_t *vm, u32 sw_if_index)
#define clib_error_return(e, args...)
static clib_error_t * tap_offload_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ip4_address_t host_ip4_gw
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)
ip6_address_t host_ip6_gw
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)
mac_address_t host_mac_addr
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)