30 #define foreach_dpdk_counter \ 31 _ (tx_frames_ok, opackets) \ 32 _ (tx_bytes_ok, obytes) \ 33 _ (tx_errors, oerrors) \ 34 _ (rx_frames_ok, ipackets) \ 35 _ (rx_bytes_ok, ibytes) \ 36 _ (rx_errors, ierrors) \ 37 _ (rx_missed, imissed) \ 38 _ (rx_no_bufs, rx_nombuf) 40 #define foreach_dpdk_q_counter \ 41 _ (rx_frames_ok, q_ipackets) \ 42 _ (tx_frames_ok, q_opackets) \ 43 _ (rx_bytes_ok, q_ibytes) \ 44 _ (tx_bytes_ok, q_obytes) \ 45 _ (rx_errors, q_errors) 47 #define foreach_dpdk_pkt_rx_offload_flag \ 48 _ (PKT_RX_VLAN, "RX packet is a 802.1q VLAN packet") \ 49 _ (PKT_RX_RSS_HASH, "RX packet with RSS hash result") \ 50 _ (PKT_RX_FDIR, "RX packet with FDIR infos") \ 51 _ (PKT_RX_L4_CKSUM_BAD, "L4 cksum of RX pkt. is not OK") \ 52 _ (PKT_RX_IP_CKSUM_BAD, "IP cksum of RX pkt. is not OK") \ 53 _ (PKT_RX_EIP_CKSUM_BAD, "External IP header checksum error") \ 54 _ (PKT_RX_VLAN_STRIPPED, "RX packet VLAN tag stripped") \ 55 _ (PKT_RX_IP_CKSUM_GOOD, "IP cksum of RX pkt. is valid") \ 56 _ (PKT_RX_L4_CKSUM_GOOD, "L4 cksum of RX pkt. is valid") \ 57 _ (PKT_RX_IEEE1588_PTP, "RX IEEE1588 L2 Ethernet PT Packet") \ 58 _ (PKT_RX_IEEE1588_TMST, "RX IEEE1588 L2/L4 timestamped packet") \ 59 _ (PKT_RX_QINQ_STRIPPED, "RX packet QinQ tags stripped") \ 60 _ (PKT_RX_TIMESTAMP, "Timestamp field is valid") 62 #define foreach_dpdk_pkt_type \ 63 _ (L2, ETHER, "Ethernet packet") \ 64 _ (L2, ETHER_TIMESYNC, "Ethernet packet for time sync") \ 65 _ (L2, ETHER_ARP, "ARP packet") \ 66 _ (L2, ETHER_LLDP, "LLDP (Link Layer Discovery Protocol) packet") \ 67 _ (L2, ETHER_NSH, "NSH (Network Service Header) packet") \ 68 _ (L2, ETHER_VLAN, "VLAN packet") \ 69 _ (L2, ETHER_QINQ, "QinQ packet") \ 70 _ (L3, IPV4, "IPv4 packet without extension headers") \ 71 _ (L3, IPV4_EXT, "IPv4 packet with extension headers") \ 72 _ (L3, IPV4_EXT_UNKNOWN, "IPv4 packet with or without extension headers") \ 73 _ (L3, IPV6, "IPv6 packet without extension headers") \ 74 _ (L3, IPV6_EXT, "IPv6 packet with extension headers") \ 75 _ (L3, IPV6_EXT_UNKNOWN, "IPv6 packet with or without extension headers") \ 76 _ (L4, TCP, "TCP packet") \ 77 _ (L4, UDP, "UDP packet") \ 78 _ (L4, FRAG, "Fragmented IP packet") \ 79 _ (L4, SCTP, "SCTP (Stream Control Transmission Protocol) packet") \ 80 _ (L4, ICMP, "ICMP packet") \ 81 _ (L4, NONFRAG, "Non-fragmented IP packet") \ 82 _ (TUNNEL, GRE, "GRE tunneling packet") \ 83 _ (TUNNEL, VXLAN, "VXLAN tunneling packet") \ 84 _ (TUNNEL, NVGRE, "NVGRE Tunneling packet") \ 85 _ (TUNNEL, GENEVE, "GENEVE Tunneling packet") \ 86 _ (TUNNEL, GRENAT, "Teredo, VXLAN or GRE Tunneling packet") \ 87 _ (INNER_L2, ETHER, "Inner Ethernet packet") \ 88 _ (INNER_L2, ETHER_VLAN, "Inner Ethernet packet with VLAN") \ 89 _ (INNER_L3, IPV4, "Inner IPv4 packet without extension headers") \ 90 _ (INNER_L3, IPV4_EXT, "Inner IPv4 packet with extension headers") \ 91 _ (INNER_L3, IPV4_EXT_UNKNOWN, "Inner IPv4 packet with or without extension headers") \ 92 _ (INNER_L3, IPV6, "Inner IPv6 packet without extension headers") \ 93 _ (INNER_L3, IPV6_EXT, "Inner IPv6 packet with extension headers") \ 94 _ (INNER_L3, IPV6_EXT_UNKNOWN, "Inner IPv6 packet with or without extension headers") \ 95 _ (INNER_L4, TCP, "Inner TCP packet") \ 96 _ (INNER_L4, UDP, "Inner UDP packet") \ 97 _ (INNER_L4, FRAG, "Inner fragmented IP packet") \ 98 _ (INNER_L4, SCTP, "Inner SCTP (Stream Control Transmission Protocol) packet") \ 99 _ (INNER_L4, ICMP, "Inner ICMP packet") \ 100 _ (INNER_L4, NONFRAG, "Inner non-fragmented IP packet") 102 #define foreach_dpdk_pkt_tx_offload_flag \ 103 _ (PKT_TX_VLAN_PKT, "TX packet is a 802.1q VLAN packet") \ 104 _ (PKT_TX_IP_CKSUM, "IP cksum of TX pkt. computed by NIC") \ 105 _ (PKT_TX_TCP_CKSUM, "TCP cksum of TX pkt. computed by NIC") \ 106 _ (PKT_TX_SCTP_CKSUM, "SCTP cksum of TX pkt. computed by NIC") \ 107 _ (PKT_TX_IEEE1588_TMST, "TX IEEE1588 packet to timestamp") 109 #define foreach_dpdk_pkt_offload_flag \ 110 foreach_dpdk_pkt_rx_offload_flag \ 111 foreach_dpdk_pkt_tx_offload_flag 117 char *devname_format;
121 struct rte_eth_dev_info dev_info;
122 struct rte_pci_device *pci_dev;
129 devname_format =
"%s%d/%d/%d";
131 devname_format =
"%s%x/%x/%x";
136 device_name =
"GigabitEthernet";
140 device_name =
"Two_FiveGigabitEthernet";
144 device_name =
"FiveGigabitEthernet";
148 device_name =
"TenGigabitEthernet";
152 device_name =
"TwentyGigabitEthernet";
156 device_name =
"TwentyFiveGigabitEthernet";
160 device_name =
"FortyGigabitEthernet";
164 device_name =
"FiftyGigabitEthernet";
168 device_name =
"FiftySixGigabitEthernet";
172 device_name =
"HundredGigabitEthernet";
176 device_name =
"EthernetSwitch";
180 device_name =
"VirtualFunctionEthernet";
187 device_name =
"VirtioUser";
191 device_name =
"VhostEthernet";
195 device_name =
"FailsafeEthernet";
200 device_name =
"UnknownEthernet";
204 rte_eth_dev_info_get (xd->
port_id, &dev_info);
208 ret =
format (s, devname_format, device_name, pci_dev->addr.bus,
209 pci_dev->addr.devid, pci_dev->addr.function);
224 #define _(a, b, c) if (xd->flags & (1 << a)) \ 225 t = format (t, "%s%s", t ? " ":"", c); 242 case VNET_DPDK_PMD_E1000EM:
243 dev_type =
"Intel 82540EM (e1000)";
246 case VNET_DPDK_PMD_IGB:
247 dev_type =
"Intel e1000";
250 case VNET_DPDK_PMD_I40E:
251 dev_type =
"Intel X710/XL710 Family";
254 case VNET_DPDK_PMD_I40EVF:
255 dev_type =
"Intel X710/XL710 Family VF";
258 case VNET_DPDK_PMD_ICE:
259 dev_type =
"Intel E810 Family";
262 case VNET_DPDK_PMD_IAVF:
263 dev_type =
"Intel iAVF";
266 case VNET_DPDK_PMD_FM10K:
267 dev_type =
"Intel FM10000 Family Ethernet Switch";
270 case VNET_DPDK_PMD_IGBVF:
271 dev_type =
"Intel e1000 VF";
274 case VNET_DPDK_PMD_VIRTIO:
275 dev_type =
"Red Hat Virtio";
278 case VNET_DPDK_PMD_IXGBEVF:
279 dev_type =
"Intel 82599 VF";
282 case VNET_DPDK_PMD_IXGBE:
283 dev_type =
"Intel 82599";
286 case VNET_DPDK_PMD_ENIC:
287 dev_type =
"Cisco VIC";
290 case VNET_DPDK_PMD_CXGBE:
291 dev_type =
"Chelsio T4/T5";
294 case VNET_DPDK_PMD_MLX4:
295 dev_type =
"Mellanox ConnectX-3 Family";
298 case VNET_DPDK_PMD_MLX5:
299 dev_type =
"Mellanox ConnectX-4 Family";
302 case VNET_DPDK_PMD_VMXNET3:
303 dev_type =
"VMware VMXNET3";
306 case VNET_DPDK_PMD_AF_PACKET:
307 dev_type =
"af_packet";
310 case VNET_DPDK_PMD_DPAA2:
311 dev_type =
"NXP DPAA2 Mac";
314 case VNET_DPDK_PMD_VIRTIO_USER:
315 dev_type =
"Virtio User";
318 case VNET_DPDK_PMD_THUNDERX:
319 dev_type =
"Cavium ThunderX";
322 case VNET_DPDK_PMD_VHOST_ETHER:
323 dev_type =
"VhostEthernet";
326 case VNET_DPDK_PMD_ENA:
327 dev_type =
"AWS ENA VF";
330 case VNET_DPDK_PMD_FAILSAFE:
331 dev_type =
"FailsafeEthernet";
334 case VNET_DPDK_PMD_LIOVF_ETHER:
335 dev_type =
"Cavium Lio VF";
338 case VNET_DPDK_PMD_QEDE:
339 dev_type =
"Cavium QLogic FastLinQ QL4xxxx";
342 case VNET_DPDK_PMD_NETVSC:
343 dev_type =
"Microsoft Hyper-V Netvsc";
346 case VNET_DPDK_PMD_BNXT:
347 dev_type =
"Broadcom NetXtreme E/S-Series";
352 dev_type =
"### UNKNOWN ###";
356 return format (s, dev_type);
363 struct rte_eth_link *l = &xd->
link;
367 s =
format (s,
"%s ", l->link_status ?
"up" :
"down");
370 u32 promisc = rte_eth_promiscuous_get (xd->
port_id);
372 s =
format (s,
"%s duplex ", (l->link_duplex == ETH_LINK_FULL_DUPLEX) ?
383 #define _(n, v, str) \ 385 if (format_get_indent (s) > 72) \ 386 s = format(s,"\n%U", format_white_space, indent); \ 387 s = format(s, "%s ", str); \ 393 u64 bitmap = va_arg (*args,
u64);
397 return format (s,
"none");
409 u8 *
id = va_arg (*va,
u8 *);
417 for (i = 0;
id[
i] != 0 && i < l; i++)
433 if (format_get_indent (s) > 72) \ 434 s = format(s,"\n%U", format_white_space, indent); \ 435 s = format(s, "%U ", format_offload, func (v)); \ 441 u64 bitmap = va_arg (*args,
u32);
446 return format (s,
"none");
448 for (i = 0; i < 64; i++)
452 _(mask, rte_eth_dev_rx_offload_name);
460 u64 bitmap = va_arg (*args,
u32);
465 return format (s,
"none");
467 for (i = 0; i < 64; i++)
471 _(mask, rte_eth_dev_tx_offload_name);
496 struct rte_eth_dev_module_info mi = { 0 };
497 struct rte_dev_eeprom_info ei = { 0 };
499 if (rte_eth_dev_get_module_info (xd->
port_id, &mi) != 0)
500 return format (s,
"unknown");
502 ei.length = mi.eeprom_len;
505 if (rte_eth_dev_get_module_eeprom (xd->
port_id, &ei) == 0)
508 (mi.type == RTE_ETH_MODULE_SFF_8436 ? 0x80 : 0));
511 s =
format (s,
"eeprom read error");
520 Dl_info info = { 0 };
522 if (dladdr (p, &info) == 0)
525 return info.dli_sname;
531 struct rte_eth_switch_info *
si =
532 va_arg (*args,
struct rte_eth_switch_info *);
535 s =
format (s,
"name %s ", si->name);
537 s =
format (s,
"domain id %d port id %d", si->domain_id, si->port_id);
545 u32 dev_instance = va_arg (*args,
u32);
546 int verbose = va_arg (*args,
int);
551 struct rte_eth_dev_info di;
552 struct rte_eth_burst_mode mode;
556 rte_eth_dev_info_get (xd->
port_id, &di);
558 s =
format (s,
"%U\n%Ucarrier %U",
561 s =
format (s,
"%Uflags: %U\n",
563 if (di.device->devargs && di.device->devargs->args)
564 s =
format (s,
"%UDevargs: %s\n",
566 s =
format (s,
"%Urx: queues %d (max %d), desc %d " 567 "(min %d max %d align %d)\n",
569 xd->
nb_rx_desc, di.rx_desc_lim.nb_min, di.rx_desc_lim.nb_max,
570 di.rx_desc_lim.nb_align);
571 s =
format (s,
"%Utx: queues %d (max %d), desc %d " 572 "(min %d max %d align %d)\n",
574 xd->
nb_tx_desc, di.tx_desc_lim.nb_min, di.tx_desc_lim.nb_max,
575 di.tx_desc_lim.nb_align);
577 if (xd->
flags & DPDK_DEVICE_FLAG_PMD)
579 struct rte_pci_device *pci;
580 struct rte_eth_rss_conf rss_conf;
584 rss_conf.rss_key = 0;
586 retval = rte_eth_dev_rss_hash_conf_get (xd->
port_id, &rss_conf);
588 clib_warning (
"rte_eth_dev_rss_hash_conf_get returned %d", retval);
598 s2 =
format (0,
"unknown");
599 s =
format (s,
"%Upci: device %04x:%04x subsystem %04x:%04x " 600 "address %04x:%02x:%02x.%02x numa %v\n",
602 pci->id.device_id, pci->id.subsystem_vendor_id,
603 pci->id.subsystem_device_id, pci->addr.domain,
604 pci->addr.bus, pci->addr.devid, pci->addr.function, s2);
608 if (di.switch_info.domain_id != RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID)
622 indent + 2, di.max_rx_pktlen);
623 s =
format (s,
"%Upromiscuous: unicast %s all-multicast %s\n",
625 rte_eth_promiscuous_get (xd->
port_id) ?
"on" :
"off",
626 rte_eth_allmulticast_get (xd->
port_id) ?
"on" :
"off");
627 vlan_off = rte_eth_dev_get_vlan_offload (xd->
port_id);
628 s =
format (s,
"%Uvlan offload: strip %s filter %s qinq %s\n",
630 vlan_off & ETH_VLAN_STRIP_OFFLOAD ?
"on" :
"off",
631 vlan_off & ETH_VLAN_FILTER_OFFLOAD ?
"on" :
"off",
632 vlan_off & ETH_VLAN_EXTEND_OFFLOAD ?
"on" :
"off");
633 s =
format (s,
"%Urx offload avail: %U\n",
636 s =
format (s,
"%Urx offload active: %U\n",
639 s =
format (s,
"%Utx offload avail: %U\n",
642 s =
format (s,
"%Utx offload active: %U\n",
645 s =
format (s,
"%Urss avail: %U\n" 646 "%Urss active: %U\n",
652 if (rte_eth_tx_burst_mode_get (xd->
port_id, 0, &mode) == 0)
654 s =
format (s,
"%Utx burst mode: %s%s\n",
657 mode.flags & RTE_ETH_BURST_FLAG_PER_QUEUE ?
658 " (per queue)" :
"");
662 s =
format (s,
"%Utx burst function: %s\n",
667 if (rte_eth_rx_burst_mode_get (xd->
port_id, 0, &mode) == 0)
669 s =
format (s,
"%Urx burst mode: %s%s\n",
672 mode.flags & RTE_ETH_BURST_FLAG_PER_QUEUE ?
673 " (per queue)" :
"");
677 s =
format (s,
"%Urx burst function: %s\n",
686 if (xd->stats.V != 0) { \ 687 s = format (s, "\n%U%-40U%16Lu", \ 688 format_white_space, indent + 2, \ 689 format_c_identifier, #N, \ 699 struct rte_eth_xstat *xstat;
700 struct rte_eth_xstat_name *xstat_names = 0;
703 int ret = rte_eth_xstats_get_names (xd->
port_id, xstat_names, len);
705 if (ret >= 0 && ret <= len)
711 if (verbose == 2 || (verbose && xstat->value))
713 xs =
format(xs,
"\n%U%-38s%16Lu",
726 s =
format (s,
"\n%Uextended stats:%v",
752 s =
format (s,
"%U tx queue %d",
755 s =
format (s,
"\n%Ubuffer 0x%x: %U",
783 s =
format (s,
"%U rx queue %d",
786 s =
format (s,
"\n%Ubuffer 0x%x: %U",
797 t->
mb.data_len > sizeof (t->
data) ?
" (truncated)" :
"");
801 sizeof (t->
data) ? sizeof (t->
data) : t->
mb.data_len);
816 u32 *pkt_types = va_arg (*va,
u32 *);
822 s =
format (s,
"Packet Types");
825 if ((*pkt_types & RTE_PTYPE_##L##_MASK) == RTE_PTYPE_##L##_##F) \ 827 s = format (s, "\n%U%s (0x%04x) %s", format_white_space, indent, \ 828 "RTE_PTYPE_" #L "_" #F, RTE_PTYPE_##L##_##F, S); \ 839 u64 *ol_flags = va_arg (*va,
u64 *);
845 s =
format (s,
"Packet Offload Flags");
850 s = format (s, "\n%U%s (0x%04x) %s", \ 851 format_white_space, indent, #F, F, S); \ 865 if (clib_net_to_host_u16 (vlan_hdr->
type) == ETHERNET_TYPE_DOT1AD)
867 s =
format (s,
"%U 802.1q vlan ",
883 struct rte_mbuf *mb = va_arg (*va,
struct rte_mbuf *);
887 s =
format (s,
"PKT MBUF: port %d, nb_segs %d, pkt_len %d" 888 "\n%Ubuf_len %d, data_len %d, ol_flags 0x%lx, data_off %d, phys_addr 0x%x" 889 "\n%Upacket_type 0x%x l2_len %u l3_len %u outer_l2_len %u outer_l3_len %u" 890 "\n%Urss 0x%x fdir.hi 0x%x fdir.lo 0x%x",
891 mb->port, mb->nb_segs, mb->pkt_len,
893 mb->buf_len, mb->data_len, mb->ol_flags, mb->data_off,
895 mb->l2_len, mb->l3_len, mb->outer_l2_len, mb->outer_l3_len,
903 if ((mb->ol_flags & PKT_RX_VLAN) &&
904 ((mb->ol_flags & (PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ_STRIPPED)) == 0))
927 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)
sll srl srl sll sra u16x4 i
#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 foreach_dpdk_rss_hf
#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