From 315af1718028f3e2af66f414396bd5ed5d56f7f8 Mon Sep 17 00:00:00 2001 From: Diego Sonaglia Date: Wed, 2 Oct 2024 14:17:06 +0200 Subject: [PATCH] Add node_guid to infiniband class (#665) --- sysfs/class_infiniband.go | 5 ++++- sysfs/class_infiniband_test.go | 1 + testdata/fixtures.ttar | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sysfs/class_infiniband.go b/sysfs/class_infiniband.go index 7892c69a..39c97a26 100644 --- a/sysfs/class_infiniband.go +++ b/sysfs/class_infiniband.go @@ -124,6 +124,7 @@ type InfiniBandDevice struct { Name string BoardID string // /sys/class/infiniband//board_id FirmwareVersion string // /sys/class/infiniband//fw_ver + NodeGUID string // /sys/class/infiniband//node_guid HCAType string // /sys/class/infiniband//hca_type Ports map[uint]InfiniBandPort } @@ -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 { @@ -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 } } diff --git a/sysfs/class_infiniband_test.go b/sysfs/class_infiniband_test.go index 461e2805..c61e8bfb 100644 --- a/sysfs/class_infiniband_test.go +++ b/sysfs/class_infiniband_test.go @@ -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", diff --git a/testdata/fixtures.ttar b/testdata/fixtures.ttar index f2bd5e56..9f05da58 100644 --- a/testdata/fixtures.ttar +++ b/testdata/fixtures.ttar @@ -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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -