FD.io VPP  v18.01-8-g0eacf49
Vector Packet Processing
format.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include <vnet/vnet.h>
16 #include <vppinfra/vec.h>
17 #include <vppinfra/format.h>
18 #include <vlib/unix/cj.h>
19 #include <assert.h>
20 
21 #include <vnet/ethernet/ethernet.h>
22 #include <dpdk/device/dpdk.h>
23 
24 #include <dpdk/device/dpdk_priv.h>
25 #include <vppinfra/error.h>
26 
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)
36 
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)
43 
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")
61 
62 
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")
70 
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")
81 
82 #if RTE_VERSION < RTE_VERSION_NUM(17, 11, 0, 0)
83 #define PKT_RX_VLAN PKT_RX_VLAN_PKT
84 #endif
85 
86 #define foreach_dpdk_pkt_rx_offload_flag \
87  _ (PKT_RX_VLAN, "RX packet is a 802.1q VLAN packet") \
88  _ (PKT_RX_RSS_HASH, "RX packet with RSS hash result") \
89  _ (PKT_RX_FDIR, "RX packet with FDIR infos") \
90  _ (PKT_RX_L4_CKSUM_BAD, "L4 cksum of RX pkt. is not OK") \
91  _ (PKT_RX_IP_CKSUM_BAD, "IP cksum of RX pkt. is not OK") \
92  _ (PKT_RX_EIP_CKSUM_BAD, "External IP header checksum error") \
93  _ (PKT_RX_VLAN_STRIPPED, "RX packet VLAN tag stripped") \
94  _ (PKT_RX_IP_CKSUM_GOOD, "IP cksum of RX pkt. is valid") \
95  _ (PKT_RX_L4_CKSUM_GOOD, "L4 cksum of RX pkt. is valid") \
96  _ (PKT_RX_IEEE1588_PTP, "RX IEEE1588 L2 Ethernet PT Packet") \
97  _ (PKT_RX_IEEE1588_TMST, "RX IEEE1588 L2/L4 timestamped packet") \
98  _ (PKT_RX_QINQ_STRIPPED, "RX packet QinQ tags stripped") \
99  _ (PKT_RX_TIMESTAMP, "Timestamp field is valid")
100 
101 #define foreach_dpdk_pkt_type \
102  _ (L2, ETHER, "Ethernet packet") \
103  _ (L2, ETHER_TIMESYNC, "Ethernet packet for time sync") \
104  _ (L2, ETHER_ARP, "ARP packet") \
105  _ (L2, ETHER_LLDP, "LLDP (Link Layer Discovery Protocol) packet") \
106  _ (L2, ETHER_NSH, "NSH (Network Service Header) packet") \
107  _ (L2, ETHER_VLAN, "VLAN packet") \
108  _ (L2, ETHER_QINQ, "QinQ packet") \
109  _ (L3, IPV4, "IPv4 packet without extension headers") \
110  _ (L3, IPV4_EXT, "IPv4 packet with extension headers") \
111  _ (L3, IPV4_EXT_UNKNOWN, "IPv4 packet with or without extension headers") \
112  _ (L3, IPV6, "IPv6 packet without extension headers") \
113  _ (L3, IPV6_EXT, "IPv6 packet with extension headers") \
114  _ (L3, IPV6_EXT_UNKNOWN, "IPv6 packet with or without extension headers") \
115  _ (L4, TCP, "TCP packet") \
116  _ (L4, UDP, "UDP packet") \
117  _ (L4, FRAG, "Fragmented IP packet") \
118  _ (L4, SCTP, "SCTP (Stream Control Transmission Protocol) packet") \
119  _ (L4, ICMP, "ICMP packet") \
120  _ (L4, NONFRAG, "Non-fragmented IP packet") \
121  _ (TUNNEL, GRE, "GRE tunneling packet") \
122  _ (TUNNEL, VXLAN, "VXLAN tunneling packet") \
123  _ (TUNNEL, NVGRE, "NVGRE Tunneling packet") \
124  _ (TUNNEL, GENEVE, "GENEVE Tunneling packet") \
125  _ (TUNNEL, GRENAT, "Teredo, VXLAN or GRE Tunneling packet") \
126  _ (INNER_L2, ETHER, "Inner Ethernet packet") \
127  _ (INNER_L2, ETHER_VLAN, "Inner Ethernet packet with VLAN") \
128  _ (INNER_L3, IPV4, "Inner IPv4 packet without extension headers") \
129  _ (INNER_L3, IPV4_EXT, "Inner IPv4 packet with extension headers") \
130  _ (INNER_L3, IPV4_EXT_UNKNOWN, "Inner IPv4 packet with or without extension headers") \
131  _ (INNER_L3, IPV6, "Inner IPv6 packet without extension headers") \
132  _ (INNER_L3, IPV6_EXT, "Inner IPv6 packet with extension headers") \
133  _ (INNER_L3, IPV6_EXT_UNKNOWN, "Inner IPv6 packet with or without extension headers") \
134  _ (INNER_L4, TCP, "Inner TCP packet") \
135  _ (INNER_L4, UDP, "Inner UDP packet") \
136  _ (INNER_L4, FRAG, "Inner fagmented IP packet") \
137  _ (INNER_L4, SCTP, "Inner SCTP (Stream Control Transmission Protocol) packet") \
138  _ (INNER_L4, ICMP, "Inner ICMP packet") \
139  _ (INNER_L4, NONFRAG, "Inner non-fragmented IP packet")
140 
141 #define foreach_dpdk_pkt_tx_offload_flag \
142  _ (PKT_TX_VLAN_PKT, "TX packet is a 802.1q VLAN packet") \
143  _ (PKT_TX_IP_CKSUM, "IP cksum of TX pkt. computed by NIC") \
144  _ (PKT_TX_TCP_CKSUM, "TCP cksum of TX pkt. computed by NIC") \
145  _ (PKT_TX_SCTP_CKSUM, "SCTP cksum of TX pkt. computed by NIC") \
146  _ (PKT_TX_IEEE1588_TMST, "TX IEEE1588 packet to timestamp")
147 
148 #define foreach_dpdk_pkt_offload_flag \
149  foreach_dpdk_pkt_rx_offload_flag \
150  foreach_dpdk_pkt_tx_offload_flag
151 
152 #define foreach_dpdk_log_level \
153  _ (EMERG, "emergency") \
154  _ (ALERT, "alert") \
155  _ (CRIT, "critical") \
156  _ (ERR, "error") \
157  _ (WARNING, "warning") \
158  _ (NOTICE, "notice") \
159  _ (INFO, "info") \
160  _ (DEBUG, "debug")
161 
162 u8 *
163 format_dpdk_device_name (u8 * s, va_list * args)
164 {
165  dpdk_main_t *dm = &dpdk_main;
166  char *devname_format;
167  char *device_name;
168  u32 i = va_arg (*args, u32);
169  struct rte_eth_dev_info dev_info;
170  u8 *ret;
171 
173  devname_format = "%s%d/%d/%d";
174  else
175  devname_format = "%s%x/%x/%x";
176 
177  switch (dm->devices[i].port_type)
178  {
180  device_name = "GigabitEthernet";
181  break;
182 
184  device_name = "TenGigabitEthernet";
185  break;
186 
188  device_name = "TwentyFiveGigabitEthernet";
189  break;
190 
192  device_name = "FortyGigabitEthernet";
193  break;
194 
196  device_name = "FiftyGigabitEthernet";
197  break;
198 
200  device_name = "HundredGigabitEthernet";
201  break;
202 
204  return format (s, "BondEthernet%d", dm->devices[i].port_id);
205 
207  device_name = "EthernetSwitch";
208  break;
209 
211  device_name = "VirtualFunctionEthernet";
212  break;
213 
215  rte_eth_dev_info_get (i, &dev_info);
216  return format (s, "af_packet%d", dm->devices[i].port_id);
217 
219  device_name = "VirtioUser";
220  break;
221 
223  device_name = "VhostEthernet";
224  break;
225 
226  default:
228  device_name = "UnknownEthernet";
229  break;
230  }
231 
232  rte_eth_dev_info_get (i, &dev_info);
233 
234  if (dev_info.pci_dev)
235  ret = format (s, devname_format, device_name, dev_info.pci_dev->addr.bus,
236  dev_info.pci_dev->addr.devid,
237  dev_info.pci_dev->addr.function);
238  else
239  ret = format (s, "%s%d", device_name, dm->devices[i].device_index);
240 
241  if (dm->devices[i].interface_name_suffix)
242  return format (ret, "/%s", dm->devices[i].interface_name_suffix);
243  return ret;
244 }
245 
246 static u8 *
247 format_dpdk_device_type (u8 * s, va_list * args)
248 {
249  dpdk_main_t *dm = &dpdk_main;
250  char *dev_type;
251  u32 i = va_arg (*args, u32);
252 
253  switch (dm->devices[i].pmd)
254  {
255  case VNET_DPDK_PMD_E1000EM:
256  dev_type = "Intel 82540EM (e1000)";
257  break;
258 
259  case VNET_DPDK_PMD_IGB:
260  dev_type = "Intel e1000";
261  break;
262 
263  case VNET_DPDK_PMD_I40E:
264  dev_type = "Intel X710/XL710 Family";
265  break;
266 
267  case VNET_DPDK_PMD_I40EVF:
268  dev_type = "Intel X710/XL710 Family VF";
269  break;
270 
271  case VNET_DPDK_PMD_FM10K:
272  dev_type = "Intel FM10000 Family Ethernet Switch";
273  break;
274 
275  case VNET_DPDK_PMD_IGBVF:
276  dev_type = "Intel e1000 VF";
277  break;
278 
279  case VNET_DPDK_PMD_VIRTIO:
280  dev_type = "Red Hat Virtio";
281  break;
282 
283  case VNET_DPDK_PMD_IXGBEVF:
284  dev_type = "Intel 82599 VF";
285  break;
286 
287  case VNET_DPDK_PMD_IXGBE:
288  dev_type = "Intel 82599";
289  break;
290 
291  case VNET_DPDK_PMD_ENIC:
292  dev_type = "Cisco VIC";
293  break;
294 
295  case VNET_DPDK_PMD_CXGBE:
296  dev_type = "Chelsio T4/T5";
297  break;
298 
299  case VNET_DPDK_PMD_MLX4:
300  dev_type = "Mellanox ConnectX-3 Family";
301  break;
302 
303  case VNET_DPDK_PMD_MLX5:
304  dev_type = "Mellanox ConnectX-4 Family";
305  break;
306 
307  case VNET_DPDK_PMD_VMXNET3:
308  dev_type = "VMware VMXNET3";
309  break;
310 
311  case VNET_DPDK_PMD_AF_PACKET:
312  dev_type = "af_packet";
313  break;
314 
315  case VNET_DPDK_PMD_BOND:
316  dev_type = "Ethernet Bonding";
317  break;
318 
319  case VNET_DPDK_PMD_DPAA2:
320  dev_type = "NXP DPAA2 Mac";
321  break;
322 
323  case VNET_DPDK_PMD_VIRTIO_USER:
324  dev_type = "Virtio User";
325  break;
326 
327  case VNET_DPDK_PMD_THUNDERX:
328  dev_type = "Cavium ThunderX";
329  break;
330 
331  case VNET_DPDK_PMD_VHOST_ETHER:
332  dev_type = "VhostEthernet";
333  break;
334 
335  case VNET_DPDK_PMD_ENA:
336  dev_type = "AWS ENA VF";
337  break;
338 
339  default:
341  dev_type = "### UNKNOWN ###";
342  break;
343  }
344 
345  return format (s, dev_type);
346 }
347 
348 static u8 *
349 format_dpdk_link_status (u8 * s, va_list * args)
350 {
351  dpdk_device_t *xd = va_arg (*args, dpdk_device_t *);
352  struct rte_eth_link *l = &xd->link;
353  vnet_main_t *vnm = vnet_get_main ();
355 
356  s = format (s, "%s ", l->link_status ? "up" : "down");
357  if (l->link_status)
358  {
359  u32 promisc = rte_eth_promiscuous_get (xd->device_index);
360 
361  s = format (s, "%s duplex ", (l->link_duplex == ETH_LINK_FULL_DUPLEX) ?
362  "full" : "half");
363  s = format (s, "speed %u mtu %d %s\n", l->link_speed,
364  hi->max_packet_bytes, promisc ? " promisc" : "");
365  }
366  else
367  s = format (s, "\n");
368 
369  return s;
370 }
371 
372 #define _line_len 72
373 #define _(v, str) \
374 if (bitmap & v) { \
375  if (format_get_indent (s) > next_split ) { \
376  next_split += _line_len; \
377  s = format(s,"\n%U", format_white_space, indent); \
378  } \
379  s = format(s, "%s ", str); \
380 }
381 
382 static u8 *
383 format_dpdk_rss_hf_name (u8 * s, va_list * args)
384 {
385  u64 bitmap = va_arg (*args, u64);
386  int next_split = _line_len;
387  u32 indent = format_get_indent (s);
388 
389  if (!bitmap)
390  return format (s, "none");
391 
392  foreach_dpdk_rss_hf return s;
393 }
394 
395 static u8 *
396 format_dpdk_rx_offload_caps (u8 * s, va_list * args)
397 {
398  u32 bitmap = va_arg (*args, u32);
399  int next_split = _line_len;
400  u32 indent = format_get_indent (s);
401 
402  if (!bitmap)
403  return format (s, "none");
404 
406 }
407 
408 static u8 *
409 format_dpdk_tx_offload_caps (u8 * s, va_list * args)
410 {
411  u32 bitmap = va_arg (*args, u32);
412  int next_split = _line_len;
413  u32 indent = format_get_indent (s);
414  if (!bitmap)
415  return format (s, "none");
416 
418 }
419 
420 #undef _line_len
421 #undef _
422 
423 u8 *
424 format_dpdk_device_errors (u8 * s, va_list * args)
425 {
426  dpdk_device_t *xd = va_arg (*args, dpdk_device_t *);
427  clib_error_t *e;
428  u32 indent = format_get_indent (s);
429 
430  vec_foreach (e, xd->errors)
431  {
432  s = format (s, "%U%v\n", format_white_space, indent, e->what);
433  }
434  return s;
435 }
436 
437 u8 *
438 format_dpdk_device (u8 * s, va_list * args)
439 {
440  u32 dev_instance = va_arg (*args, u32);
441  int verbose = va_arg (*args, int);
442  dpdk_main_t *dm = &dpdk_main;
443  dpdk_device_t *xd = vec_elt_at_index (dm->devices, dev_instance);
444  u32 indent = format_get_indent (s);
445  f64 now = vlib_time_now (dm->vlib_main);
446  struct rte_eth_dev_info di;
447 
448  dpdk_update_counters (xd, now);
449  dpdk_update_link_state (xd, now);
450 
451  s = format (s, "%U\n%Ucarrier %U",
454 
455  rte_eth_dev_info_get (xd->device_index, &di);
456 
457  if (verbose > 1 && xd->flags & DPDK_DEVICE_FLAG_PMD)
458  {
459  struct rte_pci_device *pci;
460  struct rte_eth_rss_conf rss_conf;
461  int vlan_off;
462  int retval;
463 
464  rss_conf.rss_key = 0;
465  retval = rte_eth_dev_rss_hash_conf_get (xd->device_index, &rss_conf);
466  if (retval < 0)
467  clib_warning ("rte_eth_dev_rss_hash_conf_get returned %d", retval);
468  pci = di.pci_dev;
469 
470  if (pci)
471  s =
472  format (s,
473  "%Upci id: device %04x:%04x subsystem %04x:%04x\n"
474  "%Upci address: %04x:%02x:%02x.%02x\n",
475  format_white_space, indent + 2, pci->id.vendor_id,
476  pci->id.device_id, pci->id.subsystem_vendor_id,
477  pci->id.subsystem_device_id, format_white_space, indent + 2,
478  pci->addr.domain, pci->addr.bus, pci->addr.devid,
479  pci->addr.function);
480  s =
481  format (s, "%Umax rx packet len: %d\n", format_white_space,
482  indent + 2, di.max_rx_pktlen);
483  s =
484  format (s, "%Umax num of queues: rx %d tx %d\n", format_white_space,
485  indent + 2, di.max_rx_queues, di.max_tx_queues);
486  s =
487  format (s, "%Upromiscuous: unicast %s all-multicast %s\n",
488  format_white_space, indent + 2,
489  rte_eth_promiscuous_get (xd->device_index) ? "on" : "off",
490  rte_eth_allmulticast_get (xd->device_index) ? "on" : "off");
491  vlan_off = rte_eth_dev_get_vlan_offload (xd->device_index);
492  s = format (s, "%Uvlan offload: strip %s filter %s qinq %s\n",
493  format_white_space, indent + 2,
494  vlan_off & ETH_VLAN_STRIP_OFFLOAD ? "on" : "off",
495  vlan_off & ETH_VLAN_FILTER_OFFLOAD ? "on" : "off",
496  vlan_off & ETH_VLAN_EXTEND_OFFLOAD ? "on" : "off");
497  s = format (s, "%Urx offload caps: %U\n",
498  format_white_space, indent + 2,
499  format_dpdk_rx_offload_caps, di.rx_offload_capa);
500  s = format (s, "%Utx offload caps: %U\n",
501  format_white_space, indent + 2,
502  format_dpdk_tx_offload_caps, di.tx_offload_capa);
503  s = format (s, "%Urss active: %U\n"
504  "%Urss supported: %U\n",
505  format_white_space, indent + 2,
506  format_dpdk_rss_hf_name, rss_conf.rss_hf,
507  format_white_space, indent + 2,
508  format_dpdk_rss_hf_name, di.flow_type_rss_offloads);
509  }
510 
511  s = format (s, "%Urx queues %d, rx desc %d, tx queues %d, tx desc %d\n",
512  format_white_space, indent + 2,
513  xd->rx_q_used, xd->nb_rx_desc, xd->tx_q_used, xd->nb_tx_desc);
514 
515  if (xd->cpu_socket > -1)
516  s = format (s, "%Ucpu socket %d\n",
517  format_white_space, indent + 2, xd->cpu_socket);
518 
519  /* $$$ MIB counters */
520  {
521 #define _(N, V) \
522  if ((xd->stats.V - xd->last_cleared_stats.V) != 0) { \
523  s = format (s, "\n%U%-40U%16Ld", \
524  format_white_space, indent + 2, \
525  format_c_identifier, #N, \
526  xd->stats.V - xd->last_cleared_stats.V); \
527  } \
528 
530 #undef _
531  }
532 
533  u8 *xs = 0;
534  u32 i = 0;
535  struct rte_eth_xstat *xstat, *last_xstat;
536  struct rte_eth_xstat_name *xstat_names = 0;
537  int len = rte_eth_xstats_get_names (xd->device_index, NULL, 0);
538  vec_validate (xstat_names, len - 1);
539  rte_eth_xstats_get_names (xd->device_index, xstat_names, len);
540 
542 
543  /* *INDENT-OFF* */
544  vec_foreach_index(i, xd->xstats)
545  {
546  u64 delta = 0;
547  xstat = vec_elt_at_index(xd->xstats, i);
548  last_xstat = vec_elt_at_index(xd->last_cleared_xstats, i);
549 
550  delta = xstat->value - last_xstat->value;
551  if (verbose == 2 || (verbose && delta))
552  {
553  /* format_c_identifier doesn't like c strings inside vector */
554  u8 * name = format(0,"%s", xstat_names[i].name);
555  xs = format(xs, "\n%U%-38U%16Ld",
556  format_white_space, indent + 4,
557  format_c_identifier, name, delta);
558  vec_free(name);
559  }
560  }
561  /* *INDENT-ON* */
562 
563  vec_free (xstat_names);
564 
565  if (xs)
566  {
567  s = format (s, "\n%Uextended stats:%v",
568  format_white_space, indent + 2, xs);
569  vec_free (xs);
570  }
571 
572  if (vec_len (xd->errors))
573  {
574  s = format (s, "%UErrors:\n %U", format_white_space, indent,
576  }
577 
578  return s;
579 }
580 
581 u8 *
582 format_dpdk_tx_dma_trace (u8 * s, va_list * va)
583 {
584  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
585  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
587  dpdk_tx_dma_trace_t *t = va_arg (*va, dpdk_tx_dma_trace_t *);
588  dpdk_main_t *dm = &dpdk_main;
590  u32 indent = format_get_indent (s);
592 
593  s = format (s, "%U tx queue %d",
595 
596  s = format (s, "\n%Ubuffer 0x%x: %U",
597  format_white_space, indent,
599 
600  s = format (s, "\n%U%U",
601  format_white_space, indent,
602  format_dpdk_rte_mbuf, &t->mb, &t->data);
603 
604  s = format (s, "\n%U%U", format_white_space, indent,
606  sizeof (t->buffer.pre_data));
607 
608  return s;
609 }
610 
611 u8 *
612 format_dpdk_rx_dma_trace (u8 * s, va_list * va)
613 {
614  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
615  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
617  dpdk_rx_dma_trace_t *t = va_arg (*va, dpdk_rx_dma_trace_t *);
618  dpdk_main_t *dm = &dpdk_main;
621  u32 indent = format_get_indent (s);
623 
624  s = format (s, "%U rx queue %d",
626 
627  s = format (s, "\n%Ubuffer 0x%x: %U",
628  format_white_space, indent,
630 
631  s = format (s, "\n%U%U",
632  format_white_space, indent,
633  format_dpdk_rte_mbuf, &t->mb, &t->data);
634 
635  if (vm->trace_main.verbose)
636  {
637  s = format (s, "\n%UPacket Dump%s", format_white_space, indent + 2,
638  t->mb.data_len > sizeof (t->data) ? " (truncated)" : "");
639  s = format (s, "\n%U%U", format_white_space, indent + 4,
640  format_hexdump, &t->data,
641  t->mb.data_len >
642  sizeof (t->data) ? sizeof (t->data) : t->mb.data_len);
643  }
644  f = node->format_buffer;
645  if (!f)
646  f = format_hex_bytes;
647  s = format (s, "\n%U%U", format_white_space, indent,
648  f, t->buffer.pre_data, sizeof (t->buffer.pre_data));
649 
650  return s;
651 }
652 
653 
654 static inline u8 *
655 format_dpdk_pkt_types (u8 * s, va_list * va)
656 {
657  u32 *pkt_types = va_arg (*va, u32 *);
658  u32 indent __attribute__ ((unused)) = format_get_indent (s) + 2;
659 
660  if (!*pkt_types)
661  return s;
662 
663  s = format (s, "Packet Types");
664 
665 #define _(L, F, S) \
666  if ((*pkt_types & RTE_PTYPE_##L##_MASK) == RTE_PTYPE_##L##_##F) \
667  { \
668  s = format (s, "\n%U%s (0x%04x) %s", format_white_space, indent, \
669  "RTE_PTYPE_" #L "_" #F, RTE_PTYPE_##L##_##F, S); \
670  }
671 
673 #undef _
674  return s;
675 }
676 
677 static inline u8 *
679 {
680  u64 *ol_flags = va_arg (*va, u64 *);
681  u32 indent = format_get_indent (s) + 2;
682 
683  if (!*ol_flags)
684  return s;
685 
686  s = format (s, "Packet Offload Flags");
687 
688 #define _(F, S) \
689  if (*ol_flags & F) \
690  { \
691  s = format (s, "\n%U%s (0x%04x) %s", \
692  format_white_space, indent, #F, F, S); \
693  }
694 
696 #undef _
697  return s;
698 }
699 
700 u8 *
701 format_dpdk_rte_mbuf_vlan (u8 * s, va_list * va)
702 {
703  ethernet_vlan_header_tv_t *vlan_hdr =
704  va_arg (*va, ethernet_vlan_header_tv_t *);
705 
706  if (clib_net_to_host_u16 (vlan_hdr->type) == ETHERNET_TYPE_DOT1AD)
707  {
708  s = format (s, "%U 802.1q vlan ",
710  clib_net_to_host_u16 (vlan_hdr->priority_cfi_and_id));
711  vlan_hdr++;
712  }
713 
714  s = format (s, "%U",
716  clib_net_to_host_u16 (vlan_hdr->priority_cfi_and_id));
717 
718  return s;
719 }
720 
721 u8 *
722 format_dpdk_rte_mbuf (u8 * s, va_list * va)
723 {
724  struct rte_mbuf *mb = va_arg (*va, struct rte_mbuf *);
725  ethernet_header_t *eth_hdr = va_arg (*va, ethernet_header_t *);
726  u32 indent = format_get_indent (s) + 2;
727 
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 l2_len %u l3_len %u outer_l2_len %u outer_l3_len %u",
731  mb->port, mb->nb_segs, mb->pkt_len,
732  format_white_space, indent,
733  mb->buf_len, mb->data_len, mb->ol_flags, mb->data_off,
734  mb->buf_physaddr, format_white_space, indent, mb->packet_type,
735  mb->l2_len, mb->l3_len, mb->outer_l2_len, mb->outer_l3_len);
736 
737  if (mb->ol_flags)
738  s = format (s, "\n%U%U", format_white_space, indent,
739  format_dpdk_pkt_offload_flags, &mb->ol_flags);
740 
741  if ((mb->ol_flags & PKT_RX_VLAN) &&
742  ((mb->ol_flags & (PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ_STRIPPED)) == 0))
743  {
744  ethernet_vlan_header_tv_t *vlan_hdr =
745  ((ethernet_vlan_header_tv_t *) & (eth_hdr->type));
746  s = format (s, " %U", format_dpdk_rte_mbuf_vlan, vlan_hdr);
747  }
748 
749  if (mb->packet_type)
750  s = format (s, "\n%U%U", format_white_space, indent,
751  format_dpdk_pkt_types, &mb->packet_type);
752 
753  return s;
754 }
755 
756 clib_error_t *
758 {
760  {
761  if (0)
762  ;
763 #undef _
764 #define _(f, s) \
765  else if (unformat (input, s)) \
766  *rss_fn |= f;
767 
769 #undef _
770  else
771  {
772  return clib_error_return (0, "unknown input `%U'",
773  format_unformat_error, input);
774  }
775  }
776  return 0;
777 }
778 
779 uword
780 unformat_dpdk_log_level (unformat_input_t * input, va_list * args)
781 {
782  u32 *r = va_arg (*args, u32 *);
783 
784  if (0);
785 #define _(v,s) else if (unformat (input, s)) *r = RTE_LOG_##v;
787 #undef _
788  else
789  return 0;
790  return 1;
791 }
792 
793 clib_error_t *
795 {
796  clib_error_t *error = 0;
797 
799  {
800  if (unformat (input, "hqos-thread %u", &hqos->hqos_thread))
801  hqos->hqos_thread_valid = 1;
802  else
803  {
804  error = clib_error_return (0, "unknown input `%U'",
805  format_unformat_error, input);
806  break;
807  }
808  }
809 
810  return error;
811 }
812 
813 /*
814  * fd.io coding-style-patch-verification: ON
815  *
816  * Local Variables:
817  * eval: (c-set-style "gnu")
818  * End:
819  */
static u8 * format_dpdk_tx_offload_caps(u8 *s, va_list *args)
Definition: format.c:409
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:432
u8 * format_dpdk_device(u8 *s, va_list *args)
Definition: format.c:438
vmrglw vmrglh hi
#define vec_foreach_index(var, v)
Iterate over vector indices.
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
#define CLIB_UNUSED(x)
Definition: clib.h:79
u8 * format_dpdk_rte_mbuf_vlan(u8 *s, va_list *va)
Definition: format.c:701
vlib_buffer_t buffer
Definition: dpdk.h:413
u8 interface_name_format_decimal
Definition: dpdk.h:338
dpdk_main_t dpdk_main
Definition: init.c:39
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
static u8 * format_dpdk_rss_hf_name(u8 *s, va_list *args)
Definition: format.c:383
#define NULL
Definition: clib.h:55
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:224
clib_error_t * unformat_hqos(unformat_input_t *input, dpdk_device_config_hqos_t *hqos)
Definition: format.c:794
u16 flags
Definition: dpdk.h:181
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
clib_error_t * errors
Definition: dpdk.h:237
static u8 * format_dpdk_pkt_offload_flags(u8 *s, va_list *va)
Definition: format.c:678
static u32 format_get_indent(u8 *s)
Definition: format.h:72
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
u8 * format_dpdk_rte_mbuf(u8 *s, va_list *va)
Definition: format.c:722
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
struct rte_eth_xstat * last_cleared_xstats
Definition: dpdk.h:229
#define DPDK_DEVICE_FLAG_PMD
Definition: dpdk.h:184
static u8 * format_dpdk_rx_offload_caps(u8 *s, va_list *args)
Definition: format.c:396
u8 * format_dpdk_device_name(u8 *s, va_list *args)
Definition: format.c:163
#define foreach_dpdk_rss_hf
Definition: format.c:44
u8 data[256]
Definition: dpdk.h:424
dpdk_portid_t port_id
Definition: dpdk.h:216
uword unformat_dpdk_log_level(unformat_input_t *input, va_list *args)
Definition: format.c:780
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
#define foreach_dpdk_pkt_type
Definition: format.c:101
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define foreach_dpdk_rx_offload_caps
Definition: format.c:63
u8 * format_hex_bytes(u8 *s, va_list *va)
Definition: std-formats.c:84
#define clib_error_return(e, args...)
Definition: error.h:99
u16 rx_q_used
Definition: dpdk.h:204
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:91
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
Definition: buffer.h:151
unsigned long u64
Definition: types.h:89
static u8 * format_dpdk_pkt_types(u8 *s, va_list *va)
Definition: format.c:655
u8 * format_c_identifier(u8 *s, va_list *va)
Definition: std-formats.c:258
struct rte_mbuf mb
Definition: dpdk.h:422
u32 vlib_sw_if_index
Definition: dpdk.h:166
format_function_t format_vnet_sw_interface_name
format_function_t format_vnet_buffer
Definition: buffer.h:354
struct _unformat_input_t unformat_input_t
#define foreach_dpdk_counter
Definition: format.c:27
struct rte_mbuf mb
Definition: dpdk.h:411
#define foreach_dpdk_log_level
Definition: format.c:152
dpdk_port_type_t port_type
Definition: dpdk.h:231
format_function_t * format_buffer
Definition: node.h:311
u16 tx_q_used
Definition: dpdk.h:203
u16 nb_rx_desc
Definition: dpdk.h:205
u32 hw_if_index
Definition: dpdk.h:165
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
dpdk_device_t * devices
Definition: dpdk.h:353
vlib_main_t * vm
Definition: buffer.c:283
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:86
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
#define clib_warning(format, args...)
Definition: error.h:59
dpdk_pmd_t pmd
Definition: dpdk.h:178
u8 * format_hexdump(u8 *s, va_list *va)
Definition: std-formats.c:281
struct rte_eth_xstat * xstats
Definition: dpdk.h:228
u8 * interface_name_suffix
Definition: dpdk.h:197
#define ASSERT(truth)
u8 * format_dpdk_device_errors(u8 *s, va_list *args)
Definition: format.c:424
unsigned int u32
Definition: types.h:88
clib_error_t * unformat_rss_fn(unformat_input_t *input, uword *rss_fn)
Definition: format.c:757
#define foreach_dpdk_tx_offload_caps
Definition: format.c:71
vlib_trace_main_t trace_main
Definition: main.h:135
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
Definition: init.c:1294
dpdk_portid_t device_index
Definition: dpdk.h:163
struct rte_eth_link link
Definition: dpdk.h:222
u64 uword
Definition: types.h:112
vlib_buffer_t buffer
Definition: dpdk.h:423
static u8 * format_dpdk_device_type(u8 *s, va_list *args)
Definition: format.c:247
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
u8 data[256]
Definition: dpdk.h:414
u8 * format_dpdk_tx_dma_trace(u8 *s, va_list *va)
Definition: format.c:582
#define foreach_dpdk_pkt_offload_flag
Definition: format.c:148
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
#define vec_foreach(var, vec)
Vector iterator.
i8 cpu_socket
Definition: dpdk.h:179
static u8 * format_dpdk_link_status(u8 *s, va_list *args)
Definition: format.c:349
u16 nb_tx_desc
Definition: dpdk.h:194
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
u8 * format_ethernet_vlan_tci(u8 *s, va_list *va)
Definition: format.c:73
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
dpdk_config_main_t * conf
Definition: dpdk.h:395
u8 * format_dpdk_rx_dma_trace(u8 *s, va_list *va)
Definition: format.c:612
vlib_main_t * vlib_main
Definition: dpdk.h:393