aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib/buffer.h')
-rw-r--r--src/vlib/buffer.h67
1 files changed, 44 insertions, 23 deletions
diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h
index c3c4def0991..a1c2db377ef 100644
--- a/src/vlib/buffer.h
+++ b/src/vlib/buffer.h
@@ -51,6 +51,8 @@
#define VLIB_BUFFER_DATA_SIZE (2048)
#define VLIB_BUFFER_PRE_DATA_SIZE __PRE_DATA_SIZE
+typedef u8 vlib_buffer_free_list_index_t;
+
/** \file
vlib buffer structure definition and a few select
access methods. This structure and the buffer allocation
@@ -58,6 +60,40 @@
of typing to make it so.
*/
+/**
+ * Buffer Flags
+ */
+#define foreach_vlib_buffer_flag \
+ _( 0, NON_DEFAULT_FREELIST, "non-default-fl") \
+ _( 1, IS_TRACED, 0) \
+ _( 2, NEXT_PRESENT, 0) \
+ _( 3, IS_RECYCLED, "is-recycled") \
+ _( 4, TOTAL_LENGTH_VALID, 0) \
+ _( 5, REPL_FAIL, "repl-fail") \
+ _( 6, RECYCLE, "recycle") \
+ _( 7, EXT_HDR_VALID, "ext-hdr-valid")
+
+/* NOTE: only buffer generic flags should be defined here, please consider
+ using user flags. i.e. src/vnet/buffer.h */
+
+enum
+{
+#define _(bit, name, v) VLIB_BUFFER_##name = (1 << (bit)),
+ foreach_vlib_buffer_flag
+#undef _
+};
+
+enum
+{
+#define _(bit, name, v) VLIB_BUFFER_LOG2_##name = (bit),
+ foreach_vlib_buffer_flag
+#undef _
+};
+
+ /* User defined buffer flags. */
+#define LOG2_VLIB_BUFFER_FLAG_USER(n) (32 - (n))
+#define VLIB_BUFFER_FLAG_USER(n) (1 << LOG2_VLIB_BUFFER_FLAG_USER(n))
+
/* VLIB buffer representation. */
typedef struct
{
@@ -79,30 +115,11 @@ typedef struct
<br> VLIB_BUFFER_TOTAL_LENGTH_VALID: as it says
<br> VLIB_BUFFER_REPL_FAIL: packet replication failure
<br> VLIB_BUFFER_RECYCLE: as it says
- <br> VLIB_BUFFER_FLOW_REPORT: buffer is a flow report,
<br> VLIB_BUFFER_EXT_HDR_VALID: buffer contains valid external buffer manager header,
set to avoid adding it to a flow report
<br> VLIB_BUFFER_FLAG_USER(n): user-defined bit N
*/
-/* any change to the following line requres update of
- * vlib_buffer_get_free_list_index(...) and
- * vlib_buffer_set_free_list_index(...) functions */
-#define VLIB_BUFFER_FREE_LIST_INDEX_MASK ((1 << 5) - 1)
-
-#define VLIB_BUFFER_IS_TRACED (1 << 5)
-#define VLIB_BUFFER_LOG2_NEXT_PRESENT (6)
-#define VLIB_BUFFER_NEXT_PRESENT (1 << VLIB_BUFFER_LOG2_NEXT_PRESENT)
-#define VLIB_BUFFER_IS_RECYCLED (1 << 7)
-#define VLIB_BUFFER_TOTAL_LENGTH_VALID (1 << 8)
-#define VLIB_BUFFER_REPL_FAIL (1 << 9)
-#define VLIB_BUFFER_RECYCLE (1 << 10)
-#define VLIB_BUFFER_FLOW_REPORT (1 << 11)
-#define VLIB_BUFFER_EXT_HDR_VALID (1 << 12)
-
- /* User defined buffer flags. */
-#define LOG2_VLIB_BUFFER_FLAG_USER(n) (32 - (n))
-#define VLIB_BUFFER_FLAG_USER(n) (1 << LOG2_VLIB_BUFFER_FLAG_USER(n))
STRUCT_MARK (template_end);
@@ -143,7 +160,10 @@ typedef struct
/**< Only valid for first buffer in chain. Current length plus
total length given here give total number of bytes in buffer chain.
*/
- u32 align_pad; /**< available */
+ vlib_buffer_free_list_index_t free_list_index; /** < only used if
+ VLIB_BUFFER_NON_DEFAULT_FREELIST
+ flag is set */
+ u8 align_pad[3]; /**< available */
u32 opaque2[12]; /**< More opaque data, see ../vnet/vnet/buffer.h */
/***** end of second cache line */
@@ -337,7 +357,7 @@ typedef struct vlib_buffer_free_list_t
vlib_buffer_t buffer_init_template;
/* Our index into vlib_main_t's buffer_free_list_pool. */
- u32 index;
+ vlib_buffer_free_list_index_t index;
/* Number of data bytes for buffers in this free list. */
u32 n_data_bytes;
@@ -400,7 +420,8 @@ typedef struct
min_n_buffers_each_physmem_alloc,
u8 * name);
void (*vlib_buffer_delete_free_list_cb) (struct vlib_main_t * vm,
- u32 free_list_index);
+ vlib_buffer_free_list_index_t
+ free_list_index);
} vlib_buffer_callbacks_t;
extern vlib_buffer_callbacks_t *vlib_buffer_callbacks;
@@ -479,7 +500,7 @@ typedef struct
u32 next_index;
/* Free list to use to allocate new buffers. */
- u32 free_list_index;
+ vlib_buffer_free_list_index_t free_list_index;
} tx;
struct