]> git.openfabrics.org - ~ardavis/dapl.git/commitdiff
Convert the openib_cma provider to common code between linux and windows.
authorSean Hefty <sean.hefty@intel.com>
Fri, 10 Apr 2009 15:07:18 +0000 (08:07 -0700)
committerArlin Davis <arlin.r.davis@intel.com>
Fri, 10 Apr 2009 15:07:18 +0000 (08:07 -0700)
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
15 files changed:
Makefile.am
dapl/dirs
dapl/openib_cma/SOURCES [new file with mode: 0644]
dapl/openib_cma/dapl_ib_cm.c
dapl/openib_cma/dapl_ib_cq.c
dapl/openib_cma/dapl_ib_dto.h
dapl/openib_cma/dapl_ib_mem.c
dapl/openib_cma/dapl_ib_util.c
dapl/openib_cma/dapl_ib_util.h
dapl/openib_cma/libdaplcma.map [new file with mode: 0644]
dapl/openib_cma/linux/openib_osd.h [new file with mode: 0644]
dapl/openib_cma/makefile [new file with mode: 0644]
dapl/openib_cma/udapl.rc [new file with mode: 0644]
dapl/openib_cma/udapl_ofa_cma_exports.src [new file with mode: 0644]
dapl/openib_cma/windows/openib_osd.h [new file with mode: 0644]

index 721996fe4c1de40cf544a54b57e6502fedb9f81b..a9e0fecc391ae1650bc0d9cac37f66124cfeeee0 100755 (executable)
@@ -47,7 +47,8 @@ dapl_udapl_libdaplofa_la_CFLAGS = $(AM_CFLAGS) -D_GNU_SOURCE $(OSFLAGS) $(XFLAGS
                                -DOPENIB -DCQ_WAIT_OBJECT \
                                -I$(srcdir)/dat/include/ -I$(srcdir)/dapl/include/ \
                                -I$(srcdir)/dapl/common -I$(srcdir)/dapl/udapl/linux \
-                               -I$(srcdir)/dapl/openib_cma 
+                               -I$(srcdir)/dapl/openib_cma \
+                               -I$(srcdir)/dapl/openib_cma/linux
                
 dapl_udapl_libdaploscm_la_CFLAGS = $(AM_CFLAGS) -D_GNU_SOURCE $(OSFLAGS) $(XFLAGS) \
                                 -DOPENIB -DCQ_WAIT_OBJECT \
index 6fb48fadc657f35627f0c7e957c498739187a120..713ed747f1d75d0a452507f5f0112aa77538fcf6 100644 (file)
--- a/dapl/dirs
+++ b/dapl/dirs
@@ -1 +1 @@
-DIRS = ibal ibal-scm
+DIRS = ibal ibal-scm openib_scm openib_cma
diff --git a/dapl/openib_cma/SOURCES b/dapl/openib_cma/SOURCES
new file mode 100644 (file)
index 0000000..29e836e
--- /dev/null
@@ -0,0 +1,56 @@
+!if $(FREEBUILD)\r
+TARGETNAME=dapl2-ofa-cma\r
+!else\r
+TARGETNAME=dapl2-ofa-cmad\r
+!endif\r
+\r
+TARGETPATH = ..\..\..\..\bin\user\obj$(BUILD_ALT_DIR)\r
+TARGETTYPE = DYNLINK\r
+DLLENTRY = _DllMainCRTStartup\r
+\r
+!if $(_NT_TOOLS_VERSION) == 0x700\r
+DLLDEF=$O\udapl_ofa_cma_exports.def\r
+!else\r
+DLLDEF=$(OBJ_PATH)\$O\udapl_ofa_cma_exports.def\r
+!endif\r
+\r
+USE_MSVCRT = 1\r
+\r
+SOURCES = \\r
+       udapl.rc \\r
+       ..\dapl_common_src.c    \\r
+       ..\dapl_udapl_src.c             \\r
+       dapl_ib_cq.c                    \\r
+       dapl_ib_extensions.c    \\r
+       dapl_ib_mem.c                   \\r
+       dapl_ib_qp.c                    \\r
+       dapl_ib_util.c                  \\r
+       dapl_ib_cm.c\r
+\r
+INCLUDES = ..\include;..\common;windows;..\..\dat\include;\\r
+                  ..\..\dat\udat\windows;..\udapl\windows;\\r
+                  ..\..\..\..\inc;..\..\..\..\inc\user;..\..\..\libibverbs\include;\\r
+                  ..\..\..\librdmacm\include\r
+\r
+DAPL_OPTS = -DEXPORT_DAPL_SYMBOLS -DDAT_EXTENSIONS -DOPENIB\r
+\r
+USER_C_FLAGS = $(USER_C_FLAGS) $(DAPL_OPTS)\r
+\r
+!if !$(FREEBUILD)\r
+USER_C_FLAGS = $(USER_C_FLAGS) -DDAPL_DBG\r
+!endif\r
+\r
+TARGETLIBS= \\r
+       $(SDK_LIB_PATH)\kernel32.lib \\r
+       $(SDK_LIB_PATH)\ws2_32.lib \\r
+!if $(FREEBUILD)\r
+       $(TARGETPATH)\*\dat2.lib \\r
+       $(TARGETPATH)\*\libibverbs.lib \\r
+       $(TARGETPATH)\*\librdmacm.lib\r
+!else\r
+       $(TARGETPATH)\*\dat2d.lib \\r
+       $(TARGETPATH)\*\libibverbsd.lib \\r
+       $(TARGETPATH)\*\librdmacmd.lib\r
+!endif\r
+\r
+MSC_WARNING_LEVEL = /W1 /wd4113 /Wp64\r
index de35ebae4029ee503735aaa29fa47636fab9531b..1b4145e55eda754da55d4c622872fa36e26aca7c 100755 (executable)
 #include "dapl_name_service.h"
 #include "dapl_ib_util.h"
 #include "dapl_vendor.h"
-#include <sys/poll.h>
-#include <signal.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
+#include "dapl_osd.h"
 
 extern struct rdma_event_channel *g_cm_events;
 
@@ -64,12 +60,6 @@ static void dapli_cm_passive_cb(struct dapl_cm_id *conn,
 static void dapli_addr_resolve(struct dapl_cm_id *conn);
 static void dapli_route_resolve(struct dapl_cm_id *conn);
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static inline uint64_t cpu_to_be64(uint64_t x) { return bswap_64(x); }
-#elif __BYTE_ORDER == __BIG_ENDIAN
-static inline uint64_t cpu_to_be64(uint64_t x) { return x; }
-#endif
-
 /* cma requires 16 bit SID, in network order */
 #define IB_PORT_MOD 32001
 #define IB_PORT_BASE (65535 - IB_PORT_MOD)
@@ -131,16 +121,16 @@ static void dapli_route_resolve(struct dapl_cm_id *conn)
        dapl_dbg_log(DAPL_DBG_TYPE_CM, 
                " route_resolve: SRC GID subnet %016llx id %016llx\n",
                (unsigned long long)
-                       cpu_to_be64(ibaddr->sgid.global.subnet_prefix),
+                       ntohll(ibaddr->sgid.global.subnet_prefix),
                (unsigned long long)
-                       cpu_to_be64(ibaddr->sgid.global.interface_id));
+                       ntohll(ibaddr->sgid.global.interface_id));
 
        dapl_dbg_log(DAPL_DBG_TYPE_CM, 
                " route_resolve: DST GID subnet %016llx id %016llx\n",
                (unsigned long long)
-                       cpu_to_be64(ibaddr->dgid.global.subnet_prefix),
+                       ntohll(ibaddr->dgid.global.subnet_prefix),
                (unsigned long long)
-                       cpu_to_be64(ibaddr->dgid.global.interface_id));
+                       ntohll(ibaddr->dgid.global.interface_id));
        
        dapl_dbg_log(DAPL_DBG_TYPE_CM, 
                " route_resolve: cm_id %p pdata %p plen %d rr %d ind %d\n",
@@ -904,15 +894,16 @@ dapls_ib_reject_connection(
        IN DAT_COUNT private_data_size,
        IN const DAT_PVOID private_data)
 {
-       int ret;
+       int ret;
        int offset = sizeof(struct dapl_pdata_hdr);
-       struct dapl_pdata_hdr pdata_hdr = {
-               .version = htonl(
+       struct dapl_pdata_hdr pdata_hdr;
+       
+       memset(&pdata_hdr, 0, sizeof pdata_hdr);
+       pdata_hdr.version = htonl(
                         (DAT_VERSION_MAJOR << 24) |
                         (DAT_VERSION_MINOR << 16) |
                         (VN_PROVIDER_MAJOR << 8 ) |
-                        (VN_PROVIDER_MINOR))
-       };
+                        (VN_PROVIDER_MINOR));
 
        dapl_dbg_log(DAPL_DBG_TYPE_CM,
                     " reject: handle %p reason %x, ver=%x, data %p, sz=%d\n",
index 742c247679b75e0da55893d32d2fe8224cd9613a..59ad65e4eb3d5712f4836193fbca5eb479a8d253 100755 (executable)
  *
  **********************************************************************/
 
+#include "openib_osd.h"
 #include "dapl.h"
 #include "dapl_adapter_util.h"
 #include "dapl_lmr_util.h"
 #include "dapl_evd_util.h"
 #include "dapl_ring_buffer_util.h"
-#include <sys/poll.h>
 
 /* One CQ event channel per HCA */
 void dapli_cq_event_cb(struct _ib_hca_transport *hca)
@@ -48,17 +48,11 @@ void dapli_cq_event_cb(struct _ib_hca_transport *hca)
        /* check all comp events on this device */
        struct dapl_evd *evd_ptr = NULL;
        struct ibv_cq   *ibv_cq = NULL;
-       struct pollfd   cq_fd = {
-               .fd      = hca->ib_cq->fd,
-               .events  = POLLIN,
-               .revents = 0 
-       };
        
        dapl_dbg_log(DAPL_DBG_TYPE_UTIL," dapli_cq_event_cb(%p)\n", hca);
 
-       if ((poll(&cq_fd, 1, 0) == 1) &&
-               (!ibv_get_cq_event(hca->ib_cq,  
-                                  &ibv_cq, (void*)&evd_ptr))) {
+       if (!ibv_get_cq_event(hca->ib_cq,  
+                                  &ibv_cq, (void*)&evd_ptr)) {
 
                if (DAPL_BAD_HANDLE(evd_ptr, DAPL_MAGIC_EVD)) {
                        ibv_ack_cq_events(ibv_cq, 1);
@@ -222,11 +216,11 @@ dapls_ib_cq_alloc(IN DAPL_IA *ia_ptr,
                  IN DAPL_EVD *evd_ptr,
                  IN DAT_COUNT *cqlen )
 {
+       struct ibv_comp_channel *channel = ia_ptr->hca_ptr->ib_trans.ib_cq;
+
        dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
                "dapls_ib_cq_alloc: evd %p cqlen=%d \n", evd_ptr, *cqlen);
 
-       struct ibv_comp_channel *channel = ia_ptr->hca_ptr->ib_trans.ib_cq;
-
 #ifdef CQ_WAIT_OBJECT
        if (evd_ptr->cq_wait_obj_handle)
                channel = evd_ptr->cq_wait_obj_handle->events;
index eba19b7ca8a88658601a0e9e10e596bb2516badd..feaba6e286ce0baa3363971498751d415ff5f7dd 100644 (file)
@@ -147,12 +147,6 @@ dapls_ib_post_send (
        IN  const DAT_RMR_TRIPLET       *remote_iov,
        IN  DAT_COMPLETION_FLAGS        completion_flags)
 {
-       dapl_dbg_log(DAPL_DBG_TYPE_EP,
-                    " post_snd: ep %p op %d ck %p sgs",
-                    "%d l_iov %p r_iov %p f %d\n",
-                    ep_ptr, op_type, cookie, segments, local_iov, 
-                    remote_iov, completion_flags);
-
        ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
        ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
        struct ibv_send_wr wr;
@@ -162,6 +156,12 @@ dapls_ib_post_send (
        DAT_COUNT i, total_len;
        int ret;
        
+       dapl_dbg_log(DAPL_DBG_TYPE_EP,
+                    " post_snd: ep %p op %d ck %p sgs",
+                    "%d l_iov %p r_iov %p f %d\n",
+                    ep_ptr, op_type, cookie, segments, local_iov, 
+                    remote_iov, completion_flags);
+
        dapl_dbg_log(DAPL_DBG_TYPE_EP,
                     " post_snd: ep %p cookie %p segs %d l_iov %p\n",
                     ep_ptr, cookie, segments, local_iov);
@@ -319,12 +319,6 @@ dapls_ib_post_ext_send (
        IN  DAT_UINT64                  swap,
        IN  DAT_COMPLETION_FLAGS        completion_flags)
 {
-       dapl_dbg_log(DAPL_DBG_TYPE_EP,
-                    " post_snd: ep %p op %d ck %p sgs",
-                    "%d l_iov %p r_iov %p f %d\n",
-                    ep_ptr, op_type, cookie, segments, local_iov, 
-                    remote_iov, completion_flags);
-
        ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
        ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
        struct ibv_send_wr wr;
@@ -332,6 +326,12 @@ dapls_ib_post_ext_send (
        DAT_COUNT i, total_len;
        int ret;
        
+       dapl_dbg_log(DAPL_DBG_TYPE_EP,
+                    " post_snd: ep %p op %d ck %p sgs",
+                    "%d l_iov %p r_iov %p f %d\n",
+                    ep_ptr, op_type, cookie, segments, local_iov, 
+                    remote_iov, completion_flags);
+
        dapl_dbg_log(DAPL_DBG_TYPE_EP,
                     " post_snd: ep %p cookie %p segs %d l_iov %p\n",
                     ep_ptr, cookie, segments, local_iov);
index 126777d5a2ae4005ae1217aae99473e8df1984a2..62e1cdedb8837c9426480eafae970acc80d948e7 100755 (executable)
  *
  **********************************************************************/
 
-#include <sys/ioctl.h>  /* for IOCTL's */
-#include <sys/types.h>  /* for socket(2) and related bits and pieces */
-#include <sys/socket.h> /* for socket(2) */
-#include <net/if.h>     /* for struct ifreq */
-#include <net/if_arp.h> /* for ARPHRD_ETHER */
-#include <unistd.h>            /* for _SC_CLK_TCK */
-
 #include "dapl.h"
 #include "dapl_adapter_util.h"
 #include "dapl_lmr_util.h"
@@ -212,10 +205,9 @@ dapls_ib_mr_register(IN  DAPL_IA *ia_ptr,
        lmr->param.registered_address = (DAT_VADDR)(uintptr_t)virt_addr;
 
        dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
-                    " mr_register: mr=%p addr=%p h %x pd %p ctx %p "
+                    " mr_register: mr=%p addr=%p pd %p ctx %p "
                     "lkey=0x%x rkey=0x%x priv=%x\n", 
                     lmr->mr_handle, lmr->mr_handle->addr, 
-                    lmr->mr_handle->handle,    
                     lmr->mr_handle->pd, lmr->mr_handle->context,
                     lmr->mr_handle->lkey, lmr->mr_handle->rkey, 
                     length, dapls_convert_privileges(privileges));
index c5641f0177095ed269f6737d41d26a097f5d4097..5ffe4c7b4d389ad8d0eb3e2a3ac5433935ea0dd7 100755 (executable)
 static const char rcsid[] = "$Id:  $";
 #endif
 
+#include "openib_osd.h"
 #include "dapl.h"
 #include "dapl_adapter_util.h"
 #include "dapl_ib_util.h"
+#include "dapl_osd.h"
 
 #include <stdlib.h>
-#include <netinet/tcp.h>
-#include <sys/poll.h>
-#include <fcntl.h>
-
-#include <sys/ioctl.h>  /* for IOCTL's */
-#include <sys/types.h>  /* for socket(2) and related bits and pieces */
-#include <sys/socket.h> /* for socket(2) */
-#include <net/if.h>     /* for struct ifreq */
-#include <net/if_arp.h> /* for ARPHRD_INFINIBAND */
-#include <arpa/inet.h>  /* for inet_ntoa */
 
 
 int g_dapl_loopback_connection = 0;
-int g_ib_pipe[2];
 struct rdma_event_channel *g_cm_events = NULL;
 ib_thread_state_t g_ib_thread_state = 0;
 DAPL_OS_THREAD g_ib_thread;
 DAPL_OS_LOCK g_hca_lock;
 struct dapl_llist_entry        *g_hca_list;    
 
+#if defined(_WIN64) || defined(_WIN32)
+#include "..\..\..\..\..\etc\user\comp_channel.cpp"
+#include "..\..\..\..\..\etc\user\dlist.c"
+
+#define getipaddr_netdev(x,y,z) -1
+struct ibvw_windata windata;
+
+static int dapls_os_init(void)
+{
+       return ibvw_get_windata(&windata, IBVW_WINDATA_VERSION);
+}
+
+static void dapls_os_release(void)
+{
+       if (windata.comp_mgr)
+               ibvw_release_windata(&windata, IBVW_WINDATA_VERSION);
+       windata.comp_mgr = NULL;
+}
+
+static int dapls_config_comp_channel(struct ibv_comp_channel *channel)
+{
+       channel->comp_channel.Milliseconds = 0;
+       return 0;
+}
+
+static int dapls_config_cm_channel(struct rdma_event_channel *channel)
+{
+       channel->channel.Milliseconds = 0;
+       return 0;
+}
+
+static int dapls_config_verbs(struct ibv_context *verbs)
+{
+       verbs->channel.Milliseconds = 0;
+       return 0;
+}
+
+static int dapls_thread_signal(void)
+{
+       CompManagerCancel(windata.comp_mgr);
+       return 0;
+}
+#else // _WIN64 || WIN32
+int g_ib_pipe[2];
+
+static int dapls_os_init(void)
+{
+       /* create pipe for waking up work thread */
+       return pipe(g_ib_pipe);
+}
+
+static void dapls_os_release(void)
+{
+       /* close pipe? */
+}
+
 /* Get IP address using network device name */
 static int getipaddr_netdev(char *name, char *addr, int addr_len)
 {
@@ -103,6 +150,42 @@ bail:
     return ret;
 }
 
+static int dapls_config_fd(int fd)
+{
+       int opts;
+
+       opts = fcntl(fd, F_GETFL);
+       if (opts < 0 || fcntl(fd, F_SETFL, opts | O_NONBLOCK) < 0) {
+               dapl_log(DAPL_DBG_TYPE_ERR, 
+                       " dapls_config_fd: fcntl on fd %d ERR %d %s\n",
+                       fd, opts, strerror(errno));
+               return errno;
+       }
+
+       return 0;
+}
+
+static int dapls_config_comp_channel(struct ibv_comp_channel *channel)
+{
+       return dapls_config_fd(channel->fd);
+}
+
+static int dapls_config_cm_channel(struct rdma_event_channel *channel)
+{
+       return dapls_config_fd(channel->fd);
+}
+
+static int dapls_config_verbs(struct ibv_context *verbs)
+{
+       return dapls_config_fd(verbs->async_fd);
+}
+
+static int dapls_thread_signal(void)
+{
+       return write(g_ib_pipe[1], "w", sizeof "w");
+}
+#endif
+
 /* Get IP address using network name, address, or device name */
 static int getipaddr(char *name, char *addr, int len)
 {
@@ -164,8 +247,7 @@ int32_t dapls_ib_init(void)
        /* initialize hca list for CQ events */
        dapl_llist_init_head(&g_hca_list);
 
-       /* create pipe for waking up work thread */
-       if (pipe(g_ib_pipe))
+       if (dapls_os_init())
                return 1;
 
        return 0;
@@ -177,6 +259,7 @@ int32_t dapls_ib_release(void)
        dapli_ib_thread_destroy();
        if (g_cm_events != NULL)
                rdma_destroy_event_channel(g_cm_events);
+       dapls_os_release();
        return 0;
 }
 
@@ -199,7 +282,6 @@ int32_t dapls_ib_release(void)
  */
 DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME hca_name, IN DAPL_HCA *hca_ptr)
 {
-       long opts;
        struct rdma_cm_id *cm_id = NULL;
        union ibv_gid *gid;
        int ret;
@@ -222,8 +304,7 @@ DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME hca_name, IN DAPL_HCA *hca_ptr)
        dapl_os_unlock(&g_hca_lock);
 
        dapl_dbg_log (DAPL_DBG_TYPE_UTIL, 
-                       " open_hca: RDMA channel created(%p,%d)\n",
-                       g_cm_events, g_cm_events->fd);
+                       " open_hca: RDMA channel created (%p)\n", g_cm_events);
 
        dat_status = dapli_ib_thread_init();
        if (dat_status != DAT_SUCCESS)
@@ -256,6 +337,7 @@ DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME hca_name, IN DAPL_HCA *hca_ptr)
        /* keep reference to IB device and cm_id */
        hca_ptr->ib_trans.cm_id = cm_id;
        hca_ptr->ib_hca_handle = cm_id->verbs;
+       dapls_config_verbs(cm_id->verbs);
        hca_ptr->port_num = cm_id->port_num;
        gid = &cm_id->route.addr.addr.ibaddr.sgid;
 
@@ -263,8 +345,8 @@ DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME hca_name, IN DAPL_HCA *hca_ptr)
                DAPL_DBG_TYPE_UTIL,
                " open_hca: ctx=%p port=%d GID subnet %016llx id %016llx\n",
                cm_id->verbs,cm_id->port_num,
-               (unsigned long long)bswap_64(gid->global.subnet_prefix),
-               (unsigned long long)bswap_64(gid->global.interface_id));
+               (unsigned long long)ntohll(gid->global.subnet_prefix),
+               (unsigned long long)ntohll(gid->global.interface_id));
 
        /* set inline max with env or default, get local lid and gid 0 */
         if (hca_ptr->ib_hca_handle->device->transport_type
@@ -294,20 +376,12 @@ DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME hca_name, IN DAPL_HCA *hca_ptr)
                         strerror(errno));
                goto bail;
        }
-       dapl_dbg_log (DAPL_DBG_TYPE_UTIL, 
-                       " open_hca: CQ channel created(fd=%d)\n",
-                       hca_ptr->ib_trans.ib_cq->fd);
+       dapl_dbg_log (DAPL_DBG_TYPE_UTIL, " open_hca: CQ channel created\n");
 
-       opts = fcntl(hca_ptr->ib_trans.ib_cq->fd, F_GETFL); /* uCQ */
-       if (opts < 0 || fcntl(hca_ptr->ib_trans.ib_cq->fd, 
-                             F_SETFL, opts | O_NONBLOCK) < 0) {
-               dapl_log(DAPL_DBG_TYPE_ERR, 
-                        " open_hca: fcntl on ib_cq->fd %d ERR %d %s\n", 
-                        hca_ptr->ib_trans.ib_cq->fd, opts,
-                        strerror(errno));
+       if (dapls_config_comp_channel(hca_ptr->ib_trans.ib_cq)) {
                goto bail;
        }
-       
+
        /* 
         * Put new hca_transport on list for async and CQ event processing 
         * Wakeup work thread to add to polling list
@@ -317,7 +391,7 @@ DAT_RETURN dapls_ib_open_hca(IN IB_HCA_NAME hca_name, IN DAPL_HCA *hca_ptr)
        dapl_llist_add_tail(&g_hca_list, 
                            (DAPL_LLIST_ENTRY*)&hca_ptr->ib_trans.entry, 
                            &hca_ptr->ib_trans.entry);
-       if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
+       if (dapls_thread_signal() == -1)
                dapl_log(DAPL_DBG_TYPE_UTIL, 
                         " open_hca: thread wakeup error = %s\n", 
                         strerror(errno));
@@ -387,23 +461,20 @@ DAT_RETURN dapls_ib_close_hca(IN DAPL_HCA *hca_ptr)
         * Wakeup work thread to remove from polling list
         */
        hca_ptr->ib_trans.destroy = 1;
-       if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
+       if (dapls_thread_signal() == -1)
                dapl_log(DAPL_DBG_TYPE_UTIL, 
                         " destroy: thread wakeup error = %s\n", 
                         strerror(errno));
 
        /* wait for thread to remove HCA references */
        while (hca_ptr->ib_trans.destroy != 2) {
-               struct timespec sleep, remain;
-               sleep.tv_sec = 0;
-               sleep.tv_nsec = 10000000; /* 10 ms */
-               if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
+               if (dapls_thread_signal() == -1)
                        dapl_log(DAPL_DBG_TYPE_UTIL, 
                                 " destroy: thread wakeup error = %s\n", 
                                 strerror(errno));              
                dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
                             " ib_thread_destroy: wait on hca %p destroy\n");
-               nanosleep (&sleep, &remain);
+               dapl_os_sleep_usec(10000);
        }
 bail:
        return (DAT_SUCCESS);
@@ -624,11 +695,10 @@ DAT_RETURN dapls_ib_setup_async_callback(IN  DAPL_IA *ia_ptr,
 
 DAT_RETURN dapli_ib_thread_init(void)
 {
-       long opts;
        DAT_RETURN dat_status;
 
        dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-                    " ib_thread_init(%d)\n", getpid());
+                    " ib_thread_init(%d)\n", dapl_os_getpid());
 
        dapl_os_lock(&g_hca_lock);
        if (g_ib_thread_state != IB_THREAD_INIT) {
@@ -637,9 +707,7 @@ DAT_RETURN dapli_ib_thread_init(void)
        }
                
        /* uCMA events non-blocking */
-       opts = fcntl(g_cm_events->fd, F_GETFL); /* uCMA */
-       if (opts < 0 || fcntl(g_cm_events->fd, 
-                             F_SETFL, opts | O_NONBLOCK) < 0) {
+       if (dapls_config_cm_channel(g_cm_events)) {
                dapl_os_unlock(&g_hca_lock);
                return(dapl_convert_errno(errno, "create_thread ERR: cm_fd"));
        }
@@ -657,19 +725,16 @@ DAT_RETURN dapli_ib_thread_init(void)
        /* wait for thread to start */
        dapl_os_lock(&g_hca_lock);
        while (g_ib_thread_state != IB_THREAD_RUN) {
-                struct timespec sleep, remain;
-                sleep.tv_sec = 0;
-                sleep.tv_nsec = 2000000; /* 2 ms */
                 dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
                              " ib_thread_init: waiting for ib_thread\n");
                dapl_os_unlock(&g_hca_lock);
-                nanosleep (&sleep, &remain);
+               dapl_os_sleep_usec(2000);
                dapl_os_lock(&g_hca_lock);
         }
        dapl_os_unlock(&g_hca_lock);
        
        dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-                    " ib_thread_init(%d) exit\n",getpid());
+                    " ib_thread_init(%d) exit\n",dapl_os_getpid());
 
        return DAT_SUCCESS;
 }
