Skip to content

Commit

Permalink
infiniband: do not make assumptions about counters based on HCA name
Browse files Browse the repository at this point in the history
Some users have reported cases of systemd "predictable network interface
naming" apparently also renaming the HCA device. This means we can no
longer make assumptions about which counter(s) should be present based
on the HCA name (i.e., irdma*, mlx5_*). The previous approach was quite
brittle anyway, since there will undoubtedly be other IB / RoCE drivers
in future which implement the hw_counters directory (but not the older
counters directory).

Signed-off-by: Daniel Swarbrick <[email protected]>
  • Loading branch information
dswarbrick committed Oct 18, 2024
1 parent 54b2b56 commit c02f2d5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sysfs/class_infiniband.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,20 @@ 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/<device>/ports/<port-num>/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
}
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
Expand Down

0 comments on commit c02f2d5

Please sign in to comment.