From patchwork Wed Oct 13 19:22:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 101507 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 91535A0C55; Wed, 13 Oct 2021 21:23:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B541341289; Wed, 13 Oct 2021 21:23:25 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id C9B164111B for ; Wed, 13 Oct 2021 21:23:24 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19DIqQjb000951; Wed, 13 Oct 2021 12:23:14 -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=Zo20bGgglPlk37w8IhQonvWQmXL1DMHwizF6NJWdJEU=; b=glu7DKeLZmlzrZ6iHO7Y9sqXHu1E77gUaAHvSGA8qrgyX14jVDsQQ54A2d8XLQvGolr/ 3fqdYDicCZMGAhQKGn7T7MAJMHUHYWK8txWRnmgm3FkySUCBzzuZkX+4UUawiVC3nLI3 MnzwFq49lr+1ztmiDzP8GedILWNhoSL8TwCDcJvb8OtWKyjzax7rwFoipAKSxws6Lc1N /co5hErr9RtM5o+z7PibNaSHWTThV5LcrAAKlcJLzOIlDpQaIFIJoK5aIS8LG7m/462x CTH6AiqyIQFNnvx/ADptBWFZAZyVgovxPyYa/YU9z3XCoM+PavxSlIG0HWMtyXqm3nhv YA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3bnwrxjgfm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 13 Oct 2021 12:23:14 -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; Wed, 13 Oct 2021 12:23:12 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Wed, 13 Oct 2021 12:23:12 -0700 Received: from localhost.localdomain (unknown [10.28.36.185]) by maili.marvell.com (Postfix) with ESMTP id 88A583F7082; Wed, 13 Oct 2021 12:23:06 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , , , , , , , , , , , , , , Akhil Goyal Date: Thu, 14 Oct 2021 00:52:21 +0530 Message-ID: <20211013192222.1582631-7-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211013192222.1582631-1-gakhil@marvell.com> References: <20210930145014.2476799-1-gakhil@marvell.com> <20211013192222.1582631-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 4ji-l7YUWjoZoOtGvvF02E6qXiyB5YJ8 X-Proofpoint-GUID: 4ji-l7YUWjoZoOtGvvF02E6qXiyB5YJ8 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-13_07,2021-10-13_02,2020-04-07_01 Subject: [dpdk-dev] [PATCH v2 6/7] cryptodev: hide sym session structure 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" 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 --- app/test/test_ipsec_perf.c | 4 +-- lib/cryptodev/cryptodev_pmd.h | 22 +++++++++++++ lib/cryptodev/rte_cryptodev.c | 11 ++++--- lib/cryptodev/rte_cryptodev.h | 51 ++++++++++++++--------------- lib/cryptodev/rte_cryptodev_trace.h | 13 ++------ lib/ipsec/rte_ipsec.h | 2 +- lib/ipsec/rte_ipsec_group.h | 12 +++---- lib/ipsec/ses.c | 3 +- 8 files changed, 67 insertions(+), 51 deletions(-) diff --git a/app/test/test_ipsec_perf.c b/app/test/test_ipsec_perf.c index 92106bf374..7e1cc7b920 100644 --- a/app/test/test_ipsec_perf.c +++ b/app/test/test_ipsec_perf.c @@ -215,7 +215,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; + static uint64_t dummy_ses[10]; size_t sz; int rc; @@ -235,7 +235,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/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h index 94f427a912..8d2a15d495 100644 --- a/lib/cryptodev/cryptodev_pmd.h +++ b/lib/cryptodev/cryptodev_pmd.h @@ -589,6 +589,28 @@ void cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops, const struct rte_cryptodev *dev); +/** + * @internal + * 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 { + uint64_t opaque_data; + /**< Can be used for external metadata */ + uint16_t nb_drivers; + /**< 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; + } sess_data[0]; + /**< Driver specific session material, variable size */ +}; + static inline void * get_sym_session_private_data(const struct rte_cryptodev_sym_session *sess, uint8_t driver_id) { diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 6d3390ad03..d516a444c6 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -2142,11 +2142,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, +rte_cryptodev_sym_session_set_user_data(void *session, void *data, uint16_t size) { + struct rte_cryptodev_sym_session *sess = session; if (sess == NULL) return -EINVAL; @@ -2158,9 +2158,9 @@ 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 *session) { + struct rte_cryptodev_sym_session *sess = session; if (sess == NULL || sess->user_data_sz == 0) return NULL; @@ -2177,9 +2177,10 @@ 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 *session, union rte_crypto_sym_ofs ofs, struct rte_crypto_sym_vec *vec) { + struct rte_cryptodev_sym_session *sess = session; struct rte_cryptodev *dev; if (!rte_cryptodev_is_valid_dev(dev_id)) { diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index 78c7ca3e20..17e105105b 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -897,26 +897,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 { - uint64_t opaque_data; - /**< Can be used for external metadata */ - uint16_t nb_drivers; - /**< 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; - } sess_data[0]; - /**< Driver specific session material, variable size */ -}; - /** Cryptodev asymmetric crypto session */ struct rte_cryptodev_asym_session { __extension__ void *sess_private_data[0]; @@ -1194,8 +1174,7 @@ 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); @@ -1211,8 +1190,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); /** * Perform actual crypto processing (encrypt/digest or auth/decrypt) @@ -1229,7 +1207,7 @@ rte_cryptodev_sym_session_get_user_data( __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); /** @@ -1250,11 +1228,32 @@ rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id); * pointer. */ union rte_cryptodev_session_ctx { - struct rte_cryptodev_sym_session *crypto_sess; + void *crypto_sess; struct rte_crypto_sym_xform *xform; struct rte_security_session *sec_sess; }; +#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; +} + /** * Enqueue a vectorized operation descriptor into the device queue but the * driver may or may not start processing until rte_cryptodev_raw_enqueue_done() diff --git a/lib/cryptodev/rte_cryptodev_trace.h b/lib/cryptodev/rte_cryptodev_trace.h index 44da04c425..7d0e3773e6 100644 --- a/lib/cryptodev/rte_cryptodev_trace.h +++ b/lib/cryptodev/rte_cryptodev_trace.h @@ -73,13 +73,9 @@ RTE_TRACE_POINT( RTE_TRACE_POINT( rte_cryptodev_trace_sym_session_create, - RTE_TRACE_POINT_ARGS(void *mempool, - struct rte_cryptodev_sym_session *sess), + RTE_TRACE_POINT_ARGS(void *mempool, void *sess), rte_trace_point_emit_ptr(mempool); 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( @@ -92,7 +88,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); ) @@ -105,12 +101,9 @@ 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 *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); ) diff --git a/lib/ipsec/rte_ipsec.h b/lib/ipsec/rte_ipsec.h index 50d8e5098d..d54a64c4aa 100644 --- a/lib/ipsec/rte_ipsec.h +++ b/lib/ipsec/rte_ipsec.h @@ -66,7 +66,7 @@ struct rte_ipsec_session { /** session and related data */ union { struct { - struct rte_cryptodev_sym_session *ses; + void *ses; uint8_t dev_id; } crypto; struct { diff --git a/lib/ipsec/rte_ipsec_group.h b/lib/ipsec/rte_ipsec_group.h index 0cc5fedbf1..e27d4e6f4c 100644 --- a/lib/ipsec/rte_ipsec_group.h +++ b/lib/ipsec/rte_ipsec_group.h @@ -44,16 +44,16 @@ struct rte_ipsec_group { static inline struct rte_ipsec_session * rte_ipsec_ses_from_crypto(const struct rte_crypto_op *cop) { - void *ss; - const struct rte_cryptodev_sym_session *cs; + void *ses; if (cop->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) { - ss = cop->sym[0].sec_session; + ses = cop->sym[0].sec_session; return (void *)(uintptr_t) - rte_security_session_opaque_data_get(ss); + rte_security_session_opaque_data_get(ses); } else if (cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { - cs = cop->sym[0].session; - return (void *)(uintptr_t)cs->opaque_data; + ses = cop->sym[0].session; + return (void *)(uintptr_t) + rte_cryptodev_sym_session_opaque_data_get(ses); } return NULL; } diff --git a/lib/ipsec/ses.c b/lib/ipsec/ses.c index b12114269f..bfd3cbf1d3 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 rte_security_session_opaque_data_set(ss->security.ses, (uintptr_t)ss);