FD.io VPP  v21.06-1-gbb7418cf9
Vector Packet Processing
buffer.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 
16 #include <vlib/vlib.h>
17 #include <vnet/buffer.h>
18 
19 u8 *
20 format_vnet_buffer_offload (u8 *s, va_list *args)
21 {
22  vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *);
23 
24 #define _(bit, name, ss, v) \
25  if (v && (vnet_buffer (b)->oflags & VNET_BUFFER_OFFLOAD_F_##name)) \
26  s = format (s, "%s ", ss);
28 #undef _
29  return s;
30 }
31 
32 u8 *
33 format_vnet_buffer (u8 * s, va_list * args)
34 {
35  vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *);
36  u32 indent = format_get_indent (s);
37  u8 *a = 0;
38 
39 #define _(bit,name,ss,v) \
40  if (v && (b->flags & VNET_BUFFER_F_##name)) \
41  a = format (a, "%s ", ss);
43 #undef _
44  if (b->flags & VNET_BUFFER_F_OFFLOAD) a =
45  format (a, "%U ", format_vnet_buffer_offload, b);
46 
47  if (b->flags & VNET_BUFFER_F_L2_HDR_OFFSET_VALID)
48  a = format (a, "l2-hdr-offset %d ", vnet_buffer (b)->l2_hdr_offset);
49 
50  if (b->flags & VNET_BUFFER_F_L3_HDR_OFFSET_VALID)
51  a = format (a, "l3-hdr-offset %d ", vnet_buffer (b)->l3_hdr_offset);
52 
53  if (b->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID)
54  a = format (a, "l4-hdr-offset %d ", vnet_buffer (b)->l4_hdr_offset);
55 
56  if (b->flags & VNET_BUFFER_F_GSO)
57  a = format (a, "gso gso-size %d", vnet_buffer2 (b)->gso_size);
58 
59  if (b->flags & VNET_BUFFER_F_QOS_DATA_VALID)
60  a = format (a, "qos %d.%d ",
61  vnet_buffer2 (b)->qos.bits, vnet_buffer2 (b)->qos.source);
62 
63  if (b->flags & VNET_BUFFER_F_LOOP_COUNTER_VALID)
64  a = format (a, "loop-counter %d ", vnet_buffer2 (b)->loop_counter);
65 
66  s = format (s, "%U", format_vlib_buffer_no_chain, b);
67  if (a)
68  s = format (s, "\n%U%v", format_white_space, indent, a);
69  vec_free (a);
70 
71  return s;
72 }
73 
74 
75 /*
76  * fd.io coding-style-patch-verification: ON
77  *
78  * Local Variables:
79  * eval: (c-set-style "gnu")
80  * End:
81  */
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:133
a
Definition: bitmap.h:544
#define vnet_buffer2(b)
Definition: buffer.h:499
u8 * format_vnet_buffer_offload(u8 *s, va_list *args)
Definition: buffer.c:20
static u32 format_get_indent(u8 *s)
Definition: format.h:72
unsigned char u8
Definition: types.h:56
vlib_buffer_t ** b
unsigned int u32
Definition: types.h:88
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
u8 * format_vnet_buffer(u8 *s, va_list *args)
Definition: buffer.c:33
description fragment has unexpected format
Definition: map.api:433
u8 * format_vlib_buffer_no_chain(u8 *s, va_list *args)
Definition: buffer.c:95
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:395
VLIB buffer representation.
Definition: buffer.h:111
#define vnet_buffer(b)
Definition: buffer.h:437