Skip to content

Commit 2be22f1

Browse files
Vudentzkuba-moo
authored andcommitted
Bluetooth: hci_event: Fix parsing of CIS Established Event
The ISO Interval on CIS Established Event uses 1.25 ms slots: BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E page 2304: Time = N * 1.25 ms In addition to that this always update the QoS settings based on CIS Established Event. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5b6d345 commit 2be22f1

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

net/bluetooth/hci_event.c

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6786,6 +6786,7 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data,
67866786
{
67876787
struct hci_evt_le_cis_established *ev = data;
67886788
struct hci_conn *conn;
6789+
struct bt_iso_qos *qos;
67896790
u16 handle = __le16_to_cpu(ev->handle);
67906791

67916792
bt_dev_dbg(hdev, "status 0x%2.2x", ev->status);
@@ -6807,21 +6808,39 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data,
68076808
goto unlock;
68086809
}
68096810

6810-
if (conn->role == HCI_ROLE_SLAVE) {
6811-
__le32 interval;
6812-
6813-
memset(&interval, 0, sizeof(interval));
6814-
6815-
memcpy(&interval, ev->c_latency, sizeof(ev->c_latency));
6816-
conn->iso_qos.ucast.in.interval = le32_to_cpu(interval);
6817-
memcpy(&interval, ev->p_latency, sizeof(ev->p_latency));
6818-
conn->iso_qos.ucast.out.interval = le32_to_cpu(interval);
6819-
conn->iso_qos.ucast.in.latency = le16_to_cpu(ev->interval);
6820-
conn->iso_qos.ucast.out.latency = le16_to_cpu(ev->interval);
6821-
conn->iso_qos.ucast.in.sdu = le16_to_cpu(ev->c_mtu);
6822-
conn->iso_qos.ucast.out.sdu = le16_to_cpu(ev->p_mtu);
6823-
conn->iso_qos.ucast.in.phy = ev->c_phy;
6824-
conn->iso_qos.ucast.out.phy = ev->p_phy;
6811+
qos = &conn->iso_qos;
6812+
6813+
/* Convert ISO Interval (1.25 ms slots) to SDU Interval (us) */
6814+
qos->ucast.in.interval = le16_to_cpu(ev->interval) * 1250;
6815+
qos->ucast.out.interval = qos->ucast.in.interval;
6816+
6817+
switch (conn->role) {
6818+
case HCI_ROLE_SLAVE:
6819+
/* Convert Transport Latency (us) to Latency (msec) */
6820+
qos->ucast.in.latency =
6821+
DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency),
6822+
1000);
6823+
qos->ucast.out.latency =
6824+
DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency),
6825+
1000);
6826+
qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu);
6827+
qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu);
6828+
qos->ucast.in.phy = ev->c_phy;
6829+
qos->ucast.out.phy = ev->p_phy;
6830+
break;
6831+
case HCI_ROLE_MASTER:
6832+
/* Convert Transport Latency (us) to Latency (msec) */
6833+
qos->ucast.out.latency =
6834+
DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency),
6835+
1000);
6836+
qos->ucast.in.latency =
6837+
DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency),
6838+
1000);
6839+
qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu);
6840+
qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu);
6841+
qos->ucast.out.phy = ev->c_phy;
6842+
qos->ucast.in.phy = ev->p_phy;
6843+
break;
68256844
}
68266845

68276846
if (!ev->status) {

0 commit comments

Comments
 (0)