@@ -679,7 +744,7 @@ void dapli_ib_thread_destroy(void)
        int retries = 10;
 
        dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-                    " ib_thread_destroy(%d)\n", getpid());
+                    " ib_thread_destroy(%d)\n", dapl_os_getpid());
        /* 
         * wait for async thread to terminate. 
         * pthread_join would be the correct method
@@ -692,22 +757,19 @@ void dapli_ib_thread_destroy(void)
                goto bail;
                        
        g_ib_thread_state = IB_THREAD_CANCEL;
-       if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
+       if (dapls_thread_signal() == -1)
                dapl_log(DAPL_DBG_TYPE_UTIL, 
                         " destroy: thread wakeup error = %s\n", 
                         strerror(errno));
        while ((g_ib_thread_state != IB_THREAD_EXIT) && (retries--)) {
-               struct timespec sleep, remain;
-               sleep.tv_sec = 0;
-               sleep.tv_nsec = 2000000; /* 2 ms */
                dapl_dbg_log(DAPL_DBG_TYPE_UTIL, 
                        " ib_thread_destroy: waiting for ib_thread\n");
-               if (write(g_ib_pipe[1], "w", sizeof "w") == -1)
+               if (dapls_thread_signal() == -1)
                        dapl_log(DAPL_DBG_TYPE_UTIL, 
                                 " destroy: thread wakeup error = %s\n", 
                                strerror(errno));
                dapl_os_unlock( &g_hca_lock );
