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 C1A9742D09; Tue, 20 Jun 2023 16:12:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F5C842D53; Tue, 20 Jun 2023 16:12:09 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2048.outbound.protection.outlook.com [40.107.92.48]) by mails.dpdk.org (Postfix) with ESMTP id AAFA542C4D for ; Tue, 20 Jun 2023 16:12:06 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=exvRAIAKNA9nQ8ygKq/M9hWs+afsFEuvoKZ9+9oGxjRfflX9Q4phcWxw77rDVDC+otDEHgL7ZIOXTHaA3CzoqaAamS5LwmQ0R4E2UbwRG555e/PBxAU3YG3Plw6JXaPcN+3fQOlFc0b5wlcjh4euryIsRmsEKzGTHQ/LTI4hPpX3pveuzVUcr/mpYlqWsj9nHiarel9hRl8Rb34MpuHJGx2BnNEZu76Lt0/qHBbxRgML0rsBLqPFq8zSEuxNKDfIC+B8LHgv8n+5f+wKQ/oOw6TnEyRdtkuv/2BPwjzSGNtkMTwxbLlX1vp4651ZvPyqF8N5p5un/94szZnRzFU2kA== 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=9FMbJWD2iYms/jautUKJm/wg0pRQ5x1EWNB1KiKvEPM=; b=NiOhcVXIm+mYxKyOrZZE363sDTA6QuZhdppgiBLr58uu38um7LX2oM3qtM26JFhBMD9zs2ORHUyTaxedgzwHfAFZCAULWUveaFbf52qmcDleLl7gexWFfsufNbVoRiGMr6cIVEqrpbV5x6aooPnHUKtd9r9allKIJqhapMsTMuNCodnLI/DSgGaEgUPuIDTkuGM+Hs1k/zcgvndGhoexbkzO7q4pHARBn7pxnNUX5hV6I9sTIP9PBdneNzOzc9K/UU/hJWk8qYKXKljB7zZPBdNOigiUoOnvAAoDIYbTJ6/SabGL2bRHHZFGGPHNAIjTdNEWfLLzy3/9CCiuPAWd0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=marvell.com 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=9FMbJWD2iYms/jautUKJm/wg0pRQ5x1EWNB1KiKvEPM=; b=ezD8vHNHJs5Isr4gdUtMmzg+IyIrA1NauAkxo14H+Ji2mxx6G4tt7IidIBZ75lB04Gn+YMmee5cRnsiVhn3vSC2dMcKHfcDlyAKsJ/LWQOnl+3iRE/m7mHxJdVCBA16R1VvrFmQ1IbItY5rOrab/OOlZglyB3EIpsvOzCvJQijWRZv33/SNObNUUNfVmul8Rl9fe5QRuipT+ApQ9apI2JuwjerVjOLSWFMMf/pdZbTYdxjQdByPQjmLETTWBvy42TcwC8uWIWtCYbNmGO3gOJrbEDZxLN5pMCSmHMfRw94U/JBmMaxKrM5+krwm5sxFVykzYT7mdDYpezF3h3kesLg== Received: from DM6PR11CA0001.namprd11.prod.outlook.com (2603:10b6:5:190::14) by CY8PR12MB7635.namprd12.prod.outlook.com (2603:10b6:930:9e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Tue, 20 Jun 2023 14:12:05 +0000 Received: from MWH0EPF000989E6.namprd02.prod.outlook.com (2603:10b6:5:190:cafe::44) by DM6PR11CA0001.outlook.office365.com (2603:10b6:5:190::14) 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 14:12:05 +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 MWH0EPF000989E6.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.19 via Frontend Transport; Tue, 20 Jun 2023 14:12:04 +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; Tue, 20 Jun 2023 07:11:46 -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; Tue, 20 Jun 2023 07:11:43 -0700 From: Suanming Mou To: , Matan Azrad , Viacheslav Ovsiienko , Ori Kam CC: , Subject: [PATCH v4 5/9] crypto/mlx5: add AES-GCM session configure Date: Tue, 20 Jun 2023 17:11:11 +0300 Message-ID: <20230620141115.841226-6-suanmingm@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230620141115.841226-1-suanmingm@nvidia.com> References: <20230418092325.2578712-1-suanmingm@nvidia.com> <20230620141115.841226-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: MWH0EPF000989E6:EE_|CY8PR12MB7635:EE_ X-MS-Office365-Filtering-Correlation-Id: aa837eb5-3873-469d-095d-08db71985335 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MH/0o6RAkrHApnBLy5Z9WMnfHFbXl+LOAoWldPHCpLzatdOMUyn8Ek2hgLwbKMEP6nhxcWHhnXCbFhEJ3n9bk+BbDhxajsLEo2wjeYbVBItD81x9oxmN2c39ioI4ur3DhLY39gcxrbkUKlY/A/9EUbJOoOzBag3eVxk89+OmGEiYjYPhfk3tzlO0IFfXMox8B/QVDvSfYfvA7AjTXvq1N0NzQHc++CqXxCHc2sKQR+s5Jf8+pm9nGdyrWM9f/Qc9AuKgo6yabYKVWM5bM5CPWwhT6y5+0oCXY7bJDIi31mWys+bpaWNqChI5V9DNoA1/T5DxMGmVju2+VuXNZ2frrZhlYAxZYHM+2oDIo2hFu3OaLZiAqffEwsCQiX3jLIrv+hkw5B/zieiPTH63eFnOuUYXDMOZsy0leSeJDllUL3S7L5eCuzPmQsqyxdaZAYoCI6sopC4kl3m2ty0kZAbzKiwnbNkHtQi0/MnVfl+COQwbxBOMSKUr79AoLIQUfo4yG+R9hZ3w3iRRirD5ccKhPXnXuKGB1bCXdAbp/+p2bHTTbagAbeiSs7oSCvZeGxVcmlCwAcy9mogmJqq8OAqn7vO9yC7s8LzBiZY16x1Vnm+4+4oCB0/yCxakwgKrfkcB2e6ANrgt3bYEQ9DKn8qBKAZGPLMzgrjAdK2d+eY3a/IzIQefbkfl4op7mTsaAwh14Fa0pGOLFNhJfpLH6WtyoVNH2z0O9HzM77lC5DsdHxYeQrhI1eyLemxAukEae76E 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)(136003)(39860400002)(396003)(346002)(451199021)(46966006)(36840700001)(40470700004)(40460700003)(5660300002)(2906002)(55016003)(40480700001)(82310400005)(8676002)(8936002)(7636003)(356005)(83380400001)(426003)(47076005)(36860700001)(36756003)(86362001)(82740400003)(6666004)(6636002)(4326008)(7696005)(70586007)(478600001)(70206006)(110136005)(54906003)(6286002)(186003)(26005)(16526019)(336012)(41300700001)(316002)(2616005)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2023 14:12:04.7228 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa837eb5-3873-469d-095d-08db71985335 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: MWH0EPF000989E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7635 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 Acked-by: Matan Azrad --- 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 e41b5b3528..96ce342d29 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