aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/buffer.h46
-rw-r--r--src/vlib/main.c23
2 files changed, 29 insertions, 40 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 \
diff --git a/src/vlib/main.c b/src/vlib/main.c
index bee63970f3d..f833aa25acf 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -934,29 +934,14 @@ vlib_elog_main_loop_event (vlib_main_t * vm,
}
}
-#if VLIB_BUFFER_TRACE_TRAJECTORY > 0
-void (*vlib_buffer_trace_trajectory_cb) (vlib_buffer_t * b, u32 node_index);
-void (*vlib_buffer_trace_trajectory_init_cb) (vlib_buffer_t * b);
-
-void
-vlib_buffer_trace_trajectory_init (vlib_buffer_t * b)
-{
- if (PREDICT_TRUE (vlib_buffer_trace_trajectory_init_cb != 0))
- {
- (*vlib_buffer_trace_trajectory_init_cb) (b);
- }
-}
-
-#endif
-
static inline void
add_trajectory_trace (vlib_buffer_t * b, u32 node_index)
{
#if VLIB_BUFFER_TRACE_TRAJECTORY > 0
- if (PREDICT_TRUE (vlib_buffer_trace_trajectory_cb != 0))
- {
- (*vlib_buffer_trace_trajectory_cb) (b, node_index);
- }
+ if (PREDICT_FALSE (b->trajectory_nb >= VLIB_BUFFER_TRACE_TRAJECTORY_MAX))
+ return;
+ b->trajectory_trace[b->trajectory_nb] = node_index;
+ b->trajectory_nb++;
#endif
}