From patchwork Sun May 9 16:05:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 93072 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1AA9FA0548; Sun, 9 May 2021 18:06:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3CCA54114E; Sun, 9 May 2021 18:05:51 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2050.outbound.protection.outlook.com [40.107.212.50]) by mails.dpdk.org (Postfix) with ESMTP id AC4D24114A for ; Sun, 9 May 2021 18:05:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bJHhB5W/F21yEFkzErH6uvebhqFxX93TB2ipCd6OySsVvWYrVK65hYiJIu7r/Xs6ShFdhnwemb6/OLXpvp1EhDLPWvvj/jJMYzDbMPlu4+3Z+Fv6lyKqSUkiuQN5VQPwyNBawMzN55P0Hr4BNY3g2MbJf9NwlcnoPCpaBs1G6PRsO8u5fL292oOFP/heNMl8ojPVbyYDAZMsh1br22TVXan0T4R+/1naAh+BF06mlPLKej47iiY5BmiG6MInScww9+Ry56AyP/VuAFvlNe52y95KjD7cPdaudTprf4DssdwHqXRfibCMTFMRo0wI9WEJGbmBRjSpkQtdnIyyzOnXWg== 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=ZH9UCjTOB8OkNDz3tGEkL8AoVeat/v71IsjjWzdWLD4=; b=laO2xwJgWpPOC2+c3arlLuzBPrZEC9EgKlVt1yhAnqq24jzeRNx8fwoaYOM/VoKqLeaeoB+ZR6iEyK9tNajc3WbldhPgxIijot9bBSCveLYH7rARSOMRKKceiI3aQjiWvGQxGL3o6Vcmwdr1oMu/6rEiJx5BHP39RiDS3PDDZ7NCwo3B3qHFJ3ZWN8RsEaE11wLM6GGjCBTlNPCC7XUXfXzBaLI1WpIMuKvRmcR7tUwk79ols+6Ri3GWNVruxQp1JJJjt8feFCmo6brRMZorlGQn8zCLgjKASP/78p9wHYqvyeMA5PO9SKDFrqMkNcp7xSNgL23t0Y6EFMT4bhEB8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=ZH9UCjTOB8OkNDz3tGEkL8AoVeat/v71IsjjWzdWLD4=; b=cQxEwJjj3SkwQ6dJGw3YZxYrAII1C4Z3w93ylhI6Xw5TzxQ+GX+61ew5B9SW2txHI+L/6j06nYuo7comHIs7OCHbGSWWmrZzNrrFwHURA2YuC4I2puO6Sv+aM1oo35JfaVm7FSvpb1wVY5vxIkJx4HswFpycqStPmdK0rttEthBKaUoluNP6coLDE6azsQJixw0Epn+Za1fi+BDzVhPOQGim4BWNhEtDQFwWW2xRwB0vTl9NdvpMLx/nDOipiNInQ4qdE0xIg0VVxQBd/m9+954mquvR0LBPgWSnKH5BgHyRWDPnp3l1i1ok9VtvIS/lfZ/BN4MqjG7deDmpxlkZTw== Received: from MWHPR07CA0002.namprd07.prod.outlook.com (2603:10b6:300:116::12) by BN8PR12MB3538.namprd12.prod.outlook.com (2603:10b6:408:96::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25; Sun, 9 May 2021 16:05:43 +0000 Received: from CO1NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:300:116:cafe::4a) by MWHPR07CA0002.outlook.office365.com (2603:10b6:300:116::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24 via Frontend Transport; Sun, 9 May 2021 16:05:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT042.mail.protection.outlook.com (10.13.174.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4108.25 via Frontend Transport; Sun, 9 May 2021 16:05:43 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 9 May 2021 16:05:40 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" Date: Sun, 9 May 2021 19:05:03 +0300 Message-ID: <20210509160507.224644-11-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210509160507.224644-1-matan@nvidia.com> References: <20210504210857.3398397-1-matan@nvidia.com> <20210509160507.224644-1-matan@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6be406f4-777e-49da-7b8d-08d913044c9f X-MS-TrafficTypeDiagnostic: BN8PR12MB3538: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:193; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZW+Zl9I78bQ22x4G9oQWCiEy/Tdr99gwdVYPW7swImP8ZXYy6AgV9/caOSIDmuDpskRyadJTj3F2JGbuzzxHZI7zai2hIIPOHhsxswct8Gl5/JpM3czfq35gRZlbJ3y+UjjlJTnTgRdkHTKsudSvCyxdMNp3WhQ43cpB1d9CZ42BxDuaSdxZgSMLjyZRmev2vvWahyXTu17/E9pNI2R9NcH4bl2sB3/t+xBrIU/nkog85UK3tF3NQe576Bsu4PjuzdhGV32pWbKa+dwl8g8dtET+oz9zyAj2HrTQqM21yXje7+4JMNZ+jjr0Yw1TwFU4OY35NIP4IRR7Cs94jOVbT84nKP0+LaaCLF4KoSZ3W771eupTk0k9YyxbDIBr98zkWdxDyNmGLruTHKiS5PMH2rqiSdzAUCwKYprN9cOk7bc3DnQtFa8bz3ED0SZ+ND1xnFI8QzKSiEf4tv5TUqwjIT72VEthXrF26l6/mqO7LmZC1Z15iwx7Innnp35cyHoBFaSvXDvGqFerICeKy1a5DniNSHwde52ybMtje7n9XnqzJ0GQtw+SQaenHsN5HB1CLCcMKh5mAGZl3rkilhAYx3B6E3HOp8BafPpbyOnS/jOyMsUdaD8ipFUsIL0+8hxk4qIPf6goXmEdbH4EdOaKN8yEzgmc/IGzba14+ULr3f4= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(39860400002)(396003)(346002)(376002)(136003)(46966006)(36840700001)(356005)(36906005)(26005)(7696005)(7636003)(82310400003)(8676002)(6666004)(70586007)(2616005)(4326008)(316002)(5660300002)(70206006)(82740400003)(186003)(426003)(16526019)(336012)(2906002)(6286002)(83380400001)(36756003)(1076003)(36860700001)(54906003)(8936002)(6916009)(86362001)(55016002)(47076005)(478600001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2021 16:05:43.4873 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6be406f4-777e-49da-7b8d-08d913044c9f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3538 Subject: [dpdk-dev] [PATCH v4 10/14] crypto/mlx5: add maximum segments devarg 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: Suanming Mou The mlx5 HW crypto operations are done by attaching crypto property to a memory region. Once done, every access to the memory via the crypto-enabled memory region will result with in-line encryption or decryption of the data. As a result, the design choice is to provide two types of WQEs. One is UMR WQE which sets the crypto property and the other is rdma write WQE which sends DMA command to copy data from local MR to remote MR. The size of the WQEs will be defined by a new devarg called max_segs_num. This devarg also defines the maximum segments in mbuf chain that will be supported for crypto operations. Signed-off-by: Suanming Mou Signed-off-by: Matan Azrad --- drivers/crypto/mlx5/mlx5_crypto.c | 35 +++++++++++++++++++++++++++---- drivers/crypto/mlx5/mlx5_crypto.h | 7 +++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index d4379d2b05..1a7317aef5 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -21,6 +21,7 @@ #define MLX5_CRYPTO_DRIVER_NAME mlx5_crypto #define MLX5_CRYPTO_LOG_NAME pmd.crypto.mlx5 #define MLX5_CRYPTO_MAX_QPS 1024 +#define MLX5_CRYPTO_MAX_SEGS 56 TAILQ_HEAD(mlx5_crypto_privs, mlx5_crypto_priv) mlx5_crypto_priv_list = TAILQ_HEAD_INITIALIZER(mlx5_crypto_priv_list); @@ -465,14 +466,24 @@ mlx5_crypto_args_check_handler(const char *key, const char *val, void *opaque) DRV_LOG(WARNING, "%s: \"%s\" is an invalid integer.", key, val); return -errno; } - if (strcmp(key, "import_kek_id") == 0) + if (strcmp(key, "max_segs_num") == 0) { + if (!tmp || tmp > MLX5_CRYPTO_MAX_SEGS) { + DRV_LOG(WARNING, "Invalid max_segs_num: %d, should" + " be less than %d.", + (uint32_t)tmp, MLX5_CRYPTO_MAX_SEGS); + rte_errno = EINVAL; + return -rte_errno; + } + devarg_prms->max_segs_num = (uint32_t)tmp; + } else if (strcmp(key, "import_kek_id") == 0) { attr->session_import_kek_ptr = (uint32_t)tmp; - else if (strcmp(key, "credential_id") == 0) + } else if (strcmp(key, "credential_id") == 0) { attr->credential_pointer = (uint32_t)tmp; - else if (strcmp(key, "keytag") == 0) + } else if (strcmp(key, "keytag") == 0) { devarg_prms->keytag = tmp; - else + } else { DRV_LOG(WARNING, "Invalid key %s.", key); + } return 0; } @@ -487,6 +498,7 @@ mlx5_crypto_parse_devargs(struct rte_devargs *devargs, attr->credential_pointer = 0; attr->session_import_kek_ptr = 0; devarg_prms->keytag = 0; + devarg_prms->max_segs_num = 8; if (devargs == NULL) { DRV_LOG(ERR, "No login devargs in order to enable crypto operations in the device."); @@ -627,6 +639,21 @@ mlx5_crypto_pci_probe(struct rte_pci_driver *pci_drv, priv->mr_scache.reg_mr_cb = mlx5_common_verbs_reg_mr; priv->mr_scache.dereg_mr_cb = mlx5_common_verbs_dereg_mr; priv->keytag = rte_cpu_to_be_64(devarg_prms.keytag); + priv->max_segs_num = devarg_prms.max_segs_num; + priv->umr_wqe_size = sizeof(struct mlx5_wqe_umr_bsf_seg) + + sizeof(struct mlx5_umr_wqe) + + RTE_ALIGN(priv->max_segs_num, 4) * + sizeof(struct mlx5_wqe_dseg); + priv->rdmw_wqe_size = sizeof(struct mlx5_rdma_write_wqe) + + sizeof(struct mlx5_wqe_dseg) * + (priv->max_segs_num <= 2 ? 2 : 2 + + RTE_ALIGN(priv->max_segs_num - 2, 4)); + priv->wqe_set_size = priv->umr_wqe_size + priv->rdmw_wqe_size; + priv->wqe_stride = (priv->umr_wqe_size + priv->rdmw_wqe_size) / + MLX5_SEND_WQE_BB; + priv->max_rdmaw_klm_n = (priv->rdmw_wqe_size - + sizeof(struct mlx5_rdma_write_wqe)) / + sizeof(struct mlx5_wqe_dseg); pthread_mutex_lock(&priv_list_lock); TAILQ_INSERT_TAIL(&mlx5_crypto_priv_list, priv, next); pthread_mutex_unlock(&priv_list_lock); diff --git a/drivers/crypto/mlx5/mlx5_crypto.h b/drivers/crypto/mlx5/mlx5_crypto.h index 34c65f9a24..81452bd700 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.h +++ b/drivers/crypto/mlx5/mlx5_crypto.h @@ -25,12 +25,18 @@ struct mlx5_crypto_priv { struct rte_cryptodev *crypto_dev; void *uar; /* User Access Region. */ uint32_t pdn; /* Protection Domain number. */ + uint32_t max_segs_num; /* Maximum supported data segs. */ struct ibv_pd *pd; struct mlx5_hlist *dek_hlist; /* Dek hash list. */ struct rte_cryptodev_config dev_config; struct mlx5_mr_share_cache mr_scache; /* Global shared MR cache. */ struct mlx5_devx_obj *login_obj; uint64_t keytag; + uint16_t wqe_set_size; + uint16_t umr_wqe_size; + uint16_t rdmw_wqe_size; + uint16_t wqe_stride; + uint16_t max_rdmaw_klm_n; }; struct mlx5_crypto_qp { @@ -54,6 +60,7 @@ struct mlx5_crypto_devarg_params { bool login_devarg; struct mlx5_devx_crypto_login_attr login_attr; uint64_t keytag; + uint32_t max_segs_num; }; int