IBVerbs kernel device name

Using ibverbs and ibv_get_device_list() I need to select the device according the name used by linux.

eg enp3s0f1 but what is returened by struct ibv_device → name is mlx5_1, ->dev_name gives me “uverbs1”

dev_path and ibdev_path don’t seem to help much either.

I really do need select the device by enp3s0f1, how do I get it from ibverbs?

It’s a known mapping as mst status -v shows

$ sudo mst status -v
MST modules:
------------
    MST PCI module is not loaded
    MST PCI configuration module is not loaded
PCI devices:
------------
DEVICE_TYPE             MST      PCI       RDMA            NET                       NUMA  
ConnectX5(rev:0)        NA       03:00.0   mlx5_0          net-enp3s0f0              -1    

ConnectX5(rev:0)        NA       03:00.1   mlx5_1          net-enp3s0f1              -1

The best idea I have now is to attempt:

char syspath[1024];
snprintf(syspath, sizeof(syspath), "/sys/class/net/%s/device/infiniband/%s", kernel_name, dev_list[i]->name);
DIR* dir = opendir(syspath);
if(dir) { // found it }

What am I missing?

Hi Harry

You can reference script ibdev2netdev
It should in your server after you install the OFED

Thank you
Meng, Shi