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 82E55A00C4; Mon, 18 Apr 2022 21:33:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE45640C35; Mon, 18 Apr 2022 21:33:41 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 0431440C35 for ; Mon, 18 Apr 2022 21:33:39 +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 ESMTP id 23ICP6de000468; Mon, 18 Apr 2022 12:33:39 -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=oX+qJpE7mopWgYtpNx9Je3XqRih3t3IWKv3BzjtihA4=; b=C3J1W4hl9Ceior4fAiRoaC6K5qg+m9186YJq2eDe27yhUUY+DtwuFI1/t8jWuC/4h3jk fTPTN8ER1FuAKRAEP1pv7a2t58HuAJK0uP4LzlO9qt85yw8RbxpGxIQpiQVRRSA4VGK5 Vf3UKF+TSswYgVJzcCWs/Zz6ldQ2v0Fq5qI6OIt/rTbYR8TQTQ5RPS18BIcFrr5bxclH YmHZEOS/u9fXbClILnaRuL+/os+UIAfa9OrWgxS5+9LK01RUih5hpnI4kpxE/psIiNHt 3lL51BwDjrZLNi/nZ/zBzU+6UglP5kCINp+E/WaK8N4ZihMWhEKoo7/JuuecbASwYIgS 7w== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ffu5pgh0v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 12:33:38 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 18 Apr 2022 12:33:37 -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.2 via Frontend Transport; Mon, 18 Apr 2022 12:33:37 -0700 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id B557E5B6942; Mon, 18 Apr 2022 12:33:34 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , Akhil Goyal Subject: [PATCH v2 1/7] cryptodev: add APIs to get/set event metadata Date: Tue, 19 Apr 2022 01:03:19 +0530 Message-ID: <20220418193325.368313-2-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220418193325.368313-1-gakhil@marvell.com> References: <20220325111615.1118946-1-vfialko@marvell.com> <20220418193325.368313-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: S7kButI6ILWZMpzGfzsIcNJUzPyohQZF X-Proofpoint-ORIG-GUID: S7kButI6ILWZMpzGfzsIcNJUzPyohQZF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-18_02,2022-04-15_01,2022-02-23_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 From: Volodymyr Fialko Currently, crypto session userdata is used to set event crypto metadata from the application and the driver is dereferencing it in driver which is not correct. User data is meant to be opaque to the driver. To support this, new API is added to get and set event crypto metadata. The new API, rte_cryptodev_set_session_event_mdata, allows setting event metadata in session private data which is filled inside PMD using a new cryptodev op. This operation can be performed on any of the PMD supported sessions (sym/asym/security). For SW abstraction of event crypto adapter to be used by eventdev library, a new field is added in asymmetric crypto session for now and for symmetric case, current implementation of using userdata is used. Symmetric cases cannot be fixed now, as it will be ABI breakage which will be resolved in DPDK 22.11. Signed-off-by: Volodymyr Fialko Signed-off-by: Akhil Goyal --- lib/cryptodev/cryptodev_pmd.h | 23 ++++++++++++++++ lib/cryptodev/rte_cryptodev.c | 52 +++++++++++++++++++++++++++++++++++ lib/cryptodev/rte_cryptodev.h | 34 +++++++++++++++++++++++ lib/cryptodev/version.map | 4 +++ 4 files changed, 113 insertions(+) diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h index 2b1ce2da2d..f374b6c880 100644 --- a/lib/cryptodev/cryptodev_pmd.h +++ b/lib/cryptodev/cryptodev_pmd.h @@ -398,6 +398,25 @@ typedef int (*cryptodev_sym_configure_raw_dp_ctx_t)( enum rte_crypto_op_sess_type sess_type, union rte_cryptodev_session_ctx session_ctx, uint8_t is_update); +/** + * Typedef that the driver provided to set event crypto meta data. + * + * @param dev Crypto device pointer. + * @param sess Crypto or security session. + * @param op_type Operation type. + * @param sess_type Session type. + * @param ev_mdata Pointer to the event crypto meta data + * (aka *union rte_event_crypto_metadata*) + * @return + * - On success return 0. + * - On failure return negative integer. + */ +typedef int (*cryptodev_session_event_mdata_set_t)( + struct rte_cryptodev *dev, void *sess, + enum rte_crypto_op_type op_type, + enum rte_crypto_op_sess_type sess_type, + void *ev_mdata); + /** Crypto device operations function pointer table */ struct rte_cryptodev_ops { cryptodev_configure_t dev_configure; /**< Configure device. */ @@ -442,6 +461,8 @@ struct rte_cryptodev_ops { /**< Initialize raw data path context data. */ }; }; + cryptodev_session_event_mdata_set_t session_ev_mdata_set; + /**< Set a Crypto or Security session even meta data. */ }; @@ -636,6 +657,8 @@ RTE_STD_C11 struct rte_cryptodev_asym_session { /**< Size of private data used when creating mempool */ uint16_t user_data_sz; /**< Session user data will be placed after sess_data */ + void *event_mdata; + /**< Event crypto adapter metadata */ uint8_t padding[3]; uint8_t sess_private_data[0]; }; diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 3500a2d470..9ea64bc4f0 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -2259,6 +2259,58 @@ rte_cryptodev_configure_raw_dp_ctx(uint8_t dev_id, uint16_t qp_id, sess_type, session_ctx, is_update); } +int +rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess, + enum rte_crypto_op_type op_type, + enum rte_crypto_op_sess_type sess_type, + void *ev_mdata) +{ + struct rte_cryptodev *dev; + + if (!rte_cryptodev_is_valid_dev(dev_id)) + goto skip_pmd_op; + + dev = rte_cryptodev_pmd_get_dev(dev_id); + if (dev->dev_ops->session_ev_mdata_set == NULL) + goto skip_pmd_op; + + return (*dev->dev_ops->session_ev_mdata_set)(dev, sess, op_type, + sess_type, ev_mdata); + +skip_pmd_op: +#define EVENT_CRYPTO_MDATA_SZ 16 +/**< + * sizeof(union rte_event_crypto_metadata). To be removed when event_mdata is + * added in rte_cryptodev_sym_session + */ + + if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) + return rte_cryptodev_sym_session_set_user_data(sess, ev_mdata, + EVENT_CRYPTO_MDATA_SZ); + else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) { + ((struct rte_cryptodev_asym_session *)sess)->event_mdata = + ev_mdata; + return 0; + } else + return -ENOTSUP; +} + +void * +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op) +{ + if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC && + op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) + return rte_cryptodev_sym_session_get_user_data(op->sym->session); + else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC && + op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) + return op->asym->session->event_mdata; + else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS && + op->private_data_offset) + return ((uint8_t *)op + op->private_data_offset); + else + return NULL; +} + uint32_t rte_cryptodev_raw_enqueue_burst(struct rte_crypto_raw_dp_ctx *ctx, struct rte_crypto_sym_vec *vec, union rte_crypto_sym_ofs ofs, diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index 45d33f4a50..b3ddc41ab1 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -1269,6 +1269,40 @@ __rte_experimental int rte_cryptodev_get_raw_dp_ctx_size(uint8_t dev_id); +/** + * Set session event meta data + * + * @param dev_id The device identifier. + * @param sess Crypto or security session. + * @param op_type Operation type. + * @param sess_type Session type. + * @param ev_mdata Pointer to the event crypto meta data + * (aka *union rte_event_crypto_metadata*) + * + * @return + * - On success, zero. + * - On failure, a negative value. + */ +__rte_experimental +int +rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess, + enum rte_crypto_op_type op_type, + enum rte_crypto_op_sess_type sess_type, + void *ev_mdata); + +/** + * Get session event meta data (aka *union rte_event_crypto_metadata*) + * + * @param op pointer to *rte_crypto_op* structure. + * + * @return + * - On success, pointer to event crypto metadata + * - On failure, a negative value. + */ +__rte_experimental +void * +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op); + /** * Union of different crypto session types, including session-less xform * pointer. diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map index c7c5aefceb..b8a23a1791 100644 --- a/lib/cryptodev/version.map +++ b/lib/cryptodev/version.map @@ -105,6 +105,10 @@ EXPERIMENTAL { rte_cryptodev_asym_session_pool_create; rte_cryptodev_asym_session_set_user_data; __rte_cryptodev_trace_asym_session_pool_create; + + #added in 22.07 + rte_cryptodev_session_event_mdata_get; + rte_cryptodev_session_event_mdata_set; }; INTERNAL { -- 2.25.1