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 67D13A0C48; Tue, 20 Jul 2021 15:11:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 943BF4118C; Tue, 20 Jul 2021 15:10:24 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2070.outbound.protection.outlook.com [40.107.223.70]) by mails.dpdk.org (Postfix) with ESMTP id 2ABE941154 for ; Tue, 20 Jul 2021 15:10:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iXyu6FybW5S6PAGUbSqJ5GpxE4anVQAY3wJhf95ancNj/p93iH2IvaIuMl+rwwCvS9PzEU56NcT6hNkTbReJDfI4DTKmMBWxJx9L582SPghSsJdvY+t+u/iyNfn9zi8far1mLkwO32WBX2YpuZa0gXce+r+Torid1Xl7M9si4Y8Fi4M7KdcnM7r8D5+6KJpViIMPD6JDSh8Zc9zKpZ+Ktp5uefRLwMjpLbiIXRuGbpnxW7z75zJ/EelQzqQUe4/Ed2bP9PcJRUSADHo1ABgIjitVy7ckXdyUqNg1yFJfRZDK1aM08eOXTQcTxHSnLiH2dKisGD1QP6QlY4BglePn4g== 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=ykGQyiflTFEDRXottFBDXc2+SrvFVhhvVGbrH5vtq38=; b=dYTQTkVU2EkqDFcXBg8oVVDbQSuiHntEj7cEk2DhqH+NbGSKq7v6OzzpioJPr7WzjkLH63rd8X4cWU07mkd3LEWB5LJyy1yQri3chNYYaIZOeyhX6EOXlydXUTy5aww5GY1h+SP07QNWx+tU6/8LuIQ6kh11f9ceZpgrSlLihHAkhMpLcyRriVCaDVf5cIhLOQ2+eY1oTiqfLrKjpOc3MOpfedQRNhLzaPoz7FO8fnAwMSONZqGsQdEOOg1oUyO0Yk/3JSc/nd+zGpX6c/W1sQ+N5dUwo4yqA81OqxMIxaRmaZopgWUoYiqz1HDPZc1fGDNZZAqGpOfYr8o0rwyOrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine 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=ykGQyiflTFEDRXottFBDXc2+SrvFVhhvVGbrH5vtq38=; b=IFqzoabf438PKztA84Vz/qd2/FXXNsrHDAJkIQ/amZ3FgN/9Cxd1wJ6ffD1tH2WCyGGNK6aVn6+E5l9f4qYyib19ElaHVMG5/enpLEZxjPpmbd28ifmWlJt5f0tGP4uSTIL3aGl9YXMzqqRTBF66ICzLY47ypmhmf53Q32Nfon/DrB2IARfycEn4GPFv3qS7nEXtSzs0E1e6PpS2Ib6CwYw5cA31F/v4dD7IC3B2tBwGlvDJTb4/YNg4/QqkeNWZLcDqXkdGnZL0kKvQROg3c9fcIYwYT1Gf/+wo8QvOswmeW8lu5RbFm8L5UYUlQ8siApUUQlvLw7dTWIDn+Una2g== Received: from MW4P221CA0028.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::33) by SA0PR12MB4398.namprd12.prod.outlook.com (2603:10b6:806:9f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Tue, 20 Jul 2021 13:10:20 +0000 Received: from CO1NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::6b) by MW4P221CA0028.outlook.office365.com (2603:10b6:303:8b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Tue, 20 Jul 2021 13:10:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; 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 CO1NAM11FT036.mail.protection.outlook.com (10.13.174.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4331.21 via Frontend Transport; Tue, 20 Jul 2021 13:10:20 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 20 Jul 2021 13:10:18 +0000 From: Suanming Mou To: , CC: , , Date: Tue, 20 Jul 2021 16:09:38 +0300 Message-ID: <20210720130944.5407-10-suanmingm@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210720130944.5407-1-suanmingm@nvidia.com> References: <20210408204849.9543-1-shirik@nvidia.com> <20210720130944.5407-1-suanmingm@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d08dd3c4-1b1e-4868-b139-08d94b7fba4b X-MS-TrafficTypeDiagnostic: SA0PR12MB4398: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:193; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jv+9UwQE508pDeXnf1vKY392opch8q9UgmgzhCYCg/PhG8bqMbKcNshRx9jTry2oZd8szVZCkdEvRqNcVnjwde/q7CkW4zSbUGcNW+9dJ7Bldjy39qU+tNPjlIjm1KB0yWKrjeM6svFiISshtnqMXGhpZmaehL9FPQFDjjWsaz9d56/mN4UukZ1BA7yxssXkGv5/R2PWU1ceouxac4z69Ga4UQCxNIUzZV/WpbanIxe2bp0rbF6Ay3wlYCPYYEt82Y/R84r0CoOj4CHun4/LltyGJnWuhohQ389eVLbiMi4mHfViR4VKx1ToeFX5zrv85uVYqXaNIiNHMPjbI2/38JBKmdb52Hh2DyRpEPBQojXVLV52a+ifZeng7LSI0wafkqV+FnZWF916pLFS5hidECjjH1fDYt0OjIObD9/ZQ9I5CpNh6mQx8uOek1MQB9tDckNsKB1Cu0H2Aeb4pUMWompdZApowA4JqpKUGhALpmPrYwO8YUo9AWFnjuhlDytp8UmOzEjkZ2sJ5XsCouewExBBiWkA+mNKA7g0/LXmVEXQfROj0PgjhLR2u4g6NEyJPFC2Ger+Fis/kZHu//MRnW3P0gmX1rbMreO+ICCkJ3CtxMw8hqonS2yEtcgEznNIr0xe3uWITQ5o8+DNrjbKlFAFUrYt30rRJ5bK2esX7j1BJUuZeOJc8JtGmp8UgQbhmV/BryBCVr/pj3l+rkd2YA== 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)(136003)(39860400002)(346002)(376002)(396003)(46966006)(36840700001)(7696005)(6666004)(36756003)(8936002)(7636003)(47076005)(55016002)(110136005)(8676002)(82740400003)(82310400003)(478600001)(356005)(6286002)(316002)(26005)(36906005)(54906003)(16526019)(426003)(2906002)(36860700001)(4326008)(5660300002)(70586007)(336012)(70206006)(2616005)(86362001)(186003)(83380400001)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2021 13:10:20.7078 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d08dd3c4-1b1e-4868-b139-08d94b7fba4b 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: CO1NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4398 Subject: [dpdk-dev] [PATCH v9 09/15] 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" 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 --- doc/guides/cryptodevs/mlx5.rst | 4 ++++ drivers/crypto/mlx5/mlx5_crypto.c | 33 +++++++++++++++++++++++++++---- drivers/crypto/mlx5/mlx5_crypto.h | 6 ++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/doc/guides/cryptodevs/mlx5.rst b/doc/guides/cryptodevs/mlx5.rst index 5b874824db..b20f593549 100644 --- a/doc/guides/cryptodevs/mlx5.rst +++ b/doc/guides/cryptodevs/mlx5.rst @@ -120,6 +120,10 @@ Driver options The plaintext of the keytag appanded to the AES-XTS keys, default value is 0. +- ``max_segs_num`` parameter [int] + + Maximum number of mbuf chain segments(src or dest), default value is 8. + Supported NICs -------------- diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index b24e68532c..f7e23d16e9 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -21,6 +21,7 @@ #define MLX5_CRYPTO_DRIVER_NAME crypto_mlx5 #define MLX5_CRYPTO_LOG_NAME pmd.crypto.mlx5 #define MLX5_CRYPTO_MAX_QPS 1024 +#define MLX5_CRYPTO_MAX_SEGS 56 #define MLX5_CRYPTO_FEATURE_FLAGS \ (RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO | RTE_CRYPTODEV_FF_HW_ACCELERATED | \ @@ -494,14 +495,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; } @@ -516,6 +527,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."); @@ -612,6 +624,7 @@ mlx5_crypto_pci_probe(struct rte_pci_driver *pci_drv, .max_nb_queue_pairs = RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS, }; + uint16_t rdmw_wqe_size; int ret; RTE_SET_USED(pci_drv); @@ -690,6 +703,18 @@ 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); + 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 + rdmw_wqe_size; + priv->umr_wqe_stride = priv->umr_wqe_size / MLX5_SEND_WQE_BB; + priv->max_rdmar_ds = rdmw_wqe_size / sizeof(struct mlx5_wqe_dseg); /* Register callback function for global shared MR cache management. */ if (TAILQ_EMPTY(&mlx5_crypto_priv_list)) rte_mem_event_callback_register("MLX5_MEM_EVENT_CB", diff --git a/drivers/crypto/mlx5/mlx5_crypto.h b/drivers/crypto/mlx5/mlx5_crypto.h index a513e9ee36..c0fa8ad4d4 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.h +++ b/drivers/crypto/mlx5/mlx5_crypto.h @@ -25,12 +25,17 @@ 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 umr_wqe_stride; + uint16_t max_rdmar_ds; }; struct mlx5_crypto_qp { @@ -54,6 +59,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