blob: 545018a79e9109f9658f7a1e7a4f7e50e6e10a79 [file] [log] [blame]
Damjan Marionbd846cd2017-11-21 13:12:41 +01001/*
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
Mohsin Kazmi68095382021-02-10 11:26:24 +010019u8 *
20format_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) \
Mohsin Kazmia7e830e2021-04-23 15:16:50 +020025 if (v && (vnet_buffer (b)->oflags & VNET_BUFFER_OFFLOAD_F_##name)) \
Mohsin Kazmi68095382021-02-10 11:26:24 +010026 s = format (s, "%s ", ss);
27 foreach_vnet_buffer_offload_flag
28#undef _
29 return s;
30}
Damjan Marionbd846cd2017-11-21 13:12:41 +010031
32u8 *
33format_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
Dave Barach7fff3d22018-11-27 16:52:59 -050039#define _(bit,name,ss,v) \
Damjan Marionbd846cd2017-11-21 13:12:41 +010040 if (v && (b->flags & VNET_BUFFER_F_##name)) \
Dave Barach7fff3d22018-11-27 16:52:59 -050041 a = format (a, "%s ", ss);
Damjan Mariondac03522018-02-01 15:30:13 +010042 foreach_vnet_buffer_flag
Damjan Marionbd846cd2017-11-21 13:12:41 +010043#undef _
Mohsin Kazmi68095382021-02-10 11:26:24 +010044 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)
Damjan Marionbd846cd2017-11-21 13:12:41 +010048 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)
Steven0b26bd72017-12-01 06:58:56 -080051 a = format (a, "l3-hdr-offset %d ", vnet_buffer (b)->l3_hdr_offset);
Damjan Marionbd846cd2017-11-21 13:12:41 +010052
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
Mohsin Kazmi68095382021-02-10 11:26:24 +010056 if (b->flags & VNET_BUFFER_F_GSO)
57 a = format (a, "gso gso-size %d", vnet_buffer2 (b)->gso_size);
58
Neale Ranns039cbfe2018-02-27 03:45:38 -080059 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
Neale Rannsce9e0b42018-08-01 12:53:17 -070063 if (b->flags & VNET_BUFFER_F_LOOP_COUNTER_VALID)
64 a = format (a, "loop-counter %d ", vnet_buffer2 (b)->loop_counter);
65
BenoƮt Ganne43543172019-10-21 15:13:54 +020066 s = format (s, "%U", format_vlib_buffer_no_chain, b);
Damjan Marionbd846cd2017-11-21 13:12:41 +010067 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 */