]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
librdmacm: expose ucma_init to other internal modules
authorSean Hefty <sean.hefty@intel.com>
Thu, 6 May 2010 22:45:13 +0000 (15:45 -0700)
committerSean Hefty <sean.hefty@intel.com>
Thu, 6 May 2010 22:45:13 +0000 (15:45 -0700)
Remove static property from ucma_init and expose its
definition in cma.h.  The address resolution module will
need access to this function.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/cma.c
src/cma.h

index e8f4177481e3cc16a6a3fcc45650a9a575a5346e..391f4cc6d76d548a6ecab9b7bd39eb074838a3e3 100644 (file)
--- a/src/cma.c
+++ b/src/cma.c
@@ -188,13 +188,17 @@ static int check_abi_version(void)
        return 0;
 }
 
-static int ucma_init(void)
+int ucma_init(void)
 {
        struct ibv_device **dev_list = NULL;
        struct cma_device *cma_dev;
        struct ibv_device_attr attr;
        int i, ret, dev_cnt;
 
+       /* Quick check without lock to see if we're already initialized */
+       if (cma_dev_cnt)
+               return 0;
+
        pthread_mutex_lock(&mut);
        if (cma_dev_cnt) {
                pthread_mutex_unlock(&mut);
@@ -271,7 +275,7 @@ struct ibv_context **rdma_get_devices(int *num_devices)
        struct ibv_context **devs = NULL;
        int i;
 
-       if (!cma_dev_cnt && ucma_init())
+       if (ucma_init())
                goto out;
 
        devs = malloc(sizeof *devs * (cma_dev_cnt + 1));
@@ -301,7 +305,7 @@ struct rdma_event_channel *rdma_create_event_channel(void)
 {
        struct rdma_event_channel *channel;
 
-       if (!cma_dev_cnt && ucma_init())
+       if (ucma_init())
                return NULL;
 
        channel = malloc(sizeof *channel);
@@ -396,7 +400,7 @@ int rdma_create_id(struct rdma_event_channel *channel,
        void *msg;
        int ret, size;
 
-       ret = cma_dev_cnt ? 0 : ucma_init();
+       ret = ucma_init();
        if (ret)
                return ret;
 
@@ -1712,7 +1716,7 @@ int rdma_get_cm_event(struct rdma_event_channel *channel,
        void *msg;
        int ret, size;
 
-       ret = cma_dev_cnt ? 0 : ucma_init();
+       ret = ucma_init();
        if (ret)
                return ret;
 
index 39c53ec175c96c63aa722ac2094136e1132279f4..4e2312f81c076b4a69b11ff0588aa1c1160ce866 100644 (file)
--- a/src/cma.h
+++ b/src/cma.h
@@ -72,5 +72,7 @@ static inline int ERR(int err)
        return -1;
 }
 
+int ucma_init();
+
 #endif /* CMA_H */