summaryrefslogtreecommitdiffstats
path: root/src/vlib/buffer.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-06-21 18:24:07 -0400
committerNeale Ranns <nranns@cisco.com>2019-06-24 17:13:24 +0000
commita638c18375f17891a9455e717d8436158af12387 (patch)
treec2c1528169595172372a45aa0025c033c1ecea13 /src/vlib/buffer.h
parent21b83e96d6076cda01ee80343840bc1166557150 (diff)
vlib: packet tracer support for pkt thread handoffs
Type: feature Change-Id: Ia3d9a47679202c2a47cd3746b50e86c6b8627ef6 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib/buffer.h')
-rw-r--r--src/vlib/buffer.h42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h
index 0fd57f5275b..c8761af4d20 100644
--- a/src/vlib/buffer.h
+++ b/src/vlib/buffer.h
@@ -158,9 +158,9 @@ typedef union
/** start of 2nd cache line */
CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
- /** Specifies index into trace buffer if VLIB_PACKET_IS_TRACED flag is
+ /** Specifies trace buffer handle if VLIB_PACKET_IS_TRACED flag is
* set. */
- u32 trace_index;
+ u32 trace_handle;
/** Only valid for first buffer in chain. Current length plus total length
* given here give total number of bytes in buffer chain. */
@@ -354,6 +354,44 @@ vlib_buffer_make_headroom (vlib_buffer_t * b, u8 size)
return vlib_buffer_get_current (b);
}
+/** \brief Construct a trace handle from thread and pool index
+ * @param thread Thread id
+ * @param pool_index Pool index
+ * @return trace handle
+ */
+always_inline u32
+vlib_buffer_make_trace_handle (u32 thread, u32 pool_index)
+{
+ u32 rv;
+ ASSERT (thread < 0xff);
+ ASSERT (pool_index < 0x00FFFFFF);
+ rv = (thread << 24) | (pool_index & 0x00FFFFFF);
+ return rv;
+}
+
+/** \brief Extract the thread id from a trace handle
+ * @param trace_handle the trace handle
+ * @return the thread id
+ */
+always_inline u32
+vlib_buffer_get_trace_thread (vlib_buffer_t * b)
+{
+ u32 trace_handle = b->trace_handle;
+
+ return trace_handle >> 24;
+}
+
+/** \brief Extract the trace (pool) index from a trace handle
+ * @param trace_handle the trace handle
+ * @return the trace index
+ */
+always_inline u32
+vlib_buffer_get_trace_index (vlib_buffer_t * b)
+{
+ u32 trace_handle = b->trace_handle;
+ return trace_handle & 0x00FFFFFF;
+}
+
/** \brief Retrieve bytes from buffer head
* @param b pointer to the buffer
* @param size number of bytes to pull