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 5F184A0542; Sat, 24 Sep 2022 18:36:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1882542C18; Sat, 24 Sep 2022 18:36:29 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 0A33A42C11 for ; Sat, 24 Sep 2022 18:36:26 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28OEq3Ph010252; Sat, 24 Sep 2022 09:36:22 -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=7edvtz/xZZA4z2vdNw1iEpbFQV8e5Jui4WOF2F/y/Yk=; b=JC27GBY71h3MeJtWCDKaGmrcOdlO/zc3iYrVgohC/KXYLFN3imXaZKFZQxuwhNAvRrod B7J8MfQtcWwNyDcN+Z1AFN1aopDOetfQ2Yb94U6Lkw5xyKv+xm701rYQF0tAAgJ79IIp 4QTDmagGPSaP0NMtgDMOHY5u7GRjRz7AQg3lvuwbVYSmBKEgrtP4SF9fm+tljRVqlowb n/iklH8vGJ/S/EAJU07O/VTWcaEH4VyZjVX8mvDUXux1SWa96EMgP5UYpkSrFz/bIlYv EUQgJAVtQ1yOpdCXa/3KeOVP1ylYNLy6HCxpaZ4OJq8qtkEVwetZhrB1uBeOEU9Z0cW/ 7A== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3jsy8r0u80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 24 Sep 2022 09:36:21 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 24 Sep 2022 09:36:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Sat, 24 Sep 2022 09:36:20 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id D4B4A3F7055; Sat, 24 Sep 2022 09:36:11 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , Akhil Goyal , Kai Ji , David Coyle , Kevin O'Sullivan Subject: [PATCH v3 3/6] cryptodev: hide sym session structure Date: Sat, 24 Sep 2022 22:05:39 +0530 Message-ID: <20220924163542.4159562-4-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220924163542.4159562-1-gakhil@marvell.com> References: <20220921150258.2061702-1-gakhil@marvell.com> <20220924163542.4159562-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: QXsFh9trZJKO1SkI_biqjsl3mspLI0Dz X-Proofpoint-ORIG-GUID: QXsFh9trZJKO1SkI_biqjsl3mspLI0Dz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-24_07,2022-09-22_02,2022-06-22_01 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 Structure rte_cryptodev_sym_session is moved to internal headers which are not visible to applications. The only field which should be used by app is opaque_data. This field can now be accessed via set/get APIs added in this patch. Subsequent changes in app and lib are made to compile the code. Signed-off-by: Akhil Goyal Signed-off-by: Fan Zhang Acked-by: Kai Ji Tested-by: Gagandeep Singh Tested-by: David Coyle Tested-by: Kevin O'Sullivan --- app/test/test_ipsec_perf.c | 4 +- doc/guides/prog_guide/cryptodev_lib.rst | 16 ++---- doc/guides/rel_notes/deprecation.rst | 5 -- doc/guides/rel_notes/release_22_11.rst | 9 +++ drivers/crypto/bcmfs/bcmfs_sym_session.c | 5 +- drivers/crypto/caam_jr/caam_jr.c | 10 ++-- drivers/crypto/ccp/ccp_crypto.c | 30 +++++----- drivers/crypto/ccp/ccp_pmd_ops.c | 2 +- drivers/crypto/ccp/rte_ccp_pmd.c | 4 +- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 8 +-- drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 10 ++-- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 4 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 2 +- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 11 ++-- drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c | 2 +- drivers/crypto/dpaa_sec/dpaa_sec.c | 9 ++- drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c | 2 +- drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 2 +- drivers/crypto/ipsec_mb/ipsec_mb_private.h | 4 +- drivers/crypto/ipsec_mb/pmd_aesni_gcm.c | 6 +- drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 4 +- drivers/crypto/ipsec_mb/pmd_kasumi.c | 2 +- drivers/crypto/ipsec_mb/pmd_snow3g.c | 2 +- drivers/crypto/mlx5/mlx5_crypto.c | 7 +-- drivers/crypto/nitrox/nitrox_sym.c | 6 +- drivers/crypto/null/null_crypto_pmd.c | 3 +- drivers/crypto/null/null_crypto_pmd_ops.c | 2 +- drivers/crypto/octeontx/otx_cryptodev_ops.c | 10 ++-- drivers/crypto/openssl/rte_openssl_pmd.c | 4 +- drivers/crypto/openssl/rte_openssl_pmd_ops.c | 4 +- drivers/crypto/qat/qat_sym.c | 4 +- drivers/crypto/qat/qat_sym.h | 3 +- drivers/crypto/qat/qat_sym_session.c | 6 +- .../scheduler/scheduler_pkt_size_distr.c | 13 ++--- drivers/crypto/scheduler/scheduler_pmd_ops.c | 4 +- .../crypto/scheduler/scheduler_pmd_private.h | 30 +++++----- drivers/crypto/virtio/virtio_cryptodev.c | 4 +- drivers/crypto/virtio/virtio_rxtx.c | 2 +- examples/fips_validation/fips_dev_self_test.c | 10 ++-- lib/cryptodev/cryptodev_pmd.h | 32 +++++++++++ lib/cryptodev/rte_crypto.h | 3 +- lib/cryptodev/rte_crypto_sym.h | 7 +-- lib/cryptodev/rte_cryptodev.c | 16 ++++-- lib/cryptodev/rte_cryptodev.h | 56 +++++++++---------- lib/cryptodev/rte_cryptodev_trace.h | 8 +-- lib/ipsec/rte_ipsec_group.h | 5 +- lib/ipsec/ses.c | 3 +- 47 files changed, 201 insertions(+), 194 deletions(-) diff --git a/app/test/test_ipsec_perf.c b/app/test/test_ipsec_perf.c index b5d0c2e036..b221b7fc32 100644 --- a/app/test/test_ipsec_perf.c +++ b/app/test/test_ipsec_perf.c @@ -227,7 +227,7 @@ static int create_sa(enum rte_security_session_action_type action_type, struct ipsec_sa *sa) { - static struct rte_cryptodev_sym_session dummy_ses; + void *dummy_ses = NULL; size_t sz; int rc; @@ -247,7 +247,7 @@ create_sa(enum rte_security_session_action_type action_type, "failed to allocate memory for rte_ipsec_sa\n"); sa->ss[0].type = action_type; - sa->ss[0].crypto.ses = &dummy_ses; + sa->ss[0].crypto.ses = dummy_ses; rc = rte_ipsec_sa_init(sa->ss[0].sa, &sa->sa_prm, sz); rc = (rc > 0 && (uint32_t)rc <= sz) ? 0 : -EINVAL; diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst index 9e54683aa1..01aad842a9 100644 --- a/doc/guides/prog_guide/cryptodev_lib.rst +++ b/doc/guides/prog_guide/cryptodev_lib.rst @@ -125,13 +125,11 @@ Each queue pairs resources may be allocated on a specified socket. 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 */ }; -The fields ``mp_session`` and ``mp_session_private`` are used for creating -temporary session to process the crypto operations in the session-less mode. +The field ``mp_session`` is used for creating temporary session to process +the crypto operations in the session-less mode. They can be the same other different mempools. Please note not all Cryptodev PMDs supports session-less mode. @@ -595,7 +593,7 @@ chain. struct rte_mbuf *m_dst; union { - struct rte_cryptodev_sym_session *session; + void *session; /**< Handle for the initialised session context */ struct rte_crypto_sym_xform *xform; /**< Session-less API Crypto operation parameters */ @@ -943,15 +941,11 @@ using one of the crypto PMDs available in DPDK. /* Create crypto session and initialize it for the crypto device. */ struct rte_cryptodev_sym_session *session; - session = rte_cryptodev_sym_session_create(session_pool); + session = rte_cryptodev_sym_session_create(cdev_id, &cipher_xform, + session_pool); if (session == NULL) rte_exit(EXIT_FAILURE, "Session could not be created\n"); - if (rte_cryptodev_sym_session_init(cdev_id, session, - &cipher_xform, session_priv_pool) < 0) - rte_exit(EXIT_FAILURE, "Session could not be initialized " - "for the crypto device\n"); - /* Get a burst of crypto operations. */ struct rte_crypto_op *crypto_ops[BURST_SIZE]; if (rte_crypto_op_bulk_alloc(crypto_op_pool, diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index e7583cae4c..9785a0f3ce 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -161,11 +161,6 @@ Deprecation Notices this `RFC `__. This should be updated in DPDK 22.11. -* cryptodev: Hide structures ``rte_cryptodev_sym_session`` and - ``rte_cryptodev_asym_session`` to remove unnecessary indirection between - session and the private data of session. An opaque pointer can be exposed - directly to application which can be attached to the ``rte_crypto_op``. - * cryptodev: The function ``rte_cryptodev_cb_fn`` will be updated to have another parameter ``qp_id`` to return the queue pair ID which got error interrupt to the application, diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index 7fab9d6550..4b8b34d8ba 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -89,6 +89,15 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* cryptodev: The structure ``rte_cryptodev_sym_session`` was made internal. + The API ``rte_cryptodev_sym_session_init`` and ``rte_cryptodev_sym_session_clear`` + were removed and user would only need to call ``rte_cryptodev_sym_session_create`` + and ``rte_cryptodev_sym_session_free`` to create/destroy sessions. + The API ``rte_cryptodev_sym_session_create`` was updated to take a single mempool + with element size big enough to hold session data and session private data. + All sample applications were updated to attach an opaque pointer for the session + to the ``rte_crypto_op`` while enqueuing. + ABI Changes ----------- diff --git a/drivers/crypto/bcmfs/bcmfs_sym_session.c b/drivers/crypto/bcmfs/bcmfs_sym_session.c index d3334dc920..40813d1fe5 100644 --- a/drivers/crypto/bcmfs/bcmfs_sym_session.c +++ b/drivers/crypto/bcmfs/bcmfs_sym_session.c @@ -210,8 +210,7 @@ bcmfs_sym_get_session(struct rte_crypto_op *op) BCMFS_DP_LOG(ERR, "operations op(%p) is sessionless", op); } else if (likely(op->sym->session != NULL)) { /* get existing session */ - sess = (struct bcmfs_sym_session *) - op->sym->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); } if (sess == NULL) @@ -233,7 +232,7 @@ bcmfs_sym_session_configure(struct rte_cryptodev *dev __rte_unused, return -EINVAL; } - sess_private_data = (void *)sess->driver_priv_data; + sess_private_data = CRYPTODEV_GET_SYM_SESS_PRIV(sess); ret = crypto_set_session_parameters(sess_private_data, xform); diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c index a9c93dea13..c9c783d19a 100644 --- a/drivers/crypto/caam_jr/caam_jr.c +++ b/drivers/crypto/caam_jr/caam_jr.c @@ -1356,8 +1356,7 @@ caam_jr_enqueue_op(struct rte_crypto_op *op, struct caam_jr_qp *qp) switch (op->sess_type) { case RTE_CRYPTO_OP_WITH_SESSION: - ses = (struct caam_jr_session *) - op->sym->session->driver_priv_data; + ses = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); break; case RTE_CRYPTO_OP_SECURITY_SESSION: ses = (struct caam_jr_session *) @@ -1699,7 +1698,7 @@ caam_jr_sym_session_configure(struct rte_cryptodev *dev __rte_unused, int ret; PMD_INIT_FUNC_TRACE(); - sess_private_data = (void *)sess->driver_priv_data; + sess_private_data = CRYPTODEV_GET_SYM_SESS_PRIV(sess); memset(sess_private_data, 0, sizeof(struct caam_jr_session)); ret = caam_jr_set_session_parameters(dev, xform, sess_private_data); if (ret != 0) { @@ -1716,12 +1715,11 @@ static void caam_jr_sym_session_clear(struct rte_cryptodev *dev __rte_unused, struct rte_cryptodev_sym_session *sess) { - void *sess_priv = (void *)sess->driver_priv_data; - struct caam_jr_session *s = (struct caam_jr_session *)sess_priv; + struct caam_jr_session *s = CRYPTODEV_GET_SYM_SESS_PRIV(sess); PMD_INIT_FUNC_TRACE(); - if (sess_priv) { + if (s) { rte_free(s->cipher_key.data); rte_free(s->auth_key.data); } diff --git a/drivers/crypto/ccp/ccp_crypto.c b/drivers/crypto/ccp/ccp_crypto.c index bd999abe61..b21b32e507 100644 --- a/drivers/crypto/ccp/ccp_crypto.c +++ b/drivers/crypto/ccp/ccp_crypto.c @@ -1585,7 +1585,7 @@ ccp_perform_hmac(struct rte_crypto_op *op, void *append_ptr; uint8_t *addr; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); addr = session->auth.pre_compute; src_addr = rte_pktmbuf_iova_offset(op->sym->m_src, @@ -1764,7 +1764,7 @@ ccp_perform_sha(struct rte_crypto_op *op, void *append_ptr; uint64_t auth_msg_bits; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); src_addr = rte_pktmbuf_iova_offset(op->sym->m_src, op->sym->auth.data.offset); @@ -1855,7 +1855,7 @@ ccp_perform_sha3_hmac(struct rte_crypto_op *op, uint32_t tail; phys_addr_t src_addr, dest_addr, ctx_paddr, dest_addr_t; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); src_addr = rte_pktmbuf_iova_offset(op->sym->m_src, op->sym->auth.data.offset); @@ -1999,7 +1999,7 @@ ccp_perform_sha3(struct rte_crypto_op *op, uint32_t tail; phys_addr_t src_addr, dest_addr, ctx_paddr; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); src_addr = rte_pktmbuf_iova_offset(op->sym->m_src, op->sym->auth.data.offset); @@ -2071,7 +2071,7 @@ ccp_perform_aes_cmac(struct rte_crypto_op *op, phys_addr_t src_addr, dest_addr, key_addr; int length, non_align_len; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); key_addr = rte_mem_virt2phy(session->auth.key_ccp); src_addr = rte_pktmbuf_iova_offset(op->sym->m_src, @@ -2232,7 +2232,7 @@ ccp_perform_aes(struct rte_crypto_op *op, phys_addr_t src_addr, dest_addr, key_addr; uint8_t *iv; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); function.raw = 0; iv = rte_crypto_op_ctod_offset(op, uint8_t *, session->iv.offset); @@ -2318,7 +2318,7 @@ ccp_perform_3des(struct rte_crypto_op *op, uint8_t *iv; phys_addr_t src_addr, dest_addr, key_addr; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); iv = rte_crypto_op_ctod_offset(op, uint8_t *, session->iv.offset); switch (session->cipher.um.des_mode) { @@ -2426,7 +2426,7 @@ ccp_perform_aes_gcm(struct rte_crypto_op *op, struct ccp_queue *cmd_q) phys_addr_t digest_dest_addr; int length, non_align_len; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); iv = rte_crypto_op_ctod_offset(op, uint8_t *, session->iv.offset); key_addr = session->cipher.key_phys; @@ -2591,7 +2591,7 @@ ccp_crypto_cipher(struct rte_crypto_op *op, int result = 0; struct ccp_session *session; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); switch (session->cipher.algo) { case CCP_CIPHER_ALGO_AES_CBC: @@ -2627,7 +2627,7 @@ ccp_crypto_auth(struct rte_crypto_op *op, int result = 0; struct ccp_session *session; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); switch (session->auth.algo) { case CCP_AUTH_ALGO_SHA1: @@ -2695,7 +2695,7 @@ ccp_crypto_aead(struct rte_crypto_op *op, int result = 0; struct ccp_session *session; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); switch (session->auth.algo) { case CCP_AUTH_ALGO_AES_GCM: @@ -2758,8 +2758,7 @@ process_ops_to_enqueue(struct ccp_qp *qp, b_info->head_offset = (uint32_t)(cmd_q->qbase_phys_addr + cmd_q->qidx * Q_DESC_SIZE); for (i = b_idx; i < (nb_ops+b_idx); i++) { - session = (struct ccp_session *) - op[i]->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op[i]->sym->session); switch (session->cmd_id) { case CCP_CMD_CIPHER: result = ccp_crypto_cipher(op[i], cmd_q, b_info); @@ -2835,7 +2834,7 @@ static inline void ccp_auth_dq_prepare(struct rte_crypto_op *op) int offset, digest_offset; uint8_t digest_le[64]; - session = (struct ccp_session *)op->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); if (session->cmd_id == CCP_CMD_COMBINED) { digest_data = op->sym->aead.digest.data; @@ -2909,8 +2908,7 @@ ccp_prepare_ops(struct ccp_qp *qp, for (i = b_info->b_idx; i < min_ops; i++) { op_d[i] = b_info->op[b_info->b_idx + b_info->op_idx++]; - session = (struct ccp_session *) - op_d[i]->sym->session->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(op_d[i]->sym->session); switch (session->cmd_id) { case CCP_CMD_CIPHER: op_d[i]->status = RTE_CRYPTO_OP_STATUS_SUCCESS; diff --git a/drivers/crypto/ccp/ccp_pmd_ops.c b/drivers/crypto/ccp/ccp_pmd_ops.c index e401793a76..52f320b02b 100644 --- a/drivers/crypto/ccp/ccp_pmd_ops.c +++ b/drivers/crypto/ccp/ccp_pmd_ops.c @@ -767,7 +767,7 @@ ccp_pmd_sym_session_configure(struct rte_cryptodev *dev, return -ENOMEM; } - sess_private_data = (void *)sess->driver_priv_data; + sess_private_data = CRYPTODEV_GET_SYM_SESS_PRIV(sess); internals = (struct ccp_private *)dev->data->dev_private; ret = ccp_set_session_parameters(sess_private_data, xform, internals); diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c index 7502281ad9..c0b016ea36 100644 --- a/drivers/crypto/ccp/rte_ccp_pmd.c +++ b/drivers/crypto/ccp/rte_ccp_pmd.c @@ -56,7 +56,7 @@ get_ccp_session(struct ccp_qp *qp, struct rte_crypto_op *op) if (unlikely(op->sym->session == NULL)) return NULL; - sess = (void *)op->sym->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); } else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) { struct rte_cryptodev_sym_session *_sess; struct ccp_private *internals; @@ -152,7 +152,7 @@ ccp_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops, if (unlikely(ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS)) { struct ccp_session *sess = - (void *)ops[i]->sym->session->driver_priv_data; + CRYPTODEV_GET_SYM_SESS_PRIV(ops[i]->sym->session); memset(sess, 0, sizeof(*sess)); rte_mempool_put(qp->sess_mp, diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c index f96e132513..4648576ff8 100644 --- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c @@ -110,7 +110,7 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], return 0; w7 = sec_sess->sa.inst.w7; } else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { - sess = (void *)sym_op->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(sym_op->session); ret = cpt_sym_inst_fill(qp, op, sess, infl_req, &inst[0]); if (unlikely(ret)) @@ -293,9 +293,7 @@ cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused, } else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) { struct cnxk_se_sess *priv; - priv = (void *)( - ((struct rte_cryptodev_sym_session *)sess)-> - driver_priv_data); + priv = CRYPTODEV_GET_SYM_SESS_PRIV(sess); priv->qp = qp; priv->cpt_inst_w2 = w2; } else @@ -332,7 +330,7 @@ cn10k_ca_meta_info_extract(struct rte_crypto_op *op, } else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { struct cnxk_se_sess *priv; - priv = (void *)op->sym->session->driver_priv_data; + priv = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); *qp = priv->qp; *w2 = priv->cpt_inst_w2; } else { diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c index a44f111ba6..5c344a6008 100644 --- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c @@ -69,7 +69,7 @@ cn9k_cpt_sym_temp_sess_create(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op) if (ret) goto sess_put; - priv = (void *)sess->driver_priv_data; + priv = CRYPTODEV_GET_SYM_SESS_PRIV(sess); sym_op->session = sess; @@ -92,7 +92,7 @@ cn9k_cpt_inst_prep(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op, if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { sym_op = op->sym; - sess = (void *)sym_op->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(sym_op->session); ret = cpt_sym_inst_fill(qp, op, sess, infl_req, inst); inst->w7.u64 = sess->cpt_inst_w7; } else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) @@ -344,9 +344,7 @@ cn9k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused, } else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) { struct cnxk_se_sess *priv; - priv = (void *)(( - (struct rte_cryptodev_sym_session *)sess)-> - driver_priv_data); + priv = CRYPTODEV_GET_SYM_SESS_PRIV(sess); priv->qp = qp; priv->cpt_inst_w2 = w2; } else @@ -383,7 +381,7 @@ cn9k_ca_meta_info_extract(struct rte_crypto_op *op, } else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { struct cnxk_se_sess *priv; - priv = (void *)op->sym->session->driver_priv_data; + priv = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); *qp = priv->qp; inst->w2.u64 = priv->cpt_inst_w2; } else { diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c index 018d7fcee8..a5233a942a 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c @@ -624,7 +624,7 @@ sym_session_configure(struct roc_cpt *roc_cpt, struct rte_cryptodev_sym_session *sess) { enum cpt_dp_thread_type thr_type; - struct cnxk_se_sess *sess_priv = (void *)sess->driver_priv_data; + struct cnxk_se_sess *sess_priv = CRYPTODEV_GET_SYM_SESS_PRIV(sess); int ret; memset(sess_priv, 0, sizeof(struct cnxk_se_sess)); @@ -693,7 +693,7 @@ cnxk_cpt_sym_session_configure(struct rte_cryptodev *dev, void sym_session_clear(struct rte_cryptodev_sym_session *sess) { - struct cnxk_se_sess *sess_priv = (void *)sess->driver_priv_data; + struct cnxk_se_sess *sess_priv = CRYPTODEV_GET_SYM_SESS_PRIV(sess); if (sess_priv->roc_se_ctx.auth_key != NULL) plt_free(sess_priv->roc_se_ctx.auth_key); diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h index ca90567620..37a7322e0f 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h @@ -5,7 +5,7 @@ #ifndef _CNXK_CRYPTODEV_OPS_H_ #define _CNXK_CRYPTODEV_OPS_H_ -#include +#include #include #include "roc_api.h" diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 5a38d53022..369fa9c81d 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -1379,7 +1379,7 @@ build_sec_fd(struct rte_crypto_op *op, dpaa2_sec_session *sess; if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) - sess = (dpaa2_sec_session *)op->sym->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); #ifdef RTE_LIB_SECURITY else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) sess = (dpaa2_sec_session *)get_sec_session_private_data( @@ -1677,7 +1677,7 @@ dpaa2_sec_dump(struct rte_crypto_op *op) struct rte_crypto_sym_op *sym_op; if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) - sess = (dpaa2_sec_session *)op->sym->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); #ifdef RTE_LIBRTE_SECURITY else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) sess = (dpaa2_sec_session *)get_sec_session_private_data( @@ -3756,7 +3756,7 @@ dpaa2_sec_sym_session_configure(struct rte_cryptodev *dev __rte_unused, struct rte_crypto_sym_xform *xform, struct rte_cryptodev_sym_session *sess) { - void *sess_private_data = (void *)sess->driver_priv_data; + void *sess_private_data = CRYPTODEV_GET_SYM_SESS_PRIV(sess); int ret; ret = dpaa2_sec_set_session_parameters(xform, sess_private_data); @@ -3775,10 +3775,9 @@ dpaa2_sec_sym_session_clear(struct rte_cryptodev *dev __rte_unused, struct rte_cryptodev_sym_session *sess) { PMD_INIT_FUNC_TRACE(); - void *sess_priv = (void *)sess->driver_priv_data; - dpaa2_sec_session *s = (dpaa2_sec_session *)sess_priv; + dpaa2_sec_session *s = CRYPTODEV_GET_SYM_SESS_PRIV(sess); - if (sess_priv) { + if (s) { rte_free(s->ctxt); rte_free(s->cipher_key.data); rte_free(s->auth_key.data); diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c index 795be3acc3..8c1e0abb95 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c @@ -1012,7 +1012,7 @@ dpaa2_sec_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id, sess = (dpaa2_sec_session *)get_sec_session_private_data( session_ctx.sec_sess); else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) - sess = (void *)session_ctx.crypto_sess->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(session_ctx.crypto_sess); else return -ENOTSUP; raw_dp_ctx->dequeue_burst = dpaa2_sec_raw_dequeue_burst; diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index 0cc773fba6..ec2fe56d1e 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -670,7 +670,7 @@ dpaa_sec_dump(struct dpaa_sec_op_ctx *ctx, struct dpaa_sec_qp *qp) struct qm_sg_entry sg[2]; if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) - sess = (dpaa_sec_session *)op->sym->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); #ifdef RTE_LIBRTE_SECURITY else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) sess = (dpaa_sec_session *) @@ -1924,8 +1924,7 @@ dpaa_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops, switch (op->sess_type) { case RTE_CRYPTO_OP_WITH_SESSION: - ses = (void *) - op->sym->session->driver_priv_data; + ses = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); break; #ifdef RTE_LIB_SECURITY case RTE_CRYPTO_OP_SECURITY_SESSION: @@ -2673,7 +2672,7 @@ dpaa_sec_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, struct rte_cryptodev_sym_session *sess) { - void *sess_private_data = (void *)sess->driver_priv_data; + void *sess_private_data = CRYPTODEV_GET_SYM_SESS_PRIV(sess); int ret; PMD_INIT_FUNC_TRACE(); @@ -2714,7 +2713,7 @@ dpaa_sec_sym_session_clear(struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess) { PMD_INIT_FUNC_TRACE(); - void *sess_priv = (void *)sess->driver_priv_data; + void *sess_priv = CRYPTODEV_GET_SYM_SESS_PRIV(sess); dpaa_sec_session *s = (dpaa_sec_session *)sess_priv; free_session_memory(dev, s); diff --git a/drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c b/drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c index d2e4d9d787..93129e7614 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec_raw_dp.c @@ -1018,7 +1018,7 @@ dpaa_sec_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id, session_ctx.sec_sess); else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) sess = (dpaa_sec_session *) - session_ctx.crypto_sess->driver_priv_data; + CRYPTODEV_GET_SYM_SESS_PRIV(session_ctx.crypto_sess); else return -ENOTSUP; raw_dp_ctx->dequeue_burst = dpaa_sec_raw_dequeue_burst; diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c index 90ce5bc965..cedcaa2742 100644 --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c @@ -329,7 +329,7 @@ ipsec_mb_sym_session_configure( } ret = (*pmd_data->session_configure)(mb_mgr, - (void *)sess->driver_priv_data, xform); + CRYPTODEV_GET_SYM_SESS_PRIV(sess), xform); if (ret != 0) { IPSEC_MB_LOG(ERR, "failed configure session parameters"); diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_private.h b/drivers/crypto/ipsec_mb/ipsec_mb_private.h index 14f962ef28..63e6fd58ee 100644 --- a/drivers/crypto/ipsec_mb/ipsec_mb_private.h +++ b/drivers/crypto/ipsec_mb/ipsec_mb_private.h @@ -434,7 +434,7 @@ ipsec_mb_get_session_private(struct ipsec_mb_qp *qp, struct rte_crypto_op *op) } if (unlikely(pmd_data->session_configure(qp->mb_mgr, - (void *)sess->driver_priv_data, sym_op->xform) != 0)) { + CRYPTODEV_GET_SYM_SESS_PRIV(sess), sym_op->xform) != 0)) { rte_mempool_put(qp->sess_mp, _sess); goto error_exit; } @@ -447,7 +447,7 @@ ipsec_mb_get_session_private(struct ipsec_mb_qp *qp, struct rte_crypto_op *op) IPSEC_MB_LOG(ERR, "Unrecognized session type %u", sess_type); } - return (void *)sess->driver_priv_data; + return CRYPTODEV_GET_SYM_SESS_PRIV(sess); error_exit: op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION; diff --git a/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c b/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c index e4f274b608..8d40bd9169 100644 --- a/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c +++ b/drivers/crypto/ipsec_mb/pmd_aesni_gcm.c @@ -468,7 +468,7 @@ aesni_gcm_get_session(struct ipsec_mb_qp *qp, } if (unlikely(aesni_gcm_session_configure(qp->mb_mgr, - (void *)sess->driver_priv_data, + CRYPTODEV_GET_SYM_SESS_PRIV(sess), sym_op->xform) != 0)) { rte_mempool_put(qp->sess_mp, sess); sess = NULL; @@ -479,7 +479,7 @@ aesni_gcm_get_session(struct ipsec_mb_qp *qp, if (unlikely(sess == NULL)) op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION; - return (void *)sess->driver_priv_data; + return CRYPTODEV_GET_SYM_SESS_PRIV(sess); } static uint16_t @@ -704,7 +704,7 @@ aesni_gcm_process_bulk(struct rte_cryptodev *dev __rte_unused, __rte_unused union rte_crypto_sym_ofs ofs, struct rte_crypto_sym_vec *vec) { - struct aesni_gcm_session *s = (void *)sess->driver_priv_data; + struct aesni_gcm_session *s = CRYPTODEV_GET_SYM_SESS_PRIV(sess); struct gcm_context_data gdata_ctx; IMB_MGR *mb_mgr; diff --git a/drivers/crypto/ipsec_mb/pmd_aesni_mb.c b/drivers/crypto/ipsec_mb/pmd_aesni_mb.c index f3565b04b5..7d2f3b0e4b 100644 --- a/drivers/crypto/ipsec_mb/pmd_aesni_mb.c +++ b/drivers/crypto/ipsec_mb/pmd_aesni_mb.c @@ -1723,7 +1723,7 @@ post_process_mb_job(struct ipsec_mb_qp *qp, IMB_JOB *job) sess = get_sec_session_private_data(op->sym->sec_session); } else #endif - sess = (void *)op->sym->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); if (likely(op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)) { switch (job->status) { @@ -2013,7 +2013,7 @@ aesni_mb_process_bulk(struct rte_cryptodev *dev __rte_unused, void *buf; IMB_JOB *job; IMB_MGR *mb_mgr; - struct aesni_mb_session *s = (void *)sess->driver_priv_data; + struct aesni_mb_session *s = CRYPTODEV_GET_SYM_SESS_PRIV(sess); uint8_t tmp_dgst[vec->num][DIGEST_LENGTH_MAX]; /* get per-thread MB MGR, create one if needed */ diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c b/drivers/crypto/ipsec_mb/pmd_kasumi.c index b2fb168154..705eed9758 100644 --- a/drivers/crypto/ipsec_mb/pmd_kasumi.c +++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c @@ -282,7 +282,7 @@ process_op_bit(struct rte_crypto_op *op, struct kasumi_session *session, /* Free session if a session-less crypto op. */ if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) { - memset(op->sym->session->driver_priv_data, 0, + memset(CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session), 0, sizeof(struct kasumi_session)); rte_mempool_put(qp->sess_mp, (void *)op->sym->session); op->sym->session = NULL; diff --git a/drivers/crypto/ipsec_mb/pmd_snow3g.c b/drivers/crypto/ipsec_mb/pmd_snow3g.c index f052d6d847..8ed069f428 100644 --- a/drivers/crypto/ipsec_mb/pmd_snow3g.c +++ b/drivers/crypto/ipsec_mb/pmd_snow3g.c @@ -413,7 +413,7 @@ process_op_bit(struct rte_crypto_op *op, struct snow3g_session *session, /* Free session if a session-less crypto op. */ if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) { - memset(op->sym->session->driver_priv_data, 0, + memset(CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session), 0, sizeof(struct snow3g_session)); rte_mempool_put(qp->sess_mp, (void *)op->sym->session); op->sym->session = NULL; diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index 46ea507cf5..c7d8fa311c 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -175,7 +175,7 @@ mlx5_crypto_sym_session_configure(struct rte_cryptodev *dev, { struct mlx5_crypto_priv *priv = dev->data->dev_private; struct mlx5_crypto_session *sess_private_data = - (void *)session->driver_priv_data; + CRYPTODEV_GET_SYM_SESS_PRIV(session); struct rte_crypto_cipher_xform *cipher; uint8_t encryption_order; @@ -239,7 +239,7 @@ mlx5_crypto_sym_session_clear(struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess) { struct mlx5_crypto_priv *priv = dev->data->dev_private; - struct mlx5_crypto_session *spriv = (void *)sess->driver_priv_data; + struct mlx5_crypto_session *spriv = CRYPTODEV_GET_SYM_SESS_PRIV(sess); if (unlikely(spriv == NULL)) { DRV_LOG(ERR, "Failed to get session %p private data.", spriv); @@ -355,8 +355,7 @@ mlx5_crypto_wqe_set(struct mlx5_crypto_priv *priv, struct rte_crypto_op *op, struct mlx5_umr_wqe *umr) { - struct mlx5_crypto_session *sess = - (void *)op->sym->session->driver_priv_data; + struct mlx5_crypto_session *sess = CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); struct mlx5_wqe_cseg *cseg = &umr->ctr; struct mlx5_wqe_mkey_cseg *mkc = &umr->mkc; struct mlx5_wqe_dseg *klms = &umr->kseg[0]; diff --git a/drivers/crypto/nitrox/nitrox_sym.c b/drivers/crypto/nitrox/nitrox_sym.c index 505024a810..dd8457aaa4 100644 --- a/drivers/crypto/nitrox/nitrox_sym.c +++ b/drivers/crypto/nitrox/nitrox_sym.c @@ -534,7 +534,7 @@ nitrox_sym_dev_sess_configure(struct rte_cryptodev *cdev __rte_unused, struct rte_crypto_sym_xform *xform, struct rte_cryptodev_sym_session *sess) { - struct nitrox_crypto_ctx *ctx = (void *)sess->driver_priv_data; + struct nitrox_crypto_ctx *ctx = CRYPTODEV_GET_SYM_SESS_PRIV(sess); struct rte_crypto_cipher_xform *cipher_xform = NULL; struct rte_crypto_auth_xform *auth_xform = NULL; struct rte_crypto_aead_xform *aead_xform = NULL; @@ -577,7 +577,7 @@ nitrox_sym_dev_sess_configure(struct rte_cryptodev *cdev __rte_unused, goto err; } - ctx->iova = sess->driver_priv_data_iova; + ctx->iova = CRYPTODEV_GET_SYM_SESS_PRIV_IOVA(sess); return 0; err: return ret; @@ -593,7 +593,7 @@ get_crypto_ctx(struct rte_crypto_op *op) { if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { if (likely(op->sym->session)) - return (void *)op->sym->session->driver_priv_data; + return CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); } return NULL; diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c index 09aac3065e..27f750aaca 100644 --- a/drivers/crypto/null/null_crypto_pmd.c +++ b/drivers/crypto/null/null_crypto_pmd.c @@ -77,8 +77,7 @@ get_session(struct null_crypto_qp *qp, struct rte_crypto_op *op) if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { if (likely(sym_op->session != NULL)) - sess = (struct null_crypto_session *) - sym_op->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(sym_op->session); } else { struct rte_cryptodev_sym_session *_sess = NULL; diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c index fb43d3f7b5..f07e9c2ea0 100644 --- a/drivers/crypto/null/null_crypto_pmd_ops.c +++ b/drivers/crypto/null/null_crypto_pmd_ops.c @@ -265,7 +265,7 @@ null_crypto_pmd_sym_session_configure(struct rte_cryptodev *dev __rte_unused, return -EINVAL; } - sess_private_data = (void *)sess->driver_priv_data; + sess_private_data = CRYPTODEV_GET_SYM_SESS_PRIV(sess); ret = null_crypto_set_session_parameters(sess_private_data, xform); if (ret != 0) { diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c index cd5ebc2af6..a5b595c05f 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_ops.c +++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c @@ -248,7 +248,7 @@ sym_session_configure(struct rte_crypto_sym_xform *xform, struct rte_crypto_sym_xform *temp_xform = xform; struct cpt_sess_misc *misc; vq_cmd_word3_t vq_cmd_w3; - void *priv = (void *)sess->driver_priv_data; + void *priv = CRYPTODEV_GET_SYM_SESS_PRIV(sess); int ret; ret = sym_xform_verify(xform); @@ -294,7 +294,7 @@ sym_session_configure(struct rte_crypto_sym_xform *xform, goto priv_put; } - misc->ctx_dma_addr = sess->driver_priv_data_iova + + misc->ctx_dma_addr = CRYPTODEV_GET_SYM_SESS_PRIV_IOVA(sess) + sizeof(struct cpt_sess_misc); vq_cmd_w3.u64 = 0; @@ -313,7 +313,7 @@ sym_session_configure(struct rte_crypto_sym_xform *xform, static void sym_session_clear(struct rte_cryptodev_sym_session *sess) { - void *priv = (void *)sess->driver_priv_data; + void *priv = CRYPTODEV_GET_SYM_SESS_PRIV(sess); struct cpt_sess_misc *misc; struct cpt_ctx *ctx; @@ -507,7 +507,7 @@ otx_cpt_enq_single_sym(struct cpt_instance *instance, void *req; uint64_t cpt_op; - sess = (struct cpt_sess_misc *)sym_op->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(sym_op->session); cpt_op = sess->cpt_op; if (likely(cpt_op & CPT_OP_CIPHER_MASK)) @@ -844,7 +844,7 @@ static inline void free_sym_session_data(const struct cpt_instance *instance, struct rte_crypto_op *cop) { - void *sess_private_data_t = (void *)cop->sym->session->driver_priv_data; + void *sess_private_data_t = CRYPTODEV_GET_SYM_SESS_PRIV(cop->sym->session); memset(sess_private_data_t, 0, cpt_get_session_size()); rte_mempool_put(instance->sess_mp, cop->sym->session); diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 0bb536c9e3..cc8328cd5f 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -887,8 +887,8 @@ get_session(struct openssl_qp *qp, struct rte_crypto_op *op) if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { /* get existing session */ if (likely(op->sym->session != NULL)) - sess = (void *) - op->sym->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV( + op->sym->session); } else { if (likely(op->asym->session != NULL)) asym_sess = (struct openssl_asym_session *) diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index 2a3662ee5a..defed4429e 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -795,7 +795,7 @@ openssl_pmd_sym_session_configure(struct rte_cryptodev *dev __rte_unused, struct rte_crypto_sym_xform *xform, struct rte_cryptodev_sym_session *sess) { - void *sess_private_data = (void *)sess->driver_priv_data; + void *sess_private_data = CRYPTODEV_GET_SYM_SESS_PRIV(sess); int ret; if (unlikely(sess == NULL)) { @@ -1319,7 +1319,7 @@ static void openssl_pmd_sym_session_clear(struct rte_cryptodev *dev __rte_unused, struct rte_cryptodev_sym_session *sess) { - void *sess_priv = (void *)sess->driver_priv_data; + void *sess_priv = CRYPTODEV_GET_SYM_SESS_PRIV(sess); /* Zero out the whole structure */ openssl_reset_session(sess_priv); diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c index 408ae9e42b..d7696822a8 100644 --- a/drivers/crypto/qat/qat_sym.c +++ b/drivers/crypto/qat/qat_sym.c @@ -67,7 +67,7 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg, return -EINVAL; if (likely(op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)) { - ctx = (void *)op->sym->session->driver_priv_data; + ctx = (void *)CRYPTODEV_GET_SYM_SESS_PRIV(op->sym->session); if (sess != (uintptr_t)ctx) { struct rte_cryptodev *cdev; struct qat_cryptodev_private *internals; @@ -386,7 +386,7 @@ qat_sym_configure_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id, if (sess_type != RTE_CRYPTO_OP_WITH_SESSION) return -EINVAL; - ctx = (void *)session_ctx.crypto_sess->driver_priv_data; + ctx = CRYPTODEV_GET_SYM_SESS_PRIV(session_ctx.crypto_sess); dp_ctx->session = ctx; diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h index 2853ac5b88..653df0bf69 100644 --- a/drivers/crypto/qat/qat_sym.h +++ b/drivers/crypto/qat/qat_sym.h @@ -316,8 +316,7 @@ qat_sym_process_response(void **op, uint8_t *resp, void *op_cookie, } else #endif { - sess = (struct qat_sym_session *) - rx_op->sym->session->driver_priv_data; + sess = CRYPTODEV_GET_SYM_SESS_PRIV(rx_op->sym->session); is_docsis_sec = 0; } diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c index 8dd2357702..c6976f2cdd 100644 --- a/drivers/crypto/qat/qat_sym_session.c +++ b/drivers/crypto/qat/qat_sym_session.c @@ -222,7 +222,7 @@ void qat_sym_session_clear(struct rte_cryptodev *dev __rte_unused, struct rte_cryptodev_sym_session *sess) { - struct qat_sym_session *s = (void *)sess->driver_priv_data; + struct qat_sym_session *s = CRYPTODEV_GET_SYM_SESS_PRIV(sess); if (s->bpi_ctx) bpi_cipher_ctx_free(s->bpi_ctx); @@ -505,8 +505,8 @@ qat_sym_session_configure(struct rte_cryptodev *dev, return -EINVAL; #endif ret = qat_sym_session_set_parameters(dev, xform, - (void *)sess->driver_priv_data, - sess->driver_priv_data_iova); + CRYPTODEV_GET_SYM_SESS_PRIV(sess), + CRYPTODEV_GET_SYM_SESS_PRIV_IOVA(sess)); if (ret != 0) { QAT_LOG(ERR, "Crypto QAT PMD: failed to configure session parameters"); diff --git a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c index 9204f6f608..396cc3723d 100644 --- a/drivers/crypto/scheduler/scheduler_pkt_size_distr.c +++ b/drivers/crypto/scheduler/scheduler_pkt_size_distr.c @@ -76,13 +76,10 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops) rte_prefetch0((uint8_t *)ops[i + 7]->sym->session + sizeof(struct rte_cryptodev_sym_session)); - sess_ctx[0] = (void *)ops[i]->sym->session->driver_priv_data; - sess_ctx[1] = - (void *)ops[i + 1]->sym->session->driver_priv_data; - sess_ctx[2] = - (void *)ops[i + 2]->sym->session->driver_priv_data; - sess_ctx[3] = - (void *)ops[i + 3]->sym->session->driver_priv_data; + sess_ctx[0] = CRYPTODEV_GET_SYM_SESS_PRIV(ops[i]->sym->session); + sess_ctx[1] = CRYPTODEV_GET_SYM_SESS_PRIV(ops[i + 1]->sym->session); + sess_ctx[2] = CRYPTODEV_GET_SYM_SESS_PRIV(ops[i + 2]->sym->session); + sess_ctx[3] = CRYPTODEV_GET_SYM_SESS_PRIV(ops[i + 3]->sym->session); /* job_len is initialized as cipher data length, once * it is 0, equals to auth data length @@ -166,7 +163,7 @@ schedule_enqueue(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops) for (; i < nb_ops; i++) { struct scheduler_session_ctx *sess_ctx = - (void *)ops[i]->sym->session->driver_priv_data; + CRYPTODEV_GET_SYM_SESS_PRIV(ops[i]->sym->session); uint32_t job_len; uint8_t target; diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c index 2bc3f5dd27..707bb7d8d1 100644 --- a/drivers/crypto/scheduler/scheduler_pmd_ops.c +++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c @@ -481,7 +481,7 @@ scheduler_pmd_sym_session_configure(struct rte_cryptodev *dev, { struct scheduler_ctx *sched_ctx = dev->data->dev_private; struct rte_mempool *mp = rte_mempool_from_obj(sess); - struct scheduler_session_ctx *sess_ctx = (void *)sess->driver_priv_data; + struct scheduler_session_ctx *sess_ctx = CRYPTODEV_GET_SYM_SESS_PRIV(sess); struct scheduler_configured_sess_info configured_sess[ RTE_CRYPTODEV_SCHEDULER_MAX_NB_WORKERS] = { 0 }; uint32_t i, j, n_configured_sess = 0; @@ -543,7 +543,7 @@ scheduler_pmd_sym_session_clear(struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess) { struct scheduler_ctx *sched_ctx = dev->data->dev_private; - struct scheduler_session_ctx *sess_ctx = (void *)sess->driver_priv_data; + struct scheduler_session_ctx *sess_ctx = CRYPTODEV_GET_SYM_SESS_PRIV(sess); struct scheduler_configured_sess_info deleted_sess[ RTE_CRYPTODEV_SCHEDULER_MAX_NB_WORKERS] = { 0 }; uint32_t i, j, n_deleted_sess = 0; diff --git a/drivers/crypto/scheduler/scheduler_pmd_private.h b/drivers/crypto/scheduler/scheduler_pmd_private.h index 0e508727a4..41be928dc3 100644 --- a/drivers/crypto/scheduler/scheduler_pmd_private.h +++ b/drivers/crypto/scheduler/scheduler_pmd_private.h @@ -131,28 +131,28 @@ scheduler_set_worker_session(struct rte_crypto_op **ops, uint16_t nb_ops, if (op[0]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { struct scheduler_session_ctx *sess_ctx = - (void *)op[0]->sym->session->driver_priv_data; + CRYPTODEV_GET_SYM_SESS_PRIV(op[0]->sym->session); op[0]->sym->session = sess_ctx->worker_sess[worker_index]; } if (op[1]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { struct scheduler_session_ctx *sess_ctx = - (void *)op[1]->sym->session->driver_priv_data; + CRYPTODEV_GET_SYM_SESS_PRIV(op[1]->sym->session); op[1]->sym->session = sess_ctx->worker_sess[worker_index]; } if (op[2]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { struct scheduler_session_ctx *sess_ctx = - (void *)op[2]->sym->session->driver_priv_data; + CRYPTODEV_GET_SYM_SESS_PRIV(op[2]->sym->session); op[2]->sym->session = sess_ctx->worker_sess[worker_index]; } if (op[3]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { struct scheduler_session_ctx *sess_ctx = - (void *)op[3]->sym->session->driver_priv_data; + CRYPTODEV_GET_SYM_SESS_PRIV(op[3]->sym->session); op[3]->sym->session = sess_ctx->worker_sess[worker_index]; } @@ -164,7 +164,7 @@ scheduler_set_worker_session(struct rte_crypto_op **ops, uint16_t nb_ops, while (n--) { if (op[0]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { struct scheduler_session_ctx *sess_ctx = - (void *)op[0]->sym->session->driver_priv_data; + CRYPTODEV_GET_SYM_SESS_PRIV(op[0]->sym->session); op[0]->sym->session = sess_ctx->worker_sess[worker_index]; @@ -195,17 +195,17 @@ scheduler_retrieve_session(struct rte_crypto_op **ops, uint16_t nb_ops) } if (op[0]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) - op[0]->sym->session = - (void *)op[0]->sym->session->opaque_data; + op[0]->sym->session = (void *) + rte_cryptodev_sym_session_opaque_data_get(op[0]->sym->session); if (op[1]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) - op[1]->sym->session = - (void *)op[1]->sym->session->opaque_data; + op[1]->sym->session = (void *) + rte_cryptodev_sym_session_opaque_data_get(op[1]->sym->session); if (op[2]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) - op[2]->sym->session = - (void *)op[2]->sym->session->opaque_data; + op[2]->sym->session = (void *) + rte_cryptodev_sym_session_opaque_data_get(op[2]->sym->session); if (op[3]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) - op[3]->sym->session = - (void *)op[3]->sym->session->opaque_data; + op[3]->sym->session = (void *) + rte_cryptodev_sym_session_opaque_data_get(op[3]->sym->session); op += 4; n -= 4; @@ -213,8 +213,8 @@ scheduler_retrieve_session(struct rte_crypto_op **ops, uint16_t nb_ops) while (n--) { if (op[0]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) - op[0]->sym->session = - (void *)op[0]->sym->session->opaque_data; + op[0]->sym->session = (void *) + rte_cryptodev_sym_session_opaque_data_get(op[0]->sym->session); op++; } } diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c index 6b9e57ee66..f068283290 100644 --- a/drivers/crypto/virtio/virtio_cryptodev.c +++ b/drivers/crypto/virtio/virtio_cryptodev.c @@ -951,7 +951,7 @@ virtio_crypto_sym_clear_session( hw = dev->data->dev_private; vq = hw->cvq; - session = (struct virtio_crypto_session *)sess->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(sess); VIRTIO_CRYPTO_SESSION_LOG_INFO("vq->vq_desc_head_idx = %d, " "vq = %p", vq->vq_desc_head_idx, vq); @@ -1318,7 +1318,7 @@ virtio_crypto_sym_configure_session( VIRTIO_CRYPTO_SESSION_LOG_ERR("Invalid parameters"); return ret; } - session = (struct virtio_crypto_session *)sess->driver_priv_data; + session = CRYPTODEV_GET_SYM_SESS_PRIV(sess); memset(session, 0, sizeof(struct virtio_crypto_session)); ctrl_req = &session->ctrl; ctrl_req->header.opcode = VIRTIO_CRYPTO_CIPHER_CREATE_SESSION; diff --git a/drivers/crypto/virtio/virtio_rxtx.c b/drivers/crypto/virtio/virtio_rxtx.c index b7f492a7f2..48b5f4ebbb 100644 --- a/drivers/crypto/virtio/virtio_rxtx.c +++ b/drivers/crypto/virtio/virtio_rxtx.c @@ -207,7 +207,7 @@ virtqueue_crypto_sym_enqueue_xmit( offsetof(struct virtio_crypto_op_cookie, iv); struct rte_crypto_sym_op *sym_op = cop->sym; struct virtio_crypto_session *session = - (void *)cop->sym->session->driver_priv_data; + CRYPTODEV_GET_SYM_SESS_PRIV(cop->sym->session); struct virtio_crypto_op_data_req *op_data_req; uint32_t hash_result_len = 0; struct virtio_crypto_op_cookie *crypto_op_cookie; diff --git a/examples/fips_validation/fips_dev_self_test.c b/examples/fips_validation/fips_dev_self_test.c index bce903e007..b17f664a5e 100644 --- a/examples/fips_validation/fips_dev_self_test.c +++ b/examples/fips_validation/fips_dev_self_test.c @@ -980,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 *, @@ -1172,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) { @@ -1211,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) { @@ -1250,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) { @@ -1462,7 +1462,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; diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h index f518a0f89b..bf10364b66 100644 --- a/lib/cryptodev/cryptodev_pmd.h +++ b/lib/cryptodev/cryptodev_pmd.h @@ -132,6 +132,38 @@ struct cryptodev_driver { uint8_t id; }; +/** Cryptodev symmetric crypto session + * Each session is derived from a fixed xform chain. Therefore each session + * has a fixed algo, key, op-type, digest_len etc. + */ +struct rte_cryptodev_sym_session { + RTE_MARKER cacheline0; + uint64_t opaque_data; + /**< Can be used for external metadata */ + uint32_t sess_data_sz; + /**< Pointer to the user data stored after sess data */ + uint16_t user_data_sz; + /**< Session user data will be placed after sess data */ + uint8_t driver_id; + /**< Driver id to get the session priv */ + rte_iova_t driver_priv_data_iova; + /**< Session driver data IOVA address */ + + RTE_MARKER cacheline1 __rte_cache_min_aligned; + /**< Second cache line - start of the driver session data */ + uint8_t driver_priv_data[0]; + /**< Driver specific session data, variable size */ +}; + +/** + * Helper macro to get driver private data + */ +#define CRYPTODEV_GET_SYM_SESS_PRIV(s) \ + ((void *)(((struct rte_cryptodev_sym_session *)s)->driver_priv_data)) +#define CRYPTODEV_GET_SYM_SESS_PRIV_IOVA(s) \ + (((struct rte_cryptodev_sym_session *)s)->driver_priv_data_iova) + + /** * Get the rte_cryptodev structure device pointer for the device. Assumes a * valid device index. diff --git a/lib/cryptodev/rte_crypto.h b/lib/cryptodev/rte_crypto.h index 6dfca2c169..f9644d29ec 100644 --- a/lib/cryptodev/rte_crypto.h +++ b/lib/cryptodev/rte_crypto.h @@ -430,8 +430,7 @@ rte_crypto_op_sym_xforms_alloc(struct rte_crypto_op *op, uint8_t nb_xforms) * @param sess cryptodev session */ static inline int -rte_crypto_op_attach_sym_session(struct rte_crypto_op *op, - struct rte_cryptodev_sym_session *sess) +rte_crypto_op_attach_sym_session(struct rte_crypto_op *op, 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..84deecac48 100644 --- a/lib/cryptodev/rte_crypto_sym.h +++ b/lib/cryptodev/rte_crypto_sym.h @@ -580,8 +580,6 @@ struct rte_crypto_sym_xform { }; }; -struct rte_cryptodev_sym_session; - /** * Symmetric Cryptographic Operation. * @@ -618,7 +616,7 @@ struct rte_crypto_sym_op { RTE_STD_C11 union { - struct rte_cryptodev_sym_session *session; + void *session; /**< Handle for the initialised session context */ struct rte_crypto_sym_xform *xform; /**< Session-less API crypto operation parameters */ @@ -923,8 +921,7 @@ __rte_crypto_sym_op_sym_xforms_alloc(struct rte_crypto_sym_op *sym_op, * @param sess cryptodev session */ static inline int -__rte_crypto_sym_op_attach_sym_session(struct rte_crypto_sym_op *sym_op, - struct rte_cryptodev_sym_session *sess) +__rte_crypto_sym_op_attach_sym_session(struct rte_crypto_sym_op *sym_op, void *sess) { sym_op->session = sess; diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index a326eb0e17..9ec015df8a 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -1950,11 +1950,11 @@ rte_cryptodev_asym_session_create(uint8_t dev_id, } int -rte_cryptodev_sym_session_free(uint8_t dev_id, - struct rte_cryptodev_sym_session *sess) +rte_cryptodev_sym_session_free(uint8_t dev_id, void *_sess) { struct rte_cryptodev *dev; struct rte_mempool *sess_mp; + struct rte_cryptodev_sym_session *sess = _sess; struct rte_cryptodev_sym_session_pool_private_data *pool_priv; if (sess == NULL) @@ -2069,10 +2069,11 @@ rte_cryptodev_asym_get_private_session_size(uint8_t dev_id) } int -rte_cryptodev_sym_session_set_user_data( - struct rte_cryptodev_sym_session *sess, void *data, +rte_cryptodev_sym_session_set_user_data(void *_sess, void *data, uint16_t size) { + struct rte_cryptodev_sym_session *sess = _sess; + if (sess == NULL) return -EINVAL; @@ -2084,8 +2085,10 @@ rte_cryptodev_sym_session_set_user_data( } void * -rte_cryptodev_sym_session_get_user_data(struct rte_cryptodev_sym_session *sess) +rte_cryptodev_sym_session_get_user_data(void *_sess) { + struct rte_cryptodev_sym_session *sess = _sess; + if (sess == NULL || sess->user_data_sz == 0) return NULL; @@ -2129,10 +2132,11 @@ sym_crypto_fill_status(struct rte_crypto_sym_vec *vec, int32_t errnum) uint32_t rte_cryptodev_sym_cpu_crypto_process(uint8_t dev_id, - struct rte_cryptodev_sym_session *sess, union rte_crypto_sym_ofs ofs, + void *_sess, union rte_crypto_sym_ofs ofs, struct rte_crypto_sym_vec *vec) { struct rte_cryptodev *dev; + struct rte_cryptodev_sym_session *sess = _sess; if (!rte_cryptodev_is_valid_dev(dev_id)) { sym_crypto_fill_status(vec, EINVAL); diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index 0c65958f25..8b6a7a5c1d 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -902,28 +902,6 @@ struct rte_cryptodev_cb_rcu { void * rte_cryptodev_get_sec_ctx(uint8_t dev_id); -/** Cryptodev symmetric crypto session - * Each session is derived from a fixed xform chain. Therefore each session - * has a fixed algo, key, op-type, digest_len etc. - */ -struct rte_cryptodev_sym_session { - RTE_MARKER cacheline0; - uint8_t driver_id; - uint64_t opaque_data; - /**< Can be used for external metadata */ - uint32_t sess_data_sz; - /**< Pointer to the user data stored after sess data */ - uint16_t user_data_sz; - /**< session user data will be placed after sess data */ - rte_iova_t driver_priv_data_iova; - /**< session driver data IOVA address */ - - RTE_MARKER cacheline1 __rte_cache_min_aligned; - /**< second cache line - start of the driver session data */ - uint8_t driver_priv_data[0]; - /**< Driver specific session data, variable size */ -}; - /** * Create a symmetric session mempool. * @@ -1036,7 +1014,7 @@ rte_cryptodev_asym_session_create(uint8_t dev_id, */ int rte_cryptodev_sym_session_free(uint8_t dev_id, - struct rte_cryptodev_sym_session *sess); + void *sess); /** * Clears and frees asymmetric crypto session header and private data, @@ -1136,11 +1114,31 @@ const char *rte_cryptodev_driver_name_get(uint8_t driver_id); */ __rte_experimental int -rte_cryptodev_sym_session_set_user_data( - struct rte_cryptodev_sym_session *sess, +rte_cryptodev_sym_session_set_user_data(void *sess, void *data, uint16_t size); +#define CRYPTO_SESS_OPAQUE_DATA_OFF 0 +/** + * Get opaque data from session handle + */ +static inline uint64_t +rte_cryptodev_sym_session_opaque_data_get(void *sess) +{ + return *((uint64_t *)sess + CRYPTO_SESS_OPAQUE_DATA_OFF); +} + +/** + * Set opaque data in session handle + */ +static inline void +rte_cryptodev_sym_session_opaque_data_set(void *sess, uint64_t opaque) +{ + uint64_t *data; + data = (((uint64_t *)sess) + CRYPTO_SESS_OPAQUE_DATA_OFF); + *data = opaque; +} + /** * Get user data stored in a session. * @@ -1153,8 +1151,7 @@ rte_cryptodev_sym_session_set_user_data( */ __rte_experimental void * -rte_cryptodev_sym_session_get_user_data( - struct rte_cryptodev_sym_session *sess); +rte_cryptodev_sym_session_get_user_data(void *sess); /** * Store user data in an asymmetric session. @@ -1202,7 +1199,7 @@ rte_cryptodev_asym_session_get_user_data(void *sess); __rte_experimental uint32_t rte_cryptodev_sym_cpu_crypto_process(uint8_t dev_id, - struct rte_cryptodev_sym_session *sess, union rte_crypto_sym_ofs ofs, + void *sess, union rte_crypto_sym_ofs ofs, struct rte_crypto_sym_vec *vec); /** @@ -1244,8 +1241,7 @@ rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess, * Union of different crypto session types, including session-less xform * pointer. */ -union rte_cryptodev_session_ctx { - struct rte_cryptodev_sym_session *crypto_sess; +union rte_cryptodev_session_ctx {void *crypto_sess; struct rte_crypto_sym_xform *xform; struct rte_security_session *sec_sess; }; diff --git a/lib/cryptodev/rte_cryptodev_trace.h b/lib/cryptodev/rte_cryptodev_trace.h index 055c44fb22..7b4ec5c389 100644 --- a/lib/cryptodev/rte_cryptodev_trace.h +++ b/lib/cryptodev/rte_cryptodev_trace.h @@ -73,14 +73,10 @@ RTE_TRACE_POINT( RTE_TRACE_POINT( rte_cryptodev_trace_sym_session_create, - RTE_TRACE_POINT_ARGS(uint8_t dev_id, - struct rte_cryptodev_sym_session *sess, void *xforms, + RTE_TRACE_POINT_ARGS(uint8_t dev_id, void *sess, void *xforms, void *mempool), 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_u8(sess->driver_id); - rte_trace_point_emit_u16(sess->user_data_sz); rte_trace_point_emit_ptr(xforms); rte_trace_point_emit_ptr(mempool); ) @@ -108,7 +104,7 @@ RTE_TRACE_POINT( RTE_TRACE_POINT( rte_cryptodev_trace_sym_session_free, - RTE_TRACE_POINT_ARGS(struct rte_cryptodev_sym_session *sess), + RTE_TRACE_POINT_ARGS(void *sess), rte_trace_point_emit_ptr(sess); ) diff --git a/lib/ipsec/rte_ipsec_group.h b/lib/ipsec/rte_ipsec_group.h index 62c2bd7217..a4e0e128f8 100644 --- a/lib/ipsec/rte_ipsec_group.h +++ b/lib/ipsec/rte_ipsec_group.h @@ -45,14 +45,15 @@ static inline struct rte_ipsec_session * rte_ipsec_ses_from_crypto(const struct rte_crypto_op *cop) { const struct rte_security_session *ss; - const struct rte_cryptodev_sym_session *cs; + void *cs; if (cop->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) { ss = cop->sym[0].sec_session; return (struct rte_ipsec_session *)(uintptr_t)ss->opaque_data; } else if (cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { cs = cop->sym[0].session; - return (struct rte_ipsec_session *)(uintptr_t)cs->opaque_data; + return (struct rte_ipsec_session *)(uintptr_t) + rte_cryptodev_sym_session_opaque_data_get(cs); } return NULL; } diff --git a/lib/ipsec/ses.c b/lib/ipsec/ses.c index 3d51ac4986..0d3c932302 100644 --- a/lib/ipsec/ses.c +++ b/lib/ipsec/ses.c @@ -45,7 +45,8 @@ rte_ipsec_session_prepare(struct rte_ipsec_session *ss) ss->pkt_func = fp; if (ss->type == RTE_SECURITY_ACTION_TYPE_NONE) - ss->crypto.ses->opaque_data = (uintptr_t)ss; + rte_cryptodev_sym_session_opaque_data_set(ss->crypto.ses, + (uintptr_t)ss); else ss->security.ses->opaque_data = (uintptr_t)ss; -- 2.25.1