nvme: support new format in spdk_pci_addr_parse
The new format is: domain.bus.device.function For this format, since we use '.' as separator, to avoid misusing, we only support the following: 1 domain.bus.device.function ( 4 values provided) 2 bus.device.function (3 values provoided with domain = 0) 3 bus.device (2 values provided with domain = 0, function = 0) Change-Id: Ide03db38b4ac7802cf36f0e536e8b997101d6cd3 Signed-off-by: Ziye Yang <ziye.yang@intel.com>
This commit is contained in:
parent
e02d0bbd5f
commit
e15bd00711
@ -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.
|
* Convert a string representation of a PCI address into a struct spdk_pci_addr.
|
||||||
*
|
*
|
||||||
* \param addr PCI adddress output on success
|
* \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.
|
* \return 0 on success, or a negated errno value on failure.
|
||||||
*/
|
*/
|
||||||
|
@ -166,7 +166,7 @@ struct spdk_nvme_transport_id {
|
|||||||
* Transport address of the NVMe-oF endpoint. For transports which use IP
|
* 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
|
* 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
|
* 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];
|
char traddr[SPDK_NVMF_TRADDR_MAX_LEN + 1];
|
||||||
|
|
||||||
|
@ -461,13 +461,16 @@ spdk_pci_addr_parse(struct spdk_pci_addr *addr, const char *bdf)
|
|||||||
return -EINVAL;
|
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 */
|
/* Matched a full address - all variables are initialized */
|
||||||
} else if (sscanf(bdf, "%x:%x:%x", &domain, &bus, &dev) == 3) {
|
} else if (sscanf(bdf, "%x:%x:%x", &domain, &bus, &dev) == 3) {
|
||||||
func = 0;
|
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;
|
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;
|
domain = 0;
|
||||||
func = 0;
|
func = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -171,13 +171,16 @@ spdk_pci_addr_parse(struct spdk_pci_addr *addr, const char *bdf)
|
|||||||
return -EINVAL;
|
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 */
|
/* Matched a full address - all variables are initialized */
|
||||||
} else if (sscanf(bdf, "%x:%x:%x", &domain, &bus, &dev) == 3) {
|
} else if (sscanf(bdf, "%x:%x:%x", &domain, &bus, &dev) == 3) {
|
||||||
func = 0;
|
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;
|
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;
|
domain = 0;
|
||||||
func = 0;
|
func = 0;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user