aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/memif
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-01-21 11:48:34 +0100
committerDave Barach <openvpp@barachs.net>2019-01-30 16:19:22 +0000
commit910d3694e8b22c9d14e5f2913d14ae149e184620 (patch)
treee4993e93e4d7dba51a5898e82bb6149a3e4bd7ba /src/plugins/memif
parent4fd5a9d3e6abdf61f266da8400a299fe5b0eb0ed (diff)
buffers: major cleanup and improvements
This patch introduces following changes: - deprecated free lists which are not used and not compatible with external buffer managers (i.e. DPDK) - introduces native support for per-numa buffer pools - significantly improves performance of buffer alloc and free Change-Id: I4a8e723ae47056717afd6cac0efe87cb731b5be7 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/memif')
-rw-r--r--src/plugins/memif/memif.c5
-rw-r--r--src/plugins/memif/node.c9
-rw-r--r--src/plugins/memif/private.h1
3 files changed, 12 insertions, 3 deletions
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index 6e45b573f2c..7f29f4d7f87 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -185,6 +185,7 @@ memif_int_fd_read_ready (clib_file_t * uf)
clib_error_t *
memif_connect (memif_if_t * mif)
{
+ vlib_main_t *vm = vlib_get_main ();
vnet_main_t *vnm = vnet_get_main ();
clib_file_t template = { 0 };
memif_region_t *mr;
@@ -235,6 +236,7 @@ memif_connect (memif_if_t * mif)
vec_foreach_index (i, mif->rx_queues)
{
memif_queue_t *mq = vec_elt_at_index (mif->rx_queues, i);
+ u32 ti;
int rv;
mq->ring = mif->regions[mq->region].shm + mq->offset;
@@ -254,6 +256,9 @@ memif_connect (memif_if_t * mif)
memif_file_add (&mq->int_clib_file_index, &template);
}
vnet_hw_interface_assign_rx_thread (vnm, mif->hw_if_index, i, ~0);
+ ti = vnet_get_device_input_thread_index (vnm, mif->hw_if_index, i);
+ mq->buffer_pool_index =
+ vlib_buffer_pool_get_default_for_numa (vm, vlib_mains[ti]->numa_node);
rv = vnet_hw_interface_set_rx_mode (vnm, mif->hw_if_index, i,
VNET_HW_INTERFACE_RX_MODE_DEFAULT);
if (rv)
diff --git a/src/plugins/memif/node.c b/src/plugins/memif/node.c
index 490c60356db..347112892be 100644
--- a/src/plugins/memif/node.c
+++ b/src/plugins/memif/node.c
@@ -280,7 +280,8 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
/* allocate free buffers */
vec_validate_aligned (ptd->buffers, n_buffers - 1, CLIB_CACHE_LINE_BYTES);
- n_alloc = vlib_buffer_alloc (vm, ptd->buffers, n_buffers);
+ n_alloc = vlib_buffer_alloc_from_pool (vm, ptd->buffers, n_buffers,
+ mq->buffer_pool_index);
if (PREDICT_FALSE (n_alloc != n_buffers))
{
if (n_alloc)
@@ -343,6 +344,7 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vnet_buffer (&ptd->buffer_template)->feature_arc_index = 0;
ptd->buffer_template.current_data = start_offset;
ptd->buffer_template.current_config_index = 0;
+ ptd->buffer_template.buffer_pool_index = mq->buffer_pool_index;
if (mode == MEMIF_INTERFACE_MODE_ETHERNET)
{
@@ -783,8 +785,9 @@ refill:
clib_memset (dt, 0, sizeof (memif_desc_t));
dt->length = buffer_length;
- n_alloc = vlib_buffer_alloc_to_ring (vm, mq->buffers, head & mask,
- ring_size, n_slots);
+ n_alloc = vlib_buffer_alloc_to_ring_from_pool (vm, mq->buffers, head & mask,
+ ring_size, n_slots,
+ mq->buffer_pool_index);
if (PREDICT_FALSE (n_alloc != n_slots))
{
diff --git a/src/plugins/memif/private.h b/src/plugins/memif/private.h
index a938b85e7da..2aa1f5a0cdc 100644
--- a/src/plugins/memif/private.h
+++ b/src/plugins/memif/private.h
@@ -123,6 +123,7 @@ typedef struct
u16 last_head;
u16 last_tail;
u32 *buffers;
+ u8 buffer_pool_index;
/* interrupts */
int int_fd;