]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[IPOIB] bugfix: endpt are not added to the port child list if port is marked as being...
authorsleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 13 Jul 2006 13:02:01 +0000 (13:02 +0000)
committersleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 13 Jul 2006 13:02:01 +0000 (13:02 +0000)
-add debug util to ref count
-port_resume is being called from port_destroy (and not from endpt_cleanup)

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

trunk/ulp/ipoib/kernel/ipoib_adapter.c
trunk/ulp/ipoib/kernel/ipoib_debug.h
trunk/ulp/ipoib/kernel/ipoib_driver.c
trunk/ulp/ipoib/kernel/ipoib_endpoint.c
trunk/ulp/ipoib/kernel/ipoib_port.c
trunk/ulp/ipoib/kernel/ipoib_port.h

index 9d99db637914af5a8fd7ec8e4ebb9fb828a573b0..d31380e3dad842371227c24bf229733fc9d537ed 100644 (file)
@@ -717,7 +717,7 @@ ipoib_refresh_mcast(
        if( p_adapter->state == IB_PNP_PORT_ACTIVE )\r
        {\r
                p_port = p_adapter->p_port;\r
-               cl_obj_ref( &p_port->obj );\r
+               ipoib_port_ref( p_port, ref_refresh_mcast );\r
        }\r
        cl_obj_unlock( &p_adapter->obj );\r
 \r
@@ -765,7 +765,7 @@ ipoib_refresh_mcast(
        p_adapter->mcast_array_size = num_macs;\r
 \r
        if( p_port )\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_refresh_mcast );\r
 \r
        IPOIB_EXIT( IPOIB_DBG_MCAST );\r
 }\r
index dc27bad6bb3f44c152755f3b60463d36be8f725f..20cc1b402d1e4d4788b5f6b233200f9acf53691f 100644 (file)
@@ -68,7 +68,8 @@ extern uint32_t               g_ipoib_dbg_flags;
        WPP_DEFINE_BIT(IPOIB_DBG_ALLOC) \\r
        WPP_DEFINE_BIT(IPOIB_DBG_OID) \\r
        WPP_DEFINE_BIT(IPOIB_DBG_IOCTL) \\r
-       WPP_DEFINE_BIT(IPOIB_DBG_STAT))\r
+       WPP_DEFINE_BIT(IPOIB_DBG_STAT) \\r
+       WPP_DEFINE_BIT(IPOIB_DBG_OBJ))\r
 \r
 \r
 \r
@@ -111,6 +112,7 @@ extern uint32_t             g_ipoib_dbg_flags;
 #define IPOIB_DBG_OID  (1 << 10)\r
 #define IPOIB_DBG_IOCTL        (1 << 11)\r
 #define IPOIB_DBG_STAT (1 << 12)\r
+#define IPOIB_DBG_OBJ  (1 << 13)\r
 \r
 #define IPOIB_DBG_ERROR        (CL_DBG_ERROR | IPOIB_DBG_ERR)\r
 #define IPOIB_DBG_ALL  CL_DBG_ALL\r
@@ -243,4 +245,49 @@ enum ipoib_perf_counters
 \r
 };\r
 \r
