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 7DC4DA0547; Sun, 17 Oct 2021 18:22:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB8D3410E8; Sun, 17 Oct 2021 18:21:40 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80042.outbound.protection.outlook.com [40.107.8.42]) by mails.dpdk.org (Postfix) with ESMTP id 9C1C241122 for ; Sun, 17 Oct 2021 18:21:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=adUk6vRkkLYUNgRAyg39s2HvmEuL7kVZGwi+kRMorgIPu7H1wkWsq/M67RQxRLMZJY1bNeS12U+iKFWs/FItaQ55NwEiAgPNeiHMECoIPBDvIKr8iu3mCz0l/qA43veRFyPqK1M4LJzQmNqLhhNu6bKXHg71rLu0xSae9tSsHxt/CuqCvDF2XkjHMfUknSiklG2VBDBFe/ZpNQ6lj35NdFt0qlfJjihpdHr44sCtMTd98lrbOr/AzNDOObY++da4XA4ioKlIzI5Acanv9WheLt8ohFjYxaJCvnvdSk1fPzmsXH1ej3qagKzmabP82VSXUszYPm0d+HPU+5n4kuisFQ== 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=Z7JWXIPjml8X79ypF/7Y2xsPwpdnwX6CQRRDgBHqZZVb9ZshutyVBd8T9aAM7wDQBE+B1KbX/PYHafzkxuZknp0NOnEGVrGwaX92CWAXy5mSRzNieofd5szJIwzKSQZq7uEJvuVp9e55qRa/6B16PuEWUXJ1eCui7otJm0e6B9cBJmzNs74OTRiQ2gKa+hFZJQUlNJGSdqriXoXou1MEq+aI3w+kiGJhVYdJMI9lwRZAGAdeVZ06tLgj0JkvjmSdXGX412yLzeeUPUjuZW9R2cmoQQM1K3yeOLVLjE4GktRb2QYcQnAIpUTDeqlGYz2cwlS7p8/scaZOiT9Xn6Z9YA== 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=dBxl6b+ZBu1Epnar2aWZJVIbHJgoNciCOuX0YulNtl7azl6Y8/wmx+K/JwZMvedaMHgesXK2WNZgm1nAMRYVC89fsCbL2rCmY+apFnbuiJ24eAVora+0SkXXiRR2VqZqjwscQBvOV/OIlmV3jwqFD2WPuaS6M66ZHxiWe+z08SE= 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 DU2PR04MB8615.eurprd04.prod.outlook.com (2603:10a6:10:2da::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15; Sun, 17 Oct 2021 16:21:37 +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.4608.018; Sun, 17 Oct 2021 16:21:36 +0000 From: Hemant Agrawal To: dev@dpdk.org, gakhil@marvell.com Cc: konstantin.ananyev@intel.com, roy.fan.zhang@intel.com, Gagandeep Singh Date: Sun, 17 Oct 2021 21:46:42 +0530 Message-Id: <20211017161651.9220-7-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211017161651.9220-1-hemant.agrawal@nxp.com> References: <20211013190032.2308-1-hemant.agrawal@nxp.com> <20211017161651.9220-1-hemant.agrawal@nxp.com> Content-Type: text/plain X-ClientProxiedBy: SI2PR01CA0053.apcprd01.prod.exchangelabs.com (2603:1096:4:193::7) 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 SI2PR01CA0053.apcprd01.prod.exchangelabs.com (2603:1096:4:193::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.15 via Frontend Transport; Sun, 17 Oct 2021 16:21:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53b100e1-5d56-4f6c-52ed-08d9918a3130 X-MS-TrafficTypeDiagnostic: DU2PR04MB8615: 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: kKBbz/GZAjscatBocq4GnNPzCqRQSOd+U/W11oB3Vbm74HVsXLYyF7xwq66OqeDS4UZh7MpHI+efvNTWzgKtRS3m0Hzay4cTRyaYl/QMpQQRJFIIc6FMSNlmkULf97rZhBpp+TVX3PHv/cAFv58vfGAbfsuKEwGfKIQHTI2edd/4l+/AupC/US3kvs7xhCrtbaAyaM3XYl2uUJGq8MjC1D+Kgz4ulKlnw+WVpMxoFMj6yYzR/7YctZD2xBCFU/gi4V0HmqSrLP4BSiOvFB6NWtJrM/Azbapm2yHsrPm5tAfExx+3VSj8JETsAAPxNcflWUVjCIknJozr6zxjIumAjKkZs+mw/2TIvUUqS6xc29W5NNGwTlSUW0efnnEGhIcGOq6otVnb20346DgMy3ryfI1RO0a31/8g5DWCwb+pvh0nG91TWul/vuIPSW9Nw2mWakHgCnrlPSDV0YmtnzeTx77RrNQWBiecBQcbes74CRrB2spsRKuR/Jz2VmcNlnzT8PFc1L9Qg6oYwLLr1POhcwwGfcxjwIra5qYkI+z6lr3NeZ3E43nVY8wGoSNgRSFg1CvPgdRtQO7Qu1ReUvpCQDoVtNNcPUTSI5rr9EmFh36I+AsCot7wxO8hbwG/8+3dPskIAYV/Da7MFzYMROFPua5bI9LaU2975SnBdG+i+WINz0dbhGmmZl91lFF0Me9b6yo5sCaTktJRzhWCHE/DIg== 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)(6486002)(66476007)(8936002)(66556008)(66946007)(86362001)(52116002)(36756003)(5660300002)(38350700002)(8676002)(38100700002)(508600001)(6506007)(26005)(44832011)(4326008)(6512007)(2616005)(83380400001)(6666004)(1076003)(2906002)(316002)(186003)(956004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?xEfjihWfKlbw6zBqjQdzadbkR4zSSe9amPUWRdCxQc/FB/ZliFZaMz9lApTJ?= =?us-ascii?Q?VTWiYWcnRNA+gFP95YVtT7o+X8rVt5mYyvABilo6EU9EQ+yogHovy2laafU4?= =?us-ascii?Q?1yd/m4TTdCy3vTKoAnupp89PaYxEcyi77dEUtMZweCR1DPmh7Q9OE0l4CQQ1?= =?us-ascii?Q?AqX7pjdkYkFOrwmW4AQYQuCF1EmerXPaH0TIveAdXakAZjbO/Wfvn7B8uzxL?= =?us-ascii?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7utoHMCE6PS6pyWyrveYTESlw3?= =?us-ascii?Q?WZ6RJNvx27L0jSw2cxAvsnLqIPHcfTGpDIzGin60WEOCRdaqXOSBPg2An+k4?= =?us-ascii?Q?1nvxqo5hoZiCkqgZrJVEbEFLtZNw2rnNBZ/z4eDwv3yLahjMoWw2QF/Tej6G?= =?us-ascii?Q?/I4MnoEG1l7C4ff750Gm/NYzWge/v8bWHuCEyRxzrY4Tm91eCQuQ/otDwy77?= =?us-ascii?Q?i44FO0sE0UCGMJuo174hqGeN?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53b100e1-5d56-4f6c-52ed-08d9918a3130 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2021 16:21:36.9009 (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: 7eS4OxSa+4TwZkYWmWdJGPKT+l3McBogZ3aJmf+WfvoLcYl8hDN+ibwjrNu62CVeTOwIq0Ol4NB0cJGdVdgXNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8615 Subject: [dpdk-dev] [PATCH v5 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