Hi,

right now i got the chance to play a little bit with PCIe. I read some
parts of the spec
and was interessted what my PCIe devices can do. I also found out that
pcidump can
not display the Enhanced Capabilites.

This patch enables pcidump to display them.

I did not find a good list of descriptions for the different
capabilities, the one im using
in this patch was taken from the linux kernel. Is it possible to get a
complete list
somewhere?

Here is an example output:
# pcidump -v
Domain /dev/pci0:
 0:0:0: Intel 82Q33 Host
        0x0000: Vendor ID: 8086 Product ID: 29d0
        0x0004: Command: 0006 Status: 2090
        0x0008: Class: 06 Subclass: 00 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR empty (00000000)
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fc
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 00 Line: 00 Min Gnt: 00 Max Lat: 00
        0x00e0: Capability 0x09: Vendor Specific
 0:1:0: Intel 82Q33 PCIE
        0x0000: Vendor ID: 8086 Product ID: 29d1
        0x0004: Command: 0104 Status: 0010
        0x0008: Class: 06 Subclass: 04 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 01 Latency Timer: 00 Cache Line Size: 08
        0x0010: 00000000
        0x0014: 00000000
        0x0018: Primary Bus: 0 Secondary Bus: 1 Subordinate Bus: 1
                Secondary Latency Timer: 00
        0x001c: I/O Base: f0 I/O Limit: 00 Secondary Status: 0000
        0x0020: Memory Base: fff0 Memory Limit: 0000
        0x0024: Prefetch Memory Base: fff1 Prefetch Memory Limit: 0001
        0x0028: Prefetch Memory Base Upper 32 Bits: 00000000
        0x002c: Prefetch Memory Limit Upper 32 Bits: 00000000
        0x0030: I/O Base Upper 16 Bits: 0000 I/O Limit Upper 16 Bits: 0000
        0x0038: Expansion ROM Base Address: 00000000
        0x003c: Interrupt Pin: 01 Line: 0b Bridge Control: 0000
        0x0088: Capability 0x0d: PCI-PCI
        0x0080: Capability 0x01: Power Management
                State: D0
        0x0090: Capability 0x05: Message Signalled Interrupts (MSI)
        0x00a0: Capability 0x10: PCI Express
                Link Speed: 2.5 / 2.5 GT/s Link Width: x0 / x16
        0x0100: Enhanced Capability 0x02: Virtual Channel Capability
        0x0140: Enhanced Capability 0x05: Root Complex Link Declaration
 0:2:0: Intel 82Q33 Video
        0x0000: Vendor ID: 8086 Product ID: 29d2
        0x0004: Command: 0007 Status: 0090
        0x0008: Class: 03 Subclass: 00 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR mem 32bit addr: 0xd0100000/0x00080000
        0x0014: BAR io addr: 0x00001c40/0x0008
        0x0018: BAR mem prefetchable 32bit addr: 0xe0000000/0x10000000
        0x001c: BAR mem 32bit addr: 0xd0000000/0x00100000
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fc
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 0b Min Gnt: 00 Max Lat: 00
        0x0090: Capability 0x05: Message Signalled Interrupts (MSI)
        0x00d0: Capability 0x01: Power Management
                State: D0
 0:26:0: Intel 82801I USB
        0x0000: Vendor ID: 8086 Product ID: 2937
        0x0004: Command: 0005 Status: 0290
        0x0008: Class: 0c Subclass: 03 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 80 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR empty (00000000)
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR io addr: 0x00001820/0x0020
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 0a Min Gnt: 00 Max Lat: 00
        0x0050: Capability 0x13: PCI Advanced Features
 0:26:1: Intel 82801I USB
        0x0000: Vendor ID: 8086 Product ID: 2938
        0x0004: Command: 0005 Status: 0290
        0x0008: Class: 0c Subclass: 03 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR empty (00000000)
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR io addr: 0x00001840/0x0020
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 02 Line: 09 Min Gnt: 00 Max Lat: 00
        0x0050: Capability 0x13: PCI Advanced Features
 0:26:2: Intel 82801I USB
        0x0000: Vendor ID: 8086 Product ID: 2939
        0x0004: Command: 0005 Status: 0290
        0x0008: Class: 0c Subclass: 03 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR empty (00000000)
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR io addr: 0x00001860/0x0020
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 03 Line: 0b Min Gnt: 00 Max Lat: 00
        0x0050: Capability 0x13: PCI Advanced Features
 0:26:7: Intel 82801I USB
        0x0000: Vendor ID: 8086 Product ID: 293c
        0x0004: Command: 0106 Status: 0290
        0x0008: Class: 0c Subclass: 03 Interface: 20 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR mem 32bit addr: 0xd0180000/0x00000400
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 02 Line: 09 Min Gnt: 00 Max Lat: 00
        0x0050: Capability 0x01: Power Management
                State: D0
        0x0058: Capability 0x0a: Debug Port
        0x0098: Capability 0x13: PCI Advanced Features
 0:28:0: Intel 82801I PCIE
        0x0000: Vendor ID: 8086 Product ID: 2940
        0x0004: Command: 0004 Status: 0010
        0x0008: Class: 06 Subclass: 04 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 81 Latency Timer: 00 Cache Line Size: 08
        0x0010: 00000000
        0x0014: 00000000
        0x0018: Primary Bus: 0 Secondary Bus: 2 Subordinate Bus: 2
                Secondary Latency Timer: 00
        0x001c: I/O Base: f0 I/O Limit: 00 Secondary Status: 2000
        0x0020: Memory Base: fff0 Memory Limit: 0000
        0x0024: Prefetch Memory Base: fff1 Prefetch Memory Limit: 0001
        0x0028: Prefetch Memory Base Upper 32 Bits: 00000000
        0x002c: Prefetch Memory Limit Upper 32 Bits: 00000000
        0x0030: I/O Base Upper 16 Bits: 0000 I/O Limit Upper 16 Bits: 0000
        0x0038: Expansion ROM Base Address: 00000000
        0x003c: Interrupt Pin: 01 Line: 09 Bridge Control: 0000
        0x0040: Capability 0x10: PCI Express
                Link Speed: 2.5 / 2.5 GT/s Link Width: x0 / x1
        0x0100: Enhanced Capability 0x02: Virtual Channel Capability
        0x0180: Enhanced Capability 0x05: Root Complex Link Declaration
        0x0080: Capability 0x05: Message Signalled Interrupts (MSI)
        0x0090: Capability 0x0d: PCI-PCI
        0x00a0: Capability 0x01: Power Management
                State: D0 PME# enabled
 0:28:4: Intel 82801I PCIE
        0x0000: Vendor ID: 8086 Product ID: 2948
        0x0004: Command: 0004 Status: 0010
        0x0008: Class: 06 Subclass: 04 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 81 Latency Timer: 00 Cache Line Size: 08
        0x0010: 00000000
        0x0014: 00000000
        0x0018: Primary Bus: 0 Secondary Bus: 3 Subordinate Bus: 3
                Secondary Latency Timer: 00
        0x001c: I/O Base: f0 I/O Limit: 00 Secondary Status: 2000
        0x0020: Memory Base: fff0 Memory Limit: 0000
        0x0024: Prefetch Memory Base: fff1 Prefetch Memory Limit: 0001
        0x0028: Prefetch Memory Base Upper 32 Bits: 00000000
        0x002c: Prefetch Memory Limit Upper 32 Bits: 00000000
        0x0030: I/O Base Upper 16 Bits: 0000 I/O Limit Upper 16 Bits: 0000
        0x0038: Expansion ROM Base Address: 00000000
        0x003c: Interrupt Pin: 02 Line: 05 Bridge Control: 0000
        0x0040: Capability 0x10: PCI Express
                Link Speed: 2.5 / 2.5 GT/s Link Width: x0 / x1
        0x0100: Enhanced Capability 0x02: Virtual Channel Capability
        0x0180: Enhanced Capability 0x05: Root Complex Link Declaration
        0x0080: Capability 0x05: Message Signalled Interrupts (MSI)
        0x0090: Capability 0x0d: PCI-PCI
        0x00a0: Capability 0x01: Power Management
                State: D0 PME# enabled
 0:28:5: Intel 82801I PCIE
        0x0000: Vendor ID: 8086 Product ID: 294a
        0x0004: Command: 0007 Status: 0010
        0x0008: Class: 06 Subclass: 04 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 81 Latency Timer: 00 Cache Line Size: 08
        0x0010: 00000000
        0x0014: 00000000
        0x0018: Primary Bus: 0 Secondary Bus: 4 Subordinate Bus: 4
                Secondary Latency Timer: 00
        0x001c: I/O Base: f0 I/O Limit: 00 Secondary Status: 6000
        0x0020: Memory Base: d020 Memory Limit: d020
        0x0024: Prefetch Memory Base: fff1 Prefetch Memory Limit: 0001
        0x0028: Prefetch Memory Base Upper 32 Bits: 00000000
        0x002c: Prefetch Memory Limit Upper 32 Bits: 00000000
        0x0030: I/O Base Upper 16 Bits: 0000 I/O Limit Upper 16 Bits: 0000
        0x0038: Expansion ROM Base Address: 00000000
        0x003c: Interrupt Pin: 03 Line: 0b Bridge Control: 0004
        0x0040: Capability 0x10: PCI Express
                Link Speed: 2.5 / 2.5 GT/s Link Width: x1 / x1
        0x0100: Enhanced Capability 0x02: Virtual Channel Capability
        0x0180: Enhanced Capability 0x05: Root Complex Link Declaration
        0x0080: Capability 0x05: Message Signalled Interrupts (MSI)
        0x0090: Capability 0x0d: PCI-PCI
        0x00a0: Capability 0x01: Power Management
                State: D0 PME# enabled
 0:29:0: Intel 82801I USB
        0x0000: Vendor ID: 8086 Product ID: 2934
        0x0004: Command: 0005 Status: 0290
        0x0008: Class: 0c Subclass: 03 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 80 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR empty (00000000)
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR io addr: 0x00001880/0x0020
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 0a Min Gnt: 00 Max Lat: 00
        0x0050: Capability 0x13: PCI Advanced Features
 0:29:1: Intel 82801I USB
        0x0000: Vendor ID: 8086 Product ID: 2935
        0x0004: Command: 0005 Status: 0290
        0x0008: Class: 0c Subclass: 03 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR empty (00000000)
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR io addr: 0x000018a0/0x0020
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 02 Line: 05 Min Gnt: 00 Max Lat: 00
        0x0050: Capability 0x13: PCI Advanced Features
 0:29:2: Intel 82801I USB
        0x0000: Vendor ID: 8086 Product ID: 2936
        0x0004: Command: 0005 Status: 0290
        0x0008: Class: 0c Subclass: 03 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR empty (00000000)
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR io addr: 0x000018c0/0x0020
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 03 Line: 0b Min Gnt: 00 Max Lat: 00
        0x0050: Capability 0x13: PCI Advanced Features
 0:29:7: Intel 82801I USB
        0x0000: Vendor ID: 8086 Product ID: 293a
        0x0004: Command: 0106 Status: 0290
        0x0008: Class: 0c Subclass: 03 Interface: 20 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR mem 32bit addr: 0xd0181000/0x00000400
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 0a Min Gnt: 00 Max Lat: 00
        0x0050: Capability 0x01: Power Management
                State: D0
        0x0058: Capability 0x0a: Debug Port
        0x0098: Capability 0x13: PCI Advanced Features
 0:30:0: Intel 82801BA Hub-to-PCI
        0x0000: Vendor ID: 8086 Product ID: 244e
        0x0004: Command: 0107 Status: 0010
        0x0008: Class: 06 Subclass: 04 Interface: 01 Revision: 92
        0x000c: BIST: 00 Header Type: 01 Latency Timer: 00 Cache Line Size: 00
        0x0010: 00000000
        0x0014: 00000000
        0x0018: Primary Bus: 0 Secondary Bus: 5 Subordinate Bus: 5
                Secondary Latency Timer: 20
        0x001c: I/O Base: f0 I/O Limit: 00 Secondary Status: 2280
        0x0020: Memory Base: fff0 Memory Limit: 0000
        0x0024: Prefetch Memory Base: fff1 Prefetch Memory Limit: 0001
        0x0028: Prefetch Memory Base Upper 32 Bits: 00000000
        0x002c: Prefetch Memory Limit Upper 32 Bits: 00000000
        0x0030: I/O Base Upper 16 Bits: 0000 I/O Limit Upper 16 Bits: 0000
        0x0038: Expansion ROM Base Address: 00000000
        0x003c: Interrupt Pin: 00 Line: ff Bridge Control: 0004
        0x0050: Capability 0x0d: PCI-PCI
 0:31:0: Intel 82801IB LPC
        0x0000: Vendor ID: 8086 Product ID: 2918
        0x0004: Command: 0007 Status: 0210
        0x0008: Class: 06 Subclass: 01 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 80 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR empty (00000000)
        0x0014: BAR empty (00000000)
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 00 Line: 00 Min Gnt: 00 Max Lat: 00
        0x00e0: Capability 0x09: Vendor Specific
 0:31:2: Intel 82801I AHCI
        0x0000: Vendor ID: 8086 Product ID: 2923
        0x0004: Command: 0007 Status: 02b0
        0x0008: Class: 01 Subclass: 06 Interface: 01 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR io addr: 0x00001c58/0x0008
        0x0014: BAR io addr: 0x00001c4c/0x0004
        0x0018: BAR io addr: 0x00001c50/0x0008
        0x001c: BAR io addr: 0x00001c48/0x0004
        0x0020: BAR io addr: 0x000018e0/0x0020
        0x0024: BAR mem 32bit addr: 0xd0182000/0x00000800
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 02 Line: 0b Min Gnt: 00 Max Lat: 00
        0x0080: Capability 0x05: Message Signalled Interrupts (MSI)
        0x0070: Capability 0x01: Power Management
                State: D0
        0x00a8: Capability 0x12: SATA
        0x00b0: Capability 0x13: PCI Advanced Features
 0:31:3: Intel 82801I SMBus
        0x0000: Vendor ID: 8086 Product ID: 2930
        0x0004: Command: 0103 Status: 0280
        0x0008: Class: 0c Subclass: 05 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR mem 64bit addr: 0x00000000d0183000/0x00000100
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR io addr: 0x00001c00/0x0020
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 02 Line: 0b Min Gnt: 00 Max Lat: 00
 0:31:6: Intel 82801I Thermal
        0x0000: Vendor ID: 8086 Product ID: 2932
        0x0004: Command: 0002 Status: 0010
        0x0008: Class: 11 Subclass: 80 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 00
        0x0010: BAR mem 64bit addr: 0x00000000d0184000/0x00001000
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fd
        0x0030: Expansion ROM Base Address: 00000000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 09 Min Gnt: 00 Max Lat: 00
        0x0050: Capability 0x01: Power Management
                State: D0
 4:0:0: Broadcom BCM5754
        0x0000: Vendor ID: 14e4 Product ID: 167a
        0x0004: Command: 0106 Status: 0010
        0x0008: Class: 02 Subclass: 00 Interface: 00 Revision: 02
        0x000c: BIST: 00 Header Type: 00 Latency Timer: 00 Cache Line Size: 08
        0x0010: BAR mem 64bit addr: 0x00000000d0200000/0x00010000
        0x0018: BAR empty (00000000)
        0x001c: BAR empty (00000000)
        0x0020: BAR empty (00000000)
        0x0024: BAR empty (00000000)
        0x0028: Cardbus CIS: 00000000
        0x002c: Subsystem Vendor ID: 1734 Product ID: 10fe
        0x0030: Expansion ROM Base Address: 10790000
        0x0038: 00000000
        0x003c: Interrupt Pin: 01 Line: 0b Min Gnt: 00 Max Lat: 00
        0x0048: Capability 0x01: Power Management
                State: D0 PME# enabled
        0x0050: Capability 0x03: Vital Product Data (VPD)
        0x0058: Capability 0x09: Vendor Specific
        0x00e8: Capability 0x05: Message Signalled Interrupts (MSI)
        0x00d0: Capability 0x10: PCI Express
                Link Speed: 2.5 / 2.5 GT/s Link Width: x1 / x1
        0x0100: Enhanced Capability 0x01: Advanced Error Reporting
        0x013c: Enhanced Capability 0x02: Virtual Channel Capability
        0x0160: Enhanced Capability 0x03: Device Serial Number
        0x016c: Enhanced Capability 0x04: Power Budgeting

