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 A4F4CA0A02; Tue, 4 May 2021 19:57:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 912DA410F6; Tue, 4 May 2021 19:57:02 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2055.outbound.protection.outlook.com [40.107.220.55]) by mails.dpdk.org (Postfix) with ESMTP id 4FFE040150 for ; Tue, 4 May 2021 19:57:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HcatgnzGiOJa2GX4kZX1H5VAQl5yzAcTFIMGN8LIEAVxDnQHZTys40L+L39a6WXtcwHgSAr9Db9XlHT7/sB7cc0SuYOfZ2ZdswHpKz+EzTw9bua24Eas6/TmT28ncfGLZ8rexaGSmh7yoG6zoq9nCyFtJnnA7Jn+g1Kaj6+lwSyVm/LXlMw1O9dIBAlJj2pmC2YGt1cMpZq4JIkHVeQuHw5ZTwgxLlph9+uQqK38S0o0IgZo6CPXOwdRA957zkqEcYFfYG2fy4VpkkjR1DMTSBpPdLq4GXEHYbuBuKOqtbCzX21DQs5Vn2I7K4jMCplfF4KLGYuehpmwdRzqxK3PBg== 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=jH0VLPcCbhMfVNOCvbqZ9lbZuXw5ibc7Ngebjcaghw8=; b=l+JwL8+/MySJGvuebJBH1Z4Uy9EbENhrtPDBrmCJ2AgyNn9UiEYluwEt/hVBTfLHQ+/YuvK1Y+FZn5Ce7F6cRjP0k0EsBsE6GqvbJNNIgRh7/tLweOJfsUeMVLDVeeryBHi584UHbgBMdluqkiR+ESWKnTba3ts+QeQH9Z185K6rEJuY2fNZoSjWKGpGBV7k0OPQicsJ3TivmKdwHSx6v9z4FOVa8Y1OmUMYkQsOZbsyNqwXzw0eujUuBK2jr8Y6snhGZHoWuadYtpQyG+CuhVVr9eXpOxgFlP0hL8mvktX8wAX+KXvsub+BJIKT32c0YKW8Lna2+FH5T5cTSAt9ww== 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=jH0VLPcCbhMfVNOCvbqZ9lbZuXw5ibc7Ngebjcaghw8=; b=VnzV2miwI3QKg262CJZoQXz1iZYVpdof24DZw9nKa65fn9r+SudMgKilUEcSE8ltPtE7IFvdkYXUhw+ScJ5U5y7aeqbt2q04DK5I2vKZxzBd/MT2J4w3rHOGtHgs4lJRLMnw2hSfWTzVetzXoJQqQU3+aUpawfnRGjJDdkHvCsKFkVug3zN7vjeIYOfDUsUL5eI2kcw2QeNJNINyGcufDbX4afLnPj0NFrsv4HIwrEPFv4KhJvLFhhKjyQrGdfA7Dnl+vypFHyfbBg8gfW6Zxsp26ABwmPTW0OW3ndruxzK/C58bbTAljDDykHbusCaSHMnVnBRM4JmlaUyoV9daGw== Received: from DS7PR03CA0258.namprd03.prod.outlook.com (2603:10b6:5:3b3::23) by MWHPR12MB1822.namprd12.prod.outlook.com (2603:10b6:300:114::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.43; Tue, 4 May 2021 17:56:59 +0000 Received: from DM6NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b3:cafe::ef) by DS7PR03CA0258.outlook.office365.com (2603:10b6:5:3b3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.28 via Frontend Transport; Tue, 4 May 2021 17:56:59 +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 DM6NAM11FT046.mail.protection.outlook.com (10.13.172.121) 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 17:56:59 +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 17:56:57 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Shiri Kuzin Date: Tue, 4 May 2021 20:54:56 +0300 Message-ID: <20210504175500.3385811-12-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210504175500.3385811-1-matan@nvidia.com> References: <20210429154335.2820028-1-matan@nvidia.com> <20210504175500.3385811-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: f1e6a9ac-7820-4903-4625-08d90f2603ad X-MS-TrafficTypeDiagnostic: MWHPR12MB1822: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:873; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d131zrVNGkuVFm+hx88q9SeRph+fM9Qyaukpk1q1kqkC4jkA+L8FjMtA1NYn/+hc2yQBAHcdzs7inZxnwWwl5nlwhamdx7DlmwpU/2Y9is+M2Lgwle0+pC7+nL4VYoAVcWi48uRfywhGyQ6ZAFHk+QfbkBr11yfaMyt/+GL+W3B1BT6fz2TS+3afi92sPaePa9SxDA/WKubGeCohvMDgwKGttqvkpnAseWmDvGZA8gA5WelTW6T87AWyEQSpyxwSyXx1QOy9vul6wAuQ6q5AlrWPtgHpe7iR02jKGuPjcXGftvv68nMe8PVenhEUzcRjklFdfCM6aPuBe7FESsApQPz5DnqtCp7rBrVILoPi/mTkDGhnN2YaPXkEUSqT34tjBF88LUaGCFkoQRyf1pHiOVcrPVGgGDIh/vRrMgLLoTzPtGaleVshoSTYYycBhQkNMGdTIx8I3GK3X4oF3bc5E7nlQ0m7pwmmUvp5W3axuKaAz15ics+hISPk8Lx83cHQSmIL3u7JXXRkoD5zevFvrsSKTxXo5kszG10ofRExBJ+iHuq5aMgWvs1gHa5Zn8m3gBoDLdV7fg5KcK2apiY7am2mFJN4WWo04V/IEZT318+HY0mTTztvER15bjuM1ie2ueV1S39eUvnwAO59O5SlGTydxhCkhSkmGk9jhf8FfQM= 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)(376002)(136003)(39850400004)(396003)(36840700001)(46966006)(54906003)(83380400001)(8936002)(7636003)(426003)(1076003)(36860700001)(5660300002)(478600001)(47076005)(356005)(8676002)(86362001)(55016002)(336012)(70206006)(82310400003)(6916009)(70586007)(36756003)(107886003)(6286002)(4326008)(26005)(2616005)(16526019)(36906005)(316002)(7696005)(186003)(2906002)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:56:59.3477 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1e6a9ac-7820-4903-4625-08d90f2603ad 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: DM6NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1822 Subject: [dpdk-dev] [PATCH v3 11/15] common/mlx5: share get ib device match function 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: Shiri Kuzin The get_ib_device_match function iterates over the list of ib devices returned by the get_device_list glue function and returns the ib device matching the provided address. Since this function is in use by several drivers, in this patch we share the function in common part. Signed-off-by: Shiri Kuzin Acked-by: Matan Azrad --- drivers/common/mlx5/linux/mlx5_common_os.c | 28 +++++++++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 5 ++++ drivers/common/mlx5/mlx5_common.h | 1 + drivers/common/mlx5/version.map | 1 + drivers/compress/mlx5/mlx5_compress.c | 30 +------------------- drivers/regex/mlx5/mlx5_regex.c | 30 ++------------------ drivers/vdpa/mlx5/mlx5_vdpa.c | 32 ++-------------------- 7 files changed, 40 insertions(+), 87 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c index fba8245b8b..ea0b71e425 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.c +++ b/drivers/common/mlx5/linux/mlx5_common_os.c @@ -16,6 +16,7 @@ #include "mlx5_common.h" #include "mlx5_common_log.h" +#include "mlx5_common_os.h" #include "mlx5_glue.h" #ifdef MLX5_GLUE @@ -423,3 +424,30 @@ mlx5_glue_constructor(void) mlx5_glue = NULL; } +struct ibv_device * +mlx5_os_get_ibv_device(struct rte_pci_addr *addr) +{ + int n; + struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n); + struct ibv_device *ibv_match = NULL; + + if (ibv_list == NULL) { + rte_errno = ENOSYS; + return NULL; + } + while (n-- > 0) { + struct rte_pci_addr paddr; + + DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name); + if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &paddr) != 0) + continue; + if (rte_pci_addr_cmp(addr, &paddr) != 0) + continue; + ibv_match = ibv_list[n]; + break; + } + if (ibv_match == NULL) + rte_errno = ENOENT; + mlx5_glue->free_device_list(ibv_list); + return ibv_match; +} diff --git a/drivers/common/mlx5/linux/mlx5_common_os.h b/drivers/common/mlx5/linux/mlx5_common_os.h index d1c7e3dce0..72d6bf828b 100644 --- a/drivers/common/mlx5/linux/mlx5_common_os.h +++ b/drivers/common/mlx5/linux/mlx5_common_os.h @@ -288,4 +288,9 @@ mlx5_os_free(void *addr) { free(addr); } + +__rte_internal +struct ibv_device * +mlx5_os_get_ibv_device(struct rte_pci_addr *addr); + #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */ diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index f3c6beb23b..1fbefe0fa6 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -18,6 +18,7 @@ #include "mlx5_prm.h" #include "mlx5_devx_cmds.h" +#include "mlx5_common_os.h" /* Reported driver name. */ #define MLX5_PCI_DRIVER_NAME "mlx5_pci" diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 40b0d713ac..5706c6bbef 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -126,6 +126,7 @@ INTERNAL { mlx5_os_alloc_pd; mlx5_os_dealloc_pd; mlx5_os_dereg_mr; + mlx5_os_get_ibv_device; # WINDOWS_NO_EXPORT mlx5_os_reg_mr; mlx5_os_umem_dereg; mlx5_os_umem_reg; diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c index ec3c237512..0581dee505 100644 --- a/drivers/compress/mlx5/mlx5_compress.c +++ b/drivers/compress/mlx5/mlx5_compress.c @@ -647,34 +647,6 @@ mlx5_compress_dequeue_burst(void *queue_pair, struct rte_comp_op **ops, return i; } -static struct ibv_device * -mlx5_compress_get_ib_device_match(struct rte_pci_addr *addr) -{ - int n; - struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n); - struct ibv_device *ibv_match = NULL; - - if (ibv_list == NULL) { - rte_errno = ENOSYS; - return NULL; - } - while (n-- > 0) { - struct rte_pci_addr paddr; - - DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name); - if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &paddr) != 0) - continue; - if (rte_pci_addr_cmp(addr, &paddr) != 0) - continue; - ibv_match = ibv_list[n]; - break; - } - if (ibv_match == NULL) - rte_errno = ENOENT; - mlx5_glue->free_device_list(ibv_list); - return ibv_match; -} - static void mlx5_compress_hw_global_release(struct mlx5_compress_priv *priv) { @@ -774,7 +746,7 @@ mlx5_compress_pci_probe(struct rte_pci_driver *pci_drv, rte_errno = ENOTSUP; return -rte_errno; } - ibv = mlx5_compress_get_ib_device_match(&pci_dev->addr); + ibv = mlx5_os_get_ibv_device(&pci_dev->addr); if (ibv == NULL) { DRV_LOG(ERR, "No matching IB device for PCI slot " PCI_PRI_FMT ".", pci_dev->addr.domain, diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c index 82c485e50c..dd96436d42 100644 --- a/drivers/regex/mlx5/mlx5_regex.c +++ b/drivers/regex/mlx5/mlx5_regex.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -52,33 +53,6 @@ mlx5_regex_close(struct rte_regexdev *dev __rte_unused) return 0; } -static struct ibv_device * -mlx5_regex_get_ib_device_match(struct rte_pci_addr *addr) -{ - int n; - struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n); - struct ibv_device *ibv_match = NULL; - - if (!ibv_list) { - rte_errno = ENOSYS; - return NULL; - } - while (n-- > 0) { - struct rte_pci_addr pci_addr; - - DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name); - if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &pci_addr)) - continue; - if (rte_pci_addr_cmp(addr, &pci_addr)) - continue; - ibv_match = ibv_list[n]; - break; - } - if (!ibv_match) - rte_errno = ENOENT; - mlx5_glue->free_device_list(ibv_list); - return ibv_match; -} static int mlx5_regex_engines_status(struct ibv_context *ctx, int num_engines) { @@ -121,7 +95,7 @@ mlx5_regex_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, int ret; uint32_t val; - ibv = mlx5_regex_get_ib_device_match(&pci_dev->addr); + ibv = mlx5_os_get_ibv_device(&pci_dev->addr); if (!ibv) { DRV_LOG(ERR, "No matching IB device for PCI slot " PCI_PRI_FMT ".", pci_dev->addr.domain, diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c index 898e50f807..17753ae63f 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c @@ -472,34 +472,6 @@ static struct rte_vdpa_dev_ops mlx5_vdpa_ops = { .reset_stats = mlx5_vdpa_reset_stats, }; -static struct ibv_device * -mlx5_vdpa_get_ib_device_match(struct rte_pci_addr *addr) -{ - int n; - struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n); - struct ibv_device *ibv_match = NULL; - - if (!ibv_list) { - rte_errno = ENOSYS; - return NULL; - } - while (n-- > 0) { - struct rte_pci_addr pci_addr; - - DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name); - if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &pci_addr)) - continue; - if (rte_pci_addr_cmp(addr, &pci_addr)) - continue; - ibv_match = ibv_list[n]; - break; - } - if (!ibv_match) - rte_errno = ENOENT; - mlx5_glue->free_device_list(ibv_list); - return ibv_match; -} - /* Try to disable ROCE by Netlink\Devlink. */ static int mlx5_vdpa_nl_roce_disable(const char *addr) @@ -595,7 +567,7 @@ mlx5_vdpa_roce_disable(struct rte_pci_addr *addr, struct ibv_device **ibv) struct ibv_device *ibv_new; for (r = MLX5_VDPA_MAX_RETRIES; r; r--) { - ibv_new = mlx5_vdpa_get_ib_device_match(addr); + ibv_new = mlx5_os_get_ibv_device(addr); if (ibv_new) { *ibv = ibv_new; return 0; @@ -698,7 +670,7 @@ mlx5_vdpa_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct mlx5_hca_attr attr; int ret; - ibv = mlx5_vdpa_get_ib_device_match(&pci_dev->addr); + ibv = mlx5_os_get_ibv_device(&pci_dev->addr); if (!ibv) { DRV_LOG(ERR, "No matching IB device for PCI slot " PCI_PRI_FMT ".", pci_dev->addr.domain, -- 2.25.1