19 #include <sys/ioctl.h> 57 else if (
unformat (line_input,
"host-mac-addr %U",
63 else if (
unformat (line_input,
"host-ip4-addr %U/%d",
67 else if (
unformat (line_input,
"host-ip4-gw %U",
70 else if (
unformat (line_input,
"host-ip6-addr %U/%d",
74 else if (
unformat (line_input,
"host-ip6-gw %U",
77 else if (
unformat (line_input,
"num-rx-queues %d", &tmp))
79 else if (
unformat (line_input,
"rx-ring-size %d", &tmp))
81 else if (
unformat (line_input,
"tx-ring-size %d", &tmp))
87 else if (
unformat (line_input,
"no-gso"))
89 else if (
unformat (line_input,
"gso"))
91 else if (
unformat (line_input,
"gro-coalesce"))
93 else if (
unformat (line_input,
"csum-offload"))
95 else if (
unformat (line_input,
"persist"))
97 else if (
unformat (line_input,
"attach"))
99 else if (
unformat (line_input,
"tun"))
101 else if (
unformat (line_input,
"packed"))
103 else if (
unformat (line_input,
"in-order"))
105 else if (
unformat (line_input,
"hw-addr %U",
138 .path =
"create tap",
139 .short_help =
"create tap {id <if-id>} [hw-addr <mac-address>] " 140 "[num-rx-queues <n>] [rx-ring-size <size>] [tx-ring-size <size>] " 141 "[host-ns <netns>] [host-bridge <bridge-name>] " 142 "[host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6-addr>] " 143 "[host-ip4-gw <ip4-addr>] [host-ip6-gw <ip6-addr>] " 144 "[host-mac-addr <host-mac-address>] [host-if-name <name>] " 145 "[host-mtu-size <size>] [no-gso|gso [gro-coalesce]|csum-offload] " 146 "[persist] [attach] [tun] [packed] [in-order]",
166 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
177 if (sw_if_index == ~0)
179 "please specify interface name or sw_if_index");
182 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
193 .path =
"delete tap",
194 .short_help =
"delete tap {<interface> | sw_if_index <sw_idx>}",
206 int gso_enable = 0, gso_disable = 0, is_gro_coalesce = 0;
207 int csum_offload_enable = 0, csum_offload_disable = 0;
216 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
221 else if (
unformat (line_input,
"gso-enable"))
224 if (
unformat (line_input,
"gro-coalesce"))
227 else if (
unformat (line_input,
"gso-disable"))
229 else if (
unformat (line_input,
"csum-offload-enable"))
230 csum_offload_enable = 1;
231 else if (
unformat (line_input,
"csum-offload-disable"))
232 csum_offload_disable = 1;
239 if (sw_if_index == ~0)
241 "please specify interface name or sw_if_index");
245 else if (csum_offload_enable)
247 else if (gso_disable)
249 else if (csum_offload_disable)
252 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
263 .path =
"set tap offload",
264 .short_help =
"set tap offload {<interface> | sw_if_index <sw_idx>}" 265 " <gso-enable [gro-coalesce] | gso-disable | csum-offload-enable |" 266 "csum-offload-disable>",
280 u32 hw_if_index, *hw_if_indices = 0;
286 vec_add1 (hw_if_indices, hw_if_index);
287 else if (
unformat (input,
"descriptors"))
297 if (
vec_len (hw_if_indices) == 0)
305 virtio_show (vm, hw_if_indices, show_descr, VIRTIO_IF_TYPE_TAP);
315 .short_help =
"show tap {<interface>] [descriptors]",
329 u32 hw_if_index, *hw_if_indices = 0;
335 vec_add1 (hw_if_indices, hw_if_index);
336 else if (
unformat (input,
"descriptors"))
346 if (
vec_len (hw_if_indices) == 0)
354 virtio_show (vm, hw_if_indices, show_descr, VIRTIO_IF_TYPE_TUN);
364 .short_help =
"show tun {<interface>] [descriptors]",
unformat_function_t unformat_vnet_hw_interface
static clib_error_t * tun_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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)
#define pool_foreach(VAR, POOL)
Iterate through pool.
#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
static clib_error_t * tap_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * tap_offload_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#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_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * tap_cli_init(vlib_main_t *vm)
static clib_error_t * tap_create_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).
#define VLIB_CLI_COMMAND(x,...)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
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
int tap_gso_enable_disable(vlib_main_t *vm, u32 sw_if_index, int enable_disable, int is_packet_coalesce)
vl_api_interface_index_t sw_if_index