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));
}
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.
my $info = get_hca_info($dev);
Returns a hash reference with the attributes of the RDMA device dev:
fw_ver: firmware version, for example 16.27.1016
hca_type: HCA type, for example MT4119
board_id: board ID (PSID), for example MT_0000000010
node_guid: node GUID, for example b859:9f03:00d4:2c3a
pci: PCI address of the adapter, for example 0000:3b:00.0
A value is undef if the driver does not provide the attribute. Dies if the device does not exist.
my $ports = get_hca_ports($dev);
Returns a hash reference of the port numbers of the RDMA device dev to a hash reference with:
state: logical port state, for example ACTIVE or DOWN
phys_state: physical port state, for example LinkUp or Disabled
rate: link rate, for example 100 Gb/sec (4X EDR)
link_layer: InfiniBand or Ethernet
The numeric prefix of state and phys_state in sysfs (for example 4: ACTIVE) is removed.
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.
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.