From patchwork Mon Apr 18 19:33:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 109778 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 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 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 { From patchwork Mon Apr 18 19:33:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 109779 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 BB39BA00C4; Mon, 18 Apr 2022 21:33:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D0A9427E9; Mon, 18 Apr 2022 21:33:44 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id D0AD341156 for ; Mon, 18 Apr 2022 21:33:42 +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 23ICOkDK032074; Mon, 18 Apr 2022 12:33:41 -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=157/fBHC3dSX+QjBCLWXtcDf4/tL0SnGQ3e0q1dVzh4=; b=d1DWyi7edC0eE7wJUI0bekc6aunP3dqOKJ6gt7m7BIsszZOGhWL1vJCQETPQspYA5c6k 6+YTPw8UOK1Fh9ZUgtqgM4K+oXEoqjTb1fx25blOc7FuO1OZM2UedfMvg3KRiOLCTroL kCSH85nbCYvdEduFXP+OjjzlgI86lNSn9mm//92YEP6RDE0yORv6jkP7kd0yhpAX8FtZ ki9Iv1wNeHYOZFTgZ4m44W0SECqTKSURKSAWxxplB1tJGqOLppXY8AB9pEMa2YAEIbbm Fw3zFKtHRX7ctUbduqseh8gyVq3cM4MXsuy+PV5G7WQNsBmn5eAvimJ3ZJhr9M2j8jcL 5w== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ffu5pgh14-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 12:33:41 -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.2; Mon, 18 Apr 2022 12:33:40 -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:40 -0700 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id 9D48D5B6940; Mon, 18 Apr 2022 12:33:37 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , Akhil Goyal Subject: [PATCH v2 2/7] crypto/cnxk: add event metadata set operation Date: Tue, 19 Apr 2022 01:03:20 +0530 Message-ID: <20220418193325.368313-3-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 X-Proofpoint-GUID: zqAEtipz1HGNhC_Qz5JxwONMPNKhT0ZL X-Proofpoint-ORIG-GUID: zqAEtipz1HGNhC_Qz5JxwONMPNKhT0ZL 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 Added cryptodev operation for setting event crypto metadata for all supported sessions - sym/asym/security. Signed-off-by: Volodymyr Fialko Signed-off-by: Akhil Goyal --- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 144 +++++++++++++++++++--- drivers/crypto/cnxk/cn10k_ipsec.h | 2 + drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 138 ++++++++++++++++++--- drivers/crypto/cnxk/cn9k_ipsec.h | 2 + drivers/crypto/cnxk/cnxk_ae.h | 2 + drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 18 --- drivers/crypto/cnxk/cnxk_se.h | 2 + 7 files changed, 255 insertions(+), 53 deletions(-) diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c index c4d5d039ec..08a4df1474 100644 --- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c @@ -264,30 +264,136 @@ cn10k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops) return count + i; } -uint16_t -cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op) +static int +cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused, + void *sess, + enum rte_crypto_op_type op_type, + enum rte_crypto_op_sess_type sess_type, + void *mdata) { - union rte_event_crypto_metadata *ec_mdata; - struct cpt_inflight_req *infl_req; + union rte_event_crypto_metadata *ec_mdata = mdata; struct rte_event *rsp_info; - uint64_t lmt_base, lmt_arg; - struct cpt_inst_s *inst; struct cnxk_cpt_qp *qp; uint8_t cdev_id; - uint16_t lmt_id; - uint16_t qp_id; - int ret; - - ec_mdata = cnxk_event_crypto_mdata_get(op); - if (!ec_mdata) { - rte_errno = EINVAL; - return 0; - } + int16_t qp_id; + uint64_t w2; + /* Get queue pair */ cdev_id = ec_mdata->request_info.cdev_id; qp_id = ec_mdata->request_info.queue_pair_id; qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id]; + + /* Prepare w2 */ rsp_info = &ec_mdata->response_info; + w2 = CNXK_CPT_INST_W2( + (RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id, + rsp_info->sched_type, rsp_info->queue_id, 0); + + /* Set meta according to session type */ + if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { + if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) { + struct cn10k_sec_session *priv; + struct cn10k_ipsec_sa *sa; + + priv = get_sec_session_private_data(sess); + sa = &priv->sa; + sa->qp = qp; + sa->inst.w2 = w2; + } else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + struct cnxk_se_sess *priv; + + priv = get_sym_session_private_data( + sess, cn10k_cryptodev_driver_id); + priv->qp = qp; + priv->cpt_inst_w2 = w2; + } else + return -EINVAL; + } else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) { + if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + struct rte_cryptodev_asym_session *asym_sess = sess; + struct cnxk_ae_sess *priv; + + priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data; + priv->qp = qp; + priv->cpt_inst_w2 = w2; + } else + return -EINVAL; + } else + return -EINVAL; + + return 0; +} + +static inline int +cn10k_ca_meta_info_extract(struct rte_crypto_op *op, + struct cnxk_cpt_qp **qp, uint64_t *w2) +{ + if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { + if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) { + struct cn10k_sec_session *priv; + struct cn10k_ipsec_sa *sa; + + priv = get_sec_session_private_data(op->sym->sec_session); + sa = &priv->sa; + *qp = sa->qp; + *w2 = sa->inst.w2; + } else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + struct cnxk_se_sess *priv; + + priv = get_sym_session_private_data( + op->sym->session, cn10k_cryptodev_driver_id); + *qp = priv->qp; + *w2 = priv->cpt_inst_w2; + } else { + union rte_event_crypto_metadata *ec_mdata; + struct rte_event *rsp_info; + uint8_t cdev_id; + uint16_t qp_id; + + ec_mdata = (union rte_event_crypto_metadata*) + ((uint8_t *)op + op->private_data_offset); + if (!ec_mdata) + return -EINVAL; + rsp_info = &ec_mdata->response_info; + cdev_id = ec_mdata->request_info.cdev_id; + qp_id = ec_mdata->request_info.queue_pair_id; + *qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id]; + *w2 = CNXK_CPT_INST_W2( + (RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id, + rsp_info->sched_type, rsp_info->queue_id, 0); + } + } else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) { + if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + struct rte_cryptodev_asym_session *asym_sess; + struct cnxk_ae_sess *priv; + + asym_sess = op->asym->session; + priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data; + *qp = priv->qp; + *w2 = priv->cpt_inst_w2; + } else + return -EINVAL; + } else + return -EINVAL; + + return 0; +} + +uint16_t +cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op) +{ + struct cpt_inflight_req *infl_req; + uint64_t lmt_base, lmt_arg, w2; + struct cpt_inst_s *inst; + struct cnxk_cpt_qp *qp; + uint16_t lmt_id; + int ret; + + ret = cn10k_ca_meta_info_extract(op, &qp, &w2); + if (unlikely(ret)) { + rte_errno = EINVAL; + return 0; + } if (unlikely(!qp->ca.enabled)) { rte_errno = EINVAL; @@ -316,9 +422,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op) infl_req->qp = qp; inst->w0.u64 = 0; inst->res_addr = (uint64_t)&infl_req->res; - inst->w2.u64 = CNXK_CPT_INST_W2( - (RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id, - rsp_info->sched_type, rsp_info->queue_id, 0); + inst->w2.u64 = w2; inst->w3.u64 = CNXK_CPT_INST_W3(1, infl_req); if (roc_cpt_is_iq_full(&qp->lf)) { @@ -327,7 +431,7 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op) return 0; } - if (!rsp_info->sched_type) + if (inst->w2.s.tt == RTE_SCHED_TYPE_ORDERED) roc_sso_hws_head_wait(tag_op); lmt_arg = ROC_CN10K_CPT_LMT_ARG | (uint64_t)lmt_id; @@ -592,4 +696,6 @@ struct rte_cryptodev_ops cn10k_cpt_ops = { .asym_session_configure = cnxk_ae_session_cfg, .asym_session_clear = cnxk_ae_session_clear, + /* Event crypto ops */ + .session_ev_mdata_set = cn10k_cpt_crypto_adapter_ev_mdata_set, }; diff --git a/drivers/crypto/cnxk/cn10k_ipsec.h b/drivers/crypto/cnxk/cn10k_ipsec.h index 647a71cdd5..1c1d904799 100644 --- a/drivers/crypto/cnxk/cn10k_ipsec.h +++ b/drivers/crypto/cnxk/cn10k_ipsec.h @@ -20,6 +20,8 @@ struct cn10k_ipsec_sa { uint16_t iv_offset; uint8_t iv_length; bool is_outbound; + /** Queue pair */ + struct cnxk_cpt_qp *qp; /** * End of SW mutable area diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c index d3d441cb24..987699f8d4 100644 --- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c +++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c @@ -316,28 +316,134 @@ cn9k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops) return count; } -uint16_t -cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op) +static int +cn9k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused, + void *sess, + enum rte_crypto_op_type op_type, + enum rte_crypto_op_sess_type sess_type, + void *mdata) { - union rte_event_crypto_metadata *ec_mdata; - struct cpt_inflight_req *infl_req; + union rte_event_crypto_metadata *ec_mdata = mdata; struct rte_event *rsp_info; struct cnxk_cpt_qp *qp; - struct cpt_inst_s inst; uint8_t cdev_id; uint16_t qp_id; - int ret; - - ec_mdata = cnxk_event_crypto_mdata_get(op); - if (!ec_mdata) { - rte_errno = EINVAL; - return 0; - } + uint64_t w2; + /* Get queue pair */ cdev_id = ec_mdata->request_info.cdev_id; qp_id = ec_mdata->request_info.queue_pair_id; qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id]; + + /* Prepare w2 */ rsp_info = &ec_mdata->response_info; + w2 = CNXK_CPT_INST_W2( + (RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id, + rsp_info->sched_type, rsp_info->queue_id, 0); + + /* Set meta according to session type */ + if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { + if (sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) { + struct cn9k_sec_session *priv; + struct cn9k_ipsec_sa *sa; + + priv = get_sec_session_private_data(sess); + sa = &priv->sa; + sa->qp = qp; + sa->inst.w2 = w2; + } else if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + struct cnxk_se_sess *priv; + + priv = get_sym_session_private_data( + sess, cn9k_cryptodev_driver_id); + priv->qp = qp; + priv->cpt_inst_w2 = w2; + } else + return -EINVAL; + } else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) { + if (sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + struct rte_cryptodev_asym_session *asym_sess = sess; + struct cnxk_ae_sess *priv; + + priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data; + priv->qp = qp; + priv->cpt_inst_w2 = w2; + } else + return -EINVAL; + } else + return -EINVAL; + + return 0; +} + +static inline int +cn9k_ca_meta_info_extract(struct rte_crypto_op *op, + struct cnxk_cpt_qp **qp, struct cpt_inst_s *inst) +{ + if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { + if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) { + struct cn9k_sec_session *priv; + struct cn9k_ipsec_sa *sa; + + priv = get_sec_session_private_data(op->sym->sec_session); + sa = &priv->sa; + *qp = sa->qp; + inst->w2.u64 = sa->inst.w2; + } else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + struct cnxk_se_sess *priv; + + priv = get_sym_session_private_data( + op->sym->session, cn9k_cryptodev_driver_id); + *qp = priv->qp; + inst->w2.u64 = priv->cpt_inst_w2; + } else { + union rte_event_crypto_metadata *ec_mdata; + struct rte_event *rsp_info; + uint8_t cdev_id; + uint16_t qp_id; + + ec_mdata = (union rte_event_crypto_metadata*) + ((uint8_t *)op + op->private_data_offset); + if (!ec_mdata) + return -EINVAL; + rsp_info = &ec_mdata->response_info; + cdev_id = ec_mdata->request_info.cdev_id; + qp_id = ec_mdata->request_info.queue_pair_id; + *qp = rte_cryptodevs[cdev_id].data->queue_pairs[qp_id]; + inst->w2.u64 = CNXK_CPT_INST_W2( + (RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id, + rsp_info->sched_type, rsp_info->queue_id, 0); + } + } else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) { + if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + struct rte_cryptodev_asym_session *asym_sess; + struct cnxk_ae_sess *priv; + + asym_sess = op->asym->session; + priv = (struct cnxk_ae_sess *)asym_sess->sess_private_data; + *qp = priv->qp; + inst->w2.u64 = priv->cpt_inst_w2; + } else + return -EINVAL; + } else + return -EINVAL; + + return 0; +} + +uint16_t +cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op) +{ + struct cpt_inflight_req *infl_req; + struct cnxk_cpt_qp *qp; + struct cpt_inst_s inst; + int ret; + + ret = cn9k_ca_meta_info_extract(op, &qp, &inst); + if (unlikely(ret)) { + rte_errno = EINVAL; + return 0; + } if (unlikely(!qp->ca.enabled)) { rte_errno = EINVAL; @@ -362,9 +468,6 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op) infl_req->qp = qp; inst.w0.u64 = 0; inst.res_addr = (uint64_t)&infl_req->res; - inst.w2.u64 = CNXK_CPT_INST_W2( - (RTE_EVENT_TYPE_CRYPTODEV << 28) | rsp_info->flow_id, - rsp_info->sched_type, rsp_info->queue_id, 0); inst.w3.u64 = CNXK_CPT_INST_W3(1, infl_req); if (roc_cpt_is_iq_full(&qp->lf)) { @@ -373,7 +476,7 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op) return 0; } - if (!rsp_info->sched_type) + if (inst.w2.s.tt == RTE_SCHED_TYPE_ORDERED) roc_sso_hws_head_wait(tag_op); cn9k_cpt_inst_submit(&inst, qp->lmtline.lmt_base, qp->lmtline.io_addr); @@ -613,4 +716,7 @@ struct rte_cryptodev_ops cn9k_cpt_ops = { .asym_session_configure = cnxk_ae_session_cfg, .asym_session_clear = cnxk_ae_session_clear, + /* Event crypto ops */ + .session_ev_mdata_set = cn9k_cpt_crypto_adapter_ev_mdata_set, + }; diff --git a/drivers/crypto/cnxk/cn9k_ipsec.h b/drivers/crypto/cnxk/cn9k_ipsec.h index f3acad561b..499dbc2782 100644 --- a/drivers/crypto/cnxk/cn9k_ipsec.h +++ b/drivers/crypto/cnxk/cn9k_ipsec.h @@ -42,6 +42,8 @@ struct cn9k_ipsec_sa { struct cnxk_on_ipsec_ar ar; /** Anti replay window size */ uint32_t replay_win_sz; + /** Queue pair */ + struct cnxk_cpt_qp *qp; }; struct cn9k_sec_session { diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h index 01ccfcd334..10854c79c8 100644 --- a/drivers/crypto/cnxk/cnxk_ae.h +++ b/drivers/crypto/cnxk/cnxk_ae.h @@ -22,6 +22,8 @@ struct cnxk_ae_sess { uint64_t *cnxk_fpm_iova; struct roc_ae_ec_group **ec_grp; uint64_t cpt_inst_w7; + uint64_t cpt_inst_w2; + struct cnxk_cpt_qp *qp; }; static __rte_always_inline void diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h index ab0f00ee7c..7ece0214dc 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h +++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h @@ -125,24 +125,6 @@ int cnxk_ae_session_cfg(struct rte_cryptodev *dev, struct rte_cryptodev_asym_session *sess); void cnxk_cpt_dump_on_err(struct cnxk_cpt_qp *qp); -static inline union rte_event_crypto_metadata * -cnxk_event_crypto_mdata_get(struct rte_crypto_op *op) -{ - union rte_event_crypto_metadata *ec_mdata; - - if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) - ec_mdata = rte_cryptodev_sym_session_get_user_data( - op->sym->session); - else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS && - op->private_data_offset) - ec_mdata = (union rte_event_crypto_metadata - *)((uint8_t *)op + op->private_data_offset); - else - return NULL; - - return ec_mdata; -} - static __rte_always_inline void pending_queue_advance(uint64_t *index, const uint64_t mask) { diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h index e988d57b94..b11c2bb3a2 100644 --- a/drivers/crypto/cnxk/cnxk_se.h +++ b/drivers/crypto/cnxk/cnxk_se.h @@ -33,6 +33,8 @@ struct cnxk_se_sess { uint16_t auth_iv_offset; uint32_t salt; uint64_t cpt_inst_w7; + uint64_t cpt_inst_w2; + struct cnxk_cpt_qp *qp; struct roc_se_ctx roc_se_ctx; } __rte_cache_aligned; From patchwork Mon Apr 18 19:33:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 109780 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 5EEFFA00C4; Mon, 18 Apr 2022 21:33:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 073ED41145; Mon, 18 Apr 2022 21:33:48 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 5CE9C41143 for ; Mon, 18 Apr 2022 21:33:46 +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 ESMTP id 23ICOeW6010013; Mon, 18 Apr 2022 12:33:45 -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=tcmjqLOQ/COhZYVgmZdU1zfCyoAye/tUk88CHicEsfE=; b=HacZODcBwke2Yr+fbxBxyGZ+tz9L2YSlDHZyLVrzqds/AR6uRcEMPg8SM4Ic5k9BypH1 NCkM+esh+g3f/CvqFON5wxiacL92gUyzsiBOeedEVnB/7R8J+/DdrtTmdSgvKxt5ZmmE iAy2edYQeGpEs7CHg0L/YzZJPSX20thHMkw12au73UB8T3ZBwyqlRCy+SScX88JEeouY xaX0mQGU2b9QGTDg4Adqk9znif1/U4rFleZP4eq5+lloryNrNknNXWTyeWBfyXn1tfEB l4qG2Bl7HIcd3biY8wIaq3KwX6XtJa3QpPqEK5y9A71vZOC+vb3wCg8fYJl+aHC9qbas Jg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3ffwap0bjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 12:33:45 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 18 Apr 2022 12:33:43 -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; Mon, 18 Apr 2022 12:33:43 -0700 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id 92A8A5B6942; Mon, 18 Apr 2022 12:33:40 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , Akhil Goyal Subject: [PATCH v2 3/7] crypto/octeontx: use new API for event metadata Date: Tue, 19 Apr 2022 01:03:21 +0530 Message-ID: <20220418193325.368313-4-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 X-Proofpoint-GUID: oDx47Hp1EjIEdAmnag4tw9vWd1GWE3de X-Proofpoint-ORIG-GUID: oDx47Hp1EjIEdAmnag4tw9vWd1GWE3de 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 For getting event crypto metadata from crypto_op, the new API rte_cryptodev_get_session_event_mdata can be used directly instead of getting userdata inside PMD. Signed-off-by: Akhil Goyal --- drivers/crypto/octeontx/otx_cryptodev_ops.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c index ddb1266c3c..d5851d9987 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_ops.c +++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c @@ -684,24 +684,6 @@ submit_request_to_sso(struct ssows *ws, uintptr_t req, ssovf_store_pair(add_work, req, ws->grps[rsp_info->queue_id]); } -static inline union rte_event_crypto_metadata * -get_event_crypto_mdata(struct rte_crypto_op *op) -{ - union rte_event_crypto_metadata *ec_mdata; - - if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) - ec_mdata = rte_cryptodev_sym_session_get_user_data( - op->sym->session); - else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS && - op->private_data_offset) - ec_mdata = (union rte_event_crypto_metadata *) - ((uint8_t *)op + op->private_data_offset); - else - return NULL; - - return ec_mdata; -} - uint16_t __rte_hot otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op) { @@ -712,7 +694,7 @@ otx_crypto_adapter_enqueue(void *port, struct rte_crypto_op *op) uint8_t op_type, cdev_id; uint16_t qp_id; - ec_mdata = get_event_crypto_mdata(op); + ec_mdata = rte_cryptodev_session_event_mdata_get(op); if (unlikely(ec_mdata == NULL)) { rte_errno = EINVAL; return 0; From patchwork Mon Apr 18 19:33:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 109781 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 2C9D2A00C4; Mon, 18 Apr 2022 21:34:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D1034427EF; Mon, 18 Apr 2022 21:33:49 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 6A075427ED for ; Mon, 18 Apr 2022 21:33:48 +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 23ICP0Y7032378; Mon, 18 Apr 2022 12:33:47 -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=6ZsE54J+TFtKUiVhqBBYA/62W1CvUzB5zEXbyLNGdvA=; b=U/Np+gxsAdM4/YwXi+WePccSiKjnpmme2iyKecthmttZ2hZSp8C7qZUNelzgsjp9odZk rDhwRMqvgnG5m1SqKUmY+Irn7GVw1ePa0iOO6hlC0lNrFbdsSTuxymcD1QDJRiGXXrOz o1YLO9/1XFZVpawnwnGJvjtVCD/YqIkY8UAc3nQ8V9eqQHSu8wpQVQcRdk1R4Hl4bJi2 eT7pR0JvC1m7041nWhIZIUEpMuBy04rrDvWrbBCxcVsP8z8dEjVRWgE3yzDQ4fW+DJfj bGIPd5oZDm9LVkcqQeK39P5D/Aa4JgyIyCU5oMz4z5YYdEmH1buVbOuX2lSd7fZ6if9l jg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ffu5pgh1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 12:33:47 -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:46 -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:46 -0700 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id 93A225B6940; Mon, 18 Apr 2022 12:33:43 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , Akhil Goyal Subject: [PATCH v2 4/7] test/event: use new API to set event crypto metadata Date: Tue, 19 Apr 2022 01:03:22 +0530 Message-ID: <20220418193325.368313-5-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 X-Proofpoint-GUID: xNWdYrDh6iFT2PCxpR-PDmbPxzu0LpO_ X-Proofpoint-ORIG-GUID: xNWdYrDh6iFT2PCxpR-PDmbPxzu0LpO_ 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 Used the new API rte_cryptodev_set_session_event_mdata to set event crypto metadata from the applications (app/test and app/test-eventdev) instead of using session userdata. Signed-off-by: Akhil Goyal --- app/test-eventdev/test_perf_common.c | 8 ++++++-- app/test/test_event_crypto_adapter.c | 12 ++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c index 9d1f4a4567..78dfaf4cab 100644 --- a/app/test-eventdev/test_perf_common.c +++ b/app/test-eventdev/test_perf_common.c @@ -835,8 +835,12 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt, return -ENOMEM; m_data.response_info.flow_id = flow_id; - rte_cryptodev_sym_session_set_user_data( - crypto_sess, &m_data, sizeof(m_data)); + rte_cryptodev_session_event_mdata_set(cdev_id, + crypto_sess, + RTE_CRYPTO_OP_TYPE_SYMMETRIC, + RTE_CRYPTO_OP_WITH_SESSION, + &m_data); + p->ca.crypto_sess[flow_id] = crypto_sess; } diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c index 688520db4e..631011b1bd 100644 --- a/app/test/test_event_crypto_adapter.c +++ b/app/test/test_event_crypto_adapter.c @@ -227,8 +227,10 @@ test_op_forward_mode(uint8_t session_less) m_data.request_info.queue_pair_id = request_info.queue_pair_id; m_data.response_info.event = response_info.event; - rte_cryptodev_sym_session_set_user_data(sess, - &m_data, sizeof(m_data)); + rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID, + sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC, + RTE_CRYPTO_OP_WITH_SESSION, + &m_data); } rte_crypto_op_attach_sym_session(op, sess); @@ -416,8 +418,10 @@ test_op_new_mode(uint8_t session_less) if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) { /* Fill in private user data information */ m_data.response_info.event = response_info.event; - rte_cryptodev_sym_session_set_user_data(sess, - &m_data, sizeof(m_data)); + rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID, + sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC, + RTE_CRYPTO_OP_WITH_SESSION, + &m_data); } ret = rte_cryptodev_sym_session_init(TEST_CDEV_ID, sess, &cipher_xform, params.session_priv_mpool); From patchwork Mon Apr 18 19:33:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 109782 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 09705A00C4; Mon, 18 Apr 2022 21:34:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C70CB41156; Mon, 18 Apr 2022 21:33:53 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id E54E141156 for ; Mon, 18 Apr 2022 21:33: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 ESMTP id 23ICOeW7010013; Mon, 18 Apr 2022 12:33:51 -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=C6vAene4k5JTXyy1cM2Ecx2mhnXHITXvs8rX6oCsAfk=; b=d9tcnQcXZsg6yw9RwXvxdZAOuOMZyA8gOaGELQml+AP2V59p/X66wsYIydN7CX38uG9j CcLceFLBAlNlTgvyPlGCC/iLJf2KuFg75Nhw8eFGFlbDcUqWF7jH7KE+YQUgZMkR0pwG hgvTROB/kVrLASqwCTAAkRGpvIaDLGL3CdrpioCkzYYF8vHypsUUze1LJgSigPeT0IYo f5trT29lw/QhVk3l9NQ6a3563wnkxPF4GQkv/tDPEM+g7rUFBP/d+45MUzkzKMAukP4m 8eRNjN27jpzeM2k6YXZqgvW4hdNAF5MWYrISj7BYw23Kv/2XymGjNAIdcqppvKZGOsI5 iQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3ffwap0bk9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 12:33:51 -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.2; Mon, 18 Apr 2022 12:33:49 -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:49 -0700 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id C61B55B6942; Mon, 18 Apr 2022 12:33:46 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , Akhil Goyal Subject: [PATCH v2 5/7] eventdev: use new API to get event crypto metadata Date: Tue, 19 Apr 2022 01:03:23 +0530 Message-ID: <20220418193325.368313-6-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 X-Proofpoint-GUID: 3wOIwlyYd0Mgf32utouUmGY2ZN0Lu6jM X-Proofpoint-ORIG-GUID: 3wOIwlyYd0Mgf32utouUmGY2ZN0Lu6jM 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 For getting event crypto metadata from crypto_op, the new API rte_cryptodev_get_session_event_mdata is used instead of getting userdata inside PMD. Signed-off-by: Akhil Goyal --- lib/eventdev/rte_event_crypto_adapter.c | 55 ++++++------------------- 1 file changed, 12 insertions(+), 43 deletions(-) diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c index f624f50187..7c695176f4 100644 --- a/lib/eventdev/rte_event_crypto_adapter.c +++ b/lib/eventdev/rte_event_crypto_adapter.c @@ -457,43 +457,22 @@ eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct rte_event *ev, crypto_op = ev[i].event_ptr; if (crypto_op == NULL) continue; - if (crypto_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { - m_data = rte_cryptodev_sym_session_get_user_data( - crypto_op->sym->session); - if (m_data == NULL) { - rte_pktmbuf_free(crypto_op->sym->m_src); - rte_crypto_op_free(crypto_op); - continue; - } + m_data = rte_cryptodev_session_event_mdata_get(crypto_op); + if (m_data == NULL) { + rte_pktmbuf_free(crypto_op->sym->m_src); + rte_crypto_op_free(crypto_op); + continue; + } - cdev_id = m_data->request_info.cdev_id; - qp_id = m_data->request_info.queue_pair_id; - qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id]; - if (!qp_info->qp_enabled) { - rte_pktmbuf_free(crypto_op->sym->m_src); - rte_crypto_op_free(crypto_op); - continue; - } - eca_circular_buffer_add(&qp_info->cbuf, crypto_op); - } else if (crypto_op->sess_type == RTE_CRYPTO_OP_SESSIONLESS && - crypto_op->private_data_offset) { - m_data = (union rte_event_crypto_metadata *) - ((uint8_t *)crypto_op + - crypto_op->private_data_offset); - cdev_id = m_data->request_info.cdev_id; - qp_id = m_data->request_info.queue_pair_id; - qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id]; - if (!qp_info->qp_enabled) { - rte_pktmbuf_free(crypto_op->sym->m_src); - rte_crypto_op_free(crypto_op); - continue; - } - eca_circular_buffer_add(&qp_info->cbuf, crypto_op); - } else { + cdev_id = m_data->request_info.cdev_id; + qp_id = m_data->request_info.queue_pair_id; + qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id]; + if (!qp_info->qp_enabled) { rte_pktmbuf_free(crypto_op->sym->m_src); rte_crypto_op_free(crypto_op); continue; } + eca_circular_buffer_add(&qp_info->cbuf, crypto_op); if (eca_circular_buffer_batch_ready(&qp_info->cbuf)) { ret = eca_circular_buffer_flush_to_cdev(&qp_info->cbuf, @@ -636,17 +615,7 @@ eca_ops_enqueue_burst(struct event_crypto_adapter *adapter, for (i = 0; i < num; i++) { struct rte_event *ev = &events[nb_ev++]; - m_data = NULL; - if (ops[i]->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { - m_data = rte_cryptodev_sym_session_get_user_data( - ops[i]->sym->session); - } else if (ops[i]->sess_type == RTE_CRYPTO_OP_SESSIONLESS && - ops[i]->private_data_offset) { - m_data = (union rte_event_crypto_metadata *) - ((uint8_t *)ops[i] + - ops[i]->private_data_offset); - } - + m_data = rte_cryptodev_session_event_mdata_get(ops[i]); if (unlikely(m_data == NULL)) { rte_pktmbuf_free(ops[i]->sym->m_src); rte_crypto_op_free(ops[i]); From patchwork Mon Apr 18 19:33:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 109783 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 728AFA00C4; Mon, 18 Apr 2022 21:34:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 049F842800; Mon, 18 Apr 2022 21:33:57 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id CA676427F6 for ; Mon, 18 Apr 2022 21:33:54 +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 23ICOkWK032063; Mon, 18 Apr 2022 12:33:54 -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=QrTlrRF61FAXdo2QB4EiPykLhgy7ldySmPj9XE5vEp4=; b=CBRJ+MkP7330Ijj4Pkv4AianIF+h+sOMr7f4Do4Hhieo6H35iyQ5pbqknw+rLbg+4ZNc NcVKfSxjjHHTMLkVGm/HPjJ2uzqqCJBWE/OkrUaoYRHBVigUhdGMyqxPdoYRLRQtBhSQ 00K+07YGYDRKUerIuO35LhnS7gFqC7Zn2BB5ulex1Sjat9ysfpODVTpq5agY29/daDWl 364WX2Or/9q5eqAMmw2dcF0U8iq6wm1gG8s3bjvKP3f1TJdQfLd2lOhyppvMNmZTYk6T ACSjiXSoPdlp0E9T1GkxcHanjPJurt679fleST+noAJlBWeNZnmjvRP+kyvV0oo0espr Tg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ffu5pgh23-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 12:33:53 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 18 Apr 2022 12:33:52 -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; Mon, 18 Apr 2022 12:33:52 -0700 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id C97195B6940; Mon, 18 Apr 2022 12:33:49 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , Akhil Goyal Subject: [PATCH v2 6/7] test/event: add asymmetric cases for crypto adapter Date: Tue, 19 Apr 2022 01:03:24 +0530 Message-ID: <20220418193325.368313-7-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 X-Proofpoint-GUID: C7F7Uv3gbUlZzwt98BNYXrhh0zGWpPot X-Proofpoint-ORIG-GUID: C7F7Uv3gbUlZzwt98BNYXrhh0zGWpPot 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 Test app is updated to add cases for asymmetric crypto sessions for event crypto adapter. Signed-off-by: Akhil Goyal --- app/test/test_event_crypto_adapter.c | 491 ++++++++++++++++++++++++++- 1 file changed, 485 insertions(+), 6 deletions(-) diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c index 631011b1bd..dbc9268737 100644 --- a/app/test/test_event_crypto_adapter.c +++ b/app/test/test_event_crypto_adapter.c @@ -6,6 +6,7 @@ #include "test.h" #include #include +#include #include #include #include @@ -67,12 +68,97 @@ static const uint8_t text_64B[] = { 0x31, 0xbf, 0xe9, 0xa1, 0x97, 0x5c, 0x2b, 0xd6, 0x57, 0xa5, 0x9f, 0xab, 0xbd, 0xb0, 0x9b, 0x9c }; +#define DATA_SIZE 512 +struct modex_test_data { + enum rte_crypto_asym_xform_type xform_type; + struct { + uint8_t data[DATA_SIZE]; + uint16_t len; + } base; + struct { + uint8_t data[DATA_SIZE]; + uint16_t len; + } exponent; + struct { + uint8_t data[DATA_SIZE]; + uint16_t len; + } modulus; + struct { + uint8_t data[DATA_SIZE]; + uint16_t len; + } reminder; + uint16_t result_len; +}; + +static struct +modex_test_data modex_test_case = { + .xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX, + .base = { + .data = { + 0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, + 0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, + 0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50 + }, + .len = 20, + }, + .exponent = { + .data = { + 0x01, 0x00, 0x01 + }, + .len = 3, + }, + .reminder = { + .data = { + 0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72, + 0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C, + 0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17, + 0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D, + 0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C, + 0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7, + 0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11, + 0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32, + 0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B, + 0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99, + 0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E, + 0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38, + 0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7, + 0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F, + 0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46, + 0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A + }, + .len = 128, + }, + .modulus = { + .data = { + 0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a, + 0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce, + 0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2, + 0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a, + 0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d, + 0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a, + 0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e, + 0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72, + 0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87, + 0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62, + 0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18, + 0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e, + 0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03, + 0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee, + 0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6, + 0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55 + }, + .len = 128, + }, + .result_len = 128, +}; struct event_crypto_adapter_test_params { struct rte_mempool *mbuf_pool; struct rte_mempool *op_mpool; + struct rte_mempool *asym_op_mpool; struct rte_mempool *session_mpool; struct rte_mempool *session_priv_mpool; + struct rte_mempool *asym_sess_mpool; struct rte_cryptodev_config *config; uint8_t crypto_event_port_id; uint8_t internal_port_op_fwd; @@ -134,11 +220,24 @@ send_recv_ev(struct rte_event *ev) rte_pause(); op = recv_ev.event_ptr; + if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { #if PKT_TRACE - struct rte_mbuf *m = op->sym->m_src; - rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m)); + struct rte_mbuf *m = op->sym->m_src; + rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m)); #endif - rte_pktmbuf_free(op->sym->m_src); + rte_pktmbuf_free(op->sym->m_src); + } else { + uint8_t *data_expected = NULL, *data_received = NULL; + uint32_t data_size; + + data_expected = modex_test_case.reminder.data; + data_received = op->asym->modex.result.data; + data_size = op->asym->modex.result.length; + ret = memcmp(data_expected, data_received, data_size); + TEST_ASSERT_EQUAL(ret, 0, + "Data mismatch for asym crypto adapter\n"); + rte_free(op->asym->modex.result.data); + } rte_crypto_op_free(op); return TEST_SUCCESS; @@ -348,6 +447,170 @@ test_session_with_op_forward_mode(void) return TEST_SUCCESS; } +static int +test_asym_op_forward_mode(uint8_t session_less) +{ + const struct rte_cryptodev_asymmetric_xform_capability *capability; + struct rte_cryptodev_asym_capability_idx cap_idx; + struct rte_crypto_asym_xform xform_tc; + union rte_event_crypto_metadata m_data; + struct rte_cryptodev_info dev_info; + struct rte_crypto_asym_op *asym_op; + struct rte_crypto_op *op; + uint8_t input[4096] = {0}; + uint8_t *result = NULL; + struct rte_event ev; + void *sess = NULL; + uint32_t cap; + int ret; + + memset(&m_data, 0, sizeof(m_data)); + + rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info); + if (session_less && !(dev_info.feature_flags & + RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) { + RTE_LOG(INFO, USER1, + "Device doesn't support Asym sessionless ops. Test Skipped\n"); + return TEST_SKIPPED; + } + /* Setup Cipher Parameters */ + xform_tc.next = NULL; + xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX; + cap_idx.type = xform_tc.xform_type; + capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx); + + if (capability == NULL) { + RTE_LOG(INFO, USER1, + "Device doesn't support MODEX. Test Skipped\n"); + return TEST_SKIPPED; + } + + op = rte_crypto_op_alloc(params.asym_op_mpool, + RTE_CRYPTO_OP_TYPE_ASYMMETRIC); + TEST_ASSERT_NOT_NULL(op, + "Failed to allocate asymmetric crypto operation struct\n"); + + asym_op = op->asym; + + result = rte_zmalloc(NULL, modex_test_case.result_len, 0); + xform_tc.modex.modulus.data = modex_test_case.modulus.data; + xform_tc.modex.modulus.length = modex_test_case.modulus.len; + xform_tc.modex.exponent.data = modex_test_case.exponent.data; + xform_tc.modex.exponent.length = modex_test_case.exponent.len; + memcpy(input, modex_test_case.base.data, + modex_test_case.base.len); + asym_op->modex.base.data = input; + asym_op->modex.base.length = modex_test_case.base.len; + asym_op->modex.result.data = result; + asym_op->modex.result.length = modex_test_case.result_len; + if (rte_cryptodev_asym_xform_capability_check_modlen(capability, + xform_tc.modex.modulus.length)) { + RTE_LOG(INFO, USER1, + "line %u FAILED: %s", __LINE__, + "Invalid MODULUS length specified"); + return TEST_FAILED; + } + + if (!session_less) { + /* Create Crypto session*/ + ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID, + &xform_tc, params.asym_sess_mpool, &sess); + TEST_ASSERT_SUCCESS(ret, "Failed to init session\n"); + + ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, + &cap); + TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n"); + + if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) { + /* Fill in private user data information */ + m_data.request_info.cdev_id = request_info.cdev_id; + m_data.request_info.queue_pair_id = + request_info.queue_pair_id; + m_data.response_info.event = response_info.event; + rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID, + sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC, + RTE_CRYPTO_OP_WITH_SESSION, + &m_data); + } + + rte_crypto_op_attach_asym_session(op, sess); + } else { + op->sess_type = RTE_CRYPTO_OP_SESSIONLESS; + asym_op->xform = &xform_tc; + op->private_data_offset = (sizeof(struct rte_crypto_op) + + sizeof(struct rte_crypto_asym_op) + + DEFAULT_NUM_XFORMS * + sizeof(struct rte_crypto_asym_xform)); + /* Fill in private data information */ + m_data.request_info.cdev_id = request_info.cdev_id; + m_data.request_info.queue_pair_id = request_info.queue_pair_id; + m_data.response_info.event = response_info.event; + rte_memcpy((uint8_t *)op + op->private_data_offset, + &m_data, sizeof(m_data)); + } + /* Fill in event info and update event_ptr with rte_crypto_op */ + memset(&ev, 0, sizeof(ev)); + ev.queue_id = TEST_CRYPTO_EV_QUEUE_ID; + ev.sched_type = RTE_SCHED_TYPE_ATOMIC; + ev.flow_id = 0xAABB; + ev.event_ptr = op; + + ret = send_recv_ev(&ev); + TEST_ASSERT_SUCCESS(ret, "Failed to send/receive event to " + "crypto adapter\n"); + + test_crypto_adapter_stats(); + + return TEST_SUCCESS; +} + + +static int +test_asym_sessionless_with_op_forward_mode(void) +{ + uint32_t cap; + int ret; + + ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap); + TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n"); + + if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) && + !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) + map_adapter_service_core(); + else { + if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD)) + return TEST_SKIPPED; + } + + TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID), + "Failed to start event crypto adapter"); + + return test_asym_op_forward_mode(1); +} + +static int +test_asym_session_with_op_forward_mode(void) +{ + uint32_t cap; + int ret; + + ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap); + TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n"); + + if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) && + !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) + map_adapter_service_core(); + else { + if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD)) + return TEST_SKIPPED; + } + + TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID + ), "Failed to start event crypto adapter"); + + return test_asym_op_forward_mode(0); +} + static int send_op_recv_ev(struct rte_crypto_op *op) { @@ -365,11 +628,24 @@ send_op_recv_ev(struct rte_crypto_op *op) rte_pause(); recv_op = ev.event_ptr; + if (recv_op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { #if PKT_TRACE - struct rte_mbuf *m = recv_op->sym->m_src; - rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m)); + struct rte_mbuf *m = recv_op->sym->m_src; + rte_pktmbuf_dump(stdout, m, rte_pktmbuf_pkt_len(m)); #endif - rte_pktmbuf_free(recv_op->sym->m_src); + rte_pktmbuf_free(recv_op->sym->m_src); + } else { + uint8_t *data_expected = NULL, *data_received = NULL; + uint32_t data_size; + + data_expected = modex_test_case.reminder.data; + data_received = op->asym->modex.result.data; + data_size = op->asym->modex.result.length; + ret = memcmp(data_expected, data_received, data_size); + TEST_ASSERT_EQUAL(ret, 0, + "Data mismatch for asym crypto adapter\n"); + rte_free(op->asym->modex.result.data); + } rte_crypto_op_free(recv_op); return TEST_SUCCESS; @@ -505,6 +781,156 @@ test_session_with_op_new_mode(void) return TEST_SUCCESS; } +static int +test_asym_op_new_mode(uint8_t session_less) +{ + const struct rte_cryptodev_asymmetric_xform_capability *capability; + struct rte_cryptodev_asym_capability_idx cap_idx; + struct rte_crypto_asym_xform xform_tc; + union rte_event_crypto_metadata m_data; + struct rte_cryptodev_info dev_info; + struct rte_crypto_asym_op *asym_op; + struct rte_crypto_op *op; + uint8_t input[4096] = {0}; + uint8_t *result = NULL; + void *sess = NULL; + uint32_t cap; + int ret; + + memset(&m_data, 0, sizeof(m_data)); + + rte_cryptodev_info_get(TEST_CDEV_ID, &dev_info); + if (session_less && !(dev_info.feature_flags & + RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) { + RTE_LOG(INFO, USER1, + "Device doesn't support Asym sessionless ops. Test Skipped\n"); + return TEST_SKIPPED; + } + /* Setup Cipher Parameters */ + xform_tc.next = NULL; + xform_tc.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX; + cap_idx.type = xform_tc.xform_type; + capability = rte_cryptodev_asym_capability_get(TEST_CDEV_ID, &cap_idx); + + if (capability == NULL) { + RTE_LOG(INFO, USER1, + "Device doesn't support MODEX. Test Skipped\n"); + return TEST_SKIPPED; + } + + op = rte_crypto_op_alloc(params.asym_op_mpool, + RTE_CRYPTO_OP_TYPE_ASYMMETRIC); + TEST_ASSERT_NOT_NULL(op, "Failed to allocate asym crypto_op!\n"); + + asym_op = op->asym; + + result = rte_zmalloc(NULL, modex_test_case.result_len, 0); + xform_tc.modex.modulus.data = modex_test_case.modulus.data; + xform_tc.modex.modulus.length = modex_test_case.modulus.len; + xform_tc.modex.exponent.data = modex_test_case.exponent.data; + xform_tc.modex.exponent.length = modex_test_case.exponent.len; + memcpy(input, modex_test_case.base.data, + modex_test_case.base.len); + asym_op->modex.base.data = input; + asym_op->modex.base.length = modex_test_case.base.len; + asym_op->modex.result.data = result; + asym_op->modex.result.length = modex_test_case.result_len; + if (rte_cryptodev_asym_xform_capability_check_modlen(capability, + xform_tc.modex.modulus.length)) { + RTE_LOG(INFO, USER1, + "line %u FAILED: %s", __LINE__, + "Invalid MODULUS length specified"); + return TEST_FAILED; + } + + if (!session_less) { + ret = rte_cryptodev_asym_session_create(TEST_CDEV_ID, + &xform_tc, params.asym_sess_mpool, &sess); + TEST_ASSERT_NOT_NULL(sess, "Session creation failed\n"); + TEST_ASSERT_SUCCESS(ret, "Failed to init session\n"); + + ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, + &cap); + TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n"); + + if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) { + /* Fill in private user data information */ + m_data.response_info.event = response_info.event; + rte_cryptodev_session_event_mdata_set(TEST_CDEV_ID, + sess, RTE_CRYPTO_OP_TYPE_ASYMMETRIC, + RTE_CRYPTO_OP_WITH_SESSION, + &m_data); + } + + rte_crypto_op_attach_asym_session(op, sess); + } else { + op->sess_type = RTE_CRYPTO_OP_SESSIONLESS; + asym_op->xform = &xform_tc; + op->private_data_offset = (sizeof(struct rte_crypto_op) + + sizeof(struct rte_crypto_asym_op) + + DEFAULT_NUM_XFORMS * + sizeof(struct rte_crypto_asym_xform)); + /* Fill in private data information */ + m_data.response_info.event = response_info.event; + rte_memcpy((uint8_t *)op + op->private_data_offset, + &m_data, sizeof(m_data)); + } + + ret = send_op_recv_ev(op); + TEST_ASSERT_SUCCESS(ret, "Failed to enqueue op to cryptodev\n"); + + test_crypto_adapter_stats(); + + return TEST_SUCCESS; +} + +static int +test_asym_sessionless_with_op_new_mode(void) +{ + uint32_t cap; + int ret; + + ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap); + TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n"); + + if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) && + !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) + map_adapter_service_core(); + else { + if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) + return TEST_SKIPPED; + } + + /* start the event crypto adapter */ + TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID), + "Failed to start event crypto adapter"); + + return test_asym_op_new_mode(1); +} + +static int +test_asym_session_with_op_new_mode(void) +{ + uint32_t cap; + int ret; + + ret = rte_event_crypto_adapter_caps_get(evdev, TEST_CDEV_ID, &cap); + TEST_ASSERT_SUCCESS(ret, "Failed to get adapter capabilities\n"); + + if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD) && + !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) + map_adapter_service_core(); + else { + if (!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW)) + return TEST_SKIPPED; + } + + TEST_ASSERT_SUCCESS(rte_event_crypto_adapter_start(TEST_ADAPTER_ID), + "Failed to start event crypto adapter"); + + return test_asym_op_new_mode(0); +} + static int configure_cryptodev(void) { @@ -537,6 +963,19 @@ configure_cryptodev(void) RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n"); return TEST_FAILED; } + params.asym_op_mpool = rte_crypto_op_pool_create( + "EVENT_CRYPTO_ASYM_OP_POOL", + RTE_CRYPTO_OP_TYPE_ASYMMETRIC, + NUM_MBUFS, MBUF_CACHE_SIZE, + (DEFAULT_NUM_XFORMS * + sizeof(struct rte_crypto_asym_xform)) + + sizeof(union rte_event_crypto_metadata), + rte_socket_id()); + if (params.asym_op_mpool == NULL) { + RTE_LOG(ERR, USER1, "Can't create CRYPTO_ASYM_OP_POOL\n"); + return TEST_FAILED; + } + /* Create a NULL crypto device */ nb_devs = rte_cryptodev_device_count_by_driver( @@ -581,6 +1020,15 @@ configure_cryptodev(void) TEST_ASSERT_NOT_NULL(params.session_priv_mpool, "session mempool allocation failed\n"); + params.asym_sess_mpool = rte_cryptodev_asym_session_pool_create( + "CRYPTO_AD_ASYM_SESS_MP", + MAX_NB_SESSIONS, 0, + sizeof(union rte_event_crypto_metadata), + SOCKET_ID_ANY); + TEST_ASSERT_NOT_NULL(params.asym_sess_mpool, + "asym 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; @@ -960,6 +1408,21 @@ crypto_teardown(void) params.session_priv_mpool = NULL; } + /* Free asym session mempool */ + if (params.asym_sess_mpool != NULL) { + RTE_LOG(DEBUG, USER1, "CRYPTO_AD_ASYM_SESS_MP count %u\n", + rte_mempool_avail_count(params.asym_sess_mpool)); + rte_mempool_free(params.asym_sess_mpool); + params.asym_sess_mpool = NULL; + } + /* Free asym ops mempool */ + if (params.asym_op_mpool != NULL) { + RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_ASYM_OP_POOL count %u\n", + rte_mempool_avail_count(params.asym_op_mpool)); + rte_mempool_free(params.asym_op_mpool); + params.asym_op_mpool = NULL; + } + /* Free ops mempool */ if (params.op_mpool != NULL) { RTE_LOG(DEBUG, USER1, "EVENT_CRYPTO_SYM_OP_POOL count %u\n", @@ -1016,6 +1479,22 @@ static struct unit_test_suite functional_testsuite = { test_crypto_adapter_stop, test_sessionless_with_op_new_mode), + TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode, + test_crypto_adapter_stop, + test_asym_session_with_op_forward_mode), + + TEST_CASE_ST(test_crypto_adapter_conf_op_forward_mode, + test_crypto_adapter_stop, + test_asym_sessionless_with_op_forward_mode), + + TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode, + test_crypto_adapter_stop, + test_asym_session_with_op_new_mode), + + TEST_CASE_ST(test_crypto_adapter_conf_op_new_mode, + test_crypto_adapter_stop, + test_asym_sessionless_with_op_new_mode), + TEST_CASES_END() /**< NULL terminate unit test array */ } }; From patchwork Mon Apr 18 19:33:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 109784 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 50F2CA00C4; Mon, 18 Apr 2022 21:34:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E52C3427F6; Mon, 18 Apr 2022 21:33:59 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 043F142804 for ; Mon, 18 Apr 2022 21:33:57 +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 23ICOjo0032060; Mon, 18 Apr 2022 12:33:57 -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=eAZYRx6Qbv8e+7UnSMtfuyWZBW6A0y+qgBtITbLnxIc=; b=L0rVINn4PZjcRIwj1hlwHIiwBwB4Y5DWSsLdBLoIdTanjJeHCrj7cNELQJ7oHv86/7Bt p75hPUNt6DPuUqRU9IHBvORLtRIew7CAfKPG37AauqFAjnFrbc6Mgzn0ZpttddtwJMFr /hx4LD1JSwcTsCJ704IjXghRUP0DoFwh77HMz+HBP/LJyHRTWNX1PWywBG4Q9VCqc7pT /SsNN3xGFnct85f6sYTCbkcXF3RHMSHzUduaPmNmjZgedMNb11nvxV41gKjaB2eeTX5N xJZ1K05/EUYtzU/7MGKbJLMi7wAZz2jy9LILAUz05Br6yf/6kNouEtNeHISBQqHadDAg qA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3ffu5pgh28-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Apr 2022 12:33:56 -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; Mon, 18 Apr 2022 12:33:55 -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; Mon, 18 Apr 2022 12:33:55 -0700 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id C376F5B6942; Mon, 18 Apr 2022 12:33:52 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , Akhil Goyal Subject: [PATCH v2 7/7] test-eventdev: support asym ops for crypto adapter Date: Tue, 19 Apr 2022 01:03:25 +0530 Message-ID: <20220418193325.368313-8-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 X-Proofpoint-GUID: wIqs4O2kPMrdT9AIMLCheIPPqHYPp26Q X-Proofpoint-ORIG-GUID: wIqs4O2kPMrdT9AIMLCheIPPqHYPp26Q 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 Test eventdev app is updated to add new option for asymmetric crypto ops for event crypto adapter. Signed-off-by: Akhil Goyal --- app/test-eventdev/evt_common.h | 2 + app/test-eventdev/evt_options.c | 17 ++ app/test-eventdev/evt_options.h | 4 + app/test-eventdev/test_perf_atq.c | 12 +- app/test-eventdev/test_perf_common.c | 250 +++++++++++++++++++++++---- app/test-eventdev/test_perf_common.h | 45 +++-- app/test-eventdev/test_perf_queue.c | 12 +- doc/guides/tools/testeventdev.rst | 5 + 8 files changed, 284 insertions(+), 63 deletions(-) diff --git a/app/test-eventdev/evt_common.h b/app/test-eventdev/evt_common.h index 2f301a7e79..196eca8bd0 100644 --- a/app/test-eventdev/evt_common.h +++ b/app/test-eventdev/evt_common.h @@ -6,6 +6,7 @@ #define _EVT_COMMON_ #include +#include #include #include #include @@ -80,6 +81,7 @@ struct evt_options { uint64_t optm_timer_tick_nsec; enum evt_prod_type prod_type; enum rte_event_crypto_adapter_mode crypto_adptr_mode; + enum rte_crypto_op_type crypto_op_type; }; static inline bool diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c index d3c704d2b3..8326734b64 100644 --- a/app/test-eventdev/evt_options.c +++ b/app/test-eventdev/evt_options.c @@ -38,6 +38,7 @@ evt_options_default(struct evt_options *opt) opt->eth_queues = 1; opt->vector_size = 64; opt->vector_tmo_nsec = 100E3; + opt->crypto_op_type = RTE_CRYPTO_OP_TYPE_SYMMETRIC; } typedef int (*option_parser_t)(struct evt_options *opt, @@ -142,6 +143,18 @@ evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg) return ret; } +static int +evt_parse_crypto_op_type(struct evt_options *opt, const char *arg) +{ + uint8_t op_type; + int ret; + + ret = parser_read_uint8(&op_type, arg); + opt->crypto_op_type = op_type ? RTE_CRYPTO_OP_TYPE_ASYMMETRIC : + RTE_CRYPTO_OP_TYPE_SYMMETRIC; + return ret; +} + static int evt_parse_test_name(struct evt_options *opt, const char *arg) { @@ -368,6 +381,8 @@ usage(char *program) "\t--expiry_nsec : event timer expiry ns.\n" "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n" "\t 1 for OP_FORWARD mode.\n" + "\t--crypto_op_type : 0 for SYM ops (default) and\n" + "\t 1 for ASYM ops.\n" "\t--mbuf_sz : packet mbuf size.\n" "\t--max_pkt_sz : max packet size.\n" "\t--prod_enq_burst_sz : producer enqueue burst size.\n" @@ -442,6 +457,7 @@ static struct option lgopts[] = { { EVT_PROD_TIMERDEV, 0, 0, 0 }, { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 }, { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 }, + { EVT_CRYPTO_OP_TYPE, 1, 0, 0 }, { EVT_NB_TIMERS, 1, 0, 0 }, { EVT_NB_TIMER_ADPTRS, 1, 0, 0 }, { EVT_TIMER_TICK_NSEC, 1, 0, 0 }, @@ -484,6 +500,7 @@ evt_opts_parse_long(int opt_idx, struct evt_options *opt) { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type}, { EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst}, { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode}, + { EVT_CRYPTO_OP_TYPE, evt_parse_crypto_op_type}, { EVT_NB_TIMERS, evt_parse_nb_timers}, { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs}, { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec}, diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h index 2231c58801..f23fb8a511 100644 --- a/app/test-eventdev/evt_options.h +++ b/app/test-eventdev/evt_options.h @@ -38,6 +38,7 @@ #define EVT_PROD_TIMERDEV ("prod_type_timerdev") #define EVT_PROD_TIMERDEV_BURST ("prod_type_timerdev_burst") #define EVT_CRYPTO_ADPTR_MODE ("crypto_adptr_mode") +#define EVT_CRYPTO_OP_TYPE ("crypto_op_type") #define EVT_NB_TIMERS ("nb_timers") #define EVT_NB_TIMER_ADPTRS ("nb_timer_adptrs") #define EVT_TIMER_TICK_NSEC ("timer_tick_nsec") @@ -298,6 +299,9 @@ evt_dump_producer_type(struct evt_options *opt) "Event crypto adapter producers"); evt_dump("crypto adapter mode", "%s", opt->crypto_adptr_mode ? "OP_FORWARD" : "OP_NEW"); + evt_dump("crypto op type", "%s", + (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) ? + "SYMMETRIC" : "ASYMMETRIC"); evt_dump("nb_cryptodev", "%u", rte_cryptodev_count()); break; } diff --git a/app/test-eventdev/test_perf_atq.c b/app/test-eventdev/test_perf_atq.c index 67ff681666..6a2aa86fd2 100644 --- a/app/test-eventdev/test_perf_atq.c +++ b/app/test-eventdev/test_perf_atq.c @@ -53,11 +53,13 @@ perf_atq_worker(void *arg, const int enable_fwd_latency) struct rte_crypto_op *op = ev.event_ptr; if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) { - if (op->sym->m_dst == NULL) - ev.event_ptr = op->sym->m_src; - else - ev.event_ptr = op->sym->m_dst; - rte_crypto_op_free(op); + if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { + if (op->sym->m_dst == NULL) + ev.event_ptr = op->sym->m_src; + else + ev.event_ptr = op->sym->m_dst; + rte_crypto_op_free(op); + } } else { rte_crypto_op_free(op); continue; diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c index 78dfaf4cab..bafc466d61 100644 --- a/app/test-eventdev/test_perf_common.c +++ b/app/test-eventdev/test_perf_common.c @@ -7,6 +7,89 @@ #include "test_perf_common.h" #define NB_CRYPTODEV_DESCRIPTORS 128 +#define DATA_SIZE 512 +struct modex_test_data { + enum rte_crypto_asym_xform_type xform_type; + struct { + uint8_t data[DATA_SIZE]; + uint16_t len; + } base; + struct { + uint8_t data[DATA_SIZE]; + uint16_t len; + } exponent; + struct { + uint8_t data[DATA_SIZE]; + uint16_t len; + } modulus; + struct { + uint8_t data[DATA_SIZE]; + uint16_t len; + } reminder; + uint16_t result_len; +}; + +static struct +modex_test_data modex_test_case = { + .xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX, + .base = { + .data = { + 0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, + 0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, + 0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50 + }, + .len = 20, + }, + .exponent = { + .data = { + 0x01, 0x00, 0x01 + }, + .len = 3, + }, + .reminder = { + .data = { + 0x2C, 0x60, 0x75, 0x45, 0x98, 0x9D, 0xE0, 0x72, + 0xA0, 0x9D, 0x3A, 0x9E, 0x03, 0x38, 0x73, 0x3C, + 0x31, 0x83, 0x04, 0xFE, 0x75, 0x43, 0xE6, 0x17, + 0x5C, 0x01, 0x29, 0x51, 0x69, 0x33, 0x62, 0x2D, + 0x78, 0xBE, 0xAE, 0xC4, 0xBC, 0xDE, 0x7E, 0x2C, + 0x77, 0x84, 0xF2, 0xC5, 0x14, 0xB5, 0x2F, 0xF7, + 0xC5, 0x94, 0xEF, 0x86, 0x75, 0x75, 0xB5, 0x11, + 0xE5, 0x0E, 0x0A, 0x29, 0x76, 0xE2, 0xEA, 0x32, + 0x0E, 0x43, 0x77, 0x7E, 0x2C, 0x27, 0xAC, 0x3B, + 0x86, 0xA5, 0xDB, 0xC9, 0x48, 0x40, 0xE8, 0x99, + 0x9A, 0x0A, 0x3D, 0xD6, 0x74, 0xFA, 0x2E, 0x2E, + 0x5B, 0xAF, 0x8C, 0x99, 0x44, 0x2A, 0x67, 0x38, + 0x27, 0x41, 0x59, 0x9D, 0xB8, 0x51, 0xC9, 0xF7, + 0x43, 0x61, 0x31, 0x6E, 0xF1, 0x25, 0x38, 0x7F, + 0xAE, 0xC6, 0xD0, 0xBB, 0x29, 0x76, 0x3F, 0x46, + 0x2E, 0x1B, 0xE4, 0x67, 0x71, 0xE3, 0x87, 0x5A + }, + .len = 128, + }, + .modulus = { + .data = { + 0xb3, 0xa1, 0xaf, 0xb7, 0x13, 0x08, 0x00, 0x0a, + 0x35, 0xdc, 0x2b, 0x20, 0x8d, 0xa1, 0xb5, 0xce, + 0x47, 0x8a, 0xc3, 0x80, 0xf4, 0x7d, 0x4a, 0xa2, + 0x62, 0xfd, 0x61, 0x7f, 0xb5, 0xa8, 0xde, 0x0a, + 0x17, 0x97, 0xa0, 0xbf, 0xdf, 0x56, 0x5a, 0x3d, + 0x51, 0x56, 0x4f, 0x70, 0x70, 0x3f, 0x63, 0x6a, + 0x44, 0x5b, 0xad, 0x84, 0x0d, 0x3f, 0x27, 0x6e, + 0x3b, 0x34, 0x91, 0x60, 0x14, 0xb9, 0xaa, 0x72, + 0xfd, 0xa3, 0x64, 0xd2, 0x03, 0xa7, 0x53, 0x87, + 0x9e, 0x88, 0x0b, 0xc1, 0x14, 0x93, 0x1a, 0x62, + 0xff, 0xb1, 0x5d, 0x74, 0xcd, 0x59, 0x63, 0x18, + 0x11, 0x3d, 0x4f, 0xba, 0x75, 0xd4, 0x33, 0x4e, + 0x23, 0x6b, 0x7b, 0x57, 0x44, 0xe1, 0xd3, 0x03, + 0x13, 0xa6, 0xf0, 0x8b, 0x60, 0xb0, 0x9e, 0xee, + 0x75, 0x08, 0x9d, 0x71, 0x63, 0x13, 0xcb, 0xa6, + 0x81, 0x92, 0x14, 0x03, 0x22, 0x2d, 0xde, 0x55 + }, + .len = 128, + }, + .result_len = 128, +}; int perf_test_result(struct evt_test *test, struct evt_options *opt) @@ -277,12 +360,10 @@ perf_event_timer_producer_burst(void *arg) static inline void crypto_adapter_enq_op_new(struct prod_data *p) { - struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess; struct test_perf *t = p->t; const uint32_t nb_flows = t->nb_flows; const uint64_t nb_pkts = t->nb_pkts; struct rte_mempool *pool = t->pool; - struct rte_crypto_sym_op *sym_op; struct evt_options *opt = t->opt; uint16_t qp_id = p->ca.cdev_qp_id; uint8_t cdev_id = p->ca.cdev_id; @@ -300,22 +381,39 @@ crypto_adapter_enq_op_new(struct prod_data *p) len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN; while (count < nb_pkts && t->done == false) { - m = rte_pktmbuf_alloc(pool); - if (m == NULL) - continue; + if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { + struct rte_crypto_sym_op *sym_op; - rte_pktmbuf_append(m, len); - op = rte_crypto_op_alloc(t->ca_op_pool, + op = rte_crypto_op_alloc(t->ca_op_pool, RTE_CRYPTO_OP_TYPE_SYMMETRIC); - sym_op = op->sym; - sym_op->m_src = m; - sym_op->cipher.data.offset = 0; - sym_op->cipher.data.length = len; - rte_crypto_op_attach_sym_session( - op, crypto_sess[flow_counter++ % nb_flows]); + m = rte_pktmbuf_alloc(pool); + if (m == NULL) + continue; + rte_pktmbuf_append(m, len); + sym_op = op->sym; + sym_op->m_src = m; + sym_op->cipher.data.offset = 0; + sym_op->cipher.data.length = len; + rte_crypto_op_attach_sym_session( + op, p->ca.crypto_sess[flow_counter++ % nb_flows]); + } else { + struct rte_crypto_asym_op *asym_op; + uint8_t *result = rte_zmalloc(NULL, + modex_test_case.result_len, 0); + + op = rte_crypto_op_alloc(t->ca_op_pool, + RTE_CRYPTO_OP_TYPE_ASYMMETRIC); + asym_op = op->asym; + asym_op->modex.base.data = modex_test_case.base.data; + asym_op->modex.base.length = modex_test_case.base.len; + asym_op->modex.result.data = result; + asym_op->modex.result.length = modex_test_case.result_len; + rte_crypto_op_attach_asym_session( + op, p->ca.crypto_sess[flow_counter++ % nb_flows]); + } while (rte_cryptodev_enqueue_burst(cdev_id, qp_id, &op, 1) != 1 && - t->done == false) + t->done == false) rte_pause(); count++; @@ -325,7 +423,6 @@ crypto_adapter_enq_op_new(struct prod_data *p) static inline void crypto_adapter_enq_op_fwd(struct prod_data *p) { - struct rte_cryptodev_sym_session **crypto_sess = p->ca.crypto_sess; const uint8_t dev_id = p->dev_id; const uint8_t port = p->port_id; struct test_perf *t = p->t; @@ -333,7 +430,6 @@ crypto_adapter_enq_op_fwd(struct prod_data *p) const uint64_t nb_pkts = t->nb_pkts; struct rte_mempool *pool = t->pool; struct evt_options *opt = t->opt; - struct rte_crypto_sym_op *sym_op; uint32_t flow_counter = 0; struct rte_crypto_op *op; struct rte_event ev; @@ -354,19 +450,37 @@ crypto_adapter_enq_op_fwd(struct prod_data *p) len = opt->mbuf_sz ? opt->mbuf_sz : RTE_ETHER_MIN_LEN; while (count < nb_pkts && t->done == false) { - m = rte_pktmbuf_alloc(pool); - if (m == NULL) - continue; + if (opt->crypto_op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { + struct rte_crypto_sym_op *sym_op; - rte_pktmbuf_append(m, len); - op = rte_crypto_op_alloc(t->ca_op_pool, + op = rte_crypto_op_alloc(t->ca_op_pool, RTE_CRYPTO_OP_TYPE_SYMMETRIC); - sym_op = op->sym; - sym_op->m_src = m; - sym_op->cipher.data.offset = 0; - sym_op->cipher.data.length = len; - rte_crypto_op_attach_sym_session( - op, crypto_sess[flow_counter++ % nb_flows]); + m = rte_pktmbuf_alloc(pool); + if (m == NULL) + continue; + + rte_pktmbuf_append(m, len); + sym_op = op->sym; + sym_op->m_src = m; + sym_op->cipher.data.offset = 0; + sym_op->cipher.data.length = len; + rte_crypto_op_attach_sym_session( + op, p->ca.crypto_sess[flow_counter++ % nb_flows]); + } else { + struct rte_crypto_asym_op *asym_op; + uint8_t *result = rte_zmalloc(NULL, + modex_test_case.result_len, 0); + + op = rte_crypto_op_alloc(t->ca_op_pool, + RTE_CRYPTO_OP_TYPE_ASYMMETRIC); + asym_op = op->asym; + asym_op->modex.base.data = modex_test_case.base.data; + asym_op->modex.base.length = modex_test_case.base.len; + asym_op->modex.result.data = result; + asym_op->modex.result.length = modex_test_case.result_len; + rte_crypto_op_attach_asym_session( + op, p->ca.crypto_sess[flow_counter++ % nb_flows]); + } ev.event_ptr = op; while (rte_event_crypto_adapter_enqueue(dev_id, port, &ev, 1) != 1 && @@ -729,6 +843,37 @@ cryptodev_sym_sess_create(struct prod_data *p, struct test_perf *t) return sess; } +static void * +cryptodev_asym_sess_create(struct prod_data *p, struct test_perf *t) +{ + const struct rte_cryptodev_asymmetric_xform_capability *capability; + struct rte_cryptodev_asym_capability_idx cap_idx; + struct rte_crypto_asym_xform xform; + void *sess; + + xform.next = NULL; + xform.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX; + cap_idx.type = xform.xform_type; + capability = rte_cryptodev_asym_capability_get(p->ca.cdev_id, &cap_idx); + if (capability == NULL) { + evt_err("Device doesn't support MODEX. Test Skipped\n"); + return NULL; + } + + xform.modex.modulus.data = modex_test_case.modulus.data; + xform.modex.modulus.length = modex_test_case.modulus.len; + xform.modex.exponent.data = modex_test_case.exponent.data; + xform.modex.exponent.length = modex_test_case.exponent.len; + + if (rte_cryptodev_asym_session_create(p->ca.cdev_id, &xform, + t->ca_asym_sess_pool, &sess)) { + evt_err("Failed to create asym session"); + return NULL; + } + + return sess; +} + int perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt, uint8_t stride, uint8_t nb_queues, @@ -804,7 +949,6 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt, prod = 0; for (; port < perf_nb_event_ports(opt); port++) { - struct rte_cryptodev_sym_session *crypto_sess; union rte_event_crypto_metadata m_data; struct prod_data *p = &t->prod[port]; uint32_t flow_id; @@ -820,7 +964,7 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt, p->ca.cdev_id = cdev_id; p->ca.cdev_qp_id = qp_id; p->ca.crypto_sess = rte_zmalloc_socket( - NULL, sizeof(crypto_sess) * t->nb_flows, + NULL, sizeof(void *) * t->nb_flows, RTE_CACHE_LINE_SIZE, opt->socket_id); p->t = t; @@ -830,18 +974,36 @@ perf_event_dev_port_setup(struct evt_test *test, struct evt_options *opt, m_data.response_info.queue_id = p->queue_id; for (flow_id = 0; flow_id < t->nb_flows; flow_id++) { - crypto_sess = cryptodev_sym_sess_create(p, t); - if (crypto_sess == NULL) - return -ENOMEM; - m_data.response_info.flow_id = flow_id; - rte_cryptodev_session_event_mdata_set(cdev_id, - crypto_sess, + if (opt->crypto_op_type == + RTE_CRYPTO_OP_TYPE_SYMMETRIC) { + struct rte_cryptodev_sym_session *sess; + + sess = cryptodev_sym_sess_create(p, t); + if (sess == NULL) + return -ENOMEM; + + rte_cryptodev_session_event_mdata_set( + cdev_id, + sess, RTE_CRYPTO_OP_TYPE_SYMMETRIC, RTE_CRYPTO_OP_WITH_SESSION, &m_data); + p->ca.crypto_sess[flow_id] = sess; + } else { + void *sess; - p->ca.crypto_sess[flow_id] = crypto_sess; + sess = cryptodev_asym_sess_create(p, t); + if (sess == NULL) + return -ENOMEM; + rte_cryptodev_session_event_mdata_set( + cdev_id, + sess, + RTE_CRYPTO_OP_TYPE_ASYMMETRIC, + RTE_CRYPTO_OP_WITH_SESSION, + &m_data); + p->ca.crypto_sess[flow_id] = sess; + } } conf.event_port_cfg |= @@ -1123,14 +1285,24 @@ perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) } t->ca_op_pool = rte_crypto_op_pool_create( - "crypto_op_pool", RTE_CRYPTO_OP_TYPE_SYMMETRIC, opt->pool_sz, - 128, 0, rte_socket_id()); + "crypto_op_pool", opt->crypto_op_type, opt->pool_sz, + 128, sizeof(union rte_event_crypto_metadata), + rte_socket_id()); if (t->ca_op_pool == NULL) { evt_err("Failed to create crypto op pool"); return -ENOMEM; } nb_sessions = evt_nr_active_lcores(opt->plcores) * t->nb_flows; + t->ca_asym_sess_pool = rte_cryptodev_asym_session_pool_create( + "ca_asym_sess_pool", nb_sessions, 0, + sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY); + if (t->ca_asym_sess_pool == NULL) { + evt_err("Failed to create sym session pool"); + ret = -ENOMEM; + goto err; + } + t->ca_sess_pool = rte_cryptodev_sym_session_pool_create( "ca_sess_pool", nb_sessions, 0, 0, sizeof(union rte_event_crypto_metadata), SOCKET_ID_ANY); @@ -1217,6 +1389,7 @@ perf_cryptodev_setup(struct evt_test *test, struct evt_options *opt) rte_mempool_free(t->ca_op_pool); rte_mempool_free(t->ca_sess_pool); rte_mempool_free(t->ca_sess_priv_pool); + rte_mempool_free(t->ca_asym_sess_pool); return ret; } @@ -1258,6 +1431,7 @@ perf_cryptodev_destroy(struct evt_test *test, struct evt_options *opt) rte_mempool_free(t->ca_op_pool); rte_mempool_free(t->ca_sess_pool); rte_mempool_free(t->ca_sess_priv_pool); + rte_mempool_free(t->ca_asym_sess_pool); } int diff --git a/app/test-eventdev/test_perf_common.h b/app/test-eventdev/test_perf_common.h index ea0907d61a..5651832cc9 100644 --- a/app/test-eventdev/test_perf_common.h +++ b/app/test-eventdev/test_perf_common.h @@ -40,7 +40,7 @@ struct worker_data { struct crypto_adptr_data { uint8_t cdev_id; uint16_t cdev_qp_id; - struct rte_cryptodev_sym_session **crypto_sess; + void **crypto_sess; }; struct prod_data { uint8_t dev_id; @@ -70,6 +70,7 @@ struct test_perf { struct rte_mempool *ca_op_pool; struct rte_mempool *ca_sess_pool; struct rte_mempool *ca_sess_priv_pool; + struct rte_mempool *ca_asym_sess_pool; } __rte_cache_aligned; struct perf_elt { @@ -111,8 +112,6 @@ perf_process_last_stage(struct rte_mempool *const pool, struct rte_event *const ev, struct worker_data *const w, void *bufs[], int const buf_sz, uint8_t count) { - bufs[count++] = ev->event_ptr; - /* release fence here ensures event_prt is * stored before updating the number of * processed packets for worker lcores @@ -120,9 +119,19 @@ perf_process_last_stage(struct rte_mempool *const pool, rte_atomic_thread_fence(__ATOMIC_RELEASE); w->processed_pkts++; - if (unlikely(count == buf_sz)) { - count = 0; - rte_mempool_put_bulk(pool, bufs, buf_sz); + if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV && + ((struct rte_crypto_op *)ev->event_ptr)->type == + RTE_CRYPTO_OP_TYPE_ASYMMETRIC) { + struct rte_crypto_op *op = ev->event_ptr; + + rte_free(op->asym->modex.result.data); + rte_crypto_op_free(op); + } else { + bufs[count++] = ev->event_ptr; + if (unlikely(count == buf_sz)) { + count = 0; + rte_mempool_put_bulk(pool, bufs, buf_sz); + } } return count; } @@ -135,8 +144,6 @@ perf_process_last_stage_latency(struct rte_mempool *const pool, uint64_t latency; struct perf_elt *const m = ev->event_ptr; - bufs[count++] = ev->event_ptr; - /* release fence here ensures event_prt is * stored before updating the number of * processed packets for worker lcores @@ -144,15 +151,23 @@ perf_process_last_stage_latency(struct rte_mempool *const pool, rte_atomic_thread_fence(__ATOMIC_RELEASE); w->processed_pkts++; - if (unlikely(count == buf_sz)) { - count = 0; - latency = rte_get_timer_cycles() - m->timestamp; - rte_mempool_put_bulk(pool, bufs, buf_sz); + if (ev->event_type == RTE_EVENT_TYPE_CRYPTODEV && + ((struct rte_crypto_op *)m)->type == + RTE_CRYPTO_OP_TYPE_ASYMMETRIC) { + rte_free(((struct rte_crypto_op *)m)->asym->modex.result.data); + rte_crypto_op_free((struct rte_crypto_op *)m); } else { - latency = rte_get_timer_cycles() - m->timestamp; + bufs[count++] = ev->event_ptr; + if (unlikely(count == buf_sz)) { + count = 0; + latency = rte_get_timer_cycles() - m->timestamp; + rte_mempool_put_bulk(pool, bufs, buf_sz); + } else { + latency = rte_get_timer_cycles() - m->timestamp; + } + + w->latency += latency; } - - w->latency += latency; return count; } diff --git a/app/test-eventdev/test_perf_queue.c b/app/test-eventdev/test_perf_queue.c index dcf6d82947..631a39f727 100644 --- a/app/test-eventdev/test_perf_queue.c +++ b/app/test-eventdev/test_perf_queue.c @@ -55,11 +55,13 @@ perf_queue_worker(void *arg, const int enable_fwd_latency) struct rte_crypto_op *op = ev.event_ptr; if (op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) { - if (op->sym->m_dst == NULL) - ev.event_ptr = op->sym->m_src; - else - ev.event_ptr = op->sym->m_dst; - rte_crypto_op_free(op); + if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { + if (op->sym->m_dst == NULL) + ev.event_ptr = op->sym->m_src; + else + ev.event_ptr = op->sym->m_dst; + rte_crypto_op_free(op); + } } else { rte_crypto_op_free(op); continue; diff --git a/doc/guides/tools/testeventdev.rst b/doc/guides/tools/testeventdev.rst index f7d813226d..a8e02d57a4 100644 --- a/doc/guides/tools/testeventdev.rst +++ b/doc/guides/tools/testeventdev.rst @@ -157,6 +157,11 @@ The following are the application command-line options: Set crypto adapter mode. Use 0 for OP_NEW (default) and 1 for OP_FORWARD mode. +* ``--crypto_op_type`` + + Set crypto operation type. Use 0 for symmetric crypto ops (default) + and 1 for asymmetric crypto ops. + * ``--mbuf_sz`` Set packet mbuf size. Can be used to configure Jumbo Frames. Only