FD.io VPP  v19.08.1-401-g8e4ed521a
Vector Packet Processing
format.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2018 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 
18 #include <sys/types.h>
19 #include <sys/stat.h>
20 #include <fcntl.h>
21 #include <sys/ioctl.h>
22 
23 #include <vlib/vlib.h>
24 #include <vlib/unix/unix.h>
25 #include <vppinfra/linux/syscall.h>
26 #include <vnet/plugin/plugin.h>
27 #include <marvell/pp2/pp2.h>
28 
29 static inline u32
30 mrvl_get_u32_bits (void *start, int offset, int first, int last)
31 {
32  u32 value = *(u32 *) (((u8 *) start) + offset);
33  if ((last == 0) && (first == 31))
34  return value;
35  value >>= last;
36  value &= (1 << (first - last + 1)) - 1;
37  return value;
38 }
39 
40 u8 *
41 format_mrvl_pp2_interface_name (u8 * s, va_list * args)
42 {
44  u32 dev_instance = va_arg (*args, u32);
45  mrvl_pp2_if_t *ppif = pool_elt_at_index (ppm->interfaces, dev_instance);
46  return format (s, "mv-ppio-%d/%d", ppif->ppio->pp2_id, ppif->ppio->port_id);
47 }
48 
49 #define foreach_ppio_statistics_entry \
50  _(rx_packets) \
51  _(rx_fullq_dropped) \
52  _(rx_bm_dropped) \
53  _(rx_early_dropped) \
54  _(rx_fifo_dropped) \
55  _(rx_cls_dropped) \
56  _(tx_packets)
57 
58 #define foreach_ppio_inq_statistics_entry \
59  _(enq_desc) \
60  _(drop_early) \
61  _(drop_fullq) \
62  _(drop_bm)
63 
64 #define foreach_ppio_outq_statistics_entry \
65  _(enq_desc) \
66  _(enq_dec_to_ddr) \
67  _(enq_buf_to_ddr) \
68  _(deq_desc)
69 
70 u8 *
71 format_mrvl_pp2_interface (u8 * s, va_list * args)
72 {
74  u32 dev_instance = va_arg (*args, u32);
75  u32 indent = format_get_indent (s);
76  mrvl_pp2_if_t *ppif = pool_elt_at_index (ppm->interfaces, dev_instance);
77  struct pp2_ppio_statistics stat;
78  int i;
79  u8 *s2 = 0;
80 
81  pp2_ppio_get_statistics (ppif->ppio, &stat, 0);
82 
83 #define _(c) if (stat.c) \
84  s2 = format (s2, "\n%U%-25U%16Ld", \
85  format_white_space, indent + 2, \
86  format_c_identifier, #c, stat.c);
88 
89  if (vec_len (s2))
90  s = format (s, "Interface statistics:%v", s2);
91  vec_reset_length (s2);
92 
93  vec_foreach_index (i, ppif->inqs)
94  {
95  struct pp2_ppio_inq_statistics stat = { 0 };
96  pp2_ppio_inq_get_statistics (ppif->ppio, 0, i, &stat, 0);
97 
99 
100  if (vec_len (s2))
101  s = format (s, "\n%UInput queue %u statistics:%v",
102  format_white_space, indent, i, s2);
103  vec_reset_length (s2);
104  }
105  vec_foreach_index (i, ppif->outqs)
106  {
107  struct pp2_ppio_outq_statistics stat = { 0 };
108 
109  pp2_ppio_outq_get_statistics (ppif->ppio, i, &stat, 0);
110 
112 
113  if (vec_len (s2))
114  s = format (s, "\n%UOutput queue %u statistics:%v",
115  format_white_space, indent, i, s2);
116  vec_reset_length (s2);
117  }
118 #undef _
119  vec_free (s2);
120  return s;
121 }
122 
123 #define foreach_pp2_rx_desc_field \
124  _(0x00, 6, 0, l3_offset) \
125  _(0x00, 12, 8, ip_hdlen) \
126  _(0x00, 14, 13, ec) \
127  _(0x00, 15, 15, es) \
128  _(0x00, 19, 16, pool_id) \
129  _(0x00, 21, 21, hwf_sync) \
130  _(0x00, 22, 22, l4_chk_ok) \
131  _(0x00, 23, 23, ip_frg) \
132  _(0x00, 24, 24, ipv4_hdr_err) \
133  _(0x00, 27, 25, l4_info) \
134  _(0x00, 30, 28, l3_info) \
135  _(0x00, 31, 31, buf_header) \
136  _(0x04, 5, 0, lookup_id) \
137  _(0x04, 8, 6, cpu_code) \
138  _(0x04, 9, 9, pppoe) \
139  _(0x04, 11, 10, l3_cast_info) \
140  _(0x04, 13, 12, l2_cast_info) \
141  _(0x04, 15, 14, vlan_info) \
142  _(0x04, 31, 16, byte_count) \
143  _(0x08, 11, 0, gem_port_id) \
144  _(0x08, 13, 12, color) \
145  _(0x08, 14, 14, gop_sop_u) \
146  _(0x08, 15, 15, key_hash_enable) \
147  _(0x08, 31, 16, l4chk) \
148  _(0x0c, 31, 0, timestamp) \
149  _(0x10, 31, 0, buf_phys_ptr_lo) \
150  _(0x14, 7, 0, buf_phys_ptr_hi) \
151  _(0x14, 31, 8, key_hash) \
152  _(0x18, 31, 0, buf_virt_ptr_lo) \
153  _(0x1c, 7, 0, buf_virt_ptr_hi) \
154  _(0x1c, 14, 8, buf_qset_no) \
155  _(0x1c, 15, 15, buf_type) \
156  _(0x1c, 21, 16, mod_dscp) \
157  _(0x1c, 24, 22, mod_pri) \
158  _(0x1c, 25, 25, mdscp) \
159  _(0x1c, 26, 26, mpri) \
160  _(0x1c, 27, 27, mgpid) \
161  _(0x1c, 31, 29, port_num)
162 
163 u8 *
164 format_mrvl_pp2_input_trace (u8 * s, va_list * args)
165 {
166  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
167  vlib_node_t *node = va_arg (*args, vlib_node_t *);
168  mrvl_pp2_input_trace_t *t = va_arg (*args, mrvl_pp2_input_trace_t *);
169  vnet_main_t *vnm = vnet_get_main ();
171  u32 indent = format_get_indent (s);
172  struct pp2_ppio_desc *d = &t->desc;
173  u32 r32;
174 
175  s = format (s, "pp2: %v (%d) next-node %U",
177  node->index, t->next_index);
178  s = format (s, "\n%U", format_white_space, indent + 2);
179 
180 #define _(a, b, c, n) \
181  r32 = mrvl_get_u32_bits (d, a, b, c); \
182  if (r32 > 9) \
183  s = format (s, "%s %u (0x%x)", #n, r32, r32); \
184  else \
185  s = format (s, "%s %u", #n,r32); \
186  if (format_get_indent (s) > 72) \
187  s = format (s, "\n%U", format_white_space, indent + 2); \
188  else s = format (s, " ");
189 
191 #undef _
192  return s;
193 }
194 
195 /*
196  * fd.io coding-style-patch-verification: ON
197  *
198  * Local Variables:
199  * eval: (c-set-style "gnu")
200  * End:
201  */
struct pp2_ppio * ppio
Definition: pp2.h:55
mrvl_pp2_outq_t * outqs
Definition: pp2.h:59
vmrglw vmrglh hi
#define vec_foreach_index(var, v)
Iterate over vector indices.
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
struct pp2_ppio_desc desc
Definition: pp2.h:129
u32 index
Definition: node.h:280
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
mrvl_pp2_main_t mrvl_pp2_main
Definition: pp2.c:36
static heap_elt_t * last(heap_header_t *h)
Definition: heap.c:53
int i
static u32 format_get_indent(u8 *s)
Definition: format.h:72
u8 * format_mrvl_pp2_interface_name(u8 *s, va_list *args)
Definition: format.c:41
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
unsigned char u8
Definition: types.h:56
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
u8 * format_mrvl_pp2_input_trace(u8 *s, va_list *args)
Definition: format.c:164
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
format_function_t format_vlib_next_node_name
Definition: node_funcs.h:1142
unsigned int u32
Definition: types.h:88
static heap_elt_t * first(heap_header_t *h)
Definition: heap.c:59
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
#define foreach_pp2_rx_desc_field
Definition: format.c:123
#define foreach_ppio_outq_statistics_entry
Definition: format.c:64
vlib_main_t * vm
Definition: buffer.c:323
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
#define foreach_ppio_inq_statistics_entry
Definition: format.c:58
u8 value
Definition: qos.api:53
static u32 mrvl_get_u32_bits(void *start, int offset, int first, int last)
Definition: format.c:30
template key/value backing page structure
Definition: bihash_doc.h:44
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define foreach_ppio_statistics_entry
Definition: format.c:49
struct clib_bihash_value offset
template key/value backing page structure
mrvl_pp2_if_t * interfaces
Definition: pp2.h:79
u8 * format_mrvl_pp2_interface(u8 *s, va_list *args)
Definition: format.c:71
mrvl_pp2_inq_t * inqs
Definition: pp2.h:58