aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/buffer.c56
-rw-r--r--src/vnet/buffer.h34
-rw-r--r--src/vnet/devices/devices.c10
-rw-r--r--src/vnet/devices/devices.h1
-rw-r--r--src/vnet/pg/input.c4
-rw-r--r--src/vnet/pg/stream.c2
6 files changed, 89 insertions, 18 deletions
diff --git a/src/vnet/buffer.c b/src/vnet/buffer.c
new file mode 100644
index 00000000000..78b32ea525f
--- /dev/null
+++ b/src/vnet/buffer.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vlib/vlib.h>
+#include <vnet/buffer.h>
+
+
+u8 *
+format_vnet_buffer (u8 * s, va_list * args)
+{
+ vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *);
+ u32 indent = format_get_indent (s);
+ u8 *a = 0;
+
+#define _(bit, name, v) \
+ if (v && (b->flags & VNET_BUFFER_F_##name)) \
+ a = format (a, "%s ", v);
+ foreach_vnet_buffer_field
+#undef _
+ if (b->flags & VNET_BUFFER_F_L2_HDR_OFFSET_VALID)
+ a = format (a, "l2-hdr-offset %d ", vnet_buffer (b)->l2_hdr_offset);
+
+ if (b->flags & VNET_BUFFER_F_L3_HDR_OFFSET_VALID)
+ a = format (a, "l2-hdr-offset %d ", vnet_buffer (b)->l3_hdr_offset);
+
+ if (b->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID)
+ a = format (a, "l4-hdr-offset %d ", vnet_buffer (b)->l4_hdr_offset);
+
+ s = format (s, "%U", format_vlib_buffer, b);
+ if (a)
+ s = format (s, "\n%U%v", format_white_space, indent, a);
+ vec_free (a);
+
+ return s;
+}
+
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/buffer.h b/src/vnet/buffer.h
index 6518fb67016..50b94f7ff2d 100644
--- a/src/vnet/buffer.h
+++ b/src/vnet/buffer.h
@@ -43,33 +43,36 @@
#include <vlib/vlib.h>
#define foreach_vnet_buffer_field \
- _( 1, L4_CHECKSUM_COMPUTED) \
- _( 2, L4_CHECKSUM_CORRECT) \
- _( 3, VLAN_2_DEEP) \
- _( 4, VLAN_1_DEEP) \
- _( 8, SPAN_CLONE) \
- _( 6, HANDOFF_NEXT_VALID) \
- _( 7, LOCALLY_ORIGINATED) \
- _( 8, IS_IP4) \
- _( 9, IS_IP6) \
- _(10, OFFLOAD_IP_CKSUM) \
- _(11, OFFLOAD_TCP_CKSUM) \
- _(12, OFFLOAD_UDP_CKSUM) \
- _(13, IS_NATED)
+ _( 1, L4_CHECKSUM_COMPUTED, "l4-cksum-computed") \
+ _( 2, L4_CHECKSUM_CORRECT, "l4-cksum-correct") \
+ _( 3, VLAN_2_DEEP, "vlan-2-deep") \
+ _( 4, VLAN_1_DEEP, "vlan-1-deep") \
+ _( 8, SPAN_CLONE, "span-clone") \
+ _( 6, HANDOFF_NEXT_VALID, "handoff-next-valid") \
+ _( 7, LOCALLY_ORIGINATED, "local") \
+ _( 8, IS_IP4, "ip4") \
+ _( 9, IS_IP6, "ip6") \
+ _(10, OFFLOAD_IP_CKSUM, "offload-ip-cksum") \
+ _(11, OFFLOAD_TCP_CKSUM, "offload-tcp-cksum") \
+ _(12, OFFLOAD_UDP_CKSUM, "offload-udp-cksum") \
+ _(13, IS_NATED, "nated") \
+ _(14, L2_HDR_OFFSET_VALID, 0) \
+ _(15, L3_HDR_OFFSET_VALID, 0) \
+ _(16, L4_HDR_OFFSET_VALID, 0)
#define VNET_BUFFER_FLAGS_VLAN_BITS \
(VNET_BUFFER_F_VLAN_1_DEEP | VNET_BUFFER_F_VLAN_2_DEEP)
enum
{
-#define _(bit, name) VNET_BUFFER_F_##name = (1 << LOG2_VLIB_BUFFER_FLAG_USER(bit)),
+#define _(bit, name, v) VNET_BUFFER_F_##name = (1 << LOG2_VLIB_BUFFER_FLAG_USER(bit)),
foreach_vnet_buffer_field
#undef _
};
enum
{
-#define _(bit, name) VNET_BUFFER_F_LOG2_##name = LOG2_VLIB_BUFFER_FLAG_USER(bit),
+#define _(bit, name, v) VNET_BUFFER_F_LOG2_##name = LOG2_VLIB_BUFFER_FLAG_USER(bit),
foreach_vnet_buffer_field
#undef _
};
@@ -350,6 +353,7 @@ STATIC_ASSERT (sizeof (vnet_buffer_opaque2_t) <=
STRUCT_SIZE_OF (vlib_buffer_t, opaque2),
"VNET buffer opaque2 meta-data too large for vlib_buffer");
+format_function_t format_vnet_buffer;
#endif /* included_vnet_buffer_h */
diff --git a/src/vnet/devices/devices.c b/src/vnet/devices/devices.c
index a38ecd2d1bb..99011dabc7a 100644
--- a/src/vnet/devices/devices.c
+++ b/src/vnet/devices/devices.c
@@ -52,6 +52,16 @@ device_input_next_node_advance[((VNET_DEVICE_INPUT_N_NEXT_NODES /
[VNET_DEVICE_INPUT_NEXT_MPLS_INPUT] = sizeof (ethernet_header_t),
};
+const u32 __attribute__((aligned (CLIB_CACHE_LINE_BYTES)))
+device_input_next_node_flags[((VNET_DEVICE_INPUT_N_NEXT_NODES /
+ CLIB_CACHE_LINE_BYTES) +1) * CLIB_CACHE_LINE_BYTES] =
+{
+ [VNET_DEVICE_INPUT_NEXT_IP4_INPUT] = VNET_BUFFER_F_L3_HDR_OFFSET_VALID,
+ [VNET_DEVICE_INPUT_NEXT_IP4_NCS_INPUT] = VNET_BUFFER_F_L3_HDR_OFFSET_VALID,
+ [VNET_DEVICE_INPUT_NEXT_IP6_INPUT] = VNET_BUFFER_F_L3_HDR_OFFSET_VALID,
+ [VNET_DEVICE_INPUT_NEXT_MPLS_INPUT] = VNET_BUFFER_F_L3_HDR_OFFSET_VALID,
+};
+
VNET_FEATURE_ARC_INIT (device_input, static) =
{
.arc_name = "device-input",
diff --git a/src/vnet/devices/devices.h b/src/vnet/devices/devices.h
index b74e3713dfc..c303cb67b40 100644
--- a/src/vnet/devices/devices.h
+++ b/src/vnet/devices/devices.h
@@ -73,6 +73,7 @@ typedef struct
extern vnet_device_main_t vnet_device_main;
extern vlib_node_registration_t device_input_node;
extern const u32 device_input_next_node_advance[];
+extern const u32 device_input_next_node_flags[];
static inline void
vnet_hw_interface_set_input_node (vnet_main_t * vnm, u32 hw_if_index,
diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c
index b70f3ce4fc0..f31152c3889 100644
--- a/src/vnet/pg/input.c
+++ b/src/vnet/pg/input.c
@@ -65,7 +65,7 @@ validate_buffer_data2 (vlib_buffer_t * b, pg_stream_t * s,
if (i >= n_bytes)
return 1;
- clib_warning ("buffer %U", format_vlib_buffer, b);
+ clib_warning ("buffer %U", format_vnet_buffer, b);
clib_warning ("differ at index %d", i);
clib_warning ("is %U", format_hex_bytes, bd, n_bytes);
clib_warning ("mask %U", format_hex_bytes, pm, n_bytes);
@@ -1403,7 +1403,7 @@ format_pg_input_trace (u8 * s, va_list * va)
s = format (s, ", %d sw_if_index", t->sw_if_index);
s = format (s, "\n%U%U",
- format_white_space, indent, format_vlib_buffer, &t->buffer);
+ format_white_space, indent, format_vnet_buffer, &t->buffer);
s = format (s, "\n%U", format_white_space, indent);
diff --git a/src/vnet/pg/stream.c b/src/vnet/pg/stream.c
index 2dfbf5adcbd..762f241d001 100644
--- a/src/vnet/pg/stream.c
+++ b/src/vnet/pg/stream.c
@@ -104,7 +104,7 @@ format_pg_output_trace (u8 * s, va_list * va)
s = format (s, "%Ubuffer 0x%x: %U",
format_white_space, indent,
- t->buffer_index, format_vlib_buffer, &t->buffer);
+ t->buffer_index, format_vnet_buffer, &t->buffer);
s = format (s, "\n%U%U", format_white_space, indent,
format_ethernet_header_with_length, t->buffer.pre_data,