31 #define foreach_dpdk_counter \ 32 _ (tx_frames_ok, opackets) \ 33 _ (tx_bytes_ok, obytes) \ 34 _ (tx_errors, oerrors) \ 35 _ (rx_frames_ok, ipackets) \ 36 _ (rx_bytes_ok, ibytes) \ 37 _ (rx_errors, ierrors) \ 38 _ (rx_missed, imissed) \ 39 _ (rx_no_bufs, rx_nombuf) 41 #define foreach_dpdk_q_counter \ 42 _ (rx_frames_ok, q_ipackets) \ 43 _ (tx_frames_ok, q_opackets) \ 44 _ (rx_bytes_ok, q_ibytes) \ 45 _ (tx_bytes_ok, q_obytes) \ 46 _ (rx_errors, q_errors) 48 #define foreach_dpdk_rss_hf \ 49 _(ETH_RSS_FRAG_IPV4, "ipv4-frag") \ 50 _(ETH_RSS_NONFRAG_IPV4_TCP, "ipv4-tcp") \ 51 _(ETH_RSS_NONFRAG_IPV4_UDP, "ipv4-udp") \ 52 _(ETH_RSS_NONFRAG_IPV4_SCTP, "ipv4-sctp") \ 53 _(ETH_RSS_NONFRAG_IPV4_OTHER, "ipv4-other") \ 54 _(ETH_RSS_IPV4, "ipv4") \ 55 _(ETH_RSS_IPV6_TCP_EX, "ipv6-tcp-ex") \ 56 _(ETH_RSS_IPV6_UDP_EX, "ipv6-udp-ex") \ 57 _(ETH_RSS_FRAG_IPV6, "ipv6-frag") \ 58 _(ETH_RSS_NONFRAG_IPV6_TCP, "ipv6-tcp") \ 59 _(ETH_RSS_NONFRAG_IPV6_UDP, "ipv6-udp") \ 60 _(ETH_RSS_NONFRAG_IPV6_SCTP, "ipv6-sctp") \ 61 _(ETH_RSS_NONFRAG_IPV6_OTHER, "ipv6-other") \ 62 _(ETH_RSS_IPV6_EX, "ipv6-ex") \ 63 _(ETH_RSS_IPV6, "ipv6") \ 64 _(ETH_RSS_L2_PAYLOAD, "l2-payload") \ 65 _(ETH_RSS_PORT, "port") \ 66 _(ETH_RSS_VXLAN, "vxlan") \ 67 _(ETH_RSS_GENEVE, "geneve") \ 68 _(ETH_RSS_NVGRE, "nvgre") 70 #define foreach_dpdk_pkt_rx_offload_flag \ 71 _ (PKT_RX_VLAN, "RX packet is a 802.1q VLAN packet") \ 72 _ (PKT_RX_RSS_HASH, "RX packet with RSS hash result") \ 73 _ (PKT_RX_FDIR, "RX packet with FDIR infos") \ 74 _ (PKT_RX_L4_CKSUM_BAD, "L4 cksum of RX pkt. is not OK") \ 75 _ (PKT_RX_IP_CKSUM_BAD, "IP cksum of RX pkt. is not OK") \ 76 _ (PKT_RX_EIP_CKSUM_BAD, "External IP header checksum error") \ 77 _ (PKT_RX_VLAN_STRIPPED, "RX packet VLAN tag stripped") \ 78 _ (PKT_RX_IP_CKSUM_GOOD, "IP cksum of RX pkt. is valid") \ 79 _ (PKT_RX_L4_CKSUM_GOOD, "L4 cksum of RX pkt. is valid") \ 80 _ (PKT_RX_IEEE1588_PTP, "RX IEEE1588 L2 Ethernet PT Packet") \ 81 _ (PKT_RX_IEEE1588_TMST, "RX IEEE1588 L2/L4 timestamped packet") \ 82 _ (PKT_RX_QINQ_STRIPPED, "RX packet QinQ tags stripped") \ 83 _ (PKT_RX_TIMESTAMP, "Timestamp field is valid") 85 #define foreach_dpdk_pkt_type \ 86 _ (L2, ETHER, "Ethernet packet") \ 87 _ (L2, ETHER_TIMESYNC, "Ethernet packet for time sync") \ 88 _ (L2, ETHER_ARP, "ARP packet") \ 89 _ (L2, ETHER_LLDP, "LLDP (Link Layer Discovery Protocol) packet") \ 90 _ (L2, ETHER_NSH, "NSH (Network Service Header) packet") \ 91 _ (L2, ETHER_VLAN, "VLAN packet") \ 92 _ (L2, ETHER_QINQ, "QinQ packet") \ 93 _ (L3, IPV4, "IPv4 packet without extension headers") \ 94 _ (L3, IPV4_EXT, "IPv4 packet with extension headers") \ 95 _ (L3, IPV4_EXT_UNKNOWN, "IPv4 packet with or without extension headers") \ 96 _ (L3, IPV6, "IPv6 packet without extension headers") \ 97 _ (L3, IPV6_EXT, "IPv6 packet with extension headers") \ 98 _ (L3, IPV6_EXT_UNKNOWN, "IPv6 packet with or without extension headers") \ 99 _ (L4, TCP, "TCP packet") \ 100 _ (L4, UDP, "UDP packet") \ 101 _ (L4, FRAG, "Fragmented IP packet") \ 102 _ (L4, SCTP, "SCTP (Stream Control Transmission Protocol) packet") \ 103 _ (L4, ICMP, "ICMP packet") \ 104 _ (L4, NONFRAG, "Non-fragmented IP packet") \ 105 _ (TUNNEL, GRE, "GRE tunneling packet") \ 106 _ (TUNNEL, VXLAN, "VXLAN tunneling packet") \ 107 _ (TUNNEL, NVGRE, "NVGRE Tunneling packet") \ 108 _ (TUNNEL, GENEVE, "GENEVE Tunneling packet") \ 109 _ (TUNNEL, GRENAT, "Teredo, VXLAN or GRE Tunneling packet") \ 110 _ (INNER_L2, ETHER, "Inner Ethernet packet") \ 111 _ (INNER_L2, ETHER_VLAN, "Inner Ethernet packet with VLAN") \ 112 _ (INNER_L3, IPV4, "Inner IPv4 packet without extension headers") \ 113 _ (INNER_L3, IPV4_EXT, "Inner IPv4 packet with extension headers") \ 114 _ (INNER_L3, IPV4_EXT_UNKNOWN, "Inner IPv4 packet with or without extension headers") \ 115 _ (INNER_L3, IPV6, "Inner IPv6 packet without extension headers") \ 116 _ (INNER_L3, IPV6_EXT, "Inner IPv6 packet with extension headers") \ 117 _ (INNER_L3, IPV6_EXT_UNKNOWN, "Inner IPv6 packet with or without extension headers") \ 118 _ (INNER_L4, TCP, "Inner TCP packet") \ 119 _ (INNER_L4, UDP, "Inner UDP packet") \ 120 _ (INNER_L4, FRAG, "Inner fragmented IP packet") \ 121 _ (INNER_L4, SCTP, "Inner SCTP (Stream Control Transmission Protocol) packet") \ 122 _ (INNER_L4, ICMP, "Inner ICMP packet") \ 123 _ (INNER_L4, NONFRAG, "Inner non-fragmented IP packet") 125 #define foreach_dpdk_pkt_tx_offload_flag \ 126 _ (PKT_TX_VLAN_PKT, "TX packet is a 802.1q VLAN packet") \ 127 _ (PKT_TX_IP_CKSUM, "IP cksum of TX pkt. computed by NIC") \ 128 _ (PKT_TX_TCP_CKSUM, "TCP cksum of TX pkt. computed by NIC") \ 129 _ (PKT_TX_SCTP_CKSUM, "SCTP cksum of TX pkt. computed by NIC") \ 130 _ (PKT_TX_IEEE1588_TMST, "TX IEEE1588 packet to timestamp") 132 #define foreach_dpdk_pkt_offload_flag \ 133 foreach_dpdk_pkt_rx_offload_flag \ 134 foreach_dpdk_pkt_tx_offload_flag 140 char *devname_format;
144 struct rte_eth_dev_info dev_info;
145 struct rte_pci_device *pci_dev;
152 devname_format =
"%s%d/%d/%d";
154 devname_format =
"%s%x/%x/%x";
159 device_name =
"GigabitEthernet";
163 device_name =
"Two_FiveGigabitEthernet";
167 device_name =
"FiveGigabitEthernet";
171 device_name =
"TenGigabitEthernet";
175 device_name =
"TwentyGigabitEthernet";
179 device_name =
"TwentyFiveGigabitEthernet";
183 device_name =
"FortyGigabitEthernet";
187 device_name =
"FiftyGigabitEthernet";
191 device_name =
"FiftySixGigabitEthernet";
195 device_name =
"HundredGigabitEthernet";
199 device_name =
"EthernetSwitch";
203 device_name =
"VirtualFunctionEthernet";
210 device_name =
"VirtioUser";
214 device_name =
"VhostEthernet";
218 device_name =
"FailsafeEthernet";
223 device_name =
"UnknownEthernet";
227 rte_eth_dev_info_get (xd->
port_id, &dev_info);
231 ret =
format (s, devname_format, device_name, pci_dev->addr.bus,
232 pci_dev->addr.devid, pci_dev->addr.function);
247 #define _(a, b, c) if (xd->flags & (1 << a)) \ 248 t = format (t, "%s%s", t ? " ":"", c); 265 case VNET_DPDK_PMD_E1000EM:
266 dev_type =
"Intel 82540EM (e1000)";
269 case VNET_DPDK_PMD_IGB:
270 dev_type =
"Intel e1000";
273 case VNET_DPDK_PMD_I40E:
274 dev_type =
"Intel X710/XL710 Family";
277 case VNET_DPDK_PMD_I40EVF:
278 dev_type =
"Intel X710/XL710 Family VF";
281 case VNET_DPDK_PMD_ICE:
282 dev_type =
"Intel E810 Family";
285 case VNET_DPDK_PMD_FM10K:
286 dev_type =
"Intel FM10000 Family Ethernet Switch";
289 case VNET_DPDK_PMD_IGBVF:
290 dev_type =
"Intel e1000 VF";
293 case VNET_DPDK_PMD_VIRTIO:
294 dev_type =
"Red Hat Virtio";
297 case VNET_DPDK_PMD_IXGBEVF:
298 dev_type =
"Intel 82599 VF";
301 case VNET_DPDK_PMD_IXGBE:
302 dev_type =
"Intel 82599";
305 case VNET_DPDK_PMD_ENIC:
306 dev_type =
"Cisco VIC";
309 case VNET_DPDK_PMD_CXGBE:
310 dev_type =
"Chelsio T4/T5";
313 case VNET_DPDK_PMD_MLX4:
314 dev_type =
"Mellanox ConnectX-3 Family";
317 case VNET_DPDK_PMD_MLX5:
318 dev_type =
"Mellanox ConnectX-4 Family";
321 case VNET_DPDK_PMD_VMXNET3:
322 dev_type =
"VMware VMXNET3";
325 case VNET_DPDK_PMD_AF_PACKET:
326 dev_type =
"af_packet";
329 case VNET_DPDK_PMD_DPAA2:
330 dev_type =
"NXP DPAA2 Mac";
333 case VNET_DPDK_PMD_VIRTIO_USER:
334 dev_type =
"Virtio User";
337 case VNET_DPDK_PMD_THUNDERX:
338 dev_type =
"Cavium ThunderX";
341 case VNET_DPDK_PMD_VHOST_ETHER:
342 dev_type =
"VhostEthernet";
345 case VNET_DPDK_PMD_ENA:
346 dev_type =
"AWS ENA VF";
349 case VNET_DPDK_PMD_FAILSAFE:
350 dev_type =
"FailsafeEthernet";
353 case VNET_DPDK_PMD_LIOVF_ETHER:
354 dev_type =
"Cavium Lio VF";
357 case VNET_DPDK_PMD_QEDE:
358 dev_type =
"Cavium QLogic FastLinQ QL4xxxx";
361 case VNET_DPDK_PMD_NETVSC:
362 dev_type =
"Microsoft Hyper-V Netvsc";
365 case VNET_DPDK_PMD_BNXT:
366 dev_type =
"Broadcom NetXtreme E/S-Series";
371 dev_type =
"### UNKNOWN ###";
375 return format (s, dev_type);
382 struct rte_eth_link *l = &xd->
link;
386 s =
format (s,
"%s ", l->link_status ?
"up" :
"down");
389 u32 promisc = rte_eth_promiscuous_get (xd->
port_id);
391 s =
format (s,
"%s duplex ", (l->link_duplex == ETH_LINK_FULL_DUPLEX) ?
404 if (format_get_indent (s) > 72) \ 405 s = format(s,"\n%U", format_white_space, indent); \ 406 s = format(s, "%s ", str); \ 412 u64 bitmap = va_arg (*args,
u64);
416 return format (s,
"none");
428 u8 *
id = va_arg (*va,
u8 *);
436 for (i = 0;
id[
i] != 0 && i < l; i++)
452 if (format_get_indent (s) > 72) \ 453 s = format(s,"\n%U", format_white_space, indent); \ 454 s = format(s, "%U ", format_offload, func (v)); \ 460 u64 bitmap = va_arg (*args,
u32);
465 return format (s,
"none");
467 for (i = 0; i < 64; i++)
471 _(mask, rte_eth_dev_rx_offload_name);
479 u64 bitmap = va_arg (*args,
u32);
484 return format (s,
"none");
486 for (i = 0; i < 64; i++)
490 _(mask, rte_eth_dev_tx_offload_name);
515 struct rte_eth_dev_module_info mi = { 0 };
516 struct rte_dev_eeprom_info ei = { 0 };
518 if (rte_eth_dev_get_module_info (xd->
port_id, &mi) != 0)
519 return format (s,
"unknown");
521 ei.length = mi.eeprom_len;
524 if (rte_eth_dev_get_module_eeprom (xd->
port_id, &ei) == 0)
527 (mi.type == RTE_ETH_MODULE_SFF_8436 ? 0x80 : 0));
530 s =
format (s,
"eeprom read error");
539 Dl_info info = { 0 };
541 if (dladdr (p, &info) == 0)
544 return info.dli_sname;
550 u32 dev_instance = va_arg (*args,
u32);
551 int verbose = va_arg (*args,
int);
556 struct rte_eth_dev_info di;
560 rte_eth_dev_info_get (xd->
port_id, &di);
562 s =
format (s,
"%U\n%Ucarrier %U",
565 s =
format (s,
"%Uflags: %U\n",
567 if (di.device->devargs && di.device->devargs->args)
568 s =
format (s,
"%UDevargs: %s\n",
570 s =
format (s,
"%Urx: queues %d (max %d), desc %d " 571 "(min %d max %d align %d)\n",
573 xd->
nb_rx_desc, di.rx_desc_lim.nb_min, di.rx_desc_lim.nb_max,
574 di.rx_desc_lim.nb_align);
575 s =
format (s,
"%Utx: queues %d (max %d), desc %d " 576 "(min %d max %d align %d)\n",
578 xd->
nb_tx_desc, di.tx_desc_lim.nb_min, di.tx_desc_lim.nb_max,
579 di.tx_desc_lim.nb_align);
581 if (xd->
flags & DPDK_DEVICE_FLAG_PMD)
583 struct rte_pci_device *pci;
584 struct rte_eth_rss_conf rss_conf;
588 rss_conf.rss_key = 0;
590 retval = rte_eth_dev_rss_hash_conf_get (xd->
port_id, &rss_conf);
592 clib_warning (
"rte_eth_dev_rss_hash_conf_get returned %d", retval);
602 s2 =
format (0,
"unknown");
603 s =
format (s,
"%Upci: device %04x:%04x subsystem %04x:%04x " 604 "address %04x:%02x:%02x.%02x numa %v\n",
606 pci->id.device_id, pci->id.subsystem_vendor_id,
607 pci->id.subsystem_device_id, pci->addr.domain,
608 pci->addr.bus, pci->addr.devid, pci->addr.function, s2);
619 indent + 2, di.max_rx_pktlen);
620 s =
format (s,
"%Upromiscuous: unicast %s all-multicast %s\n",
622 rte_eth_promiscuous_get (xd->
port_id) ?
"on" :
"off",
623 rte_eth_allmulticast_get (xd->
port_id) ?
"on" :
"off");
624 vlan_off = rte_eth_dev_get_vlan_offload (xd->
port_id);
625 s =
format (s,
"%Uvlan offload: strip %s filter %s qinq %s\n",
627 vlan_off & ETH_VLAN_STRIP_OFFLOAD ?
"on" :
"off",
628 vlan_off & ETH_VLAN_FILTER_OFFLOAD ?
"on" :
"off",
629 vlan_off & ETH_VLAN_EXTEND_OFFLOAD ?
"on" :
"off");
630 s =
format (s,
"%Urx offload avail: %U\n",
633 s =
format (s,
"%Urx offload active: %U\n",
636 s =
format (s,
"%Utx offload avail: %U\n",
639 s =
format (s,
"%Utx offload active: %U\n",
642 s =
format (s,
"%Urss avail: %U\n" 643 "%Urss active: %U\n",
648 s =
format (s,
"%Utx burst function: %s\n",
651 s =
format (s,
"%Urx burst function: %s\n",
659 if (xd->stats.V != 0) { \ 660 s = format (s, "\n%U%-40U%16Lu", \ 661 format_white_space, indent + 2, \ 662 format_c_identifier, #N, \ 672 struct rte_eth_xstat *xstat;
673 struct rte_eth_xstat_name *xstat_names = 0;
676 int ret = rte_eth_xstats_get_names (xd->
port_id, xstat_names, len);
678 if (ret >= 0 && ret <= len)
684 if (verbose == 2 || (verbose && xstat->value))
688 xs =
format(xs,
"\n%U%-38U%16Lu",
701 s =
format (s,
"\n%Uextended stats:%v",
727 s =
format (s,
"%U tx queue %d",
730 s =
format (s,
"\n%Ubuffer 0x%x: %U",
758 s =
format (s,
"%U rx queue %d",
761 s =
format (s,
"\n%Ubuffer 0x%x: %U",
772 t->
mb.data_len > sizeof (t->
data) ?
" (truncated)" :
"");
776 sizeof (t->
data) ? sizeof (t->
data) : t->
mb.data_len);
791 u32 *pkt_types = va_arg (*va,
u32 *);
797 s =
format (s,
"Packet Types");
800 if ((*pkt_types & RTE_PTYPE_##L##_MASK) == RTE_PTYPE_##L##_##F) \ 802 s = format (s, "\n%U%s (0x%04x) %s", format_white_space, indent, \ 803 "RTE_PTYPE_" #L "_" #F, RTE_PTYPE_##L##_##F, S); \ 814 u64 *ol_flags = va_arg (*va,
u64 *);
820 s =
format (s,
"Packet Offload Flags");
825 s = format (s, "\n%U%s (0x%04x) %s", \ 826 format_white_space, indent, #F, F, S); \ 840 if (clib_net_to_host_u16 (vlan_hdr->
type) == ETHERNET_TYPE_DOT1AD)
842 s =
format (s,
"%U 802.1q vlan ",
858 struct rte_mbuf *mb = va_arg (*va,
struct rte_mbuf *);
862 s =
format (s,
"PKT MBUF: port %d, nb_segs %d, pkt_len %d" 863 "\n%Ubuf_len %d, data_len %d, ol_flags 0x%lx, data_off %d, phys_addr 0x%x" 864 "\n%Upacket_type 0x%x l2_len %u l3_len %u outer_l2_len %u outer_l3_len %u" 865 "\n%Urss 0x%x fdir.hi 0x%x fdir.lo 0x%x",
866 mb->port, mb->nb_segs, mb->pkt_len,
868 mb->buf_len, mb->data_len, mb->ol_flags, mb->data_off,
870 mb->l2_len, mb->l3_len, mb->outer_l2_len, mb->outer_l3_len,
878 if ((mb->ol_flags & PKT_RX_VLAN) &&
879 ((mb->ol_flags & (PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ_STRIPPED)) == 0))
902 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.
u8 interface_name_format_decimal
vnet_main_t * vnet_get_main(void)
static f64 vlib_time_now(vlib_main_t *vm)
struct rte_pci_device * dpdk_get_pci_device(const struct rte_eth_dev_info *info)
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).
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#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...)
struct rte_eth_conf port_conf
format_function_t format_vnet_sw_interface_name
format_function_t format_vnet_buffer
dpdk_port_type_t port_type
format_function_t format_sfp_eeprom
format_function_t * format_buffer
u16 af_packet_instance_num
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
vlib_main_t vlib_node_runtime_t * node
struct rte_eth_xstat * xstats
u8 * interface_name_suffix
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
static void clib_mem_free(void *p)
vlib_trace_main_t trace_main
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
static void * clib_mem_alloc(uword size)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static uword clib_mem_is_vec(void *v)
Predicate function, says whether the supplied vector is a clib heap object.
#define vec_foreach(var, vec)
Vector iterator.
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
dpdk_config_main_t * conf