Blame SOURCES/0001-net-mlx5-use-PCI-address-as-port-name.patch

c7ffa4
From 1092b5cd70af89b5000f793e4e326ccb04871552 Mon Sep 17 00:00:00 2001
c7ffa4
From: Yuanhan Liu <yliu@fridaylinux.org>
c7ffa4
Date: Mon, 22 Jan 2018 17:30:06 +0800
c7ffa4
Subject: [PATCH] net/mlx5: use PCI address as port name
c7ffa4
c7ffa4
It is suggested to use PCI BDF to identify a port for port addition
c7ffa4
in OVS-DPDK. While mlx5 has its own naming style: name it by ib dev
c7ffa4
name. This breaks the typical OVS DPDK use case and brings more puzzle
c7ffa4
to the end users.
c7ffa4
c7ffa4
To fix it, this patch changes it to use PCI BDF as the name, too.
c7ffa4
Also, a postfix " port %u" is added, just in case their might be more
c7ffa4
than 1 port associated with a PCI device.
c7ffa4
c7ffa4
Signed-off-by: Yuanhan Liu <yliu@fridaylinux.org>
c7ffa4
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
c7ffa4
---
c7ffa4
 drivers/net/mlx5/mlx5.c | 22 +++++++++-------------
c7ffa4
 1 file changed, 9 insertions(+), 13 deletions(-)
c7ffa4
c7ffa4
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
c7ffa4
index a5eb3fdc5..ec3ddcf28 100644
c7ffa4
--- a/drivers/net/mlx5/mlx5.c
c7ffa4
+++ b/drivers/net/mlx5/mlx5.c
c7ffa4
@@ -662,6 +662,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
c7ffa4
 	INFO("%u port(s) detected", device_attr.orig_attr.phys_port_cnt);
c7ffa4
 
c7ffa4
 	for (i = 0; i < device_attr.orig_attr.phys_port_cnt; i++) {
c7ffa4
+		char name[RTE_ETH_NAME_MAX_LEN];
c7ffa4
+		int len;
c7ffa4
 		uint32_t port = i + 1; /* ports are indexed from one */
c7ffa4
 		uint32_t test = (1 << i);
c7ffa4
 		struct ibv_context *ctx = NULL;
c7ffa4
@@ -685,14 +687,15 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
c7ffa4
 			.rx_vec_en = MLX5_ARG_UNSET,
c7ffa4
 		};
c7ffa4
 
c7ffa4
+		len = snprintf(name, sizeof(name), PCI_PRI_FMT,
c7ffa4
+			 pci_dev->addr.domain, pci_dev->addr.bus,
c7ffa4
+			 pci_dev->addr.devid, pci_dev->addr.function);
c7ffa4
+		if (device_attr.orig_attr.phys_port_cnt > 1)
c7ffa4
+			snprintf(name + len, sizeof(name), " port %u", i);
c7ffa4
+
c7ffa4
 		mlx5_dev[idx].ports |= test;
c7ffa4
 
c7ffa4
 		if (mlx5_is_secondary()) {
c7ffa4
-			/* from rte_ethdev.c */
c7ffa4
-			char name[RTE_ETH_NAME_MAX_LEN];
c7ffa4
-
c7ffa4
-			snprintf(name, sizeof(name), "%s port %u",
c7ffa4
-				 ibv_get_device_name(ibv_dev), port);
c7ffa4
 			eth_dev = rte_eth_dev_attach_secondary(name);
c7ffa4
 			if (eth_dev == NULL) {
c7ffa4
 				ERROR("can not attach rte ethdev");
c7ffa4
@@ -902,14 +905,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
c7ffa4
 		priv_get_mtu(priv, &priv->mtu);
c7ffa4
 		DEBUG("port %u MTU is %u", priv->port, priv->mtu);
c7ffa4
 
c7ffa4
-		/* from rte_ethdev.c */
c7ffa4
-		{
c7ffa4
-			char name[RTE_ETH_NAME_MAX_LEN];
c7ffa4
-
c7ffa4
-			snprintf(name, sizeof(name), "%s port %u",
c7ffa4
-				 ibv_get_device_name(ibv_dev), port);
c7ffa4
-			eth_dev = rte_eth_dev_allocate(name);
c7ffa4
-		}
c7ffa4
+		eth_dev = rte_eth_dev_allocate(name);
c7ffa4
 		if (eth_dev == NULL) {
c7ffa4
 			ERROR("can not allocate rte ethdev");
c7ffa4
 			err = ENOMEM;
c7ffa4
-- 
c7ffa4
2.14.3
c7ffa4