diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /include/net/bluetooth/l2cap.h | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'include/net/bluetooth/l2cap.h')
-rw-r--r-- | include/net/bluetooth/l2cap.h | 225 |
1 files changed, 137 insertions, 88 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 6c241444f902..d09c9b1118e3 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | BlueZ - Bluetooth protocol stack for Linux | 2 | BlueZ - Bluetooth protocol stack for Linux |
3 | Copyright (C) 2000-2001 Qualcomm Incorporated | 3 | Copyright (C) 2000-2001 Qualcomm Incorporated |
4 | Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> | 4 | Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> |
@@ -14,13 +14,13 @@ | |||
14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
16 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | 16 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY |
17 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | 17 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
18 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 18 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
19 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 19 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
20 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 20 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
21 | 21 | ||
22 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | 22 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
23 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | 23 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
24 | SOFTWARE IS DISCLAIMED. | 24 | SOFTWARE IS DISCLAIMED. |
25 | */ | 25 | */ |
26 | 26 | ||
@@ -38,6 +38,7 @@ | |||
38 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ | 38 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ |
39 | #define L2CAP_DEFAULT_ACK_TO 200 | 39 | #define L2CAP_DEFAULT_ACK_TO 200 |
40 | #define L2CAP_LOCAL_BUSY_TRIES 12 | 40 | #define L2CAP_LOCAL_BUSY_TRIES 12 |
41 | #define L2CAP_LE_DEFAULT_MTU 23 | ||
41 | 42 | ||
42 | #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ | 43 | #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ |
43 | #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ | 44 | #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ |
@@ -88,6 +89,8 @@ struct l2cap_conninfo { | |||
88 | #define L2CAP_ECHO_RSP 0x09 | 89 | #define L2CAP_ECHO_RSP 0x09 |
89 | #define L2CAP_INFO_REQ 0x0a | 90 | #define L2CAP_INFO_REQ 0x0a |
90 | #define L2CAP_INFO_RSP 0x0b | 91 | #define L2CAP_INFO_RSP 0x0b |
92 | #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 | ||
93 | #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 | ||
91 | 94 | ||
92 | /* L2CAP feature mask */ | 95 | /* L2CAP feature mask */ |
93 | #define L2CAP_FEAT_FLOWCTL 0x00000001 | 96 | #define L2CAP_FEAT_FLOWCTL 0x00000001 |
@@ -160,6 +163,9 @@ struct l2cap_conn_rsp { | |||
160 | /* channel indentifier */ | 163 | /* channel indentifier */ |
161 | #define L2CAP_CID_SIGNALING 0x0001 | 164 | #define L2CAP_CID_SIGNALING 0x0001 |
162 | #define L2CAP_CID_CONN_LESS 0x0002 | 165 | #define L2CAP_CID_CONN_LESS 0x0002 |
166 | #define L2CAP_CID_LE_DATA 0x0004 | ||
167 | #define L2CAP_CID_LE_SIGNALING 0x0005 | ||
168 | #define L2CAP_CID_SMP 0x0006 | ||
163 | #define L2CAP_CID_DYN_START 0x0040 | 169 | #define L2CAP_CID_DYN_START 0x0040 |
164 | #define L2CAP_CID_DYN_END 0xffff | 170 | #define L2CAP_CID_DYN_END 0xffff |
165 | 171 | ||
@@ -255,63 +261,32 @@ struct l2cap_info_rsp { | |||
255 | #define L2CAP_IR_SUCCESS 0x0000 | 261 | #define L2CAP_IR_SUCCESS 0x0000 |
256 | #define L2CAP_IR_NOTSUPP 0x0001 | 262 | #define L2CAP_IR_NOTSUPP 0x0001 |
257 | 263 | ||
258 | /* ----- L2CAP connections ----- */ | 264 | struct l2cap_conn_param_update_req { |
259 | struct l2cap_chan_list { | 265 | __le16 min; |
260 | struct sock *head; | 266 | __le16 max; |
261 | rwlock_t lock; | 267 | __le16 latency; |
262 | long num; | 268 | __le16 to_multiplier; |
263 | }; | 269 | } __packed; |
264 | |||
265 | struct l2cap_conn { | ||
266 | struct hci_conn *hcon; | ||
267 | |||
268 | bdaddr_t *dst; | ||
269 | bdaddr_t *src; | ||
270 | |||
271 | unsigned int mtu; | ||
272 | |||
273 | __u32 feat_mask; | ||
274 | |||
275 | __u8 info_state; | ||
276 | __u8 info_ident; | ||
277 | |||
278 | struct timer_list info_timer; | ||
279 | |||
280 | spinlock_t lock; | ||
281 | |||
282 | struct sk_buff *rx_skb; | ||
283 | __u32 rx_len; | ||
284 | __u8 rx_ident; | ||
285 | __u8 tx_ident; | ||
286 | |||
287 | __u8 disc_reason; | ||
288 | |||
289 | struct l2cap_chan_list chan_list; | ||
290 | }; | ||
291 | |||
292 | struct sock_del_list { | ||
293 | struct sock *sk; | ||
294 | struct list_head list; | ||
295 | }; | ||
296 | 270 | ||
297 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | 271 | struct l2cap_conn_param_update_rsp { |
298 | #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 | 272 | __le16 result; |
299 | #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 | 273 | } __packed; |
300 | 274 | ||
301 | /* ----- L2CAP channel and socket info ----- */ | 275 | /* Connection Parameters result */ |
302 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | 276 | #define L2CAP_CONN_PARAM_ACCEPTED 0x0000 |
303 | #define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue) | 277 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 |
304 | #define SREJ_QUEUE(sk) (&l2cap_pi(sk)->srej_queue) | ||
305 | #define BUSY_QUEUE(sk) (&l2cap_pi(sk)->busy_queue) | ||
306 | #define SREJ_LIST(sk) (&l2cap_pi(sk)->srej_l.list) | ||
307 | 278 | ||
279 | /* ----- L2CAP channels and connections ----- */ | ||
308 | struct srej_list { | 280 | struct srej_list { |
309 | __u8 tx_seq; | 281 | __u8 tx_seq; |
310 | struct list_head list; | 282 | struct list_head list; |
311 | }; | 283 | }; |
312 | 284 | ||
313 | struct l2cap_pinfo { | 285 | struct l2cap_chan { |
314 | struct bt_sock bt; | 286 | struct sock *sk; |
287 | |||
288 | struct l2cap_conn *conn; | ||
289 | |||
315 | __le16 psm; | 290 | __le16 psm; |
316 | __u16 dcid; | 291 | __u16 dcid; |
317 | __u16 scid; | 292 | __u16 scid; |
@@ -320,16 +295,29 @@ struct l2cap_pinfo { | |||
320 | __u16 omtu; | 295 | __u16 omtu; |
321 | __u16 flush_to; | 296 | __u16 flush_to; |
322 | __u8 mode; | 297 | __u8 mode; |
323 | __u8 num_conf_req; | ||
324 | __u8 num_conf_rsp; | ||
325 | 298 | ||
326 | __u8 fcs; | 299 | __le16 sport; |
300 | |||
327 | __u8 sec_level; | 301 | __u8 sec_level; |
328 | __u8 role_switch; | 302 | __u8 role_switch; |
329 | __u8 force_reliable; | 303 | __u8 force_reliable; |
304 | __u8 flushable; | ||
305 | |||
306 | __u8 ident; | ||
330 | 307 | ||
331 | __u8 conf_req[64]; | 308 | __u8 conf_req[64]; |
332 | __u8 conf_len; | 309 | __u8 conf_len; |
310 | __u8 num_conf_req; | ||
311 | __u8 num_conf_rsp; | ||
312 | |||
313 | __u8 fcs; | ||
314 | |||
315 | __u8 tx_win; | ||
316 | __u8 max_tx; | ||
317 | __u16 retrans_timeout; | ||
318 | __u16 monitor_timeout; | ||
319 | __u16 mps; | ||
320 | |||
333 | __u8 conf_state; | 321 | __u8 conf_state; |
334 | __u16 conn_state; | 322 | __u16 conn_state; |
335 | 323 | ||
@@ -347,30 +335,61 @@ struct l2cap_pinfo { | |||
347 | __u16 partial_sdu_len; | 335 | __u16 partial_sdu_len; |
348 | struct sk_buff *sdu; | 336 | struct sk_buff *sdu; |
349 | 337 | ||
350 | __u8 ident; | ||
351 | |||
352 | __u8 tx_win; | ||
353 | __u8 max_tx; | ||
354 | __u8 remote_tx_win; | 338 | __u8 remote_tx_win; |
355 | __u8 remote_max_tx; | 339 | __u8 remote_max_tx; |
356 | __u16 retrans_timeout; | ||
357 | __u16 monitor_timeout; | ||
358 | __u16 remote_mps; | 340 | __u16 remote_mps; |
359 | __u16 mps; | ||
360 | |||
361 | __le16 sport; | ||
362 | 341 | ||
363 | struct timer_list retrans_timer; | 342 | struct timer_list retrans_timer; |
364 | struct timer_list monitor_timer; | 343 | struct timer_list monitor_timer; |
365 | struct timer_list ack_timer; | 344 | struct timer_list ack_timer; |
366 | struct sk_buff_head tx_queue; | 345 | struct sk_buff *tx_send_head; |
367 | struct sk_buff_head srej_queue; | 346 | struct sk_buff_head tx_q; |
368 | struct sk_buff_head busy_queue; | 347 | struct sk_buff_head srej_q; |
348 | struct sk_buff_head busy_q; | ||
369 | struct work_struct busy_work; | 349 | struct work_struct busy_work; |
370 | struct srej_list srej_l; | 350 | struct list_head srej_l; |
371 | struct l2cap_conn *conn; | 351 | |
372 | struct sock *next_c; | 352 | struct list_head list; |
373 | struct sock *prev_c; | 353 | struct list_head global_l; |
354 | }; | ||
355 | |||
356 | struct l2cap_conn { | ||
357 | struct hci_conn *hcon; | ||
358 | |||
359 | bdaddr_t *dst; | ||
360 | bdaddr_t *src; | ||
361 | |||
362 | unsigned int mtu; | ||
363 | |||
364 | __u32 feat_mask; | ||
365 | |||
366 | __u8 info_state; | ||
367 | __u8 info_ident; | ||
368 | |||
369 | struct timer_list info_timer; | ||
370 | |||
371 | spinlock_t lock; | ||
372 | |||
373 | struct sk_buff *rx_skb; | ||
374 | __u32 rx_len; | ||
375 | __u8 tx_ident; | ||
376 | |||
377 | __u8 disc_reason; | ||
378 | |||
379 | struct list_head chan_l; | ||
380 | rwlock_t chan_lock; | ||
381 | }; | ||
382 | |||
383 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | ||
384 | #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 | ||
385 | #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 | ||
386 | |||
387 | /* ----- L2CAP socket info ----- */ | ||
388 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | ||
389 | |||
390 | struct l2cap_pinfo { | ||
391 | struct bt_sock bt; | ||
392 | struct l2cap_chan *chan; | ||
374 | }; | 393 | }; |
375 | 394 | ||
376 | #define L2CAP_CONF_REQ_SENT 0x01 | 395 | #define L2CAP_CONF_REQ_SENT 0x01 |
@@ -397,32 +416,62 @@ struct l2cap_pinfo { | |||
397 | #define L2CAP_CONN_RNR_SENT 0x0200 | 416 | #define L2CAP_CONN_RNR_SENT 0x0200 |
398 | #define L2CAP_CONN_SAR_RETRY 0x0400 | 417 | #define L2CAP_CONN_SAR_RETRY 0x0400 |
399 | 418 | ||
400 | #define __mod_retrans_timer() mod_timer(&l2cap_pi(sk)->retrans_timer, \ | 419 | #define __mod_retrans_timer() mod_timer(&chan->retrans_timer, \ |
401 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); | 420 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); |
402 | #define __mod_monitor_timer() mod_timer(&l2cap_pi(sk)->monitor_timer, \ | 421 | #define __mod_monitor_timer() mod_timer(&chan->monitor_timer, \ |
403 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); | 422 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); |
404 | #define __mod_ack_timer() mod_timer(&l2cap_pi(sk)->ack_timer, \ | 423 | #define __mod_ack_timer() mod_timer(&chan->ack_timer, \ |
405 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); | 424 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); |
406 | 425 | ||
407 | static inline int l2cap_tx_window_full(struct sock *sk) | 426 | static inline int l2cap_tx_window_full(struct l2cap_chan *ch) |
408 | { | 427 | { |
409 | struct l2cap_pinfo *pi = l2cap_pi(sk); | ||
410 | int sub; | 428 | int sub; |
411 | 429 | ||
412 | sub = (pi->next_tx_seq - pi->expected_ack_seq) % 64; | 430 | sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; |
413 | 431 | ||
414 | if (sub < 0) | 432 | if (sub < 0) |
415 | sub += 64; | 433 | sub += 64; |
416 | 434 | ||
417 | return (sub == pi->remote_tx_win); | 435 | return sub == ch->remote_tx_win; |
418 | } | 436 | } |
419 | 437 | ||
420 | #define __get_txseq(ctrl) ((ctrl) & L2CAP_CTRL_TXSEQ) >> 1 | 438 | #define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) |
421 | #define __get_reqseq(ctrl) ((ctrl) & L2CAP_CTRL_REQSEQ) >> 8 | 439 | #define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8) |
422 | #define __is_iframe(ctrl) !((ctrl) & L2CAP_CTRL_FRAME_TYPE) | 440 | #define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) |
423 | #define __is_sframe(ctrl) (ctrl) & L2CAP_CTRL_FRAME_TYPE | 441 | #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) |
424 | #define __is_sar_start(ctrl) ((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START | 442 | #define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) |
425 | 443 | ||
426 | void l2cap_load(void); | 444 | extern int disable_ertm; |
445 | |||
446 | int l2cap_init_sockets(void); | ||
447 | void l2cap_cleanup_sockets(void); | ||
448 | |||
449 | void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); | ||
450 | void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); | ||
451 | int __l2cap_wait_ack(struct sock *sk); | ||
452 | |||
453 | struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); | ||
454 | struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); | ||
455 | struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen); | ||
456 | int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); | ||
457 | void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb); | ||
458 | void l2cap_streaming_send(struct l2cap_chan *chan); | ||
459 | int l2cap_ertm_send(struct l2cap_chan *chan); | ||
460 | |||
461 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); | ||
462 | int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); | ||
463 | |||
464 | void l2cap_sock_set_timer(struct sock *sk, long timeout); | ||
465 | void l2cap_sock_clear_timer(struct sock *sk); | ||
466 | void __l2cap_sock_close(struct sock *sk, int reason); | ||
467 | void l2cap_sock_kill(struct sock *sk); | ||
468 | void l2cap_sock_init(struct sock *sk, struct sock *parent); | ||
469 | struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, | ||
470 | int proto, gfp_t prio); | ||
471 | void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err); | ||
472 | struct l2cap_chan *l2cap_chan_create(struct sock *sk); | ||
473 | void l2cap_chan_del(struct l2cap_chan *chan, int err); | ||
474 | void l2cap_chan_destroy(struct l2cap_chan *chan); | ||
475 | int l2cap_chan_connect(struct l2cap_chan *chan); | ||
427 | 476 | ||
428 | #endif /* __L2CAP_H */ | 477 | #endif /* __L2CAP_H */ |