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

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