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