From aaa19498e194368c80f2b12b7f380c911f98d9cc Mon Sep 17 00:00:00 2001 From: Swapnil Ingle Date: Thu, 27 May 2021 13:49:57 +0200 Subject: Fix struct pxcap (#534) * Added missing reserved bits and renamed per to rer nameing as the nvme specs * Add pxcap capability in lspci test Signed-off-by: Swapnil Ingle Reviewed-by: John Levon --- include/pci_caps/px.h | 7 ++++--- samples/lspci.c | 5 ++++- test/lspci.expected.out.1 | 4 ++-- test/lspci.expected.out.2 | 4 ++-- test/lspci.expected.out.3 | 4 ++-- test/py/test_pci_caps.py | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/pci_caps/px.h b/include/pci_caps/px.h index 4c77746..86cd1b3 100644 --- a/include/pci_caps/px.h +++ b/include/pci_caps/px.h @@ -58,12 +58,13 @@ struct pxdcap { uint32_t etfs:1; uint32_t l0sl:3; uint32_t l1l:3; - uint32_t per:1; - uint32_t res1:2; + uint32_t res1:3; + uint32_t rer:1; + uint32_t res2:2; uint32_t csplv:8; uint32_t cspls:2; uint32_t flrc:1; - uint32_t res2:3; + uint32_t res3:3; } __attribute__((packed)); _Static_assert(sizeof(struct pxdcap) == 0x4, "bad PXDCAP size"); diff --git a/samples/lspci.c b/samples/lspci.c index 1a25ff6..010cd7a 100644 --- a/samples/lspci.c +++ b/samples/lspci.c @@ -50,7 +50,10 @@ int main(void) .sn_hi = 0xcafebabe }; struct pmcap pm = { .hdr.id = PCI_CAP_ID_PM, .pmcs.nsfrst = 0x1 }; /* Required for lspci to report extended caps. */ - struct pxcap px = { .hdr.id = PCI_CAP_ID_EXP }; + struct pxcap px = { + .hdr.id = PCI_CAP_ID_EXP, + .pxdcap = {.flrc = 0x1} + }; vfu_ctx_t *vfu_ctx = vfu_create_ctx(VFU_TRANS_SOCK, "", LIBVFIO_USER_FLAG_ATTACH_NB, NULL, diff --git a/test/lspci.expected.out.1 b/test/lspci.expected.out.1 index b01456a..300bc83 100644 --- a/test/lspci.expected.out.1 +++ b/test/lspci.expected.out.1 @@ -13,9 +13,9 @@ Capabilities: [48] Vendor Specific Information: Len=10 Capabilities: [58] Express (v0) Endpoint, MSI 00 DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us - ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset- SlotPowerLimit 0.000W + ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+ SlotPowerLimit 0.000W DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported- - RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- + RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset- MaxPayload 128 bytes, MaxReadReq 128 bytes DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend- LnkCap: Port #0, Speed unknown, Width x0, ASPM not supported, Exit Latency L0s <64ns, L1 <1us diff --git a/test/lspci.expected.out.2 b/test/lspci.expected.out.2 index fc1abf6..0cde25c 100644 --- a/test/lspci.expected.out.2 +++ b/test/lspci.expected.out.2 @@ -13,9 +13,9 @@ Capabilities: [48] Vendor Specific Information: Len=10 Capabilities: [58] Express (v0) Endpoint, MSI 00 DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us - ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset- SlotPowerLimit 0.000W + ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+ SlotPowerLimit 0.000W DevCtl: CorrErr- NonFatalErr- FatalErr- UnsupReq- - RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- + RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset- MaxPayload 128 bytes, MaxReadReq 128 bytes DevSta: CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr- TransPend- LnkCap: Port #0, Speed unknown, Width x0, ASPM not supported diff --git a/test/lspci.expected.out.3 b/test/lspci.expected.out.3 index 4547644..d94cee3 100644 --- a/test/lspci.expected.out.3 +++ b/test/lspci.expected.out.3 @@ -13,9 +13,9 @@ Capabilities: [48] Vendor Specific Information: Len=10 Capabilities: [58] Express (v0) Endpoint, MSI 00 DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us - ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset- SlotPowerLimit 0.000W + ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset+ SlotPowerLimit 0.000W DevCtl: CorrErr- NonFatalErr- FatalErr- UnsupReq- - RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- + RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset- MaxPayload 128 bytes, MaxReadReq 128 bytes DevSta: CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr- TransPend- LnkCap: Port #0, Speed unknown, Width x0, ASPM not supported diff --git a/test/py/test_pci_caps.py b/test/py/test_pci_caps.py index d510727..88a9b7c 100644 --- a/test/py/test_pci_caps.py +++ b/test/py/test_pci_caps.py @@ -309,7 +309,7 @@ def test_pci_cap_write_px(): #flrc cap = struct.pack("ccHHcc52c", to_byte(PCI_CAP_ID_EXP), b'\0', 0, 0, b'\0', - b'\x02', *[b'\0' for _ in range(52)]) + b'\x10', *[b'\0' for _ in range(52)]) pos = vfu_pci_add_capability(ctx, pos=cap_offsets[5], flags=0, data=cap) assert pos == cap_offsets[5] -- cgit v1.1