-               nanosleep(&sleep, &remain);
+               dapl_os_sleep_usec(2000);
                dapl_os_lock( &g_hca_lock );
        }
 
@@ -715,25 +777,19 @@ bail:
        dapl_os_unlock( &g_hca_lock );
        
        dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
-                    " ib_thread_destroy(%d) exit\n",getpid());
+                    " ib_thread_destroy(%d) exit\n",dapl_os_getpid());
 }
 
 void dapli_async_event_cb(struct _ib_hca_transport *hca)
 {
        struct ibv_async_event  event;
-       struct pollfd   async_fd = {
-               .fd      = hca->cm_id->verbs->async_fd,
-               .events  = POLLIN,
-               .revents = 0
-       };
        
        dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " async_event(%p)\n",hca);
 
        if (hca->destroy)
                return;
 
-       if ((poll(&async_fd, 1, 0)==1) &&
-               (!ibv_get_async_event(hca->cm_id->verbs, &event))) {
+       if (!ibv_get_async_event(hca->cm_id->verbs, &event)) {
 
                switch (event.event_type) {
                case    IBV_EVENT_CQ_ERR:
@@ -826,6 +882,62 @@ void dapli_async_event_cb(struct _ib_hca_transport *hca)
        }
 }
 
+#if defined(_WIN64) || defined(_WIN32)
+/* work thread for uAT, uCM, CQ, and async events */
+void dapli_thread(void *arg) 
+{
+       struct _ib_hca_transport *hca;
+       struct _ib_hca_transport *uhca[8];
+       COMP_CHANNEL *channel;
+       int ret, idx, cnt;
+
+       dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " ib_thread(%d,0x%x): ENTER: \n",
+               dapl_os_getpid(), g_ib_thread);
+
+       dapl_os_lock(&g_hca_lock);
+       for (g_ib_thread_state = IB_THREAD_RUN;
+            g_ib_thread_state == IB_THREAD_RUN; dapl_os_lock(&g_hca_lock)) {
+
+               idx = 0;
+               hca = dapl_llist_is_empty(&g_hca_list) ? NULL :
+                       dapl_llist_peek_head(&g_hca_list);
+
+               while (hca) {
+                       uhca[idx++] = hca;
+                       hca = dapl_llist_next_entry(&g_hca_list,
+                               (DAPL_LLIST_ENTRY *) &hca->entry);
+               }
+               cnt = idx;
+
+               dapl_os_unlock(&g_hca_lock);
+               ret = CompManagerPoll(windata.comp_mgr, INFINITE, &channel);
+
+               dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
+                       " ib_thread(%d) poll_event 0x%x\n",
+                       dapl_os_getpid(), ret);
+
+               dapli_cma_event_cb();
+
+               /* check and process CQ and ASYNC events, per device */
+               for (idx = 0; idx < cnt; idx++) {
+                       if (uhca[idx]->destroy == 1) {
+                               dapl_os_lock(&g_hca_lock);
+                               dapl_llist_remove_entry(&g_hca_list,
+                                       (DAPL_LLIST_ENTRY*) &uhca[idx]->entry);
+                               dapl_os_unlock(&g_hca_lock);
+                               uhca[idx]->destroy = 2;
+                       } else {
+                               dapli_cq_event_cb(uhca[idx]);
+                               dapli_async_event_cb(uhca[idx]);
+                       }
+               }
+       }
+
+       dapl_dbg_log(DAPL_DBG_TYPE_UTIL, " ib_thread(%d) EXIT\n", dapl_os_getpid());
+       g_ib_thread_state = IB_THREAD_EXIT;
+       dapl_os_unlock(&g_hca_lock);    
+}
+#else // _WIN64 || WIN32
 /* work thread for uAT, uCM, CQ, and async events */
 void dapli_thread(void *arg) 
 {
@@ -837,7 +949,7 @@ void dapli_thread(void *arg)
        
        dapl_dbg_log (DAPL_DBG_TYPE_UTIL,
                      " ib_thread(%d,0x%x): ENTER: pipe %d ucma %d\n",
-                     getpid(), g_ib_thread, g_ib_pipe[0], g_cm_events->fd);
+                     dapl_os_getpid(), g_ib_thread, g_ib_pipe[0], g_cm_events->fd);
 
        /* Poll across pipe, CM, AT never changes */
        dapl_os_lock( &g_hca_lock );
@@ -878,7 +990,7 @@ void dapli_thread(void *arg)
                        dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
                                " ib_thread(%d) poll_fd: hca[%d]=%p, async=%d"
                                " pipe=%d cm=%d cq=d\n",
-                               getpid(), hca, ufds[idx-1].fd, 
+                               dapl_os_getpid(), hca, ufds[idx-1].fd, 
                                ufds[0].fd, ufds[1].fd, ufds[idx].fd);
 
                        hca = dapl_llist_next_entry(
@@ -893,7 +1005,7 @@ void dapli_thread(void *arg)
                if (ret <= 0) {
                        dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
                                     " ib_thread(%d): ERR %s poll\n",
-                                    getpid(),strerror(errno));
+                                    dapl_os_getpid(),strerror(errno));
                        dapl_os_lock(&g_hca_lock);
                        continue;
                }
@@ -901,7 +1013,7 @@ void dapli_thread(void *arg)
                dapl_dbg_log(DAPL_DBG_TYPE_UTIL,
                        " ib_thread(%d) poll_event: "
                        " async=0x%x pipe=0x%x cm=0x%x cq=0x%x\n",
-                       getpid(), ufds[idx-1].revents, ufds[0].revents, 
+                       dapl_os_getpid(), ufds[idx-1].revents, ufds[0].revents, 
                        ufds[1].revents, ufds[idx].revents);
 
                /* uCMA events */