+\r
+enum ref_cnt_buckets\r
+{\r
+       ref_init = 0,\r
+       ref_refresh_mcast,      /* only used in refresh_mcast */\r
+       ref_send_packets,       /* only in send_packets */\r
+       ref_get_recv,\r
+       ref_repost,             /* only in __recv_mgr_repost */\r
+       ref_recv_cb,    /* only in __recv_cb */\r
+       ref_send_cb,    /* only in __send_cb */\r
+       ref_port_up,\r
+       ref_get_bcast,\r
+       ref_bcast,              /* join and create, used as base only */\r
+       ref_join_mcast,\r
+       ref_endpt_track,        /* used when endpt is in port's child list. */\r
+\r
+       ref_array_size, /* Used to size the array of ref buckets. */\r
+       ref_mask = 100, /* Used to differentiate derefs. */\r
+\r
+       ref_failed_recv_wc = 100 | ref_get_recv,\r
+       ref_recv_inv_len = 200 | ref_get_recv,\r
+       ref_recv_loopback = 300 | ref_get_recv,\r
+       ref_recv_filter = 400 | ref_get_recv,\r
+\r
+       ref_bcast_get_cb = 100 | ref_get_bcast,\r
+\r
+       ref_join_bcast = 100 | ref_bcast,\r
+       ref_create_bcast = 200 | ref_bcast,\r
+       ref_bcast_inv_state = 300 | ref_bcast,\r
+       ref_bcast_req_failed = 400 | ref_bcast,\r
+       ref_bcast_error = 500 | ref_bcast,\r
+       ref_bcast_join_failed = 600 | ref_bcast,\r
+       ref_bcast_create_failed = 700 | ref_bcast,\r
+\r
+       ref_mcast_inv_state = 100 | ref_join_mcast,\r
+       ref_mcast_req_failed = 200 | ref_join_mcast,\r
+       ref_mcast_no_endpt = 300 | ref_join_mcast,\r
+       ref_mcast_av_failed = 400 | ref_join_mcast,\r
+       ref_mcast_join_failed = 500 | ref_join_mcast,\r
+\r
+       ref_port_info_cb = 100 | ref_port_up\r
+\r
+};\r
+\r
+\r
 #endif /* _IPOIB_DEBUG_H_ */\r
index 08e9e85b0b82fada38f3945796656eec8a0ca018..521c126502ef54845f28b8508d8fd7644552b461 100644 (file)
@@ -1855,13 +1855,13 @@ ipoib_send_packets(
        }\r
 \r
        p_port = p_adapter->p_port;\r
-       cl_obj_ref( &p_port->obj );\r
+       ipoib_port_ref( p_port, ref_send_packets );\r
        cl_obj_unlock( &p_adapter->obj );\r
 \r
        cl_perf_start( PortSend );\r
        ipoib_port_send( p_port, packet_array, num_packets );\r
        cl_perf_stop( &p_port->p_adapter->perf, PortSend );\r
-       cl_obj_deref( &p_port->obj );\r
+       ipoib_port_deref( p_port, ref_send_packets );\r
 \r
        cl_perf_stop( &p_adapter->perf, SendPackets );\r
 \r
