Message ID | 20230621195407.977001-1-luiz.dentz@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [v2] Bluetooth: hci_event: Fix parsing of CIS Established Event | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/CheckPatch | success | CheckPatch PASS |
tedd_an/GitLint | success | Gitlint PASS |
tedd_an/SubjectPrefix | success | Gitlint PASS |
tedd_an/BuildKernel | success | BuildKernel PASS |
tedd_an/CheckAllWarning | success | CheckAllWarning PASS |
tedd_an/CheckSparse | warning | CheckSparse WARNING net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h): |
tedd_an/CheckSmatch | warning | CheckSparse WARNING net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h): |
tedd_an/BuildKernel32 | success | BuildKernel32 PASS |
tedd_an/TestRunnerSetup | success | TestRunnerSetup PASS |
tedd_an/TestRunner_l2cap-tester | success | TestRunner PASS |
tedd_an/TestRunner_iso-tester | fail | TestRunner_iso-tester: Total: 80, Passed: 17 (21.2%), Failed: 63, Not Run: 0 |
tedd_an/TestRunner_bnep-tester | success | TestRunner PASS |
tedd_an/TestRunner_mgmt-tester | success | TestRunner PASS |
tedd_an/TestRunner_rfcomm-tester | success | TestRunner PASS |
tedd_an/TestRunner_sco-tester | success | TestRunner PASS |
tedd_an/TestRunner_ioctl-tester | success | TestRunner PASS |
tedd_an/TestRunner_mesh-tester | success | TestRunner PASS |
tedd_an/TestRunner_smp-tester | success | TestRunner PASS |
tedd_an/TestRunner_userchan-tester | success | TestRunner PASS |
tedd_an/IncrementalBuild | success | Incremental Build PASS |
Hi Luiz, ke, 2023-06-21 kello 12:54 -0700, Luiz Augusto von Dentz kirjoitti: > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > 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> > --- > net/bluetooth/hci_event.c | 36 +++++++++++++++++++++++------------- > 1 file changed, 23 insertions(+), 13 deletions(-) > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index b1aefe4bb751..6fca6d9f1b34 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -6822,6 +6822,7 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, > { > struct hci_evt_le_cis_established *ev = data; > struct hci_conn *conn; > + struct bt_iso_qos *qos; > bool pending = false; > u16 handle = __le16_to_cpu(ev->handle); > > @@ -6846,21 +6847,30 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, > > pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); > > - if (conn->role == HCI_ROLE_SLAVE) { > - __le32 interval; > + qos = &conn->iso_qos; > > - memset(&interval, 0, sizeof(interval)); > + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ > + qos->ucast.in.latency = le16_to_cpu(ev->interval) * 125 / 100; > + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ > + qos->ucast.out.latency = le16_to_cpu(ev->interval) * 125 / 100; > > - memcpy(&interval, ev->c_latency, sizeof(ev->c_latency)); > - conn->iso_qos.ucast.in.interval = le32_to_cpu(interval); > - memcpy(&interval, ev->p_latency, sizeof(ev->p_latency)); > - conn->iso_qos.ucast.out.interval = le32_to_cpu(interval); > - conn->iso_qos.ucast.in.latency = le16_to_cpu(ev->interval); > - conn->iso_qos.ucast.out.latency = le16_to_cpu(ev->interval); > - conn->iso_qos.ucast.in.sdu = le16_to_cpu(ev->c_mtu); > - conn->iso_qos.ucast.out.sdu = le16_to_cpu(ev->p_mtu); > - conn->iso_qos.ucast.in.phy = ev->c_phy; > - conn->iso_qos.ucast.out.phy = ev->p_phy; > + switch (conn->role) { > + case HCI_ROLE_SLAVE: > + qos->ucast.in.interval = get_unaligned_le24(ev->c_latency); > + qos->ucast.out.interval = get_unaligned_le24(ev->p_latency); > + qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); > + qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); > + qos->ucast.in.phy = ev->c_phy; > + qos->ucast.out.phy = ev->p_phy; > + break; Are the ucast.latency and ucast.interval the right way around here? When I trying to use this in userspace, I expected ucast.interval contains the ISO interval, because in Set CIG Parameters we use ucast.interval to specify the SDU_Interval, and ucast.latency is used for the Transport_Latency_C_To_P and Transport_Latency_P_To_C. With real numbers the event (AX210<->AX210) looks like this > HCI Event: LE Meta Event (0x3e) plen 29 #3493 [hci0] 486.978955 LE Connected Isochronous Stream Established (0x19) Status: Success (0x00) Connection Handle: 2560 CIG Synchronization Delay: 4020 us (0x000fb4) CIS Synchronization Delay: 4020 us (0x000fb4) Central to Peripheral Latency: 94020 us (0x016f44) Peripheral to Central Latency: 94020 us (0x016f44) Central to Peripheral PHY: LE 2M (0x02) Peripheral to Central PHY: LE 2M (0x02) Number of Subevents: 2 Central to Peripheral Burst Number: 1 Peripheral to Central Burst Number: 1 Central to Peripheral Flush Timeout: 10 Peripheral to Central Flush Timeout: 10 Central to Peripheral MTU: 240 Peripheral to Central MTU: 120 ISO Interval: 8 > + case HCI_ROLE_MASTER: > + qos->ucast.out.interval = get_unaligned_le24(ev->c_latency); > + qos->ucast.in.interval = get_unaligned_le24(ev->p_latency); > + qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); > + qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); > + qos->ucast.out.phy = ev->c_phy; > + qos->ucast.in.phy = ev->p_phy; > + break; > } > > if (!ev->status) {
This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series: PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=759261 ---Test result--- Test Summary: CheckPatch PASS 0.62 seconds GitLint PASS 0.28 seconds SubjectPrefix PASS 0.10 seconds BuildKernel PASS 32.43 seconds CheckAllWarning PASS 35.86 seconds CheckSparse WARNING 40.37 seconds CheckSmatch WARNING 112.71 seconds BuildKernel32 PASS 31.55 seconds TestRunnerSetup PASS 449.78 seconds TestRunner_l2cap-tester PASS 16.88 seconds TestRunner_iso-tester FAIL 31.32 seconds TestRunner_bnep-tester PASS 5.38 seconds TestRunner_mgmt-tester PASS 129.16 seconds TestRunner_rfcomm-tester PASS 8.76 seconds TestRunner_sco-tester PASS 8.00 seconds TestRunner_ioctl-tester PASS 9.41 seconds TestRunner_mesh-tester PASS 6.80 seconds TestRunner_smp-tester PASS 8.00 seconds TestRunner_userchan-tester PASS 5.66 seconds IncrementalBuild PASS 30.47 seconds Details ############################## Test: CheckSparse - WARNING Desc: Run sparse tool with linux kernel Output: net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h): ############################## Test: CheckSmatch - WARNING Desc: Run smatch tool with source Output: net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h): ############################## Test: TestRunner_iso-tester - FAIL Desc: Run iso-tester with test-runner Output: Total: 80, Passed: 17 (21.2%), Failed: 63, Not Run: 0 Failed Test Cases ISO QoS 8_1_1 - Success Failed 1.140 seconds ISO QoS 8_2_1 - Success Failed 0.207 seconds ISO QoS 16_1_1 - Success Failed 0.211 seconds ISO QoS 16_2_1 - Success Failed 0.205 seconds ISO QoS 16_2_1 CIG 0x01 - Success Failed 0.208 seconds ISO QoS 16_2_1 CIG 0x01 CIS 0x01 - Success Failed 0.206 seconds ISO QoS 24_1_1 - Success Failed 0.208 seconds ISO QoS 24_2_1 - Success Failed 0.210 seconds ISO QoS 32_1_1 - Success Failed 0.206 seconds ISO QoS 32_2_1 - Success Failed 0.202 seconds ISO QoS 44_1_1 - Success Failed 0.205 seconds ISO QoS 44_2_1 - Success Failed 0.197 seconds ISO QoS 48_1_1 - Success Failed 0.197 seconds ISO QoS 48_2_1 - Success Failed 0.208 seconds ISO QoS 48_3_1 - Success Failed 0.207 seconds ISO QoS 48_4_1 - Success Failed 0.206 seconds ISO QoS 48_5_1 - Success Failed 0.199 seconds ISO QoS 48_6_1 - Success Failed 0.198 seconds ISO QoS 8_1_2 - Success Failed 0.208 seconds ISO QoS 8_2_2 - Success Failed 0.205 seconds ISO QoS 16_1_2 - Success Failed 0.209 seconds ISO QoS 16_2_2 - Success Failed 0.205 seconds ISO QoS 24_1_2 - Success Failed 0.207 seconds ISO QoS 24_2_2 - Success Failed 0.206 seconds ISO QoS 32_1_2 - Success Failed 0.207 seconds ISO QoS 32_2_2 - Success Failed 0.206 seconds ISO QoS 44_1_2 - Success Failed 0.202 seconds ISO QoS 44_2_2 - Success Failed 0.206 seconds ISO QoS 48_1_2 - Success Failed 0.207 seconds ISO QoS 48_2_2 - Success Failed 0.198 seconds ISO QoS 48_3_2 - Success Failed 0.199 seconds ISO QoS 48_4_2 - Success Failed 0.207 seconds ISO QoS 48_5_2 - Success Failed 0.199 seconds ISO QoS 48_6_2 - Success Failed 0.210 seconds ISO Send - Success Failed 0.203 seconds ISO Receive - Success Failed 0.194 seconds ISO Receive Timestamped - Success Failed 0.185 seconds ISO Defer Connect - Success Failed 0.205 seconds ISO Defer Connect2 CIG 0x01 - Success Failed 0.295 seconds ISO Defer Send - Success Failed 0.207 seconds ISO 48_2_1 Defer Send - Success Failed 0.209 seconds ISO Defer Receive - Success Failed 0.187 seconds ISO 48_2_1 Defer Receive - Success Failed 0.184 seconds ISO Send and Receive - Success Failed 0.209 seconds ISO Disconnect - Success Failed 0.208 seconds ISO Reconnect - Success Failed 0.202 seconds ISO AC 1 & 4 - Success Failed 0.200 seconds ISO AC 2 & 10 - Success Failed 0.199 seconds ISO AC 3 & 5 - Success Failed 0.203 seconds ISO AC 6(i) - Success Failed 0.230 seconds ISO AC 6(ii) - Success Failed 0.307 seconds ISO AC 7(i) - Success Failed 0.231 seconds ISO AC 7(ii) - Success Failed 0.289 seconds ISO AC 8(i) - Success Failed 0.237 seconds ISO AC 8(ii) - Success Failed 0.299 seconds ISO AC 9(i) - Success Failed 0.236 seconds ISO AC 9(ii) - Success Failed 0.287 seconds ISO AC 11(i) - Success Failed 0.234 seconds ISO AC 11(ii) - Success Failed 0.297 seconds ISO AC 1 + 2 - Success Failed 4.292 seconds ISO AC 1 + 2 CIG 0x01/0x02 - Success Failed 4.287 seconds ISO Reconnect AC 6(i) - Success Failed 0.296 seconds ISO Reconnect AC 6(ii) - Success Failed 0.294 seconds --- Regards, Linux Bluetooth
Hi Pauli, On Wed, Jun 21, 2023 at 1:33 PM Pauli Virtanen <pav@iki.fi> wrote: > > Hi Luiz, > > ke, 2023-06-21 kello 12:54 -0700, Luiz Augusto von Dentz kirjoitti: > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > > > 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> > > --- > > net/bluetooth/hci_event.c | 36 +++++++++++++++++++++++------------- > > 1 file changed, 23 insertions(+), 13 deletions(-) > > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > index b1aefe4bb751..6fca6d9f1b34 100644 > > --- a/net/bluetooth/hci_event.c > > +++ b/net/bluetooth/hci_event.c > > @@ -6822,6 +6822,7 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, > > { > > struct hci_evt_le_cis_established *ev = data; > > struct hci_conn *conn; > > + struct bt_iso_qos *qos; > > bool pending = false; > > u16 handle = __le16_to_cpu(ev->handle); > > > > @@ -6846,21 +6847,30 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, > > > > pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); > > > > - if (conn->role == HCI_ROLE_SLAVE) { > > - __le32 interval; > > + qos = &conn->iso_qos; > > > > - memset(&interval, 0, sizeof(interval)); > > + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ > > + qos->ucast.in.latency = le16_to_cpu(ev->interval) * 125 / 100; > > + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ > > + qos->ucast.out.latency = le16_to_cpu(ev->interval) * 125 / 100; > > > > - memcpy(&interval, ev->c_latency, sizeof(ev->c_latency)); > > - conn->iso_qos.ucast.in.interval = le32_to_cpu(interval); > > - memcpy(&interval, ev->p_latency, sizeof(ev->p_latency)); > > - conn->iso_qos.ucast.out.interval = le32_to_cpu(interval); > > - conn->iso_qos.ucast.in.latency = le16_to_cpu(ev->interval); > > - conn->iso_qos.ucast.out.latency = le16_to_cpu(ev->interval); > > - conn->iso_qos.ucast.in.sdu = le16_to_cpu(ev->c_mtu); > > - conn->iso_qos.ucast.out.sdu = le16_to_cpu(ev->p_mtu); > > - conn->iso_qos.ucast.in.phy = ev->c_phy; > > - conn->iso_qos.ucast.out.phy = ev->p_phy; > > + switch (conn->role) { > > + case HCI_ROLE_SLAVE: > > + qos->ucast.in.interval = get_unaligned_le24(ev->c_latency); > > + qos->ucast.out.interval = get_unaligned_le24(ev->p_latency); > > + qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); > > + qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); > > + qos->ucast.in.phy = ev->c_phy; > > + qos->ucast.out.phy = ev->p_phy; > > + break; > > Are the ucast.latency and ucast.interval the right way around here? > > When I trying to use this in userspace, I expected ucast.interval > contains the ISO interval, because in Set CIG Parameters we use > ucast.interval to specify the SDU_Interval, and ucast.latency is used > for the Transport_Latency_C_To_P and Transport_Latency_P_To_C. > > With real numbers the event (AX210<->AX210) looks like this > > > HCI Event: LE Meta Event (0x3e) plen 29 #3493 [hci0] 486.978955 > LE Connected Isochronous Stream Established (0x19) > Status: Success (0x00) > Connection Handle: 2560 > CIG Synchronization Delay: 4020 us (0x000fb4) > CIS Synchronization Delay: 4020 us (0x000fb4) > Central to Peripheral Latency: 94020 us (0x016f44) > Peripheral to Central Latency: 94020 us (0x016f44) No idea why these values look like this, they are not what I expect which is to match what the Central configured with Set CIG Parameters. > Central to Peripheral PHY: LE 2M (0x02) > Peripheral to Central PHY: LE 2M (0x02) > Number of Subevents: 2 > Central to Peripheral Burst Number: 1 > Peripheral to Central Burst Number: 1 > Central to Peripheral Flush Timeout: 10 > Peripheral to Central Flush Timeout: 10 > Central to Peripheral MTU: 240 > Peripheral to Central MTU: 120 > ISO Interval: 8 These seems to be fine, so I wonder what is going on with CIS Established event, this is what we are doing in the emulator: /* TODO: Figure out if these values makes sense */ memcpy(evt.cig_sync_delay, le_cig->params.c_interval, sizeof(le_cig->params.c_interval)); memcpy(evt.cis_sync_delay, le_cig->params.p_interval, sizeof(le_cig->params.p_interval)); memcpy(evt.c_latency, &le_cig->params.c_interval, sizeof(le_cig->params.c_interval)); memcpy(evt.p_latency, &le_cig->params.p_interval, sizeof(le_cig->params.p_interval)); evt.c_phy = le_cig->cis[cis_idx].c_phy; evt.p_phy = le_cig->cis[cis_idx].p_phy; evt.nse = 0x01; evt.c_bn = 0x01; evt.p_bn = 0x01; evt.c_ft = 0x01; evt.p_ft = 0x01; evt.c_mtu = le_cig->cis[cis_idx].c_sdu; evt.p_mtu = le_cig->cis[cis_idx].p_sdu; evt.interval = (le_cig->params.c_latency + 1) / 1.25; > > > + case HCI_ROLE_MASTER: > > + qos->ucast.out.interval = get_unaligned_le24(ev->c_latency); > > + qos->ucast.in.interval = get_unaligned_le24(ev->p_latency); > > + qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); > > + qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); > > + qos->ucast.out.phy = ev->c_phy; > > + qos->ucast.in.phy = ev->p_phy; > > + break; > > } > > > > if (!ev->status) { > > -- > Pauli Virtanen
Hi Luiz, ke, 2023-06-21 kello 14:12 -0700, Luiz Augusto von Dentz kirjoitti: > Hi Pauli, > > On Wed, Jun 21, 2023 at 1:33 PM Pauli Virtanen <pav@iki.fi> wrote: > > > > Hi Luiz, > > > > ke, 2023-06-21 kello 12:54 -0700, Luiz Augusto von Dentz kirjoitti: > > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > > > > > 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> > > > --- > > > net/bluetooth/hci_event.c | 36 +++++++++++++++++++++++------------- > > > 1 file changed, 23 insertions(+), 13 deletions(-) > > > > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > > index b1aefe4bb751..6fca6d9f1b34 100644 > > > --- a/net/bluetooth/hci_event.c > > > +++ b/net/bluetooth/hci_event.c > > > @@ -6822,6 +6822,7 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, > > > { > > > struct hci_evt_le_cis_established *ev = data; > > > struct hci_conn *conn; > > > + struct bt_iso_qos *qos; > > > bool pending = false; > > > u16 handle = __le16_to_cpu(ev->handle); > > > > > > @@ -6846,21 +6847,30 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, > > > > > > pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); > > > > > > - if (conn->role == HCI_ROLE_SLAVE) { > > > - __le32 interval; > > > + qos = &conn->iso_qos; > > > > > > - memset(&interval, 0, sizeof(interval)); > > > + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ > > > + qos->ucast.in.latency = le16_to_cpu(ev->interval) * 125 / 100; > > > + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ > > > + qos->ucast.out.latency = le16_to_cpu(ev->interval) * 125 / 100; > > > > > > - memcpy(&interval, ev->c_latency, sizeof(ev->c_latency)); > > > - conn->iso_qos.ucast.in.interval = le32_to_cpu(interval); > > > - memcpy(&interval, ev->p_latency, sizeof(ev->p_latency)); > > > - conn->iso_qos.ucast.out.interval = le32_to_cpu(interval); > > > - conn->iso_qos.ucast.in.latency = le16_to_cpu(ev->interval); > > > - conn->iso_qos.ucast.out.latency = le16_to_cpu(ev->interval); > > > - conn->iso_qos.ucast.in.sdu = le16_to_cpu(ev->c_mtu); > > > - conn->iso_qos.ucast.out.sdu = le16_to_cpu(ev->p_mtu); > > > - conn->iso_qos.ucast.in.phy = ev->c_phy; > > > - conn->iso_qos.ucast.out.phy = ev->p_phy; > > > + switch (conn->role) { > > > + case HCI_ROLE_SLAVE: > > > + qos->ucast.in.interval = get_unaligned_le24(ev->c_latency); > > > + qos->ucast.out.interval = get_unaligned_le24(ev->p_latency); > > > + qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); > > > + qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); > > > + qos->ucast.in.phy = ev->c_phy; > > > + qos->ucast.out.phy = ev->p_phy; > > > + break; > > > > Are the ucast.latency and ucast.interval the right way around here? > > > > When I trying to use this in userspace, I expected ucast.interval > > contains the ISO interval, because in Set CIG Parameters we use > > ucast.interval to specify the SDU_Interval, and ucast.latency is used > > for the Transport_Latency_C_To_P and Transport_Latency_P_To_C. > > > > With real numbers the event (AX210<->AX210) looks like this > > > > > HCI Event: LE Meta Event (0x3e) plen 29 #3493 [hci0] 486.978955 > > LE Connected Isochronous Stream Established (0x19) > > Status: Success (0x00) > > Connection Handle: 2560 > > CIG Synchronization Delay: 4020 us (0x000fb4) > > CIS Synchronization Delay: 4020 us (0x000fb4) > > Central to Peripheral Latency: 94020 us (0x016f44) > > Peripheral to Central Latency: 94020 us (0x016f44) > > No idea why these values look like this, they are not what I expect > which is to match what the Central configured with Set CIG Parameters. Core v5.3 Vol 6 Part G Sec 3.2.2 has the formulas Transport_Latency_C_To_P = CIG_Sync_Delay + FT_C_To_P * ISO_Interval - SDU_Interval_C_To_P Transport_Latency_P_To_C = CIG_Sync_Delay + FT_P_To_C * ISO_Interval - SDU_Interval_P_To_C for unframed so looks these come from there. Don't know how the sync delays are chosen. The Central in this case specified Max Transport Latency of 100ms (BAP QoS 48_4_2) so they satisfy it. Userspace wants to know the exact values since they matter for the total audio latency (Transport_Latency + Presentation_Delay), see Figure 3.1 in Core v5.4 Vol 6 Part G pp 3073 and Sec 7 in BAP v1.0.1. This we need to know for eg. lip sync in video playback. (I have some problems getting the latency right with the Samsung device, though, needs more looking into as its smaller than the above Transport_Latencies.) > > Central to Peripheral PHY: LE 2M (0x02) > > Peripheral to Central PHY: LE 2M (0x02) > > Number of Subevents: 2 > > Central to Peripheral Burst Number: 1 > > Peripheral to Central Burst Number: 1 > > Central to Peripheral Flush Timeout: 10 > > Peripheral to Central Flush Timeout: 10 > > Central to Peripheral MTU: 240 > > Peripheral to Central MTU: 120 > > ISO Interval: 8 > > These seems to be fine, so I wonder what is going on with CIS > Established event, this is what we are doing in the emulator: > > /* TODO: Figure out if these values makes sense */ > memcpy(evt.cig_sync_delay, le_cig->params.c_interval, > sizeof(le_cig->params.c_interval)); > memcpy(evt.cis_sync_delay, le_cig->params.p_interval, > sizeof(le_cig->params.p_interval)); > memcpy(evt.c_latency, &le_cig->params.c_interval, > sizeof(le_cig->params.c_interval)); > memcpy(evt.p_latency, &le_cig->params.p_interval, > sizeof(le_cig->params.p_interval)); > evt.c_phy = le_cig->cis[cis_idx].c_phy; > evt.p_phy = le_cig->cis[cis_idx].p_phy; > evt.nse = 0x01; > evt.c_bn = 0x01; > evt.p_bn = 0x01; > evt.c_ft = 0x01; > evt.p_ft = 0x01; > evt.c_mtu = le_cig->cis[cis_idx].c_sdu; > evt.p_mtu = le_cig->cis[cis_idx].p_sdu; > evt.interval = (le_cig->params.c_latency + 1) / 1.25; These probably assume zero sync delay in the formulas above. > > > > > > + case HCI_ROLE_MASTER: > > > + qos->ucast.out.interval = get_unaligned_le24(ev->c_latency); > > > + qos->ucast.in.interval = get_unaligned_le24(ev->p_latency); > > > + qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); > > > + qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); > > > + qos->ucast.out.phy = ev->c_phy; > > > + qos->ucast.in.phy = ev->p_phy; > > > + break; > > > } > > > > > > if (!ev->status) { > > > > -- > > Pauli Virtanen > > >
Hi Pauli, On Wed, Jun 21, 2023 at 2:46 PM Pauli Virtanen <pav@iki.fi> wrote: > > Hi Luiz, > > ke, 2023-06-21 kello 14:12 -0700, Luiz Augusto von Dentz kirjoitti: > > Hi Pauli, > > > > On Wed, Jun 21, 2023 at 1:33 PM Pauli Virtanen <pav@iki.fi> wrote: > > > > > > Hi Luiz, > > > > > > ke, 2023-06-21 kello 12:54 -0700, Luiz Augusto von Dentz kirjoitti: > > > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > > > > > > > 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> > > > > --- > > > > net/bluetooth/hci_event.c | 36 +++++++++++++++++++++++------------- > > > > 1 file changed, 23 insertions(+), 13 deletions(-) > > > > > > > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > > > > index b1aefe4bb751..6fca6d9f1b34 100644 > > > > --- a/net/bluetooth/hci_event.c > > > > +++ b/net/bluetooth/hci_event.c > > > > @@ -6822,6 +6822,7 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, > > > > { > > > > struct hci_evt_le_cis_established *ev = data; > > > > struct hci_conn *conn; > > > > + struct bt_iso_qos *qos; > > > > bool pending = false; > > > > u16 handle = __le16_to_cpu(ev->handle); > > > > > > > > @@ -6846,21 +6847,30 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, > > > > > > > > pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); > > > > > > > > - if (conn->role == HCI_ROLE_SLAVE) { > > > > - __le32 interval; > > > > + qos = &conn->iso_qos; > > > > > > > > - memset(&interval, 0, sizeof(interval)); > > > > + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ > > > > + qos->ucast.in.latency = le16_to_cpu(ev->interval) * 125 / 100; > > > > + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ > > > > + qos->ucast.out.latency = le16_to_cpu(ev->interval) * 125 / 100; > > > > > > > > - memcpy(&interval, ev->c_latency, sizeof(ev->c_latency)); > > > > - conn->iso_qos.ucast.in.interval = le32_to_cpu(interval); > > > > - memcpy(&interval, ev->p_latency, sizeof(ev->p_latency)); > > > > - conn->iso_qos.ucast.out.interval = le32_to_cpu(interval); > > > > - conn->iso_qos.ucast.in.latency = le16_to_cpu(ev->interval); > > > > - conn->iso_qos.ucast.out.latency = le16_to_cpu(ev->interval); > > > > - conn->iso_qos.ucast.in.sdu = le16_to_cpu(ev->c_mtu); > > > > - conn->iso_qos.ucast.out.sdu = le16_to_cpu(ev->p_mtu); > > > > - conn->iso_qos.ucast.in.phy = ev->c_phy; > > > > - conn->iso_qos.ucast.out.phy = ev->p_phy; > > > > + switch (conn->role) { > > > > + case HCI_ROLE_SLAVE: > > > > + qos->ucast.in.interval = get_unaligned_le24(ev->c_latency); > > > > + qos->ucast.out.interval = get_unaligned_le24(ev->p_latency); > > > > + qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); > > > > + qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); > > > > + qos->ucast.in.phy = ev->c_phy; > > > > + qos->ucast.out.phy = ev->p_phy; > > > > + break; > > > > > > Are the ucast.latency and ucast.interval the right way around here? > > > > > > When I trying to use this in userspace, I expected ucast.interval > > > contains the ISO interval, because in Set CIG Parameters we use > > > ucast.interval to specify the SDU_Interval, and ucast.latency is used > > > for the Transport_Latency_C_To_P and Transport_Latency_P_To_C. > > > > > > With real numbers the event (AX210<->AX210) looks like this > > > > > > > HCI Event: LE Meta Event (0x3e) plen 29 #3493 [hci0] 486.978955 > > > LE Connected Isochronous Stream Established (0x19) > > > Status: Success (0x00) > > > Connection Handle: 2560 > > > CIG Synchronization Delay: 4020 us (0x000fb4) > > > CIS Synchronization Delay: 4020 us (0x000fb4) > > > Central to Peripheral Latency: 94020 us (0x016f44) > > > Peripheral to Central Latency: 94020 us (0x016f44) > > > > No idea why these values look like this, they are not what I expect > > which is to match what the Central configured with Set CIG Parameters. > > Core v5.3 Vol 6 Part G Sec 3.2.2 has the formulas > > Transport_Latency_C_To_P = CIG_Sync_Delay + FT_C_To_P * > ISO_Interval - SDU_Interval_C_To_P > > Transport_Latency_P_To_C = CIG_Sync_Delay + FT_P_To_C * > ISO_Interval - SDU_Interval_P_To_C > > for unframed so looks these come from there. Don't know how the sync > delays are chosen. > > The Central in this case specified Max Transport Latency of 100ms (BAP > QoS 48_4_2) so they satisfy it. Ok, I was afraid we were not printing the right value but if the transport latency is 100ms having ~94ms is not that far off. > Userspace wants to know the exact values since they matter for the > total audio latency (Transport_Latency + Presentation_Delay), see > Figure 3.1 in Core v5.4 Vol 6 Part G pp 3073 and Sec 7 in BAP v1.0.1. > > This we need to know for eg. lip sync in video playback. (I have some > problems getting the latency right with the Samsung device, though, > needs more looking into as its smaller than the above > Transport_Latencies.) > > > > Central to Peripheral PHY: LE 2M (0x02) > > > Peripheral to Central PHY: LE 2M (0x02) > > > Number of Subevents: 2 > > > Central to Peripheral Burst Number: 1 > > > Peripheral to Central Burst Number: 1 > > > Central to Peripheral Flush Timeout: 10 > > > Peripheral to Central Flush Timeout: 10 > > > Central to Peripheral MTU: 240 > > > Peripheral to Central MTU: 120 > > > ISO Interval: 8 > > > > These seems to be fine, so I wonder what is going on with CIS > > Established event, this is what we are doing in the emulator: > > > > /* TODO: Figure out if these values makes sense */ > > memcpy(evt.cig_sync_delay, le_cig->params.c_interval, > > sizeof(le_cig->params.c_interval)); > > memcpy(evt.cis_sync_delay, le_cig->params.p_interval, > > sizeof(le_cig->params.p_interval)); > > memcpy(evt.c_latency, &le_cig->params.c_interval, > > sizeof(le_cig->params.c_interval)); > > memcpy(evt.p_latency, &le_cig->params.p_interval, > > sizeof(le_cig->params.p_interval)); > > evt.c_phy = le_cig->cis[cis_idx].c_phy; > > evt.p_phy = le_cig->cis[cis_idx].p_phy; > > evt.nse = 0x01; > > evt.c_bn = 0x01; > > evt.p_bn = 0x01; > > evt.c_ft = 0x01; > > evt.p_ft = 0x01; > > evt.c_mtu = le_cig->cis[cis_idx].c_sdu; > > evt.p_mtu = le_cig->cis[cis_idx].p_sdu; > > evt.interval = (le_cig->params.c_latency + 1) / 1.25; > > These probably assume zero sync delay in the formulas above. Yep, we probably need to start using the formula that you pasted to make sure they are in sync, that said I'd like to keep the QoS the same so we don't have to change them in iso-test so we will probably need to tune then to match exactly the suggested QoS even though in real controllers they might be a little off. > > > > > > > > > > + case HCI_ROLE_MASTER: > > > > + qos->ucast.out.interval = get_unaligned_le24(ev->c_latency); > > > > + qos->ucast.in.interval = get_unaligned_le24(ev->p_latency); > > > > + qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); > > > > + qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); > > > > + qos->ucast.out.phy = ev->c_phy; > > > > + qos->ucast.in.phy = ev->p_phy; > > > > + break; > > > > } > > > > > > > > if (!ev->status) { > > > > > > -- > > > Pauli Virtanen > > > > > > >
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index b1aefe4bb751..6fca6d9f1b34 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -6822,6 +6822,7 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, { struct hci_evt_le_cis_established *ev = data; struct hci_conn *conn; + struct bt_iso_qos *qos; bool pending = false; u16 handle = __le16_to_cpu(ev->handle); @@ -6846,21 +6847,30 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); - if (conn->role == HCI_ROLE_SLAVE) { - __le32 interval; + qos = &conn->iso_qos; - memset(&interval, 0, sizeof(interval)); + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ + qos->ucast.in.latency = le16_to_cpu(ev->interval) * 125 / 100; + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ + qos->ucast.out.latency = le16_to_cpu(ev->interval) * 125 / 100; - memcpy(&interval, ev->c_latency, sizeof(ev->c_latency)); - conn->iso_qos.ucast.in.interval = le32_to_cpu(interval); - memcpy(&interval, ev->p_latency, sizeof(ev->p_latency)); - conn->iso_qos.ucast.out.interval = le32_to_cpu(interval); - conn->iso_qos.ucast.in.latency = le16_to_cpu(ev->interval); - conn->iso_qos.ucast.out.latency = le16_to_cpu(ev->interval); - conn->iso_qos.ucast.in.sdu = le16_to_cpu(ev->c_mtu); - conn->iso_qos.ucast.out.sdu = le16_to_cpu(ev->p_mtu); - conn->iso_qos.ucast.in.phy = ev->c_phy; - conn->iso_qos.ucast.out.phy = ev->p_phy; + switch (conn->role) { + case HCI_ROLE_SLAVE: + qos->ucast.in.interval = get_unaligned_le24(ev->c_latency); + qos->ucast.out.interval = get_unaligned_le24(ev->p_latency); + qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); + qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); + qos->ucast.in.phy = ev->c_phy; + qos->ucast.out.phy = ev->p_phy; + break; + case HCI_ROLE_MASTER: + qos->ucast.out.interval = get_unaligned_le24(ev->c_latency); + qos->ucast.in.interval = get_unaligned_le24(ev->p_latency); + qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); + qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); + qos->ucast.out.phy = ev->c_phy; + qos->ucast.in.phy = ev->p_phy; + break; } if (!ev->status) {