]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
r4466: Change libibverbs API for listing all known devices from
authorRoland Dreier <rolandd@cisco.com>
Wed, 14 Dec 2005 20:44:36 +0000 (20:44 +0000)
committerRoland Dreier <roland@topspin.com>
Wed, 14 Dec 2005 20:44:36 +0000 (20:44 +0000)
ibv_get_devices() to ibv_get_device_list(), and update all
in-tree uses of this API.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
configure.in
src/cma.c

index 1f3b41783a24adda1b6188b70b9ef1e5bd91da5e..4417feae9b7e521883e3dfc432521c3c81895db3 100644 (file)
@@ -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.
index a77f13fe3ad02533ab08e283712921da025b6b80..f93d2b3d53624eccd447d38b22ee60fd1f0ca0b2 100644 (file)
--- 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;
 }