index 4ef32db44c688bbed6cd5e98cbce59d2d972ef5e..5d885c9645f1452205ec4611f0857c274a855b0a 100644 (file)
@@ -224,9 +224,6 @@ __endpt_cleanup(
        p_endpt = PARENT_STRUCT( p_obj, ipoib_endpt_t, obj );\r
        p_port = __endpt_parent( p_endpt );\r
 \r
-       /* Resume sends so that any pending sends for this endpoint fail. */\r
-       ipoib_port_resume( p_port );\r
-\r
        /* Leave the multicast group if it exists. */\r
        if( p_endpt->h_mcast )\r
        {\r
index 3eca133598b7d47a054db0fcbfc9d5dc3578100f..e6c2fa341b12aa73f18a4f982e075d0c003f3f06 100644 (file)
@@ -389,13 +389,13 @@ __endpt_mgr_get_by_lid(
        IN                              ipoib_port_t* const                     p_port,\r
        IN              const   net16_t                                         lid );\r
 \r
-static inline void\r
+static inline ib_api_status_t\r
 __endpt_mgr_insert_locked(\r
        IN                              ipoib_port_t* const                     p_port,\r
        IN              const   mac_addr_t                                      mac,\r
        IN                              ipoib_endpt_t* const            p_endpt );\r
 \r
-static inline void\r
+static inline ib_api_status_t\r
 __endpt_mgr_insert(\r
        IN                              ipoib_port_t* const                     p_port,\r
        IN              const   mac_addr_t                                      mac,\r
@@ -458,6 +458,29 @@ __gid_cmp(
 }\r
 \r
 \r
+inline void ipoib_port_ref( ipoib_port_t * p_port, int type )\r
+{\r
+       cl_obj_ref( &p_port->obj );\r
+#if DBG\r
+       cl_atomic_inc( &p_port->ref[type % ref_mask] );\r
+       IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_OBJ,\r
+               ("ref type %d ref_cnt %d\n", type, p_port->obj.ref_cnt) );\r
+#endif\r
+}\r
+\r
+\r
+inline void ipoib_port_deref(ipoib_port_t * p_port, int type)\r
+{\r
+       cl_obj_deref( &p_port->obj );\r
+\r
+#if DBG\r
+       cl_atomic_dec( &p_port->ref[type % ref_mask] );\r
+       IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_OBJ,\r
+               ("deref type %d ref_cnt %d\n", type, p_port->obj.ref_cnt) );\r
+#endif\r
+}\r
+\r
+\r
 /******************************************************************************\r
 *\r
 * Implementation\r
@@ -623,6 +646,13 @@ __port_init(
        /* We only ever destroy from the PnP callback thread. */\r
        cl_status = cl_obj_init( &p_port->obj, CL_DESTROY_SYNC,\r
                __port_destroying, __port_cleanup, __port_free );\r
+\r
+#if DBG\r
+       cl_atomic_inc( &p_port->ref[ref_init] );\r
+       IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_OBJ,\r
+               ("ref type %d ref_cnt %d\n", ref_init, p_port->obj.ref_cnt) );\r
+#endif\r
+\r
        if( cl_status != CL_SUCCESS )\r
        {\r
                IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
@@ -630,7 +660,20 @@ __port_init(
                return IB_ERROR;\r
        }\r
 \r
-       cl_obj_insert_rel( &p_port->rel, &p_adapter->obj, &p_port->obj );\r
+       cl_status = cl_obj_insert_rel( &p_port->rel, &p_adapter->obj, &p_port->obj );\r
+       if( cl_status != CL_SUCCESS )\r
+       {\r
+               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                       ("cl_obj_insert_rel returned %s\n", cl_status_text[cl_status]) );\r
+               cl_obj_destroy( &p_port->obj );\r
+               return IB_ERROR;\r
+       }\r
+\r
+#if DBG\r
+       cl_atomic_inc( &p_port->ref[ref_init] );\r
+       IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_OBJ,\r
+               ("ref type %d ref_cnt %d\n", ref_init, p_port->obj.ref_cnt) );\r
+#endif\r
 \r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
        return IB_SUCCESS;\r
@@ -653,6 +696,8 @@ __port_destroying(
 \r
        __endpt_mgr_remove_all( p_port );\r
 \r
+       ipoib_port_resume( p_port );\r
+\r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
 }\r
 \r
@@ -1137,7 +1182,7 @@ __buf_mgr_get_recv(
        /* Reference the port object for the send. */\r
        if( p_desc )\r
        {\r
-               cl_obj_ref( &p_port->obj );\r
+               ipoib_port_ref( p_port, ref_get_recv );\r
                CL_ASSERT( p_desc->wr.wr_id == (uintn_t)p_desc );\r
 #if IPOIB_INLINE_RECV\r
                CL_ASSERT( p_desc->local_ds[0].vaddr ==\r
@@ -1181,8 +1226,7 @@ __buf_mgr_put_recv(
        /*\r
         * Dereference the port object since the receive is no longer outstanding.\r
         */\r
-       cl_obj_deref( &p_port->obj );\r
-\r
+       ipoib_port_deref( p_port, ref_get_recv );\r
        IPOIB_EXIT(  IPOIB_DBG_RECV );\r
 }\r
 \r
@@ -1327,7 +1371,7 @@ __recv_mgr_repost(
                        ("Port in invalid state.  Not reposting.\n") );\r
                return 0;\r
        }\r
-       cl_obj_ref( &p_port->obj );\r
+       ipoib_port_ref( p_port, ref_repost );\r
        cl_obj_unlock( &p_port->obj );\r
 \r
        while( p_port->recv_mgr.depth < p_port->p_adapter->params.rq_depth )\r
@@ -1382,8 +1426,7 @@ __recv_mgr_repost(
                }\r
        }\r
 \r
-       cl_obj_deref( &p_port->obj );\r
-\r
+       ipoib_port_deref( p_port, ref_repost );\r
        IPOIB_EXIT( IPOIB_DBG_RECV );\r
        return p_port->p_adapter->params.rq_low_watermark - p_port->recv_mgr.depth;\r
 }\r
