[IBAL] bugfix: QP has to increment the reference on the pool key upon creation and...
[mirror/winof/.git] / core / al / al_qp.c
index 9465948..9ff407c 100644 (file)
 #include "al_cm_cep.h"\r
 #include "al_cq.h"\r
 #include "al_debug.h"\r
+#if defined(EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
+#endif\r
+#include "al_qp.tmh"\r
+#endif\r
 #include "al_mad.h"\r
 #include "al_mad_pool.h"\r
 #include "al_mcast.h"\r
@@ -284,7 +290,7 @@ create_qp(
 \r
        if( !p_qp_create || !ph_qp )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_PARAMETER\n") );\r
                return IB_INVALID_PARAMETER;\r
        }\r
 \r
@@ -377,7 +383,7 @@ get_spl_qp(
 \r
        if( !p_qp_create || !ph_qp )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_PARAMETER\n") );\r
                return IB_INVALID_PARAMETER;\r
        }\r
 \r
@@ -442,7 +448,14 @@ get_spl_qp(
                        status = ib_reg_mad_pool( gh_mad_pool, h_pd,\r
                                &((al_qp_alias_t*)h_qp)->pool_key );\r
                        if( status == IB_SUCCESS )\r
+                       {\r
+                               /*\r
+                                * Take a reference on the pool key since we don't have a\r
+                                * mechanism for the pool key to clear the QP's pointer to it.\r
+                                */\r
+                               ref_al_obj( &((al_qp_alias_t*)h_qp)->pool_key->obj );\r
                                *p_pool_key = ((al_qp_alias_t*)h_qp)->pool_key;\r
+                       }\r
                }\r
                break;\r
 \r
@@ -623,6 +636,12 @@ init_base_qp(
        p_qp->pfn_init_dgrm_svc = al_bad_init_dgrm_svc;\r
        p_qp->pfn_join_mcast = al_bad_join_mcast;\r
 \r
+       if( p_qp->type == IB_QPT_RELIABLE_CONN ||\r
+               p_qp->type == IB_QPT_UNRELIABLE_CONN )\r
+       {\r
+               ((al_conn_qp_t*)p_qp)->cid = AL_INVALID_CID;\r
+       }\r
+\r
        return status;\r
 }\r
 \r
@@ -723,7 +742,6 @@ init_conn_qp(
        status = init_raw_qp( &p_conn_qp->qp, h_pd, UNBOUND_PORT_GUID,\r
                p_qp_create, p_umv_buf );\r
 \r
-       p_conn_qp->cid = AL_INVALID_CID;\r
 \r
        return status;\r
 }\r
