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 921A4A0C53; Wed, 25 Aug 2021 09:19:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 260ED411F0; Wed, 25 Aug 2021 09:19:03 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20065.outbound.protection.outlook.com [40.107.2.65]) by mails.dpdk.org (Postfix) with ESMTP id 33F93411E7 for ; Wed, 25 Aug 2021 09:19:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HLZop5QHYYyXXWdFpjGtDej6JchASupt5YdCxOW+blNEQMqA+loao0UbZUPWY8Q+ESOWfs+f62pclQjgOHlUh997KDwG9px3zcw72J4JvQbf5bM1X7CSdx8RXixXTik4qqvu9CrIaI/lvErczw0Z93LoiilfY6bWRvCuGQWLCeRyPk+XE+gQNHso28aJJNF+0Fn0opcW3tU8BTTF2+zNMJs/tLkPstZ4T1z0gGBH1uoCj/BkU2a5nblqozlR7PkT+5IieMNQJSATAYE4ABahFyBOK7oyfOHISEHR96LKu2G347IioUbUIVV0zpvFCt1l3oWUoa+rlF2gNwz4SZCJkQ== 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-SenderADCheck; bh=AwF9cy2Wu06LGZsc7ollU4u4igDpcftii7N4enq75HI=; b=Ckmub4onYKdnAfOnc1PN17VIYQaXEfz+tr5ZKKCyXOle1s+zK9EqKxSS+sUg++yqSauR0HQFhyOh03rhLNuBzcXKA5mTPZmzUefoHWASv6xqz4KT8Ue20vdvLkMTfKB90CaKjk+Tpg/kn9pT6UD1sp1TwY7PWnnB3uw+Ud6x2FMfTw/QLhrO+Y/H1fyyTVv8Gcie++qAUU+DbMaeALxDsqg7sBJbH3tdqI5RvkN9AUSwzyEkUus5FZb5TzBhcwahFEdDjDnzTn2gHvRvLKA2bl40bSCgHpcCfXYHsGXsGdsGkoN1b4RZBPZjQ4cyXarOuoltoJucd6dgk7rfZetZEA== 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=AwF9cy2Wu06LGZsc7ollU4u4igDpcftii7N4enq75HI=; b=Tvk04T9TmqHKL3tBTMQDtkLlXBacnu/0DNm6IXNX8AUpBwtrXt/pZinuAf2u6fnmkU7NpsHpi6O6iqnzP37eRcHJ4hTvQAYuQWeGV6o4To/Hx4VHdY+Lqb0jmEnvSYDQMvf4KhLmRV8j48Cl38D/MMMMthPBCRgpknikJmUGXaM= 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 DU2PR04MB8614.eurprd04.prod.outlook.com (2603:10a6:10:2d9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 07:19:01 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::2590:514a:df1f:a793]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::2590:514a:df1f:a793%8]) with mapi id 15.20.4436.025; Wed, 25 Aug 2021 07:19: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: Wed, 25 Aug 2021 12:45:02 +0530 Message-Id: <20210825071510.7913-8-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210825071510.7913-1-hemant.agrawal@nxp.com> References: <20210812071244.28799-1-hemant.agrawal@nxp.com> <20210825071510.7913-1-hemant.agrawal@nxp.com> Content-Type: text/plain X-ClientProxiedBy: SG2PR01CA0126.apcprd01.prod.exchangelabs.com (2603:1096:4:40::30) 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 SG2PR01CA0126.apcprd01.prod.exchangelabs.com (2603:1096:4:40::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 07:18:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fba280d3-3ba6-414f-a8c7-08d967989c81 X-MS-TrafficTypeDiagnostic: DU2PR04MB8614: 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: /jWTVsLWkhs9SF81I6+gAeh6+VLbDilzxk1R1KuDnMsUDjHcVzk6v4aAqx6JUqr5mLNed3eCwM4Y1ij32iBV1zJ3cw6H3RpedA87ihxpMKPl95N1UKnbUbOV4y6s+0PcfWImIto3DUFkFCa/WAanzD434ODFXVmBA3LpkbGHR7a4KfPpN+WLpPJnG9ToXFrIA9BwVkFP9hsVO3dyXm9KIz4bw1R8ppHVPvchJFJoUsYBqT02jbiyArV2sXCDJHbMB4N1GCM/+Q6uuksUXRgfYSCjG/ZTnMuuCvk8B3xJyvfwosB/ap1wblckjN1kXzSN25NmSjrMl/ZwHjqEWsE6iIjPJJjwqUNa2ip1DRX0j5SHVaZoHgFH49Uw7rBPHtgcP8DJ3ClA5MoBZPEJKQMYbITA3OnABEF4yicFB5LS68BoGq46iTf1Z0WUMFRIYOG53b+DyTXY46vXP81IUf7aoBW9Htb58VXTVkxDmQwZVcLk/ivWLkXl8Cvf3WWelzZbxzWVwbvbkpudQPkh5SrvDp6denVaeCtLlsyXT3Zxy9EqH1dTWWcXEYrucoey3J+YFfyrdlZZBpVW8lEEArsmzGKbA5m+ktc+NHIvrPv+nEOTvKxJtkEDrATUnJgJTYystSGtA60/Iq+KM+zbC7c9XsJITsPpLvyX9i7Qnk/aP8sj53etXJkUvzv3+jvibz/PDwMkakX9lOhswkeBufAMCA== 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)(376002)(366004)(346002)(396003)(39860400002)(186003)(83380400001)(6512007)(66476007)(66556008)(4326008)(86362001)(38100700002)(38350700002)(36756003)(316002)(6506007)(66946007)(1076003)(8676002)(26005)(2906002)(52116002)(2616005)(956004)(6666004)(5660300002)(44832011)(478600001)(8936002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?HO7pknmiFqBj502o9sWB1zlwj4Jke6scjgN3TwAGJNpmbcZCzJqlt/YPalBr?= =?us-ascii?Q?VJjmkh72m5anFWjPDeI7Hk4WlrwafISQT6x4hpKruNjRgsbh9+FUvfAlY+/N?= =?us-ascii?Q?lb56D8BDk3DN90vWDoxGs+ZrC2JGsjbLI22KytTszNYqKiumafCrMnSA92kB?= =?us-ascii?Q?XPN1oJ9PLJKa2x/oCVlopVNGWgdHKJyla0PNHgMAC/HU14sjtaLm4ovWiSR0?= =?us-ascii?Q?urZTVwifsSfnBSHeqMPW1Z+z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=?us-ascii?Q?3QFZqZlWYc5YWCTbr1r0g5dH6dyh93TTYzNFgI+EYDcXjgYRn9pee3+seSxE?= =?us-ascii?Q?ylyh3UTBp8TVkoY0jENDkw4aLrAW5Tj3jJLZfLd3DXG8y051648oQI7Ightr?= =?us-ascii?Q?V27lGltDQqdPLYATbjD1gtFx1OVrLQeFR8tIwPxyDs2+a8Jq6xGWtpciUONK?= =?us-ascii?Q?OgjZwia6a/amUOdAF8cPdeZY?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fba280d3-3ba6-414f-a8c7-08d967989c81 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 07:19:01.0518 (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: IKiVtYQpojv/MLb64Ozjpxd9fc37RcPJvhq63SA83BE7pWD5T7IXH/kTvPjYoxj5s6ysAI2r12nOle7x8N/fbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8614 Subject: [dpdk-dev] [PATCH 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 af052202d9..505431fc23 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