@@ -1513,8 +1556,7 @@ __recv_cb(
        cl_qlist_init( &done_list );\r
        cl_qlist_init( &bad_list );\r
 \r
-       cl_obj_ref( &p_port->obj );\r
-\r
+       ipoib_port_ref( p_port, ref_recv_cb );\r
        for( i = 0; i < MAX_RECV_WC; i++ )\r
                wc[i].p_next = &wc[i + 1];\r
        wc[MAX_RECV_WC - 1].p_next = NULL;\r
@@ -1633,7 +1675,7 @@ __recv_cb(
        cl_perf_stop( &p_port->p_adapter->perf, RearmRecv );\r
        CL_ASSERT( status == IB_SUCCESS );\r
 \r
-       cl_obj_deref( &p_port->obj );\r
+       ipoib_port_deref( p_port, ref_recv_cb );\r
 \r
        cl_perf_stop( &p_port->p_adapter->perf, RecvCb );\r
 \r
@@ -1715,13 +1757,19 @@ __recv_get_endpts(
                        if( !*pp_src )\r
                        {\r
                                IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
-                                       ("ipoib_endpt_create returned %s\n",\r
-                                       p_port->p_adapter->p_ifc->get_err_str( status )) );\r
+                                       ("ipoib_endpt_create failed\n") );\r
                                return;\r
                        }\r
                        cl_perf_start( EndptInsert );\r
                        cl_obj_lock( &p_port->obj );\r
-                       __endpt_mgr_insert( p_port, mac, *pp_src );\r
+                       status = __endpt_mgr_insert( p_port, mac, *pp_src );\r
+                       if( status != IB_SUCCESS )\r
+                       {\r
+                               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                                       ("__endpt_mgr_insert returned %s\n",\r
+                                       p_port->p_adapter->p_ifc->get_err_str( status )) );\r
+                               return;\r
+                       }\r
                        cl_obj_unlock( &p_port->obj );\r
                        cl_perf_stop( &p_port->p_adapter->perf, EndptInsert );\r
                }\r
@@ -1816,7 +1864,7 @@ __recv_mgr_filter(
                        }\r
                        cl_qlist_insert_tail( p_bad_list, &p_desc->item.list_item );\r
                        /* Dereference the port object on behalf of the failed receive. */\r
-                       cl_obj_deref( &p_port->obj );\r
+                       ipoib_port_deref( p_port, ref_failed_recv_wc );\r
                        continue;\r
                }\r
 \r
@@ -1828,7 +1876,7 @@ __recv_mgr_filter(
                                ("Received ETH packet < min size\n") );\r
                        ipoib_inc_recv_stat( p_port->p_adapter, IP_STAT_ERROR, 0 );\r
                        cl_qlist_insert_tail( p_bad_list, &p_desc->item.list_item );\r
-                       cl_obj_deref( &p_port->obj );\r
+                       ipoib_port_deref( p_port, ref_recv_inv_len );\r
                        continue;\r
                }\r
 \r
@@ -1857,7 +1905,7 @@ __recv_mgr_filter(
                                 */\r
                                cl_qlist_insert_tail( p_bad_list, &p_desc->item.list_item );\r
                                /* Dereference the port object on behalf of the failed recv. */\r
-                               cl_obj_deref( &p_port->obj );\r
+                               ipoib_port_deref( p_port, ref_recv_loopback );\r
                                continue;\r
                        }\r
                }\r
@@ -1948,7 +1996,7 @@ __recv_mgr_filter(
                        ipoib_inc_recv_stat( p_port->p_adapter, IP_STAT_ERROR, 0 );\r
                        cl_qlist_insert_tail( p_bad_list, &p_desc->item.list_item );\r
                        /* Dereference the port object on behalf of the failed receive. */\r
-                       cl_obj_deref( &p_port->obj );\r
+                       ipoib_port_deref( p_port, ref_recv_filter );\r
                }\r
                else\r
                {\r
@@ -2255,16 +2303,24 @@ __recv_arp(
                 */\r
                *pp_src = ipoib_endpt_create( &p_ib_arp->src_hw.gid,\r
                        0, (p_ib_arp->src_hw.flags_qpn & CL_HTON32(0x00FFFFFF)) );\r
+\r
                if( !*pp_src )\r
                {\r
                        IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
-                               ("ipoib_endpt_create returned %s\n",\r
-                               p_port->p_adapter->p_ifc->get_err_str( status )) );\r
+                               ("ipoib_endpt_create failed\n") );\r
                        return status;\r
                }\r
 \r
                cl_obj_lock( &p_port->obj );\r
