rdmamap

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 13 Imported by: 16

README

License Go Report Card Build Status Coverage Status

rdmamap

This is golang package that provides map of rdma device with its character and network devices.

It uses sysfs and netlink interfaces provided by kernel to perform this mapping.

Local build and test

You can use go get command:

go get github.com/Mellanox/rdmamap

Example:

package main

import (
    "fmt"
    "github.com/Mellanox/rdmamap"
)

func main() {
	rdmaDevices := rdmamap.GetRdmaDeviceList()
	fmt.Println("Devices: ", rdmaDevices)
  
	for _, dev := range rdmaDevices {
		charDevices := rdmamap.GetRdmaCharDevices(dev)
		fmt.Printf("Rdma device: = %s", dev)
		fmt.Println(" Char devices: = ", charDevices)
	}
}

Documentation

Index

Constants

View Source
const (
	RdmaClassName     = "infiniband"
	RdmaClassDir      = "/sys/class/infiniband"
	RdmaIbUcmDir      = "/sys/class/infiniband_cm"
	RdmaUcmFilePrefix = "ucm"

	RdmaUmadDir        = "/sys/class/infiniband_mad"
	RdmaIssmFilePrefix = "issm"
	RdmaUmadFilxPrefix = "umad"

	RdmaUverbsDir        = "/sys/class/infiniband_verbs"
	RdmaUverbsFilxPrefix = "uverbs"

	RdmaGidAttrDir     = "gid_attrs" //nolint:stylecheck,golint
	RdmaGidAttrNdevDir = "ndevs"     //nolint:stylecheck,golint
	RdmaPortsdir       = "ports"

	RdmaNodeGuidFile = "node_guid" //nolint:stylecheck,golint
	RdmaUcmDevice    = "/dev/infiniband/rdma_cm"
	RdmaDeviceDir    = "/dev/infiniband"

	RdmaCountersDir   = "counters"
	RdmaHwCountersDir = "hw_counters"

	PciDevDir = "/sys/bus/pci/devices"
	AuxDevDir = "/sys/bus/auxiliary/devices"
)

Variables

This section is empty.

Functions

func GetDockerContainerRdmaStats

func GetDockerContainerRdmaStats(containerID string)

Get RDMA statistics of a docker container. containerID is prefixed matched against the running docker containers, so a non ambiguous short identifier can be supplied as well.

func GetPorts

func GetPorts(rdmaDeviceName string) []string

Gets a list of ports for a specified device

func GetRdmaCharDevices

func GetRdmaCharDevices(rdmaDeviceName string) []string

Returns a list of character device absolute path for a requested rdmaDeviceName. Returns nil if no character devices are found.

func GetRdmaDeviceForNetdevice

func GetRdmaDeviceForNetdevice(netdevName string) (string, error)

Get RDMA device for the netdevice

func GetRdmaDeviceList

func GetRdmaDeviceList() []string

Returns a list of rdma device names

func GetRdmaDevicesForAuxdev added in v1.1.0

func GetRdmaDevicesForAuxdev(deviceID string) []string

Get list of RDMA devices for an auxiliary device. When switchdev mode is used, there may be more than one rdma device. Example deviceID: mlx5_core.sf.4, when found, returns list of devices one or more devices names such as mlx5_0, mlx5_10

func GetRdmaDevicesForPcidev

func GetRdmaDevicesForPcidev(pcidevName string) []string

Get list of RDMA devices for a pci device. When switchdev mode is used, there may be more than one rdma device. Example pcidevName: 0000:05:00.0, when found, returns list of devices one or more devices names such as mlx5_0, mlx5_10

func IsRDmaDeviceForNetdevice

func IsRDmaDeviceForNetdevice(netdevName string) bool

Returns true if rdma device exist for netdevice, else false

Types

type RdmaPortStats

type RdmaPortStats struct {
	HwStats []RdmaStatEntry /* /sys/class/infiniband/<dev>/<port>/hw_counters */
	Stats   []RdmaStatEntry /* /sys/class/infiniband/<dev>/<port>/counters */
	Port    int
}

func GetRdmaSysfsAllStats

func GetRdmaSysfsAllStats(rdmaDevice string, port int) (RdmaPortStats, error)

Get RDMA sysfs starts from counter and hw_counters directory for a requested port of a device.

type RdmaStatEntry

type RdmaStatEntry struct {
	Name  string
	Value uint64
}

func GetRdmaSysfsHwStats

func GetRdmaSysfsHwStats(rdmaDevice string, port int) ([]RdmaStatEntry, error)

Get RDMA Sysfs stats from hw_counters directory of a port of a rdma device Port number starts from 1.

func GetRdmaSysfsStats

func GetRdmaSysfsStats(rdmaDevice string, port int) ([]RdmaStatEntry, error)

Get RDMA Sysfs stats from counters directory of a port of a rdma device Port number starts from 1.

type RdmaStats

type RdmaStats struct {
	PortStats []RdmaPortStats
}

func GetRdmaSysfsAllPortsStats

func GetRdmaSysfsAllPortsStats(rdmaDevice string) (RdmaStats, error)

Get RDMA sysfs starts from counter and hw_counters directory for a rdma device.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL