summaryrefslogtreecommitdiffstats
path: root/src/vlib/buffer.h
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2021-03-04 14:31:03 +0100
committerDamjan Marion <dmarion@me.com>2021-05-01 11:42:37 +0000
commitf89bbbe300dad7bc479db535e7822199f98aca30 (patch)
tree1163eeac010375a962fcda8c2e0c7a7046161bf1 /src/vlib/buffer.h
parentc8983241b9d93d2c3b60b0705efbc3cdee54c534 (diff)
vlib: refactor trajectory trace debug feature
trajectory trace has been broken for a while because we used to save the buffer trajectory in a vector pointed to in opaque2. This does not work well when opaque2 is copied (eg. because of a clone) as 2 buffers end up sharing the same vector. This dedicates a full cacheline in the buffer metadata instead when trajectory is compiled in. No dynamic allocation, no sharing, no tears. Type: refactor Change-Id: I6a028ca1b48d38f393a36979e5e452c2dd48ad3f Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vlib/buffer.h')
-rw-r--r--src/vlib/buffer.h46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h
index 297240d45f7..349b7324996 100644
--- a/src/vlib/buffer.h
+++ b/src/vlib/buffer.h
@@ -98,6 +98,15 @@ enum
#define VLIB_BUFFER_FLAG_USER(n) (1 << LOG2_VLIB_BUFFER_FLAG_USER(n))
#define VLIB_BUFFER_FLAGS_ALL (0x0f)
+/** \brief Compile time buffer trajectory tracing option
+ Turn this on if you run into "bad monkey" contexts,
+ and you want to know exactly which nodes they've visited...
+ See vlib/main.c...
+*/
+#ifndef VLIB_BUFFER_TRACE_TRAJECTORY
+#define VLIB_BUFFER_TRACE_TRAJECTORY 0
+#endif /* VLIB_BUFFER_TRACE_TRAJECTORY */
+
/** VLIB buffer representation. */
typedef union
{
@@ -169,6 +178,20 @@ typedef union
/**< More opaque data, see ../vnet/vnet/buffer.h */
u32 opaque2[14];
+#if VLIB_BUFFER_TRACE_TRAJECTORY > 0
+ /** trace trajectory data - we use a specific cacheline for that in the
+ * buffer when it is compiled-in */
+#define VLIB_BUFFER_TRACE_TRAJECTORY_MAX 31
+#define VLIB_BUFFER_TRACE_TRAJECTORY_SZ 64
+#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b) (b)->trajectory_nb = 0
+ CLIB_ALIGN_MARK (trajectory, 64);
+ u16 trajectory_nb;
+ u16 trajectory_trace[VLIB_BUFFER_TRACE_TRAJECTORY_MAX];
+#else /* VLIB_BUFFER_TRACE_TRAJECTORY */
+#define VLIB_BUFFER_TRACE_TRAJECTORY_SZ 0
+#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
+#endif /* VLIB_BUFFER_TRACE_TRAJECTORY */
+
/** start of buffer headroom */
CLIB_ALIGN_MARK (headroom, 64);
@@ -191,7 +214,8 @@ typedef union
#endif
} vlib_buffer_t;
-STATIC_ASSERT_SIZEOF (vlib_buffer_t, 128 + VLIB_BUFFER_PRE_DATA_SIZE);
+STATIC_ASSERT_SIZEOF (vlib_buffer_t, 128 + VLIB_BUFFER_TRACE_TRAJECTORY_SZ +
+ VLIB_BUFFER_PRE_DATA_SIZE);
STATIC_ASSERT (VLIB_BUFFER_PRE_DATA_SIZE % CLIB_CACHE_LINE_BYTES == 0,
"VLIB_BUFFER_PRE_DATA_SIZE must be divisible by cache line size");
@@ -477,26 +501,6 @@ typedef struct
clib_error_t *vlib_buffer_main_init (struct vlib_main_t *vm);
-/*
- */
-
-/** \brief Compile time buffer trajectory tracing option
- Turn this on if you run into "bad monkey" contexts,
- and you want to know exactly which nodes they've visited...
- See vlib/main.c...
-*/
-#define VLIB_BUFFER_TRACE_TRAJECTORY 0
-
-#if VLIB_BUFFER_TRACE_TRAJECTORY > 0
-extern void (*vlib_buffer_trace_trajectory_cb) (vlib_buffer_t * b, u32 index);
-extern void (*vlib_buffer_trace_trajectory_init_cb) (vlib_buffer_t * b);
-extern void vlib_buffer_trace_trajectory_init (vlib_buffer_t * b);
-#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b) \
- vlib_buffer_trace_trajectory_init (b);
-#else
-#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
-#endif /* VLIB_BUFFER_TRACE_TRAJECTORY */
-
extern u16 __vlib_buffer_external_hdr_size;
#define VLIB_BUFFER_SET_EXT_HDR_SIZE(x) \
static void __clib_constructor \