aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2011-10-11 06:37:46 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-10-13 15:44:59 -0400
commit0b209fae88c6e844f2ee9d4d791f0f31f7f42ae9 (patch)
treed925ff36cf0f92a7b1404390086a77034548ae03 /net
parent7e0ef6ee13ecdf38c2c8b0b0c8ef729710b994eb (diff)
Bluetooth: EWS: rewrite reqseq calculation
reqseq calculation uses now information about control field type. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/l2cap_core.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 9ee42ba808f6..f35eb73b25fd 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -618,7 +618,7 @@ static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control)
618 } else 618 } else
619 control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); 619 control |= __set_ctrl_super(chan, L2CAP_SUPER_RR);
620 620
621 control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 621 control |= __set_reqseq(chan, chan->buffer_seq);
622 622
623 l2cap_send_sframe(chan, control); 623 l2cap_send_sframe(chan, control);
624} 624}
@@ -1316,8 +1316,8 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq)
1316 if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) 1316 if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state))
1317 control |= L2CAP_CTRL_FINAL; 1317 control |= L2CAP_CTRL_FINAL;
1318 1318
1319 control |= (chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) 1319 control |= __set_reqseq(chan, chan->buffer_seq);
1320 | (tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); 1320 control |= tx_seq << L2CAP_CTRL_TXSEQ_SHIFT;
1321 1321
1322 put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); 1322 put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE);
1323 1323
@@ -1356,8 +1356,8 @@ static int l2cap_ertm_send(struct l2cap_chan *chan)
1356 if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) 1356 if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state))
1357 control |= L2CAP_CTRL_FINAL; 1357 control |= L2CAP_CTRL_FINAL;
1358 1358
1359 control |= (chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) 1359 control |= __set_reqseq(chan, chan->buffer_seq);
1360 | (chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); 1360 control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT;
1361 put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); 1361 put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE);
1362 1362
1363 1363
@@ -1405,7 +1405,7 @@ static void l2cap_send_ack(struct l2cap_chan *chan)
1405{ 1405{
1406 u16 control = 0; 1406 u16 control = 0;
1407 1407
1408 control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 1408 control |= __set_reqseq(chan, chan->buffer_seq);
1409 1409
1410 if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { 1410 if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) {
1411 control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); 1411 control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR);
@@ -1430,7 +1430,7 @@ static void l2cap_send_srejtail(struct l2cap_chan *chan)
1430 control |= L2CAP_CTRL_FINAL; 1430 control |= L2CAP_CTRL_FINAL;
1431 1431
1432 tail = list_entry((&chan->srej_l)->prev, struct srej_list, list); 1432 tail = list_entry((&chan->srej_l)->prev, struct srej_list, list);
1433 control |= tail->tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; 1433 control |= __set_reqseq(chan, tail->tx_seq);
1434 1434
1435 l2cap_send_sframe(chan, control); 1435 l2cap_send_sframe(chan, control);
1436} 1436}
@@ -3116,7 +3116,7 @@ static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan)
3116 3116
3117 chan->frames_sent = 0; 3117 chan->frames_sent = 0;
3118 3118
3119 control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3119 control |= __set_reqseq(chan, chan->buffer_seq);
3120 3120
3121 if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { 3121 if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) {
3122 control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); 3122 control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR);
@@ -3286,7 +3286,7 @@ static void l2cap_ertm_enter_local_busy(struct l2cap_chan *chan)
3286 3286
3287 set_bit(CONN_LOCAL_BUSY, &chan->conn_state); 3287 set_bit(CONN_LOCAL_BUSY, &chan->conn_state);
3288 3288
3289 control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3289 control = __set_reqseq(chan, chan->buffer_seq);
3290 control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); 3290 control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR);
3291 l2cap_send_sframe(chan, control); 3291 l2cap_send_sframe(chan, control);
3292 3292
@@ -3302,7 +3302,7 @@ static void l2cap_ertm_exit_local_busy(struct l2cap_chan *chan)
3302 if (!test_bit(CONN_RNR_SENT, &chan->conn_state)) 3302 if (!test_bit(CONN_RNR_SENT, &chan->conn_state))
3303 goto done; 3303 goto done;
3304 3304
3305 control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3305 control = __set_reqseq(chan, chan->buffer_seq);
3306 control |= L2CAP_CTRL_POLL; 3306 control |= L2CAP_CTRL_POLL;
3307 control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); 3307 control |= __set_ctrl_super(chan, L2CAP_SUPER_RR);
3308 l2cap_send_sframe(chan, control); 3308 l2cap_send_sframe(chan, control);
@@ -3369,7 +3369,7 @@ static void l2cap_resend_srejframe(struct l2cap_chan *chan, u8 tx_seq)
3369 return; 3369 return;
3370 } 3370 }
3371 control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); 3371 control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ);
3372 control |= l->tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3372 control |= __set_reqseq(chan, l->tx_seq);
3373 l2cap_send_sframe(chan, control); 3373 l2cap_send_sframe(chan, control);
3374 list_del(&l->list); 3374 list_del(&l->list);
3375 list_add_tail(&l->list, &chan->srej_l); 3375 list_add_tail(&l->list, &chan->srej_l);
@@ -3383,7 +3383,7 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq)
3383 3383
3384 while (tx_seq != chan->expected_tx_seq) { 3384 while (tx_seq != chan->expected_tx_seq) {
3385 control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); 3385 control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ);
3386 control |= chan->expected_tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3386 control |= __set_reqseq(chan, chan->expected_tx_seq);
3387 l2cap_send_sframe(chan, control); 3387 l2cap_send_sframe(chan, control);
3388 3388
3389 new = kzalloc(sizeof(struct srej_list), GFP_ATOMIC); 3389 new = kzalloc(sizeof(struct srej_list), GFP_ATOMIC);
@@ -3397,7 +3397,7 @@ static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq)
3397static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) 3397static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb)
3398{ 3398{
3399 u8 tx_seq = __get_txseq(rx_control); 3399 u8 tx_seq = __get_txseq(rx_control);
3400 u8 req_seq = __get_reqseq(rx_control); 3400 u16 req_seq = __get_reqseq(chan, rx_control);
3401 u8 sar = __get_ctrl_sar(chan, rx_control); 3401 u8 sar = __get_ctrl_sar(chan, rx_control);
3402 int tx_seq_offset, expected_tx_seq_offset; 3402 int tx_seq_offset, expected_tx_seq_offset;
3403 int num_to_ack = (chan->tx_win/6) + 1; 3403 int num_to_ack = (chan->tx_win/6) + 1;
@@ -3531,10 +3531,10 @@ drop:
3531 3531
3532static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_control) 3532static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_control)
3533{ 3533{
3534 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, __get_reqseq(rx_control), 3534 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan,
3535 rx_control); 3535 __get_reqseq(chan, rx_control), rx_control);
3536 3536
3537 chan->expected_ack_seq = __get_reqseq(rx_control); 3537 chan->expected_ack_seq = __get_reqseq(chan, rx_control);
3538 l2cap_drop_acked_frames(chan); 3538 l2cap_drop_acked_frames(chan);
3539 3539
3540 if (rx_control & L2CAP_CTRL_POLL) { 3540 if (rx_control & L2CAP_CTRL_POLL) {
@@ -3571,7 +3571,7 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co
3571 3571
3572static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_control) 3572static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_control)
3573{ 3573{
3574 u8 tx_seq = __get_reqseq(rx_control); 3574 u16 tx_seq = __get_reqseq(chan, rx_control);
3575 3575
3576 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); 3576 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
3577 3577
@@ -3592,7 +3592,7 @@ static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_c
3592} 3592}
3593static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_control) 3593static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_control)
3594{ 3594{
3595 u8 tx_seq = __get_reqseq(rx_control); 3595 u16 tx_seq = __get_reqseq(chan, rx_control);
3596 3596
3597 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); 3597 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
3598 3598
@@ -3628,7 +3628,7 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_
3628 3628
3629static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_control) 3629static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_control)
3630{ 3630{
3631 u8 tx_seq = __get_reqseq(rx_control); 3631 u16 tx_seq = __get_reqseq(chan, rx_control);
3632 3632
3633 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); 3633 BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
3634 3634
@@ -3692,7 +3692,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
3692{ 3692{
3693 struct l2cap_chan *chan = l2cap_pi(sk)->chan; 3693 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
3694 u16 control; 3694 u16 control;
3695 u8 req_seq; 3695 u16 req_seq;
3696 int len, next_tx_seq_offset, req_seq_offset; 3696 int len, next_tx_seq_offset, req_seq_offset;
3697 3697
3698 control = get_unaligned_le16(skb->data); 3698 control = get_unaligned_le16(skb->data);
@@ -3718,7 +3718,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
3718 goto drop; 3718 goto drop;
3719 } 3719 }
3720 3720
3721 req_seq = __get_reqseq(control); 3721 req_seq = __get_reqseq(chan, control);
3722 req_seq_offset = (req_seq - chan->expected_ack_seq) % 64; 3722 req_seq_offset = (req_seq - chan->expected_ack_seq) % 64;
3723 if (req_seq_offset < 0) 3723 if (req_seq_offset < 0)
3724 req_seq_offset += 64; 3724 req_seq_offset += 64;