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: e30b2833c4 ("security: update session create API")

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
This commit is contained in:
Vladimir Medvedkin 2020-10-27 14:03:40 +00:00 committed by Akhil Goyal
parent 8bd1040a70
commit 57ddbf7edd

View File

@ -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,