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 D50F2A0C53; Wed, 25 Aug 2021 09:19:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8483411EA; Wed, 25 Aug 2021 09:19:01 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2040.outbound.protection.outlook.com [40.107.21.40]) by mails.dpdk.org (Postfix) with ESMTP id 52131411E0 for ; Wed, 25 Aug 2021 09:19:00 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ci9Q1HaHvjG4xaV8bmP7xysgbOFinqo5n9pTrmKaziD0RB/CM0k9qMhpSifc21yZXUq83o0LSMy7bR2/3sKCctEnvu6lyKEiW5RLAlbikdvmLMwwCzFPrdZfYEhhDNbIJ2A1Sh8v1ae9lKmbPhQdktrnMg5WYnsTW/wM+5sDvMd5FashuAijQnCH7IitMUNbCv+IRYdEKeMOeO8UE1QnD1vUl5Urk6TFTeSxIy3om5vUfkFOcZNhbtouzp7JMwwePGQY30Fr0dZYFdPxUfV9nERxtGs+eXS7TtSc49fOV1VSfINVWTPWMqTOiJkRUuYHZXbqz//tC5es8TXYXckcWA== 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=XQwCm89ieuX9D1ojA8sGVwL3QpSqqoe249Ajyl2B+O4=; b=e9ARcSY7+jLy/T3MgecI7mavgi1HZgaU+hpc6hNk+TZfp5OyKfKCw/+cvPFK8u+9R/XXe0+c3q9MGDBW0BqA1qHJdVcJsq+5Z1pbCF+VOtQwupi7sf3q9UdvTUhI75nlCAjtcnzq/bDoJS1tI0fNZdDhZJL2yNraXNrM3E/0ORcOdlyeL6tu23Glu7spe1ylUyG+aFf9tkTTPuQKve2iOOj734HVZuVLj2ijQXio4+JNcYgeaHZjWud6XkuFG/u4STz/Jm86dKavISS//F5mTHRt+pEKWmhDXgh6xgQT4oIee8Ttak5Qw1SAnxDkCQgorAsQmS+FGQeDcNwaw8eIhw== 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=XQwCm89ieuX9D1ojA8sGVwL3QpSqqoe249Ajyl2B+O4=; b=VLieUraZf1cd3pIMaAHSZWm3TCksAEgl+lCOFXgP1wITASEndn4EJYhFXNdHVSYiiAJVA7EgobaneLTpJgnsE7TTL6n3dqjWgWt7VrLOY2TZNIl4aHvlXU+x4/wDsI8xBxsEn7Zdldsf54ePPqGeJEb7txTv/9vMiRKm+ls5mQU= 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:18:58 +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:18:58 +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:01 +0530 Message-Id: <20210825071510.7913-7-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:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e0919b3b-a03c-4d7a-7080-08d967989af0 X-MS-TrafficTypeDiagnostic: DU2PR04MB8614: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q9wc1y3k+tO4BmIqYoSaw6Rk4gLqNl0ml1ApKhMCM/7ZK7hY4mts3uTZU2MqRRrzYoqLW09IIDoA+zlu1IFH7aKveBU36CW0bS7KP3+N6RQVWvhZp5/L3vaaCiQ6mOiKVLQHVNpi2t7N0AW3wD5PgN0/0E7WRVW5RrVrILo9xqm+R1/Tr87JEB7ml9MffLW9eShbucuLkS4znXnOAfrBUqhiLYx1J5VO2IQi35HVH0f6sv/lXfdrzFOwP7uY7uUZCaplNvef3g8QerB+IN0Dxu1/LSeu9A2n/1EHLiRgC0ICQcS7HBve8GTCwORHlqjIh+gH8uuBROok6F35eca+/uR1z2eQ+XzkVbdgw4pFK8VrGcBCpprB1EQWg1BE3nIdKmF8Mh7LGKaHJ5gzCKFwEwfXTIKY/Lgt1wGSw3JJ/utka5CpWYlV7Vllqy0SR+aovnz8QWQahP/cZRuuiy7i9YDWEjlrMfUlzOWmXoWw6zOEVB5NWcGbjfh+pXqloHLCGvTBRcereDPpywfzeuUK6f/uhhmW/n2ofeqcgBS6vdJWycwex+UQ2s8AXv9zAdcsJa11Zj9FODOn6/0NjKEmsYJuIhyyMF5fkf1VT3LuxuK+FLbqu9In6MH1KyEYPQIVwrYJgs8yQtLsU/CI9YAbTYahUKWNX5w+D4i/BB1PvQPVVzaTLoDkkq68XTJpc9dfnMLEihfgQEK8cueeeTTokA== 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?facOuIkCEGdWZcPCtiQhpiMIYYPVtA2/dMg4lbhmfD9Ml/903yTS1yW5rtqX?= =?us-ascii?Q?0in3JSjhihY3BcfQzkrbLLrJUEwG/qUD75ypK+Q4qocYHrNZ/U6IhXxp3x0H?= =?us-ascii?Q?9R1iJ/Qt/xnr/agVeHAcQWAQzZN5rOBsP+3wzZVx9ZdeQib1uqRszJWmR+Al?= =?us-ascii?Q?soWlmqvOM448D3VGmR3kQNqSbLPl8ACAaQxnjTPPv0fMv/RsZuKiwbJd2Tiu?= =?us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N9VGrVttcdM5AiQaH4BawHFVZcuTHxn/Yhfa?= =?us-ascii?Q?OMP970gckQEl453gTv6D2kQ4SU1/yx3Zq834SrbuovaoAum6ps0XwiTiF+hQ?= =?us-ascii?Q?ULAXVNGMbZld+txpQfT0fBhsnbBjkvknANLH7T33/qEccOezmCIP1kqrWDB1?= =?us-ascii?Q?8B24OjWUXzd9Vd1sk4nqYg8CyBEsZG3DQXMTKOy+D6G7pBU8yQLyZN0xFc6y?= =?us-ascii?Q?T5BWrRFdbrFii4G8BML1MnNs?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0919b3b-a03c-4d7a-7080-08d967989af0 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:18:58.5756 (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: BP1jYjOEQSy7sIfHIHrouFNrbeeXVWX4tNrBAGW1vjaNLLhPfakxyMcVhOE0AM4wLc5JXFvi6zrpiXdtTj8JAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8614 Subject: [dpdk-dev] [PATCH 06/15] crypto/dpaa2_sec: support AUTH only 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 Auth only with raw buffer APIs has been supported in this patch. Signed-off-by: Gagandeep Singh --- drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 21 ---- drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c | 114 ++++++++++++++++++-- 2 files changed, 108 insertions(+), 27 deletions(-) diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h b/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h index 860c9b6520..f6507855e3 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h @@ -231,27 +231,6 @@ typedef struct dpaa2_sec_session_entry { static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = { /* Symmetric capabilities */ - { /* NULL (AUTH) */ - .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, - {.sym = { - .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH, - {.auth = { - .algo = RTE_CRYPTO_AUTH_NULL, - .block_size = 1, - .key_size = { - .min = 0, - .max = 0, - .increment = 0 - }, - .digest_size = { - .min = 0, - .max = 0, - .increment = 0 - }, - .iv_size = { 0 } - }, }, - }, }, - }, { /* MD5 */ .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, {.sym = { diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c index 32abf5a431..af052202d9 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c @@ -11,6 +11,8 @@ #include "dpaa2_sec_priv.h" #include "dpaa2_sec_logs.h" +#include + struct dpaa2_sec_raw_dp_ctx { dpaa2_sec_session *session; uint32_t tail; @@ -73,14 +75,114 @@ build_raw_dp_auth_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 qbman_fle *fle, *sge, *ip_fle, *op_fle; + struct sec_flow_context *flc; + int total_len = 0, data_len = 0, data_offset; + uint8_t *old_digest; + struct ctxt_priv *priv = sess->ctxt; + unsigned int i; + + for (i = 0; i < sgl->num; i++) + total_len += sgl->vec[i].len; + + data_len = total_len - ofs.ofs.auth.head - ofs.ofs.auth.tail; + data_offset = ofs.ofs.auth.head; + + if (sess->auth_alg == RTE_CRYPTO_AUTH_SNOW3G_UIA2 || + sess->auth_alg == RTE_CRYPTO_AUTH_ZUC_EIA3) { + if ((data_len & 7) || (data_offset & 7)) { + DPAA2_SEC_ERR("AUTH: len/offset must be full bytes"); + return -ENOTSUP; + } + + data_len = data_len >> 3; + data_offset = data_offset >> 3; + } + fle = (struct qbman_fle *)rte_malloc(NULL, + FLE_SG_MEM_SIZE(2 * sgl->num), + RTE_CACHE_LINE_SIZE); + if (unlikely(!fle)) { + DPAA2_SEC_ERR("AUTH SG: Memory alloc failed for SGE"); + return -ENOMEM; + } + memset(fle, 0, FLE_SG_MEM_SIZE(2*sgl->num)); + /* first FLE entry used to store mbuf and session ctxt */ + 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; + + flc = &priv->flc_desc[DESC_INITFINAL].flc; + + /* sg FD */ + DPAA2_SET_FD_FLC(fd, DPAA2_VADDR_TO_IOVA(flc)); + DPAA2_SET_FD_ADDR(fd, DPAA2_VADDR_TO_IOVA(op_fle)); + DPAA2_SET_FD_COMPOUND_FMT(fd); + + /* o/p fle */ + DPAA2_SET_FLE_ADDR(op_fle, + DPAA2_VADDR_TO_IOVA(digest->va)); + op_fle->length = sess->digest_length; + + /* i/p fle */ + DPAA2_SET_FLE_SG_EXT(ip_fle); + DPAA2_SET_FLE_ADDR(ip_fle, DPAA2_VADDR_TO_IOVA(sge)); + ip_fle->length = data_len; + + if (sess->iv.length) { + uint8_t *iv_ptr; + + iv_ptr = rte_crypto_op_ctod_offset(userdata, uint8_t *, + sess->iv.offset); + + if (sess->auth_alg == RTE_CRYPTO_AUTH_SNOW3G_UIA2) { + iv_ptr = conv_to_snow_f9_iv(iv_ptr); + sge->length = 12; + } else if (sess->auth_alg == RTE_CRYPTO_AUTH_ZUC_EIA3) { + iv_ptr = conv_to_zuc_eia_iv(iv_ptr); + sge->length = 8; + } else { + sge->length = sess->iv.length; + } + DPAA2_SET_FLE_ADDR(sge, DPAA2_VADDR_TO_IOVA(iv_ptr)); + ip_fle->length += sge->length; + sge++; + } + /* i/p 1st seg */ + DPAA2_SET_FLE_ADDR(sge, sgl->vec[0].iova); + DPAA2_SET_FLE_OFFSET(sge, data_offset); + + if (data_len <= (int)(sgl->vec[0].len - data_offset)) { + sge->length = data_len; + data_len = 0; + } else { + sge->length = sgl->vec[0].len - data_offset; + 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) { + /* Digest verification case */ + sge++; + old_digest = (uint8_t *)(sge + 1); + rte_memcpy(old_digest, digest->va, + sess->digest_length); + DPAA2_SET_FLE_ADDR(sge, DPAA2_VADDR_TO_IOVA(old_digest)); + sge->length = sess->digest_length; + ip_fle->length += sess->digest_length; + } + DPAA2_SET_FLE_FIN(sge); + DPAA2_SET_FLE_FIN(ip_fle); + DPAA2_SET_FD_LEN(fd, ip_fle->length); return 0; } -- 2.17.1