raw/ifpga: fix device name format
authorWei Huang <wei.huang@intel.com>
Thu, 29 Apr 2021 02:33:40 +0000 (22:33 -0400)
committerQi Zhang <qi.z.zhang@intel.com>
Thu, 29 Apr 2021 08:25:28 +0000 (10:25 +0200)
The device name format used in ifpga_rawdev_create() was changed to
"IFPGA:%02x:%02x.%x", but the format used in ifpga_rawdev_destroy()
was left as "IFPGA:%x:%02x.%x", it should be changed synchronously.

To prevent further similar errors, macro "IFPGA_RAWDEV_NAME_FMT" is
defined to replace this format string.

Fixes: 9c006c45d0c5 ("raw/ifpga: scan PCIe BDF device tree")
Cc: stable@dpdk.org
Signed-off-by: Wei Huang <wei.huang@intel.com>
Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
Acked-by: Rosen Xu <rosen.xu@intel.com>
drivers/raw/ifpga/ifpga_rawdev.c
drivers/raw/ifpga/ifpga_rawdev.h
drivers/raw/ifpga/rte_pmd_ifpga.c

index f2551be..7ccebfa 100644 (file)
@@ -1448,7 +1448,7 @@ ifpga_rawdev_create(struct rte_pci_device *pci_dev,
        }
 
        memset(name, 0, sizeof(name));
-       snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%02x:%02x.%x",
+       snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, IFPGA_RAWDEV_NAME_FMT,
                pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
 
        IFPGA_RAWDEV_PMD_INFO("Init %s on NUMA node %d", name, rte_socket_id());
@@ -1551,7 +1551,7 @@ ifpga_rawdev_destroy(struct rte_pci_device *pci_dev)
        }
 
        memset(name, 0, sizeof(name));
-       snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%x:%02x.%x",
+       snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, IFPGA_RAWDEV_NAME_FMT,
                pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
 
        IFPGA_RAWDEV_PMD_INFO("Closing %s on NUMA node %d",
index 9bbe9a4..61c8366 100644 (file)
@@ -7,6 +7,8 @@
 
 extern int ifpga_rawdev_logtype;
 
+#define IFPGA_RAWDEV_NAME_FMT "IFPGA:%02x:%02x.%x"
+
 #define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \
        rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "%s(): " fmt "\n", \
                                __func__, ##args)
index 6e23a25..2314643 100644 (file)
@@ -34,7 +34,7 @@ rte_pmd_ifpga_get_dev_id(const char *pci_addr, uint16_t *dev_id)
                return -EINVAL;
        }
 
-       snprintf(rdev_name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%02x:%02x.%x",
+       snprintf(rdev_name, RTE_RAWDEV_NAME_MAX_LEN, IFPGA_RAWDEV_NAME_FMT,
                addr.bus, addr.devid, addr.function);
        rdev = rte_rawdev_pmd_get_named_dev(rdev_name);
        if (!rdev) {