From patchwork Tue Sep 7 07:59:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 507509 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp4012513jai; Tue, 7 Sep 2021 01:04:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrbbDcnshz58UE7Bd5NVanl0atHuGf13w18UKvEIWpBYWracHtEC1mAhUto7n9aLgRvCsn X-Received: by 2002:a17:906:8297:: with SMTP id h23mr17777917ejx.168.1631001896095; Tue, 07 Sep 2021 01:04:56 -0700 (PDT) Return-Path: Received: from mails.dpdk.org (mails.dpdk.org. [217.70.189.124]) by mx.google.com with ESMTP id 5si10206609eji.628.2021.09.07.01.04.55; Tue, 07 Sep 2021 01:04:56 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) client-ip=217.70.189.124; Authentication-Results: mx.google.com; dkim=fail header.i=@nxp.com header.s=selector2 header.b=ExtFidLT; arc=fail (signature failed); spf=pass (google.com: domain of dev-bounces@dpdk.org designates 217.70.189.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3E0341130; Tue, 7 Sep 2021 10:04:07 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2041.outbound.protection.outlook.com [40.107.21.41]) by mails.dpdk.org (Postfix) with ESMTP id F3D5F41150 for ; Tue, 7 Sep 2021 10:04:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KhsQVu2rcQsPG28a75iBpIAKpY7XUgv5Lg5nhbIj6sImnWFaYH2zHY15vYB/0oLUhEdYXt8O/5Wy02BwLZG/DsEIvO/V+gFgkQH8XVFxa9SH//NddD1cgzL9Nl/FozDLC5MQEO+uTNV2ij4HTLr9ZCRIexk5PWQauIgpeY84WAJheioSR1AJitmC83D/GIURhqyafG49IovfiMOLdi/Rlzw7KiXdfdAQfNI9z8Vnxnu51KTooO9UqN90nkA5wD0pxiLPegCyjxoFQDZYN5TVTwIPcnfgqHzqnyi05iCLbEWAaXjOrpFW6uD2hqVIEoeDarFvLFTXJ4989MUukD8ZMg== 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; bh=AwF9cy2Wu06LGZsc7ollU4u4igDpcftii7N4enq75HI=; b=Dz/Ea7Hew/FU5vZWtXfQn6MqhLID5Ywhc7cncfju2EVFHskhCwe+QQx8pI9XnV1yuf/yeZ5PhZoBEMPABAlE+QNG+lOaNMMrwCWBZC0kj9bFe8MRF4BuZEE3gGLS7ow//tRAZMcOh1h9YPW/ZjH6JCPxIlxN1lAMTwCaPmwVnJ94vimJ9R9FptVYFLdWwiAXF5QNrM4BQ1Mq2i+96enQHoZuSG8xrTviwgz7RO8pBgvtyn6caHIwMKAZcXdAj2kX8r4rUbgI/kQVZHU+Yn/rJR+eyAtti0lrEckPwOgI6lF58cBAkfWAv5fV1irG2E4ejfP3FVzBArC6gRaA+8YweA== 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=ExtFidLTfTcED3HJZvHRBUVHdlN/rUFzlHkxdfg216rM6sxm6tJTlfR+KY22VcETGb1DZOBK8IAtfn48WGprWuzMlNr0QJ+RlSmvfdq50MzltPFueJnmRcZVk8JPbyqSRutgp4u2dv7FzJqKZl8N/KJ3U9autfwbcuGwXPKxv0w= 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 DU2PR04MB8709.eurprd04.prod.outlook.com (2603:10a6:10:2dc::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Tue, 7 Sep 2021 08:04:04 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::945d:e362:712d:1b80]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::945d:e362:712d:1b80%4]) with mapi id 15.20.4478.025; Tue, 7 Sep 2021 08:04:04 +0000 From: Hemant Agrawal To: dev@dpdk.org, gakhil@marvell.com Cc: konstantin.ananyev@intel.com, roy.fan.zhang@intel.com, Gagandeep Singh Date: Tue, 7 Sep 2021 13:29:49 +0530 Message-Id: <20210907075957.28848-8-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210907075957.28848-1-hemant.agrawal@nxp.com> References: <20210825071510.7913-1-hemant.agrawal@nxp.com> <20210907075957.28848-1-hemant.agrawal@nxp.com> X-ClientProxiedBy: SG2PR02CA0068.apcprd02.prod.outlook.com (2603:1096:4:54::32) 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 SG2PR02CA0068.apcprd02.prod.outlook.com (2603:1096:4:54::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Tue, 7 Sep 2021 08:04:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0fd70b22-94a6-4dfd-38a1-08d971d60f13 X-MS-TrafficTypeDiagnostic: DU2PR04MB8709: 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: 17f7eVpF145lHSCBIt6O0/she5X2LY/VMnVTpn8Q5Q0t2i/fvzEfjckz9o3Kw7qeE/XKRRPjd6ZRC1yxMLXxswaIUS3BMSnfdJEBRqn92O392VbeWWdSttceK18Ug+virK4vnIxBb+POdijHaSVMdKtcfM73UKfkuEirO3c4kZv33SojJeUxNRhwRYz1Zd9EOmka0JV2HixlS9qTKz4QtSH46QQlAiKiETnW5yxjBl5l7hAxoY7elbsUD7ytXGHKKOfgSdUVmZaEs6hj8h9Z02CBmdcn8HhS4pytHARxXIXAjpPFerDrP2p11M2mD5RLDAvvgoGN135PEZ7XKv8j8zzpy/y9BdK72msCu8rkAGlyrTwUr2r14XVQD0a9BZnU3YZrak33rRw+y7HiYF2gN7HaKYEVmV2WNPB7ZkV9yxIpONLGKeAm5VGZtBwggO4bSW6MVevlEK9il1BZ0K8gNlmen0eqFYAQX+Q9tVl1wPmqDhi1PxlcXFulaXC7RMYausFvXqhGFeUSxlYTVqzzDTbLkdw93asH1MIzYmVavkQUEtpUHHId+zpO5fslKDGA07V1aIrlvZMsFJrHmlpkM4hYs2j0IN+PV/lblNaOaSidaoBLIEZmJz7JZyPk+YR4xF1NTfdjGEmocDl5ohOj126i65p03pzHhdutxGAEEA4q9cKHZiFkS+6UrpQMfooB7X1y3xEGzJGlGOS+4RI8/Q== 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)(39860400002)(366004)(396003)(346002)(376002)(2906002)(956004)(2616005)(86362001)(83380400001)(478600001)(316002)(6512007)(4326008)(52116002)(1076003)(5660300002)(38100700002)(6666004)(38350700002)(36756003)(186003)(26005)(44832011)(66946007)(6486002)(6506007)(66476007)(66556008)(8936002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yix8Ypa+fVpBIguzS2U+GwH3UzY2rJ0Vq3X5YHXmXnxh6wmosgiGPSFXW1tRnQ5b7V62iPLqOkwRKHYb44aZYx7YK0P3fEzfgLWvIIpPjkp4XLETCUmVGVVHP+jjZbOcumUiPkbsTdb6tDQF4FeX1ql3JpRK8xiV7dbGGfu4JynDjg9fO2xyJUk9IJnRm5URWlPKv6vSLdgV6B6BqlSbAFsdZebx53etvnJMDUdmHrs8rQLyp9Gpbfsh5JGYkcEVxVjG9/AHBE7LRNjv0dCe6aa7+aL3wm/sXAfy/k9SGu/gA/w6QbrxqYZ9DcrCgLv3YL8ACRLtzFut1FqAo/qulaYjyUR/20aeaMfkFX3omP0Pf8r7bR1IwR0cFCm7x9IKP+jqg6lznd/Jq1+LXnG1Tscw+HeYKFrTUqfZ69RfEwcddWIF7qy3A/7qLUC+WxVWFydJmB4ThEsoro4MD1kAGW2tYLYkZhmj4BssNDxrP/x+b+/nsWCq/dnnNFvvXQ8czG9QCgVT3U29sqK2Wl7NwGH1gWY91xTyeDUX8uyNlh1e6NbR7UD9eCQrgaidkRlMCdYfv+ZnPtzVjzzKmx1W4MsphUWmDQjyCj2OKh6WCEt4AGX3Jc95dYKNmbvROi54oWPbJsk3325je+5lOPK55lo9FrMUp53qZJvoOs80iNgz9C2qo8fc2/KjnG1ijdCAC0a+9YlovdZJ1ZPffYQklaIzxpEMf2e8EFVhVwKd7v8BRcCW8EnRwJUzYhr2ETEmai4FtxMdUPB3FjZTo+uS73e5E6BfaW1V0b33Sb6CxrbA9ma/rd4u0rgs3d5kzjYBrRM4qgvHh49XiP6WAkH44GMw+TOlCBllRk485YFNV6CjM+1v1ZgsL9VA3Iue0EVWvFKsEUXIEMvKca3JOd+MCdeibmNaRIJ9EqpTJSeIkgNo6e7Phm3JZUinMzvk6fbT+CzxPeu7G8uaZhrQ4la29xOpC6CU0vJjOfeoYyyM5McepNkuagLjGmq5fNEyYBPW8wADQrdG2n5QB/tCaa0qV6wofEkE0RI/VLRn1e2wpceLdHB5XRaNoeOSYmUyHc+tEyq4yFdKh0XiKppd849WMkz9lsiM52sRs/FrA04aHjq3JV42BTf54Jcb72now6AG0TumiHmkX1Jw6fJrr512CgbbObAKlhsdHhmEZzK9JHIhFYe1pkijkl/vbOfTdJ/CD8nL41Ay7MMNQ0EHrGDrlzvjVkU+5LSqmxfmlS0eXryZxg6wzYMJWqsTpnP94PAHLDo5PayH2lY5lx0Txdy87RSRlx2n5BjTCKpNk91scrf/H1S7jzDIQgZ+XX7YCyvD X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0fd70b22-94a6-4dfd-38a1-08d971d60f13 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2021 08:04:04.2181 (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: H+4dCddZBVxsP0Kqya+sxs6SkHmUqQvUBUkagdCzY/GoXYtD52tXIaK4uvcOZTVqVnSJ0zZe5fevjylpwXmnyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8709 Subject: [dpdk-dev] [PATCH v2 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(-) -- 2.17.1 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; }