27 #define foreach_dpdk_counter \ 28 _ (tx_frames_ok, opackets) \ 29 _ (tx_bytes_ok, obytes) \ 30 _ (tx_errors, oerrors) \ 31 _ (rx_frames_ok, ipackets) \ 32 _ (rx_bytes_ok, ibytes) \ 33 _ (rx_errors, ierrors) \ 34 _ (rx_missed, imissed) \ 35 _ (rx_no_bufs, rx_nombuf) 37 #define foreach_dpdk_q_counter \ 38 _ (rx_frames_ok, q_ipackets) \ 39 _ (tx_frames_ok, q_opackets) \ 40 _ (rx_bytes_ok, q_ibytes) \ 41 _ (tx_bytes_ok, q_obytes) \ 42 _ (rx_errors, q_errors) 44 #define foreach_dpdk_rss_hf \ 45 _(ETH_RSS_FRAG_IPV4, "ipv4-frag") \ 46 _(ETH_RSS_NONFRAG_IPV4_TCP, "ipv4-tcp") \ 47 _(ETH_RSS_NONFRAG_IPV4_UDP, "ipv4-udp") \ 48 _(ETH_RSS_NONFRAG_IPV4_SCTP, "ipv4-sctp") \ 49 _(ETH_RSS_NONFRAG_IPV4_OTHER, "ipv4-other") \ 50 _(ETH_RSS_IPV4, "ipv4") \ 51 _(ETH_RSS_IPV6_TCP_EX, "ipv6-tcp-ex") \ 52 _(ETH_RSS_IPV6_UDP_EX, "ipv6-udp-ex") \ 53 _(ETH_RSS_FRAG_IPV6, "ipv6-frag") \ 54 _(ETH_RSS_NONFRAG_IPV6_TCP, "ipv6-tcp") \ 55 _(ETH_RSS_NONFRAG_IPV6_UDP, "ipv6-udp") \ 56 _(ETH_RSS_NONFRAG_IPV6_SCTP, "ipv6-sctp") \ 57 _(ETH_RSS_NONFRAG_IPV6_OTHER, "ipv6-other") \ 58 _(ETH_RSS_L2_PAYLOAD, "l2-payload") \ 59 _(ETH_RSS_IPV6_EX, "ipv6-ex") \ 60 _(ETH_RSS_IPV6, "ipv6") 63 #define foreach_dpdk_rx_offload_caps \ 64 _(DEV_RX_OFFLOAD_VLAN_STRIP, "vlan-strip") \ 65 _(DEV_RX_OFFLOAD_IPV4_CKSUM, "ipv4-cksum") \ 66 _(DEV_RX_OFFLOAD_UDP_CKSUM , "udp-cksum") \ 67 _(DEV_RX_OFFLOAD_TCP_CKSUM , "tcp-cksum") \ 68 _(DEV_RX_OFFLOAD_TCP_LRO , "rcp-lro") \ 69 _(DEV_RX_OFFLOAD_QINQ_STRIP, "qinq-strip") 71 #define foreach_dpdk_tx_offload_caps \ 72 _(DEV_TX_OFFLOAD_VLAN_INSERT, "vlan-insert") \ 73 _(DEV_TX_OFFLOAD_IPV4_CKSUM, "ipv4-cksum") \ 74 _(DEV_TX_OFFLOAD_UDP_CKSUM , "udp-cksum") \ 75 _(DEV_TX_OFFLOAD_TCP_CKSUM , "tcp-cksum") \ 76 _(DEV_TX_OFFLOAD_SCTP_CKSUM , "sctp-cksum") \ 77 _(DEV_TX_OFFLOAD_TCP_TSO , "tcp-tso") \ 78 _(DEV_TX_OFFLOAD_UDP_TSO , "udp-tso") \ 79 _(DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM, "outer-ipv4-cksum") \ 80 _(DEV_TX_OFFLOAD_QINQ_INSERT, "qinq-insert") 82 #define foreach_dpdk_pkt_rx_offload_flag \ 83 _ (PKT_RX_VLAN_PKT, "RX packet is a 802.1q VLAN packet") \ 84 _ (PKT_RX_RSS_HASH, "RX packet with RSS hash result") \ 85 _ (PKT_RX_FDIR, "RX packet with FDIR infos") \ 86 _ (PKT_RX_L4_CKSUM_BAD, "L4 cksum of RX pkt. is not OK") \ 87 _ (PKT_RX_IP_CKSUM_BAD, "IP cksum of RX pkt. is not OK") \ 88 _ (PKT_RX_IEEE1588_PTP, "RX IEEE1588 L2 Ethernet PT Packet") \ 89 _ (PKT_RX_IEEE1588_TMST, "RX IEEE1588 L2/L4 timestamped packet") 91 #define foreach_dpdk_pkt_type \ 92 _ (L2, ETHER, "Ethernet packet") \ 93 _ (L2, ETHER_TIMESYNC, "Ethernet packet for time sync") \ 94 _ (L2, ETHER_ARP, "ARP packet") \ 95 _ (L2, ETHER_LLDP, "LLDP (Link Layer Discovery Protocol) packet") \ 96 _ (L3, IPV4, "IPv4 packet without extension headers") \ 97 _ (L3, IPV4_EXT, "IPv4 packet with extension headers") \ 98 _ (L3, IPV4_EXT_UNKNOWN, "IPv4 packet with or without extension headers") \ 99 _ (L3, IPV6, "IPv6 packet without extension headers") \ 100 _ (L3, IPV6_EXT, "IPv6 packet with extension headers") \ 101 _ (L3, IPV6_EXT_UNKNOWN, "IPv6 packet with or without extension headers") \ 102 _ (L4, TCP, "TCP packet") \ 103 _ (L4, UDP, "UDP packet") \ 104 _ (L4, FRAG, "Fragmented IP packet") \ 105 _ (L4, SCTP, "SCTP (Stream Control Transmission Protocol) packet") \ 106 _ (L4, ICMP, "ICMP packet") \ 107 _ (L4, NONFRAG, "Non-fragmented IP packet") \ 108 _ (TUNNEL, GRE, "GRE tunneling packet") \ 109 _ (TUNNEL, VXLAN, "VXLAN tunneling packet") \ 110 _ (TUNNEL, NVGRE, "NVGRE Tunneling packet") \ 111 _ (TUNNEL, GENEVE, "GENEVE Tunneling packet") \ 112 _ (TUNNEL, GRENAT, "Teredo, VXLAN or GRE Tunneling packet") \ 113 _ (INNER_L2, ETHER, "Inner Ethernet packet") \ 114 _ (INNER_L2, ETHER_VLAN, "Inner Ethernet packet with VLAN") \ 115 _ (INNER_L3, IPV4, "Inner IPv4 packet without extension headers") \ 116 _ (INNER_L3, IPV4_EXT, "Inner IPv4 packet with extension headers") \ 117 _ (INNER_L3, IPV4_EXT_UNKNOWN, "Inner IPv4 packet with or without extension headers") \ 118 _ (INNER_L3, IPV6, "Inner IPv6 packet without extension headers") \ 119 _ (INNER_L3, IPV6_EXT, "Inner IPv6 packet with extension headers") \ 120 _ (INNER_L3, IPV6_EXT_UNKNOWN, "Inner IPv6 packet with or without extension headers") \ 121 _ (INNER_L4, TCP, "Inner TCP packet") \ 122 _ (INNER_L4, UDP, "Inner UDP packet") \ 123 _ (INNER_L4, FRAG, "Inner fagmented IP packet") \ 124 _ (INNER_L4, SCTP, "Inner SCTP (Stream Control Transmission Protocol) packet") \ 125 _ (INNER_L4, ICMP, "Inner ICMP packet") \ 126 _ (INNER_L4, NONFRAG, "Inner non-fragmented IP packet") 128 #define foreach_dpdk_pkt_tx_offload_flag \ 129 _ (PKT_TX_VLAN_PKT, "TX packet is a 802.1q VLAN packet") \ 130 _ (PKT_TX_IP_CKSUM, "IP cksum of TX pkt. computed by NIC") \ 131 _ (PKT_TX_TCP_CKSUM, "TCP cksum of TX pkt. computed by NIC") \ 132 _ (PKT_TX_SCTP_CKSUM, "SCTP cksum of TX pkt. computed by NIC") \ 133 _ (PKT_TX_IEEE1588_TMST, "TX IEEE1588 packet to timestamp") 135 #define foreach_dpdk_pkt_offload_flag \ 136 foreach_dpdk_pkt_rx_offload_flag \ 137 foreach_dpdk_pkt_tx_offload_flag 139 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS 140 #define foreach_dpdk_pkt_ext_rx_offload_flag \ 141 _ (PKT_EXT_RX_PKT_ERROR, "RX Packet Error") \ 142 _ (PKT_EXT_RX_BAD_FCS, "RX Bad FCS checksum") \ 143 _ (PKT_EXT_RX_UDP, "RX packet with UDP L4 header") \ 144 _ (PKT_EXT_RX_TCP, "RX packet with TCP L4 header") \ 145 _ (PKT_EXT_RX_IPV4_FRAGMENT, "RX packet IPv4 Fragment") 147 #define foreach_dpdk_pkt_ext_offload_flag \ 148 foreach_dpdk_pkt_rx_offload_flag \ 149 foreach_dpdk_pkt_ext_rx_offload_flag 157 char *devname_format;
160 struct rte_eth_dev_info dev_info;
164 devname_format =
"%s%d/%d/%d";
166 devname_format =
"%s%x/%x/%x";
168 #ifdef RTE_LIBRTE_KNI 178 return format (s,
"VirtualEthernet0/0/%d", dm->
devices[i].vu_if_id);
184 device_name =
"GigabitEthernet";
188 device_name =
"TenGigabitEthernet";
192 device_name =
"FortyGigabitEthernet";
199 device_name =
"EthernetSwitch";
203 rte_eth_dev_info_get (i, &dev_info);
208 device_name =
"UnknownEthernet";
212 rte_eth_dev_info_get (i, &dev_info);
213 ret =
format (s, devname_format, device_name, dev_info.pci_dev->addr.bus,
214 dev_info.pci_dev->addr.devid,
215 dev_info.pci_dev->addr.function);
231 return format (s,
"Kernel NIC Interface");
235 return format (s,
"vhost-user interface");
240 case VNET_DPDK_PMD_E1000EM:
241 dev_type =
"Intel 82540EM (e1000)";
244 case VNET_DPDK_PMD_IGB:
245 dev_type =
"Intel e1000";
248 case VNET_DPDK_PMD_I40E:
249 dev_type =
"Intel X710/XL710 Family";
252 case VNET_DPDK_PMD_I40EVF:
253 dev_type =
"Intel X710/XL710 Family VF";
256 case VNET_DPDK_PMD_FM10K:
257 dev_type =
"Intel FM10000 Family Ethernet Switch";
260 case VNET_DPDK_PMD_IGBVF:
261 dev_type =
"Intel e1000 VF";
264 case VNET_DPDK_PMD_VIRTIO:
265 dev_type =
"Red Hat Virtio";
268 case VNET_DPDK_PMD_IXGBEVF:
269 dev_type =
"Intel 82599 VF";
272 case VNET_DPDK_PMD_IXGBE:
273 dev_type =
"Intel 82599";
276 case VNET_DPDK_PMD_ENIC:
277 dev_type =
"Cisco VIC";
280 case VNET_DPDK_PMD_CXGBE:
281 dev_type =
"Chelsio T4/T5";
284 case VNET_DPDK_PMD_VMXNET3:
285 dev_type =
"VMware VMXNET3";
288 case VNET_DPDK_PMD_AF_PACKET:
289 dev_type =
"af_packet";
292 case VNET_DPDK_PMD_BOND:
293 dev_type =
"Ethernet Bonding";
296 case VNET_DPDK_PMD_DPAA2:
297 dev_type =
"NXP DPAA2 Mac";
302 dev_type =
"### UNKNOWN ###";
306 return format (s, dev_type);
313 struct rte_eth_link *l = &xd->
link;
317 s =
format (s,
"%s ", l->link_status ?
"up" :
"down");
322 s =
format (s,
"%s duplex ", (l->link_duplex == ETH_LINK_FULL_DUPLEX) ?
324 s =
format (s,
"speed %u mtu %d %s\n", l->link_speed,
336 if (format_get_indent (s) > next_split ) { \ 337 next_split += _line_len; \ 338 s = format(s,"\n%U", format_white_space, indent); \ 340 s = format(s, "%s ", str); \ 346 u64 bitmap = va_arg (*args,
u64);
347 int next_split = _line_len;
351 return format (s,
"none");
359 u32 bitmap = va_arg (*args,
u32);
360 int next_split = _line_len;
364 return format (s,
"none");
372 u32 bitmap = va_arg (*args,
u32);
373 int next_split = _line_len;
376 return format (s,
"none");
387 u32 dev_instance = va_arg (*args,
u32);
388 int verbose = va_arg (*args,
int);
393 struct rte_eth_dev_info di;
398 s =
format (s,
"%U\n%Ucarrier %U",
406 struct rte_pci_device *pci;
407 struct rte_eth_rss_conf rss_conf;
411 rss_conf.rss_key = 0;
412 retval = rte_eth_dev_rss_hash_conf_get (xd->
device_index, &rss_conf);
414 clib_warning (
"rte_eth_dev_rss_hash_conf_get returned %d", retval);
420 "%Upci id: device %04x:%04x subsystem %04x:%04x\n" 421 "%Upci address: %04x:%02x:%02x.%02x\n",
423 pci->id.device_id, pci->id.subsystem_vendor_id,
425 pci->addr.domain, pci->addr.bus, pci->addr.devid,
429 indent + 2, di.max_rx_pktlen);
432 indent + 2, di.max_rx_queues, di.max_tx_queues);
434 format (s,
"%Upromiscuous: unicast %s all-multicast %s\n",
436 rte_eth_promiscuous_get (xd->
device_index) ?
"on" :
"off",
437 rte_eth_promiscuous_get (xd->
device_index) ?
"on" :
"off");
438 vlan_off = rte_eth_dev_get_vlan_offload (xd->
device_index);
439 s =
format (s,
"%Uvlan offload: strip %s filter %s qinq %s\n",
441 vlan_off & ETH_VLAN_STRIP_OFFLOAD ?
"on" :
"off",
442 vlan_off & ETH_VLAN_FILTER_OFFLOAD ?
"on" :
"off",
443 vlan_off & ETH_VLAN_EXTEND_OFFLOAD ?
"on" :
"off");
444 s =
format (s,
"%Urx offload caps: %U\n",
447 s =
format (s,
"%Utx offload caps: %U\n",
450 s =
format (s,
"%Urss active: %U\n" 451 "%Urss supported: %U\n",
460 s =
format (s,
"%Uqueue size (max): rx %d (%d) tx %d (%d)\n",
465 s =
format (s,
"%Urx queues %d, rx desc %d, tx queues %d, tx desc %d\n",
470 s =
format (s,
"%Ucpu socket %d\n",
476 if ((xd->stats.V - xd->last_cleared_stats.V) != 0) { \ 477 s = format (s, "\n%U%-40U%16Ld", \ 478 format_white_space, indent + 2, \ 479 format_c_identifier, #N, \ 480 xd->stats.V - xd->last_cleared_stats.V); \ 489 #if RTE_VERSION < RTE_VERSION_NUM(16, 7, 0, 0) 490 struct rte_eth_xstats *xstat, *last_xstat;
492 struct rte_eth_xstat *xstat, *last_xstat;
493 struct rte_eth_xstat_name *xstat_names = 0;
496 rte_eth_xstats_get_names (xd->
device_index, xstat_names, len);
508 delta = xstat->value - last_xstat->value;
509 if (verbose == 2 || (verbose && delta))
512 #if RTE_VERSION < RTE_VERSION_NUM(16, 7, 0, 0) 513 u8 * name =
format(0,
"%s", xstat->name);
515 u8 * name =
format(0,
"%s", xstat_names[i].name);
517 xs =
format(xs,
"\n%U%-38U%16Ld",
525 #if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0) 533 for (i = 0; i < xd->
rx_q_used * VIRTIO_QNUM; i++)
536 if (verbose == 2 || xd->vu_intf->vrings[i].packets)
540 name =
format (
NULL,
"tx q%d packets", i >> 1);
544 name =
format (
NULL,
"rx q%d packets", i >> 1);
546 xs =
format (xs,
"\n%U%-38U%16Ld",
549 xd->vu_intf->vrings[i].packets);
560 xs =
format (xs,
"\n%U%-38U%16Ld",
563 xd->vu_intf->vrings[i].bytes);
572 s =
format (s,
"\n%Uextended stats:%v",
592 s =
format (s,
"%U tx queue %d",
595 s =
format (s,
"\n%Ubuffer 0x%x: %U",
619 s =
format (s,
"%U rx queue %d",
622 s =
format (s,
"\n%Ubuffer 0x%x: %U",
626 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS 638 t->
mb.data_len > sizeof (t->
data) ?
" (truncated)" :
"");
642 sizeof (t->
data) ? sizeof (t->
data) : t->
mb.data_len);
657 u32 *pkt_types = va_arg (*va,
u32 *);
663 s =
format (s,
"Packet Types");
666 if ((*pkt_types & RTE_PTYPE_##L##_MASK) == RTE_PTYPE_##L##_##F) \ 668 s = format (s, "\n%U%s (0x%04x) %s", format_white_space, indent, \ 669 "RTE_PTYPE_" #L "_" #F, RTE_PTYPE_##L##_##F, S); \ 680 u64 *ol_flags = va_arg (*va,
u64 *);
686 s =
format (s,
"Packet Offload Flags");
691 s = format (s, "\n%U%s (0x%04x) %s", \ 692 format_white_space, indent, #F, F, S); \ 706 if (clib_net_to_host_u16 (vlan_hdr->
type) == ETHERNET_TYPE_DOT1AD)
708 s =
format (s,
"%U 802.1q vlan ",
724 struct rte_mbuf *mb = va_arg (*va,
struct rte_mbuf *);
728 s =
format (s,
"PKT MBUF: port %d, nb_segs %d, pkt_len %d" 729 "\n%Ubuf_len %d, data_len %d, ol_flags 0x%x, data_off %d, phys_addr 0x%x" 730 "\n%Upacket_type 0x%x",
731 mb->port, mb->nb_segs, mb->pkt_len,
733 mb->buf_len, mb->data_len, mb->ol_flags, mb->data_off,
740 if (mb->ol_flags & PKT_RX_VLAN_PKT)
754 #ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS 757 format_dpdk_pkt_rx_offload_flags (
u8 * s, va_list * va)
759 u16 *ol_flags = va_arg (*va,
u16 *);
765 s =
format (s,
"Packet RX Offload Flags");
770 s = format (s, "\n%U%s (0x%04x) %s", \ 771 format_white_space, indent, #F, F, S); \ 774 foreach_dpdk_pkt_ext_offload_flag
782 struct rte_mbuf *mb = va_arg (*va,
struct rte_mbuf *);
790 s =
format (s,
"PKT MBUF: port %d, nb_segs %d, pkt_len %d" 791 "\n%Ubuf_len %d, data_len %d, ol_flags 0x%x" 792 "\n%Upacket_type 0x%x",
793 mb->port, mb->nb_segs, mb->pkt_len,
795 mb->buf_len, mb->data_len, mb->ol_flags,
800 format_dpdk_pkt_rx_offload_flags, &mb->ol_flags);
802 if (mb->ol_flags & PKT_RX_VLAN_PKT)
828 else if (
unformat (input,
"%u,", &mem))
830 else if (
unformat (input,
"%u", &mem))
853 else if (unformat (input, s)) \
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
u8 interface_name_format_decimal
format_function_t format_vlib_buffer
static f64 vlib_time_now(vlib_main_t *vm)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
struct rte_eth_xstat * last_cleared_xstats
vnet_main_t * vnet_get_main(void)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
#define clib_warning(format, args...)
format_function_t format_dpdk_rx_rte_mbuf
format_function_t format_vnet_sw_interface_name
dpdk_port_type_t port_type
format_function_t * format_buffer
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
#define vec_free(V)
Free vector's memory (no header).
struct rte_eth_xstat * xstats
u8 * interface_name_suffix
vlib_trace_main_t trace_main
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
dpdk_device_type_t dev_type
#define clib_error_return(e, args...)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
dpdk_config_main_t * conf