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