FD.io VPP  v17.01-9-ge7dcee4
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 <vnet/devices/dpdk/dpdk.h>
23 
24 #include "dpdk_priv.h"
25 #include <vppinfra/error.h>
26 
27 #define foreach_dpdk_counter \
28  _ (tx_frames_ok, opackets) \
29  _ (tx_bytes_ok, obytes) \
30  _ (tx_errors, oerrors) \
31  _ (rx_frames_ok, ipackets) \
32  _ (rx_bytes_ok, ibytes) \
33  _ (rx_errors, ierrors) \
34  _ (rx_missed, imissed) \
35  _ (rx_no_bufs, rx_nombuf)
36 
37 #define foreach_dpdk_q_counter \
38  _ (rx_frames_ok, q_ipackets) \
39  _ (tx_frames_ok, q_opackets) \
40  _ (rx_bytes_ok, q_ibytes) \
41  _ (tx_bytes_ok, q_obytes) \
42  _ (rx_errors, q_errors)
43 
44 #define foreach_dpdk_rss_hf \
45  _(ETH_RSS_FRAG_IPV4, "ipv4-frag") \
46  _(ETH_RSS_NONFRAG_IPV4_TCP, "ipv4-tcp") \
47  _(ETH_RSS_NONFRAG_IPV4_UDP, "ipv4-udp") \
48  _(ETH_RSS_NONFRAG_IPV4_SCTP, "ipv4-sctp") \
49  _(ETH_RSS_NONFRAG_IPV4_OTHER, "ipv4-other") \
50  _(ETH_RSS_IPV4, "ipv4") \
51  _(ETH_RSS_IPV6_TCP_EX, "ipv6-tcp-ex") \
52  _(ETH_RSS_IPV6_UDP_EX, "ipv6-udp-ex") \
53  _(ETH_RSS_FRAG_IPV6, "ipv6-frag") \
54  _(ETH_RSS_NONFRAG_IPV6_TCP, "ipv6-tcp") \
55  _(ETH_RSS_NONFRAG_IPV6_UDP, "ipv6-udp") \
56  _(ETH_RSS_NONFRAG_IPV6_SCTP, "ipv6-sctp") \
57  _(ETH_RSS_NONFRAG_IPV6_OTHER, "ipv6-other") \
58  _(ETH_RSS_L2_PAYLOAD, "l2-payload") \
59  _(ETH_RSS_IPV6_EX, "ipv6-ex") \
60  _(ETH_RSS_IPV6, "ipv6")
61 
62 
63 #define foreach_dpdk_rx_offload_caps \
64  _(DEV_RX_OFFLOAD_VLAN_STRIP, "vlan-strip") \
65  _(DEV_RX_OFFLOAD_IPV4_CKSUM, "ipv4-cksum") \
66  _(DEV_RX_OFFLOAD_UDP_CKSUM , "udp-cksum") \
67  _(DEV_RX_OFFLOAD_TCP_CKSUM , "tcp-cksum") \
68  _(DEV_RX_OFFLOAD_TCP_LRO , "rcp-lro") \
69  _(DEV_RX_OFFLOAD_QINQ_STRIP, "qinq-strip")
70 
71 #define foreach_dpdk_tx_offload_caps \
72  _(DEV_TX_OFFLOAD_VLAN_INSERT, "vlan-insert") \
73  _(DEV_TX_OFFLOAD_IPV4_CKSUM, "ipv4-cksum") \
74  _(DEV_TX_OFFLOAD_UDP_CKSUM , "udp-cksum") \
75  _(DEV_TX_OFFLOAD_TCP_CKSUM , "tcp-cksum") \
76  _(DEV_TX_OFFLOAD_SCTP_CKSUM , "sctp-cksum") \
77  _(DEV_TX_OFFLOAD_TCP_TSO , "tcp-tso") \
78  _(DEV_TX_OFFLOAD_UDP_TSO , "udp-tso") \
79  _(DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM, "outer-ipv4-cksum") \
80  _(DEV_TX_OFFLOAD_QINQ_INSERT, "qinq-insert")
81 
82 #if RTE_VERSION < RTE_VERSION_NUM(16, 11, 0, 0)
83 /* New ol_flags bits added in DPDK-16.11 */
84 #define PKT_RX_IP_CKSUM_GOOD (1ULL << 7)
85 #define PKT_RX_L4_CKSUM_GOOD (1ULL << 8)
86 #endif
87 
88 #define foreach_dpdk_pkt_rx_offload_flag \
89  _ (PKT_RX_VLAN_PKT, "RX packet is a 802.1q VLAN packet") \
90  _ (PKT_RX_RSS_HASH, "RX packet with RSS hash result") \
91  _ (PKT_RX_FDIR, "RX packet with FDIR infos") \
92  _ (PKT_RX_L4_CKSUM_BAD, "L4 cksum of RX pkt. is not OK") \
93  _ (PKT_RX_IP_CKSUM_BAD, "IP cksum of RX pkt. is not OK") \
94  _ (PKT_RX_VLAN_STRIPPED, "RX packet VLAN tag stripped") \
95  _ (PKT_RX_IP_CKSUM_GOOD, "IP cksum of RX pkt. is valid") \
96  _ (PKT_RX_L4_CKSUM_GOOD, "L4 cksum of RX pkt. is valid") \
97  _ (PKT_RX_IEEE1588_PTP, "RX IEEE1588 L2 Ethernet PT Packet") \
98  _ (PKT_RX_IEEE1588_TMST, "RX IEEE1588 L2/L4 timestamped packet") \
99  _ (PKT_RX_QINQ_STRIPPED, "RX packet QinQ tags stripped")
100 
101 #if RTE_VERSION < RTE_VERSION_NUM(16, 11, 0, 0)
102 /* PTYPE added in DPDK-16.11 */
103 #define RTE_PTYPE_L2_ETHER_VLAN 0x00000006
104 #define RTE_PTYPE_L2_ETHER_QINQ 0x00000007
105 #endif
106 
107 #define foreach_dpdk_pkt_type \
108  _ (L2, ETHER, "Ethernet packet") \
109  _ (L2, ETHER_TIMESYNC, "Ethernet packet for time sync") \
110  _ (L2, ETHER_ARP, "ARP packet") \
111  _ (L2, ETHER_LLDP, "LLDP (Link Layer Discovery Protocol) packet") \
112  _ (L2, ETHER_NSH, "NSH (Network Service Header) packet") \
113  _ (L2, ETHER_VLAN, "VLAN packet") \
114  _ (L2, ETHER_QINQ, "QinQ packet") \
115  _ (L3, IPV4, "IPv4 packet without extension headers") \
116  _ (L3, IPV4_EXT, "IPv4 packet with extension headers") \
117  _ (L3, IPV4_EXT_UNKNOWN, "IPv4 packet with or without extension headers") \
118  _ (L3, IPV6, "IPv6 packet without extension headers") \
119  _ (L3, IPV6_EXT, "IPv6 packet with extension headers") \
120  _ (L3, IPV6_EXT_UNKNOWN, "IPv6 packet with or without extension headers") \
121  _ (L4, TCP, "TCP packet") \
122  _ (L4, UDP, "UDP packet") \
123  _ (L4, FRAG, "Fragmented IP packet") \
124  _ (L4, SCTP, "SCTP (Stream Control Transmission Protocol) packet") \
125  _ (L4, ICMP, "ICMP packet") \
126  _ (L4, NONFRAG, "Non-fragmented IP packet") \
127  _ (TUNNEL, GRE, "GRE tunneling packet") \
128  _ (TUNNEL, VXLAN, "VXLAN tunneling packet") \
129  _ (TUNNEL, NVGRE, "NVGRE Tunneling packet") \
130  _ (TUNNEL, GENEVE, "GENEVE Tunneling packet") \
131  _ (TUNNEL, GRENAT, "Teredo, VXLAN or GRE Tunneling packet") \
132  _ (INNER_L2, ETHER, "Inner Ethernet packet") \
133  _ (INNER_L2, ETHER_VLAN, "Inner Ethernet packet with VLAN") \
134  _ (INNER_L3, IPV4, "Inner IPv4 packet without extension headers") \
135  _ (INNER_L3, IPV4_EXT, "Inner IPv4 packet with extension headers") \
136  _ (INNER_L3, IPV4_EXT_UNKNOWN, "Inner IPv4 packet with or without extension headers") \
137  _ (INNER_L3, IPV6, "Inner IPv6 packet without extension headers") \
138  _ (INNER_L3, IPV6_EXT, "Inner IPv6 packet with extension headers") \
139  _ (INNER_L3, IPV6_EXT_UNKNOWN, "Inner IPv6 packet with or without extension headers") \
140  _ (INNER_L4, TCP, "Inner TCP packet") \
141  _ (INNER_L4, UDP, "Inner UDP packet") \
142  _ (INNER_L4, FRAG, "Inner fagmented IP packet") \
143  _ (INNER_L4, SCTP, "Inner SCTP (Stream Control Transmission Protocol) packet") \
144  _ (INNER_L4, ICMP, "Inner ICMP packet") \
145  _ (INNER_L4, NONFRAG, "Inner non-fragmented IP packet")
146 
147 #define foreach_dpdk_pkt_tx_offload_flag \
148  _ (PKT_TX_VLAN_PKT, "TX packet is a 802.1q VLAN packet") \
149  _ (PKT_TX_IP_CKSUM, "IP cksum of TX pkt. computed by NIC") \
150  _ (PKT_TX_TCP_CKSUM, "TCP cksum of TX pkt. computed by NIC") \
151  _ (PKT_TX_SCTP_CKSUM, "SCTP cksum of TX pkt. computed by NIC") \
152  _ (PKT_TX_IEEE1588_TMST, "TX IEEE1588 packet to timestamp")
153 
154 #define foreach_dpdk_pkt_offload_flag \
155  foreach_dpdk_pkt_rx_offload_flag \
156  foreach_dpdk_pkt_tx_offload_flag
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 = "TenGigabitEthernet";
181  break;
182 
184  device_name = "FortyGigabitEthernet";
185  break;
186 
188  return format (s, "BondEthernet%d", dm->devices[i].device_index);
189 
191  device_name = "EthernetSwitch";
192  break;
193 
195  rte_eth_dev_info_get (i, &dev_info);
196  return format (s, "af_packet%d", dm->devices[i].af_packet_port_id);
197 
198  default:
200  device_name = "UnknownEthernet";
201  break;
202  }
203 
204  rte_eth_dev_info_get (i, &dev_info);
205 
206  if (dev_info.pci_dev)
207  ret = format (s, devname_format, device_name, dev_info.pci_dev->addr.bus,
208  dev_info.pci_dev->addr.devid,
209  dev_info.pci_dev->addr.function);
210  else
211  ret = format (s, "%s%d", device_name, dm->devices[i].device_index);
212 
213  if (dm->devices[i].interface_name_suffix)
214  return format (ret, "/%s", dm->devices[i].interface_name_suffix);
215  return ret;
216 }
217 
218 static u8 *
219 format_dpdk_device_type (u8 * s, va_list * args)
220 {
221  dpdk_main_t *dm = &dpdk_main;
222  char *dev_type;
223  u32 i = va_arg (*args, u32);
224 
225  switch (dm->devices[i].pmd)
226  {
227  case VNET_DPDK_PMD_E1000EM:
228  dev_type = "Intel 82540EM (e1000)";
229  break;
230 
231  case VNET_DPDK_PMD_IGB:
232  dev_type = "Intel e1000";
233  break;
234 
235  case VNET_DPDK_PMD_I40E:
236  dev_type = "Intel X710/XL710 Family";
237  break;
238 
239  case VNET_DPDK_PMD_I40EVF:
240  dev_type = "Intel X710/XL710 Family VF";
241  break;
242 
243  case VNET_DPDK_PMD_FM10K:
244  dev_type = "Intel FM10000 Family Ethernet Switch";
245  break;
246 
247  case VNET_DPDK_PMD_IGBVF:
248  dev_type = "Intel e1000 VF";
249  break;
250 
251  case VNET_DPDK_PMD_VIRTIO:
252  dev_type = "Red Hat Virtio";
253  break;
254 
255  case VNET_DPDK_PMD_IXGBEVF:
256  dev_type = "Intel 82599 VF";
257  break;
258 
259  case VNET_DPDK_PMD_IXGBE:
260  dev_type = "Intel 82599";
261  break;
262 
263  case VNET_DPDK_PMD_ENIC:
264  dev_type = "Cisco VIC";
265  break;
266 
267  case VNET_DPDK_PMD_CXGBE:
268  dev_type = "Chelsio T4/T5";
269  break;
270 
271  case VNET_DPDK_PMD_VMXNET3:
272  dev_type = "VMware VMXNET3";
273  break;
274 
275  case VNET_DPDK_PMD_AF_PACKET:
276  dev_type = "af_packet";
277  break;
278 
279  case VNET_DPDK_PMD_BOND:
280  dev_type = "Ethernet Bonding";
281  break;
282 
283  case VNET_DPDK_PMD_DPAA2:
284  dev_type = "NXP DPAA2 Mac";
285  break;
286 
287  default:
289  dev_type = "### UNKNOWN ###";
290  break;
291  }
292 
293  return format (s, dev_type);
294 }
295 
296 static u8 *
297 format_dpdk_link_status (u8 * s, va_list * args)
298 {
299  dpdk_device_t *xd = va_arg (*args, dpdk_device_t *);
300  struct rte_eth_link *l = &xd->link;
301  vnet_main_t *vnm = vnet_get_main ();
303 
304  s = format (s, "%s ", l->link_status ? "up" : "down");
305  if (l->link_status)
306  {
307  u32 promisc = rte_eth_promiscuous_get (xd->device_index);
308 
309  s = format (s, "%s duplex ", (l->link_duplex == ETH_LINK_FULL_DUPLEX) ?
310  "full" : "half");
311  s = format (s, "speed %u mtu %d %s\n", l->link_speed,
312  hi->max_packet_bytes, promisc ? " promisc" : "");
313  }
314  else
315  s = format (s, "\n");
316 
317  return s;
318 }
319 
320 #define _line_len 72
321 #define _(v, str) \
322 if (bitmap & v) { \
323  if (format_get_indent (s) > next_split ) { \
324  next_split += _line_len; \
325  s = format(s,"\n%U", format_white_space, indent); \
326  } \
327  s = format(s, "%s ", str); \
328 }
329 
330 static u8 *
331 format_dpdk_rss_hf_name (u8 * s, va_list * args)
332 {
333  u64 bitmap = va_arg (*args, u64);
334  int next_split = _line_len;
335  int indent = format_get_indent (s);
336 
337  if (!bitmap)
338  return format (s, "none");
339 
340  foreach_dpdk_rss_hf return s;
341 }
342 
343 static u8 *
344 format_dpdk_rx_offload_caps (u8 * s, va_list * args)
345 {
346  u32 bitmap = va_arg (*args, u32);
347  int next_split = _line_len;
348  int indent = format_get_indent (s);
349 
350  if (!bitmap)
351  return format (s, "none");
352 
354 }
355 
356 static u8 *
357 format_dpdk_tx_offload_caps (u8 * s, va_list * args)
358 {
359  u32 bitmap = va_arg (*args, u32);
360  int next_split = _line_len;
361  int indent = format_get_indent (s);
362  if (!bitmap)
363  return format (s, "none");
364 
366 }
367 
368 #undef _line_len
369 #undef _
370 
371 u8 *
372 format_dpdk_device (u8 * s, va_list * args)
373 {
374  u32 dev_instance = va_arg (*args, u32);
375  int verbose = va_arg (*args, int);
376  dpdk_main_t *dm = &dpdk_main;
377  dpdk_device_t *xd = vec_elt_at_index (dm->devices, dev_instance);
378  uword indent = format_get_indent (s);
379  f64 now = vlib_time_now (dm->vlib_main);
380  struct rte_eth_dev_info di;
381 
382  dpdk_update_counters (xd, now);
383  dpdk_update_link_state (xd, now);
384 
385  s = format (s, "%U\n%Ucarrier %U",
388 
389  rte_eth_dev_info_get (xd->device_index, &di);
390 
391  if (verbose > 1 && xd->flags & DPDK_DEVICE_FLAG_PMD)
392  {
393  struct rte_pci_device *pci;
394  struct rte_eth_rss_conf rss_conf;
395  int vlan_off;
396  int retval;
397 
398  rss_conf.rss_key = 0;
399  retval = rte_eth_dev_rss_hash_conf_get (xd->device_index, &rss_conf);
400  if (retval < 0)
401  clib_warning ("rte_eth_dev_rss_hash_conf_get returned %d", retval);
402  pci = di.pci_dev;
403 
404  if (pci)
405  s =
406  format (s,
407  "%Upci id: device %04x:%04x subsystem %04x:%04x\n"
408  "%Upci address: %04x:%02x:%02x.%02x\n",
409  format_white_space, indent + 2, pci->id.vendor_id,
410  pci->id.device_id, pci->id.subsystem_vendor_id,
411  pci->id.subsystem_device_id, format_white_space, indent + 2,
412  pci->addr.domain, pci->addr.bus, pci->addr.devid,
413  pci->addr.function);
414  s =
415  format (s, "%Umax rx packet len: %d\n", format_white_space,
416  indent + 2, di.max_rx_pktlen);
417  s =
418  format (s, "%Umax num of queues: rx %d tx %d\n", format_white_space,
419  indent + 2, di.max_rx_queues, di.max_tx_queues);
420  s =
421  format (s, "%Upromiscuous: unicast %s all-multicast %s\n",
422  format_white_space, indent + 2,
423  rte_eth_promiscuous_get (xd->device_index) ? "on" : "off",
424  rte_eth_promiscuous_get (xd->device_index) ? "on" : "off");
425  vlan_off = rte_eth_dev_get_vlan_offload (xd->device_index);
426  s = format (s, "%Uvlan offload: strip %s filter %s qinq %s\n",
427  format_white_space, indent + 2,
428  vlan_off & ETH_VLAN_STRIP_OFFLOAD ? "on" : "off",
429  vlan_off & ETH_VLAN_FILTER_OFFLOAD ? "on" : "off",
430  vlan_off & ETH_VLAN_EXTEND_OFFLOAD ? "on" : "off");
431  s = format (s, "%Urx offload caps: %U\n",
432  format_white_space, indent + 2,
433  format_dpdk_rx_offload_caps, di.rx_offload_capa);
434  s = format (s, "%Utx offload caps: %U\n",
435  format_white_space, indent + 2,
436  format_dpdk_tx_offload_caps, di.tx_offload_capa);
437  s = format (s, "%Urss active: %U\n"
438  "%Urss supported: %U\n",
439  format_white_space, indent + 2,
440  format_dpdk_rss_hf_name, rss_conf.rss_hf,
441  format_white_space, indent + 2,
442  format_dpdk_rss_hf_name, di.flow_type_rss_offloads);
443  }
444 
445  s = format (s, "%Urx queues %d, rx desc %d, tx queues %d, tx desc %d\n",
446  format_white_space, indent + 2,
447  xd->rx_q_used, xd->nb_rx_desc, xd->tx_q_used, xd->nb_tx_desc);
448 
449  if (xd->cpu_socket > -1)
450  s = format (s, "%Ucpu socket %d\n",
451  format_white_space, indent + 2, xd->cpu_socket);
452 
453  /* $$$ MIB counters */
454  {
455 #define _(N, V) \
456  if ((xd->stats.V - xd->last_cleared_stats.V) != 0) { \
457  s = format (s, "\n%U%-40U%16Ld", \
458  format_white_space, indent + 2, \
459  format_c_identifier, #N, \
460  xd->stats.V - xd->last_cleared_stats.V); \
461  } \
462 
464 #undef _
465  }
466 
467  u8 *xs = 0;
468  u32 i = 0;
469  struct rte_eth_xstat *xstat, *last_xstat;
470  struct rte_eth_xstat_name *xstat_names = 0;
471  int len = rte_eth_xstats_get_names (xd->device_index, NULL, 0);
472  vec_validate (xstat_names, len - 1);
473  rte_eth_xstats_get_names (xd->device_index, xstat_names, len);
474 
476 
477  /* *INDENT-OFF* */
478  vec_foreach_index(i, xd->xstats)
479  {
480  u64 delta = 0;
481  xstat = vec_elt_at_index(xd->xstats, i);
482  last_xstat = vec_elt_at_index(xd->last_cleared_xstats, i);
483 
484  delta = xstat->value - last_xstat->value;
485  if (verbose == 2 || (verbose && delta))
486  {
487  /* format_c_identifier doesn't like c strings inside vector */
488  u8 * name = format(0,"%s", xstat_names[i].name);
489  xs = format(xs, "\n%U%-38U%16Ld",
490  format_white_space, indent + 4,
491  format_c_identifier, name, delta);
492  vec_free(name);
493  }
494  }
495  /* *INDENT-ON* */
496 
497  vec_free (xstat_names);
498 
499  if (xs)
500  {
501  s = format (s, "\n%Uextended stats:%v",
502  format_white_space, indent + 2, xs);
503  vec_free (xs);
504  }
505 
506  return s;
507 }
508 
509 u8 *
510 format_dpdk_tx_dma_trace (u8 * s, va_list * va)
511 {
512  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
513  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
515  dpdk_tx_dma_trace_t *t = va_arg (*va, dpdk_tx_dma_trace_t *);
516  dpdk_main_t *dm = &dpdk_main;
518  uword indent = format_get_indent (s);
520 
521  s = format (s, "%U tx queue %d",
523 
524  s = format (s, "\n%Ubuffer 0x%x: %U",
525  format_white_space, indent,
527 
528  s = format (s, "\n%U%U", format_white_space, indent,
530  sizeof (t->buffer.pre_data));
531 
532  return s;
533 }
534 
535 u8 *
536 format_dpdk_rx_dma_trace (u8 * s, va_list * va)
537 {
538  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
539  CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
541  dpdk_rx_dma_trace_t *t = va_arg (*va, dpdk_rx_dma_trace_t *);
542  dpdk_main_t *dm = &dpdk_main;
545  uword indent = format_get_indent (s);
547 
548  s = format (s, "%U rx queue %d",
550 
551  s = format (s, "\n%Ubuffer 0x%x: %U",
552  format_white_space, indent,
554 
555  s = format (s, "\n%U%U",
556  format_white_space, indent,
557  format_dpdk_rte_mbuf, &t->mb, &t->data);
558 
559  if (vm->trace_main.verbose)
560  {
561  s = format (s, "\n%UPacket Dump%s", format_white_space, indent + 2,
562  t->mb.data_len > sizeof (t->data) ? " (truncated)" : "");
563  s = format (s, "\n%U%U", format_white_space, indent + 4,
564  format_hexdump, &t->data,
565  t->mb.data_len >
566  sizeof (t->data) ? sizeof (t->data) : t->mb.data_len);
567  }
568  f = node->format_buffer;
569  if (!f)
570  f = format_hex_bytes;
571  s = format (s, "\n%U%U", format_white_space, indent,
572  f, t->buffer.pre_data, sizeof (t->buffer.pre_data));
573 
574  return s;
575 }
576 
577 
578 static inline u8 *
579 format_dpdk_pkt_types (u8 * s, va_list * va)
580 {
581  u32 *pkt_types = va_arg (*va, u32 *);
582  uword indent __attribute__ ((unused)) = format_get_indent (s) + 2;
583 
584  if (!*pkt_types)
585  return s;
586 
587  s = format (s, "Packet Types");
588 
589 #define _(L, F, S) \
590  if ((*pkt_types & RTE_PTYPE_##L##_MASK) == RTE_PTYPE_##L##_##F) \
591  { \
592  s = format (s, "\n%U%s (0x%04x) %s", format_white_space, indent, \
593  "RTE_PTYPE_" #L "_" #F, RTE_PTYPE_##L##_##F, S); \
594  }
595 
597 #undef _
598  return s;
599 }
600 
601 static inline u8 *
603 {
604  u64 *ol_flags = va_arg (*va, u64 *);
605  uword indent = format_get_indent (s) + 2;
606 
607  if (!*ol_flags)
608  return s;
609 
610  s = format (s, "Packet Offload Flags");
611 
612 #define _(F, S) \
613  if (*ol_flags & F) \
614  { \
615  s = format (s, "\n%U%s (0x%04x) %s", \
616  format_white_space, indent, #F, F, S); \
617  }
618 
620 #undef _
621  return s;
622 }
623 
624 u8 *
625 format_dpdk_rte_mbuf_vlan (u8 * s, va_list * va)
626 {
627  ethernet_vlan_header_tv_t *vlan_hdr =
628  va_arg (*va, ethernet_vlan_header_tv_t *);
629 
630  if (clib_net_to_host_u16 (vlan_hdr->type) == ETHERNET_TYPE_DOT1AD)
631  {
632  s = format (s, "%U 802.1q vlan ",
634  clib_net_to_host_u16 (vlan_hdr->priority_cfi_and_id));
635  vlan_hdr++;
636  }
637 
638  s = format (s, "%U",
640  clib_net_to_host_u16 (vlan_hdr->priority_cfi_and_id));
641 
642  return s;
643 }
644 
645 u8 *
646 format_dpdk_rte_mbuf (u8 * s, va_list * va)
647 {
648  struct rte_mbuf *mb = va_arg (*va, struct rte_mbuf *);
649  ethernet_header_t *eth_hdr = va_arg (*va, ethernet_header_t *);
650  uword indent = format_get_indent (s) + 2;
651 
652  s = format (s, "PKT MBUF: port %d, nb_segs %d, pkt_len %d"
653  "\n%Ubuf_len %d, data_len %d, ol_flags 0x%x, data_off %d, phys_addr 0x%x"
654  "\n%Upacket_type 0x%x",
655  mb->port, mb->nb_segs, mb->pkt_len,
656  format_white_space, indent,
657  mb->buf_len, mb->data_len, mb->ol_flags, mb->data_off,
658  mb->buf_physaddr, format_white_space, indent, mb->packet_type);
659 
660  if (mb->ol_flags)
661  s = format (s, "\n%U%U", format_white_space, indent,
662  format_dpdk_pkt_offload_flags, &mb->ol_flags);
663 
664  if ((mb->ol_flags & PKT_RX_VLAN_PKT) &&
665  ((mb->ol_flags & (PKT_RX_VLAN_STRIPPED | PKT_RX_QINQ_STRIPPED)) == 0))
666  {
667  ethernet_vlan_header_tv_t *vlan_hdr =
668  ((ethernet_vlan_header_tv_t *) & (eth_hdr->type));
669  s = format (s, " %U", format_dpdk_rte_mbuf_vlan, vlan_hdr);
670  }
671 
672  if (mb->packet_type)
673  s = format (s, "\n%U%U", format_white_space, indent,
674  format_dpdk_pkt_types, &mb->packet_type);
675 
676  return s;
677 }
678 
679 uword
680 unformat_socket_mem (unformat_input_t * input, va_list * va)
681 {
682  uword **r = va_arg (*va, uword **);
683  int i = 0;
684  u32 mem;
685 
687  {
688  if (unformat (input, ","))
689  hash_set (*r, i, 1024);
690  else if (unformat (input, "%u,", &mem))
691  hash_set (*r, i, mem);
692  else if (unformat (input, "%u", &mem))
693  hash_set (*r, i, mem);
694  else
695  {
696  unformat_put_input (input);
697  goto done;
698  }
699  i++;
700  }
701 
702 done:
703  return 1;
704 }
705 
706 clib_error_t *
708 {
710  {
711  if (0)
712  ;
713 #undef _
714 #define _(f, s) \
715  else if (unformat (input, s)) \
716  *rss_fn |= f;
717 
719 #undef _
720  else
721  {
722  return clib_error_return (0, "unknown input `%U'",
723  format_unformat_error, input);
724  }
725  }
726  return 0;
727 }
728 
729 clib_error_t *
731 {
732  clib_error_t *error = 0;
733 
735  {
736  if (unformat (input, "hqos-thread %u", &hqos->hqos_thread))
737  hqos->hqos_thread_valid = 1;
738  else
739  {
740  error = clib_error_return (0, "unknown input `%U'",
741  format_unformat_error, input);
742  break;
743  }
744  }
745 
746  return error;
747 }
748 
749 /*
750  * fd.io coding-style-patch-verification: ON
751  *
752  * Local Variables:
753  * eval: (c-set-style "gnu")
754  * End:
755  */
#define foreach_dpdk_pkt_offload_flag
Definition: format.c:154
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:396
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
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
vlib_buffer_t buffer
Definition: dpdk.h:437
u8 interface_name_format_decimal
Definition: dpdk.h:349
dpdk_main_t dpdk_main
Definition: dpdk.h:428
format_function_t format_vlib_buffer
Definition: buffer_funcs.h:532
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
#define NULL
Definition: clib.h:55
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:182
u16 flags
Definition: dpdk.h:191
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u8 * format_c_identifier(u8 *s, va_list *va)
Definition: std-formats.c:258
u8 * format_dpdk_rte_mbuf_vlan(u8 *s, va_list *va)
Definition: format.c:625
u8 * format_dpdk_tx_dma_trace(u8 *s, va_list *va)
Definition: format.c:510
static void unformat_put_input(unformat_input_t *input)
Definition: format.h:203
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
struct rte_eth_xstat * last_cleared_xstats
Definition: dpdk.h:230
u8 * format_ethernet_vlan_tci(u8 *s, va_list *va)
Definition: format.c:73
clib_error_t * unformat_hqos(unformat_input_t *input, dpdk_device_config_hqos_t *hqos)
Definition: format.c:730
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:115
static u8 * format_dpdk_device_type(u8 *s, va_list *args)
Definition: format.c:219
#define DPDK_DEVICE_FLAG_PMD
Definition: dpdk.h:194
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
u8 data[256]
Definition: dpdk.h:447
static u8 * format_dpdk_rx_offload_caps(u8 *s, va_list *args)
Definition: format.c:344
static u8 * format_dpdk_pkt_offload_flags(u8 *s, va_list *va)
Definition: format.c:602
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
#define foreach_dpdk_rx_offload_caps
Definition: format.c:63
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u8 * format_hex_bytes(u8 *s, va_list *va)
Definition: std-formats.c:84
u16 rx_q_used
Definition: dpdk.h:210
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
Definition: buffer.h:150
#define clib_warning(format, args...)
Definition: error.h:59
unsigned long u64
Definition: types.h:89
#define foreach_dpdk_pkt_type
Definition: format.c:107
u32 device_index
Definition: dpdk.h:173
#define foreach_dpdk_counter
Definition: format.c:27
struct rte_mbuf mb
Definition: dpdk.h:445
u32 vlib_sw_if_index
Definition: dpdk.h:176
format_function_t format_vnet_sw_interface_name
static uword format_get_indent(u8 *s)
Definition: format.h:72
u32 vlib_hw_if_index
Definition: dpdk.h:175
clib_error_t * unformat_rss_fn(unformat_input_t *input, uword *rss_fn)
Definition: format.c:707
static u8 * format_dpdk_rss_hf_name(u8 *s, va_list *args)
Definition: format.c:331
#define foreach_dpdk_rss_hf
Definition: format.c:44
dpdk_port_type_t port_type
Definition: dpdk.h:232
format_function_t * format_buffer
Definition: node.h:311
u16 tx_q_used
Definition: dpdk.h:209
u16 nb_rx_desc
Definition: dpdk.h:211
static u8 * format_dpdk_link_status(u8 *s, va_list *args)
Definition: format.c:297
u8 * format_dpdk_device_name(u8 *s, va_list *args)
Definition: format.c:159
static u8 * format_dpdk_pkt_types(u8 *s, va_list *va)
Definition: format.c:579
dpdk_device_t * devices
Definition: dpdk.h:364
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:80
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
u8 * format_hexdump(u8 *s, va_list *va)
Definition: std-formats.c:281
dpdk_pmd_t pmd
Definition: dpdk.h:188
u8 * format_dpdk_rte_mbuf(u8 *s, va_list *va)
Definition: format.c:646
struct rte_eth_xstat * xstats
Definition: dpdk.h:229
u8 * interface_name_suffix
Definition: dpdk.h:203
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
u8 af_packet_port_id
Definition: dpdk.h:221
vlib_trace_main_t trace_main
Definition: main.h:121
void dpdk_update_link_state(dpdk_device_t *xd, f64 now)
Definition: init.c:1395
struct rte_eth_link link
Definition: dpdk.h:223
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
uword unformat_socket_mem(unformat_input_t *input, va_list *va)
Definition: format.c:680
u64 uword
Definition: types.h:112
vlib_buffer_t buffer
Definition: dpdk.h:446
#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
static u8 * format_dpdk_tx_offload_caps(u8 *s, va_list *args)
Definition: format.c:357
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
u8 * format_dpdk_rx_dma_trace(u8 *s, va_list *va)
Definition: format.c:536
i8 cpu_socket
Definition: dpdk.h:189
#define clib_error_return(e, args...)
Definition: error.h:111
struct _unformat_input_t unformat_input_t
u8 * format_dpdk_device(u8 *s, va_list *args)
Definition: format.c:372
u16 nb_tx_desc
Definition: dpdk.h:200
#define foreach_dpdk_tx_offload_caps
Definition: format.c:71
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
dpdk_config_main_t * conf
Definition: dpdk.h:425
vlib_main_t * vlib_main
Definition: dpdk.h:423