Print this page
3373 gcc >= 4.5 concerns about offsetof()
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/uwb/uwba/uwba.h
+++ new/usr/src/uts/common/sys/uwb/uwba/uwba.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 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #ifndef _SYS_UWB_UWBA_H
27 27 #define _SYS_UWB_UWBA_H
28 28
29 29 #ifdef __cplusplus
30 30 extern "C" {
31 31 #endif
32 32
33 33
34 34 /*
35 35 * UWBA private header file.
36 36 */
37 37
38 38 #include <sys/note.h>
39 39 #include <sys/sunddi.h>
40 40 #include <sys/types.h>
41 41 #include <sys/list.h>
42 42 #include <sys/bitset.h>
↓ open down ↓ |
42 lines elided |
↑ open up ↑ |
43 43 #include <sys/bitmap.h>
44 44
45 45 #include <sys/uwb/uwb.h>
46 46 #include <sys/uwb/uwbai.h>
47 47
48 48 /* For logging. */
49 49 #define UWBA_LOG_DEBUG 2
50 50 #define UWBA_LOG_LOG 1
51 51 #define UWBA_LOG_CONSOLE 0
52 52
53 +#if defined(__GNUC__)
54 +#define offsetof(s, m) __builtin_offsetof(s, m)
55 +#else
53 56 #define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
57 +#endif
54 58 #define isdigit(ch) ((ch >= '0') && (ch <= '9'))
55 59
56 60 #define UWB_RAW_RESULT_CODE_SIZE 5 /* size of RCEB + bResultCode */
57 61 #define UWB_RAW_RCCB_HEAD_SIZE 4 /* size of RCCB */
58 62
59 63 #define UWB_RAW_BEVENTTYPE_OFFSET 0 /* offset of bEventType */
60 64 #define UWB_RAW_WEVENT_OFFSET 1 /* offset of wEvent */
61 65 #define UWB_RAW_BEVENTCONTEXT_OFFSET 3 /* offset of bEventContext */
62 66 #define UWB_RAW_BRESULTCODE_OFFSET 4 /* offset of bResultCode */
63 67
64 68
65 69
66 70 #define UWB_CTXT_ID_TOP 0xfe /* top context id */
67 71 #define UWB_CTXT_ID_BOTTOM 0x1 /* bottom context id */
68 72 #define UWB_CTXT_ID_NOTIF 0x0 /* notification context id */
69 73 #define UWB_CTXT_ID_UNVALID 0xff /* invalid context id */
70 74
71 75
72 76 #define UWB_INVALID_EVT_CODE 0x7ffe /* invalid evt/notif code */
73 77 #define UWB_INVALID_EVT_SIZE 0x7fff /* invalid evt length */
74 78
75 79 #define UWB_MAX_NOTIF_NUMBER 10 /* Max notifications in a notif_list */
76 80
77 81 #define UWB_MAX_CDEV_NUMBER 32 /* Max client radio device */
78 82
79 83 /*
80 84 * Offset of data rates Bits in PHY Capability Bitmap.
81 85 * [ECMA, 16.8.16, table 112]
82 86 */
83 87 #define UWB_RATE_OFFSET_BASE 16
84 88 /* the offset of data rate 53.3Mbps in PHY capability bitmap */
85 89 #define UWB_RATE_OFFSET_53 UWB_RATE_OFFSET_BASE
86 90 #define UWB_RATE_OFFSET_80 (UWB_RATE_OFFSET_BASE + 1) /* 80Mbps */
87 91 #define UWB_RATE_OFFSET_106 (UWB_RATE_OFFSET_BASE + 2)
88 92 #define UWB_RATE_OFFSET_160 (UWB_RATE_OFFSET_BASE + 3)
89 93 #define UWB_RATE_OFFSET_200 (UWB_RATE_OFFSET_BASE + 4)
90 94 #define UWB_RATE_OFFSET_320 (UWB_RATE_OFFSET_BASE + 5)
91 95 #define UWB_RATE_OFFSET_400 (UWB_RATE_OFFSET_BASE + 6)
92 96 #define UWB_RATE_OFFSET_480 (UWB_RATE_OFFSET_BASE + 7)
93 97
94 98 typedef int (*uwb_rccb_handler_t)(uwb_dev_handle_t, uwb_rccb_cmd_t *);
95 99 #define UWB_RCCB_NULL_HANDLER ((uwb_rccb_handler_t)0)
96 100
97 101 #define UWB_STATE_IDLE 0
98 102 #define UWB_STATE_BEACON 1
99 103 #define UWB_STATE_SCAN 2
100 104
101 105 /* radio client device */
102 106 typedef struct uwba_client_dev {
103 107 uint8_t bChannelNumber;
104 108 uint8_t bBeaconType;
105 109 uint16_t wBPSTOffset;
106 110 uwb_beacon_frame_t beacon_frame;
107 111 list_node_t dev_node;
108 112 } uwba_client_dev_t;
109 113
110 114 /* Command result from the radio controller */
111 115 typedef struct uwb_cmd_result {
112 116 uwb_rceb_head_t rceb;
113 117
114 118 /* Cmd result data from device when cmd is finished. */
115 119 uint8_t buf[1];
116 120 } uwb_cmd_result_t;
117 121
118 122
119 123 typedef struct uwb_cmd_result_wrapper {
120 124 /* Length of a uwb cmd_result */
121 125 int length;
122 126
123 127 uwb_cmd_result_t *cmd_result;
124 128 } uwb_cmd_result_wrapper_t;
125 129
126 130 typedef struct uwb_notif_wrapper {
127 131 /* Length of uwb notifcation */
128 132 int length;
129 133 uwb_rceb_notif_t *notif;
130 134
131 135 list_node_t notif_node;
132 136 } uwb_notif_wrapper_t;
133 137
134 138
135 139
136 140 typedef struct uwba_dev {
137 141 /* dip of the uwb radio controller device */
138 142 dev_info_t *dip;
139 143
140 144 /* Dev and instance */
141 145 char *devinst;
142 146
143 147 kmutex_t dev_mutex;
144 148
145 149 /* send cmd to the device */
146 150 int (*send_cmd)(uwb_dev_handle_t, mblk_t *, uint16_t);
147 151
148 152 /* current command block */
149 153 uwb_rccb_cmd_t curr_rccb;
150 154
151 155 /* wait for cmd complete and the cmd result available */
152 156 kcondvar_t cmd_result_cv;
153 157 kcondvar_t cmd_handler_cv;
154 158
155 159 /* filled by uwb_fill_cmd_result in rc driver's cmd call back */
156 160 uwb_cmd_result_wrapper_t cmd_result_wrap;
157 161
158 162 /*
159 163 * set to TRUE when start to do cmd ioctl;
160 164 * set to FALSE when put_cmd and exit cmd ioctl
161 165 */
162 166 boolean_t cmd_busy;
163 167
164 168 /* Device state */
165 169 uint8_t dev_state;
166 170
167 171 /* Beacon or scan channel */
168 172 uint8_t channel;
169 173
170 174 /* Device address */
171 175 uint16_t dev_addr;
172 176
173 177 /* notifications from radio controller device */
174 178 list_t notif_list;
175 179
176 180 /* the current number of notifications in the notif_list */
177 181 int notif_cnt;
178 182
179 183 /* client radio devices found through beacons by this radio host */
180 184 list_t client_dev_list;
181 185
182 186 /* the current number of devices in dev_list */
183 187 int client_dev_cnt;
184 188
185 189 /* context id is maintained by uwba */
186 190 uint8_t ctxt_id; /* current command context id */
187 191 bitset_t ctxt_bits; /* command context bit map */
188 192
189 193 /* PHY capability bitmap, saved from PHY capability IE */
190 194 ulong_t phy_cap_bm;
191 195
192 196 /* list node of a uwb radio host device */
193 197 list_node_t uwba_dev_node;
194 198 } uwba_dev_t;
195 199
196 200 _NOTE(MUTEX_PROTECTS_DATA(uwba_dev_t::dev_mutex, uwba_dev_t))
197 201 _NOTE(DATA_READABLE_WITHOUT_LOCK(uwba_dev_t::{
198 202 dip
199 203 devinst
200 204 send_cmd
201 205 phy_cap_bm
202 206 notif_cnt
203 207 dev_state
204 208 dip
205 209 ctxt_id
206 210 ctxt_bits
207 211 notif_list
208 212 cmd_result_wrap
209 213 client_dev_cnt
210 214 channel
211 215 dev_addr
212 216 }))
213 217
214 218
215 219 typedef struct uwba_evt_size {
216 220 /* length of a evt/notif structure, impact by alignment */
217 221 uint8_t struct_len;
218 222
219 223 /*
220 224 * offset of the length member of an event/notif struct.
221 225 * if zero, means there is no variable buf length member
222 226 * in this struct
223 227 */
224 228 uint16_t buf_len_offset;
225 229 } uwba_evt_size_t;
226 230 typedef struct uwba_channel_range {
227 231 /* First channel in the specific bandgroup */
228 232 uint8_t base;
229 233
230 234 /* Length since this first channel in the bandgroup */
231 235 uint8_t offset;
232 236 } uwba_channel_range_t;
233 237
234 238 #define UWB_RESULT_CODE_SIZE (sizeof (uwb_rceb_result_code_t))
235 239
236 240 /* str_t is the struct type of the notif/evt */
237 241 #define UWB_EVT_RCEB_SZ (sizeof (uwb_rceb_t))
238 242
239 243 /* the size after excluded the rceb head */
240 244 #define UWB_EVT_END_SZ(stru_t) (sizeof (stru_t) - sizeof (uwb_rceb_t))
241 245
242 246 #define UWB_EVT_NO_BUF_LEN_OFFSET 0
243 247
244 248 /* Offset of wBeaconInfoLength in uwb_rceb_beacon_t */
245 249 #define UWB_BEACONINFOLEN_OFFSET 10
246 250
247 251 /* Offset of BeaconInfo from bChannelNumber in uwb_rceb_beacon_t */
248 252 #define UWB_BEACONINFO_OFFSET 8
249 253
250 254 /*
251 255 * UWB radio controller device list
252 256 */
253 257 void uwba_dev_add_to_list(uwba_dev_t *);
254 258 void uwba_dev_rm_from_list(uwba_dev_t *);
255 259 void uwba_alloc_uwb_dev(dev_info_t *, uwba_dev_t **, uint_t);
256 260 void uwba_free_uwb_dev(uwba_dev_t *);
257 261 uwb_dev_handle_t uwba_dev_search(dev_info_t *);
258 262
259 263 /*
260 264 * Context ID operations
261 265 */
262 266 void uwba_init_ctxt_id(uwba_dev_t *);
263 267 void uwba_fini_ctxt_id(uwba_dev_t *);
264 268 uint8_t uwba_get_ctxt_id(uwba_dev_t *);
265 269 void uwba_free_ctxt_id(uwba_dev_t *, uint8_t);
266 270
267 271 void uwba_fill_rccb_head(uwba_dev_t *, uint16_t, mblk_t *);
268 272 uint16_t uwba_get_evt_code(uint8_t *, int);
269 273 uint16_t uwba_get_evt_size(uint8_t *, int, uint16_t);
270 274
271 275 void uwba_put_cmd_result(uwba_dev_t *, void *, uint16_t);
272 276 int uwba_add_notif_to_list(uwba_dev_t *, void *, uint16_t);
273 277
274 278 /*
275 279 * Parse events/notifications from radio controller device
276 280 */
277 281 int uwba_parse_data(char *, uchar_t *, size_t, void *, size_t);
278 282 int uwba_parse_rceb(uint8_t *, size_t, void *, size_t);
279 283 int uwba_parse_dev_addr_mgmt(uint8_t *, int, uwb_rceb_dev_addr_mgmt_t *);
280 284 int uwba_parse_get_ie(uwb_dev_handle_t, uint8_t *,
281 285 int, uwb_rceb_get_ie_t *);
282 286 int uwba_parse_beacon_rcv(uwb_dev_handle_t, uint8_t *,
283 287 int, uwb_rceb_beacon_t *);
284 288 int uwba_parse_bpoie_chg(uwb_dev_handle_t, uint8_t *,
285 289 int, uwb_rceb_bpoie_change_t *);
286 290 uint8_t uwba_allocate_channel(uwb_dev_handle_t);
287 291 uint8_t *uwba_find_ie(uwb_dev_handle_t, uint_t, uint8_t *, uint16_t);
288 292
289 293 void uwba_copy_rccb(uwb_rccb_cmd_t *, uwb_rccb_cmd_t *);
290 294
291 295 uwba_client_dev_t *uwba_find_cdev_by_channel(uwba_dev_t *, uint8_t);
292 296
293 297 /* Debug/message log */
294 298 void uwba_log(uwba_dev_t *, uint_t, char *, ...);
295 299 const char *uwba_event_msg(uint16_t);
296 300
297 301 /* Turn a little endian byte array to a uint32_t */
298 302 #define LE_TO_UINT32(src, off, des) \
299 303 { \
300 304 uint32_t tmp; \
301 305 des = src[off + 3]; \
302 306 des = des << 24; \
303 307 tmp = src[off + 2]; \
304 308 des |= tmp << 16; \
305 309 tmp = src[off + 1]; \
306 310 des |= tmp << 8; \
307 311 des |= src[off]; \
308 312 }
309 313
310 314 /* Turn a uint32_t to a little endian byte array */
311 315 #define UINT32_TO_LE(src, off, des) \
312 316 { \
313 317 des[off + 0] = 0xff & src; \
314 318 des[off + 1] = 0xff & (src >> 8); \
315 319 des[off + 2] = 0xff & (src >> 16); \
316 320 des[off + 3] = 0xff & (src >> 24); \
317 321 }
318 322
319 323 /* Turn a little endian byte array to a uint16_t */
320 324 #define LE_TO_UINT16(src, off, des) \
321 325 { \
322 326 des = src[off + 1]; \
323 327 des = des << 8; \
324 328 des |= src[off]; \
325 329 }
326 330
327 331 /* Turn a uint16_t to alittle endian byte array */
328 332 #define UINT16_TO_LE(src, off, des) \
329 333 { \
330 334 des[off + 0] = 0xff & src; \
331 335 des[off + 1] = 0xff & (src >> 8); \
332 336 }
333 337
334 338
335 339 /* Max string length for the driver name and instance number. */
336 340 #define UWB_MAXSTRINGLEN 255
337 341
338 342
339 343 #ifdef __cplusplus
340 344 }
341 345 #endif
342 346
343 347 #endif /* _SYS_UWB_UWBA_H */
↓ open down ↓ |
280 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX