Skip to content

sysfs: add PCIe AER counters and Root Port AER totals to PciDevice - #888

Open
lpneyon wants to merge 2 commits into
prometheus:masterfrom
lpneyon:pcie-aer
Open

lpneyon wants to merge 2 commits into
prometheus:masterfrom
lpneyon:pcie-aer

Conversation

@lpneyon

@lpneyon lpneyon commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What

Two commits, both adding optional fields to PciDevice. Every field is nil when the kernel does not create the file:

  1. Per-device AER counters: AerCorrectable, AerFatal and AerNonFatal, parsed from aer_dev_correctable, aer_dev_fatal and aer_dev_nonfatal under /sys/bus/pci/devices/<BDF>/.
  2. Root Port AER totals: AerRootPortTotalErrCor, AerRootPortTotalErrFatal and AerRootPortTotalErrNonFatal, parsed from aer_rootport_total_err_{cor,fatal,nonfatal}. The kernel creates these only on AER-capable Root Ports. They count every error reported to the port by the devices below it.

Why

AER parsing already exists, but it is only reachable through /sys/class/net/<iface>/device. GPUs, NVMe drives and InfiniBand HCAs have no net-class entry, so procfs cannot read their AER counters today. A rising correctable count is often the first sign of a degrading PCIe link, before the device drops off the bus.

Implementation

  • The two file parsers in net_class_aer.go now take a file path and report whether the file existed. The existing net-class functions are thin wrappers around them, so their behaviour is unchanged.
  • The Root Port totals follow the pattern parsePciDevice already uses for optional files, such as SR-IOV and power management.

If you would rather keep PciDevices() to its current reads and expose AER through methods, as in #887, I am happy to rework it that way.

Testing

  • TestPciDevices covers four cases: a device with non-zero AER counters, one with all-zero counters, one with no AER files, and Root Port totals on 0000:00:02.1.
  • TestAerCounters is updated, because enp3s0f0 points at the 0000:a2:00.0 fixture, which now has non-zero values.
  • go test ./... passes, and golangci-lint v2.14.0 reports 0 issues.
  • Tested end to end on Linux 7.3 in QEMU (Ubuntu 26.10 guest, OS-native AER through _OSC). I injected 2 receiver errors, 1 bad TLP and 1 completion timeout into a pcie-root-port with pcie_aer_inject_error. The parsed values matched the kernel's counters exactly: RxErr 2, BadTLP 1 and CmpltTO 1, with Root Port totals of 3 correctable and 1 non-fatal.
  • Not yet tested on physical hardware. QEMU's e1000e and igb cannot report AER upstream, because their Device Control error-reporting bits are read-only. So errors reported by an endpoint below a port were not covered.

Ref: Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats

Parse aer_dev_correctable, aer_dev_fatal and aer_dev_nonfatal for every
PCI device under /sys/bus/pci/devices, exposing them as the optional
AerCorrectable, AerFatal and AerNonFatal fields. They are nil when the
kernel does not expose AER statistics for a device.

AER parsing was previously only reachable through network interfaces
(/sys/class/net/<iface>/device). The file parsers are refactored to take
a file path so both callers share them; the net class behaviour is
unchanged.

Signed-off-by: Lakshmi Pradeep <lakshmi.pradeep@neyon.ai>
Parse aer_rootport_total_err_cor, aer_rootport_total_err_fatal and
aer_rootport_total_err_nonfatal into the optional
AerRootPortTotalErrCor, AerRootPortTotalErrFatal and
AerRootPortTotalErrNonFatal fields. The kernel creates these files only
on AER-capable PCIe Root Ports, where they count every error reported
to the port by the devices below it; the fields are nil elsewhere.

Signed-off-by: Lakshmi Pradeep <lakshmi.pradeep@neyon.ai>
@SuperQ

SuperQ commented Oct 22, 2026

Copy link
Copy Markdown
Member

Please do not tag mention maintainers directly. We have a number of maintainers and review as soon as we can. Direct pings are unnecessary and somewhat rude.

@lpneyon

lpneyon commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, didn't mean to be rude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants