diff --git a/sysfs/class_infiniband.go b/sysfs/class_infiniband.go index 7892c69a..deaa0a4a 100644 --- a/sysfs/class_infiniband.go +++ b/sysfs/class_infiniband.go @@ -279,8 +279,12 @@ func (fs FS) parseInfiniBandPort(name string, port string) (*InfiniBandPort, err return nil, fmt.Errorf("could not parse rate file in %q: %w", portPath, err) } - // Intel irdma module does not expose /sys/class/infiniband//ports//counters - if !strings.HasPrefix(ibp.Name, "irdma") { + // Since the HCA may have been renamed by systemd, we cannot infer the kernel driver used by the + // device, and thus do not know what type(s) of counters should be present. Attempt to parse + // either / both "counters" (and potentially also "counters_ext"), and "hw_counters", subject + // to their availability on the system - irrespective of HCA naming convention. + + if _, err := os.Stat(filepath.Join(portPath, "counters")); err == nil { counters, err := parseInfiniBandCounters(portPath) if err != nil { return nil, err @@ -288,7 +292,7 @@ func (fs FS) parseInfiniBandPort(name string, port string) (*InfiniBandPort, err ibp.Counters = *counters } - if strings.HasPrefix(ibp.Name, "irdma") || strings.HasPrefix(ibp.Name, "mlx5_") { + if _, err := os.Stat(filepath.Join(portPath, "hw_counters")); err == nil { hwCounters, err := parseInfiniBandHwCounters(portPath) if err != nil { return nil, err