From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 28CE9A0C41; Thu, 30 Sep 2021 16:51:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 18E0F4113A; Thu, 30 Sep 2021 16:51:41 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 01824410EA for ; Thu, 30 Sep 2021 16:51:38 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18UDg338025463; Thu, 30 Sep 2021 07:51:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=2Gimz5aiioIriYMX12JabmdmmGFL5ESWu+RJhKejDdk=; b=eAykXY7VAB6sjdrVwgcow5aX8s75so+K5ALtoz0x9p52qV/Gah3h+xXN9x7rv+PTf75T 5WwtE2eK5MgY4nBQxFKKx94nrwljyLTuSzA5M5/97qWrkMNsYC+NALtIHsqvLN0MwWP4 9DqKU9Ddd8tka6e/Zv2nSP/Ctc8m5qDjKhdPJXV6rTMdcPE9ZS341XAx9AhhTaRqU/bd kDCpKXyud1VfoMRaubMvG406oQqLPdJ6pbjdS+KMbvjJ/9xi2CcsllikLfXoHaJN1TxQ +xfvPwx2aQdNbElb/eG8LAho/PV4je7kJeqsd1CedQa6cu07a6If3oBzYrMWy//3UHKk tg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 3bdebtg9rx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 30 Sep 2021 07:51:30 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 30 Sep 2021 07:51:29 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 30 Sep 2021 07:51:29 -0700 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id E6E513F7070; Thu, 30 Sep 2021 07:51:20 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , , , , , , , , , Akhil Goyal Date: Thu, 30 Sep 2021 20:20:14 +0530 Message-ID: <20210930145014.2476799-4-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930145014.2476799-1-gakhil@marvell.com> References: <20210930145014.2476799-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: TydrEE0PDMY2L0CbT7oDAfqiorCcpcfH X-Proofpoint-GUID: TydrEE0PDMY2L0CbT7oDAfqiorCcpcfH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-30_05,2021-09-30_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH 3/3] cryptodev: rework session framework X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" As per current design, rte_cryptodev_sym_session_create() and rte_cryptodev_sym_session_init() use separate mempool objects for a single session. And structure rte_cryptodev_sym_session is not directly used by the application, it may cause ABI breakage if the structure is modified in future. To address these two issues, the rte_cryptodev_sym_session_create will take one mempool object for both the session and session private data. The API rte_cryptodev_sym_session_init will now not take mempool object. rte_cryptodev_sym_session_create will now return an opaque session pointer which will be used by the app in rte_cryptodev_sym_session_init and other APIs. With this change, rte_cryptodev_sym_session_init will send pointer to session private data of corresponding driver to the PMD based on the driver_id for filling the PMD data. In data path, opaque session pointer is attached to rte_crypto_op and the PMD can call an internal library API to get the session private data pointer based on the driver id. TODO: - inline APIs for opaque data - move rte_cryptodev_sym_session struct to cryptodev_pmd.h - currently nb_drivers are getting updated in RTE_INIT which result in increasing the memory requirements for session. This will be moved to PMD probe so that memory is created only for those PMDs which are probed and not just compiled in. Signed-off-by: Akhil Goyal --- app/test-crypto-perf/cperf.h | 1 - app/test-crypto-perf/cperf_ops.c | 33 ++--- app/test-crypto-perf/cperf_ops.h | 6 +- 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 | 29 +--- app/test/test_cryptodev.c | 130 +++++------------- app/test/test_cryptodev.h | 1 - app/test/test_cryptodev_asym.c | 1 - app/test/test_cryptodev_blockcipher.c | 6 +- app/test/test_event_crypto_adapter.c | 28 +--- app/test/test_ipsec.c | 22 +-- drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c | 33 +---- .../crypto/aesni_mb/rte_aesni_mb_pmd_ops.c | 34 +---- drivers/crypto/armv8/rte_armv8_pmd_ops.c | 34 +---- drivers/crypto/bcmfs/bcmfs_sym_session.c | 36 +---- drivers/crypto/bcmfs/bcmfs_sym_session.h | 6 +- drivers/crypto/caam_jr/caam_jr.c | 32 ++--- drivers/crypto/ccp/ccp_pmd_ops.c | 32 +---- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 18 ++- drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 18 +-- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 61 +++----- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 13 +- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 29 +--- drivers/crypto/dpaa_sec/dpaa_sec.c | 31 +---- drivers/crypto/kasumi/rte_kasumi_pmd_ops.c | 34 +---- drivers/crypto/mlx5/mlx5_crypto.c | 24 +--- drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 36 ++--- drivers/crypto/nitrox/nitrox_sym.c | 31 +---- drivers/crypto/null/null_crypto_pmd_ops.c | 34 +---- .../crypto/octeontx/otx_cryptodev_hw_access.h | 1 - drivers/crypto/octeontx/otx_cryptodev_ops.c | 60 +++----- drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 52 +++---- .../octeontx2/otx2_cryptodev_ops_helper.h | 16 +-- drivers/crypto/openssl/rte_openssl_pmd_ops.c | 35 +---- drivers/crypto/qat/qat_sym_session.c | 29 +--- drivers/crypto/qat/qat_sym_session.h | 6 +- drivers/crypto/scheduler/scheduler_pmd_ops.c | 9 +- drivers/crypto/snow3g/rte_snow3g_pmd_ops.c | 34 +---- drivers/crypto/virtio/virtio_cryptodev.c | 31 ++--- drivers/crypto/zuc/rte_zuc_pmd_ops.c | 35 +---- .../octeontx2/otx2_evdev_crypto_adptr_rx.h | 3 +- examples/fips_validation/fips_dev_self_test.c | 32 ++--- examples/fips_validation/main.c | 20 +-- examples/ipsec-secgw/ipsec-secgw.c | 72 +++++----- examples/ipsec-secgw/ipsec.c | 3 +- examples/ipsec-secgw/ipsec.h | 1 - examples/ipsec-secgw/ipsec_worker.c | 4 - examples/l2fwd-crypto/main.c | 41 +----- examples/vhost_crypto/main.c | 16 +-- lib/cryptodev/cryptodev_pmd.h | 7 +- lib/cryptodev/rte_crypto.h | 2 +- lib/cryptodev/rte_crypto_sym.h | 2 +- lib/cryptodev/rte_cryptodev.c | 73 ++++++---- lib/cryptodev/rte_cryptodev.h | 23 ++-- lib/cryptodev/rte_cryptodev_trace.h | 5 +- lib/pipeline/rte_table_action.c | 8 +- lib/pipeline/rte_table_action.h | 2 +- lib/vhost/rte_vhost_crypto.h | 3 - lib/vhost/vhost_crypto.c | 7 +- 66 files changed, 399 insertions(+), 1050 deletions(-) diff --git a/app/test-crypto-perf/cperf.h b/app/test-crypto-perf/cperf.h index 2b0aad095c..db58228dce 100644 --- a/app/test-crypto-perf/cperf.h +++ b/app/test-crypto-perf/cperf.h @@ -15,7 +15,6 @@ 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 1b3cbe77b9..f094bc656d 100644 --- a/app/test-crypto-perf/cperf_ops.c +++ b/app/test-crypto-perf/cperf_ops.c @@ -12,7 +12,7 @@ static int cperf_set_ops_asym(struct rte_crypto_op **ops, uint32_t src_buf_offset __rte_unused, uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops, - struct rte_cryptodev_sym_session *sess, + void *sess, const struct cperf_options *options __rte_unused, const struct cperf_test_vector *test_vector __rte_unused, uint16_t iv_offset __rte_unused, @@ -40,7 +40,7 @@ static int cperf_set_ops_security(struct rte_crypto_op **ops, uint32_t src_buf_offset __rte_unused, uint32_t dst_buf_offset __rte_unused, - uint16_t nb_ops, struct rte_cryptodev_sym_session *sess, + uint16_t nb_ops, void *sess, const struct cperf_options *options __rte_unused, const struct cperf_test_vector *test_vector __rte_unused, uint16_t iv_offset __rte_unused, uint32_t *imix_idx) @@ -106,7 +106,7 @@ cperf_set_ops_security(struct rte_crypto_op **ops, static int cperf_set_ops_null_cipher(struct rte_crypto_op **ops, uint32_t src_buf_offset, uint32_t dst_buf_offset, - uint16_t nb_ops, struct rte_cryptodev_sym_session *sess, + uint16_t nb_ops, void *sess, const struct cperf_options *options, const struct cperf_test_vector *test_vector __rte_unused, uint16_t iv_offset __rte_unused, uint32_t *imix_idx) @@ -145,7 +145,7 @@ cperf_set_ops_null_cipher(struct rte_crypto_op **ops, static int cperf_set_ops_null_auth(struct rte_crypto_op **ops, uint32_t src_buf_offset, uint32_t dst_buf_offset, - uint16_t nb_ops, struct rte_cryptodev_sym_session *sess, + uint16_t nb_ops, void *sess, const struct cperf_options *options, const struct cperf_test_vector *test_vector __rte_unused, uint16_t iv_offset __rte_unused, uint32_t *imix_idx) @@ -184,7 +184,7 @@ cperf_set_ops_null_auth(struct rte_crypto_op **ops, static int cperf_set_ops_cipher(struct rte_crypto_op **ops, uint32_t src_buf_offset, uint32_t dst_buf_offset, - uint16_t nb_ops, struct rte_cryptodev_sym_session *sess, + uint16_t nb_ops, void *sess, const struct cperf_options *options, const struct cperf_test_vector *test_vector, uint16_t iv_offset, uint32_t *imix_idx) @@ -240,7 +240,7 @@ cperf_set_ops_cipher(struct rte_crypto_op **ops, static int cperf_set_ops_auth(struct rte_crypto_op **ops, uint32_t src_buf_offset, uint32_t dst_buf_offset, - uint16_t nb_ops, struct rte_cryptodev_sym_session *sess, + uint16_t nb_ops, void *sess, const struct cperf_options *options, const struct cperf_test_vector *test_vector, uint16_t iv_offset, uint32_t *imix_idx) @@ -340,7 +340,7 @@ cperf_set_ops_auth(struct rte_crypto_op **ops, static int cperf_set_ops_cipher_auth(struct rte_crypto_op **ops, uint32_t src_buf_offset, uint32_t dst_buf_offset, - uint16_t nb_ops, struct rte_cryptodev_sym_session *sess, + uint16_t nb_ops, void *sess, const struct cperf_options *options, const struct cperf_test_vector *test_vector, uint16_t iv_offset, uint32_t *imix_idx) @@ -455,7 +455,7 @@ cperf_set_ops_cipher_auth(struct rte_crypto_op **ops, static int cperf_set_ops_aead(struct rte_crypto_op **ops, uint32_t src_buf_offset, uint32_t dst_buf_offset, - uint16_t nb_ops, struct rte_cryptodev_sym_session *sess, + uint16_t nb_ops, void *sess, const struct cperf_options *options, const struct cperf_test_vector *test_vector, uint16_t iv_offset, uint32_t *imix_idx) @@ -563,9 +563,8 @@ cperf_set_ops_aead(struct rte_crypto_op **ops, return 0; } -static struct rte_cryptodev_sym_session * +static void * 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, @@ -590,7 +589,7 @@ cperf_create_session(struct rte_mempool *sess_mp, if (sess == NULL) return NULL; rc = rte_cryptodev_asym_session_init(dev_id, (void *)sess, - &xform, priv_mp); + &xform, sess_mp); if (rc < 0) { if (sess != NULL) { rte_cryptodev_asym_session_clear(dev_id, @@ -742,8 +741,7 @@ cperf_create_session(struct rte_mempool *sess_mp, cipher_xform.cipher.iv.length = 0; } /* create crypto session */ - rte_cryptodev_sym_session_init(dev_id, sess, &cipher_xform, - priv_mp); + rte_cryptodev_sym_session_init(dev_id, sess, &cipher_xform); /* * auth only */ @@ -770,8 +768,7 @@ cperf_create_session(struct rte_mempool *sess_mp, auth_xform.auth.iv.length = 0; } /* create crypto session */ - rte_cryptodev_sym_session_init(dev_id, sess, &auth_xform, - priv_mp); + rte_cryptodev_sym_session_init(dev_id, sess, &auth_xform); /* * cipher and auth */ @@ -830,12 +827,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, priv_mp); + sess, &cipher_xform); } else { /* auth then cipher */ auth_xform.next = &cipher_xform; /* create crypto session */ rte_cryptodev_sym_session_init(dev_id, - sess, &auth_xform, priv_mp); + sess, &auth_xform); } } else { /* options->op_type == CPERF_AEAD */ aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD; @@ -856,7 +853,7 @@ cperf_create_session(struct rte_mempool *sess_mp, /* Create crypto session */ rte_cryptodev_sym_session_init(dev_id, - sess, &aead_xform, priv_mp); + sess, &aead_xform); } return sess; diff --git a/app/test-crypto-perf/cperf_ops.h b/app/test-crypto-perf/cperf_ops.h index ff125d12cd..3ff10491a0 100644 --- a/app/test-crypto-perf/cperf_ops.h +++ b/app/test-crypto-perf/cperf_ops.h @@ -12,15 +12,15 @@ #include "cperf_test_vectors.h" -typedef struct rte_cryptodev_sym_session *(*cperf_sessions_create_t)( - struct rte_mempool *sess_mp, struct rte_mempool *sess_priv_mp, +typedef void *(*cperf_sessions_create_t)( + struct rte_mempool *sess_mp, uint8_t dev_id, const struct cperf_options *options, const struct cperf_test_vector *test_vector, uint16_t iv_offset); typedef int (*cperf_populate_ops_t)(struct rte_crypto_op **ops, uint32_t src_buf_offset, uint32_t dst_buf_offset, - uint16_t nb_ops, struct rte_cryptodev_sym_session *sess, + uint16_t nb_ops, void *sess, const struct cperf_options *options, const struct cperf_test_vector *test_vector, uint16_t iv_offset, uint32_t *imix_idx); diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c index 159fe8492b..4193f7e777 100644 --- a/app/test-crypto-perf/cperf_test_latency.c +++ b/app/test-crypto-perf/cperf_test_latency.c @@ -24,7 +24,7 @@ struct cperf_latency_ctx { struct rte_mempool *pool; - struct rte_cryptodev_sym_session *sess; + void *sess; cperf_populate_ops_t populate_ops; @@ -59,7 +59,6 @@ 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, @@ -84,7 +83,7 @@ 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, sess_priv_mp, dev_id, options, + ctx->sess = op_fns->sess_create(sess_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 ed5b0a07bb..d3fc3218d7 100644 --- a/app/test-crypto-perf/cperf_test_latency.h +++ b/app/test-crypto-perf/cperf_test_latency.h @@ -17,7 +17,6 @@ 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 cbbbedd9ba..3dd489376f 100644 --- a/app/test-crypto-perf/cperf_test_pmd_cyclecount.c +++ b/app/test-crypto-perf/cperf_test_pmd_cyclecount.c @@ -27,7 +27,7 @@ struct cperf_pmd_cyclecount_ctx { struct rte_crypto_op **ops; struct rte_crypto_op **ops_processed; - struct rte_cryptodev_sym_session *sess; + void *sess; cperf_populate_ops_t populate_ops; @@ -93,7 +93,6 @@ 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, @@ -120,7 +119,7 @@ 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, sess_priv_mp, dev_id, options, + ctx->sess = op_fns->sess_create(sess_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 3084038a18..beb4419910 100644 --- a/app/test-crypto-perf/cperf_test_pmd_cyclecount.h +++ b/app/test-crypto-perf/cperf_test_pmd_cyclecount.h @@ -18,7 +18,6 @@ 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 76fcda47ff..dc5c48b4da 100644 --- a/app/test-crypto-perf/cperf_test_throughput.c +++ b/app/test-crypto-perf/cperf_test_throughput.c @@ -18,7 +18,7 @@ struct cperf_throughput_ctx { struct rte_mempool *pool; - struct rte_cryptodev_sym_session *sess; + void *sess; cperf_populate_ops_t populate_ops; @@ -64,7 +64,6 @@ 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, @@ -87,7 +86,7 @@ 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, sess_priv_mp, dev_id, options, + ctx->sess = op_fns->sess_create(sess_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 91e1a4b708..439ec8e559 100644 --- a/app/test-crypto-perf/cperf_test_throughput.h +++ b/app/test-crypto-perf/cperf_test_throughput.h @@ -18,7 +18,6 @@ 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 2939aeaa93..cf561dd700 100644 --- a/app/test-crypto-perf/cperf_test_verify.c +++ b/app/test-crypto-perf/cperf_test_verify.c @@ -18,7 +18,7 @@ struct cperf_verify_ctx { struct rte_mempool *pool; - struct rte_cryptodev_sym_session *sess; + void *sess; cperf_populate_ops_t populate_ops; @@ -51,7 +51,6 @@ 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, @@ -74,7 +73,7 @@ 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, sess_priv_mp, dev_id, options, + ctx->sess = op_fns->sess_create(sess_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 ac2192ba99..9f70ad87ba 100644 --- a/app/test-crypto-perf/cperf_test_verify.h +++ b/app/test-crypto-perf/cperf_test_verify.h @@ -18,7 +18,6 @@ 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 390380898e..c3327b7e55 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -118,35 +118,14 @@ fill_session_pool_socket(int32_t socket_id, uint32_t session_priv_size, 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); + nb_sessions, session_priv_size, + 0, 0, socket_id); if (sess_mp == NULL) { printf("Cannot create pool \"%s\" on socket %d\n", @@ -344,12 +323,9 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs) return ret; qp_conf.mp_session = session_pool_socket[socket_id].sess_mp; - qp_conf.mp_session_private = - session_pool_socket[socket_id].priv_mp; if (opts->op_type == CPERF_ASYM_MODEX) { qp_conf.mp_session = NULL; - qp_conf.mp_session_private = NULL; } ret = rte_cryptodev_configure(cdev_id, &conf); @@ -704,7 +680,6 @@ main(int argc, char **argv) ctx[i] = cperf_testmap[opts.test].constructor( 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) { diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 82f819211a..e5c7930c63 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -79,7 +79,7 @@ struct crypto_unittest_params { #endif union { - struct rte_cryptodev_sym_session *sess; + void *sess; #ifdef RTE_LIB_SECURITY void *sec_session; #endif @@ -119,7 +119,7 @@ test_AES_CBC_HMAC_SHA512_decrypt_create_session_params( uint8_t *hmac_key); static int -test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, +test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess, struct crypto_unittest_params *ut_params, struct crypto_testsuite_params *ts_param, const uint8_t *cipher, @@ -596,23 +596,11 @@ testsuite_setup(void) } ts_params->session_mpool = rte_cryptodev_sym_session_pool_create( - "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0, + "test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0, SOCKET_ID_ANY); TEST_ASSERT_NOT_NULL(ts_params->session_mpool, "session mempool allocation failed"); - ts_params->session_priv_mpool = rte_mempool_create( - "test_sess_mp_priv", - MAX_NB_SESSIONS, - session_size, - 0, 0, NULL, NULL, NULL, - NULL, SOCKET_ID_ANY, - 0); - TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool, - "session mempool allocation failed"); - - - TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf), "Failed to configure cryptodev %u with %u qps", @@ -620,7 +608,6 @@ testsuite_setup(void) ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; ts_params->qp_conf.mp_session = ts_params->session_mpool; - ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool; for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) { TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( @@ -650,11 +637,6 @@ testsuite_teardown(void) } /* Free session mempools */ - if (ts_params->session_priv_mpool != NULL) { - rte_mempool_free(ts_params->session_priv_mpool); - ts_params->session_priv_mpool = NULL; - } - if (ts_params->session_mpool != NULL) { rte_mempool_free(ts_params->session_mpool); ts_params->session_mpool = NULL; @@ -1330,7 +1312,6 @@ dev_configure_and_start(uint64_t ff_disable) ts_params->conf.ff_disable = ff_disable; ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; ts_params->qp_conf.mp_session = ts_params->session_mpool; - ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool; TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0], &ts_params->conf), @@ -1552,7 +1533,6 @@ test_queue_pair_descriptor_setup(void) */ qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/ qp_conf.mp_session = ts_params->session_mpool; - qp_conf.mp_session_private = ts_params->session_priv_mpool; for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) { TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( @@ -2146,8 +2126,7 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void) /* Create crypto session*/ rte_cryptodev_sym_session_init(ts_params->valid_devs[0], - ut_params->sess, &ut_params->cipher_xform, - ts_params->session_priv_mpool); + ut_params->sess, &ut_params->cipher_xform); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); /* Generate crypto op data structure */ @@ -2247,7 +2226,7 @@ test_AES_CBC_HMAC_SHA512_decrypt_create_session_params( uint8_t *hmac_key); static int -test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, +test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess, struct crypto_unittest_params *ut_params, struct crypto_testsuite_params *ts_params, const uint8_t *cipher, @@ -2288,7 +2267,7 @@ test_AES_CBC_HMAC_SHA512_decrypt_create_session_params( static int -test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, +test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess, struct crypto_unittest_params *ut_params, struct crypto_testsuite_params *ts_params, const uint8_t *cipher, @@ -2401,8 +2380,7 @@ create_wireless_algo_hash_session(uint8_t dev_id, ts_params->session_mpool); status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, - &ut_params->auth_xform, - ts_params->session_priv_mpool); + &ut_params->auth_xform); if (status == -ENOTSUP) return TEST_SKIPPED; @@ -2443,8 +2421,7 @@ create_wireless_algo_cipher_session(uint8_t dev_id, ts_params->session_mpool); status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, - &ut_params->cipher_xform, - ts_params->session_priv_mpool); + &ut_params->cipher_xform); if (status == -ENOTSUP) return TEST_SKIPPED; @@ -2566,8 +2543,7 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id, TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, - &ut_params->cipher_xform, - ts_params->session_priv_mpool); + &ut_params->cipher_xform); if (status == -ENOTSUP) return TEST_SKIPPED; @@ -2629,8 +2605,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id, ts_params->session_mpool); status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, - &ut_params->cipher_xform, - ts_params->session_priv_mpool); + &ut_params->cipher_xform); if (status == -ENOTSUP) return TEST_SKIPPED; @@ -2699,13 +2674,11 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id, ut_params->auth_xform.next = NULL; ut_params->cipher_xform.next = &ut_params->auth_xform; status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, - &ut_params->cipher_xform, - ts_params->session_priv_mpool); + &ut_params->cipher_xform); } else status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, - &ut_params->auth_xform, - ts_params->session_priv_mpool); + &ut_params->auth_xform); if (status == -ENOTSUP) return TEST_SKIPPED; @@ -7838,8 +7811,7 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo, ts_params->session_mpool); rte_cryptodev_sym_session_init(dev_id, ut_params->sess, - &ut_params->aead_xform, - ts_params->session_priv_mpool); + &ut_params->aead_xform); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); @@ -10992,8 +10964,7 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params, ts_params->session_mpool); rte_cryptodev_sym_session_init(ts_params->valid_devs[0], - ut_params->sess, &ut_params->auth_xform, - ts_params->session_priv_mpool); + ut_params->sess, &ut_params->auth_xform); if (ut_params->sess == NULL) return TEST_FAILED; @@ -11206,7 +11177,7 @@ test_multi_session(void) struct crypto_unittest_params *ut_params = &unittest_params; struct rte_cryptodev_info dev_info; - struct rte_cryptodev_sym_session **sessions; + void **sessions; uint16_t i; @@ -11229,9 +11200,7 @@ test_multi_session(void) rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); - sessions = rte_malloc(NULL, - sizeof(struct rte_cryptodev_sym_session *) * - (MAX_NB_SESSIONS + 1), 0); + sessions = rte_malloc(NULL, sizeof(void *) * (MAX_NB_SESSIONS + 1), 0); /* Create multiple crypto sessions*/ for (i = 0; i < MAX_NB_SESSIONS; i++) { @@ -11240,8 +11209,7 @@ test_multi_session(void) ts_params->session_mpool); rte_cryptodev_sym_session_init(ts_params->valid_devs[0], - sessions[i], &ut_params->auth_xform, - ts_params->session_priv_mpool); + sessions[i], &ut_params->auth_xform); TEST_ASSERT_NOT_NULL(sessions[i], "Session creation failed at session number %u", i); @@ -11279,8 +11247,7 @@ test_multi_session(void) sessions[i] = NULL; /* Next session create should fail */ rte_cryptodev_sym_session_init(ts_params->valid_devs[0], - sessions[i], &ut_params->auth_xform, - ts_params->session_priv_mpool); + sessions[i], &ut_params->auth_xform); TEST_ASSERT_NULL(sessions[i], "Session creation succeeded unexpectedly!"); @@ -11311,7 +11278,7 @@ test_multi_session_random_usage(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct rte_cryptodev_info dev_info; - struct rte_cryptodev_sym_session **sessions; + void **sessions; uint32_t i, j; struct multi_session_params ut_paramz[] = { @@ -11355,8 +11322,7 @@ test_multi_session_random_usage(void) rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); sessions = rte_malloc(NULL, - (sizeof(struct rte_cryptodev_sym_session *) - * MAX_NB_SESSIONS) + 1, 0); + (sizeof(void *) * MAX_NB_SESSIONS) + 1, 0); for (i = 0; i < MB_SESSION_NUMBER; i++) { sessions[i] = rte_cryptodev_sym_session_create( @@ -11373,8 +11339,7 @@ test_multi_session_random_usage(void) rte_cryptodev_sym_session_init( ts_params->valid_devs[0], sessions[i], - &ut_paramz[i].ut_params.auth_xform, - ts_params->session_priv_mpool); + &ut_paramz[i].ut_params.auth_xform); TEST_ASSERT_NOT_NULL(sessions[i], "Session creation failed at session number %u", @@ -11457,8 +11422,7 @@ test_null_invalid_operation(void) /* Create Crypto session*/ ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], - ut_params->sess, &ut_params->cipher_xform, - ts_params->session_priv_mpool); + ut_params->sess, &ut_params->cipher_xform); TEST_ASSERT(ret < 0, "Session creation succeeded unexpectedly"); @@ -11475,8 +11439,7 @@ test_null_invalid_operation(void) /* Create Crypto session*/ ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], - ut_params->sess, &ut_params->auth_xform, - ts_params->session_priv_mpool); + ut_params->sess, &ut_params->auth_xform); TEST_ASSERT(ret < 0, "Session creation succeeded unexpectedly"); @@ -11521,8 +11484,7 @@ test_null_burst_operation(void) /* Create Crypto session*/ rte_cryptodev_sym_session_init(ts_params->valid_devs[0], - ut_params->sess, &ut_params->cipher_xform, - ts_params->session_priv_mpool); + ut_params->sess, &ut_params->cipher_xform); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool, @@ -11634,7 +11596,6 @@ test_enq_callback_setup(void) qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; qp_conf.mp_session = ts_params->session_mpool; - qp_conf.mp_session_private = ts_params->session_priv_mpool; TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, @@ -11734,7 +11695,6 @@ test_deq_callback_setup(void) qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; qp_conf.mp_session = ts_params->session_mpool; - qp_conf.mp_session_private = ts_params->session_priv_mpool; TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( ts_params->valid_devs[0], qp_id, &qp_conf, @@ -11943,8 +11903,7 @@ static int create_gmac_session(uint8_t dev_id, ts_params->session_mpool); rte_cryptodev_sym_session_init(dev_id, ut_params->sess, - &ut_params->auth_xform, - ts_params->session_priv_mpool); + &ut_params->auth_xform); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); @@ -12588,8 +12547,7 @@ create_auth_session(struct crypto_unittest_params *ut_params, ts_params->session_mpool); rte_cryptodev_sym_session_init(dev_id, ut_params->sess, - &ut_params->auth_xform, - ts_params->session_priv_mpool); + &ut_params->auth_xform); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); @@ -12641,8 +12599,7 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params, ts_params->session_mpool); rte_cryptodev_sym_session_init(dev_id, ut_params->sess, - &ut_params->auth_xform, - ts_params->session_priv_mpool); + &ut_params->auth_xform); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); @@ -13149,8 +13106,7 @@ test_authenticated_encrypt_with_esn( rte_cryptodev_sym_session_init(ts_params->valid_devs[0], ut_params->sess, - &ut_params->cipher_xform, - ts_params->session_priv_mpool); + &ut_params->cipher_xform); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); @@ -13281,8 +13237,7 @@ test_authenticated_decrypt_with_esn( rte_cryptodev_sym_session_init(ts_params->valid_devs[0], ut_params->sess, - &ut_params->auth_xform, - ts_params->session_priv_mpool); + &ut_params->auth_xform); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); @@ -14003,11 +13958,6 @@ test_scheduler_attach_worker_op(void) rte_mempool_free(ts_params->session_mpool); ts_params->session_mpool = NULL; } - if (ts_params->session_priv_mpool) { - rte_mempool_free(ts_params->session_priv_mpool); - ts_params->session_priv_mpool = NULL; - } - if (info.sym.max_nb_sessions != 0 && info.sym.max_nb_sessions < MAX_NB_SESSIONS) { RTE_LOG(ERR, USER1, @@ -14024,32 +13974,14 @@ test_scheduler_attach_worker_op(void) ts_params->session_mpool = rte_cryptodev_sym_session_pool_create( "test_sess_mp", - MAX_NB_SESSIONS, 0, 0, 0, + MAX_NB_SESSIONS, + session_size, 0, 0, SOCKET_ID_ANY); TEST_ASSERT_NOT_NULL(ts_params->session_mpool, "session mempool allocation failed"); } - /* - * Create mempool with maximum number of sessions, - * to include device specific session private data - */ - if (ts_params->session_priv_mpool == NULL) { - ts_params->session_priv_mpool = rte_mempool_create( - "test_sess_mp_priv", - MAX_NB_SESSIONS, - session_size, - 0, 0, NULL, NULL, NULL, - NULL, SOCKET_ID_ANY, - 0); - - TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool, - "session mempool allocation failed"); - } - ts_params->qp_conf.mp_session = ts_params->session_mpool; - ts_params->qp_conf.mp_session_private = - ts_params->session_priv_mpool; ret = rte_cryptodev_scheduler_worker_attach(sched_id, (uint8_t)i); diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h index 1cdd84d01f..a3a10d484b 100644 --- a/app/test/test_cryptodev.h +++ b/app/test/test_cryptodev.h @@ -89,7 +89,6 @@ struct crypto_testsuite_params { struct rte_mempool *large_mbuf_pool; struct rte_mempool *op_mpool; struct rte_mempool *session_mpool; - struct rte_mempool *session_priv_mpool; struct rte_cryptodev_config conf; struct rte_cryptodev_qp_conf qp_conf; diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index 9d19a6d6d9..35da574da8 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -924,7 +924,6 @@ testsuite_setup(void) /* configure qp */ ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; ts_params->qp_conf.mp_session = ts_params->session_mpool; - ts_params->qp_conf.mp_session_private = ts_params->session_mpool; for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) { TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( dev_id, qp_id, &ts_params->qp_conf, diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c index 3cdb2c96e8..9417803f18 100644 --- a/app/test/test_cryptodev_blockcipher.c +++ b/app/test/test_cryptodev_blockcipher.c @@ -68,7 +68,6 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, struct rte_mempool *mbuf_pool, struct rte_mempool *op_mpool, struct rte_mempool *sess_mpool, - struct rte_mempool *sess_priv_mpool, uint8_t dev_id, char *test_msg) { @@ -81,7 +80,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, struct rte_crypto_sym_op *sym_op = NULL; struct rte_crypto_op *op = NULL; struct rte_cryptodev_info dev_info; - struct rte_cryptodev_sym_session *sess = NULL; + void *sess = NULL; int status = TEST_SUCCESS; const struct blockcipher_test_data *tdata = t->test_data; @@ -514,7 +513,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t, sess = rte_cryptodev_sym_session_create(sess_mpool); status = rte_cryptodev_sym_session_init(dev_id, sess, - init_xform, sess_priv_mpool); + init_xform); if (status == -ENOTSUP) { snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "UNSUPPORTED"); status = TEST_SKIPPED; @@ -831,7 +830,6 @@ blockcipher_test_case_run(const void *data) p_testsuite_params->mbuf_pool, p_testsuite_params->op_mpool, p_testsuite_params->session_mpool, - p_testsuite_params->session_priv_mpool, p_testsuite_params->valid_devs[0], test_msg); return status; diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c index 3ad20921e2..59229a1cde 100644 --- a/app/test/test_event_crypto_adapter.c +++ b/app/test/test_event_crypto_adapter.c @@ -61,7 +61,6 @@ struct event_crypto_adapter_test_params { struct rte_mempool *mbuf_pool; struct rte_mempool *op_mpool; struct rte_mempool *session_mpool; - struct rte_mempool *session_priv_mpool; struct rte_cryptodev_config *config; uint8_t crypto_event_port_id; uint8_t internal_port_op_fwd; @@ -167,7 +166,7 @@ static int test_op_forward_mode(uint8_t session_less) { struct rte_crypto_sym_xform cipher_xform; - struct rte_cryptodev_sym_session *sess; + void *sess; union rte_event_crypto_metadata m_data; struct rte_crypto_sym_op *sym_op; struct rte_crypto_op *op; @@ -203,7 +202,7 @@ test_op_forward_mode(uint8_t session_less) /* Create Crypto session*/ ret = rte_cryptodev_sym_session_init(TEST_CDEV_ID, sess, - &cipher_xform, params.session_priv_mpool); + &cipher_xform); TEST_ASSERT_SUCCESS(ret, "Failed to init session\n"); ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, @@ -367,7 +366,7 @@ static int test_op_new_mode(uint8_t session_less) { struct rte_crypto_sym_xform cipher_xform; - struct rte_cryptodev_sym_session *sess; + void *sess; union rte_event_crypto_metadata m_data; struct rte_crypto_sym_op *sym_op; struct rte_crypto_op *op; @@ -411,7 +410,7 @@ test_op_new_mode(uint8_t session_less) &m_data, sizeof(m_data)); } ret = rte_cryptodev_sym_session_init(TEST_CDEV_ID, sess, - &cipher_xform, params.session_priv_mpool); + &cipher_xform); TEST_ASSERT_SUCCESS(ret, "Failed to init session\n"); rte_crypto_op_attach_sym_session(op, sess); @@ -553,22 +552,12 @@ configure_cryptodev(void) params.session_mpool = rte_cryptodev_sym_session_pool_create( "CRYPTO_ADAPTER_SESSION_MP", - MAX_NB_SESSIONS, 0, 0, + MAX_NB_SESSIONS, session_size, 0, sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY); TEST_ASSERT_NOT_NULL(params.session_mpool, "session mempool allocation failed\n"); - params.session_priv_mpool = rte_mempool_create( - "CRYPTO_AD_SESS_MP_PRIV", - MAX_NB_SESSIONS, - session_size, - 0, 0, NULL, NULL, NULL, - NULL, SOCKET_ID_ANY, - 0); - TEST_ASSERT_NOT_NULL(params.session_priv_mpool, - "session mempool allocation failed\n"); - rte_cryptodev_info_get(TEST_CDEV_ID, &info); conf.nb_queue_pairs = info.max_nb_queue_pairs; conf.socket_id = SOCKET_ID_ANY; @@ -580,7 +569,6 @@ configure_cryptodev(void) qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; qp_conf.mp_session = params.session_mpool; - qp_conf.mp_session_private = params.session_priv_mpool; TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( TEST_CDEV_ID, TEST_CDEV_QP_ID, &qp_conf, @@ -934,12 +922,6 @@ crypto_teardown(void) rte_mempool_free(params.session_mpool); params.session_mpool = NULL; } - if (params.session_priv_mpool != NULL) { - rte_mempool_avail_count(params.session_priv_mpool); - rte_mempool_free(params.session_priv_mpool); - params.session_priv_mpool = NULL; - } - /* Free ops mempool */ if (params.op_mpool != NULL) { RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_SYM_OP_POOL count %u\n", diff --git a/app/test/test_ipsec.c b/app/test/test_ipsec.c index 2ffa2a8e79..134545efe1 100644 --- a/app/test/test_ipsec.c +++ b/app/test/test_ipsec.c @@ -355,20 +355,9 @@ testsuite_setup(void) return TEST_FAILED; } - ts_params->qp_conf.mp_session_private = rte_mempool_create( - "test_priv_sess_mp", - MAX_NB_SESSIONS, - sess_sz, - 0, 0, NULL, NULL, NULL, - NULL, SOCKET_ID_ANY, - 0); - - TEST_ASSERT_NOT_NULL(ts_params->qp_conf.mp_session_private, - "private session mempool allocation failed"); - ts_params->qp_conf.mp_session = rte_cryptodev_sym_session_pool_create("test_sess_mp", - MAX_NB_SESSIONS, 0, 0, 0, SOCKET_ID_ANY); + MAX_NB_SESSIONS, sess_sz, 0, 0, SOCKET_ID_ANY); TEST_ASSERT_NOT_NULL(ts_params->qp_conf.mp_session, "session mempool allocation failed"); @@ -413,11 +402,6 @@ testsuite_teardown(void) rte_mempool_free(ts_params->qp_conf.mp_session); ts_params->qp_conf.mp_session = NULL; } - - if (ts_params->qp_conf.mp_session_private != NULL) { - rte_mempool_free(ts_params->qp_conf.mp_session_private); - ts_params->qp_conf.mp_session_private = NULL; - } } static int @@ -644,7 +628,7 @@ create_crypto_session(struct ipsec_unitest_params *ut, struct rte_cryptodev_qp_conf *qp, uint8_t dev_id, uint32_t j) { int32_t rc; - struct rte_cryptodev_sym_session *s; + void *s; s = rte_cryptodev_sym_session_create(qp->mp_session); if (s == NULL) @@ -652,7 +636,7 @@ create_crypto_session(struct ipsec_unitest_params *ut, /* initiliaze SA crypto session for device */ rc = rte_cryptodev_sym_session_init(dev_id, s, - ut->crypto_xforms, qp->mp_session_private); + ut->crypto_xforms); if (rc == 0) { ut->ss[j].crypto.ses = s; return 0; diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c index edb7275e76..75330292af 100644 --- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c +++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c @@ -235,7 +235,6 @@ aesni_gcm_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, goto qp_setup_cleanup; qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); @@ -259,10 +258,8 @@ aesni_gcm_pmd_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int aesni_gcm_pmd_sym_session_configure(struct rte_cryptodev *dev __rte_unused, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { - void *sess_private_data; int ret; struct aesni_gcm_private *internals = dev->data->dev_private; @@ -271,42 +268,24 @@ aesni_gcm_pmd_sym_session_configure(struct rte_cryptodev *dev __rte_unused, return -EINVAL; } - if (rte_mempool_get(mempool, &sess_private_data)) { - AESNI_GCM_LOG(ERR, - "Couldn't get object from session mempool"); - return -ENOMEM; - } ret = aesni_gcm_set_session_parameters(internals->ops, - sess_private_data, xform); + sess, xform); if (ret != 0) { AESNI_GCM_LOG(ERR, "failed configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } /** Clear the memory of session so it doesn't leave key material behind */ static void -aesni_gcm_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +aesni_gcm_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - + RTE_SET_USED(dev); /* Zero out the whole structure */ - if (sess_priv) { - memset(sess_priv, 0, sizeof(struct aesni_gcm_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); - } + if (sess) + memset(sess, 0, sizeof(struct aesni_gcm_session)); } struct rte_cryptodev_ops aesni_gcm_pmd_ops = { diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c index 39c67e3952..efdc05c45f 100644 --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c @@ -944,7 +944,6 @@ aesni_mb_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, } qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; memset(&qp->stats, 0, sizeof(qp->stats)); @@ -974,11 +973,8 @@ aesni_mb_pmd_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) /** Configure a aesni multi-buffer session from a crypto xform chain */ static int aesni_mb_pmd_sym_session_configure(struct rte_cryptodev *dev, - struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + struct rte_crypto_sym_xform *xform, void *sess) { - void *sess_private_data; struct aesni_mb_private *internals = dev->data->dev_private; int ret; @@ -987,43 +983,25 @@ aesni_mb_pmd_sym_session_configure(struct rte_cryptodev *dev, return -EINVAL; } - if (rte_mempool_get(mempool, &sess_private_data)) { - AESNI_MB_LOG(ERR, - "Couldn't get object from session mempool"); - return -ENOMEM; - } - ret = aesni_mb_set_session_parameters(internals->mb_mgr, - sess_private_data, xform); + sess, xform); if (ret != 0) { AESNI_MB_LOG(ERR, "failed configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } /** Clear the memory of session so it doesn't leave key material behind */ static void -aesni_mb_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +aesni_mb_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); + RTE_SET_USED(dev); /* Zero out the whole structure */ - if (sess_priv) { - memset(sess_priv, 0, sizeof(struct aesni_mb_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); - } + if (sess) + memset(sess, 0, sizeof(struct aesni_mb_session)); } struct rte_cryptodev_ops aesni_mb_pmd_ops = { diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c index 1b2749fe62..2d3b54b063 100644 --- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c +++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c @@ -244,7 +244,6 @@ armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, goto qp_setup_cleanup; qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; memset(&qp->stats, 0, sizeof(qp->stats)); @@ -268,10 +267,8 @@ armv8_crypto_pmd_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int armv8_crypto_pmd_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { - void *sess_private_data; int ret; if (unlikely(sess == NULL)) { @@ -279,42 +276,23 @@ armv8_crypto_pmd_sym_session_configure(struct rte_cryptodev *dev, return -EINVAL; } - if (rte_mempool_get(mempool, &sess_private_data)) { - CDEV_LOG_ERR( - "Couldn't get object from session mempool"); - return -ENOMEM; - } - - ret = armv8_crypto_set_session_parameters(sess_private_data, xform); + ret = armv8_crypto_set_session_parameters(sess, xform); if (ret != 0) { ARMV8_CRYPTO_LOG_ERR("failed configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } /** Clear the memory of session so it doesn't leave key material behind */ static void -armv8_crypto_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +armv8_crypto_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - + RTE_SET_USED(dev); /* Zero out the whole structure */ - if (sess_priv) { - memset(sess_priv, 0, sizeof(struct armv8_crypto_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); - } + if (sess) + memset(sess, 0, sizeof(struct armv8_crypto_session)); } struct rte_cryptodev_ops armv8_crypto_pmd_ops = { diff --git a/drivers/crypto/bcmfs/bcmfs_sym_session.c b/drivers/crypto/bcmfs/bcmfs_sym_session.c index 675ed0ad55..b4b167d0c2 100644 --- a/drivers/crypto/bcmfs/bcmfs_sym_session.c +++ b/drivers/crypto/bcmfs/bcmfs_sym_session.c @@ -224,10 +224,9 @@ bcmfs_sym_get_session(struct rte_crypto_op *op) int bcmfs_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { - void *sess_private_data; + RTE_SET_USED(dev); int ret; if (unlikely(sess == NULL)) { @@ -235,44 +234,23 @@ bcmfs_sym_session_configure(struct rte_cryptodev *dev, return -EINVAL; } - if (rte_mempool_get(mempool, &sess_private_data)) { - BCMFS_DP_LOG(ERR, - "Couldn't get object from session mempool"); - return -ENOMEM; - } - - ret = crypto_set_session_parameters(sess_private_data, xform); + ret = crypto_set_session_parameters(sess, xform); if (ret != 0) { BCMFS_DP_LOG(ERR, "Failed configure session parameters"); - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } /* Clear the memory of session so it doesn't leave key material behind */ void -bcmfs_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +bcmfs_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - - if (sess_priv) { - struct rte_mempool *sess_mp; - - memset(sess_priv, 0, sizeof(struct bcmfs_sym_session)); - sess_mp = rte_mempool_from_obj(sess_priv); - - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); - } + RTE_SET_USED(dev); + if (sess) + memset(sess, 0, sizeof(struct bcmfs_sym_session)); } unsigned int diff --git a/drivers/crypto/bcmfs/bcmfs_sym_session.h b/drivers/crypto/bcmfs/bcmfs_sym_session.h index d40595b4bd..7faafe2fd5 100644 --- a/drivers/crypto/bcmfs/bcmfs_sym_session.h +++ b/drivers/crypto/bcmfs/bcmfs_sym_session.h @@ -93,12 +93,10 @@ bcmfs_process_crypto_op(struct rte_crypto_op *op, int bcmfs_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool); + void *sess); void -bcmfs_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess); +bcmfs_sym_session_clear(struct rte_cryptodev *dev, void *sess); unsigned int bcmfs_sym_session_get_private_size(struct rte_cryptodev *dev __rte_unused); diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c index ce7a100778..8a04820fa6 100644 --- a/drivers/crypto/caam_jr/caam_jr.c +++ b/drivers/crypto/caam_jr/caam_jr.c @@ -1692,52 +1692,36 @@ caam_jr_set_session_parameters(struct rte_cryptodev *dev, static int caam_jr_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { - void *sess_private_data; int ret; PMD_INIT_FUNC_TRACE(); - if (rte_mempool_get(mempool, &sess_private_data)) { - CAAM_JR_ERR("Couldn't get object from session mempool"); - return -ENOMEM; - } - - memset(sess_private_data, 0, sizeof(struct caam_jr_session)); - ret = caam_jr_set_session_parameters(dev, xform, sess_private_data); + memset(sess, 0, sizeof(struct caam_jr_session)); + ret = caam_jr_set_session_parameters(dev, xform, sess); if (ret != 0) { CAAM_JR_ERR("failed to configure session parameters"); - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, sess_private_data); - return 0; } /* Clear the memory of session so it doesn't leave key material behind */ static void -caam_jr_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +caam_jr_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - struct caam_jr_session *s = (struct caam_jr_session *)sess_priv; + RTE_SET_USED(dev); + + struct caam_jr_session *s = (struct caam_jr_session *)sess; PMD_INIT_FUNC_TRACE(); - if (sess_priv) { - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - + if (sess) { rte_free(s->cipher_key.data); rte_free(s->auth_key.data); memset(s, 0, sizeof(struct caam_jr_session)); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); } } diff --git a/drivers/crypto/ccp/ccp_pmd_ops.c b/drivers/crypto/ccp/ccp_pmd_ops.c index 0d615d311c..cac1268130 100644 --- a/drivers/crypto/ccp/ccp_pmd_ops.c +++ b/drivers/crypto/ccp/ccp_pmd_ops.c @@ -727,7 +727,6 @@ ccp_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, } qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; /* mempool for batch info */ qp->batch_mp = rte_mempool_create( @@ -758,11 +757,9 @@ ccp_pmd_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int ccp_pmd_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { int ret; - void *sess_private_data; struct ccp_private *internals; if (unlikely(sess == NULL || xform == NULL)) { @@ -770,39 +767,22 @@ ccp_pmd_sym_session_configure(struct rte_cryptodev *dev, return -ENOMEM; } - if (rte_mempool_get(mempool, &sess_private_data)) { - CCP_LOG_ERR("Couldn't get object from session mempool"); - return -ENOMEM; - } internals = (struct ccp_private *)dev->data->dev_private; - ret = ccp_set_session_parameters(sess_private_data, xform, internals); + ret = ccp_set_session_parameters(sess, xform, internals); if (ret != 0) { CCP_LOG_ERR("failed configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); return 0; } static void -ccp_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +ccp_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - - if (sess_priv) { - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - - rte_mempool_put(sess_mp, sess_priv); - memset(sess_priv, 0, sizeof(struct ccp_session)); - set_sym_session_private_data(sess, index, NULL); - } + RTE_SET_USED(dev); + if (sess) + memset(sess, 0, sizeof(struct ccp_session)); } struct rte_cryptodev_ops ccp_ops = { diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c index 99968cc353..50cae5e3d6 100644 --- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c @@ -32,17 +32,18 @@ cn10k_cpt_sym_temp_sess_create(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op) if (sess == NULL) return NULL; - ret = sym_session_configure(qp->lf.roc_cpt, driver_id, sym_op->xform, - sess, qp->sess_mp_priv); + sess->sess_data[driver_id].data = + (void *)((uint8_t *)sess + + rte_cryptodev_sym_get_header_session_size() + + (driver_id * sess->priv_sz)); + priv = get_sym_session_private_data(sess, driver_id); + ret = sym_session_configure(qp->lf.roc_cpt, sym_op->xform, (void *)priv); if (ret) goto sess_put; - priv = get_sym_session_private_data(sess, driver_id); - sym_op->session = sess; return priv; - sess_put: rte_mempool_put(qp->sess_mp, sess); return NULL; @@ -144,9 +145,7 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], ret = cpt_sym_inst_fill(qp, op, sess, infl_req, &inst[0]); if (unlikely(ret)) { - sym_session_clear(cn10k_cryptodev_driver_id, - op->sym->session); - rte_mempool_put(qp->sess_mp, op->sym->session); + sym_session_clear(op->sym->session); return 0; } w7 = sess->cpt_inst_w7; @@ -437,8 +436,7 @@ cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp, temp_sess_free: if (unlikely(cop->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { if (cop->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { - sym_session_clear(cn10k_cryptodev_driver_id, - cop->sym->session); + sym_session_clear(cop->sym->session); sz = rte_cryptodev_sym_get_existing_header_session_size( cop->sym->session); memset(cop->sym->session, 0, sz); diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c index 4c2dc5b080..5f83581131 100644 --- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c @@ -81,17 +81,19 @@ cn9k_cpt_sym_temp_sess_create(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op) if (sess == NULL) return NULL; - ret = sym_session_configure(qp->lf.roc_cpt, driver_id, sym_op->xform, - sess, qp->sess_mp_priv); + sess->sess_data[driver_id].data = + (void *)((uint8_t *)sess + + rte_cryptodev_sym_get_header_session_size() + + (driver_id * sess->priv_sz)); + priv = get_sym_session_private_data(sess, driver_id); + ret = sym_session_configure(qp->lf.roc_cpt, sym_op->xform, + (void *)priv); if (ret) goto sess_put; - priv = get_sym_session_private_data(sess, driver_id); - sym_op->session = sess; return priv; - sess_put: rte_mempool_put(qp->sess_mp, sess); return NULL; @@ -126,8 +128,7 @@ cn9k_cpt_inst_prep(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op, ret = cn9k_cpt_sym_inst_fill(qp, op, sess, infl_req, inst); if (unlikely(ret)) { - sym_session_clear(cn9k_cryptodev_driver_id, - op->sym->session); + sym_session_clear(op->sym->session); rte_mempool_put(qp->sess_mp, op->sym->session); } inst->w7.u64 = sess->cpt_inst_w7; @@ -484,8 +485,7 @@ cn9k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp, struct rte_crypto_op *cop, temp_sess_free: if (unlikely(cop->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { if (cop->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { - sym_session_clear(cn9k_cryptodev_driver_id, - cop->sym->session); + sym_session_clear(cop->sym->session); sz = rte_cryptodev_sym_get_existing_header_session_size( cop->sym->session); memset(cop->sym->session, 0, sz); diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c index 41d8fe49e1..52d9cf0cf3 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c @@ -379,7 +379,6 @@ cnxk_cpt_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, } qp->sess_mp = conf->mp_session; - qp->sess_mp_priv = conf->mp_session_private; dev->data->queue_pairs[qp_id] = qp; return 0; @@ -493,27 +492,20 @@ cnxk_cpt_inst_w7_get(struct cnxk_se_sess *sess, struct roc_cpt *roc_cpt) } int -sym_session_configure(struct roc_cpt *roc_cpt, int driver_id, +sym_session_configure(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *pool) + void *sess) { struct cnxk_se_sess *sess_priv; - void *priv; int ret; ret = sym_xform_verify(xform); if (unlikely(ret < 0)) return ret; - if (unlikely(rte_mempool_get(pool, &priv))) { - plt_dp_err("Could not allocate session private data"); - return -ENOMEM; - } + memset(sess, 0, sizeof(struct cnxk_se_sess)); - memset(priv, 0, sizeof(struct cnxk_se_sess)); - - sess_priv = priv; + sess_priv = sess; switch (ret) { case CNXK_CPT_CIPHER: @@ -547,7 +539,7 @@ sym_session_configure(struct roc_cpt *roc_cpt, int driver_id, } if (ret) - goto priv_put; + return -ENOTSUP; if ((sess_priv->roc_se_ctx.fc_type == ROC_SE_HASH_HMAC) && cpt_mac_len_verify(&xform->auth)) { @@ -557,66 +549,45 @@ sym_session_configure(struct roc_cpt *roc_cpt, int driver_id, sess_priv->roc_se_ctx.auth_key = NULL; } - ret = -ENOTSUP; - goto priv_put; + return -ENOTSUP; } sess_priv->cpt_inst_w7 = cnxk_cpt_inst_w7_get(sess_priv, roc_cpt); - set_sym_session_private_data(sess, driver_id, sess_priv); - return 0; - -priv_put: - rte_mempool_put(pool, priv); - - return -ENOTSUP; } int cnxk_cpt_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *pool) + void *sess) { struct cnxk_cpt_vf *vf = dev->data->dev_private; struct roc_cpt *roc_cpt = &vf->cpt; - uint8_t driver_id; - driver_id = dev->driver_id; - - return sym_session_configure(roc_cpt, driver_id, xform, sess, pool); + return sym_session_configure(roc_cpt, xform, sess); } void -sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess) +sym_session_clear(void *sess) { - void *priv = get_sym_session_private_data(sess, driver_id); - struct cnxk_se_sess *sess_priv; - struct rte_mempool *pool; + struct cnxk_se_sess *sess_priv = sess; - if (priv == NULL) + if (sess == NULL) return; - sess_priv = priv; - if (sess_priv->roc_se_ctx.auth_key != NULL) plt_free(sess_priv->roc_se_ctx.auth_key); - memset(priv, 0, cnxk_cpt_sym_session_get_size(NULL)); - - pool = rte_mempool_from_obj(priv); - - set_sym_session_private_data(sess, driver_id, NULL); - - rte_mempool_put(pool, priv); + memset(sess_priv, 0, cnxk_cpt_sym_session_get_size(NULL)); } void -cnxk_cpt_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +cnxk_cpt_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - return sym_session_clear(dev->driver_id, sess); + RTE_SET_USED(dev); + + return sym_session_clear(sess); } unsigned int diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h index c5332dec53..3c09d10582 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h @@ -111,18 +111,15 @@ unsigned int cnxk_cpt_sym_session_get_size(struct rte_cryptodev *dev); int cnxk_cpt_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *pool); + void *sess); -int sym_session_configure(struct roc_cpt *roc_cpt, int driver_id, +int sym_session_configure(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *pool); + void *sess); -void cnxk_cpt_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess); +void cnxk_cpt_sym_session_clear(struct rte_cryptodev *dev, void *sess); -void sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess); +void sym_session_clear(void *sess); unsigned int cnxk_ae_session_size_get(struct rte_cryptodev *dev __rte_unused); diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 176f1a27a0..42229763f8 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -3438,49 +3438,32 @@ dpaa2_sec_security_session_destroy(void *dev __rte_unused, void *sess) static int dpaa2_sec_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { - void *sess_private_data; int ret; - if (rte_mempool_get(mempool, &sess_private_data)) { - DPAA2_SEC_ERR("Couldn't get object from session mempool"); - return -ENOMEM; - } - - ret = dpaa2_sec_set_session_parameters(dev, xform, sess_private_data); + ret = dpaa2_sec_set_session_parameters(dev, xform, sess); if (ret != 0) { DPAA2_SEC_ERR("Failed to configure session parameters"); - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } /** Clear the memory of session so it doesn't leave key material behind */ static void -dpaa2_sec_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +dpaa2_sec_sym_session_clear(struct rte_cryptodev *dev, void *sess) { PMD_INIT_FUNC_TRACE(); - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - dpaa2_sec_session *s = (dpaa2_sec_session *)sess_priv; + RTE_SET_USED(dev); + dpaa2_sec_session *s = (dpaa2_sec_session *)sess; - if (sess_priv) { + if (sess) { rte_free(s->ctxt); rte_free(s->cipher_key.data); rte_free(s->auth_key.data); memset(s, 0, sizeof(dpaa2_sec_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); } } diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index 5a087df090..4727088b45 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -2537,33 +2537,18 @@ dpaa_sec_set_session_parameters(struct rte_cryptodev *dev, static int dpaa_sec_sym_session_configure(struct rte_cryptodev *dev, - struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + struct rte_crypto_sym_xform *xform, void *sess) { - void *sess_private_data; int ret; PMD_INIT_FUNC_TRACE(); - if (rte_mempool_get(mempool, &sess_private_data)) { - DPAA_SEC_ERR("Couldn't get object from session mempool"); - return -ENOMEM; - } - - ret = dpaa_sec_set_session_parameters(dev, xform, sess_private_data); + ret = dpaa_sec_set_session_parameters(dev, xform, sess); if (ret != 0) { DPAA_SEC_ERR("failed to configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - - return 0; } @@ -2584,18 +2569,14 @@ free_session_memory(struct rte_cryptodev *dev, dpaa_sec_session *s) /** Clear the memory of session so it doesn't leave key material behind */ static void -dpaa_sec_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +dpaa_sec_sym_session_clear(struct rte_cryptodev *dev, void *sess) { PMD_INIT_FUNC_TRACE(); - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - dpaa_sec_session *s = (dpaa_sec_session *)sess_priv; + RTE_SET_USED(dev); + dpaa_sec_session *s = (dpaa_sec_session *)sess; - if (sess_priv) { + if (sess) free_session_memory(dev, s); - set_sym_session_private_data(sess, index, NULL); - } } #ifdef RTE_LIB_SECURITY diff --git a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c index f075054807..b2e5c92598 100644 --- a/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c +++ b/drivers/crypto/kasumi/rte_kasumi_pmd_ops.c @@ -220,7 +220,6 @@ kasumi_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, qp->mgr = internals->mgr; qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); @@ -243,10 +242,8 @@ kasumi_pmd_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int kasumi_pmd_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { - void *sess_private_data; int ret; struct kasumi_private *internals = dev->data->dev_private; @@ -255,43 +252,24 @@ kasumi_pmd_sym_session_configure(struct rte_cryptodev *dev, return -EINVAL; } - if (rte_mempool_get(mempool, &sess_private_data)) { - KASUMI_LOG(ERR, - "Couldn't get object from session mempool"); - return -ENOMEM; - } - ret = kasumi_set_session_parameters(internals->mgr, - sess_private_data, xform); + sess, xform); if (ret != 0) { KASUMI_LOG(ERR, "failed configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } /** Clear the memory of session so it doesn't leave key material behind */ static void -kasumi_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +kasumi_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - + RTE_SET_USED(dev); /* Zero out the whole structure */ - if (sess_priv) { - memset(sess_priv, 0, sizeof(struct kasumi_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); - } + if (sess) + memset(sess, 0, sizeof(struct kasumi_session)); } struct rte_cryptodev_ops kasumi_pmd_ops = { diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index 682cf8b607..615ab9f45d 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -165,14 +165,12 @@ mlx5_crypto_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int mlx5_crypto_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *session, - struct rte_mempool *mp) + void *session) { struct mlx5_crypto_priv *priv = dev->data->dev_private; - struct mlx5_crypto_session *sess_private_data; + struct mlx5_crypto_session *sess_private_data = session; struct rte_crypto_cipher_xform *cipher; uint8_t encryption_order; - int ret; if (unlikely(xform->next != NULL)) { DRV_LOG(ERR, "Xform next is not supported."); @@ -183,17 +181,9 @@ mlx5_crypto_sym_session_configure(struct rte_cryptodev *dev, DRV_LOG(ERR, "Only AES-XTS algorithm is supported."); return -ENOTSUP; } - ret = rte_mempool_get(mp, (void *)&sess_private_data); - if (ret != 0) { - DRV_LOG(ERR, - "Failed to get session %p private data from mempool.", - sess_private_data); - return -ENOMEM; - } cipher = &xform->cipher; sess_private_data->dek = mlx5_crypto_dek_prepare(priv, cipher); if (sess_private_data->dek == NULL) { - rte_mempool_put(mp, sess_private_data); DRV_LOG(ERR, "Failed to prepare dek."); return -ENOMEM; } @@ -228,27 +218,21 @@ mlx5_crypto_sym_session_configure(struct rte_cryptodev *dev, sess_private_data->dek_id = rte_cpu_to_be_32(sess_private_data->dek->obj->id & 0xffffff); - set_sym_session_private_data(session, dev->driver_id, - sess_private_data); DRV_LOG(DEBUG, "Session %p was configured.", sess_private_data); return 0; } static void -mlx5_crypto_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +mlx5_crypto_sym_session_clear(struct rte_cryptodev *dev, void *sess) { struct mlx5_crypto_priv *priv = dev->data->dev_private; - struct mlx5_crypto_session *spriv = get_sym_session_private_data(sess, - dev->driver_id); + struct mlx5_crypto_session *spriv = sess; if (unlikely(spriv == NULL)) { DRV_LOG(ERR, "Failed to get session %p private data.", spriv); return; } mlx5_crypto_dek_destroy(priv, spriv->dek); - set_sym_session_private_data(sess, dev->driver_id, NULL); - rte_mempool_put(rte_mempool_from_obj(spriv), spriv); DRV_LOG(DEBUG, "Session %p was cleared.", spriv); } diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c index e04a2c88c7..2e4b27ea21 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c @@ -704,7 +704,6 @@ mrvl_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, break; qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; memset(&qp->stats, 0, sizeof(qp->stats)); dev->data->queue_pairs[qp_id] = qp; @@ -735,12 +734,9 @@ mrvl_crypto_pmd_sym_session_get_size(__rte_unused struct rte_cryptodev *dev) */ static int mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, - struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mp) + struct rte_crypto_sym_xform *xform, void *sess) { struct mrvl_crypto_session *mrvl_sess; - void *sess_private_data; int ret; if (sess == NULL) { @@ -748,25 +744,16 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, return -EINVAL; } - if (rte_mempool_get(mp, &sess_private_data)) { - CDEV_LOG_ERR("Couldn't get object from session mempool."); - return -ENOMEM; - } + memset(sess, 0, sizeof(struct mrvl_crypto_session)); - memset(sess_private_data, 0, sizeof(struct mrvl_crypto_session)); - - ret = mrvl_crypto_set_session_parameters(sess_private_data, xform); + ret = mrvl_crypto_set_session_parameters(sess, xform); if (ret != 0) { MRVL_LOG(ERR, "Failed to configure session parameters!"); - - /* Return session to mempool */ - rte_mempool_put(mp, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, sess_private_data); - mrvl_sess = (struct mrvl_crypto_session *)sess_private_data; + mrvl_sess = (struct mrvl_crypto_session *)sess; if (sam_session_create(&mrvl_sess->sam_sess_params, &mrvl_sess->sam_sess) < 0) { MRVL_LOG(DEBUG, "Failed to create session!"); @@ -789,17 +776,13 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, * @returns 0. Always. */ static void -mrvl_crypto_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +mrvl_crypto_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - + RTE_SET_USED(dev); /* Zero out the whole structure */ - if (sess_priv) { + if (sess) { struct mrvl_crypto_session *mrvl_sess = - (struct mrvl_crypto_session *)sess_priv; + (struct mrvl_crypto_session *)sess; if (mrvl_sess->sam_sess && sam_session_destroy(mrvl_sess->sam_sess) < 0) { @@ -807,9 +790,6 @@ mrvl_crypto_pmd_sym_session_clear(struct rte_cryptodev *dev, } memset(mrvl_sess, 0, sizeof(struct mrvl_crypto_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); } } diff --git a/drivers/crypto/nitrox/nitrox_sym.c b/drivers/crypto/nitrox/nitrox_sym.c index f8b7edcd69..0c9bbfef46 100644 --- a/drivers/crypto/nitrox/nitrox_sym.c +++ b/drivers/crypto/nitrox/nitrox_sym.c @@ -532,22 +532,16 @@ configure_aead_ctx(struct rte_crypto_aead_xform *xform, static int nitrox_sym_dev_sess_configure(struct rte_cryptodev *cdev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { - void *mp_obj; struct nitrox_crypto_ctx *ctx; struct rte_crypto_cipher_xform *cipher_xform = NULL; struct rte_crypto_auth_xform *auth_xform = NULL; struct rte_crypto_aead_xform *aead_xform = NULL; int ret = -EINVAL; - if (rte_mempool_get(mempool, &mp_obj)) { - NITROX_LOG(ERR, "Couldn't allocate context\n"); - return -ENOMEM; - } - - ctx = mp_obj; + RTE_SET_USED(cdev); + ctx = sess; ctx->nitrox_chain = get_crypto_chain_order(xform); switch (ctx->nitrox_chain) { case NITROX_CHAIN_CIPHER_ONLY: @@ -586,28 +580,17 @@ nitrox_sym_dev_sess_configure(struct rte_cryptodev *cdev, } ctx->iova = rte_mempool_virt2iova(ctx); - set_sym_session_private_data(sess, cdev->driver_id, ctx); return 0; err: - rte_mempool_put(mempool, mp_obj); return ret; } static void -nitrox_sym_dev_sess_clear(struct rte_cryptodev *cdev, - struct rte_cryptodev_sym_session *sess) +nitrox_sym_dev_sess_clear(struct rte_cryptodev *cdev, void *sess) { - struct nitrox_crypto_ctx *ctx = get_sym_session_private_data(sess, - cdev->driver_id); - struct rte_mempool *sess_mp; - - if (!ctx) - return; - - memset(ctx, 0, sizeof(*ctx)); - sess_mp = rte_mempool_from_obj(ctx); - set_sym_session_private_data(sess, cdev->driver_id, NULL); - rte_mempool_put(sess_mp, ctx); + RTE_SET_USED(cdev); + if (sess) + memset(sess, 0, sizeof(struct nitrox_crypto_ctx)); } static struct nitrox_crypto_ctx * diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c index a8b5a06e7f..65bfa8dcf7 100644 --- a/drivers/crypto/null/null_crypto_pmd_ops.c +++ b/drivers/crypto/null/null_crypto_pmd_ops.c @@ -234,7 +234,6 @@ null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, } qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); @@ -258,10 +257,8 @@ null_crypto_pmd_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int null_crypto_pmd_sym_session_configure(struct rte_cryptodev *dev __rte_unused, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mp) + void *sess) { - void *sess_private_data; int ret; if (unlikely(sess == NULL)) { @@ -269,42 +266,23 @@ null_crypto_pmd_sym_session_configure(struct rte_cryptodev *dev __rte_unused, return -EINVAL; } - if (rte_mempool_get(mp, &sess_private_data)) { - NULL_LOG(ERR, - "Couldn't get object from session mempool"); - return -ENOMEM; - } - - ret = null_crypto_set_session_parameters(sess_private_data, xform); + ret = null_crypto_set_session_parameters(sess, xform); if (ret != 0) { NULL_LOG(ERR, "failed configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mp, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } /** Clear the memory of session so it doesn't leave key material behind */ static void -null_crypto_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +null_crypto_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - + RTE_SET_USED(dev); /* Zero out the whole structure */ - if (sess_priv) { - memset(sess_priv, 0, sizeof(struct null_crypto_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); - } + if (sess) + memset(sess, 0, sizeof(struct null_crypto_session)); } static struct rte_cryptodev_ops pmd_ops = { diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.h b/drivers/crypto/octeontx/otx_cryptodev_hw_access.h index 7c6b1e45b4..95659e472b 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.h +++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.h @@ -49,7 +49,6 @@ struct cpt_instance { uint32_t queue_id; uintptr_t rsvd; struct rte_mempool *sess_mp; - struct rte_mempool *sess_mp_priv; struct cpt_qp_meta_info meta_info; uint8_t ca_enabled; }; diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c index 9e8fd495cf..abd0963be0 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_ops.c +++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c @@ -171,7 +171,6 @@ otx_cpt_que_pair_setup(struct rte_cryptodev *dev, instance->queue_id = que_pair_id; instance->sess_mp = qp_conf->mp_session; - instance->sess_mp_priv = qp_conf->mp_session_private; dev->data->queue_pairs[que_pair_id] = instance; return 0; @@ -243,29 +242,22 @@ sym_xform_verify(struct rte_crypto_sym_xform *xform) } static int -sym_session_configure(int driver_id, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *pool) +sym_session_configure(struct rte_crypto_sym_xform *xform, + void *sess) { struct rte_crypto_sym_xform *temp_xform = xform; struct cpt_sess_misc *misc; vq_cmd_word3_t vq_cmd_w3; - void *priv; int ret; ret = sym_xform_verify(xform); if (unlikely(ret)) return ret; - if (unlikely(rte_mempool_get(pool, &priv))) { - CPT_LOG_ERR("Could not allocate session private data"); - return -ENOMEM; - } - - memset(priv, 0, sizeof(struct cpt_sess_misc) + + memset(sess, 0, sizeof(struct cpt_sess_misc) + offsetof(struct cpt_ctx, mc_ctx)); - misc = priv; + misc = sess; for ( ; xform != NULL; xform = xform->next) { switch (xform->type) { @@ -301,8 +293,6 @@ sym_session_configure(int driver_id, struct rte_crypto_sym_xform *xform, goto priv_put; } - set_sym_session_private_data(sess, driver_id, priv); - misc->ctx_dma_addr = rte_mempool_virt2iova(misc) + sizeof(struct cpt_sess_misc); @@ -316,56 +306,46 @@ sym_session_configure(int driver_id, struct rte_crypto_sym_xform *xform, return 0; priv_put: - if (priv) - rte_mempool_put(pool, priv); return -ENOTSUP; } static void -sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess) +sym_session_clear(void *sess) { - void *priv = get_sym_session_private_data(sess, driver_id); struct cpt_sess_misc *misc; - struct rte_mempool *pool; struct cpt_ctx *ctx; - if (priv == NULL) + if (sess == NULL) return; - misc = priv; + misc = sess; ctx = SESS_PRIV(misc); if (ctx->auth_key != NULL) rte_free(ctx->auth_key); - memset(priv, 0, cpt_get_session_size()); - - pool = rte_mempool_from_obj(priv); - - set_sym_session_private_data(sess, driver_id, NULL); - - rte_mempool_put(pool, priv); + memset(sess, 0, cpt_get_session_size()); } static int otx_cpt_session_cfg(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *pool) + void *sess) { CPT_PMD_INIT_FUNC_TRACE(); + RTE_SET_USED(dev); - return sym_session_configure(dev->driver_id, xform, sess, pool); + return sym_session_configure(xform, sess); } static void -otx_cpt_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +otx_cpt_session_clear(struct rte_cryptodev *dev, void *sess) { CPT_PMD_INIT_FUNC_TRACE(); + RTE_SET_USED(dev); - return sym_session_clear(dev->driver_id, sess); + return sym_session_clear(sess); } static unsigned int @@ -576,7 +556,6 @@ static __rte_always_inline void * __rte_hot otx_cpt_enq_single_sym_sessless(struct cpt_instance *instance, struct rte_crypto_op *op) { - const int driver_id = otx_cryptodev_driver_id; struct rte_crypto_sym_op *sym_op = op->sym; struct rte_cryptodev_sym_session *sess; void *req; @@ -589,8 +568,12 @@ otx_cpt_enq_single_sym_sessless(struct cpt_instance *instance, return NULL; } - ret = sym_session_configure(driver_id, sym_op->xform, sess, - instance->sess_mp_priv); + sess->sess_data[otx_cryptodev_driver_id].data = + (void *)((uint8_t *)sess + + rte_cryptodev_sym_get_header_session_size() + + (otx_cryptodev_driver_id * sess->priv_sz)); + ret = sym_session_configure(sym_op->xform, + sess->sess_data[otx_cryptodev_driver_id].data); if (ret) goto sess_put; @@ -604,7 +587,7 @@ otx_cpt_enq_single_sym_sessless(struct cpt_instance *instance, return req; priv_put: - sym_session_clear(driver_id, sess); + sym_session_clear(sess); sess_put: rte_mempool_put(instance->sess_mp, sess); return NULL; @@ -913,7 +896,6 @@ free_sym_session_data(const struct cpt_instance *instance, memset(cop->sym->session, 0, rte_cryptodev_sym_get_existing_header_session_size( cop->sym->session)); - rte_mempool_put(instance->sess_mp_priv, sess_private_data_t); rte_mempool_put(instance->sess_mp, cop->sym->session); cop->sym->session = NULL; } diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c index 7b744cd4b4..dcfbc49996 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c @@ -371,29 +371,21 @@ sym_xform_verify(struct rte_crypto_sym_xform *xform) } static int -sym_session_configure(int driver_id, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *pool) +sym_session_configure(struct rte_crypto_sym_xform *xform, void *sess) { struct rte_crypto_sym_xform *temp_xform = xform; struct cpt_sess_misc *misc; vq_cmd_word3_t vq_cmd_w3; - void *priv; int ret; ret = sym_xform_verify(xform); if (unlikely(ret)) return ret; - if (unlikely(rte_mempool_get(pool, &priv))) { - CPT_LOG_ERR("Could not allocate session private data"); - return -ENOMEM; - } - - memset(priv, 0, sizeof(struct cpt_sess_misc) + + memset(sess, 0, sizeof(struct cpt_sess_misc) + offsetof(struct cpt_ctx, mc_ctx)); - misc = priv; + misc = sess; for ( ; xform != NULL; xform = xform->next) { switch (xform->type) { @@ -414,7 +406,7 @@ sym_session_configure(int driver_id, struct rte_crypto_sym_xform *xform, } if (ret) - goto priv_put; + return -ENOTSUP; } if ((GET_SESS_FC_TYPE(misc) == HASH_HMAC) && @@ -425,12 +417,9 @@ sym_session_configure(int driver_id, struct rte_crypto_sym_xform *xform, rte_free(ctx->auth_key); ctx->auth_key = NULL; } - ret = -ENOTSUP; - goto priv_put; + return -ENOTSUP; } - set_sym_session_private_data(sess, driver_id, misc); - misc->ctx_dma_addr = rte_mempool_virt2iova(misc) + sizeof(struct cpt_sess_misc); @@ -451,11 +440,6 @@ sym_session_configure(int driver_id, struct rte_crypto_sym_xform *xform, misc->cpt_inst_w7 = vq_cmd_w3.u64; return 0; - -priv_put: - rte_mempool_put(pool, priv); - - return -ENOTSUP; } static __rte_always_inline int32_t __rte_hot @@ -765,7 +749,6 @@ otx2_cpt_enqueue_sym_sessless(struct otx2_cpt_qp *qp, struct rte_crypto_op *op, struct pending_queue *pend_q, unsigned int burst_index) { - const int driver_id = otx2_cryptodev_driver_id; struct rte_crypto_sym_op *sym_op = op->sym; struct rte_cryptodev_sym_session *sess; int ret; @@ -775,8 +758,12 @@ otx2_cpt_enqueue_sym_sessless(struct otx2_cpt_qp *qp, struct rte_crypto_op *op, if (sess == NULL) return -ENOMEM; - ret = sym_session_configure(driver_id, sym_op->xform, sess, - qp->sess_mp_priv); + sess->sess_data[otx2_cryptodev_driver_id].data = + (void *)((uint8_t *)sess + + rte_cryptodev_sym_get_header_session_size() + + (otx2_cryptodev_driver_id * sess->priv_sz)); + ret = sym_session_configure(sym_op->xform, + sess->sess_data[otx2_cryptodev_driver_id].data); if (ret) goto sess_put; @@ -790,7 +777,7 @@ otx2_cpt_enqueue_sym_sessless(struct otx2_cpt_qp *qp, struct rte_crypto_op *op, return 0; priv_put: - sym_session_clear(driver_id, sess); + sym_session_clear(sess); sess_put: rte_mempool_put(qp->sess_mp, sess); return ret; @@ -1035,8 +1022,7 @@ otx2_cpt_dequeue_post_process(struct otx2_cpt_qp *qp, struct rte_crypto_op *cop, } if (unlikely(cop->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { - sym_session_clear(otx2_cryptodev_driver_id, - cop->sym->session); + sym_session_clear(cop->sym->session); sz = rte_cryptodev_sym_get_existing_header_session_size( cop->sym->session); memset(cop->sym->session, 0, sz); @@ -1291,7 +1277,6 @@ otx2_cpt_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id, } qp->sess_mp = conf->mp_session; - qp->sess_mp_priv = conf->mp_session_private; dev->data->queue_pairs[qp_id] = qp; return 0; @@ -1330,21 +1315,22 @@ otx2_cpt_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int otx2_cpt_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *pool) + void *sess) { CPT_PMD_INIT_FUNC_TRACE(); + RTE_SET_USED(dev); - return sym_session_configure(dev->driver_id, xform, sess, pool); + return sym_session_configure(xform, sess); } static void otx2_cpt_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) + void *sess) { CPT_PMD_INIT_FUNC_TRACE(); + RTE_SET_USED(dev); - return sym_session_clear(dev->driver_id, sess); + return sym_session_clear(sess); } static unsigned int diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_ops_helper.h b/drivers/crypto/octeontx2/otx2_cryptodev_ops_helper.h index 01c081a216..5f63eaf7b7 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_ops_helper.h +++ b/drivers/crypto/octeontx2/otx2_cryptodev_ops_helper.h @@ -8,29 +8,21 @@ #include "cpt_pmd_logs.h" static void -sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess) +sym_session_clear(void *sess) { - void *priv = get_sym_session_private_data(sess, driver_id); struct cpt_sess_misc *misc; - struct rte_mempool *pool; struct cpt_ctx *ctx; - if (priv == NULL) + if (sess == NULL) return; - misc = priv; + misc = sess; ctx = SESS_PRIV(misc); if (ctx->auth_key != NULL) rte_free(ctx->auth_key); - memset(priv, 0, cpt_get_session_size()); - - pool = rte_mempool_from_obj(priv); - - set_sym_session_private_data(sess, driver_id, NULL); - - rte_mempool_put(pool, priv); + memset(sess, 0, cpt_get_session_size()); } static __rte_always_inline uint8_t diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index 52715f86f8..1b48a6b400 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -741,7 +741,6 @@ openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, goto qp_setup_cleanup; qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; memset(&qp->stats, 0, sizeof(qp->stats)); @@ -772,10 +771,8 @@ openssl_pmd_asym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int openssl_pmd_sym_session_configure(struct rte_cryptodev *dev __rte_unused, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { - void *sess_private_data; int ret; if (unlikely(sess == NULL)) { @@ -783,24 +780,12 @@ openssl_pmd_sym_session_configure(struct rte_cryptodev *dev __rte_unused, return -EINVAL; } - if (rte_mempool_get(mempool, &sess_private_data)) { - OPENSSL_LOG(ERR, - "Couldn't get object from session mempool"); - return -ENOMEM; - } - - ret = openssl_set_session_parameters(sess_private_data, xform); + ret = openssl_set_session_parameters(sess, xform); if (ret != 0) { OPENSSL_LOG(ERR, "failed configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } @@ -1154,19 +1139,13 @@ openssl_pmd_asym_session_configure(struct rte_cryptodev *dev __rte_unused, /** Clear the memory of session so it doesn't leave key material behind */ static void -openssl_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +openssl_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - + RTE_SET_USED(dev); /* Zero out the whole structure */ - if (sess_priv) { - openssl_reset_session(sess_priv); - memset(sess_priv, 0, sizeof(struct openssl_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); + if (sess) { + openssl_reset_session(sess); + memset(sess, 0, sizeof(struct openssl_session)); } } diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c index 2a22347c7f..114bf081c1 100644 --- a/drivers/crypto/qat/qat_sym_session.c +++ b/drivers/crypto/qat/qat_sym_session.c @@ -172,21 +172,14 @@ qat_is_auth_alg_supported(enum rte_crypto_auth_algorithm algo, } void -qat_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +qat_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - struct qat_sym_session *s = (struct qat_sym_session *)sess_priv; + struct qat_sym_session *s = (struct qat_sym_session *)sess; - if (sess_priv) { + if (sess) { if (s->bpi_ctx) bpi_cipher_ctx_free(s->bpi_ctx); memset(s, 0, qat_sym_session_get_private_size(dev)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); } } @@ -458,31 +451,17 @@ qat_sym_session_configure_cipher(struct rte_cryptodev *dev, int qat_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess_private_data) { - void *sess_private_data; int ret; - if (rte_mempool_get(mempool, &sess_private_data)) { - CDEV_LOG_ERR( - "Couldn't get object from session mempool"); - return -ENOMEM; - } - ret = qat_sym_session_set_parameters(dev, xform, sess_private_data); if (ret != 0) { QAT_LOG(ERR, "Crypto QAT PMD: failed to configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } diff --git a/drivers/crypto/qat/qat_sym_session.h b/drivers/crypto/qat/qat_sym_session.h index 7fcc1d6f7b..6da29e2305 100644 --- a/drivers/crypto/qat/qat_sym_session.h +++ b/drivers/crypto/qat/qat_sym_session.h @@ -112,8 +112,7 @@ struct qat_sym_session { int qat_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool); + void *sess); int qat_sym_session_set_parameters(struct rte_cryptodev *dev, @@ -135,8 +134,7 @@ qat_sym_session_configure_auth(struct rte_cryptodev *dev, struct qat_sym_session *session); void -qat_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *session); +qat_sym_session_clear(struct rte_cryptodev *dev, void *session); unsigned int qat_sym_session_get_private_size(struct rte_cryptodev *dev); diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c index 465b88ade8..87260b5a22 100644 --- a/drivers/crypto/scheduler/scheduler_pmd_ops.c +++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c @@ -476,9 +476,7 @@ scheduler_pmd_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int scheduler_pmd_sym_session_configure(struct rte_cryptodev *dev, - struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + struct rte_crypto_sym_xform *xform, void *sess) { struct scheduler_ctx *sched_ctx = dev->data->dev_private; uint32_t i; @@ -488,7 +486,7 @@ scheduler_pmd_sym_session_configure(struct rte_cryptodev *dev, struct scheduler_worker *worker = &sched_ctx->workers[i]; ret = rte_cryptodev_sym_session_init(worker->dev_id, sess, - xform, mempool); + xform); if (ret < 0) { CR_SCHED_LOG(ERR, "unable to config sym session"); return ret; @@ -500,8 +498,7 @@ scheduler_pmd_sym_session_configure(struct rte_cryptodev *dev, /** Clear the memory of session so it doesn't leave key material behind */ static void -scheduler_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +scheduler_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { struct scheduler_ctx *sched_ctx = dev->data->dev_private; uint32_t i; diff --git a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c index 3f46014b7d..b0f8f6d86a 100644 --- a/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c +++ b/drivers/crypto/snow3g/rte_snow3g_pmd_ops.c @@ -226,7 +226,6 @@ snow3g_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, qp->mgr = internals->mgr; qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); @@ -250,10 +249,8 @@ snow3g_pmd_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int snow3g_pmd_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { - void *sess_private_data; int ret; struct snow3g_private *internals = dev->data->dev_private; @@ -262,43 +259,24 @@ snow3g_pmd_sym_session_configure(struct rte_cryptodev *dev, return -EINVAL; } - if (rte_mempool_get(mempool, &sess_private_data)) { - SNOW3G_LOG(ERR, - "Couldn't get object from session mempool"); - return -ENOMEM; - } - ret = snow3g_set_session_parameters(internals->mgr, - sess_private_data, xform); + sess, xform); if (ret != 0) { SNOW3G_LOG(ERR, "failed configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } /** Clear the memory of session so it doesn't leave key material behind */ static void -snow3g_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +snow3g_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - + RTE_SET_USED(dev); /* Zero out the whole structure */ - if (sess_priv) { - memset(sess_priv, 0, sizeof(struct snow3g_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); - } + if (sess) + memset(sess, 0, sizeof(struct snow3g_session)); } struct rte_cryptodev_ops snow3g_pmd_ops = { diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c index 8faa39df4a..de52fec32e 100644 --- a/drivers/crypto/virtio/virtio_cryptodev.c +++ b/drivers/crypto/virtio/virtio_cryptodev.c @@ -37,11 +37,10 @@ static void virtio_crypto_dev_free_mbufs(struct rte_cryptodev *dev); static unsigned int virtio_crypto_sym_get_session_private_size( struct rte_cryptodev *dev); static void virtio_crypto_sym_clear_session(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess); + void *sess); static int virtio_crypto_sym_configure_session(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *session, - struct rte_mempool *mp); + void *session); /* * The set of PCI devices this driver supports @@ -927,7 +926,7 @@ virtio_crypto_check_sym_clear_session_paras( static void virtio_crypto_sym_clear_session( struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) + void *sess) { struct virtio_crypto_hw *hw; struct virtqueue *vq; @@ -1290,11 +1289,9 @@ static int virtio_crypto_check_sym_configure_session_paras( struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sym_sess, - struct rte_mempool *mempool) + void *sym_sess) { - if (unlikely(xform == NULL) || unlikely(sym_sess == NULL) || - unlikely(mempool == NULL)) { + if (unlikely(xform == NULL) || unlikely(sym_sess == NULL)) { VIRTIO_CRYPTO_SESSION_LOG_ERR("NULL pointer"); return -1; } @@ -1309,12 +1306,9 @@ static int virtio_crypto_sym_configure_session( struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { int ret; - struct virtio_crypto_session crypto_sess; - void *session_private = &crypto_sess; struct virtio_crypto_session *session; struct virtio_crypto_op_ctrl_req *ctrl_req; enum virtio_crypto_cmd_id cmd_id; @@ -1326,19 +1320,13 @@ virtio_crypto_sym_configure_session( PMD_INIT_FUNC_TRACE(); ret = virtio_crypto_check_sym_configure_session_paras(dev, xform, - sess, mempool); + sess); if (ret < 0) { VIRTIO_CRYPTO_SESSION_LOG_ERR("Invalid parameters"); return ret; } - if (rte_mempool_get(mempool, &session_private)) { - VIRTIO_CRYPTO_SESSION_LOG_ERR( - "Couldn't get object from session mempool"); - return -ENOMEM; - } - - session = (struct virtio_crypto_session *)session_private; + session = (struct virtio_crypto_session *)sess; memset(session, 0, sizeof(struct virtio_crypto_session)); ctrl_req = &session->ctrl; ctrl_req->header.opcode = VIRTIO_CRYPTO_CIPHER_CREATE_SESSION; @@ -1401,9 +1389,6 @@ virtio_crypto_sym_configure_session( goto error_out; } - set_sym_session_private_data(sess, dev->driver_id, - session_private); - return 0; error_out: diff --git a/drivers/crypto/zuc/rte_zuc_pmd_ops.c b/drivers/crypto/zuc/rte_zuc_pmd_ops.c index 38642d45ab..04126c8a04 100644 --- a/drivers/crypto/zuc/rte_zuc_pmd_ops.c +++ b/drivers/crypto/zuc/rte_zuc_pmd_ops.c @@ -226,7 +226,6 @@ zuc_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, qp->mb_mgr = internals->mb_mgr; qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); @@ -250,10 +249,8 @@ zuc_pmd_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) static int zuc_pmd_sym_session_configure(struct rte_cryptodev *dev __rte_unused, struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *sess, - struct rte_mempool *mempool) + void *sess) { - void *sess_private_data; int ret; if (unlikely(sess == NULL)) { @@ -261,43 +258,23 @@ zuc_pmd_sym_session_configure(struct rte_cryptodev *dev __rte_unused, return -EINVAL; } - if (rte_mempool_get(mempool, &sess_private_data)) { - ZUC_LOG(ERR, - "Couldn't get object from session mempool"); - - return -ENOMEM; - } - - ret = zuc_set_session_parameters(sess_private_data, xform); + ret = zuc_set_session_parameters(sess, xform); if (ret != 0) { ZUC_LOG(ERR, "failed configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); return ret; } - set_sym_session_private_data(sess, dev->driver_id, - sess_private_data); - return 0; } /** Clear the memory of session so it doesn't leave key material behind */ static void -zuc_pmd_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +zuc_pmd_sym_session_clear(struct rte_cryptodev *dev, void *sess) { - uint8_t index = dev->driver_id; - void *sess_priv = get_sym_session_private_data(sess, index); - + RTE_SET_USED(dev); /* Zero out the whole structure */ - if (sess_priv) { - memset(sess_priv, 0, sizeof(struct zuc_session)); - struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv); - set_sym_session_private_data(sess, index, NULL); - rte_mempool_put(sess_mp, sess_priv); - } + if (sess) + memset(sess, 0, sizeof(struct zuc_session)); } struct rte_cryptodev_ops zuc_pmd_ops = { diff --git a/drivers/event/octeontx2/otx2_evdev_crypto_adptr_rx.h b/drivers/event/octeontx2/otx2_evdev_crypto_adptr_rx.h index b33cb7e139..8522f2dfda 100644 --- a/drivers/event/octeontx2/otx2_evdev_crypto_adptr_rx.h +++ b/drivers/event/octeontx2/otx2_evdev_crypto_adptr_rx.h @@ -38,8 +38,7 @@ otx2_ca_deq_post_process(const struct otx2_cpt_qp *qp, } if (unlikely(cop->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { - sym_session_clear(otx2_cryptodev_driver_id, - cop->sym->session); + sym_session_clear(cop->sym->session); memset(cop->sym->session, 0, rte_cryptodev_sym_get_existing_header_session_size( cop->sym->session)); diff --git a/examples/fips_validation/fips_dev_self_test.c b/examples/fips_validation/fips_dev_self_test.c index b4eab05a98..bbc27a1b6f 100644 --- a/examples/fips_validation/fips_dev_self_test.c +++ b/examples/fips_validation/fips_dev_self_test.c @@ -969,7 +969,6 @@ struct fips_dev_auto_test_env { struct rte_mempool *mpool; struct rte_mempool *op_pool; struct rte_mempool *sess_pool; - struct rte_mempool *sess_priv_pool; struct rte_mbuf *mbuf; struct rte_crypto_op *op; }; @@ -981,7 +980,7 @@ typedef int (*fips_dev_self_test_prepare_xform_t)(uint8_t, uint32_t); typedef int (*fips_dev_self_test_prepare_op_t)(struct rte_crypto_op *, - struct rte_mbuf *, struct rte_cryptodev_sym_session *, + struct rte_mbuf *, void *, uint32_t, struct fips_dev_self_test_vector *); typedef int (*fips_dev_self_test_check_result_t)(struct rte_crypto_op *, @@ -1173,7 +1172,7 @@ prepare_aead_xform(uint8_t dev_id, static int prepare_cipher_op(struct rte_crypto_op *op, struct rte_mbuf *mbuf, - struct rte_cryptodev_sym_session *session, + void *session, uint32_t dir, struct fips_dev_self_test_vector *vec) { @@ -1212,7 +1211,7 @@ prepare_cipher_op(struct rte_crypto_op *op, static int prepare_auth_op(struct rte_crypto_op *op, struct rte_mbuf *mbuf, - struct rte_cryptodev_sym_session *session, + void *session, uint32_t dir, struct fips_dev_self_test_vector *vec) { @@ -1251,7 +1250,7 @@ prepare_auth_op(struct rte_crypto_op *op, static int prepare_aead_op(struct rte_crypto_op *op, struct rte_mbuf *mbuf, - struct rte_cryptodev_sym_session *session, + void *session, uint32_t dir, struct fips_dev_self_test_vector *vec) { @@ -1464,7 +1463,7 @@ run_single_test(uint8_t dev_id, uint32_t negative_test) { struct rte_crypto_sym_xform xform; - struct rte_cryptodev_sym_session *sess; + void *sess; uint16_t n_deqd; uint8_t key[256]; int ret; @@ -1484,8 +1483,7 @@ run_single_test(uint8_t dev_id, if (!sess) return -ENOMEM; - ret = rte_cryptodev_sym_session_init(dev_id, - sess, &xform, env->sess_priv_pool); + ret = rte_cryptodev_sym_session_init(dev_id, sess, &xform); if (ret < 0) { RTE_LOG(ERR, PMD, "Error %i: Init session\n", ret); return ret; @@ -1533,8 +1531,6 @@ fips_dev_auto_test_uninit(uint8_t dev_id, rte_mempool_free(env->op_pool); if (env->sess_pool) rte_mempool_free(env->sess_pool); - if (env->sess_priv_pool) - rte_mempool_free(env->sess_priv_pool); rte_cryptodev_stop(dev_id); } @@ -1542,7 +1538,7 @@ fips_dev_auto_test_uninit(uint8_t dev_id, static int fips_dev_auto_test_init(uint8_t dev_id, struct fips_dev_auto_test_env *env) { - struct rte_cryptodev_qp_conf qp_conf = {128, NULL, NULL}; + struct rte_cryptodev_qp_conf qp_conf = {128, NULL}; uint32_t sess_sz = rte_cryptodev_sym_get_private_session_size(dev_id); struct rte_cryptodev_config conf; char name[128]; @@ -1586,25 +1582,13 @@ fips_dev_auto_test_init(uint8_t dev_id, struct fips_dev_auto_test_env *env) snprintf(name, 128, "%s%u", "SELF_TEST_SESS_POOL", dev_id); env->sess_pool = rte_cryptodev_sym_session_pool_create(name, - 128, 0, 0, 0, rte_cryptodev_socket_id(dev_id)); + 128, sess_sz, 0, 0, rte_cryptodev_socket_id(dev_id)); if (!env->sess_pool) { ret = -ENOMEM; goto error_exit; } - memset(name, 0, 128); - snprintf(name, 128, "%s%u", "SELF_TEST_SESS_PRIV_POOL", dev_id); - - env->sess_priv_pool = rte_mempool_create(name, - 128, sess_sz, 0, 0, NULL, NULL, NULL, - NULL, rte_cryptodev_socket_id(dev_id), 0); - if (!env->sess_priv_pool) { - ret = -ENOMEM; - goto error_exit; - } - qp_conf.mp_session = env->sess_pool; - qp_conf.mp_session_private = env->sess_priv_pool; ret = rte_cryptodev_queue_pair_setup(dev_id, 0, &qp_conf, rte_cryptodev_socket_id(dev_id)); diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index a8daad1f48..03c6ccb5b8 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -48,13 +48,12 @@ struct cryptodev_fips_validate_env { uint16_t mbuf_data_room; struct rte_mempool *mpool; struct rte_mempool *sess_mpool; - struct rte_mempool *sess_priv_mpool; struct rte_mempool *op_pool; struct rte_mbuf *mbuf; uint8_t *digest; uint16_t digest_len; struct rte_crypto_op *op; - struct rte_cryptodev_sym_session *sess; + void *sess; uint16_t self_test; struct fips_dev_broken_test_config *broken_test_config; } env; @@ -63,7 +62,7 @@ static int cryptodev_fips_validate_app_int(void) { struct rte_cryptodev_config conf = {rte_socket_id(), 1, 0}; - struct rte_cryptodev_qp_conf qp_conf = {128, NULL, NULL}; + struct rte_cryptodev_qp_conf qp_conf = {128, NULL}; struct rte_cryptodev_info dev_info; uint32_t sess_sz = rte_cryptodev_sym_get_private_session_size( env.dev_id); @@ -103,16 +102,11 @@ 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()); + "FIPS_SESS_MEMPOOL", 16, sess_sz, 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, @@ -127,7 +121,6 @@ cryptodev_fips_validate_app_int(void) 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()); @@ -141,8 +134,6 @@ cryptodev_fips_validate_app_int(void) 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); @@ -158,7 +149,6 @@ cryptodev_fips_validate_app_uninit(void) 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); } @@ -1179,7 +1169,7 @@ fips_run_test(void) return -ENOMEM; ret = rte_cryptodev_sym_session_init(env.dev_id, - env.sess, &xform, env.sess_priv_mpool); + env.sess, &xform); if (ret < 0) { RTE_LOG(ERR, USER1, "Error %i: Init session\n", ret); diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index 7ad94cb822..65528ee2e7 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -1216,15 +1216,11 @@ ipsec_poll_mode_worker(void) 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; qconf->frag.pool_dir = socket_ctx[socket_id].mbuf_pool; qconf->frag.pool_indir = socket_ctx[socket_id].mbuf_pool_indir; @@ -2142,8 +2138,6 @@ cryptodevs_init(uint16_t req_queue_num) qp_conf.nb_descriptors = CDEV_QUEUE_DESC; qp_conf.mp_session = socket_ctx[dev_conf.socket_id].session_pool; - qp_conf.mp_session_private = - 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)) @@ -2405,37 +2399,37 @@ session_pool_init(struct socket_ctx *ctx, int32_t socket_id, size_t sess_sz) printf("Allocated session pool on socket %d\n", socket_id); } -static void -session_priv_pool_init(struct socket_ctx *ctx, int32_t socket_id, - size_t sess_sz) -{ - char mp_name[RTE_MEMPOOL_NAMESIZE]; - struct rte_mempool *sess_mp; - uint32_t nb_sess; - - snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, - "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, - CDEV_MP_CACHE_SZ, - 0, NULL, NULL, NULL, - NULL, socket_id, - 0); - ctx->session_priv_pool = sess_mp; - - if (ctx->session_priv_pool == NULL) - rte_exit(EXIT_FAILURE, - "Cannot init session priv pool on socket %d\n", - socket_id); - else - printf("Allocated session priv pool on socket %d\n", - socket_id); -} +//static void +//session_priv_pool_init(struct socket_ctx *ctx, int32_t socket_id, +// size_t sess_sz) +//{ +// char mp_name[RTE_MEMPOOL_NAMESIZE]; +// struct rte_mempool *sess_mp; +// uint32_t nb_sess; +// +// snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, +// "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, +// CDEV_MP_CACHE_SZ, +// 0, NULL, NULL, NULL, +// NULL, socket_id, +// 0); +// ctx->session_priv_pool = sess_mp; +// +// if (ctx->session_priv_pool == NULL) +// rte_exit(EXIT_FAILURE, +// "Cannot init session priv pool on socket %d\n", +// socket_id); +// else +// printf("Allocated session priv pool on socket %d\n", +// socket_id); +//} static void pool_init(struct socket_ctx *ctx, int32_t socket_id, uint32_t nb_mbuf) @@ -2938,8 +2932,8 @@ main(int32_t argc, char **argv) pool_init(&socket_ctx[socket_id], socket_id, nb_bufs_in_pool); session_pool_init(&socket_ctx[socket_id], socket_id, sess_sz); - session_priv_pool_init(&socket_ctx[socket_id], socket_id, - sess_sz); +// session_priv_pool_init(&socket_ctx[socket_id], socket_id, +// sess_sz); } printf("Number of mbufs in packet pool %d\n", nb_bufs_in_pool); diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 03d907cba8..a5921de11c 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -143,8 +143,7 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa, ips->crypto.ses = rte_cryptodev_sym_session_create( ipsec_ctx->session_pool); rte_cryptodev_sym_session_init(ipsec_ctx->tbl[cdev_id_qp].id, - ips->crypto.ses, sa->xforms, - ipsec_ctx->session_priv_pool); + ips->crypto.ses, sa->xforms); 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 8405c48171..673c64e8dc 100644 --- a/examples/ipsec-secgw/ipsec.h +++ b/examples/ipsec-secgw/ipsec.h @@ -243,7 +243,6 @@ struct socket_ctx { struct rte_mempool *mbuf_pool; struct rte_mempool *mbuf_pool_indir; struct rte_mempool *session_pool; - struct rte_mempool *session_priv_pool; }; struct cnt_blk { diff --git a/examples/ipsec-secgw/ipsec_worker.c b/examples/ipsec-secgw/ipsec_worker.c index c545497cee..04bcce49db 100644 --- a/examples/ipsec-secgw/ipsec_worker.c +++ b/examples/ipsec-secgw/ipsec_worker.c @@ -537,14 +537,10 @@ ipsec_wrkr_non_burst_int_port_app_mode(struct eh_event_link_info *links, lconf.inbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_in; lconf.inbound.sa_ctx = socket_ctx[socket_id].sa_in; lconf.inbound.session_pool = socket_ctx[socket_id].session_pool; - lconf.inbound.session_priv_pool = - socket_ctx[socket_id].session_priv_pool; lconf.outbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_out; lconf.outbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_out; lconf.outbound.sa_ctx = socket_ctx[socket_id].sa_out; lconf.outbound.session_pool = socket_ctx[socket_id].session_pool; - lconf.outbound.session_priv_pool = - socket_ctx[socket_id].session_priv_pool; RTE_LOG(INFO, IPSEC, "Launching event mode worker (non-burst - Tx internal port - " diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index 66d1491bf7..bdc3da731c 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -188,7 +188,7 @@ struct l2fwd_crypto_params { struct l2fwd_iv auth_iv; struct l2fwd_iv aead_iv; struct l2fwd_key aad; - struct rte_cryptodev_sym_session *session; + void *session; uint8_t do_cipher; uint8_t do_hash; @@ -229,7 +229,6 @@ struct rte_mempool *l2fwd_pktmbuf_pool; struct rte_mempool *l2fwd_crypto_op_pool; static struct { struct rte_mempool *sess_mp; - struct rte_mempool *priv_mp; } session_pool_socket[RTE_MAX_NUMA_NODES]; /* Per-port statistics struct */ @@ -671,11 +670,11 @@ generate_random_key(uint8_t *key, unsigned length) } /* Session is created and is later attached to the crypto operation. 8< */ -static struct rte_cryptodev_sym_session * +static void * initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id) { struct rte_crypto_sym_xform *first_xform; - struct rte_cryptodev_sym_session *session; + void *session; int retval = rte_cryptodev_socket_id(cdev_id); if (retval < 0) @@ -703,8 +702,7 @@ initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id) return NULL; if (rte_cryptodev_sym_session_init(cdev_id, session, - first_xform, - session_pool_socket[socket_id].priv_mp) < 0) + first_xform) < 0) return NULL; return session; @@ -730,7 +728,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options) US_PER_S * BURST_TX_DRAIN_US; struct l2fwd_crypto_params *cparams; struct l2fwd_crypto_params port_cparams[qconf->nb_crypto_devs]; - struct rte_cryptodev_sym_session *session; + void *session; if (qconf->nb_rx_ports == 0) { RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id); @@ -2388,30 +2386,6 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports, } else sessions_needed = enabled_cdev_count; - if (session_pool_socket[socket_id].priv_mp == NULL) { - char mp_name[RTE_MEMPOOL_NAMESIZE]; - - snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, - "priv_sess_mp_%u", socket_id); - - session_pool_socket[socket_id].priv_mp = - rte_mempool_create(mp_name, - sessions_needed, - max_sess_sz, - 0, 0, NULL, NULL, NULL, - NULL, socket_id, - 0); - - 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, @@ -2421,7 +2395,8 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports, rte_cryptodev_sym_session_pool_create( mp_name, sessions_needed, - 0, 0, 0, socket_id); + max_sess_sz, + 0, 0, socket_id); if (session_pool_socket[socket_id].sess_mp == NULL) { printf("Cannot create pool on socket %d\n", @@ -2573,8 +2548,6 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports, qp_conf.nb_descriptors = 2048; 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 dea7dcbd07..cbb97aaf76 100644 --- a/examples/vhost_crypto/main.c +++ b/examples/vhost_crypto/main.c @@ -46,7 +46,6 @@ 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; @@ -304,7 +303,6 @@ 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"); @@ -458,7 +456,6 @@ 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]); @@ -544,16 +541,12 @@ main(int argc, char *argv[]) snprintf(name, 127, "SESS_POOL_%u", lo->lcore_id); 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_priv_pool || !info->sess_pool) { + info->cid), 0, 0, + rte_lcore_to_socket_id(lo->lcore_id)); + + if (!info->sess_pool) { RTE_LOG(ERR, USER1, "Failed to create mempool"); goto error_exit; } @@ -574,7 +567,6 @@ main(int argc, char *argv[]) qp_conf.nb_descriptors = NB_CRYPTO_DESCRIPTORS; qp_conf.mp_session = info->sess_pool; - qp_conf.mp_session_private = info->sess_priv_pool; for (j = 0; j < dev_info.max_nb_queue_pairs; j++) { ret = rte_cryptodev_queue_pair_setup(info->cid, j, diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h index ae3aac59ae..d758b3b85d 100644 --- a/lib/cryptodev/cryptodev_pmd.h +++ b/lib/cryptodev/cryptodev_pmd.h @@ -242,7 +242,6 @@ typedef unsigned int (*cryptodev_asym_get_session_private_size_t)( * @param dev Crypto device pointer * @param xform Single or chain of crypto xforms * @param session Pointer to cryptodev's private session structure - * @param mp Mempool where the private session is allocated * * @return * - Returns 0 if private session structure have been created successfully. @@ -251,9 +250,7 @@ typedef unsigned int (*cryptodev_asym_get_session_private_size_t)( * - Returns -ENOMEM if the private session could not be allocated. */ typedef int (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev, - struct rte_crypto_sym_xform *xform, - struct rte_cryptodev_sym_session *session, - struct rte_mempool *mp); + struct rte_crypto_sym_xform *xform, void *session); /** * Configure a Crypto asymmetric session on a device. * @@ -279,7 +276,7 @@ typedef int (*cryptodev_asym_configure_session_t)(struct rte_cryptodev *dev, * @param sess Cryptodev session structure */ typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess); + void *sess); /** * Free asymmetric session private data. * diff --git a/lib/cryptodev/rte_crypto.h b/lib/cryptodev/rte_crypto.h index a864f5036f..200617f623 100644 --- a/lib/cryptodev/rte_crypto.h +++ b/lib/cryptodev/rte_crypto.h @@ -420,7 +420,7 @@ rte_crypto_op_sym_xforms_alloc(struct rte_crypto_op *op, uint8_t nb_xforms) */ static inline int rte_crypto_op_attach_sym_session(struct rte_crypto_op *op, - struct rte_cryptodev_sym_session *sess) + void *sess) { if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC)) return -1; diff --git a/lib/cryptodev/rte_crypto_sym.h b/lib/cryptodev/rte_crypto_sym.h index 58c0724743..848da1942c 100644 --- a/lib/cryptodev/rte_crypto_sym.h +++ b/lib/cryptodev/rte_crypto_sym.h @@ -932,7 +932,7 @@ __rte_crypto_sym_op_sym_xforms_alloc(struct rte_crypto_sym_op *sym_op, */ static inline int __rte_crypto_sym_op_attach_sym_session(struct rte_crypto_sym_op *sym_op, - struct rte_cryptodev_sym_session *sess) + void *sess) { sym_op->session = sess; diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 9fa3aff1d3..a31cae202a 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -199,6 +199,8 @@ struct rte_cryptodev_sym_session_pool_private_data { /**< number of elements in sess_data array */ uint16_t user_data_sz; /**< session user data will be placed after sess_data */ + uint16_t sess_priv_sz; + /**< session user data will be placed after sess_data */ }; int @@ -1223,8 +1225,7 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, return -EINVAL; } - if ((qp_conf->mp_session && !qp_conf->mp_session_private) || - (!qp_conf->mp_session && qp_conf->mp_session_private)) { + if (!qp_conf->mp_session) { CDEV_LOG_ERR("Invalid mempools\n"); return -EINVAL; } @@ -1232,7 +1233,6 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, if (qp_conf->mp_session) { struct rte_cryptodev_sym_session_pool_private_data *pool_priv; uint32_t obj_size = qp_conf->mp_session->elt_size; - uint32_t obj_priv_size = qp_conf->mp_session_private->elt_size; struct rte_cryptodev_sym_session s = {0}; pool_priv = rte_mempool_get_priv(qp_conf->mp_session); @@ -1244,11 +1244,11 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, s.nb_drivers = pool_priv->nb_drivers; s.user_data_sz = pool_priv->user_data_sz; + s.priv_sz = pool_priv->sess_priv_sz; - if ((rte_cryptodev_sym_get_existing_header_session_size(&s) > - obj_size) || (s.nb_drivers <= dev->driver_id) || - rte_cryptodev_sym_get_private_session_size(dev_id) > - obj_priv_size) { + if (((rte_cryptodev_sym_get_existing_header_session_size(&s) + + (s.nb_drivers * s.priv_sz)) > obj_size) || + (s.nb_drivers <= dev->driver_id)) { CDEV_LOG_ERR("Invalid mempool\n"); return -EINVAL; } @@ -1710,11 +1710,11 @@ rte_cryptodev_pmd_callback_process(struct rte_cryptodev *dev, int rte_cryptodev_sym_session_init(uint8_t dev_id, - struct rte_cryptodev_sym_session *sess, - struct rte_crypto_sym_xform *xforms, - struct rte_mempool *mp) + void *sess_opaque, + struct rte_crypto_sym_xform *xforms) { struct rte_cryptodev *dev; + struct rte_cryptodev_sym_session *sess = sess_opaque; uint32_t sess_priv_sz = rte_cryptodev_sym_get_private_session_size( dev_id); uint8_t index; @@ -1727,10 +1727,10 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, dev = rte_cryptodev_pmd_get_dev(dev_id); - if (sess == NULL || xforms == NULL || dev == NULL || mp == NULL) + if (sess == NULL || xforms == NULL || dev == NULL) return -EINVAL; - if (mp->elt_size < sess_priv_sz) + if (sess->priv_sz < sess_priv_sz) return -EINVAL; index = dev->driver_id; @@ -1740,8 +1740,11 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->sym_session_configure, -ENOTSUP); if (sess->sess_data[index].refcnt == 0) { + sess->sess_data[index].data = (void *)((uint8_t *)sess + + rte_cryptodev_sym_get_header_session_size() + + (index * sess->priv_sz)); ret = dev->dev_ops->sym_session_configure(dev, xforms, - sess, mp); + sess->sess_data[index].data); if (ret < 0) { CDEV_LOG_ERR( "dev_id %d failed to configure session details", @@ -1750,7 +1753,7 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, } } - rte_cryptodev_trace_sym_session_init(dev_id, sess, xforms, mp); + rte_cryptodev_trace_sym_session_init(dev_id, sess, xforms); sess->sess_data[index].refcnt++; return 0; } @@ -1795,6 +1798,21 @@ rte_cryptodev_asym_session_init(uint8_t dev_id, rte_cryptodev_trace_asym_session_init(dev_id, sess, xforms, mp); return 0; } +static size_t +get_max_sym_sess_priv_sz(void) +{ + size_t max_sz, sz; + int16_t cdev_id, n; + + max_sz = 0; + n = rte_cryptodev_count(); + for (cdev_id = 0; cdev_id != n; cdev_id++) { + sz = rte_cryptodev_sym_get_private_session_size(cdev_id); + if (sz > max_sz) + max_sz = sz; + } + return max_sz; +} struct rte_mempool * rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts, @@ -1804,15 +1822,15 @@ rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts, struct rte_mempool *mp; struct rte_cryptodev_sym_session_pool_private_data *pool_priv; uint32_t obj_sz; + uint32_t sess_priv_sz = get_max_sym_sess_priv_sz(); obj_sz = rte_cryptodev_sym_get_header_session_size() + user_data_size; - if (obj_sz > elt_size) + if (elt_size < obj_sz + (sess_priv_sz * nb_drivers)) { CDEV_LOG_INFO("elt_size %u is expanded to %u\n", elt_size, - obj_sz); - else - obj_sz = elt_size; - - mp = rte_mempool_create(name, nb_elts, obj_sz, cache_size, + obj_sz + (sess_priv_sz * nb_drivers)); + elt_size = obj_sz + (sess_priv_sz * nb_drivers); + } + mp = rte_mempool_create(name, nb_elts, elt_size, cache_size, (uint32_t)(sizeof(*pool_priv)), NULL, NULL, NULL, NULL, socket_id, 0); @@ -1832,6 +1850,7 @@ rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts, pool_priv->nb_drivers = nb_drivers; pool_priv->user_data_sz = user_data_size; + pool_priv->sess_priv_sz = sess_priv_sz; rte_cryptodev_trace_sym_session_pool_create(name, nb_elts, elt_size, cache_size, user_data_size, mp); @@ -1865,7 +1884,7 @@ rte_cryptodev_sym_is_valid_session_pool(struct rte_mempool *mp) return 1; } -struct rte_cryptodev_sym_session * +void * rte_cryptodev_sym_session_create(struct rte_mempool *mp) { struct rte_cryptodev_sym_session *sess; @@ -1886,6 +1905,7 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mp) sess->nb_drivers = pool_priv->nb_drivers; sess->user_data_sz = pool_priv->user_data_sz; + sess->priv_sz = pool_priv->sess_priv_sz; sess->opaque_data = 0; /* Clear device session pointer. @@ -1895,7 +1915,7 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mp) rte_cryptodev_sym_session_data_size(sess)); rte_cryptodev_trace_sym_session_create(mp, sess); - return sess; + return (void *)sess; } struct rte_cryptodev_asym_session * @@ -1933,9 +1953,9 @@ rte_cryptodev_asym_session_create(struct rte_mempool *mp) } int -rte_cryptodev_sym_session_clear(uint8_t dev_id, - struct rte_cryptodev_sym_session *sess) +rte_cryptodev_sym_session_clear(uint8_t dev_id, void *s) { + struct rte_cryptodev_sym_session *sess = s; struct rte_cryptodev *dev; uint8_t driver_id; @@ -1957,7 +1977,7 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id, RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->sym_session_clear, -ENOTSUP); - dev->dev_ops->sym_session_clear(dev, sess); + dev->dev_ops->sym_session_clear(dev, sess->sess_data[driver_id].data); rte_cryptodev_trace_sym_session_clear(dev_id, sess); return 0; @@ -1988,10 +2008,11 @@ rte_cryptodev_asym_session_clear(uint8_t dev_id, } int -rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess) +rte_cryptodev_sym_session_free(void *s) { uint8_t i; struct rte_mempool *sess_mp; + struct rte_cryptodev_sym_session *sess = s; if (sess == NULL) return -EINVAL; diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index bb01f0f195..25af6fa7b9 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -537,8 +537,6 @@ struct rte_cryptodev_qp_conf { uint32_t nb_descriptors; /**< Number of descriptors per queue pair */ struct rte_mempool *mp_session; /**< The mempool for creating session in sessionless mode */ - struct rte_mempool *mp_session_private; - /**< The mempool for creating sess private data in sessionless mode */ }; /** @@ -1126,6 +1124,8 @@ struct rte_cryptodev_sym_session { /**< number of elements in sess_data array */ uint16_t user_data_sz; /**< session user data will be placed after sess_data */ + uint16_t priv_sz; + /**< Maximum private session data size which each driver can use */ __extension__ struct { void *data; uint16_t refcnt; @@ -1177,10 +1177,10 @@ rte_cryptodev_sym_session_pool_create(const char *name, uint32_t nb_elts, * @param mempool Symmetric session mempool to allocate session * objects from * @return - * - On success return pointer to sym-session + * - On success return opaque pointer to sym-session * - On failure returns NULL */ -struct rte_cryptodev_sym_session * +void * rte_cryptodev_sym_session_create(struct rte_mempool *mempool); /** @@ -1209,7 +1209,7 @@ rte_cryptodev_asym_session_create(struct rte_mempool *mempool); * - -EBUSY if not all device private data has been freed. */ int -rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess); +rte_cryptodev_sym_session_free(void *sess); /** * Frees asymmetric crypto session header, after checking that all @@ -1229,25 +1229,23 @@ rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess); /** * Fill out private data for the device id, based on its device type. + * Memory for private data is already allocated in sess, driver need + * to fill the content. * * @param dev_id ID of device that we want the session to be used on * @param sess Session where the private data will be attached to * @param xforms Symmetric crypto transform operations to apply on flow * processed with this session - * @param mempool Mempool where the private data is allocated. * * @return * - On success, zero. * - -EINVAL if input parameters are invalid. * - -ENOTSUP if crypto device does not support the crypto transform or * does not support symmetric operations. - * - -ENOMEM if the private session could not be allocated. */ int -rte_cryptodev_sym_session_init(uint8_t dev_id, - struct rte_cryptodev_sym_session *sess, - struct rte_crypto_sym_xform *xforms, - struct rte_mempool *mempool); +rte_cryptodev_sym_session_init(uint8_t dev_id, void *sess, + struct rte_crypto_sym_xform *xforms); /** * Initialize asymmetric session on a device with specific asymmetric xform @@ -1286,8 +1284,7 @@ rte_cryptodev_asym_session_init(uint8_t dev_id, * - -ENOTSUP if crypto device does not support symmetric operations. */ int -rte_cryptodev_sym_session_clear(uint8_t dev_id, - struct rte_cryptodev_sym_session *sess); +rte_cryptodev_sym_session_clear(uint8_t dev_id, void *sess); /** * Frees resources held by asymmetric session during rte_cryptodev_session_init diff --git a/lib/cryptodev/rte_cryptodev_trace.h b/lib/cryptodev/rte_cryptodev_trace.h index d1f4f069a3..44da04c425 100644 --- a/lib/cryptodev/rte_cryptodev_trace.h +++ b/lib/cryptodev/rte_cryptodev_trace.h @@ -56,7 +56,6 @@ RTE_TRACE_POINT( rte_trace_point_emit_u16(queue_pair_id); rte_trace_point_emit_u32(conf->nb_descriptors); rte_trace_point_emit_ptr(conf->mp_session); - rte_trace_point_emit_ptr(conf->mp_session_private); ) RTE_TRACE_POINT( @@ -106,15 +105,13 @@ RTE_TRACE_POINT( RTE_TRACE_POINT( rte_cryptodev_trace_sym_session_init, RTE_TRACE_POINT_ARGS(uint8_t dev_id, - struct rte_cryptodev_sym_session *sess, void *xforms, - void *mempool), + struct rte_cryptodev_sym_session *sess, void *xforms), rte_trace_point_emit_u8(dev_id); rte_trace_point_emit_ptr(sess); rte_trace_point_emit_u64(sess->opaque_data); rte_trace_point_emit_u16(sess->nb_drivers); rte_trace_point_emit_u16(sess->user_data_sz); rte_trace_point_emit_ptr(xforms); - rte_trace_point_emit_ptr(mempool); ) RTE_TRACE_POINT( diff --git a/lib/pipeline/rte_table_action.c b/lib/pipeline/rte_table_action.c index ad7904c0ee..efdba9c899 100644 --- a/lib/pipeline/rte_table_action.c +++ b/lib/pipeline/rte_table_action.c @@ -1719,7 +1719,7 @@ struct sym_crypto_data { uint16_t op_mask; /** Session pointer. */ - struct rte_cryptodev_sym_session *session; + void *session; /** Direction of crypto, encrypt or decrypt */ uint16_t direction; @@ -1780,7 +1780,7 @@ sym_crypto_apply(struct sym_crypto_data *data, const struct rte_crypto_auth_xform *auth_xform = NULL; const struct rte_crypto_aead_xform *aead_xform = NULL; struct rte_crypto_sym_xform *xform = p->xform; - struct rte_cryptodev_sym_session *session; + void *session; int ret; memset(data, 0, sizeof(*data)); @@ -1905,7 +1905,7 @@ sym_crypto_apply(struct sym_crypto_data *data, return -ENOMEM; ret = rte_cryptodev_sym_session_init(cfg->cryptodev_id, session, - p->xform, cfg->mp_init); + p->xform); if (ret < 0) { rte_cryptodev_sym_session_free(session); return ret; @@ -2858,7 +2858,7 @@ rte_table_action_time_read(struct rte_table_action *action, return 0; } -struct rte_cryptodev_sym_session * +void * rte_table_action_crypto_sym_session_get(struct rte_table_action *action, void *data) { diff --git a/lib/pipeline/rte_table_action.h b/lib/pipeline/rte_table_action.h index 82bc9d9ac9..68db453a8b 100644 --- a/lib/pipeline/rte_table_action.h +++ b/lib/pipeline/rte_table_action.h @@ -1129,7 +1129,7 @@ rte_table_action_time_read(struct rte_table_action *action, * The pointer to the session on success, NULL otherwise. */ __rte_experimental -struct rte_cryptodev_sym_session * +void * rte_table_action_crypto_sym_session_get(struct rte_table_action *action, void *data); diff --git a/lib/vhost/rte_vhost_crypto.h b/lib/vhost/rte_vhost_crypto.h index f54d731139..d9b7beed9c 100644 --- a/lib/vhost/rte_vhost_crypto.h +++ b/lib/vhost/rte_vhost_crypto.h @@ -50,8 +50,6 @@ rte_vhost_crypto_driver_start(const char *path); * multiple Vhost-crypto devices. * @param sess_pool * The pointer to the created cryptodev session pool. - * @param sess_priv_pool - * The pointer to the created cryptodev session private data mempool. * @param socket_id * NUMA Socket ID to allocate resources on. * * @return @@ -61,7 +59,6 @@ rte_vhost_crypto_driver_start(const char *path); int rte_vhost_crypto_create(int vid, uint8_t cryptodev_id, struct rte_mempool *sess_pool, - struct rte_mempool *sess_priv_pool, int socket_id); /** diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c index 926b5c0bd9..b4464c4253 100644 --- a/lib/vhost/vhost_crypto.c +++ b/lib/vhost/vhost_crypto.c @@ -338,7 +338,7 @@ vhost_crypto_create_sess(struct vhost_crypto *vcrypto, VhostUserCryptoSessionParam *sess_param) { struct rte_crypto_sym_xform xform1 = {0}, xform2 = {0}; - struct rte_cryptodev_sym_session *session; + void *session; int ret; switch (sess_param->op_type) { @@ -383,8 +383,7 @@ vhost_crypto_create_sess(struct vhost_crypto *vcrypto, return; } - if (rte_cryptodev_sym_session_init(vcrypto->cid, session, &xform1, - vcrypto->sess_priv_pool) < 0) { + if (rte_cryptodev_sym_session_init(vcrypto->cid, session, &xform1) < 0) { VC_LOG_ERR("Failed to initialize session"); sess_param->session_id = -VIRTIO_CRYPTO_ERR; return; @@ -1425,7 +1424,6 @@ rte_vhost_crypto_driver_start(const char *path) int rte_vhost_crypto_create(int vid, uint8_t cryptodev_id, struct rte_mempool *sess_pool, - struct rte_mempool *sess_priv_pool, int socket_id) { struct virtio_net *dev = get_device(vid); @@ -1447,7 +1445,6 @@ rte_vhost_crypto_create(int vid, uint8_t cryptodev_id, } vcrypto->sess_pool = sess_pool; - vcrypto->sess_priv_pool = sess_priv_pool; vcrypto->cid = cryptodev_id; vcrypto->cache_session_id = UINT64_MAX; vcrypto->last_session_id = 1; -- 2.25.1