@@ -985,18 +1003,18 @@ ib_destroy_qp(
        IN              const   ib_qp_handle_t                          h_qp,\r
        IN              const   ib_pfn_destroy_cb_t                     pfn_destroy_cb OPTIONAL )\r
 {\r
-       CL_ENTER( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_ENTER( AL_DBG_QP );\r
 \r
        if( AL_OBJ_INVALID_HANDLE( h_qp, AL_OBJ_TYPE_H_QP ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_QP_HANDLE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_QP_HANDLE\n") );\r
                return IB_INVALID_QP_HANDLE;\r
        }\r
 \r
        ref_al_obj( &h_qp->obj );\r
        h_qp->obj.pfn_destroy( &h_qp->obj, pfn_destroy_cb );\r
 \r
-       CL_EXIT( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_EXIT( AL_DBG_QP );\r
        return IB_SUCCESS;\r
 }\r
 \r
@@ -1052,12 +1070,13 @@ destroying_qp(
                {\r
                        ib_api_status_t         status;\r
                        /* Deregister the pool_key. */\r
-                       ref_al_obj( &p_qp_alias->pool_key->obj );\r
                        status = dereg_mad_pool( p_qp_alias->pool_key, AL_KEY_ALIAS );\r
                        if( status != IB_SUCCESS )\r
                        {\r
-                               AL_TRACE( AL_DBG_ERROR, ("dereg_mad_pool returned %s.\n",\r
+                               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
+                                       ("dereg_mad_pool returned %s.\n",\r
                                        ib_get_err_str(status)) );\r
+                               /* Release the reference taken when we created the pool key. */\r
                                deref_al_obj( &p_qp_alias->pool_key->obj );\r
                        }\r
                        p_qp_alias->pool_key = NULL;\r
@@ -1126,7 +1145,7 @@ cleanup_qp(
                status = verbs_destroy_qp( h_qp );\r
                if( status != IB_SUCCESS )\r
                {\r
-                       CL_TRACE( AL_DBG_ERROR, g_al_dbg_lvl,\r
+                       AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
                                ("verbs_destroy_qp failed with status %s.\n",\r
                                ib_get_err_str(status)) );\r
                }\r
@@ -1228,23 +1247,23 @@ query_qp(
 {\r
        ib_api_status_t                 status;\r
 \r
-       CL_ENTER( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_ENTER( AL_DBG_QP );\r
 \r
        if( AL_OBJ_INVALID_HANDLE( h_qp, AL_OBJ_TYPE_H_QP ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_QP_HANDLE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_QP_HANDLE\n") );\r
                return IB_INVALID_QP_HANDLE;\r
        }\r
        if( !p_qp_attr )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_PARAMETER\n") );\r
                return IB_INVALID_PARAMETER;\r
        }\r
 \r
        status = verbs_query_qp( h_qp, p_qp_attr );\r
        if( status != IB_SUCCESS )\r
        {\r
-               CL_EXIT( AL_DBG_QP, g_al_dbg_lvl );\r
+               AL_EXIT( AL_DBG_QP );\r
                return status;\r
        }\r
 \r
@@ -1254,7 +1273,7 @@ query_qp(
        p_qp_attr->h_sq_cq = h_qp->h_send_cq;\r
        p_qp_attr->qp_type = h_qp->type;\r
 \r
-       CL_EXIT( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_EXIT( AL_DBG_QP );\r
        return IB_SUCCESS;\r
 }\r
 \r
@@ -1278,22 +1297,22 @@ modify_qp(
 {\r
        ib_api_status_t                 status;\r
 \r
-       CL_ENTER( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_ENTER( AL_DBG_QP );\r
 \r
        if( AL_OBJ_INVALID_HANDLE( h_qp, AL_OBJ_TYPE_H_QP ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_QP_HANDLE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_QP_HANDLE\n") );\r
                return IB_INVALID_QP_HANDLE;\r
        }\r
        if( !p_qp_mod )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_PARAMETER\n") );\r
                return IB_INVALID_PARAMETER;\r
        }\r
 \r
        status = h_qp->pfn_modify_qp( h_qp, p_qp_mod, p_umv_buf );\r
 \r
-       CL_EXIT( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_EXIT( AL_DBG_QP );\r
        return status;\r
 }\r
 \r
@@ -1342,11 +1361,11 @@ ib_init_dgrm_svc(
 {\r
        ib_api_status_t                 status;\r
 \r
-       CL_ENTER( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_ENTER( AL_DBG_QP );\r
 \r
        if( AL_OBJ_INVALID_HANDLE( h_qp, AL_OBJ_TYPE_H_QP ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_QP_HANDLE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_QP_HANDLE\n") );\r
                return IB_INVALID_QP_HANDLE;\r
        }\r
 \r
@@ -1362,20 +1381,20 @@ ib_init_dgrm_svc(
        case IB_QPT_MAD:\r
                if( !p_dgrm_info )\r
                {\r
-                       CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl,\r
+                       AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,\r
                                ("IB_INVALID_PARAMETER\n") );\r
                        return IB_INVALID_PARAMETER;\r
                }\r
                break;\r
 \r
        default:\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_PARAMETER\n") );\r
                return IB_INVALID_PARAMETER;\r
        }\r
 \r
        status = h_qp->pfn_init_dgrm_svc( h_qp, p_dgrm_info );\r
 \r
-       CL_EXIT( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_EXIT( AL_DBG_QP );\r
        return status;\r
 }\r
 \r
@@ -1499,11 +1518,11 @@ ib_reg_mad_svc(
 {\r
        ib_api_status_t                 status;\r
 \r
-       CL_ENTER( AL_DBG_MAD_SVC, g_al_dbg_lvl );\r
+       AL_ENTER( AL_DBG_MAD_SVC );\r
 \r
        if( AL_OBJ_INVALID_HANDLE( h_qp, AL_OBJ_TYPE_H_QP ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_QP_HANDLE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_QP_HANDLE\n") );\r
                return IB_INVALID_QP_HANDLE;\r
        }\r
 \r
@@ -1513,7 +1532,7 @@ ib_reg_mad_svc(
        if( status == IB_SUCCESS )\r
                deref_al_obj( &(*ph_mad_svc)->obj );\r
 \r
-       CL_EXIT( AL_DBG_MAD_SVC, g_al_dbg_lvl );\r
+       AL_EXIT( AL_DBG_MAD_SVC );\r
        return status;\r
 }\r
 \r
@@ -1525,22 +1544,22 @@ ib_join_mcast(
 {\r
        ib_api_status_t                 status;\r
 \r
-       CL_ENTER( AL_DBG_MCAST, g_al_dbg_lvl );\r
+       AL_ENTER( AL_DBG_MCAST );\r
 \r
        if( AL_OBJ_INVALID_HANDLE( h_qp, AL_OBJ_TYPE_H_QP ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_QP_HANDLE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_QP_HANDLE\n") );\r
                return IB_INVALID_QP_HANDLE;\r
        }\r
        if( !p_mcast_req )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_PARAMETER\n") );\r
                return IB_INVALID_PARAMETER;\r
        }\r
 \r
        status = h_qp->pfn_join_mcast( h_qp, p_mcast_req );\r
 \r
-       CL_EXIT( AL_DBG_MCAST, g_al_dbg_lvl );\r
+       AL_EXIT( AL_DBG_MCAST );\r
        return status;\r
 }\r
 \r
@@ -1560,16 +1579,16 @@ ib_post_send(
        PERF_DECLARE( PostSend );\r
 \r
        cl_perf_start( IbPostSend );\r
-       CL_ENTER( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_ENTER( AL_DBG_QP );\r
 \r
        if( AL_OBJ_INVALID_HANDLE( h_qp, AL_OBJ_TYPE_H_QP ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_QP_HANDLE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_QP_HANDLE\n") );\r
                return IB_INVALID_QP_HANDLE;\r
        }\r
        if( !p_send_wr || ( p_send_wr->p_next && !pp_send_failure ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_PARAMETER\n") );\r
                return IB_INVALID_PARAMETER;\r
        }\r
 \r
@@ -1578,7 +1597,7 @@ ib_post_send(
                h_qp->pfn_post_send( h_qp->h_send_qp, p_send_wr, pp_send_failure );\r
        cl_perf_stop( &g_perf, PostSend );\r
 \r
-       CL_EXIT( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_EXIT( AL_DBG_QP );\r
        cl_perf_stop( &g_perf, IbPostSend );\r
        return status;\r
 }\r
@@ -1772,23 +1791,23 @@ ib_post_recv(
 {\r
        ib_api_status_t                 status;\r
 \r
-       CL_ENTER( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_ENTER( AL_DBG_QP );\r
 \r
        if( AL_OBJ_INVALID_HANDLE( h_qp, AL_OBJ_TYPE_H_QP ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_QP_HANDLE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_QP_HANDLE\n") );\r
                return IB_INVALID_QP_HANDLE;\r
        }\r
        if( !p_recv_wr || ( p_recv_wr->p_next && !pp_recv_failure ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_PARAMETER\n") );\r
                return IB_INVALID_PARAMETER;\r
        }\r
 \r
        status =\r
                h_qp->pfn_post_recv( h_qp->h_recv_qp, p_recv_wr, pp_recv_failure );\r
 \r
-       CL_EXIT( AL_DBG_QP, g_al_dbg_lvl );\r
+       AL_EXIT( AL_DBG_QP );\r
        return status;\r
 }\r
 \r
@@ -2047,21 +2066,21 @@ ib_bind_mw(
        ib_mr_handle_t                  h_mr;\r
        ib_api_status_t                 status;\r
 \r
-       CL_ENTER( AL_DBG_MW, g_al_dbg_lvl );\r
+       AL_ENTER( AL_DBG_MW );\r
 \r
        if( AL_OBJ_INVALID_HANDLE( h_mw, AL_OBJ_TYPE_H_MW ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_MW_HANDLE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_MW_HANDLE\n") );\r
                return IB_INVALID_MW_HANDLE;\r
        }\r
        if( AL_OBJ_INVALID_HANDLE( h_qp, AL_OBJ_TYPE_H_QP ) )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_QP_HANDLE\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_QP_HANDLE\n") );\r
                return IB_INVALID_QP_HANDLE;\r
        }\r
        if( !p_mw_bind || !p_rkey )\r
        {\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );\r
+               AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR, ("IB_INVALID_PARAMETER\n") );\r
                return IB_INVALID_PARAMETER;\r
        }\r
 \r
@@ -2073,6 +2092,6 @@ ib_bind_mw(
 \r
        p_mw_bind->h_mr = h_mr;\r
 \r
-       CL_EXIT( AL_DBG_MW, g_al_dbg_lvl );\r
+       AL_EXIT( AL_DBG_MW );\r
        return status;\r
 }\r