summaryrefslogtreecommitdiffstats
path: root/src/plugins/dev_iavf/format.c
blob: b4a29e4e20a1f637088b6372cc3925eb618f684c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* SPDX-License-Identifier: Apache-2.0
 * Copyright (c) 2023 Cisco Systems, Inc.
 */

#include <vnet/vnet.h>
#include <vnet/dev/dev.h>
#include <vnet/dev/counters.h>
#include <dev_iavf/iavf.h>
#include <dev_iavf/virtchnl.h>

u8 *
format_iavf_vf_cap_flags (u8 *s, va_list *args)
{
  u32 flags = va_arg (*args, u32);
  int not_first = 0;

  char *strs[32] = {
#define _(a, b, c) [a] = c,
    foreach_iavf_vf_cap_flag
#undef _
  };

  for (int i = 0; i < 32; i++)
    {
      if ((flags & (1 << i)) == 0)
	continue;
      if (not_first)
	s = format (s, " ");
      if (strs[i])
	s = format (s, "%s", strs[i]);
      else
	s = format (s, "unknown(%u)", i);
      not_first = 1;
    }
  return s;
}

u8 *
format_iavf_rx_desc_qw1 (u8 *s, va_list *args)
{
  iavf_rx_desc_qw1_t *qw1 = va_arg (*args, iavf_rx_desc_qw1_t *);
  s = format (s, "len %u ptype %u ubmcast %u fltstat %u flags", qw1->length,
	      qw1->ptype, qw1->ubmcast, qw1->fltstat);

#define _(f)                                                                  \
  if (qw1->f)                                                                 \
  s = format (s, " " #f)

  _ (dd);
  _ (eop);
  _ (l2tag1p);
  _ (l3l4p);
  _ (crcp);
  _ (flm);
  _ (lpbk);
  _ (ipv6exadd);
  _ (int_udp_0);
  _ (ipe);
  _ (l4e);
  _ (oversize);
#undef _
  return s;
}

u8 *
format_iavf_rx_trace (u8 *s, va_list *args)
{
  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
  vlib_node_t *node = va_arg (*args, vlib_node_t *);
  iavf_rx_trace_t *t = va_arg (*args, iavf_rx_trace_t *);
  iavf_rx_desc_qw1_t *qw1;
  vnet_main_t *vnm = vnet_get_main ();
  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, t->hw_if_index);
  u32 indent = format_get_indent (s);
  int i = 0;

  s = format (s, "avf: %v (%d) qid %u next-node %U flow-id %u", hi->name,
	      t->hw_if_index, t->qid, format_vlib_next_node_name, vm,
	      node->index, t->next_index, t->flow_id);

  qw1 = (iavf_rx_desc_qw1_t *) t->qw1s;

  do
    s = format (s, "\n%Udesc %u: %U", format_white_space, indent + 2, i,
		format_iavf_rx_desc_qw1, qw1 + i);
  while ((qw1[i++].eop) == 0 && i < IAVF_RX_MAX_DESC_IN_CHAIN);

  return s;
}

u8 *
format_iavf_port_status (u8 *s, va_list *args)
{
  vnet_dev_format_args_t __clib_unused *a =
    va_arg (*args, vnet_dev_format_args_t *);
  vnet_dev_port_t *port = va_arg (*args, vnet_dev_port_t *);
  iavf_port_t *ap = vnet_dev_get_port_data (port);
  u32 indent = format_get_indent (s);

  s = format (s, "caps: %U", format_iavf_vf_cap_flags, ap->vf_cap_flags);
  s = format (s, "\n%Uvsi is %u, RSS key size is %u, RSS lut size is %u",
	      format_white_space, indent, ap->vsi_id, ap->rss_key_size,
	      ap->rss_lut_size);
  s = format (s, "\n%Uflow offload ", format_white_space, indent);
  if (ap->flow_offload)
    s = format (s, "enabled, %u flows configured",
		vec_len (ap->flow_lookup_entries));
  else
    s = format (s, "disabled");
  return s;
}