Print this page
2976 remove useless offsetof() macros
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/ib/clients/of/sol_ofs/sol_cma.h
+++ new/usr/src/uts/common/sys/ib/clients/of/sol_ofs/sol_cma.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
23 23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 26 #ifndef _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_CMA_H
27 27 #define _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_CMA_H
28 28
29 29 #ifdef __cplusplus
30 30 extern "C" {
31 31 #endif
32 32
33 +#include <sys/sysmacros.h>
33 34
34 35 #include <sys/ib/clients/of/sol_ofs/sol_ofs_common.h>
35 36 #include <sys/ib/clients/of/rdma/rdma_cm.h>
36 37 #include <sys/ib/clients/of/sol_ofs/sol_ib_cma.h> /* Transport Specific */
37 38
38 -#if !defined(offsetof)
39 -#define offsetof(s, m) (size_t)(&(((s *)0)->m))
40 -#endif
41 39
42 40 #define IS_UDP_CMID(idp) ((idp)->ps == RDMA_PS_UDP || \
43 41 (idp)->ps == RDMA_PS_IPOIB)
44 42 #define IS_VALID_SOCKADDR(sockaddrp) \
45 43 ((sockaddrp)->sa_family == AF_INET || \
46 44 (sockaddrp)->sa_family == AF_INET6)
47 45
48 46 /*
49 47 * Global structure which contains information about all
50 48 * CMIDs, which have called rdma_listen().
51 49 */
52 50 typedef struct sol_cma_glbl_listen_s {
53 51 avl_node_t cma_listen_node;
54 52
55 53 uint64_t cma_listen_chan_sid;
56 54 void *cma_listen_clnt_hdl;
57 55 void *cma_listen_svc_hdl;
58 56 genlist_t cma_listen_chan_list;
59 57 } sol_cma_glbl_listen_t;
60 58
61 59 /* State of the RDMA-CM ID */
62 60 typedef enum {
63 61 SOL_CMA_CHAN_IDLE,
64 62 SOL_CMA_CHAN_BOUND,
65 63 SOL_CMA_CHAN_ADDR_QUERY,
66 64 SOL_CMA_CHAN_ADDR_BOUND,
67 65 SOL_CMA_CHAN_ADDR_RESLVD,
68 66 SOL_CMA_CHAN_ROUTE_QUERY,
69 67 SOL_CMA_CHAN_ROUTE_RESLVD,
70 68
71 69 SOL_CMA_CHAN_EVENT_NOTIFIED,
72 70
73 71 SOL_CMA_CHAN_CONNECT,
74 72 SOL_CMA_CHAN_LISTEN,
75 73 SOL_CMA_CHAN_DISCONNECT,
76 74 SOL_CMA_CHAN_ACCEPT,
77 75 SOL_CMA_CHAN_REJECT,
78 76
79 77 SOL_CMA_CHAN_DESTROYING,
80 78 SOL_CMA_CHAN_DESTROY_PENDING,
81 79 SOL_CMA_CHAN_DESTROY_WAIT,
82 80
83 81 SOL_CMA_CHAN_HCA_DOWN,
84 82 SOL_CMA_CHAN_PORT_DOWN
85 83 } cma_chan_state_t;
86 84
87 85 typedef struct listen_info_s {
88 86 uint8_t listen_is_root;
89 87
90 88 /* For Root CMIDs, pointer to global listen info */
91 89 genlist_entry_t *listen_entry;
92 90 sol_cma_glbl_listen_t *chan_glbl_listen_info;
93 91
94 92 /*
95 93 * For EP CMIDs, pointer to ib_device and root CMID
96 94 * for HCA DR
97 95 */
98 96 genlist_entry_t *listen_ep_dev_entry;
99 97 genlist_entry_t *listen_ep_root_entry;
100 98 struct ib_device *listen_ep_device;
101 99
102 100 /*
103 101 * Count & list of EPs for this listen_info.
104 102 * This is 0, if listen_is_root is 0.
105 103 */
106 104 uint32_t listen_eps;
107 105 genlist_t listen_list;
108 106
109 107 /* Transport Specific */
110 108 union {
111 109 /* For Root CMID */
112 110 ibt_srv_hdl_t _listen_srv_hdl;
113 111
114 112 /* For Endpoint CMID */
115 113 ibt_sbind_hdl_t _listen_sbind_hdl;
116 114 } un_listen;
117 115 #define listen_ib_srv_hdl un_listen._listen_srv_hdl
118 116 #define listen_ib_sbind_hdl un_listen._listen_sbind_hdl
119 117 } sol_cma_listen_info_t;
120 118
121 119 typedef enum {
122 120 SOL_CMA_XPORT_NONE = 0,
123 121 SOL_CMA_XPORT_IB,
124 122 SOL_CMA_XPORT_IWARP
125 123 } sol_cma_xport_type_t;
126 124
127 125 /*
128 126 * This is used to track the state of a client side CMID.
129 127 * CONNECT_NONE Server side CMID, or CMID for which
130 128 * rdma_connect() has not been called.
131 129 *
132 130 * CLIENT_NONE Client side CMID for which connection
133 131 * has been torn down.
134 132 *
135 133 * For UDP it also represents connection
136 134 * established (no more IBTF CM events
137 135 * expected).
138 136 *
139 137 * INITIATED rdma_connect() has been called not yet
140 138 * established.
141 139 *
142 140 * ESTABLISHED Client CMID has connection established.
143 141 */
144 142 typedef enum {
145 143 SOL_CMA_CONNECT_NONE = 0,
146 144 SOL_CMA_CONNECT_CLIENT_NONE,
147 145 SOL_CMA_CONNECT_INITIATED,
148 146 SOL_CMA_CONNECT_ESTABLISHED,
149 147 } sol_cma_connect_flag_t;
150 148
151 149 /*
152 150 * This is used to track the state of CMIDs created for Connection
153 151 * Requests and listening CMID.
154 152 *
155 153 * NONE Client CMID, listen CMID with no REQs yet.
156 154 *
157 155 * SERVER_DONE REQ CMID connection done, no more events.
158 156 *
159 157 * For listening CMID all REQ CMIDs have events
160 158 * completed.
161 159 *
162 160 * CREATED listening CMID with > 1 REQ CMID with events
163 161 * pending.
164 162 *
165 163 * QUEUED REQ CMID in REQ AVL tree of listening CMID
166 164 *
167 165 * ACCEPTED REQ CMID accepted and in ACPT AVL tree of the
168 166 * listening CMID.
169 167 */
170 168 typedef enum {
171 169 REQ_CMID_NONE = 0,
172 170 REQ_CMID_SERVER_NONE,
173 171 REQ_CMID_CREATED,
174 172 REQ_CMID_QUEUED,
175 173 REQ_CMID_NOTIFIED,
176 174 REQ_CMID_ACCEPTED,
177 175 } cma_req_cmid_state_t;
178 176
179 177 #define SOL_IS_SERVER_CMID(chanp) \
180 178 ((chanp)->chan_req_state != REQ_CMID_NONE)
181 179 #define SOL_IS_CLIENT_CMID(chanp) \
182 180 ((chanp)->chan_connect_flag != SOL_CMA_CONNECT_NONE)
183 181
184 182 #define REQ_CMID_IN_REQ_AVL_TREE(chanp) \
185 183 ((chanp)->chan_req_state == REQ_CMID_QUEUED || \
186 184 (chanp)->chan_req_state == REQ_CMID_NOTIFIED)
187 185 #define SOL_CMID_CLOSE_REQUIRED(chanp) \
188 186 ((chanp)->chan_connect_flag == SOL_CMA_CONNECT_INITIATED || \
189 187 (chanp)->chan_connect_flag == SOL_CMA_CONNECT_ESTABLISHED || \
190 188 (chanp)->chan_req_state == REQ_CMID_ACCEPTED)
191 189 #define SOL_CMAID_CONNECTED(chanp) \
192 190 (SOL_CMID_CLOSE_REQUIRED(chanp) || \
193 191 (chanp)->chan_req_state == REQ_CMID_NOTIFIED)
194 192
195 193 /*
196 194 * CMID_DESTROYED - Flag to indicate rdma_destroy_id has been
197 195 * called for this CMID
198 196 *
199 197 * EVENT_PROGRESS - RDMACM Event for this CMID been passed to
200 198 * the sol_ofs client.
201 199 *
202 200 * API_PROGRESS - rdma_resolve_addr() / rdma_resolve_route() /
203 201 * rdma_listen() is in progress.
204 202 */
205 203 #define SOL_CMA_CALLER_CMID_DESTROYED 0x01
206 204 #define SOL_CMA_CALLER_EVENT_PROGRESS 0x02
207 205 #define SOL_CMA_CALLER_API_PROGRESS 0x04
208 206
209 207 typedef struct {
210 208 struct rdma_cm_id chan_rdma_cm;
211 209
212 210 /*
213 211 * Below are all CMA Channel specific fields required in Solaris,
214 212 * apart from rdma_cm_id.
215 213 */
216 214
217 215 /* AVL Tree for REQs and EST CMIDs */
218 216 avl_node_t chan_req_avl_node;
219 217 avl_node_t chan_acpt_avl_node;
220 218 avl_tree_t chan_req_avl_tree;
221 219 avl_tree_t chan_acpt_avl_tree;
222 220
223 221 /*
224 222 * chan_req_cnt -
225 223 * REQ CMIDs created not yet notified to client
226 224 * chan_total_req_cnt -
227 225 * REQ CMIDs created not destroy_id(0 not called.
228 226 */
229 227 uint64_t chan_req_cnt;
230 228 uint64_t chan_req_total_cnt;
231 229
232 230
233 231 /* State for Server side and client side CMIDs */
234 232 cma_req_cmid_state_t chan_req_state;
235 233 sol_cma_connect_flag_t chan_connect_flag;
236 234
237 235 kmutex_t chan_mutex;
238 236 kcondvar_t chan_destroy_cv;
239 237 cma_chan_state_t chan_state;
240 238 uint8_t chan_cmid_destroy_state;
241 239
242 240 /*
243 241 * Transport type for the rdma_id, IB or IWARP. This is set to
244 242 * NONE, when the transport type is not yet determined.
245 243 */
246 244 sol_cma_xport_type_t chan_xport_type;
247 245
248 246 /*
249 247 * Passed from sol_ofs consumer, using the rdma_map_id2clnthdl
250 248 * and rdma_map_id2qphdl
251 249 */
252 250 void *chan_ib_client_hdl;
253 251 void *chan_iw_client_hdl;
254 252 void *chan_qp_hdl;
255 253
256 254 /* Data for root / endpoint CM ID. */
257 255 sol_cma_listen_info_t *chan_listenp;
258 256
259 257 /* Ptr to the root CMID for Endpoint & Req CMID */
260 258 struct rdma_cm_id *listen_root;
261 259 #define CHAN_LISTEN_LIST(chanp) (((chanp)->chan_listenp)->listen_list)
262 260 #define CHAN_LISTEN_ROOT(chanp) ((chanp)->listen_root)
263 261
264 262 struct rdma_conn_param chan_param;
265 263
266 264 /* Session ID for completion */
267 265 void *chan_session_id;
268 266
269 267 uint32_t chan_qp_num;
270 268 uint8_t chan_is_srq;
271 269
272 270 union {
273 271 ibcma_chan_t chan_ib_xport;
274 272 } un_xport; /* Transport specific fields */
275 273 #define chan_ib un_xport.chan_ib_xport
276 274 } sol_cma_chan_t;
277 275
278 276 void ibcma_append_listen_list(struct rdma_cm_id *);
279 277 #ifdef IWARP_SUPPORT
280 278 void iwcma_append_listen_list(struct rdma_cm_id *);
281 279 #endif
282 280
283 281
284 282 extern void cma_generate_event(struct rdma_cm_id *, enum rdma_cm_event_type,
285 283 int, struct rdma_conn_param *, struct rdma_ud_param *);
286 284 extern struct ib_device *sol_cma_acquire_device(ib_guid_t);
287 285
288 286 static inline int
289 287 sol_cma_any_addr(struct sockaddr *addr)
290 288 {
291 289 ASSERT(addr);
292 290 if (addr->sa_family == AF_INET) {
293 291 struct sockaddr_in *in_addr;
294 292 in_addr = (struct sockaddr_in *)addr;
295 293
296 294 return (in_addr->sin_addr.s_addr == INADDR_ANY);
297 295 } else if (addr->sa_family == AF_INET6) {
298 296 struct sockaddr_in6 *in6_addr;
299 297 in6_addr = (struct sockaddr_in6 *)addr;
300 298
301 299 return (IN6_IS_ADDR_UNSPECIFIED(&(in6_addr->sin6_addr)));
302 300 }
303 301 return (0);
304 302 }
305 303
306 304 static inline struct rdma_cm_id *
307 305 cma_create_new_id(struct rdma_cm_id *srcid)
308 306 {
309 307 struct rdma_cm_id *newid;
310 308 sol_cma_chan_t *new_chanp, *src_chanp;
311 309
312 310 newid = rdma_create_id(srcid->event_handler, srcid->context,
313 311 srcid->ps);
314 312 if (newid == NULL)
315 313 return (newid);
316 314
317 315 if (srcid->device) {
318 316 newid->device =
319 317 sol_cma_acquire_device(srcid->device->node_guid);
320 318 }
321 319 bcopy(&((srcid->route).addr), &((newid->route).addr),
322 320 sizeof (struct rdma_addr));
323 321 if ((srcid->route).num_paths) {
324 322 int num_paths;
325 323
326 324 num_paths = (newid->route).num_paths =
327 325 (srcid->route).num_paths;
328 326 (newid->route).path_rec = kmem_zalloc(num_paths *
329 327 sizeof (struct ib_sa_path_rec), KM_SLEEP);
330 328 bcopy(&((srcid->route).path_rec),
331 329 &((newid->route).path_rec),
332 330 num_paths * sizeof (struct ib_sa_path_rec));
333 331 }
334 332 newid->port_num = srcid->port_num;
335 333
336 334 new_chanp = (sol_cma_chan_t *)newid;
337 335 src_chanp = (sol_cma_chan_t *)srcid;
338 336 new_chanp->chan_state = src_chanp->chan_state;
339 337 new_chanp->chan_xport_type = src_chanp->chan_xport_type;
340 338 if (CHAN_LISTEN_ROOT(src_chanp))
341 339 CHAN_LISTEN_ROOT(new_chanp) = CHAN_LISTEN_ROOT(src_chanp);
342 340 else
343 341 CHAN_LISTEN_ROOT(new_chanp) = srcid;
344 342 return (newid);
345 343 }
346 344
347 345
348 346 static inline struct rdma_cm_id *
349 347 cma_get_req_idp(struct rdma_cm_id *root_idp, void *qp_hdl)
350 348 {
351 349 struct rdma_cm_id *req_idp;
352 350 sol_cma_chan_t *root_chanp;
353 351
354 352 root_chanp = (sol_cma_chan_t *)root_idp;
355 353 ASSERT(MUTEX_HELD(&root_chanp->chan_mutex));
356 354 req_idp = (struct rdma_cm_id *)avl_find(
357 355 &root_chanp->chan_req_avl_tree, (void *)qp_hdl, NULL);
358 356 return (req_idp);
359 357 }
360 358
361 359 static inline struct rdma_cm_id *
362 360 cma_get_acpt_idp(struct rdma_cm_id *root_idp, void *qp_hdl)
363 361 {
364 362 struct rdma_cm_id *acpt_idp;
365 363 sol_cma_chan_t *root_chanp;
366 364
367 365 root_chanp = (sol_cma_chan_t *)root_idp;
368 366 ASSERT(MUTEX_HELD(&root_chanp->chan_mutex));
369 367 acpt_idp = (struct rdma_cm_id *)avl_find(
370 368 &root_chanp->chan_acpt_avl_tree, (void *)qp_hdl, NULL);
371 369 return (acpt_idp);
372 370 }
373 371 #ifdef __cplusplus
374 372 }
375 373 #endif
376 374
377 375 #endif /* _SYS_IB_CLIENTS_OF_SOL_OFS_SOL_CMA_H */
↓ open down ↓ |
327 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX