Commit e15bd007 authored by Ziye Yang's avatar Ziye Yang Committed by Jim Harris
Browse files

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: default avatarZiye Yang <ziye.yang@intel.com>
parent e02d0bbd
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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.
 */
+1 −1
Original line number Diff line number Diff line
@@ -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];

+6 −3
Original line number Diff line number Diff line
@@ -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 {
+6 −3
Original line number Diff line number Diff line
@@ -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 {