Skip to content

Commit 31df0ef

Browse files
niag-Oticoncarlescufi
authored andcommitted
Bluetooth: controller: corrected time-offset for endianness
Changes: -- Corrected reading and writing time offset in framed segment header to account for endianness -- Corrected bit positioning of time offset bit field in the segment header structure definition -- Fixed upstream Zephyr BSIM test build failure due to debug logging 39-bit variable Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
1 parent ec20938 commit 31df0ef

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

subsys/bluetooth/controller/ll_sw/isoal.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <zephyr/bluetooth/hci_types.h>
1717
#include <zephyr/bluetooth/conn.h>
1818

19+
#include <zephyr/sys/byteorder.h>
20+
1921
#include "util/memq.h"
2022

2123
#include "hal/ccm.h"
@@ -1158,7 +1160,7 @@ static isoal_status_t isoal_rx_framed_consume(struct isoal_sink *sink,
11581160
case ISOAL_START:
11591161
if (!sc) {
11601162
/* Start segment, included time-offset */
1161-
timeoffset = seg_hdr->timeoffset;
1163+
timeoffset = sys_le24_to_cpu(seg_hdr->timeoffset);
11621164
anchorpoint = meta->timestamp;
11631165
latency = session->sdu_sync_const;
11641166
timestamp = isoal_get_wrapped_time_us(anchorpoint,
@@ -1215,7 +1217,7 @@ static isoal_status_t isoal_rx_framed_consume(struct isoal_sink *sink,
12151217

12161218
if (!sc) {
12171219
/* Start segment, included time-offset */
1218-
timeoffset = seg_hdr->timeoffset;
1220+
timeoffset = sys_le24_to_cpu(seg_hdr->timeoffset);
12191221
anchorpoint = meta->timestamp;
12201222
latency = session->sdu_sync_const;
12211223
timestamp = isoal_get_wrapped_time_us(anchorpoint,
@@ -1634,7 +1636,7 @@ static isoal_status_t isoal_tx_pdu_emit(const struct isoal_source *source_ctx,
16341636
status = source_ctx->session.pdu_emit(node_tx, handle);
16351637

16361638
ISOAL_LOG_DBG("[%p] PDU %llu err=%X len=%u frags=%u released",
1637-
source_ctx, node_tx->payload_count, status,
1639+
source_ctx, payload_number, status,
16381640
produced_pdu->contents.pdu->len, sdu_fragments);
16391641

16401642
if (status != ISOAL_STATUS_OK) {
@@ -2479,15 +2481,15 @@ static isoal_status_t isoal_tx_framed_produce(isoal_source_handle_t source_hdl,
24792481
*/
24802482
err |= isoal_insert_seg_header_timeoffset(source,
24812483
false, false,
2482-
time_offset);
2484+
sys_cpu_to_le24(time_offset));
24832485
pp->pdu_state = BT_ISO_CONT;
24842486
} else if (!padding_pdu && pp->pdu_state == BT_ISO_CONT && pp->pdu_written == 0) {
24852487
/* Continuing an SDU in a new PDU. Segmentation header
24862488
* alone should be inserted.
24872489
*/
24882490
err |= isoal_insert_seg_header_timeoffset(source,
24892491
true, false,
2490-
0);
2492+
sys_cpu_to_le24(0));
24912493
}
24922494

24932495
/*

subsys/bluetooth/controller/ll_sw/pdu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,8 @@ struct pdu_iso_sdu_sh {
10181018
uint8_t len;
10191019

10201020
/* Note, timeoffset only available in first segment of sdu */
1021-
uint32_t payload:8;
10221021
uint32_t timeoffset:24;
1022+
uint32_t payload:8;
10231023
#endif /* CONFIG_LITTLE_ENDIAN */
10241024
} __packed;
10251025

0 commit comments

Comments
 (0)