FD.io VPP  v17.07-30-g839fa73
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 
216  default:
218  device_name = "UnknownEthernet";
219  break;
220  }
221 
222  rte_eth_dev_info_get (i, &dev_info);
223 
224  if (dev_info.pci_dev)
225  ret = format (s, devname_format, device_name, dev_info.pci_dev->addr.bus,
226  dev_info.pci_dev->addr.devid,
227  dev_info.pci_dev->addr.function);
228  else
229  ret = format (s, "%s%d", device_name, dm->devices[i].device_index);
230 
231  if (dm->devices[i].interface_name_suffix)
232  return format (ret, "/%s", dm->devices[i].interface_name_suffix);
233  return ret;
234 }
235 
236 static u8 *
237 format_dpdk_device_type (u8 * s, va_list * args)
238 {
239  dpdk_main_t *dm = &dpdk_main;
240  char *dev_type;
241  u32 i = va_arg (*args, u32);
242 
243  switch (dm->devices[i].pmd)
244  {
245  case VNET_DPDK_PMD_E1000EM:
246  dev_type = "Intel 82540EM (e1000)";
247  break;
248 
249  case VNET_DPDK_PMD_IGB:
250  dev_type = "Intel e1000";
251  break;
252 
253  case VNET_DPDK_PMD_I40E:
254  dev_type = "Intel X710/XL710 Family";
255  break;
256 
257  case VNET_DPDK_PMD_I40EVF:
258  dev_type = "Intel X710/XL710 Family VF";
259  break;
260 
261  case VNET_DPDK_PMD_FM10K:
262  dev_type = "Intel FM10000 Family Ethernet Switch";
263  break;
264 
265  case VNET_DPDK_PMD_IGBVF:
266  dev_type = "Intel e1000 VF";
267  break;
268 
269  case VNET_DPDK_PMD_VIRTIO:
270  dev_type = "Red Hat Virtio";
271  break;
272 
273  case VNET_DPDK_PMD_IXGBEVF:
274  dev_type = "Intel 82599 VF";
275  break;
276 
277  case VNET_DPDK_PMD_IXGBE:
278  dev_type = "Intel 82599";
279  break;
280 
281  case VNET_DPDK_PMD_ENIC:
282  dev_type = "Cisco VIC";
283  break;
284 
285  case VNET_DPDK_PMD_CXGBE:
286  dev_type = "Chelsio T4/T5";
287  break;
288 
289  case VNET_DPDK_PMD_MLX4:
290  dev_type = "Mellanox ConnectX-3 Family";
291  break;
292 
293  case VNET_DPDK_PMD_MLX5:
294  dev_type = "Mellanox ConnectX-4 Family";
295  break;
296 
297  case VNET_DPDK_PMD_VMXNET3:
298  dev_type = "VMware VMXNET3";
299  break;
300 
301  case VNET_DPDK_PMD_AF_PACKET:
302  dev_type = "af_packet";
303  break;
304 
305  case VNET_DPDK_PMD_BOND:
306  dev_type = "Ethernet Bonding";
307  break;
308 
309  case VNET_DPDK_PMD_DPAA2:
310  dev_type = "NXP DPAA2 Mac";
311  break;
312 
313  case VNET_DPDK_PMD_VIRTIO_USER:
314  dev_type = "Virtio User";
315  break;
316 
317  default:
319  dev_type = "### UNKNOWN ###";
320  break;
321  }
322 
323  return format (s, dev_type);
324 }
325 
326 static u8 *
327 format_dpdk_link_status (u8 * s, va_list * args)
328 {
329  dpdk_device_t *xd = va_arg (*args, dpdk_device_t *);
330  struct rte_eth_link *l = &xd->link;
331  vnet_main_t *vnm = vnet_get_main ();
333 
334  s = format (s, "%s ", l->link_status ? "up" : "down");
335  if (l->link_status)
336  {
337  u32 promisc = rte_eth_promiscuous_get (xd->device_index);
338 
339  s = format (s, "%s duplex ", (l->link_duplex == ETH_LINK_FULL_DUPLEX) ?
340  "full" : "half");
341  s = format (s, "speed %u mtu %d %s\n", l->link_speed,
342  hi->max_packet_bytes, promisc ? " promisc" : "");
343  }
344  else
345  s = format (s, "\n");
346 
347  return s;
348 }
349 
350 #define _line_len 72
351 #define _(v, str) \
352 if (bitmap & v) { \
353  if (format_get_indent (s) > next_split ) { \
354  next_split += _line_len; \
355  s = format(s,"\n%U", format_white_space, indent); \
356  } \
357  s = format(s, "%s ", str); \
358 }
359 
360 static u8 *
361 format_dpdk_rss_hf_name (u8 * s, va_list * args)
362 {
363  u64 bitmap = va_arg (*args, u64);
364  int next_split = _line_len;
365  int indent = format_get_indent (s);
366 
367  if (!bitmap)
368  return format (s, "none");
369 
370  foreach_dpdk_rss_hf return s;
371 }
372 
373 static u8 *
374 format_dpdk_rx_offload_caps (u8 * s, va_list * args)
375 {
376  u32 bitmap = va_arg (*args, u32);
377  int next_split = _line_len;
378  int indent = format_get_indent (s);
379 
380  if (!bitmap)
381  return format (s, "none");
382 
384 }
385 
386 static u8 *
387 format_dpdk_tx_offload_caps (u8 * s, va_list * args)
388 {
389  u32 bitmap = va_arg (*args, u32);
390  int next_split = _line_len;
391  int indent = format_get_indent (s);
392  if (!bitmap)
393  return format (s, "none");
394 
396 }
397 
398 #undef _line_len
399 #undef _
400 
401 u8 *
402 format_dpdk_device_errors (u8 * s, va_list * args)
403 {
404  dpdk_device_t *xd = va_arg (*args, dpdk_device_t *);
405  clib_error_t *e;
406  uword indent = format_get_indent (s);
407 
408  vec_foreach (e, xd->errors)
409  {
410  s = format (s, "%U%v\n", format_white_space, indent, e->what);
411  }
412  return s;
413 }
414 
415 u8 *
416 format_dpdk_device (u8 * s, va_list * args)
417 {
418  u32 dev_instance = va_arg (*args, u32);
419  int verbose = va_arg (*args, int);
420  dpdk_main_t *dm = &dpdk_main;
421  dpdk_device_t *xd = vec_elt_at_index (dm->devices, dev_instance);
422  uword indent = format_get_indent (s);
423  f64 now = vlib_time_now (dm->vlib_main);
424  struct rte_eth_dev_info di;
425 
426  dpdk_update_counters (xd, now);
427  dpdk_update_link_state (xd, now);
428 
429  s = format (s, "%U\n%Ucarrier %U",
432 
433  rte_eth_dev_info_get (xd->device_index, &di);
434 
435  if (verbose > 1 && xd->flags & DPDK_DEVICE_FLAG_PMD)
436  {
437  struct rte_pci_device *pci;
438  struct rte_eth_rss_conf rss_conf;
439  int vlan_off;
440  int retval;
441 
442  rss_conf.rss_key = 0;
443  retval = rte_eth_dev_rss_hash_conf_get (xd->device_index, &rss_conf);
444  if (retval < 0)
445  clib_warning ("rte_eth_dev_rss_hash_conf_get returned %d", retval);
446  pci = di.pci_dev;
447 
448  if (pci)
449  s =
450  format (s,
451  "%Upci id: device %04x:%04x subsystem %04x:%04x\n"
452  "%Upci address: %04x:%02x:%02x.%02x\n",
453  format_white_space, indent + 2, pci->id.vendor_id,
454  pci->id.device_id, pci->id.subsystem_vendor_id,
455  pci->id.subsystem_device_id, format_white_space, indent + 2,
456  pci->addr.domain, pci->addr.bus, pci->addr.devid,
457  pci->addr.function);
458  s =
459  format (s, "%Umax rx packet len: %d\n", format_white_space,
460  indent + 2, di.max_rx_pktlen);
461  s =
462  format (s, "%Umax num of queues: rx %d tx %d\n", format_white_space,
463  indent + 2, di.max_rx_queues, di.max_tx_queues);
464  s =
465  format (s, "%Upromiscuous: unicast %s all-multicast %s\n",
466  format_white_space, indent + 2,
467  rte_eth_promiscuous_get (xd->device_index) ? "on" : "off",
468  rte_eth_allmulticast_get (xd->device_index) ? "on" : "off");
469  vlan_off = rte_eth_dev_get_vlan_offload (xd->device_index);
470  s = format (s, "%Uvlan offload: strip %s filter %s qinq %s\n",
471  format_white_space, indent + 2,
472  vlan_off & ETH_VLAN_STRIP_OFFLOAD ? "on" : "off",
473  vlan_off & ETH_VLAN_FILTER_OFFLOAD ? "on" : "off",
474  vlan_off & ETH_VLAN_EXTEND_OFFLOAD ? "on" : "off");
475  s = format (s, "%Urx offload caps: %U\n",
476  format_white_space, indent + 2,
477  format_dpdk_rx_offload_caps, di.rx_offload_capa);
478  s = format (s, "%Utx offload caps: %U\n",
479  format_white_space, indent + 2,
480  format_dpdk_tx_offload_caps, di.tx_offload_capa);
481  s = format (s, "%Urss active: %U\n"
482  "%Urss supported: %U\n",
483  format_white_space, indent + 2,
484  format_dpdk_rss_hf_name, rss_conf.rss_hf,
485  format_white_space, indent + 2,
486  format_dpdk_rss_hf_name, di.flow_type_rss_offloads);
487  }
488 
489  s = format (s, "%Urx queues %d, rx desc %d, tx queues %d, tx desc %d\n",
490  format_white_space, indent + 2,
491  xd->rx_q_used, xd->nb_rx_desc, xd->tx_q_used, xd->nb_tx_desc);
492 
493  if (xd->cpu_socket > -1)
494  s = format (s, "%Ucpu socket %d\n",
495  format_white_space, indent + 2, xd->cpu_socket);
496 
497  /* $$$ MIB counters */
498  {
499 #define _(N, V) \
500  if ((xd->stats.V - xd->last_cleared_stats.V) != 0) { \
501  s = format (s, "\n%U%-40U%16Ld", \
502  format_white_space, indent + 2, \
503  format_c_identifier, #N, \
504  xd->stats.V - xd->last_cleared_stats.V); \
505  } \
506 
508 #undef _
509  }
510 
511  u8 *xs = 0;
512  u32 i = 0;
513  struct rte_eth_xstat *xstat, *last_xstat;
514  struct rte_eth_xstat_name *xstat_names = 0;
515  int len = rte_eth_xstats_get_names (xd->device_index, NULL, 0);
516  vec_validate (xstat_names, len - 1);
517  rte_eth_xstats_get_names (xd->device_index, xstat_names, len);
518 
520 
521  /* *INDENT-OFF* */
522  vec_foreach_index(i, xd->xstats)
523  {
524  u64 delta = 0;
525  xstat = vec_elt_at_index(xd->xstats, i);
526  last_xstat = vec_elt_at_index(xd->last_cleared_xstats, i);
527 
528  delta = xstat->value - last_xstat->value;
529  if (verbose == 2 || (verbose && delta))
530  {
531  /* format_c_identifier doesn't like c strings inside vector */
532  u8 * name = format(0,"%s", xstat_names[i].name);
533  xs = format(xs, "\n%U%-38U%16Ld",
534  format_white_space, indent + 4,
535  format_c_identifier, name, delta);
536  vec_free(name);
537  }
538  }
539  /* *INDENT-ON* */
540 
541  vec_free (xstat_names);
542 
543  if (xs)
544  {
545  s = format (s, "\n%Uextended stats:%v",
546  format_white_space, indent + 2, xs);
547  vec_free (xs);
548  }
549 
550  if (vec_len (xd->errors))
551  {
552  s = format (s, "%UErrors:\n %U", format_white_space, indent,
554  }
555 
556  return s;
557 }
558 
559 u8 *
560 format_dpdk_tx_dma_trace (u8 * s, va_list * va)
561 {
562  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
563  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
565  dpdk_tx_dma_trace_t *t = va_arg (*va, dpdk_tx_dma_trace_t *);
566  dpdk_main_t *dm = &dpdk_main;
568  uword indent = format_get_indent (s);
570 
571  s = format (s, "%U tx queue %d",
573 
574  s = format (s, "\n%Ubuffer 0x%x: %U",
575  format_white_space, indent,
577 
578  s = format (s, "\n%U%U", format_white_space, indent,
580  sizeof (t->buffer.pre_data));
581 
582  return s;
583 }
584 
585 u8 *
586 format_dpdk_rx_dma_trace (u8 * s, va_list * va)
587 {
588  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
589  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
591  dpdk_rx_dma_trace_t *t = va_arg (*va, dpdk_rx_dma_trace_t *);
592  dpdk_main_t *dm = &dpdk_main;
595  uword indent = format_get_indent (s);
597 
598  s = format (s, "%U rx queue %d",
600 
601  s = format (s, "\n%Ubuffer 0x%x: %U",
602  format_white_space, indent,
604 
605  s = format (s, "\n%U%U",
606  format_white_space, indent,
607  format_dpdk_rte_mbuf, &t->mb, &t->data);
608 
609  if (vm->trace_main.verbose)
610  {
611  s = format (s, "\n%UPacket Dump%s", format_white_space, indent + 2,
612  t->mb.data_len > sizeof (t->data) ? " (truncated)" : "");
613  s = format (s, "\n%U%U", format_white_space, indent + 4,
614  format_hexdump, &t->data,
615  t->mb.data_len >
616  sizeof (t->data) ? sizeof (t->data) : t->mb.data_len);
617  }
618  f = node->format_buffer;
619  if (!f)
620  f = format_hex_bytes;
621  s = format (s, "\n%U%U", format_white_space, indent,
622  f, t->buffer.pre_data, sizeof (t->buffer.pre_data));
623 
624  return s;
625 }
626 
627 
628 static inline u8 *
629 format_dpdk_pkt_types (u8 * s, va_list * va)
630 {
631  u32 *pkt_types = va_arg (*va, u32 *);
632  uword indent __attribute__ ((unused)) = format_get_indent (s) + 2;
633 
634  if (!*pkt_types)
635  return s;
636 
637  s = format (s, "Packet Types");
638 
639 #define _(L, F, S) \
640  if ((*pkt_types & RTE_PTYPE_##L##_MASK) == RTE_PTYPE_##L##_##F) \
641  { \
642  s = format (s, "\n%U%s (0x%04x) %s", format_white_space, indent, \
643  "RTE_PTYPE_" #L "_" #F, RTE_PTYPE_##L##_##F, S); \
644  }
645 
647 #undef _
648  return s;
649 }
650 
651 static inline u8 *
653 {
654  u64 *ol_flags = va_arg (*va, u64 *);
655  uword indent = format_get_indent (s) + 2;
656 
657  if (!*ol_flags)
658  return s;
659 
660  s = format (s, "Packet Offload Flags");
661 
662 #define _(F, S) \
663  if (*ol_flags & F) \
664  { \
665  s = format (s, "\n%U%s (0x%04x) %s", \
666  format_white_space, indent, #F, F, S); \
667  }
668 
670 #undef _
671  return s;
672 }
673 
674 u8 *
675 format_dpdk_rte_mbuf_vlan (u8 * s, va_list * va)
676 {
677  ethernet_vlan_header_tv_t *vlan_hdr =
678  va_arg (*va, ethernet_vlan_header_tv_t *);
679 
680  if (clib_net_to_host_u16 (vlan_hdr->type) == ETHERNET_TYPE_DOT1AD)
681  {
682  s = format (s, "%U 802.1q vlan ",
684  clib_net_to_host_u16 (vlan_hdr->priority_cfi_and_id));
685  vlan_hdr++;
686  }
687 
688  s = format (s, "%U",
690  clib_net_to_host_u16 (vlan_hdr->priority_cfi_and_id));
691 
692  return s;
693 }
694 
695 u8 *
696 format_dpdk_rte_mbuf (u8 * s, va_list * va)
697 {
698  struct rte_mbuf *mb = va_arg (*va, struct rte_mbuf *);
699  ethernet_header_t *eth_hdr = va_arg (*va, ethernet_header_t *);
700  uword indent = format_get_indent (s) + 2;
701 
702  s = format (s, "PKT MBUF: port %d, nb_segs %d, pkt_len %d"
703  "\n%Ubuf_len %d, data_len %d, ol_flags 0x%x, data_off %d, phys_addr 0x%x"
704  "\n%Upacket_type 0x%x",
705  mb->port, mb->nb_segs, mb->pkt_len,
706  format_white_space, indent,
707  mb->buf_len, mb->data_len, mb->ol_flags, mb->data_off,
708  mb->buf_physaddr, format_white_space, indent, mb->packet_type);
709 
710  if (mb->ol_flags)
711  s = format (s, "\n%U%U", format_white_space, indent,
712  format_dpdk_pkt_offload_flags, &mb->ol_flags);
713 
714  if ((mb->ol_flags & PKT_RX_VLAN_PKT) &&
715  ((mb->ol_flags & (PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ_STRIPPED)) == 0))
716  {
717  ethernet_vlan_header_tv_t *vlan_hdr =
718  ((ethernet_vlan_header_tv_t *) & (eth_hdr->type));
719  s = format (s, " %U", format_dpdk_rte_mbuf_vlan, vlan_hdr);
720  }
721 
722  if (mb->packet_type)
723  s = format (s, "\n%U%U", format_white_space, indent,
724  format_dpdk_pkt_types, &mb->packet_type);
725 
726  return s;
727 }
728 
729 clib_error_t *
731 {
733  {
734  if (0)
735  ;
736 #undef _
737 #define _(f, s) \
738  else if (unformat (input, s)) \
739  *rss_fn |= f;
740 
742 #undef _
743  else
744  {
745  return clib_error_return (0, "unknown input `%U'",
746  format_unformat_error, input);
747  }
748  }
749  return 0;
750 }
751 
752 uword
753 unformat_dpdk_log_level (unformat_input_t * input, va_list * args)
754 {
755  u32 *r = va_arg (*args, u32 *);
756 
757  if (0);
758 #define _(v,s) else if (unformat (input, s)) *r = RTE_LOG_##v;
760 #undef _
761  else
762  return 0;
763  return 1;
764 }
765 
766 clib_error_t *
768 {
769  clib_error_t *error = 0;
770 
772  {
773  if (unformat (input, "hqos-thread %u", &hqos->hqos_thread))
774  hqos->hqos_thread_valid = 1;
775  else
776  {
777  error = clib_error_return (0, "unknown input `%U'",
778  format_unformat_error, input);
779  break;
780  }
781  }
782 
783  return error;
784 }
785 
786 /*
787  * fd.io coding-style-patch-verification: ON
788  *
789  * Local Variables:
790  * eval: (c-set-style "gnu")
791  * End:
792  */
static u8 * format_dpdk_tx_offload_caps(u8 *s, va_list *args)
Definition: format.c:387
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:436
u8 * format_dpdk_device(u8 *s, va_list *args)
Definition: format.c:416
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:675
vlib_buffer_t buffer
Definition: dpdk.h:402
u8 interface_name_format_decimal
Definition: dpdk.h:322
dpdk_main_t dpdk_main
Definition: init.c:36
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:361
format_function_t format_vlib_buffer
Definition: buffer_funcs.h:705
#define NULL
Definition: clib.h:55
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:192
clib_error_t * unformat_hqos(unformat_input_t *input, dpdk_device_config_hqos_t *hqos)
Definition: format.c:767
u16 flags
Definition: dpdk.h:169
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
clib_error_t * errors
Definition: dpdk.h:222
static u8 * format_dpdk_pkt_offload_flags(u8 *s, va_list *va)
Definition: format.c:652
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:696
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:214
#define DPDK_DEVICE_FLAG_PMD
Definition: dpdk.h:172
u8 port_id
Definition: dpdk.h:201
static u8 * format_dpdk_rx_offload_caps(u8 *s, va_list *args)
Definition: format.c:374
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:412
uword unformat_dpdk_log_level(unformat_input_t *input, va_list *args)
Definition: format.c:753
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:190
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:144
unsigned long u64
Definition: types.h:89
u32 device_index
Definition: dpdk.h:151
static u8 * format_dpdk_pkt_types(u8 *s, va_list *va)
Definition: format.c:629
u8 * format_c_identifier(u8 *s, va_list *va)
Definition: std-formats.c:258
struct rte_mbuf mb
Definition: dpdk.h:410
u32 vlib_sw_if_index
Definition: dpdk.h:154
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:216
format_function_t * format_buffer
Definition: node.h:312
u16 tx_q_used
Definition: dpdk.h:189
u16 nb_rx_desc
Definition: dpdk.h:191
u32 hw_if_index
Definition: dpdk.h:153
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
dpdk_device_t * devices
Definition: dpdk.h:337
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:340
#define clib_warning(format, args...)
Definition: error.h:59
dpdk_pmd_t pmd
Definition: dpdk.h:166
u8 * format_hexdump(u8 *s, va_list *va)
Definition: std-formats.c:281
struct rte_eth_xstat * xstats
Definition: dpdk.h:213
u8 * interface_name_suffix
Definition: dpdk.h:183
#define ASSERT(truth)
u8 * format_dpdk_device_errors(u8 *s, va_list *args)
Definition: format.c:402
unsigned int u32
Definition: types.h:88
clib_error_t * unformat_rss_fn(unformat_input_t *input, uword *rss_fn)
Definition: format.c:730
#define foreach_dpdk_tx_offload_caps
Definition: format.c:71
vlib_trace_main_t trace_main
Definition: main.h:121
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
Definition: init.c:1236
struct rte_eth_link link
Definition: dpdk.h:207
u64 uword
Definition: types.h:112
vlib_buffer_t buffer
Definition: dpdk.h:411
static u8 * format_dpdk_device_type(u8 *s, va_list *args)
Definition: format.c:237
#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:560
#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:167
static u8 * format_dpdk_link_status(u8 *s, va_list *args)
Definition: format.c:327
u16 nb_tx_desc
Definition: dpdk.h:180
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:384
u8 * format_dpdk_rx_dma_trace(u8 *s, va_list *va)
Definition: format.c:586
vlib_main_t * vlib_main
Definition: dpdk.h:382