Patch:
Index: sys/dev/pci/pcireg.h
==================================================================
--- sys/dev/pci/pcireg.h
+++ sys/dev/pci/pcireg.h
@@ -591,10 +591,19 @@
 #define PCI_PCIE_SLCSR_PDS     0x00400000
 #define PCI_PCIE_SLCSR_LACS    0x01000000
 #define PCI_PCIE_RCSR          0x1c
 #define PCI_PCIE_LCAP2         0x2c

+/*
+ * PCI Express; enhanced capabilities
+ */
+#define PCI_PCIE_ECAP          0x100
+#define        PCI_PCIE_ECAP_ID(x)     (((x) & 0x0000ffff))
+#define PCI_PCIE_ECAP_VER(x)   (((x) >> 16) & 0x0f)
+#define        PCI_PCIE_ECAP_NEXT(x)   ((x) >> 20)
+#define PCI_PCIE_ECAP_LAST     0x0
+
 /*
  * Extended Message Signaled Interrups; access via capability pointer.
  */
 #define PCI_MSIX_MC_MSIXE      0x80000000
 #define PCI_MSIX_MC_TBLSZ_MASK 0x07ff0000

Index: usr.sbin/pcidump/pcidump.c
==================================================================
--- usr.sbin/pcidump/pcidump.c
+++ usr.sbin/pcidump/pcidump.c
@@ -99,10 +99,43 @@
        "PCI Express",
        "Extended Message Signalled Interrupts (MSI-X)",
        "SATA",
        "PCI Advanced Features"
 };
