aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoltan Kiss <zoltan.kiss@linaro.org>2016-07-18 14:56:13 +0100
committerZoltan Kiss <zoltan.kiss@linaro.org>2016-07-26 15:57:45 +0100
commiteaa5e887731be7a4e2ab40aabbd421e9bdbe0291 (patch)
tree5286ee8a02018157106a6304ffc6b7eda32488e9
parent49f2d7589ba3a6e76b47078c2f13b0b5da5594fe (diff)
linux-dpdk: pool: check pool name lengthv1.10.1.0_DPDK_16.04
DPDK only supports RTE_MEMPOOL_NAMESIZE, this patch trims the name, and warns about name collision. Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
-rw-r--r--platform/linux-dpdk/README8
-rw-r--r--platform/linux-dpdk/include/odp_pool_internal.h4
-rw-r--r--platform/linux-dpdk/odp_pool.c17
3 files changed, 24 insertions, 5 deletions
diff --git a/platform/linux-dpdk/README b/platform/linux-dpdk/README
index c74b39b68..09c95f1e9 100644
--- a/platform/linux-dpdk/README
+++ b/platform/linux-dpdk/README
@@ -3,6 +3,14 @@ All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
+
+ERRATA:
+- DPDK 16.07 and earlier supports pool names with RTE_MEMZONE_NAMESIZE
+ characters (including terminating NULL), which is 6 characters less than
+ ODP_POOL_NAME_LEN. Names reaching into this interval might collide if the
+ first 25 characters are not unique.
+
+
1. Rationale
=================================================
diff --git a/platform/linux-dpdk/include/odp_pool_internal.h b/platform/linux-dpdk/include/odp_pool_internal.h
index ee0a5d1c9..693442965 100644
--- a/platform/linux-dpdk/include/odp_pool_internal.h
+++ b/platform/linux-dpdk/include/odp_pool_internal.h
@@ -31,10 +31,6 @@ extern "C" {
/* for DPDK */
#include <rte_mempool.h>
-#include <rte_memzone.h>
-
-ODP_STATIC_ASSERT(ODP_POOL_NAME_LEN == RTE_MEMZONE_NAMESIZE,
- "ERROR: Pool name sizes doesn't match");
/* Use ticketlock instead of spinlock */
#define POOL_USE_TICKETLOCK
diff --git a/platform/linux-dpdk/odp_pool.c b/platform/linux-dpdk/odp_pool.c
index 67e2fb259..f4cb4d486 100644
--- a/platform/linux-dpdk/odp_pool.c
+++ b/platform/linux-dpdk/odp_pool.c
@@ -237,10 +237,16 @@ odp_pool_t odp_pool_create(const char *name, odp_pool_param_t *params)
size_t hdr_size;
pool_entry_t *pool;
uint32_t buf_align, blk_size, headroom, tailroom, seg_len;
+ char *rte_name = NULL;
#if RTE_MEMPOOL_CACHE_MAX_SIZE > 0
unsigned j;
#endif
+ if (strlen(name) > ODP_POOL_NAME_LEN - 1) {
+ ODP_ERR("Name too long! (%u characters)\n", strlen(name));
+ return ODP_POOL_INVALID;
+ }
+
/* Find an unused buffer pool slot and initalize it as requested */
for (i = 0; i < ODP_CONFIG_POOLS; i++) {
uint32_t num;
@@ -368,8 +374,16 @@ odp_pool_t odp_pool_create(const char *name, odp_pool_param_t *params)
#endif
ODP_DBG("cache_size %d\n", cache_size);
+ if (strlen(name) > RTE_MEMPOOL_NAMESIZE - 1) {
+ ODP_ERR("Max pool name size: %u. Trimming %u long, name collision might happen!\n",
+ RTE_MEMPOOL_NAMESIZE - 1, strlen(name));
+ rte_name = malloc(RTE_MEMPOOL_NAMESIZE);
+ snprintf(rte_name, RTE_MEMPOOL_NAMESIZE - 1, "%s",
+ name);
+ }
+
pool->s.rte_mempool =
- rte_mempool_create(name,
+ rte_mempool_create(rte_name ? rte_name : name,
num,
mb_size,
cache_size,
@@ -380,6 +394,7 @@ odp_pool_t odp_pool_create(const char *name, odp_pool_param_t *params)
&mb_ctor_arg,
rte_socket_id(),
0);
+ free(rte_name);
if (pool->s.rte_mempool == NULL) {
ODP_ERR("Cannot init DPDK mbuf pool: %s\n",
rte_strerror(rte_errno));