Add lspci support for Enhanced Allocation Capability.
Subsystems (2)
PATCH v3 1/1 Add lspci support for Enhanced Allocation Capability.
From: David Daney <[email protected]>
The PCISIG recently added the Enhanced Allocation Capability. Decode it in lspci.
---
The specification is currently located here:
Bjorn Helgaas recently merged Linux kernel support for EA, and Cavium ThunderX processors have implemented it. This patch gives us a pretty view of the capability structure.
Changes from v1: Add and use more symbolic names. Use FLAG() macro where appropiate. Read subordinate bus number from proper offset.
Changes from v2: Reword and reformat some messages.
Thanks,
David Daney
lib/header.h | 8 +++ ls-caps.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+)
lib/header.h +8 -0
@@ -203,6 +203,7 @@#define PCI_CAP_ID_MSIX 0x11/* MSI-X */ #define PCI_CAP_ID_SATA 0x12/* Serial-ATA HBA */ #define PCI_CAP_ID_AF 0x13/* Advanced features of PCI devices integrated in PCIe root cplx */ +#define PCI_CAP_ID_EA 0x14/* Enhanced Allocation */ #define PCI_CAP_LIST_NEXT 1/* Next capability in the list */ #define PCI_CAP_FLAGS 2/* Capability defined flags (16 bits) */ #define PCI_CAP_SIZEOF 4
@@ -906,6 +907,13 @@#define PCI_SATA_HBA_BARS 4#define PCI_SATA_HBA_REG0 8 +/* Enhanced Allocation (EA) */ +#define PCI_EA_CAP_TYPE1_SECONDARY 4 +#define PCI_EA_CAP_TYPE1_SUBORDINATE 5 +/* EA Entry header */ +#define PCI_EA_CAP_ENT_WRITABLE 0x40000000/* Writable: 1 = RW, 0 = HwInit */ +#define PCI_EA_CAP_ENT_ENABLE 0x80000000/* Enable for this entry */ +/*** Definitions of extended capabilities ***/ /* Advanced Error Reporting */
ls-caps.c +156 -0
168 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 1 line
From
484344fef7e5c96c54576586ce81e6209a48b92cMon Sep 17 00:00:00 2001
From: "Sean O. Stalley" <[email protected]>
Date: Wed, 16 Dec 2015 10:31:51 -0800
Subject: [PATCH 1/1] Support region sizes that are not power-of-2
Enhanced Allocation allows PCI devices to reserve regions with DWORD granularity. Make sure lspci doesn't tuncate least significant bits of the region size.
ex: a 2000 byte region should display [size=2000] instead of [size=1K]
---
Hi David,
Here are some additional changes I think we should make to lspci in order to support EA.
The truncation problem was a simple fix.
Regions described by EA are being mislabeled as [virtual]. I spent some time today trying to write a patch that fixes this issue. I couldn't come up with a clean solution, so I just added a comment.
Let me know if you have any questions.
Thanks,
Sean
lspci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lspci.c +2 -2
@@ -336,7 +336,7 @@ show_size(pciaddr_t x)if (!x)return ;for (i =0 ; i < (sizeof (suffix) /sizeof (*suffix) -1 ); i++) { -if (x <1024 ) +if (x %1024 )break ; x /=1024 ; }
@@ -366,7 +366,7 @@ show_bases(struct device *d, int cnt)putchar ('\t' );if (pos && !flg)/* Reported by the OS, but not by the device */ { -printf ("[virtual] " ); +printf ("[virtual] " );/* could also be enhanced */ flg = pos; virtual =1 ; }
Signature · 1 line
1.9.1
Sean,
I think this is a good addition.
I don't plan on merging it into my patch, but instead think it should be applied separately
Thanks,
David Daney
Quoted 54 lines · Sean O. Stalley
From
484344fef7e5c96c54576586ce81e6209a48b92cMon Sep 17 00:00:00 2001
From: "Sean O. Stalley" <[email protected]>
Date: Wed, 16 Dec 2015 10:31:51 -0800
Subject: [PATCH 1/1] Support region sizes that are not power-of-2Enhanced Allocation allows PCI devices to reserve regions with DWORD granularity. Make sure lspci doesn't tuncate least significant bits of the region size.
ex: a 2000 byte region should display [size=2000] instead of [size=1K]
Signed-off-by Sean O. Stalley <[email protected]>---
Hi David,
Here are some additional changes I think we should make to lspci in order to support EA.
The truncation problem was a simple fix.
Regions described by EA are being mislabeled as [virtual]. I spent some time today trying to write a patch that fixes this issue. I couldn't come up with a clean solution, so I just added a comment.
Let me know if you have any questions.
Thanks,
Seanlspci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lspci.c +2
-2@@ -336,7 +336,7 @@ show_size(pciaddr_t x)if (!x)return ;for (i =0 ; i < (sizeof (suffix) /sizeof (*suffix) -1 ); i++) { -if (x <1024 ) +if (x %1024 )break ; x /=1024 ; }@@ -366,7 +366,7 @@ show_bases(struct device *d, int cnt)putchar ('\t' );if (pos && !flg)/* Reported by the OS, but not by the device */ { -printf ("[virtual] " ); +printf ("[virtual] " );/* could also be enhanced */ flg = pos; virtual =1 ; }
Hi!
Quoted 7 lines
From: David Daney <[email protected]>
The PCISIG recently added the Enhanced Allocation Capability. Decode it in lspci.
---
The specification is currently located here:
Quoted 5 lines
Bjorn Helgaas recently merged Linux kernel support for EA, and Cavium ThunderX processors have implemented it. This patch gives us a pretty view of the capability structure.
I will merge this soon.
Could you please provide a hex dump of a config space with this capability? (See the test cases in pciutils/tests/.)
Have a nice fortnight
Signature · 3 lines
Martin `MJ' Mares <[email protected]> http://mj.ucw.cz/ Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth Q: How many Prolog programmers does it take to change a light bulb? A: No.
Quoted 5 lines · Martin Mares
I will merge this soon.
Could you please provide a hex dump of a config space with this capability? (See the test cases in pciutils/tests/.)
Attached is a hex dump from a QEMU model using EA entries in leiu of BARs.
I also attached the output of lspci, so you can see how the Region fields are displayed. Note that EA memory regions get tagged as [virtual].
I attached 2 outputs to show the truncation case I was talking about [1]. lt_size is the output when (x < 1024) is used in show_size(), whereas mod_size is the output when (x % 1024) is used.
Thanks for taking a look,
Sean
[1]
diff mod_size lt_size
8c8
< Region 0: [virtual] Memory at 80000000 (32-bit, non-prefetchable) [size=131076]
---
Quoted 1 line
Region 0: [virtual] Memory at 80000000 (32-bit, non-prefetchable) [size=128K]
00:04.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 03)
Subsystem: Red Hat, Inc QEMU Virtual Machine
Physical Slot: 4
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin A routed to IRQ 11
Region 0: [virtual] Memory at 80000000 (32-bit, non-prefetchable) [size=131076] Region 1: I/O ports at 0a00 [size=68]
Capabilities: [40] Enhanced Allocation (EA): NumEntries=2
Entry 0: Enable+ Writable- EntrySize=2
BAR Equivalent Indicator: BAR 0
PrimaryProperties: memory space, non-prefetchable
SecondaryProperties: entry unavailable for use, PrimaryProperties should be used
Base: 80000000
MaxOffset: 00020003
Entry 1: Enable+ Writable- EntrySize=2
BAR Equivalent Indicator: BAR 1
PrimaryProperties: I/O space
SecondaryProperties: entry unavailable for use, PrimaryProperties should be used
Base: 00000a00
MaxOffset: 00000043
Kernel driver in use: e1000
00:04.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 03)
Subsystem: Red Hat, Inc QEMU Virtual Machine
Physical Slot: 4
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin A routed to IRQ 11
Region 0: [virtual] Memory at 80000000 (32-bit, non-prefetchable) [size=128K] Region 1: I/O ports at 0a00 [size=68]
Capabilities: [40] Enhanced Allocation (EA): NumEntries=2
Entry 0: Enable+ Writable- EntrySize=2
BAR Equivalent Indicator: BAR 0
PrimaryProperties: memory space, non-prefetchable
SecondaryProperties: entry unavailable for use, PrimaryProperties should be used
Base: 80000000
MaxOffset: 00020003
Entry 1: Enable+ Writable- EntrySize=2
BAR Equivalent Indicator: BAR 1
PrimaryProperties: I/O space
SecondaryProperties: entry unavailable for use, PrimaryProperties should be used
Base: 00000a00
MaxOffset: 00000043
Kernel driver in use: e1000
00:04.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 03) 00: 86 80 0e 10 07 01 10 00 03 00 00 02 00 00 00 00
10: 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 f4 1a 00 11
30: 00 00 00 00 40 00 00 00 00 00 00 00 0b 01 00 00
40: 14 00 02 00 02 00 ff 80 00 00 00 80 00 00 02 00
50: 12 02 ff 80 00 0a 00 00 40 00 00 00 00 00 00 00
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00