Skip to content

pci: expose more sysfs metadata on Device for tree walks - #463

Merged
jaypipes merged 1 commit into
jaypipes:mainfrom
dims:rdma-topo-features
May 13, 2026
Merged

jaypipes merged 1 commit into
jaypipes:mainfrom
dims:rdma-topo-features

Conversation

@dims

@dims dims commented May 12, 2026

Copy link
Copy Markdown
Contributor

Adds the per-device information callers need to walk the PCI tree and inspect each node beyond vendor / product / class identifiers:

  • Modalias - raw modalias string from sysfs
  • Parent/Children - resolved *Device pointers, built after
    enumeration; ParentAddress remains the
    serialized form
  • VPD() - lazy reader for /sys/.../vpd with a TLV parser
    handling the 0x82 / 0x90 / 0x91 / 0x78 large
    resource tags and PN / EC / SN / V0-VZ
    keywords
  • Subsystems() - per-device map of subsystem kind to
    registered device names for
    drm / infiniband / net / nvme
  • SetVPD() - test seam to pre-populate the VPD cache

Tests cover the VPD parser via in-memory byte fixtures, and exercise Modalias / Parent pointer / NVMe Subsystems against the existing linux-amd64-intel-i7-1270P snapshot.

@jaypipes

Copy link
Copy Markdown
Owner

Well hello there @dims! :) thanks very much for the contribution, sir!

@dims

dims commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

Well hello there @dims! :) thanks very much for the contribution, sir!

Hello my dear friend :)

@jaypipes jaypipes left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dims for the great submission! Left a few comments inline for you to have a look at :)

Comment thread pkg/pci/vpd_linux.go Resolved
Comment thread pkg/pci/pci_linux.go Resolved
Comment thread pkg/pci/pci.go Resolved
Comment thread pkg/pci/pci.go Resolved
Comment thread pkg/pci/pci_linux.go Resolved
Comment thread pkg/pci/subsystems.go Resolved
Comment thread pkg/pci/subsystems.go Resolved
Comment thread pkg/pci/vpd.go Resolved
Comment thread pkg/pci/vpd.go Resolved
Comment thread pkg/pci/vpd_linux.go Resolved
@dims

dims commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

Done @jaypipes !

@dims
dims force-pushed the rdma-topo-features branch from ccc0662 to 21a9b13 Compare May 13, 2026 01:35
@dims dims changed the title [WIP] pci: expose more sysfs metadata on Device for tree walks pci: expose more sysfs metadata on Device for tree walks May 13, 2026

@jaypipes jaypipes left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesomesauce, thank you so much @dims! :)

Comment thread pkg/pci/pci_linux.go Resolved
Adds the per-device information callers need to walk the PCI tree
and inspect each node beyond vendor / product / class identifiers:

  * Modalias        - raw modalias string from sysfs
  * Parent/Children - resolved *Device pointers, built after
                      enumeration; ParentAddress remains the
                      serialized form
  * VPD()           - lazy reader for /sys/.../vpd with a TLV parser
                      handling the 0x82 / 0x90 / 0x91 / 0x78 large
                      resource tags and PN / EC / SN / V0-VZ
                      keywords
  * DeviceNamesByLinuxSystem(ctx, dev) - free function returning
                      a map of linux system kind (drm / infiniband /
                      net / nvme) to the device names registered
                      under that kind, with a non-Linux stub

The Linux-specific reader and parser live in vpd_linux.go; pci_stub.go
carries minimal type and method stubs so non-Linux still compiles
against the same Device struct.

Tests cover the VPD parser via in-memory byte fixtures, and exercise
Modalias / Parent pointer / DeviceNamesByLinuxSystem against the
existing linux-amd64-intel-i7-1270P snapshot.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
@dims
dims force-pushed the rdma-topo-features branch from 0049662 to a770a47 Compare May 13, 2026 17:36
@dims

dims commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

@jaypipes tested in a couple of boxes. please trigger workflows again

@jaypipes
jaypipes merged commit ea9e990 into jaypipes:main May 13, 2026
15 checks passed
dims added a commit to dims/rdma_topo that referenced this pull request May 13, 2026
PR jaypipes/ghw#463 ("pci: expose more sysfs metadata on Device for
tree walks") has landed, so the local replace directive pointing at
~/go/src/github.com/jaypipes/ghw-rdma-topo is no longer needed.

Pin ghw to the pseudo-version for merge commit ea9e990; switch to a
tagged release once one is cut that contains the merge.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
@dims

dims commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

thanks @jaypipes !

FYI, was prototyping something https://github.com/dims/rdma_topo

context: kubernetes-sigs/dra-driver-nvidia-gpu#1123 (comment)

@jaypipes

Copy link
Copy Markdown
Owner

FYI, was prototyping something https://github.com/dims/rdma_topo

I think that might be a private repo? :)

@dims

dims commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

I think that might be a private repo? :)

public now!

@dims

dims commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

@jaypipes if you see something that can belong to this repo from there, please let me know and i'll open another PR

dims added a commit to dims/ghw that referenced this pull request May 14, 2026
PR jaypipes#463 exposed Parent and Children pointers on pci.Device so
callers can walk the tree. Anything non-trivial consuming those
fields ends up reinventing the same three traversals.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
dims added a commit to dims/rdma_topo that referenced this pull request May 14, 2026
PR jaypipes/ghw#463 ("pci: expose more sysfs metadata on Device for
tree walks") has landed, so the local replace directive pointing at
~/go/src/github.com/jaypipes/ghw-rdma-topo is no longer needed.

Pin ghw to the pseudo-version for merge commit ea9e990; switch to a
tagged release once one is cut that contains the merge.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
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