Skip to content

Commit 3f7a56c

Browse files
Mat MartineauGustavo Padovan
authored andcommitted
Bluetooth: Start channel move when socket option is changed
Channel moves are triggered by changes to the BT_CHANNEL_POLICY sockopt when an ERTM or streaming-mode channel is connected. Moves are only started if enable_hs is true. Signed-off-by: Mat Martineau <mathewm@codeaurora.org> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent e6a3ee6 commit 3f7a56c

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎include/net/bluetooth/l2cap.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,5 +809,6 @@ void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
809809
void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
810810
void l2cap_chan_del(struct l2cap_chan *chan, int err);
811811
void l2cap_send_conn_req(struct l2cap_chan *chan);
812+
void l2cap_move_start(struct l2cap_chan *chan);
812813

813814
#endif /* __L2CAP_H */

‎net/bluetooth/l2cap_core.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4453,6 +4453,25 @@ static void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan,
44534453
}
44544454
}
44554455

4456+
void l2cap_move_start(struct l2cap_chan *chan)
4457+
{
4458+
BT_DBG("chan %p", chan);
4459+
4460+
if (chan->local_amp_id == HCI_BREDR_ID) {
4461+
if (chan->chan_policy != BT_CHANNEL_POLICY_AMP_PREFERRED)
4462+
return;
4463+
chan->move_role = L2CAP_MOVE_ROLE_INITIATOR;
4464+
chan->move_state = L2CAP_MOVE_WAIT_PREPARE;
4465+
/* Placeholder - start physical link setup */
4466+
} else {
4467+
chan->move_role = L2CAP_MOVE_ROLE_INITIATOR;
4468+
chan->move_state = L2CAP_MOVE_WAIT_RSP_SUCCESS;
4469+
chan->move_id = 0;
4470+
l2cap_move_setup(chan);
4471+
l2cap_send_move_chan_req(chan, 0);
4472+
}
4473+
}
4474+
44564475
static void l2cap_do_create(struct l2cap_chan *chan, int result,
44574476
u8 local_amp_id, u8 remote_amp_id)
44584477
{

‎net/bluetooth/l2cap_sock.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,11 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
736736
}
737737

738738
chan->chan_policy = (u8) opt;
739+
740+
if (sk->sk_state == BT_CONNECTED &&
741+
chan->move_role == L2CAP_MOVE_ROLE_NONE)
742+
l2cap_move_start(chan);
743+
739744
break;
740745

741746
default:

0 commit comments

Comments
 (0)