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 28D6542CFF; Tue, 20 Jun 2023 03:24:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D30ED42D13; Tue, 20 Jun 2023 03:24:30 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2055.outbound.protection.outlook.com [40.107.220.55]) by mails.dpdk.org (Postfix) with ESMTP id E8E2942D12 for ; Tue, 20 Jun 2023 03:24:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PwwyxznDiZcv664Yr83Eebm6U0gRvkc0EhFgyvkT2zZZoWUTmG1C/eRs/NnTmjGDeQSBUNb1mtqKyxwR/JIpKWd+Ndny8151lAGOnx+UT5xyBd0CQug68SuEJ44do5Nvdrla4hetnTgKA8zXJaIgJQsQBCPxvObVt7IeFAoG24tgi6tq+nTrqPXDBL5UT+b+8DP8H5BISaQYArFNqNk3IGX2HiPao7uH/REQ20e6+JIlb9bhiMxdcFiVM2m2CZvj53zC31DY+vugVLunoHXWPAE9Mzu4d3UrynF3k27Pi4JFAbqMqdyr4nvRDic0wXp3zUROPD6/U4216Nn6IRfjBQ== 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=/NA9wnjJ6PtBq2wCOwpZy4M86G/GIq/gu5L5i1WNYGk=; b=PwzHTKGWcW3HhiUsYkBYmaoGq57baECI/eFWqKgOnRHZcQ069P6UNjMxIigONNl58JZ9Ef6Bpdsncz0NUVxDiP3CE3I/I3kv/blp070iHyZSg86poCxAo5l0G5CO5JA46aDIDTqoxPFLGCExtnPIQ3rsVUcSyPXDAiJmW3UuOtcWbaS1v/ipM3En7XXso7ZxkfHBdm0PE8M50PPmhOqJspZM3d2g0ENGHxz7nCRNlB77evl0PTMdV3aUhPjb9quFRI9z5MzOkmYBUvvpKL/u2m/+P0kLoJWqrKqQNNsm6xjNcZtcCZtdbQOohZmDhfO/djflzPsqFgkcEl/39vQFHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/NA9wnjJ6PtBq2wCOwpZy4M86G/GIq/gu5L5i1WNYGk=; b=syMQ/k2uU1Rvutocmo1E7Cf7N6W+pAr7iaoLwawV/kMx25Z6XfTfBOCRz88tJ9XSHkUwXTpoG0XReE7J3bWxW3kydUFHtQvZbrzaz4cv7pLD6c0cwtC46ETcsyvTvHSAtbjBXbGHi4kKM0bJdkOHnanFqmkLUXibt7YE2WMJX9h8EfpJNh4yLiJ/6e6N4GciIYmWqX7Df1TT1QGuY40kf9bpd5TWZvYjeVjnf4wlNjQJi98bGbKQKLuHgxPV9dQz73QAer65yiZqqooTprtPsE00omkDUV6IiOS2+cDFSgltGC4qQErnDuR4sNCI6oLROuRZRPkaJsivMpkTdSGy9w== Received: from CY5PR18CA0037.namprd18.prod.outlook.com (2603:10b6:930:13::20) by DS0PR12MB8366.namprd12.prod.outlook.com (2603:10b6:8:f9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Tue, 20 Jun 2023 01:24:27 +0000 Received: from CY4PEPF0000E9D0.namprd03.prod.outlook.com (2603:10b6:930:13:cafe::c3) by CY5PR18CA0037.outlook.office365.com (2603:10b6:930:13::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Tue, 20 Jun 2023 01:24:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000E9D0.mail.protection.outlook.com (10.167.241.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.20 via Frontend Transport; Tue, 20 Jun 2023 01:24:26 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 19 Jun 2023 18:24:21 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 19 Jun 2023 18:24:17 -0700 From: Suanming Mou To: Matan Azrad , Viacheslav Ovsiienko , Ori Kam CC: , , Subject: [PATCH v3 5/9] crypto/mlx5: add AES-GCM session configure Date: Tue, 20 Jun 2023 04:23:18 +0300 Message-ID: <20230620012322.788099-6-suanmingm@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230620012322.788099-1-suanmingm@nvidia.com> References: <20230418092325.2578712-1-suanmingm@nvidia.com> <20230620012322.788099-1-suanmingm@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D0:EE_|DS0PR12MB8366:EE_ X-MS-Office365-Filtering-Correlation-Id: f64378d4-1f5d-480d-4ace-08db712d169f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IqKG6NvCvy4q94p+MHUyNkiRLWgQ6S+JItcOD5SciZDe626TBa8b0lbItWKYSQwseNdLoLersxsMDhqNDb7ONV8KXsw7yaswFBx8s1RLtLfAYdi4ZpOGnBmggAHEliV+LvH/SJ05dn3Kxza69oKoTmL98o5uNscMkh4iL/gcoxyUgUzQGMpqVmTMTA4YArwRa3BOotLxdrIQyjwl0taPbD2nCVDNUqFw4y0Y0TCFSjL+yeDDmc+rMQpm36s+3Hf2uOls/Elkh445IWlmXylA3eoUOAyDmlJLijWnNAxiP9Crl5A51CK+D/XiR2KZywGFK4fxdt1oR8driSTcMyXL/HLpUEWvO0GSWE70ZSiRYDh8YMsod2A1QhgR4r9XyUd4LVMga0Eh2hoviEwpKoKNGuCLvzQ6lV2KnqnGS63NhmmrRKlcUOaP8GUsOEIhgZ4ALQWzyXYKHpQxDn7q0dwNpanVu6i2pIGjYXCPH08V8tTv6ASkZqvm1QOTEoqyohdxvqSwXFDiS0rNcYTws/sQr85xg0JDKtuLlEZBCugpQTDFNI+3YJKs5eMVkKZHME3JUvnmOVC/rAHxoGw9GB1ZUDtK9fBtLXZTA0EH6CCRotu0axtYi0+0iwbCXHKNDp2wx69fuLOtZKObUWKUeAa7Cg8VctC9F5W4FGfrJ/C6Cv4raXQTgicn+lu0CEseEdhyuzBbJ3gUe/EEO89Oh6GiGkIp8d5mtqNyfJ8aM0LMwmoHBCmc9qjG+BvNNTWA4ObD X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(396003)(136003)(346002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(478600001)(70206006)(70586007)(36756003)(8676002)(6636002)(41300700001)(4326008)(7636003)(47076005)(356005)(40480700001)(2616005)(55016003)(426003)(83380400001)(336012)(82310400005)(86362001)(7696005)(5660300002)(2906002)(54906003)(110136005)(316002)(8936002)(40460700003)(1076003)(26005)(186003)(6286002)(16526019)(82740400003)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2023 01:24:26.8968 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f64378d4-1f5d-480d-4ace-08db712d169f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8366 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 Sessions are used in symmetric transformations in order to prepare objects and data for packet processing stage. The AES-GCM session includes IV, AAD, digest(tag), DEK, operation mode information. Signed-off-by: Suanming Mou --- drivers/common/mlx5/mlx5_prm.h | 12 +++++++ drivers/crypto/mlx5/mlx5_crypto.h | 40 ++++++++++++++++++----- drivers/crypto/mlx5/mlx5_crypto_gcm.c | 47 +++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 8 deletions(-) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index 755bd73275..6b48c6ca32 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -523,11 +523,23 @@ enum { MLX5_BLOCK_SIZE_4048B = 0x6, }; +enum { + MLX5_ENCRYPTION_TYPE_AES_GCM = 0x3, +}; + +enum { + MLX5_CRYPTO_OP_TYPE_ENCRYPTION = 0x0, + MLX5_CRYPTO_OP_TYPE_DECRYPTION = 0x1, +}; + #define MLX5_BSF_SIZE_OFFSET 30 #define MLX5_BSF_P_TYPE_OFFSET 24 #define MLX5_ENCRYPTION_ORDER_OFFSET 16 #define MLX5_BLOCK_SIZE_OFFSET 24 +#define MLX5_CRYPTO_MMO_TYPE_OFFSET 24 +#define MLX5_CRYPTO_MMO_OP_OFFSET 20 + struct mlx5_wqe_umr_bsf_seg { /* * bs_bpt_eo_es contains: diff --git a/drivers/crypto/mlx5/mlx5_crypto.h b/drivers/crypto/mlx5/mlx5_crypto.h index bb5a557a38..6cb4d4ddec 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.h +++ b/drivers/crypto/mlx5/mlx5_crypto.h @@ -72,16 +72,40 @@ struct mlx5_crypto_devarg_params { }; struct mlx5_crypto_session { - uint32_t bs_bpt_eo_es; - /**< bsf_size, bsf_p_type, encryption_order and encryption standard, - * saved in big endian format. - */ - uint32_t bsp_res; - /**< crypto_block_size_pointer and reserved 24 bits saved in big - * endian format. - */ + union { + /**< AES-XTS configuration. */ + struct { + uint32_t bs_bpt_eo_es; + /**< bsf_size, bsf_p_type, encryption_order and encryption standard, + * saved in big endian format. + */ + uint32_t bsp_res; + /**< crypto_block_size_pointer and reserved 24 bits saved in big + * endian format. + */ + }; + /**< AES-GCM configuration. */ + struct { + uint32_t mmo_ctrl; + /**< Crypto control fields with algo type and op type in big + * endian format. + */ + uint32_t wqe_aad_len; + /**< Crypto AAD length field in big endian format. */ + uint32_t wqe_tag_len; + /**< Crypto tag length field in big endian format. */ + uint16_t tag_len; + /**< AES-GCM crypto digest size in bytes. */ + uint16_t aad_len; + /**< The length of the additional authenticated data (AAD) in bytes. */ + uint32_t op_type; + /**< Operation type. */ + }; + }; uint32_t iv_offset:16; /**< Starting point for Initialisation Vector. */ + uint32_t iv_len; + /**< Initialisation Vector length. */ struct mlx5_crypto_dek *dek; /**< Pointer to dek struct. */ uint32_t dek_id; /**< DEK ID */ } __rte_packed; diff --git a/drivers/crypto/mlx5/mlx5_crypto_gcm.c b/drivers/crypto/mlx5/mlx5_crypto_gcm.c index 5b315ef42c..5f55314382 100644 --- a/drivers/crypto/mlx5/mlx5_crypto_gcm.c +++ b/drivers/crypto/mlx5/mlx5_crypto_gcm.c @@ -60,9 +60,56 @@ mlx5_crypto_dek_fill_gcm_attr(struct mlx5_crypto_dek *dek, return 0; } +static int +mlx5_crypto_sym_gcm_session_configure(struct rte_cryptodev *dev, + struct rte_crypto_sym_xform *xform, + struct rte_cryptodev_sym_session *session) +{ + struct mlx5_crypto_priv *priv = dev->data->dev_private; + struct mlx5_crypto_session *sess_private_data = CRYPTODEV_GET_SYM_SESS_PRIV(session); + struct rte_crypto_aead_xform *aead = &xform->aead; + uint32_t op_type; + + if (unlikely(xform->next != NULL)) { + DRV_LOG(ERR, "Xform next is not supported."); + return -ENOTSUP; + } + if (aead->algo != RTE_CRYPTO_AEAD_AES_GCM) { + DRV_LOG(ERR, "Only AES-GCM algorithm is supported."); + return -ENOTSUP; + } + if (aead->op == RTE_CRYPTO_AEAD_OP_ENCRYPT) + op_type = MLX5_CRYPTO_OP_TYPE_ENCRYPTION; + else + op_type = MLX5_CRYPTO_OP_TYPE_DECRYPTION; + sess_private_data->op_type = op_type; + sess_private_data->mmo_ctrl = rte_cpu_to_be_32 + (op_type << MLX5_CRYPTO_MMO_OP_OFFSET | + MLX5_ENCRYPTION_TYPE_AES_GCM << MLX5_CRYPTO_MMO_TYPE_OFFSET); + sess_private_data->aad_len = aead->aad_length; + sess_private_data->tag_len = aead->digest_length; + sess_private_data->iv_offset = aead->iv.offset; + sess_private_data->iv_len = aead->iv.length; + sess_private_data->dek = mlx5_crypto_dek_prepare(priv, xform); + if (sess_private_data->dek == NULL) { + DRV_LOG(ERR, "Failed to prepare dek."); + return -ENOMEM; + } + sess_private_data->dek_id = + rte_cpu_to_be_32(sess_private_data->dek->obj->id & + 0xffffff); + DRV_LOG(DEBUG, "Session %p was configured.", sess_private_data); + return 0; +} + int mlx5_crypto_gcm_init(struct mlx5_crypto_priv *priv) { + struct rte_cryptodev *crypto_dev = priv->crypto_dev; + struct rte_cryptodev_ops *dev_ops = crypto_dev->dev_ops; + + /* Override AES-GCM specified ops. */ + dev_ops->sym_session_configure = mlx5_crypto_sym_gcm_session_configure; priv->caps = mlx5_crypto_gcm_caps; return 0; } -- 2.25.1