summaryrefslogtreecommitdiffstats
path: root/src/plugins/dpdk/buffer.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-03-12 18:14:15 +0100
committerDave Barach <openvpp@barachs.net>2019-10-28 14:07:27 +0000
commitb6e8b1a7c8bf9f9fbd05cdc3c90111d9e7a6897b (patch)
treeadd9c6ecd3321e299c698f2763b2db70b01b6893 /src/plugins/dpdk/buffer.c
parent38f7ccbce0c9f4c4c9fbd37232ac1365b5dc1252 (diff)
vlib: don't use vector for keeping buffer indices in the pool
Type: refactor Change-Id: I72221b97d7e0bf5c93e20bbda4473ca67bfcdeb4 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/dpdk/buffer.c')
-rw-r--r--src/plugins/dpdk/buffer.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/plugins/dpdk/buffer.c b/src/plugins/dpdk/buffer.c
index a1c1ea1ca46..d7a79161386 100644
--- a/src/plugins/dpdk/buffer.c
+++ b/src/plugins/dpdk/buffer.c
@@ -40,7 +40,7 @@ dpdk_buffer_pool_init (vlib_main_t * vm, vlib_buffer_pool_t * bp)
struct rte_mempool *mp, *nmp;
struct rte_pktmbuf_pool_private priv;
enum rte_iova_mode iova_mode;
- u32 *bi;
+ u32 i;
u8 *name = 0;
u32 elt_size =
@@ -54,7 +54,7 @@ dpdk_buffer_pool_init (vlib_main_t * vm, vlib_buffer_pool_t * bp)
/* normal mempool */
name = format (name, "vpp pool %u%c", bp->index, 0);
- mp = rte_mempool_create_empty ((char *) name, vec_len (bp->buffers),
+ mp = rte_mempool_create_empty ((char *) name, bp->n_buffers,
elt_size, 512, sizeof (priv),
bp->numa_node, 0);
if (!mp)
@@ -68,7 +68,7 @@ dpdk_buffer_pool_init (vlib_main_t * vm, vlib_buffer_pool_t * bp)
/* non-cached mempool */
name = format (name, "vpp pool %u (no cache)%c", bp->index, 0);
- nmp = rte_mempool_create_empty ((char *) name, vec_len (bp->buffers),
+ nmp = rte_mempool_create_empty ((char *) name, bp->n_buffers,
elt_size, 0, sizeof (priv),
bp->numa_node, 0);
if (!nmp)
@@ -99,11 +99,10 @@ dpdk_buffer_pool_init (vlib_main_t * vm, vlib_buffer_pool_t * bp)
iova_mode = rte_eal_iova_mode ();
/* populate mempool object buffer header */
- /* *INDENT-OFF* */
- vec_foreach (bi, bp->buffers)
+ for (i = 0; i < bp->n_buffers; i++)
{
struct rte_mempool_objhdr *hdr;
- vlib_buffer_t *b = vlib_get_buffer (vm, *bi);
+ vlib_buffer_t *b = vlib_get_buffer (vm, bp->buffers[i]);
struct rte_mbuf *mb = rte_mbuf_from_vlib_buffer (b);
hdr = (struct rte_mempool_objhdr *) RTE_PTR_SUB (mb, sizeof (*hdr));
hdr->mp = mp;
@@ -114,7 +113,6 @@ dpdk_buffer_pool_init (vlib_main_t * vm, vlib_buffer_pool_t * bp)
mp->populated_size++;
nmp->populated_size++;
}
- /* *INDENT-ON* */
/* call the object initializers */
rte_mempool_obj_iter (mp, rte_pktmbuf_init, 0);
@@ -127,14 +125,12 @@ dpdk_buffer_pool_init (vlib_main_t * vm, vlib_buffer_pool_t * bp)
(buffer_mem_start, *bp->buffers,
0)), sizeof (struct rte_mbuf));
- /* *INDENT-OFF* */
- vec_foreach (bi, bp->buffers)
+ for (i = 0; i < bp->n_buffers; i++)
{
vlib_buffer_t *b;
- b = vlib_buffer_ptr_from_index (buffer_mem_start, *bi, 0);
+ b = vlib_buffer_ptr_from_index (buffer_mem_start, bp->buffers[i], 0);
vlib_buffer_copy_template (b, &bp->buffer_template);
}
- /* *INDENT-ON* */
/* map DMA pages if at least one physical device exists */
if (rte_eth_dev_count_avail ())