@@ -939,10 +1051,11 @@ void dapli_thread(void *arg)
                dapl_os_lock(&g_hca_lock);
        }
 
-       dapl_dbg_log(DAPL_DBG_TYPE_UTIL," ib_thread(%d) EXIT\n",getpid());
+       dapl_dbg_log(DAPL_DBG_TYPE_UTIL," ib_thread(%d) EXIT\n",dapl_os_getpid());
        g_ib_thread_state = IB_THREAD_EXIT;
        dapl_os_unlock(&g_hca_lock);    
 }
+#endif
 
 /*
  * dapls_set_provider_specific_attr
index 1e13db9d5bd91c9f07f9939f86ca418dbe76df55..93635ef21f90321eb2b99ea767be068c30a97d42 100755 (executable)
@@ -38,8 +38,8 @@
 #ifndef _DAPL_IB_UTIL_H_
 #define _DAPL_IB_UTIL_H_
 
+#include "openib_osd.h"
 #include <infiniband/verbs.h>
-#include <byteswap.h>
 #include <rdma/rdma_cma.h>
 
 /* Typedefs to map common DAPL provider types to IB verbs */
@@ -294,33 +294,24 @@ dapl_convert_errno( IN int err, IN const char *str )
 {
     if (!err)  return DAT_SUCCESS;
        
-    if ((err != EAGAIN) && (err != ETIME) && 
-       (err != ETIMEDOUT) && (err != EINTR))
-       dapl_log (DAPL_DBG_TYPE_ERR," %s %s\n", str, strerror(err));
+#if DAPL_DBG
+    if ((err != EAGAIN) && (err != ETIMEDOUT))
+       dapl_dbg_log (DAPL_DBG_TYPE_ERR," %s %s\n", str, strerror(err));
+#endif 
 
     switch( err )
     {
        case EOVERFLOW  : return DAT_LENGTH_ERROR;
        case EACCES     : return DAT_PRIVILEGES_VIOLATION;
-       case ENXIO      : 
-       case ERANGE     : 
        case EPERM      : return DAT_PROTECTION_VIOLATION;                
-       case EINVAL     :
-        case EBADF     : 
-       case ENOENT     :
-       case ENOTSOCK   : return DAT_INVALID_HANDLE;
+       case EINVAL     : return DAT_INVALID_HANDLE;
        case EISCONN    : return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_CONNECTED;
        case ECONNREFUSED : return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_NOTREADY;
-       case ETIME      :           
        case ETIMEDOUT  : return DAT_TIMEOUT_EXPIRED;
        case ENETUNREACH: return DAT_INVALID_ADDRESS | DAT_INVALID_ADDRESS_UNREACHABLE;
-       case EBUSY      : return DAT_PROVIDER_IN_USE;
-       case EADDRINUSE : return DAT_CONN_QUAL_IN_USE;
+       case EADDRINUSE : return DAT_CONN_QUAL_IN_USE;
        case EALREADY   : return DAT_INVALID_STATE | DAT_INVALID_STATE_EP_ACTCONNPENDING;
-        case ENOSPC    : 
-       case ENOMEM     :
-        case E2BIG     :
-        case EDQUOT    : return DAT_INSUFFICIENT_RESOURCES;
+       case ENOMEM     : return DAT_INSUFFICIENT_RESOURCES;
         case EAGAIN    : return DAT_QUEUE_EMPTY;
        case EINTR      : return DAT_INTERRUPTED_CALL;
        case EAFNOSUPPORT : return DAT_INVALID_ADDRESS | DAT_INVALID_ADDRESS_MALFORMED;
diff --git a/dapl/openib_cma/libdaplcma.map b/dapl/openib_cma/libdaplcma.map
new file mode 100644 (file)
index 0000000..de06305
--- /dev/null
@@ -0,0 +1,7 @@
+DAPL_CMA_2.0 {\r
+        global:\r
+               dat_provider_fini;\r
+               dat_provider_init;\r
+               dapl_extensions;\r
+       local: *;\r
+};\r
diff --git a/dapl/openib_cma/linux/openib_osd.h b/dapl/openib_cma/linux/openib_osd.h
new file mode 100644 (file)
index 0000000..309972f
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef OPENIB_OSD_H
+#define OPENIB_OSD_H
+
+#include <byteswap.h>
+#include <sys/poll.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define htonll(x) (x)
+#define ntohll(x) (x)
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define htonll(x)  bswap_64(x)
+#define ntohll(x)  bswap_64(x)
+#endif
+
+#endif // OPENIB_OSD_H
diff --git a/dapl/openib_cma/makefile b/dapl/openib_cma/makefile
new file mode 100644 (file)
index 0000000..a0c0627
--- /dev/null
@@ -0,0 +1,7 @@
+#\r
+# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source\r
+# file to this component.  This file merely indirects to the real make file\r
+# that is shared by all the driver components of the OpenIB Windows project.\r
+#\r
+\r
+!INCLUDE ..\..\..\..\inc\openib.def\r
diff --git a/dapl/openib_cma/udapl.rc b/dapl/openib_cma/udapl.rc
new file mode 100644 (file)
index 0000000..c053329
--- /dev/null
@@ -0,0 +1,48 @@
+/*\r
+ * Copyright (c) 2007, 2009 Intel Corporation.  All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ * $Id$\r
+ */\r
+\r
+\r
+#include <oib_ver.h>\r
+\r
+#define VER_FILETYPE                   VFT_DLL\r
+#define VER_FILESUBTYPE                        VFT2_UNKNOWN\r
+\r
+#if DBG\r
+#define VER_FILEDESCRIPTION_STR                "Direct Access Provider Library v2.0 (OFA rdma-cm) (Debug)"\r
+#define VER_INTERNALNAME_STR           "dapl2-ofa-cmad.dll"\r
+#define VER_ORIGINALFILENAME_STR       "dapl2-ofa-cmad.dll"\r
+#else\r
+#define VER_FILEDESCRIPTION_STR                "Direct Access Provider Library v2.0 (OFA rdma-cm)"\r
+#define VER_INTERNALNAME_STR           "dapl2-ofa-cma.dll"\r
+#define VER_ORIGINALFILENAME_STR       "dapl2-ofa-cma.dll"\r
+#endif\r
+\r
+#include <common.ver>\r
diff --git a/dapl/openib_cma/udapl_ofa_cma_exports.src b/dapl/openib_cma/udapl_ofa_cma_exports.src
new file mode 100644 (file)
index 0000000..32e74d2
--- /dev/null
@@ -0,0 +1,14 @@
+#if DBG\r
+LIBRARY dapl2-ofa-cmad.dll\r
+#else\r
+LIBRARY dapl2-ofa-cma.dll\r
+#endif\r
+\r
+\r
+EXPORTS\r
+dat_provider_init\r
+dat_provider_fini\r
+#ifdef DAT_EXTENSIONS\r
+dapl_extensions\r
+#endif\r
+\r
diff --git a/dapl/openib_cma/windows/openib_osd.h b/dapl/openib_cma/windows/openib_osd.h
new file mode 100644 (file)
index 0000000..d008fc0
--- /dev/null
@@ -0,0 +1,5 @@
+#include <winsock2.h>\r
+#include <ws2tcpip.h>\r
+\r
+#define ntohll _byteswap_uint64\r
+#define htonll _byteswap_uint64\r