+
+const char *pci_enhanced_capnames[] = {
+       "Unknown",
+       "Advanced Error Reporting",
+       "Virtual Channel Capability",
+       "Device Serial Number",
+       "Power Budgeting",
+       "Root Complex Link Declaration",
+       "Root Complex Internal Link Control",
+       "Root Complex Event Collector",
+       "Multi-Function VC Capability",
+       "Virtual Channel Capability",
+       "Root Complex/Root Bridge",
+       "Vendor-Specific",
+       "Config Access",
+       "Access Control Services",
+       "Alternate Routing ID",
+       "Address Translation Services",
+       "Single Root I/O Virtualization",
+       "Multi Root I/O Virtualization",
+       "Multicast",
+       "Page Request Interface",
+       "Reserved for AMD",
+       "Resizable BAR",
+       "Dynamic Power Allocation",
+       "TPH Requester",
+       "Latency Tolerance Reporting",
+       "Secondary PCIe Capability",
+       "Protocol Multiplexing",
+       "Process Address Space ID",
+       "Downstream Port Containment",
+       "Precision Time Measurement",
+};

 int
 main(int argc, char *argv[])
 {
        int nfuncs;
@@ -352,10 +385,39 @@
        printf(" / ");
        print_pcie_ls(cspeed);

        printf(" GT/s Link Width: x%d / x%d\n", swidth, cwidth);
 }
+
+void
+dump_pcie_ehanced_caplist(int bus, int dev, int func)
+{
+       u_int32_t reg;
+       u_int16_t ptr;
+       u_int16_t ecap;
+
+       ptr = PCI_PCIE_ECAP;
+
+       do {
+               if (pci_read(bus, dev, func, ptr, &reg) != 0)
+                       return;
+
+               if (PCI_PCIE_ECAP_ID(reg) == 0xffff &&
+                   PCI_PCIE_ECAP_NEXT(reg) == PCI_PCIE_ECAP_LAST)
+                       return;
+
+               ecap = PCI_PCIE_ECAP_ID(reg);
+               if (ecap >= nitems(pci_enhanced_capnames))
+                       ecap = 0;
+
+               printf("\t0x%04x: Enhanced Capability 0x%02x: ", ptr, ecap);
+               printf("%s\n", pci_enhanced_capnames[ecap]);
+
+               ptr = PCI_PCIE_ECAP_NEXT(reg);
+
+       } while (ptr != PCI_PCIE_ECAP_LAST);
+}

 void
 dump_caplist(int bus, int dev, int func, u_int8_t ptr)
 {
        u_int32_t reg;
@@ -377,12 +439,14 @@
                if (cap >= nitems(pci_capnames))
                        cap = 0;
                printf("%s\n", pci_capnames[cap]);
                if (cap == PCI_CAP_PWRMGMT)
                        dump_pci_powerstate(bus, dev, func, ptr);
-               if (cap == PCI_CAP_PCIEXPRESS)
+               if (cap == PCI_CAP_PCIEXPRESS) {
                        dump_pcie_linkspeed(bus, dev, func, ptr);
+                       dump_pcie_ehanced_caplist(bus, dev, func);
+               }
                ptr = PCI_CAPLIST_NEXT(reg);
        }
 }

 void

Reply via email to