aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/buffer.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-07-10 15:06:17 +0200
committerDave Barach <openvpp@barachs.net>2017-07-10 19:35:57 +0000
commit04a7f05e91e919f51eaecaee476435484076655b (patch)
treeb7cbd12430c4a16b6289300b5b604835791bd780 /src/vlib/buffer.h
parent28160f38488743b8cee0a7bd62b432a9dd8f4bfd (diff)
vlib: store buffer memory information in the buffer_main
Currently, buffer index is calculated as a offset to the physmem region shifted by log2_cacheline size. When DPDK is used we "hack" physmem data with information taken from dpdk mempool. This makes physmem code not usable with DPDK. This change makes buffer memory start and size independent of physmem basically allowing physmem to be used when DPDK plugin is loaded. Change-Id: Ieb399d398f147583b9baab467152a352d58c9c31 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/buffer.h')
-rw-r--r--src/vlib/buffer.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h
index 18e2437d775..b20538b7f8c 100644
--- a/src/vlib/buffer.h
+++ b/src/vlib/buffer.h
@@ -388,12 +388,20 @@ typedef struct
u32 free_list_index);
} vlib_buffer_callbacks_t;
+extern vlib_buffer_callbacks_t *vlib_buffer_callbacks;
+
typedef struct
{
+ CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
+ /* Virtual memory address and size of buffer memory, used for calculating
+ buffer index */
+ uword buffer_mem_start;
+ uword buffer_mem_size;
+
/* Buffer free callback, for subversive activities */
- u32 (*buffer_free_callback) (struct vlib_main_t * vm,
- u32 * buffers,
- u32 n_buffers, u32 follow_buffer_next);
+ u32 (*buffer_free_callback) (struct vlib_main_t * vm,
+ u32 * buffers,
+ u32 n_buffers, u32 follow_buffer_next);
/* Pool of buffer free lists.
Multiple free lists exist for packet generator which uses
separate free lists for each packet stream --- so as to avoid
@@ -417,12 +425,12 @@ typedef struct
/* Callbacks */
vlib_buffer_callbacks_t cb;
- int extern_buffer_mgmt;
+ int callbacks_registered;
} vlib_buffer_main_t;
+void vlib_buffer_add_mem_range (struct vlib_main_t *vm, uword start,
+ uword size);
void vlib_buffer_cb_init (struct vlib_main_t *vm);
-int vlib_buffer_cb_register (struct vlib_main_t *vm,
- vlib_buffer_callbacks_t * cb);
typedef struct
{
@@ -498,6 +506,18 @@ serialize_vlib_buffer_n_bytes (serialize_main_t * m)
#endif /* included_vlib_buffer_h */
+#define VLIB_BUFFER_REGISTER_CALLBACKS(x,...) \
+ __VA_ARGS__ vlib_buffer_callbacks_t __##x##_buffer_callbacks; \
+static void __vlib_add_buffer_callbacks_t_##x (void) \
+ __attribute__((__constructor__)) ; \
+static void __vlib_add_buffer_callbacks_t_##x (void) \
+{ \
+ if (vlib_buffer_callbacks) \
+ clib_panic ("vlib buffer callbacks already registered"); \
+ vlib_buffer_callbacks = &__##x##_buffer_callbacks; \
+} \
+__VA_ARGS__ vlib_buffer_callbacks_t __##x##_buffer_callbacks
+
/*
* fd.io coding-style-patch-verification: ON
*