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 EC0C9A0A02; Tue, 4 May 2021 23:10:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B4E541101; Tue, 4 May 2021 23:09:48 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2072.outbound.protection.outlook.com [40.107.212.72]) by mails.dpdk.org (Postfix) with ESMTP id 688FE4114C for ; Tue, 4 May 2021 23:09:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VQ53E/vENLy95DmmVmtL4tqDOmdO7GvXDRZcSa+dTRhdm9pcb60tOntyOb/U4EIVRoXbGywvZpVR3WOSk458h6enozvfx7mgGv1FPqOmyblaWNsrED82rqb6frE21Mlx0FsL6ToDhYqe6n9UngcMFNjiIHWnL41Sae/7lW/1EmvVIuG7d3sgR94mxetdSHjmPbEB9QHpTsqAHbab/nuztLJ4ZC+HWKY/m7riaOH0rSpjhj7ZnjyYDsvtQHuaxQ/Xx0UVqdUys2TxcjLwd7f4hltZ48gpMdKdijsjYelRJReH4S40g6nk5XBCCma9vPTkr4gcnuWBi+LHw1Luu3iASg== 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=/NpWLe+ia0nSMGwsI/c5gykkscolkO9ODmNScODBdG0=; b=iwHy5QBd7YYAJaOiYu/Ceorvqq6uaoTmGZLot1TRm8WtbPsPOnXWaZe4savPj5rfWzz3iyML+kQe3AKbVccuf7ofCcFyuXAS0FSqVmRlZNFxGaCV90PTpO53VypfjFCKGG+LmOFTl0QtEHefEGsw4nyjzE0w+XkiNrSEGxD5SlIDlxhNZWVDtGHAH9p/hqh06n70YdDXdTMCs4e9faHhrQm//6nprUoyt/DAqzrezimBXu9VNXBc+S3LBSYcLzB0O7V2Lr2XvKHgnCN/99f86w8OFkZZgp7ySsVaIuMbA4fPBfK/c80x0X+VXqt7687Y9+UtCPBlLApJ2AOEwKIVNA== 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=/NpWLe+ia0nSMGwsI/c5gykkscolkO9ODmNScODBdG0=; b=Icp0hkCT9994xggcHwq0/o4FQjC9FI8qOvsSDWzHKUgTzxasphgyNQReNPBSkvY6CX6nSiOAGSSoBhevjZJ9XvvsQg9tNeK+kK9uiPEl0zYvZpKfvc8rzUFKIEnQPZ/nyjHM2iF5m1mcwIqMWVnoQFpBXsk7ROWOZY1y3ByrEWrLemjyRpbRyISsFyAXjPVN5H65Wqj34OUos0IFAuEEWcDvlFz+OC/uIGAel9UnendgznyYBAVFNzWH980/e0r4xZmV9Ax4Z4vZcLHSbLcV+Mjdij3NdDewS3ZWeVWqWg66nucv4HmZc/lYvtViL+Oe5pUQa/JSQwdiuskJJG2CIA== Received: from MW4PR04CA0361.namprd04.prod.outlook.com (2603:10b6:303:81::6) by BY5PR12MB3761.namprd12.prod.outlook.com (2603:10b6:a03:1af::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.38; Tue, 4 May 2021 21:09:43 +0000 Received: from CO1NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:303:81:cafe::b6) by MW4PR04CA0361.outlook.office365.com (2603:10b6:303:81::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27 via Frontend Transport; Tue, 4 May 2021 21:09: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 CO1NAM11FT007.mail.protection.outlook.com (10.13.174.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.27 via Frontend Transport; Tue, 4 May 2021 21:09:42 +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; Tue, 4 May 2021 21:09:40 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" Date: Wed, 5 May 2021 00:08:53 +0300 Message-ID: <20210504210857.3398397-12-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210504210857.3398397-1-matan@nvidia.com> References: <20210429154712.2820159-1-matan@nvidia.com> <20210504210857.3398397-1-matan@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 64fc08a7-8147-4158-508c-08d90f40eff9 X-MS-TrafficTypeDiagnostic: BY5PR12MB3761: 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: HFEnqeh5+7T8Kqj+F61li16e2uo0ydajltkJly23gm8vJY2qnSE744d1c7v9+QbS1uwyhhaC3gdHmLhVo0AMB5M4I5LjhIIt4F997+TuOkabUVif2Mu7SEQdIts6AD0Dsn8AU7zFo64uk8n0ZXUMcupFEnao4DFZEuseGnON8QEhaIPVlgCcJKxoj30tEmYYVAzS9X8bp2S53lPWqZEfJhrAyFIxWDC/chuOyOlN5ItIwfz2JH9YOKIL4c6wTAtnAmzgWavnCvdHPOhJG7BmLWKyOqulSdy46jRtWSBvTpWGgggMxcMYGElq5+HixnKS5ASnhz8uQNAPsQLbv0QTnxtKY8dgacJrUcRfSpHTFVNAhh20R9ChRA50auNYz0deiJ8tnxkYes2ojxiwrjbU5Q4GsJBqsvqQ+tHa5/LsSnOcDyhleGJCnHOyk7jSGMZGovyvrKVdOFn5ErQvJ2akTiEO8hRE78m8CTdWo2Oz4VYkq3S+ZA41fn2jlJFDVY3lWKZ0jkGYz/S2LnhwuzmoykceOadJnPbLn0MiBrvFRrzVMby06sGwrzbRLMxD4lMfmCah4Nr7e1xPYZdAK7vz+unycB8DJM2axX3z7EIl4MyRWRWA1tgoKf6XE2OPI/lvBYYSymYu+V61TrPlSy2wl/h0Glkfr++wnMKSbATYhO0= 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)(346002)(136003)(396003)(376002)(39860400002)(36840700001)(46966006)(8936002)(54906003)(316002)(356005)(86362001)(2616005)(70586007)(1076003)(16526019)(36906005)(7696005)(7636003)(2906002)(36756003)(83380400001)(82740400003)(426003)(6916009)(47076005)(336012)(82310400003)(8676002)(6286002)(186003)(5660300002)(4326008)(6666004)(55016002)(26005)(478600001)(36860700001)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 21:09:42.6064 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64fc08a7-8147-4158-508c-08d90f40eff9 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: CO1NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3761 Subject: [dpdk-dev] [PATCH v3 11/15] crypto/mlx5: add maximum segments device argument 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 73cca8136b..6de44398bd 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); @@ -464,14 +465,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; } @@ -486,6 +497,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."); @@ -626,6 +638,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 -- 2.25.1