Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infiniband: support Intel irdma devices #605

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions sysfs/class_infiniband.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,16 @@ func (fs FS) parseInfiniBandPort(name string, port string) (*InfiniBandPort, err
return nil, fmt.Errorf("could not parse rate file in %q: %w", portPath, err)
}

counters, err := parseInfiniBandCounters(portPath)
if err != nil {
return nil, err
// Intel irdma module does not expose /sys/class/infiniband/<device>/ports/<port-num>/counters
if !strings.HasPrefix(ibp.Name, "irdma") {
counters, err := parseInfiniBandCounters(portPath)
if err != nil {
return nil, err
}
ibp.Counters = *counters
}
ibp.Counters = *counters

if strings.Contains(ibp.Name, "mlx5") {
if strings.HasPrefix(ibp.Name, "irdma") || strings.HasPrefix(ibp.Name, "mlx5_") {
hwCounters, err := parseInfiniBandHwCounters(portPath)
if err != nil {
return nil, err
Expand All @@ -296,6 +299,9 @@ func (fs FS) parseInfiniBandPort(name string, port string) (*InfiniBandPort, err
return &ibp, nil
}

// parseInfiniBandCounters parses the counters exposed under
// /sys/class/infiniband/<device>/ports/<port-num>/counters, which first appeared in kernel v2.6.12.
// Prior to kernel v4.5, 64-bit counters were exposed separately under the "counters_ext" directory.
func parseInfiniBandCounters(portPath string) (*InfiniBandCounters, error) {
var counters InfiniBandCounters

Expand Down Expand Up @@ -393,7 +399,7 @@ func parseInfiniBandCounters(portPath string) (*InfiniBandCounters, error) {
}
}

// Parse legacy counters
// Parse pre-kernel-v4.5 64-bit counters.
path = filepath.Join(portPath, "counters_ext")
files, err = os.ReadDir(path)
if err != nil && !os.IsNotExist(err) {
Expand Down Expand Up @@ -457,6 +463,8 @@ func parseInfiniBandCounters(portPath string) (*InfiniBandCounters, error) {
return &counters, nil
}

// parseInfiniBandHwCounters parses the optional counters exposed under
// /sys/class/infiniband/<device>/ports/<port-num>/hw_counters, which first appeared in kernel v4.6.
func parseInfiniBandHwCounters(portPath string) (*InfiniBandHwCounters, error) {
var hwCounters InfiniBandHwCounters

Expand Down
Loading