74 u32 hw_if_index, *hw_if_indices = 0;
77 is_show = strstr (cmd->
path,
"show") != 0;
83 vec_add1 (hw_if_indices, hw_if_index);
86 else if (
unformat (input,
"%u", &hw_if_index))
87 vec_add1 (hw_if_indices, hw_if_index);
89 else if (
unformat (input,
"verbose"))
114 if (
vec_len (hw_if_indices) == 0)
127 for (i = 0; i <
vec_len (hw_if_indices); i++)
144 shi = vnet_get_hw_interface(vnm, hw_idx);
145 vlib_cli_output (vm,
"%U\n",
146 format_vnet_hw_interface, vnm, shi, verbose);
154 for (i = 0; i <
vec_len (hw_if_indices); i++)
161 if (dc->clear_counters)
229 .path =
"show hardware-interfaces",
230 .short_help =
"show hardware-interfaces [brief|verbose|detail] [bond] " 231 "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
250 .path =
"clear hardware-interfaces",
251 .short_help =
"clear hardware-interfaces " 252 "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
277 u8 show_addresses = 0;
278 u8 show_features = 0;
303 else if (
unformat (linput,
"verbose"))
315 if (show_features || show_tag)
317 if (sw_if_index == ~(
u32) 0)
351 tag ? (
char *) tag :
"(none)");
364 _vec_len (sorted_sis) = 0;
368 int visible = vnet_swif_is_api_visible (si);
370 vec_add1 (sorted_sis, si[0]);}
386 u32 fib_index4 = 0, fib_index6 = 0;
401 (vm,
"%U (%s): \n unnumbered, use %U",
419 l2_input->
bvi ?
"bvi" :
" ");
431 ip4_address_t *r4 = ip_interface_address_get_address (lm4, ia);
433 vlib_cli_output (vm,
" L3 %U/%d ip4 table-id %d fib-idx %d",
434 format_ip4_address, r4, ia->address_length,
436 ip4_fib_index_from_table_id (fib4->table_id));
438 vlib_cli_output (vm,
" L3 %U/%d",
439 format_ip4_address, r4, ia->address_length);
448 ip6_address_t *r6 = ip_interface_address_get_address (lm6, ia);
450 vlib_cli_output (vm,
" L3 %U/%d ip6 table-id %d fib-idx %d",
451 format_ip6_address, r6, ia->address_length,
453 ip6_fib_index_from_table_id (fib6->table_id));
455 vlib_cli_output (vm,
" L3 %U/%d",
456 format_ip6_address, r6, ia->address_length);
476 .path =
"show interface",
477 .short_help =
"show interface [address|addr|features|feat] [<interface> [<interface> [..]]] [verbose]",
487 .short_help =
"Interface commands",
493 .path =
"set interface",
494 .short_help =
"Interface commands",
510 for (j = 0; j < n_counters; j++)
519 for (j = 0; j < n_counters; j++)
539 .path =
"clear interfaces",
540 .short_help =
"clear interfaces",
612 u32 inner_vlan, outer_vlan;
614 if (
unformat (input,
"any inner-dot1q any"))
616 template->sub.eth.
flags.two_tags = 1;
617 template->sub.eth.flags.outer_vlan_id_any = 1;
618 template->sub.eth.flags.inner_vlan_id_any = 1;
622 template->sub.eth.flags.one_tag = 1;
623 template->sub.eth.flags.outer_vlan_id_any = 1;
625 else if (
unformat (input,
"%d inner-dot1q any", &outer_vlan))
627 template->sub.eth.flags.two_tags = 1;
628 template->sub.eth.flags.inner_vlan_id_any = 1;
629 template->sub.eth.outer_vlan_id = outer_vlan;
631 else if (
unformat (input,
"%d inner-dot1q %d", &outer_vlan, &inner_vlan))
633 template->sub.eth.flags.two_tags = 1;
634 template->sub.eth.outer_vlan_id = outer_vlan;
635 template->sub.eth.inner_vlan_id = inner_vlan;
637 else if (
unformat (input,
"%d", &outer_vlan))
639 template->sub.eth.flags.one_tag = 1;
640 template->sub.eth.outer_vlan_id = outer_vlan;
651 if (
unformat (input,
"exact-match"))
653 template->sub.eth.flags.exact_match = 1;
669 u32 id, id_min, id_max;
681 template.sub.eth.raw_flags = 0;
683 if (
unformat (input,
"%d default", &id_min))
686 template.sub.eth.flags.default_sub = 1;
688 else if (
unformat (input,
"%d untagged", &id_min))
691 template.sub.eth.flags.no_tags = 1;
692 template.sub.eth.flags.exact_match = 1;
694 else if (
unformat (input,
"%d dot1q", &id_min))
702 else if (
unformat (input,
"%d dot1ad", &id_min))
706 template.sub.eth.flags.dot1ad = 1;
711 else if (
unformat (input,
"%d-%d", &id_min, &id_max))
713 template.sub.eth.flags.one_tag = 1;
714 template.sub.eth.flags.exact_match = 1;
718 else if (
unformat (input,
"%d", &id_min))
721 template.sub.eth.flags.one_tag = 1;
722 template.sub.eth.outer_vlan_id = id_min;
723 template.sub.eth.flags.exact_match = 1;
739 "not allowed as %v belong to a BondEthernet interface",
744 for (
id = id_min;
id <= id_max;
id++)
755 clib_warning (
"sup sw_if_index %d, sub id %d already exists\n",
761 *kp = sup_and_sub_key;
766 template.sub.id =
id;
768 template.sub.eth.outer_vlan_id =
id;
870 .path =
"create sub-interfaces",
871 .short_help =
"create sub-interfaces <interface> " 872 "{<subId> [default|untagged]} | " 873 "{<subId>-<subId>} | " 874 "{<subId> dot1q|dot1ad <vlanId>|any [inner-dot1q <vlanId>|any] [exact-match]}",
927 .path =
"set interface state",
928 .short_help =
"set interface state <interface> [up|down|punt|enable]",
938 u32 unnumbered_sw_if_index = ~0;
939 u32 inherit_from_sw_if_index = ~0;
948 &unnumbered_sw_if_index))
954 if (~0 == unnumbered_sw_if_index)
956 if (enable && ~0 == inherit_from_sw_if_index)
958 " IP enabled interface that it uses");
961 inherit_from_sw_if_index, enable);
968 .path =
"set interface unnumbered",
969 .short_help =
"set interface unnumbered [<interface> use <interface> | del <interface>]",
983 u32 hw_if_index, hw_class_index;
1011 .path =
"set interface hw-class",
1012 .short_help =
"Set interface hardware class",
1031 u32 new_dev_instance;
1039 if (!
unformat (input,
"%d", &new_dev_instance))
1061 .path =
"renumber interface",
1062 .short_help =
"renumber interface <interface> <new-dev-instance>",
1080 else if (
unformat (input,
"off %U",
1097 .path =
"set interface promiscuous",
1098 .short_help =
"set interface promiscuous [on|off] <interface>",
1111 if (
unformat (input,
"%d %U", &mtu,
1124 if (mtu < hi->min_supported_packet_bytes)
1126 "must be >= min pkt bytes (%d)", mtu,
1136 else if (
unformat (input,
"packet %d %U", &mtu,
1140 else if (
unformat (input,
"ip4 %d %U", &mtu,
1143 else if (
unformat (input,
"ip6 %d %U", &mtu,
1146 else if (
unformat (input,
"mpls %d %U", &mtu,
1161 .path =
"set interface mtu",
1162 .short_help =
"set interface mtu [packet|ip4|ip6|mpls] <value> <interface>",
1211 .path =
"set interface mac address",
1212 .short_help =
"set interface mac address <interface> <mac-address>",
1225 vnm, &sw_if_index, &tag))
1236 .path =
"set interface tag",
1237 .short_help =
"set interface tag <interface> <tag>",
1260 .path =
"clear interface tag",
1261 .short_help =
"clear interface tag <interface>",
1275 else if (
unformat (input,
"enable"))
1277 else if (
unformat (input,
"disable"))
1283 if (~0 == sw_if_index)
1300 .path =
"set interface ip directed-broadcast",
1301 .short_help =
"set interface enable <interface> <enable|disable>",
1324 if (old_mode == mode)
1327 case VNET_API_ERROR_INVALID_INTERFACE:
1329 case VNET_API_ERROR_INVALID_QUEUE:
1335 if (dev_class->rx_mode_change_function)
1337 error = dev_class->rx_mode_change_function (vnm, hw_if_index, queue_id,
1348 case VNET_API_ERROR_UNSUPPORTED:
1350 case VNET_API_ERROR_INVALID_INTERFACE:
1352 case VNET_API_ERROR_INVALID_QUEUE:
1363 u8 queue_id_valid,
u32 queue_id,
1372 if (queue_id_valid == 0)
1395 u32 hw_if_index = (
u32) ~ 0;
1396 u32 queue_id = (
u32) ~ 0;
1398 u8 queue_id_valid = 0;
1408 else if (
unformat (line_input,
"queue %d", &queue_id))
1410 else if (
unformat (line_input,
"polling"))
1412 else if (
unformat (line_input,
"interrupt"))
1414 else if (
unformat (line_input,
"adaptive"))
1427 if (hw_if_index == (
u32) ~ 0)
1474 .path =
"set interface rx-mode",
1475 .short_help =
"set interface rx-mode <interface> [queue <n>] [polling | interrupt | adaptive]",
1496 rt = vlib_node_get_runtime_data (this_vlib_main, si);
1498 if (vec_len (rt->devices_and_queues))
1499 s = format (s,
" node %U:\n", format_vlib_node_name, vm, si);
1501 vec_foreach (dq, rt->devices_and_queues)
1503 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm,
1505 s = format (s,
" %U queue %u (%U)\n",
1506 format_vnet_sw_if_index_name, vnm, hi->sw_if_index,
1508 format_vnet_hw_interface_rx_mode, dq->mode);
1552 .path =
"show interface rx-placement",
1553 .short_help =
"show interface rx-placement",
1560 u32 thread_index,
u8 is_main)
1575 "please specify valid worker thread or main");
1601 u32 hw_if_index = (
u32) ~ 0;
1603 u32 thread_index = (
u32) ~ 0;
1614 else if (
unformat (line_input,
"queue %d", &queue_id))
1616 else if (
unformat (line_input,
"main", &thread_index))
1618 else if (
unformat (line_input,
"worker %d", &thread_index))
1631 if (hw_if_index == (
u32) ~ 0)
1690 .path =
"set interface rx-placement",
1691 .short_help =
"set interface rx-placement <interface> [queue <n>] " 1692 "[worker <n> | main]",
1711 (vm,
"pcap %s dispatch capture enabled: %d of %d pkts...",
1712 (rxtx ==
VLIB_RX) ?
"rx" :
"tx",
1718 (rxtx ==
VLIB_RX) ?
"rx" :
"tx");
1726 return VNET_API_ERROR_INVALID_VALUE;
1730 return VNET_API_ERROR_VALUE_EXIST;
1735 return VNET_API_ERROR_INVALID_VALUE_2;
1742 memset (pm, 0,
sizeof (*pm));
1750 (rxtx ==
VLIB_RX) ?
"rx" :
"tx", 0);
1775 return VNET_API_ERROR_SYSCALL_ERROR_1;
1780 return VNET_API_ERROR_NO_SUCH_ENTRY;
1807 if (
unformat (line_input,
"on %=", &enable, 1))
1809 else if (
unformat (line_input,
"enable %=", &enable, 1))
1811 else if (
unformat (line_input,
"off %=", &enable, 0))
1813 else if (
unformat (line_input,
"disable %=", &enable, 0))
1815 else if (
unformat (line_input,
"max %d", &max))
1817 else if (
unformat (line_input,
"packets-to-capture %d", &max))
1822 else if (
unformat (line_input,
"status %=", &status, 1))
1824 else if (
unformat (line_input,
"intfc %U",
1827 else if (
unformat (line_input,
"intfc any"))
1853 case VNET_API_ERROR_INVALID_VALUE:
1856 case VNET_API_ERROR_VALUE_EXIST:
1859 case VNET_API_ERROR_INVALID_VALUE_2:
1861 (0,
"can't change number of records to capture while tracing...");
1863 case VNET_API_ERROR_SYSCALL_ERROR_1:
1866 case VNET_API_ERROR_NO_SUCH_ENTRY:
1948 .path =
"pcap tx trace",
1950 "pcap tx trace [on|off] [max <nn>] [intfc <interface>|any] [file <name>] [status]",
1954 .path =
"pcap rx trace",
1956 "pcap rx trace [on|off] [max <nn>] [intfc <interface>|any] [file <name>] [status]",
unformat_function_t unformat_vnet_hw_interface
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
static clib_error_t * clear_interface_counters(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
format_function_t format_vnet_sw_interface
static clib_error_t * create_sub_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define hash_set(h, key, value)
char * file_name
File name of pcap output.
static clib_error_t * promiscuous_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * set_hw_class(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * set_hw_interface_rx_placement(u32 hw_if_index, u32 queue_id, u32 thread_index, u8 is_main)
static int sw_interface_name_compare(void *a1, void *a2)
void vnet_sw_interface_ip_directed_broadcast(vnet_main_t *vnm, u32 sw_if_index, u8 enable)
static clib_error_t * set_state(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int file_descriptor
File descriptor for reading/writing.
uword first_worker_thread_index
u32 n_packets_to_capture
Number of packets to capture.
static ip6_fib_t * ip6_fib_get(fib_node_index_t index)
static clib_error_t * set_interface_mac_address(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_main_t * vnet_get_main(void)
u8 * format_l2_output_features(u8 *s, va_list *args)
unformat_function_t unformat_hash_string
vnet_interface_main_t interface_main
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).
word vnet_sw_interface_compare(vnet_main_t *vnm, uword sw_if_index0, uword sw_if_index1)
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
static void vnet_clear_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * set_tag(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * renumber_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define hash_set_mem(h, key, value)
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
ip_lookup_main_t lookup_main
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
uword * sub_interface_sw_if_index_by_id
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
unformat_function_t unformat_vnet_sw_interface
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
struct _vnet_device_class vnet_device_class_t
uword * dq_runtime_index_by_queue
format_function_t format_vnet_sw_if_index_name
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
uword last_worker_thread_index
ethernet_main_t ethernet_main
vnet_hw_interface_rx_mode
format_function_t format_vnet_hw_interface
PCAP main state data structure.
clib_spinlock_t lock
spinlock to protect e.g.
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Clear a collection of combined counters.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
static vnet_device_class_t * vnet_get_device_class(vnet_main_t *vnm, u32 dev_class_index)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
vlib_combined_counter_main_t * combined_sw_if_counters
static clib_error_t * parse_vlan_sub_interfaces(unformat_input_t *input, vnet_sw_interface_t *template)
Parse subinterface names.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
static clib_error_t * set_unnumbered(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
A collection of simple counters.
void vnet_sw_interface_set_protocol_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu[])
static clib_error_t * mtu_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void clib_spinlock_init(clib_spinlock_t *p)
u32 max_supported_packet_bytes
vnet_hw_interface_t * hw_interfaces
vlib_worker_thread_t * vlib_worker_threads
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
l2_output_config_t * l2output_intf_config(u32 sw_if_index)
Get a pointer to the config for the given interface.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u8 * pcap_data
Vector of pcap data.
int vnet_pcap_dispatch_trace_configure(vnet_pcap_dispatch_trace_args_t *a)
int vnet_hw_interface_get_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, vnet_hw_interface_rx_mode *mode)
uword * sw_if_index_by_sup_and_sub
vnet_sw_interface_flags_t flags
clib_error_t * set_hw_interface_change_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u8 queue_id_valid, u32 queue_id, vnet_hw_interface_rx_mode mode)
static clib_error_t * show_sw_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_simple_counter_main_t * sw_if_counters
word vnet_hw_interface_compare(vnet_main_t *vnm, uword hw_if_index0, uword hw_if_index1)
static clib_error_t * set_interface_rx_placement(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vnet_sw_interface_update_unnumbered(u32 unnumbered_sw_if_index, u32 ip_sw_if_index, u8 enable)
#define foreach_vlib_main(body)
static int compare_interface_names(void *a1, void *a2)
uword * hw_interface_class_by_name
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
clib_error_t * pcap_close(pcap_main_t *pm)
Close PCAP file.
static clib_error_t * clear_tag(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vnet_interface_features_show(vlib_main_t *vm, u32 sw_if_index, int verbose)
Display the set of driver features configured on a specific interface Called by "show interface" hand...
#define vec_free(V)
Free vector's memory (no header).
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
static clib_error_t * pcap_trace_command_internal(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd, vlib_rx_or_tx_t rxtx)
#define clib_warning(format, args...)
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static void show_bond(vlib_main_t *vm)
clib_error_t * pcap_write(pcap_main_t *pm)
Write PCAP file.
vl_api_vxlan_gbp_api_tunnel_mode_t mode
static clib_error_t * show_or_clear_hw_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 unnumbered_sw_if_index
#define VLIB_CLI_COMMAND(x,...)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
void vnet_hw_interface_assign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, uword thread_index)
ip_lookup_main_t lookup_main
static void vnet_set_sw_interface_tag(vnet_main_t *vnm, u8 *tag, u32 sw_if_index)
static clib_error_t * pcap_tx_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Bitmaps built as vectors of machine words.
#define clib_error_report(e)
static u8 * vnet_get_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
static void * clib_mem_alloc(uword size)
uword unformat_ethernet_interface(unformat_input_t *input, va_list *args)
static vlib_main_t * vlib_get_main(void)
#define vec_elt(v, i)
Get vector value at index i.
pcap_packet_type_t packet_type
Packet type.
void vnet_hw_interface_set_mtu(vnet_main_t *vnm, u32 hw_if_index, u32 mtu)
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unformat_function_t unformat_vnet_sw_interface_flags
static clib_error_t * pcap_rx_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * vnet_interface_cli_init(vlib_main_t *vm)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
vnet_sw_interface_t * sw_interfaces
static clib_error_t * set_ip_directed_broadcast(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * set_hw_interface_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u32 queue_id, vnet_hw_interface_rx_mode mode)
l2_bridge_domain_t * bd_configs
A collection of combined counters.
#define hash_get_mem(h, key)
int vnet_hw_interface_unassign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
vnet_pcap_t pcap[VLIB_N_RX_TX]
u32 min_supported_packet_bytes
void vlib_clear_simple_counters(vlib_simple_counter_main_t *cm)
Clear a collection of simple counters.
ip4_main_t ip4_main
Global ip4 main structure.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
#define vec_foreach(var, vec)
Vector iterator.
vnet_hw_interface_rx_mode default_rx_mode
vnet_device_class_t * device_classes
u32 bd_find_index(bd_main_t *bdm, u32 bd_id)
Get a bridge domain.
int vnet_hw_interface_set_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, vnet_hw_interface_rx_mode mode)
static clib_error_t * set_interface_rx_mode(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * vnet_hw_interface_change_mac_address(vnet_main_t *vnm, u32 hw_if_index, const u8 *mac_address)
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u32 * fib_index_by_sw_if_index
u32 n_packets_captured
Number of packets currently captured.
static clib_error_t * show_interface_rx_placement_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_device_main_t vnet_device_main
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
clib_error_t * vnet_hw_interface_set_class(vnet_main_t *vnm, u32 hw_if_index, u32 hw_class_index)
static uword pool_elts(void *v)
Number of active elements in a pool.