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 89137A0C52; Thu, 12 Aug 2021 09:16:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CEC1B41227; Thu, 12 Aug 2021 09:16:18 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20088.outbound.protection.outlook.com [40.107.2.88]) by mails.dpdk.org (Postfix) with ESMTP id 73AFD4121A for ; Thu, 12 Aug 2021 09:16:15 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GZocGW3sUzrUCg2mpd8nW4t2+d3CO94MNIAiSMN5JAPAyf/VfidizOhosR+2Bsjn+IjfXQJsURIYlMFGeSXX1c8i5ujBu3OgtR0cuG/dSIzwnYaeA7RdV1Xhs9IIg6qCIg+QIXETs1HbIfdm7WsQelA/dfHvY4bhAUsnTvmDZ9S4ILwColn/iyrMDQafMk6ZkzakEVxL10JrvuIkDiWfs688c2cZ78y9XbxhG39jkyXGxmm8SRjSbUI6je2kWAKYcL5183Q2A53XoYc3ivw+o1kIW7PvRPeRFpD94RtzFRiI1+cew1JzFnxHtwDJfsoPog8bszPcSKQe1VT9PhOs0A== 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=kKhL+HnRHN3YbKDfgRKgLgDb2iirBd8l+ojgqk93ou4=; b=ENcUbSZ5ho42H/BdLjMB5jcD7cwVXyOTLoGfarm9Sv4OhV9zSruGA1tgo4/VgL6T6TltpLGQdxvb3nNAmDXn/hXRp50n1Ef6MWkFW9NJTHGNKpdG/3iBg+SfhTUBfpEuOmOOvitHsa2vqxTYr7SUFzDtDPf1X4GQ2SegB46mtdcGJiWu/PpsR6BLd1c/MgcfpPInqeMTlNqryN4LFmxe9qwFg7I+DtqUedw0F5Ydvklx1fQnlBVYABuKB9+x7Xp1v2YjgtlmHBtoLDGlcyY/FyAJ839Rszn736B+sP3XDUQext3Zop8QtmOLujZ+NqCKKZ+LqWZQ+WNnehMnIbH/iA== 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=kKhL+HnRHN3YbKDfgRKgLgDb2iirBd8l+ojgqk93ou4=; b=QAkVnlt75ONo1oDen/0XvWnmjX1mhaSGqytIrzrTendFpz+vlK2wx9HU3CVf3MTKz2xnLwE+e74FQdJ96LVIOPXNXEWlsSXfqQ1YmiUSRzWA5LlDm1VH7ZYz+iOqA8UOccGW4xDOO0Z/28unSjkg1eh5TQNCAGnyOUBR4jk8O0c= 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:14 +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:14 +0000 From: Hemant Agrawal To: dev@dpdk.org, gakhil@marvell.com Cc: Gagandeep Singh Date: Thu, 12 Aug 2021 12:42:34 +0530 Message-Id: <20210812071244.28799-7-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:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 34fc260e-e9ad-4475-691e-08d95d6111f1 X-MS-TrafficTypeDiagnostic: DB9PR04MB8461: 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: p1NiJXEnJSWWebDvBsjM9OPjmzkw4FWeU4SFOeRjHPGO5OlH2VszhYuMw3XhpCpPYYQEZyX2T2nFK9GFDU+C5Dj8K8T3ot2SQPIbe4gi8sOm/qW5w6M+iJw3W5alUnEdnMAM+MGTdjG2I8LtJ8E9AFVGvLINubdnYJrCTgzT6UYOfbsqbRY0Jt3Nunybbk9NZ0mBfOGJNdICy/rvXbrvpmAsJMiy3xV/UDokLGUe5Iu01IzNTwnjgxLZ7QyC6f4av/qvxznHkto4qhh4CHZ/YA+QG5HUgonALA8xtky2vwfCVhs2bLS46ex7kH1LReAxXzBPYJJKLrnRxEq8khdEr8Fda7UsCOY76pIdBbPoycTn9BaIplk7qAXvzXMUrJuxuZ3wTw/HxjISWz2iYV3xl5Y5zlZNwLuXGyMGW0sGMoiiQcbmxX6Iz7C48oleIUZ7l98dvLb5nmHDUVU4tgJ+OEJGDyvqEwERmOIBvKSbjF4efYAkofEpkCXmnXLK/5rUY3TjYDeTgQucxVJ8lMYwynnnRXnwBV3AzOXn8L9tbkO0+zoBxhmzJ/pjL++3YzZQZeKFhfskaqDPMn2hkpRXAdLIncjSjxZbQzGnqs95pVg+refkAs3md/X3sLqc+xqf9m3rWCr+E6xCaVfZ13ptNxgS9pX3u9vAhh8d/M3g8YOTW1S/4t9YjUpDW8YNMq6vBB0Q6fjWtxJiX+wGDkdS4A== 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?K9cGaUxAXRcZFFgHD7kSXuKzKgjfDU1WP4JbPceam/pyNEqpzdAetyInclug?= =?us-ascii?Q?fC5MMedXONzrrBUqUF7bVG2rNCcvR2M4SfxT/wTiNMPb2wPtNPWhJBg8AeUZ?= =?us-ascii?Q?2HydBExg/Ep7lQ1zCr871GVlfzkmCkhLCMSdG3b8ToTE9MW0MlR7lSdnYrS2?= =?us-ascii?Q?hcno+2kghEW6XcGUp+/RsgarnvEqmHOIhyJ4wCqijMrwd8Nf+OSYlJkOJatD?= =?us-ascii?Q?oYeTbdd2YN5JiZiWVgOYnLSa5WBR4ubWirryYkJLqgUykzwhWX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/1dd3R4Dq05feiIZbGbEd7TvgEHQj?= =?us-ascii?Q?BWl1v3ZxS4xXhCNdl5jXN4VJiGXz7JLfMPeB72Ns3tXT6NRImpeDoUjP8wox?= =?us-ascii?Q?41SGVpMi1BYp86SbjSjWjOw/k7iRGD2rTW+qJNcBS1lHm8uzuYT6rzvUuKIM?= =?us-ascii?Q?/Pl3bH9tql1Ao2TC8Hv4heOz?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34fc260e-e9ad-4475-691e-08d95d6111f1 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:14.6170 (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: hh0qAwV1xLZmcNZ2QKmxR5p4W1L9xLGp66beKBuqx6OUREHmn+euJ1yullJoNjjRklsdEAjxE46tP+9kI20SFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8461 Subject: [dpdk-dev] [RFC 06/16] 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 10cb4247b0..4c11a79d90 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