From patchwork Sun Sep 11 05:23:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 604777 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:2213:b0:1da:4c02:b5e7 with SMTP id z19csp1853484ltw; Sat, 10 Sep 2022 22:24:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Tw8k1tH8K4r9SjIwcP8a2rBZJYmAbHYdwBdUe84eLbGLbaNfNeTYvMnun7DF/5Ex8t53Q X-Received: by 2002:a05:6000:384:b0:22a:5d05:c562 with SMTP id u4-20020a056000038400b0022a5d05c562mr1726385wrf.701.1662873855366; Sat, 10 Sep 2022 22:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662873855; cv=none; d=google.com; s=arc-20160816; b=xsUZn5Oate3xz8JKuHMeySzxAWkw8Q49DT7M0rTS86CDgqMkYDC6sN4m0YL/roupv2 P69LLPriywWrKJeZsU3bwAExxZ0h0uRne3y0iOjGIPUJPSLm2AkjvL5fGmh1bzkO/nv+ SBw2QTyFDNbLYwupZRjLMKwCbX+6BifxBkiudORjMywCIDre0OO9CcMhLEz4FZExk+iq 6Kl5Lm7Wffwa2LPxutYuk0qHG8THEpJjZIkJgVlDHUKXI/6v+IontBkvTnOsehHxP+bn MEIsWsoQgvTF4VwUzQClLDoLt9RX+hFUR1e/v5xbRe6unCWxKkpuCShX4vkVw4UHnwSM E/PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BGcdQOc1bnJ2ZCqvNh3r1sScWnwCKajO19G5gE2o2RA=; b=x7waRXeAX2bxcjfA2QVh196HDivjPjw1hm0p9i4XP8x4NESNE8G68ARbsiC9iONTts hffl6QbtH8YYCJ2mh8Oy2+Sk2TVVl8e3wP6JrOsCMMFf7mJu+4BcxVudBzPMhn1b1RxC I6UiNSemjO6dh7CmVsBgS4v1U8ZzbQY4mF8AlMpqgKZLjHrbz7ZqyDAjfaC9Wq0egbL7 UT3mAdpzPlnciI8sORfPzl3rDZl8Wn4FkswKZnp5AlydkXNcgcMGrm2SVmvEwGvJJkHI zsV9LGf6hfjuVWl00ndEU19tINWI2sa5h/vu/gLizb8eqhD9asDpvz6dsmHfe2qtCGmQ c2eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p+cPHkMd; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id w7-20020adfde87000000b00228639b6695si2815337wrl.815.2022.09.10.22.24.15; Sat, 10 Sep 2022 22:24:15 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p+cPHkMd; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 215C0427F1; Sun, 11 Sep 2022 07:24:15 +0200 (CEST) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mails.dpdk.org (Postfix) with ESMTP id A87AB4003C for ; Sun, 11 Sep 2022 07:24:13 +0200 (CEST) Received: by mail-pl1-f171.google.com with SMTP id jm11so5546249plb.13 for ; Sat, 10 Sep 2022 22:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=BGcdQOc1bnJ2ZCqvNh3r1sScWnwCKajO19G5gE2o2RA=; b=p+cPHkMdPGPDql9yWMcHhzHHS6z70tkFnwBdPyyzwg67ahQLKY8uwK4769WB774JWY 3y6conOkDtG2kQcLbnMZ1OAIVca38aA5+GlsII0S9ckUox5sPocLAvc/cqvnan/OGcVl nzpEb0VQAJXa6ZAKgBxUzHQkqO3WNNtTxlvX1W5TD0UETrqiHye261PjetMgdakjCyhf 1Qd4OEOe9Ox2X/tTsAZckPNtIb1so5WEHv9f9eqD23P6hbXDLnuQnhKL83wGbykx+EWm 6SRLD4qrd7Bu9GeTaGOKKT5MNLRa5HJNMJjy/hshEco/Mx8kznQ5qPHe3rgNKLBvQFSd URnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=BGcdQOc1bnJ2ZCqvNh3r1sScWnwCKajO19G5gE2o2RA=; b=2i7vwuKkX2P96i3owsGbJkbOEqUWhoLftSfKqTmOxxXSBpN6mm7UUgaCjHvNKccrJc u8M15N5/Ebb/IzzLSkjZgIkJgHbn0SJEZbnDfCZivUsleLYmh5PsB1auznEOe3sMvJ3t L8PqwlGfk+9JsEb9ltXzJgnqZu1Tyf9gJ04vJgXSGqx2wESrKdxsy0BS5d1e5MWaqMBa RujGNV3V6s1O3uC8+McgLiJ/CKUFgQTHxXMmFaiOleXgAnJ8JhipCu7UArpJEGwJQE3k p5ch6+l83IdKqeZ2jKccjgVR+pSr/iOTL7ODmHSfV4JaRvA9Qb31Bbu658QLewGB1jW9 jp1Q== X-Gm-Message-State: ACgBeo09fQHLiyFj8DIXl35bkvm1wfqHhEO+rwuGHfBNdCfHJGiZ15si VCNypUVaU4TBcmcqeBYyaGeCcw== X-Received: by 2002:a17:903:3294:b0:176:8d60:b947 with SMTP id jh20-20020a170903329400b001768d60b947mr20730189plb.56.1662873852974; Sat, 10 Sep 2022 22:24:12 -0700 (PDT) Received: from localhost.localdomain ([199.101.192.45]) by smtp.gmail.com with ESMTPSA id z11-20020a170902cccb00b00173cfaed233sm3215860ple.62.2022.09.10.22.24.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Sep 2022 22:24:12 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Declan Doherty , Fan Zhang , Ashish Gupta , Ray Kinsella Cc: dev@dpdk.org, acc@openeuler.org, Zhangfei Gao Subject: [PATCH 1/5] test/crypto: add cryptodev_uadk_autotest Date: Sun, 11 Sep 2022 13:23:40 +0800 Message-Id: <20220911052344.31239-2-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220911052344.31239-1-zhangfei.gao@linaro.org> References: <20220911052344.31239-1-zhangfei.gao@linaro.org> MIME-Version: 1.0 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 Example: sudo dpdk-test --vdev=crypto_uadk --log-level=6 RTE>>cryptodev_uadk_autotest RTE>>quit Signed-off-by: Zhangfei Gao --- app/test/test_cryptodev.c | 7 +++++++ app/test/test_cryptodev.h | 1 + 2 files changed, 8 insertions(+) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 6ee4480399..7541cffd36 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -16580,6 +16580,12 @@ test_cryptodev_qat(void) return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)); } +static int +test_cryptodev_uadk(void) +{ + return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD)); +} + static int test_cryptodev_virtio(void) { @@ -16923,6 +16929,7 @@ REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl); REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec); REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec); REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp); +REGISTER_TEST_COMMAND(cryptodev_uadk_autotest, test_cryptodev_uadk); REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio); REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx); REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr); diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h index 29a7d4db2b..abd795f54a 100644 --- a/app/test/test_cryptodev.h +++ b/app/test/test_cryptodev.h @@ -74,6 +74,7 @@ #define CRYPTODEV_NAME_CN9K_PMD crypto_cn9k #define CRYPTODEV_NAME_CN10K_PMD crypto_cn10k #define CRYPTODEV_NAME_MLX5_PMD crypto_mlx5 +#define CRYPTODEV_NAME_UADK_PMD crypto_uadk enum cryptodev_api_test_type { From patchwork Sun Sep 11 05:23:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 604778 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:2213:b0:1da:4c02:b5e7 with SMTP id z19csp1853538ltw; Sat, 10 Sep 2022 22:24:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ghlsYS2HKuqmq3Q09CDP5d8or4NoAZBUmUPdX9Ir2SrHvkE1MDIizJ8pv3sGJSP2dLvjw X-Received: by 2002:a5d:584e:0:b0:22a:7a88:a400 with SMTP id i14-20020a5d584e000000b0022a7a88a400mr305725wrf.266.1662873865525; Sat, 10 Sep 2022 22:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662873865; cv=none; d=google.com; s=arc-20160816; b=0fwjWU+0s3RpVc8kBG6hGx/b0hdlA8BQ+2IGSbWBnHj7bnXGJCiE2WvbcSiTo2zKlt ZS4G0hFCMlbTpR16hC/dB/UnS3HXlvoTKevViC84LGE8weNEzahGY3Pa9EQTKGUTzf8b N89dYhF+1+uT8Ou+LNGcrupaJ7ozbtwPgWiIY16m6qNNTNBdUl84tsaKSdrqayqGuDqz npb+8cZDlIN1B/hCNSCah6ZweVpKlhVv+vfOFWzFvTdk+uFc+NfNM+mf8lmqhq6unaS5 9g5tmrxyr7XUX9aM6FKKjfRTIA8oYPSHIlbFVhR/CbDi0NAJV6Mm773C49qhAqMrwXJy O8xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bg4zxlYgNgfTOImrS9WKNjlTBHx83DVzXbQ2GI6H+Os=; b=zAIK+8NH1wuSCgmkd5c6MIX7kYscDAhu7G5fUzaGfE5noIC2YiSalGlfj55nAEpZP9 WOwkQJtcsx+p7qIJUaL7+9kzVh+lpUYssEKnCm37hjR9lNNfXHxfcoHBRlNFMiXuJQbj XtSnlV0jXpbLxx+S6CIIHMlnSP3dFJcy16lplERqXoof36OeBcGflw20vukRIGGU1pTW vXmXVXs89GiojtHolQ2/jRYG6Mt6EHF9vyG8R7u27ZvLVEMtZ8iBIfZfdwmekemu2COD jE9uH13KmrDC9NyNGo6kGvEH5f8T7SWdx/0q0Onh/NxnXOeCKJa4v/wQ4MBUCEWuppFs euEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DpOFtILM; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id bi19-20020a05600c3d9300b003ad932f2657si3152118wmb.79.2022.09.10.22.24.25; Sat, 10 Sep 2022 22:24:25 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DpOFtILM; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 39C3C42802; Sun, 11 Sep 2022 07:24:25 +0200 (CEST) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mails.dpdk.org (Postfix) with ESMTP id 062F441156 for ; Sun, 11 Sep 2022 07:24:24 +0200 (CEST) Received: by mail-pl1-f171.google.com with SMTP id b21so5571801plz.7 for ; Sat, 10 Sep 2022 22:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=bg4zxlYgNgfTOImrS9WKNjlTBHx83DVzXbQ2GI6H+Os=; b=DpOFtILM748YPdxlrVEFEOoxQPGrm9CVIJkP9WJE+M7sMuSZHvzqiublV7pdKd44qE Y3fTHGxZRVRV1LCRx9jVllNvDakQSny6oYWWCbTDKBxHmrcYJR5/Uju/E3ZpiGM5GL2Q NJn1FYYimrkN7AgXLlvWuhOc1xrgU4PeUkbuleuGMxKTDxoaYaSXpGmIOygHKNpmXFfG 1vP6tI8ni6S1mVcm6/Gt4bq+6cyKFl+NexXA1fiChncR3lpt9r91EqDMra8JblqN9jmU rAyKSPtrbB0zKw70Uz0iJAQ5364ULXkDMsxLFkaqorZQd5SPH1wadGTBDVuRlMa3hzRP szMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=bg4zxlYgNgfTOImrS9WKNjlTBHx83DVzXbQ2GI6H+Os=; b=0Pjyi+GM8A3gy87paa8WgAIBuuX7WaPyJc5UCIL/8SCwY0uTpSUpFQyRtxbcf8mnQ4 UQVc6V7RIBVsGirk3+QR0FYh03dvBoO6RSOkCMTdDgBfp9ZEnJgsqBCJUKXr4z3zMDYe +TmPcPHLmu1uhSXwT359GPNyrEWO00KKWWNQd75bEaMdP5rVzxCeC0UzrakrmIVEr7YJ l4z/toxM2jaHz12/gP7Znt2El4t8GXynK3AOgJ0LzF3p+vF3liYc8sZRBP0uHsVa3iUW wOhg35Icmttawr+InlLyY2eQBvSoma3yPAVabbgOXtJr4OfW1cGD/QQafnOKfaqhuomW Ql4w== X-Gm-Message-State: ACgBeo0WI2qlw1d8lLw015VX9q/YqFVhe+m39yqdg5LPp8eDfmK3i4IJ cwoIUKIqqaCJMsXKV62rqFjTavme5OVZow== X-Received: by 2002:a17:903:41c6:b0:16f:3d1:f63 with SMTP id u6-20020a17090341c600b0016f03d10f63mr20851454ple.50.1662873863221; Sat, 10 Sep 2022 22:24:23 -0700 (PDT) Received: from localhost.localdomain ([199.101.192.45]) by smtp.gmail.com with ESMTPSA id z11-20020a170902cccb00b00173cfaed233sm3215860ple.62.2022.09.10.22.24.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Sep 2022 22:24:22 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Declan Doherty , Fan Zhang , Ashish Gupta , Ray Kinsella Cc: dev@dpdk.org, acc@openeuler.org, Zhangfei Gao Subject: [PATCH 2/5] crypto/uadk: introduce uadk crypto driver Date: Sun, 11 Sep 2022 13:23:41 +0800 Message-Id: <20220911052344.31239-3-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220911052344.31239-1-zhangfei.gao@linaro.org> References: <20220911052344.31239-1-zhangfei.gao@linaro.org> MIME-Version: 1.0 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 Introduce a new crypto PMD for UADK, which relies on UADK library [1]. UADK is a framework for user applications to access hardware accelerators. UADK relies on IOMMU SVA (Shared Virtual Address) feature, which share the same page table between IOMMU and MMU. Thereby user application can directly use virtual address for device dma, which enhances the performance as well as easy usability. Currently supported platforms: HiSilicon kunpeng920 & kunpeng930. This patch add basic framework. [1] https://github.com/Linaro/uadk Test: sudo dpdk-test --vdev=crypto_uadk (--log-level=6) RTE>>cryptodev_uadk_autotest RTE>>quit Signed-off-by: Zhangfei Gao --- drivers/crypto/meson.build | 1 + drivers/crypto/uadk/meson.build | 36 +++ drivers/crypto/uadk/uadk_crypto_pmd.c | 450 ++++++++++++++++++++++++++ drivers/crypto/uadk/version.map | 3 + 4 files changed, 490 insertions(+) create mode 100644 drivers/crypto/uadk/meson.build create mode 100644 drivers/crypto/uadk/uadk_crypto_pmd.c create mode 100644 drivers/crypto/uadk/version.map diff --git a/drivers/crypto/meson.build b/drivers/crypto/meson.build index 147b8cf633..ee5377deff 100644 --- a/drivers/crypto/meson.build +++ b/drivers/crypto/meson.build @@ -18,6 +18,7 @@ drivers = [ 'octeontx', 'openssl', 'scheduler', + 'uadk', 'virtio', ] diff --git a/drivers/crypto/uadk/meson.build b/drivers/crypto/uadk/meson.build new file mode 100644 index 0000000000..a67c6c7ca5 --- /dev/null +++ b/drivers/crypto/uadk/meson.build @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved. +# Copyright 2022-2023 Linaro ltd. + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +if arch_subdir != 'arm' or not dpdk_conf.get('RTE_ARCH_64') + build = false + reason = 'only supported on aarch64' + subdir_done() +endif + +sources = files( + 'uadk_crypto_pmd.c', +) + +deps += 'bus_vdev' +dep = cc.find_library('libwd_crypto', dirs: ['/usr/local/lib'], required: false) +if not dep.found() + build = false + reason = 'missing dependency, "libwd_crypto"' +else + ext_deps += dep +endif + +dep = cc.find_library('libwd', dirs: ['/usr/local/lib'], required: false) +if not dep.found() + build = false + reason = 'missing dependency, "libwd"' +else + ext_deps += dep +endif diff --git a/drivers/crypto/uadk/uadk_crypto_pmd.c b/drivers/crypto/uadk/uadk_crypto_pmd.c new file mode 100644 index 0000000000..486aeab08b --- /dev/null +++ b/drivers/crypto/uadk/uadk_crypto_pmd.c @@ -0,0 +1,450 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved. + * Copyright 2022-2023 Linaro ltd. + */ + +#include +#include +#include +#include +#include +#include + +/* Maximum length for digest (SHA-512 needs 64 bytes) */ +#define DIGEST_LENGTH_MAX 64 + +struct uadk_qp { + struct rte_ring *processed_pkts; + /* Ring for placing process packets */ + struct rte_cryptodev_stats qp_stats; + /* Queue pair statistics */ + uint16_t id; + /* Queue Pair Identifier */ + char name[RTE_CRYPTODEV_NAME_MAX_LEN]; + /* Unique Queue Pair Name */ + uint8_t temp_digest[DIGEST_LENGTH_MAX]; + /* Buffer used to store the digest generated + * by the driver when verifying a digest provided + * by the user (using authentication verify operation) + */ +} __rte_cache_aligned; + +enum uadk_chain_order { + UADK_CHAIN_NOT_SUPPORTED +}; + +struct uadk_crypto_session { + enum uadk_chain_order chain_order; +} __rte_cache_aligned; + +enum uadk_supported_platform { + UADK_KUNPENG920, + UADK_KUNPENG930, +}; + +struct uadk_crypto_priv { + enum uadk_supported_platform platform; +} __rte_cache_aligned; + +static uint8_t uadk_cryptodev_driver_id; + +RTE_LOG_REGISTER_DEFAULT(uadk_crypto_logtype, INFO); + +#define UADK_LOG(level, fmt, ...) \ + rte_log(RTE_LOG_ ## level, uadk_crypto_logtype, \ + "%s() line %u: " fmt "\n", __func__, __LINE__, \ + ## __VA_ARGS__) + +static const struct rte_cryptodev_capabilities uadk_crypto_920_capabilities[] = { + /* End of symmetric capabilities */ + RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() +}; + +/* Configure device */ +static int +uadk_crypto_pmd_config(struct rte_cryptodev *dev __rte_unused, + struct rte_cryptodev_config *config __rte_unused) +{ + return 0; +} + +/* Start device */ +static int +uadk_crypto_pmd_start(struct rte_cryptodev *dev __rte_unused) +{ + return 0; +} + +/* Stop device */ +static void +uadk_crypto_pmd_stop(struct rte_cryptodev *dev __rte_unused) +{ +} + +/* Close device */ +static int +uadk_crypto_pmd_close(struct rte_cryptodev *dev __rte_unused) +{ + return 0; +} + +/* Get device statistics */ +static void +uadk_crypto_pmd_stats_get(struct rte_cryptodev *dev, + struct rte_cryptodev_stats *stats) +{ + int qp_id; + + for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) { + struct uadk_qp *qp = dev->data->queue_pairs[qp_id]; + + stats->enqueued_count += qp->qp_stats.enqueued_count; + stats->dequeued_count += qp->qp_stats.dequeued_count; + stats->enqueue_err_count += qp->qp_stats.enqueue_err_count; + stats->dequeue_err_count += qp->qp_stats.dequeue_err_count; + } +} + +/* Reset device statistics */ +static void +uadk_crypto_pmd_stats_reset(struct rte_cryptodev *dev __rte_unused) +{ + int qp_id; + + for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) { + struct uadk_qp *qp = dev->data->queue_pairs[qp_id]; + + memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); + } +} + +/* Get device info */ +static void +uadk_crypto_pmd_info_get(struct rte_cryptodev *dev, + struct rte_cryptodev_info *dev_info) +{ + struct uadk_crypto_priv *priv = dev->data->dev_private; + + if (dev_info != NULL) { + dev_info->driver_id = dev->driver_id; + dev_info->driver_name = dev->device->driver->name; + dev_info->max_nb_queue_pairs = 128; + /* No limit of number of sessions */ + dev_info->sym.max_nb_sessions = 0; + dev_info->feature_flags = dev->feature_flags; + + if (priv->platform == UADK_KUNPENG920) + dev_info->capabilities = uadk_crypto_920_capabilities; + } +} + +/* Release queue pair */ +static int +uadk_crypto_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id) +{ + struct uadk_qp *qp = dev->data->queue_pairs[qp_id]; + + if (qp) { + rte_ring_free(qp->processed_pkts); + rte_free(qp); + dev->data->queue_pairs[qp_id] = NULL; + } + + return 0; +} + +/* set a unique name for the queue pair based on its name, dev_id and qp_id */ +static int +uadk_pmd_qp_set_unique_name(struct rte_cryptodev *dev, + struct uadk_qp *qp) +{ + unsigned int n = snprintf(qp->name, sizeof(qp->name), + "uadk_crypto_pmd_%u_qp_%u", + dev->data->dev_id, qp->id); + + if (n >= sizeof(qp->name)) + return -EINVAL; + + return 0; +} + +/* Create a ring to place process packets on */ +static struct rte_ring * +uadk_pmd_qp_create_processed_pkts_ring(struct uadk_qp *qp, + unsigned int ring_size, int socket_id) +{ + struct rte_ring *r = qp->processed_pkts; + + if (r) { + if (rte_ring_get_size(r) >= ring_size) { + UADK_LOG(INFO, "Reusing existing ring %s for processed packets", + qp->name); + return r; + } + + UADK_LOG(ERR, "Unable to reuse existing ring %s for processed packets", + qp->name); + return NULL; + } + + return rte_ring_create(qp->name, ring_size, socket_id, + RING_F_EXACT_SZ); +} + +static int +uadk_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, + const struct rte_cryptodev_qp_conf *qp_conf, + int socket_id) +{ + struct uadk_qp *qp; + + /* Free memory prior to re-allocation if needed. */ + if (dev->data->queue_pairs[qp_id] != NULL) + uadk_crypto_pmd_qp_release(dev, qp_id); + + /* Allocate the queue pair data structure. */ + qp = rte_zmalloc_socket("uadk PMD Queue Pair", sizeof(*qp), + RTE_CACHE_LINE_SIZE, socket_id); + if (qp == NULL) + return (-ENOMEM); + + qp->id = qp_id; + dev->data->queue_pairs[qp_id] = qp; + + if (uadk_pmd_qp_set_unique_name(dev, qp)) + goto qp_setup_cleanup; + + qp->processed_pkts = uadk_pmd_qp_create_processed_pkts_ring(qp, + qp_conf->nb_descriptors, socket_id); + if (qp->processed_pkts == NULL) + goto qp_setup_cleanup; + + memset(&qp->qp_stats, 0, sizeof(qp->qp_stats)); + + return 0; + +qp_setup_cleanup: + if (qp) { + rte_free(qp); + qp = NULL; + } + return -EINVAL; +} + +static unsigned int +uadk_crypto_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) +{ + return sizeof(struct uadk_crypto_session); +} + +static enum uadk_chain_order +uadk_get_chain_order(const struct rte_crypto_sym_xform *xform __rte_unused) +{ + enum uadk_chain_order res = UADK_CHAIN_NOT_SUPPORTED; + + return res; +} + +static int +uadk_crypto_sym_session_configure(struct rte_cryptodev *dev, + struct rte_crypto_sym_xform *xform, + struct rte_cryptodev_sym_session *session, + struct rte_mempool *mp) +{ + struct uadk_crypto_session *sess; + int ret; + + ret = rte_mempool_get(mp, (void *)&sess); + if (ret != 0) { + UADK_LOG(ERR, "Failed to get session %p private data from mempool", + sess); + return -ENOMEM; + } + + sess->chain_order = uadk_get_chain_order(xform); + switch (sess->chain_order) { + default: + ret = -ENOTSUP; + goto err; + } + + set_sym_session_private_data(session, dev->driver_id, sess); + + return 0; +err: + rte_mempool_put(mp, sess); + return ret; +} + +static void +uadk_crypto_sym_session_clear(struct rte_cryptodev *dev, + struct rte_cryptodev_sym_session *sess) +{ + struct uadk_crypto_session *priv_sess = + get_sym_session_private_data(sess, dev->driver_id); + + if (unlikely(priv_sess == NULL)) { + UADK_LOG(ERR, "Failed to get session %p private data.", priv_sess); + return; + } + + set_sym_session_private_data(sess, dev->driver_id, NULL); + rte_mempool_put(rte_mempool_from_obj(priv_sess), priv_sess); +} + +static struct rte_cryptodev_ops uadk_crypto_pmd_ops = { + .dev_configure = uadk_crypto_pmd_config, + .dev_start = uadk_crypto_pmd_start, + .dev_stop = uadk_crypto_pmd_stop, + .dev_close = uadk_crypto_pmd_close, + .stats_get = uadk_crypto_pmd_stats_get, + .stats_reset = uadk_crypto_pmd_stats_reset, + .dev_infos_get = uadk_crypto_pmd_info_get, + .queue_pair_setup = uadk_crypto_pmd_qp_setup, + .queue_pair_release = uadk_crypto_pmd_qp_release, + .sym_session_get_size = uadk_crypto_sym_session_get_size, + .sym_session_configure = uadk_crypto_sym_session_configure, + .sym_session_clear = uadk_crypto_sym_session_clear, +}; + +static uint16_t +uadk_crypto_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, + uint16_t nb_ops) +{ + struct uadk_qp *qp = queue_pair; + struct uadk_crypto_session *sess = NULL; + struct rte_crypto_op *op; + uint16_t enqd = 0; + int i, ret; + + for (i = 0; i < nb_ops; i++) { + op = ops[i]; + op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; + + if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { + if (likely(op->sym->session != NULL)) + sess = (struct uadk_crypto_session *) + get_sym_session_private_data( + op->sym->session, + uadk_cryptodev_driver_id); + } + + switch (sess->chain_order) { + default: + op->status = RTE_CRYPTO_OP_STATUS_ERROR; + break; + } + + if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) + op->status = RTE_CRYPTO_OP_STATUS_SUCCESS; + + if (op->status != RTE_CRYPTO_OP_STATUS_ERROR) { + ret = rte_ring_enqueue(qp->processed_pkts, (void *)op); + if (ret < 0) + goto enqueue_err; + qp->qp_stats.enqueued_count++; + enqd++; + } else { + /* increment count if failed to enqueue op */ + qp->qp_stats.enqueue_err_count++; + } + } + + return enqd; + +enqueue_err: + qp->qp_stats.enqueue_err_count++; + return enqd; +} + +static uint16_t +uadk_crypto_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops, + uint16_t nb_ops) +{ + struct uadk_qp *qp = queue_pair; + unsigned int nb_dequeued; + + nb_dequeued = rte_ring_dequeue_burst(qp->processed_pkts, + (void **)ops, nb_ops, NULL); + qp->qp_stats.dequeued_count += nb_dequeued; + + return nb_dequeued; +} + +static int +uadk_cryptodev_probe(struct rte_vdev_device *vdev) +{ + struct rte_cryptodev_pmd_init_params init_params = { + .name = "", + .private_data_size = sizeof(struct uadk_crypto_priv), + .max_nb_queue_pairs = + RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS, + }; + enum uadk_supported_platform platform = UADK_KUNPENG920; + struct uadk_crypto_priv *priv; + struct rte_cryptodev *dev; + struct uacce_dev *udev; + const char *name; + + udev = wd_get_accel_dev("cipher"); + if (!udev) + return -ENODEV; + + if (!strcmp(udev->api, "hisi_qm_v2")) + platform = UADK_KUNPENG920; + + free(udev); + + name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; + + dev = rte_cryptodev_pmd_create(name, &vdev->device, &init_params); + if (dev == NULL) { + UADK_LOG(ERR, "driver %s: create failed", init_params.name); + return -ENODEV; + } + + dev->dev_ops = &uadk_crypto_pmd_ops; + dev->driver_id = uadk_cryptodev_driver_id; + dev->dequeue_burst = uadk_crypto_dequeue_burst; + dev->enqueue_burst = uadk_crypto_enqueue_burst; + dev->feature_flags = RTE_CRYPTODEV_FF_HW_ACCELERATED | + RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO | + RTE_CRYPTODEV_FF_SYM_SESSIONLESS; + priv = dev->data->dev_private; + priv->platform = platform; + + rte_cryptodev_pmd_probing_finish(dev); + + return 0; +} + +static int +uadk_cryptodev_remove(struct rte_vdev_device *vdev) +{ + struct rte_cryptodev *cryptodev; + const char *name; + + name = rte_vdev_device_name(vdev); + if (name == NULL) + return -EINVAL; + + cryptodev = rte_cryptodev_pmd_get_named_dev(name); + if (cryptodev == NULL) + return -ENODEV; + + return rte_cryptodev_pmd_destroy(cryptodev); +} + +static struct rte_vdev_driver uadk_crypto_pmd = { + .probe = uadk_cryptodev_probe, + .remove = uadk_cryptodev_remove, +}; + +static struct cryptodev_driver uadk_crypto_drv; + +#define UADK_CRYPTO_DRIVER_NAME crypto_uadk +RTE_PMD_REGISTER_VDEV(UADK_CRYPTO_DRIVER_NAME, uadk_crypto_pmd); +RTE_PMD_REGISTER_CRYPTO_DRIVER(uadk_crypto_drv, uadk_crypto_pmd.driver, + uadk_cryptodev_driver_id); diff --git a/drivers/crypto/uadk/version.map b/drivers/crypto/uadk/version.map new file mode 100644 index 0000000000..c2e0723b4c --- /dev/null +++ b/drivers/crypto/uadk/version.map @@ -0,0 +1,3 @@ +DPDK_22 { + local: *; +}; From patchwork Sun Sep 11 05:23:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 604779 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:2213:b0:1da:4c02:b5e7 with SMTP id z19csp1853594ltw; Sat, 10 Sep 2022 22:24:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5cWzkrMCtk/MJZMxjHiQPnGe/Mn7T5Jcc3NFInV7LOgpb/z6TAaml92sd4DItiy+TNGMFE X-Received: by 2002:adf:f4cf:0:b0:228:63bd:da33 with SMTP id h15-20020adff4cf000000b0022863bdda33mr11680311wrp.181.1662873874679; Sat, 10 Sep 2022 22:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662873874; cv=none; d=google.com; s=arc-20160816; b=P1qd9pLx08DZlCbZLk1KcAShY3wPZpjuT2pwnSNBqdFphaqHTaPeJbgyTdDww6P6mY hGu2xrOl5p0WXA+o697/HSmEAL6POCDzKo1l6s6jyv197DUyCAD7h0LATHgfCXGbqw3o 7PvQVuL6mFvyKY3dPDlM/QdlfLGhVF2wZDvPlHYJ8tcD4L40BMGWd+Bg8O41i65qZY7L OoRemq378eKtd4mO9w1D4CBwD2juH+HeUQrihBz4VMot/GLtJmseujtlqqCUThvRYDxf QHx5CfSQZPhRWJjQpayydbdVTGqbEYWgQz7B7XdjUPq9lqLioZR1MQP3vez77xc37Wgk nCUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bIp7uo8Cy0S2bSTk/AXEBUjY0A2DZCNA6pH3Tq00+cc=; b=vDRHOPNbwemWeWbw70Xq9qye/S1wV34caKECEzbv+YvJ6jS5nhiRNbkivdysCWXnvS klNMO9SM3O99QaCkCT6BXYCCK80L3qDFFjPETa7DXaV9gf6u8rBiE3AUy1IZxbU1sOzH SK4On9oi3UEnWBpdkjGD+inF4ywjk9W82dvdQDpvHRv1mlnfPo1To/ViYfmGASp+ud2O 3D0wB8O/6Uv+IzVsiIF0QeCOjt0HRNTo1zoMSxb7Qy6fB32kfm1Gh/ThX8o1o9dR3wKY z/6N+xYuTaUCTKnDV0Jmt6GQiRO9gug9hZNgzvFHcuEz3vsrJwReiZjn8EFAVWDS9jZJ WaWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kre5GFvb; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id y13-20020a05600015cd00b00228c8fc8ec1si3392501wry.395.2022.09.10.22.24.34; Sat, 10 Sep 2022 22:24:34 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kre5GFvb; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 615994280D; Sun, 11 Sep 2022 07:24:34 +0200 (CEST) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mails.dpdk.org (Postfix) with ESMTP id 6C01C427F6 for ; Sun, 11 Sep 2022 07:24:33 +0200 (CEST) Received: by mail-pf1-f169.google.com with SMTP id y136so5569486pfb.3 for ; Sat, 10 Sep 2022 22:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=bIp7uo8Cy0S2bSTk/AXEBUjY0A2DZCNA6pH3Tq00+cc=; b=Kre5GFvbj5sGrCBqmJOE2zG1L+FtOvMRMb1bRC0Pv+t4lqP6CXMmyLJhT1Bk6CW5Z8 CTnii+Ra01MntXXMyvBR+41RaJAjcqIQGu7InjGRIWuJkBG1AdgqKUUopiuUIb6G4kqo cYRTPUmiIPkRYIFTFFiTamdwqqqoBxusjkHt3CCZRhrb9riRI0WV9GgWKAAtJbBcZyTh Y/64bdRydjCvP5UbmRjFG9K4tCe0AoHk1pJbqf3o1ke6W9ZrMQBgOC62x+lRwHWkPBRP C1SCt3nyYfp2rKC9UMfwfxjzM7lBRuWIsAdEHEYNqSHSifQzwV3HFMkOnd6WGW4IFZ10 0Dkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=bIp7uo8Cy0S2bSTk/AXEBUjY0A2DZCNA6pH3Tq00+cc=; b=TeKuTLFGjlBNgcTx4qbetkPcEW/KBxMHcTxUB+T6xssNImiRzI6C4Uwfm0aXsw3DJc zozVA2VvJnJuVfVC/Q/Q6wKT6sZmHuC8+XcrHQXO4HDpR74AdGqAwsMEqur+6RSyCL6f K2KLgoo29fBaL7qCb7PocVXc1omyIpcBvAhB/o9FCBXoFPx37HPY1yZuFRaWQl3LdDbo taHWD74bTvnO8BJ1WEZ3RcSSUL2jU4aUJQdGbt7MENXdzW3P2j8ONWl7TZuoFLLnvaMy L3FDv0KIO6spPMALKUmqgsGyEChEOtsqcI+9Ov+7BuHrQuYo1VlAAJ6lohF4xR+1m7uL zb+g== X-Gm-Message-State: ACgBeo0Ir4YRnHntwNTITg3aEoyHPi/UloJP6M66JGnYjvNkRmWcuyuV WWq8lnFCqAefMNYdKa3VHkQAxg== X-Received: by 2002:a63:6ac6:0:b0:437:ebac:3336 with SMTP id f189-20020a636ac6000000b00437ebac3336mr12448638pgc.364.1662873872640; Sat, 10 Sep 2022 22:24:32 -0700 (PDT) Received: from localhost.localdomain ([199.101.192.45]) by smtp.gmail.com with ESMTPSA id z11-20020a170902cccb00b00173cfaed233sm3215860ple.62.2022.09.10.22.24.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Sep 2022 22:24:32 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Declan Doherty , Fan Zhang , Ashish Gupta , Ray Kinsella Cc: dev@dpdk.org, acc@openeuler.org, Zhangfei Gao Subject: [PATCH 3/5] crypto/uadk: support cipher algorithms Date: Sun, 11 Sep 2022 13:23:42 +0800 Message-Id: <20220911052344.31239-4-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220911052344.31239-1-zhangfei.gao@linaro.org> References: <20220911052344.31239-1-zhangfei.gao@linaro.org> MIME-Version: 1.0 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 Cipher algorithms: * ``RTE_CRYPTO_CIPHER_AES_ECB`` * ``RTE_CRYPTO_CIPHER_AES_CBC`` * ``RTE_CRYPTO_CIPHER_AES_XTS`` * ``RTE_CRYPTO_CIPHER_DES_CBC`` Signed-off-by: Zhangfei Gao --- drivers/crypto/uadk/uadk_crypto_pmd.c | 254 +++++++++++++++++++++++++- 1 file changed, 252 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/uadk/uadk_crypto_pmd.c b/drivers/crypto/uadk/uadk_crypto_pmd.c index 486aeab08b..7ca3e3ecd8 100644 --- a/drivers/crypto/uadk/uadk_crypto_pmd.c +++ b/drivers/crypto/uadk/uadk_crypto_pmd.c @@ -30,11 +30,26 @@ struct uadk_qp { } __rte_cache_aligned; enum uadk_chain_order { + UADK_CHAIN_ONLY_CIPHER, UADK_CHAIN_NOT_SUPPORTED }; struct uadk_crypto_session { + handle_t handle_cipher; enum uadk_chain_order chain_order; + + /* IV parameters */ + struct { + uint16_t length; + uint16_t offset; + } iv; + + /* Cipher Parameters */ + struct { + enum rte_crypto_cipher_operation direction; + /* cipher operation direction */ + struct wd_cipher_req req; + } cipher; } __rte_cache_aligned; enum uadk_supported_platform { @@ -43,6 +58,7 @@ enum uadk_supported_platform { }; struct uadk_crypto_priv { + bool env_cipher_init; enum uadk_supported_platform platform; } __rte_cache_aligned; @@ -56,6 +72,86 @@ RTE_LOG_REGISTER_DEFAULT(uadk_crypto_logtype, INFO); ## __VA_ARGS__) static const struct rte_cryptodev_capabilities uadk_crypto_920_capabilities[] = { + { /* AES ECB */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, + {.cipher = { + .algo = RTE_CRYPTO_CIPHER_AES_ECB, + .block_size = 16, + .key_size = { + .min = 16, + .max = 32, + .increment = 8 + }, + .iv_size = { + .min = 0, + .max = 0, + .increment = 0 + } + }, } + }, } + }, + { /* AES CBC */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, + {.cipher = { + .algo = RTE_CRYPTO_CIPHER_AES_CBC, + .block_size = 16, + .key_size = { + .min = 16, + .max = 32, + .increment = 8 + }, + .iv_size = { + .min = 16, + .max = 16, + .increment = 0 + } + }, } + }, } + }, + { /* AES XTS */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, + {.cipher = { + .algo = RTE_CRYPTO_CIPHER_AES_XTS, + .block_size = 1, + .key_size = { + .min = 32, + .max = 64, + .increment = 32 + }, + .iv_size = { + .min = 0, + .max = 0, + .increment = 0 + } + }, } + }, } + }, + { /* DES CBC */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER, + {.cipher = { + .algo = RTE_CRYPTO_CIPHER_DES_CBC, + .block_size = 8, + .key_size = { + .min = 8, + .max = 8, + .increment = 0 + }, + .iv_size = { + .min = 8, + .max = 8, + .increment = 0 + } + }, } + }, } + }, /* End of symmetric capabilities */ RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() }; @@ -83,8 +179,15 @@ uadk_crypto_pmd_stop(struct rte_cryptodev *dev __rte_unused) /* Close device */ static int -uadk_crypto_pmd_close(struct rte_cryptodev *dev __rte_unused) +uadk_crypto_pmd_close(struct rte_cryptodev *dev) { + struct uadk_crypto_priv *priv = dev->data->dev_private; + + if (priv->env_cipher_init) { + wd_cipher_env_uninit(); + priv->env_cipher_init = false; + } + return 0; } @@ -238,19 +341,107 @@ uadk_crypto_sym_session_get_size(struct rte_cryptodev *dev __rte_unused) } static enum uadk_chain_order -uadk_get_chain_order(const struct rte_crypto_sym_xform *xform __rte_unused) +uadk_get_chain_order(const struct rte_crypto_sym_xform *xform) { enum uadk_chain_order res = UADK_CHAIN_NOT_SUPPORTED; + if (xform != NULL) { + if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER) { + if (xform->next == NULL) + res = UADK_CHAIN_ONLY_CIPHER; + } + } + return res; } +static int +uadk_set_session_cipher_parameters(struct rte_cryptodev *dev, + struct uadk_crypto_session *sess, + struct rte_crypto_sym_xform *xform) +{ + struct uadk_crypto_priv *priv = dev->data->dev_private; + struct rte_crypto_cipher_xform *cipher = &xform->cipher; + struct wd_cipher_sess_setup setup = {0}; + struct sched_params params = {0}; + int ret; + + if (!priv->env_cipher_init) { + ret = wd_cipher_env_init(NULL); + if (ret < 0) + return -EINVAL; + priv->env_cipher_init = true; + } + + sess->cipher.direction = cipher->op; + sess->iv.offset = cipher->iv.offset; + sess->iv.length = cipher->iv.length; + + switch (cipher->algo) { + /* Cover supported cipher algorithms */ + case RTE_CRYPTO_CIPHER_AES_CTR: + setup.alg = WD_CIPHER_AES; + setup.mode = WD_CIPHER_CTR; + sess->cipher.req.out_bytes = 64; + break; + case RTE_CRYPTO_CIPHER_AES_ECB: + setup.alg = WD_CIPHER_AES; + setup.mode = WD_CIPHER_ECB; + sess->cipher.req.out_bytes = 16; + break; + case RTE_CRYPTO_CIPHER_AES_CBC: + setup.alg = WD_CIPHER_AES; + setup.mode = WD_CIPHER_CBC; + if (cipher->key.length == 16) + sess->cipher.req.out_bytes = 16; + else + sess->cipher.req.out_bytes = 64; + break; + case RTE_CRYPTO_CIPHER_AES_XTS: + setup.alg = WD_CIPHER_AES; + setup.mode = WD_CIPHER_XTS; + if (cipher->key.length == 16) + sess->cipher.req.out_bytes = 32; + else + sess->cipher.req.out_bytes = 512; + break; + default: + ret = -ENOTSUP; + goto env_uninit; + } + + params.numa_id = -1; /* choose nearby numa node */ + setup.sched_param = ¶ms; + sess->handle_cipher = wd_cipher_alloc_sess(&setup); + if (!sess->handle_cipher) { + UADK_LOG(ERR, "uadk failed to alloc session!\n"); + ret = -EINVAL; + goto env_uninit; + } + + ret = wd_cipher_set_key(sess->handle_cipher, cipher->key.data, cipher->key.length); + if (ret) { + wd_cipher_free_sess(sess->handle_cipher); + UADK_LOG(ERR, "uadk failed to set key!\n"); + ret = -EINVAL; + goto env_uninit; + } + + return 0; + +env_uninit: + wd_cipher_env_uninit(); + priv->env_cipher_init = false; + return ret; +} + static int uadk_crypto_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, struct rte_cryptodev_sym_session *session, struct rte_mempool *mp) { + struct rte_crypto_sym_xform *cipher_xform = NULL; struct uadk_crypto_session *sess; int ret; @@ -263,11 +454,23 @@ uadk_crypto_sym_session_configure(struct rte_cryptodev *dev, sess->chain_order = uadk_get_chain_order(xform); switch (sess->chain_order) { + case UADK_CHAIN_ONLY_CIPHER: + cipher_xform = xform; + break; default: ret = -ENOTSUP; goto err; } + if (cipher_xform) { + ret = uadk_set_session_cipher_parameters(dev, sess, cipher_xform); + if (ret != 0) { + UADK_LOG(ERR, + "Invalid/unsupported cipher parameters"); + goto err; + } + } + set_sym_session_private_data(session, dev->driver_id, sess); return 0; @@ -288,6 +491,11 @@ uadk_crypto_sym_session_clear(struct rte_cryptodev *dev, return; } + if (priv_sess->handle_cipher) { + wd_cipher_free_sess(priv_sess->handle_cipher); + priv_sess->handle_cipher = 0; + } + set_sym_session_private_data(sess, dev->driver_id, NULL); rte_mempool_put(rte_mempool_from_obj(priv_sess), priv_sess); } @@ -307,12 +515,49 @@ static struct rte_cryptodev_ops uadk_crypto_pmd_ops = { .sym_session_clear = uadk_crypto_sym_session_clear, }; +static void +uadk_process_cipher_op(struct rte_crypto_op *op, + struct uadk_crypto_session *sess, + struct rte_mbuf *msrc, struct rte_mbuf *mdst) +{ + uint32_t off = op->sym->cipher.data.offset; + int ret; + + if (!sess) { + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return; + } + + sess->cipher.req.src = rte_pktmbuf_mtod_offset(msrc, uint8_t *, off); + sess->cipher.req.in_bytes = op->sym->cipher.data.length; + sess->cipher.req.dst = rte_pktmbuf_mtod_offset(mdst, uint8_t *, off); + sess->cipher.req.out_buf_bytes = sess->cipher.req.in_bytes; + sess->cipher.req.iv_bytes = sess->iv.length; + sess->cipher.req.iv = rte_crypto_op_ctod_offset(op, uint8_t *, + sess->iv.offset); + if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) + sess->cipher.req.op_type = WD_CIPHER_ENCRYPTION; + else + sess->cipher.req.op_type = WD_CIPHER_DECRYPTION; + + do { + ret = wd_do_cipher_sync(sess->handle_cipher, &sess->cipher.req); + } while (ret == -WD_EBUSY); + + if (sess->cipher.req.out_buf_bytes > sess->cipher.req.in_bytes) + op->status = RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED; + + if (ret) + op->status = RTE_COMP_OP_STATUS_ERROR; +} + static uint16_t uadk_crypto_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, uint16_t nb_ops) { struct uadk_qp *qp = queue_pair; struct uadk_crypto_session *sess = NULL; + struct rte_mbuf *msrc, *mdst; struct rte_crypto_op *op; uint16_t enqd = 0; int i, ret; @@ -320,6 +565,8 @@ uadk_crypto_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, for (i = 0; i < nb_ops; i++) { op = ops[i]; op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; + msrc = op->sym->m_src; + mdst = op->sym->m_dst ? op->sym->m_dst : op->sym->m_src; if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) { if (likely(op->sym->session != NULL)) @@ -330,6 +577,9 @@ uadk_crypto_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, } switch (sess->chain_order) { + case UADK_CHAIN_ONLY_CIPHER: + uadk_process_cipher_op(op, sess, msrc, mdst); + break; default: op->status = RTE_CRYPTO_OP_STATUS_ERROR; break; From patchwork Sun Sep 11 05:23:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 604780 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:2213:b0:1da:4c02:b5e7 with SMTP id z19csp1853649ltw; Sat, 10 Sep 2022 22:24:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Qs3LvRIHZmAgfv6Z5hWKwzoP7IvlGjoXFuCv4WQpHi+1KjIbOvIuIop5AbI9xY/jau6uO X-Received: by 2002:a05:600c:211a:b0:3b4:75ee:c63e with SMTP id u26-20020a05600c211a00b003b475eec63emr2373859wml.44.1662873885983; Sat, 10 Sep 2022 22:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662873885; cv=none; d=google.com; s=arc-20160816; b=GglYBxcmY6FKCvTTT5LHPG1X5nHRbsWjA/aALsMFDRCsWNxDjLkZoERfVHgvMqW7OX xvHZWLf9tmc1J6PpUPH69c/KQKekbhLWxgIVOMo+4oZJmpWlLTzrqPOCAT46b8RDnvxb zRI5opa5PZgp4mBUHKZe+MJmu28lc5QH3GsPHTn2ybMYL1yvacUdoFYQLlPxlB042Rgf KLA31dLdka77Q9r5US/XtS78sukYzIu5zbpTSIYOPlUU7fmehQ+BNUtVzEiW3eix24mb xRp5CIafU8cVIGsu1iUKAtcarKr9c0a4gA2WE4Y8cbQnGSif/uZnCQqgI9v6e20e+gZu G5yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tlwT6bU8yoMxo/vHHPcuO7Xm21mnVbwN64DJRq4bKx8=; b=pdtywVjr+U7HNUoUtS/O0ONmE66Xs7otfdER8QfTwWpaTW5yfE05oOzSkGnbMfuHT4 gv4G3ixHHNoEtQs3g8qO7uwf75AtuNUte8oopiAKOlYz1wxsHcdMOgXWtl7nTDH0VUkZ oG7Tnqn1dpNeVjTZHom0ooODQwYwB7oBxJ8QmoQhkLEHbf2nR43Tgcy6PitB4B6t+RY3 3LkSzTvmedAqAkTOENp/ApbS1pXR0aY5jD+4haXrWTf9v2WqC2LuOZ5Sx5F3Ow1VV2qD /xK1jQ8AftVtF2SpMBPZ7xSSrzGCWGVfMtGpghVhfxYSIOUSZjaJ9/6kex0nafofXNKz Irbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cCShGtdA; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id f7-20020a7bcc07000000b003b356093436si2782968wmh.66.2022.09.10.22.24.45; Sat, 10 Sep 2022 22:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cCShGtdA; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B11B5410D2; Sun, 11 Sep 2022 07:24:45 +0200 (CEST) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id C040C40156 for ; Sun, 11 Sep 2022 07:24:44 +0200 (CEST) Received: by mail-pl1-f170.google.com with SMTP id 9so5546580plj.11 for ; Sat, 10 Sep 2022 22:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=tlwT6bU8yoMxo/vHHPcuO7Xm21mnVbwN64DJRq4bKx8=; b=cCShGtdArrXNV/GWAeFLM3LqRjCIwFLgs+m1kNO4D/zVlwJOSkngZ+jb+Y5QvJBF2d xVR7ZQna6MShLWVBEoL3/L4uHDIa9+W6LrZFbA1ZeGEeXOQMO+S86QsD5XrTNHICkiin 9sLISnuyDLjIbyQOxEwjhDCqMbFGKCpniWo68DihdjemwjMfUqonxQQfEwbDljYBxV+J R7xFc/CH6fBcPQabqSQGzGVCLylMrCDO/t/w/Nw79iparwCeObV2plppTNaBCNm9E5ij vPivVk0e2FL/I5bV/156OCl5sQa14PKlQXNmOuOpAbRtlLfdLzDh3BCUno/0JUGDBIYu vykA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=tlwT6bU8yoMxo/vHHPcuO7Xm21mnVbwN64DJRq4bKx8=; b=NQpS43aXN7SFS1H5jVLMK97xGHqaSIQDPXOduCm7BgNs7F/CPVfV7JKtdBAh4nTUXD mBfXR07/QhVvE6ST8wffv6+JG3XFx+NOniozaAXR9AmEkeK2/2Zpk8iRvLbbiv6AcoSN Lil5w27v1sQ89SGO5tKQNeOIZFo2ZKl1x7mIAugnDva9ZbM6UqzluvyTTRwVy6xx6bb5 lb+wFsM5jNQz38E7Dx5GGMmmwzc9fNZGyrmy00U1fF7gs3xT7qml1iwWdfi5KcwIAUXI o7YfnPEya1phTaSOKfxOVvz2kWVRZxd7VR/glKezwhqYxHgjzo0pRAuqP6Et3dyApru6 Q4mA== X-Gm-Message-State: ACgBeo1L/wJMPat+BcDN6bTVG968MF7yvXpbhAJOUjM8PEELAyyTNUNY Wogd6Unp80lLcQezLd3iic69PQ== X-Received: by 2002:a17:902:ce8f:b0:176:e0b3:cf14 with SMTP id f15-20020a170902ce8f00b00176e0b3cf14mr20884308plg.153.1662873883959; Sat, 10 Sep 2022 22:24:43 -0700 (PDT) Received: from localhost.localdomain ([199.101.192.45]) by smtp.gmail.com with ESMTPSA id z11-20020a170902cccb00b00173cfaed233sm3215860ple.62.2022.09.10.22.24.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Sep 2022 22:24:43 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Declan Doherty , Fan Zhang , Ashish Gupta , Ray Kinsella Cc: dev@dpdk.org, acc@openeuler.org, Zhangfei Gao Subject: [PATCH 4/5] crypto/uadk: support auth algorithms Date: Sun, 11 Sep 2022 13:23:43 +0800 Message-Id: <20220911052344.31239-5-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220911052344.31239-1-zhangfei.gao@linaro.org> References: <20220911052344.31239-1-zhangfei.gao@linaro.org> MIME-Version: 1.0 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 Hash algorithms: * ``RTE_CRYPTO_AUTH_MD5`` * ``RTE_CRYPTO_AUTH_MD5_HMAC`` * ``RTE_CRYPTO_AUTH_SHA1`` * ``RTE_CRYPTO_AUTH_SHA1_HMAC`` * ``RTE_CRYPTO_AUTH_SHA224`` * ``RTE_CRYPTO_AUTH_SHA224_HMAC`` * ``RTE_CRYPTO_AUTH_SHA256`` * ``RTE_CRYPTO_AUTH_SHA256_HMAC`` * ``RTE_CRYPTO_AUTH_SHA384`` * ``RTE_CRYPTO_AUTH_SHA384_HMAC`` * ``RTE_CRYPTO_AUTH_SHA512`` * ``RTE_CRYPTO_AUTH_SHA512_HMAC`` Signed-off-by: Zhangfei Gao --- drivers/crypto/uadk/uadk_crypto_pmd.c | 461 ++++++++++++++++++++++++++ 1 file changed, 461 insertions(+) diff --git a/drivers/crypto/uadk/uadk_crypto_pmd.c b/drivers/crypto/uadk/uadk_crypto_pmd.c index 7ca3e3ecd8..a1196560b8 100644 --- a/drivers/crypto/uadk/uadk_crypto_pmd.c +++ b/drivers/crypto/uadk/uadk_crypto_pmd.c @@ -31,11 +31,15 @@ struct uadk_qp { enum uadk_chain_order { UADK_CHAIN_ONLY_CIPHER, + UADK_CHAIN_ONLY_AUTH, + UADK_CHAIN_CIPHER_AUTH, + UADK_CHAIN_AUTH_CIPHER, UADK_CHAIN_NOT_SUPPORTED }; struct uadk_crypto_session { handle_t handle_cipher; + handle_t handle_digest; enum uadk_chain_order chain_order; /* IV parameters */ @@ -50,6 +54,15 @@ struct uadk_crypto_session { /* cipher operation direction */ struct wd_cipher_req req; } cipher; + + /* Authentication Parameters */ + struct { + struct wd_digest_req req; + enum rte_crypto_auth_operation operation; + /* auth operation generate or verify */ + uint16_t digest_length; + /* digest length */ + } auth; } __rte_cache_aligned; enum uadk_supported_platform { @@ -59,6 +72,7 @@ enum uadk_supported_platform { struct uadk_crypto_priv { bool env_cipher_init; + bool env_auth_init; enum uadk_supported_platform platform; } __rte_cache_aligned; @@ -72,6 +86,252 @@ RTE_LOG_REGISTER_DEFAULT(uadk_crypto_logtype, INFO); ## __VA_ARGS__) static const struct rte_cryptodev_capabilities uadk_crypto_920_capabilities[] = { + { /* MD5 HMAC */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_MD5_HMAC, + .block_size = 64, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 16, + .max = 16, + .increment = 0 + }, + .iv_size = { 0 } + }, } + }, } + }, + { /* MD5 */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_MD5, + .block_size = 64, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 16, + .max = 16, + .increment = 0 + }, + }, } + }, } + }, + { /* SHA1 HMAC */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SHA1_HMAC, + .block_size = 64, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 20, + .max = 20, + .increment = 0 + }, + .iv_size = { 0 } + }, } + }, } + }, + { /* SHA1 */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SHA1, + .block_size = 64, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 20, + .max = 20, + .increment = 0 + }, + }, } + }, } + }, + { /* SHA224 HMAC */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SHA224_HMAC, + .block_size = 64, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 28, + .max = 28, + .increment = 0 + }, + .iv_size = { 0 } + }, } + }, } + }, + { /* SHA224 */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SHA224, + .block_size = 64, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 28, + .max = 28, + .increment = 0 + }, + }, } + }, } + }, + { /* SHA256 HMAC */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SHA256_HMAC, + .block_size = 64, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 32, + .max = 32, + .increment = 0 + }, + .iv_size = { 0 } + }, } + }, } + }, + { /* SHA256 */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SHA256, + .block_size = 64, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 32, + .max = 32, + .increment = 0 + }, + }, } + }, } + }, + { /* SHA384 HMAC */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SHA384_HMAC, + .block_size = 128, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 48, + .max = 48, + .increment = 0 + }, + .iv_size = { 0 } + }, } + }, } + }, + { /* SHA384 */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SHA384, + .block_size = 64, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 48, + .max = 48, + .increment = 0 + }, + }, } + }, } + }, + { /* SHA512 HMAC */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SHA512_HMAC, + .block_size = 128, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 64, + .max = 64, + .increment = 0 + }, + .iv_size = { 0 } + }, } + }, } + }, + { /* SHA512 */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, + {.auth = { + .algo = RTE_CRYPTO_AUTH_SHA512, + .block_size = 128, + .key_size = { + .min = 0, + .max = 0, + .increment = 0 + }, + .digest_size = { + .min = 64, + .max = 64, + .increment = 0 + }, + }, } + }, } + }, { /* AES ECB */ .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, {.sym = { @@ -188,6 +448,11 @@ uadk_crypto_pmd_close(struct rte_cryptodev *dev) priv->env_cipher_init = false; } + if (priv->env_auth_init) { + wd_digest_env_uninit(); + priv->env_auth_init = false; + } + return 0; } @@ -346,9 +611,19 @@ uadk_get_chain_order(const struct rte_crypto_sym_xform *xform) enum uadk_chain_order res = UADK_CHAIN_NOT_SUPPORTED; if (xform != NULL) { + if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH) { + if (xform->next == NULL) + res = UADK_CHAIN_ONLY_AUTH; + else if (xform->next->type == + RTE_CRYPTO_SYM_XFORM_CIPHER) + res = UADK_CHAIN_AUTH_CIPHER; + } + if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER) { if (xform->next == NULL) res = UADK_CHAIN_ONLY_CIPHER; + else if (xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH) + res = UADK_CHAIN_CIPHER_AUTH; } } @@ -435,6 +710,112 @@ uadk_set_session_cipher_parameters(struct rte_cryptodev *dev, return ret; } +/* Set session auth parameters */ +static int +uadk_set_session_auth_parameters(struct rte_cryptodev *dev, + struct uadk_crypto_session *sess, + struct rte_crypto_sym_xform *xform) +{ + struct uadk_crypto_priv *priv = dev->data->dev_private; + struct wd_digest_sess_setup setup = {0}; + struct sched_params params = {0}; + int ret; + + if (!priv->env_auth_init) { + ret = wd_digest_env_init(NULL); + if (ret < 0) + return -EINVAL; + priv->env_auth_init = true; + } + + sess->auth.operation = xform->auth.op; + sess->auth.digest_length = xform->auth.digest_length; + + switch (xform->auth.algo) { + case RTE_CRYPTO_AUTH_MD5: + case RTE_CRYPTO_AUTH_MD5_HMAC: + setup.mode = (xform->auth.algo == RTE_CRYPTO_AUTH_MD5) ? + WD_DIGEST_NORMAL : WD_DIGEST_HMAC; + setup.alg = WD_DIGEST_MD5; + sess->auth.req.out_buf_bytes = 16; + sess->auth.req.out_bytes = 16; + break; + case RTE_CRYPTO_AUTH_SHA1: + case RTE_CRYPTO_AUTH_SHA1_HMAC: + setup.mode = (xform->auth.algo == RTE_CRYPTO_AUTH_SHA1) ? + WD_DIGEST_NORMAL : WD_DIGEST_HMAC; + setup.alg = WD_DIGEST_SHA1; + sess->auth.req.out_buf_bytes = 20; + sess->auth.req.out_bytes = 20; + break; + case RTE_CRYPTO_AUTH_SHA224: + case RTE_CRYPTO_AUTH_SHA224_HMAC: + setup.mode = (xform->auth.algo == RTE_CRYPTO_AUTH_SHA224) ? + WD_DIGEST_NORMAL : WD_DIGEST_HMAC; + setup.alg = WD_DIGEST_SHA224; + sess->auth.req.out_buf_bytes = 28; + sess->auth.req.out_bytes = 28; + break; + case RTE_CRYPTO_AUTH_SHA256: + case RTE_CRYPTO_AUTH_SHA256_HMAC: + setup.mode = (xform->auth.algo == RTE_CRYPTO_AUTH_SHA256) ? + WD_DIGEST_NORMAL : WD_DIGEST_HMAC; + setup.alg = WD_DIGEST_SHA256; + sess->auth.req.out_buf_bytes = 32; + sess->auth.req.out_bytes = 32; + break; + case RTE_CRYPTO_AUTH_SHA384: + case RTE_CRYPTO_AUTH_SHA384_HMAC: + setup.mode = (xform->auth.algo == RTE_CRYPTO_AUTH_SHA384) ? + WD_DIGEST_NORMAL : WD_DIGEST_HMAC; + setup.alg = WD_DIGEST_SHA384; + sess->auth.req.out_buf_bytes = 48; + sess->auth.req.out_bytes = 48; + break; + case RTE_CRYPTO_AUTH_SHA512: + case RTE_CRYPTO_AUTH_SHA512_HMAC: + setup.mode = (xform->auth.algo == RTE_CRYPTO_AUTH_SHA512) ? + WD_DIGEST_NORMAL : WD_DIGEST_HMAC; + setup.alg = WD_DIGEST_SHA512; + sess->auth.req.out_buf_bytes = 64; + sess->auth.req.out_bytes = 64; + break; + default: + ret = -ENOTSUP; + goto env_uninit; + } + + params.numa_id = -1; /* choose nearby numa node */ + setup.sched_param = ¶ms; + sess->handle_digest = wd_digest_alloc_sess(&setup); + if (!sess->handle_digest) { + UADK_LOG(ERR, "uadk failed to alloc session!\n"); + ret = -EINVAL; + goto env_uninit; + } + + /* if mode is HMAC, should set key */ + if (setup.mode == WD_DIGEST_HMAC) { + ret = wd_digest_set_key(sess->handle_digest, + xform->auth.key.data, + xform->auth.key.length); + if (ret) { + UADK_LOG(ERR, "uadk failed to alloc session!\n"); + wd_digest_free_sess(sess->handle_digest); + sess->handle_digest = 0; + ret = -EINVAL; + goto env_uninit; + } + } + + return 0; + +env_uninit: + wd_digest_env_uninit(); + priv->env_auth_init = false; + return ret; +} + static int uadk_crypto_sym_session_configure(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, @@ -442,6 +823,7 @@ uadk_crypto_sym_session_configure(struct rte_cryptodev *dev, struct rte_mempool *mp) { struct rte_crypto_sym_xform *cipher_xform = NULL; + struct rte_crypto_sym_xform *auth_xform = NULL; struct uadk_crypto_session *sess; int ret; @@ -457,6 +839,17 @@ uadk_crypto_sym_session_configure(struct rte_cryptodev *dev, case UADK_CHAIN_ONLY_CIPHER: cipher_xform = xform; break; + case UADK_CHAIN_ONLY_AUTH: + auth_xform = xform; + break; + case UADK_CHAIN_CIPHER_AUTH: + cipher_xform = xform; + auth_xform = xform->next; + break; + case UADK_CHAIN_AUTH_CIPHER: + auth_xform = xform; + cipher_xform = xform->next; + break; default: ret = -ENOTSUP; goto err; @@ -471,6 +864,15 @@ uadk_crypto_sym_session_configure(struct rte_cryptodev *dev, } } + if (auth_xform) { + ret = uadk_set_session_auth_parameters(dev, sess, auth_xform); + if (ret != 0) { + UADK_LOG(ERR, + "Invalid/unsupported auth parameters"); + goto err; + } + } + set_sym_session_private_data(session, dev->driver_id, sess); return 0; @@ -496,6 +898,11 @@ uadk_crypto_sym_session_clear(struct rte_cryptodev *dev, priv_sess->handle_cipher = 0; } + if (priv_sess->handle_digest) { + wd_digest_free_sess(priv_sess->handle_digest); + priv_sess->handle_digest = 0; + } + set_sym_session_private_data(sess, dev->driver_id, NULL); rte_mempool_put(rte_mempool_from_obj(priv_sess), priv_sess); } @@ -551,6 +958,49 @@ uadk_process_cipher_op(struct rte_crypto_op *op, op->status = RTE_COMP_OP_STATUS_ERROR; } +static void +uadk_process_auth_op(struct uadk_qp *qp, struct rte_crypto_op *op, + struct uadk_crypto_session *sess, + struct rte_mbuf *msrc, struct rte_mbuf *mdst) +{ + uint32_t srclen = op->sym->auth.data.length; + uint32_t off = op->sym->auth.data.offset; + uint8_t *dst = qp->temp_digest; + int ret; + + if (!sess) { + op->status = RTE_COMP_OP_STATUS_INVALID_ARGS; + return; + } + + sess->auth.req.in = rte_pktmbuf_mtod_offset(msrc, uint8_t *, off); + sess->auth.req.in_bytes = srclen; + sess->auth.req.out = dst; + + do { + ret = wd_do_digest_sync(sess->handle_digest, &sess->auth.req); + } while (ret == -WD_EBUSY); + + if (sess->auth.operation == RTE_CRYPTO_AUTH_OP_VERIFY) { + if (memcmp(dst, op->sym->auth.digest.data, + sess->auth.digest_length) != 0) { + op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED; + } + } else { + uint8_t *auth_dst; + + auth_dst = op->sym->auth.digest.data; + if (auth_dst == NULL) + auth_dst = rte_pktmbuf_mtod_offset(mdst, uint8_t *, + op->sym->auth.data.offset + + op->sym->auth.data.length); + memcpy(auth_dst, dst, sess->auth.digest_length); + } + + if (ret) + op->status = RTE_COMP_OP_STATUS_ERROR; +} + static uint16_t uadk_crypto_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, uint16_t nb_ops) @@ -580,6 +1030,17 @@ uadk_crypto_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops, case UADK_CHAIN_ONLY_CIPHER: uadk_process_cipher_op(op, sess, msrc, mdst); break; + case UADK_CHAIN_ONLY_AUTH: + uadk_process_auth_op(qp, op, sess, msrc, mdst); + break; + case UADK_CHAIN_CIPHER_AUTH: + uadk_process_cipher_op(op, sess, msrc, mdst); + uadk_process_auth_op(qp, op, sess, mdst, mdst); + break; + case UADK_CHAIN_AUTH_CIPHER: + uadk_process_auth_op(qp, op, sess, msrc, mdst); + uadk_process_cipher_op(op, sess, msrc, mdst); + break; default: op->status = RTE_CRYPTO_OP_STATUS_ERROR; break; From patchwork Sun Sep 11 05:23:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 604781 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:2213:b0:1da:4c02:b5e7 with SMTP id z19csp1853679ltw; Sat, 10 Sep 2022 22:24:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR4pXdv1ta/KtQYNWmfx99uWehhYiFYEVLrzsFfWTDxwKH+IHPFTGR5KYsm1FJymorJL7WB+ X-Received: by 2002:adf:fc91:0:b0:228:afa5:2432 with SMTP id g17-20020adffc91000000b00228afa52432mr11730779wrr.255.1662873892071; Sat, 10 Sep 2022 22:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662873892; cv=none; d=google.com; s=arc-20160816; b=ZIC3/ekFiZpLrqLQnwD0JLH6CZkxgb0srJwCpzprYYRPIRYLxbSul5lXYuJpqguGkE zWGITz6iiyiJMZZ7opWrmCR66yUI83NoSMa4MRvVToASICTcIlmcr2KV1Miq48HdW0u3 b0ARWbUUBy9tanVKeIRQ1y4cF2I7/UgM8gZbPPwF3CDkTuzNf9tTkFB7bKDw35iG6e1T MQNutemI9mv/t0RxZvMKGrOr/LIL3mT2QaBKD6JRP30sbQx9GMDnpomCXUidKiUukFeq E53OCG8c1kwQOcpk6atD4zpNsOOOUBny3yzPDeFotzBTh56LXfdofs8XoPojhELvSZ9O GWQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QIJmCNhgKMbCLLjYtKQBhxgAslbXzlK4XmTkHnMh2Ik=; b=P5pkNSEf/hGphrVDnXwNA+i6n4ZbS4hiub4YdipgoInoE7NSCAPzi8B/nrf8rVRVk2 MdylRXomo+ITbBWWBlGa6bTY4YmgHjLQVZT2MJtxfb1E9Xwrbs9pW19YwbWf30pFJqz7 +OD8AxAfg/+lVdKuhGjQ4iiE4zkiY4y7a/H/ZiRuTFpCXFb10+G879ROh81MLXhNnobI W0sPmjQVDNwbOdnuxQ8XkIcwGWOhsL5I1OL4o8PeJLdKfXkmwGgLYjmhNrIYoTmbMbd1 KxCguH8qLF21NsEf9biIMswQ8ndDwmmft1ZWG95gzYluuRzuVUw49f/i6CZLexwyubMk kv8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZTNkxDgC; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id m15-20020a7bca4f000000b003a30fab2540si2796892wml.29.2022.09.10.22.24.51; Sat, 10 Sep 2022 22:24:52 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZTNkxDgC; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5B61427F3; Sun, 11 Sep 2022 07:24:51 +0200 (CEST) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id 000BC427F3 for ; Sun, 11 Sep 2022 07:24:50 +0200 (CEST) Received: by mail-pl1-f182.google.com with SMTP id t3so5589793ply.2 for ; Sat, 10 Sep 2022 22:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=QIJmCNhgKMbCLLjYtKQBhxgAslbXzlK4XmTkHnMh2Ik=; b=ZTNkxDgCahKuzfJA6WVcyjgcK7NJAfOqE7kV0sHTDc+7Yolq153UnGMIVeokd/6Vlj DRLphoSjpyLthR+6+1eCQ6j9zRxbbmWe77ug1etPQeB1Yg7fSymyhqUQZ6W7ieawZZng rWq9BO2tVq4/LDuvWZrMlZEzoQsQRI77DmAdPfkDR51IMBUOtVqd/SCjDizogqzzAjdu REVo/64JmuCH/GSXoM4y+hX/+sYS9UMPItvM0jJL0cri/Rtt2qV9IanRBE42Vg5ukEFp 9wcV+R2Q3pRcINQ7v6YfjoeS2n7h+QCbhTQcn7U7fs8gTP8i1y7HHZXiHNb+Fy/t1jGU lMJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=QIJmCNhgKMbCLLjYtKQBhxgAslbXzlK4XmTkHnMh2Ik=; b=acOS6tJJDdOePCsQVl9huaHCcN3K+d+NoRDoYK+hXkYR1PdbnlQYgjedE+4houxtDN qhwlARVa/mw/pbi7nIeZeqidy1y1dUeyLShZR61MNIM1GhhLCm/y4VETNMu6Fxrmc06M 6hBObRApF/qTgayts2R7XlKvRb16KTot8mxyoGZ9vsoa5InkdiLKq14CB71T017EkuNV Er7wu9GFIycBbqhh8tcvY0LkIvqWXFc0poy+xZBoyVDwMLfKt8NAF/dC8ip7MgV5JTHe Vd6pPkB/9NuCCoK+BNoYdLp4Cjd2fVifaPTchv4Czf0uhKGv9a2bwv5xrc2Pk+q9klyz kvAA== X-Gm-Message-State: ACgBeo2sCNaskmC1oHk+cywGx6Ds+hkpN9IJHckK+cfcWTafRfAchbCp +vivHuK15VnQsTa0zKDdwWC3lZa5Y2Y1ZQ== X-Received: by 2002:a17:902:d54e:b0:178:2da7:1bea with SMTP id z14-20020a170902d54e00b001782da71beamr126119plf.161.1662873890219; Sat, 10 Sep 2022 22:24:50 -0700 (PDT) Received: from localhost.localdomain ([199.101.192.45]) by smtp.gmail.com with ESMTPSA id z11-20020a170902cccb00b00173cfaed233sm3215860ple.62.2022.09.10.22.24.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Sep 2022 22:24:49 -0700 (PDT) From: Zhangfei Gao To: Akhil Goyal , Declan Doherty , Fan Zhang , Ashish Gupta , Ray Kinsella Cc: dev@dpdk.org, acc@openeuler.org, Zhangfei Gao Subject: [PATCH 5/5] doc: Update doc for UADK crypto PMD Date: Sun, 11 Sep 2022 13:23:44 +0800 Message-Id: <20220911052344.31239-6-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220911052344.31239-1-zhangfei.gao@linaro.org> References: <20220911052344.31239-1-zhangfei.gao@linaro.org> MIME-Version: 1.0 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 Update doc for the new UADK crypto PMD, which relies on UADK library [1]. UADK is a framework for user applications to access hardware accelerators. UADK relies on IOMMU SVA (Shared Virtual Address) feature, which share the same page table between IOMMU and MMU. [1] https://github.com/Linaro/uadk Signed-off-by: Zhangfei Gao --- MAINTAINERS | 6 ++ doc/guides/cryptodevs/features/uadk.ini | 54 +++++++++++++++++ doc/guides/cryptodevs/index.rst | 1 + doc/guides/cryptodevs/uadk.rst | 80 +++++++++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 doc/guides/cryptodevs/features/uadk.ini create mode 100644 doc/guides/cryptodevs/uadk.rst diff --git a/MAINTAINERS b/MAINTAINERS index 32ffdd1a61..f485cec2ed 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1061,6 +1061,12 @@ M: Fan Zhang F: drivers/crypto/scheduler/ F: doc/guides/cryptodevs/scheduler.rst +HiSilicon UADK crypto +M: Zhangfei Gao +F: drivers/crypto/uadk/ +F: doc/guides/cryptodevs/uadk.rst +F: doc/guides/cryptodevs/features/uadk.ini + Intel QuickAssist M: Fan Zhang F: drivers/crypto/qat/ diff --git a/doc/guides/cryptodevs/features/uadk.ini b/doc/guides/cryptodevs/features/uadk.ini new file mode 100644 index 0000000000..1418959bd4 --- /dev/null +++ b/doc/guides/cryptodevs/features/uadk.ini @@ -0,0 +1,54 @@ +; +; Supported features of the 'uadk' crypto driver. +; +; Refer to default.ini for the full list of available PMD features. +; +[Features] +Symmetric crypto = Y +HW Accelerated = Y + +; +; Supported crypto algorithms of the 'uadk' crypto driver. +; +[Cipher] +AES CBC (128) = Y +AES CBC (192) = Y +AES CBC (256) = Y +AES ECB (128) = Y +AES ECB (192) = Y +AES ECB (256) = Y +AES XTS (128) = Y +AES XTS (256) = Y +DES CBC = Y +; +; Supported authentication algorithms of the 'uadk' crypto driver. +; +[Auth] +MD5 = Y +MD5 HMAC = Y +SHA1 = Y +SHA1 HMAC = Y +SHA224 = Y +SHA224 HMAC = Y +SHA256 = Y +SHA256 HMAC = Y +SHA384 = Y +SHA384 HMAC = Y +SHA512 = Y +SHA512 HMAC = Y + +; +; Supported AEAD algorithms of the 'uadk' crypto driver. +; +[AEAD] + +; +; Supported Asymmetric algorithms of the 'uadk' crypto driver. +; +[Asymmetric] + +; +; Supported Operating systems of the 'uadk' crypto driver. +; +[OS] +Linux = Y diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst index 39cca6dbde..cb4ce227e9 100644 --- a/doc/guides/cryptodevs/index.rst +++ b/doc/guides/cryptodevs/index.rst @@ -30,5 +30,6 @@ Crypto Device Drivers scheduler snow3g qat + uadk virtio zuc diff --git a/doc/guides/cryptodevs/uadk.rst b/doc/guides/cryptodevs/uadk.rst new file mode 100644 index 0000000000..ec00b509b2 --- /dev/null +++ b/doc/guides/cryptodevs/uadk.rst @@ -0,0 +1,80 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright 2022-2023 Huawei Technologies Co.,Ltd. All rights reserved. + Copyright 2022-2023 Linaro ltd. + +UADK Crypto Poll Mode Driver +======================================================= + +UADK crypto PMD provides poll mode driver +All cryptographic operations are using UADK crypto API. +Support for the following hardware accelerator devices: + +* ``HiSilicon Kunpeng920`` +* ``HiSilicon Kunpeng930`` + + +Features +-------- + +UADK crypto PMD has support for: + +Cipher algorithms: + +* ``RTE_CRYPTO_CIPHER_AES_ECB`` +* ``RTE_CRYPTO_CIPHER_AES_CBC`` +* ``RTE_CRYPTO_CIPHER_AES_XTS`` +* ``RTE_CRYPTO_CIPHER_DES_CBC`` + +Hash algorithms: + +* ``RTE_CRYPTO_AUTH_MD5`` +* ``RTE_CRYPTO_AUTH_MD5_HMAC`` +* ``RTE_CRYPTO_AUTH_SHA1`` +* ``RTE_CRYPTO_AUTH_SHA1_HMAC`` +* ``RTE_CRYPTO_AUTH_SHA224`` +* ``RTE_CRYPTO_AUTH_SHA224_HMAC`` +* ``RTE_CRYPTO_AUTH_SHA256`` +* ``RTE_CRYPTO_AUTH_SHA256_HMAC`` +* ``RTE_CRYPTO_AUTH_SHA384`` +* ``RTE_CRYPTO_AUTH_SHA384_HMAC`` +* ``RTE_CRYPTO_AUTH_SHA512`` +* ``RTE_CRYPTO_AUTH_SHA512_HMAC`` + +Test steps +----------- + + .. code-block:: console + + 1. Build + cd dpdk + mkdir build + meson build (--reconfigure) + cd build + ninja + sudo ninja install + + 2. Prepare + echo 1024 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages + echo 1024 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages + echo 1024 > /sys/devices/system/node/node2/hugepages/hugepages-2048kB/nr_hugepages + echo 1024 > /sys/devices/system/node/node3/hugepages/hugepages-2048kB/nr_hugepages + mkdir -p /mnt/huge_2mb + mount -t hugetlbfs none /mnt/huge_2mb -o pagesize=2MB + + 2 Test with crypto_uadk + sudo dpdk-test --vdev=crypto_uadk (--log-level=6) + RTE>>cryptodev_uadk_autotest + RTE>>quit + +Dependency +------------ + +UADK crypto PMD relies on UADK library [1] + +UADK is a framework for user applications to access hardware accelerators. +UADK relies on IOMMU SVA (Shared Virtual Address) feature, which share +the same page table between IOMMU and MMU. +As a result, user application can directly use virtual address for device dma, +which enhances the performance as well as easy usability. + +[1] https://github.com/Linaro/uadk