]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[IBAL] Cleanup user-mode __get_mad_element for better legibility.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 7 Apr 2006 04:36:53 +0000 (04:36 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 7 Apr 2006 04:36:53 +0000 (04:36 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@292 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/core/al/user/al_mad_pool.c

index 231f42745460beb4f96c02f442245ffe6cf40dcf..0ec4e156f1d584a0a1b85ad37dccdd700d443475 100644 (file)
@@ -191,16 +191,20 @@ ib_create_mad_pool(
 \r
        /* Save the pool parameters.  Set grow_size to min for initialization. */\r
        h_pool->max = max;\r
-       h_pool->grow_size = min;\r
-\r
-       /* Grow the pool to the minimum size. */\r
-       status = __grow_mad_pool( h_pool, NULL );\r
-       if( status != IB_SUCCESS )\r
+       if( min )\r
        {\r
-               h_pool->obj.pfn_destroy( &h_pool->obj, NULL );\r
-               CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl,\r
-                       ("grow_mad_pool failed with status %s.\n", ib_get_err_str(status)) );\r
-               return status;\r
+               h_pool->grow_size = min;\r
+\r
+               /* Grow the pool to the minimum size. */\r
+               status = __grow_mad_pool( h_pool, NULL );\r
+               if( status != IB_SUCCESS )\r
+               {\r
+                       h_pool->obj.pfn_destroy( &h_pool->obj, NULL );\r
+                       CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl,\r
+                               ("grow_mad_pool failed with status %s.\n",\r
+                               ib_get_err_str(status)) );\r
+                       return status;\r
+               }\r
        }\r
 \r
        /* Save the grow_size for subsequent allocations. */\r
@@ -771,9 +775,8 @@ __get_mad_element(
 {\r
        al_pool_key_t*                  p_pool_key;\r
        ib_pool_handle_t                h_pool;\r
-       cl_list_item_t*                 p_mad_item;\r
-       al_mad_element_t*               p_mad_element;\r
-       mad_item_t*                             p_mad;\r
+       cl_list_item_t*                 p_item;\r
+       mad_item_t*                             p_mad_item;\r
        ib_api_status_t                 status;\r
 \r
        CL_ENTER( AL_DBG_MAD_POOL, g_al_dbg_lvl );\r
@@ -786,14 +789,13 @@ __get_mad_element(
 \r
        /* Obtain a MAD item from the stack. */\r
        cl_spinlock_acquire( &h_pool->obj.lock );\r
-       p_mad_item = cl_qlist_remove_head( &h_pool->mad_stack );\r
-       p_mad_element = PARENT_STRUCT( p_mad_item, al_mad_element_t, list_item );\r
-       p_mad = PARENT_STRUCT( p_mad_element, mad_item_t, al_mad_element );\r
-       if( p_mad_item == cl_qlist_end( &h_pool->mad_stack ) )\r
+       p_item = cl_qlist_remove_head( &h_pool->mad_stack );\r
+       p_mad_item = PARENT_STRUCT( p_item, mad_item_t, al_mad_element.list_item );\r
+       if( p_item == cl_qlist_end( &h_pool->mad_stack ) )\r
        {\r
                /* The stack was empty.  Grow the pool and obtain a new item. */\r
                cl_spinlock_release( &h_pool->obj.lock );\r
-               status = __grow_mad_pool( h_pool, &p_mad );\r
+               status = __grow_mad_pool( h_pool, &p_mad_item );\r
                if( status != IB_SUCCESS )\r
                {\r
                        CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl,\r
@@ -807,16 +809,13 @@ __get_mad_element(
                cl_spinlock_release( &h_pool->obj.lock );\r
        }\r
 \r
-       if( p_mad == NULL )\r
-               return IB_INSUFFICIENT_RESOURCES;\r
-\r
        /* Get the local data segment information for this pool key. */\r
-       status = __init_mad_element( p_pool_key, p_mad );\r
+       status = __init_mad_element( p_pool_key, p_mad_item );\r
        if( status != IB_SUCCESS )\r
        {\r
                cl_spinlock_acquire( &h_pool->obj.lock );\r
                cl_qlist_insert_head( &h_pool->mad_stack,\r
-                       &p_mad_element->list_item );\r
+                       &p_mad_item->al_mad_element.list_item );\r
                cl_spinlock_release( &h_pool->obj.lock );\r
 \r
                CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl,\r
@@ -826,11 +825,11 @@ __get_mad_element(
        }\r
 \r
        /* Hold a reference on the array while a MAD element is removed. */\r
-       ref_al_obj( &p_mad->p_mad_array->obj );\r
+       ref_al_obj( &p_mad_item->p_mad_array->obj );\r
 \r
-       p_mad->al_mad_element.pool_key = (ib_pool_key_t)pool_key;\r
+       p_mad_item->al_mad_element.pool_key = (ib_pool_key_t)pool_key;\r
        /* Return the MAD element. */\r
-       *pp_mad_element = &p_mad->al_mad_element;\r
+       *pp_mad_element = &p_mad_item->al_mad_element;\r
 \r
        CL_EXIT( AL_DBG_MAD_POOL, g_al_dbg_lvl );\r
        return IB_SUCCESS;\r
@@ -1004,11 +1003,7 @@ __grow_mad_pool(
 \r
        /* Determine if the pool is allowed to grow. */\r
        if( h_pool->grow_size == 0 )\r
-       {\r
-               /* Cannot grow the pool.  Clear the p_mad_item if one was provided. */\r
-               if( pp_mad_item != NULL) *pp_mad_item = NULL;\r
-               return IB_SUCCESS;\r
-       }\r
+               return IB_INSUFFICIENT_RESOURCES;\r
 \r
        /* Lock the pool. */\r
        cl_spinlock_acquire( &h_pool->obj.lock );\r