-               __endpt_mgr_insert( p_port, mac, *pp_src );\r
+               status = __endpt_mgr_insert( p_port, mac, *pp_src );\r
+               if( status != IB_SUCCESS )\r
+               {\r
+                       IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                               ("__endpt_mgr_insert return %s \n",\r
+                               p_port->p_adapter->p_ifc->get_err_str( status )) );\r
+                       return status;\r
+               }\r
+\r
                cl_obj_unlock( &p_port->obj );\r
        }\r
 \r
@@ -3774,7 +3830,7 @@ __send_cb(
 \r
        p_port = (ipoib_port_t*)cq_context;\r
 \r
-       cl_obj_ref( &p_port->obj );\r
+       ipoib_port_ref( p_port, ref_send_cb );\r
 \r
        for( i = 0; i < MAX_SEND_WC; i++ )\r
                wc[i].p_next = &wc[i + 1];\r
@@ -3873,7 +3929,7 @@ __send_cb(
        ipoib_port_resume( p_port );\r
        cl_perf_stop( &p_port->p_adapter->perf, PortResume );\r
        \r
-       cl_obj_deref( &p_port->obj );\r
+       ipoib_port_deref( p_port, ref_send_cb );\r
 \r
        cl_perf_stop( &p_port->p_adapter->perf, SendCb );\r
        cl_perf_update_ctr( &p_port->p_adapter->perf, SendCompBundle );\r
@@ -4240,12 +4296,14 @@ __endpt_mgr_get_by_lid(
 }\r
 \r
 \r
-inline void\r
+inline ib_api_status_t\r
 __endpt_mgr_insert_locked(\r
        IN                              ipoib_port_t* const                     p_port,\r
        IN              const   mac_addr_t                                      mac,\r
        IN                              ipoib_endpt_t* const            p_endpt )\r
 {\r
+       ib_api_status_t status;\r
+\r
        IPOIB_ENTER( IPOIB_DBG_ENDPT );\r
 \r
        IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_ENDPT,\r
@@ -4261,21 +4319,22 @@ __endpt_mgr_insert_locked(
        }\r
        /* __endpt_mgr_insert expects *one* reference to be held when being called. */\r
        cl_atomic_inc( &p_port->endpt_rdr );\r
-       __endpt_mgr_insert( p_port, mac, p_endpt );\r
+       status= __endpt_mgr_insert( p_port, mac, p_endpt );\r
        cl_atomic_dec( &p_port->endpt_rdr );\r
        cl_obj_unlock( &p_port->obj );\r
 \r
-       IPOIB_EXIT( IPOIB_DBG_ENDPT );\r
+       return status;\r
 }\r
 \r
 \r
-void\r
+inline ib_api_status_t\r
 __endpt_mgr_insert(\r
        IN                              ipoib_port_t* const                     p_port,\r
        IN              const   mac_addr_t                                      mac,\r
        IN                              ipoib_endpt_t* const            p_endpt )\r
 {\r
        uint64_t                key;\r
+       cl_status_t             cl_status;\r
        cl_map_item_t   *p_qitem;\r
        cl_fmap_item_t  *p_fitem;\r
 \r
@@ -4286,9 +4345,21 @@ __endpt_mgr_insert(
                ;\r
 \r
        /* Link the endpoint to the port. */\r
-       cl_obj_insert_rel_parent_locked(\r
+       cl_status = cl_obj_insert_rel_parent_locked(\r
                &p_endpt->rel, &p_port->obj, &p_endpt->obj );\r
 \r
+       if( cl_status != CL_SUCCESS )\r
+       {\r
+               cl_obj_destroy( &p_endpt->obj );\r
+               return IB_INVALID_STATE;\r
+       }\r
+\r
+#if DBG\r
+       cl_atomic_inc( &p_port->ref[ref_endpt_track] );\r
+       IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_OBJ,\r
+               ("ref  type %d ref_cnt %d\n", ref_endpt_track, p_port->obj.ref_cnt) );\r
+#endif\r
+\r
        p_endpt->mac = mac;\r
        key = 0;\r
        cl_memcpy( &key, &mac, sizeof(mac_addr_t) );\r
@@ -4306,6 +4377,7 @@ __endpt_mgr_insert(
        }\r
 \r
        IPOIB_EXIT( IPOIB_DBG_ENDPT );\r
+       return IB_SUCCESS;\r
 }\r
 \r
 \r
@@ -4348,10 +4420,10 @@ __endpt_mgr_add_bcast(
 \r
        /* Add the broadcast endpoint to the endpoint map. */\r
        cl_memset( &bcast_mac, 0xFF, sizeof(bcast_mac) );\r
-       __endpt_mgr_insert_locked( p_port, bcast_mac, p_endpt );\r
+       status = __endpt_mgr_insert_locked( p_port, bcast_mac, p_endpt );\r
 \r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
-       return IB_SUCCESS;\r
+       return status;\r
 }\r
 \r
 \r
@@ -4397,6 +4469,12 @@ ipoib_port_remove_endpt(
 \r
                cl_obj_unlock( &p_port->obj );\r
                cl_obj_destroy( &p_endpt->obj );\r
+#if DBG\r
+               cl_atomic_dec( &p_port->ref[ref_endpt_track] );\r
+               IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_OBJ,\r
+                       ("ref type %d ref_cnt %d\n", ref_endpt_track, p_port->obj.ref_cnt) );\r
+#endif\r
+\r
        }\r
        else\r
        {\r
@@ -4506,7 +4584,7 @@ ipoib_port_up(
        query.pfn_query_cb = __port_info_cb;\r
 \r
        /* reference the object for the multicast query. */\r
-       cl_obj_ref( &p_port->obj );\r
+       ipoib_port_ref( p_port, ref_port_up );\r
 \r
        status = p_port->p_adapter->p_ifc->query(\r
                p_port->p_adapter->h_al, &query, &p_port->ib_mgr.h_query );\r
@@ -4514,7 +4592,7 @@ ipoib_port_up(
        {\r
                KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );\r
                ipoib_set_inactive( p_port->p_adapter );\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_port_up );\r
                IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
                        ("ib_query returned %s\n", \r
                        p_port->p_adapter->p_ifc->get_err_str( status )) );\r
@@ -4567,13 +4645,20 @@ __endpt_mgr_add_local(
 \r
        /* __endpt_mgr_insert expects *one* reference to be held. */\r
        cl_atomic_inc( &p_port->endpt_rdr );\r
-       __endpt_mgr_insert( p_port, p_port->p_adapter->params.conf_mac, p_endpt );\r
+       status = __endpt_mgr_insert( p_port, p_port->p_adapter->params.conf_mac, p_endpt );\r
        cl_atomic_dec( &p_port->endpt_rdr );\r
+       if( status != IB_SUCCESS )\r
+       {\r
+               IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                       ("__endpt_mgr_insert for local endpoint returned %s\n",\r
+                       p_port->p_adapter->p_ifc->get_err_str( status )) );\r
+               return status;\r
+       }\r
 \r
        p_port->p_local_endpt = p_endpt;\r
 \r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
-       return IB_SUCCESS;\r
+       return status;\r
 }\r
 \r
 \r
@@ -4674,7 +4759,7 @@ done:
                p_port->p_adapter->p_ifc->put_mad( p_query_rec->p_result_mad );\r
 \r
        /* Release the reference taken when issuing the port info query. */\r
-       cl_obj_deref( &p_port->obj );\r
+       ipoib_port_deref( p_port, ref_port_info_cb );\r
 \r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
 }\r
@@ -4711,13 +4796,13 @@ __port_get_bcast(
        query.pfn_query_cb = __bcast_get_cb;\r
 \r
        /* reference the object for the multicast query. */\r
-       cl_obj_ref( &p_port->obj );\r
+       ipoib_port_ref( p_port, ref_get_bcast );\r
 \r
        status = p_port->p_adapter->p_ifc->query(\r
                p_port->p_adapter->h_al, &query, &p_port->ib_mgr.h_query );\r
        if( status != IB_SUCCESS )\r
        {\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_get_bcast );\r
                IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
                        ("ib_query returned %s\n", \r
                        p_port->p_adapter->p_ifc->get_err_str( status )) );\r
@@ -4796,7 +4881,7 @@ done:
                p_port->p_adapter->p_ifc->put_mad( p_query_rec->p_result_mad );\r
 \r
        /* Release the reference taken when issuing the member record query. */\r
-       cl_obj_deref( &p_port->obj );\r
+       ipoib_port_deref( p_port, ref_bcast_get_cb );\r
 \r
        IPOIB_EXIT( IPOIB_DBG_MCAST );\r
 }\r
@@ -4855,13 +4940,13 @@ __port_join_bcast(
        }\r
 \r
        /* reference the object for the multicast join request. */\r
-       cl_obj_ref( &p_port->obj );\r
+       ipoib_port_ref( p_port, ref_join_bcast );\r
 \r
        status = p_port->p_adapter->p_ifc->join_mcast(\r
                p_port->ib_mgr.h_qp, &mcast_req );\r
        if( status != IB_SUCCESS )\r
        {\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_bcast_join_failed );\r
                IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
                        ("ib_join_mcast returned %s\n", \r
                        p_port->p_adapter->p_ifc->get_err_str( status )) );\r
@@ -4915,12 +5000,12 @@ __port_create_bcast(
        mcast_req.pkey_index = 0;\r
 \r
        /* reference the object for the multicast join request. */\r
-       cl_obj_ref( &p_port->obj );\r
+       ipoib_port_ref( p_port, ref_join_bcast );\r
 \r
        status = p_port->p_adapter->p_ifc->join_mcast( p_port->ib_mgr.h_qp, &mcast_req );\r
        if( status != IB_SUCCESS )\r
        {\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_bcast_create_failed );\r
                IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
                        ("ib_join_mcast returned %s\n", \r
                        p_port->p_adapter->p_ifc->get_err_str( status )) );\r
@@ -5011,7 +5096,7 @@ __bcast_cb(
                        p_port->p_adapter->p_ifc->leave_mcast( p_mcast_rec->h_mcast, NULL );\r
 \r
                KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_bcast_inv_state );\r
                IPOIB_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,\r
                        ("Invalid state - Aborting.\n") );\r
                return;\r
@@ -5056,7 +5141,7 @@ __bcast_cb(
                        ipoib_set_inactive( p_port->p_adapter );\r
                        KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );\r
                }\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_bcast_req_failed );\r
                IPOIB_EXIT( IPOIB_DBG_INIT );\r
                return;\r
        }\r
@@ -5085,7 +5170,7 @@ err:
                /* Flag the adapter as hung. */\r
                p_port->p_adapter->hung = TRUE;\r
                KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_bcast_error );\r
                IPOIB_EXIT( IPOIB_DBG_INIT );\r
                return;\r
        }\r
@@ -5105,7 +5190,7 @@ err:
        ipoib_set_active( p_port->p_adapter );\r
 \r
        KeSetEvent( &p_port->sa_event, EVENT_INCREMENT, FALSE );\r
-       cl_obj_deref( &p_port->obj );\r
+       ipoib_port_deref( p_port, ref_join_bcast );\r
        IPOIB_EXIT( IPOIB_DBG_INIT );\r
 }\r
 \r
@@ -5277,15 +5362,22 @@ ipoib_port_join_mcast(
                return IB_INSUFFICIENT_MEMORY;\r
        }\r
 \r
-       __endpt_mgr_insert_locked( p_port, mac, p_endpt );\r
+       status = __endpt_mgr_insert_locked( p_port, mac, p_endpt );\r
+       if( status != IB_SUCCESS )\r
+       {\r
+               IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+                       ("__endpt_mgr_insert_locked returned %s\n", \r
+                       p_port->p_adapter->p_ifc->get_err_str( status )) );\r
+               return status;\r
+       }\r
 \r
        /* reference the object for the multicast join request. */\r
