aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-10-12 13:09:26 +0200
committerDave Barach <openvpp@barachs.net>2017-10-25 19:04:06 +0000
commit149ba779cff4ffc48d87ca67a2a8d4afd49b05f5 (patch)
treebc0467669b33b745fe4f44d4d0c787cf53900536 /src/plugins
parenta19d7b822ae9584cde522aefba36915e2af58846 (diff)
vlib: add support for multiple buffer pools
Change-Id: Icaf7d7ad47284aea7a56e8006b69f45874d64202 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/dpdk/buffer.c22
-rw-r--r--src/plugins/dpdk/device/common.c6
-rw-r--r--src/plugins/dpdk/device/dpdk.h1
-rw-r--r--src/plugins/dpdk/device/dpdk_priv.h8
-rw-r--r--src/plugins/dpdk/device/node.c3
-rw-r--r--src/plugins/ixge/ixge.c12
6 files changed, 37 insertions, 15 deletions
diff --git a/src/plugins/dpdk/buffer.c b/src/plugins/dpdk/buffer.c
index a44428a4592..b3dca95227c 100644
--- a/src/plugins/dpdk/buffer.c
+++ b/src/plugins/dpdk/buffer.c
@@ -193,6 +193,8 @@ fill_free_list (vlib_main_t * vm,
if (rte_mempool_get_bulk (rmp, vm->mbuf_alloc_list, n) < 0)
return 0;
+ dpdk_mempool_private_t *privp = rte_mempool_get_priv (rmp);
+
_vec_len (vm->mbuf_alloc_list) = n;
i = 0;
@@ -233,6 +235,11 @@ fill_free_list (vlib_main_t * vm,
vlib_buffer_init_for_free_list (b2, fl);
vlib_buffer_init_for_free_list (b3, fl);
+ b0->buffer_pool_index = privp->buffer_pool_index;
+ b1->buffer_pool_index = privp->buffer_pool_index;
+ b2->buffer_pool_index = privp->buffer_pool_index;
+ b3->buffer_pool_index = privp->buffer_pool_index;
+
if (fl->buffer_init_function)
{
fl->buffer_init_function (vm, fl, &bi0, 1);
@@ -253,6 +260,7 @@ fill_free_list (vlib_main_t * vm,
vec_add1_aligned (fl->buffers, bi0, CLIB_CACHE_LINE_BYTES);
vlib_buffer_init_for_free_list (b0, fl);
+ b0->buffer_pool_index = privp->buffer_pool_index;
if (fl->buffer_init_function)
fl->buffer_init_function (vm, fl, &bi0, 1);
@@ -409,13 +417,6 @@ dpdk_packet_template_init (vlib_main_t * vm,
vlib_worker_thread_barrier_release (vm);
}
-typedef struct
-{
- /* must be first */
- struct rte_pktmbuf_pool_private mbp_priv;
- vlib_physmem_region_index_t region_index;
-} dpdk_mempool_private_t;
-
clib_error_t *
dpdk_buffer_pool_create (vlib_main_t * vm, unsigned num_mbufs,
unsigned socket_id)
@@ -446,9 +447,8 @@ dpdk_buffer_pool_create (vlib_main_t * vm, unsigned num_mbufs,
size = rte_mempool_xmem_size (num_mbufs, obj_size, 21);
clib_error_t *error = 0;
- error =
- vlib_physmem_region_alloc (vm, (char *) pool_name, size, socket_id,
- VLIB_PHYSMEM_F_HAVE_BUFFERS, &pri);
+ error = vlib_physmem_region_alloc (vm, (char *) pool_name, size, socket_id,
+ 0, &pri);
if (error)
clib_error_report (error);
@@ -487,7 +487,7 @@ dpdk_buffer_pool_create (vlib_main_t * vm, unsigned num_mbufs,
rte_mempool_obj_iter (rmp, rte_pktmbuf_init, 0);
dpdk_mempool_private_t *privp = rte_mempool_get_priv (rmp);
- privp->region_index = pri;
+ privp->buffer_pool_index = vlib_buffer_add_physmem_region (vm, pri);
dm->pktmbuf_pools[socket_id] = rmp;
diff --git a/src/plugins/dpdk/device/common.c b/src/plugins/dpdk/device/common.c
index aedc3f5227d..c65cec6734d 100644
--- a/src/plugins/dpdk/device/common.c
+++ b/src/plugins/dpdk/device/common.c
@@ -78,8 +78,11 @@ dpdk_device_setup (dpdk_device_t * xd)
dpdk_device_error (xd, "rte_eth_tx_queue_setup", rv);
}
+ vec_validate_aligned (xd->buffer_pool_for_queue, xd->rx_q_used - 1,
+ CLIB_CACHE_LINE_BYTES);
for (j = 0; j < xd->rx_q_used; j++)
{
+ dpdk_mempool_private_t *privp;
uword tidx = vnet_get_device_input_thread_index (dm->vnet_main,
xd->hw_if_index, j);
unsigned lcore = vlib_worker_threads[tidx].lcore_id;
@@ -95,6 +98,9 @@ dpdk_device_setup (dpdk_device_t * xd)
SOCKET_ID_ANY, 0,
dm->pktmbuf_pools[socket_id]);
+ privp = rte_mempool_get_priv (dm->pktmbuf_pools[socket_id]);
+ xd->buffer_pool_for_queue[j] = privp->buffer_pool_index;
+
if (rv < 0)
dpdk_device_error (xd, "rte_eth_rx_queue_setup", rv);
}
diff --git a/src/plugins/dpdk/device/dpdk.h b/src/plugins/dpdk/device/dpdk.h
index a0c57ea21b3..1ed3b280385 100644
--- a/src/plugins/dpdk/device/dpdk.h
+++ b/src/plugins/dpdk/device/dpdk.h
@@ -194,6 +194,7 @@ typedef struct
u16 rx_q_used;
u16 nb_rx_desc;
u16 *cpu_socket_id_by_queue;
+ u8 *buffer_pool_for_queue;
struct rte_eth_conf port_conf;
struct rte_eth_txconf tx_conf;
diff --git a/src/plugins/dpdk/device/dpdk_priv.h b/src/plugins/dpdk/device/dpdk_priv.h
index 52b4ca4b303..a95d03cfba4 100644
--- a/src/plugins/dpdk/device/dpdk_priv.h
+++ b/src/plugins/dpdk/device/dpdk_priv.h
@@ -51,6 +51,14 @@ _(proc-type) \
_(file-prefix) \
_(vdev)
+typedef struct
+{
+ /* must be first */
+ struct rte_pktmbuf_pool_private mbp_priv;
+ u8 buffer_pool_index;
+} dpdk_mempool_private_t;
+
+
static inline void
dpdk_get_xstats (dpdk_device_t * xd)
{
diff --git a/src/plugins/dpdk/device/node.c b/src/plugins/dpdk/device/node.c
index cf8b9699206..82978216817 100644
--- a/src/plugins/dpdk/device/node.c
+++ b/src/plugins/dpdk/device/node.c
@@ -347,6 +347,9 @@ dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd,
/* Update buffer template */
vnet_buffer (bt)->sw_if_index[VLIB_RX] = xd->vlib_sw_if_index;
bt->error = node->errors[DPDK_ERROR_NONE];
+ /* as DPDK is allocating empty buffers from mempool provided before interface
+ start for each queue, it is safe to store this in the template */
+ bt->buffer_pool_index = xd->buffer_pool_for_queue[queue_id];
mb_index = 0;
diff --git a/src/plugins/ixge/ixge.c b/src/plugins/ixge/ixge.c
index 5fd6a901e35..f9d01d55ffd 100644
--- a/src/plugins/ixge/ixge.c
+++ b/src/plugins/ixge/ixge.c
@@ -2528,8 +2528,9 @@ ixge_dma_init (ixge_device_t * xd, vlib_rx_or_tx_t rt, u32 queue_index)
u32 i;
dq->tx.head_index_write_back =
- vlib_physmem_alloc (vm, vm->buffer_main->physmem_region, &error,
- CLIB_CACHE_LINE_BYTES);
+ vlib_physmem_alloc (vm,
+ vm->buffer_main->buffer_pools[0].physmem_region,
+ &error, CLIB_CACHE_LINE_BYTES);
for (i = 0; i < dq->n_descriptors; i++)
dq->descriptors[i].tx = xm->tx_descriptor_template;
@@ -2542,7 +2543,9 @@ ixge_dma_init (ixge_device_t * xd, vlib_rx_or_tx_t rt, u32 queue_index)
u64 a;
a =
- vlib_physmem_virtual_to_physical (vm, vm->buffer_main->physmem_region,
+ vlib_physmem_virtual_to_physical (vm,
+ vm->buffer_main->
+ buffer_pools[0].physmem_region,
dq->descriptors);
dr->descriptor_address[0] = a & 0xFFFFFFFF;
dr->descriptor_address[1] = a >> (u64) 32;
@@ -2570,7 +2573,8 @@ ixge_dma_init (ixge_device_t * xd, vlib_rx_or_tx_t rt, u32 queue_index)
a =
vlib_physmem_virtual_to_physical (vm,
- vm->buffer_main->physmem_region,
+ vm->buffer_main->
+ buffer_pools[0].physmem_region,
dq->tx.head_index_write_back);
dr->tx.head_index_write_back_address[0] = /* enable bit */ 1 | a;
dr->tx.head_index_write_back_address[1] = (u64) a >> (u64) 32;