This source file includes following definitions.
- wusb_dev_init
- wusb_dev_get
- wusb_dev_put
- usb_hcd_get_by_usb_dev
- wusbhc_get
- wusbhc_get_by_usb_dev
- wusbhc_put
- wusb_port_by_idx
- wusb_port_no_to_idx
- wusb_dev_get_by_usb_dev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 #ifndef __WUSBHC_H__
40 #define __WUSBHC_H__
41
42 #include <linux/usb.h>
43 #include <linux/list.h>
44 #include <linux/mutex.h>
45 #include <linux/kref.h>
46 #include <linux/workqueue.h>
47 #include <linux/usb/hcd.h>
48 #include "../uwb/uwb.h"
49 #include "include/wusb.h"
50
51
52
53
54
55
56
57 #define WUSB_CHANNEL_STOP_DELAY_MS 8
58 #define WUSB_RETRY_COUNT_MAX 15
59 #define WUSB_RETRY_COUNT_INFINITE 0
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 struct wusb_dev {
83 struct kref refcnt;
84 struct wusbhc *wusbhc;
85 struct list_head cack_node;
86 struct list_head rekey_node;
87 u8 port_idx;
88 u8 addr;
89 u8 beacon_type:4;
90 struct usb_encryption_descriptor ccm1_etd;
91 struct wusb_ckhdid cdid;
92 unsigned long entry_ts;
93 struct usb_bos_descriptor *bos;
94 struct usb_wireless_cap_descriptor *wusb_cap_descr;
95 struct uwb_mas_bm availability;
96 struct work_struct devconnect_acked_work;
97 struct usb_device *usb_dev;
98 };
99
100 #define WUSB_DEV_ADDR_UNAUTH 0x80
101
102 static inline void wusb_dev_init(struct wusb_dev *wusb_dev)
103 {
104 kref_init(&wusb_dev->refcnt);
105
106 }
107
108 extern void wusb_dev_destroy(struct kref *_wusb_dev);
109
110 static inline struct wusb_dev *wusb_dev_get(struct wusb_dev *wusb_dev)
111 {
112 kref_get(&wusb_dev->refcnt);
113 return wusb_dev;
114 }
115
116 static inline void wusb_dev_put(struct wusb_dev *wusb_dev)
117 {
118 kref_put(&wusb_dev->refcnt, wusb_dev_destroy);
119 }
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138 struct wusb_port {
139 u16 status;
140 u16 change;
141 struct wusb_dev *wusb_dev;
142 u32 ptk_tkid;
143 };
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233 struct wusbhc {
234 struct usb_hcd usb_hcd;
235 struct device *dev;
236 struct uwb_rc *uwb_rc;
237 struct uwb_pal pal;
238
239 unsigned trust_timeout;
240 struct wusb_ckhdid chid;
241 uint8_t phy_rate;
242 uint8_t dnts_num_slots;
243 uint8_t dnts_interval;
244 uint8_t retry_count;
245 struct wuie_host_info *wuie_host_info;
246
247 struct mutex mutex;
248 u16 cluster_id;
249 struct wusb_port *port;
250 struct wusb_dev_info *dev_info;
251 u8 ports_max;
252 unsigned active:1;
253 struct wuie_keep_alive keep_alive_ie;
254 struct delayed_work keep_alive_timer;
255 struct list_head cack_list;
256 size_t cack_count;
257 struct wuie_connect_ack cack_ie;
258 struct uwb_rsv *rsv;
259
260 struct mutex mmcie_mutex;
261 struct wuie_hdr **mmcie;
262 u8 mmcies_max;
263
264 int (*start)(struct wusbhc *wusbhc);
265 void (*stop)(struct wusbhc *wusbhc, int delay);
266 int (*mmcie_add)(struct wusbhc *wusbhc, u8 interval, u8 repeat_cnt,
267 u8 handle, struct wuie_hdr *wuie);
268 int (*mmcie_rm)(struct wusbhc *wusbhc, u8 handle);
269 int (*dev_info_set)(struct wusbhc *, struct wusb_dev *wusb_dev);
270 int (*bwa_set)(struct wusbhc *wusbhc, s8 stream_index,
271 const struct uwb_mas_bm *);
272 int (*set_ptk)(struct wusbhc *wusbhc, u8 port_idx,
273 u32 tkid, const void *key, size_t key_size);
274 int (*set_gtk)(struct wusbhc *wusbhc,
275 u32 tkid, const void *key, size_t key_size);
276 int (*set_num_dnts)(struct wusbhc *wusbhc, u8 interval, u8 slots);
277
278 struct {
279 struct usb_key_descriptor descr;
280 u8 data[16];
281 } __attribute__((packed)) gtk;
282 u8 gtk_index;
283 u32 gtk_tkid;
284
285
286 struct workqueue_struct *wq_security;
287 struct work_struct gtk_rekey_work;
288
289 struct usb_encryption_descriptor *ccm1_etd;
290 };
291
292 #define usb_hcd_to_wusbhc(u) container_of((u), struct wusbhc, usb_hcd)
293
294
295 extern int wusbhc_create(struct wusbhc *);
296 extern int wusbhc_b_create(struct wusbhc *);
297 extern void wusbhc_b_destroy(struct wusbhc *);
298 extern void wusbhc_destroy(struct wusbhc *);
299 extern int wusb_dev_sysfs_add(struct wusbhc *, struct usb_device *,
300 struct wusb_dev *);
301 extern void wusb_dev_sysfs_rm(struct wusb_dev *);
302 extern int wusbhc_sec_create(struct wusbhc *);
303 extern int wusbhc_sec_start(struct wusbhc *);
304 extern void wusbhc_sec_stop(struct wusbhc *);
305 extern void wusbhc_sec_destroy(struct wusbhc *);
306 extern void wusbhc_giveback_urb(struct wusbhc *wusbhc, struct urb *urb,
307 int status);
308 void wusbhc_reset_all(struct wusbhc *wusbhc);
309
310 int wusbhc_pal_register(struct wusbhc *wusbhc);
311 void wusbhc_pal_unregister(struct wusbhc *wusbhc);
312
313
314
315
316
317
318
319
320
321 static inline
322 struct usb_hcd *usb_hcd_get_by_usb_dev(struct usb_device *usb_dev)
323 {
324 struct usb_hcd *usb_hcd;
325 usb_hcd = bus_to_hcd(usb_dev->bus);
326 return usb_get_hcd(usb_hcd);
327 }
328
329
330
331
332
333
334 static inline struct wusbhc *wusbhc_get(struct wusbhc *wusbhc)
335 {
336 return usb_get_hcd(&wusbhc->usb_hcd) ? wusbhc : NULL;
337 }
338
339
340
341
342
343
344
345
346
347
348
349 static inline struct wusbhc *wusbhc_get_by_usb_dev(struct usb_device *usb_dev)
350 {
351 struct wusbhc *wusbhc = NULL;
352 struct usb_hcd *usb_hcd;
353 if (usb_dev->devnum > 1 && !usb_dev->wusb) {
354
355 dev_err(&usb_dev->dev, "devnum %d wusb %d\n", usb_dev->devnum,
356 usb_dev->wusb);
357 BUG_ON(usb_dev->devnum > 1 && !usb_dev->wusb);
358 }
359 usb_hcd = usb_hcd_get_by_usb_dev(usb_dev);
360 if (usb_hcd == NULL)
361 return NULL;
362 BUG_ON(usb_hcd->wireless == 0);
363 return wusbhc = usb_hcd_to_wusbhc(usb_hcd);
364 }
365
366
367 static inline void wusbhc_put(struct wusbhc *wusbhc)
368 {
369 usb_put_hcd(&wusbhc->usb_hcd);
370 }
371
372 int wusbhc_start(struct wusbhc *wusbhc);
373 void wusbhc_stop(struct wusbhc *wusbhc);
374 extern int wusbhc_chid_set(struct wusbhc *, const struct wusb_ckhdid *);
375
376
377 extern int wusbhc_devconnect_create(struct wusbhc *);
378 extern void wusbhc_devconnect_destroy(struct wusbhc *);
379 extern int wusbhc_devconnect_start(struct wusbhc *wusbhc);
380 extern void wusbhc_devconnect_stop(struct wusbhc *wusbhc);
381 extern void wusbhc_handle_dn(struct wusbhc *, u8 srcaddr,
382 struct wusb_dn_hdr *dn_hdr, size_t size);
383 extern void __wusbhc_dev_disable(struct wusbhc *wusbhc, u8 port);
384 extern int wusb_usb_ncb(struct notifier_block *nb, unsigned long val,
385 void *priv);
386 extern int wusb_set_dev_addr(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
387 u8 addr);
388
389
390 extern int wusbhc_rh_create(struct wusbhc *);
391 extern void wusbhc_rh_destroy(struct wusbhc *);
392
393 extern int wusbhc_rh_status_data(struct usb_hcd *, char *);
394 extern int wusbhc_rh_control(struct usb_hcd *, u16, u16, u16, char *, u16);
395 extern int wusbhc_rh_start_port_reset(struct usb_hcd *, unsigned);
396
397
398 extern int wusbhc_mmcie_create(struct wusbhc *);
399 extern void wusbhc_mmcie_destroy(struct wusbhc *);
400 extern int wusbhc_mmcie_set(struct wusbhc *, u8 interval, u8 repeat_cnt,
401 struct wuie_hdr *);
402 extern void wusbhc_mmcie_rm(struct wusbhc *, struct wuie_hdr *);
403
404
405 int wusbhc_rsv_establish(struct wusbhc *wusbhc);
406 void wusbhc_rsv_terminate(struct wusbhc *wusbhc);
407
408
409
410
411
412
413
414
415
416
417
418
419
420 extern int wusb_dev_sec_add(struct wusbhc *, struct usb_device *,
421 struct wusb_dev *);
422 extern void wusb_dev_sec_rm(struct wusb_dev *) ;
423 extern int wusb_dev_4way_handshake(struct wusbhc *, struct wusb_dev *,
424 struct wusb_ckhdid *ck);
425 void wusbhc_gtk_rekey(struct wusbhc *wusbhc);
426 int wusb_dev_update_address(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev);
427
428
429
430 extern u8 wusb_cluster_id_get(void);
431 extern void wusb_cluster_id_put(u8);
432
433
434
435
436
437
438
439
440 static inline struct wusb_port *wusb_port_by_idx(struct wusbhc *wusbhc,
441 u8 port_idx)
442 {
443 return &wusbhc->port[port_idx];
444 }
445
446
447
448
449
450
451
452
453
454 static inline u8 wusb_port_no_to_idx(u8 port_no)
455 {
456 return port_no - 1;
457 }
458
459 extern struct wusb_dev *__wusb_dev_get_by_usb_dev(struct wusbhc *,
460 struct usb_device *);
461
462
463
464
465
466
467
468
469 static inline
470 struct wusb_dev *wusb_dev_get_by_usb_dev(struct usb_device *usb_dev)
471 {
472 struct wusbhc *wusbhc;
473 struct wusb_dev *wusb_dev;
474 wusbhc = wusbhc_get_by_usb_dev(usb_dev);
475 if (wusbhc == NULL)
476 return NULL;
477 mutex_lock(&wusbhc->mutex);
478 wusb_dev = __wusb_dev_get_by_usb_dev(wusbhc, usb_dev);
479 mutex_unlock(&wusbhc->mutex);
480 wusbhc_put(wusbhc);
481 return wusb_dev;
482 }
483
484
485
486 extern struct workqueue_struct *wusbd;
487 #endif