-       cl_obj_ref( &p_port->obj );\r
+       ipoib_port_ref( p_port, ref_join_mcast );\r
 \r
        status = p_port->p_adapter->p_ifc->join_mcast( p_port->ib_mgr.h_qp, &mcast_req );\r
        if( status != IB_SUCCESS )\r
        {\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_mcast_join_failed );\r
                IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
                        ("ib_join_mcast returned %s\n", \r
                        p_port->p_adapter->p_ifc->get_err_str( status )) );\r
@@ -5317,7 +5409,7 @@ __mcast_cb(
                if( p_mcast_rec->status == IB_SUCCESS )\r
                        p_port->p_adapter->p_ifc->leave_mcast( p_mcast_rec->h_mcast, NULL );\r
 \r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_mcast_inv_state );\r
                IPOIB_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,\r
                        ("Invalid state - Aborting.\n") );\r
                return;\r
@@ -5331,7 +5423,7 @@ __mcast_cb(
                        p_port->p_adapter->p_ifc->get_err_str( p_mcast_rec->status )) );\r
                /* Flag the adapter as hung. */\r
                p_port->p_adapter->hung =TRUE;\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_mcast_req_failed );\r
                IPOIB_EXIT( IPOIB_DBG_MCAST );\r
                return;\r
        }\r
@@ -5350,7 +5442,7 @@ __mcast_cb(
                IPOIB_PRINT(TRACE_LEVEL_WARNING, IPOIB_DBG_ERROR,\r
                        ("Failed to find endpoint for update.\n") );\r
                p_port->p_adapter->p_ifc->leave_mcast( p_mcast_rec->h_mcast, NULL );\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_mcast_no_endpt );\r
                IPOIB_EXIT( IPOIB_DBG_MCAST );\r
                return;\r
        }\r
@@ -5369,7 +5461,7 @@ __mcast_cb(
                        p_port->p_adapter->p_ifc->get_err_str( status )) );\r
                /* Flag the adapter as hung. */\r
                p_port->p_adapter->hung = TRUE;\r
-               cl_obj_deref( &p_port->obj );\r
+               ipoib_port_deref( p_port, ref_mcast_av_failed );\r
                IPOIB_EXIT( IPOIB_DBG_MCAST );\r
                return;\r
        }\r
@@ -5389,7 +5481,7 @@ __mcast_cb(
        /* Try to send all pending sends. */\r
        ipoib_port_resume( p_port );\r
 \r
-       cl_obj_deref( &p_port->obj );\r
+       ipoib_port_deref( p_port, ref_join_mcast );\r
 \r
        IPOIB_EXIT( IPOIB_DBG_MCAST );\r
 }\r
index b693ccc76bdbb079313d22fce219b6273f696556..31ee612fd280ff66fa119d5578d499418643f1e6 100644 (file)
@@ -494,10 +494,14 @@ typedef struct _ipoib_port
 \r
        ipoib_endpt_t                   *p_local_endpt;\r
 \r
+#if DBG\r
+       atomic32_t                              ref[ref_array_size];\r
+#endif\r
+\r
        atomic32_t                              endpt_rdr;\r
 \r
        atomic32_t                              hdr_idx;\r
-       ipoib_hdr_t                             hdr[1];\r
+       ipoib_hdr_t                             hdr[1]; /* Must be last! */\r
 \r
 }      ipoib_port_t;\r
 /*\r
@@ -592,4 +596,13 @@ ipoib_mac_to_gid(
        IN              const   mac_addr_t                                      mac,\r
                OUT                     ib_gid_t*                                       p_gid );\r
 \r
+inline void ipoib_port_ref(\r
+       IN                              ipoib_port_t *                          p_port, \r
+       IN                              int                                             type);\r
+\r
+inline void ipoib_port_deref(\r
+       IN                              ipoib_port_t *                          p_port,\r
+       IN                              int                                             type);\r
+\r
+\r
 #endif /* _IPOIB_PORT_H_ */\r