[IBAL] Remove TO_LONG_PTR from IOCTL structures.
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 13 Jul 2008 10:51:31 +0000 (10:51 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Sun, 13 Jul 2008 10:51:31 +0000 (10:51 +0000)
This patch removes all instances of TO_LONG_PTR from internal IOCTL structures.  The only place TO_LONG_PTR should be used is in public structures that contain pointers and are exchanged between user-mode and kernel-mode.  Actually, the code should ideally have proxy structures for such API structures into which API structure members
are copied member-wise, and whose size is fixed.  Unused pointers should be stripped from the IOCTL proxy structures.  But that's a change for some other time...

All fields in internal IOCTL structures that were formerly TO_LONG_PTR are not uint64_t, and all uses have appropriate casts.

Signed-off-by: Fab Tillier <ftillier@microsoft.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1386 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

21 files changed:
core/al/al_mad_pool.h
core/al/al_proxy_ioctl.h
core/al/kernel/al_proxy.c
core/al/kernel/al_proxy_cep.c
core/al/kernel/al_proxy_ndi.c
core/al/kernel/al_proxy_subnet.c
core/al/kernel/al_proxy_verbs.c
core/al/kernel/al_smi.c
core/al/kernel/al_smi.h
core/al/user/ual_ca.c
core/al/user/ual_cm_cep.c
core/al/user/ual_cq.c
core/al/user/ual_mad.c
core/al/user/ual_mcast.c
core/al/user/ual_mgr.c
core/al/user/ual_pd.c
core/al/user/ual_pnp.c
core/al/user/ual_qp.c
core/al/user/ual_sa_req.c
core/al/user/ual_srq.c
inc/iba/ib_al_ioctl.h

index 6acac50..cc08888 100644 (file)
@@ -139,7 +139,7 @@ typedef struct _al_mad_element
        uint8_t                                 mad_buf[MAD_BLOCK_GRH_SIZE];\r
 #endif\r
 \r
-       TO_LONG_PTR(ib_mad_element_t*, h_proxy_element) ; /* For user-mode support */\r
+       uint64_t                                h_proxy_element; /* For user-mode support */\r
 \r
 }      al_mad_element_t;\r
 \r
index 4434cb3..07b27b4 100644 (file)
@@ -87,10 +87,10 @@ typedef union _misc_cb_ioctl_rec
        /* Multicast record */\r
        struct _mcast_cb_ioctl_rec\r
        {\r
-               TO_LONG_PTR(const void* ,                       mcast_context) ;\r
+               uint64_t                                        mcast_context;\r
                ib_api_status_t                         status;\r
                ib_net16_t                                      error_status;\r
-TO_LONG_PTR(           ib_mcast_handle_t ,                     h_mcast) ; \r
+               uint64_t                                        h_mcast;\r
                ib_member_rec_t                         member_rec;\r
 \r
        }       mcast_cb_ioctl_rec;\r
@@ -99,9 +99,9 @@ TO_LONG_PTR(          ib_mcast_handle_t ,                     h_mcast) ;
        /* Mad send */\r
        struct _mad_send_cb_ioctl_rec\r
        {\r
-               TO_LONG_PTR(ib_mad_element_t* , p_um_mad) ;\r
+               uint64_t                                        p_um_mad;\r
                ib_wc_status_t                          wc_status;\r
-               TO_LONG_PTR(void* ,                             mad_svc_context) ;\r
+               uint64_t                                        mad_svc_context;\r
 \r
        }       mad_send_cb_ioctl_rec;\r
 \r
@@ -111,8 +111,8 @@ TO_LONG_PTR(                ib_mcast_handle_t ,                     h_mcast) ;
        {\r
                uint64_t                                        h_mad;\r
                uint32_t                                        elem_size;\r
-               TO_LONG_PTR(void* ,                             mad_svc_context) ;\r
-               TO_LONG_PTR(ib_mad_element_t* , p_send_mad) ;\r
+               uint64_t                                        mad_svc_context;\r
+               uint64_t                                        p_send_mad;\r
 \r
        }       mad_recv_cb_ioctl_rec;\r
 \r
@@ -143,7 +143,7 @@ TO_LONG_PTR(                ib_mcast_handle_t ,                     h_mcast) ;
 \r
 typedef struct _comp_cb_ioctl_info\r
 {\r
-       TO_LONG_PTR(void* ,                                     cq_context) ;\r
+       uint64_t                                                cq_context;\r
 \r
 }      comp_cb_ioctl_info_t;\r
 \r
index 12809bb..acff865 100644 (file)
@@ -912,8 +912,8 @@ proxy_reg_pnp(
        pnp_req.pnp_context = p_open_context;\r
        pnp_req.pfn_pnp_cb = __proxy_pnp_cb;\r
 \r
-       p_user_status = p_ioctl->p_status;\r
-       p_user_hdl = p_ioctl->p_hdl;\r
+       p_user_status = (ib_api_status_t*)(ULONG_PTR)p_ioctl->p_status;\r
+       p_user_hdl = (uint64_t*)(ULONG_PTR)p_ioctl->p_hdl;\r
 \r
        if( pnp_get_flag( p_ioctl->pnp_class ) & IB_PNP_FLAG_REG_SYNC )\r
        {\r
@@ -1087,7 +1087,7 @@ proxy_rearm_pnp(
                p_context->h_al, p_ioctl->last_evt_hdl, AL_OBJ_TYPE_H_PNP_EVENT );\r
        if( p_evt )\r
        {\r
-               p_evt->evt_context = p_ioctl->last_evt_context;\r
+               p_evt->evt_context = (void*)(ULONG_PTR)p_ioctl->last_evt_context;\r
                p_evt->evt_status = p_ioctl->last_evt_status;\r
                cl_event_signal( &p_evt->event );\r
        }\r
index 8afbf30..29ff546 100644 (file)
@@ -303,7 +303,8 @@ proxy_cep_pre_rep(
 \r
        cid = AL_INVALID_CID;\r
        p_ioctl->out.status = al_cep_pre_rep( p_context->h_al, p_ioctl->in.cid,\r
-               p_ioctl->in.context, NULL, &p_ioctl->in.cm_rep, &cid, &p_ioctl->out.init );\r
+               (void*)(ULONG_PTR)p_ioctl->in.context, NULL, &p_ioctl->in.cm_rep,\r
+               &cid, &p_ioctl->out.init );\r
 \r
        deref_al_obj( &h_qp->obj );\r
 \r
@@ -786,7 +787,8 @@ proxy_cep_poll(
        *p_ret_bytes = sizeof(ual_cep_poll_ioctl_t);\r
 \r
        p_ioctl->status = al_cep_poll( p_context->h_al,\r
-               *(net32_t*)cl_ioctl_in_buf( h_ioctl ), &p_ioctl->context,\r
+               *(net32_t*)cl_ioctl_in_buf( h_ioctl ),\r
+               &(void*)(ULONG_PTR)p_ioctl->context,\r
                &p_ioctl->new_cid, &p_mad );\r
 \r
        if( p_ioctl->status == IB_SUCCESS )\r
index 4a94740..382e829 100644 (file)
@@ -111,8 +111,8 @@ __ndi_create_cq(
        if( status != IB_SUCCESS )\r
                goto proxy_create_cq_err2;\r
 \r
-       status = create_cq( h_ca, &cq_create, p_ioctl->in.context,\r
-               pfn_ev, &h_cq, p_umv_buf );\r
+       status = create_cq( h_ca, &cq_create,\r
+               (void*)(ULONG_PTR)p_ioctl->in.context, pfn_ev, &h_cq, p_umv_buf );\r
 \r
        if( status != IB_SUCCESS )\r
                goto proxy_create_cq_err2;\r
index 3c05a35..8e5b74e 100644 (file)
@@ -247,8 +247,8 @@ proxy_send_sa_req(
        CL_ASSERT( p_ioctl );\r
 \r
        /* Must save user's pointers in case req completes before call returns. */\r
-       p_usr_status = p_ioctl->in.p_status;\r
-       p_usr_hdl = p_ioctl->in.ph_sa_req;\r
+       p_usr_status = (ib_api_status_t*)(ULONG_PTR)p_ioctl->in.p_status;\r
+       p_usr_hdl = (uint64_t*)(ULONG_PTR)p_ioctl->in.ph_sa_req;\r
 \r
        if( p_ioctl->in.sa_req.attr_size > IB_SA_DATA_SIZE )\r
        {\r
@@ -445,7 +445,8 @@ proxy_send_mad(
 \r
        /* Now copy the mad element with all info */\r
        status = ib_convert_cl_status( cl_copy_from_user( p_mad_el,\r
-               p_ioctl->in.p_mad_element, sizeof(ib_mad_element_t) ) );\r
+               (void*)(ULONG_PTR)p_ioctl->in.p_mad_element,\r
+               sizeof(ib_mad_element_t) ) );\r
        if( status != IB_SUCCESS )\r
                goto proxy_send_mad_err2;\r
 \r
@@ -463,7 +464,7 @@ proxy_send_mad(
         * MAD receive completion could fail to be delivered to the app even though\r
         * the response was properly received in the kernel.\r
         */\r
-       p_mad_el->context1 = p_ioctl->in.p_mad_element;\r
+       p_mad_el->context1 = (void*)(ULONG_PTR)p_ioctl->in.p_mad_element;\r
 \r
        /* Set the kernel AV handle. This is either NULL or a valid KM handle. */\r
        p_mad_el->h_av = h_av;\r
@@ -485,7 +486,8 @@ proxy_send_mad(
 \r
        /* Copy the handle to UM to allow cancelling. */\r
        status = ib_convert_cl_status( cl_copy_to_user(\r
-               p_ioctl->in.ph_proxy, p_mad_el, sizeof(ib_mad_element_t*) ) );\r
+               (void*)(ULONG_PTR)p_ioctl->in.ph_proxy,\r
+               &p_mad_el, sizeof(ib_mad_element_t*) ) );\r
        if( status != IB_SUCCESS )\r
                goto proxy_send_mad_err2;\r
 \r
@@ -563,7 +565,8 @@ proxy_mad_comp(
         * for correcting all pointers.\r
         */\r
        status = ib_convert_cl_status( cl_copy_to_user(\r
-               p_ioctl->in.p_user_mad, p_mad, sizeof(ib_mad_element_t) ) );\r
+               (void*)(ULONG_PTR)p_ioctl->in.p_user_mad,\r
+               p_mad, sizeof(ib_mad_element_t) ) );\r
        if( status != IB_SUCCESS )\r
        {\r
                AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
@@ -573,7 +576,7 @@ proxy_mad_comp(
 \r
        /* Copy the MAD buffer. */\r
        status = ib_convert_cl_status( cl_copy_to_user(\r
-               p_ioctl->in.p_mad_buf, p_mad->p_mad_buf, p_mad->size ) );\r
+               (void*)(ULONG_PTR)p_ioctl->in.p_mad_buf, p_mad->p_mad_buf, p_mad->size ) );\r
        if( status != IB_SUCCESS )\r
        {\r
                AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
@@ -585,7 +588,7 @@ proxy_mad_comp(
        if( p_mad->grh_valid )\r
        {\r
                status = ib_convert_cl_status( cl_copy_to_user(\r
-                       p_ioctl->in.p_grh, p_mad->p_grh, sizeof(ib_grh_t) ) );\r
+                       (void*)(ULONG_PTR)p_ioctl->in.p_grh, p_mad->p_grh, sizeof(ib_grh_t) ) );\r
                if( status != IB_SUCCESS )\r
                {\r
                        AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
@@ -659,7 +662,7 @@ __proxy_mad_send_cb(
                cb_info.ioctl_rec.mad_send_cb_ioctl_rec.p_um_mad =\r
                        p_al_el->h_proxy_element;\r
                cb_info.ioctl_rec.mad_send_cb_ioctl_rec.mad_svc_context =\r
-                       mad_svc_context;\r
+                       (ULONG_PTR)mad_svc_context;\r
 \r
                /* Queue this mad completion notification for the user. */\r
                proxy_queue_cb_buf( UAL_GET_MISC_CB_INFO, p_context, &cb_info,\r
@@ -694,10 +697,10 @@ __proxy_mad_recv_cb(
 \r
        /* Set up context and callback record type appropriate for UAL */\r
        cb_info.rec_type = MAD_RECV_REC;\r
-       cb_info.ioctl_rec.mad_recv_cb_ioctl_rec.mad_svc_context = mad_svc_context;\r
+       cb_info.ioctl_rec.mad_recv_cb_ioctl_rec.mad_svc_context = (ULONG_PTR)mad_svc_context;\r
        cb_info.ioctl_rec.mad_recv_cb_ioctl_rec.elem_size = p_mad_element->size;\r
        cb_info.ioctl_rec.mad_recv_cb_ioctl_rec.p_send_mad =\r
-               (ib_mad_element_t*)p_mad_element->send_context1;\r
+               (ULONG_PTR)p_mad_element->send_context1;\r
 \r
        /*\r
         * If we're already closing the device - do not queue a callback, since\r
@@ -1015,8 +1018,8 @@ proxy_cancel_mad(
                return CL_SUCCESS;\r
        }\r
 \r
-       p_ioctl->out.status =\r
-               ib_cancel_mad( h_mad_svc, p_ioctl->in.h_proxy_element );\r
+       p_ioctl->out.status = ib_cancel_mad( h_mad_svc,\r
+               (ib_mad_element_t*)(ULONG_PTR)p_ioctl->in.h_proxy_element );\r
 \r
        /*\r
         * The clean up of resources allocated for the sent mad will\r
index 52a8cf5..38a9b7f 100644 (file)
@@ -401,7 +401,7 @@ proxy_open_ca(
                goto proxy_open_ca_err;\r
 \r
        status = open_ca( p_context->h_al, p_ioctl->in.guid, proxy_ca_err_cb,\r
-               p_ioctl->in.context, &h_ca, p_umv_buf );\r
+               (void*)(ULONG_PTR)p_ioctl->in.context, &h_ca, p_umv_buf );\r
        if( status != IB_SUCCESS )\r
                goto proxy_open_ca_err;\r
 \r
@@ -502,14 +502,16 @@ proxy_query_ca(
        {\r
                __try\r
                {\r
-                       ProbeForWrite( p_ioctl->in.p_ca_attr, byte_cnt, sizeof(void*) );\r
-                       ib_copy_ca_attr( p_ioctl->in.p_ca_attr, p_ca_attr );\r
+                       ProbeForWrite( (void*)(ULONG_PTR)p_ioctl->in.p_ca_attr,\r
+                               byte_cnt, sizeof(void*) );\r
+                       ib_copy_ca_attr( (void*)(ULONG_PTR)p_ioctl->in.p_ca_attr,\r
+                               p_ca_attr );\r
                }\r
                __except(EXCEPTION_EXECUTE_HANDLER)\r
                {\r
                        AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
                                ("Failed to copy CA attributes to user buffer %016I64x\n",\r
-                               (LONG64)p_ioctl->in.p_ca_attr) );\r
+                               p_ioctl->in.p_ca_attr) );\r
                        status = IB_INVALID_PERMISSION;\r
                }\r
        }\r
@@ -877,8 +879,8 @@ proxy_alloc_pd(
        if( status != IB_SUCCESS )\r
                goto proxy_alloc_pd_err;\r
 \r
-       status = alloc_pd( h_ca, p_ioctl->in.type, p_ioctl->in.context,\r
-               &h_pd, p_umv_buf );\r
+       status = alloc_pd( h_ca, p_ioctl->in.type,\r
+               (void*)(ULONG_PTR)p_ioctl->in.context, &h_pd, p_umv_buf );\r
 \r
        if( status != IB_SUCCESS )\r
                goto proxy_alloc_pd_err;\r
@@ -1049,8 +1051,8 @@ proxy_create_srq(
        else\r
                pfn_ev = NULL;\r
 \r
-       status = create_srq( h_pd, &p_ioctl->in.srq_attr, p_ioctl->in.context,\r
-               pfn_ev, &h_srq, p_umv_buf );\r
+       status = create_srq( h_pd, &p_ioctl->in.srq_attr,\r
+               (void*)(ULONG_PTR)p_ioctl->in.context, pfn_ev, &h_srq, p_umv_buf );\r
        if( status != IB_SUCCESS )\r
                goto proxy_create_srq_err1;\r
 \r
@@ -1387,8 +1389,8 @@ proxy_create_qp(
        else\r
                pfn_ev = NULL;\r
 \r
-       status = create_qp( h_pd, &p_ioctl->in.qp_create, p_ioctl->in.context,\r
-               pfn_ev, &h_qp, p_umv_buf );\r
+       status = create_qp( h_pd, &p_ioctl->in.qp_create,\r
+               (void*)(ULONG_PTR)p_ioctl->in.context, pfn_ev, &h_qp, p_umv_buf );\r
        /* TODO: The create_qp call should return the attributes... */\r
        if( status != IB_SUCCESS )\r
                goto proxy_create_qp_err1;\r
@@ -2003,7 +2005,7 @@ proxy_cq_comp_cb(
        }\r
 \r
        /* Set up context and callback record type appropriate for UAL */\r
-       cb_info.cq_context = cq_context;\r
+       cb_info.cq_context = (ULONG_PTR)cq_context;\r
 \r
        /* The proxy handle must be valid now. */\r
        if( !h_cq->obj.hdl_valid )\r
@@ -2123,8 +2125,8 @@ proxy_create_cq(
        else\r
                pfn_ev = NULL;\r
 \r
-       status = create_cq( h_ca, &cq_create, p_ioctl->in.context,\r
-               pfn_ev, &h_cq, p_umv_buf );\r
+       status = create_cq( h_ca, &cq_create,\r
+               (void*)(ULONG_PTR)p_ioctl->in.context, pfn_ev, &h_cq, p_umv_buf );\r
 \r
        if( status != IB_SUCCESS )\r
                goto proxy_create_cq_err2;\r
@@ -3603,7 +3605,8 @@ proxy_get_spl_qp(
 \r
        /* We obtain the pool_key separately from the special QP. */\r
        status = get_spl_qp( h_pd, p_ioctl->in.port_guid,\r
-               &p_ioctl->in.qp_create, p_ioctl->in.context, proxy_qp_err_cb, NULL, &h_qp, p_umv_buf );\r
+               &p_ioctl->in.qp_create, (void*)(ULONG_PTR)p_ioctl->in.context,\r
+               proxy_qp_err_cb, NULL, &h_qp, p_umv_buf );\r
        if( status != IB_SUCCESS )\r
                goto proxy_get_spl_qp_err;\r
 \r
index b3cc398..255c0c2 100644 (file)
@@ -140,6 +140,22 @@ spl_qp_send_comp_cb(
        IN              const   ib_cq_handle_t                          h_cq,\r
        IN                              void                                            *cq_context );\r
 \r
+void\r
+spl_qp_send_dpc_cb(\r
+    IN              KDPC                        *p_dpc,\r
+    IN              void                        *context,\r
+    IN              void                        *arg1,\r
+    IN              void                        *arg2\r
+    );\r
+\r
+void\r
+spl_qp_recv_dpc_cb(\r
+    IN              KDPC                        *p_dpc,\r
+    IN              void                        *context,\r
+    IN              void                        *arg1,\r
+    IN              void                        *arg2\r
+    );\r
+\r
 void\r
 spl_qp_recv_comp_cb(\r
        IN              const   ib_cq_handle_t                          h_cq,\r
@@ -554,7 +570,17 @@ create_spl_qp_svc(
        cl_qlist_init( &p_spl_qp_svc->send_queue );\r
        cl_qlist_init( &p_spl_qp_svc->recv_queue );\r
        cl_spinlock_init(&p_spl_qp_svc->cache_lock);\r
-       \r
+\r
+    /* Initialize the DPCs. */\r
+    KeInitializeDpc( &p_spl_qp_svc->send_dpc, spl_qp_send_dpc_cb, p_spl_qp_svc );\r
+    KeInitializeDpc( &p_spl_qp_svc->recv_dpc, spl_qp_recv_dpc_cb, p_spl_qp_svc );\r
+\r
+    if( qp_type == IB_QPT_QP0 )\r
+    {\r
+        KeSetImportanceDpc( &p_spl_qp_svc->send_dpc, HighImportance );\r
+        KeSetImportanceDpc( &p_spl_qp_svc->recv_dpc, HighImportance );\r
+    }\r
+\r
 #if defined( CL_USE_MUTEX )\r
        /* Initialize async callbacks and flags for send/receive processing. */\r
        p_spl_qp_svc->send_async_queued = FALSE;\r
@@ -2461,6 +2487,8 @@ spl_qp_send_comp_cb(
 \r
        AL_ENTER( AL_DBG_SMI );\r
 \r
+       UNREFERENCED_PARAMETER( h_cq );\r
+\r
        CL_ASSERT( cq_context );\r
        p_spl_qp_svc = cq_context;\r
 \r
@@ -2477,21 +2505,55 @@ spl_qp_send_comp_cb(
        cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
 \r
 #else\r
+    cl_spinlock_acquire( &p_spl_qp_svc->obj.lock );\r
+       if( p_spl_qp_svc->state != SPL_QP_ACTIVE )\r
+       {\r
+               cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
+        AL_EXIT( AL_DBG_SMI );\r
+               return;\r
+       }\r
+       cl_atomic_inc( &p_spl_qp_svc->in_use_cnt );\r
+       cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
 \r
-       /* Invoke the callback directly. */\r
+    /* Queue the DPC. */\r
        CL_ASSERT( h_cq == p_spl_qp_svc->h_send_cq );\r
-       spl_qp_comp( p_spl_qp_svc, h_cq, IB_WC_SEND );\r
+    KeInsertQueueDpc( &p_spl_qp_svc->send_dpc, NULL, NULL );\r
+#endif\r
+\r
+       AL_EXIT( AL_DBG_SMI );\r
+}\r
+\r
+\r
+void\r
+spl_qp_send_dpc_cb(\r
+    IN              KDPC                        *p_dpc,\r
+    IN              void                        *context,\r
+    IN              void                        *arg1,\r
+    IN              void                        *arg2\r
+    )\r
+{\r
+       spl_qp_svc_t*                   p_spl_qp_svc;\r
+\r
+       AL_ENTER( AL_DBG_SMI );\r
+\r
+       CL_ASSERT( context );\r
+       p_spl_qp_svc = context;\r
+\r
+    UNREFERENCED_PARAMETER( p_dpc );\r
+    UNREFERENCED_PARAMETER( arg1 );\r
+    UNREFERENCED_PARAMETER( arg2 );\r
+\r
+       spl_qp_comp( p_spl_qp_svc, p_spl_qp_svc->h_send_cq, IB_WC_SEND );\r
 \r
        /* Continue processing any queued MADs on the QP. */\r
        special_qp_resume_sends( p_spl_qp_svc->h_qp );\r
 \r
-#endif\r
+    cl_atomic_dec( &p_spl_qp_svc->in_use_cnt );\r
 \r
-       AL_EXIT( AL_DBG_SMI );\r
+    AL_EXIT( AL_DBG_SMI );\r
 }\r
 \r
 \r
-\r
 #if defined( CL_USE_MUTEX )\r
 void\r
 spl_qp_send_async_cb(\r
@@ -2536,6 +2598,8 @@ spl_qp_recv_comp_cb(
 \r
        AL_ENTER( AL_DBG_SMI );\r
 \r
+       UNREFERENCED_PARAMETER( h_cq );\r
+\r
        CL_ASSERT( cq_context );\r
        p_spl_qp_svc = cq_context;\r
 \r
@@ -2552,16 +2616,51 @@ spl_qp_recv_comp_cb(
        cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
 \r
 #else\r
+    cl_spinlock_acquire( &p_spl_qp_svc->obj.lock );\r
+       if( p_spl_qp_svc->state != SPL_QP_ACTIVE )\r
+       {\r
+               cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
+        AL_EXIT( AL_DBG_SMI );\r
+               return;\r
+       }\r
+       cl_atomic_inc( &p_spl_qp_svc->in_use_cnt );\r
+       cl_spinlock_release( &p_spl_qp_svc->obj.lock );\r
 \r
+    /* Queue the DPC. */\r
        CL_ASSERT( h_cq == p_spl_qp_svc->h_recv_cq );\r
-       spl_qp_comp( p_spl_qp_svc, h_cq, IB_WC_RECV );\r
-\r
+    KeInsertQueueDpc( &p_spl_qp_svc->recv_dpc, NULL, NULL );\r
 #endif\r
 \r
        AL_EXIT( AL_DBG_SMI );\r
 }\r
 \r
 \r
+void\r
+spl_qp_recv_dpc_cb(\r
+    IN              KDPC                        *p_dpc,\r
+    IN              void                        *context,\r
+    IN              void                        *arg1,\r
+    IN              void                        *arg2\r
+    )\r
+{\r
+       spl_qp_svc_t*                   p_spl_qp_svc;\r
+\r
+       AL_ENTER( AL_DBG_SMI );\r
+\r
+       CL_ASSERT( context );\r
+       p_spl_qp_svc = context;\r
+\r
+    UNREFERENCED_PARAMETER( p_dpc );\r
+    UNREFERENCED_PARAMETER( arg1 );\r
+    UNREFERENCED_PARAMETER( arg2 );\r
+\r
+       spl_qp_comp( p_spl_qp_svc, p_spl_qp_svc->h_recv_cq, IB_WC_RECV );\r
+\r
+    cl_atomic_dec( &p_spl_qp_svc->in_use_cnt );\r
+\r
+    AL_EXIT( AL_DBG_SMI );\r
+}\r
+\r
 \r
 #if defined( CL_USE_MUTEX )\r
 void\r
@@ -2589,7 +2688,7 @@ spl_qp_recv_async_cb(
 #endif\r
 \r
 \r
-\r
+#define SPL_QP_MAX_POLL 16\r
 /*\r
  * Special QP completion handler.\r
  */\r
@@ -2607,6 +2706,7 @@ spl_qp_comp(
        ib_mad_element_t*               p_mad_element;\r
        ib_smp_t*                               p_smp;\r
        ib_api_status_t                 status;\r
+    int                     max_poll = SPL_QP_MAX_POLL;\r
 \r
        AL_ENTER( AL_DBG_SMI_CB );\r
 \r
@@ -2625,7 +2725,7 @@ spl_qp_comp(
 \r
        wc.p_next = NULL;\r
        /* Process work completions. */\r
-       while( ib_poll_cq( h_cq, &p_free_wc, &p_done_wc ) == IB_SUCCESS )\r
+       while( max_poll && ib_poll_cq( h_cq, &p_free_wc, &p_done_wc ) == IB_SUCCESS )\r
        {\r
                /* Process completions one at a time. */\r
                CL_ASSERT( p_done_wc );\r
@@ -2713,13 +2813,25 @@ spl_qp_comp(
                        spl_qp_svc_reset( p_spl_qp_svc );\r
                }\r
                p_free_wc = &wc;\r
-       }\r
-\r
-       /* Rearm the CQ. */\r
-       status = ib_rearm_cq( h_cq, FALSE );\r
-       CL_ASSERT( status == IB_SUCCESS );\r
-\r
-       cl_atomic_dec( &p_spl_qp_svc->in_use_cnt );\r
+        --max_poll;\r
+       }\r
+\r
+    if( max_poll == 0 )\r
+    {\r
+        /* We already have an in_use_cnt reference - use it to queue the DPC. */\r
+        if( wc_type == IB_WC_SEND )\r
+            KeInsertQueueDpc( &p_spl_qp_svc->send_dpc, NULL, NULL );\r
+        else\r
+            KeInsertQueueDpc( &p_spl_qp_svc->recv_dpc, NULL, NULL );\r
+    }\r
+    else\r
+    {\r
+           /* Rearm the CQ. */\r
+           status = ib_rearm_cq( h_cq, FALSE );\r
+           CL_ASSERT( status == IB_SUCCESS );\r
+\r
+           cl_atomic_dec( &p_spl_qp_svc->in_use_cnt );\r
+    }\r
        AL_EXIT( AL_DBG_SMI_CB );\r
 }\r
 \r
index 95b2718..62cb0fe 100644 (file)
@@ -157,6 +157,9 @@ typedef struct _spl_qp_svc
        ib_pool_key_t                           pool_key;\r
        ib_mad_svc_handle_t                     h_mad_svc;\r
 \r
+    KDPC                        send_dpc;\r
+    KDPC                        recv_dpc;\r
+\r
 }      spl_qp_svc_t;\r
 \r
 \r
index ec37f5c..b1a12cb 100644 (file)
@@ -169,7 +169,7 @@ ual_open_ca(
        }\r
 \r
        ca_ioctl.in.guid = ca_guid;\r
-       ca_ioctl.in.context = p_ci_ca;\r
+       ca_ioctl.in.context = (ULONG_PTR)p_ci_ca;\r
 \r
        cl_status = do_al_dev_ioctl( UAL_OPEN_CA,\r
                &ca_ioctl.in, sizeof(ca_ioctl.in), &ca_ioctl.out, sizeof(ca_ioctl.out),\r
@@ -273,7 +273,7 @@ ual_query_ca(
        cl_memclr( &ca_ioctl, sizeof(ca_ioctl) );\r
 \r
        ca_ioctl.in.h_ca = h_ca->obj.p_ci_ca->obj.hdl;\r
-       ca_ioctl.in.p_ca_attr = p_ca_attr;\r
+       ca_ioctl.in.p_ca_attr = (ULONG_PTR)p_ca_attr;\r
        ca_ioctl.in.byte_cnt = *p_size;\r
 \r
        /* Call the uvp pre call if the vendor library provided a valid ca handle */\r
@@ -336,7 +336,7 @@ ual_modify_ca(
        uvp_interface_t                         uvp_intf = h_ca->obj.p_ci_ca->verbs.user_verbs;\r
 \r
        AL_ENTER( AL_DBG_CA );\r
-    cl_memclr(&ca_ioctl, sizeof(ca_ioctl));\r
+\r
        /* Call the uvp pre call if the vendor library provided a valid ca handle */\r
        if( h_ca->obj.p_ci_ca->h_ci_ca && uvp_intf.pre_modify_ca )\r
        {\r
index 07b14fe..6b9003d 100644 (file)
@@ -267,13 +267,14 @@ __create_ucep(
 \r
        /* Store user parameters. */\r
        p_cep->pfn_cb = pfn_cb;\r
-       p_cep->destroy_context = context; //TODO: context will no be longer __ptr64\r
+       p_cep->destroy_context = context;\r
 \r
        /* Create a kernel CEP only if we don't already have a CID. */\r
        if( cid == AL_INVALID_CID )\r
        {\r
-               if( !DeviceIoControl( g_al_device, UAL_CREATE_CEP, &context, \r
-                       sizeof(context), &ioctl, sizeof(ioctl), &bytes_ret, NULL ) ||\r
+               uint64_t cep_context = (ULONG_PTR)context;\r
+               if( !DeviceIoControl( g_al_device, UAL_CREATE_CEP, &cep_context,\r
+                       sizeof(cep_context), &ioctl, sizeof(ioctl), &bytes_ret, NULL ) ||\r
                        bytes_ret != sizeof(ioctl) )\r
                {\r
                        __destroy_ucep( p_cep );\r
@@ -648,7 +649,7 @@ al_cep_pre_rep(
        p_cep->destroy_context = context;\r
        cl_spinlock_release( &gp_cep_mgr->obj.lock );\r
 \r
-       ioctl.in.context = context;\r
+       ioctl.in.context = (ULONG_PTR)context;\r
        ioctl.in.cid = cid;\r
        ioctl.in.cm_rep = *p_cm_rep;\r
        ioctl.in.cm_rep.h_qp = (ib_qp_handle_t)HDL_TO_PTR(p_cm_rep->h_qp->obj.hdl);\r
@@ -1384,7 +1385,7 @@ al_cep_poll(
                \r
                cl_memcpy( p_mad->p_mad_buf, ioctl.mad_buf, MAD_BLOCK_SIZE );\r
 \r
-               *p_context = ioctl.context;\r
+               *p_context = (void*)(ULONG_PTR)ioctl.context;\r
                *p_new_cid = ioctl.new_cid;\r
                *pp_mad = p_mad;\r
        }\r
index d71390b..46aea61 100644 (file)
@@ -78,8 +78,8 @@ ual_create_cq(
 \r
        cq_ioctl.in.h_ca = p_ci_ca->obj.hdl;\r
        cq_ioctl.in.size = p_cq_create->size;\r
-       cq_ioctl.in.h_wait_obj = p_cq_create->h_wait_obj;\r
-       cq_ioctl.in.context = h_cq;\r
+       cq_ioctl.in.h_wait_obj = HandleToHandle64( p_cq_create->h_wait_obj );\r
+       cq_ioctl.in.context = (ULONG_PTR)h_cq;\r
        cq_ioctl.in.ev_notify = (h_cq->pfn_event_cb != NULL) ? TRUE : FALSE;\r
 \r
        cl_status = do_al_dev_ioctl( UAL_CREATE_CQ,\r
index 9e454bd..e175ee5 100644 (file)
@@ -202,7 +202,7 @@ ual_send_one_mad(
        AL_ENTER( AL_DBG_MAD );\r
 \r
        CL_ASSERT( p_mad_element );\r
-    cl_memclr(&ioctl_buf, sizeof(ioctl_buf));\r
+\r
        p_al_element = PARENT_STRUCT(\r
                p_mad_element, al_mad_element_t, element );\r
 \r
@@ -223,9 +223,9 @@ ual_send_one_mad(
        else\r
                ioctl_buf.in.h_av = AL_INVALID_HANDLE;\r
 \r
-       ioctl_buf.in.p_mad_element = p_mad_element;\r
+       ioctl_buf.in.p_mad_element = (ULONG_PTR)p_mad_element;\r
        ioctl_buf.in.size = p_mad_element->size;\r
-       ioctl_buf.in.ph_proxy = &p_al_element->h_proxy_element;\r
+       ioctl_buf.in.ph_proxy = (ULONG_PTR)&p_al_element->h_proxy_element;\r
 \r
        cl_status = do_al_dev_ioctl( UAL_MAD_SEND,\r
                &ioctl_buf.in, sizeof(ioctl_buf.in),\r
@@ -439,7 +439,7 @@ ual_get_recv_mad(
         * Note that we issue the IOCTL regardless of failure of ib_get_mad.\r
         * This is done in order to release the kernel-mode MAD.\r
         */\r
-       ioctl_buf.in.p_user_mad = p_mad;\r
+       ioctl_buf.in.p_user_mad = (ULONG_PTR)p_mad;\r
 \r
        if( p_mad )\r
        {\r
@@ -447,8 +447,8 @@ ual_get_recv_mad(
                p_mad_buf = p_mad->p_mad_buf;\r
                p_grh = p_mad->p_grh;\r
 \r
-               ioctl_buf.in.p_mad_buf = p_mad_buf;\r
-               ioctl_buf.in.p_grh = p_grh;\r
+               ioctl_buf.in.p_mad_buf = (ULONG_PTR)p_mad_buf;\r
+               ioctl_buf.in.p_grh = (ULONG_PTR)p_grh;\r
        }\r
        ioctl_buf.in.h_mad = h_mad;\r
 \r
@@ -500,7 +500,7 @@ ual_local_mad(
        ib_api_status_t                         status = IB_SUCCESS;\r
 \r
        AL_ENTER( AL_DBG_CA );\r
-    cl_memclr(&local_mad_ioctl, sizeof (local_mad_ioctl));\r
+\r
        local_mad_ioctl.in.h_ca = h_ca->obj.p_ci_ca->obj.hdl;\r
        local_mad_ioctl.in.port_num = port_num;\r
        cl_memcpy( local_mad_ioctl.in.mad_in, p_mad_in,\r
index 01253bd..7c17f07 100644 (file)
@@ -99,7 +99,7 @@ ual_attach_mcast(
                status = ioctl_buf.out.status;\r
                if( status == IB_SUCCESS ){\r
                        h_mcast->obj.hdl = ioctl_buf.out.h_attach;\r
-                       h_mcast->h_ci_mcast = (ib_mcast_handle_t) HDL_TO_PTR(ioctl_buf.out.h_attach);\r
+                       h_mcast->h_ci_mcast = (ib_mcast_handle_t)(ULONG_PTR)ioctl_buf.out.h_attach;\r
                }\r
        }\r
 \r
index e5f7c90..e92ac6b 100644 (file)
@@ -162,11 +162,11 @@ ual_create_async_file(
        uintn_t                                 bytes_ret;\r
 \r
        AL_ENTER( AL_DBG_MGR );\r
-    cl_memclr(&ioctl, sizeof (ual_bind_file_ioctl_t));\r
+\r
        /* Create a file object on which to issue all SA requests. */\r
-       ioctl.h_file = CreateFileW( L"\\\\.\\ibal",\r
+       ioctl.h_file = HandleToHandle64( CreateFileW( L"\\\\.\\ibal",\r
                GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,\r
-               NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL );\r
+               NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL ) );\r
        if( ioctl.h_file == INVALID_HANDLE_VALUE )\r
        {\r
                AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR,\r
@@ -646,11 +646,12 @@ __process_misc_cb(
                /* We got a send completion. */\r
                ib_mad_element_t                        *p_element;\r
 \r
-               ib_mad_svc_handle_t                     h_mad_svc = (ib_mad_svc_handle_t)\r
+               ib_mad_svc_handle_t                     h_mad_svc = (ib_mad_svc_handle_t)(ULONG_PTR)\r
                        p_misc_cb_info->ioctl_rec.mad_send_cb_ioctl_rec.mad_svc_context;\r
 \r
                /* Copy the data to the user's element. */\r
-               p_element = p_misc_cb_info->ioctl_rec.mad_send_cb_ioctl_rec.p_um_mad;\r
+               p_element = (ib_mad_element_t*)(ULONG_PTR)\r
+                       p_misc_cb_info->ioctl_rec.mad_send_cb_ioctl_rec.p_um_mad;\r
                /* Only update the status if a receive wasn't failed. */\r
                if( p_element->status != IB_WCS_TIMEOUT_RETRY_ERR )\r
                {\r
@@ -682,10 +683,10 @@ __process_misc_cb(
                ib_mad_t                                *p_mad_buf = NULL;\r
                ib_grh_t                                *p_grh = NULL;\r
 \r
-               h_mad_svc = (ib_mad_svc_handle_t)\r
+               h_mad_svc = (ib_mad_svc_handle_t)(ULONG_PTR)\r
                        p_misc_cb_info->ioctl_rec.mad_recv_cb_ioctl_rec.mad_svc_context;\r
 \r
-               p_send_mad =\r
+               p_send_mad = (ib_mad_element_t*)(ULONG_PTR)\r
                        p_misc_cb_info->ioctl_rec.mad_recv_cb_ioctl_rec.p_send_mad;\r
 \r
                cl_memclr( &ioctl_buf, sizeof(ioctl_buf) );\r
@@ -708,7 +709,7 @@ __process_misc_cb(
                else if( p_send_mad )\r
                        p_send_mad->status = IB_WCS_TIMEOUT_RETRY_ERR;\r
 \r
-               ioctl_buf.in.p_user_mad = p_mad;\r
+               ioctl_buf.in.p_user_mad = (ULONG_PTR)p_mad;\r
 \r
                if( p_mad )\r
                {\r
@@ -716,8 +717,8 @@ __process_misc_cb(
                        p_mad_buf = p_mad->p_mad_buf;\r
                        p_grh = p_mad->p_grh;\r
 \r
-                       ioctl_buf.in.p_mad_buf = p_mad_buf;\r
-                       ioctl_buf.in.p_grh = p_grh;\r
+                       ioctl_buf.in.p_mad_buf = (ULONG_PTR)p_mad_buf;\r
+                       ioctl_buf.in.p_grh = (ULONG_PTR)p_grh;\r
                }\r
                ioctl_buf.in.h_mad = p_misc_cb_info->ioctl_rec.mad_recv_cb_ioctl_rec.h_mad;\r
 \r
index 0274d2d..3d58cd0 100644 (file)
@@ -80,7 +80,7 @@ ual_allocate_pd(
 \r
        pd_ioctl.in.h_ca = h_ca->obj.p_ci_ca->obj.hdl;\r
        pd_ioctl.in.type = pd_type;\r
-       pd_ioctl.in.context = h_pd;\r
+       pd_ioctl.in.context = (ULONG_PTR)h_pd;\r
 \r
        cl_status = do_al_dev_ioctl( UAL_ALLOC_PD,\r
                &pd_ioctl.in, sizeof(pd_ioctl.in), &pd_ioctl.out, sizeof(pd_ioctl.out),\r
index 7c9366a..d0eb397 100644 (file)
@@ -321,14 +321,14 @@ ib_reg_pnp(
 \r
        /* Copy the request information. */\r
        p_reg->pfn_pnp_cb = p_pnp_req->pfn_pnp_cb;\r
-    cl_memclr(&in, sizeof(in));\r
+\r
        in.pnp_class = p_pnp_req->pnp_class;\r
-       in.p_status = &status;\r
-       in.p_hdl = &p_reg->obj.hdl;\r
+       in.p_status = (ULONG_PTR)&status;\r
+       in.p_hdl = (ULONG_PTR)&p_reg->obj.hdl;\r
 \r
        if( pnp_get_flag( p_pnp_req->pnp_class ) & IB_PNP_FLAG_REG_SYNC )\r
        {\r
-               in.sync_event = CreateEvent( NULL, FALSE, FALSE, NULL );\r
+               in.sync_event = HandleToHandle64( CreateEvent( NULL, FALSE, FALSE, NULL ) );\r
                if( !in.sync_event )\r
                {\r
                        p_reg->obj.pfn_destroy( &p_reg->obj, NULL );\r
@@ -458,9 +458,10 @@ __pnp_async_cb(
        AL_ENTER( AL_DBG_PNP );\r
 \r
        p_reg = PARENT_STRUCT( p_item, al_pnp_t, async_item );\r
-    cl_memclr(&in, sizeof(in));\r
+\r
        in.pnp_hdl = p_reg->obj.hdl;\r
        in.last_evt_hdl = p_reg->rearm.evt_hdl;\r
+       in.last_evt_context = 0;\r
 \r
        if( p_reg->rearm.evt_size )\r
        {\r
@@ -491,12 +492,11 @@ __pnp_async_cb(
                                }\r
                                p_pnp_rec->pnp_context = (void*)p_reg->obj.context;\r
                                in.last_evt_status = p_reg->pfn_pnp_cb( p_pnp_rec );\r
-                               in.last_evt_context = p_pnp_rec->context;\r
+                               in.last_evt_context = (ULONG_PTR)p_pnp_rec->context;\r
                        }\r
                        else\r
                        {\r
                                in.last_evt_status = IB_SUCCESS;\r
-                               in.last_evt_context = NULL;\r
                        }\r
 \r
                        if( p_pnp_rec )\r
@@ -505,13 +505,11 @@ __pnp_async_cb(
                else\r
                {\r
                        in.last_evt_status = IB_SUCCESS;\r
-                       in.last_evt_context = NULL;\r
                }\r
        }\r
        else\r
        {\r
                in.last_evt_status = IB_SUCCESS;\r
-               in.last_evt_context = NULL;\r
        }\r
 \r
        /* Request the next PnP event. */\r
index b7996b8..f7eb650 100644 (file)
@@ -320,7 +320,7 @@ ual_create_qp(
        if (p_qp_create->h_srq)\r
                qp_ioctl.in.qp_create.h_srq =\r
                        (ib_srq_handle_t)HDL_TO_PTR(p_qp_create->h_srq->obj.hdl);\r
-       qp_ioctl.in.context = h_qp;\r
+       qp_ioctl.in.context = (ULONG_PTR)h_qp;\r
        qp_ioctl.in.ev_notify = (h_qp->pfn_event_cb != NULL) ? TRUE : FALSE;\r
 \r
        cl_status = do_al_dev_ioctl( UAL_CREATE_QP,\r
@@ -620,7 +620,7 @@ ual_init_qp_alias(
                qp_ioctl.in.h_pd = h_pd->obj.hdl;\r
                qp_ioctl.in.port_guid = port_guid;\r
                qp_ioctl.in.qp_create = *p_qp_create;\r
-               qp_ioctl.in.context = &p_qp_alias->qp;\r
+               qp_ioctl.in.context = (ULONG_PTR)&p_qp_alias->qp;\r
 \r
                cl_status = do_al_dev_ioctl( UAL_GET_SPL_QP_ALIAS,\r
                        &qp_ioctl.in, sizeof(qp_ioctl.in),\r
index a22222f..5f1363c 100644 (file)
@@ -198,8 +198,8 @@ al_send_sa_req(
        p_sa_req->ioctl.in.sa_req = *p_sa_req_data;\r
        cl_memcpy( p_sa_req->ioctl.in.attr,\r
                p_sa_req_data->p_attr, p_sa_req_data->attr_size );\r
-       p_sa_req->ioctl.in.ph_sa_req = &p_sa_req->hdl;\r
-       p_sa_req->ioctl.in.p_status = &p_sa_req->status;\r
+       p_sa_req->ioctl.in.ph_sa_req = (ULONG_PTR)&p_sa_req->hdl;\r
+       p_sa_req->ioctl.in.p_status = (ULONG_PTR)&p_sa_req->status;\r
 \r
        if( flags & IB_FLAGS_SYNC )\r
                h_dev = g_al_device;\r
@@ -299,7 +299,7 @@ al_cancel_sa_req(
        size_t                                          bytes_ret;\r
 \r
        AL_ENTER( AL_DBG_SA_REQ );\r
-    cl_memclr(&ioctl, sizeof(ioctl));\r
+\r
        ioctl.h_sa_req = p_sa_req->hdl;\r
 \r
        do_al_dev_ioctl(\r
index 9327833..a9d0d1e 100644 (file)
@@ -200,7 +200,7 @@ ual_create_srq(
         */\r
        srq_ioctl.in.h_pd = h_pd->obj.hdl;\r
        srq_ioctl.in.srq_attr = *p_srq_attr;\r
-       srq_ioctl.in.context = h_srq;\r
+       srq_ioctl.in.context = (ULONG_PTR)h_srq;\r
        srq_ioctl.in.ev_notify = (h_srq->pfn_event_cb != NULL) ? TRUE : FALSE;\r
 \r
        cl_status = do_al_dev_ioctl( UAL_CREATE_SRQ,\r
index e62d8ae..0a67f0c 100644 (file)
@@ -42,7 +42,6 @@
 #include <iba/ib_al.h>\r
 \r
 \r
-\r
 /*\r
 * Typedefs\r
 *\r
@@ -70,7 +69,7 @@
 */\r
 typedef struct _ual_bind_file_ioctl\r
 {\r
-       TO_LONG_PTR(void* ,                     h_file) ;\r
+       void* __ptr64                   h_file; /* __ptr64 is correct for HANDLE types. */\r
 \r
 }      ual_bind_file_ioctl_t;\r
 /*\r
@@ -146,7 +145,7 @@ typedef union _ual_open_ca_ioctl
        {\r
                ci_umv_buf_t                            umv_buf;\r
                ib_net64_t                                      guid;\r
-               TO_LONG_PTR(void* ,                             context) ;\r
+               uint64_t                                        context;\r
 \r
        }       in;\r
 \r
@@ -203,7 +202,7 @@ typedef union _ual_query_ca_ioctl
                ci_umv_buf_t                            umv_buf;\r
                uint64_t                                        h_ca;\r
                uint32_t                                        byte_cnt;\r
-               TO_LONG_PTR(ib_ca_attr_t* ,             p_ca_attr) ;\r
+               uint64_t                                        p_ca_attr;\r
 \r
        }       in;\r
        struct _ual_query_ca_ioctl_out\r
@@ -414,7 +413,7 @@ typedef union _ual_alloc_pd_ioctl
                ci_umv_buf_t                            umv_buf;\r
                uint64_t                                        h_ca;\r
                ib_pd_type_t                            type;\r
-               TO_LONG_PTR(void* ,                             context) ;\r
+               uint64_t                                        context;\r
 \r
        }       in;\r
        struct _ual_alloc_pd_ioctl_out\r
@@ -687,14 +686,14 @@ typedef union _ual_create_srq_ioctl
                ci_umv_buf_t                            umv_buf;\r
                uint64_t                                        h_pd;\r
                ib_srq_attr_t                           srq_attr;\r
-               TO_LONG_PTR(void* ,                             context) ;\r
-               boolean_t                               ev_notify;\r
+               uint64_t                                        context;\r
+               boolean_t                                       ev_notify;\r
 \r
        }       in;\r
        struct _ual_create_srq_ioctl_out\r
        {\r
                ci_umv_buf_t                            umv_buf;\r
-               ib_api_status_t                 status;\r
+               ib_api_status_t                         status;\r
                uint64_t                                        h_srq;\r
 \r
        }       out;\r
@@ -883,7 +882,7 @@ typedef union _ual_create_qp_ioctl
                ci_umv_buf_t                            umv_buf;\r
                uint64_t                                        h_pd;\r
                ib_qp_create_t                          qp_create;\r
-               TO_LONG_PTR(void* ,                             context) ;\r
+               uint64_t                                        context;\r
                boolean_t                                       ev_notify;\r
 \r
        }       in;\r
@@ -1086,8 +1085,8 @@ typedef union _ual_create_cq_ioctl
        {\r
                ci_umv_buf_t                            umv_buf;\r
                uint64_t                                        h_ca;\r
-               TO_LONG_PTR(void* ,                             h_wait_obj) ;\r
-               TO_LONG_PTR(void* ,                             context) ;\r
+               void* __ptr64                           h_wait_obj;     /* __ptr64 is correct for HANDLE types. */\r
+               uint64_t                                        context;\r
                uint32_t                                        size;\r
                boolean_t                                       ev_notify;\r
 \r
@@ -2288,9 +2287,9 @@ typedef union _ual_send_mad_ioctl
                uint64_t                                                h_mad_svc;\r
                uint64_t                                                pool_key;\r
                uint64_t                                                h_av;\r
-               TO_LONG_PTR(ib_mad_element_t* ,         p_mad_element) ;\r
+               uint64_t                                                p_mad_element;\r
                uint32_t                                                size;\r
-               TO_LONG_PTR(void* *, /*__ptr64*/                ph_proxy) ;\r
+               uint64_t                                                ph_proxy;\r
 \r
        }       in;\r
        struct _ual_send_mad_ioctl_out\r
@@ -2341,7 +2340,7 @@ typedef union _ual_cancel_mad_ioctl
        struct _ual_cancel_mad_ioctl_in\r
        {\r
                uint64_t                                        h_mad_svc;\r
-               TO_LONG_PTR(void* ,                             h_proxy_element) ;\r
+               uint64_t                                        h_proxy_element;\r
 \r
        }       in;\r
        struct _ual_cancel_mad_ioctl_out\r
@@ -2383,7 +2382,7 @@ typedef union _ual_spl_qp_ioctl
                uint64_t                                        h_pd;\r
                ib_net64_t                                      port_guid;\r
                ib_qp_create_t                          qp_create;\r
-               TO_LONG_PTR(void* ,                             context) ;\r
+               uint64_t                                        context;\r
 \r
        }       in;\r
        struct _ual_spl_qp_ioctl_out\r
@@ -2433,9 +2432,9 @@ typedef union _ual_mad_recv_ioctl
        struct _ual_mad_recv_comp_ioctl_in\r
        {\r
                uint64_t                                        h_mad;\r
-               TO_LONG_PTR(ib_mad_element_t* , p_user_mad) ;\r
-               TO_LONG_PTR(ib_mad_t* ,                 p_mad_buf) ;\r
-               TO_LONG_PTR(ib_grh_t* ,                 p_grh) ;\r
+               uint64_t                                        p_user_mad;\r
+               uint64_t                                        p_mad_buf;\r
+               uint64_t                                        p_grh;\r
 \r
        }       in;\r
        struct _ual_mad_recv_comp_ioctl_out\r
@@ -2481,13 +2480,13 @@ typedef union _ual_local_mad_ioctl
        {\r
                uint64_t                                        h_ca;\r
                __declspec(align(8)) uint8_t mad_in[MAD_BLOCK_SIZE];\r
-               uint8_t                                         port_num;\r
+               uint8_t                                 port_num;\r
                \r
                \r
        }       in;\r
        struct _ual_local_mad_ioctl_out\r
        {\r
-               ib_api_status_t                         status;\r
+               ib_api_status_t                 status;\r
                uint32_t                                        _pad; /* 8-byte alignment needed for ia64 */\r
                __declspec(align(8)) uint8_t mad_out[MAD_BLOCK_SIZE];\r
 \r
@@ -2537,29 +2536,6 @@ typedef struct _ual_create_cep_ioctl
 *              CID of the created CEP.\r
 *****/\r
 \r
-/****s* User-mode Access Layer/ual_create_cep_ioctl_in\r
-* NAME\r
-*      ual_create_cep_ioctl_in\r
-*\r
-* DESCRIPTION\r
-*      IOCTL structure containing the input parameters to\r
-*      create a CEP.\r
-*\r
-* SYNOPSIS\r
-*/\r
-\r
-typedef struct _ual_create_cep_ioctl_in\r
-{\r
-    TO_LONG_PTR(void* , context);\r
-} ual_create_cep_ioctl_in;\r
-\r
-/*\r
-* FIELDS\r
-*      context\r
-*              \r
-*              \r
-*****/\r
-\r
 \r
 /****s* User-mode Access Layer/ual_cep_listen_ioctl_t\r
 * NAME\r
@@ -2653,7 +2629,7 @@ typedef union _ual_cep_rep_ioctl
 {\r
        struct _ual_cep_rep_ioctl_in\r
        {\r
-               TO_LONG_PTR(void* ,                             context) ;\r
+               uint64_t                                        context;\r
                net32_t                                         cid;\r
                ib_cm_rep_t                                     cm_rep;\r
                uint8_t                                         pdata[IB_REP_PDATA_SIZE];\r
@@ -3077,7 +3053,7 @@ typedef struct _ual_cep_get_timewait_ioctl
 typedef struct _ual_cep_poll_ioctl\r
 {\r
        ib_api_status_t                         status;\r
-       TO_LONG_PTR(void* ,                             context) ;\r
+       uint64_t                                        context;\r
        net32_t                                         new_cid;\r
        ib_mad_element_t                        element;\r
        ib_grh_t                                        grh;\r
@@ -3229,8 +3205,8 @@ typedef union _ual_send_sa_req_ioctl
                uint32_t                                        retry_cnt;\r
                ib_user_query_t                         sa_req;\r
                uint8_t                                         attr[IB_SA_DATA_SIZE];\r
-               TO_LONG_PTR(uint64_t* ,                 ph_sa_req) ;\r
-               TO_LONG_PTR(ib_api_status_t* ,  p_status) ;\r
+               uint64_t                                        ph_sa_req;\r
+               uint64_t                                        p_status;\r
 \r
        }       in;\r
        struct _ual_send_sa_req_ioctl_out\r
@@ -3305,9 +3281,9 @@ typedef struct _ual_cancel_sa_req_ioctl
 typedef struct _ual_reg_pnp_ioctl_in\r
 {\r
        ib_pnp_class_t                          pnp_class;\r
-       TO_LONG_PTR(void* ,                             sync_event) ;\r
-       TO_LONG_PTR(ib_api_status_t* ,  p_status) ;\r
-       TO_LONG_PTR(uint64_t* ,                 p_hdl) ;\r
+       void* __ptr64                           sync_event; /* __ptr64 is correct for HANDLE types. */\r
+       uint64_t                                        p_status;\r
+       uint64_t                                        p_hdl;\r
 \r
 }      ual_reg_pnp_ioctl_in_t;\r
 /*\r
@@ -3381,7 +3357,7 @@ typedef struct _ual_rearm_pnp_ioctl_in
 {\r
        uint64_t                                        pnp_hdl;\r
        uint64_t                                        last_evt_hdl;\r
-       TO_LONG_PTR(void* ,                             last_evt_context) ;\r
+       uint64_t                                        last_evt_context;\r
        ib_api_status_t                         last_evt_status;\r
 \r
 }      ual_rearm_pnp_ioctl_in_t;\r
@@ -3508,6 +3484,7 @@ typedef struct _ual_ndi_req_cm_ioctl_in
        uint64_t                                        h_qp;\r
        net64_t                                         guid;\r
        uint16_t                                        dst_port;\r
+    uint16_t                    pkey;\r
     uint8_t                     resp_res;\r
     uint8_t                     init_depth;\r
        uint8_t                                         prot;\r
@@ -3529,6 +3506,9 @@ typedef struct _ual_ndi_req_cm_ioctl_in
 *      dst_port\r
 *              Destination port number.\r
 *\r
+*   pkey\r
+*       Partition key.\r
+*\r
 *   resp_res\r
 *       Responder resources for the QP.\r
 *\r
@@ -3583,7 +3563,7 @@ typedef struct _ual_ndi_rep_cm_ioctl_in
 *      resp_res\r
 *              The maximum number of RDMA read/atomic operations from the recipient.\r
 *\r
-*      pdata_size\r
+*      pdata_size\r
 *              The size of following private data\r
 *\r
 *      pdata\r
@@ -3616,7 +3596,7 @@ typedef struct _ual_ndi_rej_cm_ioctl_in
 *      cid\r
 *              Connection ID.\r
 *\r
-*      pdata_size\r
+*      pdata_size\r
 *              The size of following private data\r
 *\r
 *      pdata\r