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 0311DA0C46; Sun, 5 Sep 2021 20:33:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B2DA040042; Sun, 5 Sep 2021 20:33:56 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2062.outbound.protection.outlook.com [40.107.101.62]) by mails.dpdk.org (Postfix) with ESMTP id 0F4B14003D for ; Sun, 5 Sep 2021 20:33:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bZvdz8rU3RR9bMEGTn5VXA8gta8UNhXRjnIDBPBP4lPQiJ+4ypmzgsNiDBn2NlS22JPZz5llqb7Bzqbmll2ihwwxdD96hTC+hOtvJfCHDrCH7IMbP6+9g7d9GlN72jZHLt59XzCyKvQuYaZeNfwphhJp6yvKivYeKD+BFqDUZ1tz3C0UCLFUlvRcvOhqNPajAU5C1MC+t7x/ARyCxOyDQrHxnZsPxVH0CWS/5zZlk2IjKAW+aNy1YFZhPMXqj+hbY1Mee6Vyesy2Omf6di0BXH6+Px84p9xI0q/FbY8Ga4qmF9wjRz3pFnxKgg3AAkNyzk8pnnqiX36NjzoKB8WB3g== 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; bh=TKl0ikeSp1I3Fo0JCXe87fPYt2ADWIOyTmP7EWR7hIU=; b=ea7yp691REfC15RUAvuZb8N1cPeH4BRAxRz6AiIS5G4f3IMLFvzuXVG37J8NV+vu22lDsNAg/GEW9B7dW7MXpw59mcbUI7YuzUiAghpGRxCmkCn0iBAJjTfkaio/2BpwLuhtXaUWUM6HSifHnr1MSriIUMD8OOazSYCTt+v6HUKEKUFTZsZQKp6a7op/INM/KKhGdxb3wGrqYs7nZbJIaZCXtyJP/7zJjDuYE1gLtZ3evpd6SJ27LX0sjIhOU//eFmYxy4ePtrwNky4Rw56kpzFnx7CEUtRo45PC+yr6ZRMKbLRDHwTY1KW0+zI2E8/yeDbZI3mtEzc8gObOUJoIUg== 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=TKl0ikeSp1I3Fo0JCXe87fPYt2ADWIOyTmP7EWR7hIU=; b=OQa0h+F1fwbs9tlSh4PT+slqLuUkm2yn13CL4LoI1ddhxvfYf2XDMW2O2/l7dF/4erxAVBuAn797JRNMp6emF2aU1/jE2L0Qfd5X3wTEmUzs/YzoaB8R/pwgKLGY5fH+rFwV5udwztMelAWHGZZM08+99Yx52vERUXxFZP3BNfF0AW6LsxJxwGjUFxt5Uy3eDS9S79Xg9GWQDUoZJ9Vi5HW0ADnj7KTQlxR0ucULwbDxv1dDcQe5DVcm18Z4QfvpPr3tPd6bYkldUyybvxwIlvMtob1VnpSutZsbvWq5T1mmR2sUR7f6VgFo3Mucf0Y/CkeOXyR1AkcYKhcTgUc9pA== Received: from BN9PR03CA0744.namprd03.prod.outlook.com (2603:10b6:408:110::29) by DM6PR12MB4561.namprd12.prod.outlook.com (2603:10b6:5:2ac::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.22; Sun, 5 Sep 2021 18:33:53 +0000 Received: from BN8NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:408:110::4) by BN9PR03CA0744.outlook.office365.com (2603:10b6:408:110::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Sun, 5 Sep 2021 18:33:52 +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 BN8NAM11FT023.mail.protection.outlook.com (10.13.177.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4478.19 via Frontend Transport; Sun, 5 Sep 2021 18:33:52 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sun, 5 Sep 2021 18:33:50 +0000 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Date: Sun, 5 Sep 2021 21:33:31 +0300 Message-ID: <20210905183331.3895109-1-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] 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: c431b910-da44-4042-99ed-08d9709bb630 X-MS-TrafficTypeDiagnostic: DM6PR12MB4561: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k8vZTjxPIM7DUWJNatip2fJp4ypR/+1Q0WT2vwg2in/gGQMw6HO9sgCt5943uw/yGeCDx5zJZQeejf1jkuFOO6BJl77oRs6ebCrf+Fy9eCIKuX9SZa3tnGk5J1UW5Dd9Ef5gRGdb7mYVzG8ciW+i8lQsRmZMrWe+z98qjZ1suNmZUfjp7yO/g3Oxnk3Fh2Y9LNWSxKM56RJqBWgvuvUEySqIG1m29CJtV4OhUCweurqdtuDooJMO2ZIQCX9kG89UFbfkuu+/Zuffc9o7ZGOHaGVcMBpn77RbauwkgxqaSMIYK4Kupfmhi7r2iC0Ko3YZPWQxKU30tP9Zh7vXxLNtnXh/sWDpsT1SjdjIMtlxUQ1I4YMbJq1B0DA+mYnvY4UyKRB7hd51HKGQgVdrjVp1ZVleri6sSpi+243jX9Y6njCTJ0d0jMo2gvbAdgnwxbvh/eXKdHT/nACzurHKLNPXSmREDOvlOuV1PXW7L6fnCPBjvmsEk8ZN3+Zz0xezxCOuiZDdl0nV4vSfMdIevSxxXyNDFzonkQwyVwzHvK+wyjzoW5ieEqGBILosWRELry53SZoE9bnR6ebV6U6+ER5R8gTWpKRgj/9ZaVSIVEGsYgKfNSVfXG57A+lgrgeFvRKZlYfLgw+ZpcFsEbg5fQykbtrZv7tVshK4r6sExKF7wrUQKDH1dMxwdPR0/yci5ijH2073Bm1cZZ1z6KURmVPTgg== 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)(36840700001)(46966006)(356005)(82310400003)(6916009)(36756003)(86362001)(26005)(2616005)(426003)(54906003)(70586007)(16526019)(6666004)(70206006)(186003)(36906005)(2906002)(5660300002)(316002)(4326008)(107886003)(1076003)(336012)(6286002)(508600001)(55016002)(8676002)(83380400001)(7696005)(36860700001)(47076005)(7636003)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2021 18:33:52.6227 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c431b910-da44-4042-99ed-08d9709bb630 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: BN8NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4561 Subject: [dpdk-dev] [RFC] common/mlx5: support cross vHCA mkey 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 devices support multiple vHCA under the same device. The mlx5 devices IOVA addresses are built from mkey ID and the process virtual address(VA); given the VA, the kernel mlx5 driver creates an mkey that defines the mapping between the VA space and the PA space. This feature allows having a mkey that points to another mkey that resides in a different vHCA. This allows one vHCA, using a locally defined mkey, to access the memory of another vHCA. One of the motivations is to allow a DPDK application on BF2 to map Host (x86) memory to be used on the DPU ARM CPUs. Using cross vHCA mkey, we can register host memory and expose this to the DPU ARM CPUs, which will map this as a crossed-mkey (CROSSING_VHCA_MKEY). Using this local crossed-mkey, the DPU can issue QP operations that access the host memory. Suggest the following mlx5 private APIs: - Add a new private dynamic mbuf's flag to indicate that the mkey is provided in the buf_iova mbuf field - RTE_PMD_MLX5_PRIVATE_IOVA. - If the application wants to create the cross vHCA mkey by itself, the device context (CTX) and the protection domain (PD) must be shared between the application to the driver Due to the HW restriction to configure the HW objects with the same CTX and PD. Allowing this by two methods: 1. Add two new devargs to get the CTX and PD from the application. 2. Add a new driver API to provide the CTX and PD to the application. - Add a PMD API to create cross vHCA MKey by the driver. - Add a PMD API to get the mkey ID of a local buffer. For all the usages above, the user should build the mbuf like the following: mbuf->buf_addr = mbuf->buf_iova = struct mlx5_iova{uint32_t resrvd = 0; uint32_t mkey_id;} mbuf->ol_flags |= RTE_PMD_MLX5_PRIVATE_IOVA (for cross vHCA mkey it will be probably EXT buf) It is the application's responsibility to reset the mbuf fields before moving the mbuf to another device. Signed-off-by: Michael Baum --- drivers/common/mlx5/mlx5_common.c | 22 ++++++ drivers/common/mlx5/rte_pmd_mlx5.h | 105 +++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 drivers/common/mlx5/rte_pmd_mlx5.h diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 459cf4bcc4..4ac4794983 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -8,13 +8,16 @@ #include #include +#include #include #include +#include #include "mlx5_common.h" #include "mlx5_common_os.h" #include "mlx5_common_log.h" #include "mlx5_common_private.h" +#include "rte_pmd_mlx5.h" uint8_t haswell_broadwell_cpu; @@ -51,6 +54,25 @@ static TAILQ_HEAD(mlx5_drivers, mlx5_class_driver) drivers_list = static TAILQ_HEAD(mlx5_devices, mlx5_common_device) devices_list = TAILQ_HEAD_INITIALIZER(devices_list); +int +rte_pmd_common_mlx5_get_dyn_flag_names(char *names[], unsigned int n) +{ + static const char *const dynf_names[] = { + RTE_PMD_MLX5_FINE_GRANULARITY_INLINE, + RTE_PMD_MLX5_PRIVATE_IOVA, + }; + unsigned int i; + + if (n < RTE_DIM(dynf_names)) + return -ENOMEM; + for (i = 0; i < RTE_DIM(dynf_names); i++) { + if (names[i] == NULL) + return -EINVAL; + strcpy(names[i], dynf_names[i]); + } + return RTE_DIM(dynf_names); +} + static const struct { const char *name; unsigned int drv_class; diff --git a/drivers/common/mlx5/rte_pmd_mlx5.h b/drivers/common/mlx5/rte_pmd_mlx5.h new file mode 100644 index 0000000000..b032996917 --- /dev/null +++ b/drivers/common/mlx5/rte_pmd_mlx5.h @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2021 Mellanox Technologies, Ltd + */ + +#ifndef RTE_PMD_PRIVATE_MLX5_H_ +#define RTE_PMD_PRIVATE_MLX5_H_ + +/** + * @file + * MLX5 public header. + * + * This interface provides the ability to support private PMD dynamic flags. + */ + +#define RTE_PMD_MLX5_PRIVATE_IOVA "mlx5_privet_iova" + +/** + * Returns the dynamic flags name, that are supported. + * + * @param[out] names + * Array that is used to return the supported dynamic flags names. + * @param[in] n + * The number of elements in the names array. + * + * @return + * The number of dynamic flags that were copied if not negative. + * Otherwise: + * - ENOMEM - not enough entries in the array + * - EINVAL - invalid array entry + */ +__rte_experimental +int rte_pmd_common_mlx5_get_dyn_flag_names(char *names[], unsigned int n); + +/** + * Returns the device context and its Protection Domain, for given device. + * + * @param[in] dev + * Pointer to the generic device. + * @param[out] ctx + * Pointer that is used to return the context device pointer. + * @param[out] pd + * Pointer that is used to return the protection domain pointer. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + * Possible values for rte_errno: + * - EINVAL - invalid parameters (dev, ctx, or pd). + * - ENODEV - the given device doesn't exist. + */ +__rte_experimental +int rte_pmd_mlx5_get_dev_ctx_and_pd(rte_device *dev, void **ctx, void **pd); + +/** + * A PMD API to create cross virtual HCA MKey. + * In BlueField family devices, there are some vHCA under same device. + * Each of them represents a different part of the device (host / guest), and + * it has id for itself. + * + * This API creates for the user cross vHCA MKey and returns it in rte_iova_t + * variable. + * + * @param[in] dev + * Pointer to the generic device. + * @param[in] remote_vhca_id + * ID of remote vHCA. + * @param[in] remote_mkey + * The MKey created by remote vHCA. + * + * @return + * Cross vHCA MKey for buf_iova mbuf field on success, 0 otherwise. + * Possible values for rte_errno: + * - ENOMEM - allocation failure. + * - EINVAL - invalid parameters (dev). + * - ENODEV - the given device doesn't exist. + */ +__rte_experimental +rte_iova_t rte_pmd_mlx5_create_cross_vhca_mkey(rte_device *dev, + uint32_t remote_vhca_id, + uint32_t remote_mkey); + +/** + * A PMD API to get mlx5 IOVA on local process VA. + * This function creates memory regions for given virtual addresses on control + * path, and returns it in rte_iova_t variable. + * + * @param[in] dev + * Pointer to the generic device. + * @param[in] va + * Pointer to memory start virtual address. + * @param[in] len + * Length of the memory to register. + * + * @return + * Compatible MKey for buf_iova mbuf field on success, 0 otherwise. + * Possible values for rte_errno: + * - ENOMEM - allocation failure. + * - EINVAL - invalid parameters (dev or va). + * - ENODEV - the given device doesn't exist. + */ +__rte_experimental +rte_iova_t rte_pmd_mlx5_get_buf_private_iova(rte_device *dev, void *va, + uint32_t len); + + +#endif /* RTE_PMD_PRIVATE_MLX5_H_ */ -- 2.25.1