From patchwork Tue Sep 7 07:59:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 507508 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp4012419jai; Tue, 7 Sep 2021 01:04:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYAY/sVMGOeI71XEc7oycXGrf+Jpg5QK2EfGCDAkBv9OEps76IUiOTHCuhlRHbIzctPXX3 X-Received: by 2002:aa7:c952:: with SMTP id h18mr17275595edt.18.1631001889372; Tue, 07 Sep 2021 01:04:49 -0700 (PDT) Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id e30si10209302ejl.127.2021.09.07.01.04.49; Tue, 07 Sep 2021 01:04:49 -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=fail header.i=@nxp.com header.s=selector2 header.b=IIbINMG9; arc=fail (signature failed); 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BCE4341165; Tue, 7 Sep 2021 10:04:03 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2058.outbound.protection.outlook.com [40.107.21.58]) by mails.dpdk.org (Postfix) with ESMTP id 92BEB4114E for ; Tue, 7 Sep 2021 10:04:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YjOnOhHb2gfOXMuYqTsGlMsZtYROxcgbx0PmnZ1FiPvpex+kuMu+vjGh2wpRVkPUry8dUyYE6nALDOf3VuQKuIi2KsThnzjbTSL+A1f3vMRo01p1XWHbDtgaFHr6i7VkxeCknSnO3oAl5sO6YP0b/L1+1F9gBsYEjMgoZDbW/4UmzrU1F+GkEmfrP9kf1VARIr4FlKDD186nQCEMDBng1BosDSievPVK7cT8c/huVhMFBJKbTI111+TJPPVs3UI1iJbzI+d1ND+4Url/4WSJ6LicD2EWxAEGHPT3b7XbAuKAtGXXtlHh7mJfb0PBL/o6yee/oSS3uMuKAUP2PSYQxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=XQwCm89ieuX9D1ojA8sGVwL3QpSqqoe249Ajyl2B+O4=; b=c5G0rxC04FTprfAJpClToyyZ0FBtldB6y/x+LiP6wr7fpLFkym145duXAtQm1cugVWGScY3Y0wjbDWXKonYLzUBSUWtNo46VAF3xn92AiU/aZSk4KXlZcWi2hH1dU28zsyd9Qh/BDpGZV2T5Uzfl32MEBN5Y/KdMOt8ofoNVB7/HpG/xYZOrelOH68HMZZXBnhHiyigBwsh6xZXKu91eq8t+Tkhuqsc7hWiYXOsBUPd4pIg5BQgcG066d8pIzFQvJqo7ycz1GNOqpEDtt6KPaxwV4ZsWUOXFAjZCJMdmAzTEmfuoJjGH8/cOKbKAYBsiS3mP0ZsFzON5WURpAfcRhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XQwCm89ieuX9D1ojA8sGVwL3QpSqqoe249Ajyl2B+O4=; b=IIbINMG9NnczMz6vVQQG5oUx6ZgnAvamPht+zMPvUOImH3luhS0V7szyCAEHmMboGiOjK33khsbqGnHm2LhaKOI/5eTEdroSzFIvV28xViVFheWmwcrIsjiGEG3cG6tbeD9BF6Ue8EXVm4So7Zia/8Br34mqNoQq6N3dyvqn0kE= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by DU2PR04MB8709.eurprd04.prod.outlook.com (2603:10a6:10:2dc::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Tue, 7 Sep 2021 08:04:01 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::945d:e362:712d:1b80]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::945d:e362:712d:1b80%4]) with mapi id 15.20.4478.025; Tue, 7 Sep 2021 08:04:01 +0000 From: Hemant Agrawal To: dev@dpdk.org, gakhil@marvell.com Cc: konstantin.ananyev@intel.com, roy.fan.zhang@intel.com, Gagandeep Singh Date: Tue, 7 Sep 2021 13:29:48 +0530 Message-Id: <20210907075957.28848-7-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210907075957.28848-1-hemant.agrawal@nxp.com> References: <20210825071510.7913-1-hemant.agrawal@nxp.com> <20210907075957.28848-1-hemant.agrawal@nxp.com> X-ClientProxiedBy: SG2PR02CA0068.apcprd02.prod.outlook.com (2603:1096:4:54::32) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from dpdk-xeon.ap.freescale.net (92.120.0.67) by SG2PR02CA0068.apcprd02.prod.outlook.com (2603:1096:4:54::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Tue, 7 Sep 2021 08:03:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d09dbb84-7fdb-4f59-28d3-08d971d60db2 X-MS-TrafficTypeDiagnostic: DU2PR04MB8709: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r3Vz5Iwqc8GNXSuWoTNleYxJHJJBGnCwBXcoegl174PfX0tX9Aor+v0WbK2UkSZMr3sFfPGF86LJGDHTXfDvYl2COlkuRZy+rUG6Ez8ljGZ4rnUMaSm27NBcmgzf339uMMuIDGAobAEjP5AIWqoqr++L5S2piC4+72YuGIFpk0LmNbu1BgEvMFVvmh3S4UgvQ/6DJ6dnCN9vzmEsu3svWVIhgCfIXZ2QOb6CsgD6zZzEY9ApkWwsCh6FEEYg81Wo4CGSVpd9iCmgJ0hO2LOUC6hMnbBmSuMpt3DxrwSRK8r4IMU31OM+8aHo9K63pIGZC0IHuz5T65LrKkoGhePsW3cGee8ku9XNWl5PjmbI4Roqt3OjTZEeRrtWqdLnR5GUTfl7t1yGEdlybih04e+EpGqW12L6yJKOso2vJQI9SLgU+rVYvvICrORHqv2/FtFnCzpn/2NvkxrIrQKqu1wL6oEJXH/e19Ch2aQz9sW3WiGRpEvOADDgajdZfZh5m29gIhSfykKrrZ8YWBfV/4jo8qP+K2rdc/21HiJYWuJcR4za0Iu1qsSLqQT1uHb4XXRctN6WWMfxBbgAtrBADE19f1CiAbLo6lqvwIat5TatTLJo6qAOULWGT4yOXBRmF4Q5LAQhzzSD6IT9Ov4Dvlz9YW1UBMLbCrXWs//J6QR6Snp+J078iXVIkkmKeHy8uLg5UpY9ap1Jt363FR/Y38hj5A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB8630.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(39860400002)(366004)(396003)(346002)(376002)(2906002)(956004)(2616005)(86362001)(83380400001)(478600001)(316002)(6512007)(4326008)(52116002)(1076003)(5660300002)(38100700002)(6666004)(38350700002)(36756003)(186003)(26005)(44832011)(66946007)(6486002)(6506007)(66476007)(66556008)(8936002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /fAWu+ENmr8IKLOXIPzoNyqSitmJDw9bhDJ4FGjANuslS/Xy+I8wYm7c9ge7hhjOLaPWZ4EAzYbcuIm7KsLcxFLjaGF5hC0XhNegIw9x+xVG8JZBjZcDUCBI5wTblwdRZfH3e5VlZ808Yn2EAz695VXMHZ5Gpg0Cw3GImTkK+f/OiInlyqMocb4lTz8gkLiap+C+IOrX8DBMCYnqam5ZRqo0g3aCDSqtQOdmV1KFof5JC49K3sdiZGjSyLVyYJ/4/YBMyy2ohiSgUz7LFD3TP8v8bWyIfOSe1/7lZDB0SrxVBZx4bmI8d9tN3pzttCCp2BRn/t4ElZMWPR4+aobXWnu49fmW/ARJ2wCqKFfXy1opDPF2BHUADpPCIuDQOJ/4gLQYmDG0IYGfD0EBbQJNtuWrcxih2yjGRnBkqI+vZeRt0oPllq19h7mnObCnPPmsf6594uqnhYzpsA2LEot1cy7hYMptxy8Aeci10xvDPG0JSXLs5dXTfA9bze2d6sGDAsSTFeYSGwYQAwTRr3QWPyqb4DLCC2H/gfifEYh10+ZpE1etGEvQ7nUCn96fP6Z50P1zb1BVcJFzCygXwBtGXAm0pc/5dBtT7GiWNtjCuZLIn7M+/L+YdHK6pxqD8pvUfC/1rYDlMN0tyzVpTDw55sET+KKK50aW0ZpzbwTUE6z8IWEI+nVLUQGGkqVqQRl3JC0VQ7U9r1Jab/oA0EkFpjofW5Gg2B8hj2CVRJcrSwYUHB6vX1fJPb+thVQvzptqxjmk34lojvgzZHS1ENg/srMci3vnibr1H/5XI0AwpjvgNhq1rA3acqJ4u7Z6oklS+teoW6euoCjJUjEUlequlMhsmivbLnX5iDXqYz5ihgS6ai25p1nr49xVsFCRKt3y/2ikWw/t6SA4U2ug4xUDERBmoNn5QuoaxMfSrrzIns7wd0Hk+uDavZiQbjs61pigIN/qIyMKNDkimOF4gE/oZGXdOGfA31K0ooDW5PSFi3NI8hwhj3H+mJ+N8uX7DRHQgMGpkzZPTv52ytJW2eneftOgOGDjEzdmnZgBsID9tezCAX2tMLN37nTwEBu60UbgihTBGDX2LKKxXffYq4f7aVnaL2BuRbTr9GI8htpfimXW9SD0WA4ptGlsVe+wW6WKEbj5+AARMAiYluO1sDh6qy98TqoipCDE9SWH5Gh4w/eNE7gBCatXUF6+En2wHRjeSI/rsKxrw8TPJaQsGqH8d7nquRapnZY/MEsd2X42W7uZQvVHp+El98S+ZIRDT2WIyDQHl8jphvG1hFxiD1pDifkxyWCIE6etZ7DpPHarDbMTB9zwHYeXEWMrSpipe3Hn X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d09dbb84-7fdb-4f59-28d3-08d971d60db2 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2021 08:04:01.8346 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: evr86GMKsbKz6BrJ2ZJNGBpgoRUKXLFVeM41lyAcaKppR+3gNf2UbcwzKb0Qg67NVG3jbk+TLiQJgvSVAvIHjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8709 Subject: [dpdk-dev] [PATCH v2 06/15] crypto/dpaa2_sec: support AUTH only with raw buffer APIs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Gagandeep Singh Auth only with raw buffer APIs has been supported in this patch. Signed-off-by: Gagandeep Singh --- drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 21 ---- drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c | 114 ++++++++++++++++++-- 2 files changed, 108 insertions(+), 27 deletions(-) -- 2.17.1 diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h b/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h index 860c9b6520..f6507855e3 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h @@ -231,27 +231,6 @@ typedef struct dpaa2_sec_session_entry { static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = { /* Symmetric capabilities */ - { /* NULL (AUTH) */ - .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, - {.sym = { - .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, - {.auth = { - .algo = RTE_CRYPTO_AUTH_NULL, - .block_size = 1, - .key_size = { - .min = 0, - .max = 0, - .increment = 0 - }, - .digest_size = { - .min = 0, - .max = 0, - .increment = 0 - }, - .iv_size = { 0 } - }, }, - }, }, - }, { /* MD5 */ .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, {.sym = { diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c index 32abf5a431..af052202d9 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c @@ -11,6 +11,8 @@ #include "dpaa2_sec_priv.h" #include "dpaa2_sec_logs.h" +#include + struct dpaa2_sec_raw_dp_ctx { dpaa2_sec_session *session; uint32_t tail; @@ -73,14 +75,114 @@ build_raw_dp_auth_fd(uint8_t *drv_ctx, void *userdata, struct qbman_fd *fd) { - RTE_SET_USED(drv_ctx); - RTE_SET_USED(sgl); RTE_SET_USED(iv); - RTE_SET_USED(digest); RTE_SET_USED(auth_iv); - RTE_SET_USED(ofs); - RTE_SET_USED(userdata); - RTE_SET_USED(fd); + + dpaa2_sec_session *sess = + ((struct dpaa2_sec_raw_dp_ctx *)drv_ctx)->session; + struct qbman_fle *fle, *sge, *ip_fle, *op_fle; + struct sec_flow_context *flc; + int total_len = 0, data_len = 0, data_offset; + uint8_t *old_digest; + struct ctxt_priv *priv = sess->ctxt; + unsigned int i; + + for (i = 0; i < sgl->num; i++) + total_len += sgl->vec[i].len; + + data_len = total_len - ofs.ofs.auth.head - ofs.ofs.auth.tail; + data_offset = ofs.ofs.auth.head; + + if (sess->auth_alg == RTE_CRYPTO_AUTH_SNOW3G_UIA2 || + sess->auth_alg == RTE_CRYPTO_AUTH_ZUC_EIA3) { + if ((data_len & 7) || (data_offset & 7)) { + DPAA2_SEC_ERR("AUTH: len/offset must be full bytes"); + return -ENOTSUP; + } + + data_len = data_len >> 3; + data_offset = data_offset >> 3; + } + fle = (struct qbman_fle *)rte_malloc(NULL, + FLE_SG_MEM_SIZE(2 * sgl->num), + RTE_CACHE_LINE_SIZE); + if (unlikely(!fle)) { + DPAA2_SEC_ERR("AUTH SG: Memory alloc failed for SGE"); + return -ENOMEM; + } + memset(fle, 0, FLE_SG_MEM_SIZE(2*sgl->num)); + /* first FLE entry used to store mbuf and session ctxt */ + DPAA2_SET_FLE_ADDR(fle, (size_t)userdata); + DPAA2_FLE_SAVE_CTXT(fle, (ptrdiff_t)priv); + op_fle = fle + 1; + ip_fle = fle + 2; + sge = fle + 3; + + flc = &priv->flc_desc[DESC_INITFINAL].flc; + + /* sg FD */ + DPAA2_SET_FD_FLC(fd, DPAA2_VADDR_TO_IOVA(flc)); + DPAA2_SET_FD_ADDR(fd, DPAA2_VADDR_TO_IOVA(op_fle)); + DPAA2_SET_FD_COMPOUND_FMT(fd); + + /* o/p fle */ + DPAA2_SET_FLE_ADDR(op_fle, + DPAA2_VADDR_TO_IOVA(digest->va)); + op_fle->length = sess->digest_length; + + /* i/p fle */ + DPAA2_SET_FLE_SG_EXT(ip_fle); + DPAA2_SET_FLE_ADDR(ip_fle, DPAA2_VADDR_TO_IOVA(sge)); + ip_fle->length = data_len; + + if (sess->iv.length) { + uint8_t *iv_ptr; + + iv_ptr = rte_crypto_op_ctod_offset(userdata, uint8_t *, + sess->iv.offset); + + if (sess->auth_alg == RTE_CRYPTO_AUTH_SNOW3G_UIA2) { + iv_ptr = conv_to_snow_f9_iv(iv_ptr); + sge->length = 12; + } else if (sess->auth_alg == RTE_CRYPTO_AUTH_ZUC_EIA3) { + iv_ptr = conv_to_zuc_eia_iv(iv_ptr); + sge->length = 8; + } else { + sge->length = sess->iv.length; + } + DPAA2_SET_FLE_ADDR(sge, DPAA2_VADDR_TO_IOVA(iv_ptr)); + ip_fle->length += sge->length; + sge++; + } + /* i/p 1st seg */ + DPAA2_SET_FLE_ADDR(sge, sgl->vec[0].iova); + DPAA2_SET_FLE_OFFSET(sge, data_offset); + + if (data_len <= (int)(sgl->vec[0].len - data_offset)) { + sge->length = data_len; + data_len = 0; + } else { + sge->length = sgl->vec[0].len - data_offset; + for (i = 1; i < sgl->num; i++) { + sge++; + DPAA2_SET_FLE_ADDR(sge, sgl->vec[i].iova); + DPAA2_SET_FLE_OFFSET(sge, 0); + sge->length = sgl->vec[i].len; + } + } + if (sess->dir == DIR_DEC) { + /* Digest verification case */ + sge++; + old_digest = (uint8_t *)(sge + 1); + rte_memcpy(old_digest, digest->va, + sess->digest_length); + DPAA2_SET_FLE_ADDR(sge, DPAA2_VADDR_TO_IOVA(old_digest)); + sge->length = sess->digest_length; + ip_fle->length += sess->digest_length; + } + DPAA2_SET_FLE_FIN(sge); + DPAA2_SET_FLE_FIN(ip_fle); + DPAA2_SET_FD_LEN(fd, ip_fle->length); return 0; }