aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-03-25 18:58:34 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-04-07 17:06:26 -0400
commit42e5c8027bad6f1591032941f0ebf4fc079405c8 (patch)
treec0f95eca98dafd0104f01b3967cd7f1d643bcfe3
parent525cd1851b9faaadf5ea33e05192b8d22f42487e (diff)
Bluetooth: Move of ERTM *_seq vars to struct l2cap_chan
As part of the moving channel to stuff to struct l2cap_chan. Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r--include/net/bluetooth/l2cap.h20
-rw-r--r--net/bluetooth/l2cap_core.c128
-rw-r--r--net/bluetooth/l2cap_sock.c2
3 files changed, 73 insertions, 77 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 82d5b81a779b..9b43874ca6e4 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -288,6 +288,12 @@ struct l2cap_chan {
288 288
289 __u16 conn_state; 289 __u16 conn_state;
290 290
291 __u8 next_tx_seq;
292 __u8 expected_ack_seq;
293 __u8 expected_tx_seq;
294 __u8 buffer_seq;
295 __u8 buffer_seq_srej;
296
291 struct list_head list; 297 struct list_head list;
292}; 298};
293 299
@@ -353,11 +359,6 @@ struct l2cap_pinfo {
353 359
354 __u8 conf_state; 360 __u8 conf_state;
355 361
356 __u8 next_tx_seq;
357 __u8 expected_ack_seq;
358 __u8 expected_tx_seq;
359 __u8 buffer_seq;
360 __u8 buffer_seq_srej;
361 __u8 srej_save_reqseq; 362 __u8 srej_save_reqseq;
362 __u8 frames_sent; 363 __u8 frames_sent;
363 __u8 unacked_frames; 364 __u8 unacked_frames;
@@ -421,17 +422,16 @@ struct l2cap_pinfo {
421#define __mod_ack_timer() mod_timer(&l2cap_pi(sk)->ack_timer, \ 422#define __mod_ack_timer() mod_timer(&l2cap_pi(sk)->ack_timer, \
422 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); 423 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO));
423 424
424static inline int l2cap_tx_window_full(struct sock *sk) 425static inline int l2cap_tx_window_full(struct l2cap_chan *ch)
425{ 426{
426 struct l2cap_pinfo *pi = l2cap_pi(sk);
427 int sub; 427 int sub;
428 428
429 sub = (pi->next_tx_seq - pi->expected_ack_seq) % 64; 429 sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64;
430 430
431 if (sub < 0) 431 if (sub < 0)
432 sub += 64; 432 sub += 64;
433 433
434 return sub == pi->remote_tx_win; 434 return sub == l2cap_pi(ch->sk)->remote_tx_win;
435} 435}
436 436
437#define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) 437#define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1)
@@ -456,7 +456,7 @@ struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size
456struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen); 456struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen);
457int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len); 457int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len);
458void l2cap_do_send(struct sock *sk, struct sk_buff *skb); 458void l2cap_do_send(struct sock *sk, struct sk_buff *skb);
459void l2cap_streaming_send(struct sock *sk); 459void l2cap_streaming_send(struct l2cap_chan *chan);
460int l2cap_ertm_send(struct l2cap_chan *chan); 460int l2cap_ertm_send(struct l2cap_chan *chan);
461 461
462void l2cap_sock_set_timer(struct sock *sk, long timeout); 462void l2cap_sock_set_timer(struct sock *sk, long timeout);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b5435cd74f99..d975092904c1 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -395,15 +395,13 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control)
395 395
396static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control) 396static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control)
397{ 397{
398 struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
399
400 if (chan->conn_state & L2CAP_CONN_LOCAL_BUSY) { 398 if (chan->conn_state & L2CAP_CONN_LOCAL_BUSY) {
401 control |= L2CAP_SUPER_RCV_NOT_READY; 399 control |= L2CAP_SUPER_RCV_NOT_READY;
402 chan->conn_state |= L2CAP_CONN_RNR_SENT; 400 chan->conn_state |= L2CAP_CONN_RNR_SENT;
403 } else 401 } else
404 control |= L2CAP_SUPER_RCV_READY; 402 control |= L2CAP_SUPER_RCV_READY;
405 403
406 control |= pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 404 control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT;
407 405
408 l2cap_send_sframe(chan, control); 406 l2cap_send_sframe(chan, control);
409} 407}
@@ -988,13 +986,14 @@ static void l2cap_retrans_timeout(unsigned long arg)
988 bh_unlock_sock(sk); 986 bh_unlock_sock(sk);
989} 987}
990 988
991static void l2cap_drop_acked_frames(struct sock *sk) 989static void l2cap_drop_acked_frames(struct l2cap_chan *chan)
992{ 990{
991 struct sock *sk = chan->sk;
993 struct sk_buff *skb; 992 struct sk_buff *skb;
994 993
995 while ((skb = skb_peek(TX_QUEUE(sk))) && 994 while ((skb = skb_peek(TX_QUEUE(sk))) &&
996 l2cap_pi(sk)->unacked_frames) { 995 l2cap_pi(sk)->unacked_frames) {
997 if (bt_cb(skb)->tx_seq == l2cap_pi(sk)->expected_ack_seq) 996 if (bt_cb(skb)->tx_seq == chan->expected_ack_seq)
998 break; 997 break;
999 998
1000 skb = skb_dequeue(TX_QUEUE(sk)); 999 skb = skb_dequeue(TX_QUEUE(sk));
@@ -1023,15 +1022,16 @@ void l2cap_do_send(struct sock *sk, struct sk_buff *skb)
1023 hci_send_acl(hcon, skb, flags); 1022 hci_send_acl(hcon, skb, flags);
1024} 1023}
1025 1024
1026void l2cap_streaming_send(struct sock *sk) 1025void l2cap_streaming_send(struct l2cap_chan *chan)
1027{ 1026{
1027 struct sock *sk = chan->sk;
1028 struct sk_buff *skb; 1028 struct sk_buff *skb;
1029 struct l2cap_pinfo *pi = l2cap_pi(sk); 1029 struct l2cap_pinfo *pi = l2cap_pi(sk);
1030 u16 control, fcs; 1030 u16 control, fcs;
1031 1031
1032 while ((skb = skb_dequeue(TX_QUEUE(sk)))) { 1032 while ((skb = skb_dequeue(TX_QUEUE(sk)))) {
1033 control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE); 1033 control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE);
1034 control |= pi->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; 1034 control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT;
1035 put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE); 1035 put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE);
1036 1036
1037 if (pi->fcs == L2CAP_FCS_CRC16) { 1037 if (pi->fcs == L2CAP_FCS_CRC16) {
@@ -1041,7 +1041,7 @@ void l2cap_streaming_send(struct sock *sk)
1041 1041
1042 l2cap_do_send(sk, skb); 1042 l2cap_do_send(sk, skb);
1043 1043
1044 pi->next_tx_seq = (pi->next_tx_seq + 1) % 64; 1044 chan->next_tx_seq = (chan->next_tx_seq + 1) % 64;
1045 } 1045 }
1046} 1046}
1047 1047
@@ -1080,7 +1080,7 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq)
1080 chan->conn_state &= ~L2CAP_CONN_SEND_FBIT; 1080 chan->conn_state &= ~L2CAP_CONN_SEND_FBIT;
1081 } 1081 }
1082 1082
1083 control |= (pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) 1083 control |= (chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT)
1084 | (tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); 1084 | (tx_seq << L2CAP_CTRL_TXSEQ_SHIFT);
1085 1085
1086 put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); 1086 put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE);
@@ -1104,7 +1104,7 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
1104 if (sk->sk_state != BT_CONNECTED) 1104 if (sk->sk_state != BT_CONNECTED)
1105 return -ENOTCONN; 1105 return -ENOTCONN;
1106 1106
1107 while ((skb = sk->sk_send_head) && (!l2cap_tx_window_full(sk))) { 1107 while ((skb = sk->sk_send_head) && (!l2cap_tx_window_full(chan))) {
1108 1108
1109 if (pi->remote_max_tx && 1109 if (pi->remote_max_tx &&
1110 bt_cb(skb)->retries == pi->remote_max_tx) { 1110 bt_cb(skb)->retries == pi->remote_max_tx) {
@@ -1123,8 +1123,8 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
1123 control |= L2CAP_CTRL_FINAL; 1123 control |= L2CAP_CTRL_FINAL;
1124 chan->conn_state &= ~L2CAP_CONN_SEND_FBIT; 1124 chan->conn_state &= ~L2CAP_CONN_SEND_FBIT;
1125 } 1125 }
1126 control |= (pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) 1126 control |= (chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT)
1127 | (pi->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); 1127 | (chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT);
1128 put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); 1128 put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE);
1129 1129
1130 1130
@@ -1137,8 +1137,8 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
1137 1137
1138 __mod_retrans_timer(); 1138 __mod_retrans_timer();
1139 1139
1140 bt_cb(skb)->tx_seq = pi->next_tx_seq; 1140 bt_cb(skb)->tx_seq = chan->next_tx_seq;
1141 pi->next_tx_seq = (pi->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 pi->unacked_frames++;
@@ -1159,23 +1159,21 @@ int l2cap_ertm_send(struct l2cap_chan *chan)
1159static int l2cap_retransmit_frames(struct l2cap_chan *chan) 1159static int l2cap_retransmit_frames(struct l2cap_chan *chan)
1160{ 1160{
1161 struct sock *sk = chan->sk; 1161 struct sock *sk = chan->sk;
1162 struct l2cap_pinfo *pi = l2cap_pi(sk);
1163 int ret; 1162 int ret;
1164 1163
1165 if (!skb_queue_empty(TX_QUEUE(sk))) 1164 if (!skb_queue_empty(TX_QUEUE(sk)))
1166 sk->sk_send_head = TX_QUEUE(sk)->next; 1165 sk->sk_send_head = TX_QUEUE(sk)->next;
1167 1166
1168 pi->next_tx_seq = pi->expected_ack_seq; 1167 chan->next_tx_seq = chan->expected_ack_seq;
1169 ret = l2cap_ertm_send(chan); 1168 ret = l2cap_ertm_send(chan);
1170 return ret; 1169 return ret;
1171} 1170}
1172 1171
1173static void l2cap_send_ack(struct l2cap_chan *chan) 1172static void l2cap_send_ack(struct l2cap_chan *chan)
1174{ 1173{
1175 struct sock *sk = chan->sk;
1176 u16 control = 0; 1174 u16 control = 0;
1177 1175
1178 control |= l2cap_pi(sk)->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 1176 control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT;
1179 1177
1180 if (chan->conn_state & L2CAP_CONN_LOCAL_BUSY) { 1178 if (chan->conn_state & L2CAP_CONN_LOCAL_BUSY) {
1181 control |= L2CAP_SUPER_RCV_NOT_READY; 1179 control |= L2CAP_SUPER_RCV_NOT_READY;
@@ -1575,9 +1573,9 @@ static inline void l2cap_ertm_init(struct l2cap_chan *chan)
1575{ 1573{
1576 struct sock *sk = chan->sk; 1574 struct sock *sk = chan->sk;
1577 1575
1578 l2cap_pi(sk)->expected_ack_seq = 0; 1576 chan->expected_ack_seq = 0;
1579 l2cap_pi(sk)->unacked_frames = 0; 1577 l2cap_pi(sk)->unacked_frames = 0;
1580 l2cap_pi(sk)->buffer_seq = 0; 1578 chan->buffer_seq = 0;
1581 l2cap_pi(sk)->num_acked = 0; 1579 l2cap_pi(sk)->num_acked = 0;
1582 l2cap_pi(sk)->frames_sent = 0; 1580 l2cap_pi(sk)->frames_sent = 0;
1583 1581
@@ -2311,8 +2309,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2311 2309
2312 sk->sk_state = BT_CONNECTED; 2310 sk->sk_state = BT_CONNECTED;
2313 2311
2314 l2cap_pi(sk)->next_tx_seq = 0; 2312 chan->next_tx_seq = 0;
2315 l2cap_pi(sk)->expected_tx_seq = 0; 2313 chan->expected_tx_seq = 0;
2316 __skb_queue_head_init(TX_QUEUE(sk)); 2314 __skb_queue_head_init(TX_QUEUE(sk));
2317 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) 2315 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM)
2318 l2cap_ertm_init(chan); 2316 l2cap_ertm_init(chan);
@@ -2402,8 +2400,8 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2402 set_default_fcs(l2cap_pi(sk)); 2400 set_default_fcs(l2cap_pi(sk));
2403 2401
2404 sk->sk_state = BT_CONNECTED; 2402 sk->sk_state = BT_CONNECTED;
2405 l2cap_pi(sk)->next_tx_seq = 0; 2403 chan->next_tx_seq = 0;
2406 l2cap_pi(sk)->expected_tx_seq = 0; 2404 chan->expected_tx_seq = 0;
2407 __skb_queue_head_init(TX_QUEUE(sk)); 2405 __skb_queue_head_init(TX_QUEUE(sk));
2408 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM) 2406 if (l2cap_pi(sk)->mode == L2CAP_MODE_ERTM)
2409 l2cap_ertm_init(chan); 2407 l2cap_ertm_init(chan);
@@ -2794,7 +2792,7 @@ static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan)
2794 2792
2795 pi->frames_sent = 0; 2793 pi->frames_sent = 0;
2796 2794
2797 control |= pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 2795 control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT;
2798 2796
2799 if (chan->conn_state & L2CAP_CONN_LOCAL_BUSY) { 2797 if (chan->conn_state & L2CAP_CONN_LOCAL_BUSY) {
2800 control |= L2CAP_SUPER_RCV_NOT_READY; 2798 control |= L2CAP_SUPER_RCV_NOT_READY;
@@ -2814,10 +2812,10 @@ static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan)
2814 } 2812 }
2815} 2813}
2816 2814
2817static int l2cap_add_to_srej_queue(struct sock *sk, struct sk_buff *skb, u8 tx_seq, u8 sar) 2815static int l2cap_add_to_srej_queue(struct l2cap_chan *chan, struct sk_buff *skb, u8 tx_seq, u8 sar)
2818{ 2816{
2817 struct sock *sk = chan->sk;
2819 struct sk_buff *next_skb; 2818 struct sk_buff *next_skb;
2820 struct l2cap_pinfo *pi = l2cap_pi(sk);
2821 int tx_seq_offset, next_tx_seq_offset; 2819 int tx_seq_offset, next_tx_seq_offset;
2822 2820
2823 bt_cb(skb)->tx_seq = tx_seq; 2821 bt_cb(skb)->tx_seq = tx_seq;
@@ -2829,7 +2827,7 @@ static int l2cap_add_to_srej_queue(struct sock *sk, struct sk_buff *skb, u8 tx_s
2829 return 0; 2827 return 0;
2830 } 2828 }
2831 2829
2832 tx_seq_offset = (tx_seq - pi->buffer_seq) % 64; 2830 tx_seq_offset = (tx_seq - chan->buffer_seq) % 64;
2833 if (tx_seq_offset < 0) 2831 if (tx_seq_offset < 0)
2834 tx_seq_offset += 64; 2832 tx_seq_offset += 64;
2835 2833
@@ -2838,7 +2836,7 @@ static int l2cap_add_to_srej_queue(struct sock *sk, struct sk_buff *skb, u8 tx_s
2838 return -EINVAL; 2836 return -EINVAL;
2839 2837
2840 next_tx_seq_offset = (bt_cb(next_skb)->tx_seq - 2838 next_tx_seq_offset = (bt_cb(next_skb)->tx_seq -
2841 pi->buffer_seq) % 64; 2839 chan->buffer_seq) % 64;
2842 if (next_tx_seq_offset < 0) 2840 if (next_tx_seq_offset < 0)
2843 next_tx_seq_offset += 64; 2841 next_tx_seq_offset += 64;
2844 2842
@@ -2981,13 +2979,13 @@ static int l2cap_try_push_rx_skb(struct l2cap_chan *chan)
2981 return -EBUSY; 2979 return -EBUSY;
2982 } 2980 }
2983 2981
2984 pi->buffer_seq = (pi->buffer_seq + 1) % 64; 2982 chan->buffer_seq = (chan->buffer_seq + 1) % 64;
2985 } 2983 }
2986 2984
2987 if (!(chan->conn_state & L2CAP_CONN_RNR_SENT)) 2985 if (!(chan->conn_state & L2CAP_CONN_RNR_SENT))
2988 goto done; 2986 goto done;
2989 2987
2990 control = pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 2988 control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT;
2991 control |= L2CAP_SUPER_RCV_READY | L2CAP_CTRL_POLL; 2989 control |= L2CAP_SUPER_RCV_READY | L2CAP_CTRL_POLL;
2992 l2cap_send_sframe(chan, control); 2990 l2cap_send_sframe(chan, control);
2993 l2cap_pi(sk)->retry_count = 1; 2991 l2cap_pi(sk)->retry_count = 1;
@@ -3069,7 +3067,7 @@ static int l2cap_push_rx_skb(struct l2cap_chan *chan, struct sk_buff *skb, u16 c
3069 3067
3070 err = l2cap_ertm_reassembly_sdu(chan, skb, control); 3068 err = l2cap_ertm_reassembly_sdu(chan, skb, control);
3071 if (err >= 0) { 3069 if (err >= 0) {
3072 pi->buffer_seq = (pi->buffer_seq + 1) % 64; 3070 chan->buffer_seq = (chan->buffer_seq + 1) % 64;
3073 return err; 3071 return err;
3074 } 3072 }
3075 3073
@@ -3080,7 +3078,7 @@ static int l2cap_push_rx_skb(struct l2cap_chan *chan, struct sk_buff *skb, u16 c
3080 bt_cb(skb)->sar = control >> L2CAP_CTRL_SAR_SHIFT; 3078 bt_cb(skb)->sar = control >> L2CAP_CTRL_SAR_SHIFT;
3081 __skb_queue_tail(BUSY_QUEUE(sk), skb); 3079 __skb_queue_tail(BUSY_QUEUE(sk), skb);
3082 3080
3083 sctrl = pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3081 sctrl = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT;
3084 sctrl |= L2CAP_SUPER_RCV_NOT_READY; 3082 sctrl |= L2CAP_SUPER_RCV_NOT_READY;
3085 l2cap_send_sframe(chan, sctrl); 3083 l2cap_send_sframe(chan, sctrl);
3086 3084
@@ -3200,8 +3198,8 @@ static void l2cap_check_srej_gap(struct l2cap_chan *chan, u8 tx_seq)
3200 skb = skb_dequeue(SREJ_QUEUE(sk)); 3198 skb = skb_dequeue(SREJ_QUEUE(sk));
3201 control = bt_cb(skb)->sar << L2CAP_CTRL_SAR_SHIFT; 3199 control = bt_cb(skb)->sar << L2CAP_CTRL_SAR_SHIFT;
3202 l2cap_ertm_reassembly_sdu(chan, skb, control); 3200 l2cap_ertm_reassembly_sdu(chan, skb, control);
3203 l2cap_pi(sk)->buffer_seq_srej = 3201 chan->buffer_seq_srej =
3204 (l2cap_pi(sk)->buffer_seq_srej + 1) % 64; 3202 (chan->buffer_seq_srej + 1) % 64;
3205 tx_seq = (tx_seq + 1) % 64; 3203 tx_seq = (tx_seq + 1) % 64;
3206 } 3204 }
3207} 3205}
@@ -3229,21 +3227,20 @@ static void l2cap_resend_srejframe(struct l2cap_chan *chan, u8 tx_seq)
3229static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq) 3227static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq)
3230{ 3228{
3231 struct sock *sk = chan->sk; 3229 struct sock *sk = chan->sk;
3232 struct l2cap_pinfo *pi = l2cap_pi(sk);
3233 struct srej_list *new; 3230 struct srej_list *new;
3234 u16 control; 3231 u16 control;
3235 3232
3236 while (tx_seq != pi->expected_tx_seq) { 3233 while (tx_seq != chan->expected_tx_seq) {
3237 control = L2CAP_SUPER_SELECT_REJECT; 3234 control = L2CAP_SUPER_SELECT_REJECT;
3238 control |= pi->expected_tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3235 control |= chan->expected_tx_seq << L2CAP_CTRL_REQSEQ_SHIFT;
3239 l2cap_send_sframe(chan, control); 3236 l2cap_send_sframe(chan, control);
3240 3237
3241 new = kzalloc(sizeof(struct srej_list), GFP_ATOMIC); 3238 new = kzalloc(sizeof(struct srej_list), GFP_ATOMIC);
3242 new->tx_seq = pi->expected_tx_seq; 3239 new->tx_seq = chan->expected_tx_seq;
3243 pi->expected_tx_seq = (pi->expected_tx_seq + 1) % 64; 3240 chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64;
3244 list_add_tail(&new->list, SREJ_LIST(sk)); 3241 list_add_tail(&new->list, SREJ_LIST(sk));
3245 } 3242 }
3246 pi->expected_tx_seq = (pi->expected_tx_seq + 1) % 64; 3243 chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64;
3247} 3244}
3248 3245
3249static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) 3246static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb)
@@ -3268,13 +3265,13 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
3268 chan->conn_state &= ~L2CAP_CONN_WAIT_F; 3265 chan->conn_state &= ~L2CAP_CONN_WAIT_F;
3269 } 3266 }
3270 3267
3271 pi->expected_ack_seq = req_seq; 3268 chan->expected_ack_seq = req_seq;
3272 l2cap_drop_acked_frames(sk); 3269 l2cap_drop_acked_frames(chan);
3273 3270
3274 if (tx_seq == pi->expected_tx_seq) 3271 if (tx_seq == chan->expected_tx_seq)
3275 goto expected; 3272 goto expected;
3276 3273
3277 tx_seq_offset = (tx_seq - pi->buffer_seq) % 64; 3274 tx_seq_offset = (tx_seq - chan->buffer_seq) % 64;
3278 if (tx_seq_offset < 0) 3275 if (tx_seq_offset < 0)
3279 tx_seq_offset += 64; 3276 tx_seq_offset += 64;
3280 3277
@@ -3293,14 +3290,14 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
3293 first = list_first_entry(SREJ_LIST(sk), 3290 first = list_first_entry(SREJ_LIST(sk),
3294 struct srej_list, list); 3291 struct srej_list, list);
3295 if (tx_seq == first->tx_seq) { 3292 if (tx_seq == first->tx_seq) {
3296 l2cap_add_to_srej_queue(sk, skb, tx_seq, sar); 3293 l2cap_add_to_srej_queue(chan, skb, tx_seq, sar);
3297 l2cap_check_srej_gap(chan, tx_seq); 3294 l2cap_check_srej_gap(chan, tx_seq);
3298 3295
3299 list_del(&first->list); 3296 list_del(&first->list);
3300 kfree(first); 3297 kfree(first);
3301 3298
3302 if (list_empty(SREJ_LIST(sk))) { 3299 if (list_empty(SREJ_LIST(sk))) {
3303 pi->buffer_seq = pi->buffer_seq_srej; 3300 chan->buffer_seq = chan->buffer_seq_srej;
3304 chan->conn_state &= ~L2CAP_CONN_SREJ_SENT; 3301 chan->conn_state &= ~L2CAP_CONN_SREJ_SENT;
3305 l2cap_send_ack(chan); 3302 l2cap_send_ack(chan);
3306 BT_DBG("sk %p, Exit SREJ_SENT", sk); 3303 BT_DBG("sk %p, Exit SREJ_SENT", sk);
@@ -3309,7 +3306,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
3309 struct srej_list *l; 3306 struct srej_list *l;
3310 3307
3311 /* duplicated tx_seq */ 3308 /* duplicated tx_seq */
3312 if (l2cap_add_to_srej_queue(sk, skb, tx_seq, sar) < 0) 3309 if (l2cap_add_to_srej_queue(chan, skb, tx_seq, sar) < 0)
3313 goto drop; 3310 goto drop;
3314 3311
3315 list_for_each_entry(l, SREJ_LIST(sk), list) { 3312 list_for_each_entry(l, SREJ_LIST(sk), list) {
@@ -3322,7 +3319,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
3322 } 3319 }
3323 } else { 3320 } else {
3324 expected_tx_seq_offset = 3321 expected_tx_seq_offset =
3325 (pi->expected_tx_seq - pi->buffer_seq) % 64; 3322 (chan->expected_tx_seq - chan->buffer_seq) % 64;
3326 if (expected_tx_seq_offset < 0) 3323 if (expected_tx_seq_offset < 0)
3327 expected_tx_seq_offset += 64; 3324 expected_tx_seq_offset += 64;
3328 3325
@@ -3335,11 +3332,11 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
3335 BT_DBG("sk %p, Enter SREJ", sk); 3332 BT_DBG("sk %p, Enter SREJ", sk);
3336 3333
3337 INIT_LIST_HEAD(SREJ_LIST(sk)); 3334 INIT_LIST_HEAD(SREJ_LIST(sk));
3338 pi->buffer_seq_srej = pi->buffer_seq; 3335 chan->buffer_seq_srej = chan->buffer_seq;
3339 3336
3340 __skb_queue_head_init(SREJ_QUEUE(sk)); 3337 __skb_queue_head_init(SREJ_QUEUE(sk));
3341 __skb_queue_head_init(BUSY_QUEUE(sk)); 3338 __skb_queue_head_init(BUSY_QUEUE(sk));
3342 l2cap_add_to_srej_queue(sk, skb, tx_seq, sar); 3339 l2cap_add_to_srej_queue(chan, skb, tx_seq, sar);
3343 3340
3344 chan->conn_state |= L2CAP_CONN_SEND_PBIT; 3341 chan->conn_state |= L2CAP_CONN_SEND_PBIT;
3345 3342
@@ -3350,7 +3347,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
3350 return 0; 3347 return 0;
3351 3348
3352expected: 3349expected:
3353 pi->expected_tx_seq = (pi->expected_tx_seq + 1) % 64; 3350 chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64;
3354 3351
3355 if (chan->conn_state & L2CAP_CONN_SREJ_SENT) { 3352 if (chan->conn_state & L2CAP_CONN_SREJ_SENT) {
3356 bt_cb(skb)->tx_seq = tx_seq; 3353 bt_cb(skb)->tx_seq = tx_seq;
@@ -3391,8 +3388,8 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co
3391 BT_DBG("sk %p, req_seq %d ctrl 0x%4.4x", sk, __get_reqseq(rx_control), 3388 BT_DBG("sk %p, req_seq %d ctrl 0x%4.4x", sk, __get_reqseq(rx_control),
3392 rx_control); 3389 rx_control);
3393 3390
3394 pi->expected_ack_seq = __get_reqseq(rx_control); 3391 chan->expected_ack_seq = __get_reqseq(rx_control);
3395 l2cap_drop_acked_frames(sk); 3392 l2cap_drop_acked_frames(chan);
3396 3393
3397 if (rx_control & L2CAP_CTRL_POLL) { 3394 if (rx_control & L2CAP_CTRL_POLL) {
3398 chan->conn_state |= L2CAP_CONN_SEND_FBIT; 3395 chan->conn_state |= L2CAP_CONN_SEND_FBIT;
@@ -3430,15 +3427,14 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co
3430 3427
3431static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_control) 3428static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_control)
3432{ 3429{
3433 struct l2cap_pinfo *pi = l2cap_pi(chan->sk);
3434 u8 tx_seq = __get_reqseq(rx_control); 3430 u8 tx_seq = __get_reqseq(rx_control);
3435 3431
3436 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); 3432 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
3437 3433
3438 chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; 3434 chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY;
3439 3435
3440 pi->expected_ack_seq = tx_seq; 3436 chan->expected_ack_seq = tx_seq;
3441 l2cap_drop_acked_frames(chan->sk); 3437 l2cap_drop_acked_frames(chan);
3442 3438
3443 if (rx_control & L2CAP_CTRL_FINAL) { 3439 if (rx_control & L2CAP_CTRL_FINAL) {
3444 if (chan->conn_state & L2CAP_CONN_REJ_ACT) 3440 if (chan->conn_state & L2CAP_CONN_REJ_ACT)
@@ -3462,8 +3458,8 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_
3462 chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; 3458 chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY;
3463 3459
3464 if (rx_control & L2CAP_CTRL_POLL) { 3460 if (rx_control & L2CAP_CTRL_POLL) {
3465 pi->expected_ack_seq = tx_seq; 3461 chan->expected_ack_seq = tx_seq;
3466 l2cap_drop_acked_frames(chan->sk); 3462 l2cap_drop_acked_frames(chan);
3467 3463
3468 chan->conn_state |= L2CAP_CONN_SEND_FBIT; 3464 chan->conn_state |= L2CAP_CONN_SEND_FBIT;
3469 l2cap_retransmit_one_frame(chan, tx_seq); 3465 l2cap_retransmit_one_frame(chan, tx_seq);
@@ -3497,8 +3493,8 @@ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_c
3497 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); 3493 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
3498 3494
3499 chan->conn_state |= L2CAP_CONN_REMOTE_BUSY; 3495 chan->conn_state |= L2CAP_CONN_REMOTE_BUSY;
3500 pi->expected_ack_seq = tx_seq; 3496 chan->expected_ack_seq = tx_seq;
3501 l2cap_drop_acked_frames(chan->sk); 3497 l2cap_drop_acked_frames(chan);
3502 3498
3503 if (rx_control & L2CAP_CTRL_POLL) 3499 if (rx_control & L2CAP_CTRL_POLL)
3504 chan->conn_state |= L2CAP_CONN_SEND_FBIT; 3500 chan->conn_state |= L2CAP_CONN_SEND_FBIT;
@@ -3584,12 +3580,12 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
3584 } 3580 }
3585 3581
3586 req_seq = __get_reqseq(control); 3582 req_seq = __get_reqseq(control);
3587 req_seq_offset = (req_seq - pi->expected_ack_seq) % 64; 3583 req_seq_offset = (req_seq - chan->expected_ack_seq) % 64;
3588 if (req_seq_offset < 0) 3584 if (req_seq_offset < 0)
3589 req_seq_offset += 64; 3585 req_seq_offset += 64;
3590 3586
3591 next_tx_seq_offset = 3587 next_tx_seq_offset =
3592 (pi->next_tx_seq - pi->expected_ack_seq) % 64; 3588 (chan->next_tx_seq - chan->expected_ack_seq) % 64;
3593 if (next_tx_seq_offset < 0) 3589 if (next_tx_seq_offset < 0)
3594 next_tx_seq_offset += 64; 3590 next_tx_seq_offset += 64;
3595 3591
@@ -3689,10 +3685,10 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
3689 3685
3690 tx_seq = __get_txseq(control); 3686 tx_seq = __get_txseq(control);
3691 3687
3692 if (pi->expected_tx_seq == tx_seq) 3688 if (chan->expected_tx_seq == tx_seq)
3693 pi->expected_tx_seq = (pi->expected_tx_seq + 1) % 64; 3689 chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64;
3694 else 3690 else
3695 pi->expected_tx_seq = (tx_seq + 1) % 64; 3691 chan->expected_tx_seq = (tx_seq + 1) % 64;
3696 3692
3697 l2cap_streaming_reassembly_sdu(chan, skb, control); 3693 l2cap_streaming_reassembly_sdu(chan, skb, control);
3698 3694
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 66ec966ffc18..19574e43226a 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -777,7 +777,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
777 } 777 }
778 778
779 if (pi->mode == L2CAP_MODE_STREAMING) { 779 if (pi->mode == L2CAP_MODE_STREAMING) {
780 l2cap_streaming_send(sk); 780 l2cap_streaming_send(pi->chan);
781 err = len; 781 err = len;
782 break; 782 break;
783 } 783 }