const char *ibv_get_device_name(struct ibv_device *device);
描述
函数用来获取一个与RDMA设备相关联的名字
注意
- 这个名字在一台特定的机器中是唯一的(相同的名字不会分配给其他设备);
- 这个名字在跨InfiniBand fabric并不是唯一的;
- 当一台电脑上拥有多于一台的RDMA设备时,修改RDMA设备在电脑上的位置(例如,总线上的位置),可能会导致关联的name改变;
- 为了区分设备,建议使用设备的GUID进行区分,函数ibv_get_device_guid()可以返回该值;
参数(struct ibv_device *device)
函数ibv_get_device_list()返回值中的某一项。(函数ibv_get_device_list()返回当前可用的RDMA设备数组)
返回值(const char *)
函数返回一个指向设备名的指针,如果出错,返回NULL。
名字的组成
- prefix前缀—描述RDMA设备供应商和样式
- cxgb3 —Chelsio Communications, T3 RDMA family
- cxgb4 – Chelsio Communications, T4 RDMA family
- ehca – IBM, eHCA family
- ipathverbs – QLogic
- mlx4 – Mellanox Technologies, ConnectX family
- mthca – Mellanox Technologies, InfiniHost family
- nes – Intel, Intel-NE family
- index索引-用来在同一台电脑中区分相同供应商的一个数字
例子
函数ibv_get_device_name()可能返回的RDMA设备名的例子
- mlx4_0
- mlx4_1
- mthca0
#include <stdio.h>
#include <infiniband/verbs.h>int main(void)
{
struct ibv_device **device_list;
int num_devices;
int i; device_list = ibv_get_device_list(&num_devices);
if (!device_list) {
fprintf(stderr, "Error, ibv_get_device_list() failed\n");
return -;
} printf("%d RDMA device(s) found:\n\n", num_devices); for (i = ; i < num_devices; ++ i)
printf("RDMA device[%d]: name=%s\n", i,
ibv_get_device_name(device_list[i])); ibv_free_device_list(device_list); return ;
}