diff mbox series

[RFC,09/21] net/mlx5: improve spawn function

Message ID 20210817134441.1966618-10-michaelba@nvidia.com (mailing list archive)
State RFC, archived
Delegated to: Raslan Darawsheh
Headers show
Series mlx5: sharing global MR cache between drivers | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Michael Baum Aug. 17, 2021, 1:44 p.m. UTC
Add name as a parameter to spawn structure.

Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_os.c   | 24 ++++++++++--------------
 drivers/net/mlx5/mlx5.c            |  5 ++---
 drivers/net/mlx5/mlx5.h            |  1 +
 drivers/net/mlx5/windows/mlx5_os.c |  1 +
 4 files changed, 14 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 375bc55e79..b4670fad6e 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -938,7 +938,7 @@  mlx5_representor_match(struct mlx5_dev_spawn_data *spawn,
  *   Verbs device parameters (name, port, switch_info) to spawn.
  * @param config
  *   Device configuration parameters.
- * @param config
+ * @param eth_da
  *   Device arguments.
  *
  * @return
@@ -997,12 +997,11 @@  mlx5_dev_spawn(struct rte_device *dpdk_dev,
 		/* Bonding device. */
 		if (!switch_info->representor) {
 			err = snprintf(name, sizeof(name), "%s_%s",
-				 dpdk_dev->name,
-				 mlx5_os_get_dev_device_name(spawn->phys_dev));
+				       dpdk_dev->name, spawn->phys_dev_name);
 		} else {
 			err = snprintf(name, sizeof(name), "%s_%s_representor_c%dpf%d%s%u",
 				dpdk_dev->name,
-				mlx5_os_get_dev_device_name(spawn->phys_dev),
+				spawn->phys_dev_name,
 				switch_info->ctrl_num,
 				switch_info->pf_num,
 				switch_info->name_type ==
@@ -1227,8 +1226,7 @@  mlx5_dev_spawn(struct rte_device *dpdk_dev,
 		if (err) {
 			DRV_LOG(WARNING,
 				"can't query devx port %d on device %s",
-				spawn->phys_port,
-				mlx5_os_get_dev_device_name(spawn->phys_dev));
+				spawn->phys_port, spawn->phys_dev_name);
 			vport_info.query_flags = 0;
 		}
 	}
@@ -1238,18 +1236,14 @@  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->phys_port,
-				     mlx5_os_get_dev_device_name
-							(spawn->phys_dev));
+				     spawn->phys_port, spawn->phys_dev_name);
 			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->phys_port,
-				     mlx5_os_get_dev_device_name
-							(spawn->phys_dev));
+				     spawn->phys_port, spawn->phys_dev_name);
 			err = ENOTSUP;
 			goto error;
 		}
@@ -1260,8 +1254,7 @@  mlx5_dev_spawn(struct rte_device *dpdk_dev,
 		   (switch_info->representor || switch_info->master)) {
 		DRV_LOG(ERR, "can't deduce vport index for port %d"
 			     " on bonding device %s",
-			     spawn->phys_port,
-			     mlx5_os_get_dev_device_name(spawn->phys_dev));
+			     spawn->phys_port, spawn->phys_dev_name);
 		err = ENOTSUP;
 		goto error;
 	} else {
@@ -2314,6 +2307,7 @@  mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev,
 			list[ns].max_port = np;
 			list[ns].phys_port = i;
 			list[ns].phys_dev = ibv_match[0];
+			list[ns].phys_dev_name = ibv_match[0]->name;
 			list[ns].eth_dev = NULL;
 			list[ns].pci_dev = pci_dev;
 			list[ns].pf_bond = bd;
@@ -2410,6 +2404,7 @@  mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev,
 			list[ns].max_port = 1;
 			list[ns].phys_port = 1;
 			list[ns].phys_dev = ibv_match[i];
+			list[ns].phys_dev_name = ibv_match[i]->name;
 			list[ns].eth_dev = NULL;
 			list[ns].pci_dev = pci_dev;
 			list[ns].pf_bond = -1;
@@ -2732,6 +2727,7 @@  mlx5_os_auxiliary_probe(struct rte_device *dev)
 	spawn.phys_dev = mlx5_os_get_ibv_dev(dev);
 	if (spawn.phys_dev == NULL)
 		return -rte_errno;
+	spawn.phys_dev_name = mlx5_os_get_dev_device_name(spawn.phys_dev);
 	ret = mlx5_auxiliary_get_ifindex(dev->name);
 	if (ret < 0) {
 		DRV_LOG(ERR, "failed to get ethdev ifindex: %s", dev->name);
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 02ea2e781e..08c9a6ec6f 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1107,7 +1107,7 @@  mlx5_alloc_rxtx_uars(struct mlx5_dev_ctx_shared *sh,
  */
 struct mlx5_dev_ctx_shared *
 mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
-			   const struct mlx5_dev_config *config)
+			  const struct mlx5_dev_config *config)
 {
 	struct mlx5_dev_ctx_shared *sh;
 	int err = 0;
@@ -1120,8 +1120,7 @@  mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
 	pthread_mutex_lock(&mlx5_dev_ctx_list_mutex);
 	/* Search for IB context by device name. */
 	LIST_FOREACH(sh, &mlx5_dev_ctx_list, next) {
-		if (!strcmp(sh->ibdev_name,
-			mlx5_os_get_dev_device_name(spawn->phys_dev))) {
+		if (!strcmp(sh->ibdev_name, spawn->phys_dev_name)) {
 			sh->refcnt++;
 			goto exit;
 		}
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 3581414b78..9a8e34535c 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -137,6 +137,7 @@  struct mlx5_dev_spawn_data {
 	int numa_node; /**< Device numa node. */
 	struct mlx5_switch_info info; /**< Switch information. */
 	void *phys_dev; /**< Associated physical device. */
+	const char *phys_dev_name; /**< Name of physical device. */
 	struct rte_eth_dev *eth_dev; /**< Associated Ethernet device. */
 	struct rte_pci_device *pci_dev; /**< Backend PCI device. */
 	struct mlx5_bond_info *bond_info;
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index 0ff9e70d96..2f5c29662e 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -942,6 +942,7 @@  mlx5_os_net_probe(struct rte_device *dev)
 	spawn.max_port = 1;
 	spawn.phys_port = 1;
 	spawn.phys_dev = devx_bdf_match;
+	spawn.phys_dev_name = mlx5_os_get_dev_device_name(devx_bdf_match);
 	spawn.eth_dev = NULL;
 	spawn.pci_dev = pci_dev;
 	spawn.ifindex = -1; /* Spawn will assign */