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