diff --git a/debian/libibverbs1.symbols b/debian/libibverbs1.symbols index ec40b29b0..10ca9bf3e 100644 --- a/debian/libibverbs1.symbols +++ b/debian/libibverbs1.symbols @@ -6,6 +6,7 @@ libibverbs.so.1 libibverbs1 #MINVER# IBVERBS_1.6@IBVERBS_1.6 24 IBVERBS_1.7@IBVERBS_1.7 25 IBVERBS_1.8@IBVERBS_1.8 28 + IBVERBS_1.9@IBVERBS_1.9 30 (symver)IBVERBS_PRIVATE_25 25 ibv_ack_async_event@IBVERBS_1.0 1.1.6 ibv_ack_async_event@IBVERBS_1.1 1.1.6 @@ -58,6 +59,7 @@ libibverbs.so.1 libibverbs1 #MINVER# ibv_get_cq_event@IBVERBS_1.1 1.1.6 ibv_get_device_guid@IBVERBS_1.0 1.1.6 ibv_get_device_guid@IBVERBS_1.1 1.1.6 + ibv_get_device_index@IBVERBS_1.9 30 ibv_get_device_list@IBVERBS_1.0 1.1.6 ibv_get_device_list@IBVERBS_1.1 1.1.6 ibv_get_device_name@IBVERBS_1.0 1.1.6 diff --git a/libibverbs/CMakeLists.txt b/libibverbs/CMakeLists.txt index 432854892..a10bf1035 100644 --- a/libibverbs/CMakeLists.txt +++ b/libibverbs/CMakeLists.txt @@ -21,7 +21,7 @@ configure_file("libibverbs.map.in" rdma_library(ibverbs "${CMAKE_CURRENT_BINARY_DIR}/libibverbs.map" # See Documentation/versioning.md - 1 1.8.${PACKAGE_VERSION} + 1 1.9.${PACKAGE_VERSION} all_providers.c cmd.c cmd_ah.c diff --git a/libibverbs/device.c b/libibverbs/device.c index bc7df1b06..0427c74e1 100644 --- a/libibverbs/device.c +++ b/libibverbs/device.c @@ -150,6 +150,13 @@ LATEST_SYMVER_FUNC(ibv_get_device_guid, 1_1, "IBVERBS_1.1", return htobe64(guid); } +int ibv_get_device_index(struct ibv_device *device) +{ + struct verbs_sysfs_dev *sysfs_dev = verbs_get_device(device)->sysfs; + + return sysfs_dev->ibdev_idx; +} + int ibv_get_fw_ver(char *value, size_t len, struct verbs_sysfs_dev *sysfs_dev) { /* diff --git a/libibverbs/libibverbs.map.in b/libibverbs/libibverbs.map.in index 5280cfe6c..f0d79c78f 100644 --- a/libibverbs/libibverbs.map.in +++ b/libibverbs/libibverbs.map.in @@ -126,6 +126,11 @@ IBVERBS_1.8 { ibv_reg_mr_iova2; } IBVERBS_1.7; +IBVERBS_1.9 { + global: + ibv_get_device_index; +} IBVERBS_1.8; + /* If any symbols in this stanza change ABI then the entire staza gets a new symbol version. See the top level CMakeLists.txt for this setting. */ diff --git a/libibverbs/man/CMakeLists.txt b/libibverbs/man/CMakeLists.txt index e1d5edf8d..87f00185b 100644 --- a/libibverbs/man/CMakeLists.txt +++ b/libibverbs/man/CMakeLists.txt @@ -32,6 +32,7 @@ rdma_man_pages( ibv_get_async_event.3 ibv_get_cq_event.3 ibv_get_device_guid.3.md + ibv_get_device_index.3.md ibv_get_device_list.3.md ibv_get_device_name.3.md ibv_get_pkey_index.3.md diff --git a/libibverbs/man/ibv_get_device_guid.3.md b/libibverbs/man/ibv_get_device_guid.3.md index 6dc96001d..376c78711 100644 --- a/libibverbs/man/ibv_get_device_guid.3.md +++ b/libibverbs/man/ibv_get_device_guid.3.md @@ -31,7 +31,7 @@ RDMA device *device*. order. # SEE ALSO - +**ibv_get_device_index**(3), **ibv_get_device_list**(3), **ibv_get_device_name**(3), **ibv_open_device**(3) diff --git a/libibverbs/man/ibv_get_device_index.3.md b/libibverbs/man/ibv_get_device_index.3.md new file mode 100644 index 000000000..69f00c4fe --- /dev/null +++ b/libibverbs/man/ibv_get_device_index.3.md @@ -0,0 +1,40 @@ +--- +date: ' 2020-04-22' +footer: libibverbs +header: "Libibverbs Programmer's Manual" +layout: page +license: 'Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md' +section: 3 +title: IBV_GET_DEVICE_INDEX +--- + +# NAME + +ibv_get_device_index - get an RDMA device index + +# SYNOPSIS + +```c +#include + +int ibv_get_device_index(struct ibv_device *device); +``` + +# DESCRIPTION + +**ibv_get_device_index()** returns stable IB device index as it is assigned by the kernel. + +# RETURN VALUE + +**ibv_get_device_index()** returns an index, or -1 if the kernel doesn't support device indexes. + +# SEE ALSO + +**ibv_get_device_name**(3), +**ibv_get_device_guid**(3), +**ibv_get_device_list**(3), +**ibv_open_device**(3) + +# AUTHOR + +Leon Romanovsky diff --git a/libibverbs/man/ibv_get_device_list.3.md b/libibverbs/man/ibv_get_device_list.3.md index 3d222f668..8f3995e4e 100644 --- a/libibverbs/man/ibv_get_device_list.3.md +++ b/libibverbs/man/ibv_get_device_list.3.md @@ -88,6 +88,7 @@ recommended. **ibv_fork_init**(3), **ibv_get_device_guid**(3), **ibv_get_device_name**(3), +**ibv_get_device_index**(3), **ibv_open_device**(3) # AUTHOR diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 288985d54..b08b4c203 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -2202,6 +2202,15 @@ void ibv_free_device_list(struct ibv_device **list); */ const char *ibv_get_device_name(struct ibv_device *device); +/** + * ibv_get_device_index - Return kernel device index + * + * Available for the kernel with support of IB device query + * over netlink interface. For the unsupported kernels, the + * relevant -1 will be returned. + */ +int ibv_get_device_index(struct ibv_device *device); + /** * ibv_get_device_guid - Return device's node GUID */