diff --git a/sysfs/class_infiniband.go b/sysfs/class_infiniband.go index 89478f93..30d1d3f0 100644 --- a/sysfs/class_infiniband.go +++ b/sysfs/class_infiniband.go @@ -280,8 +280,11 @@ 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 and Broadcom RoCE does not expose /sys/class/infiniband//ports//counters - if !strings.HasPrefix(ibp.Name, "irdma") && !strings.HasPrefix(ibp.Name, "bnxt_re") { + // 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 @@ -289,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