aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@linaro.org>2018-10-12 11:06:19 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2018-10-15 16:59:32 +0300
commit664cbd820806256b9f9d44dd879b5fa85c70d40c (patch)
tree46342015c8aa351f7f4b7a9da1c67f1a20e6dfdf
parent01a3bd80c5e56bdfa1868cfb1f030ca3a834d742 (diff)
helper: iplookup: check capabilities
Check pool and queue capabilities instead of assuming e.g. that 1M events can be stored into a queue. Reduced table defines (pool / queue size requirement) as an easy fix to pass tests. Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r--helper/iplookuptable.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/helper/iplookuptable.c b/helper/iplookuptable.c
index 7102eb541..84b4e2cbb 100644
--- a/helper/iplookuptable.c
+++ b/helper/iplookuptable.c
@@ -83,9 +83,9 @@ typedef struct trie_node {
} trie_node_t;
/** Number of L2\L3 entries(subtrees) per cache cube. */
-#define CACHE_NUM_SUBTREE (1 << 13)
+#define CACHE_NUM_SUBTREE (4 * 1024)
/** Number of trie nodes per cache cube. */
-#define CACHE_NUM_TRIE (1 << 20)
+#define CACHE_NUM_TRIE (4 * 1024)
/** @typedef cache_type_t
* Cache node type
@@ -187,12 +187,34 @@ cache_alloc_new_pool(
{
odp_pool_t pool;
odp_pool_param_t param;
+ odp_pool_capability_t pool_capa;
odp_queue_t queue = tbl->free_slots[type];
odp_buffer_t buffer;
char pool_name[ODPH_TABLE_NAME_LEN + 8];
uint32_t size = 0, num = 0;
+ if (odp_pool_capability(&pool_capa)) {
+ ODPH_ERR("pool capa failed\n");
+ return -1;
+ }
+
+ if (pool_capa.buf.max_num) {
+ if (pool_capa.buf.max_num < CACHE_NUM_TRIE ||
+ pool_capa.buf.max_num < CACHE_NUM_SUBTREE) {
+ ODPH_ERR("pool size too small\n");
+ return -1;
+ }
+ }
+
+ if (pool_capa.buf.max_size) {
+ if (pool_capa.buf.max_size < ENTRY_SIZE * ENTRY_NUM_SUBTREE ||
+ pool_capa.buf.max_size < sizeof(trie_node_t)) {
+ ODPH_ERR("buffer size too small\n");
+ return -1;
+ }
+ }
+
/* Create new pool (new free buffers). */
odp_pool_param_init(&param);
param.type = ODP_POOL_BUFFER;
@@ -223,7 +245,11 @@ cache_alloc_new_pool(
while ((buffer = odp_buffer_alloc(pool))
!= ODP_BUFFER_INVALID) {
cache_init_buffer(buffer, type, size);
- odp_queue_enq(queue, odp_buffer_to_event(buffer));
+ if (odp_queue_enq(queue, odp_buffer_to_event(buffer))) {
+ ODPH_DBG("queue enqueue failed\n");
+ odp_buffer_free(buffer);
+ break;
+ }
}
tbl->cache_count[type]++;
@@ -449,10 +475,28 @@ odph_table_t odph_iplookup_table_create(const char *name,
odp_shm_t shm_tbl;
odp_queue_t queue;
odp_queue_param_t qparam;
+ odp_queue_capability_t queue_capa;
unsigned i;
- uint32_t impl_size, l1_size;
+ uint32_t impl_size, l1_size, queue_size;
char queue_name[ODPH_TABLE_NAME_LEN + 2];
+ if (odp_queue_capability(&queue_capa)) {
+ ODPH_ERR("queue capa failed\n");
+ return NULL;
+ }
+
+ if (queue_capa.plain.max_size) {
+ if (queue_capa.plain.max_size < CACHE_NUM_TRIE ||
+ queue_capa.plain.max_size < CACHE_NUM_SUBTREE) {
+ ODPH_ERR("queue size too small\n");
+ return NULL;
+ }
+ }
+
+ queue_size = CACHE_NUM_TRIE;
+ if (CACHE_NUM_SUBTREE > CACHE_NUM_TRIE)
+ queue_size = CACHE_NUM_SUBTREE;
+
/* Check for valid parameters */
if (strlen(name) == 0) {
ODPH_DBG("invalid parameters\n");
@@ -502,6 +546,7 @@ odph_table_t odph_iplookup_table_create(const char *name,
odp_queue_param_init(&qparam);
qparam.type = ODP_QUEUE_TYPE_PLAIN;
+ qparam.size = queue_size;
sprintf(queue_name, "%s_%d", name, i);
queue = odp_queue_create(queue_name, &qparam);
if (queue == ODP_QUEUE_INVALID) {