From 3fe64d3f514963262dcd99370fddf48b9621525b Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 14 Dec 2005 20:44:36 +0000 Subject: [PATCH] r4466: Change libibverbs API for listing all known devices from ibv_get_devices() to ibv_get_device_list(), and update all in-tree uses of this API. Signed-off-by: Roland Dreier --- configure.in | 4 ++-- src/cma.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/configure.in b/configure.in index 1f3b4178..4417feae 100644 --- a/configure.in +++ b/configure.in @@ -25,8 +25,8 @@ AC_CHECK_SIZEOF(long) dnl Checks for libraries if test "$disable_libcheck" != "yes" then -AC_CHECK_LIB(ibverbs, ibv_get_devices, [], - AC_MSG_ERROR([ibv_get_devices() not found. librdmacm requires libibverbs.])) +AC_CHECK_LIB(ibverbs, ibv_get_device_list, [], + AC_MSG_ERROR([ibv_get_device_list() not found. librdmacm requires libibverbs.])) fi dnl Checks for header files. diff --git a/src/cma.c b/src/cma.c index a77f13fe..f93d2b3d 100644 --- a/src/cma.c +++ b/src/cma.c @@ -114,7 +114,7 @@ struct cma_id_private { uint32_t handle; }; -static struct dlist *dev_list; +static struct ibv_device **dev_list; static struct dlist *cma_dev_list; static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; static int ucma_initialized; @@ -141,7 +141,7 @@ static void ucma_cleanup(void) static int ucma_init(void) { - struct ibv_device *dev; + int i; struct cma_device *cma_dev; struct ibv_device_attr attr; int ret; @@ -163,22 +163,22 @@ static int ucma_init(void) goto err; } - dev_list = ibv_get_devices(); + dev_list = ibv_get_device_list(NULL); if (!dev_list) { printf("CMA: unable to get RDMA device liste\n"); ret = -ENODEV; goto err; } - dlist_for_each_data(dev_list, dev, struct ibv_device) { + for (i = 0; dev_list[i]; ++i) { cma_dev = malloc(sizeof *cma_dev); if (!cma_dev) { ret = -ENOMEM; goto err; } - cma_dev->guid = ibv_get_device_guid(dev); - cma_dev->verbs = ibv_open_device(dev); + cma_dev->guid = ibv_get_device_guid(dev_list[i]); + cma_dev->verbs = ibv_open_device(dev_list[i]); if (!cma_dev->verbs) { printf("CMA: unable to open RDMA device\n"); ret = -ENODEV; @@ -201,6 +201,8 @@ out: err: ucma_cleanup(); pthread_mutex_unlock(&mut); + if (dev_list) + ibv_free_device_list(dev_list); return ret; } -- 2.41.0