X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlib%2Fbuffer.h;h=cfe7d6487b63b3c9ae19c75f591c51c9428fba11;hb=164c44f0b85fb635adcced8503f32ba9e2453fae;hp=1adde73d4ee1570ee0b23eba6bccee26587d77fd;hpb=910d3694e8b22c9d14e5f2913d14ae149e184620;p=vpp.git diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h index 1adde73d4ee..cfe7d6487b6 100644 --- a/src/vlib/buffer.h +++ b/src/vlib/buffer.h @@ -48,9 +48,10 @@ #include /* for vlib_error_t */ #include /* for __PRE_DATA_SIZE */ -#define VLIB_BUFFER_DATA_SIZE (2048) #define VLIB_BUFFER_PRE_DATA_SIZE __PRE_DATA_SIZE +#define VLIB_BUFFER_DEFAULT_DATA_SIZE (2048) + /* Minimum buffer chain segment size. Does not apply to last buffer in chain. Dataplane code can safely asume that specified amount of data is not split into 2 chained buffers */ @@ -71,7 +72,7 @@ */ #define foreach_vlib_buffer_flag \ _( 0, IS_TRACED, 0) \ - _( 1, NEXT_PRESENT, 0) \ + _( 1, NEXT_PRESENT, "next-present") \ _( 2, TOTAL_LENGTH_VALID, 0) \ _( 3, EXT_HDR_VALID, "ext-hdr-valid") @@ -138,8 +139,15 @@ typedef union * VLIB_BUFFER_NEXT_PRESENT flag is set. */ u32 next_buffer; - /** Used by feature subgraph arcs to visit enabled feature nodes */ - u32 current_config_index; + /** The following fields can be in a union because once a packet enters + * the punt path, it is no longer on a feature arc */ + union + { + /** Used by feature subgraph arcs to visit enabled feature nodes */ + u32 current_config_index; + /* the reason the packet once punted */ + u32 punt_reason; + }; /** Opaque data used by sub-graphs for their own purposes. */ u32 opaque[10]; @@ -150,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. */ @@ -341,11 +349,48 @@ vlib_buffer_push_uninit (vlib_buffer_t * b, u8 size) always_inline void * vlib_buffer_make_headroom (vlib_buffer_t * b, u8 size) { - ASSERT (b->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= size); b->current_data += 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 @@ -365,12 +410,15 @@ vlib_buffer_pull (vlib_buffer_t * b, u8 size) /* Forward declaration. */ struct vlib_main_t; +#define VLIB_BUFFER_POOL_PER_THREAD_CACHE_SZ 512 + typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); - u32 *cached_buffers; - u32 n_alloc; + u32 cached_buffers[VLIB_BUFFER_POOL_PER_THREAD_CACHE_SZ]; + u32 n_cached; } vlib_buffer_pool_thread_t; + typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); @@ -382,6 +430,7 @@ typedef struct u32 physmem_map_index; u32 data_size; u32 n_buffers; + u32 n_avail; u32 *buffers; u8 *name; clib_spinlock_t lock; @@ -393,6 +442,8 @@ typedef struct vlib_buffer_t buffer_template; } vlib_buffer_pool_t; +#define VLIB_BUFFER_MAX_NUMA_NODES 32 + typedef struct { CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); @@ -408,11 +459,12 @@ typedef struct has never been allocated. */ uword *buffer_known_hash; clib_spinlock_t buffer_known_hash_lockp; - u32 n_numa_nodes; + u8 default_buffer_pool_index_for_numa[VLIB_BUFFER_MAX_NUMA_NODES]; /* config */ u32 buffers_per_numa; u16 ext_hdr_size; + u32 default_data_size; /* logging */ vlib_log_class_t log_default;