diff options
-rw-r--r-- | include/net/bluetooth/l2cap.h | 10 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 51 |
2 files changed, 29 insertions, 32 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 9b43874ca6e4..041213b4175a 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -293,6 +293,11 @@ struct l2cap_chan { | |||
293 | __u8 expected_tx_seq; | 293 | __u8 expected_tx_seq; |
294 | __u8 buffer_seq; | 294 | __u8 buffer_seq; |
295 | __u8 buffer_seq_srej; | 295 | __u8 buffer_seq_srej; |
296 | __u8 srej_save_reqseq; | ||
297 | __u8 frames_sent; | ||
298 | __u8 unacked_frames; | ||
299 | __u8 retry_count; | ||
300 | __u8 num_acked; | ||
296 | 301 | ||
297 | struct list_head list; | 302 | struct list_head list; |
298 | }; | 303 | }; |
@@ -359,11 +364,6 @@ struct l2cap_pinfo { | |||
359 | 364 | ||
360 | __u8 conf_state; | 365 | __u8 conf_state; |
361 | 366 | ||
362 | __u8 srej_save_reqseq; | ||
363 | __u8 frames_sent; | ||
364 | __u8 unacked_frames; | ||
365 | __u8 retry_count; | ||
366 | __u8 num_acked; | ||
367 | __u16 sdu_len; | 367 | __u16 sdu_len; |
368 | __u16 partial_sdu_len; | 368 | __u16 partial_sdu_len; |
369 | struct sk_buff *sdu; | 369 | struct sk_buff *sdu; |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index d975092904c1..3f601d1c164a 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -924,7 +924,7 @@ int __l2cap_wait_ack(struct sock *sk) | |||
924 | int timeo = HZ/5; | 924 | int timeo = HZ/5; |
925 | 925 | ||
926 | add_wait_queue(sk_sleep(sk), &wait); | 926 | add_wait_queue(sk_sleep(sk), &wait); |
927 | while ((l2cap_pi(sk)->unacked_frames > 0 && l2cap_pi(sk)->conn)) { | 927 | while ((l2cap_pi(sk)->chan->unacked_frames > 0 && l2cap_pi(sk)->conn)) { |
928 | set_current_state(TASK_INTERRUPTIBLE); | 928 | set_current_state(TASK_INTERRUPTIBLE); |
929 | 929 | ||
930 | if (!timeo) | 930 | if (!timeo) |
@@ -956,13 +956,13 @@ static void l2cap_monitor_timeout(unsigned long arg) | |||
956 | BT_DBG("chan %p", chan); | 956 | BT_DBG("chan %p", chan); |
957 | 957 | ||
958 | bh_lock_sock(sk); | 958 | bh_lock_sock(sk); |
959 | if (l2cap_pi(sk)->retry_count >= l2cap_pi(sk)->remote_max_tx) { | 959 | if (chan->retry_count >= l2cap_pi(sk)->remote_max_tx) { |
960 | l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk, ECONNABORTED); | 960 | l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk, ECONNABORTED); |
961 | bh_unlock_sock(sk); | 961 | bh_unlock_sock(sk); |
962 | return; | 962 | return; |
963 | } | 963 | } |
964 | 964 | ||
965 | l2cap_pi(sk)->retry_count++; | 965 | chan->retry_count++; |
966 | __mod_monitor_timer(); | 966 | __mod_monitor_timer(); |
967 | 967 | ||
968 | l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_POLL); | 968 | l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_POLL); |
@@ -977,7 +977,7 @@ static void l2cap_retrans_timeout(unsigned long arg) | |||
977 | BT_DBG("sk %p", sk); | 977 | BT_DBG("sk %p", sk); |
978 | 978 | ||
979 | bh_lock_sock(sk); | 979 | bh_lock_sock(sk); |
980 | l2cap_pi(sk)->retry_count = 1; | 980 | chan->retry_count = 1; |
981 | __mod_monitor_timer(); | 981 | __mod_monitor_timer(); |
982 | 982 | ||
983 | chan->conn_state |= L2CAP_CONN_WAIT_F; | 983 | chan->conn_state |= L2CAP_CONN_WAIT_F; |
@@ -992,17 +992,17 @@ static void l2cap_drop_acked_frames(struct l2cap_chan *chan) | |||
992 | struct sk_buff *skb; | 992 | struct sk_buff *skb; |
993 | 993 | ||
994 | while ((skb = skb_peek(TX_QUEUE(sk))) && | 994 | while ((skb = skb_peek(TX_QUEUE(sk))) && |
995 | l2cap_pi(sk)->unacked_frames) { | 995 | chan->unacked_frames) { |
996 | if (bt_cb(skb)->tx_seq == chan->expected_ack_seq) | 996 | if (bt_cb(skb)->tx_seq == chan->expected_ack_seq) |
997 | break; | 997 | break; |
998 | 998 | ||
999 | skb = skb_dequeue(TX_QUEUE(sk)); | 999 | skb = skb_dequeue(TX_QUEUE(sk)); |
1000 | kfree_skb(skb); | 1000 | kfree_skb(skb); |
1001 | 1001 | ||
1002 | l2cap_pi(sk)->unacked_frames--; | 1002 | chan->unacked_frames--; |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | if (!l2cap_pi(sk)->unacked_frames) | 1005 | if (!chan->unacked_frames) |
1006 | del_timer(&l2cap_pi(sk)->retrans_timer); | 1006 | del_timer(&l2cap_pi(sk)->retrans_timer); |
1007 | } | 1007 | } |
1008 | 1008 | ||
@@ -1141,9 +1141,9 @@ int l2cap_ertm_send(struct l2cap_chan *chan) | |||
1141 | chan->next_tx_seq = (chan->next_tx_seq + 1) % 64; | 1141 | chan->next_tx_seq = (chan->next_tx_seq + 1) % 64; |
1142 | 1142 | ||
1143 | if (bt_cb(skb)->retries == 1) | 1143 | if (bt_cb(skb)->retries == 1) |
1144 | pi->unacked_frames++; | 1144 | chan->unacked_frames++; |
1145 | 1145 | ||
1146 | pi->frames_sent++; | 1146 | chan->frames_sent++; |
1147 | 1147 | ||
1148 | if (skb_queue_is_last(TX_QUEUE(sk), skb)) | 1148 | if (skb_queue_is_last(TX_QUEUE(sk), skb)) |
1149 | sk->sk_send_head = NULL; | 1149 | sk->sk_send_head = NULL; |
@@ -1574,10 +1574,10 @@ static inline void l2cap_ertm_init(struct l2cap_chan *chan) | |||
1574 | struct sock *sk = chan->sk; | 1574 | struct sock *sk = chan->sk; |
1575 | 1575 | ||
1576 | chan->expected_ack_seq = 0; | 1576 | chan->expected_ack_seq = 0; |
1577 | l2cap_pi(sk)->unacked_frames = 0; | 1577 | chan->unacked_frames = 0; |
1578 | chan->buffer_seq = 0; | 1578 | chan->buffer_seq = 0; |
1579 | l2cap_pi(sk)->num_acked = 0; | 1579 | chan->num_acked = 0; |
1580 | l2cap_pi(sk)->frames_sent = 0; | 1580 | chan->frames_sent = 0; |
1581 | 1581 | ||
1582 | setup_timer(&l2cap_pi(sk)->retrans_timer, | 1582 | setup_timer(&l2cap_pi(sk)->retrans_timer, |
1583 | l2cap_retrans_timeout, (unsigned long) chan); | 1583 | l2cap_retrans_timeout, (unsigned long) chan); |
@@ -2787,10 +2787,9 @@ static int l2cap_check_fcs(struct l2cap_pinfo *pi, struct sk_buff *skb) | |||
2787 | 2787 | ||
2788 | static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) | 2788 | static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) |
2789 | { | 2789 | { |
2790 | struct l2cap_pinfo *pi = l2cap_pi(chan->sk); | ||
2791 | u16 control = 0; | 2790 | u16 control = 0; |
2792 | 2791 | ||
2793 | pi->frames_sent = 0; | 2792 | chan->frames_sent = 0; |
2794 | 2793 | ||
2795 | control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; | 2794 | control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; |
2796 | 2795 | ||
@@ -2806,7 +2805,7 @@ static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) | |||
2806 | l2cap_ertm_send(chan); | 2805 | l2cap_ertm_send(chan); |
2807 | 2806 | ||
2808 | if (!(chan->conn_state & L2CAP_CONN_LOCAL_BUSY) && | 2807 | if (!(chan->conn_state & L2CAP_CONN_LOCAL_BUSY) && |
2809 | pi->frames_sent == 0) { | 2808 | chan->frames_sent == 0) { |
2810 | control |= L2CAP_SUPER_RCV_READY; | 2809 | control |= L2CAP_SUPER_RCV_READY; |
2811 | l2cap_send_sframe(chan, control); | 2810 | l2cap_send_sframe(chan, control); |
2812 | } | 2811 | } |
@@ -2988,7 +2987,7 @@ static int l2cap_try_push_rx_skb(struct l2cap_chan *chan) | |||
2988 | control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; | 2987 | control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; |
2989 | control |= L2CAP_SUPER_RCV_READY | L2CAP_CTRL_POLL; | 2988 | control |= L2CAP_SUPER_RCV_READY | L2CAP_CTRL_POLL; |
2990 | l2cap_send_sframe(chan, control); | 2989 | l2cap_send_sframe(chan, control); |
2991 | l2cap_pi(sk)->retry_count = 1; | 2990 | chan->retry_count = 1; |
2992 | 2991 | ||
2993 | del_timer(&pi->retrans_timer); | 2992 | del_timer(&pi->retrans_timer); |
2994 | __mod_monitor_timer(); | 2993 | __mod_monitor_timer(); |
@@ -3260,7 +3259,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont | |||
3260 | if (L2CAP_CTRL_FINAL & rx_control && | 3259 | if (L2CAP_CTRL_FINAL & rx_control && |
3261 | chan->conn_state & L2CAP_CONN_WAIT_F) { | 3260 | chan->conn_state & L2CAP_CONN_WAIT_F) { |
3262 | del_timer(&pi->monitor_timer); | 3261 | del_timer(&pi->monitor_timer); |
3263 | if (pi->unacked_frames > 0) | 3262 | if (chan->unacked_frames > 0) |
3264 | __mod_retrans_timer(); | 3263 | __mod_retrans_timer(); |
3265 | chan->conn_state &= ~L2CAP_CONN_WAIT_F; | 3264 | chan->conn_state &= ~L2CAP_CONN_WAIT_F; |
3266 | } | 3265 | } |
@@ -3369,8 +3368,8 @@ expected: | |||
3369 | 3368 | ||
3370 | __mod_ack_timer(); | 3369 | __mod_ack_timer(); |
3371 | 3370 | ||
3372 | pi->num_acked = (pi->num_acked + 1) % num_to_ack; | 3371 | chan->num_acked = (chan->num_acked + 1) % num_to_ack; |
3373 | if (pi->num_acked == num_to_ack - 1) | 3372 | if (chan->num_acked == num_to_ack - 1) |
3374 | l2cap_send_ack(chan); | 3373 | l2cap_send_ack(chan); |
3375 | 3374 | ||
3376 | return 0; | 3375 | return 0; |
@@ -3383,7 +3382,6 @@ drop: | |||
3383 | static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_control) | 3382 | static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_control) |
3384 | { | 3383 | { |
3385 | struct sock *sk = chan->sk; | 3384 | struct sock *sk = chan->sk; |
3386 | struct l2cap_pinfo *pi = l2cap_pi(sk); | ||
3387 | 3385 | ||
3388 | BT_DBG("sk %p, req_seq %d ctrl 0x%4.4x", sk, __get_reqseq(rx_control), | 3386 | BT_DBG("sk %p, req_seq %d ctrl 0x%4.4x", sk, __get_reqseq(rx_control), |
3389 | rx_control); | 3387 | rx_control); |
@@ -3395,7 +3393,7 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co | |||
3395 | chan->conn_state |= L2CAP_CONN_SEND_FBIT; | 3393 | chan->conn_state |= L2CAP_CONN_SEND_FBIT; |
3396 | if (chan->conn_state & L2CAP_CONN_SREJ_SENT) { | 3394 | if (chan->conn_state & L2CAP_CONN_SREJ_SENT) { |
3397 | if ((chan->conn_state & L2CAP_CONN_REMOTE_BUSY) && | 3395 | if ((chan->conn_state & L2CAP_CONN_REMOTE_BUSY) && |
3398 | (pi->unacked_frames > 0)) | 3396 | (chan->unacked_frames > 0)) |
3399 | __mod_retrans_timer(); | 3397 | __mod_retrans_timer(); |
3400 | 3398 | ||
3401 | chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; | 3399 | chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; |
@@ -3414,7 +3412,7 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co | |||
3414 | 3412 | ||
3415 | } else { | 3413 | } else { |
3416 | if ((chan->conn_state & L2CAP_CONN_REMOTE_BUSY) && | 3414 | if ((chan->conn_state & L2CAP_CONN_REMOTE_BUSY) && |
3417 | (pi->unacked_frames > 0)) | 3415 | (chan->unacked_frames > 0)) |
3418 | __mod_retrans_timer(); | 3416 | __mod_retrans_timer(); |
3419 | 3417 | ||
3420 | chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; | 3418 | chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; |
@@ -3450,7 +3448,6 @@ static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_c | |||
3450 | } | 3448 | } |
3451 | static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_control) | 3449 | static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_control) |
3452 | { | 3450 | { |
3453 | struct l2cap_pinfo *pi = l2cap_pi(chan->sk); | ||
3454 | u8 tx_seq = __get_reqseq(rx_control); | 3451 | u8 tx_seq = __get_reqseq(rx_control); |
3455 | 3452 | ||
3456 | BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); | 3453 | BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); |
@@ -3467,19 +3464,19 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_ | |||
3467 | l2cap_ertm_send(chan); | 3464 | l2cap_ertm_send(chan); |
3468 | 3465 | ||
3469 | if (chan->conn_state & L2CAP_CONN_WAIT_F) { | 3466 | if (chan->conn_state & L2CAP_CONN_WAIT_F) { |
3470 | pi->srej_save_reqseq = tx_seq; | 3467 | chan->srej_save_reqseq = tx_seq; |
3471 | chan->conn_state |= L2CAP_CONN_SREJ_ACT; | 3468 | chan->conn_state |= L2CAP_CONN_SREJ_ACT; |
3472 | } | 3469 | } |
3473 | } else if (rx_control & L2CAP_CTRL_FINAL) { | 3470 | } else if (rx_control & L2CAP_CTRL_FINAL) { |
3474 | if ((chan->conn_state & L2CAP_CONN_SREJ_ACT) && | 3471 | if ((chan->conn_state & L2CAP_CONN_SREJ_ACT) && |
3475 | pi->srej_save_reqseq == tx_seq) | 3472 | chan->srej_save_reqseq == tx_seq) |
3476 | chan->conn_state &= ~L2CAP_CONN_SREJ_ACT; | 3473 | chan->conn_state &= ~L2CAP_CONN_SREJ_ACT; |
3477 | else | 3474 | else |
3478 | l2cap_retransmit_one_frame(chan, tx_seq); | 3475 | l2cap_retransmit_one_frame(chan, tx_seq); |
3479 | } else { | 3476 | } else { |
3480 | l2cap_retransmit_one_frame(chan, tx_seq); | 3477 | l2cap_retransmit_one_frame(chan, tx_seq); |
3481 | if (chan->conn_state & L2CAP_CONN_WAIT_F) { | 3478 | if (chan->conn_state & L2CAP_CONN_WAIT_F) { |
3482 | pi->srej_save_reqseq = tx_seq; | 3479 | chan->srej_save_reqseq = tx_seq; |
3483 | chan->conn_state |= L2CAP_CONN_SREJ_ACT; | 3480 | chan->conn_state |= L2CAP_CONN_SREJ_ACT; |
3484 | } | 3481 | } |
3485 | } | 3482 | } |
@@ -3521,7 +3518,7 @@ static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_cont | |||
3521 | if (L2CAP_CTRL_FINAL & rx_control && | 3518 | if (L2CAP_CTRL_FINAL & rx_control && |
3522 | chan->conn_state & L2CAP_CONN_WAIT_F) { | 3519 | chan->conn_state & L2CAP_CONN_WAIT_F) { |
3523 | del_timer(&l2cap_pi(sk)->monitor_timer); | 3520 | del_timer(&l2cap_pi(sk)->monitor_timer); |
3524 | if (l2cap_pi(sk)->unacked_frames > 0) | 3521 | if (chan->unacked_frames > 0) |
3525 | __mod_retrans_timer(); | 3522 | __mod_retrans_timer(); |
3526 | chan->conn_state &= ~L2CAP_CONN_WAIT_F; | 3523 | chan->conn_state &= ~L2CAP_CONN_WAIT_F; |
3527 | } | 3524 | } |