aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/odp_pool.c
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@linaro.org>2018-10-17 16:41:52 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2018-10-18 17:26:39 +0300
commit95cbee5ac9cdcb696d48e6f820593c813f535f8a (patch)
treef20bd14f0d017012451f16fa80531b788f3d437e /platform/linux-generic/odp_pool.c
parent0c8a2c0027e35184cbc6eeadc3a8aa8bd2e8605b (diff)
linux-gen: pool: add max num packets in config file
This config is used to for maximum capability. The default capability needs to be modest so that system memory limit is not exceeded. User may increase maximum number of packets when system memory size allows (and SHM single VA is not used). Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform/linux-generic/odp_pool.c')
-rw-r--r--platform/linux-generic/odp_pool.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index db7a8da3f..d08be4378 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -22,6 +22,7 @@
#include <odp_ring_internal.h>
#include <odp_shm_internal.h>
#include <odp_global_data.h>
+#include <odp_libconfig_internal.h>
#include <string.h>
#include <stdio.h>
@@ -33,8 +34,9 @@
#define UNLOCK(a) odp_ticketlock_unlock(a)
#define LOCK_INIT(a) odp_ticketlock_init(a)
-#define CACHE_BURST 32
-#define RING_SIZE_MIN (2 * CACHE_BURST)
+#define CACHE_BURST 32
+#define RING_SIZE_MIN (2 * CACHE_BURST)
+#define POOL_MAX_NUM_MIN RING_SIZE_MIN
/* Make sure packet buffers don't cross huge page boundaries starting from this
* page size. 2MB is typically the smallest used huge page size. */
@@ -83,6 +85,32 @@ static inline pool_t *pool_from_buf(odp_buffer_t buf)
return buf_hdr->pool_ptr;
}
+static int read_config_file(pool_table_t *pool_tbl)
+{
+ const char *str;
+ int val = 0;
+
+ ODP_PRINT("Pool config:\n");
+
+ str = "pool.pkt.max_num";
+ if (!_odp_libconfig_lookup_int(str, &val)) {
+ ODP_ERR("Config option '%s' not found.\n", str);
+ return -1;
+ }
+
+ if (val > CONFIG_POOL_MAX_NUM || val < POOL_MAX_NUM_MIN) {
+ ODP_ERR("Bad value %s = %u\n", str, val);
+ return -1;
+ }
+
+ pool_tbl->config.pkt_max_num = val;
+ ODP_PRINT(" %s: %i\n", str, val);
+
+ ODP_PRINT("\n");
+
+ return 0;
+}
+
int odp_pool_init_global(void)
{
uint32_t i;
@@ -101,6 +129,11 @@ int odp_pool_init_global(void)
memset(pool_tbl, 0, sizeof(pool_table_t));
pool_tbl->shm = shm;
+ if (read_config_file(pool_tbl)) {
+ odp_shm_free(shm);
+ return -1;
+ }
+
for (i = 0; i < ODP_CONFIG_POOLS; i++) {
pool_t *pool = pool_entry(i);
@@ -950,7 +983,7 @@ int odp_pool_capability(odp_pool_capability_t *capa)
/* Packet pools */
capa->pkt.max_pools = ODP_CONFIG_POOLS;
capa->pkt.max_len = CONFIG_PACKET_MAX_LEN;
- capa->pkt.max_num = CONFIG_POOL_MAX_NUM;
+ capa->pkt.max_num = pool_tbl->config.pkt_max_num;
capa->pkt.min_headroom = CONFIG_PACKET_HEADROOM;
capa->pkt.max_headroom = CONFIG_PACKET_HEADROOM;
capa->pkt.min_tailroom = CONFIG_PACKET_TAILROOM;