2 * Copyright (c) 2005 SilverStorm Technologies. All rights reserved.
\r
3 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
\r
5 * This software is available to you under the OpenIB.org BSD license
\r
8 * Redistribution and use in source and binary forms, with or
\r
9 * without modification, are permitted provided that the following
\r
10 * conditions are met:
\r
12 * - Redistributions of source code must retain the above
\r
13 * copyright notice, this list of conditions and the following
\r
16 * - Redistributions in binary form must reproduce the above
\r
17 * copyright notice, this list of conditions and the following
\r
18 * disclaimer in the documentation and/or other materials
\r
19 * provided with the distribution.
\r
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
25 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
26 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
33 #include <iba/ib_al.h>
\r
36 #include "al_debug.h"
\r
38 #include "al_res_mgr.h"
\r
39 #include "al_verbs.h"
\r
45 IN struct _al_obj *p_obj );
\r
50 IN al_obj_t *p_obj );
\r
56 IN void* const p_object,
\r
58 OUT cl_pool_item_t** const pp_pool_item )
\r
60 ib_api_status_t status;
\r
61 ib_av_handle_t h_av;
\r
63 UNUSED_PARAM( context );
\r
65 h_av = (ib_av_handle_t)p_object;
\r
66 cl_memclr( h_av, sizeof( ib_av_t ) );
\r
68 construct_al_obj( &h_av->obj, AL_OBJ_TYPE_H_AV );
\r
69 status = init_al_obj( &h_av->obj, NULL, FALSE, NULL,
\r
70 __cleanup_av, __return_av );
\r
71 if( status != IB_SUCCESS )
\r
76 *pp_pool_item = &((ib_av_handle_t)p_object)->obj.pool_item;
\r
78 /* Release the reference taken in init_al_obj. */
\r
79 deref_al_obj( &h_av->obj );
\r
87 IN const cl_pool_item_t* const p_pool_item,
\r
92 UNUSED_PARAM( context );
\r
94 p_obj = PARENT_STRUCT( p_pool_item, al_obj_t, pool_item );
\r
97 * The AV is being totally destroyed. Modify the free_cb to destroy the
\r
100 p_obj->pfn_free = (al_pfn_free_t)destroy_al_obj;
\r
101 ref_al_obj( p_obj );
\r
102 p_obj->pfn_destroy( p_obj, NULL );
\r
109 IN const ib_pd_handle_t h_pd,
\r
110 IN const ib_av_attr_t* const p_av_attr,
\r
111 OUT ib_av_handle_t* const ph_av,
\r
112 IN OUT ci_umv_buf_t* const p_umv_buf )
\r
114 ib_api_status_t status;
\r
115 ib_av_handle_t h_av;
\r
119 if( !p_av_attr || !ph_av )
\r
121 CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );
\r
122 return IB_INVALID_PARAMETER;
\r
125 /* Get an AV tracking structure. */
\r
128 return IB_INSUFFICIENT_MEMORY;
\r
130 status = attach_al_obj( &h_pd->obj, &h_av->obj );
\r
131 if( status != IB_SUCCESS )
\r
133 h_av->obj.pfn_destroy( &h_av->obj, NULL );
\r
137 /* Create the address vector. */
\r
138 status = verbs_create_av( h_pd, p_av_attr, h_av );
\r
139 if( status != IB_SUCCESS )
\r
141 h_av->obj.pfn_destroy( &h_av->obj, NULL );
\r
145 /* keep a copy of the av for special qp access */
\r
146 h_av->av_attr = *p_av_attr;
\r
156 IN const ib_av_handle_t h_av )
\r
158 CL_ENTER( AL_DBG_AV, g_al_dbg_lvl );
\r
160 if( AL_OBJ_INVALID_HANDLE( h_av, AL_OBJ_TYPE_H_AV ) )
\r
162 CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_AV_HANDLE\n") );
\r
163 return IB_INVALID_AV_HANDLE;
\r
166 ref_al_obj( &h_av->obj );
\r
167 h_av->obj.pfn_destroy( &h_av->obj, NULL );
\r
169 CL_EXIT( AL_DBG_AV, g_al_dbg_lvl );
\r
177 IN struct _al_obj *p_obj )
\r
179 ib_api_status_t status;
\r
180 ib_av_handle_t h_av;
\r
182 CL_ASSERT( p_obj );
\r
183 h_av = PARENT_STRUCT( p_obj, ib_av_t, obj );
\r
185 /* Destroy the AV. */
\r
186 if( verbs_check_av( h_av ) )
\r
188 status = verbs_destroy_av(h_av);
\r
189 CL_ASSERT( status == IB_SUCCESS );
\r
191 h_av->obj.hdl = AL_INVALID_HANDLE;
\r
193 h_av->h_ci_av = NULL;
\r
201 IN al_obj_t *p_obj )
\r
203 ib_av_handle_t h_av;
\r
205 h_av = PARENT_STRUCT( p_obj, ib_av_t, obj );
\r
206 reset_al_obj( p_obj );
\r
214 IN const ib_av_handle_t h_av,
\r
215 OUT ib_av_attr_t* const p_av_attr,
\r
216 OUT ib_pd_handle_t* const ph_pd )
\r
218 return query_av( h_av, p_av_attr, ph_pd, NULL );
\r
225 IN const ib_av_handle_t h_av,
\r
226 OUT ib_av_attr_t* const p_av_attr,
\r
227 OUT ib_pd_handle_t* const ph_pd,
\r
228 IN OUT ci_umv_buf_t* const p_umv_buf )
\r
230 ib_api_status_t status;
\r
232 CL_ENTER( AL_DBG_AV, g_al_dbg_lvl );
\r
234 if( AL_OBJ_INVALID_HANDLE( h_av, AL_OBJ_TYPE_H_AV ) )
\r
236 CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_AV_HANDLE\n") );
\r
237 return IB_INVALID_AV_HANDLE;
\r
239 if( !p_av_attr || !ph_pd )
\r
241 CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );
\r
242 return IB_INVALID_PARAMETER;
\r
245 status = verbs_query_av(h_av, p_av_attr, ph_pd);
\r
247 /* Record AL's PD handle. */
\r
248 if( status == IB_SUCCESS )
\r
250 *ph_pd = PARENT_STRUCT( h_av->obj.p_parent_obj, ib_pd_t, obj );
\r
251 h_av->av_attr = *p_av_attr;
\r
254 CL_EXIT( AL_DBG_AV, g_al_dbg_lvl );
\r
262 IN const ib_av_handle_t h_av,
\r
263 IN const ib_av_attr_t* const p_av_mod )
\r
265 return modify_av( h_av, p_av_mod, NULL );
\r
271 IN const ib_av_handle_t h_av,
\r
272 IN const ib_av_attr_t* const p_av_mod,
\r
273 IN OUT ci_umv_buf_t* const p_umv_buf )
\r
275 ib_api_status_t status;
\r
277 CL_ENTER( AL_DBG_AV, g_al_dbg_lvl );
\r
279 if( AL_OBJ_INVALID_HANDLE( h_av, AL_OBJ_TYPE_H_AV ) )
\r
281 CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_AV_HANDLE\n") );
\r
282 return IB_INVALID_AV_HANDLE;
\r
286 CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, ("IB_INVALID_PARAMETER\n") );
\r
287 return IB_INVALID_PARAMETER;
\r
290 status = verbs_modify_av(h_av, p_av_mod);
\r
292 /* Record av for special qp access */
\r
293 if( status == IB_SUCCESS )
\r
295 h_av->av_attr = *p_av_mod;
\r
298 CL_EXIT( AL_DBG_AV, g_al_dbg_lvl );
\r