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 #if !defined( __AL_MAD_POOL_H__ )
\r
34 #define __AL_MAD_POOL_H__
\r
36 #include <complib/cl_qlist.h>
\r
37 #include <iba/ib_al.h>
\r
38 #include "al_common.h"
\r
41 typedef struct _al_pool
\r
43 al_obj_t obj; /* Child of ib_al_handle_t */
\r
44 #if defined( CL_KERNEL )
\r
45 NPAGED_LOOKASIDE_LIST mad_stack;
\r
47 cl_qlist_t mad_stack;
\r
49 cl_qlist_t key_list;
\r
53 #if defined( CL_KERNEL )
\r
54 NPAGED_LOOKASIDE_LIST mad_send_pool;
\r
55 NPAGED_LOOKASIDE_LIST mad_rmpp_pool;
\r
57 cl_qpool_t mad_send_pool;
\r
58 cl_qpool_t mad_rmpp_pool;
\r
66 * Pool key type used to distinguish between pool_keys allocated by the user
\r
67 * and those that reference AL's internal MAD pool_key.
\r
69 typedef enum _al_key_type
\r
78 typedef struct _al_pool_key
\r
80 al_obj_t obj; /* Not a child object. */
\r
81 /* Parent of mad_reg_t */
\r
85 * Pool keys can be destroyed either by deregistering them, destroying
\r
86 * the associated pool, or destroying the associated PD. We track the
\r
87 * pool key with the AL instance in order to synchronize destruction.
\r
89 boolean_t in_al_list;
\r
90 ib_al_handle_t h_al;
\r
91 cl_list_item_t al_item; /* Chain in ib_al_t for dereg */
\r
92 cl_list_item_t pool_item; /* Chain in al_pool_t for grow */
\r
94 ib_pool_handle_t h_pool;
\r
96 ib_pd_handle_t h_pd;
\r
98 ib_mr_handle_t h_mr;
\r
102 /* Number of MADs currently removed from pool using this key. */
\r
103 atomic32_t mad_cnt;
\r
105 /* For alias keys, maintain a reference to the actual pool key. */
\r
106 ib_pool_key_t pool_key;
\r
113 IN const ib_pool_handle_t h_pool,
\r
114 IN const ib_pd_handle_t h_pd,
\r
115 OUT ib_pool_key_t* const pp_pool_key );
\r
117 /* Deregister a MAD pool key if it is of the expected type. */
\r
120 IN const ib_pool_key_t pool_key,
\r
121 IN const al_key_type_t expected_type );
\r
125 (* __ptr64 pfn_mad_dbg_t)(void);
\r
127 typedef struct _al_mad_element
\r
130 * List item used to track free MADs by the MAD pool. Also used by
\r
131 * the SMI and MAD QPs to track received MADs.
\r
133 cl_list_item_t list_item;
\r
134 ib_al_handle_t h_al; /* Track out-of-pool MAD owner */
\r
135 cl_list_item_t al_item; /* Out-of-pool MAD owner chain */
\r
136 ib_mad_element_t element;
\r
137 ib_pool_key_t pool_key; /* For getting mads for RMPP ACK */
\r
138 ib_local_ds_t grh_ds; /* GRH + 256 byte buffer. */
\r
139 ib_local_ds_t mad_ds; /* Registered 256-byte buffer. */
\r
140 ib_mad_t *p_al_mad_buf; /* Allocated send/recv buffer. */
\r
141 #if defined( CL_KERNEL )
\r
142 uint8_t mad_buf[MAD_BLOCK_GRH_SIZE];
\r
145 ib_mad_element_t* __ptr64 h_proxy_element; /* For user-mode support */
\r
147 } al_mad_element_t;
\r
153 OUT ib_mad_element_t *p_mad_element,
\r
154 IN const size_t buf_size );
\r
158 /* We don't have MAD array structures in the Windows kernel. */
\r
159 #if !defined( CL_KERNEL )
\r
160 typedef struct _mad_array
\r
162 al_obj_t obj; /* Child of al_pool_t */
\r
163 ib_pool_handle_t h_pool;
\r
164 size_t sizeof_array;
\r
171 typedef struct _mad_item
\r
173 al_mad_element_t al_mad_element;
\r
174 #if defined( CL_KERNEL )
\r
175 ib_pool_key_t pool_key;
\r
177 mad_array_t* p_mad_array;
\r
185 * Work request structure to use when posting sends.
\r
187 typedef struct _al_mad_wr
\r
189 cl_list_item_t list_item;
\r
191 uint32_t client_id;
\r
192 ib_net64_t client_tid;
\r
195 * Work request used when sending MADs. This permits formatting the
\r
196 * work request once and re-using it when issuing retries.
\r
198 ib_send_wr_t send_wr;
\r
205 * Structure used to track an outstanding send request.
\r
207 typedef struct _al_mad_send
\r
209 cl_pool_item_t pool_item;
\r
210 ib_mad_element_t *p_send_mad;
\r
211 ib_av_handle_t h_av;
\r
213 al_mad_wr_t mad_wr;
\r
216 * Received MAD in response to a send. This is not set until
\r
217 * the entire response has been received.
\r
219 ib_mad_element_t *p_resp_mad;
\r
221 /* Absolute time that the request should be retried. */
\r
222 uint64_t retry_time;
\r
224 /* Delay, in milliseconds, to add before the next retry. */
\r
227 /* Number of times that the request can be retried. */
\r
228 uint32_t retry_cnt;
\r
229 boolean_t canceled; /* indicates if send was canceled */
\r
232 * SAR tracking information.
\r
234 boolean_t uses_rmpp;
\r
235 uint32_t ack_seg; /* last segment number ack'ed*/
\r
236 uint32_t cur_seg; /* current segment to send */
\r
237 uint32_t seg_limit; /* max. segment to send */
\r
238 uint32_t total_seg; /* total segments to send */
\r
245 * Structure used to track receiving an RMPP MAD.
\r
247 typedef struct _al_mad_rmpp
\r
249 cl_pool_item_t pool_item;
\r
251 boolean_t inactive; /* used to time out reassembly */
\r
253 uint32_t expected_seg;/* next segment to receive */
\r
254 uint32_t seg_limit; /* upper bound of recv window */
\r
255 ib_mad_element_t *p_mad_element;/* reassembled recv */
\r
261 ib_mad_send_handle_t
\r
263 IN const al_mad_element_t *p_mad_element );
\r
268 IN ib_mad_send_handle_t h_mad_send );
\r
273 IN const al_mad_element_t *p_mad_element );
\r
278 IN al_mad_rmpp_t *p_rmpp );
\r
281 #endif // __AL_MAD_POOL_H__
\r