diff --git a/include/spdk/env.h b/include/spdk/env.h index f50499cc5..b164ffcfc 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -291,7 +291,8 @@ int spdk_pci_addr_compare(const struct spdk_pci_addr *a1, const struct spdk_pci_ * Convert a string representation of a PCI address into a struct spdk_pci_addr. * * \param addr PCI adddress output on success - * \param bdf PCI address in domain:bus:device.function format + * \param bdf PCI address in domain:bus:device.function format or + * domain.bus.device.function format * * \return 0 on success, or a negated errno value on failure. */ diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 79958ec62..73ab523ec 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -166,7 +166,7 @@ struct spdk_nvme_transport_id { * Transport address of the NVMe-oF endpoint. For transports which use IP * addressing (e.g. RDMA), this should be an IP address. For PCIe, this * can either be a zero length string (the whole bus) or a PCI address - * in the format DDDD:BB:DD.FF + * in the format DDDD:BB:DD.FF or DDDD.BB.DD.FF */ char traddr[SPDK_NVMF_TRADDR_MAX_LEN + 1]; diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index acad241c7..9259b99d1 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -461,13 +461,16 @@ spdk_pci_addr_parse(struct spdk_pci_addr *addr, const char *bdf) return -EINVAL; } - if (sscanf(bdf, "%x:%x:%x.%x", &domain, &bus, &dev, &func) == 4) { + if ((sscanf(bdf, "%x:%x:%x.%x", &domain, &bus, &dev, &func) == 4) || + (sscanf(bdf, "%x.%x.%x.%x", &domain, &bus, &dev, &func) == 4)) { /* Matched a full address - all variables are initialized */ } else if (sscanf(bdf, "%x:%x:%x", &domain, &bus, &dev) == 3) { func = 0; - } else if (sscanf(bdf, "%x:%x.%x", &bus, &dev, &func) == 3) { + } else if ((sscanf(bdf, "%x:%x.%x", &bus, &dev, &func) == 3) || + (sscanf(bdf, "%x.%x.%x", &bus, &dev, &func) == 3)) { domain = 0; - } else if (sscanf(bdf, "%x:%x", &bus, &dev) == 2) { + } else if ((sscanf(bdf, "%x:%x", &bus, &dev) == 2) || + (sscanf(bdf, "%x.%x", &bus, &dev) == 2)) { domain = 0; func = 0; } else { diff --git a/test/lib/test_env.c b/test/lib/test_env.c index 74950421b..8b1a1b59c 100644 --- a/test/lib/test_env.c +++ b/test/lib/test_env.c @@ -171,13 +171,16 @@ spdk_pci_addr_parse(struct spdk_pci_addr *addr, const char *bdf) return -EINVAL; } - if (sscanf(bdf, "%x:%x:%x.%x", &domain, &bus, &dev, &func) == 4) { + if ((sscanf(bdf, "%x:%x:%x.%x", &domain, &bus, &dev, &func) == 4) || + (sscanf(bdf, "%x.%x.%x.%x", &domain, &bus, &dev, &func) == 4)) { /* Matched a full address - all variables are initialized */ } else if (sscanf(bdf, "%x:%x:%x", &domain, &bus, &dev) == 3) { func = 0; - } else if (sscanf(bdf, "%x:%x.%x", &bus, &dev, &func) == 3) { + } else if ((sscanf(bdf, "%x:%x.%x", &bus, &dev, &func) == 3) || + (sscanf(bdf, "%x.%x.%x", &bus, &dev, &func) == 3)) { domain = 0; - } else if (sscanf(bdf, "%x:%x", &bus, &dev) == 2) { + } else if ((sscanf(bdf, "%x:%x", &bus, &dev) == 2) || + (sscanf(bdf, "%x.%x", &bus, &dev) == 2)) { domain = 0; func = 0; } else {