diff options
Diffstat (limited to 'include/linux/uwb.h')
-rw-r--r-- | include/linux/uwb.h | 123 |
1 files changed, 94 insertions, 29 deletions
diff --git a/include/linux/uwb.h b/include/linux/uwb.h index f9ccbd9a2ced..c02128991ff7 100644 --- a/include/linux/uwb.h +++ b/include/linux/uwb.h | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/device.h> | 30 | #include <linux/device.h> |
31 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
32 | #include <linux/timer.h> | 32 | #include <linux/timer.h> |
33 | #include <linux/wait.h> | ||
33 | #include <linux/workqueue.h> | 34 | #include <linux/workqueue.h> |
34 | #include <linux/uwb/spec.h> | 35 | #include <linux/uwb/spec.h> |
35 | 36 | ||
@@ -66,6 +67,7 @@ struct uwb_dev { | |||
66 | struct uwb_dev_addr dev_addr; | 67 | struct uwb_dev_addr dev_addr; |
67 | int beacon_slot; | 68 | int beacon_slot; |
68 | DECLARE_BITMAP(streams, UWB_NUM_STREAMS); | 69 | DECLARE_BITMAP(streams, UWB_NUM_STREAMS); |
70 | DECLARE_BITMAP(last_availability_bm, UWB_NUM_MAS); | ||
69 | }; | 71 | }; |
70 | #define to_uwb_dev(d) container_of(d, struct uwb_dev, dev) | 72 | #define to_uwb_dev(d) container_of(d, struct uwb_dev, dev) |
71 | 73 | ||
@@ -86,12 +88,31 @@ struct uwb_notifs_chain { | |||
86 | struct mutex mutex; | 88 | struct mutex mutex; |
87 | }; | 89 | }; |
88 | 90 | ||
91 | /* Beacon cache list */ | ||
92 | struct uwb_beca { | ||
93 | struct list_head list; | ||
94 | size_t entries; | ||
95 | struct mutex mutex; | ||
96 | }; | ||
97 | |||
98 | /* Event handling thread. */ | ||
99 | struct uwbd { | ||
100 | int pid; | ||
101 | struct task_struct *task; | ||
102 | wait_queue_head_t wq; | ||
103 | struct list_head event_list; | ||
104 | spinlock_t event_list_lock; | ||
105 | }; | ||
106 | |||
89 | /** | 107 | /** |
90 | * struct uwb_mas_bm - a bitmap of all MAS in a superframe | 108 | * struct uwb_mas_bm - a bitmap of all MAS in a superframe |
91 | * @bm: a bitmap of length #UWB_NUM_MAS | 109 | * @bm: a bitmap of length #UWB_NUM_MAS |
92 | */ | 110 | */ |
93 | struct uwb_mas_bm { | 111 | struct uwb_mas_bm { |
94 | DECLARE_BITMAP(bm, UWB_NUM_MAS); | 112 | DECLARE_BITMAP(bm, UWB_NUM_MAS); |
113 | DECLARE_BITMAP(unsafe_bm, UWB_NUM_MAS); | ||
114 | int safe; | ||
115 | int unsafe; | ||
95 | }; | 116 | }; |
96 | 117 | ||
97 | /** | 118 | /** |
@@ -117,14 +138,24 @@ struct uwb_mas_bm { | |||
117 | * FIXME: further target states TBD. | 138 | * FIXME: further target states TBD. |
118 | */ | 139 | */ |
119 | enum uwb_rsv_state { | 140 | enum uwb_rsv_state { |
120 | UWB_RSV_STATE_NONE, | 141 | UWB_RSV_STATE_NONE = 0, |
121 | UWB_RSV_STATE_O_INITIATED, | 142 | UWB_RSV_STATE_O_INITIATED, |
122 | UWB_RSV_STATE_O_PENDING, | 143 | UWB_RSV_STATE_O_PENDING, |
123 | UWB_RSV_STATE_O_MODIFIED, | 144 | UWB_RSV_STATE_O_MODIFIED, |
124 | UWB_RSV_STATE_O_ESTABLISHED, | 145 | UWB_RSV_STATE_O_ESTABLISHED, |
146 | UWB_RSV_STATE_O_TO_BE_MOVED, | ||
147 | UWB_RSV_STATE_O_MOVE_EXPANDING, | ||
148 | UWB_RSV_STATE_O_MOVE_COMBINING, | ||
149 | UWB_RSV_STATE_O_MOVE_REDUCING, | ||
125 | UWB_RSV_STATE_T_ACCEPTED, | 150 | UWB_RSV_STATE_T_ACCEPTED, |
126 | UWB_RSV_STATE_T_DENIED, | 151 | UWB_RSV_STATE_T_DENIED, |
152 | UWB_RSV_STATE_T_CONFLICT, | ||
127 | UWB_RSV_STATE_T_PENDING, | 153 | UWB_RSV_STATE_T_PENDING, |
154 | UWB_RSV_STATE_T_EXPANDING_ACCEPTED, | ||
155 | UWB_RSV_STATE_T_EXPANDING_CONFLICT, | ||
156 | UWB_RSV_STATE_T_EXPANDING_PENDING, | ||
157 | UWB_RSV_STATE_T_EXPANDING_DENIED, | ||
158 | UWB_RSV_STATE_T_RESIZED, | ||
128 | 159 | ||
129 | UWB_RSV_STATE_LAST, | 160 | UWB_RSV_STATE_LAST, |
130 | }; | 161 | }; |
@@ -149,6 +180,12 @@ struct uwb_rsv_target { | |||
149 | }; | 180 | }; |
150 | }; | 181 | }; |
151 | 182 | ||
183 | struct uwb_rsv_move { | ||
184 | struct uwb_mas_bm final_mas; | ||
185 | struct uwb_ie_drp *companion_drp_ie; | ||
186 | struct uwb_mas_bm companion_mas; | ||
187 | }; | ||
188 | |||
152 | /* | 189 | /* |
153 | * Number of streams reserved for reservations targeted at DevAddrs. | 190 | * Number of streams reserved for reservations targeted at DevAddrs. |
154 | */ | 191 | */ |
@@ -186,6 +223,7 @@ typedef void (*uwb_rsv_cb_f)(struct uwb_rsv *rsv); | |||
186 | * | 223 | * |
187 | * @status: negotiation status | 224 | * @status: negotiation status |
188 | * @stream: stream index allocated for this reservation | 225 | * @stream: stream index allocated for this reservation |
226 | * @tiebreaker: conflict tiebreaker for this reservation | ||
189 | * @mas: reserved MAS | 227 | * @mas: reserved MAS |
190 | * @drp_ie: the DRP IE | 228 | * @drp_ie: the DRP IE |
191 | * @ie_valid: true iff the DRP IE matches the reservation parameters | 229 | * @ie_valid: true iff the DRP IE matches the reservation parameters |
@@ -201,25 +239,29 @@ struct uwb_rsv { | |||
201 | struct uwb_rc *rc; | 239 | struct uwb_rc *rc; |
202 | struct list_head rc_node; | 240 | struct list_head rc_node; |
203 | struct list_head pal_node; | 241 | struct list_head pal_node; |
242 | struct kref kref; | ||
204 | 243 | ||
205 | struct uwb_dev *owner; | 244 | struct uwb_dev *owner; |
206 | struct uwb_rsv_target target; | 245 | struct uwb_rsv_target target; |
207 | enum uwb_drp_type type; | 246 | enum uwb_drp_type type; |
208 | int max_mas; | 247 | int max_mas; |
209 | int min_mas; | 248 | int min_mas; |
210 | int sparsity; | 249 | int max_interval; |
211 | bool is_multicast; | 250 | bool is_multicast; |
212 | 251 | ||
213 | uwb_rsv_cb_f callback; | 252 | uwb_rsv_cb_f callback; |
214 | void *pal_priv; | 253 | void *pal_priv; |
215 | 254 | ||
216 | enum uwb_rsv_state state; | 255 | enum uwb_rsv_state state; |
256 | bool needs_release_companion_mas; | ||
217 | u8 stream; | 257 | u8 stream; |
258 | u8 tiebreaker; | ||
218 | struct uwb_mas_bm mas; | 259 | struct uwb_mas_bm mas; |
219 | struct uwb_ie_drp *drp_ie; | 260 | struct uwb_ie_drp *drp_ie; |
261 | struct uwb_rsv_move mv; | ||
220 | bool ie_valid; | 262 | bool ie_valid; |
221 | struct timer_list timer; | 263 | struct timer_list timer; |
222 | bool expired; | 264 | struct work_struct handle_timeout_work; |
223 | }; | 265 | }; |
224 | 266 | ||
225 | static const | 267 | static const |
@@ -261,6 +303,13 @@ struct uwb_drp_avail { | |||
261 | bool ie_valid; | 303 | bool ie_valid; |
262 | }; | 304 | }; |
263 | 305 | ||
306 | struct uwb_drp_backoff_win { | ||
307 | u8 window; | ||
308 | u8 n; | ||
309 | int total_expired; | ||
310 | struct timer_list timer; | ||
311 | bool can_reserve_extra_mases; | ||
312 | }; | ||
264 | 313 | ||
265 | const char *uwb_rsv_state_str(enum uwb_rsv_state state); | 314 | const char *uwb_rsv_state_str(enum uwb_rsv_state state); |
266 | const char *uwb_rsv_type_str(enum uwb_drp_type type); | 315 | const char *uwb_rsv_type_str(enum uwb_drp_type type); |
@@ -276,6 +325,8 @@ void uwb_rsv_terminate(struct uwb_rsv *rsv); | |||
276 | 325 | ||
277 | void uwb_rsv_accept(struct uwb_rsv *rsv, uwb_rsv_cb_f cb, void *pal_priv); | 326 | void uwb_rsv_accept(struct uwb_rsv *rsv, uwb_rsv_cb_f cb, void *pal_priv); |
278 | 327 | ||
328 | void uwb_rsv_get_usable_mas(struct uwb_rsv *orig_rsv, struct uwb_mas_bm *mas); | ||
329 | |||
279 | /** | 330 | /** |
280 | * Radio Control Interface instance | 331 | * Radio Control Interface instance |
281 | * | 332 | * |
@@ -337,23 +388,33 @@ struct uwb_rc { | |||
337 | u8 ctx_roll; | 388 | u8 ctx_roll; |
338 | 389 | ||
339 | int beaconing; /* Beaconing state [channel number] */ | 390 | int beaconing; /* Beaconing state [channel number] */ |
391 | int beaconing_forced; | ||
340 | int scanning; | 392 | int scanning; |
341 | enum uwb_scan_type scan_type:3; | 393 | enum uwb_scan_type scan_type:3; |
342 | unsigned ready:1; | 394 | unsigned ready:1; |
343 | struct uwb_notifs_chain notifs_chain; | 395 | struct uwb_notifs_chain notifs_chain; |
396 | struct uwb_beca uwb_beca; | ||
397 | |||
398 | struct uwbd uwbd; | ||
344 | 399 | ||
400 | struct uwb_drp_backoff_win bow; | ||
345 | struct uwb_drp_avail drp_avail; | 401 | struct uwb_drp_avail drp_avail; |
346 | struct list_head reservations; | 402 | struct list_head reservations; |
403 | struct list_head cnflt_alien_list; | ||
404 | struct uwb_mas_bm cnflt_alien_bitmap; | ||
347 | struct mutex rsvs_mutex; | 405 | struct mutex rsvs_mutex; |
406 | spinlock_t rsvs_lock; | ||
348 | struct workqueue_struct *rsv_workq; | 407 | struct workqueue_struct *rsv_workq; |
349 | struct work_struct rsv_update_work; | ||
350 | 408 | ||
409 | struct delayed_work rsv_update_work; | ||
410 | struct delayed_work rsv_alien_bp_work; | ||
411 | int set_drp_ie_pending; | ||
351 | struct mutex ies_mutex; | 412 | struct mutex ies_mutex; |
352 | struct uwb_rc_cmd_set_ie *ies; | 413 | struct uwb_rc_cmd_set_ie *ies; |
353 | size_t ies_capacity; | 414 | size_t ies_capacity; |
354 | 415 | ||
355 | spinlock_t pal_lock; | ||
356 | struct list_head pals; | 416 | struct list_head pals; |
417 | int active_pals; | ||
357 | 418 | ||
358 | struct uwb_dbg *dbg; | 419 | struct uwb_dbg *dbg; |
359 | }; | 420 | }; |
@@ -361,11 +422,19 @@ struct uwb_rc { | |||
361 | 422 | ||
362 | /** | 423 | /** |
363 | * struct uwb_pal - a UWB PAL | 424 | * struct uwb_pal - a UWB PAL |
364 | * @name: descriptive name for this PAL (wushc, wlp, etc.). | 425 | * @name: descriptive name for this PAL (wusbhc, wlp, etc.). |
365 | * @device: a device for the PAL. Used to link the PAL and the radio | 426 | * @device: a device for the PAL. Used to link the PAL and the radio |
366 | * controller in sysfs. | 427 | * controller in sysfs. |
428 | * @rc: the radio controller the PAL uses. | ||
429 | * @channel_changed: called when the channel used by the radio changes. | ||
430 | * A channel of -1 means the channel has been stopped. | ||
367 | * @new_rsv: called when a peer requests a reservation (may be NULL if | 431 | * @new_rsv: called when a peer requests a reservation (may be NULL if |
368 | * the PAL cannot accept reservation requests). | 432 | * the PAL cannot accept reservation requests). |
433 | * @channel: channel being used by the PAL; 0 if the PAL isn't using | ||
434 | * the radio; -1 if the PAL wishes to use the radio but | ||
435 | * cannot. | ||
436 | * @debugfs_dir: a debugfs directory which the PAL can use for its own | ||
437 | * debugfs files. | ||
369 | * | 438 | * |
370 | * A Protocol Adaptation Layer (PAL) is a user of the WiMedia UWB | 439 | * A Protocol Adaptation Layer (PAL) is a user of the WiMedia UWB |
371 | * radio platform (e.g., WUSB, WLP or Bluetooth UWB AMP). | 440 | * radio platform (e.g., WUSB, WLP or Bluetooth UWB AMP). |
@@ -384,12 +453,21 @@ struct uwb_pal { | |||
384 | struct list_head node; | 453 | struct list_head node; |
385 | const char *name; | 454 | const char *name; |
386 | struct device *device; | 455 | struct device *device; |
387 | void (*new_rsv)(struct uwb_rsv *rsv); | 456 | struct uwb_rc *rc; |
457 | |||
458 | void (*channel_changed)(struct uwb_pal *pal, int channel); | ||
459 | void (*new_rsv)(struct uwb_pal *pal, struct uwb_rsv *rsv); | ||
460 | |||
461 | int channel; | ||
462 | struct dentry *debugfs_dir; | ||
388 | }; | 463 | }; |
389 | 464 | ||
390 | void uwb_pal_init(struct uwb_pal *pal); | 465 | void uwb_pal_init(struct uwb_pal *pal); |
391 | int uwb_pal_register(struct uwb_rc *rc, struct uwb_pal *pal); | 466 | int uwb_pal_register(struct uwb_pal *pal); |
392 | void uwb_pal_unregister(struct uwb_rc *rc, struct uwb_pal *pal); | 467 | void uwb_pal_unregister(struct uwb_pal *pal); |
468 | |||
469 | int uwb_radio_start(struct uwb_pal *pal); | ||
470 | void uwb_radio_stop(struct uwb_pal *pal); | ||
393 | 471 | ||
394 | /* | 472 | /* |
395 | * General public API | 473 | * General public API |
@@ -443,8 +521,6 @@ ssize_t uwb_rc_vcmd(struct uwb_rc *rc, const char *cmd_name, | |||
443 | struct uwb_rccb *cmd, size_t cmd_size, | 521 | struct uwb_rccb *cmd, size_t cmd_size, |
444 | u8 expected_type, u16 expected_event, | 522 | u8 expected_type, u16 expected_event, |
445 | struct uwb_rceb **preply); | 523 | struct uwb_rceb **preply); |
446 | ssize_t uwb_rc_get_ie(struct uwb_rc *, struct uwb_rc_evt_get_ie **); | ||
447 | int uwb_bg_joined(struct uwb_rc *rc); | ||
448 | 524 | ||
449 | size_t __uwb_addr_print(char *, size_t, const unsigned char *, int); | 525 | size_t __uwb_addr_print(char *, size_t, const unsigned char *, int); |
450 | 526 | ||
@@ -520,6 +596,8 @@ void uwb_rc_rm(struct uwb_rc *); | |||
520 | void uwb_rc_neh_grok(struct uwb_rc *, void *, size_t); | 596 | void uwb_rc_neh_grok(struct uwb_rc *, void *, size_t); |
521 | void uwb_rc_neh_error(struct uwb_rc *, int); | 597 | void uwb_rc_neh_error(struct uwb_rc *, int); |
522 | void uwb_rc_reset_all(struct uwb_rc *rc); | 598 | void uwb_rc_reset_all(struct uwb_rc *rc); |
599 | void uwb_rc_pre_reset(struct uwb_rc *rc); | ||
600 | void uwb_rc_post_reset(struct uwb_rc *rc); | ||
523 | 601 | ||
524 | /** | 602 | /** |
525 | * uwb_rsv_is_owner - is the owner of this reservation the RC? | 603 | * uwb_rsv_is_owner - is the owner of this reservation the RC? |
@@ -531,7 +609,9 @@ static inline bool uwb_rsv_is_owner(struct uwb_rsv *rsv) | |||
531 | } | 609 | } |
532 | 610 | ||
533 | /** | 611 | /** |
534 | * Events generated by UWB that can be passed to any listeners | 612 | * enum uwb_notifs - UWB events that can be passed to any listeners |
613 | * @UWB_NOTIF_ONAIR: a new neighbour has joined the beacon group. | ||
614 | * @UWB_NOTIF_OFFAIR: a neighbour has left the beacon group. | ||
535 | * | 615 | * |
536 | * Higher layers can register callback functions with the radio | 616 | * Higher layers can register callback functions with the radio |
537 | * controller using uwb_notifs_register(). The radio controller | 617 | * controller using uwb_notifs_register(). The radio controller |
@@ -539,8 +619,6 @@ static inline bool uwb_rsv_is_owner(struct uwb_rsv *rsv) | |||
539 | * nodes when an event occurs. | 619 | * nodes when an event occurs. |
540 | */ | 620 | */ |
541 | enum uwb_notifs { | 621 | enum uwb_notifs { |
542 | UWB_NOTIF_BG_JOIN = 0, /* radio controller joined a beacon group */ | ||
543 | UWB_NOTIF_BG_LEAVE = 1, /* radio controller left a beacon group */ | ||
544 | UWB_NOTIF_ONAIR, | 622 | UWB_NOTIF_ONAIR, |
545 | UWB_NOTIF_OFFAIR, | 623 | UWB_NOTIF_OFFAIR, |
546 | }; | 624 | }; |
@@ -652,22 +730,9 @@ static inline int edc_inc(struct edc *err_hist, u16 max_err, u16 timeframe) | |||
652 | 730 | ||
653 | /* Information Element handling */ | 731 | /* Information Element handling */ |
654 | 732 | ||
655 | /* For representing the state of writing to a buffer when iterating */ | ||
656 | struct uwb_buf_ctx { | ||
657 | char *buf; | ||
658 | size_t bytes, size; | ||
659 | }; | ||
660 | |||
661 | typedef int (*uwb_ie_f)(struct uwb_dev *, const struct uwb_ie_hdr *, | ||
662 | size_t, void *); | ||
663 | struct uwb_ie_hdr *uwb_ie_next(void **ptr, size_t *len); | 733 | struct uwb_ie_hdr *uwb_ie_next(void **ptr, size_t *len); |
664 | ssize_t uwb_ie_for_each(struct uwb_dev *uwb_dev, uwb_ie_f fn, void *data, | 734 | int uwb_rc_ie_add(struct uwb_rc *uwb_rc, const struct uwb_ie_hdr *ies, size_t size); |
665 | const void *buf, size_t size); | 735 | int uwb_rc_ie_rm(struct uwb_rc *uwb_rc, enum uwb_ie element_id); |
666 | int uwb_ie_dump_hex(struct uwb_dev *, const struct uwb_ie_hdr *, | ||
667 | size_t, void *); | ||
668 | int uwb_rc_set_ie(struct uwb_rc *, struct uwb_rc_cmd_set_ie *); | ||
669 | struct uwb_ie_hdr *uwb_ie_next(void **ptr, size_t *len); | ||
670 | |||
671 | 736 | ||
672 | /* | 737 | /* |
673 | * Transmission statistics | 738 | * Transmission statistics |