From: Ophir Munk <ophirmu@mellanox.com>
To: dev@dpdk.org, Matan Azrad <matan@mellanox.com>,
Raslan Darawsheh <rasland@mellanox.com>
Cc: Ophir Munk <ophirmu@mellanox.com>
Subject: [dpdk-dev] [PATCH v1 8/8] net/mlx5: remove ibv dependency in spawn struct
Date: Wed, 3 Jun 2020 15:06:02 +0000 [thread overview]
Message-ID: <20200603150602.4686-9-ophirmu@mellanox.com> (raw)
In-Reply-To: <20200603150602.4686-1-ophirmu@mellanox.com>
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 <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
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
next prev parent reply other threads:[~2020-06-03 15:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 15:05 [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support Ophir Munk
2020-06-03 15:05 ` [dpdk-dev] [PATCH v1 1/8] net/mlx5: rename mlx5 ibv shared struct Ophir Munk
2020-06-03 15:05 ` [dpdk-dev] [PATCH v1 2/8] net/mlx5: add mlx5 Linux specific file with getter functions Ophir Munk
2020-06-08 11:20 ` Ferruh Yigit
2020-06-09 8:40 ` Ophir Munk
2020-06-09 8:43 ` Ferruh Yigit
2020-06-03 15:05 ` [dpdk-dev] [PATCH v1 3/8] drivers: remove mlx5 protection domain dependency on ibv Ophir Munk
2020-06-03 15:05 ` [dpdk-dev] [PATCH v1 4/8] net/mlx5: remove attributes dependency on ibv and dv Ophir Munk
2020-06-03 15:05 ` [dpdk-dev] [PATCH v1 5/8] net/mlx5: remove umem field dependency on dv Ophir Munk
2020-06-03 15:06 ` [dpdk-dev] [PATCH v1 6/8] net/mlx5: refactor PCI probing under Linux Ophir Munk
2020-06-03 15:06 ` [dpdk-dev] [PATCH v1 7/8] net/mlx5: add mlx5 header file specific to Linux Ophir Munk
2020-06-08 11:31 ` Ferruh Yigit
2020-06-09 8:44 ` Ophir Munk
2020-06-09 11:48 ` Ferruh Yigit
2020-06-09 14:49 ` Ophir Munk
2020-06-03 15:06 ` Ophir Munk [this message]
2020-06-07 8:49 ` [dpdk-dev] [PATCH v1 0/8] mlx5 PMD multi OS support Raslan Darawsheh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200603150602.4686-9-ophirmu@mellanox.com \
--to=ophirmu@mellanox.com \
--cc=dev@dpdk.org \
--cc=matan@mellanox.com \
--cc=rasland@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).