From 57ddbf7edd9c5041603e224fbbb62c11ce423135 Mon Sep 17 00:00:00 2001 From: Vladimir Medvedkin Date: Tue, 27 Oct 2020 14:03:40 +0000 Subject: [PATCH] examples/ipsec-secgw: fix session mempool initialisation Creation of a session mempool may fail in the case of a single lcore and a low number of SA. In case when there is only one lcore and number of configures SA less then (0.5 * CDEV_MP_CACHE_SZ) then creation of the mempool fails with EINVAL. This is because the number of requested items is less than (cache size * CDEV_MP_CACHE_MULTIPLIER). Hence, the number of elements in mempool is increased in such cases. Fixes: e30b2833c47c ("security: update session create API") Signed-off-by: Vladimir Medvedkin Acked-by: Akhil Goyal --- examples/ipsec-secgw/ipsec-secgw.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index bbe7ce48d9..20d69ba813 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -65,6 +65,7 @@ volatile bool force_quit; #define CDEV_QUEUE_DESC 2048 #define CDEV_MAP_ENTRIES 16384 #define CDEV_MP_CACHE_SZ 64 +#define CDEV_MP_CACHE_MULTIPLIER 1.5 /* from rte_mempool.c */ #define MAX_QUEUE_PAIRS 1 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */ @@ -2349,6 +2350,8 @@ session_pool_init(struct socket_ctx *ctx, int32_t socket_id, size_t sess_sz) "sess_mp_%u", socket_id); nb_sess = (get_nb_crypto_sessions() + CDEV_MP_CACHE_SZ * rte_lcore_count()); + nb_sess = RTE_MAX(nb_sess, CDEV_MP_CACHE_SZ * + CDEV_MP_CACHE_MULTIPLIER); sess_mp = rte_cryptodev_sym_session_pool_create( mp_name, nb_sess, sess_sz, CDEV_MP_CACHE_SZ, 0, socket_id); @@ -2373,6 +2376,8 @@ session_priv_pool_init(struct socket_ctx *ctx, int32_t socket_id, "sess_mp_priv_%u", socket_id); nb_sess = (get_nb_crypto_sessions() + CDEV_MP_CACHE_SZ * rte_lcore_count()); + nb_sess = RTE_MAX(nb_sess, CDEV_MP_CACHE_SZ * + CDEV_MP_CACHE_MULTIPLIER); sess_mp = rte_mempool_create(mp_name, nb_sess, sess_sz, -- 2.20.1