summaryrefslogtreecommitdiffstats
path: root/vlib
diff options
context:
space:
mode:
Diffstat (limited to 'vlib')
-rw-r--r--vlib/vlib/dpdk_buffer.c78
1 files changed, 73 insertions, 5 deletions
diff --git a/vlib/vlib/dpdk_buffer.c b/vlib/vlib/dpdk_buffer.c
index 84bca0f53d0..337fca9ade7 100644
--- a/vlib/vlib/dpdk_buffer.c
+++ b/vlib/vlib/dpdk_buffer.c
@@ -964,7 +964,9 @@ vlib_buffer_pool_create (vlib_main_t * vm, unsigned num_mbufs,
vlib_buffer_main_t *bm = vm->buffer_main;
vlib_physmem_main_t *vpm = &vm->physmem_main;
struct rte_mempool *rmp;
+#if RTE_VERSION < RTE_VERSION_NUM(16, 7, 0, 0)
uword new_start, new_size;
+#endif
int i;
if (!rte_pktmbuf_pool_create)
@@ -985,16 +987,78 @@ vlib_buffer_pool_create (vlib_main_t * vm, unsigned num_mbufs,
VLIB_BUFFER_PRE_DATA_SIZE + VLIB_BUFFER_DATA_SIZE, /* dataroom size */
socket_id); /* cpu socket */
- vec_free (pool_name);
-
if (rmp)
{
- new_start = pointer_to_uword (rmp);
#if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0)
- new_size = (uintptr_t)STAILQ_FIRST(&rmp->mem_list)->addr + STAILQ_FIRST(&rmp->mem_list)->len - new_start;
+ {
+ uword this_pool_end;
+ uword this_pool_start;
+ uword this_pool_size;
+ uword save_vpm_start, save_vpm_end, save_vpm_size;
+ struct rte_mempool_memhdr *memhdr;
+
+ this_pool_start = ~0ULL;
+ this_pool_end = 0LL;
+
+ STAILQ_FOREACH (memhdr, &rmp->mem_list, next)
+ {
+ if (((uword)(memhdr->addr + memhdr->len)) > this_pool_end)
+ this_pool_end = (uword)(memhdr->addr + memhdr->len);
+ if (((uword)memhdr->addr) < this_pool_start)
+ this_pool_start = (uword)(memhdr->addr);
+ }
+ ASSERT (this_pool_start < ~0ULL && this_pool_end > 0);
+ this_pool_size = this_pool_end - this_pool_start;
+
+ if (CLIB_DEBUG > 1)
+ {
+ clib_warning ("%s: pool start %llx pool end %llx pool size %lld",
+ pool_name, this_pool_start, this_pool_end,
+ this_pool_size);
+ clib_warning
+ ("before: virtual.start %llx virtual.end %llx virtual.size %lld",
+ vpm->virtual.start, vpm->virtual.end, vpm->virtual.size);
+ }
+
+ save_vpm_start = vpm->virtual.start;
+ save_vpm_end = vpm->virtual.end;
+ save_vpm_size = vpm->virtual.size;
+
+ if ((this_pool_start < vpm->virtual.start) || vpm->virtual.start == 0)
+ vpm->virtual.start = this_pool_start;
+ if (this_pool_end > vpm->virtual.end)
+ vpm->virtual.end = this_pool_end;
+
+ vpm->virtual.size = vpm->virtual.end - vpm->virtual.start;
+
+ if (CLIB_DEBUG > 1)
+ {
+ clib_warning
+ ("after: virtual.start %llx virtual.end %llx virtual.size %lld",
+ vpm->virtual.start, vpm->virtual.end, vpm->virtual.size);
+ }
+
+ /* check if fits into buffer index range */
+ if ((u64) vpm->virtual.size >
+ ((u64) 1 << (32 + CLIB_LOG2_CACHE_LINE_BYTES)))
+ {
+ clib_warning ("physmem: virtual size out of range!");
+ vpm->virtual.start = save_vpm_start;
+ vpm->virtual.end = save_vpm_end;
+ vpm->virtual.size = save_vpm_size;
+ rmp = 0;
+ }
+ }
+ if (rmp)
+ {
+ bm->pktmbuf_pools[socket_id] = rmp;
+ vec_free(pool_name);
+ return 0;
+ }
+ }
#else
+ new_start = pointer_to_uword (rmp);
new_size = rmp->elt_va_end - new_start;
-#endif
if (vpm->virtual.size > 0)
{
@@ -1021,8 +1085,12 @@ vlib_buffer_pool_create (vlib_main_t * vm, unsigned num_mbufs,
vpm->virtual.start = new_start;
vpm->virtual.size = new_size;
vpm->virtual.end = new_start + new_size;
+ vec_free(pool_name);
return 0;
}
+#endif
+
+ vec_free (pool_name);
/* no usable pool for this socket, try to use pool from another one */
for (i = 0; i < vec_len (bm->pktmbuf_pools); i++)