FD.io VPP  v17.04-9-g99c0734
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 u8 *
147 format_dpdk_device_name (u8 * s, va_list * args)
148 {
149  dpdk_main_t *dm = &dpdk_main;
150  char *devname_format;
151  char *device_name;
152  u32 i = va_arg (*args, u32);
153  struct rte_eth_dev_info dev_info;
154  u8 *ret;
155 
157  devname_format = "%s%d/%d/%d";
158  else
159  devname_format = "%s%x/%x/%x";
160 
161  switch (dm->devices[i].port_type)
162  {
164  device_name = "GigabitEthernet";
165  break;
166 
168  device_name = "TenGigabitEthernet";
169  break;
170 
172  device_name = "FortyGigabitEthernet";
173  break;
174 
176  device_name = "HundredGigabitEthernet";
177  break;
178 
180  return format (s, "BondEthernet%d", dm->devices[i].port_id);
181 
183  device_name = "EthernetSwitch";
184  break;
185 
187  rte_eth_dev_info_get (i, &dev_info);
188  return format (s, "af_packet%d", dm->devices[i].port_id);
189 
190  default:
192  device_name = "UnknownEthernet";
193  break;
194  }
195 
196  rte_eth_dev_info_get (i, &dev_info);
197 
198  if (dev_info.pci_dev)
199  ret = format (s, devname_format, device_name, dev_info.pci_dev->addr.bus,
200  dev_info.pci_dev->addr.devid,
201  dev_info.pci_dev->addr.function);
202  else
203  ret = format (s, "%s%d", device_name, dm->devices[i].device_index);
204 
205  if (dm->devices[i].interface_name_suffix)
206  return format (ret, "/%s", dm->devices[i].interface_name_suffix);
207  return ret;
208 }
209 
210 static u8 *
211 format_dpdk_device_type (u8 * s, va_list * args)
212 {
213  dpdk_main_t *dm = &dpdk_main;
214  char *dev_type;
215  u32 i = va_arg (*args, u32);
216 
217  switch (dm->devices[i].pmd)
218  {
219  case VNET_DPDK_PMD_E1000EM:
220  dev_type = "Intel 82540EM (e1000)";
221  break;
222 
223  case VNET_DPDK_PMD_IGB:
224  dev_type = "Intel e1000";
225  break;
226 
227  case VNET_DPDK_PMD_I40E:
228  dev_type = "Intel X710/XL710 Family";
229  break;
230 
231  case VNET_DPDK_PMD_I40EVF:
232  dev_type = "Intel X710/XL710 Family VF";
233  break;
234 
235  case VNET_DPDK_PMD_FM10K:
236  dev_type = "Intel FM10000 Family Ethernet Switch";
237  break;
238 
239  case VNET_DPDK_PMD_IGBVF:
240  dev_type = "Intel e1000 VF";
241  break;
242 
243  case VNET_DPDK_PMD_VIRTIO:
244  dev_type = "Red Hat Virtio";
245  break;
246 
247  case VNET_DPDK_PMD_IXGBEVF:
248  dev_type = "Intel 82599 VF";
249  break;
250 
251  case VNET_DPDK_PMD_IXGBE:
252  dev_type = "Intel 82599";
253  break;
254 
255  case VNET_DPDK_PMD_ENIC:
256  dev_type = "Cisco VIC";
257  break;
258 
259  case VNET_DPDK_PMD_CXGBE:
260  dev_type = "Chelsio T4/T5";
261  break;
262 
263  case VNET_DPDK_PMD_MLX5:
264  dev_type = "Mellanox ConnectX-4 Family";
265  break;
266 
267  case VNET_DPDK_PMD_VMXNET3:
268  dev_type = "VMware VMXNET3";
269  break;
270 
271  case VNET_DPDK_PMD_AF_PACKET:
272  dev_type = "af_packet";
273  break;
274 
275  case VNET_DPDK_PMD_BOND:
276  dev_type = "Ethernet Bonding";
277  break;
278 
279  case VNET_DPDK_PMD_DPAA2:
280  dev_type = "NXP DPAA2 Mac";
281  break;
282 
283  default:
285  dev_type = "### UNKNOWN ###";
286  break;
287  }
288 
289  return format (s, dev_type);
290 }
291 
292 static u8 *
293 format_dpdk_link_status (u8 * s, va_list * args)
294 {
295  dpdk_device_t *xd = va_arg (*args, dpdk_device_t *);
296  struct rte_eth_link *l = &xd->link;
297  vnet_main_t *vnm = vnet_get_main ();
299 
300  s = format (s, "%s ", l->link_status ? "up" : "down");
301  if (l->link_status)
302  {
303  u32 promisc = rte_eth_promiscuous_get (xd->device_index);
304 
305  s = format (s, "%s duplex ", (l->link_duplex == ETH_LINK_FULL_DUPLEX) ?
306  "full" : "half");
307  s = format (s, "speed %u mtu %d %s\n", l->link_speed,
308  hi->max_packet_bytes, promisc ? " promisc" : "");
309  }
310  else
311  s = format (s, "\n");
312 
313  return s;
314 }
315 
316 #define _line_len 72
317 #define _(v, str) \
318 if (bitmap & v) { \
319  if (format_get_indent (s) > next_split ) { \
320  next_split += _line_len; \
321  s = format(s,"\n%U", format_white_space, indent); \
322  } \
323  s = format(s, "%s ", str); \
324 }
325 
326 static u8 *
327 format_dpdk_rss_hf_name (u8 * s, va_list * args)
328 {
329  u64 bitmap = va_arg (*args, u64);
330  int next_split = _line_len;
331  int indent = format_get_indent (s);
332 
333  if (!bitmap)
334  return format (s, "none");
335 
336  foreach_dpdk_rss_hf return s;
337 }
338 
339 static u8 *
340 format_dpdk_rx_offload_caps (u8 * s, va_list * args)
341 {
342  u32 bitmap = va_arg (*args, u32);
343  int next_split = _line_len;
344  int indent = format_get_indent (s);
345 
346  if (!bitmap)
347  return format (s, "none");
348 
350 }
351 
352 static u8 *
353 format_dpdk_tx_offload_caps (u8 * s, va_list * args)
354 {
355  u32 bitmap = va_arg (*args, u32);
356  int next_split = _line_len;
357  int indent = format_get_indent (s);
358  if (!bitmap)
359  return format (s, "none");
360 
362 }
363 
364 #undef _line_len
365 #undef _
366 
367 u8 *
368 format_dpdk_device (u8 * s, va_list * args)
369 {
370  u32 dev_instance = va_arg (*args, u32);
371  int verbose = va_arg (*args, int);
372  dpdk_main_t *dm = &dpdk_main;
373  dpdk_device_t *xd = vec_elt_at_index (dm->devices, dev_instance);
374  uword indent = format_get_indent (s);
375  f64 now = vlib_time_now (dm->vlib_main);
376  struct rte_eth_dev_info di;
377 
378  dpdk_update_counters (xd, now);
379  dpdk_update_link_state (xd, now);
380 
381  s = format (s, "%U\n%Ucarrier %U",
384 
385  rte_eth_dev_info_get (xd->device_index, &di);
386 
387  if (verbose > 1 && xd->flags & DPDK_DEVICE_FLAG_PMD)
388  {
389  struct rte_pci_device *pci;
390  struct rte_eth_rss_conf rss_conf;
391  int vlan_off;
392  int retval;
393 
394  rss_conf.rss_key = 0;
395  retval = rte_eth_dev_rss_hash_conf_get (xd->device_index, &rss_conf);
396  if (retval < 0)
397  clib_warning ("rte_eth_dev_rss_hash_conf_get returned %d", retval);
398  pci = di.pci_dev;
399 
400  if (pci)
401  s =
402  format (s,
403  "%Upci id: device %04x:%04x subsystem %04x:%04x\n"
404  "%Upci address: %04x:%02x:%02x.%02x\n",
405  format_white_space, indent + 2, pci->id.vendor_id,
406  pci->id.device_id, pci->id.subsystem_vendor_id,
407  pci->id.subsystem_device_id, format_white_space, indent + 2,
408  pci->addr.domain, pci->addr.bus, pci->addr.devid,
409  pci->addr.function);
410  s =
411  format (s, "%Umax rx packet len: %d\n", format_white_space,
412  indent + 2, di.max_rx_pktlen);
413  s =
414  format (s, "%Umax num of queues: rx %d tx %d\n", format_white_space,
415  indent + 2, di.max_rx_queues, di.max_tx_queues);
416  s =
417  format (s, "%Upromiscuous: unicast %s all-multicast %s\n",
418  format_white_space, indent + 2,
419  rte_eth_promiscuous_get (xd->device_index) ? "on" : "off",
420  rte_eth_promiscuous_get (xd->device_index) ? "on" : "off");
421  vlan_off = rte_eth_dev_get_vlan_offload (xd->device_index);
422  s = format (s, "%Uvlan offload: strip %s filter %s qinq %s\n",
423  format_white_space, indent + 2,
424  vlan_off & ETH_VLAN_STRIP_OFFLOAD ? "on" : "off",
425  vlan_off & ETH_VLAN_FILTER_OFFLOAD ? "on" : "off",
426  vlan_off & ETH_VLAN_EXTEND_OFFLOAD ? "on" : "off");
427  s = format (s, "%Urx offload caps: %U\n",
428  format_white_space, indent + 2,
429  format_dpdk_rx_offload_caps, di.rx_offload_capa);
430  s = format (s, "%Utx offload caps: %U\n",
431  format_white_space, indent + 2,
432  format_dpdk_tx_offload_caps, di.tx_offload_capa);
433  s = format (s, "%Urss active: %U\n"
434  "%Urss supported: %U\n",
435  format_white_space, indent + 2,
436  format_dpdk_rss_hf_name, rss_conf.rss_hf,
437  format_white_space, indent + 2,
438  format_dpdk_rss_hf_name, di.flow_type_rss_offloads);
439  }
440 
441  s = format (s, "%Urx queues %d, rx desc %d, tx queues %d, tx desc %d\n",
442  format_white_space, indent + 2,
443  xd->rx_q_used, xd->nb_rx_desc, xd->tx_q_used, xd->nb_tx_desc);
444 
445  if (xd->cpu_socket > -1)
446  s = format (s, "%Ucpu socket %d\n",
447  format_white_space, indent + 2, xd->cpu_socket);
448 
449  /* $$$ MIB counters */
450  {
451 #define _(N, V) \
452  if ((xd->stats.V - xd->last_cleared_stats.V) != 0) { \
453  s = format (s, "\n%U%-40U%16Ld", \
454  format_white_space, indent + 2, \
455  format_c_identifier, #N, \
456  xd->stats.V - xd->last_cleared_stats.V); \
457  } \
458 
460 #undef _
461  }
462 
463  u8 *xs = 0;
464  u32 i = 0;
465  struct rte_eth_xstat *xstat, *last_xstat;
466  struct rte_eth_xstat_name *xstat_names = 0;
467  int len = rte_eth_xstats_get_names (xd->device_index, NULL, 0);
468  vec_validate (xstat_names, len - 1);
469  rte_eth_xstats_get_names (xd->device_index, xstat_names, len);
470 
472 
473  /* *INDENT-OFF* */
474  vec_foreach_index(i, xd->xstats)
475  {
476  u64 delta = 0;
477  xstat = vec_elt_at_index(xd->xstats, i);
478  last_xstat = vec_elt_at_index(xd->last_cleared_xstats, i);
479 
480  delta = xstat->value - last_xstat->value;
481  if (verbose == 2 || (verbose && delta))
482  {
483  /* format_c_identifier doesn't like c strings inside vector */
484  u8 * name = format(0,"%s", xstat_names[i].name);
485  xs = format(xs, "\n%U%-38U%16Ld",
486  format_white_space, indent + 4,
487  format_c_identifier, name, delta);
488  vec_free(name);
489  }
490  }
491  /* *INDENT-ON* */
492 
493  vec_free (xstat_names);
494 
495  if (xs)
496  {
497  s = format (s, "\n%Uextended stats:%v",
498  format_white_space, indent + 2, xs);
499  vec_free (xs);
500  }
501 
502  return s;
503 }
504 
505 u8 *
506 format_dpdk_tx_dma_trace (u8 * s, va_list * va)
507 {
508  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
509  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
511  dpdk_tx_dma_trace_t *t = va_arg (*va, dpdk_tx_dma_trace_t *);
512  dpdk_main_t *dm = &dpdk_main;
514  uword indent = format_get_indent (s);
516 
517  s = format (s, "%U tx queue %d",
519 
520  s = format (s, "\n%Ubuffer 0x%x: %U",
521  format_white_space, indent,
523 
524  s = format (s, "\n%U%U", format_white_space, indent,
526  sizeof (t->buffer.pre_data));
527 
528  return s;
529 }
530 
531 u8 *
532 format_dpdk_rx_dma_trace (u8 * s, va_list * va)
533 {
534  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
535  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
537  dpdk_rx_dma_trace_t *t = va_arg (*va, dpdk_rx_dma_trace_t *);
538  dpdk_main_t *dm = &dpdk_main;
541  uword indent = format_get_indent (s);
543 
544  s = format (s, "%U rx queue %d",
546 
547  s = format (s, "\n%Ubuffer 0x%x: %U",
548  format_white_space, indent,
550 
551  s = format (s, "\n%U%U",
552  format_white_space, indent,
553  format_dpdk_rte_mbuf, &t->mb, &t->data);
554 
555  if (vm->trace_main.verbose)
556  {
557  s = format (s, "\n%UPacket Dump%s", format_white_space, indent + 2,
558  t->mb.data_len > sizeof (t->data) ? " (truncated)" : "");
559  s = format (s, "\n%U%U", format_white_space, indent + 4,
560  format_hexdump, &t->data,
561  t->mb.data_len >
562  sizeof (t->data) ? sizeof (t->data) : t->mb.data_len);
563  }
564  f = node->format_buffer;
565  if (!f)
566  f = format_hex_bytes;
567  s = format (s, "\n%U%U", format_white_space, indent,
568  f, t->buffer.pre_data, sizeof (t->buffer.pre_data));
569 
570  return s;
571 }
572 
573 
574 static inline u8 *
575 format_dpdk_pkt_types (u8 * s, va_list * va)
576 {
577  u32 *pkt_types = va_arg (*va, u32 *);
578  uword indent __attribute__ ((unused)) = format_get_indent (s) + 2;
579 
580  if (!*pkt_types)
581  return s;
582 
583  s = format (s, "Packet Types");
584 
585 #define _(L, F, S) \
586  if ((*pkt_types & RTE_PTYPE_##L##_MASK) == RTE_PTYPE_##L##_##F) \
587  { \
588  s = format (s, "\n%U%s (0x%04x) %s", format_white_space, indent, \
589  "RTE_PTYPE_" #L "_" #F, RTE_PTYPE_##L##_##F, S); \
590  }
591 
593 #undef _
594  return s;
595 }
596 
597 static inline u8 *
599 {
600  u64 *ol_flags = va_arg (*va, u64 *);
601  uword indent = format_get_indent (s) + 2;
602 
603  if (!*ol_flags)
604  return s;
605 
606  s = format (s, "Packet Offload Flags");
607 
608 #define _(F, S) \
609  if (*ol_flags & F) \
610  { \
611  s = format (s, "\n%U%s (0x%04x) %s", \
612  format_white_space, indent, #F, F, S); \
613  }
614 
616 #undef _
617  return s;
618 }
619 
620 u8 *
621 format_dpdk_rte_mbuf_vlan (u8 * s, va_list * va)
622 {
623  ethernet_vlan_header_tv_t *vlan_hdr =
624  va_arg (*va, ethernet_vlan_header_tv_t *);
625 
626  if (clib_net_to_host_u16 (vlan_hdr->type) == ETHERNET_TYPE_DOT1AD)
627  {
628  s = format (s, "%U 802.1q vlan ",
630  clib_net_to_host_u16 (vlan_hdr->priority_cfi_and_id));
631  vlan_hdr++;
632  }
633 
634  s = format (s, "%U",
636  clib_net_to_host_u16 (vlan_hdr->priority_cfi_and_id));
637 
638  return s;
639 }
640 
641 u8 *
642 format_dpdk_rte_mbuf (u8 * s, va_list * va)
643 {
644  struct rte_mbuf *mb = va_arg (*va, struct rte_mbuf *);
645  ethernet_header_t *eth_hdr = va_arg (*va, ethernet_header_t *);
646  uword indent = format_get_indent (s) + 2;
647 
648  s = format (s, "PKT MBUF: port %d, nb_segs %d, pkt_len %d"
649  "\n%Ubuf_len %d, data_len %d, ol_flags 0x%x, data_off %d, phys_addr 0x%x"
650  "\n%Upacket_type 0x%x",
651  mb->port, mb->nb_segs, mb->pkt_len,
652  format_white_space, indent,
653  mb->buf_len, mb->data_len, mb->ol_flags, mb->data_off,
654  mb->buf_physaddr, format_white_space, indent, mb->packet_type);
655 
656  if (mb->ol_flags)
657  s = format (s, "\n%U%U", format_white_space, indent,
658  format_dpdk_pkt_offload_flags, &mb->ol_flags);
659 
660  if ((mb->ol_flags & PKT_RX_VLAN_PKT) &&
661  ((mb->ol_flags & (PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ_STRIPPED)) == 0))
662  {
663  ethernet_vlan_header_tv_t *vlan_hdr =
664  ((ethernet_vlan_header_tv_t *) & (eth_hdr->type));
665  s = format (s, " %U", format_dpdk_rte_mbuf_vlan, vlan_hdr);
666  }
667 
668  if (mb->packet_type)
669  s = format (s, "\n%U%U", format_white_space, indent,
670  format_dpdk_pkt_types, &mb->packet_type);
671 
672  return s;
673 }
674 
675 /* FIXME is this function used? */
676 #if 0
677 uword
678 unformat_socket_mem (unformat_input_t * input, va_list * va)
679 {
680  uword **r = va_arg (*va, uword **);
681  int i = 0;
682  u32 mem;
683 
685  {
686  if (unformat (input, ","))
687  hash_set (*r, i, 1024);
688  else if (unformat (input, "%u,", &mem))
689  hash_set (*r, i, mem);
690  else if (unformat (input, "%u", &mem))
691  hash_set (*r, i, mem);
692  else
693  {
694  unformat_put_input (input);
695  goto done;
696  }
697  i++;
698  }
699 
700 done:
701  return 1;
702 }
703 #endif
704 
705 clib_error_t *
707 {
709  {
710  if (0)
711  ;
712 #undef _
713 #define _(f, s) \
714  else if (unformat (input, s)) \
715  *rss_fn |= f;
716 
718 #undef _
719  else
720  {
721  return clib_error_return (0, "unknown input `%U'",
722  format_unformat_error, input);
723  }
724  }
725  return 0;
726 }
727 
728 clib_error_t *
730 {
731  clib_error_t *error = 0;
732 
734  {
735  if (unformat (input, "hqos-thread %u", &hqos->hqos_thread))
736  hqos->hqos_thread_valid = 1;
737  else
738  {
739  error = clib_error_return (0, "unknown input `%U'",
740  format_unformat_error, input);
741  break;
742  }
743  }
744 
745  return error;
746 }
747 
748 /*
749  * fd.io coding-style-patch-verification: ON
750  *
751  * Local Variables:
752  * eval: (c-set-style "gnu")
753  * End:
754  */
static u8 * format_dpdk_tx_offload_caps(u8 *s, va_list *args)
Definition: format.c:353
#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:368
vmrglw vmrglh hi
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define hash_set(h, key, value)
Definition: hash.h:254
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
#define CLIB_UNUSED(x)
Definition: clib.h:79
u8 * format_dpdk_rte_mbuf_vlan(u8 *s, va_list *va)
Definition: format.c:621
vlib_buffer_t buffer
Definition: dpdk.h:431
u8 interface_name_format_decimal
Definition: dpdk.h:340
dpdk_main_t dpdk_main
Definition: dpdk.h:422
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:327
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:185
clib_error_t * unformat_hqos(unformat_input_t *input, dpdk_device_config_hqos_t *hqos)
Definition: format.c:729
u16 flags
Definition: dpdk.h:194
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
static u8 * format_dpdk_pkt_offload_flags(u8 *s, va_list *va)
Definition: format.c:598
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:642
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
struct rte_eth_xstat * last_cleared_xstats
Definition: dpdk.h:233
#define DPDK_DEVICE_FLAG_PMD
Definition: dpdk.h:197
u8 port_id
Definition: dpdk.h:224
static u8 * format_dpdk_rx_offload_caps(u8 *s, va_list *args)
Definition: format.c:340
u8 * format_dpdk_device_name(u8 *s, va_list *args)
Definition: format.c:147
#define foreach_dpdk_rss_hf
Definition: format.c:44
u8 data[256]
Definition: dpdk.h:441
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
unformat_function_t unformat_socket_mem
Definition: dpdk.h:497
#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:111
u16 rx_q_used
Definition: dpdk.h:213
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:176
static u8 * format_dpdk_pkt_types(u8 *s, va_list *va)
Definition: format.c:575
u8 * format_c_identifier(u8 *s, va_list *va)
Definition: std-formats.c:258
struct rte_mbuf mb
Definition: dpdk.h:439
u32 vlib_sw_if_index
Definition: dpdk.h:179
format_function_t format_vnet_sw_interface_name
u32 vlib_hw_if_index
Definition: dpdk.h:178
struct _unformat_input_t unformat_input_t
#define foreach_dpdk_counter
Definition: format.c:27
dpdk_port_type_t port_type
Definition: dpdk.h:235
static void unformat_put_input(unformat_input_t *input)
Definition: format.h:203
format_function_t * format_buffer
Definition: node.h:311
u16 tx_q_used
Definition: dpdk.h:212
u16 nb_rx_desc
Definition: dpdk.h:214
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
dpdk_device_t * devices
Definition: dpdk.h:355
vlib_main_t * vm
Definition: buffer.c:276
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:191
u8 * format_hexdump(u8 *s, va_list *va)
Definition: std-formats.c:281
struct rte_eth_xstat * xstats
Definition: dpdk.h:232
u8 * interface_name_suffix
Definition: dpdk.h:206
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
clib_error_t * unformat_rss_fn(unformat_input_t *input, uword *rss_fn)
Definition: format.c:706
#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:1688
struct rte_eth_link link
Definition: dpdk.h:226
u64 uword
Definition: types.h:112
vlib_buffer_t buffer
Definition: dpdk.h:440
static u8 * format_dpdk_device_type(u8 *s, va_list *args)
Definition: format.c:211
#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:506
#define foreach_dpdk_pkt_offload_flag
Definition: format.c:142
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
i8 cpu_socket
Definition: dpdk.h:192
static u8 * format_dpdk_link_status(u8 *s, va_list *args)
Definition: format.c:293
u16 nb_tx_desc
Definition: dpdk.h:203
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:971
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:413
u8 * format_dpdk_rx_dma_trace(u8 *s, va_list *va)
Definition: format.c:532
vlib_main_t * vlib_main
Definition: dpdk.h:411