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 D16D5A0C55; Wed, 13 Oct 2021 21:05:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E38BB4127E; Wed, 13 Oct 2021 21:05:15 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2078.outbound.protection.outlook.com [40.107.22.78]) by mails.dpdk.org (Postfix) with ESMTP id 204B141277 for ; Wed, 13 Oct 2021 21:05:14 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O7v4PbxkwKs6NQzuSgKxi2ZF400CSzhI6sryRkgsgLPE0r/QVBkken7jfGiuc2Axout+BTP+zS1H5zzn4nfKZeiPd6hVMPIR0Ta7EoD4wf+yprEdmSBJjfvxwRPzuf5I6ExOiUlruXamESe1J3Wc96zcg+vef0hY9nz4QR1jkVBUuHOR9oWtVGLOm5cVfghBnqU5CnlhYYNSXpvEi8QrEUKDsh40u4OfUpxun9tQ9mXA/KWlZxzl40sIrch0FDWZRFCaGW9J7yW2NwHKqwnwXBlNIQLFu2QRdHVm0C2Q6gk23xt65u1aspho2Czub6tlcdfCtAyCIjjebjxhp0ju3A== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JHkHTOw9GC7O9qEgO7F+uXIPHJEBB+RStE3p/D3Nbrg=; b=VLx7lZiT/xtgCEanRftP4IkdKnwaQgDfRzk7WMLt6xTf0O64jEPyOOZ1+RmHo6u/QzTvopWuskn1Ddz9GCRQqvqnakjiyzLkFlfgcJxAu9YHazkEfMZuGcbDQCHvaLOBctKxWh2/T0l1oCCUun2plPrcnjYfKr4CLzkda0vAwq8Zq+pChMJlmiyGgVU6yFsJ8aIa15xFPRtNY8NCBxrUHsJdE7sJHW/JnSQOgyP5icBtvjVLjwKIY8/OptmWDJjjHzkLcXq+m/UJykvwzn8L0zeYd2/dOrYj2+3KECEcSEC3LPC40waN14D6WpH/9+nXwN9MdSoHogl3LqmhlrPuFA== 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=JHkHTOw9GC7O9qEgO7F+uXIPHJEBB+RStE3p/D3Nbrg=; b=FoG/dC+1DVhFlEss8CbcElCJD2KCWBe9UDCciBafkuheaD3bLU6wupJ8V9BKo7ZUVfwr4nVJZRRaUlby67TWjmj2HYSTb5zw8pjRkiE5imhpi9G+KJXHQ/ydCgf0/Tc3N3lh3jvrMha/n1LPVtZazxP+z3ozkgK4Ht1JY+fHjm8= 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 DU2PR04MB8870.eurprd04.prod.outlook.com (2603:10a6:10:2e1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.19; Wed, 13 Oct 2021 19:05:13 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::945d:e362:712d:1b80]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::945d:e362:712d:1b80%3]) with mapi id 15.20.4587.026; Wed, 13 Oct 2021 19:05:13 +0000 From: Hemant Agrawal To: dev@dpdk.org, gakhil@marvell.com Cc: konstantin.ananyev@intel.com, roy.fan.zhang@intel.com, Gagandeep Singh Date: Thu, 14 Oct 2021 00:30:23 +0530 Message-Id: <20211013190032.2308-7-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211013190032.2308-1-hemant.agrawal@nxp.com> References: <20210907075957.28848-1-hemant.agrawal@nxp.com> <20211013190032.2308-1-hemant.agrawal@nxp.com> Content-Type: text/plain X-ClientProxiedBy: SG2PR0302CA0011.apcprd03.prod.outlook.com (2603:1096:3:2::21) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 Received: from dpdk-xeon.ap.freescale.net (92.120.0.67) by SG2PR0302CA0011.apcprd03.prod.outlook.com (2603:1096:3:2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.4 via Frontend Transport; Wed, 13 Oct 2021 19:05:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 06307235-a4cd-460a-0f69-08d98e7c629f X-MS-TrafficTypeDiagnostic: DU2PR04MB8870: 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: seJmpGVv/lJ8jC2JC9SS79iYZntfL0hxA2ySfnEEqmtNMOg0oxrjrDrGbRos2zErLaZhN9/atV5/a7pZM3xTy5EgXZ2XXH8nv+/Q5gFeYeKUIPf3nuriwiN34FJAmvLRJEZvRhEBWkMptubAAsq9r3dZpLOzTCkK+jU0ZgsDMIRxDa3m7k1vwK2GJjAd6zmld+EM1zyQ8ir4Q8NF6K4WYmlIXdOor9+JH7lypkuBKpiNa9zGt7pjyHz4wEXp0FeFjZMoWY863SdsEifM33Jpd1lTf1zi0waFPJpy1GicPHOMbf7Sng2JAQ0a0mIKQHe9tcPCbT9/2gcOwlAOX9TboNZzKDxM978rzeMIfsbunCh+pEWOWmIJwMFh6b2vMr6fW5GJJJY4aJKAOs/sysy9CrE18lDcgGxxyXBLj8qcJe4ry6eVvlxTaO9ZssHzYUOj6xI4T3FeTC/8CXIij946vednvQawFjBmdjDxG0NOKydaSZRDKQVIMM6KLdWFzIVezAJsPsdvkWLg3iLKnjhb2KBKWuGNIHdjRprlUouYJxaWfGQp4BQlk06RJe3Iz9hVH9E1Q8SNIwV1Z31CcacDcbjyyaxwkQvCehCpYhQi0qwrJNd3/pB6las/Z7aLp1VKrxg7za0etngSfPcxidSP4sOLPrqXj/T4RQIwWPMsBFOtCIV3E6Jkg1OFh5JQyF+AZlbsyoRyK1lwVsBpiP3w+A== 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)(366004)(66946007)(66556008)(316002)(6666004)(6506007)(36756003)(6512007)(2906002)(8936002)(1076003)(52116002)(186003)(4326008)(956004)(66476007)(2616005)(5660300002)(83380400001)(38100700002)(44832011)(38350700002)(8676002)(26005)(6486002)(508600001)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?5R95R1Rc74UGKCl8PQFy46A2nYpSzda5++sVAKOvTUbisbAx9KYo/28Eqp5V?= =?us-ascii?Q?xOCqSVlOZXwWZkFHhHX/CraHONEFNsT7ck6ExRlq5UWp872OlI+4zzMlzC7c?= =?us-ascii?Q?vEVr+Rt9gBtmh0JJLSwUbMphuI/oLqjmU427xTtYHxxmcr/NF+QbinQyFOts?= =?us-ascii?Q?0QZg+yYzz00HzIBDsbCKwmiUi0ZBI1W7C7zH8qj3GnA6IABDjjHLlx3f2kSs?= =?us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RoKXi+hSo7?= =?us-ascii?Q?SUfb/EFimVlW7rZtkEMam2qvGpGs2eoQMFwYNjGAZtjGWUUFed6EvlfUZ12c?= =?us-ascii?Q?PhFiaoBXBIlaLwlRZhM/kF/r2djRD2XnGwyMX1SF7NzY+xHwaMLHZJFRwUyF?= =?us-ascii?Q?OUlF1kZ3GU3PDWgQiUlriCOdTPPUbOTUaMsnY+GljS7Y1vey5d8HdO4FfC97?= =?us-ascii?Q?nwe0VrViBrqguP3f0lb0zGjn?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 06307235-a4cd-460a-0f69-08d98e7c629f X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2021 19:05:13.2978 (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: UMPVr6zrAzILhhzthXs1SLiieavAYNd4RGJaqemCmvOK0gJ7jIWTTHxYF2Sdul/fr+Uw+ElzEHMt36DyanZXyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8870 Subject: [dpdk-dev] [PATCH v4 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(-) diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h b/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h index e9b888186e..f397b756e8 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 8925c8e938..471c81b9e7 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; } -- 2.17.1