2023-06-22 19:24:20

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ] btdev: Fix LE CIS Established Event

From: Luiz Augusto von Dentz <[email protected]>

LE CIS Established Event Transport Latency shall follow the formula from
the spec:

BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 6, Part G
page 3050:

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
---
emulator/btdev.c | 43 +++++++++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 0a375febad68..d5450190c38e 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -5940,6 +5940,18 @@ static int cmd_create_cis(struct btdev *dev, const void *data, uint8_t len)
return 0;
}

+static uint32_t le_cis_transport_latecy(uint8_t ft, uint8_t iso_interval,
+ uint8_t sdu_interval[3])
+{
+ uint32_t latency;
+ uint32_t interval = get_le24(sdu_interval);
+
+ /* Transport_Latency = FT × ISO_Interval - SDU_Interval */
+ latency = ft * (iso_interval * 1250) - interval;
+
+ return latency <= interval ? latency : interval;
+}
+
static void le_cis_estabilished(struct btdev *dev, struct btdev_conn *conn,
uint8_t status)
{
@@ -5959,25 +5971,32 @@ static void le_cis_estabilished(struct btdev *dev, struct btdev_conn *conn,
struct btdev *remote = conn->link->dev;
struct le_cig *le_cig = &remote->le_cig[cig_idx];

- /* 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));
+ memset(evt.cig_sync_delay, 0, sizeof(evt.cig_sync_delay));
+ memset(evt.cis_sync_delay, 0, sizeof(evt.cis_sync_delay));
+
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_ft = 0x02;
+ evt.p_ft = 0x02;
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;
+ evt.interval = (le_cig->params.c_latency + 0.625) / 1.25;
+
+ /* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 6, Part G
+ * page 3050:
+ *
+ * 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
+ */
+ put_le24(le_cis_transport_latecy(evt.c_ft, evt.interval,
+ le_cig->params.c_interval), evt.c_latency);
+ put_le24(le_cis_transport_latecy(evt.p_ft, evt.interval,
+ le_cig->params.p_interval), evt.p_latency);
}

le_meta_event(dev, BT_HCI_EVT_LE_CIS_ESTABLISHED, &evt, sizeof(evt));
--
2.40.1



2023-06-22 20:32:08

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ] btdev: Fix LE CIS Established Event

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=759611

---Test result---

Test Summary:
CheckPatch PASS 0.41 seconds
GitLint PASS 0.27 seconds
BuildEll PASS 27.25 seconds
BluezMake PASS 1008.24 seconds
MakeCheck PASS 12.06 seconds
MakeDistcheck PASS 155.83 seconds
CheckValgrind PASS 254.00 seconds
CheckSmatch WARNING 343.13 seconds
bluezmakeextell PASS 103.98 seconds
IncrementalBuild PASS 869.61 seconds
ScanBuild PASS 1090.43 seconds

Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
emulator/btdev.c:417:29: warning: Variable length array is used.


---
Regards,
Linux Bluetooth

2023-06-22 23:11:09

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ] btdev: Fix LE CIS Established Event

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Thu, 22 Jun 2023 12:08:43 -0700 you wrote:
> From: Luiz Augusto von Dentz <[email protected]>
>
> LE CIS Established Event Transport Latency shall follow the formula from
> the spec:
>
> BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 6, Part G
> page 3050:
>
> [...]

Here is the summary with links:
- [BlueZ] btdev: Fix LE CIS Established Event
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=97a07d8485a3

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html