Skip to content

Commit e378173

Browse files
finikorgGustavo F. Padovan
authored andcommitted
Bluetooth: EWS: rewrite handling POLL (P) bit
Handle POLL (P) bit in L2CAP ERTM using information about control field type. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent 03f6715 commit e378173

2 files changed

Lines changed: 23 additions & 7 deletions

File tree

‎include/net/bluetooth/l2cap.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,22 @@ static inline bool __is_ctrl_final(struct l2cap_chan *chan, __u32 ctrl)
627627
else
628628
return ctrl & L2CAP_CTRL_FINAL;
629629
}
630+
631+
static inline __u32 __set_ctrl_poll(struct l2cap_chan *chan)
632+
{
633+
if (test_bit(FLAG_EXT_CTRL, &chan->flags))
634+
return L2CAP_EXT_CTRL_POLL;
635+
else
636+
return L2CAP_CTRL_POLL;
637+
}
638+
639+
static inline bool __is_ctrl_poll(struct l2cap_chan *chan, __u32 ctrl)
640+
{
641+
if (test_bit(FLAG_EXT_CTRL, &chan->flags))
642+
return ctrl & L2CAP_EXT_CTRL_POLL;
643+
else
644+
return ctrl & L2CAP_CTRL_POLL;
645+
}
630646
extern int disable_ertm;
631647

632648
int l2cap_init_sockets(void);

‎net/bluetooth/l2cap_core.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control)
585585
control |= __set_ctrl_final(chan);
586586

587587
if (test_and_clear_bit(CONN_SEND_PBIT, &chan->conn_state))
588-
control |= L2CAP_CTRL_POLL;
588+
control |= __set_ctrl_poll(chan);
589589

590590
skb = bt_skb_alloc(count, GFP_ATOMIC);
591591
if (!skb)
@@ -3304,7 +3304,7 @@ static void l2cap_ertm_exit_local_busy(struct l2cap_chan *chan)
33043304
goto done;
33053305

33063306
control = __set_reqseq(chan, chan->buffer_seq);
3307-
control |= L2CAP_CTRL_POLL;
3307+
control |= __set_ctrl_poll(chan);
33083308
control |= __set_ctrl_super(chan, L2CAP_SUPER_RR);
33093309
l2cap_send_sframe(chan, control);
33103310
chan->retry_count = 1;
@@ -3538,7 +3538,7 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co
35383538
chan->expected_ack_seq = __get_reqseq(chan, rx_control);
35393539
l2cap_drop_acked_frames(chan);
35403540

3541-
if (rx_control & L2CAP_CTRL_POLL) {
3541+
if (__is_ctrl_poll(chan, rx_control)) {
35423542
set_bit(CONN_SEND_FBIT, &chan->conn_state);
35433543
if (test_bit(CONN_SREJ_SENT, &chan->conn_state)) {
35443544
if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state) &&
@@ -3599,7 +3599,7 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_
35993599

36003600
clear_bit(CONN_REMOTE_BUSY, &chan->conn_state);
36013601

3602-
if (rx_control & L2CAP_CTRL_POLL) {
3602+
if (__is_ctrl_poll(chan, rx_control)) {
36033603
chan->expected_ack_seq = tx_seq;
36043604
l2cap_drop_acked_frames(chan);
36053605

@@ -3637,17 +3637,17 @@ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_c
36373637
chan->expected_ack_seq = tx_seq;
36383638
l2cap_drop_acked_frames(chan);
36393639

3640-
if (rx_control & L2CAP_CTRL_POLL)
3640+
if (__is_ctrl_poll(chan, rx_control))
36413641
set_bit(CONN_SEND_FBIT, &chan->conn_state);
36423642

36433643
if (!test_bit(CONN_SREJ_SENT, &chan->conn_state)) {
36443644
__clear_retrans_timer(chan);
3645-
if (rx_control & L2CAP_CTRL_POLL)
3645+
if (__is_ctrl_poll(chan, rx_control))
36463646
l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_FINAL);
36473647
return;
36483648
}
36493649

3650-
if (rx_control & L2CAP_CTRL_POLL) {
3650+
if (__is_ctrl_poll(chan, rx_control)) {
36513651
l2cap_send_srejtail(chan);
36523652
} else {
36533653
rx_control = __set_ctrl_super(chan, L2CAP_SUPER_RR);

0 commit comments

Comments
 (0)