Skip to content

Commit

Permalink
Add node_guid to infiniband class (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
di3go-sona committed Oct 2, 2024
1 parent 54b2b56 commit 315af17
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sysfs/class_infiniband.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ type InfiniBandDevice struct {
Name string
BoardID string // /sys/class/infiniband/<Name>/board_id
FirmwareVersion string // /sys/class/infiniband/<Name>/fw_ver
NodeGUID string // /sys/class/infiniband/<Name>/node_guid
HCAType string // /sys/class/infiniband/<Name>/hca_type
Ports map[uint]InfiniBandPort
}
Expand Down Expand Up @@ -171,7 +172,7 @@ func (fs FS) parseInfiniBandDevice(name string) (*InfiniBandDevice, error) {
device.FirmwareVersion = value

// Not all InfiniBand drivers expose all of these.
for _, f := range [...]string{"board_id", "hca_type"} {
for _, f := range [...]string{"board_id", "hca_type", "node_guid"} {
name := filepath.Join(path, f)
value, err := util.SysReadFile(name)
if err != nil {
Expand All @@ -186,6 +187,8 @@ func (fs FS) parseInfiniBandDevice(name string) (*InfiniBandDevice, error) {
device.BoardID = value
case "hca_type":
device.HCAType = value
case "node_guid":
device.NodeGUID = value
}
}

Expand Down
1 change: 1 addition & 0 deletions sysfs/class_infiniband_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func TestInfiniBandClass(t *testing.T) {
BoardID: "SM_2001000001034",
FirmwareVersion: "14.28.2006",
HCAType: "MT4118",
NodeGUID: "0a7f:bc12:45ef:d23b",
Ports: map[uint]InfiniBandPort{
1: {
Name: "mlx5_0",
Expand Down
5 changes: 5 additions & 0 deletions testdata/fixtures.ttar
Original file line number Diff line number Diff line change
Expand Up @@ -5525,6 +5525,11 @@ Lines: 1
MT4118
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: fixtures/sys/class/infiniband/mlx5_0/node_guid
Lines: 1
0a7f:bc12:45ef:d23bEOF
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: fixtures/sys/class/infiniband/mlx5_0/ports
Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down

0 comments on commit 315af17

Please sign in to comment.