From d4ad392cbbff873dd821fa9b2681dbbccc23a6c1 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Thu, 10 Jan 2019 14:50:13 +0000 Subject: [PATCH] app/crypto-perf: use separate session mempools This patch uses the two session mempool approach to crypto perf application. One mempool is for session header objects, and the other is for session private data. Signed-off-by: Fan Zhang Acked-by: Fiona Trahe Acked-by: Akhil Goyal --- app/test-crypto-perf/cperf.h | 1 + app/test-crypto-perf/cperf_ops.c | 11 +- app/test-crypto-perf/cperf_ops.h | 2 +- app/test-crypto-perf/cperf_test_latency.c | 5 +- app/test-crypto-perf/cperf_test_latency.h | 1 + .../cperf_test_pmd_cyclecount.c | 5 +- .../cperf_test_pmd_cyclecount.h | 1 + app/test-crypto-perf/cperf_test_throughput.c | 5 +- app/test-crypto-perf/cperf_test_throughput.h | 1 + app/test-crypto-perf/cperf_test_verify.c | 5 +- app/test-crypto-perf/cperf_test_verify.h | 1 + app/test-crypto-perf/main.c | 103 ++++++++++++------ 12 files changed, 93 insertions(+), 48 deletions(-) diff --git a/app/test-crypto-perf/cperf.h b/app/test-crypto-perf/cperf.h index db58228dce..2b0aad095c 100644 --- a/app/test-crypto-perf/cperf.h +++ b/app/test-crypto-perf/cperf.h @@ -15,6 +15,7 @@ struct cperf_op_fns; typedef void *(*cperf_constructor_t)( struct rte_mempool *sess_mp, + struct rte_mempool *sess_priv_mp, uint8_t dev_id, uint16_t qp_id, const struct cperf_options *options, diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c index 44808f50a5..f59568b801 100644 --- a/app/test-crypto-perf/cperf_ops.c +++ b/app/test-crypto-perf/cperf_ops.c @@ -469,6 +469,7 @@ cperf_set_ops_aead(struct rte_crypto_op **ops, static struct rte_cryptodev_sym_session * cperf_create_session(struct rte_mempool *sess_mp, + struct rte_mempool *priv_mp, uint8_t dev_id, const struct cperf_options *options, const struct cperf_test_vector *test_vector, @@ -505,7 +506,7 @@ cperf_create_session(struct rte_mempool *sess_mp, } /* create crypto session */ rte_cryptodev_sym_session_init(dev_id, sess, &cipher_xform, - sess_mp); + priv_mp); /* * auth only */ @@ -533,7 +534,7 @@ cperf_create_session(struct rte_mempool *sess_mp, } /* create crypto session */ rte_cryptodev_sym_session_init(dev_id, sess, &auth_xform, - sess_mp); + priv_mp); /* * cipher and auth */ @@ -592,12 +593,12 @@ cperf_create_session(struct rte_mempool *sess_mp, cipher_xform.next = &auth_xform; /* create crypto session */ rte_cryptodev_sym_session_init(dev_id, - sess, &cipher_xform, sess_mp); + sess, &cipher_xform, priv_mp); } else { /* auth then cipher */ auth_xform.next = &cipher_xform; /* create crypto session */ rte_cryptodev_sym_session_init(dev_id, - sess, &auth_xform, sess_mp); + sess, &auth_xform, priv_mp); } } else { /* options->op_type == CPERF_AEAD */ aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD; @@ -618,7 +619,7 @@ cperf_create_session(struct rte_mempool *sess_mp, /* Create crypto session */ rte_cryptodev_sym_session_init(dev_id, - sess, &aead_xform, sess_mp); + sess, &aead_xform, priv_mp); } return sess; diff --git a/app/test-crypto-perf/cperf_ops.h b/app/test-crypto-perf/cperf_ops.h index 29e109f2a3..ff125d12cd 100644 --- a/app/test-crypto-perf/cperf_ops.h +++ b/app/test-crypto-perf/cperf_ops.h @@ -13,7 +13,7 @@ typedef struct rte_cryptodev_sym_session *(*cperf_sessions_create_t)( - struct rte_mempool *sess_mp, + struct rte_mempool *sess_mp, struct rte_mempool *sess_priv_mp, uint8_t dev_id, const struct cperf_options *options, const struct cperf_test_vector *test_vector, uint16_t iv_offset); diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c index c9c98dc50d..0fc3a6680c 100644 --- a/app/test-crypto-perf/cperf_test_latency.c +++ b/app/test-crypto-perf/cperf_test_latency.c @@ -62,6 +62,7 @@ cperf_latency_test_free(struct cperf_latency_ctx *ctx) void * cperf_latency_test_constructor(struct rte_mempool *sess_mp, + struct rte_mempool *sess_priv_mp, uint8_t dev_id, uint16_t qp_id, const struct cperf_options *options, const struct cperf_test_vector *test_vector, @@ -86,8 +87,8 @@ cperf_latency_test_constructor(struct rte_mempool *sess_mp, sizeof(struct rte_crypto_sym_op) + sizeof(struct cperf_op_result *); - ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector, - iv_offset); + ctx->sess = op_fns->sess_create(sess_mp, sess_priv_mp, dev_id, options, + test_vector, iv_offset); if (ctx->sess == NULL) goto err; diff --git a/app/test-crypto-perf/cperf_test_latency.h b/app/test-crypto-perf/cperf_test_latency.h index d3fc3218d7..ed5b0a07bb 100644 --- a/app/test-crypto-perf/cperf_test_latency.h +++ b/app/test-crypto-perf/cperf_test_latency.h @@ -17,6 +17,7 @@ void * cperf_latency_test_constructor( struct rte_mempool *sess_mp, + struct rte_mempool *sess_priv_mp, uint8_t dev_id, uint16_t qp_id, const struct cperf_options *options, diff --git a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c index c8d16db6d9..92af5ec905 100644 --- a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c +++ b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c @@ -80,6 +80,7 @@ cperf_pmd_cyclecount_test_free(struct cperf_pmd_cyclecount_ctx *ctx) void * cperf_pmd_cyclecount_test_constructor(struct rte_mempool *sess_mp, + struct rte_mempool *sess_priv_mp, uint8_t dev_id, uint16_t qp_id, const struct cperf_options *options, const struct cperf_test_vector *test_vector, @@ -106,8 +107,8 @@ cperf_pmd_cyclecount_test_constructor(struct rte_mempool *sess_mp, uint16_t iv_offset = sizeof(struct rte_crypto_op) + sizeof(struct rte_crypto_sym_op); - ctx->sess = op_fns->sess_create( - sess_mp, dev_id, options, test_vector, iv_offset); + ctx->sess = op_fns->sess_create(sess_mp, sess_priv_mp, dev_id, options, + test_vector, iv_offset); if (ctx->sess == NULL) goto err; diff --git a/app/test-crypto-perf/cperf_test_pmd_cyclecount.h b/app/test-crypto-perf/cperf_test_pmd_cyclecount.h index beb4419910..3084038a18 100644 --- a/app/test-crypto-perf/cperf_test_pmd_cyclecount.h +++ b/app/test-crypto-perf/cperf_test_pmd_cyclecount.h @@ -18,6 +18,7 @@ void * cperf_pmd_cyclecount_test_constructor( struct rte_mempool *sess_mp, + struct rte_mempool *sess_priv_mp, uint8_t dev_id, uint16_t qp_id, const struct cperf_options *options, diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c index 8766d6e9b0..2767f4ea85 100644 --- a/app/test-crypto-perf/cperf_test_throughput.c +++ b/app/test-crypto-perf/cperf_test_throughput.c @@ -47,6 +47,7 @@ cperf_throughput_test_free(struct cperf_throughput_ctx *ctx) void * cperf_throughput_test_constructor(struct rte_mempool *sess_mp, + struct rte_mempool *sess_priv_mp, uint8_t dev_id, uint16_t qp_id, const struct cperf_options *options, const struct cperf_test_vector *test_vector, @@ -69,8 +70,8 @@ cperf_throughput_test_constructor(struct rte_mempool *sess_mp, uint16_t iv_offset = sizeof(struct rte_crypto_op) + sizeof(struct rte_crypto_sym_op); - ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector, - iv_offset); + ctx->sess = op_fns->sess_create(sess_mp, sess_priv_mp, dev_id, options, + test_vector, iv_offset); if (ctx->sess == NULL) goto err; diff --git a/app/test-crypto-perf/cperf_test_throughput.h b/app/test-crypto-perf/cperf_test_throughput.h index 439ec8e559..91e1a4b708 100644 --- a/app/test-crypto-perf/cperf_test_throughput.h +++ b/app/test-crypto-perf/cperf_test_throughput.h @@ -18,6 +18,7 @@ void * cperf_throughput_test_constructor( struct rte_mempool *sess_mp, + struct rte_mempool *sess_priv_mp, uint8_t dev_id, uint16_t qp_id, const struct cperf_options *options, diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c index 9134b921e0..0497cf9a11 100644 --- a/app/test-crypto-perf/cperf_test_verify.c +++ b/app/test-crypto-perf/cperf_test_verify.c @@ -51,6 +51,7 @@ cperf_verify_test_free(struct cperf_verify_ctx *ctx) void * cperf_verify_test_constructor(struct rte_mempool *sess_mp, + struct rte_mempool *sess_priv_mp, uint8_t dev_id, uint16_t qp_id, const struct cperf_options *options, const struct cperf_test_vector *test_vector, @@ -73,8 +74,8 @@ cperf_verify_test_constructor(struct rte_mempool *sess_mp, uint16_t iv_offset = sizeof(struct rte_crypto_op) + sizeof(struct rte_crypto_sym_op); - ctx->sess = op_fns->sess_create(sess_mp, dev_id, options, test_vector, - iv_offset); + ctx->sess = op_fns->sess_create(sess_mp, sess_priv_mp, dev_id, options, + test_vector, iv_offset); if (ctx->sess == NULL) goto err; diff --git a/app/test-crypto-perf/cperf_test_verify.h b/app/test-crypto-perf/cperf_test_verify.h index 9f70ad87ba..ac2192ba99 100644 --- a/app/test-crypto-perf/cperf_test_verify.h +++ b/app/test-crypto-perf/cperf_test_verify.h @@ -18,6 +18,7 @@ void * cperf_verify_test_constructor( struct rte_mempool *sess_mp, + struct rte_mempool *sess_priv_mp, uint8_t dev_id, uint16_t qp_id, const struct cperf_options *options, diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c index 38a2e429fa..175c639fbe 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -21,6 +21,10 @@ #include "cperf_test_verify.h" #include "cperf_test_pmd_cyclecount.h" +static struct { + struct rte_mempool *sess_mp; + struct rte_mempool *priv_mp; +} session_pool_socket[RTE_MAX_NUMA_NODES]; const char *cperf_test_type_strs[] = { [CPERF_TEST_TYPE_THROUGHPUT] = "throughput", @@ -61,8 +65,58 @@ const struct cperf_test cperf_testmap[] = { }; static int -cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs, - struct rte_mempool *session_pool_socket[]) +fill_session_pool_socket(int32_t socket_id, uint32_t session_priv_size, + uint32_t nb_sessions) +{ + char mp_name[RTE_MEMPOOL_NAMESIZE]; + struct rte_mempool *sess_mp; + + if (session_pool_socket[socket_id].priv_mp == NULL) { + snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, + "priv_sess_mp_%u", socket_id); + + sess_mp = rte_mempool_create(mp_name, + nb_sessions, + session_priv_size, + 0, 0, NULL, NULL, NULL, + NULL, socket_id, + 0); + + if (sess_mp == NULL) { + printf("Cannot create pool \"%s\" on socket %d\n", + mp_name, socket_id); + return -ENOMEM; + } + + printf("Allocated pool \"%s\" on socket %d\n", + mp_name, socket_id); + session_pool_socket[socket_id].priv_mp = sess_mp; + } + + if (session_pool_socket[socket_id].sess_mp == NULL) { + + snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, + "sess_mp_%u", socket_id); + + sess_mp = rte_cryptodev_sym_session_pool_create(mp_name, + nb_sessions, 0, 0, 0, socket_id); + + if (sess_mp == NULL) { + printf("Cannot create pool \"%s\" on socket %d\n", + mp_name, socket_id); + return -ENOMEM; + } + + printf("Allocated pool \"%s\" on socket %d\n", + mp_name, socket_id); + session_pool_socket[socket_id].sess_mp = sess_mp; + } + + return 0; +} + +static int +cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs) { uint8_t enabled_cdev_count = 0, nb_lcores, cdev_id; uint32_t sessions_needed = 0; @@ -177,11 +231,11 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs, rte_cryptodev_scheduler_slaves_get(cdev_id, NULL); - sessions_needed = 2 * enabled_cdev_count * + sessions_needed = enabled_cdev_count * opts->nb_qps * nb_slaves; #endif } else - sessions_needed = 2 * enabled_cdev_count * + sessions_needed = enabled_cdev_count * opts->nb_qps; /* @@ -194,32 +248,15 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs, "%u sessions\n", opts->nb_qps); return -ENOTSUP; } - if (session_pool_socket[socket_id] == NULL) { - char mp_name[RTE_MEMPOOL_NAMESIZE]; - struct rte_mempool *sess_mp; - - snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, - "sess_mp_%u", socket_id); - sess_mp = rte_mempool_create(mp_name, - sessions_needed, - max_sess_size, - 0, - 0, NULL, NULL, NULL, - NULL, socket_id, - 0); - - if (sess_mp == NULL) { - printf("Cannot create session 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; - } + ret = fill_session_pool_socket(socket_id, max_sess_size, + sessions_needed); + if (ret < 0) + return ret; - 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; ret = rte_cryptodev_configure(cdev_id, &conf); if (ret < 0) { @@ -453,10 +490,7 @@ main(int argc, char **argv) struct cperf_options opts = {0}; struct cperf_test_vector *t_vec = NULL; struct cperf_op_fns op_fns; - void *ctx[RTE_MAX_LCORE] = { }; - struct rte_mempool *session_pool_socket[RTE_MAX_NUMA_NODES] = { 0 }; - int nb_cryptodevs = 0; uint16_t total_nb_qps = 0; uint8_t cdev_id, i; @@ -489,8 +523,7 @@ main(int argc, char **argv) goto err; } - nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs, - session_pool_socket); + nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs); if (!opts.silent) cperf_options_dump(&opts); @@ -558,7 +591,9 @@ main(int argc, char **argv) uint8_t socket_id = rte_cryptodev_socket_id(cdev_id); ctx[i] = cperf_testmap[opts.test].constructor( - session_pool_socket[socket_id], cdev_id, qp_id, + session_pool_socket[socket_id].sess_mp, + session_pool_socket[socket_id].priv_mp, + cdev_id, qp_id, &opts, t_vec, &op_fns); if (ctx[i] == NULL) { RTE_LOG(ERR, USER1, "Test run constructor failed\n"); -- 2.20.1