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 78E0BA0C52; Mon, 18 Oct 2021 23:36:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 385D2410EE; Mon, 18 Oct 2021 23:35:55 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id E07504111D for ; Mon, 18 Oct 2021 23:35:51 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19IK0K65000860; Mon, 18 Oct 2021 14:35:46 -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=FbcMBOe+KVrZPhvQ8peA+IT5HyMm+5i9JcNvWJZR+jc=; b=URGFc3cAViy6Q9j9uQdiFQDRQJMW15xwo1y7TQ+jaQxOEmak42HmqnL4TLcUF9Rd0qPM dW0/Wo1tdj2DyrEF/H+4MEx3N8N7euKPx8JZ+8l/Cx1CsFgJxHkAdMLlYM1AyonQQlbi +pKGnPP3uud7Bip+W8DO83yCG6wncNFD6UphkhfBrFl7S3KElSls3sR9vVnEN6kaGFAR Fd+1xSOT6D/jL3eLOaWaQ/OIX3u6fp2lXE0Ai5tiuFttz2fdaA7Wddka9MIfc2QsjE2p OfzN8YtPG6rC5mDGzaCC19IivRPKi19Kd97HAMmlvKVK96LVGaegfAybimQy74iOV/8j GA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 3bsfk489r5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Oct 2021 14:35:46 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 18 Oct 2021 14:35:43 -0700 Received: from maili.marvell.com (10.68.76.51) by dc5-exch01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 18 Oct 2021 14:35:43 -0700 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id 115CE3F7041; Mon, 18 Oct 2021 14:35:36 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , , , , , , , , , , , , Akhil Goyal Date: Tue, 19 Oct 2021 03:04:50 +0530 Message-ID: <20211018213452.2734720-7-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018213452.2734720-1-gakhil@marvell.com> References: <20211013192222.1582631-2-gakhil@marvell.com> <20211018213452.2734720-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: UYYlu7Sy-7cazLGD2ZuwA7_Bz0STFh24 X-Proofpoint-GUID: UYYlu7Sy-7cazLGD2ZuwA7_Bz0STFh24 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-18_07,2021-10-18_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH v3 6/8] 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. Note: currently nb_drivers are getting updated in RTE_INIT which result in increasing the memory requirements for session. User can compile off drivers which are not in use to reduce the memory consumption of a session. 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 | 3 +- app/test/test_cryptodev_blockcipher.c | 6 +- app/test/test_event_crypto_adapter.c | 28 +--- app/test/test_ipsec.c | 22 +-- drivers/crypto/armv8/armv8_pmd_private.h | 2 - drivers/crypto/armv8/rte_armv8_pmd.c | 21 ++- 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/ccp/ccp_pmd_private.h | 2 - drivers/crypto/ccp/rte_ccp_pmd.c | 24 ++-- 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 | 15 +- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 29 +--- drivers/crypto/dpaa_sec/dpaa_sec.c | 31 +---- drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 32 +---- drivers/crypto/ipsec_mb/ipsec_mb_private.h | 29 ++-- drivers/crypto/ipsec_mb/pmd_aesni_gcm.c | 23 ++-- drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 1 - drivers/crypto/ipsec_mb/pmd_chacha_poly.c | 1 - drivers/crypto/ipsec_mb/pmd_kasumi.c | 1 - drivers/crypto/ipsec_mb/pmd_snow3g.c | 1 - drivers/crypto/ipsec_mb/pmd_zuc.c | 1 - drivers/crypto/mlx5/mlx5_crypto.c | 24 +--- drivers/crypto/mvsam/mrvl_pmd_private.h | 3 - drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 36 ++--- drivers/crypto/nitrox/nitrox_sym.c | 31 +---- drivers/crypto/null/null_crypto_pmd.c | 20 ++- drivers/crypto/null/null_crypto_pmd_ops.c | 34 +---- drivers/crypto/null/null_crypto_pmd_private.h | 2 - .../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/octeontx2/otx2_cryptodev_qp.h | 2 - drivers/crypto/openssl/openssl_pmd_private.h | 2 - drivers/crypto/openssl/rte_openssl_pmd.c | 18 +-- 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/virtio/virtio_cryptodev.c | 31 ++--- .../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 | 40 ------ 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 | 76 ++++++---- 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 +- 79 files changed, 396 insertions(+), 1043 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 6c3aa77dec..ec867b0174 100644 --- a/app/test-crypto-perf/cperf_ops.c +++ b/app/test-crypto-perf/cperf_ops.c @@ -13,7 +13,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, @@ -56,7 +56,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, const struct cperf_test_vector *test_vector, uint16_t iv_offset __rte_unused, uint32_t *imix_idx, @@ -141,7 +141,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, @@ -181,7 +181,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, @@ -221,7 +221,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, @@ -278,7 +278,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, @@ -379,7 +379,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, @@ -495,7 +495,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, @@ -720,9 +720,8 @@ create_ipsec_session(struct rte_mempool *sess_mp, &sess_conf, sess_mp); } -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, @@ -747,7 +746,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, @@ -905,8 +904,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 */ @@ -933,8 +931,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 */ @@ -993,12 +990,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; @@ -1019,7 +1016,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 30d38f90e3..d3513590f1 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 69f55de50a..63d520ee66 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 e43e2a3b96..11083ea141 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 739ed9e573..887f42c532 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; @@ -65,7 +65,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, @@ -88,7 +87,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 1962438034..0b3d4f7c59 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 6fdb92fb7c..7a9fb9a64d 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -119,35 +119,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", @@ -345,12 +324,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); @@ -705,7 +681,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 996b3b4de6..c2032b619b 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -81,7 +81,7 @@ struct crypto_unittest_params { #endif union { - struct rte_cryptodev_sym_session *sess; + void *sess; #ifdef RTE_LIB_SECURITY void *sec_session; #endif @@ -121,7 +121,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, @@ -612,23 +612,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", @@ -636,7 +624,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( @@ -666,11 +653,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; @@ -1346,7 +1328,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), @@ -1568,7 +1549,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( @@ -2162,8 +2142,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 */ @@ -2263,7 +2242,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, @@ -2304,7 +2283,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, @@ -2417,8 +2396,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; @@ -2459,8 +2437,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; @@ -2582,8 +2559,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; @@ -2645,8 +2621,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; @@ -2715,13 +2690,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; @@ -7965,8 +7938,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"); @@ -11192,8 +11164,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; @@ -11406,7 +11377,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; @@ -11429,9 +11400,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++) { @@ -11440,8 +11409,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); @@ -11479,8 +11447,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!"); @@ -11511,7 +11478,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[] = { @@ -11555,8 +11522,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( @@ -11573,8 +11539,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", @@ -11657,8 +11622,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"); @@ -11675,8 +11639,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"); @@ -11721,8 +11684,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, @@ -11834,7 +11796,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, @@ -11934,7 +11895,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, @@ -12143,8 +12103,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"); @@ -12788,8 +12747,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"); @@ -12841,8 +12799,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"); @@ -13352,8 +13309,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"); @@ -13484,8 +13440,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"); @@ -14214,11 +14169,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, @@ -14235,32 +14185,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 90c8287365..f5cdf40e93 100644 --- a/app/test/test_cryptodev.h +++ b/app/test/test_cryptodev.h @@ -90,7 +90,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..7b05cb1647 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -923,8 +923,7 @@ 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; + ts_params->qp_conf.mp_session = NULL; 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 0c7ebe6981..76d2aeab6d 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, @@ -366,7 +365,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; @@ -409,7 +408,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); @@ -550,22 +549,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; @@ -577,7 +566,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, @@ -931,12 +919,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 3b49a0b13a..1e3913489d 100644 --- a/app/test/test_ipsec.c +++ b/app/test/test_ipsec.c @@ -356,20 +356,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"); @@ -414,11 +403,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 @@ -645,7 +629,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) @@ -653,7 +637,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/armv8/armv8_pmd_private.h b/drivers/crypto/armv8/armv8_pmd_private.h index 75ddba79c1..41292d8851 100644 --- a/drivers/crypto/armv8/armv8_pmd_private.h +++ b/drivers/crypto/armv8/armv8_pmd_private.h @@ -106,8 +106,6 @@ struct armv8_crypto_qp { /**< Ring for placing process packets */ struct rte_mempool *sess_mp; /**< Session Mempool */ - struct rte_mempool *sess_mp_priv; - /**< Session Private Data Mempool */ struct rte_cryptodev_stats stats; /**< Queue pair statistics */ char name[RTE_CRYPTODEV_NAME_MAX_LEN]; diff --git a/drivers/crypto/armv8/rte_armv8_pmd.c b/drivers/crypto/armv8/rte_armv8_pmd.c index 32127a874c..51034de9eb 100644 --- a/drivers/crypto/armv8/rte_armv8_pmd.c +++ b/drivers/crypto/armv8/rte_armv8_pmd.c @@ -528,27 +528,23 @@ get_session(struct armv8_crypto_qp *qp, struct rte_crypto_op *op) } } else { /* provide internal session */ - void *_sess = NULL; - void *_sess_private_data = NULL; + struct rte_cryptodev_sym_session *_sess = + rte_cryptodev_sym_session_create(qp->sess_mp); - if (rte_mempool_get(qp->sess_mp, (void **)&_sess)) + if (_sess == NULL) return NULL; - if (rte_mempool_get(qp->sess_mp_priv, - (void **)&_sess_private_data)) - return NULL; - - sess = (struct armv8_crypto_session *)_sess_private_data; - + _sess->sess_data[cryptodev_driver_id].data = + (void *)((uint8_t *)_sess + + rte_cryptodev_sym_get_header_session_size() + + (cryptodev_driver_id * _sess->priv_sz)); + sess = _sess->sess_data[cryptodev_driver_id].data; if (unlikely(armv8_crypto_set_session_parameters(sess, op->sym->xform) != 0)) { rte_mempool_put(qp->sess_mp, _sess); - rte_mempool_put(qp->sess_mp_priv, _sess_private_data); sess = NULL; } op->sym->session = (struct rte_cryptodev_sym_session *)_sess; - set_sym_session_private_data(op->sym->session, - cryptodev_driver_id, _sess_private_data); } if (unlikely(sess == NULL)) @@ -677,7 +673,6 @@ process_op(struct armv8_crypto_qp *qp, struct rte_crypto_op *op, memset(op->sym->session, 0, rte_cryptodev_sym_get_existing_header_session_size( op->sym->session)); - rte_mempool_put(qp->sess_mp_priv, sess); rte_mempool_put(qp->sess_mp, op->sym->session); op->sym->session = NULL; } 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 44de978d29..4c88ec637a 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/ccp/ccp_pmd_private.h b/drivers/crypto/ccp/ccp_pmd_private.h index 1c4118ee3c..6704e39ab8 100644 --- a/drivers/crypto/ccp/ccp_pmd_private.h +++ b/drivers/crypto/ccp/ccp_pmd_private.h @@ -78,8 +78,6 @@ struct ccp_qp { /**< Ring for placing process packets */ struct rte_mempool *sess_mp; /**< Session Mempool */ - struct rte_mempool *sess_mp_priv; - /**< Session Private Data Mempool */ struct rte_mempool *batch_mp; /**< Session Mempool for batch info */ struct rte_cryptodev_stats qp_stats; diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c index a35a8cd775..3e8c1f3b51 100644 --- a/drivers/crypto/ccp/rte_ccp_pmd.c +++ b/drivers/crypto/ccp/rte_ccp_pmd.c @@ -61,28 +61,26 @@ get_ccp_session(struct ccp_qp *qp, struct rte_crypto_op *op) op->sym->session, ccp_cryptodev_driver_id); } else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) { - void *_sess; - void *_sess_private_data = NULL; struct ccp_private *internals; + struct rte_cryptodev_sym_session *_sess = + rte_cryptodev_sym_session_create(qp->sess_mp); - if (rte_mempool_get(qp->sess_mp, &_sess)) - return NULL; - if (rte_mempool_get(qp->sess_mp, (void **)&_sess_private_data)) + if (_sess == NULL) return NULL; - sess = (struct ccp_session *)_sess_private_data; + _sess->sess_data[ccp_cryptodev_driver_id].data = + (void *)((uint8_t *)_sess + + rte_cryptodev_sym_get_header_session_size() + + (ccp_cryptodev_driver_id * _sess->priv_sz)); + sess = _sess->sess_data[ccp_cryptodev_driver_id].data; internals = (struct ccp_private *)qp->dev->data->dev_private; if (unlikely(ccp_set_session_parameters(sess, op->sym->xform, internals) != 0)) { rte_mempool_put(qp->sess_mp, _sess); - rte_mempool_put(qp->sess_mp_priv, _sess_private_data); sess = NULL; } op->sym->session = (struct rte_cryptodev_sym_session *)_sess; - set_sym_session_private_data(op->sym->session, - ccp_cryptodev_driver_id, - _sess_private_data); } return sess; @@ -166,8 +164,10 @@ ccp_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops, ops[i]->sym->session, ccp_cryptodev_driver_id); - rte_mempool_put(qp->sess_mp_priv, - sess); + memset(sess, 0, sizeof(struct ccp_session)); + memset(ops[i]->sym->session, 0, + rte_cryptodev_sym_get_existing_header_session_size( + ops[i]->sym->session)); rte_mempool_put(qp->sess_mp, ops[i]->sym->session); ops[i]->sym->session = NULL; diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c index de2eebd507..76c992858f 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; @@ -147,9 +148,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; @@ -474,8 +473,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 e49f826225..776cf02b57 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c @@ -382,7 +382,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; @@ -496,27 +495,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: @@ -550,7 +542,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)) { @@ -560,66 +552,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..97a2fb1050 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h @@ -79,8 +79,6 @@ struct cnxk_cpt_qp { /**< Pending queue */ struct rte_mempool *sess_mp; /**< Session mempool */ - struct rte_mempool *sess_mp_priv; - /**< Session private data mempool */ struct cpt_qp_meta_info meta_info; /**< Metabuf info required to support operations on the queue pair */ struct roc_cpt_lmtline lmtline; @@ -111,18 +109,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 9115dd8e70..717e506998 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_get_size(void *device __rte_unused) 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 e38ba21e89..fc267784a8 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -2534,33 +2534,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; } @@ -2581,18 +2566,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/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c index 189262c4ad..e4b4de7612 100644 --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c @@ -262,7 +262,6 @@ ipsec_mb_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, qp->pmd_type = internals->pmd_type; qp->sess_mp = qp_conf->mp_session; - qp->sess_mp_priv = qp_conf->mp_session_private; qp->ingress_queue = ipsec_mb_qp_create_processed_ops_ring(qp, qp_conf->nb_descriptors, socket_id); @@ -311,9 +310,8 @@ ipsec_mb_sym_session_get_size(struct rte_cryptodev *dev) int ipsec_mb_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; struct ipsec_mb_dev_private *internals = dev->data->dev_private; struct ipsec_mb_internals *pmd_data = &ipsec_mb_pmds[internals->pmd_type]; @@ -329,42 +327,22 @@ ipsec_mb_sym_session_configure( return -EINVAL; } - if (rte_mempool_get(mempool, &sess_private_data)) { - IPSEC_MB_LOG(ERR, "Couldn't get object from session mempool"); - free_mb_mgr(mb_mgr); - return -ENOMEM; - } - - ret = (*pmd_data->session_configure)(mb_mgr, sess_private_data, xform); + ret = (*pmd_data->session_configure)(mb_mgr, sess, xform); if (ret != 0) { IPSEC_MB_LOG(ERR, "failed configure session parameters"); - - /* Return session to mempool */ - rte_mempool_put(mempool, sess_private_data); free_mb_mgr(mb_mgr); return ret; } - set_sym_session_private_data(sess, dev->driver_id, sess_private_data); - free_mb_mgr(mb_mgr); return 0; } /** Clear the session memory */ void -ipsec_mb_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess) +ipsec_mb_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); - /* Zero out the whole structure */ - if (sess_priv) { - memset(sess_priv, 0, ipsec_mb_sym_session_get_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); - } + if (sess) + memset(sess, 0, ipsec_mb_sym_session_get_size(dev)); } diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_private.h b/drivers/crypto/ipsec_mb/ipsec_mb_private.h index 866722d6f4..38850c6532 100644 --- a/drivers/crypto/ipsec_mb/ipsec_mb_private.h +++ b/drivers/crypto/ipsec_mb/ipsec_mb_private.h @@ -132,8 +132,6 @@ struct ipsec_mb_qp { /**< Ring for placing operations ready for processing */ struct rte_mempool *sess_mp; /**< Session Mempool */ - struct rte_mempool *sess_mp_priv; - /**< Session Private Data Mempool */ struct rte_cryptodev_stats stats; /**< Queue pair statistics */ enum ipsec_mb_pmd_types pmd_type; @@ -394,13 +392,11 @@ ipsec_mb_sym_session_get_size(struct rte_cryptodev *dev); int ipsec_mb_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); /** Clear the memory of session so it does not leave key material behind */ void -ipsec_mb_sym_session_clear(struct rte_cryptodev *dev, - struct rte_cryptodev_sym_session *sess); +ipsec_mb_sym_session_clear(struct rte_cryptodev *dev, void *sess); /** Get session from op. If sessionless create a session */ static __rte_always_inline void * @@ -410,8 +406,7 @@ ipsec_mb_get_session_private(struct ipsec_mb_qp *qp, struct rte_crypto_op *op) uint32_t driver_id = ipsec_mb_get_driver_id(qp->pmd_type); struct rte_crypto_sym_op *sym_op = op->sym; uint8_t sess_type = op->sess_type; - void *_sess; - void *_sess_private_data = NULL; + struct rte_cryptodev_sym_session *_sess; struct ipsec_mb_internals *pmd_data = &ipsec_mb_pmds[qp->pmd_type]; switch (sess_type) { @@ -421,26 +416,22 @@ ipsec_mb_get_session_private(struct ipsec_mb_qp *qp, struct rte_crypto_op *op) driver_id); break; case RTE_CRYPTO_OP_SESSIONLESS: - if (!qp->sess_mp || - rte_mempool_get(qp->sess_mp, (void **)&_sess)) + _sess = rte_cryptodev_sym_session_create(qp->sess_mp); + if (_sess == NULL) return NULL; - if (!qp->sess_mp_priv || - rte_mempool_get(qp->sess_mp_priv, - (void **)&_sess_private_data)) - return NULL; - - sess = _sess_private_data; + _sess->sess_data[driver_id].data = + (void *)((uint8_t *)_sess + + rte_cryptodev_sym_get_header_session_size() + + (driver_id * _sess->priv_sz)); + sess = _sess->sess_data[driver_id].data; if (unlikely(pmd_data->session_configure(qp->mb_mgr, sess, sym_op->xform) != 0)) { rte_mempool_put(qp->sess_mp, _sess); - rte_mempool_put(qp->sess_mp_priv, _sess_private_data); sess = NULL; } sym_op->session = (struct rte_cryptodev_sym_session *)_sess; - set_sym_session_private_data(sym_op->session, driver_id, - _sess_private_data); break; default: IPSEC_MB_LOG(ERR, "Unrecognized session type %u", sess_type); diff --git a/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c b/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c index 2c203795ab..0c3a689074 100644 --- a/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c +++ b/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c @@ -240,7 +240,6 @@ handle_completed_gcm_crypto_op(struct ipsec_mb_qp *qp, memset(op->sym->session, 0, rte_cryptodev_sym_get_existing_header_session_size( op->sym->session)); - rte_mempool_put(qp->sess_mp_priv, sess); rte_mempool_put(qp->sess_mp, op->sym->session); op->sym->session = NULL; } @@ -462,27 +461,23 @@ aesni_gcm_get_session(struct ipsec_mb_qp *qp, get_sym_session_private_data(sym_op->session, driver_id); } else { - void *_sess; - void *_sess_private_data = NULL; + struct rte_cryptodev_sym_session *_sess = + rte_cryptodev_sym_session_create(qp->sess_mp); - if (rte_mempool_get(qp->sess_mp, (void **)&_sess)) + if(_sess == NULL) return NULL; - if (rte_mempool_get(qp->sess_mp_priv, - (void **)&_sess_private_data)) - return NULL; - - sess = (struct aesni_gcm_session *)_sess_private_data; - + _sess->sess_data[driver_id].data = + (void *)((uint8_t *)_sess + + rte_cryptodev_sym_get_header_session_size() + + (driver_id * _sess->priv_sz)); + sess = _sess->sess_data[driver_id].data; if (unlikely(aesni_gcm_session_configure(qp->mb_mgr, - _sess_private_data, sym_op->xform) != 0)) { + sess, sym_op->xform) != 0)) { rte_mempool_put(qp->sess_mp, _sess); - rte_mempool_put(qp->sess_mp_priv, _sess_private_data); sess = NULL; } sym_op->session = (struct rte_cryptodev_sym_session *)_sess; - set_sym_session_private_data(sym_op->session, driver_id, - _sess_private_data); } if (unlikely(sess == NULL)) diff --git a/drivers/crypto/ipsec_mb/pmd_aesni_mb.c b/drivers/crypto/ipsec_mb/pmd_aesni_mb.c index a7b65e565c..e2654b4a0b 100644 --- a/drivers/crypto/ipsec_mb/pmd_aesni_mb.c +++ b/drivers/crypto/ipsec_mb/pmd_aesni_mb.c @@ -1542,7 +1542,6 @@ post_process_mb_job(struct ipsec_mb_qp *qp, IMB_JOB *job) memset(op->sym->session, 0, rte_cryptodev_sym_get_existing_header_session_size( op->sym->session)); - rte_mempool_put(qp->sess_mp_priv, sess); rte_mempool_put(qp->sess_mp, op->sym->session); op->sym->session = NULL; } diff --git a/drivers/crypto/ipsec_mb/pmd_chacha_poly.c b/drivers/crypto/ipsec_mb/pmd_chacha_poly.c index d953d6e5f5..7a90836602 100644 --- a/drivers/crypto/ipsec_mb/pmd_chacha_poly.c +++ b/drivers/crypto/ipsec_mb/pmd_chacha_poly.c @@ -293,7 +293,6 @@ handle_completed_chacha20_poly1305_crypto_op(struct ipsec_mb_qp *qp, memset(op->sym->session, 0, rte_cryptodev_sym_get_existing_header_session_size( op->sym->session)); - rte_mempool_put(qp->sess_mp_priv, sess); rte_mempool_put(qp->sess_mp, op->sym->session); op->sym->session = NULL; } diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c b/drivers/crypto/ipsec_mb/pmd_kasumi.c index c9d4f9d0ae..1ecb73a392 100644 --- a/drivers/crypto/ipsec_mb/pmd_kasumi.c +++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c @@ -235,7 +235,6 @@ process_ops(struct rte_crypto_op **ops, struct kasumi_session *session, ops[i]->sym->session, 0, rte_cryptodev_sym_get_existing_header_session_size( ops[i]->sym->session)); - rte_mempool_put(qp->sess_mp_priv, session); rte_mempool_put(qp->sess_mp, ops[i]->sym->session); ops[i]->sym->session = NULL; } diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c index ebc9a0b562..13b425d1ad 100644 --- a/drivers/crypto/ipsec_mb/pmd_snow3g.c +++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c @@ -365,7 +365,6 @@ process_ops(struct rte_crypto_op **ops, struct snow3g_session *session, memset(ops[i]->sym->session, 0, rte_cryptodev_sym_get_existing_header_session_size( ops[i]->sym->session)); - rte_mempool_put(qp->sess_mp_priv, session); rte_mempool_put(qp->sess_mp, ops[i]->sym->session); ops[i]->sym->session = NULL; } diff --git a/drivers/crypto/ipsec_mb/pmd_zuc.c b/drivers/crypto/ipsec_mb/pmd_zuc.c index b542264069..616accb2fa 100644 --- a/drivers/crypto/ipsec_mb/pmd_zuc.c +++ b/drivers/crypto/ipsec_mb/pmd_zuc.c @@ -239,7 +239,6 @@ process_ops(struct rte_crypto_op **ops, enum ipsec_mb_operation op_type, memset(ops[i]->sym->session, 0, rte_cryptodev_sym_get_existing_header_session_size( ops[i]->sym->session)); - rte_mempool_put(qp->sess_mp_priv, sessions[i]); rte_mempool_put(qp->sess_mp, ops[i]->sym->session); ops[i]->sym->session = NULL; } diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index 14b6783e13..8babdad59f 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/mrvl_pmd_private.h b/drivers/crypto/mvsam/mrvl_pmd_private.h index 719d73d82c..8ebebd88c5 100644 --- a/drivers/crypto/mvsam/mrvl_pmd_private.h +++ b/drivers/crypto/mvsam/mrvl_pmd_private.h @@ -51,9 +51,6 @@ struct mrvl_crypto_qp { /** Session Mempool. */ struct rte_mempool *sess_mp; - /** Session Private Data Mempool. */ - struct rte_mempool *sess_mp_priv; - /** Queue pair statistics. */ struct rte_cryptodev_stats stats; diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c index 6ca1bb8b40..bf058d254c 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 cb5393d2f1..9405cb62f5 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.c b/drivers/crypto/null/null_crypto_pmd.c index 9ecb434fd0..1785a08822 100644 --- a/drivers/crypto/null/null_crypto_pmd.c +++ b/drivers/crypto/null/null_crypto_pmd.c @@ -81,27 +81,25 @@ get_session(struct null_crypto_qp *qp, struct rte_crypto_op *op) get_sym_session_private_data( sym_op->session, cryptodev_driver_id); } else { - void *_sess = NULL; - void *_sess_private_data = NULL; + struct rte_cryptodev_sym_session *_sess = NULL; - if (rte_mempool_get(qp->sess_mp, (void **)&_sess)) + /* Create temporary session */ + _sess = rte_cryptodev_sym_session_create(qp->sess_mp); + if (_sess == NULL) return NULL; - if (rte_mempool_get(qp->sess_mp_priv, - (void **)&_sess_private_data)) - return NULL; - - sess = (struct null_crypto_session *)_sess_private_data; + _sess->sess_data[cryptodev_driver_id].data = + (void *)((uint8_t *)_sess + + rte_cryptodev_sym_get_header_session_size() + + (cryptodev_driver_id * _sess->priv_sz)); + sess = _sess->sess_data[cryptodev_driver_id].data; if (unlikely(null_crypto_set_session_parameters(sess, sym_op->xform) != 0)) { rte_mempool_put(qp->sess_mp, _sess); - rte_mempool_put(qp->sess_mp_priv, _sess_private_data); sess = NULL; } sym_op->session = (struct rte_cryptodev_sym_session *)_sess; - set_sym_session_private_data(op->sym->session, - cryptodev_driver_id, _sess_private_data); } return sess; 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/null/null_crypto_pmd_private.h b/drivers/crypto/null/null_crypto_pmd_private.h index 89c4345b6f..ae34ce6671 100644 --- a/drivers/crypto/null/null_crypto_pmd_private.h +++ b/drivers/crypto/null/null_crypto_pmd_private.h @@ -31,8 +31,6 @@ struct null_crypto_qp { /**< Ring for placing process packets */ struct rte_mempool *sess_mp; /**< Session Mempool */ - struct rte_mempool *sess_mp_priv; - /**< Session Mempool */ struct rte_cryptodev_stats qp_stats; /**< Queue pair statistics */ } __rte_cache_aligned; diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.h b/drivers/crypto/octeontx/otx_cryptodev_hw_access.h index e48805fb09..4647d568de 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/octeontx2/otx2_cryptodev_qp.h b/drivers/crypto/octeontx2/otx2_cryptodev_qp.h index 95bce3621a..82ece44723 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_qp.h +++ b/drivers/crypto/octeontx2/otx2_cryptodev_qp.h @@ -27,8 +27,6 @@ struct otx2_cpt_qp { /**< Pending queue */ struct rte_mempool *sess_mp; /**< Session mempool */ - struct rte_mempool *sess_mp_priv; - /**< Session private data mempool */ struct cpt_qp_meta_info meta_info; /**< Metabuf info required to support operations on the queue pair */ rte_iova_t iq_dma_addr; diff --git a/drivers/crypto/openssl/openssl_pmd_private.h b/drivers/crypto/openssl/openssl_pmd_private.h index b2054b3754..2a9302bc19 100644 --- a/drivers/crypto/openssl/openssl_pmd_private.h +++ b/drivers/crypto/openssl/openssl_pmd_private.h @@ -64,8 +64,6 @@ struct openssl_qp { /**< Ring for placing process packets */ struct rte_mempool *sess_mp; /**< Session Mempool */ - struct rte_mempool *sess_mp_priv; - /**< Session Private Data Mempool */ struct rte_cryptodev_stats stats; /**< Queue pair statistics */ uint8_t temp_digest[DIGEST_LENGTH_MAX]; diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 5794ed8159..feb4a2dece 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -762,27 +762,24 @@ get_session(struct openssl_qp *qp, struct rte_crypto_op *op) return NULL; /* provide internal session */ - void *_sess = rte_cryptodev_sym_session_create(qp->sess_mp); - void *_sess_private_data = NULL; + struct rte_cryptodev_sym_session *_sess = + rte_cryptodev_sym_session_create(qp->sess_mp); if (_sess == NULL) return NULL; - if (rte_mempool_get(qp->sess_mp_priv, - (void **)&_sess_private_data)) - return NULL; - - sess = (struct openssl_session *)_sess_private_data; + _sess->sess_data[cryptodev_driver_id].data = + (void *)((uint8_t *)_sess + + rte_cryptodev_sym_get_header_session_size() + + (cryptodev_driver_id * _sess->priv_sz)); + sess = _sess->sess_data[cryptodev_driver_id].data; if (unlikely(openssl_set_session_parameters(sess, op->sym->xform) != 0)) { rte_mempool_put(qp->sess_mp, _sess); - rte_mempool_put(qp->sess_mp_priv, _sess_private_data); sess = NULL; } op->sym->session = (struct rte_cryptodev_sym_session *)_sess; - set_sym_session_private_data(op->sym->session, - cryptodev_driver_id, _sess_private_data); } if (sess == NULL) @@ -2106,7 +2103,6 @@ process_op(struct openssl_qp *qp, struct rte_crypto_op *op, memset(op->sym->session, 0, rte_cryptodev_sym_get_existing_header_session_size( op->sym->session)); - rte_mempool_put(qp->sess_mp_priv, sess); rte_mempool_put(qp->sess_mp, op->sym->session); op->sym->session = NULL; } 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 cfa7d59914..5df8f86420 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 ea329c1f71..299e758d1c 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/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c index ed64866758..70d03869fe 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 @@ -929,7 +928,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; @@ -1292,11 +1291,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; } @@ -1311,12 +1308,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; @@ -1328,19 +1322,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; @@ -1403,9 +1391,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/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 b0de3d269a..837afddcda 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 f458d15a7a..ccaa0c31f7 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -1206,15 +1206,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; @@ -2132,8 +2128,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)) @@ -2395,38 +2389,6 @@ 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 pool_init(struct socket_ctx *ctx, int32_t socket_id, uint32_t nb_mbuf) { @@ -2928,8 +2890,6 @@ 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); } 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 6f49239c4a..c65855a460 100644 --- a/examples/ipsec-secgw/ipsec_worker.c +++ b/examples/ipsec-secgw/ipsec_worker.c @@ -540,14 +540,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 2b029c65e6..154ac7793f 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 89bf2af399..d35e66d3b5 100644 --- a/lib/cryptodev/cryptodev_pmd.h +++ b/lib/cryptodev/cryptodev_pmd.h @@ -301,7 +301,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. @@ -310,9 +309,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. * @@ -338,7 +335,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 daa090b978..a84964163c 100644 --- a/lib/cryptodev/rte_crypto_sym.h +++ b/lib/cryptodev/rte_crypto_sym.h @@ -924,7 +924,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 305e013ebb..783e33bef6 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -201,6 +201,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 @@ -1218,16 +1220,9 @@ 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)) { - CDEV_LOG_ERR("Invalid mempools\n"); - return -EINVAL; - } - 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); @@ -1239,11 +1234,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; } @@ -1705,11 +1700,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; @@ -1722,10 +1717,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; @@ -1735,8 +1730,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", @@ -1745,7 +1743,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; } @@ -1790,6 +1788,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, @@ -1799,15 +1812,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); @@ -1827,6 +1840,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); @@ -1860,7 +1874,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; @@ -1881,6 +1895,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. @@ -1890,7 +1905,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 * @@ -1928,9 +1943,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; @@ -1952,7 +1967,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; @@ -1983,10 +1998,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 56e3868ada..68271fd7e3 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -539,8 +539,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 */ }; /** @@ -910,6 +908,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; @@ -961,10 +961,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); /** @@ -993,7 +993,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 @@ -1013,25 +1013,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 @@ -1070,8 +1068,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 4b0316bfed..c3b7fb84c4 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