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 7DDFEA0547; Sun, 17 Oct 2021 18:22:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C479C4112E; Sun, 17 Oct 2021 18:21:41 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80087.outbound.protection.outlook.com [40.107.8.87]) by mails.dpdk.org (Postfix) with ESMTP id E522240692 for ; Sun, 17 Oct 2021 18:21:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ahjbOEprQO6/SYDgzx9/odTqO6ID4OX+30xufOA1adrnmqv07Nekjk4odebkddQl7l0W6Z8Vly6yRSC0LuwnWLW0YMdOElyeJDB+tY7+LPnfj23rx3YdwU4v1uLvDnLc7jQqYgFWkB2D1F5KB188phwOYn4ZOYvt2mZwKG1LxAX8BH7YX3QbUhg/512JIciptmMOYTQzf0pZrLsdfIkCCzQBVF4NbvHNNkGk13ijbZdVDnREWBz1IObsgw6BzAgbWJKoKhfnNmycgOs7RX2u2lejz3LmL0ayxHn9aG2OAw/jsHE+1ZGv5X5Go13/bKosk1JZaPwyx0AZ9yS7bpdDkQ== 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=NR6RaTbBiTNoZ5qZ22wqvHEBDNNoDnouoddbcXlzjDc8CfoZC484zLyGYfc+Hbi5qYnTJco4yH7b0/3yYNjVLEPztDL0wpzJSFFZ8fBS96LamEYVLrfj71kTmWTzKMWdqg8YyNOKt5YNnmo8Sy4KC4G5guomKYDOxXd4FsfK4rrOvpHoZpmxYS3Jimd1C32v/gBcymdYhnVVNEQ7+bzKAzFMiJsTl4nrQ4v9ZSTZjMNIi1Ws2yiiI88nTEK29nS+eweV+Uu6LFC0+Sf8XXthKVB3IwFUr7IshFei7tkEGfK2nszDfI/K0uo2GFrleVQM+Ke+hOYOaKPWu4+75c8JoQ== 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=b9G05HlAGhfsJvXVAIhdvj0tft6+6Z4ZAmdyqn+TTDkqlQDO58alMnX1gCI6PCd4qt3UGI2rMoE+u0jBddZLMxBEPsXt4DFa4cHkfN1dm0N9/aZ7FYKRdRp0J9t8tt6HC/JPtHwuODwsr9tvAyUQ83hMpyt9PAtNYcnxy2JLWD8= 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:39 +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:39 +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:43 +0530 Message-Id: <20211017161651.9220-8-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:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a0c0c294-94f1-41b0-da4b-08d9918a328a X-MS-TrafficTypeDiagnostic: DU2PR04MB8615: 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: +DVnPSlVxc8DD9ctaRDRKaYiX0RjAw7NGFckPge/IMp9Hfyfai1/djiNuowwbkPzybvQjk+aAhbeE7qu3sq8jSYwmuCjmHHSMEt63XDURjIi6PhyGryaVaYeTcmBTwAccRqHNwzF5w/LpAdiYEklm4GVa4WRy1cEGMKuja1AJVupvqC5nJSS6KvjJVkGEQYsND6Myf7GNgHCx+OXHBrV8UX+WZA5l9TD3b0268NRt6Rjm9oGr1ZSqOCzk4IrELne1mGIALU5euij7LBT2C82+g8ixStnsCZaLXPrzwxAqnetYuM/D1jVbVYJ/1WtUmFVxzNn7tw1IFtIRRPhO1t2/6vPDa3t31oYfgjYfZmctV5u7qQ8LKu+gMUk7Y02KEySYB9hJHJMYULbQNcACeWfdY6NaGb65ydiMoaItYU5YAU/oY3/YUpIdGnF5sSy/lbSUKteX6U3AhMQcpLDIm+j/3C2o17ikGHnIQ3gJXYx+dVJlqAIkdOpjBn+c8oiEJvWi70gkuAAz5oYLf6FgVwC2PijAptaB5DJoxoIV9dVxQStwFfEOzobYIj5XqQ2i9GllcE6rRL67AcMG7xIbRH+m+VLWJ3TgNfaxtyU05eF4DAqW/8+3M5pRcSLQ5x35obdAt8Vnl93eq2ahtCYGUzcvstw0ecnlemukQPPAOedeI7Fv7tgoXE9nVwNotxPq24NmnrrCFpz6vpqVEJTwDtdvg== 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?mvOauQ35WceyXLKrfx3qn/WMSnEl3FgCRNgnEyDiGzSY0wnNrqrhSAsYr0rb?= =?us-ascii?Q?unWkAXcwRCZSFuTEC/K75ct/5I6oftU2sFYdlfpIT/qljZRWpFMc9bl89205?= =?us-ascii?Q?m1EzlEdjQPMGbNfG/0zM9DMiG0plWreVc6bBv5iZZbJ11hmzoGM8TI4u6tXV?= =?us-ascii?Q?GjCLEneZ0WFbia8TL7wBLUcZurHZDV0S8ssa8bBtlknA3G/Yya2oXUyZhWb1?= =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1k4P5KMh7Ry5Nl664jAAOgKtlcHgwTPuFm29/aQHh?= =?us-ascii?Q?AUnE0u3wBXYT6WctDSnMI7F40fOGZGZLpod6cLW5LbWjFOQtJ7/iZGvOeHor?= =?us-ascii?Q?7MIeXlXOF9kJABKIjxG96B6po6on2yo6o2XaYTUfonk45XIAAbe+LGG94GX9?= =?us-ascii?Q?0lwSAOnHEtgL31AyKYbwA5YlGIWDxwR9MxpGrQFm0tSpIVxwjEw4CFxAhZS0?= =?us-ascii?Q?RSi4OosjoL+2gib0+7YmaWEc?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0c0c294-94f1-41b0-da4b-08d9918a328a 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:39.1241 (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: vFV1p5NgA2QC1WvB7NJ0NYg8j26kkPUrCDNWFatFYLgkAZeSYeAB1ju94WVUUaoaxCh8h6oIUKETWzMhq7jusg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8615 Subject: [dpdk-dev] [PATCH v5 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