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 EB55CA0C55; Wed, 13 Oct 2021 21:05:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E137E41283; Wed, 13 Oct 2021 21:05:17 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2045.outbound.protection.outlook.com [40.107.22.45]) by mails.dpdk.org (Postfix) with ESMTP id 864AE41282 for ; Wed, 13 Oct 2021 21:05:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KzGyC1kwYEJufd+Ufhh65R6lLD+htER3fGTGDxt9axJ7bE1pBs/1/JVQ+xFx0Ol9aS4CJ4qBOkcxutW0O7tQa4nOiO6mfVZiyEdtS6tMBLgzNoYjlt7b0oHH8KKs3MNU/XVRX9iBx8ZE8Wz6BHdGLIFZBRjzvg/sDAG609sMDP+dY8H/haWVPvWzxicv18jJCoUXFoYjhroMzqUTo3OgDvGbxBI5JG3v111wlpWHMjDpHN6qTZdcT3I1vQ77m2iTGE5vhefElNBRkL5UaYKT/R7TgXVg5POxc7uROFeJTmA6ItusPOPjIVkya3n21dkwnPir86i3oWU7BUqtGhwHbw== 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=5zzQKmiuou0kaNbTzNaLCDM3bJYBZPoCh/dlUzPWCIg=; b=ku7h6+785Nc5Psa5y/vc8B7UNMnPCQ/gHnT5pCKRndZhxrZ/61ABhyTHV8/xVePb1Cwz7phKHAEkY0kuISiIMZAHg0uA99L52exVee3fXc8tGEaLMIF/+WJmsE9K58UxFmCV7f7sdkKLtcOeuXIkNDUZ8qYDDAx/Dy9g4mktSROl5m2gWk6BXAVyNLaY9EnJapzxynXb3TDJtuOkAyXgfC78B7agtZLq8LKQ/tW3b/WemmNwemlJz7xCDeddNU2S9SecVqPLXQ8aXwcuBHmLNXD62Q3SkO0+3KAo3540t73Dd6UvhgRTCrrzNk0dw6NedItwb9nq01E7FyQsnMYQzQ== 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=5zzQKmiuou0kaNbTzNaLCDM3bJYBZPoCh/dlUzPWCIg=; b=Sh33DKnBGvT/RcQJU2IeTMNjtb53CfGJ01jpMqDJPYD06PPJJ9EJUoUY44hpdDfbUKIqj/Wiln1p+OaX9RPmETHpNoobgUVX5DWlfdn606pCPj8zotkHpwINFHANH2X+MxZP77Xg5MzaZ2glXMCE69yAv9GkoFHUdM3gSdZGk34= 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:15 +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:15 +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:24 +0530 Message-Id: <20211013190032.2308-8-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:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58444f18-c5f0-4dd0-b312-08d98e7c63ea X-MS-TrafficTypeDiagnostic: DU2PR04MB8870: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A+wT6/yGb/U+YG4kVcWxcQzCA4L3ysLIcqlcV8SgJICwRAqvBkdN3cdNLQZL/npC/RN69X3xynPWbKKFz2WJVgcmARxmtk6GIECMIWDHXyCE4R7Qf9xQaXLSXF7sHpx9ezRMO3NYmApN3EeDTPj+S5+hpPWy51rXQShztKwH/o9NqlEoYpqapuo75cacYBoWi++gSEmSv/qLilNZR9HeDAd6GbQNhfeHP18nFv9Go92BehKVWA+Ig5LFxv4zehnyCfK1Y9IMzdVaCWD0S1Y8ht8oQONchG+Au2vni4evAF6RvtT9RZb4SmEHv0E0jBSyPlJkfRQ2Mevsn5W5RjbuYjGq8fXCdM36WVz3tEXAPhAsvauOLKteDVcNeSIVj/Gq8s1qTVAKGAMMBjO0FvqeuJx824MfOo9wkFMo57STqx18exWb5K6K5wsvqfcpOwc+LyXHe5aOLdNZ+t5cZb+v0b2ezinqJogxVHFaqm5b+dS39if1evs+IHPACknnpFXWx4iqvYQ6CJFGOCnrW35El0HSPsk8EPw+8lTTaHFQu6GfgyIf5gm2pHypdlip44UWeqO1nj1v0MD81ddsw5zq8JQFQXJV1Y6FjVvNymizRfCxc/3NDPZKBGB2V8B1/sPxHi6yw2unh0XGA2rrAlyFniwLttDXPAx3POnqP3Cxgg4T9nqT+owZS5AcBSomtAFOugyheij1PZuSIzgjd5NAaQ== 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?O+22cl6YhCy/vVIwwGjU9+68EZl04yWXq6d56jIsuIk2v75tJmbGu5mJgnRX?= =?us-ascii?Q?lHohaveRfL7VRiDyYbFYYiI6ymfXDcd7Ws8Ofp5Eg28stANUkuWw8XCphq/Q?= =?us-ascii?Q?Z0/3d07f6zAWsRQ5gh4LySdI7bfMqXLOf2+f5KKxumCbUqirlIhRjzGib5fT?= =?us-ascii?Q?huL2jMav6Xa6EYHbIDNCnfK1DLI4RlZsvyXlDxe3Kznj2CNp35rjBNUfXC84?= =?us-ascii?Q?PTgkoR7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qp1dR8ze?= =?us-ascii?Q?6lUbXlbpp3Fuh5nKogqlCZnS+vftGB3WJjyZWYQ5+CMGaH2xN0pjLVXkF1oQ?= =?us-ascii?Q?Xvja7EBXbNM8//QnqQAS5ulzqXfRV8nZ7t+YWndBAYJ4ohx1WoOJ7aguHvAx?= =?us-ascii?Q?mmK7TLyb5QSHfZJ+9u0aADus0fMZxqR25cdgRRRpQ0a1950nwkkdmDmWEfPw?= =?us-ascii?Q?P+g1v/V3ceYCELdEOYjOu5Gw?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58444f18-c5f0-4dd0-b312-08d98e7c63ea 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:15.6395 (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: J76zDKkp1OBUaPlBY5N4Sk4VLPAWDFox4V46OThqKkyU1Ero/U69wOGJ5GbJpmrKRhFsxn99m+51y6M3M3N+VA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8870 Subject: [dpdk-dev] [PATCH v4 07/15] crypto/dpaa2_sec: support AUTHENC 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 This patch supports AUTHENC with raw buufer APIs Signed-off-by: Gagandeep Singh --- drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c | 128 ++++++++++++++++++-- 1 file changed, 121 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c index 471c81b9e7..565af6dcba 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c @@ -31,14 +31,128 @@ build_raw_dp_chain_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 ctxt_priv *priv = sess->ctxt; + struct qbman_fle *fle, *sge, *ip_fle, *op_fle; + struct sec_flow_context *flc; + int data_len = 0, auth_len = 0, cipher_len = 0; + unsigned int i = 0; + uint16_t auth_hdr_len = ofs.ofs.cipher.head - + ofs.ofs.auth.head; + + uint16_t auth_tail_len = ofs.ofs.auth.tail; + uint32_t auth_only_len = (auth_tail_len << 16) | auth_hdr_len; + int icv_len = sess->digest_length; + uint8_t *old_icv; + uint8_t *iv_ptr = iv->va; + + for (i = 0; i < sgl->num; i++) + data_len += sgl->vec[i].len; + + cipher_len = data_len - ofs.ofs.cipher.head - ofs.ofs.cipher.tail; + auth_len = data_len - ofs.ofs.auth.head - ofs.ofs.auth.tail; + /* first FLE entry used to store session ctxt */ + fle = (struct qbman_fle *)rte_malloc(NULL, + FLE_SG_MEM_SIZE(2 * sgl->num), + RTE_CACHE_LINE_SIZE); + if (unlikely(!fle)) { + DPAA2_SEC_ERR("AUTHENC SG: Memory alloc failed for SGE"); + return -ENOMEM; + } + memset(fle, 0, FLE_SG_MEM_SIZE(2 * sgl->num)); + 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; + + /* Save the shared descriptor */ + flc = &priv->flc_desc[0].flc; + + /* Configure FD as a FRAME LIST */ + DPAA2_SET_FD_ADDR(fd, DPAA2_VADDR_TO_IOVA(op_fle)); + DPAA2_SET_FD_COMPOUND_FMT(fd); + DPAA2_SET_FD_FLC(fd, DPAA2_VADDR_TO_IOVA(flc)); + + /* Configure Output FLE with Scatter/Gather Entry */ + DPAA2_SET_FLE_SG_EXT(op_fle); + DPAA2_SET_FLE_ADDR(op_fle, DPAA2_VADDR_TO_IOVA(sge)); + + if (auth_only_len) + DPAA2_SET_FLE_INTERNAL_JD(op_fle, auth_only_len); + + op_fle->length = (sess->dir == DIR_ENC) ? + (cipher_len + icv_len) : + cipher_len; + + /* Configure Output SGE for Encap/Decap */ + DPAA2_SET_FLE_ADDR(sge, sgl->vec[0].iova); + DPAA2_SET_FLE_OFFSET(sge, ofs.ofs.auth.head); + sge->length = sgl->vec[0].len - ofs.ofs.auth.head; + + /* o/p segs */ + 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_ENC) { + sge++; + DPAA2_SET_FLE_ADDR(sge, + digest->iova); + sge->length = icv_len; + } + DPAA2_SET_FLE_FIN(sge); + + sge++; + + /* Configure Input FLE with Scatter/Gather Entry */ + DPAA2_SET_FLE_ADDR(ip_fle, DPAA2_VADDR_TO_IOVA(sge)); + DPAA2_SET_FLE_SG_EXT(ip_fle); + DPAA2_SET_FLE_FIN(ip_fle); + + ip_fle->length = (sess->dir == DIR_ENC) ? + (auth_len + sess->iv.length) : + (auth_len + sess->iv.length + + icv_len); + + /* Configure Input SGE for Encap/Decap */ + DPAA2_SET_FLE_ADDR(sge, DPAA2_VADDR_TO_IOVA(iv_ptr)); + sge->length = sess->iv.length; + + sge++; + DPAA2_SET_FLE_ADDR(sge, sgl->vec[0].iova); + DPAA2_SET_FLE_OFFSET(sge, ofs.ofs.auth.head); + sge->length = sgl->vec[0].len - ofs.ofs.auth.head; + + 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) { + sge++; + old_icv = (uint8_t *)(sge + 1); + memcpy(old_icv, digest->va, + icv_len); + DPAA2_SET_FLE_ADDR(sge, DPAA2_VADDR_TO_IOVA(old_icv)); + sge->length = icv_len; + } + + DPAA2_SET_FLE_FIN(sge); + if (auth_only_len) { + DPAA2_SET_FLE_INTERNAL_JD(ip_fle, auth_only_len); + DPAA2_SET_FD_INTERNAL_JD(fd, auth_only_len); + } + DPAA2_SET_FD_LEN(fd, ip_fle->length); return 0; } -- 2.17.1