Line data Source code
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 112 : format_vnet_buffer_offload (u8 *s, va_list *args)
21 : {
22 112 : 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);
27 112 : foreach_vnet_buffer_offload_flag
28 : #undef _
29 :
30 112 : if (vnet_buffer (b)->oflags & VNET_BUFFER_OFFLOAD_F_TNL_MASK)
31 : {
32 0 : s = format (s, "outer-l3-hdr-offset %d ",
33 0 : vnet_buffer2 (b)->outer_l3_hdr_offset);
34 0 : s = format (s, "outer-l4-hdr-offset %d ",
35 0 : vnet_buffer2 (b)->outer_l4_hdr_offset);
36 : }
37 112 : return s;
38 : }
39 :
40 : static u8 *
41 648390 : format_vnet_buffer_internal (u8 *s, vlib_buffer_t *b, int no_chain)
42 : {
43 648390 : u32 indent = format_get_indent (s);
44 648390 : u8 *a = 0;
45 :
46 : #define _(bit,name,ss,v) \
47 : if (v && (b->flags & VNET_BUFFER_F_##name)) \
48 : a = format (a, "%s ", ss);
49 648390 : foreach_vnet_buffer_flag
50 : #undef _
51 648502 : if (b->flags & VNET_BUFFER_F_OFFLOAD) a =
52 112 : format (a, "%U ", format_vnet_buffer_offload, b);
53 :
54 648390 : if (b->flags & VNET_BUFFER_F_L2_HDR_OFFSET_VALID)
55 307605 : a = format (a, "l2-hdr-offset %d ", vnet_buffer (b)->l2_hdr_offset);
56 :
57 648390 : if (b->flags & VNET_BUFFER_F_L3_HDR_OFFSET_VALID)
58 309430 : a = format (a, "l3-hdr-offset %d ", vnet_buffer (b)->l3_hdr_offset);
59 :
60 648390 : if (b->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID)
61 4410 : a = format (a, "l4-hdr-offset %d ", vnet_buffer (b)->l4_hdr_offset);
62 :
63 648390 : if (b->flags & VNET_BUFFER_F_GSO)
64 295 : a = format (a, "gso l4-hdr-len %d gso-size %d",
65 295 : vnet_buffer2 (b)->gso_l4_hdr_sz, vnet_buffer2 (b)->gso_size);
66 :
67 648390 : if (b->flags & VNET_BUFFER_F_QOS_DATA_VALID)
68 1234 : a = format (a, "qos %d.%d ",
69 1234 : vnet_buffer2 (b)->qos.bits, vnet_buffer2 (b)->qos.source);
70 :
71 648390 : if (b->flags & VNET_BUFFER_F_LOOP_COUNTER_VALID)
72 1906 : a = format (a, "loop-counter %d ", vnet_buffer2 (b)->loop_counter);
73 :
74 648390 : s = format (s, "%U",
75 : no_chain ? format_vlib_buffer_no_chain : format_vlib_buffer, b);
76 648390 : if (a)
77 309870 : s = format (s, "\n%U%v", format_white_space, indent, a);
78 648390 : vec_free (a);
79 :
80 648390 : return s;
81 : }
82 :
83 : u8 *
84 648390 : format_vnet_buffer_no_chain (u8 *s, va_list *args)
85 : {
86 648390 : vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *);
87 648390 : return format_vnet_buffer_internal (s, b, 1 /* no_chain */);
88 : }
89 :
90 : u8 *
91 0 : format_vnet_buffer (u8 *s, va_list *args)
92 : {
93 0 : vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *);
94 0 : return format_vnet_buffer_internal (s, b, 0 /* no_chain */);
95 : }
96 :
97 : /*
98 : * fd.io coding-style-patch-verification: ON
99 : *
100 : * Local Variables:
101 : * eval: (c-set-style "gnu")
102 : * End:
103 : */
|