@@ -121,16 +121,24 @@ func (fs FS) InfiniBandClass() (InfiniBandClass, error) {
121121}
122122
123123// Parse one InfiniBand device.
124+ // Refer to https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-class-infiniband
124125func (fs FS ) parseInfiniBandDevice (name string ) (* InfiniBandDevice , error ) {
125126 path := fs .sys .Path (infinibandClassPath , name )
126127 device := InfiniBandDevice {Name : name }
127128
128- for _ , f := range [... ]string {"board_id" , "fw_ver" , "hca_type" } {
129+ // fw_ver is exposed by all InfiniBand drivers since kernel version 4.10.
130+ value , err := util .SysReadFile (filepath .Join (path , "fw_ver" ))
131+ if err != nil {
132+ return nil , fmt .Errorf ("failed to read HCA firmware version: %w" , err )
133+ }
134+ device .FirmwareVersion = value
135+
136+ // Not all InfiniBand drivers expose all of these.
137+ for _ , f := range [... ]string {"board_id" , "hca_type" } {
129138 name := filepath .Join (path , f )
130139 value , err := util .SysReadFile (name )
131140 if err != nil {
132- // Not all InfiniBand drivers provide hca_type.
133- if os .IsNotExist (err ) && (f == "hca_type" ) {
141+ if os .IsNotExist (err ) {
134142 continue
135143 }
136144 return nil , fmt .Errorf ("failed to read file %q: %w" , name , err )
@@ -139,8 +147,6 @@ func (fs FS) parseInfiniBandDevice(name string) (*InfiniBandDevice, error) {
139147 switch f {
140148 case "board_id" :
141149 device .BoardID = value
142- case "fw_ver" :
143- device .FirmwareVersion = value
144150 case "hca_type" :
145151 device .HCAType = value
146152 }
0 commit comments