[ipoib] Added support for Cisco GUIDs.
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 31 Jan 2008 09:20:41 +0000 (09:20 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 31 Jan 2008 09:20:41 +0000 (09:20 +0000)
[IBAL, MTHCA] (user space) changed low-level IBAL interface to facilitate (for verb provider) creation of objects in pre- functions.
[ALL] added NDI support.

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@931 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

103 files changed:
core/al/al_cm_cep.h
core/al/al_cm_qp.c
core/al/al_common.c
core/al/al_common.h
core/al/al_cq.c
core/al/al_cq.h
core/al/al_debug.h
core/al/al_dev.h
core/al/al_pd.c
core/al/al_proxy.h
core/al/al_proxy_ndi.h [new file with mode: 0644]
core/al/al_qp.c
core/al/al_qp.h
core/al/al_query.c
core/al/al_verbs.h
core/al/kernel/SOURCES
core/al/kernel/al_cm_cep.c
core/al/kernel/al_dev.c
core/al/kernel/al_ioc_pnp.c
core/al/kernel/al_ndi_cm.c [new file with mode: 0644]
core/al/kernel/al_ndi_cm.h [new file with mode: 0644]
core/al/kernel/al_ndi_cq.c [new file with mode: 0644]
core/al/kernel/al_ndi_cq.h [new file with mode: 0644]
core/al/kernel/al_pnp.c
core/al/kernel/al_proxy.c
core/al/kernel/al_proxy_cep.c
core/al/kernel/al_proxy_ndi.c [new file with mode: 0644]
core/al/kernel/al_proxy_verbs.c
core/al/user/ual_av.c
core/al/user/ual_ca.c
core/al/user/ual_ci_ca.h
core/al/user/ual_cq.c
core/al/user/ual_mcast.c
core/al/user/ual_mw.c
core/al/user/ual_pd.c
core/al/user/ual_qp.c
core/al/user/ual_srq.c
core/bus/kernel/bus_iou_mgr.c
core/bus/kernel/bus_port_mgr.c
core/complib/kernel/cl_driver.c
core/iou/kernel/iou_ioc_mgr.c
hw/mt23108/kernel/hca_driver.c
hw/mt23108/user/mlnx_ual_av.c
hw/mt23108/user/mlnx_ual_ca.c
hw/mt23108/user/mlnx_ual_cq.c
hw/mt23108/user/mlnx_ual_main.h
hw/mt23108/user/mlnx_ual_mcast.c
hw/mt23108/user/mlnx_ual_mrw.c
hw/mt23108/user/mlnx_ual_pd.c
hw/mt23108/user/mlnx_ual_qp.c
hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdConf.c
hw/mthca/kernel/hca_driver.c
hw/mthca/kernel/hca_verbs.c
hw/mthca/user/mlnx_ual_av.c
hw/mthca/user/mlnx_ual_ca.c
hw/mthca/user/mlnx_ual_cq.c
hw/mthca/user/mlnx_ual_main.c
hw/mthca/user/mlnx_ual_main.h
hw/mthca/user/mlnx_ual_mcast.c
hw/mthca/user/mlnx_ual_mrw.c
hw/mthca/user/mlnx_ual_osbypass.c
hw/mthca/user/mlnx_ual_pd.c
hw/mthca/user/mlnx_ual_qp.c
hw/mthca/user/mlnx_ual_srq.c
hw/mthca/user/mlnx_uvp.h
hw/mthca/user/mlnx_uvp_cq.c
hw/mthca/user/mlnx_uvp_qp.c
inc/complib/cl_types.h
inc/iba/ib_al_ioctl.h
inc/iba/ib_at_ioctl.h
inc/iba/ib_ci.h
inc/iba/ib_types.h
inc/kernel/complib/cl_types_osd.h
inc/user/iba/ib_uvp.h
tests/alts/createanddestroycq.c
tests/alts/user/SOURCES
tests/cmtest/user/SOURCES
tests/ibat/user/SOURCES
tests/limits/user/SOURCES
tests/wsd/user/ttcp/SOURCES
tools/fwupdate/user/SOURCES
tools/perftests/user/read_bw/SOURCES
tools/perftests/user/read_lat/SOURCES
tools/perftests/user/send_bw/SOURCES
tools/perftests/user/send_lat/SOURCES
tools/perftests/user/write_bw/SOURCES
tools/perftests/user/write_lat/SOURCES
tools/vstat/user/SOURCES
tools/vstat/user/vstat_main.c
tools/wsdinstall/user/SOURCES
ulp/dapl/dapl/udapl/SOURCES
ulp/dapl/dat/udat/SOURCES
ulp/ipoib/kernel/ipoib_adapter.c
ulp/ipoib/kernel/ipoib_driver.c
ulp/ipoib/kernel/ipoib_ibat.c
ulp/ipoib/kernel/ipoib_port.c
ulp/ipoib/kernel/ipoib_xfr_mgr.h
ulp/opensm/user/ibtrapgen/SOURCES
ulp/opensm/user/include/iba/ib_types.h
ulp/opensm/user/opensm/SOURCES
ulp/opensm/user/osmtest/SOURCES
ulp/srp/kernel/srp_hba.c
ulp/srp/kernel/srp_session.c

index a3f3307..9d06785 100644 (file)
@@ -55,6 +55,7 @@
 \r
 \r
 #define AL_INVALID_CID         0xFFFFFFFF\r
+#define AL_RESERVED_CID                0\r
 \r
 \r
 typedef void\r
@@ -144,6 +145,14 @@ al_cep_pre_rep(
        IN              const   ib_cm_rep_t* const                      p_cm_rep,\r
                OUT                     ib_qp_mod_t* const                      p_init );\r
 \r
+ib_api_status_t\r
+al_cep_pre_rep_ex(\r
+       IN                              ib_al_handle_t                          h_al,\r
+       IN                              net32_t                                         cid,\r
+       IN                              al_pfn_cep_cb_t                         pfn_cb,\r
+       IN                              void* __ptr64                           context,\r
+       IN              const   ib_cm_rep_t* const                      p_cm_rep,\r
+               OUT                     ib_qp_mod_t* const                      p_init );\r
 \r
 ib_api_status_t\r
 al_cep_send_rep(\r
@@ -256,11 +265,34 @@ al_cep_poll(
 \r
 \r
 #ifdef CL_KERNEL\r
+\r
 NTSTATUS\r
 al_cep_queue_irp(\r
        IN                              ib_al_handle_t                          h_al,\r
        IN                              net32_t                                         cid,\r
        IN                              IRP* const                                      p_irp );\r
+\r
+NTSTATUS\r
+al_cep_get_cid(\r
+       IN              ib_al_handle_t                                          h_al,\r
+       IN              net32_t                 const                           cid,\r
+       IN              PIRP                                                            h_ioctl\r
+       );\r
+\r
+ib_api_status_t\r
+al_cep_get_pdata(\r
+       IN                              ib_al_handle_t                          h_al,\r
+       IN                              net32_t                                         cid,\r
+       IN      OUT                     uint8_t                                         *p_psize,\r
+               OUT                     uint8_t*                                        pdata );\r
+\r
+ib_api_status_t\r
+al_cep_set_pdata(\r
+       IN                              ib_al_handle_t                          h_al,\r
+       IN                              net32_t                                         cid,\r
+       IN                              uint8_t                                         psize,\r
+       IN                              uint8_t*                                        pdata );\r
+\r
 #endif /* CL_KERNEL */\r
 \r
 \r
index 187a81d..468216a 100644 (file)
@@ -528,7 +528,7 @@ __proc_rej(
                __cep_timewait_qp( p_cm->h_qp );\r
 \r
                cid = cl_atomic_xchg( &((al_conn_qp_t*)p_cm->h_qp)->cid, AL_INVALID_CID );\r
-               CL_ASSERT( cid == p_cm->cid || cid == AL_INVALID_CID );\r
+               CL_ASSERT( cid == p_cm->cid || cid == AL_INVALID_CID || cid == AL_RESERVED_CID );\r
                if( cid == AL_INVALID_CID ||\r
                        al_destroy_cep( p_cm->h_al, cid, deref_al_obj ) != IB_SUCCESS )\r
                {\r
@@ -788,12 +788,14 @@ __proc_conn(
        {\r
        case CM_REQ_ATTR_ID:\r
                CL_ASSERT( ((al_conn_qp_t*)p_cm->h_qp)->cid == (int32_t)p_cm->cid ||\r
+                       ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_RESERVED_CID ||\r
                        ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_INVALID_CID );\r
                __proc_peer_req( p_cm, (mad_cm_req_t*)p_mad );\r
                break;\r
 \r
        case CM_MRA_ATTR_ID:\r
                CL_ASSERT( ((al_conn_qp_t*)p_cm->h_qp)->cid == (int32_t)p_cm->cid ||\r
+                       ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_RESERVED_CID ||\r
                        ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_INVALID_CID );\r
                __proc_mra( p_cm, (mad_cm_mra_t*)p_mad );\r
                break;\r
@@ -804,12 +806,14 @@ __proc_conn(
 \r
        case CM_REP_ATTR_ID:\r
                CL_ASSERT( ((al_conn_qp_t*)p_cm->h_qp)->cid == (int32_t)p_cm->cid ||\r
+                       ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_RESERVED_CID ||\r
                        ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_INVALID_CID );\r
                __proc_rep( p_cm, (mad_cm_rep_t*)p_mad );\r
                break;\r
 \r
        case CM_RTU_ATTR_ID:\r
                CL_ASSERT( ((al_conn_qp_t*)p_cm->h_qp)->cid == (int32_t)p_cm->cid ||\r
+                       ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_RESERVED_CID ||\r
                        ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_INVALID_CID );\r
                __proc_rtu( p_cm, (mad_cm_rtu_t*)p_mad );\r
                break;\r
@@ -822,12 +826,14 @@ __proc_conn(
 \r
        case CM_DREP_ATTR_ID:\r
                CL_ASSERT( ((al_conn_qp_t*)p_cm->h_qp)->cid == (int32_t)p_cm->cid ||\r
+                       ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_RESERVED_CID ||\r
                        ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_INVALID_CID );\r
                __proc_drep( p_cm, (mad_cm_drep_t*)p_mad );\r
                break;\r
 \r
        case CM_LAP_ATTR_ID:\r
                CL_ASSERT( ((al_conn_qp_t*)p_cm->h_qp)->cid == (int32_t)p_cm->cid ||\r
+                       ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_RESERVED_CID ||\r
                        ((al_conn_qp_t*)p_cm->h_qp)->cid == AL_INVALID_CID );\r
                __proc_lap( p_cm, (mad_cm_lap_t*)p_mad );\r
                break;\r
index 722c32f..29e1ee1 100644 (file)
@@ -121,7 +121,8 @@ const char* ib_obj_type_str[] =
        "AL_OBJ_TYPE_H_SA_REG",\r
        "AL_OBJ_TYPE_H_FMR",\r
        "AL_OBJ_TYPE_H_SRQ",\r
-       "AL_OBJ_TYPE_H_FMR_POOL"\r
+       "AL_OBJ_TYPE_H_FMR_POOL",\r
+       "AL_OBJ_TYPE_NDI"\r
 };\r
 \r
 \r
index 84af999..78fb227 100644 (file)
@@ -164,7 +164,8 @@ typedef void
 #define AL_OBJ_TYPE_H_FMR                      40\r
 #define AL_OBJ_TYPE_H_SRQ                      41\r
 #define AL_OBJ_TYPE_H_FMR_POOL         42\r
-#define AL_OBJ_TYPE_INVALID            43      /* Must be last type. */\r
+#define AL_OBJ_TYPE_NDI                                43\r
+#define AL_OBJ_TYPE_INVALID            44      /* Must be last type. */\r
 \r
 /* Kernel object for a user-mode app. */\r
 #define AL_OBJ_SUBTYPE_UM_EXPORT       0x80000000\r
index 243be6e..e3bf855 100644 (file)
@@ -44,6 +44,9 @@
 #include "al_pd.h"\r
 #include "al_qp.h"\r
 #include "al_verbs.h"\r
+#ifdef CL_KERNEL\r
+#include "al_proxy_ndi.h"\r
+#endif\r
 \r
 /*\r
  * Function prototypes.\r
@@ -96,6 +99,14 @@ create_cq(
        {\r
                return IB_INSUFFICIENT_MEMORY;\r
        }\r
+\r
+#ifdef CL_KERNEL\r
+       if( !NT_SUCCESS( ndi_cq_init( h_cq ) ) )\r
+       {\r
+               free_cq( &h_cq->obj );\r
+               return IB_ERROR;\r
+       }\r
+#endif\r
        \r
        if( p_umv_buf )\r
                obj_type |= AL_OBJ_SUBTYPE_UM_EXPORT;\r
@@ -208,7 +219,14 @@ destroying_cq(
                        cl_spinlock_acquire( &h_cq->obj.lock );\r
                }\r
        }\r
+\r
        cl_spinlock_release( &h_cq->obj.lock );\r
+\r
+#ifdef CL_KERNEL\r
+       /* cancel pending IRPS for NDI type CQ */\r
+       ndi_cq_flush_ques( h_cq );\r
+#endif\r
+\r
 }\r
 \r
 \r
index d3ff456..d3e6c52 100644 (file)
@@ -35,8 +35,6 @@
 \r
 #include "al_ca.h"\r
 \r
-\r
-\r
 typedef void\r
 (*pfn_proc_comp_t)(\r
        IN              const   ib_cq_handle_t                          h_cq );\r
@@ -62,6 +60,18 @@ typedef ib_api_status_t
        IN              const   ib_cq_handle_t                          h_cq,\r
        IN              const   uint32_t                                        n_cqes );\r
 \r
+#ifdef CL_KERNEL\r
+\r
+typedef struct _ib_cq  ib_cq_t;\r
+\r
+typedef struct _ndi_cq_csq\r
+{\r
+       IO_CSQ                                          csq;\r
+       ib_cq_t*                                        h_cq;\r
+       LIST_ENTRY                                      que;\r
+} ndi_cq_csq_t;\r
+\r
+#endif\r
 \r
 /*\r
  * Completion queue information required by the access layer.  This structure\r
@@ -95,6 +105,12 @@ typedef struct _ib_cq
 \r
        ib_pfn_event_cb_t                       pfn_event_cb;\r
 \r
+       /* NDI CQ fields */\r
+#ifdef CL_KERNEL\r
+       ndi_cq_csq_t                            compl;\r
+       ndi_cq_csq_t                            error;\r
+#endif\r
+\r
 }      ib_cq_t;\r
 \r
 \r
index 3d24c19..d3f1534 100644 (file)
@@ -76,7 +76,7 @@ extern uint32_t                       g_al_dbg_flags;
        WPP_DEFINE_BIT( AL_DBG_QP)\\r
        WPP_DEFINE_BIT( AL_DBG_SRQ)\\r
        WPP_DEFINE_BIT( AL_DBG_MW)\\r
-       WPP_DEFINE_BIT( AL_DBG_RES4) \\r
+       WPP_DEFINE_BIT( AL_DBG_NDI) \\r
        WPP_DEFINE_BIT( AL_DBG_PROXY_CB)\\r
        WPP_DEFINE_BIT( AL_DBG_UAL)\\r
        WPP_DEFINE_BIT( AL_DBG_QUERY)\\r
@@ -111,7 +111,7 @@ extern uint32_t                     g_al_dbg_flags;
        WPP_DEFINE_BIT( AL_DBG_QP)\\r
        WPP_DEFINE_BIT( AL_DBG_SRQ)\\r
        WPP_DEFINE_BIT( AL_DBG_MW)\\r
-       WPP_DEFINE_BIT( AL_DBG_RES4) \\r
+       WPP_DEFINE_BIT( AL_DBG_NDI) \\r
        WPP_DEFINE_BIT( AL_DBG_PROXY_CB)\\r
        WPP_DEFINE_BIT( AL_DBG_UAL)\\r
        WPP_DEFINE_BIT( AL_DBG_QUERY)\\r
@@ -171,6 +171,7 @@ extern uint32_t                     g_al_dbg_flags;
 #define AL_DBG_QP              (1 << 19)\r
 #define AL_DBG_SRQ             (1 << 20)\r
 #define AL_DBG_MW              (1 << 21)\r
+#define AL_DBG_NDI             (1 << 22)\r
 #define AL_DBG_PROXY_CB        (1 << 23)\r
 #define AL_DBG_UAL             (1 << 24)\r
 #define AL_DBG_QUERY   (1 << 25)\r
index c201f32..cca9874 100644 (file)
@@ -45,7 +45,6 @@
 #ifndef _ALDEV_H_\r
 #define _ALDEV_H_\r
 \r
-\r
 #include <complib/comp_lib.h>\r
 #include <complib/cl_waitobj.h>\r
 #include <complib/cl_ioctl.h>\r
@@ -55,7 +54,8 @@
 #define AL_DEVICE_NAME L"\\Device\\ibal"\r
 #define        ALDEV_KEY               (0x3B)  /* Matches FILE_DEVICE_INFINIBAND from wdm.h */\r
 \r
-#define AL_IOCTL_VERSION                       (3)\r
+#define AL_IOCTL_VERSION                       (4)\r
+\r
 \r
 #ifdef CL_KERNEL\r
 \r
@@ -131,6 +131,7 @@ typedef enum al_proxy_ops
        ual_bind_cm,\r
        ual_bind_cq,\r
        ual_bind_destroy,\r
+       ual_bind_nd,\r
 \r
        al_proxy_maxops\r
 \r
@@ -154,6 +155,7 @@ typedef enum al_proxy_ops
 #define UAL_BIND_CM                    IOCTL_CODE(ALDEV_KEY, ual_bind_cm)\r
 #define UAL_BIND_CQ                    IOCTL_CODE(ALDEV_KEY, ual_bind_cq)\r
 #define UAL_BIND_DESTROY       IOCTL_CODE(ALDEV_KEY, ual_bind_destroy)\r
+#define UAL_BIND_ND                    IOCTL_CODE(ALDEV_KEY, ual_bind_nd)\r
 \r
 #define AL_PROXY_OPS_START     IOCTL_CODE(ALDEV_KEY, al_proxy_ops_start)\r
 #define AL_PROXY_MAXOPS                IOCTL_CODE(ALDEV_KEY, al_proxy_maxops)\r
@@ -315,7 +317,7 @@ typedef enum _al_cm_sidr_ops
        ((cmd) > AL_CM_OPS_START && (cmd) < AL_CM_MAXOPS)\r
 \r
 \r
-enum _ual_cep_ops\r
+typedef enum _ual_cep_ops\r
 {\r
        al_cep_ops_start = al_ioc_maxops,\r
        ual_create_cep,\r
@@ -338,6 +340,8 @@ enum _ual_cep_ops
        ual_cep_get_timewait,\r
        ual_cep_get_event,\r
        ual_cep_poll,\r
+       ual_cep_get_req_cid,\r
+       ual_cep_get_pdata,\r
 \r
        al_cep_maxops\r
 \r
@@ -374,8 +378,45 @@ typedef enum _al_dev_ops
 #define IS_AL_IOCTL(cmd)               \\r
        ((cmd) > AL_OPS_START && (cmd) < AL_MAXOPS)\r
 \r
+/* NDI ioctls */\r
+\r
+typedef enum _al_ndi_ops\r
+{\r
+       al_ndi_ops_start = al_maxops,\r
+\r
+       ual_ndi_create_cq_ioctl_cmd,\r
+       ual_ndi_notify_cq_ioctl_cmd,\r
+       ual_ndi_cancel_cq_ioctl_cmd,\r
+       ual_ndi_modify_qp_ioctl_cmd,\r
+       ual_ndi_req_cm_ioctl_cmd,\r
+       ual_ndi_rep_cm_ioctl_cmd,\r
+       ual_ndi_rtu_cm_ioctl_cmd,\r
+       ual_ndi_rej_cm_ioctl_cmd,\r
+       ual_ndi_dreq_cm_ioctl_cmd,\r
+\r
+       al_ndi_maxops\r
+\r
+}      al_ndi_ops_t;\r
+\r
+#define AL_NDI_OPS_START                       IOCTL_CODE(ALDEV_KEY, al_ndi_ops_start)\r
+#define AL_NDI_MAXOPS                          IOCTL_CODE(ALDEV_KEY, al_ndi_maxops)\r
+\r
+#define IS_NDI_IOCTL(cmd)              \\r
+       ((cmd) > AL_NDI_OPS_START && (cmd) < AL_NDI_MAXOPS)\r
+\r
+/* NDI Related ioctl commands */\r
+#define UAL_NDI_CREATE_CQ              IOCTL_CODE(ALDEV_KEY, ual_ndi_create_cq_ioctl_cmd)\r
+#define UAL_NDI_NOTIFY_CQ              IOCTL_CODE(ALDEV_KEY, ual_ndi_notify_cq_ioctl_cmd)\r
+#define UAL_NDI_CANCEL_CQ              IOCTL_CODE(ALDEV_KEY, ual_ndi_cancel_cq_ioctl_cmd)\r
+#define UAL_NDI_MODIFY_QP              IOCTL_CODE(ALDEV_KEY, ual_ndi_modify_qp_ioctl_cmd)\r
+#define UAL_NDI_REQ_CM                 IOCTL_CODE(ALDEV_KEY, ual_ndi_req_cm_ioctl_cmd)\r
+#define UAL_NDI_REP_CM                 IOCTL_CODE(ALDEV_KEY, ual_ndi_rep_cm_ioctl_cmd)\r
+#define UAL_NDI_RTU_CM                 IOCTL_CODE(ALDEV_KEY, ual_ndi_rtu_cm_ioctl_cmd)\r
+#define UAL_NDI_REJ_CM                 IOCTL_CODE(ALDEV_KEY, ual_ndi_rej_cm_ioctl_cmd)\r
+#define UAL_NDI_DREQ_CM                        IOCTL_CODE(ALDEV_KEY, ual_ndi_dreq_cm_ioctl_cmd)\r
+\r
 /*\r
- * Various Opration Allowable on the System Helper\r
+ * Various Operation Allowable on the System Helper\r
  */\r
 \r
 #define UAL_REG_SHMID          IOCTL_CODE(ALDEV_KEY, ual_reg_shmid_cmd)\r
@@ -474,6 +515,9 @@ typedef enum _al_dev_ops
 #define UAL_CEP_GET_TIMEWAIT   IOCTL_CODE(ALDEV_KEY, ual_cep_get_timewait)\r
 #define UAL_CEP_GET_EVENT      IOCTL_CODE(ALDEV_KEY, ual_cep_get_event)\r
 #define UAL_CEP_POLL           IOCTL_CODE(ALDEV_KEY, ual_cep_poll)\r
+#define UAL_CEP_GET_REQ_CID    IOCTL_CODE(ALDEV_KEY, ual_cep_get_req_cid)\r
+#define UAL_CEP_GET_PDATA      IOCTL_CODE(ALDEV_KEY, ual_cep_get_pdata)\r
+\r
 \r
 #define UAL_GET_CA_ATTR_INFO   IOCTL_CODE(ALDEV_KEY, ual_get_ca_attr)\r
 \r
index 5e19729..a9363ec 100644 (file)
@@ -334,17 +334,23 @@ ib_create_qp(
                return IB_INVALID_PD_HANDLE;\r
        }\r
 \r
-       if( !p_qp_create->rq_depth &&  !p_qp_create->sq_depth )\r
+#if 0\r
+       /* seems like no need in these checks */\r
+       if( !p_qp_create->rq_depth || !p_qp_create->sq_depth )\r
        {\r
-               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_MAX_WRS\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_MAX_WRS (%d:%d)\n",\r
+                       p_qp_create->rq_depth, p_qp_create->sq_depth ) );\r
                return IB_INVALID_MAX_WRS;\r
        }\r
-       if( !p_qp_create->sq_sge && !p_qp_create->sq_sge)\r
+\r
+       if( !p_qp_create->rq_sge || !p_qp_create->sq_sge)\r
        {\r
-               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_MAX_SGE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_MAX_SGE (%d:%d)\n", \r
+                       p_qp_create->rq_sge, p_qp_create->sq_sge ) );\r
                return IB_INVALID_MAX_SGE;\r
-\r
        }\r
+#endif \r
+\r
        if (h_pd->obj.p_ci_ca && h_pd->obj.p_ci_ca->p_pnp_attr)\r
        {\r
                if ((p_qp_create->rq_depth > h_pd->obj.p_ci_ca->p_pnp_attr->max_wrs) ||\r
index fccf903..ea39237 100644 (file)
@@ -54,7 +54,6 @@
 #include "al_proxy_ioctl.h"\r
 #include "al_mcast.h"\r
 \r
-\r
 #define AL_CB_POOL_START_SIZE                  10\r
 #define AL_CB_POOL_GROW_SIZE                   5\r
 \r
@@ -238,6 +237,10 @@ cl_status_t ioc_ioctl(
        IN              cl_ioctl_handle_t               h_ioctl,\r
                OUT     size_t                                  *p_ret_bytes );\r
 \r
+cl_status_t ndi_ioctl(\r
+       IN              cl_ioctl_handle_t               h_ioctl,\r
+               OUT     size_t                                  *p_ret_bytes );\r
+\r
 boolean_t\r
 proxy_queue_cb_buf(\r
        IN              uintn_t                                 cb_type,\r
diff --git a/core/al/al_proxy_ndi.h b/core/al/al_proxy_ndi.h
new file mode 100644 (file)
index 0000000..ff58962
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: al_proxy.h 33 2005-07-11 19:51:17Z ftillier $
+ */
+
+/*
+ * Abstract:
+ *     This header file defines data structures for the kernel-mode NDI support 
+ *
+ * Environment:
+ *     Kernel .
+ */
+
+
+#ifndef _ALPROXY_NDI_H_
+#define _ALPROXY_NDI_H_
+
+#include "complib/cl_ioctl_osd.h"
+#include "al_cq.h"
+#include "al_ndi_cq.h"
+#include "al_qp.h"
+#include "al_ndi_cm.h"
+
+/* functions from al_proxy_verbs.c */
+ib_api_status_t
+cpyin_umvbuf(
+       IN              ci_umv_buf_t    *p_src,
+               OUT     ci_umv_buf_t    **pp_dst );
+
+ib_api_status_t
+cpyout_umvbuf(
+       IN              ci_umv_buf_t    *p_dest,
+       IN              ci_umv_buf_t    *p_src);
+
+void
+free_umvbuf(
+       IN                              ci_umv_buf_t                            *p_umv_buf );
+
+
+#endif
+
+
+
index 69aa89b..1edf360 100644 (file)
@@ -57,6 +57,7 @@
 #include "al_query.h"\r
 #ifdef CL_KERNEL\r
 #include "al_smi.h"\r
+#include "al_proxy_ndi.h"\r
 #endif /* CL_KERNEL */\r
 #include "al_verbs.h"\r
 \r
@@ -325,6 +326,10 @@ create_qp(
                        break;\r
                }\r
                status = init_conn_qp( (al_conn_qp_t*)h_qp, h_pd, p_qp_create, p_umv_buf );\r
+#ifdef CL_KERNEL\r
+               if( NT_SUCCESS( status ) )\r
+                       status = ndi_qp_init( h_qp );\r
+#endif\r
                break;\r
 \r
        case IB_QPT_UNRELIABLE_DGRM:\r
@@ -1113,7 +1118,7 @@ destroying_qp(
        case IB_QPT_RELIABLE_CONN:\r
        case IB_QPT_UNRELIABLE_CONN:\r
                cid = cl_atomic_xchg(\r
-                       &((al_conn_qp_t*)h_qp)->cid, AL_INVALID_CID );\r
+                       &((al_conn_qp_t*)h_qp)->cid, AL_RESERVED_CID );\r
                if( cid != AL_INVALID_CID )\r
                {\r
                        ref_al_obj( &h_qp->obj );\r
@@ -1123,6 +1128,9 @@ destroying_qp(
                                deref_al_obj( &h_qp->obj );\r
                        }\r
                }\r
+#ifdef CL_KERNEL\r
+               ndi_qp_destroy( h_qp );\r
+#endif\r
 \r
                /* Fall through. */\r
        case IB_QPT_UNRELIABLE_DGRM:\r
@@ -1240,6 +1248,10 @@ free_qp(
        CL_ASSERT( p_obj );\r
        h_qp = PARENT_STRUCT( p_obj, ib_qp_t, obj );\r
 \r
+#ifdef CL_KERNEL\r
+       ndi_qp_free( h_qp );\r
+#endif\r
+\r
        destroy_al_obj( p_obj );\r
        cl_free( h_qp );\r
 }\r
@@ -1370,6 +1382,31 @@ al_modify_qp(
 }\r
 \r
 \r
+#ifdef CL_KERNEL\r
+\r
+ib_api_status_t\r
+ndi_modify_qp(\r
+       IN              const   ib_qp_handle_t                          h_qp,\r
+       IN              const   ib_qp_mod_t* const                      p_qp_mod,\r
+       IN              const   uint32_t                                        buf_size,\r
+       IN                              uint8_t* const                          p_outbuf)\r
+{\r
+       ib_api_status_t                 status;\r
+       ib_qp_attr_t                    qp_attr;\r
+\r
+       CL_ASSERT( h_qp );\r
+\r
+       /* Modify the actual QP attributes. */\r
+       status = verbs_ndi_modify_qp( h_qp, p_qp_mod, qp_attr, buf_size, p_outbuf );\r
+\r
+       /* Record the QP state if the modify was successful. */\r
+       if( status == IB_SUCCESS )\r
+               h_qp->state = p_qp_mod->req_state;\r
+\r
+       return status;\r
+}\r
+\r
+#endif\r
 \r
 ib_api_status_t\r
 ib_init_dgrm_svc(\r
index 8b18d58..4c94dbb 100644 (file)
@@ -44,6 +44,7 @@
 #include "al_mcast.h"\r
 #ifdef CL_KERNEL\r
 #include "al_smi.h"\r
+#include "al_ndi_cm.h"\r
 #endif /* CL_KERNEL */\r
 \r
 \r
@@ -137,7 +138,7 @@ typedef struct _ib_qp
        cl_obj_rel_t                            recv_cq_rel;\r
        cl_obj_rel_t                            send_cq_rel;\r
 \r
-       ib_srq_handle_t                 h_srq;\r
+       ib_srq_handle_t                         h_srq;\r
        cl_obj_rel_t                            srq_rel;\r
 \r
        ib_pfn_event_cb_t                       pfn_event_cb;\r
@@ -152,6 +153,10 @@ typedef struct _ib_qp
        ib_pfn_init_dgrm_svc_t          pfn_init_dgrm_svc;\r
        ib_pfn_join_mcast_t                     pfn_join_mcast;\r
 \r
+#ifdef CL_KERNEL\r
+       ndi_qp_csq_t                            *p_irp_que;\r
+#endif\r
+\r
 }      ib_qp_t;\r
 \r
 \r
index 34e99f5..87484c8 100644 (file)
@@ -330,8 +330,6 @@ query_req_cb(
        /* Form the result of the query, if we got one. */\r
        if( query_rec.status == IB_SUCCESS )\r
        {\r
-               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_QUERY,\r
-                       ("query succeeded\n") );\r
 \r
                CL_ASSERT( p_mad_response );\r
                p_sa_mad = (ib_sa_mad_t*)p_mad_response->p_mad_buf;\r
@@ -347,6 +345,9 @@ query_req_cb(
                        query_rec.result_cnt = 0;\r
                }\r
 \r
+               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_QUERY,\r
+                       ("query succeeded with result_cnt = %d\n", query_rec.result_cnt) );\r
+\r
                query_rec.p_result_mad = p_mad_response;\r
        }\r
        else\r
index dec7a33..6bfce15 100644 (file)
@@ -332,6 +332,10 @@ verbs_create_qp(
        h_qp->obj.p_ci_ca->verbs.modify_qp( h_qp->h_ci_qp,\\r
                p_qp_mod, &qp_attr, p_umv_buf )\r
 \r
+#define verbs_ndi_modify_qp(h_qp, p_qp_mod, qp_attr, buf_size, p_buf) \\r
+               h_qp->obj.p_ci_ca->verbs.ndi_modify_qp( h_qp->h_ci_qp,\\r
+                       p_qp_mod, &qp_attr, buf_size, p_buf )\r
+\r
 #define verbs_post_send(h_qp, p_send_wr, pp_send_failure) \\r
        h_qp->obj.p_ci_ca->verbs.post_send( h_qp->h_ci_qp,\\r
                p_send_wr, pp_send_failure )\r
index b45085b..6d682e3 100644 (file)
@@ -29,6 +29,9 @@ SOURCES= ibal.rc                      \
        al_proxy_ioc.c                  \\r
        al_proxy_subnet.c               \\r
        al_proxy_verbs.c                \\r
+       al_proxy_ndi.c                  \\r
+       al_ndi_cq.c                             \\r
+       al_ndi_cm.c                             \\r
        al_sa_req.c                             \\r
        al_smi.c                                \\r
        ..\al.c                                 \\r
index 51ea1c3..56556d5 100644 (file)
@@ -364,6 +364,17 @@ typedef struct _al_kcep
 \r
        }       mads;\r
 \r
+       /*\r
+        * NDI stuff\r
+        */\r
+\r
+       /* IRP list head */\r
+       LIST_ENTRY                                      irp_que;\r
+\r
+       /* private data of REQ, REP, REJ CM requests */ \r
+       uint8_t                                         psize;\r
+       uint8_t                                         pdata[IB_REP_PDATA_SIZE];\r
+\r
 }      kcep_t;\r
 \r
 \r
@@ -893,7 +904,8 @@ __process_rej(
        p_rej = (mad_cm_rej_t*)p_mad->p_mad_buf;\r
 \r
        AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_CM,\r
-               ("Request rejected reason - %d.\n", p_rej->reason) );\r
+               ("Request rejected p_rej %p, reason - %d.\n", \r
+               p_rej, cl_ntoh16(p_rej->reason) ) );\r
 \r
        switch( p_cep->state )\r
        {\r
@@ -1120,6 +1132,9 @@ __req_handler(
                        goto unbind;\r
                }\r
 \r
+               /* __cep_queue_mad may complete a pending IRP */\r
+               p_mad->send_context1 = p_new_cep;        \r
+\r
                /*\r
                 * Queue the mad - the return value indicates whether we should\r
                 * invoke the callback.\r
@@ -1129,10 +1144,15 @@ __req_handler(
                {\r
                case IB_SUCCESS:\r
                case IB_PENDING:\r
-                       p_mad->send_context1 = p_new_cep;\r
                        break;\r
 \r
+               case IB_UNSUPPORTED:\r
+                       p_mad->send_context1 = NULL;\r
+                       reason = IB_REJ_USER_DEFINED;\r
+                       goto unbind;\r
+               \r
                default:\r
+                       p_mad->send_context1 = NULL;\r
                        reason = IB_REJ_INSUF_RESOURCES;\r
                        goto unbind;\r
                }\r
@@ -1618,6 +1638,22 @@ __dreq_handler(
                __repeat_mad( p_port_cep, p_cep, p_mad );\r
                break;\r
 \r
+       case CEP_STATE_DREQ_DESTROY:\r
+               /* Send the DREP with no private data. */\r
+\r
+               ib_put_mad( p_mad );    /* release DREQ MAD */\r
+\r
+               status = __cep_get_mad( p_cep, CM_DREP_ATTR_ID, &(cep_agent_t*)p_port_cep, \r
+                       &(ib_mad_element_t*)p_mad );\r
+               if( status != IB_SUCCESS )\r
+                       break;\r
+\r
+               p_mad->p_mad_buf->attr_id = CM_DREP_ATTR_ID;\r
+               /* __format_drep returns always SUCCESS while no private data */\r
+               __format_drep( p_cep, NULL, 0, (mad_cm_drep_t*)p_mad->p_mad_buf );\r
+               __cep_send_mad( p_port_cep, p_mad );\r
+               break;\r
+\r
        default:\r
                AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_CM, ("DREQ received in invalid state.\n") );\r
        case CEP_STATE_DREQ_RCVD:\r
@@ -3293,12 +3329,12 @@ create_cep_mgr(
        {\r
                gp_cep_mgr->obj.pfn_destroy( &gp_cep_mgr->obj, NULL );\r
                AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
-                       ("cl_vector_init failed with status %s.\n",\r
-                       CL_STATUS_MSG(cl_status)) );\r
+                       ("cl_vector_init failed with status %#x.\n",\r
+                       cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
-       gp_cep_mgr->free_cid = 0;\r
+       gp_cep_mgr->free_cid = 1;\r
 \r
        /* Register for port PnP notifications. */\r
        cl_memclr( &pnp_req, sizeof(pnp_req) );\r
@@ -3328,6 +3364,53 @@ create_cep_mgr(
 * CEP manager API\r
 ******************************************************************************/\r
 \r
+static inline void \r
+__complete_ndi_irp(\r
+       IN                              PIRP                                            p_irp,\r
+       IN                              ib_mad_element_t*                       p_mad )\r
+{\r
+       NTSTATUS nt_status;\r
+       net32_t* p_new_cid = (net32_t*)cl_ioctl_out_buf( p_irp );\r
+       kcep_t* p_cep = (kcep_t* __ptr64)p_mad->send_context1;\r
+\r
+       *p_new_cid = p_cep->cid;\r
+       nt_status = STATUS_SUCCESS;\r
+       p_irp->IoStatus.Information = sizeof(uint32_t);\r
+       p_irp->IoStatus.Status = nt_status;\r
+       IoCompleteRequest( p_irp, IO_NETWORK_INCREMENT );\r
+       ib_put_mad( p_mad );\r
+}\r
+\r
+static ib_api_status_t\r
+__cep_set_pdata(\r
+       IN                              ib_al_handle_t                          h_al,\r
+       IN                              net32_t                                         cid,\r
+       IN                              uint8_t                                         psize,\r
+       IN                              uint8_t*                                        pdata )\r
+{\r
+       kcep_t                          *p_cep;\r
+\r
+       AL_ENTER( AL_DBG_CM );\r
+\r
+       CL_ASSERT( h_al );\r
+\r
+       p_cep = __lookup_cep( h_al, cid );\r
+       if( !p_cep )\r
+       {\r
+               AL_EXIT( AL_DBG_CM );\r
+               return IB_INVALID_HANDLE;\r
+       }\r
+       cl_memclr( p_cep->pdata, sizeof(p_cep->pdata) );\r
+       p_cep->psize = min( psize, sizeof(p_cep->pdata) );\r
+       memcpy( p_cep->pdata, pdata, p_cep->psize );\r
+       AL_PRINT(TRACE_LEVEL_INFORMATION ,AL_DBG_CM ,\r
+               ("__cep_set_pdata: set %d of pdata for cid %d, h_al %p, context %p \n", \r
+               p_cep->psize, cid, h_al, p_cep->context ));\r
+\r
+       AL_EXIT( AL_DBG_CM );\r
+       return IB_SUCCESS;\r
+}\r
+\r
 /* Called with the CEP and CEP manager locks held */\r
 static ib_api_status_t\r
 __cep_queue_mad(\r
@@ -3344,6 +3427,56 @@ __cep_queue_mad(
                return IB_INVALID_STATE;\r
        }\r
 \r
+       /* NDI connection request case */\r
+       if ( p_cep->state == CEP_STATE_LISTEN &&\r
+               (p_cep->sid & ~0x0ffffffI64) == IB_REQ_CM_RDMA_SID_PREFIX )\r
+       { /* Try to complete pending IRP, if any */\r
+               PIRP p_irp;\r
+               PLIST_ENTRY p_list_entry;\r
+               mad_cm_req_t* p_req = (mad_cm_req_t*)ib_get_mad_buf( p_mad );\r
+               ib_cm_rdma_req_t *p_rdma_req = (ib_cm_rdma_req_t *)p_req->pdata;\r
+\r
+               /* reject connection request with incorrect version parameters */\r
+               if ( ((p_rdma_req->maj_min_ver >> 4) != IB_REQ_CM_RDMA_MAJOR_VERSION) ||\r
+                        ((p_rdma_req->maj_min_ver & 0x0f) > IB_REQ_CM_RDMA_MINOR_VERSION) ||\r
+                        (p_rdma_req->ipv != 0x40 && p_rdma_req->ipv != 0x60) )\r
+               {\r
+                       AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, \r
+                               ("NDI connection req is rejected: maj_min_ver %d, ipv %#x \n", \r
+                               p_rdma_req->maj_min_ver, p_rdma_req->ipv ) );\r
+                       return IB_UNSUPPORTED;\r
+               }\r
+               \r
+               /* get a pending IRP */\r
+               if ( !IsListEmpty( &p_cep->irp_que ) )\r
+               {\r
+                       kcep_t* p_new_cep = (kcep_t* __ptr64)p_mad->send_context1;\r
+                       \r
+                       // get IRP\r
+                       p_list_entry = RemoveHeadList( &p_cep->irp_que );\r
+                       p_irp = (PIRP)CONTAINING_RECORD( p_list_entry, IRP, Tail.Overlay.ListEntry );\r
+                       \r
+                       // store REQ private data\r
+                       __cep_set_pdata( \r
+                               (ib_al_handle_t)p_irp->Tail.Overlay.DriverContext[1], \r
+                               p_new_cep->cid, sizeof(p_req->pdata), (uint8_t*)p_req->pdata );\r
+                       AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR ,\r
+                               ("set %d of REQ pdata to CEP with cid %d, h_al %p\n", \r
+                               sizeof(p_req->pdata), p_new_cep->cid, \r
+                               (ib_al_handle_t)p_irp->Tail.Overlay.DriverContext[1] ));\r
+\r
+                       // complete GetConnectionReq IRP\r
+#pragma warning(push, 3)\r
+                       IoSetCancelRoutine( p_irp, NULL );\r
+#pragma warning(pop)\r
+\r
+                       __complete_ndi_irp( p_irp, p_mad );\r
+\r
+                       AL_EXIT( AL_DBG_CM );\r
+                       return IB_PENDING;\r
+               }\r
+       }\r
+\r
        /* Queue this MAD for processing. */\r
        if( p_cep->p_mad_head )\r
        {\r
@@ -3515,6 +3648,8 @@ __create_cep()
 \r
        p_cep->p_cid->p_cep = p_cep;\r
 \r
+       InitializeListHead( &p_cep->irp_que );\r
+\r
        ref_al_obj( &gp_cep_mgr->obj );\r
 \r
        AL_EXIT( AL_DBG_CM );\r
@@ -3794,7 +3929,6 @@ __drep_cep(
        AL_EXIT( AL_DBG_CM );\r
 }\r
 \r
-\r
 /* Called with CEP manager lock held. */\r
 static int32_t\r
 __cleanup_cep(\r
@@ -3890,6 +4024,12 @@ __cleanup_cep(
        case CEP_STATE_LISTEN:\r
                /* Remove from listen map. */\r
                cl_rbmap_remove_item( &gp_cep_mgr->listen_map, &p_cep->listen_item );\r
+\r
+               if( p_cep->p_cmp_buf )\r
+               {\r
+                       cl_free( p_cep->p_cmp_buf );\r
+                       p_cep->p_cmp_buf = NULL;\r
+               }\r
                break;\r
 \r
        case CEP_STATE_PRE_REQ:\r
@@ -3972,6 +4112,10 @@ al_create_cep(
 \r
        *p_cid = p_cep->cid;\r
 \r
+       AL_PRINT(TRACE_LEVEL_INFORMATION ,AL_DBG_CM ,\r
+               ("Created CEP with cid %d, h_al %p, context %p \n", \r
+               p_cep->cid, h_al, p_cep->context ));\r
+\r
        AL_EXIT( AL_DBG_CM );\r
        return IB_SUCCESS;\r
 }\r
@@ -4023,6 +4167,10 @@ al_destroy_cep(
        if( !ref_cnt && pfn_destroy_cb )\r
                pfn_destroy_cb( context );\r
 \r
+       AL_PRINT(TRACE_LEVEL_INFORMATION ,AL_DBG_CM ,\r
+               ("Destroeyd CEP with cid %d, h_al %p, context %p \n", \r
+               cid, h_al, context ));\r
+\r
        AL_EXIT( AL_DBG_CM );\r
        return IB_SUCCESS;\r
 }\r
@@ -4773,34 +4921,22 @@ __format_rep(
 }\r
 \r
 \r
+\r
 ib_api_status_t\r
-al_cep_pre_rep(\r
-       IN                              ib_al_handle_t                          h_al,\r
-       IN                              net32_t                                         cid,\r
+__al_cep_pre_rep(\r
+       IN                              kcep_t                                          *p_cep,\r
        IN                              void* __ptr64                           context,\r
        IN              const   ib_cm_rep_t* const                      p_cm_rep,\r
                OUT                     ib_qp_mod_t* const                      p_init )\r
 {\r
        ib_api_status_t         status;\r
-       kcep_t                          *p_cep;\r
-       KLOCK_QUEUE_HANDLE      hdl;\r
        cep_agent_t                     *p_port_cep;\r
 \r
        AL_ENTER( AL_DBG_CM );\r
 \r
-       CL_ASSERT( h_al );\r
        CL_ASSERT( p_cm_rep );\r
        CL_ASSERT( p_init );\r
 \r
-       KeAcquireInStackQueuedSpinLock( &gp_cep_mgr->lock, &hdl );\r
-       p_cep = __lookup_cep( h_al, cid );\r
-       if( !p_cep )\r
-       {\r
-               KeReleaseInStackQueuedSpinLock( &hdl );\r
-               AL_EXIT( AL_DBG_CM );\r
-               return IB_INVALID_HANDLE;\r
-       }\r
-\r
        switch( p_cep->state )\r
        {\r
        case CEP_STATE_PRE_REP:\r
@@ -4847,12 +4983,86 @@ al_cep_pre_rep(
                        ("Invalid state: %d\n", p_cep->state) );\r
                status = IB_INVALID_STATE;\r
        }\r
+       AL_EXIT( AL_DBG_CM );\r
+       return status;\r
+}\r
+\r
+\r
+ib_api_status_t\r
+al_cep_pre_rep(\r
+       IN                              ib_al_handle_t                          h_al,\r
+       IN                              net32_t                                         cid,\r
+       IN                              void* __ptr64                           context,\r
+       IN              const   ib_cm_rep_t* const                      p_cm_rep,\r
+               OUT                     ib_qp_mod_t* const                      p_init )\r
+{\r
+       ib_api_status_t         status;\r
+       kcep_t                          *p_cep;\r
+       KLOCK_QUEUE_HANDLE      hdl;\r
+\r
+       AL_ENTER( AL_DBG_CM );\r
+\r
+       CL_ASSERT( h_al );\r
+       CL_ASSERT( p_cm_rep );\r
+       CL_ASSERT( p_init );\r
+\r
+       KeAcquireInStackQueuedSpinLock( &gp_cep_mgr->lock, &hdl );\r
+       p_cep = __lookup_cep( h_al, cid );\r
+       if( !p_cep )\r
+       {\r
+               KeReleaseInStackQueuedSpinLock( &hdl );\r
+               AL_EXIT( AL_DBG_CM );\r
+               return IB_INVALID_HANDLE;\r
+       }\r
+\r
+       status = __al_cep_pre_rep( p_cep, context, p_cm_rep, p_init );\r
+\r
        KeReleaseInStackQueuedSpinLock( &hdl );\r
        AL_EXIT( AL_DBG_CM );\r
        return status;\r
 }\r
 \r
 \r
+ib_api_status_t\r
+al_cep_pre_rep_ex(\r
+       IN                              ib_al_handle_t                          h_al,\r
+       IN                              net32_t                                         cid,\r
+       IN                              al_pfn_cep_cb_t                         pfn_cb,\r
+       IN                              void* __ptr64                           context,\r
+       IN              const   ib_cm_rep_t* const                      p_cm_rep,\r
+               OUT                     ib_qp_mod_t* const                      p_init )\r
+{\r
+       ib_api_status_t         status;\r
+       kcep_t                          *p_cep;\r
+       KLOCK_QUEUE_HANDLE      hdl;\r
+\r
+       AL_ENTER( AL_DBG_CM );\r
+\r
+       CL_ASSERT( h_al );\r
+       CL_ASSERT( p_cm_rep );\r
+       CL_ASSERT( p_init );\r
+\r
+       KeAcquireInStackQueuedSpinLock( &gp_cep_mgr->lock, &hdl );\r
+       p_cep = __lookup_cep( h_al, cid );\r
+       if( !p_cep )\r
+       {\r
+               KeReleaseInStackQueuedSpinLock( &hdl );\r
+               AL_EXIT( AL_DBG_CM );\r
+               return IB_INVALID_HANDLE;\r
+       }\r
+\r
+       status = __al_cep_pre_rep( p_cep, context, p_cm_rep, p_init );\r
+\r
+       if (status == IB_SUCCESS)\r
+       {\r
+               p_cep->pfn_cb = pfn_cb;\r
+       }\r
+\r
+       KeReleaseInStackQueuedSpinLock( &hdl );\r
+       AL_EXIT( AL_DBG_CM );\r
+       return status;\r
+}\r
+\r
 ib_api_status_t\r
 al_cep_send_rep(\r
        IN                              ib_al_handle_t                          h_al,\r
@@ -6080,3 +6290,173 @@ al_cep_cleanup_al(
 \r
        AL_EXIT( AL_DBG_CM );\r
 }\r
+\r
+static void\r
+__cep_cancel_ndi_irp(\r
+       IN                              DEVICE_OBJECT*                          p_dev_obj,\r
+       IN                              IRP*                                            p_irp )\r
+{\r
+       KLOCK_QUEUE_HANDLE              hdl;\r
+\r
+       AL_ENTER( AL_DBG_CM );\r
+\r
+       UNUSED_PARAM( p_dev_obj );\r
+       CL_ASSERT( p_irp );\r
+\r
+       KeAcquireInStackQueuedSpinLock( &gp_cep_mgr->lock, &hdl );\r
+       RemoveEntryList( &p_irp->Tail.Overlay.ListEntry );\r
+       KeReleaseInStackQueuedSpinLock( &hdl );\r
+\r
+#pragma warning(push, 3)\r
+       IoSetCancelRoutine( p_irp, NULL );\r
+#pragma warning(pop)\r
+       IoReleaseCancelSpinLock( p_irp->CancelIrql );\r
+               \r
+       /* Complete the IRP. */\r
+       p_irp->IoStatus.Status = STATUS_CANCELLED;\r
+       p_irp->IoStatus.Information = 0;\r
+       IoCompleteRequest( p_irp, IO_NO_INCREMENT );\r
+\r
+       AL_EXIT( AL_DBG_CM );\r
+}\r
+\r
+NTSTATUS\r
+al_cep_get_cid(\r
+       IN              ib_al_handle_t                                          h_al,\r
+       IN              net32_t                 const                           cid,\r
+       IN              PIRP                                                            p_irp\r
+       )\r
+{\r
+       kcep_t *p_cep, *p_new_cep;\r
+       NTSTATUS nt_status;\r
+       KLOCK_QUEUE_HANDLE hdl;\r
+       ib_mad_element_t* p_mad = NULL;\r
+       mad_cm_req_t* p_req;\r
+\r
+       AL_ENTER( AL_DBG_NDI );\r
+       KeAcquireInStackQueuedSpinLock( &gp_cep_mgr->lock, &hdl );\r
+\r
+       p_cep = __lookup_cep( h_al, cid );\r
+       if( !p_cep )\r
+       {\r
+               p_irp->IoStatus.Information = 0;\r
+               p_irp->IoStatus.Status = STATUS_INVALID_PARAMETER;\r
+               IoCompleteRequest( p_irp, IO_NETWORK_INCREMENT );\r
+               nt_status = STATUS_EVENT_DONE;\r
+               goto exit;\r
+       }\r
+\r
+       if( !p_cep->p_mad_head )\r
+       { /* no pending MADs - queue the IRP */ \r
+               p_cep->signalled = FALSE;\r
+               InsertTailList( &p_cep->irp_que, &p_irp->Tail.Overlay.ListEntry );\r
+               p_irp->Tail.Overlay.DriverContext[0] = (void*)(size_t)cid;\r
+               p_irp->Tail.Overlay.DriverContext[1] = (void*)h_al;\r
+#pragma warning(push, 3)\r
+               IoSetCancelRoutine( p_irp, __cep_cancel_ndi_irp );\r
+#pragma warning(pop)\r
+               IoMarkIrpPending( p_irp );\r
+               nt_status = STATUS_PENDING;\r
+               goto exit;\r
+       }\r
+\r
+       /* Set the MAD. */\r
+       p_mad = p_cep->p_mad_head;\r
+       p_cep->p_mad_head = p_mad->p_next;\r
+       p_mad->p_next = NULL;\r
+\r
+       /* store REQ private data */\r
+       p_req = (mad_cm_req_t*)ib_get_mad_buf( p_mad );\r
+       p_new_cep = (kcep_t* __ptr64)p_mad->send_context1;\r
+       __cep_set_pdata( h_al, p_new_cep->cid,\r
+               sizeof(p_req->pdata), (uint8_t*)p_req->pdata );\r
+       AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR ,\r
+               ("set %d of REQ pdata to CEP with cid %d, h_al %p\n", \r
+               sizeof(p_req->pdata), p_new_cep->cid, h_al ));\r
+\r
+       /* complete the IRP */\r
+       __complete_ndi_irp( p_irp, p_mad );\r
+       nt_status = STATUS_EVENT_DONE;\r
+       \r
+exit:\r
+       KeReleaseInStackQueuedSpinLock( &hdl );\r
+       AL_EXIT( AL_DBG_NDI );\r
+       return nt_status;\r
+}\r
+\r
+\r
+ib_api_status_t\r
+al_cep_get_pdata(\r
+       IN                              ib_al_handle_t                          h_al,\r
+       IN                              net32_t                                         cid,\r
+       IN      OUT                     uint8_t                                         *p_psize,\r
+               OUT                     uint8_t*                                        pdata )\r
+{\r
+       kcep_t                          *p_cep;\r
+       KLOCK_QUEUE_HANDLE      hdl;\r
+       uint8_t remainder;\r
+\r
+       AL_ENTER( AL_DBG_CM );\r
+\r
+       CL_ASSERT( h_al );\r
+\r
+       KeAcquireInStackQueuedSpinLock( &gp_cep_mgr->lock, &hdl );\r
+       p_cep = __lookup_cep( h_al, cid );\r
+       if( !p_cep )\r
+       {\r
+               KeReleaseInStackQueuedSpinLock( &hdl );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, \r
+                       ("CEP not found for cid %d, h_al %p\n", cid, h_al ));\r
+               return IB_INVALID_HANDLE;\r
+       }\r
+\r
+       if ( *p_psize < p_cep->psize )\r
+       {\r
+               KeReleaseInStackQueuedSpinLock( &hdl );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, \r
+                       ("Insufficient size: *p_psize %d, max %d, cid %d, h_al %p\n", \r
+                       *p_psize, p_cep->psize, cid, h_al ));\r
+               return IB_INVALID_PARAMETER;\r
+       }\r
+       \r
+       memcpy( pdata, p_cep->pdata, p_cep->psize );\r
+       remainder = *p_psize - p_cep->psize;\r
+       if (remainder)\r
+               cl_memclr( &pdata[p_cep->psize], remainder );\r
+       *p_psize = p_cep->psize;\r
+       if ( !*p_psize )\r
+       {\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, \r
+                       ("p_cep->psize is zero for cid %d, h_al %p\n", cid, h_al ));\r
+       }\r
+\r
+       AL_PRINT(TRACE_LEVEL_INFORMATION ,AL_DBG_CM ,\r
+               ("al_cep_get_pdata: get %d of pdata from CEP with cid %d, h_al %p, context %p \n", \r
+               p_cep->psize, cid, h_al, p_cep->context ));\r
+\r
+       KeReleaseInStackQueuedSpinLock( &hdl );\r
+       AL_EXIT( AL_DBG_CM );\r
+       return IB_SUCCESS;\r
+}\r
+\r
+ib_api_status_t\r
+al_cep_set_pdata(\r
+       IN                              ib_al_handle_t                          h_al,\r
+       IN                              net32_t                                         cid,\r
+       IN                              uint8_t                                         psize,\r
+       IN                              uint8_t*                                        pdata )\r
+{\r
+       ib_api_status_t         status;\r
+       KLOCK_QUEUE_HANDLE      hdl;\r
+\r
+       AL_ENTER( AL_DBG_CM );\r
+\r
+       CL_ASSERT( h_al );\r
+\r
+       KeAcquireInStackQueuedSpinLock( &gp_cep_mgr->lock, &hdl );\r
+       status = __cep_set_pdata( h_al, cid, psize, pdata );\r
+       KeReleaseInStackQueuedSpinLock( &hdl );\r
+\r
+       AL_EXIT( AL_DBG_CM );\r
+       return IB_SUCCESS;\r
+}\r
index 1969830..767d2dc 100644 (file)
@@ -460,6 +460,8 @@ al_dev_ioctl(
                cl_status = subnet_ioctl( h_ioctl, &ret_bytes );\r
        else if( IS_IOC_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )\r
                cl_status = ioc_ioctl( h_ioctl, &ret_bytes );\r
+       else if( IS_NDI_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )\r
+               cl_status = ndi_ioctl( h_ioctl, &ret_bytes );\r
        else\r
                cl_status = CL_INVALID_REQUEST;\r
 \r
index 0970e61..b175de8 100644 (file)
@@ -717,7 +717,7 @@ __init_ioc_pnp(
        if( cl_status != CL_SUCCESS )\r
        {\r
                AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
-                       ("cl_spinlock_init returned %s\n", cl_status_text[cl_status]) );\r
+                       ("cl_spinlock_init returned %#x\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
@@ -725,7 +725,7 @@ __init_ioc_pnp(
        if( cl_status != CL_SUCCESS )\r
        {\r
                AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
-                       ("cl_spinlock_init returned %s\n", cl_status_text[cl_status]) );\r
+                       ("cl_spinlock_init returned %#x\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
@@ -733,7 +733,7 @@ __init_ioc_pnp(
        if( cl_status != CL_SUCCESS )\r
        {\r
                AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
-                       ("cl_spinlock_init returned %s\n", cl_status_text[cl_status]) );\r
+                       ("cl_spinlock_init returned %#x\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
@@ -743,7 +743,7 @@ __init_ioc_pnp(
        if( cl_status != CL_SUCCESS )\r
        {\r
                AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
-                       ("cl_qpool_init returned %s\n", cl_status_text[cl_status]) );\r
+                       ("cl_qpool_init returned %#x\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
@@ -752,7 +752,7 @@ __init_ioc_pnp(
        if( cl_status != CL_SUCCESS )\r
        {\r
                AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
-                       ("cl_qpool_init returned %s\n", cl_status_text[cl_status]) );\r
+                       ("cl_qpool_init returned %#x\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
@@ -761,7 +761,7 @@ __init_ioc_pnp(
        if( cl_status != CL_SUCCESS )\r
        {\r
                AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
-                       ("cl_qpool_init returned %s\n", cl_status_text[cl_status]) );\r
+                       ("cl_qpool_init returned %#x\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
@@ -771,7 +771,7 @@ __init_ioc_pnp(
        if( cl_status != CL_SUCCESS )\r
        {\r
                AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
-                       ("cl_timer_init failed with %s\n", cl_status_text[cl_status]) );\r
+                       ("cl_timer_init failed with %#x\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
diff --git a/core/al/kernel/al_ndi_cm.c b/core/al/kernel/al_ndi_cm.c
new file mode 100644 (file)
index 0000000..9d93f0e
--- /dev/null
@@ -0,0 +1,1582 @@
+/*
+ * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: al_proxy_verbs.c 548 2006-11-27 20:03:51Z leonidk $
+ */
+
+
+#include <complib/comp_lib.h>
+#include <iba/ib_al.h>
+#include <iba/ib_al_ioctl.h>
+#include "al.h"
+#include "al_mgr.h"
+#include "al_debug.h"
+
+#if defined(EVENT_TRACING)
+#ifdef offsetof
+#undef offsetof
+#endif
+#include "al_ndi_cm.tmh"
+#endif
+
+#include "al_dev.h"
+/* Get the internal definitions of apis for the proxy */
+#include "al_ca.h"
+#include "ib_common.h"
+#include "al_qp.h"
+#include "al_cm_conn.h"
+#include "al_cm_cep.h"
+#include "al_ndi_cm.h"
+
+uint32_t               g_sa_timeout = 500;
+uint32_t               g_sa_retries = 4;
+uint8_t                        g_qp_retries = QP_ATTRIB_RETRY_COUNT;
+uint8_t                        g_pkt_life_modifier = 0;
+uint8_t                        g_max_cm_retries = CM_RETRIES;
+
+/*******************************************************************
+ *
+ * Helpers
+ *
+ ******************************************************************/
+
+static char * State2String(ndi_cm_state_t state) 
+{
+       switch (state) 
+       {
+               case NDI_CM_IDLE                                        : return "NDI_CM_IDLE";
+               case NDI_CM_CONNECTING_ATS_SENT         : return "NDI_CM_CONNECTING_ATS_SENT";
+               case NDI_CM_CONNECTING_QPR_SENT         : return "NDI_CM_CONNECTING_QPR_SENT";
+               case NDI_CM_CONNECTING_REQ_SENT         : return "NDI_CM_CONNECTING_REQ_SENT";
+               case NDI_CM_CONNECTING_REP_RCVD         : return "NDI_CM_CONNECTING_REP_RCVD";
+               case NDI_CM_CONNECTING_REJ_RCVD         : return "NDI_CM_CONNECTING_REJ_RCVD";
+               case NDI_CM_CONNECTED                           : return "NDI_CM_CONNECTED";
+               case NDI_CM_BOUND                                       : return "NDI_CM_BOUND";
+               case NDI_CM_LISTENING                           : return "NDI_CM_LISTENING";
+               case NDI_CM_REP_SENT                            : return "NDI_CM_REP_SENT";
+               case NDI_CM_CONNECTED_DREP_SENT         : return "NDI_CM_CONNECTED_DREP_SENT";
+               case NDI_CM_CONNECTED_DREQ_SENT         : return "NDI_CM_CONNECTED_DREQ_SENT";
+               default : 
+                       ASSERT(FALSE);
+       }
+       return "Unknown state";
+}
+
+static inline void
+__ndi_complete_irp(
+       IN      ib_qp_handle_t                                                  h_qp,
+       IN      PIRP                                                                    Irp,
+       IN      NTSTATUS                                                                code
+       )
+{
+       AL_ENTER( AL_DBG_NDI );
+
+       CL_ASSERT( Irp );
+
+       cl_ioctl_complete( Irp, code, 0 );
+       deref_al_obj( &h_qp->obj );                     /* release IRP life reference */
+       h_qp->p_irp_que->h_ioctl = NULL;        /* mark IRP as cancelled */
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static inline void
+__ndi_complete_irp_ex(
+       IN      ib_qp_handle_t                                                  h_qp,
+       IN      NTSTATUS                                                                code,
+       IN      ndi_cm_state_t                                                  new_state
+       )
+{
+       PIRP Irp;
+
+       AL_ENTER( AL_DBG_NDI );
+       h_qp->p_irp_que->state = new_state;     
+       Irp = IoCsqRemoveNextIrp( &h_qp->p_irp_que->csq, NULL );
+       if ( Irp )
+               __ndi_complete_irp( h_qp, Irp, code );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+/*
+ * Transition the QP to the error state to flush all oustanding work
+ * requests and sets the timewait time.  This function may be called
+ * when destroying the QP in order to flush all work requests, so we
+ * cannot call through the main API, or the call will fail since the
+ * QP is no longer in the initialize state.
+ */
+static void
+__cep_timewait_qp(
+       IN              const   ib_qp_handle_t                          h_qp )
+{
+       uint64_t                        timewait = 0;
+       ib_qp_mod_t                     qp_mod;
+       ib_api_status_t         status;
+
+       AL_ENTER( AL_DBG_CM );
+
+       CL_ASSERT( h_qp );
+
+       /*
+        * The CM should have set the proper timewait time-out value.  Reset
+        * the QP and let it enter the timewait state.
+        */
+       if( al_cep_get_timewait( h_qp->obj.h_al,
+               ((al_conn_qp_t*)h_qp)->cid, &timewait ) == IB_SUCCESS )
+       {
+               /* Special checks on the QP state for error handling - see above. */
+               if( !h_qp || !AL_OBJ_IS_TYPE( h_qp, AL_OBJ_TYPE_H_QP ) ||
+                       ( (h_qp->obj.state != CL_INITIALIZED) && 
+                       (h_qp->obj.state != CL_DESTROYING) ) )
+               {
+                       AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_QP_HANDLE\n") );
+                       return;
+               }
+
+               cl_memclr( &qp_mod, sizeof(ib_qp_mod_t) );
+               qp_mod.req_state = IB_QPS_ERROR;
+
+               /* Modify to error state using function pointers - see above. */
+               status = h_qp->pfn_modify_qp( h_qp, &qp_mod, NULL );
+               if( status != IB_SUCCESS )
+               {
+                       AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                               ("pfn_modify_qp to IB_QPS_ERROR returned %s\n",
+                               ib_get_err_str( status )) );
+                       return;
+               }
+
+#ifdef CL_KERNEL
+               /* Store the timestamp after which the QP exits timewait. */
+               h_qp->timewait = cl_get_time_stamp() + timewait;
+#endif /* CL_KERNEL */
+       }
+
+       AL_EXIT( AL_DBG_CM );
+}
+
+static ib_api_status_t
+__ndi_qp2rts(
+       IN              ib_qp_handle_t  const                           h_qp,
+       IN              uint8_t                                                         init_depth,
+       IN              uint8_t                                                         resp_res,
+       IN              PIRP                                                            p_irp,
+       IN      OUT     ib_qp_mod_t                                                     *p_qp_mod
+       )
+{
+       ib_api_status_t status;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       /* fill required qp attributes */
+       status = al_cep_get_rtr_attr( qp_get_al( h_qp ), 
+               ((al_conn_qp_t*)h_qp)->cid, p_qp_mod );
+       if ( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("al_cep_get_rtr_attr returned %s\n", ib_get_err_str( status )) );
+               goto exit;
+       }
+       p_qp_mod->state.rtr.resp_res = resp_res;
+
+       /* perform the request: INIT->RTR */
+       status = ndi_modify_qp( h_qp, p_qp_mod, 
+               cl_ioctl_out_size( p_irp ), cl_ioctl_out_buf( p_irp ) );
+       if ( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("ndi_modify_qp to RTR returned %s.\n", ib_get_err_str(status) ) );
+               goto exit;
+       }
+
+       /* fill required qp attributes */
+       status = al_cep_get_rts_attr( qp_get_al( h_qp ), 
+               ((al_conn_qp_t*)h_qp)->cid, p_qp_mod );
+       if ( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("al_cep_get_rts_attr returned %s\n", ib_get_err_str( status )) );
+               goto exit;
+       }
+       p_qp_mod->state.rts.init_depth = init_depth;
+
+       /* perform the request: RTR->RTS */
+       status = ndi_modify_qp( h_qp, p_qp_mod, 
+               cl_ioctl_out_size( p_irp ), cl_ioctl_out_buf( p_irp ) );
+       if ( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("ndi_modify_qp to RTS returned %s.\n", ib_get_err_str(status) ) );
+       }
+
+exit:
+       AL_EXIT( AL_DBG_NDI );
+       return status;
+}
+
+
+/*******************************************************************
+ *
+ * CSQ
+ *
+ ******************************************************************/
+
+static VOID __ndi_insert_irp(
+       IN      PIO_CSQ                                                                 Csq,
+       IN      PIRP                                                                    Irp
+       )
+{
+       ndi_qp_csq_t *p_ndi_csq = (ndi_qp_csq_t*)Csq;
+
+       AL_ENTER( AL_DBG_NDI );
+       InsertTailList( &p_ndi_csq->que, &Irp->Tail.Overlay.ListEntry );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static VOID __ndi_remove_irp(
+       IN      PIO_CSQ                                                                 Csq,
+       IN      PIRP                                                                    Irp
+       )
+{
+       UNUSED_PARAM( Csq );
+
+       AL_ENTER( AL_DBG_NDI );
+       RemoveEntryList( &Irp->Tail.Overlay.ListEntry );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static PIRP __ndi_peek_next_irp(
+       IN      PIO_CSQ                                                                 Csq,
+       IN      PIRP                                                                    Irp,
+       IN      PVOID                                                                   PeekContext
+       )
+{
+       PIRP nextIrp = NULL;
+       PLIST_ENTRY nextEntry;
+       PLIST_ENTRY listHead;
+       ndi_qp_csq_t *p_ndi_csq = (ndi_qp_csq_t*)Csq;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       listHead = &p_ndi_csq->que;
+
+       // 
+       // If the IRP is NULL, we will start peeking from the listhead, else
+       // we will start from that IRP onwards. This is done under the
+       // assumption that new IRPs are always inserted at the tail.
+       //
+
+       if(Irp == NULL)
+               nextEntry = listHead->Flink;
+       else
+               nextEntry = Irp->Tail.Overlay.ListEntry.Flink;
+
+       while(nextEntry != listHead) {
+               nextIrp = CONTAINING_RECORD(nextEntry, IRP, Tail.Overlay.ListEntry);
+
+               //
+               // If context is present, continue until you find a matching one.
+               // Else you break out as you got next one.
+               //
+
+               if(PeekContext) 
+               {
+                       /* for now PeekContext is not used */
+               } 
+               else
+               {
+                       break;
+               }
+
+               nextIrp = NULL;
+               nextEntry = nextEntry->Flink;
+       }
+
+       AL_EXIT( AL_DBG_NDI );
+       return nextIrp;
+}
+
+static VOID __ndi_acquire_lock(
+       IN      PIO_CSQ                                                                 Csq,
+       OUT     PKIRQL                                                                  Irql
+       )
+{
+       ndi_qp_csq_t *p_ndi_csq = (ndi_qp_csq_t*)Csq;
+       ib_qp_handle_t h_qp = p_ndi_csq->h_qp;
+       UNUSED_PARAM( Irql );
+
+       AL_ENTER( AL_DBG_NDI );
+       cl_spinlock_acquire( &h_qp->obj.lock );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static VOID __ndi_release_lock(
+       IN      PIO_CSQ                                                                 Csq,
+       IN      KIRQL                                                                   Irql
+       )
+{
+       ndi_qp_csq_t *p_ndi_csq = (ndi_qp_csq_t*)Csq;
+       ib_qp_handle_t h_qp = p_ndi_csq->h_qp;
+       UNUSED_PARAM( Irql );
+
+       AL_ENTER( AL_DBG_NDI );
+       cl_spinlock_release( &h_qp->obj.lock );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static VOID __ndi_complete_cancelled_irp(
+       IN      PIO_CSQ                                                                 Csq,
+       IN      PIRP                                                                    Irp
+       )
+{
+       ndi_qp_csq_t *p_ndi_csq = (ndi_qp_csq_t*)Csq;
+       ib_qp_handle_t h_qp = p_ndi_csq->h_qp;
+       net32_t cid;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       switch (p_ndi_csq->state)
+       {
+       case NDI_CM_CONNECTING_REQ_SENT:
+               /* Cleanup from issuing CM REQ. */
+               ref_al_obj( &h_qp->obj );
+               cid = cl_atomic_xchg( &((al_conn_qp_t*)h_qp)->cid, AL_INVALID_CID );
+               if( cid == AL_INVALID_CID || al_destroy_cep( qp_get_al( h_qp ), cid, deref_al_obj ) != IB_SUCCESS )
+               {
+                       deref_al_obj( &h_qp->obj );
+               }
+               break;
+
+       case NDI_CM_CONNECTING_ATS_SENT:
+       case NDI_CM_CONNECTING_QPR_SENT:
+               al_cancel_sa_req( &h_qp->p_irp_que->h_query->sa_req );
+               break;
+
+       default:
+               /* fall through */
+               break;
+       }
+
+       //TODO: is it always true ?
+       p_ndi_csq->state = NDI_CM_IDLE;
+       __ndi_complete_irp( h_qp, Irp, CL_CANCELED );
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+/* flush a queue of pending requests */
+
+#pragma warning(disable:4706)
+static inline void __ndi_flush_que(
+       IN      ndi_qp_csq_t*                                                   p_ndi_csq,
+       IN      NTSTATUS                                                                completion_code
+       )
+{
+       PIRP Irp;
+       while( Irp = IoCsqRemoveNextIrp( &p_ndi_csq->csq, NULL ) )
+       {
+               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI, 
+                       ("h_qp %#I64x, uhdl %#I64x, ref_cnt %d\n", 
+                       (uint64_t)p_ndi_csq->h_qp, p_ndi_csq->h_qp->obj.hdl, 
+                       p_ndi_csq->h_qp->obj.ref_cnt ) );
+               cl_ioctl_complete( Irp, completion_code, 0 );
+               deref_al_obj( &p_ndi_csq->h_qp->obj );          /* release IRP life reference */
+       }
+}
+#pragma warning(default:4706)
+
+void
+ndi_qp_flush_ques(
+       IN      ib_qp_handle_t                                                  h_qp
+       )
+{
+       AL_ENTER( AL_DBG_NDI );
+       __ndi_flush_que( h_qp->p_irp_que, STATUS_CANCELLED );
+       AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI, 
+               ("h_qp %#I64x, uhdl %#I64x, ref_cnt %d\n", 
+               (uint64_t)h_qp, h_qp->obj.hdl, h_qp->obj.ref_cnt ) );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+
+
+NTSTATUS
+ndi_qp_init(
+       IN                              ib_qp_handle_t                          h_qp )
+{
+
+       NTSTATUS status;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       if ( h_qp->type == IB_QPT_UNRELIABLE_CONN )
+       {
+               status = STATUS_SUCCESS;
+               goto exit;
+       }
+       
+       h_qp->p_irp_que = (ndi_qp_csq_t*)cl_zalloc(sizeof(ndi_qp_csq_t));
+       if (!h_qp->p_irp_que)
+       {
+               status = STATUS_NO_MEMORY;
+               goto exit;
+       }
+
+       status = IoCsqInitialize( &h_qp->p_irp_que->csq, 
+               __ndi_insert_irp, __ndi_remove_irp,
+               __ndi_peek_next_irp, __ndi_acquire_lock,
+               __ndi_release_lock, __ndi_complete_cancelled_irp );
+       if ( !NT_SUCCESS( status ) )
+               goto exit;
+
+       InitializeListHead( &h_qp->p_irp_que->que );
+       h_qp->p_irp_que->h_qp = h_qp;
+       h_qp->p_irp_que->h_query = NULL;
+       h_qp->p_irp_que->state = NDI_CM_IDLE;
+       status = STATUS_SUCCESS;
+
+AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+       ("Creating h_qp %#I64x, uhdl %#I64x \n", 
+       (uint64_t)h_qp, h_qp->obj.hdl ) );
+
+exit:
+       AL_EXIT( AL_DBG_NDI );
+       return status;
+}
+
+void
+ndi_qp_destroy(
+       IN              ib_qp_handle_t                                  h_qp )
+{
+       AL_ENTER( AL_DBG_NDI );
+
+       if (h_qp->type == IB_QPT_RELIABLE_CONN && h_qp->p_irp_que)
+       {
+               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+                       ("Destroying h_qp %#I64x, uhdl %#I64x, h_ioctl %p, cid %d\n", 
+                       (uint64_t)h_qp, h_qp->obj.hdl, h_qp->p_irp_que->h_ioctl, ((al_conn_qp_t*)h_qp)->cid ) );
+
+               /* cancel pending IRPS for NDI type CQ */
+               ndi_qp_flush_ques( h_qp );
+       }
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+void
+ndi_qp_free(
+       IN              ib_qp_handle_t                                  h_qp )
+{
+       AL_ENTER( AL_DBG_NDI );
+
+       if (h_qp->type == IB_QPT_RELIABLE_CONN && h_qp->p_irp_que)
+       {
+               /* free NDI context */
+               cl_free( h_qp->p_irp_que );
+               h_qp->p_irp_que = NULL;
+       }
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+
+/*******************************************************************
+ *
+ * REQ CM request
+ *
+ ******************************************************************/
+
+static void
+__ndi_req_cm_wi(
+       IN                              DEVICE_OBJECT*                          p_dev_obj,
+       IN                              void*                                           context )
+{
+       NTSTATUS status;
+       ib_qp_handle_t  h_qp = (ib_qp_handle_t)context;
+       UNUSED_PARAM(p_dev_obj);
+
+       AL_ENTER( AL_DBG_NDI );
+
+       IoFreeWorkItem( h_qp->p_irp_que->p_workitem );
+
+       __cep_timewait_qp( h_qp );
+       
+       h_qp->p_irp_que->state = NDI_CM_IDLE;   
+       status = (h_qp->p_irp_que->state == NDI_CM_CONNECTED) ? STATUS_CONNECTION_DISCONNECTED : STATUS_CONNECTION_REFUSED;
+       __ndi_complete_irp( h_qp, h_qp->p_irp_que->h_ioctl, status );
+       deref_al_obj( &h_qp->obj );     /* release IRP SA reference */
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+/*
+ * A user-specified callback that is invoked after receiving a connection
+ * rejection message (REJ).
+ */
+       
+       
+static void
+__ndi_proc_rej(
+       IN              const   ib_cm_handle_t* const           p_cm,
+       IN              const   mad_cm_rej_t* const             p_rej )
+{
+       net32_t cid;
+       NTSTATUS status;
+       ib_qp_handle_t  h_qp = p_cm->h_qp;
+       ndi_qp_csq_t *p_ndi_csq = h_qp->p_irp_que;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       AL_PRINT(TRACE_LEVEL_ERROR, AL_DBG_ERROR, 
+               ("p_rej %p, h_qp %#I64x, uhdl %#I64x, connect reject, reason=%hd\n", 
+               p_rej, (uint64_t)h_qp, h_qp->obj.hdl, cl_ntoh16(p_rej->reason) ) );
+
+       ref_al_obj( &h_qp->obj );
+       cid = cl_atomic_xchg( &((al_conn_qp_t*)h_qp)->cid, AL_INVALID_CID );
+       CL_ASSERT( cid == p_cm->cid || cid == AL_RESERVED_CID || cid == AL_INVALID_CID );
+       if( cid == AL_INVALID_CID ||
+               al_destroy_cep( p_cm->h_al, cid, deref_al_obj ) != IB_SUCCESS )
+       {
+               deref_al_obj( &h_qp->obj );
+       }
+
+       switch (p_ndi_csq->state)
+       {
+       case NDI_CM_CONNECTING_REQ_SENT:
+               al_cep_set_pdata( p_cm->h_al, p_cm->cid, IB_REJ_PDATA_SIZE, (uint8_t*)p_rej->pdata );
+               AL_PRINT(TRACE_LEVEL_INFORMATION, AL_DBG_NDI ,
+                       ("set %d of REQ pdata to CEP with cid %d, h_al %p\n", 
+                       IB_REJ_PDATA_SIZE, p_cm->cid, p_cm->h_al ));
+               status = (p_rej->reason == IB_REJ_TIMEOUT) ? STATUS_TIMEOUT : STATUS_CONNECTION_REFUSED;
+               __ndi_complete_irp_ex( h_qp, status, NDI_CM_CONNECTING_REJ_RCVD );
+               break;
+
+       case NDI_CM_CONNECTED:
+       case NDI_CM_REP_SENT:
+               /* a race: the passive side\92s REP times out, but active side has sent the RTU.  
+                  We are treating this case it like a DREQ */
+               {
+                       IO_STACK_LOCATION *p_io_stack;
+                       cl_ioctl_handle_t h_ioctl;
+
+                       h_ioctl = IoCsqRemoveNextIrp( &h_qp->p_irp_que->csq, NULL );
+                       if (!h_ioctl)
+                       { /* IRP has been cancelled */
+                               // TODO: no QP flash
+                               AL_PRINT(TRACE_LEVEL_INFORMATION, AL_DBG_NDI ,
+                                       ( "IRP cancelled: Can't flush the QP %p, ndi_state %d\n",
+                                       h_qp, p_ndi_csq->state ) );
+                               h_qp->p_irp_que->state = NDI_CM_IDLE;   
+//                             ASSERT(FALSE);
+                       }
+                       else
+                       {
+                               p_io_stack = IoGetCurrentIrpStackLocation( h_ioctl );
+                               h_qp->p_irp_que->p_workitem = IoAllocateWorkItem( p_io_stack->DeviceObject );
+                               if ( h_qp->p_irp_que->p_workitem )
+                               { /* asyncronous performing */
+                                       IoQueueWorkItem( h_qp->p_irp_que->p_workitem,
+                                               __ndi_req_cm_wi, DelayedWorkQueue, h_qp );
+                               }
+                               else
+                               { /* syncronous performing */
+                                       // TODO: no QP flash
+                                       AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR ,
+                                               ( "Can't flush the QP %p, ndi_state %d\n",
+                                               h_qp, p_ndi_csq->state ) );
+                                       h_qp->p_irp_que->state = NDI_CM_IDLE;   
+                                       status = (h_qp->p_irp_que->state == NDI_CM_CONNECTED) ? STATUS_CONNECTION_DISCONNECTED : STATUS_CONNECTION_REFUSED;
+                                       __ndi_complete_irp( h_qp, h_ioctl, status );
+                                       deref_al_obj( &h_qp->obj );     /* release IRP SA reference */
+                                       h_qp->p_irp_que->h_ioctl = NULL;
+                               }
+                       }
+                       break;
+               }
+               
+       default:        
+               // This is not the state that we waited for, not much that we can
+               // do. (This might happen in shutdown)
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, 
+                       ("Not the expected state %s\n", State2String( p_ndi_csq->state )));
+               ASSERT(FALSE);
+               break;
+       }
+       
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static void
+__ndi_proc_rep(
+       IN                              ib_cm_handle_t* const           p_cm,
+       IN                              mad_cm_rep_t* const                     p_rep )
+{
+       ndi_qp_csq_t *p_ndi_csq = p_cm->h_qp->p_irp_que;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI ,("h_qp = 0x%p\n", p_cm->h_qp));
+
+       if ( p_ndi_csq->state  != NDI_CM_CONNECTING_REQ_SENT) 
+       {
+               // This is not the state that we waited for, not much that we can do
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, 
+                       ("Not the expected state %s\n", State2String( p_ndi_csq->state )));
+               ASSERT(FALSE);
+               goto exit;
+       }
+
+       /* fill the rej data */
+       al_cep_set_pdata( p_cm->h_al, p_cm->cid, IB_REJ_PDATA_SIZE, p_rep->pdata );
+       AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR ,
+               ("set %d of REQ pdata to CEP with cid %d, h_al %p\n", 
+               IB_REJ_PDATA_SIZE, p_cm->cid, p_cm->h_al ));
+
+       __ndi_complete_irp_ex( p_cm->h_qp, STATUS_SUCCESS, NDI_CM_CONNECTING_REP_RCVD );
+
+exit:  
+       AL_EXIT( AL_DBG_NDI );
+}
+
+typedef struct _ndi_async_dreq
+{
+       cl_async_proc_item_t    item;
+       ib_cm_handle_t                  cm;
+
+}      ndi_async_dreq_t;
+
+static void
+__ndi_proc_dreq_async(
+       IN                              cl_async_proc_item_t            *p_item )
+{
+       ib_qp_mod_t qp_mod;
+       ib_api_status_t status;
+       ib_cm_drep_t cm_drep = { NULL, 0 };
+       ndi_async_dreq_t *p_async_dreq = PARENT_STRUCT( p_item, ndi_async_dreq_t, item );
+
+       AL_ENTER( AL_DBG_NDI );
+
+       /* bring QP to error state */
+       cl_memclr( &qp_mod, sizeof(qp_mod) );
+       qp_mod.req_state = IB_QPS_ERROR;
+
+       status = modify_qp( p_async_dreq->cm.h_qp, &qp_mod, NULL );
+       if ( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("al_modify_qp to ERROR returned %s.\n", ib_get_err_str(status) ) );
+               goto exit;
+       }
+
+       status = al_cep_drep( p_async_dreq->cm.h_al,
+               ((al_conn_qp_t*)p_async_dreq->cm.h_qp)->cid, &cm_drep);
+
+       if ( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("al_cep_drep returned %s.\n", ib_get_err_str(status) ) );
+       }
+       //TODO: what state is to be set here ?
+       //p_async_dreq->cm.h_qp->p_irp_que->state = NDI_CM_IDLE;        
+
+exit:
+       cl_free( p_async_dreq );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static void
+__ndi_proc_dreq(
+       IN                              ib_cm_handle_t* const           p_cm,
+       IN                              mad_cm_dreq_t* const            p_dreq )
+{
+       ndi_async_dreq_t *p_async_dreq;
+       UNUSED_PARAM(p_dreq);
+
+       AL_ENTER( AL_DBG_NDI );
+
+       AL_PRINT(TRACE_LEVEL_INFORMATION ,AL_DBG_NDI ,("h_qp = 0x%p\n", p_cm->h_qp));
+
+       p_async_dreq = (ndi_async_dreq_t*)cl_zalloc( sizeof(ndi_async_dreq_t) );
+       if( !p_async_dreq )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("failed to cl_zalloc ndi_async_dreq_t (%d bytes)\n",
+                       sizeof(ndi_async_dreq_t)) );
+               ASSERT(FALSE);
+               goto exit;
+       }
+
+       p_async_dreq->cm = *p_cm;
+       p_async_dreq->item.pfn_callback = __ndi_proc_dreq_async;
+
+       /* Queue the MAD for asynchronous processing. */
+       cl_async_proc_queue( gp_async_proc_mgr, &p_async_dreq->item );
+
+exit:  
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static void
+__ndi_cm_handler(
+       IN              const   ib_al_handle_t                          h_al,
+       IN              const   net32_t                                         cid )
+{
+       void* __ptr64           context;
+       net32_t                         new_cid;
+       ib_mad_element_t        *p_mad_el;
+       ib_cm_handle_t          h_cm;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       while( al_cep_poll( h_al, cid, &context, &new_cid, &p_mad_el ) == IB_SUCCESS )
+       {
+               ib_mad_t*p_mad = ib_get_mad_buf( p_mad_el );
+               ib_qp_handle_t h_qp = (ib_qp_handle_t)context;
+
+               if( p_mad_el->status != IB_SUCCESS )
+               {
+                       switch( p_mad->attr_id )
+                       {
+                       case CM_REQ_ATTR_ID:
+                               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+                                       ("REQ timeouted for CEP with cid %d, h_al %p, context %p, new_cid %d .\n", 
+                                       cid, h_al, h_qp, new_cid ) );
+                               __ndi_complete_irp_ex( h_qp, STATUS_TIMEOUT, NDI_CM_IDLE );
+                               break;
+
+                       case CM_REP_ATTR_ID:
+                               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+                                       ("REP timeouted for CEP with cid %d, h_al %p, context %p, new_cid %d .\n", 
+                                       cid, h_al, h_qp, new_cid ) );
+                               __ndi_complete_irp_ex( h_qp, STATUS_CONNECTION_ABORTED, NDI_CM_IDLE );
+                               break;
+
+                       case CM_DREQ_ATTR_ID:
+                       default:
+                               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                                       ("Unhandled MAD attr ID %d for CEP with cid %d, h_al %p, context %p, new_cid %d .\n", 
+                                       p_mad->attr_id, cid, h_al, h_qp, new_cid ) );
+                               break;
+                       }
+               }
+               else
+               {
+                       h_cm.h_al = h_al;
+                       h_cm.h_qp = h_qp;
+                       h_cm.cid = cid;
+                       
+                       switch( p_mad->attr_id )
+                       {
+                       case CM_REP_ATTR_ID:
+                               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+                                       ("REP received for CEP with cid %d, h_al %p, context %p, new_cid %d .\n", 
+                                       cid, h_al, h_qp, new_cid ) );
+                               CL_ASSERT( ((al_conn_qp_t*)h_qp)->cid == (int32_t)cid || 
+                                       ((al_conn_qp_t*)h_qp)->cid == AL_INVALID_CID ||
+                                       ((al_conn_qp_t*)h_qp)->cid == AL_RESERVED_CID );
+                               __ndi_proc_rep( &h_cm, (mad_cm_rep_t*)p_mad );
+                               break;
+                       
+                       case CM_REJ_ATTR_ID:
+                               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+                                       ("REJ received for CEP with cid %d, h_al %p, context %p, new_cid %d .\n", 
+                                       cid, h_al, h_qp, new_cid ) );
+                               __ndi_proc_rej( &h_cm, (mad_cm_rej_t*)p_mad );
+                               break;
+               
+                       case CM_DREQ_ATTR_ID:
+                               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+                                       ("DREQ received for CEP with cid %d, h_al %p, context %p, new_cid %d .\n", 
+                                       cid, h_al, h_qp, new_cid ) );
+                               CL_ASSERT( ((al_conn_qp_t*)h_qp)->cid == (int32_t)cid || 
+                               ((al_conn_qp_t*)h_qp)->cid == AL_INVALID_CID ||
+                               ((al_conn_qp_t*)h_qp)->cid == AL_RESERVED_CID );
+                               __ndi_proc_dreq( &h_cm, (mad_cm_dreq_t*)p_mad );
+                               break;
+               
+                       default:
+                               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                                       ("Invalid CM recv MAD attribute ID %d.\n", p_mad->attr_id) );
+                       }
+               }
+
+               ib_put_mad( p_mad_el );
+       }
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static void
+__ndi_fill_cm_req(
+       IN              ib_qp_handle_t  const                           h_qp,
+       IN              ual_ndi_req_cm_ioctl_in_t                       *p_req,
+       IN              ib_path_rec_t                                           *p_path_rec,
+               OUT     ib_cm_req_t                                                     *p_cm_req)
+{
+       AL_ENTER( AL_DBG_NDI );
+
+       memset( p_cm_req, 0, sizeof(ib_cm_req_t) );
+
+       p_cm_req->svc_id = IB_REQ_CM_RDMA_SID_PREFIX | (p_req->prot << 16) | p_req->dst_port;
+       p_cm_req->max_cm_retries = g_max_cm_retries;
+       p_cm_req->p_primary_path = p_path_rec;  
+
+       p_cm_req->p_req_pdata = (uint8_t *)&p_req->pdata;
+       p_cm_req->req_length = sizeof(p_req->pdata);
+
+       p_cm_req->qp_type = IB_QPT_RELIABLE_CONN;
+       p_cm_req->h_qp = h_qp;
+       p_cm_req->resp_res = 0;
+       p_cm_req->init_depth = 0;
+
+       p_cm_req->remote_resp_timeout =
+               ib_path_rec_pkt_life( p_path_rec ) + CM_REMOTE_TIMEOUT;
+       if( p_cm_req->remote_resp_timeout > 0x1F )
+               p_cm_req->remote_resp_timeout = 0x1F;
+       else if( p_cm_req->remote_resp_timeout < CM_MIN_REMOTE_TIMEOUT )
+               p_cm_req->remote_resp_timeout = CM_MIN_REMOTE_TIMEOUT;
+
+       p_cm_req->flow_ctrl = TRUE;     /* HCAs must support end-to-end flow control. */
+
+       p_cm_req->local_resp_timeout =
+               ib_path_rec_pkt_life( p_path_rec ) + CM_LOCAL_TIMEOUT;
+       if( p_cm_req->local_resp_timeout > 0x1F )
+               p_cm_req->local_resp_timeout = 0x1F;
+       else if( p_cm_req->local_resp_timeout < CM_MIN_LOCAL_TIMEOUT )
+               p_cm_req->local_resp_timeout = CM_MIN_LOCAL_TIMEOUT;
+
+       p_cm_req->rnr_nak_timeout = QP_ATTRIB_RNR_NAK_TIMEOUT;
+       p_cm_req->rnr_retry_cnt = QP_ATTRIB_RNR_RETRY;
+       p_cm_req->retry_cnt = g_qp_retries;
+       p_cm_req->p_alt_path = NULL;
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static void AL_API
+__ndi_pr_query_cb(
+                                       ib_query_rec_t                          *p_query_rec )
+{
+       ib_api_status_t status;
+       cl_ioctl_handle_t h_ioctl;
+       ib_cm_req_t cm_req;
+       uint8_t pkt_life;
+       ib_qp_mod_t qp_mod;
+       ib_path_rec_t *p_path_rec;
+       ual_ndi_req_cm_ioctl_in_t *p_req = (ual_ndi_req_cm_ioctl_in_t* __ptr64)p_query_rec->query_context;
+       ib_qp_handle_t h_qp = (ib_qp_handle_t)p_req->h_qp;
+       net32_t cid, old_cid;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+               ("status is %d, count is %d, context %p\n", p_query_rec->status,
+               p_query_rec->result_cnt, p_query_rec->query_context) );
+
+       h_ioctl = IoCsqRemoveNextIrp( &h_qp->p_irp_que->csq, NULL );
+       if( !h_ioctl || p_query_rec->status != IB_SUCCESS || !p_query_rec->result_cnt )
+               goto err_irp_complete;
+
+       /* Path Record has been received ! */
+       p_path_rec = ib_get_query_path_rec( p_query_rec->p_result_mad, 0 );
+
+       /* fix packet life */
+       CL_ASSERT( p_path_rec );
+       pkt_life = ib_path_rec_pkt_life( p_path_rec ) + g_pkt_life_modifier;
+       if( pkt_life > 0x1F )
+               pkt_life = 0x1F;
+
+       p_path_rec->pkt_life &= IB_PATH_REC_SELECTOR_MASK;
+       p_path_rec->pkt_life |= pkt_life;
+
+       /* Get a CEP and bind it to the QP. */
+       status = al_create_cep( qp_get_al( h_qp ), __ndi_cm_handler, h_qp, &cid );
+       if( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("al_create_cep returned %s.\n", ib_get_err_str( status )) );
+               goto err_irp_complete;
+       }
+       AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+               ("Created Active CEP with cid %d, h_al %p, context %p\n",
+               cid, qp_get_al( h_qp ), h_qp ) );
+
+       /* See if this QP has already been connected. */
+       old_cid = cl_atomic_comp_xchg( &((al_conn_qp_t*)h_qp)->cid, AL_INVALID_CID, cid );
+       if( old_cid != AL_INVALID_CID || h_qp->obj.state == CL_DESTROYING )
+               goto err_cep_destroy;
+
+       /* Format ib_cm_req_t structure */
+       __ndi_fill_cm_req( h_qp, p_req, p_path_rec, &cm_req );
+
+       /* prepare CEP for connection */
+       status = al_cep_pre_req( qp_get_al( h_qp ),
+               ((al_conn_qp_t*)h_qp)->cid, &cm_req, &qp_mod );
+       if( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("al_cep_pre_req returned %s.\n", ib_get_err_str( status )) );
+               goto err_cep_destroy;
+       }
+
+       /* insert IRP in the queue */
+       h_qp->p_irp_que->state = NDI_CM_CONNECTING_REQ_SENT;
+       IoCsqInsertIrp( &h_qp->p_irp_que->csq, h_ioctl, NULL );
+
+       /* send CM REQ */
+       status = al_cep_send_req( qp_get_al( h_qp ), cid );
+       if( status != IB_SUCCESS )
+               goto err_irp_remove;
+
+       /* we can release it now. In case of QP destroy __destroying_qp will remove CEP */
+       deref_al_obj( &h_qp->obj );     /* release IRP SA reference */
+
+       /* SUCCESS ! */
+       goto exit;
+
+err_irp_remove:
+       h_ioctl = IoCsqRemoveNextIrp( &h_qp->p_irp_que->csq, NULL );
+
+err_cep_destroy:
+       al_destroy_cep( qp_get_al( h_qp ), cid, NULL );
+       
+err_irp_complete:
+       h_qp->p_irp_que->state = NDI_CM_IDLE;   
+       /* the IRP "has" 2 QP references, taken in __ndi_ats_query */
+       if ( h_ioctl )
+               __ndi_complete_irp( h_qp, h_ioctl, STATUS_HOST_UNREACHABLE );
+       deref_al_obj( &h_qp->obj );     /* release IRP SA reference */
+
+exit:  
+       cl_free( p_req );
+       if( p_query_rec->p_result_mad )
+               ib_put_mad( p_query_rec->p_result_mad );
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+
+
+/* Synchronously query the SA for a GUID. Return 0 on success. */
+void
+__ndi_pr_query(
+       IN              cl_ioctl_handle_t                                       h_ioctl,
+       IN              ual_ndi_req_cm_ioctl_in_t                       *p_req,
+       IN              ib_gid_t                                                        *p_dest_gid )
+{
+       ib_gid_pair_t user_query;
+       ib_query_req_t query_req;
+       ib_api_status_t status;
+       ib_qp_handle_t h_qp = (ib_qp_handle_t)p_req->h_qp;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       query_req.query_type = IB_QUERY_PATH_REC_BY_GIDS;
+       query_req.p_query_input = &user_query;
+       query_req.port_guid = p_req->guid;
+       query_req.timeout_ms = g_sa_timeout;
+       query_req.retry_cnt = g_sa_retries;
+       query_req.flags = 0;    /* IB_FLAGS_SYNC */
+       query_req.query_context = p_req;
+       query_req.pfn_query_cb = __ndi_pr_query_cb;
+
+       user_query.src_gid.unicast.prefix = p_dest_gid->unicast.prefix;
+       user_query.src_gid.unicast.interface_id = p_req->guid;
+       user_query.dest_gid = *p_dest_gid;
+
+       AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+               ("Query for path from %I64x to %I64x\n",
+               p_req->guid, ib_gid_get_guid( p_dest_gid )) );
+
+       /* insert IRP in the queue */
+       h_qp->p_irp_que->state = NDI_CM_CONNECTING_QPR_SENT;
+       IoCsqInsertIrp( &h_qp->p_irp_que->csq, h_ioctl, NULL );
+
+       status = ib_query( qp_get_al( h_qp ), &query_req, &h_qp->p_irp_que->h_query );
+
+       if( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("ib_query failed (%d)\n", status) );
+               cl_free( p_req );
+               __ndi_complete_irp_ex( h_qp, CL_ERROR, NDI_CM_IDLE );
+               /* relase additional reference, taken in __ndi_ats_query */
+               deref_al_obj( &h_qp->obj );     /* release IRP SA reference */
+       }
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+
+static void AL_API
+__ndi_ats_query_cb(
+       IN                              ib_query_rec_t                          *p_query_rec )
+{
+       cl_ioctl_handle_t h_ioctl;
+       ib_service_record_t *service_record;
+       ual_ndi_req_cm_ioctl_in_t *p_req = (ual_ndi_req_cm_ioctl_in_t* __ptr64)p_query_rec->query_context;
+       ib_qp_handle_t h_qp = (ib_qp_handle_t)p_req->h_qp;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+               ("status is %d, count is %d, context %p\n", p_query_rec->status,
+               p_query_rec->result_cnt, p_query_rec->query_context) );
+
+       h_ioctl = IoCsqRemoveNextIrp( &h_qp->p_irp_que->csq, NULL );
+       if( !h_ioctl || p_query_rec->status != IB_SUCCESS || !p_query_rec->result_cnt )
+       {
+               h_qp->p_irp_que->state = NDI_CM_IDLE; 
+               if ( h_ioctl )
+                       __ndi_complete_irp( h_qp, h_ioctl, STATUS_HOST_UNREACHABLE );
+               deref_al_obj( &h_qp->obj );     /* release IRP SA reference */
+               cl_free( p_req );
+               goto exit;              /* ATS request failed */
+       }
+
+       /* send Path Request */
+       service_record = ib_get_query_svc_rec( p_query_rec->p_result_mad, 0 );
+       __ndi_pr_query( h_ioctl, p_req, &service_record->service_gid );
+
+exit:  
+       if( p_query_rec->p_result_mad )
+               ib_put_mad( p_query_rec->p_result_mad );
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+/* Send asynchronous query to SA for a GUID. Return STATUS_PENDING on success. */
+NTSTATUS
+__ndi_ats_query(
+       IN              ib_qp_handle_t  const                           h_qp,
+       IN              cl_ioctl_handle_t                                       h_ioctl,
+       IN              ual_ndi_req_cm_ioctl_in_t                       *p_req )
+{
+       ib_user_query_t user_query;
+       ib_service_record_t service_record;
+       ib_query_req_t query_req;
+       ib_api_status_t status;
+       NTSTATUS nt_status = STATUS_PENDING;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       query_req.query_type = IB_QUERY_USER_DEFINED;
+       query_req.p_query_input = &user_query;
+       query_req.port_guid = p_req->guid;
+       query_req.timeout_ms = g_sa_timeout;
+       query_req.retry_cnt = g_sa_retries;
+       query_req.flags = 0;    /* IB_FLAGS_SYNC */
+       query_req.query_context = p_req;
+       query_req.pfn_query_cb = __ndi_ats_query_cb;
+
+       /* TODO: which method one is correct? */
+       user_query.method = IB_MAD_METHOD_GETTABLE;
+       //user_query.method = IB_MAD_METHOD_GET;
+       user_query.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+       user_query.attr_size = sizeof(ib_service_record_t);
+       user_query.comp_mask =
+               IB_SR_COMPMASK_SPKEY |
+               IB_SR_COMPMASK_SLEASE |
+               IB_SR_COMPMASK_SNAME |
+               IB_SR_COMPMASK_SDATA8_12 |
+               IB_SR_COMPMASK_SDATA8_13 | IB_SR_COMPMASK_SDATA8_14 | IB_SR_COMPMASK_SDATA8_15;
+
+       user_query.p_attr = &service_record;
+
+       memset( &service_record, 0, sizeof(service_record) );
+       service_record.service_pkey = cl_hton16( IB_DEFAULT_PKEY );
+       service_record.service_data8[12] = (uint8_t) (p_req->pdata.dst_ip_addr[3] >> 0);
+       service_record.service_data8[13] = (uint8_t) (p_req->pdata.dst_ip_addr[3] >> 8);
+       service_record.service_data8[14] = (uint8_t) (p_req->pdata.dst_ip_addr[3] >> 16);
+       service_record.service_data8[15] = (uint8_t) (p_req->pdata.dst_ip_addr[3] >> 24);
+       service_record.service_lease = 0xFFFFFFFF;
+       strcpy( (void*)service_record.service_name, ATS_NAME );
+       
+       AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+               ("ATS:: MAD: method %#x, attr_id %#hx, Service: comp_mask %#I64x, IP %d.%d.%d.%d \n", 
+               user_query.method,
+               CL_NTOH16(user_query.attr_id),
+               user_query.comp_mask,
+               service_record.service_data8[12],
+               service_record.service_data8[13],
+               service_record.service_data8[14],
+               service_record.service_data8[15]
+               ) );
+
+       AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI, 
+               ("h_qp %#I64x, uhdl %#I64x, ref_cnt %d\n", 
+               (uint64_t)h_qp, h_qp->obj.hdl, h_qp->obj.ref_cnt ) );
+
+       // preserve QP for the life of this IOCTL
+       ref_al_obj( &h_qp->obj );               /* take IRP life reference */
+
+       /* insert IRP in the queue */
+       IoCsqInsertIrp( &h_qp->p_irp_que->csq, h_ioctl, NULL );
+
+       /* prevent destroying QP after cancelling of the IRP and before ib_query calback*/
+       ref_al_obj( &h_qp->obj );               /* take IRP SA reference */
+
+       /* query SA */
+       status = ib_query( qp_get_al( h_qp ), &query_req, &h_qp->p_irp_que->h_query );
+       if( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("ib_query failed (%d)\n", status) );
+               deref_al_obj( &h_qp->obj );     /* release IRP SA reference */
+               h_ioctl = IoCsqRemoveNextIrp( &h_qp->p_irp_que->csq, NULL );
+               if ( h_ioctl )
+               { /* IOCTL should be released in the caller */
+                       deref_al_obj( &h_qp->obj );             /* release IRP life reference */
+                       nt_status = STATUS_DRIVER_INTERNAL_ERROR;
+               }
+       }
+
+       AL_EXIT( AL_DBG_NDI );
+       return nt_status;
+}
+
+NTSTATUS
+ndi_req_cm(
+       IN              ib_qp_handle_t  const                           h_qp,
+       IN              cl_ioctl_handle_t                                       h_ioctl,
+       IN              ual_ndi_req_cm_ioctl_in_t                       *p_req
+       )
+{
+       NTSTATUS nt_status;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       /* check outstanding request */
+       __ndi_acquire_lock( &h_qp->p_irp_que->csq, NULL);
+       if ( h_qp->p_irp_que->h_ioctl )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, 
+                       ("STATUS_CONNECTION_ACTIVE: h_qp %#I64x, uhdl %#I64x, ref_cnt %d\n",
+                       (uint64_t)h_qp, h_qp->obj.hdl, h_qp->obj.ref_cnt ) );
+               nt_status = STATUS_CONNECTION_ACTIVE;
+               __ndi_release_lock( &h_qp->p_irp_que->csq, 0 );
+               goto exit;
+       }
+       if ( h_qp->p_irp_que->state != NDI_CM_IDLE )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, 
+                       ("STATUS_INVALID_DEVICE_STATE: h_qp %I64x, ref_cnt %d, state %d\n",
+                       (uint64_t)h_qp, h_qp->obj.ref_cnt, h_qp->p_irp_que->state ) );
+               nt_status = STATUS_INVALID_DEVICE_STATE;
+               __ndi_release_lock( &h_qp->p_irp_que->csq, 0 );
+               goto exit;
+       }
+       h_qp->p_irp_que->h_ioctl = h_ioctl;     /* mark IRP as present */
+       h_qp->p_irp_que->state = NDI_CM_CONNECTING_ATS_SENT;
+       __ndi_release_lock( &h_qp->p_irp_que->csq, 0 );
+
+       /* send ATS request */
+       nt_status = __ndi_ats_query( h_qp, h_ioctl, p_req );
+
+exit:
+       if ( nt_status != STATUS_PENDING )
+       {
+               cl_free( p_req );
+               h_qp->p_irp_que->state = NDI_CM_IDLE; 
+               h_qp->p_irp_que->h_ioctl = NULL; /* mark IRP as present */
+               cl_ioctl_complete( h_ioctl, nt_status, 0 );
+       }
+       AL_EXIT( AL_DBG_NDI );
+       return STATUS_PENDING;
+}
+
+
+/*******************************************************************
+ *
+ * RTU CM request
+ *
+ ******************************************************************/
+
+static void
+__ndi_rtu_cm(
+       IN                              DEVICE_OBJECT*                          p_dev_obj,
+       IN                              PIRP                                            p_irp )
+{
+       NTSTATUS nt_status;
+       ib_qp_mod_t qp_mod;
+       ib_api_status_t status;
+       ib_qp_handle_t h_qp = p_irp->Tail.Overlay.DriverContext[0];
+       ual_ndi_rtu_cm_ioctl_in_t *p_rtu = 
+               (ual_ndi_rtu_cm_ioctl_in_t*)cl_ioctl_in_buf( p_irp );
+       uint8_t pdata[IB_REJ_PDATA_SIZE];
+       uint8_t psize = sizeof(pdata);
+
+       UNUSED_PARAM(p_dev_obj);
+
+       AL_ENTER( AL_DBG_NDI );
+
+       /* free the work item if any */
+       if ( p_irp->Tail.Overlay.DriverContext[1] )
+               IoFreeWorkItem( p_irp->Tail.Overlay.DriverContext[1] );
+
+       /* change the QP state to RTS */
+       status = __ndi_qp2rts( h_qp, p_rtu->init_depth, 
+               p_rtu->resp_res, p_irp, &qp_mod );
+       if ( status != IB_SUCCESS )
+       {
+               goto err;
+       }
+       
+       /* send RTU */
+       al_cep_get_pdata( qp_get_al( h_qp ), ((al_conn_qp_t*)h_qp)->cid, &psize, pdata );
+       status = al_cep_rtu( qp_get_al( h_qp ), ((al_conn_qp_t*)h_qp)->cid, pdata, psize );
+       if( status != IB_SUCCESS && status != IB_INVALID_STATE )
+       {
+               net32_t                         cid;
+err:
+               /* Reject and abort the connection. */
+               al_cep_rej(
+                       qp_get_al( h_qp ), ((al_conn_qp_t*)h_qp)->cid, 
+                       IB_REJ_INSUF_QP, NULL, 0, NULL, 0 );
+
+               __cep_timewait_qp( h_qp );
+
+               cid = cl_atomic_xchg( &((al_conn_qp_t*)h_qp)->cid, AL_INVALID_CID );
+
+               if( cid != AL_INVALID_CID )
+               {
+                       ref_al_obj( &h_qp->obj );
+                       if( al_destroy_cep( qp_get_al( h_qp ), cid, deref_al_obj ) != IB_SUCCESS )
+                       {
+                               deref_al_obj( &h_qp->obj );
+                       }
+               }
+
+               AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+                       ("al_cep_rtu returned %s.\n", ib_get_err_str( status )) );
+               h_qp->p_irp_que->state = NDI_CM_IDLE;   
+               nt_status = STATUS_DRIVER_INTERNAL_ERROR;
+               p_irp->IoStatus.Information = 0;
+               goto exit;
+       }
+
+       p_irp->IoStatus.Information = sizeof(uint32_t);;
+       h_qp->p_irp_que->state = NDI_CM_CONNECTED;
+       nt_status = STATUS_SUCCESS;
+
+exit:  
+       /* release the reference only for async case */
+       if ( p_irp->Tail.Overlay.DriverContext[1] )
+               deref_al_obj( &h_qp->obj );
+
+       p_irp->IoStatus.Status = nt_status;
+       IoCompleteRequest( p_irp, IO_NO_INCREMENT );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+cl_status_t
+ndi_rtu_cm(
+       IN              ib_qp_handle_t  const                           h_qp,
+       IN              PIRP                                                            p_irp
+       )
+{
+       IO_STACK_LOCATION       *p_io_stack;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       p_irp->Tail.Overlay.DriverContext[0] = h_qp;
+       p_io_stack = IoGetCurrentIrpStackLocation( p_irp );
+       p_irp->Tail.Overlay.DriverContext[1] = IoAllocateWorkItem( p_io_stack->DeviceObject );
+       if ( p_irp->Tail.Overlay.DriverContext[1] )
+       { /* asyncronous performing */
+               /* take a ref to prevent QP destroy before calling work item */
+               ref_al_obj( &h_qp->obj );
+               IoMarkIrpPending( p_irp );
+               IoQueueWorkItem( p_irp->Tail.Overlay.DriverContext[1],
+                       __ndi_rtu_cm, DelayedWorkQueue, p_irp );
+       }
+       else
+       { /* syncronous performing */
+               p_irp->Tail.Overlay.DriverContext[1] = NULL;
+               __ndi_rtu_cm( p_io_stack->DeviceObject, p_irp );
+       }
+
+       AL_EXIT( AL_DBG_NDI );
+       return CL_PENDING;
+}
+
+
+/*******************************************************************
+ *
+ * REP CM request
+ *
+ ******************************************************************/
+
+static void
+__ndi_rep_cm(
+       IN                              DEVICE_OBJECT*                          p_dev_obj,
+       IN                              PIRP                                            p_irp )
+{
+       NTSTATUS nt_status;
+       ib_qp_mod_t qp_mod;
+       ib_api_status_t status;
+       ib_qp_handle_t h_qp = p_irp->Tail.Overlay.DriverContext[0];
+       ual_ndi_rep_cm_ioctl_in_t *p_rep = 
+               (ual_ndi_rep_cm_ioctl_in_t*)cl_ioctl_in_buf( p_irp );
+
+       UNUSED_PARAM(p_dev_obj);
+
+       AL_ENTER( AL_DBG_NDI );
+
+       /* free the work item if any */
+       if ( p_irp->Tail.Overlay.DriverContext[1] )
+               IoFreeWorkItem( p_irp->Tail.Overlay.DriverContext[1] );
+
+       /* change the QP state to RTS */
+       status = __ndi_qp2rts( h_qp, p_rep->init_depth, 
+               p_rep->resp_res, p_irp, &qp_mod );
+       if ( status != IB_SUCCESS )
+       {
+               nt_status = STATUS_CONNECTION_ABORTED;
+               goto err;
+       }
+       
+       /* send REP */
+       status = al_cep_send_rep ( qp_get_al( h_qp ), p_rep->cid );
+       if( status != IB_SUCCESS )
+       {
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("al_cep_send_rep returned %s\n", ib_get_err_str(status)) );
+               if (status == IB_INSUFFICIENT_RESOURCES)
+                       nt_status = STATUS_INSUFFICIENT_RESOURCES;
+               else
+                       nt_status = STATUS_CONNECTION_ABORTED;
+err:
+               cl_atomic_xchg( &((al_conn_qp_t*)h_qp)->cid, AL_INVALID_CID );
+
+               /* Reject and abort the connection. */
+               al_cep_rej( qp_get_al( h_qp ), p_rep->cid, IB_REJ_INSUF_QP, NULL, 0, NULL, 0 );
+
+               /* transit QP to error state */
+               __cep_timewait_qp( h_qp );
+
+               ref_al_obj( &h_qp->obj );
+               if( al_destroy_cep( qp_get_al( h_qp ), p_rep->cid, deref_al_obj ) != IB_SUCCESS )
+                       deref_al_obj( &h_qp->obj );
+
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("al_cep_rtu returned %s.\n", ib_get_err_str( status )) );
+               h_qp->p_irp_que->state = NDI_CM_IDLE;   
+               p_irp->IoStatus.Information = 0;
+               goto exit;
+       }
+
+       p_irp->IoStatus.Information = cl_ioctl_out_size( p_irp );
+       h_qp->p_irp_que->state = NDI_CM_CONNECTED;
+       nt_status = STATUS_SUCCESS;
+
+exit:  
+       /* release the reference only for async case */
+       if ( p_irp->Tail.Overlay.DriverContext[1] )
+               deref_al_obj( &h_qp->obj );
+
+       p_irp->IoStatus.Status = nt_status;
+       IoCompleteRequest( p_irp, IO_NO_INCREMENT );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static void
+__ndi_fill_cm_rep(
+       IN              ib_qp_handle_t  const                           h_qp,
+       IN              ual_ndi_rep_cm_ioctl_in_t                       *p_rep,
+               OUT     ib_cm_rep_t                                                     *p_cm_rep)
+{
+       AL_ENTER( AL_DBG_NDI );
+
+       memset( p_cm_rep, 0, sizeof(ib_cm_rep_t) );
+
+       p_cm_rep->p_rep_pdata = p_rep->pdata;
+       p_cm_rep->rep_length = sizeof(p_rep->pdata);
+
+       p_cm_rep->qp_type = IB_QPT_RELIABLE_CONN;
+       p_cm_rep->h_qp = h_qp;
+
+       p_cm_rep->access_ctrl = IB_AC_RDMA_READ | IB_AC_RDMA_WRITE | IB_AC_LOCAL_WRITE;
+       p_cm_rep->init_depth = 0;
+       p_cm_rep->target_ack_delay = 10;
+       p_cm_rep->failover_accepted = IB_FAILOVER_ACCEPT_UNSUPPORTED;
+       p_cm_rep->flow_ctrl = TRUE;     /* HCAs must support end-to-end flow control. */
+       p_cm_rep->rnr_nak_timeout = QP_ATTRIB_RNR_NAK_TIMEOUT;
+       p_cm_rep->rnr_retry_cnt = QP_ATTRIB_RNR_RETRY;
+
+       AL_EXIT( AL_DBG_NDI );
+}
+
+NTSTATUS
+ndi_rep_cm(
+       IN              ib_qp_handle_t  const                           h_qp,
+       IN              net32_t                 const                           cid,
+       IN              PIRP                                                            p_irp,
+       IN              ual_ndi_rep_cm_ioctl_in_t                       *p_rep
+       )
+{
+       IO_STACK_LOCATION       *p_io_stack;
+       ib_cm_rep_t cm_rep;
+       ib_qp_mod_t qp_mod;
+       net32_t old_cid;
+       ib_api_status_t status;
+       NTSTATUS nt_status;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       /* Format ib_cm_req_t structure */
+       __ndi_fill_cm_rep( h_qp, p_rep, &cm_rep );
+
+       /* prepare Passive CEP for connection */
+       status = al_cep_pre_rep_ex( qp_get_al( h_qp ), cid, __ndi_cm_handler, h_qp, &cm_rep, &qp_mod );
+       if( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("al_cep_pre_rep_ex returned %s.\n", ib_get_err_str( status )) );
+               switch (status)
+               {
+                       case IB_INVALID_HANDLE:
+                               nt_status = STATUS_CANCELLED;
+                               break;
+                       case IB_INVALID_STATE:
+                               nt_status = STATUS_CONNECTION_ABORTED;
+                               break;
+                       default:
+                               nt_status = STATUS_INSUFFICIENT_RESOURCES;
+                               break;
+               }
+               goto err_cep_destroy;
+       }
+
+       AL_PRINT( TRACE_LEVEL_INFORMATION, AL_DBG_NDI,
+               ("Prepared Passive CEP with cid %d, h_al %p, context %p\n",
+               cid, qp_get_al( h_qp ), h_qp ) );
+
+       /* See if this QP has already been connected. */
+       old_cid = cl_atomic_comp_xchg( &((al_conn_qp_t*)h_qp)->cid, AL_INVALID_CID, cid );
+       if( old_cid != AL_INVALID_CID )
+       {
+               nt_status = STATUS_CONNECTION_ACTIVE;
+               goto err_cep_destroy;
+       }
+
+       /* transfer work to a work the thread */
+       p_irp->Tail.Overlay.DriverContext[0] = h_qp;
+       p_io_stack = IoGetCurrentIrpStackLocation( p_irp );
+       p_irp->Tail.Overlay.DriverContext[1] = IoAllocateWorkItem( p_io_stack->DeviceObject );
+       if ( p_irp->Tail.Overlay.DriverContext[1] )
+       { /* asyncronous performing */
+               /* take a ref to prevent QP destroy before calling work item */
+               ref_al_obj( &h_qp->obj );
+               IoMarkIrpPending( p_irp );
+               IoQueueWorkItem( p_irp->Tail.Overlay.DriverContext[1],
+                       __ndi_rep_cm, DelayedWorkQueue, p_irp );
+       }
+       else
+       { /* syncronous performing */
+               __ndi_rep_cm( p_io_stack->DeviceObject, p_irp );
+       }
+       goto exit;
+
+err_cep_destroy:
+       al_destroy_cep( qp_get_al( h_qp ), cid, NULL );
+       
+       h_qp->p_irp_que->state = NDI_CM_IDLE;   
+       cl_ioctl_complete( p_irp, nt_status, 0 );
+
+exit:
+       AL_EXIT( AL_DBG_NDI );
+       return CL_PENDING;
+}
+
+
+/*******************************************************************
+ *
+ * DREQ CM request
+ *
+ ******************************************************************/
+
+NTSTATUS
+ndi_dreq_cm(
+       IN              ib_qp_handle_t  const                           h_qp,
+       IN              PIRP                                                            p_irp
+       )
+{
+       ib_qp_mod_t qp_mod;
+       net32_t cid;
+       ib_api_status_t status;
+       NTSTATUS nt_status;
+       uint64_t timewait_us;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       status = al_cep_get_timewait( qp_get_al( h_qp ), 
+               ((al_conn_qp_t*)h_qp)->cid, &timewait_us );
+
+       if (status != IB_SUCCESS)
+       {
+               nt_status = STATUS_CONNECTION_INVALID;
+               goto exit;
+       }
+
+       /* bring QP to error state */
+       cl_memclr( &qp_mod, sizeof(qp_mod) );
+       qp_mod.req_state = IB_QPS_ERROR;
+       
+       status = ndi_modify_qp( h_qp, &qp_mod, 
+               cl_ioctl_out_size( p_irp ), cl_ioctl_out_buf( p_irp ) );
+       if ( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("ndi_modify_qp to ERROR returned %s.\n", ib_get_err_str(status) ) );
+               nt_status = STATUS_CONNECTION_INVALID;
+               goto exit;
+       }
+
+       /* Store the timestamp after which the QP exits timewait. */
+       h_qp->timewait = cl_get_time_stamp() + timewait_us;
+
+       cid = cl_atomic_xchg( &((al_conn_qp_t*)h_qp)->cid, AL_INVALID_CID );
+
+       if( cid != AL_INVALID_CID )
+       {
+               ref_al_obj( &h_qp->obj );
+               if( al_destroy_cep( qp_get_al( h_qp ), cid, deref_al_obj ) != IB_SUCCESS )
+               {
+                       deref_al_obj( &h_qp->obj );
+               }
+       }
+
+       nt_status = STATUS_SUCCESS;
+
+exit:
+       h_qp->p_irp_que->state = NDI_CM_IDLE;   
+       cl_ioctl_complete( p_irp, nt_status, cl_ioctl_out_size( p_irp ) );
+
+       AL_EXIT( AL_DBG_NDI );
+       return STATUS_EVENT_DONE;       /* CL_COMPLETED */
+}
+
diff --git a/core/al/kernel/al_ndi_cm.h b/core/al/kernel/al_ndi_cm.h
new file mode 100644 (file)
index 0000000..787e2e8
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: al_proxy.h 33 2005-07-11 19:51:17Z ftillier $
+ */
+
+/*
+ * Abstract:
+ *     This header file defines data structures for the kernel-mode NDI support 
+ *
+ * Environment:
+ *     Kernel .
+ */
+
+
+#ifndef _AL_NDI_CM_H_
+#define _AL_NDI_CM_H_
+
+#include "complib/cl_ioctl_osd.h"
+
+/* QP creation parameters */
+#define QP_ATTRIB_RESPONDER_RESOURCES  4
+#define QP_ATTRIB_INITIATOR_DEPTH              4
+#define QP_ATTRIB_RETRY_COUNT                  6
+#define QP_ATTRIB_RNR_RETRY                            7
+#define QP_ATTRIB_RNR_NAK_TIMEOUT              8 /* 16 ms */
+
+#define QP_ATTRIB_SQ_DEPTH                             16
+
+/* CM timeouts */
+#define CM_MIN_LOCAL_TIMEOUT   (18)
+#define CM_LOCAL_TIMEOUT               (1)
+#define CM_MIN_REMOTE_TIMEOUT  (18)
+#define CM_REMOTE_TIMEOUT              (2)
+#define CM_RETRIES 4
+
+typedef enum _ndi_cm_state 
+{
+       NDI_CM_IDLE,
+       NDI_CM_CONNECTING_ATS_SENT, // ATS = Address Translation Service
+       NDI_CM_CONNECTING_QPR_SENT, // QPR = Query path record
+       NDI_CM_CONNECTING_REQ_SENT,
+       NDI_CM_CONNECTING_REP_RCVD,
+       NDI_CM_CONNECTING_REJ_RCVD,
+       NDI_CM_CONNECTED,
+       NDI_CM_BOUND,
+       NDI_CM_LISTENING,
+       NDI_CM_REP_SENT,
+       NDI_CM_CONNECTED_DREP_SENT,
+       NDI_CM_CONNECTED_DREQ_SENT,
+} ndi_cm_state_t;
+
+typedef struct _ib_qp  ib_qp_t;
+
+typedef struct _ndi_qp_csq
+{
+       IO_CSQ                                          csq;
+       ib_qp_t*                                        h_qp;
+       ib_query_handle_t                       h_query;
+       LIST_ENTRY                                      que;
+       ndi_cm_state_t                          state;
+       PIO_WORKITEM                            p_workitem;
+       PIRP                                            h_ioctl;
+} ndi_qp_csq_t;
+
+ib_api_status_t
+ndi_modify_qp(
+       IN              const   ib_qp_handle_t                          h_qp,
+       IN              const   ib_qp_mod_t* const                      p_qp_mod,
+       IN              const   uint32_t                                        buf_size,
+       IN                              uint8_t* const                          p_outbuf);
+
+NTSTATUS
+ndi_req_cm(
+       IN              ib_qp_handle_t  const                   h_qp,
+       IN              cl_ioctl_handle_t                               h_ioctl,
+       IN              ual_ndi_req_cm_ioctl_in_t               *p_req
+       );
+
+NTSTATUS
+ndi_rep_cm(
+       IN              ib_qp_handle_t  const                   h_qp,
+       IN              net32_t                 const                   cid,
+       IN              cl_ioctl_handle_t                               h_ioctl,
+       IN              ual_ndi_rep_cm_ioctl_in_t               *p_ndi_rep_cm
+       );
+
+cl_status_t
+ndi_rtu_cm(
+       IN              ib_qp_handle_t  const                           h_qp,
+       IN              PIRP                                                            p_irp
+       );
+
+NTSTATUS
+ndi_dreq_cm(
+       IN              ib_qp_handle_t  const                           h_qp,
+       IN              PIRP                                                            p_irp
+       );
+
+void
+ndi_qp_flush_ques(
+       IN                              ib_qp_handle_t                          h_qp );
+
+       
+NTSTATUS
+ndi_qp_init(
+       IN              ib_qp_handle_t                                  h_qp );
+
+void
+ndi_qp_destroy(
+       IN              ib_qp_handle_t                                  h_qp );
+
+void
+ndi_qp_free(
+       IN              ib_qp_handle_t                                  h_qp );
+
+#endif
+
diff --git a/core/al/kernel/al_ndi_cq.c b/core/al/kernel/al_ndi_cq.c
new file mode 100644 (file)
index 0000000..f9d9ff0
--- /dev/null
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: al_proxy_verbs.c 548 2006-11-27 20:03:51Z leonidk $
+ */
+
+
+#include <complib/comp_lib.h>
+#include <iba/ib_al.h>
+#include <iba/ib_al_ioctl.h>
+#include "al.h"
+#include "al_debug.h"
+
+#if defined(EVENT_TRACING)
+#ifdef offsetof
+#undef offsetof
+#endif
+#include "al_ndi_cq.tmh"
+#endif
+
+#include "al_dev.h"
+/* Get the internal definitions of apis for the proxy */
+#include "al_ca.h"
+#include "al_cq.h"
+#include "ib_common.h"
+
+/*******************************************************************
+ *
+ * Helpers
+ *
+ ******************************************************************/
+
+#pragma warning(disable:4706)
+static inline void __ndi_flush_que(
+       IN      ndi_cq_csq_t*                                                   p_ndi_csq,
+       IN      NTSTATUS                                                                completion_code
+       )
+{
+       PIRP Irp;
+       while( Irp = IoCsqRemoveNextIrp( &p_ndi_csq->csq, NULL ) )
+       {
+               cl_ioctl_complete( Irp, completion_code, 0 );
+               deref_al_obj( &p_ndi_csq->h_cq->obj );
+       }
+}
+#pragma warning(default:4706)
+
+/*******************************************************************
+ *
+ * Callbacks
+ *
+ ******************************************************************/
+
+#pragma warning(disable:4706)
+void ndi_cq_compl_cb(
+       IN              const   ib_cq_handle_t                          h_cq,
+       IN                              void                                            *cq_context )
+{
+       PIRP Irp;
+       ndi_cq_csq_t*p_ndi_csq = &h_cq->compl;
+       UNUSED_PARAM( cq_context );
+
+       AL_ENTER( AL_DBG_NDI );
+
+       while( Irp = IoCsqRemoveNextIrp( &p_ndi_csq->csq, NULL ) )
+       {
+               Irp->IoStatus.Status = STATUS_SUCCESS;
+               Irp->IoStatus.Information = 0;
+               IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
+               deref_al_obj( &p_ndi_csq->h_cq->obj );
+       }
+
+       AL_EXIT( AL_DBG_NDI );
+}
+#pragma warning(default:4706)
+
+void ndi_cq_error_cb(
+       IN                              ib_async_event_rec_t            *p_err_rec)
+{
+       ib_cq_handle_t h_cq = p_err_rec->handle.h_cq;
+       AL_ENTER( AL_DBG_NDI );
+       __ndi_flush_que( &h_cq->compl, STATUS_INTERNAL_ERROR );
+       __ndi_flush_que( &h_cq->error, STATUS_INTERNAL_ERROR );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+/*******************************************************************
+ *
+ * Public routines
+ *
+ ******************************************************************/
+
+/* flush a queue of pending requests */
+void
+ndi_cq_flush_ques(
+       IN      ib_cq_handle_t                                                  h_cq
+       )
+{
+       AL_ENTER( AL_DBG_NDI );
+       if ( h_cq->pfn_user_comp_cb == ndi_cq_compl_cb )
+       {
+               __ndi_flush_que( &h_cq->compl, STATUS_CANCELLED );
+               __ndi_flush_que( &h_cq->error, STATUS_CANCELLED );
+       }
+       AL_EXIT( AL_DBG_NDI );
+}
+
+
+/*******************************************************************
+ *
+ * CSQ
+ *
+ ******************************************************************/
+
+static VOID __ndi_insert_irp(
+       IN      PIO_CSQ                                                                 Csq,
+       IN      PIRP                                                                    Irp
+       )
+{
+       ndi_cq_csq_t *p_ndi_csq = (ndi_cq_csq_t*)Csq;
+
+       AL_ENTER( AL_DBG_NDI );
+       InsertTailList( &p_ndi_csq->que, &Irp->Tail.Overlay.ListEntry );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static VOID __ndi_remove_irp(
+       IN      PIO_CSQ                                                                 Csq,
+       IN      PIRP                                                                    Irp
+       )
+{
+       UNUSED_PARAM( Csq );
+
+       AL_ENTER( AL_DBG_NDI );
+       RemoveEntryList( &Irp->Tail.Overlay.ListEntry );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static PIRP __ndi_peek_next_irp(
+       IN      PIO_CSQ                                                                 Csq,
+       IN      PIRP                                                                    Irp,
+       IN      PVOID                                                                   PeekContext
+       )
+{
+       PIRP nextIrp = NULL;
+       PLIST_ENTRY nextEntry;
+       PLIST_ENTRY listHead;
+       ndi_cq_csq_t *p_ndi_csq = (ndi_cq_csq_t*)Csq;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       listHead = &p_ndi_csq->que;
+
+       // 
+       // If the IRP is NULL, we will start peeking from the listhead, else
+       // we will start from that IRP onwards. This is done under the
+       // assumption that new IRPs are always inserted at the tail.
+       //
+
+       if(Irp == NULL)
+               nextEntry = listHead->Flink;
+       else
+               nextEntry = Irp->Tail.Overlay.ListEntry.Flink;
+
+       while(nextEntry != listHead) {
+               nextIrp = CONTAINING_RECORD(nextEntry, IRP, Tail.Overlay.ListEntry);
+
+               //
+               // If context is present, continue until you find a matching one.
+               // Else you break out as you got next one.
+               //
+
+               if(PeekContext) 
+               {
+                       /* for now PeekContext is not used */
+               } 
+               else
+               {
+                       break;
+               }
+
+               nextIrp = NULL;
+               nextEntry = nextEntry->Flink;
+       }
+
+       AL_EXIT( AL_DBG_NDI );
+       return nextIrp;
+}
+
+static VOID __ndi_acquire_lock(
+       IN      PIO_CSQ                                                                 Csq,
+       OUT     PKIRQL                                                                  Irql
+       )
+{
+       ndi_cq_csq_t *p_ndi_csq = (ndi_cq_csq_t*)Csq;
+       ib_cq_handle_t h_cq = p_ndi_csq->h_cq;
+       UNUSED_PARAM( Irql );
+
+       AL_ENTER( AL_DBG_NDI );
+       cl_spinlock_acquire( &h_cq->obj.lock );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static VOID __ndi_release_lock(
+       IN      PIO_CSQ                                                                 Csq,
+       IN      KIRQL                                                                   Irql
+       )
+{
+       ndi_cq_csq_t *p_ndi_csq = (ndi_cq_csq_t*)Csq;
+       ib_cq_handle_t h_cq = p_ndi_csq->h_cq;
+       UNUSED_PARAM( Irql );
+
+       AL_ENTER( AL_DBG_NDI );
+       cl_spinlock_release( &h_cq->obj.lock );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+static VOID __ndi_complete_cancelled_irp(
+       IN      PIO_CSQ                                                                 Csq,
+       IN      PIRP                                                                    Irp
+       )
+{
+       ndi_cq_csq_t *p_ndi_csq = (ndi_cq_csq_t*)Csq;
+       ib_cq_handle_t h_cq = p_ndi_csq->h_cq;
+
+       AL_ENTER( AL_DBG_NDI );
+       cl_ioctl_complete( Irp, CL_CANCELED, 0 );
+       deref_al_obj( &h_cq->obj );
+       AL_EXIT( AL_DBG_NDI );
+}
+
+NTSTATUS
+ndi_cq_init(
+       IN                              ib_cq_handle_t                          h_cq )
+{
+
+       NTSTATUS status;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       status = IoCsqInitialize( &h_cq->compl.csq, 
+               __ndi_insert_irp, __ndi_remove_irp,
+               __ndi_peek_next_irp, __ndi_acquire_lock,
+               __ndi_release_lock, __ndi_complete_cancelled_irp );
+       if ( !NT_SUCCESS( status ) )
+               goto exit;
+
+       status = IoCsqInitialize( &h_cq->error.csq, 
+               __ndi_insert_irp, __ndi_remove_irp,
+               __ndi_peek_next_irp, __ndi_acquire_lock,
+               __ndi_release_lock, __ndi_complete_cancelled_irp );
+       if ( !NT_SUCCESS( status ) )
+               goto exit;
+
+       InitializeListHead( &h_cq->compl.que );
+       InitializeListHead( &h_cq->error.que );
+       h_cq->compl.h_cq = h_cq;
+       h_cq->error.h_cq = h_cq;
+       status = STATUS_SUCCESS;
+
+exit:
+       AL_EXIT( AL_DBG_NDI );
+       return status;
+}
+
+
+
diff --git a/core/al/kernel/al_ndi_cq.h b/core/al/kernel/al_ndi_cq.h
new file mode 100644 (file)
index 0000000..466722d
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: al_proxy.h 33 2005-07-11 19:51:17Z ftillier $
+ */
+
+/*
+ * Abstract:
+ *     This header file defines data structures for the kernel-mode NDI support 
+ *
+ * Environment:
+ *     Kernel .
+ */
+
+
+#ifndef _AL_NDI_CQ_H_
+#define _AL_NDI_CQ_H_
+
+void
+ndi_cq_flush_ques(
+       IN                              ib_cq_handle_t                          h_cq );
+
+NTSTATUS
+ndi_cq_init(
+       IN                              ib_cq_handle_t                          h_cq );
+
+void 
+ndi_cq_compl_cb(
+       IN              const   ib_cq_handle_t                          h_cq,
+       IN                              void                                            *cq_context );
+
+void 
+ndi_cq_error_cb(
+       IN                              ib_async_event_rec_t            *p_err_rec );
+
+#endif
index df7dffa..4ec7da2 100644 (file)
@@ -203,8 +203,8 @@ create_pnp(
        {\r
                __pnp_free( &gp_pnp->obj );\r
                AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
-                       ("cl_ptr_vector_init failed with status %s.\n",\r
-                       CL_STATUS_MSG( cl_status )) );\r
+                       ("cl_ptr_vector_init failed with status %#x.\n",\r
+                       cl_status) );\r
                return IB_ERROR;\r
        }\r
 \r
@@ -1184,8 +1184,8 @@ pnp_ca_event(
                {\r
                        cl_free( p_event_rec );\r
                        AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
-                               ("cl_ptr_vector_set_size failed with status %s.\n",\r
-                               CL_STATUS_MSG( cl_status )) );\r
+                               ("cl_ptr_vector_set_size failed with status %#x.\n",\r
+                               cl_status) );\r
                        return ib_convert_cl_status( cl_status );\r
                }\r
 \r
index d6ef240..86e7ff6 100644 (file)
@@ -702,6 +702,9 @@ proxy_ioctl(
        case UAL_BIND_MISC:\r
                cl_status = proxy_bind_file( h_ioctl, AL_OBJ_TYPE_AL_MGR );\r
                break;\r
+       case UAL_BIND_ND:\r
+               cl_status = proxy_bind_file( h_ioctl, AL_OBJ_TYPE_NDI );\r
+               break;\r
        default:\r
                cl_status = CL_INVALID_PARAMETER;\r
                break;\r
index 6b1ccdd..67d1f9a 100644 (file)
@@ -858,6 +858,111 @@ proxy_cep_get_event(
 }\r
 \r
 \r
+static cl_status_t\r
+proxy_cep_get_req_cid(\r
+       IN              void                                    *p_open_context,\r
+       IN              cl_ioctl_handle_t               h_ioctl,\r
+               OUT     size_t                                  *p_ret_bytes )\r
+{\r
+       cl_status_t cl_status;\r
+       al_dev_open_context_t *p_context;\r
+       UNUSED_PARAM(p_ret_bytes);\r
+       \r
+       AL_ENTER( AL_DBG_CM );\r
+\r
+       p_context = (al_dev_open_context_t*)p_open_context;\r
+\r
+       /* Validate user parameters. */\r
+       if( cl_ioctl_in_size( h_ioctl ) != sizeof(uint32_t) ||\r
+               cl_ioctl_out_size( h_ioctl ) != sizeof(uint32_t) )\r
+       {\r
+               AL_EXIT( AL_DBG_CM );\r
+               return CL_INVALID_PARAMETER;\r
+       }\r
+\r
+       /* get CID */\r
+       cl_status = al_cep_get_cid( p_context->h_al, \r
+               *(uint32_t*)cl_ioctl_in_buf( h_ioctl ), h_ioctl );\r
+\r
+       AL_EXIT( AL_DBG_CM );\r
+       return cl_status;\r
+}\r
+\r
+\r
+\r
+static cl_status_t\r
+proxy_cep_get_pdata(\r
+       IN              void                                    *p_open_context,\r
+       IN              cl_ioctl_handle_t               h_ioctl,\r
+               OUT     size_t                                  *p_ret_bytes )\r
+{\r
+       al_dev_open_context_t           *p_context;\r
+       ual_cep_get_pdata_ioctl_t       *p_ioctl;\r
+       ib_qp_handle_t                          h_qp = NULL;\r
+       net32_t                                         cid;\r
+       ib_api_status_t                         status;\r
+       cl_status_t                                     cl_status;\r
+\r
+       AL_ENTER( AL_DBG_CM );\r
+\r
+       p_context = (al_dev_open_context_t*)p_open_context;\r
+       p_ioctl = (ual_cep_get_pdata_ioctl_t*)cl_ioctl_in_buf( h_ioctl );\r
+\r
+       /* Validate user parameters. */\r
+       if( cl_ioctl_in_size( h_ioctl ) != sizeof(struct _ual_cep_get_pdata_ioctl_in) ||\r
+               cl_ioctl_out_size( h_ioctl ) != sizeof(struct _ual_cep_get_pdata_ioctl_out) )\r
+       {\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, \r
+                       ("Incorrect sizes: in %d, out %d (expected - %d, %d)\n",\r
+                       cl_ioctl_in_size( h_ioctl ), cl_ioctl_out_size( h_ioctl ), \r
+                       sizeof(struct _ual_cep_get_pdata_ioctl_in),\r
+                       sizeof(struct _ual_cep_get_pdata_ioctl_out) ) );\r
+               return CL_INVALID_PARAMETER;\r
+       }\r
+\r
+       *p_ret_bytes = sizeof(struct _ual_cep_get_pdata_ioctl_out);\r
+\r
+       if ( p_ioctl->in.h_qp )\r
+       {\r
+               /* Get the kernel QP handle. */\r
+               h_qp = (ib_qp_handle_t)al_hdl_ref(\r
+                       p_context->h_al, p_ioctl->in.h_qp, AL_OBJ_TYPE_H_QP );\r
+               if( !h_qp )\r
+               {\r
+                       AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, \r
+                               ("Invalid QP handle\n"));\r
+                       return CL_CONNECTION_INVALID;\r
+               }\r
+               cid = ((al_conn_qp_t*)h_qp)->cid;\r
+       }\r
+       else\r
+       {\r
+               cid = p_ioctl->in.cid;\r
+       }\r
+\r
+       p_ioctl->out.pdata_len = sizeof(p_ioctl->out.pdata);\r
+       status = al_cep_get_pdata( p_context->h_al, cid, \r
+               (uint8_t*)&p_ioctl->out.pdata_len, p_ioctl->out.pdata );\r
+\r
+       if ( status == IB_SUCCESS )\r
+       {\r
+               cl_status = CL_SUCCESS;\r
+               *p_ret_bytes = p_ioctl->out.pdata_len;\r
+               AL_PRINT(TRACE_LEVEL_INFORMATION ,AL_DBG_CM ,\r
+                       ("proxy_cep_get_pdata: get %d of pdata \n", (int)*p_ret_bytes ));\r
+       }\r
+       else\r
+       {\r
+               cl_status = CL_CONNECTION_INVALID;\r
+       }\r
+\r
+       if ( h_qp )\r
+               deref_al_obj( &h_qp->obj );\r
+\r
+       AL_EXIT( AL_DBG_CM );\r
+       return cl_status;\r
+}\r
+\r
 cl_status_t cep_ioctl(\r
        IN              cl_ioctl_handle_t               h_ioctl,\r
                OUT     size_t                                  *p_ret_bytes )\r
@@ -941,6 +1046,12 @@ cl_status_t cep_ioctl(
        case UAL_CEP_POLL:\r
                cl_status = proxy_cep_poll( p_context, h_ioctl, p_ret_bytes );\r
                break;\r
+       case UAL_CEP_GET_REQ_CID:\r
+               cl_status = proxy_cep_get_req_cid( p_context, h_ioctl, p_ret_bytes );\r
+               break;\r
+       case UAL_CEP_GET_PDATA:\r
+               cl_status = proxy_cep_get_pdata( p_context, h_ioctl, p_ret_bytes );\r
+               break;\r
        default:\r
                cl_status = CL_INVALID_PARAMETER;\r
                break;\r
diff --git a/core/al/kernel/al_proxy_ndi.c b/core/al/kernel/al_proxy_ndi.c
new file mode 100644 (file)
index 0000000..0c275b7
--- /dev/null
@@ -0,0 +1,641 @@
+/*
+ * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: al_proxy_verbs.c 548 2006-11-27 20:03:51Z leonidk $
+ */
+
+
+#include <complib/comp_lib.h>
+#include <iba/ib_al.h>
+#include <iba/ib_al_ioctl.h>
+#include "al.h"
+#include "al_qp.h"
+#include "al_debug.h"
+#include "al_cm_cep.h"
+
+#if defined(EVENT_TRACING)
+#ifdef offsetof
+#undef offsetof
+#endif
+#include "al_proxy_ndi.tmh"
+#endif
+
+#include "al_dev.h"
+/* Get the internal definitions of apis for the proxy */
+#include "al_ca.h"
+#include "ib_common.h"
+#include "al_proxy_ndi.h"
+#include "al_ndi_cm.h"
+
+/*******************************************************************
+ *
+ * IOCTLS
+ *
+ ******************************************************************/
+
+/*
+ * Process the ioctl UAL_NDI_CREATE_CQ:
+ */
+static cl_status_t
+__ndi_create_cq(
+       IN              void                                    *p_open_context,
+       IN              cl_ioctl_handle_t               h_ioctl,
+               OUT     size_t                                  *p_ret_bytes )
+{
+       ual_create_cq_ioctl_t   *p_ioctl =
+               (ual_create_cq_ioctl_t *)cl_ioctl_in_buf( h_ioctl );
+       al_dev_open_context_t   *p_context =
+               (al_dev_open_context_t *)p_open_context;
+       ib_ca_handle_t                  h_ca;
+       ib_cq_handle_t                  h_cq;
+       ib_cq_create_t                  cq_create;
+       ci_umv_buf_t                    *p_umv_buf = NULL;
+       ib_api_status_t                 status;
+       ib_pfn_event_cb_t               pfn_ev;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       /* Validate input buffers. */
+       if( !cl_ioctl_in_buf( h_ioctl ) || !cl_ioctl_out_buf( h_ioctl ) ||
+               cl_ioctl_in_size( h_ioctl ) != sizeof(p_ioctl->in) ||
+               cl_ioctl_out_size( h_ioctl ) != sizeof(p_ioctl->out) )
+       {
+               status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+
+       /* Validate CA handle */
+       h_ca = (ib_ca_handle_t)
+               al_hdl_ref( p_context->h_al, p_ioctl->in.h_ca, AL_OBJ_TYPE_H_CA );
+       if( !h_ca )
+       {
+               status = IB_INVALID_CA_HANDLE;
+               goto proxy_create_cq_err1;
+       }
+
+       cq_create.size = p_ioctl->in.size;
+
+       /* Override with proxy's cq callback */
+       cq_create.pfn_comp_cb = ndi_cq_compl_cb;
+       cq_create.h_wait_obj = NULL;
+       pfn_ev = ndi_cq_error_cb;
+
+       status = cpyin_umvbuf( &p_ioctl->in.umv_buf, &p_umv_buf );
+       if( status != IB_SUCCESS )
+               goto proxy_create_cq_err2;
+
+       status = create_cq( h_ca, &cq_create, p_ioctl->in.context,
+               pfn_ev, &h_cq, p_umv_buf );
+
+       if( status != IB_SUCCESS )
+               goto proxy_create_cq_err2;
+
+       status = cpyout_umvbuf( &p_ioctl->out.umv_buf, p_umv_buf );
+       if( status == IB_SUCCESS )
+       {
+               p_ioctl->out.size = cq_create.size;
+               p_ioctl->out.h_cq = h_cq->obj.hdl;
+               h_cq->obj.hdl_valid = TRUE;
+               deref_al_obj( &h_cq->obj );
+       }
+       else
+       {
+               h_cq->obj.pfn_destroy( &h_cq->obj, NULL );
+
+proxy_create_cq_err2:
+               cl_waitobj_deref( cq_create.h_wait_obj );
+
+proxy_create_cq_err1:
+               p_ioctl->out.umv_buf = p_ioctl->in.umv_buf;
+               p_ioctl->out.h_cq = AL_INVALID_HANDLE;
+               p_ioctl->out.size = 0;
+       }
+       free_umvbuf( p_umv_buf );
+
+       if( h_ca )
+               deref_al_obj( &h_ca->obj );
+
+       p_ioctl->out.status = status;
+       *p_ret_bytes = sizeof(p_ioctl->out);
+
+exit:
+       AL_EXIT( AL_DBG_NDI );
+       return CL_SUCCESS;
+}
+
+
+static cl_status_t
+__ndi_notify_cq(
+       IN              void                                    *p_open_context,
+       IN              cl_ioctl_handle_t               h_ioctl,
+               OUT     size_t                                  *p_ret_bytes )
+{
+       cl_status_t cl_status;
+       ual_ndi_notify_cq_ioctl_in_t *p_ioctl;
+       al_dev_open_context_t *p_context;
+       ib_cq_handle_t h_cq;
+       UNUSED_PARAM(p_ret_bytes);
+       
+       AL_ENTER( AL_DBG_NDI );
+
+       p_context = (al_dev_open_context_t*)p_open_context;
+       p_ioctl = (ual_ndi_notify_cq_ioctl_in_t*)cl_ioctl_in_buf( h_ioctl );
+
+       /* Validate user parameters. */
+       if( cl_ioctl_in_size( h_ioctl ) != sizeof(ual_ndi_notify_cq_ioctl_in_t) )
+       {
+               cl_status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+
+       /* Validate CQ handle */
+       h_cq = (ib_cq_handle_t)
+               al_hdl_ref( p_context->h_al, p_ioctl->h_cq, AL_OBJ_TYPE_H_CQ );
+       if( !h_cq )
+       {
+               cl_status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       /* enqueue the IRP (h_cq is referenced in al_hdl_ref) */
+       if (p_ioctl->notify_comps)
+               IoCsqInsertIrp( &h_cq->compl.csq, h_ioctl, NULL );
+       else
+               IoCsqInsertIrp( &h_cq->error.csq, h_ioctl, NULL );
+
+       cl_status = CL_PENDING;
+
+exit:
+       AL_EXIT( AL_DBG_NDI );
+       return cl_status;
+}
+
+static cl_status_t
+__ndi_cancel_cq(
+       IN              void                                    *p_open_context,
+       IN              cl_ioctl_handle_t               h_ioctl,
+               OUT     size_t                                  *p_ret_bytes )
+{
+       cl_status_t cl_status;
+       ib_cq_handle_t h_cq = NULL;
+       al_dev_open_context_t *p_context;
+       UNUSED_PARAM(p_ret_bytes);
+       
+       AL_ENTER( AL_DBG_NDI );
+
+       p_context = (al_dev_open_context_t*)p_open_context;
+
+       /* Validate user parameters. */
+       if( cl_ioctl_in_size( h_ioctl ) != sizeof(uint64_t) )
+       {
+               cl_status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+
+       /* Validate CQ handle */
+       h_cq = (ib_cq_handle_t)
+               al_hdl_ref( p_context->h_al, 
+                       *(uint64_t*)cl_ioctl_in_buf( h_ioctl ), AL_OBJ_TYPE_H_CQ );
+       if( !h_cq )
+       {
+               cl_status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       /* flush IRP queues */
+       ndi_cq_flush_ques( h_cq );
+
+       cl_status = CL_SUCCESS;
+       deref_al_obj( &h_cq->obj );
+
+exit:
+       AL_EXIT( AL_DBG_NDI );
+       return cl_status;
+}
+
+static cl_status_t
+__ndi_modify_qp(
+       IN              void                                    *p_open_context,
+       IN              cl_ioctl_handle_t               h_ioctl,
+               OUT     size_t                                  *p_ret_bytes )
+{
+       cl_status_t cl_status;
+       ib_api_status_t status;
+       ib_qp_handle_t h_qp = NULL;
+       al_dev_open_context_t *p_context;
+       ual_ndi_modify_qp_ioctl_in_t *p_req = 
+               (ual_ndi_modify_qp_ioctl_in_t*)cl_ioctl_in_buf( h_ioctl );
+
+       UNUSED_PARAM(p_ret_bytes);
+       
+       AL_ENTER( AL_DBG_NDI );
+
+       p_context = (al_dev_open_context_t*)p_open_context;
+
+       /* Validate user parameters. */
+       if( cl_ioctl_in_size( h_ioctl ) < sizeof(ual_ndi_modify_qp_ioctl_in_t))
+       {
+               cl_status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+
+       /* Validate QP handle */
+       h_qp = (ib_qp_handle_t)al_hdl_ref( p_context->h_al, p_req->h_qp, AL_OBJ_TYPE_H_QP );
+       if( !h_qp )
+       {
+               cl_status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       /* Check QP type */
+       if( h_qp->type != IB_QPT_RELIABLE_CONN )
+       {
+               cl_status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       /* perform the ioctl */
+       status = ndi_modify_qp( h_qp, &p_req->qp_mod, 
+               cl_ioctl_out_size( h_ioctl ), cl_ioctl_out_buf( h_ioctl ) );
+       if ( status != IB_SUCCESS )
+       {
+               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
+                       ("ndi_modify_qp returned %s.\n", ib_get_err_str(status) ) );
+               cl_status = CL_ERROR;
+       }
+       else
+       {
+               cl_status = CL_SUCCESS;
+               *p_ret_bytes = cl_ioctl_out_size( h_ioctl );
+       }
+
+exit:
+       if ( h_qp )
+               deref_al_obj( &h_qp->obj );
+
+       AL_EXIT( AL_DBG_NDI );
+       return cl_status;
+}
+
+static cl_status_t
+__ndi_req_cm(
+       IN              void                                    *p_open_context,
+       IN              cl_ioctl_handle_t               h_ioctl,
+               OUT     size_t                                  *p_ret_bytes )
+{
+       cl_status_t cl_status;
+       ib_qp_handle_t h_qp = NULL;
+       al_dev_open_context_t *p_context;
+       ual_ndi_req_cm_ioctl_in_t *p_parm, *p_req = 
+               (ual_ndi_req_cm_ioctl_in_t*)cl_ioctl_in_buf( h_ioctl );
+       UNUSED_PARAM(p_ret_bytes);
+       
+       AL_ENTER( AL_DBG_NDI );
+
+       p_context = (al_dev_open_context_t*)p_open_context;
+
+       /* Validate user parameters. */
+       if( cl_ioctl_in_size( h_ioctl ) < sizeof(ual_ndi_req_cm_ioctl_in_t))
+       {
+               cl_status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+
+       /* Validate QP handle */
+       h_qp = (ib_qp_handle_t)al_hdl_ref( p_context->h_al, p_req->h_qp, AL_OBJ_TYPE_H_QP );
+       if( !h_qp )
+       {
+               cl_status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       /* Check QP type */
+       if( h_qp->type != IB_QPT_RELIABLE_CONN )
+       {
+               cl_status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       /* Check psize */
+       if ( p_req->pdata_size > sizeof(p_req->pdata) )
+       {
+               cl_status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+
+       /* copy request parameters a side to prevent problems from cancelled IRP */
+       p_parm = cl_zalloc( sizeof(ual_ndi_req_cm_ioctl_in_t) );
+       if (!p_parm )
+       {
+               cl_status = CL_INSUFFICIENT_MEMORY;
+               goto exit;
+       }
+       RtlCopyMemory( p_parm, p_req, sizeof(ual_ndi_req_cm_ioctl_in_t) );
+       p_parm->h_qp = (uint64_t)h_qp;
+       
+       /* perform the ioctl */
+       cl_status = ndi_req_cm( h_qp, h_ioctl, p_parm );
+
+exit:
+       if (h_qp)
+               deref_al_obj( &h_qp->obj );
+
+       AL_EXIT( AL_DBG_NDI );
+       return cl_status;
+}
+
+static cl_status_t
+__ndi_rep_cm(
+       IN              void                                    *p_open_context,
+       IN              cl_ioctl_handle_t               h_ioctl,
+               OUT     size_t                                  *p_ret_bytes )
+{
+       cl_status_t cl_status;
+       ib_qp_handle_t h_qp = NULL;
+       al_dev_open_context_t *p_context;
+       net32_t cid;
+       ual_ndi_rep_cm_ioctl_in_t *p_rep = 
+               (ual_ndi_rep_cm_ioctl_in_t*)cl_ioctl_in_buf( h_ioctl );
+       UNUSED_PARAM(p_ret_bytes);
+
+       AL_ENTER( AL_DBG_NDI );
+
+       p_context = (al_dev_open_context_t*)p_open_context;
+
+       /* Validate user parameters. */
+       if( (cl_ioctl_in_size( h_ioctl ) < sizeof(ual_ndi_rep_cm_ioctl_in_t)) ||
+               cl_ioctl_out_size( h_ioctl ) < sizeof(net32_t) )
+       {
+               cl_status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+
+       /* Get and validate QP handle */
+       h_qp = (ib_qp_handle_t)al_hdl_ref( p_context->h_al, p_rep->h_qp, AL_OBJ_TYPE_H_QP );
+       if( !h_qp )
+       {
+               cl_status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       if( h_qp->type != IB_QPT_RELIABLE_CONN )
+       {
+               cl_status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       /* Check psize */
+       if ( p_rep->pdata_size >= sizeof(p_rep->pdata) )
+       {
+               cl_status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+       
+       /* Get and validate CID */
+       cid = p_rep->cid;
+
+       /* perform the ioctls */
+       cl_status = ndi_rep_cm( h_qp, cid, h_ioctl, p_rep );
+
+exit:
+       if (h_qp)
+               deref_al_obj( &h_qp->obj );
+
+       AL_EXIT( AL_DBG_NDI );
+       return cl_status;
+}
+
+
+static cl_status_t
+__ndi_rej_cm(
+       IN              void                                    *p_open_context,
+       IN              cl_ioctl_handle_t               h_ioctl,
+               OUT     size_t                                  *p_ret_bytes )
+{
+       al_dev_open_context_t *p_context;
+       net32_t cid;
+       ib_api_status_t status;
+       ual_ndi_rej_cm_ioctl_in_t *p_rej = 
+               (ual_ndi_rej_cm_ioctl_in_t*)cl_ioctl_in_buf( h_ioctl );
+       UNUSED_PARAM(p_ret_bytes);
+
+       AL_ENTER( AL_DBG_NDI );
+
+       p_context = (al_dev_open_context_t*)p_open_context;
+
+       /* Check psize */
+       if ( p_rej->pdata_size >= sizeof(p_rej->pdata) )
+       {
+               h_ioctl->IoStatus.Status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+       
+       /* Get and validate CID */
+       cid = p_rej->cid;
+
+       /* perform the ioctl */
+       status = al_cep_rej( p_context->h_al, cid, IB_REJ_INSUF_QP, 
+               NULL, 0, p_rej->pdata, p_rej->pdata_size);
+       if (status != IB_SUCCESS)
+       {
+               h_ioctl->IoStatus.Status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       al_destroy_cep( p_context->h_al, cid, NULL );
+       h_ioctl->IoStatus.Status = STATUS_SUCCESS;
+
+exit:
+       /* complete the IRP */
+       h_ioctl->IoStatus.Information = 0;
+       IoCompleteRequest( h_ioctl, IO_NO_INCREMENT );
+
+       AL_EXIT( AL_DBG_NDI );
+       return CL_COMPLETED;
+}
+
+static cl_status_t
+__ndi_rtu_cm(
+       IN              void                                    *p_open_context,
+       IN              cl_ioctl_handle_t               h_ioctl,
+               OUT     size_t                                  *p_ret_bytes )
+{
+       cl_status_t cl_status;
+       ib_qp_handle_t h_qp = NULL;
+       al_dev_open_context_t *p_context;
+       ual_ndi_rtu_cm_ioctl_in_t *p_rtu = 
+               (ual_ndi_rtu_cm_ioctl_in_t*)cl_ioctl_in_buf( h_ioctl );
+
+       UNUSED_PARAM(p_ret_bytes);
+       
+       AL_ENTER( AL_DBG_NDI );
+
+       p_context = (al_dev_open_context_t*)p_open_context;
+
+       /* Validate user parameters. */
+       if( cl_ioctl_in_size( h_ioctl ) < sizeof(ual_ndi_rtu_cm_ioctl_in_t))
+       {
+               cl_status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+
+       /* Validate QP handle */
+       h_qp = (ib_qp_handle_t)al_hdl_ref( p_context->h_al, p_rtu->h_qp, AL_OBJ_TYPE_H_QP );
+       if( !h_qp )
+       {
+               cl_status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       /* Check QP type */
+       if( h_qp->type != IB_QPT_RELIABLE_CONN )
+       {
+               cl_status = CL_INVALID_HANDLE;
+               goto exit;
+       }
+
+       /* perform the ioctl */
+       cl_status = ndi_rtu_cm( h_qp, h_ioctl );
+
+exit:
+       if (h_qp)
+               deref_al_obj( &h_qp->obj );
+
+       AL_EXIT( AL_DBG_NDI );
+       return cl_status;
+}
+
+static cl_status_t
+__ndi_dreq_cm(
+       IN              void                                    *p_open_context,
+       IN              cl_ioctl_handle_t               h_ioctl,
+               OUT     size_t                                  *p_ret_bytes )
+{
+       cl_status_t cl_status;
+       ib_qp_handle_t h_qp = NULL;
+       al_dev_open_context_t *p_context;
+
+       UNUSED_PARAM(p_ret_bytes);
+       
+       AL_ENTER( AL_DBG_NDI );
+
+       p_context = (al_dev_open_context_t*)p_open_context;
+
+       /* Validate user parameters. */
+       if( cl_ioctl_in_size( h_ioctl ) < sizeof(uint64_t))
+       {
+               cl_status = CL_INVALID_PARAMETER;
+               goto exit;
+       }
+
+       /* Validate QP handle */
+       h_qp = (ib_qp_handle_t)al_hdl_ref( p_context->h_al, 
+               *(uint64_t*)cl_ioctl_in_buf( h_ioctl ), AL_OBJ_TYPE_H_QP );
+       if( !h_qp )
+       {
+               cl_status = CL_CONNECTION_INVALID;
+               goto exit;
+       }
+
+       /* Check QP type */
+       if( h_qp->type != IB_QPT_RELIABLE_CONN )
+       {
+               cl_status = CL_CONNECTION_INVALID;
+               goto exit;
+       }
+
+       /* perform the ioctl */
+       cl_status = ndi_dreq_cm( h_qp, h_ioctl );
+
+exit:
+       if (h_qp)
+               deref_al_obj( &h_qp->obj );
+
+       AL_EXIT( AL_DBG_NDI );
+       return cl_status;
+}
+
+cl_status_t
+ndi_ioctl(
+       IN              cl_ioctl_handle_t               h_ioctl,
+               OUT     size_t                                  *p_ret_bytes )
+{
+       cl_status_t                             cl_status;
+       IO_STACK_LOCATION               *p_io_stack;
+       void                                    *p_context;
+
+       AL_ENTER( AL_DBG_NDI );
+
+       p_io_stack = IoGetCurrentIrpStackLocation( h_ioctl );
+       p_context = p_io_stack->FileObject->FsContext;
+
+       if( !p_context )
+       {
+               AL_EXIT( AL_DBG_DEV );
+               return CL_INVALID_PARAMETER;
+       }
+
+       switch( cl_ioctl_ctl_code( h_ioctl ) )
+       {
+       case UAL_NDI_CREATE_CQ:
+               cl_status = __ndi_create_cq( p_context, h_ioctl, p_ret_bytes );
+               break;
+       case UAL_NDI_NOTIFY_CQ:
+               cl_status = __ndi_notify_cq( p_context, h_ioctl, p_ret_bytes );
+               break;
+       case UAL_NDI_CANCEL_CQ:
+               cl_status = __ndi_cancel_cq( p_context, h_ioctl, p_ret_bytes );
+               break;
+       case UAL_NDI_MODIFY_QP:
+               cl_status = __ndi_modify_qp( p_context, h_ioctl, p_ret_bytes );
+               break;
+       case UAL_NDI_REQ_CM:
+               cl_status = __ndi_req_cm( p_context, h_ioctl, p_ret_bytes );
+               break;
+       case UAL_NDI_REP_CM:
+               cl_status = __ndi_rep_cm( p_context, h_ioctl, p_ret_bytes );
+               break;
+       case UAL_NDI_RTU_CM:
+               cl_status = __ndi_rtu_cm( p_context, h_ioctl, p_ret_bytes );
+               break;
+       case UAL_NDI_REJ_CM:
+               cl_status = __ndi_rej_cm( p_context, h_ioctl, p_ret_bytes );
+               break;
+       case UAL_NDI_DREQ_CM:
+               cl_status = __ndi_dreq_cm( p_context, h_ioctl, p_ret_bytes );
+               break;
+       default:
+               cl_status = CL_INVALID_PARAMETER;
+               break;
+       }
+
+       AL_EXIT( AL_DBG_NDI );
+       return cl_status;
+}
+
index 5bf7db8..6dbaeab 100644 (file)
@@ -72,7 +72,6 @@ extern al_mgr_t                               *gp_al_mgr;
  * It is assumed that the p_buf does not have any embedded user-mode pointers\r
  */\r
 \r
-static\r
 ib_api_status_t\r
 cpyin_umvbuf(\r
        IN              ci_umv_buf_t    *p_src,\r
@@ -140,7 +139,6 @@ cpyin_umvbuf(
  * user process context may not be valid\r
  *\r
  */\r
-static\r
 ib_api_status_t\r
 cpyout_umvbuf(\r
        IN              ci_umv_buf_t    *p_dest,\r
@@ -173,7 +171,7 @@ cpyout_umvbuf(
 }\r
 \r
 \r
-static void\r
+void\r
 free_umvbuf(\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
index 1a6729c..ff90c1c 100644 (file)
@@ -66,7 +66,7 @@ ual_create_av(
        if( h_pd->h_ci_pd && uvp_intf.pre_create_av )\r
        {\r
                status = uvp_intf.pre_create_av( h_pd->h_ci_pd,\r
-                       p_av_attr, &ioctl_buf.in.umv_buf );\r
+                       p_av_attr, &ioctl_buf.in.umv_buf, &h_av->h_ci_av );\r
                if( status == IB_VERBS_PROCESSING_DONE )\r
                {\r
                        /* Creation is done entirely in user mode.  Issue the post call */\r
index a2691a0..1ade5fa 100644 (file)
@@ -158,7 +158,7 @@ ual_open_ca(
        /* Pre call to the UVP library */\r
        if( uvp_intf.pre_open_ca )\r
        {\r
-               status = uvp_intf.pre_open_ca( ca_guid, &ca_ioctl.in.umv_buf );\r
+               status = uvp_intf.pre_open_ca( ca_guid, &ca_ioctl.in.umv_buf, &p_ci_ca->h_ci_ca );\r
                if( status != IB_SUCCESS )\r
                {\r
                        CL_ASSERT( status != IB_VERBS_PROCESSING_DONE );\r
index 87dc7e4..5946b05 100644 (file)
@@ -276,7 +276,7 @@ ual_rearm_n_cq(
 typedef struct _ual_ci_interface\r
 {\r
        uvp_interface_t                 user_verbs;\r
-       void                                    *h_uvp_lib;             /* UVP Library Handle */\r
+       HMODULE                                 h_uvp_lib;              /* UVP Library Handle */\r
        ib_net64_t                              guid;\r
 \r
 } ual_ci_interface_t;\r
index c21ddea..622f711 100644 (file)
@@ -67,7 +67,7 @@ ual_create_cq(
        if( p_ci_ca->h_ci_ca && uvp_intf.pre_create_cq )\r
        {\r
                status = uvp_intf.pre_create_cq( p_ci_ca->h_ci_ca,\r
-                       &p_cq_create->size, &cq_ioctl.in.umv_buf );\r
+                       &p_cq_create->size, &cq_ioctl.in.umv_buf, &h_cq->h_ci_cq );\r
                if( status != IB_SUCCESS )\r
                {\r
                        AL_EXIT( AL_DBG_CQ );\r
index 6f05f3d..e5cc99b 100644 (file)
@@ -69,7 +69,7 @@ ual_attach_mcast(
        {\r
                status = uvp_intf.pre_attach_mcast( h_qp->h_ci_qp,\r
                        &h_mcast->member_rec.mgid, h_mcast->member_rec.mlid,\r
-                       &ioctl_buf.in.umv_buf );\r
+                       &ioctl_buf.in.umv_buf, &h_mcast->h_ci_mcast );\r
                if( status != IB_SUCCESS )\r
                {\r
                        AL_EXIT( AL_DBG_PD );\r
index 3fefe0e..3171659 100644 (file)
@@ -69,7 +69,7 @@ ual_create_mw(
        if( h_pd->h_ci_pd && uvp_intf.pre_create_mw )\r
        {\r
                status = uvp_intf.pre_create_mw(\r
-                       h_pd->h_ci_pd, &mw_ioctl.in.umv_buf );\r
+                       h_pd->h_ci_pd, &mw_ioctl.in.umv_buf, &h_mw->h_ci_mw );\r
                if( status != IB_SUCCESS )\r
                {\r
                        AL_EXIT( AL_DBG_MW );\r
index b069591..183a8a6 100644 (file)
@@ -69,7 +69,7 @@ ual_allocate_pd(
        /* Pre call to the UVP library */\r
        if( pd_type != IB_PDT_ALIAS && h_uvp_ca && uvp_intf.pre_allocate_pd )\r
        {\r
-               status = uvp_intf.pre_allocate_pd( h_uvp_ca, &pd_ioctl.in.umv_buf );\r
+               status = uvp_intf.pre_allocate_pd( h_uvp_ca, &pd_ioctl.in.umv_buf, &h_pd->h_ci_pd );\r
                if( status != IB_SUCCESS )\r
                {\r
                        AL_EXIT( AL_DBG_PD );\r
index 0ff6486..8dfef60 100644 (file)
@@ -277,6 +277,7 @@ ual_create_qp(
        uintn_t                                 bytes_ret;\r
        cl_status_t                             cl_status;\r
        ib_api_status_t                 status;\r
+       ib_api_status_t                 uvp_status = IB_SUCCESS;\r
        uvp_interface_t                 uvp_intf = h_qp->obj.p_ci_ca->verbs.user_verbs;\r
        ib_qp_create_t                  qp_create;\r
 \r
@@ -298,7 +299,7 @@ ual_create_qp(
                if (qp_create.h_srq)\r
                        qp_create.h_srq = qp_create.h_srq->h_ci_srq;\r
                status = uvp_intf.pre_create_qp( h_pd->h_ci_pd,\r
-                       &qp_create, &qp_ioctl.in.umv_buf );\r
+                       &qp_create, &qp_ioctl.in.umv_buf, &h_qp->h_ci_qp );\r
                if( status != IB_SUCCESS )\r
                {\r
                        AL_EXIT( AL_DBG_QP );\r
@@ -346,7 +347,7 @@ ual_create_qp(
        /* Post uvp call */\r
        if( h_pd->h_ci_pd && uvp_intf.post_create_qp )\r
        {\r
-               uvp_intf.post_create_qp( h_pd->h_ci_pd,\r
+               uvp_status = uvp_intf.post_create_qp( h_pd->h_ci_pd,\r
                        status, &h_qp->h_ci_qp, &qp_ioctl.out.umv_buf );\r
 \r
                if( uvp_intf.post_recv )\r
@@ -379,6 +380,8 @@ ual_create_qp(
                h_qp->pfn_post_send = ual_post_send;\r
        }\r
 \r
+       if( (status == IB_SUCCESS) && (uvp_status != IB_SUCCESS) )\r
+               status = uvp_status;\r
 \r
        AL_EXIT( AL_DBG_QP );\r
        return status;\r
index a575b7e..203587b 100644 (file)
@@ -186,7 +186,7 @@ ual_create_srq(
                /* Convert the handles to UVP handles */
                srq_attr = *p_srq_attr;
                status = uvp_intf.pre_create_srq( h_pd->h_ci_pd,
-                       &srq_attr, &srq_ioctl.in.umv_buf );
+                       &srq_attr, &srq_ioctl.in.umv_buf, &h_srq->h_ci_srq );
                if( status != IB_SUCCESS )
                {
                        AL_EXIT( AL_DBG_SRQ );
index 6a6645d..277730f 100644 (file)
@@ -305,7 +305,7 @@ create_iou_mgr(
        {\r
                free_iou_mgr( &gp_iou_mgr->obj );\r
                BUS_TRACE_EXIT( BUS_DBG_ERROR, \r
-                       ("cl_mutex_init returned %s.\n", cl_status_text[cl_status]) );\r
+                       ("cl_mutex_init returned %#x.\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
@@ -316,7 +316,7 @@ create_iou_mgr(
        {\r
                free_iou_mgr( &gp_iou_mgr->obj );\r
                BUS_TRACE_EXIT( BUS_DBG_ERROR,\r
-                       ("cl_obj_init returned %s.\n", cl_status_text[cl_status]) );\r
+                       ("cl_obj_init returned %#x.\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
index eaefe8d..f74bab3 100644 (file)
@@ -299,7 +299,7 @@ create_port_mgr(
        {\r
                free_port_mgr( &gp_port_mgr->obj );\r
                BUS_TRACE_EXIT( BUS_DBG_ERROR,\r
-                       ("cl_mutex_init returned %s.\n", cl_status_text[cl_status]) );\r
+                       ("cl_mutex_init returned %#x.\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
@@ -310,7 +310,7 @@ create_port_mgr(
        {\r
                free_port_mgr( &gp_port_mgr->obj );\r
                BUS_TRACE_EXIT( BUS_DBG_ERROR,\r
-                       ("cl_obj_init returned %s.\n", cl_status_text[cl_status]) );\r
+                       ("cl_obj_init returned %#x.\n", cl_status) );\r
                return ib_convert_cl_status( cl_status );\r
        }\r
 \r
index 2efa987..28558e6 100644 (file)
@@ -37,55 +37,7 @@ CL_EXPORT NTSTATUS
 cl_to_ntstatus(\r
        IN      cl_status_t     status )\r
 {\r
-       switch( status )\r
-       {\r
-       case CL_SUCCESS:\r
-               return STATUS_SUCCESS;\r
-       case CL_ERROR:\r
-               return STATUS_DRIVER_INTERNAL_ERROR;\r
-       case CL_INVALID_STATE:\r
-               return STATUS_INVALID_DEVICE_STATE;\r
-       case CL_INVALID_OPERATION:\r
-               return STATUS_NOT_SUPPORTED;\r
-       case CL_INVALID_SETTING:\r
-               return STATUS_INVALID_PARAMETER_1;\r
-       case CL_INVALID_PARAMETER:\r
-               return STATUS_INVALID_PARAMETER;\r
-       case CL_INSUFFICIENT_RESOURCES:\r
-               return STATUS_INSUFFICIENT_RESOURCES;\r
-       case CL_INSUFFICIENT_MEMORY:\r
-               return STATUS_NO_MEMORY;\r
-       case CL_INVALID_PERMISSION:\r
-               return STATUS_ACCESS_DENIED;\r
-       case CL_COMPLETED:\r
-               return STATUS_EVENT_DONE;\r
-       case CL_NOT_DONE:\r
-               return STATUS_ABANDONED;\r
-       case CL_PENDING:\r
-               return STATUS_PENDING;\r
-       case CL_TIMEOUT:\r
-               return STATUS_TIMEOUT;\r
-       case CL_CANCELED:\r
-               return STATUS_CANCELLED;\r
-       case CL_REJECT:\r
-               return STATUS_REQUEST_NOT_ACCEPTED;\r
-       case CL_OVERRUN:\r
-               return STATUS_DATA_OVERRUN;\r
-       case CL_NOT_FOUND:\r
-               return STATUS_NOT_FOUND;\r
-       case CL_UNAVAILABLE:\r
-               return STATUS_DEVICE_NOT_READY;\r
-       case CL_BUSY:\r
-               return STATUS_DEVICE_BUSY;\r
-       case CL_DISCONNECT:\r
-               return STATUS_LOCAL_DISCONNECT;\r
-       case CL_DUPLICATE:\r
-               return STATUS_DUPLICATE_NAME;\r
-       case CL_INVALID_REQUEST:\r
-               return STATUS_INVALID_DEVICE_REQUEST;\r
-       default:\r
-               return STATUS_UNSUCCESSFUL;\r
-       }\r
+       return (NTSTATUS)status;\r
 }\r
 \r
 \r
@@ -95,50 +47,19 @@ cl_from_ntstatus(
 {\r
        switch( status )\r
        {\r
-       case STATUS_SUCCESS:\r
-               return CL_SUCCESS;\r
-       case STATUS_DRIVER_INTERNAL_ERROR:\r
-               return CL_ERROR;\r
-       case STATUS_INVALID_DEVICE_STATE:\r
-               return CL_INVALID_STATE;\r
-       case STATUS_NOT_SUPPORTED:\r
-               return CL_INVALID_OPERATION;\r
-       case STATUS_INVALID_PARAMETER_1:\r
-               return CL_INVALID_SETTING;\r
-       case STATUS_INVALID_PARAMETER:\r
-               return CL_INVALID_PARAMETER;\r
-       case STATUS_INSUFFICIENT_RESOURCES:\r
-               return CL_INSUFFICIENT_RESOURCES;\r
-       case STATUS_NO_MEMORY:\r
-               return CL_INSUFFICIENT_MEMORY;\r
-       case STATUS_ACCESS_DENIED:\r
-               return CL_INVALID_PERMISSION;\r
-       case STATUS_EVENT_DONE:\r
-               return CL_COMPLETED;\r
-       case STATUS_ABANDONED:\r
-               return CL_NOT_DONE;\r
-       case STATUS_PENDING:\r
-               return CL_PENDING;\r
-       case STATUS_TIMEOUT:\r
-               return CL_TIMEOUT;\r
-       case STATUS_CANCELLED:\r
-               return CL_CANCELED;\r
-       case STATUS_REQUEST_NOT_ACCEPTED:\r
-               return CL_REJECT;\r
-       case STATUS_DATA_OVERRUN:\r
-               return CL_OVERRUN;\r
-       case STATUS_NOT_FOUND:\r
-               return CL_NOT_FOUND;\r
-       case STATUS_DEVICE_NOT_READY:\r
-               return CL_UNAVAILABLE;\r
-       case STATUS_DEVICE_BUSY:\r
-               return CL_BUSY;\r
-       case STATUS_LOCAL_DISCONNECT:\r
-               return CL_DISCONNECT;\r
-       case STATUS_DUPLICATE_NAME:\r
-               return CL_DUPLICATE;\r
-       case STATUS_INVALID_DEVICE_REQUEST:\r
-               return CL_INVALID_REQUEST;\r
+       case STATUS_SUCCESS:                            case STATUS_DRIVER_INTERNAL_ERROR:\r
+       case STATUS_INVALID_DEVICE_STATE:       case STATUS_NOT_SUPPORTED:\r
+       case STATUS_INVALID_PARAMETER_1:        case STATUS_INVALID_PARAMETER:\r
+       case STATUS_INSUFFICIENT_RESOURCES:     case STATUS_NO_MEMORY:\r
+       case STATUS_ACCESS_DENIED:                      case STATUS_EVENT_DONE:\r
+       case STATUS_ABANDONED:                          case STATUS_PENDING:\r
+       case STATUS_TIMEOUT:                            case STATUS_CANCELLED:\r
+       case STATUS_REQUEST_NOT_ACCEPTED:       case STATUS_DATA_OVERRUN:\r
+       case STATUS_NOT_FOUND:                          case STATUS_DEVICE_NOT_READY:\r
+       case STATUS_DEVICE_BUSY:                        case STATUS_LOCAL_DISCONNECT:\r
+       case STATUS_DUPLICATE_NAME:             case STATUS_INVALID_DEVICE_REQUEST:\r
+       case STATUS_INVALID_HANDLE:             case STATUS_CONNECTION_INVALID:\r
+               return (cl_status_t)status;\r
        default:\r
                return CL_ERROR;\r
        }\r
index ade863c..392dcc8 100644 (file)
@@ -290,7 +290,7 @@ ioc_mgr_init(
        {\r
                free_ioc_mgr( &p_ioc_mgr->obj );\r
                IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
-                       ("cl_mutex_init returned %s.\n", cl_status_text[cl_status]) );\r
+                       ("cl_mutex_init returned %#x.\n", cl_status) );\r
                return IB_ERROR;\r
        }\r
 \r
@@ -301,7 +301,7 @@ ioc_mgr_init(
        {\r
                free_ioc_mgr( &p_ioc_mgr->obj );\r
                IOU_PRINT_EXIT( TRACE_LEVEL_ERROR, IOU_DBG_ERROR,\r
-                       ("cl_obj_init returned %s.\n", cl_status_text[cl_status]) );\r
+                       ("cl_obj_init returned %#x.\n", cl_status) );\r
                return IB_ERROR;\r
        }\r
 \r
index 735fe24..c16d71e 100644 (file)
@@ -291,7 +291,7 @@ DriverEntry(
        {\r
                CL_DEINIT;\r
                HCA_TRACE_EXIT( HCA_DBG_ERROR,\r
-                       ("mlnx_hobs_init returned %s.\n", cl_status_text[cl_status]) );\r
+                       ("mlnx_hobs_init returned %#x.\n", cl_status) );\r
                return cl_to_ntstatus( cl_status );\r
        }\r
 //     cl_memclr( mlnx_hca_array, MLNX_MAX_HCA * sizeof(ci_interface_t) );\r
@@ -422,8 +422,8 @@ hca_add_device(
        //{\r
        //      IoDeleteDevice( p_dev_obj );\r
        //      HCA_TRACE_EXIT( HCA_DBG_ERROR,\r
-       //              ("cl_mutex_init returned %s.\n", cl_status_text[status]) );\r
-       //      return cl_to_ntstatus( status );\r
+       //              ("cl_mutex_init returned %#x.\n", cl_status) );\r
+       //      return cl_to_ntstatus( cl_status );\r
        //}\r
        //cl_event_signal( &p_ext->mutex );\r
 \r
index 6a82cd4..dc5b20a 100644 (file)
@@ -136,10 +136,13 @@ ib_api_status_t
 mlnx_pre_create_av (\r
     IN         const ib_pd_handle_t            h_uvp_pd,\r
     IN         const ib_av_attr_t              *p_av_attr,\r
-    IN OUT     ci_umv_buf_t                    *p_umv_buf)\r
+    IN OUT     ci_umv_buf_t                    *p_umv_buf,\r
+        OUT            ib_av_handle_t          *ph_uvp_av)\r
 {\r
     ib_api_status_t status = IB_VERBS_PROCESSING_DONE;\r
 \r
+    UNREFERENCED_PARAMETER(ph_uvp_av);\r
+\r
     FUNC_ENTER;\r
     CL_ASSERT(p_umv_buf);\r
     /* \r
@@ -170,7 +173,7 @@ void
 mlnx_post_create_av (\r
     IN         const ib_pd_handle_t            h_uvp_pd,\r
     IN         ib_api_status_t                 ioctl_status,\r
-    OUT                ib_av_handle_t                  *ph_uvp_av,\r
+    IN OUT     ib_av_handle_t                  *ph_uvp_av,\r
     IN OUT     ci_umv_buf_t                    *p_umv_buf)\r
 {\r
     ib_api_status_t status;\r
index 09edb90..5cb1954 100644 (file)
@@ -64,8 +64,11 @@ mlnx_get_ca_interface (
 ib_api_status_t\r
 mlnx_pre_open_ca (\r
        IN              const   ib_net64_t                                      ca_guid,\r
-       IN      OUT                     ci_umv_buf_t                            *p_umv_buf )\r
+       IN      OUT                     ci_umv_buf_t                            *p_umv_buf,\r
+               OUT                     ib_ca_handle_t                          *ph_uvp_ca)\r
 {\r
+       UNREFERENCED_PARAMETER(ph_uvp_ca);\r
+       \r
        FUNC_ENTER;\r
        if( p_umv_buf )\r
        {\r
@@ -89,7 +92,7 @@ ib_api_status_t
 mlnx_post_open_ca (\r
        IN                              const ib_net64_t                        ca_guid,\r
        IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_ca_handle_t                          *ph_uvp_ca,\r
+       IN      OUT                     ib_ca_handle_t                          *ph_uvp_ca,\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
        ib_api_status_t  status = ioctl_status;\r
index 083bec9..7187f48 100644 (file)
@@ -65,7 +65,8 @@ ib_api_status_t
 mlnx_pre_create_cq (\r
        IN              const   ib_ca_handle_t                          h_uvp_ca,\r
        IN      OUT                     uint32_t*                       const   p_size,\r
-       IN      OUT                     ci_umv_buf_t                            *p_umv_buf )\r
+       IN      OUT                     ci_umv_buf_t                            *p_umv_buf,\r
+               OUT                     ib_cq_handle_t                          *ph_uvp_cq)\r
 {\r
     ib_api_status_t status = IB_SUCCESS;\r
     HH_ret_t  hh_ret = HH_OK;\r
@@ -74,6 +75,8 @@ mlnx_pre_create_cq (
     mlnx_ual_cq_info_t *p_new_cq = NULL;\r
     size_t size;\r
 \r
+    UNREFERENCED_PARAMETER(ph_uvp_cq);\r
+       \r
     FUNC_ENTER;\r
 \r
     CL_ASSERT(p_umv_buf);\r
@@ -211,7 +214,7 @@ mlnx_post_create_cq (
        IN              const   ib_ca_handle_t                          h_uvp_ca,\r
        IN                              ib_api_status_t                         ioctl_status,\r
        IN              const   uint32_t                                        size,\r
-               OUT                     ib_cq_handle_t                          *ph_uvp_cq,\r
+       IN      OUT                     ib_cq_handle_t                          *ph_uvp_cq,\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
        mlnx_ual_hobul_t *p_hobul = (mlnx_ual_hobul_t *)((void*)h_uvp_ca);\r
index 306588d..6b03c19 100644 (file)
@@ -87,14 +87,15 @@ mlnx_get_ca_interface (
 ib_api_status_t  \r
 mlnx_pre_open_ca (\r
     IN         const ib_net64_t                        ca_guid,\r
-    IN OUT      ci_umv_buf_t                           *p_umv_buf);\r
+    IN OUT      ci_umv_buf_t                           *p_umv_buf,\r
+        OUT    ib_ca_handle_t                  *ph_uvp_ca);\r
    \r
     \r
 ib_api_status_t\r
 mlnx_post_open_ca (\r
        IN                              const ib_net64_t                        ca_guid,\r
        IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_ca_handle_t                          *ph_uvp_ca,\r
+       IN      OUT                     ib_ca_handle_t                          *ph_uvp_ca,\r
        IN                              ci_umv_buf_t                            *p_umv_buf );\r
 \r
 \r
@@ -143,13 +144,14 @@ mlnx_get_pd_interface (
 ib_api_status_t  \r
 mlnx_pre_allocate_pd (\r
     IN         const ib_ca_handle_t            h_uvp_ca,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
+    IN OUT     ci_umv_buf_t                            *p_umv_buf,\r
+        OUT    ib_pd_handle_t                  *ph_uvp_pd);\r
 \r
 void  \r
 mlnx_post_allocate_pd (\r
        IN                              ib_ca_handle_t                          h_uvp_ca,\r
        IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_pd_handle_t                          *ph_uvp_pd,\r
+       IN      OUT                     ib_pd_handle_t                          *ph_uvp_pd,\r
        IN                              ci_umv_buf_t                            *p_umv_buf );\r
 \r
 ib_api_status_t  \r
@@ -171,14 +173,15 @@ ib_api_status_t
 mlnx_pre_create_av (\r
     IN         const ib_pd_handle_t            h_uvp_pd,\r
     IN         const ib_av_attr_t                      *p_addr_vector,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
+    IN OUT     ci_umv_buf_t                            *p_umv_buf,\r
+        OUT    ib_av_handle_t                  *ph_uvp_av);\r
 \r
 \r
 void\r
 mlnx_post_create_av (\r
        IN              const   ib_pd_handle_t                          h_uvp_pd,\r
        IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_av_handle_t                          *ph_uvp_av,\r
+       IN      OUT                     ib_av_handle_t                          *ph_uvp_av,\r
        IN      OUT                     ci_umv_buf_t                            *p_umv_buf);\r
 \r
 ib_api_status_t  \r
@@ -225,14 +228,15 @@ ib_api_status_t
 mlnx_pre_create_cq (\r
        IN              const   ib_ca_handle_t                          h_uvp_ca,\r
        IN      OUT                     uint32_t*                       const   p_size,\r
-       IN      OUT                     ci_umv_buf_t                            *p_umv_buf );\r
+       IN      OUT                     ci_umv_buf_t                            *p_umv_buf,\r
+               OUT                     ib_cq_handle_t                          *ph_uvp_cq);\r
 \r
 void  \r
 mlnx_post_create_cq (\r
        IN              const   ib_ca_handle_t                          h_uvp_ca,\r
        IN                              ib_api_status_t                         ioctl_status,\r
        IN              const   uint32_t                                        size,\r
-               OUT                     ib_cq_handle_t                          *ph_uvp_cq,\r
+       IN      OUT                     ib_cq_handle_t                          *ph_uvp_cq,\r
        IN                              ci_umv_buf_t                            *p_umv_buf );\r
 \r
 ib_api_status_t  \r
@@ -272,13 +276,14 @@ ib_api_status_t
 mlnx_pre_create_qp (\r
     IN         const   ib_pd_handle_t          h_uvp_pd,// Fix me: if needed\r
     IN         const   ib_qp_create_t          *p_create_attr,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
+    IN OUT     ci_umv_buf_t                            *p_umv_buf,\r
+        OUT    ib_qp_handle_t                          *ph_uvp_qp);\r
 \r
-void  \r
+ib_api_status_t  \r
 mlnx_post_create_qp (\r
        IN              const   ib_pd_handle_t                          h_uvp_pd,\r
        IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_qp_handle_t                          *ph_uvp_qp,\r
+       IN      OUT                     ib_qp_handle_t                          *ph_uvp_qp,\r
        IN                              ci_umv_buf_t                            *p_umv_buf );\r
 \r
 ib_api_status_t  \r
@@ -395,14 +400,15 @@ mlnx_post_deregister_mr (
 ib_api_status_t  \r
 mlnx_pre_create_mw (\r
     IN         const ib_pd_handle_t            h_uvp_pd,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
+    IN OUT     ci_umv_buf_t                            *p_umv_buf,\r
+        OUT    ib_mw_handle_t                  *ph_uvp_mw);\r
 \r
 void  \r
 mlnx_post_create_mw (\r
        IN              const   ib_pd_handle_t                          h_uvp_pd,\r
        IN                              ib_api_status_t                         ioctl_status,\r
        IN                              net32_t                                         rkey,\r
-               OUT                     ib_mw_handle_t                          *ph_uvp_mw,\r
+       IN      OUT                     ib_mw_handle_t                          *ph_uvp_mw,\r
        IN                              ci_umv_buf_t                            *p_umv_buf );\r
 \r
 ib_api_status_t  \r
@@ -440,13 +446,14 @@ mlnx_pre_attach_mcast (
     IN         const ib_qp_handle_t            h_uvp_qp,\r
     IN         const ib_gid_t                          *p_mcast_gid,\r
     IN         const uint16_t                          mcast_lid,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
+    IN OUT     ci_umv_buf_t                            *p_umv_buf,\r
+        OUT    ib_mcast_handle_t                       *ph_mcast);\r
 \r
 void  \r
 mlnx_post_attach_mcast (\r
     IN         const ib_qp_handle_t            h_uvp_qp,\r
     IN         ib_api_status_t                         ioctl_status,\r
-    OUT                ib_mcast_handle_t                       *ph_mcast,\r
+    IN OUT     ib_mcast_handle_t                       *ph_mcast,\r
     IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
 \r
 ib_api_status_t  \r
index f847f00..246eeff 100644 (file)
@@ -60,8 +60,11 @@ mlnx_pre_attach_mcast (
     IN const   ib_qp_handle_t          h_uvp_qp,\r
     IN const   ib_gid_t                        *p_mcast_gid,\r
     IN const   uint16_t                        mcast_lid,\r
-    IN OUT             ci_umv_buf_t            *p_umv_buf)\r
+    IN OUT             ci_umv_buf_t            *p_umv_buf,\r
+        OUT            ib_mcast_handle_t               *ph_mcast)\r
 {\r
+    UNREFERENCED_PARAMETER(ph_mcast);\r
+               \r
     FUNC_ENTER;\r
 #if 1\r
     CL_ASSERT(p_umv_buf);\r
@@ -81,7 +84,7 @@ void
 mlnx_post_attach_mcast (\r
     IN         const ib_qp_handle_t    h_uvp_qp,\r
     IN         ib_api_status_t                 ioctl_status,\r
-    OUT                ib_mcast_handle_t               *ph_mcast,\r
+    IN OUT             ib_mcast_handle_t               *ph_mcast,\r
     IN OUT     ci_umv_buf_t                    *p_umv_buf)\r
 {\r
     FUNC_ENTER;\r
index 2c0e808..4665d01 100644 (file)
@@ -229,13 +229,16 @@ mlnx_post_deregister_mr (
 ib_api_status_t\r
 mlnx_pre_create_mw (\r
     IN         const ib_pd_handle_t            h_uvp_pd,\r
-    IN OUT     ci_umv_buf_t                    *p_umv_buf)\r
+    IN OUT     ci_umv_buf_t                    *p_umv_buf,\r
+        OUT    ib_mw_handle_t                  *ph_uvp_mw)\r
 {\r
     ib_api_status_t status = IB_SUCCESS;\r
     mlnx_ual_pd_info_t *p_pd_info = (mlnx_ual_pd_info_t *)((void*) h_uvp_pd);\r
     mlnx_ual_hobul_t *p_hobul;\r
     mlnx_ual_mw_info_t *p_new_mw;\r
 \r
+    UNREFERENCED_PARAMETER(ph_uvp_mw);\r
+       \r
     FUNC_ENTER;\r
     CL_ASSERT(p_umv_buf);\r
     CL_ASSERT(p_pd_info);\r
@@ -288,7 +291,7 @@ mlnx_post_create_mw (
        IN              const   ib_pd_handle_t                          h_uvp_pd,\r
        IN                              ib_api_status_t                         ioctl_status,\r
        IN                              net32_t                                         rkey,\r
-               OUT                     ib_mw_handle_t                          *ph_uvp_mw,\r
+       IN      OUT                     ib_mw_handle_t                          *ph_uvp_mw,\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
     ib_api_status_t status;\r
index fa4d011..d79ae9c 100644 (file)
@@ -59,13 +59,16 @@ mlnx_get_pd_interface (
 ib_api_status_t\r
 mlnx_pre_allocate_pd (\r
     IN         const ib_ca_handle_t            h_uvp_ca,\r
-    IN OUT     ci_umv_buf_t                    *p_umv_buf)\r
+    IN OUT     ci_umv_buf_t                    *p_umv_buf,\r
+        OUT    ib_pd_handle_t                  *ph_uvp_pd)\r
 {\r
     ib_api_status_t status = IB_SUCCESS;\r
     mlnx_ual_hobul_t *p_hobul = (mlnx_ual_hobul_t *)((void *)h_uvp_ca);\r
     mlnx_ual_pd_info_t *p_new_pd = NULL;\r
     MT_size_t size;\r
 \r
+    UNREFERENCED_PARAMETER(ph_uvp_pd);\r
+\r
     FUNC_ENTER;\r
 \r
     CL_ASSERT(p_hobul);\r
@@ -187,7 +190,7 @@ void
 mlnx_post_allocate_pd (\r
        IN                              ib_ca_handle_t                          h_uvp_ca,\r
        IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_pd_handle_t                          *ph_uvp_pd,\r
+       IN      OUT                     ib_pd_handle_t                          *ph_uvp_pd,\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
        mlnx_ual_hobul_t *p_hobul = (mlnx_ual_hobul_t *)((void *)h_uvp_ca);\r
index 4fff143..85ff147 100644 (file)
@@ -79,7 +79,8 @@ ib_api_status_t
 mlnx_pre_create_qp (\r
     IN         const   ib_pd_handle_t          h_uvp_pd,\r
     IN         const   ib_qp_create_t          *p_create_attr,\r
-    IN OUT     ci_umv_buf_t                    *p_umv_buf)\r
+    IN OUT     ci_umv_buf_t                    *p_umv_buf,\r
+        OUT    ib_qp_handle_t                          *ph_uvp_qp)\r
 {\r
     ib_api_status_t status = IB_SUCCESS;\r
     mlnx_ual_pd_info_t *p_pd_info = (mlnx_ual_pd_info_t *)((void *)h_uvp_pd);\r
@@ -88,6 +89,8 @@ mlnx_pre_create_qp (
     HHUL_qp_init_attr_t ul_qp_init_attr;\r
     MT_size_t size;\r
 \r
+    UNREFERENCED_PARAMETER(ph_uvp_qp);\r
+\r
     FUNC_ENTER;\r
     CL_ASSERT(p_pd_info);\r
     CL_ASSERT(p_umv_buf);\r
@@ -244,18 +247,19 @@ mlnx_pre_create_qp (
 }\r
 \r
 \r
-void\r
+ib_api_status_t\r
 mlnx_post_create_qp (\r
        IN              const   ib_pd_handle_t                          h_uvp_pd,\r
        IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_qp_handle_t                          *ph_uvp_qp,\r
+       IN      OUT                     ib_qp_handle_t                          *ph_uvp_qp,\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
        mlnx_ual_pd_info_t *p_pd_info = (mlnx_ual_pd_info_t *)((void*)h_uvp_pd);\r
        mlnx_ual_hobul_t *p_hobul;\r
        mlnx_ual_qp_info_t *p_new_qp;\r
        MT_size_t buf_size;\r
-\r
+       ib_api_status_t status = IB_SUCCESS;\r
+       \r
        FUNC_ENTER;\r
        CL_ASSERT(p_pd_info);\r
        CL_ASSERT(p_umv_buf);\r
@@ -279,6 +283,7 @@ mlnx_post_create_qp (
                {\r
                        CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
                                ("Bad status %ld\n", p_umv_buf->status));\r
+                       status = p_umv_buf->status;\r
                        goto err;\r
                }\r
                else if ((buf_size - sizeof (mlnx_ual_qp_info_t *)) != \r
@@ -287,6 +292,7 @@ mlnx_post_create_qp (
                        CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
                                ("Bad user priv buffer size exp = %d, res = %ld\n",\r
                                buf_size, p_umv_buf->output_size));\r
+                       status = IB_ERROR;\r
                        goto err;\r
                }\r
 \r
@@ -307,6 +313,7 @@ mlnx_post_create_qp (
                {\r
                        CL_TRACE (MLNX_TRACE_LVL_1, mlnx_dbg_lvl,\r
                                ("Call THHUL_qpm_create_qp_done Failed\n"));\r
+                       status = IB_ERROR;\r
                        goto err;\r
                }\r
 \r
@@ -327,7 +334,7 @@ err:
        p_umv_buf->p_inout_buf = NULL;\r
 \r
        FUNC_EXIT;\r
-       return;\r
+       return status;\r
 }\r
 \r
 \r
index 12b8db2..01bc805 100644 (file)
@@ -644,6 +644,7 @@ PciHdrWrite(
                                pi_pMdDevContext->m_BridgeHdr.m_Slot,\r
                                0, &l_pLdo )) {\r
                                MdKdPrint( DBGLVL_LOW,("(PciHdrWrite) Not found bridge PDO - can't restore the PCI header \n"  ));\r
+                               KSEM_REL(&pi_pMdDevContext->m_Sem);\r
                                return STATUS_UNSUCCESSFUL;\r
                        }\r
                        l_pFdo = l_pLdo->AttachedDevice;\r
@@ -652,6 +653,7 @@ PciHdrWrite(
                l_Status = PciIfOpen( l_pFdo, l_pLdo, &l_Interface );\r
                        if (!NT_SUCCESS(l_Status))  {\r
                            MdKdPrint( DBGLVL_LOW,("(PciHdrWrite) PciIfOpen failed (0x%x) \n", l_Status  ));\r
+                               KSEM_REL(&pi_pMdDevContext->m_Sem);\r
                                return l_Status;\r
                        }\r
 \r
@@ -693,6 +695,7 @@ PciHdrWrite(
                                pi_pMdDevContext->m_BridgeHdr.m_Slot,\r
                                0, &l_pLdo )) {\r
                                MdKdPrint( DBGLVL_LOW,("(PciHdrWrite) Not found bridge PDO - can't restore the PCI header \n"  ));\r
+                               KSEM_REL(&pi_pMdDevContext->m_Sem);\r
                                return STATUS_UNSUCCESSFUL;\r
                        }\r
                        l_pFdo = l_pLdo->AttachedDevice;\r
@@ -701,6 +704,7 @@ PciHdrWrite(
                l_Status = PciIfOpen( l_pFdo, l_pLdo, &l_Interface );\r
                        if (!NT_SUCCESS(l_Status))  {\r
                            MdKdPrint( DBGLVL_LOW,("(PciHdrWrite) PciIfOpen failed (0x%x) \n", l_Status  ));\r
+                               KSEM_REL(&pi_pMdDevContext->m_Sem);\r
                                return l_Status;\r
                        }\r
 \r
index a91abe5..417da7e 100644 (file)
@@ -196,7 +196,7 @@ DriverEntry(
        if( cl_status != CL_SUCCESS )\r
        {\r
                HCA_PRINT( TRACE_LEVEL_ERROR ,HCA_DBG_INIT ,\r
-                       ("mlnx_hcas_init returned %s.\n", cl_status_text[cl_status]));\r
+                       ("mlnx_hcas_init returned %#x.\n", cl_status));\r
                return cl_to_ntstatus( cl_status );\r
        }\r
 //     cl_memclr( mlnx_hca_array, MLNX_MAX_HCA * sizeof(ci_interface_t) );\r
index 2afd30b..f0ddfbf 100644 (file)
@@ -1200,17 +1200,16 @@ query_qp:
                                goto err_query_qp;\r
        }\r
        \r
-       if( p_umv_buf && p_umv_buf->command )\r
-       {\r
-               struct ibv_modify_qp_resp resp;\r
-               resp.attr_mask = qp_attr_mask;\r
-               resp.qp_state = qp_attr.qp_state;\r
-               err = ib_copy_to_umv_buf(p_umv_buf, &resp, sizeof(struct ibv_modify_qp_resp));\r
-               if (err) {\r
-                       HCA_PRINT(TRACE_LEVEL_ERROR  , HCA_DBG_SHIM  ,("ib_copy_to_umv_buf failed (%d)\n", err));\r
-                       status = errno_to_iberr(err);\r
-                       goto err_copy;\r
-               }\r
+       if( p_umv_buf && p_umv_buf->command ) {\r
+                       struct ibv_modify_qp_resp resp;\r
+                       resp.attr_mask = qp_attr_mask;\r
+                       resp.qp_state = qp_attr.qp_state;\r
+                       err = ib_copy_to_umv_buf(p_umv_buf, &resp, sizeof(struct ibv_modify_qp_resp));\r
+                       if (err) {\r
+                               HCA_PRINT(TRACE_LEVEL_ERROR  , HCA_DBG_SHIM  ,("ib_copy_to_umv_buf failed (%d)\n", err));\r
+                               status = errno_to_iberr(err);\r
+                               goto err_copy;\r
+                       }\r
        }\r
 \r
        status = IB_SUCCESS;\r
@@ -1231,6 +1230,38 @@ err_inval_params:
        return status;\r
 }\r
 \r
+ib_api_status_t\r
+mlnx_ndi_modify_qp (\r
+       IN              const   ib_qp_handle_t                          h_qp,\r
+       IN              const   ib_qp_mod_t                                     *p_modify_attr,\r
+               OUT                     ib_qp_attr_t                            *p_qp_attr OPTIONAL,\r
+       IN              const   uint32_t                                        buf_size,\r
+       IN                              uint8_t* const                          p_outbuf)\r
+{\r
+       ci_umv_buf_t umv_buf;\r
+       ib_api_status_t status;\r
+       struct ibv_modify_qp_resp resp;\r
+       void *buf = &resp;\r
+\r
+       HCA_ENTER(HCA_DBG_QP);\r
+\r
+       /* imitate umv_buf */\r
+       umv_buf.command = TRUE; /* special case for NDI. Usually it's TRUE */\r
+       umv_buf.input_size = 0;\r
+       umv_buf.output_size = sizeof(struct ibv_modify_qp_resp);\r
+       umv_buf.p_inout_buf = buf;\r
+\r
+       status = mlnx_modify_qp ( h_qp, p_modify_attr, p_qp_attr, &umv_buf );\r
+\r
+       if (status == IB_SUCCESS) {\r
+               cl_memclr( p_outbuf, buf_size );\r
+               *p_outbuf = resp.qp_state;\r
+       }\r
+\r
+       HCA_EXIT(HCA_DBG_QP);\r
+       return status;\r
+}\r
+\r
 ib_api_status_t\r
 mlnx_query_qp (\r
        IN              const   ib_qp_handle_t                          h_qp,\r
@@ -1644,6 +1675,7 @@ setup_ci_interface(
                p_interface->create_qp = mlnx_create_qp;\r
                p_interface->create_spl_qp = mlnx_create_spl_qp;\r
                p_interface->modify_qp = mlnx_modify_qp;\r
+               p_interface->ndi_modify_qp = mlnx_ndi_modify_qp;\r
                p_interface->query_qp = mlnx_query_qp;\r
                p_interface->destroy_qp = mlnx_destroy_qp;\r
 \r
index 8bc46a5..abf2562 100644 (file)
 #include "mlnx_ual_av.tmh"\r
 #endif\r
 \r
-void\r
-mlnx_get_av_interface (\r
-       IN OUT  uvp_interface_t         *p_uvp )\r
-{\r
-\r
-       CL_ASSERT(p_uvp);\r
-\r
-       /*\r
-        * Address Vector Management Verbs\r
-        */\r
-       p_uvp->pre_create_av  = mlnx_pre_create_av;\r
-       p_uvp->post_create_av = mlnx_post_create_av;\r
-       p_uvp->pre_query_av   = mlnx_pre_query_av;\r
-       p_uvp->post_query_av  = mlnx_post_query_av;\r
-       p_uvp->pre_modify_av   = mlnx_pre_modify_av;\r
-       p_uvp->post_modify_av  = mlnx_post_modify_av;\r
-       p_uvp->pre_destroy_av  = mlnx_pre_destroy_av;\r
-       p_uvp->post_destroy_av = mlnx_post_destroy_av;\r
-\r
-}\r
-\r
 \r
 uint8_t\r
 gid_to_index_lookup (\r
@@ -133,11 +112,12 @@ map_itom_av_attr (
        return status;\r
 } \r
 \r
-ib_api_status_t\r
-mlnx_pre_create_av (\r
+static ib_api_status_t\r
+__pre_create_av (\r
        IN              const ib_pd_handle_t            h_uvp_pd,\r
        IN              const ib_av_attr_t              *p_av_attr,\r
-       IN OUT  ci_umv_buf_t                    *p_umv_buf)\r
+       IN OUT  ci_umv_buf_t                    *p_umv_buf,\r
+           OUT ib_av_handle_t                  *ph_uvp_av)\r
 {\r
        int err;\r
        struct mthca_ah *ah;\r
@@ -148,6 +128,8 @@ mlnx_pre_create_av (
        mlnx_ual_pd_info_t *p_pd = (mlnx_ual_pd_info_t *)h_uvp_pd;\r
        mlnx_ual_hobul_t *p_hobul = p_pd->p_hobul;\r
 \r
+       UNREFERENCED_PARAMETER(ph_uvp_av);\r
+       \r
        UVP_ENTER(UVP_DBG_AV);\r
 \r
        CL_ASSERT(p_umv_buf);\r
@@ -226,11 +208,11 @@ end:
 }\r
 \r
 \r
-void\r
-mlnx_post_create_av (\r
+static void\r
+__post_create_av (\r
        IN              const ib_pd_handle_t            h_uvp_pd,\r
        IN              ib_api_status_t                 ioctl_status,\r
-       OUT             ib_av_handle_t                  *ph_uvp_av,\r
+       IN OUT          ib_av_handle_t                  *ph_uvp_av,\r
        IN OUT  ci_umv_buf_t                    *p_umv_buf)\r
 {\r
        int err;\r
@@ -275,8 +257,8 @@ end:
        UVP_EXIT(UVP_DBG_AV);\r
 }\r
 \r
-ib_api_status_t\r
-mlnx_pre_query_av (\r
+static ib_api_status_t\r
+__pre_query_av (\r
        IN      const   ib_av_handle_t          h_uvp_av,\r
        IN OUT          ci_umv_buf_t            *p_umv_buf )\r
 {\r
@@ -288,8 +270,8 @@ mlnx_pre_query_av (
 }\r
 \r
 \r
-void\r
-mlnx_post_query_av (\r
+static void\r
+__post_query_av (\r
        IN              const   ib_av_handle_t                          h_uvp_av,\r
        IN                              ib_api_status_t                         ioctl_status,\r
        IN      OUT                     ib_av_attr_t                            *p_addr_vector,\r
@@ -315,8 +297,8 @@ mlnx_post_query_av (
 \r
 void mthca_set_av_params( struct mthca_ah *ah_p, struct ibv_ah_attr *ah_attr );\r
 \r
-ib_api_status_t\r
-mlnx_pre_modify_av (\r
+static ib_api_status_t\r
+__pre_modify_av (\r
        IN              const ib_av_handle_t            h_uvp_av,\r
        IN              const ib_av_attr_t              *p_addr_vector,\r
        IN OUT  ci_umv_buf_t                    *p_umv_buf)\r
@@ -350,8 +332,8 @@ mlnx_pre_modify_av (
        return IB_VERBS_PROCESSING_DONE;\r
 }\r
 \r
-void\r
-mlnx_post_modify_av (\r
+static void\r
+__post_modify_av (\r
        IN              const ib_av_handle_t    h_uvp_av,\r
        IN              ib_api_status_t         ioctl_status,\r
        IN OUT  ci_umv_buf_t            *p_umv_buf)\r
@@ -361,8 +343,8 @@ mlnx_post_modify_av (
 }\r
 \r
 \r
-ib_api_status_t\r
-mlnx_pre_destroy_av (\r
+static ib_api_status_t\r
+__pre_destroy_av (\r
        IN              const ib_av_handle_t            h_uvp_av)\r
 {\r
        ib_api_status_t status ;\r
@@ -376,8 +358,8 @@ mlnx_pre_destroy_av (
        return status;\r
 }\r
 \r
-void\r
-mlnx_post_destroy_av (\r
+static void\r
+__post_destroy_av (\r
        IN              const ib_av_handle_t            h_uvp_av,\r
        IN              ib_api_status_t                 ioctl_status)\r
 {\r
@@ -395,3 +377,24 @@ mlnx_post_destroy_av (
        return;\r
 }\r
 \r
+void\r
+mlnx_get_av_interface (\r
+       IN OUT  uvp_interface_t         *p_uvp )\r
+{\r
+\r
+       CL_ASSERT(p_uvp);\r
+\r
+       /*\r
+        * Address Vector Management Verbs\r
+        */\r
+       p_uvp->pre_create_av  = __pre_create_av;\r
+       p_uvp->post_create_av = __post_create_av;\r
+       p_uvp->pre_query_av   = __pre_query_av;\r
+       p_uvp->post_query_av  = __post_query_av;\r
+       p_uvp->pre_modify_av   = __pre_modify_av;\r
+       p_uvp->post_modify_av  = __post_modify_av;\r
+       p_uvp->pre_destroy_av  = __pre_destroy_av;\r
+       p_uvp->post_destroy_av = __post_destroy_av;\r
+\r
+}\r
+\r
index 29b0981..c66d7f7 100644 (file)
 \r
 extern uint32_t        mlnx_dbg_lvl;\r
 \r
-void\r
-mlnx_get_ca_interface (\r
-       IN OUT  uvp_interface_t         *p_uvp )\r
-{\r
-       CL_ASSERT(p_uvp);\r
-\r
-       /*\r
-        * HCA Access Verbs\r
-        */\r
-       p_uvp->pre_open_ca  = mlnx_pre_open_ca;\r
-       p_uvp->post_open_ca = mlnx_post_open_ca;\r
-\r
-\r
-       p_uvp->pre_query_ca  = mlnx_pre_query_ca;\r
-       p_uvp->post_query_ca = mlnx_post_query_ca;\r
-\r
-       p_uvp->pre_modify_ca  = NULL;\r
-       p_uvp->post_modify_ca = NULL;\r
-\r
-       p_uvp->pre_close_ca  = mlnx_pre_close_ca;\r
-       p_uvp->post_close_ca = mlnx_post_close_ca;\r
-\r
-}\r
-\r
-\r
-\r
-ib_api_status_t\r
-mlnx_pre_open_ca (\r
+static ib_api_status_t\r
+__pre_open_ca (\r
        IN              const   ib_net64_t                                      ca_guid,\r
-       IN      OUT                     ci_umv_buf_t                            *p_umv_buf )\r
+       IN      OUT                     ci_umv_buf_t                            *p_umv_buf,\r
+               OUT                     ib_ca_handle_t                          *ph_uvp_ca)\r
 {\r
        ib_api_status_t  status = IB_SUCCESS;\r
 \r
+       UNREFERENCED_PARAMETER(ph_uvp_ca);\r
+               \r
        UVP_ENTER(UVP_DBG_SHIM);\r
        if( p_umv_buf )\r
        {\r
@@ -96,11 +73,11 @@ err_memory:
 }\r
 \r
 \r
-ib_api_status_t\r
-mlnx_post_open_ca (\r
+static ib_api_status_t\r
+__post_open_ca (\r
        IN                              const ib_net64_t                        ca_guid,\r
        IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_ca_handle_t                          *ph_uvp_ca,\r
+       IN      OUT                     ib_ca_handle_t                          *ph_uvp_ca,\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
        ib_api_status_t  status = ioctl_status;\r
@@ -144,8 +121,8 @@ err_alloc_context:
        return status;\r
 }\r
 \r
-ib_api_status_t\r
-mlnx_pre_query_ca (\r
+static ib_api_status_t\r
+__pre_query_ca (\r
        IN                              ib_ca_handle_t                          h_uvp_ca,\r
        IN                              ib_ca_attr_t                            *p_ca_attr,\r
        IN                              size_t                                          byte_count,\r
@@ -190,8 +167,8 @@ mlnx_pre_query_ca (
 }\r
 \r
 \r
-void\r
-mlnx_post_query_ca (\r
+static void\r
+__post_query_ca (\r
        IN                              ib_ca_handle_t                          h_uvp_ca,\r
        IN                              ib_api_status_t                         ioctl_status,\r
        IN                              ib_ca_attr_t                            *p_ca_attr,\r
@@ -220,8 +197,8 @@ mlnx_post_query_ca (
 }\r
 \r
 \r
-ib_api_status_t\r
-mlnx_pre_modify_ca (\r
+static ib_api_status_t\r
+__pre_modify_ca (\r
     IN         ib_ca_handle_t                          h_uvp_ca,\r
     IN         uint8_t                                         port_num,\r
     IN         ib_ca_mod_t                                     ca_mod,\r
@@ -233,8 +210,8 @@ mlnx_pre_modify_ca (
 }\r
 \r
 \r
-void\r
-mlnx_post_modify_ca (\r
+static void\r
+__post_modify_ca (\r
        IN              ib_ca_handle_t                  h_uvp_ca,\r
        IN              ib_api_status_t                 ioctl_status)\r
 {\r
@@ -243,8 +220,8 @@ mlnx_post_modify_ca (
 }\r
 \r
 \r
-ib_api_status_t\r
-mlnx_pre_close_ca (\r
+static ib_api_status_t\r
+__pre_close_ca (\r
        IN              ib_ca_handle_t          h_uvp_ca)\r
 {\r
        UVP_ENTER(UVP_DBG_SHIM);\r
@@ -253,8 +230,8 @@ mlnx_pre_close_ca (
 }\r
 \r
 \r
-ib_api_status_t\r
-mlnx_post_close_ca (\r
+static ib_api_status_t\r
+__post_close_ca (\r
        IN              ib_ca_handle_t          h_uvp_ca,\r
        IN              ib_api_status_t         ioctl_status )\r
 {\r
@@ -282,3 +259,28 @@ mlnx_post_close_ca (
        return IB_SUCCESS;\r
 }\r
 \r
+void\r
+mlnx_get_ca_interface (\r
+       IN OUT  uvp_interface_t         *p_uvp )\r
+{\r
+       CL_ASSERT(p_uvp);\r
+\r
+       /*\r
+        * HCA Access Verbs\r
+        */\r
+       p_uvp->pre_open_ca  = __pre_open_ca;\r
+       p_uvp->post_open_ca = __post_open_ca;\r
+\r
+\r
+       p_uvp->pre_query_ca  = __pre_query_ca;\r
+       p_uvp->post_query_ca = __post_query_ca;\r
+\r
+       p_uvp->pre_modify_ca  = NULL;\r
+       p_uvp->post_modify_ca = NULL;\r
+\r
+       p_uvp->pre_close_ca  = __pre_close_ca;\r
+       p_uvp->post_close_ca = __post_close_ca;\r
+\r
+}\r
+\r
+\r
index ef70415..22d3628 100644 (file)
 \r
 extern uint32_t        mlnx_dbg_lvl;\r
 \r
-void\r
-mlnx_get_cq_interface (\r
-       IN OUT  uvp_interface_t         *p_uvp )\r
-{\r
-       UVP_ENTER(UVP_DBG_DEV);\r
-\r
-       CL_ASSERT(p_uvp);\r
-\r
-       /*\r
-        * Completion Queue Management Verbs\r
-        */\r
-       p_uvp->pre_create_cq  = mlnx_pre_create_cq;\r
-       p_uvp->post_create_cq = mlnx_post_create_cq;\r
-\r
-       p_uvp->pre_query_cq  = mlnx_pre_query_cq;\r
-       p_uvp->post_query_cq = NULL;\r
-\r
-       p_uvp->pre_resize_cq  = NULL; /* mlnx_pre_resize_cq: not supported in kernel */\r
-       p_uvp->post_resize_cq = NULL;   /* mlnx_post_resize_cq:not supported in kernel */ \r
-\r
-       p_uvp->pre_destroy_cq  = mlnx_pre_destroy_cq;\r
-       p_uvp->post_destroy_cq = mlnx_post_destroy_cq;\r
-\r
-       UVP_EXIT(UVP_DBG_DEV);\r
-}\r
-\r
-ib_api_status_t\r
-       mlnx_pre_create_cq (\r
+static ib_api_status_t\r
+__pre_create_cq (\r
                IN              const ib_ca_handle_t                            h_uvp_ca,\r
                IN      OUT             uint32_t*               const p_size,\r
-               IN      OUT             ci_umv_buf_t                            *p_umv_buf )\r
+               IN      OUT             ci_umv_buf_t                            *p_umv_buf,\r
+                       OUT                     ib_cq_handle_t                  *ph_uvp_cq)\r
 {\r
        struct ibv_cq *ibv_cq;\r
        ib_api_status_t status = IB_SUCCESS;\r
@@ -81,6 +56,8 @@ ib_api_status_t
        struct ibv_create_cq *p_create_cq;\r
        int err;\r
 \r
+       UNREFERENCED_PARAMETER(ph_uvp_cq);\r
+\r
        UVP_ENTER(UVP_DBG_CQ);\r
 \r
        CL_ASSERT(p_umv_buf);\r
@@ -119,12 +96,12 @@ end:
 }\r
 \r
 \r
-void\r
-mlnx_post_create_cq (\r
+static void\r
+__post_create_cq (\r
        IN              const   ib_ca_handle_t                          h_uvp_ca,\r
        IN                              ib_api_status_t                         ioctl_status,\r
        IN              const   uint32_t                                        size,\r
-               OUT                     ib_cq_handle_t                          *ph_uvp_cq,\r
+       IN      OUT                     ib_cq_handle_t                          *ph_uvp_cq,\r
        IN                              ci_umv_buf_t                            *p_umv_buf )\r
 {\r
        int err;\r
@@ -165,8 +142,8 @@ end:
 }\r
 \r
 \r
-ib_api_status_t\r
-mlnx_pre_query_cq (\r
+static ib_api_status_t\r
+__pre_query_cq (\r
        IN              const   ib_cq_handle_t          h_uvp_cq,\r
                OUT                     uint32_t* const         p_size,\r
        IN      OUT                     ci_umv_buf_t            *p_umv_buf)\r
@@ -182,8 +159,8 @@ mlnx_pre_query_cq (
 }\r
 \r
 \r
-ib_api_status_t\r
-mlnx_pre_destroy_cq (\r
+static ib_api_status_t\r
+__pre_destroy_cq (\r
        IN              const ib_cq_handle_t                    h_uvp_cq)\r
 {\r
        UVP_ENTER(UVP_DBG_CQ);\r
@@ -191,8 +168,8 @@ mlnx_pre_destroy_cq (
        return IB_SUCCESS;\r
 }\r
 \r
-void\r
-mlnx_post_destroy_cq (\r
+static void\r
+__post_destroy_cq (\r
        IN              const ib_cq_handle_t            h_uvp_cq,\r
        IN              ib_api_status_t                 ioctl_status)\r
 {\r
@@ -214,3 +191,30 @@ mlnx_post_destroy_cq (
        UVP_EXIT(UVP_DBG_CQ);\r
 }\r
 \r
+void\r
+mlnx_get_cq_interface (\r
+       IN OUT  uvp_interface_t         *p_uvp )\r
+{\r
+       UVP_ENTER(UVP_DBG_DEV);\r
+\r
+       CL_ASSERT(p_uvp);\r
+\r
+       /*\r
+        * Completion Queue Management Verbs\r
+        */\r
+       p_uvp->pre_create_cq  = __pre_create_cq;\r
+       p_uvp->post_create_cq = __post_create_cq;\r
+\r
+       p_uvp->pre_query_cq  = __pre_query_cq;\r
+       p_uvp->post_query_cq = NULL;\r
+\r
+       p_uvp->pre_resize_cq  = NULL; /* __pre_resize_cq: not supported in kernel */\r
+       p_uvp->post_resize_cq = NULL;   /* __post_resize_cq:not supported in kernel */ \r
+\r
+       p_uvp->pre_destroy_cq  = __pre_destroy_cq;\r
+       p_uvp->post_destroy_cq = __post_destroy_cq;\r
+\r
+       UVP_EXIT(UVP_DBG_DEV);\r
+}\r
+\r
+\r
index 03d9057..172fd34 100644 (file)
@@ -143,7 +143,7 @@ uvp_get_interface (
     /*\r
      * Version of the header file this interface export can handle\r
      */\r
-    p_uvp->version = 0x100;\r
+    p_uvp->version = 0x101;\r
     p_uvp->guid    = 0x12345678;\r
 \r
     /*\r
index bbc5fdc..9d717d8 100644 (file)
@@ -91,486 +91,44 @@ void
 mlnx_get_ca_interface (\r
     IN OUT     uvp_interface_t                         *p_uvp );\r
 \r
-\r
-ib_api_status_t  \r
-mlnx_pre_open_ca (\r
-    IN         const ib_net64_t                        ca_guid,\r
-    IN OUT      ci_umv_buf_t                           *p_umv_buf);\r
-   \r
-    \r
-ib_api_status_t\r
-mlnx_post_open_ca (\r
-       IN                              const ib_net64_t                        ca_guid,\r
-       IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_ca_handle_t                          *ph_uvp_ca,\r
-       IN                              ci_umv_buf_t                            *p_umv_buf );\r
-\r
-\r
-ib_api_status_t  \r
-mlnx_pre_query_ca (\r
-       IN                              ib_ca_handle_t                          h_uvp_ca,\r
-       IN                              ib_ca_attr_t                            *p_ca_attr,\r
-       IN                              size_t                                          byte_count,\r
-       IN                              ci_umv_buf_t                            *p_umv_buf );\r
-\r
-void  \r
-mlnx_post_query_ca (\r
-       IN                              ib_ca_handle_t                          h_uvp_ca,\r
-       IN                              ib_api_status_t                         ioctl_status,\r
-       IN                              ib_ca_attr_t                            *p_ca_attr,\r
-       IN                              size_t                                          byte_count,\r
-       IN                              ci_umv_buf_t                            *p_umv_buf );\r
-\r
-ib_api_status_t  \r
-mlnx_pre_modify_ca (\r
-    IN         ib_ca_handle_t                          h_uvp_ca,\r
-    IN         uint8_t                                 port_num,\r
-    IN         ib_ca_mod_t                             modca_cmd,\r
-    IN         const ib_port_attr_mod_t*       p_port_attr_mod );\r
-\r
-void  \r
-mlnx_post_modify_ca (\r
-    IN         ib_ca_handle_t                          h_uvp_ca,\r
-    IN         ib_api_status_t                         ioctl_status);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_close_ca (\r
-    IN         ib_ca_handle_t                          h_uvp_ca );\r
-\r
-ib_api_status_t\r
-mlnx_post_close_ca (\r
-    IN         ib_ca_handle_t                          h_uvp_ca,\r
-    IN         ib_api_status_t                         ioctl_status );\r
-\r
-\r
 /************* PD Management *************************/\r
 void  \r
 mlnx_get_pd_interface (\r
     IN OUT     uvp_interface_t                         *p_uvp );\r
-    \r
-ib_api_status_t  \r
-mlnx_pre_allocate_pd (\r
-    IN         const ib_ca_handle_t            h_uvp_ca,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_allocate_pd (\r
-       IN                              ib_ca_handle_t                          h_uvp_ca,\r
-       IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_pd_handle_t                          *ph_uvp_pd,\r
-       IN                              ci_umv_buf_t                            *p_umv_buf );\r
-\r
-ib_api_status_t  \r
-mlnx_pre_deallocate_pd (\r
-    IN         const ib_pd_handle_t            h_uvp_pd);\r
-\r
-void  \r
-mlnx_post_deallocate_pd (\r
-    IN         const ib_pd_handle_t            h_uvp_pd,\r
-    IN         ib_api_status_t                 ioctl_status );\r
-\r
 \r
 /************* AV Management *************************/\r
 void\r
 mlnx_get_av_interface (\r
     IN OUT     uvp_interface_t                         *p_uvp );\r
 \r
-ib_api_status_t  \r
-mlnx_pre_create_av (\r
-    IN         const ib_pd_handle_t            h_uvp_pd,\r
-    IN         const ib_av_attr_t                      *p_addr_vector,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-\r
-void\r
-mlnx_post_create_av (\r
-       IN              const   ib_pd_handle_t                          h_uvp_pd,\r
-       IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_av_handle_t                          *ph_uvp_av,\r
-       IN      OUT                     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_query_av (\r
-       IN      const           ib_av_handle_t          h_uvp_av,\r
-       IN OUT                  ci_umv_buf_t            *p_umv_buf );\r
-\r
-void  \r
-mlnx_post_query_av (\r
-       IN              const   ib_av_handle_t                          h_uvp_av,\r
-       IN                              ib_api_status_t                         ioctl_status,\r
-       IN      OUT                     ib_av_attr_t                            *p_addr_vector,\r
-       IN      OUT                     ib_pd_handle_t                          *ph_pd,\r
-       IN      OUT                     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_modify_av (\r
-    IN         const ib_av_handle_t            h_uvp_av,\r
-    IN         const ib_av_attr_t                      *p_addr_vector,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_modify_av (\r
-    IN         const ib_av_handle_t            h_uvp_av,\r
-    IN         ib_api_status_t                         ioctl_status,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_destroy_av (\r
-    IN         const ib_av_handle_t            h_uvp_av);\r
-\r
-void  \r
-mlnx_post_destroy_av (\r
-    IN         const ib_av_handle_t            h_uvp_av,\r
-    IN         ib_api_status_t                 ioctl_status);\r
-\r
-\r
 /************* CQ Management *************************/\r
 void  \r
 mlnx_get_cq_interface (\r
     IN OUT     uvp_interface_t                         *p_uvp );\r
 \r
-ib_api_status_t  \r
-mlnx_pre_create_cq (\r
-       IN              const   ib_ca_handle_t                          h_uvp_ca,\r
-       IN      OUT                     uint32_t*                       const   p_size,\r
-       IN      OUT                     ci_umv_buf_t                            *p_umv_buf );\r
-\r
-void  \r
-mlnx_post_create_cq (\r
-       IN              const   ib_ca_handle_t                          h_uvp_ca,\r
-       IN                              ib_api_status_t                         ioctl_status,\r
-       IN              const   uint32_t                                        size,\r
-               OUT                     ib_cq_handle_t                          *ph_uvp_cq,\r
-       IN                              ci_umv_buf_t                            *p_umv_buf );\r
-\r
-ib_api_status_t  \r
-mlnx_pre_resize_cq (\r
-       IN              const   ib_cq_handle_t                          h_uvp_cq,\r
-       IN      OUT                     uint32_t*                       const   p_size,\r
-       IN      OUT                     ci_umv_buf_t                            *p_umv_buf );\r
-\r
-void  \r
-mlnx_post_resize_cq (\r
-    IN         const ib_cq_handle_t            h_uvp_cq,\r
-    IN         ib_api_status_t                         ioctl_status,\r
-    IN         const uint32_t                          size,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_query_cq (\r
-       IN              const   ib_cq_handle_t          h_uvp_cq,\r
-               OUT                     uint32_t* const         p_size,\r
-       IN      OUT                     ci_umv_buf_t            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_destroy_cq (\r
-    IN         const ib_cq_handle_t            h_uvp_cq);\r
-\r
-void  \r
-mlnx_post_destroy_cq (\r
-    IN         const ib_cq_handle_t            h_uvp_cq,\r
-    IN         ib_api_status_t                 ioctl_status);\r
-\r
 /************* SRQ Management *************************/\r
 void  \r
 mlnx_get_srq_interface (\r
     IN OUT     uvp_interface_t                         *p_uvp );\r
 \r
-ib_api_status_t  \r
-mlnx_pre_create_srq (\r
-    IN         const   ib_pd_handle_t          h_uvp_pd,// Fix me: if needed\r
-    IN         const   ib_srq_attr_t           *p_srq_attr,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_create_srq (\r
-       IN              const   ib_pd_handle_t                          h_uvp_pd,\r
-       IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_srq_handle_t                         *ph_uvp_srq,\r
-       IN                              ci_umv_buf_t                            *p_umv_buf );\r
-\r
-ib_api_status_t  \r
-mlnx_pre_modify_srq (\r
-    IN         const ib_srq_handle_t           h_uvp_srq,\r
-    IN         const ib_srq_attr_mask_t        srq_attr_attr,  // Fixme\r
-    IN         const ib_srq_attr_t                     *p_srq_attr,    // Fixme\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_modify_srq (\r
-       IN              const ib_srq_handle_t           h_uvp_srq,\r
-       IN              ib_api_status_t                         ioctl_status,\r
-       IN OUT  ci_umv_buf_t                            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_query_srq (\r
-    IN         ib_srq_handle_t                         h_uvp_srq,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_query_srq (\r
-    IN         ib_srq_handle_t                         h_uvp_srq,\r
-    IN         ib_api_status_t                         ioctl_status,\r
-    IN         ib_srq_attr_t                           *p_query_attr,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_destroy_srq (\r
-    IN         const ib_srq_handle_t           h_uvp_srq);\r
-\r
-void  \r
-mlnx_post_destroy_srq (\r
-    IN         const ib_srq_handle_t           h_uvp_srq,\r
-    IN         ib_api_status_t                 ioctl_status );\r
-\r
-\r
 /************* QP Management *************************/\r
 void  \r
 mlnx_get_qp_interface (\r
     IN OUT     uvp_interface_t                         *p_uvp );\r
 \r
-ib_api_status_t  \r
-mlnx_pre_create_qp (\r
-    IN         const   ib_pd_handle_t          h_uvp_pd,// Fix me: if needed\r
-    IN         const   ib_qp_create_t          *p_create_attr,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_create_qp (\r
-       IN              const   ib_pd_handle_t                          h_uvp_pd,\r
-       IN                              ib_api_status_t                         ioctl_status,\r
-               OUT                     ib_qp_handle_t                          *ph_uvp_qp,\r
-       IN                              ci_umv_buf_t                            *p_umv_buf );\r
-\r
-ib_api_status_t  \r
-mlnx_pre_modify_qp (\r
-    IN         const ib_qp_handle_t            h_uvp_qp,\r
-    IN         const ib_qp_mod_t                       *p_modify_attr, // Fixme\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_modify_qp (\r
-    IN         const ib_qp_handle_t            h_uvp_qp,\r
-    IN         ib_api_status_t                         ioctl_status,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_query_qp (\r
-    IN         ib_qp_handle_t                          h_uvp_qp,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_query_qp (\r
-    IN         ib_qp_handle_t                          h_uvp_qp,\r
-    IN         ib_api_status_t                         ioctl_status,\r
-    IN         ib_qp_attr_t                            *p_query_attr,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_destroy_qp (\r
-    IN         const ib_qp_handle_t            h_uvp_qp);\r
-\r
-void  \r
-mlnx_post_destroy_qp (\r
-    IN         const ib_qp_handle_t            h_uvp_qp,\r
-    IN         ib_api_status_t                 ioctl_status );\r
-\r
 /************* MR/MW Management *************************/\r
 void  \r
 mlnx_get_mrw_interface (\r
     IN OUT     uvp_interface_t                         *p_uvp );\r
 \r
-ib_api_status_t  \r
-mlnx_pre_register_mr (\r
-    IN         const ib_pd_handle_t            h_uvp_pd,\r
-    IN         const ib_mr_create_t            *p_mr_create,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_register_mr (\r
-    IN         const ib_pd_handle_t            h_uvp_pd,\r
-    IN         ib_api_status_t                         ioctl_status,\r
-    IN         const uint32_t                          *p_lkey,\r
-    IN         const uint32_t                          *p_rkey,\r
-    OUT                const ib_mr_handle_t            *ph_uvp_mr,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_query_mr (\r
-    IN         const ib_mr_handle_t            h_uvp_mr,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_query_mr (\r
-    IN         const ib_mr_handle_t            h_uvp_mr,\r
-    IN         ib_api_status_t                         ioctl_status,\r
-    IN         const ib_mr_attr_t                      *p_mr_query,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-ib_api_status_t  \r
-mlnx_pre_modify_mr (\r
-    IN         const ib_mr_handle_t            h_uvp_mr,\r
-    IN         const ib_pd_handle_t            h_uvp_pd                OPTIONAL,\r
-    IN         const ib_mr_mod_t                       mr_mod_mask,\r
-    IN         const ib_mr_create_t            *p_mr_create    OPTIONAL,\r
-    IN OUT     ci_umv_buf_t                            *p_umv_buf);\r
-\r
-void  \r
-mlnx_post_modify_mr (\r
-    IN         const ib_mr_handle_t            h_uvp_mr,