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 DCB1D45AEE; Wed, 9 Oct 2024 09:12:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 628194060C; Wed, 9 Oct 2024 09:12:02 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 85131402BC for ; Wed, 9 Oct 2024 09:12:01 +0200 (CEST) Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49971ceX011175; Wed, 9 Oct 2024 00:12:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=z q01VKJkG7HhW/h93XFLb4D2z32hjiUnHcUaI6OoTXs=; b=LrFhnfS7EmlHr4I3Z M3v4FWwQTnkvk9K4nt5qVDotrmf2KDb60mgjaKPqKKLmA6oPToAh7lbS4pJxiKf6 8aZW3NNPhkUeF65DYzJ0w5BHC8KA4PZWMts5Vi+/HITOeudduhI3OLY/fGsMciee omm8AUzg4bI74QdQbBJJg8l725zXJC/J3UuR6RJn63hUXGGu56TAyM7XPJ1xICCh T4AmI2ZkzSItTWshiS28FAyZaWZ9KnMc7j6+9sPyCRiu1RRCvN/Po6Q1Lqw1TbCL waBtBS0gKp5UfVFSvphSr98fJaTl5cz15EwGDBsBpCxxCzDwkoXvNoCkHVcqxEg6 DTtoQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 425n2yr0m9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Oct 2024 00:12:00 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 9 Oct 2024 00:11:59 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 9 Oct 2024 00:11:59 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 9FC2E5B693B; Wed, 9 Oct 2024 00:11:56 -0700 (PDT) From: Gowrishankar Muthukrishnan To: , , Akhil Goyal , Fan Zhang CC: Anoob Joseph , , "Kai Ji" , , Gowrishankar Muthukrishnan Subject: [PATCH v3 1/3] cryptodev: add asymmetric operational capability Date: Wed, 9 Oct 2024 12:41:47 +0530 Message-ID: <20241009071151.1106-1-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20241004181255.916-1-gmuthukrishn@marvell.com> References: <20241004181255.916-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: qELyJYTFzBYybVlqu4EuK38dpzbyIRxf X-Proofpoint-ORIG-GUID: qELyJYTFzBYybVlqu4EuK38dpzbyIRxf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_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 Asymmetric crypto algorithms such as SM2, EdDSA would need per op capability and based on it, the input param to a crypto operation is chosen wisely. Signed-off-by: Gowrishankar Muthukrishnan --- v3: - Removed unused rte_crypto_sm2_op_capa enum value RTE_CRYPTO_SM2_PKE_KDF. HW that needs it can add this enum. - Test and driver changes split from it and follows within same series. --- lib/cryptodev/rte_crypto_asym.h | 10 ++++++++++ lib/cryptodev/rte_cryptodev.c | 16 ++++++++++++++++ lib/cryptodev/rte_cryptodev.h | 23 +++++++++++++++++++++++ lib/cryptodev/version.map | 3 +++ 4 files changed, 52 insertions(+) diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h index 39d3da3952..1adbe9c389 100644 --- a/lib/cryptodev/rte_crypto_asym.h +++ b/lib/cryptodev/rte_crypto_asym.h @@ -633,6 +633,16 @@ struct rte_crypto_asym_xform { }; }; +/** + * SM2 operation capabilities + */ +enum rte_crypto_sm2_op_capa { + RTE_CRYPTO_SM2_RNG, + /**< Random number generator supported in SM2 ops. */ + RTE_CRYPTO_SM2_PH, + /**< Prehash message before crypto op. */ +}; + /** * SM2 operation params. */ diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 682c9f49d0..d3d8e25b39 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -628,6 +628,22 @@ rte_cryptodev_asym_xform_capability_check_hash( return ret; } +int +rte_cryptodev_asym_xform_capability_check_opcap( + const struct rte_cryptodev_asymmetric_xform_capability *capability, + enum rte_crypto_asym_op_type op_type, uint8_t cap) +{ + int ret = 0; + + if (!(capability->op_types & (1 << op_type))) + return ret; + + if (capability->op_capa[op_type] & (1 << cap)) + ret = 1; + + return ret; +} + /* spinlock for crypto device enq callbacks */ static rte_spinlock_t rte_cryptodev_callback_lock = RTE_SPINLOCK_INITIALIZER; diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h index bec947f6d5..aa6ef3a94d 100644 --- a/lib/cryptodev/rte_cryptodev.h +++ b/lib/cryptodev/rte_cryptodev.h @@ -185,6 +185,9 @@ struct rte_cryptodev_asymmetric_xform_capability { * Value 0 means unavailable, and application should pass the required * random value. Otherwise, PMD would internally compute the random number. */ + + uint32_t op_capa[RTE_CRYPTO_ASYM_OP_LIST_END]; + /**< Operation specific capabilities. */ }; uint64_t hash_algos; @@ -359,6 +362,26 @@ rte_cryptodev_asym_xform_capability_check_hash( const struct rte_cryptodev_asymmetric_xform_capability *capability, enum rte_crypto_auth_algorithm hash); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Check if op capability is supported + * + * @param capability Description of the asymmetric crypto capability. + * @param op_type op type + * @param cap op capability + * + * @return + * - Return 1 if the op capability is supported + * - Return 0 if unsupported + */ +__rte_experimental +int +rte_cryptodev_asym_xform_capability_check_opcap( + const struct rte_cryptodev_asymmetric_xform_capability *capability, + enum rte_crypto_asym_op_type op_type, uint8_t cap); + /** * Provide the cipher algorithm enum, given an algorithm string * diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map index 594c501855..5d40b7fed0 100644 --- a/lib/cryptodev/version.map +++ b/lib/cryptodev/version.map @@ -87,6 +87,9 @@ EXPERIMENTAL { # added in 24.03 __rte_cryptodev_trace_qp_depth_used; + + # added in 24.11 + rte_cryptodev_asym_xform_capability_check_opcap; }; INTERNAL { -- 2.21.0