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 41AA6A0C52; Thu, 12 Aug 2021 09:16:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E5EA4122E; Thu, 12 Aug 2021 09:16:20 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20079.outbound.protection.outlook.com [40.107.2.79]) by mails.dpdk.org (Postfix) with ESMTP id 13FE1411FC for ; Thu, 12 Aug 2021 09:16:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O6alW/u1x2OIn08InBh+Q5EUF7qZ6GsPBZ6PbMy2CF6u+zDlscsoVv2U4x0CuDmNclZeQp8MaQjuiv9Px+fhADXtjCCqz+FDgAP3bXRNqS2hnSOqbHUIgk2LqviDsuZMTUIHRoxvSmrlnCDHp4fPDcSioGghrX/GaB90nBYkHz4UUx5MtU8ZwNj/gD9S7ubgqvyH/duX+5blXmgn9zMCq4ueJAdvEpa90Outd7cNJQ7JIxskks7OM21gvuCH594Fr/7UcHkA1PcrPZD1seIk5NT8QDnuSg1SI+f5ksr7J4qCrCH6QKjSyLXFRPW9PPDAjD/lWBI6yXNSC1BkFE8+vA== 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=t3fRuk+5Dcqm2aJbSFmczw46lG8D/hISJnycA1Ov3OY=; b=NX94ruuonx0J5CvRqjKZVR9+uuK0yWn60pFI8qFsaZw8pUty23ew6c49JzEBmZ18MqZphWIbGSRhw3ly9kzde1nwbuUHl89gkZ5PXlVr/jRFhCEFXS7E4n6UQp6zQqUZJyddZZrdcW4jA9LG7qm7T7u2NGN9Co/b6XSmsy42U8I8ahBuRUJygB/pPIso84exX4ze0gT9K1pFBaqPuzlLoQIMfuD1NR+68WEIP3NlBaf0zJBrJTd/HO+kwyDDNZDiYx9ueD1onu3tJS83T3SGfj9/nWDIbOq/cnTS8oFYrCIPD/pVyW7497QJhtWRLhGxsANHgt+g282ZFdMJgHIjcQ== 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=t3fRuk+5Dcqm2aJbSFmczw46lG8D/hISJnycA1Ov3OY=; b=l1W2ECh973zkpGh1rwC8tYIoweJ7nuCG4icskCw8kH6TFSjwQyEZs0rChaFsu8wzz8edXzJ49RBbFUmK7M8bqL+Wg/Z58dCz+zQwp7HddMQgf4/ZriHluhtBT9gexewQ56kb28NdbkSqLRB5mS7bgSbxRtRCZxOjGQfl3kJmavQ= 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 DB9PR04MB8461.eurprd04.prod.outlook.com (2603:10a6:10:2bc::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.13; Thu, 12 Aug 2021 07:16:16 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::2590:514a:df1f:a793]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::2590:514a:df1f:a793%9]) with mapi id 15.20.4415.016; Thu, 12 Aug 2021 07:16:16 +0000 From: Hemant Agrawal To: dev@dpdk.org, gakhil@marvell.com Cc: Gagandeep Singh Date: Thu, 12 Aug 2021 12:42:35 +0530 Message-Id: <20210812071244.28799-8-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210812071244.28799-1-hemant.agrawal@nxp.com> References: <20210812071244.28799-1-hemant.agrawal@nxp.com> Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0105.apcprd02.prod.outlook.com (2603:1096:4:92::21) 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 SG2PR02CA0105.apcprd02.prod.outlook.com (2603:1096:4:92::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.14 via Frontend Transport; Thu, 12 Aug 2021 07:16:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2d64500e-c6d4-4a94-7c9d-08d95d611308 X-MS-TrafficTypeDiagnostic: DB9PR04MB8461: 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: lute50u99kUYx/hOC+VnJ5wZ+rJEg2f7QpdRlPFRcQkMT7fYJyVwIHsyYeUco3lM3KfsdPrnCgf2kQqLgiKgbf7EB9kUUXdmR4kkK8tOfIMyshZfEIy/DN40FLE++2GaEFiUQE4EMKwsnkCL2fhICe5/Twq7WHX3EmGiN25LKj+knvnxLoV3g717Q0fVjKBP6ejbYrlXhCbfhLGQncev5zybscmf+Ot3s/oQs2q3x+2UA7gkXcvbrii9fwWVSN7ASv+V2AlRczY+axMUQXaQ6vRymMe+r1NvAszxFhnRSPpqOb+LEr91Pu3fGSmWdqikfWhm7dG632LzhjnPoE81kF+ThRfnJNg3Z4QnKcfsCs/vebCeXJHND8+0PoEUBVPziXCp6j6wL1m8ungxd9tMy77mJahQrVU5kNTrxg93okXLX7kcaS106FddqtQjAsUdWXaN2yPuxi0fc2pXzbx4kXkzk8pWVonsLUeTdmQySLS0gXUIRWHXzYEJE0KwZski+AWt3ZRA6nXahWfm4rs6jljt3fOrbngZH4YVHTF2tEsbBC9xld76MZBqAkBofyCfU0t4lVii+U8aeX+JrdSnHAmu5rAJKMSzNYzgewrtKyg9YrrLVzufJwaZl4+S+BWNIujmE1LiteeI12r8H9MeEIZrbbvy098JQ4XmBa+9K6TVRHyDi//hJWfG1/aOwgoYyiDYmQP52NOlgPQneOb6Vg== 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)(376002)(346002)(39860400002)(396003)(136003)(366004)(8936002)(956004)(6512007)(2616005)(2906002)(6666004)(36756003)(86362001)(4326008)(83380400001)(38350700002)(44832011)(478600001)(26005)(6506007)(66476007)(186003)(52116002)(5660300002)(1076003)(66556008)(6486002)(38100700002)(8676002)(66946007)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?V0Y7NwUuIx8KXZL3UfY3y0G01lBIplL5//TqfLbzDX3NK2ODUUXh3XUaEN5T?= =?us-ascii?Q?3bZwtXOqCIGMNUmfPztUSfsfMI2W83Jvpl16EvBfNHbXrs8n884p3lGZw+1g?= =?us-ascii?Q?pujgvEjHK4/5oMelv/2bpNvaikDMbwtwWJmYp+uKkpoMO/+FJHX6jHs+IoCi?= =?us-ascii?Q?X1KekV8OpIV9waAtTCRgqqtziOcgQv7mQP6E3KmsD70cQcFqKebeviGxtRWl?= =?us-ascii?Q?O15BSTyRS00aRe2JIAhrw4z4u9uYxrSy/WcYLQ5p3MTared9zxrxjUnvKLDg?= =?us-ascii?Q?8DktTRs21JCV8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MsOvOuZY9Opzq?= =?us-ascii?Q?sqXgGamZJwNQVQfI9KH4E1aDr/VC//vD+euMSLi/G6ojZcjK74eOc9eWugKT?= =?us-ascii?Q?96p+abvD8tYK297CxMb92YIHi4lxM2ME2+CMPY4pv0DvrE1Qqul3urFO/mlp?= =?us-ascii?Q?wEsuKIymKK/LEy0eFCs3SHCO?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d64500e-c6d4-4a94-7c9d-08d95d611308 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2021 07:16:16.4031 (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: QvXxsCUKmSAdNxRydOmUU/6M/E7/GtEqDMUHtMle63ucYhRuKKhw0AdNzHu5sPyXyKJlryE7osPv8Kvo8PAZEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8461 Subject: [dpdk-dev] [RFC 07/16] 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 4c11a79d90..79ba0ecb81 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