lib/Kernel/hca.pm

SYNOPSIS

Helpers for InfiniBand and RDMA Host Channel Adapters (HCAs), for example Mellanox/NVIDIA ConnectX adapters with the mlx5 driver.

The helpers read the RDMA devices from /sys/class/infiniband, so they do not need ibv_devinfo or other packages. Only get_hca_model() uses lspci.

for my $dev (get_hca_devices()) {
    my $info = get_hca_info($dev);
    my $ports = get_hca_ports($dev);
    record_info("HCA $dev", "fw: $info->{fw_ver}\nmodel: " . get_hca_model($dev));
}

get_hca_devices

my @devs = get_hca_devices();

Returns the names of the RDMA devices in /sys/class/infiniband, for example mlx5_0 and mlx5_1, sorted. Returns an empty list if there is no RDMA device, for example if the driver is not loaded.

get_hca_info

my $info = get_hca_info($dev);

Returns a hash reference with the attributes of the RDMA device dev:

A value is undef if the driver does not provide the attribute. Dies if the device does not exist.

get_hca_ports

my $ports = get_hca_ports($dev);

Returns a hash reference of the port numbers of the RDMA device dev to a hash reference with:

The numeric prefix of state and phys_state in sysfs (for example 4: ACTIVE) is removed.

get_hca_model

my $model = get_hca_model($dev [, pci => $pci]);

Returns the exact adapter model of the RDMA device dev from lspci -nn, with the PCI vendor and device ID, for example Mellanox Technologies MT27800 Family [ConnectX-5] [15b3:1017]. The pciutils package must be installed.

If the caller already has the PCI address of the device, for example from get_hca_info(), give it as pci to not read it again from sysfs.

get_hca_netdevs

my @netdevs = get_hca_netdevs($dev);

Returns the network interfaces of the RDMA device dev, for example ib0 for IP over InfiniBand, sorted. Returns an empty list if the adapter has no network interface.