Skip to contentSkip to conversation

bus/pci: support segment value as address domain on Windows

PATCH In review Tal Shnaiderman 5 participants 9 messages Aug 25, 2020 – Oct 14, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus/pci: support segment value as address domain on Windows

Set the domain value for rte_pci_addr probing on Windows to the value of the PCI segment returned by SPDRP_BUSNUMBER.

---
 drivers/bus/pci/windows/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/pci/windows/pci.c +2 -2
index 489aa7902a..a40acec609 100644
@@ -195,8 +195,8 @@ get_device_pci_address(HDEVINFO dev_info,
 		return -1;
 	}
 
-	addr->domain = 0;
-	addr->bus = bus_num;
+	addr->domain = bus_num >> 8;
+	addr->bus = bus_num & 0xff;
 	addr->devid = dev_and_func >> 16;
 	addr->function = dev_and_func & 0xffff;
 	return 0;
Signature · 1 line
2.16.1.windows.4
#1 lore raw
Quoted 14 lines · Tal Shnaiderman

Set the domain value for rte_pci_addr probing on Windows to the value of the PCI segment returned by SPDRP_BUSNUMBER.

---
 drivers/bus/pci/windows/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/pci/windows/pci.c +0 -0
index 489aa7902a..a40acec609 100644

drivers/bus/pci/windows/pci.c get_device_pci_address(HDEVINFO dev_info, · line 202

Quoted 10 lines
drivers/bus/pci/windows/pci.c +2 -2
@@ -195,8 +195,8 @@ get_device_pci_address(HDEVINFO dev_info,
 		return -1;
 	}
 
-	addr->domain = 0;
-	addr->bus = bus_num;
+	addr->domain = bus_num >> 8;
+	addr->bus = bus_num & 0xff;
 	addr->devid = dev_and_func >> 16;
 	addr->function = dev_and_func & 0xffff;
 	return 0;

Is this needed to avoid collision of devices with the same B:D:F?

#2 lore raw
Quoted 20 lines

Subject: Re: [PATCH] bus/pci: support segment value as address domain on Windows

Quoted 16 lines · Tal Shnaiderman

Set the domain value for rte_pci_addr probing on Windows to the value of the PCI segment returned by SPDRP_BUSNUMBER.

---
 drivers/bus/pci/windows/pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/bus/pci/windows/pci.c index 489aa7902a..a40acec609 100644

drivers/bus/pci/windows/pci.c +0 -0
@@ -195,8 +195,8 @@ get_device_pci_address(HDEVINFO dev_info,
 		return -1;
 	}
 
Quoted 9 lines

drivers/bus/pci/windows/pci.c get_device_pci_address(HDEVINFO dev_info,

Quoted 8 lines
drivers/bus/pci/windows/pci.c +2 -3
-	addr->domain = 0;
-	addr->bus = bus_num;
+	addr->domain = bus_num >> 8;
+	addr->bus = bus_num & 0xff;
 	addr->devid = dev_and_func >> 16;
 	addr->function = dev_and_func & 0xffff;
 	return 0;
--

Is this needed to avoid collision of devices with the same B:D:F?

Right, it can happen in virtualization setups when several virtual functions can have the same BDF, e.g.:

PS > Get-NetAdapterHardwareInfo

Name Segment Bus Device Function Slot NumaNode PcieLinkSpeed
---- ------- --- ------ -------- ---- -------- -------------
Ethernet 0 0 10 0 Unknown

Ethernet 4                       58601   0      2        0             0       Unknown
Ethernet 5                       52956   0      2        0             0       Unknown

DPDK currently can detect either Ethernet 4 or ethernet 5 if only BDF is checked. Unix uses the Domain value, the equivalent value for Windows is Segment.

#3 lore raw
Quoted 33 lines · Tal Shnaiderman
Quoted 20 lines

Subject: Re: [PATCH] bus/pci: support segment value as address domain on Windows

Quoted 16 lines · Tal Shnaiderman

Set the domain value for rte_pci_addr probing on Windows to the value of the PCI segment returned by SPDRP_BUSNUMBER.

---
  drivers/bus/pci/windows/pci.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/bus/pci/windows/pci.c index 489aa7902a..a40acec609 100644

drivers/bus/pci/windows/pci.c +0 -0
@@ -195,8 +195,8 @@ get_device_pci_address(HDEVINFO dev_info,
  		return -1;
  	}
 
Quoted 9 lines

drivers/bus/pci/windows/pci.c get_device_pci_address(HDEVINFO dev_info,

Quoted 8 lines
drivers/bus/pci/windows/pci.c +2 -3
-	addr->domain = 0;
-	addr->bus = bus_num;
+	addr->domain = bus_num >> 8;
+	addr->bus = bus_num & 0xff;
  	addr->devid = dev_and_func >> 16;
  	addr->function = dev_and_func & 0xffff;
  	return 0;
--

Is this needed to avoid collision of devices with the same B:D:F?

Right, it can happen in virtualization setups when several virtual functions can have the same BDF, e.g.:

PS > Get-NetAdapterHardwareInfo

Quoted 8 lines

Name Segment Bus Device Function Slot NumaNode PcieLinkSpeed
---- ------- --- ------ -------- ---- -------- -------------
Ethernet 0 0 10 0 Unknown

Ethernet 4                       58601   0      2        0             0       Unknown
Ethernet 5                       52956   0      2        0             0       Unknown

DPDK currently can detect either Ethernet 4 or ethernet 5 if only BDF is checked. Unix uses the Domain value, the equivalent value for Windows is Segment.

Thanks for the explanation, Tal.

I had always been curious how Windows stores the PCIe segment (domain) number.

On VMs hosted on Hyper-V, the VF segment numbers are always in the high 16-bit values.

Is this documented somewhere, or did you find this by experimentation?

ranjit m.

#4 lore raw
Quoted 5 lines

Subject: Re: [PATCH] bus/pci: support segment value as address domain on Windows

Thanks for the explanation, Tal.

Quoted 8 lines

I had always been curious how Windows stores the PCIe segment (domain) number.

On VMs hosted on Hyper-V, the VF segment numbers are always in the high 16-bit values.

Is this documented somewhere, or did you find this by experimentation?

Hi Ranjit,

I didn’t find documentation on it.
I found it by experimentation on a Windows VM with several VFs using the same virtual switch, Linux VFs showed the same behavior but they are being detected using the domain value which is different.

Quoted 2 lines

ranjit m.

#5 lore raw
In reply to Tal Shnaiderman
Quoted 4 lines · Tal Shnaiderman

Right, it can happen in virtualization setups when several virtual functions can have the same BDF, e.g.:

PS > Get-NetAdapterHardwareInfo

Quoted 8 lines

Name Segment Bus Device Function Slot NumaNode PcieLinkSpeed
---- ------- --- ------ -------- ---- -------- -------------
Ethernet 0 0 10 0 Unknown

Ethernet 4                       58601   0      2        0             0       Unknown
Ethernet 5                       52956   0      2        0             0       Unknown

DPDK currently can detect either Ethernet 4 or ethernet 5 if only BDF is checked. Unix uses the Domain value, the equivalent value for Windows is Segment.

Hi Tal,

I wonder how exactly this setup can be reproduced, i.e. could you share relevant QEMU options, VMX file or some other config you're using? Patch idea and code look clear, however, I never managed to build QEMU PCIe hierarchy to see it working.

#6 lore raw
Quoted 18 lines

Subject: Re: [PATCH] bus/pci: support segment value as address domain on Windows

Quoted 1 line · Tal Shnaiderman

Right, it can happen in virtualization setups when several virtual functions

can have the same BDF, e.g.:

Quoted 4 lines

PS > Get-NetAdapterHardwareInfo

Name Segment Bus Device Function Slot NumaNode

PcieLinkSpeed

Quoted 6 lines

---- ------- --- ------ -------- ---- -------- -------------
Ethernet 0 0 10 0 Unknown

Ethernet 4                       58601   0      2        0             0       Unknown
Ethernet 5                       52956   0      2        0             0       Unknown

DPDK currently can detect either Ethernet 4 or ethernet 5 if only BDF is

checked.

Quoted 8 lines
Quoted 1 line

Unix uses the Domain value, the equivalent value for Windows is Segment.

Hi Tal,

I wonder how exactly this setup can be reproduced, i.e. could you share relevant QEMU options, VMX file or some other config you're using? Patch idea and code look clear, however, I never managed to build QEMU PCIe hierarchy to see it working.

Hi Dmitry,

I'm not sure it is relevant to all NICs but for Mellanox you can recreate it on a Hyper-V Windows VM with several SR-IOV VFs using the same virtual switch.

Acked-by on v1 1/1
#7 lore raw
In reply to Tal Shnaiderman
Quoted 13 lines · Tal Shnaiderman

Set the domain value for rte_pci_addr probing on Windows to the value of the PCI segment returned by SPDRP_BUSNUMBER.

---
  drivers/bus/pci/windows/pci.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bus/pci/windows/pci.c +0 -0
index 489aa7902a..a40acec609 100644

drivers/bus/pci/windows/pci.c get_device_pci_address(HDEVINFO dev_info, · line 202

Quoted 10 lines
drivers/bus/pci/windows/pci.c +2 -2
@@ -195,8 +195,8 @@ get_device_pci_address(HDEVINFO dev_info,
  		return -1;
  	}
 
-	addr->domain = 0;
-	addr->bus = bus_num;
+	addr->domain = bus_num >> 8;
+	addr->bus = bus_num & 0xff;
  	addr->devid = dev_and_func >> 16;
  	addr->function = dev_and_func & 0xffff;
  	return 0;
#8 lore raw

16/09/2020 20:32, Ranjit Menon:

Quoted 18 lines · Tal Shnaiderman
Quoted 8 lines

Set the domain value for rte_pci_addr probing on Windows to the value of the PCI segment returned by SPDRP_BUSNUMBER.

---

drivers/bus/pci/windows/pci.c get_device_pci_address(HDEVINFO dev_info, · line 198

Quoted 6 lines
drivers/bus/pci/windows/pci.c +2 -2
@@ -195,8 +195,8 @@ get_device_pci_address(HDEVINFO dev_info,
-	addr->domain = 0;
-	addr->bus = bus_num;
+	addr->domain = bus_num >> 8;
+	addr->bus = bus_num & 0xff;
  	addr->devid = dev_and_func >> 16;
  	addr->function = dev_and_func & 0xffff;

I was waiting for feedback from Microsoft, but never happened, so Applied, thanks

Microsoft, we need a better support for porting DPDK on Windows.