From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E7115A04A4; Wed, 3 Jun 2020 17:07:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 03E9C1D5CF; Wed, 3 Jun 2020 17:06:21 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2051.outbound.protection.outlook.com [40.107.20.51]) by dpdk.org (Postfix) with ESMTP id 04BF11D5AC for ; Wed, 3 Jun 2020 17:06:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PzpAhqCniq/TQIheOrbzycRVDXLjBxr0uX7TcT+JRjc2zkpr0smF8qr3WnLpwwJYCriIBJFXKHy+DuokoVLfcN0XAeY3GrAhojKL03ReDDQQEG/cdIkS/0fUIDUo7j/xNRLdB1cI3oiNTply5x5Jz1v47U2AXkuHfkbXnLIwXtyX/PJpziyxZdv8qCdq4QwPtWFccmVV6Si9vL6p+SwlLgjx8tnMkGCR4iwktRB3tb5ZdFNKQ1qsDuPvPZIBrOVPNscTm6O+ZGOSJ4pL72MfyuPKVtX6CXM2z+HfXCwsVkW7iF60+mgk01GfmkWpKluHivtOUwUUmwYEbbbsq329pg== 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=W4ElFJax/YQdYinl8tBagZ6cu9JJlxw3hPQxLa74+ws=; b=Mf0FhmmRYpfNjN33rDF1ByROhHGoLWVzBd96/jphBMVWyANysinzNSWbhKgxNDXJcRGZ06Frh+n0d0NsUF62X5OOHijNU4Nb/eAcUimnMngKCAdZL4LisjbLrdDiMNUnEBFTneaS2y0YRL16RbetHYZOvGWzWjKo9710bqXM0AReaqSgi5dA2F2kWP2M2saWH5m747T5rjQSslZD+FEuVIQL/TlZQsKfRLnJNLzFEXYo/VaHxzCqHg+BYMbtExUY6U7zJwUuGxUb26YsvkclscRu7qYDjAT4bQDnE3Taa82JEC9nZcN+m4Gvzxiy2OhUbfH2tkLlzqExnA4xIfTFpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W4ElFJax/YQdYinl8tBagZ6cu9JJlxw3hPQxLa74+ws=; b=XmRdZSGdmFlC0xhXbeM/l+iOt77/ClUkSGzaJUN7bMkpVfue0FT8bTTGQ7hGAM4OBsxp61Cz+yODWPcE65HIf2/c2wriFgx1xRGqdbOUEUSptlzFF8AxfkTaxDFTiappr+rt/jcvD8CABzVriYvjvjM76izS3ALvzK3v4bi1UDA= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) by AM0PR05MB5235.eurprd05.prod.outlook.com (2603:10a6:208:f5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Wed, 3 Jun 2020 15:06:16 +0000 Received: from AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::1068:89a9:41d3:b14a]) by AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::1068:89a9:41d3:b14a%3]) with mapi id 15.20.3066.018; Wed, 3 Jun 2020 15:06:16 +0000 From: Ophir Munk To: dev@dpdk.org, Matan Azrad , Raslan Darawsheh Cc: Ophir Munk Date: Wed, 3 Jun 2020 15:06:02 +0000 Message-Id: <20200603150602.4686-9-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200603150602.4686-1-ophirmu@mellanox.com> References: <20200603150602.4686-1-ophirmu@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: AM4PR0302CA0033.eurprd03.prod.outlook.com (2603:10a6:205:2::46) To AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by AM4PR0302CA0033.eurprd03.prod.outlook.com (2603:10a6:205:2::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.19 via Frontend Transport; Wed, 3 Jun 2020 15:06:15 +0000 X-Mailer: git-send-email 2.8.4 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 11eb4be5-1e52-4ccd-9102-08d807cfa991 X-MS-TrafficTypeDiagnostic: AM0PR05MB5235: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:172; X-Forefront-PRVS: 04238CD941 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jr68fRleKGOH8ksohq+oTJbFWNPy/z985LPGshjR479H64byEndkBDofU1w8JlMPGnTzelrXAERqj6ir0VvTE8ImOj0UsG2omQ+fFOjO/u0Oj3k0NJWByp6naJTHjCpZ4RPZiH40RAhBYtIz4cWcNUsJRpCDMO78/uQf0gyRCDXeM3QM386nl6Os4xx/wcDpVD//+uuILF7BfwFNBp9MDymnCI3NPDvD1qg847Z8ygD4XepB+EU90nEfTxR4yV1zGRspN8jIYBMJQ9mg4m3Q7GT0VCGBsIRjUCGXuHMzf7a9ugK4U4LpoxBti59JBH217ASulPbaSlb5LiGqwfAP5Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB4209.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(26005)(4326008)(186003)(478600001)(316002)(8676002)(16526019)(8886007)(6666004)(2906002)(66476007)(8936002)(66946007)(956004)(66556008)(2616005)(55016002)(107886003)(86362001)(83380400001)(36756003)(6636002)(7696005)(5660300002)(1076003)(52116002)(110136005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: pJ+b30wk9RuY8XJTZYTX5odBZhzzTHtAZaEoZgbr+IBjHorrTtlMxCKXkGGNruKAAvFJWaP15fIVMzYEesROy8k7BnrcR98RwPKtQ7uEIHWYgUsoVQ+orMfy/2irB4xCSgFFSawvYkdR/N6dv5y5Q+M65lVmT83wEbu9d1qEbW4tIdSbhAAxHUGrmesVuifh9/SIFEoCXItk9+SVwpWX0SuEPV5DfKZtCMzwibXC7FkH23cEUK1swPVpXsUesbYEROy8ITye4tHVrPohGJHohy9Ejo486yB+jd0xdfiem1O7zml5Kyjgm2CxLkaPs3f0Ns61Gat3kbdwXN+Gpu0YvjUc+TKppKHdWEOqubS20WRTwJm7Q3xmTYHazCCU+ekg1gGSFjzgaWclU8Cp0AzVqyfrHs/N3EI5G8EMMFDHt4KhBh6uYPGwJM8v82m7WUrkl4f0pibgyV0AvHT7JNaLLsoMf4wPCq8sVFbdxwjXowqT7KfYBht8KeX66VEFdKt6 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11eb4be5-1e52-4ccd-9102-08d807cfa991 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2020 15:06:16.0047 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gGbg5MqOzwrn/Xblj0Cw0clVYV8LHW2qxc3Wl0RwXnTfi05tB88iy27IrkA583dt5Z+lgmR3i1nVcseq6rd3gg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB5235 Subject: [dpdk-dev] [PATCH v1 8/8] net/mlx5: remove ibv dependency in spawn struct X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" 1. Replace 'struct ibv_device *' with 'void *' in 'struct mlx5_dev_spawn_data'. Define a getter function to retrieve the device name. 2. Rename ibv_dev and ibv_port as phys_dev and phys_port respectively. Signed-off-by: Ophir Munk Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 64 +++++++++++++++++++++++++++++----------- drivers/net/mlx5/mlx5.c | 3 +- drivers/net/mlx5/mlx5.h | 7 +++-- 3 files changed, 53 insertions(+), 21 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index d1476c2..92422db 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -62,6 +62,24 @@ #endif /** + * Get device name. Given an ibv_device pointer - return a + * pointer to the corresponding device name. + * + * @param[in] dev + * Pointer to ibv device. + * + * @return + * Pointer to device name if dev is valid, NULL otherwise. + */ +const char * +mlx5_os_get_dev_device_name(void *dev) +{ + if (!dev) + return NULL; + return ((struct ibv_device *)dev)->name; +} + +/** * Get ibv device name. Given an ibv_context pointer - return a * pointer to the corresponding device name. * @@ -482,10 +500,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, /* Bonding device. */ if (!switch_info->representor) snprintf(name, sizeof(name), "%s_%s", - dpdk_dev->name, spawn->ibv_dev->name); + dpdk_dev->name, + mlx5_os_get_dev_device_name(spawn->phys_dev)); else snprintf(name, sizeof(name), "%s_%s_representor_%u", - dpdk_dev->name, spawn->ibv_dev->name, + dpdk_dev->name, + mlx5_os_get_dev_device_name(spawn->phys_dev), switch_info->port_name); } /* check if the device is already spawned */ @@ -649,7 +669,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, #endif config.mpls_en = mpls_en; /* Check port status. */ - err = mlx5_glue->query_port(sh->ctx, spawn->ibv_port, &port_attr); + err = mlx5_glue->query_port(sh->ctx, spawn->phys_port, &port_attr); if (err) { DRV_LOG(ERR, "port query failed: %s", strerror(err)); goto error; @@ -673,7 +693,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error; } priv->sh = sh; - priv->ibv_port = spawn->ibv_port; + priv->ibv_port = spawn->phys_port; priv->pci_dev = spawn->pci_dev; priv->mtu = RTE_ETHER_MTU; priv->mp_id.port_id = port_id; @@ -703,12 +723,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, if (switch_info->representor || switch_info->master) { devx_port.comp_mask = MLX5DV_DEVX_PORT_VPORT | MLX5DV_DEVX_PORT_MATCH_REG_C_0; - err = mlx5_glue->devx_port_query(sh->ctx, spawn->ibv_port, + err = mlx5_glue->devx_port_query(sh->ctx, spawn->phys_port, &devx_port); if (err) { DRV_LOG(WARNING, "can't query devx port %d on device %s", - spawn->ibv_port, spawn->ibv_dev->name); + spawn->phys_port, + mlx5_os_get_dev_device_name(spawn->phys_dev)); devx_port.comp_mask = 0; } } @@ -718,14 +739,18 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, if (!priv->vport_meta_mask) { DRV_LOG(ERR, "vport zero mask for port %d" " on bonding device %s", - spawn->ibv_port, spawn->ibv_dev->name); + spawn->phys_port, + mlx5_os_get_dev_device_name + (spawn->phys_dev)); err = ENOTSUP; goto error; } if (priv->vport_meta_tag & ~priv->vport_meta_mask) { DRV_LOG(ERR, "invalid vport tag for port %d" " on bonding device %s", - spawn->ibv_port, spawn->ibv_dev->name); + spawn->phys_port, + mlx5_os_get_dev_device_name + (spawn->phys_dev)); err = ENOTSUP; goto error; } @@ -735,7 +760,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, } else if (spawn->pf_bond >= 0) { DRV_LOG(ERR, "can't deduce vport index for port %d" " on bonding device %s", - spawn->ibv_port, spawn->ibv_dev->name); + spawn->phys_port, + mlx5_os_get_dev_device_name(spawn->phys_dev)); err = ENOTSUP; goto error; } else { @@ -1491,13 +1517,15 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, MLX5_ASSERT(np); for (i = 1; i <= np; ++i) { list[ns].max_port = np; - list[ns].ibv_port = i; - list[ns].ibv_dev = ibv_match[0]; + list[ns].phys_port = i; + list[ns].phys_dev = ibv_match[0]; list[ns].eth_dev = NULL; list[ns].pci_dev = pci_dev; list[ns].pf_bond = bd; list[ns].ifindex = mlx5_nl_ifindex - (nl_rdma, list[ns].ibv_dev->name, i); + (nl_rdma, + mlx5_os_get_dev_device_name + (list[ns].phys_dev), i); if (!list[ns].ifindex) { /* * No network interface index found for the @@ -1573,15 +1601,17 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, for (i = 0; i != nd; ++i) { memset(&list[ns].info, 0, sizeof(list[ns].info)); list[ns].max_port = 1; - list[ns].ibv_port = 1; - list[ns].ibv_dev = ibv_match[i]; + list[ns].phys_port = 1; + list[ns].phys_dev = ibv_match[i]; list[ns].eth_dev = NULL; list[ns].pci_dev = pci_dev; list[ns].pf_bond = -1; list[ns].ifindex = 0; if (nl_rdma >= 0) list[ns].ifindex = mlx5_nl_ifindex - (nl_rdma, list[ns].ibv_dev->name, 1); + (nl_rdma, + mlx5_os_get_dev_device_name + (list[ns].phys_dev), 1); if (!list[ns].ifindex) { char ifname[IF_NAMESIZE]; @@ -1858,7 +1888,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn, dbmap_env = mlx5_config_doorbell_mapping_env(config); /* Try to open IB device with DV first, then usual Verbs. */ errno = 0; - sh->ctx = mlx5_glue->dv_open_device(spawn->ibv_dev); + sh->ctx = mlx5_glue->dv_open_device(spawn->phys_dev); if (sh->ctx) { sh->devx = 1; DRV_LOG(DEBUG, "DevX is supported"); @@ -1866,7 +1896,7 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn, mlx5_restore_doorbell_mapping_env(dbmap_env); } else { /* The environment variable is still configured. */ - sh->ctx = mlx5_glue->open_device(spawn->ibv_dev); + sh->ctx = mlx5_glue->open_device(spawn->phys_dev); err = errno ? errno : ENODEV; /* * The environment variable is not needed anymore, diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 16ab8b0..7c5e23d 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -613,7 +613,8 @@ mlx5_alloc_shared_ibctx(const struct mlx5_dev_spawn_data *spawn, pthread_mutex_lock(&mlx5_ibv_list_mutex); /* Search for IB context by device name. */ LIST_FOREACH(sh, &mlx5_ibv_list, next) { - if (!strcmp(sh->ibdev_name, spawn->ibv_dev->name)) { + if (!strcmp(sh->ibdev_name, + mlx5_os_get_dev_device_name(spawn->phys_dev))) { sh->refcnt++; goto exit; } diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index eca4472..8c4b234 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -98,11 +98,11 @@ struct mlx5_dev_attr { /** Data associated with devices to spawn. */ struct mlx5_dev_spawn_data { uint32_t ifindex; /**< Network interface index. */ - uint32_t max_port; /**< IB device maximal port index. */ - uint32_t ibv_port; /**< IB device physical port index. */ + uint32_t max_port; /**< Device maximal port index. */ + uint32_t phys_port; /**< Device physical port index. */ int pf_bond; /**< bonding device PF index. < 0 - no bonding */ struct mlx5_switch_info info; /**< Switch information. */ - struct ibv_device *ibv_dev; /**< Associated IB device. */ + void *phys_dev; /**< Associated physical device. */ struct rte_eth_dev *eth_dev; /**< Associated Ethernet device. */ struct rte_pci_device *pci_dev; /**< Backend PCI device. */ }; @@ -911,6 +911,7 @@ void mlx5_flow_meter_detach(struct mlx5_flow_meter *fm); struct rte_pci_driver; const char *mlx5_os_get_ctx_device_name(void *ctx); const char *mlx5_os_get_ctx_device_path(void *ctx); +const char *mlx5_os_get_dev_device_name(void *dev); uint32_t mlx5_os_get_umem_id(void *umem); int mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *dev_attr); void mlx5_os_free_shared_dr(struct mlx5_priv *priv); -- 2.8.4