diff options
Diffstat (limited to 'include/net/bluetooth/l2cap.h')
-rw-r--r-- | include/net/bluetooth/l2cap.h | 87 |
1 files changed, 54 insertions, 33 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index b1664ed884e6..9b242c6bf55b 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -45,11 +45,11 @@ | |||
45 | #define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF | 45 | #define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF |
46 | #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF | 46 | #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF |
47 | 47 | ||
48 | #define L2CAP_DISC_TIMEOUT (100) | 48 | #define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100) |
49 | #define L2CAP_DISC_REJ_TIMEOUT (5000) /* 5 seconds */ | 49 | #define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000) |
50 | #define L2CAP_ENC_TIMEOUT (5000) /* 5 seconds */ | 50 | #define L2CAP_ENC_TIMEOUT msecs_to_jiffies(5000) |
51 | #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ | 51 | #define L2CAP_CONN_TIMEOUT msecs_to_jiffies(40000) |
52 | #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ | 52 | #define L2CAP_INFO_TIMEOUT msecs_to_jiffies(4000) |
53 | 53 | ||
54 | /* L2CAP socket address */ | 54 | /* L2CAP socket address */ |
55 | struct sockaddr_l2 { | 55 | struct sockaddr_l2 { |
@@ -492,51 +492,56 @@ struct l2cap_chan { | |||
492 | struct sk_buff_head srej_q; | 492 | struct sk_buff_head srej_q; |
493 | struct list_head srej_l; | 493 | struct list_head srej_l; |
494 | 494 | ||
495 | struct list_head list; | 495 | struct list_head list; |
496 | struct list_head global_l; | 496 | struct list_head global_l; |
497 | 497 | ||
498 | void *data; | 498 | void *data; |
499 | struct l2cap_ops *ops; | 499 | struct l2cap_ops *ops; |
500 | struct mutex lock; | ||
500 | }; | 501 | }; |
501 | 502 | ||
502 | struct l2cap_ops { | 503 | struct l2cap_ops { |
503 | char *name; | 504 | char *name; |
504 | 505 | ||
505 | struct l2cap_chan *(*new_connection) (void *data); | 506 | struct l2cap_chan *(*new_connection) (void *data); |
506 | int (*recv) (void *data, struct sk_buff *skb); | 507 | int (*recv) (void *data, struct sk_buff *skb); |
507 | void (*close) (void *data); | 508 | void (*close) (void *data); |
508 | void (*state_change) (void *data, int state); | 509 | void (*state_change) (void *data, int state); |
510 | struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, | ||
511 | unsigned long len, int nb, int *err); | ||
512 | |||
509 | }; | 513 | }; |
510 | 514 | ||
511 | struct l2cap_conn { | 515 | struct l2cap_conn { |
512 | struct hci_conn *hcon; | 516 | struct hci_conn *hcon; |
513 | struct hci_chan *hchan; | 517 | struct hci_chan *hchan; |
514 | 518 | ||
515 | bdaddr_t *dst; | 519 | bdaddr_t *dst; |
516 | bdaddr_t *src; | 520 | bdaddr_t *src; |
517 | 521 | ||
518 | unsigned int mtu; | 522 | unsigned int mtu; |
519 | 523 | ||
520 | __u32 feat_mask; | 524 | __u32 feat_mask; |
525 | __u8 fixed_chan_mask; | ||
521 | 526 | ||
522 | __u8 info_state; | 527 | __u8 info_state; |
523 | __u8 info_ident; | 528 | __u8 info_ident; |
524 | 529 | ||
525 | struct delayed_work info_timer; | 530 | struct delayed_work info_timer; |
526 | 531 | ||
527 | spinlock_t lock; | 532 | spinlock_t lock; |
528 | 533 | ||
529 | struct sk_buff *rx_skb; | 534 | struct sk_buff *rx_skb; |
530 | __u32 rx_len; | 535 | __u32 rx_len; |
531 | __u8 tx_ident; | 536 | __u8 tx_ident; |
532 | 537 | ||
533 | __u8 disc_reason; | 538 | __u8 disc_reason; |
534 | 539 | ||
535 | struct delayed_work security_timer; | 540 | struct delayed_work security_timer; |
536 | struct smp_chan *smp_chan; | 541 | struct smp_chan *smp_chan; |
537 | 542 | ||
538 | struct list_head chan_l; | 543 | struct list_head chan_l; |
539 | struct mutex chan_lock; | 544 | struct mutex chan_lock; |
540 | }; | 545 | }; |
541 | 546 | ||
542 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | 547 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 |
@@ -551,9 +556,9 @@ struct l2cap_conn { | |||
551 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | 556 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) |
552 | 557 | ||
553 | struct l2cap_pinfo { | 558 | struct l2cap_pinfo { |
554 | struct bt_sock bt; | 559 | struct bt_sock bt; |
555 | struct l2cap_chan *chan; | 560 | struct l2cap_chan *chan; |
556 | struct sk_buff *rx_busy_skb; | 561 | struct sk_buff *rx_busy_skb; |
557 | }; | 562 | }; |
558 | 563 | ||
559 | enum { | 564 | enum { |
@@ -606,21 +611,37 @@ static inline void l2cap_chan_put(struct l2cap_chan *c) | |||
606 | kfree(c); | 611 | kfree(c); |
607 | } | 612 | } |
608 | 613 | ||
614 | static inline void l2cap_chan_lock(struct l2cap_chan *chan) | ||
615 | { | ||
616 | mutex_lock(&chan->lock); | ||
617 | } | ||
618 | |||
619 | static inline void l2cap_chan_unlock(struct l2cap_chan *chan) | ||
620 | { | ||
621 | mutex_unlock(&chan->lock); | ||
622 | } | ||
623 | |||
609 | static inline void l2cap_set_timer(struct l2cap_chan *chan, | 624 | static inline void l2cap_set_timer(struct l2cap_chan *chan, |
610 | struct delayed_work *work, long timeout) | 625 | struct delayed_work *work, long timeout) |
611 | { | 626 | { |
612 | BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout); | 627 | BT_DBG("chan %p state %s timeout %ld", chan, |
628 | state_to_string(chan->state), timeout); | ||
613 | 629 | ||
614 | if (!cancel_delayed_work(work)) | 630 | if (!cancel_delayed_work(work)) |
615 | l2cap_chan_hold(chan); | 631 | l2cap_chan_hold(chan); |
616 | schedule_delayed_work(work, timeout); | 632 | schedule_delayed_work(work, timeout); |
617 | } | 633 | } |
618 | 634 | ||
619 | static inline void l2cap_clear_timer(struct l2cap_chan *chan, | 635 | static inline bool l2cap_clear_timer(struct l2cap_chan *chan, |
620 | struct delayed_work *work) | 636 | struct delayed_work *work) |
621 | { | 637 | { |
622 | if (cancel_delayed_work(work)) | 638 | bool ret; |
639 | |||
640 | ret = cancel_delayed_work(work); | ||
641 | if (ret) | ||
623 | l2cap_chan_put(chan); | 642 | l2cap_chan_put(chan); |
643 | |||
644 | return ret; | ||
624 | } | 645 | } |
625 | 646 | ||
626 | #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) | 647 | #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) |