PCI Alternative Routing-ID Interpretation (ARI) capable devices
use an implied Device Number of 0 and repurpose those bits to allow
for 256 Function Numbers instead of 8.
An example of such a device is the Chelsio T580-LP-CR, which uses the
additional function numbers to provide Virtual Function (VF) features.
Below is an excerpt from the `pciconf -lvc` output for this device
when a few VFs are configured:
ppt7@pci0:5:0:21: class=0x020000 card=0x00001425 chip=0x58101425 rev=0x00 hdr=0x00
vendor = 'Chelsio Communications Inc'
device = 'T580-LP-CR Unified Wire Ethernet Controller [VF]'
class = network
subclass = ethernet
cap 10[70] = PCI-Express 2 endpoint max data 256(2048) FLR NS
link x0(x8) speed 0.0(8.0) ASPM disabled(L0s/L1)
cap 11[b0] = MSI-X supports 8 messages
Table in map 0x20[0x0], PBA in map 0x20[0x8000]
cap 05[50] = MSI supports 32 messages, 64 bit, vector masks
ecap 0001[100] = AER 2 0 fatal 0 non-fatal 0 corrected
ecap 000e[140] = ARI 1
ecap 0017[150] = TPH Requester 1
Of note: the Bus/Device/Function 5/0/21 and the ARI ecap.
Attempting to pass this through to a VM as a PCI device produces a
validation error due to the function number being out of range.
To enable use of devices that use ARI, relax the schema and validity
check for PCI addresses to permit function numbers up to 255.
Update a few tests to give coverage.
Ref:
https://pcisig.com/sites/default/files/specification_documents/ECN-alt-ri...
Signed-off-by: Ryan Moeller <ryan(a)iXsystems.com>
---
docs/schemas/basictypes.rng | 10 +---------
src/util/virpci.c | 4 ++--
tests/bhyveargv2xmldata/bhyveargv2xml-passthru.args | 2 +-
tests/bhyveargv2xmldata/bhyveargv2xml-passthru.xml | 2 +-
tests/bhyvexml2argvdata/bhyvexml2argv-passthru.args | 2 +-
tests/bhyvexml2argvdata/bhyvexml2argv-passthru.xml | 2 +-
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-passthru.xml | 2 +-
7 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index 81465273c8..03ce3f3be3 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -341,15 +341,7 @@
</choice>
</define>
<define name="pciFunc">
- <choice>
- <data type="string">
- <param name="pattern">(0x)?[0-7]</param>
- </data>
- <data type="int">
- <param name="minInclusive">0</param>
- <param name="maxInclusive">7</param>
- </data>
- </choice>
+ <ref name="uint8"/>
</define>
<define name='wwn'>
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 0b1222373e..d60cf5eff7 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1302,11 +1302,11 @@ virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
addr->slot);
return false;
}
- if (addr->function > 7) {
+ if (addr->function > 255) {
if (report)
virReportError(VIR_ERR_XML_ERROR,
_("Invalid PCI address function=0x%x, "
- "must be <= 7"),
+ "must be <= 255"),
addr->function);
return false;
}
diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-passthru.args
b/tests/bhyveargv2xmldata/bhyveargv2xml-passthru.args
index 697bafd642..726dade59e 100644
--- a/tests/bhyveargv2xmldata/bhyveargv2xml-passthru.args
+++ b/tests/bhyveargv2xmldata/bhyveargv2xml-passthru.args
@@ -5,4 +5,4 @@
-P \
-S \
-s 0:0,hostbridge \
--s 0:1:0,passthru,5/0/7 bhyve
+-s 0:1:0,passthru,5/0/9 bhyve
diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-passthru.xml
b/tests/bhyveargv2xmldata/bhyveargv2xml-passthru.xml
index af99279448..a8d7a574af 100644
--- a/tests/bhyveargv2xmldata/bhyveargv2xml-passthru.xml
+++ b/tests/bhyveargv2xmldata/bhyveargv2xml-passthru.xml
@@ -18,7 +18,7 @@
<hostdev mode='subsystem' type='pci' managed='no'>
<driver name='vmm'/>
<source>
- <address domain='0x0000' bus='0x05' slot='0x00'
function='0x7'/>
+ <address domain='0x0000' bus='0x05' slot='0x00'
function='0x9'/>
</source>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x0'/>
</hostdev>
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-passthru.args
b/tests/bhyvexml2argvdata/bhyvexml2argv-passthru.args
index c268da957c..afa99344af 100644
--- a/tests/bhyvexml2argvdata/bhyvexml2argv-passthru.args
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-passthru.args
@@ -7,5 +7,5 @@
-P \
-s 0:0,hostbridge \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE-devel.fd \
--s 0:3:0,passthru,5/0/7 \
+-s 0:3:0,passthru,5/0/9 \
-s 1,lpc bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-passthru.xml
b/tests/bhyvexml2argvdata/bhyvexml2argv-passthru.xml
index ba0744f35d..e8b3a4064f 100644
--- a/tests/bhyvexml2argvdata/bhyvexml2argv-passthru.xml
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-passthru.xml
@@ -14,7 +14,7 @@
<hostdev mode='subsystem' type='pci' managed='no'>
<driver name='vmm'/>
<source>
- <address domain='0x0000' bus='0x05' slot='0x00'
function='0x7'/>
+ <address domain='0x0000' bus='0x05' slot='0x00'
function='0x9'/>
</source>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
</hostdev>
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-passthru.xml
b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-passthru.xml
index 0313fa0dfa..7f96831df9 100644
--- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-passthru.xml
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-passthru.xml
@@ -21,7 +21,7 @@
<hostdev mode='subsystem' type='pci' managed='no'>
<driver name='vmm'/>
<source>
- <address domain='0x0000' bus='0x05' slot='0x00'
function='0x7'/>
+ <address domain='0x0000' bus='0x05' slot='0x00'
function='0x9'/>
</source>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
</hostdev>
--
2.24.1