From: Fan Zhang <roy.fan.zhang@intel.com>
To: dev@dpdk.org
Cc: akhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com,
fiona.trahe@intel.com
Subject: [dpdk-dev] [PATCH v4 05/12] examples: use separate session mempools
Date: Wed, 9 Jan 2019 22:56:02 +0000 [thread overview]
Message-ID: <20190109225609.20590-6-roy.fan.zhang@intel.com> (raw)
In-Reply-To: <20190109225609.20590-1-roy.fan.zhang@intel.com>
This patch uses the two session mempool approach to all cryptodev
sample applications. One mempool is for session header objects, and
the other is for session private data.
Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
---
examples/fips_validation/main.c | 34 +++++++++++++-
examples/ip_pipeline/cli.c | 49 +++++++++-----------
examples/ip_pipeline/cryptodev.c | 49 +++++++++++++++++++-
examples/ip_pipeline/cryptodev.h | 3 ++
examples/ip_pipeline/examples/flow_crypto.cli | 9 ++--
examples/ipsec-secgw/ipsec-secgw.c | 48 +++++++++++++------
examples/ipsec-secgw/ipsec.c | 2 +-
examples/ipsec-secgw/ipsec.h | 2 +
examples/l2fwd-crypto/main.c | 66 +++++++++++++++++----------
examples/vhost_crypto/main.c | 13 +++++-
10 files changed, 200 insertions(+), 75 deletions(-)
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index 384b7a240..bd9aa9018 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -29,6 +29,8 @@ struct cryptodev_fips_validate_env {
uint32_t is_path_folder;
uint32_t dev_id;
struct rte_mempool *mpool;
+ struct rte_mempool *sess_mpool;
+ struct rte_mempool *sess_priv_mpool;
struct rte_mempool *op_pool;
struct rte_mbuf *mbuf;
struct rte_crypto_op *op;
@@ -40,6 +42,8 @@ cryptodev_fips_validate_app_int(void)
{
struct rte_cryptodev_config conf = {rte_socket_id(), 1};
struct rte_cryptodev_qp_conf qp_conf = {128, NULL, NULL};
+ uint32_t sess_sz = rte_cryptodev_sym_get_private_session_size(
+ env.dev_id);
int ret;
ret = rte_cryptodev_configure(env.dev_id, &conf);
@@ -58,6 +62,17 @@ cryptodev_fips_validate_app_int(void)
ret = -ENOMEM;
+ env.sess_mpool = rte_cryptodev_sym_session_pool_create(
+ "FIPS_SESS_MEMPOOL", 16, 0, 0, 0, rte_socket_id());
+ if (!env.sess_mpool)
+ goto error_exit;
+
+ env.sess_priv_mpool = rte_mempool_create("FIPS_SESS_PRIV_MEMPOOL",
+ 16, sess_sz, 0, 0, NULL, NULL, NULL,
+ NULL, rte_socket_id(), 0);
+ if (!env.sess_priv_mpool)
+ goto error_exit;
+
env.op_pool = rte_crypto_op_pool_create(
"FIPS_OP_POOL",
RTE_CRYPTO_OP_TYPE_SYMMETRIC,
@@ -75,10 +90,23 @@ cryptodev_fips_validate_app_int(void)
if (!env.op)
goto error_exit;
+ qp_conf.mp_session = env.sess_mpool;
+ qp_conf.mp_session_private = env.sess_priv_mpool;
+
+ ret = rte_cryptodev_queue_pair_setup(env.dev_id, 0, &qp_conf,
+ rte_socket_id());
+ if (ret < 0)
+ goto error_exit;
+
return 0;
error_exit:
+
rte_mempool_free(env.mpool);
+ if (env.sess_mpool)
+ rte_mempool_free(env.sess_mpool);
+ if (env.sess_priv_mpool)
+ rte_mempool_free(env.sess_priv_mpool);
if (env.op_pool)
rte_mempool_free(env.op_pool);
@@ -93,6 +121,8 @@ cryptodev_fips_validate_app_uninit(void)
rte_cryptodev_sym_session_clear(env.dev_id, env.sess);
rte_cryptodev_sym_session_free(env.sess);
rte_mempool_free(env.mpool);
+ rte_mempool_free(env.sess_mpool);
+ rte_mempool_free(env.sess_priv_mpool);
rte_mempool_free(env.op_pool);
}
@@ -797,12 +827,12 @@ fips_run_test(void)
if (ret < 0)
return ret;
- env.sess = rte_cryptodev_sym_session_create(env.mpool);
+ env.sess = rte_cryptodev_sym_session_create(env.sess_mpool);
if (!env.sess)
return -ENOMEM;
ret = rte_cryptodev_sym_session_init(env.dev_id,
- env.sess, &xform, env.mpool);
+ env.sess, &xform, env.sess_priv_mpool);
if (ret < 0) {
RTE_LOG(ERR, USER1, "Error %i: Init session\n",
ret);
diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index 910386282..a92467e63 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -790,7 +790,8 @@ cmd_kni(char **tokens,
static const char cmd_cryptodev_help[] =
"cryptodev <cryptodev_name>\n"
" dev <device_name> | dev_id <device_id>\n"
-" queue <n_queues> <queue_size>\n";
+" queue <n_queues> <queue_size>\n"
+" max_sessions <n_sessions>";
static void
cmd_cryptodev(char **tokens,
@@ -802,7 +803,7 @@ cmd_cryptodev(char **tokens,
char *name;
memset(¶ms, 0, sizeof(params));
- if (n_tokens != 7) {
+ if (n_tokens != 9) {
snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
return;
}
@@ -825,7 +826,7 @@ cmd_cryptodev(char **tokens,
if (strcmp(tokens[4], "queue")) {
snprintf(out, out_size, MSG_ARG_NOT_FOUND,
- "4");
+ "queue");
return;
}
@@ -841,6 +842,18 @@ cmd_cryptodev(char **tokens,
return;
}
+ if (strcmp(tokens[7], "max_sessions")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND,
+ "max_sessions");
+ return;
+ }
+
+ if (parser_read_uint32(¶ms.session_pool_size, tokens[8]) < 0) {
+ snprintf(out, out_size, MSG_ARG_INVALID,
+ "queue_size");
+ return;
+ }
+
if (cryptodev_create(name, ¶ms) == NULL) {
snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
return;
@@ -1030,9 +1043,7 @@ static const char cmd_table_action_profile_help[] =
" stats none | pkts]\n"
" [stats pkts | bytes | both]\n"
" [time]\n"
-" [sym_crypto dev <CRYPTODEV_NAME> offset <op_offset> "
-" mempool_create <mempool_name>\n"
-" mempool_init <mempool_name>]\n"
+" [sym_crypto dev <CRYPTODEV_NAME> offset <op_offset>]\n"
" [tag]\n"
" [decap]\n";
@@ -1404,13 +1415,10 @@ cmd_table_action_profile(char **tokens,
if ((t0 < n_tokens) && (strcmp(tokens[t0], "sym_crypto") == 0)) {
struct cryptodev *cryptodev;
- struct mempool *mempool;
- if (n_tokens < t0 + 9 ||
+ if (n_tokens < t0 + 5 ||
strcmp(tokens[t0 + 1], "dev") ||
- strcmp(tokens[t0 + 3], "offset") ||
- strcmp(tokens[t0 + 5], "mempool_create") ||
- strcmp(tokens[t0 + 7], "mempool_init")) {
+ strcmp(tokens[t0 + 3], "offset")) {
snprintf(out, out_size, MSG_ARG_MISMATCH,
"table action profile sym_crypto");
return;
@@ -1432,25 +1440,12 @@ cmd_table_action_profile(char **tokens,
return;
}
- mempool = mempool_find(tokens[t0 + 6]);
- if (mempool == NULL) {
- snprintf(out, out_size, MSG_ARG_INVALID,
- "table action profile sym_crypto");
- return;
- }
- p.sym_crypto.mp_create = mempool->m;
-
- mempool = mempool_find(tokens[t0 + 8]);
- if (mempool == NULL) {
- snprintf(out, out_size, MSG_ARG_INVALID,
- "table action profile sym_crypto");
- return;
- }
- p.sym_crypto.mp_init = mempool->m;
+ p.sym_crypto.mp_create = cryptodev->mp_create;
+ p.sym_crypto.mp_init = cryptodev->mp_init;
p.action_mask |= 1LLU << RTE_TABLE_ACTION_SYM_CRYPTO;
- t0 += 9;
+ t0 += 5;
} /* sym_crypto */
if ((t0 < n_tokens) && (strcmp(tokens[t0], "tag") == 0)) {
diff --git a/examples/ip_pipeline/cryptodev.c b/examples/ip_pipeline/cryptodev.c
index b365810de..ac1e38d6a 100644
--- a/examples/ip_pipeline/cryptodev.c
+++ b/examples/ip_pipeline/cryptodev.c
@@ -11,6 +11,8 @@
#include "cryptodev.h"
+#define PIPELINE_CRYPTO_SESSION_CACHE_SIZE 128
+
static struct cryptodev_list cryptodev_list;
int
@@ -53,13 +55,16 @@ cryptodev_create(const char *name, struct cryptodev_params *params)
struct cryptodev *cryptodev;
uint32_t dev_id, i;
uint32_t socket_id;
+ uint32_t cache_size;
+ char mp_name[NAME_SIZE];
int status;
/* Check input params */
if ((name == NULL) ||
cryptodev_find(name) ||
(params->n_queues == 0) ||
- (params->queue_size == 0))
+ (params->queue_size == 0) ||
+ (params->session_pool_size == 0))
return NULL;
if (params->dev_name) {
@@ -75,6 +80,11 @@ cryptodev_create(const char *name, struct cryptodev_params *params)
dev_id = params->dev_id;
}
+ cache_size = (params->session_pool_size / 2 <
+ PIPELINE_CRYPTO_SESSION_CACHE_SIZE) ?
+ (params->session_pool_size / 2) :
+ PIPELINE_CRYPTO_SESSION_CACHE_SIZE;
+
socket_id = rte_cryptodev_socket_id(dev_id);
rte_cryptodev_info_get(dev_id, &dev_info);
@@ -111,7 +121,44 @@ cryptodev_create(const char *name, struct cryptodev_params *params)
cryptodev->dev_id = dev_id;
cryptodev->n_queues = params->n_queues;
+ snprintf(mp_name, NAME_SIZE, "%s_mp%u", name, dev_id);
+ cryptodev->mp_create = rte_cryptodev_sym_session_pool_create(
+ mp_name,
+ params->session_pool_size,
+ 0,
+ cache_size,
+ 0,
+ socket_id);
+ if (!cryptodev->mp_create)
+ goto error_exit;
+
+ snprintf(mp_name, NAME_SIZE, "%s_mp_priv%u", name, dev_id);
+ cryptodev->mp_init = rte_mempool_create(
+ NULL,
+ params->session_pool_size,
+ rte_cryptodev_sym_get_private_session_size(dev_id),
+ cache_size,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ socket_id,
+ 0);
+ if (!cryptodev->mp_init)
+ goto error_exit;
+
TAILQ_INSERT_TAIL(&cryptodev_list, cryptodev, node);
return cryptodev;
+
+error_exit:
+ if (cryptodev->mp_create)
+ rte_mempool_free(cryptodev->mp_create);
+ if (cryptodev->mp_init)
+ rte_mempool_free(cryptodev->mp_init);
+
+ free(cryptodev);
+
+ return NULL;
}
diff --git a/examples/ip_pipeline/cryptodev.h b/examples/ip_pipeline/cryptodev.h
index d06b3f2f1..d00434379 100644
--- a/examples/ip_pipeline/cryptodev.h
+++ b/examples/ip_pipeline/cryptodev.h
@@ -17,6 +17,8 @@ struct cryptodev {
char name[NAME_SIZE];
uint16_t dev_id;
uint32_t n_queues;
+ struct rte_mempool *mp_create;
+ struct rte_mempool *mp_init;
};
TAILQ_HEAD(cryptodev_list, cryptodev);
@@ -35,6 +37,7 @@ struct cryptodev_params {
uint32_t dev_id; /**< Valid only when *dev_name* is NULL. */
uint32_t n_queues;
uint32_t queue_size;
+ uint32_t session_pool_size;
};
struct cryptodev *
diff --git a/examples/ip_pipeline/examples/flow_crypto.cli b/examples/ip_pipeline/examples/flow_crypto.cli
index 9b639deb7..849f9d5fe 100644
--- a/examples/ip_pipeline/examples/flow_crypto.cli
+++ b/examples/ip_pipeline/examples/flow_crypto.cli
@@ -21,14 +21,13 @@
; 5 Crypto Operation 1792 160
mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 1
-mempool MEMPOOL_SESSION0 buffer 1024 pool 1024 cache 128 cpu 1
-link LINK0 dev 0000:81:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
+link LINK0 dev 81:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
#Cryptodev
-cryptodev CRYPTO0 dev crypto_aesni_gcm0 queue 1 1024
+cryptodev CRYPTO0 dev crypto_aesni_gcm0 queue 1 1024 max_sessions 512
-table action profile AP0 ipv4 offset 270 fwd sym_crypto dev CRYPTO0 offset 1792 mempool_create MEMPOOL_SESSION0 mempool_init MEMPOOL_SESSION0
+table action profile AP0 ipv4 offset 270 fwd sym_crypto dev CRYPTO0 offset 1792
table action profile AP1 ipv4 offset 270 fwd
pipeline PIPELINE0 period 10 offset_port_id 0 cpu 1
@@ -46,7 +45,7 @@ pipeline PIPELINE0 table match stub action AP1
pipeline PIPELINE0 port in 0 table 0
pipeline PIPELINE0 port in 1 table 1
-thread 24 pipeline PIPELINE0 enable
+thread 2 pipeline PIPELINE0 enable
pipeline PIPELINE0 table 0 rule add match default action fwd port 2
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index a0ff8f7f7..fc102a396 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -55,7 +55,7 @@
#define CDEV_QUEUE_DESC 2048
#define CDEV_MAP_ENTRIES 16384
-#define CDEV_MP_NB_OBJS 2048
+#define CDEV_MP_NB_OBJS 1024
#define CDEV_MP_CACHE_SZ 64
#define MAX_QUEUE_PAIRS 1
@@ -820,11 +820,15 @@ main_loop(__attribute__((unused)) void *dummy)
qconf->inbound.sa_ctx = socket_ctx[socket_id].sa_in;
qconf->inbound.cdev_map = cdev_map_in;
qconf->inbound.session_pool = socket_ctx[socket_id].session_pool;
+ qconf->inbound.session_priv_pool =
+ socket_ctx[socket_id].session_priv_pool;
qconf->outbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_out;
qconf->outbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_out;
qconf->outbound.sa_ctx = socket_ctx[socket_id].sa_out;
qconf->outbound.cdev_map = cdev_map_out;
qconf->outbound.session_pool = socket_ctx[socket_id].session_pool;
+ qconf->outbound.session_priv_pool =
+ socket_ctx[socket_id].session_priv_pool;
if (qconf->nb_rx_queue == 0) {
RTE_LOG(INFO, IPSEC, "lcore %u has nothing to do\n", lcore_id);
@@ -1460,10 +1464,10 @@ cryptodevs_init(void)
dev_conf.nb_queue_pairs = qp;
uint32_t dev_max_sess = cdev_info.sym.max_nb_sessions;
- if (dev_max_sess != 0 && dev_max_sess < (CDEV_MP_NB_OBJS / 2))
+ if (dev_max_sess != 0 && dev_max_sess < CDEV_MP_NB_OBJS)
rte_exit(EXIT_FAILURE,
"Device does not support at least %u "
- "sessions", CDEV_MP_NB_OBJS / 2);
+ "sessions", CDEV_MP_NB_OBJS);
if (!socket_ctx[dev_conf.socket_id].session_pool) {
char mp_name[RTE_MEMPOOL_NAMESIZE];
@@ -1471,6 +1475,19 @@ cryptodevs_init(void)
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
"sess_mp_%u", dev_conf.socket_id);
+ sess_mp = rte_cryptodev_sym_session_pool_create(
+ mp_name, CDEV_MP_NB_OBJS,
+ 0, CDEV_MP_CACHE_SZ, 0,
+ dev_conf.socket_id);
+ socket_ctx[dev_conf.socket_id].session_pool = sess_mp;
+ }
+
+ if (!socket_ctx[dev_conf.socket_id].session_priv_pool) {
+ char mp_name[RTE_MEMPOOL_NAMESIZE];
+ struct rte_mempool *sess_mp;
+
+ snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
+ "sess_mp_priv_%u", dev_conf.socket_id);
sess_mp = rte_mempool_create(mp_name,
CDEV_MP_NB_OBJS,
max_sess_sz,
@@ -1478,25 +1495,28 @@ cryptodevs_init(void)
0, NULL, NULL, NULL,
NULL, dev_conf.socket_id,
0);
- if (sess_mp == NULL)
- rte_exit(EXIT_FAILURE,
- "Cannot create session pool on socket %d\n",
- dev_conf.socket_id);
- else
- printf("Allocated session pool on socket %d\n",
- dev_conf.socket_id);
- socket_ctx[dev_conf.socket_id].session_pool = sess_mp;
+ socket_ctx[dev_conf.socket_id].session_priv_pool =
+ sess_mp;
}
+ if (!socket_ctx[dev_conf.socket_id].session_priv_pool ||
+ !socket_ctx[dev_conf.socket_id].session_pool)
+ rte_exit(EXIT_FAILURE,
+ "Cannot create session pool on socket %d\n",
+ dev_conf.socket_id);
+ else
+ printf("Allocated session pool on socket %d\n",
+ dev_conf.socket_id);
+
if (rte_cryptodev_configure(cdev_id, &dev_conf))
rte_panic("Failed to initialize cryptodev %u\n",
cdev_id);
qp_conf.nb_descriptors = CDEV_QUEUE_DESC;
qp_conf.mp_session =
- socket_ctx[dev_conf.socket_id].session_pool;
+ socket_ctx[dev_conf.socket_id].session_pool;
qp_conf.mp_session_private =
- socket_ctx[dev_conf.socket_id].session_pool;
+ socket_ctx[dev_conf.socket_id].session_priv_pool;
for (qp = 0; qp < dev_conf.nb_queue_pairs; qp++)
if (rte_cryptodev_queue_pair_setup(cdev_id, qp,
&qp_conf, dev_conf.socket_id))
@@ -1521,7 +1541,7 @@ cryptodevs_init(void)
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
"sess_mp_%u", socket_id);
sess_mp = rte_mempool_create(mp_name,
- CDEV_MP_NB_OBJS,
+ (CDEV_MP_NB_OBJS * 2),
max_sess_sz,
CDEV_MP_CACHE_SZ,
0, NULL, NULL, NULL,
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index 3d415f1af..9dc6e173c 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -323,7 +323,7 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa)
ipsec_ctx->session_pool);
rte_cryptodev_sym_session_init(ipsec_ctx->tbl[cdev_id_qp].id,
sa->crypto_session, sa->xforms,
- ipsec_ctx->session_pool);
+ ipsec_ctx->session_priv_pool);
rte_cryptodev_info_get(ipsec_ctx->tbl[cdev_id_qp].id,
&cdev_info);
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index c998c8076..f35552857 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -144,6 +144,7 @@ struct ipsec_ctx {
uint16_t last_qp;
struct cdev_qp tbl[MAX_QP_PER_LCORE];
struct rte_mempool *session_pool;
+ struct rte_mempool *session_priv_pool;
struct rte_mbuf *ol_pkts[MAX_PKT_BURST] __rte_aligned(sizeof(void *));
uint16_t ol_pkts_cnt;
};
@@ -166,6 +167,7 @@ struct socket_ctx {
struct rt_ctx *rt_ip6;
struct rte_mempool *mbuf_pool;
struct rte_mempool *session_pool;
+ struct rte_mempool *session_priv_pool;
};
struct cnt_blk {
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 1df7ba743..9982f07e9 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -221,7 +221,10 @@ static struct rte_eth_conf port_conf = {
struct rte_mempool *l2fwd_pktmbuf_pool;
struct rte_mempool *l2fwd_crypto_op_pool;
-struct rte_mempool *session_pool_socket[RTE_MAX_NUMA_NODES] = { 0 };
+static struct {
+ struct rte_mempool *sess_mp;
+ struct rte_mempool *priv_mp;
+} session_pool_socket[RTE_MAX_NUMA_NODES];
/* Per-port statistics struct */
struct l2fwd_port_statistics {
@@ -645,7 +648,6 @@ initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id)
return NULL;
uint8_t socket_id = (uint8_t) retval;
- struct rte_mempool *sess_mp = session_pool_socket[socket_id];
if (options->xform_chain == L2FWD_CRYPTO_AEAD) {
first_xform = &options->aead_xform;
@@ -661,13 +663,14 @@ initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id)
first_xform = &options->auth_xform;
}
- session = rte_cryptodev_sym_session_create(sess_mp);
-
+ session = rte_cryptodev_sym_session_create(
+ session_pool_socket[socket_id].sess_mp);
if (session == NULL)
return NULL;
if (rte_cryptodev_sym_session_init(cdev_id, session,
- first_xform, sess_mp) < 0)
+ first_xform,
+ session_pool_socket[socket_id].priv_mp) < 0)
return NULL;
return session;
@@ -2267,38 +2270,54 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
rte_cryptodev_scheduler_slaves_get(cdev_id,
NULL);
- sessions_needed = 2 * enabled_cdev_count * nb_slaves;
+ sessions_needed = enabled_cdev_count * nb_slaves;
#endif
} else
- sessions_needed = 2 * enabled_cdev_count;
+ sessions_needed = enabled_cdev_count;
- if (session_pool_socket[socket_id] == NULL) {
+ if (session_pool_socket[socket_id].priv_mp == NULL) {
char mp_name[RTE_MEMPOOL_NAMESIZE];
- struct rte_mempool *sess_mp;
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
- "sess_mp_%u", socket_id);
+ "priv_sess_mp_%u", socket_id);
- /*
- * Create enough objects for session headers and
- * device private data
- */
- sess_mp = rte_mempool_create(mp_name,
+ session_pool_socket[socket_id].priv_mp =
+ rte_mempool_create(mp_name,
sessions_needed,
max_sess_sz,
- SESSION_POOL_CACHE_SIZE,
- 0, NULL, NULL, NULL,
+ 0, 0, NULL, NULL, NULL,
NULL, socket_id,
0);
- if (sess_mp == NULL) {
- printf("Cannot create session pool on socket %d\n",
+ if (session_pool_socket[socket_id].priv_mp == NULL) {
+ printf("Cannot create pool on socket %d\n",
+ socket_id);
+ return -ENOMEM;
+ }
+
+ printf("Allocated pool \"%s\" on socket %d\n",
+ mp_name, socket_id);
+ }
+
+ if (session_pool_socket[socket_id].sess_mp == NULL) {
+ char mp_name[RTE_MEMPOOL_NAMESIZE];
+ snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
+ "sess_mp_%u", socket_id);
+
+ session_pool_socket[socket_id].sess_mp =
+ rte_cryptodev_sym_session_pool_create(
+ mp_name,
+ sessions_needed,
+ 0, 0, 0, socket_id);
+
+ if (session_pool_socket[socket_id].sess_mp == NULL) {
+ printf("Cannot create pool on socket %d\n",
socket_id);
return -ENOMEM;
}
- printf("Allocated session pool on socket %d\n", socket_id);
- session_pool_socket[socket_id] = sess_mp;
+ printf("Allocated pool \"%s\" on socket %d\n",
+ mp_name, socket_id);
}
/* Set AEAD parameters */
@@ -2443,8 +2462,9 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
}
qp_conf.nb_descriptors = 2048;
- qp_conf.mp_session = session_pool_socket[socket_id];
- qp_conf.mp_session_private = session_pool_socket[socket_id];
+ qp_conf.mp_session = session_pool_socket[socket_id].sess_mp;
+ qp_conf.mp_session_private =
+ session_pool_socket[socket_id].priv_mp;
retval = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
socket_id);
diff --git a/examples/vhost_crypto/main.c b/examples/vhost_crypto/main.c
index cb30f84c0..8bdcb3a9c 100644
--- a/examples/vhost_crypto/main.c
+++ b/examples/vhost_crypto/main.c
@@ -46,6 +46,7 @@ struct vhost_crypto_info {
int vids[MAX_NB_SOCKETS];
uint32_t nb_vids;
struct rte_mempool *sess_pool;
+ struct rte_mempool *sess_priv_pool;
struct rte_mempool *cop_pool;
uint8_t cid;
uint32_t qid;
@@ -289,6 +290,7 @@ new_device(int vid)
}
ret = rte_vhost_crypto_create(vid, info->cid, info->sess_pool,
+ info->sess_priv_pool,
rte_lcore_to_socket_id(options.los[i].lcore_id));
if (ret) {
RTE_LOG(ERR, USER1, "Cannot create vhost crypto\n");
@@ -448,6 +450,7 @@ free_resource(void)
rte_mempool_free(info->cop_pool);
rte_mempool_free(info->sess_pool);
+ rte_mempool_free(info->sess_priv_pool);
for (j = 0; j < lo->nb_sockets; j++) {
rte_vhost_driver_unregister(lo->socket_files[i]);
@@ -528,11 +531,17 @@ main(int argc, char *argv[])
}
snprintf(name, 127, "SESS_POOL_%u", lo->lcore_id);
- info->sess_pool = rte_mempool_create(name, SESSION_MAP_ENTRIES,
+ info->sess_pool = rte_cryptodev_sym_session_pool_create(name,
+ SESSION_MAP_ENTRIES, 0, 0, 0,
+ rte_lcore_to_socket_id(lo->lcore_id));
+
+ snprintf(name, 127, "SESS_POOL_PRIV_%u", lo->lcore_id);
+ info->sess_priv_pool = rte_mempool_create(name,
+ SESSION_MAP_ENTRIES,
rte_cryptodev_sym_get_private_session_size(
info->cid), 64, 0, NULL, NULL, NULL, NULL,
rte_lcore_to_socket_id(lo->lcore_id), 0);
- if (!info->sess_pool) {
+ if (!info->sess_priv_pool || info->sess_pool) {
RTE_LOG(ERR, USER1, "Failed to create mempool");
goto error_exit;
}
--
2.13.6
next prev parent reply other threads:[~2019-01-09 22:56 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 17:24 [dpdk-dev] [PATCH 0/2] lib/cryptodev: change qp conf and sym session Fan Zhang
2018-11-15 17:24 ` [dpdk-dev] [PATCH 1/2] cryptodev: change queue pair configure structure Fan Zhang
2018-11-16 12:05 ` Ananyev, Konstantin
2018-11-19 10:12 ` Zhang, Roy Fan
2018-12-04 16:05 ` Trahe, Fiona
2018-11-15 17:24 ` [dpdk-dev] [PATCH 2/2] cryptodev: change symmetric session structure Fan Zhang
2018-11-16 0:47 ` Ananyev, Konstantin
2018-11-16 14:32 ` Ananyev, Konstantin
2018-11-19 10:11 ` Zhang, Roy Fan
2018-12-11 10:34 ` [dpdk-dev] [PATCH v2 0/2] lib/cryptodev: change qp conf and sym session Fan Zhang
2018-12-11 10:34 ` [dpdk-dev] [PATCH v2 1/2] cryptodev: change queue pair configure structure Fan Zhang
2018-12-17 19:31 ` Trahe, Fiona
2018-12-11 10:34 ` [dpdk-dev] [PATCH v2 2/2] cryptodev: change symmetric session structure Fan Zhang
2018-12-17 20:29 ` Trahe, Fiona
2018-12-18 16:25 ` Zhang, Roy Fan
2018-12-18 16:32 ` Trahe, Fiona
2018-12-11 12:26 ` [dpdk-dev] [PATCH v2 0/2] lib/cryptodev: change qp conf and sym session Ananyev, Konstantin
2018-12-21 13:55 ` [dpdk-dev] [PATCH v3 0/2] cryptodev: " Fan Zhang
2018-12-21 13:55 ` [dpdk-dev] [PATCH v3 1/2] cryptodev: change queue pair configure structure Fan Zhang
2019-01-08 23:20 ` De Lara Guarch, Pablo
2019-01-09 11:30 ` Zhang, Roy Fan
2019-01-09 10:41 ` De Lara Guarch, Pablo
2018-12-21 13:55 ` [dpdk-dev] [PATCH v3 2/2] cryptodev: change symmetric session structure Fan Zhang
2019-01-08 16:12 ` Trahe, Fiona
2019-01-09 11:01 ` De Lara Guarch, Pablo
2019-01-09 11:10 ` Zhang, Roy Fan
2019-01-09 22:55 ` [dpdk-dev] [PATCH v4 00/12] cryptodev: change qp conf and sym session Fan Zhang
2019-01-09 22:55 ` [dpdk-dev] [PATCH v4 01/12] cryptodev: change queue pair configure structure Fan Zhang
2019-01-10 9:47 ` De Lara Guarch, Pablo
2019-01-10 11:24 ` De Lara Guarch, Pablo
2019-01-09 22:55 ` [dpdk-dev] [PATCH v4 02/12] cryptodev: add sym session mempool create Fan Zhang
2019-01-10 11:22 ` De Lara Guarch, Pablo
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 03/12] app/test-crypto-perf: use separate session mempools Fan Zhang
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 04/12] net/softnic: " Fan Zhang
2019-01-09 22:56 ` Fan Zhang [this message]
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 06/12] vhost/crypto: " Fan Zhang
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 07/12] test/crypto: " Fan Zhang
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 08/12] cryptodev: add sym session header size API Fan Zhang
2019-01-10 13:28 ` De Lara Guarch, Pablo
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 09/12] cryptodev: update symmetric session structure Fan Zhang
2019-01-10 13:06 ` De Lara Guarch, Pablo
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 10/12] cryptodev: add user data size to symmetric session Fan Zhang
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 11/12] cryptodev: add reference count to session private data Fan Zhang
2019-01-10 12:35 ` De Lara Guarch, Pablo
2019-01-09 22:56 ` [dpdk-dev] [PATCH v4 12/12] cryptodev: add opaque data field to symmetric session Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 00/12] cryptodev: change qp conf and sym session Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 01/12] cryptodev: change queue pair configure structure Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 02/12] cryptodev: add sym session mempool create Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 03/12] app/test-crypto-perf: use separate session mempools Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 04/12] net/softnic: " Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 05/12] examples: " Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 06/12] vhost/crypto: " Fan Zhang
2019-01-11 9:13 ` Maxime Coquelin
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 07/12] test/crypto: " Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 08/12] cryptodev: add sym session header size API Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 09/12] cryptodev: update symmetric session structure Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 10/12] cryptodev: add user data size to symmetric session Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 11/12] cryptodev: add reference count to session private data Fan Zhang
2019-01-10 14:50 ` [dpdk-dev] [PATCH v5 12/12] cryptodev: add opaque data field to symmetric session Fan Zhang
2019-01-10 15:06 ` [dpdk-dev] [PATCH v5 00/12] cryptodev: change qp conf and sym session Akhil Goyal
2019-01-10 17:18 ` De Lara Guarch, Pablo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190109225609.20590-6-roy.fan.zhang@intel.com \
--to=roy.fan.zhang@intel.com \
--cc=akhil.goyal@nxp.com \
--cc=dev@dpdk.org \
--cc=fiona.trahe@intel.com \
--cc=pablo.de.lara.guarch@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).