Skip to content

Commit 61d0046

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Option to ignore Tx ISO Data Packet Seq Num
Kconfig option to turn off ISO Data Packet Sequence Number use to place the ISO Data in the correct radio event, instead simply buffer it to next radio event. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent e3ecab3 commit 61d0046

File tree

5 files changed

+111
-16
lines changed

5 files changed

+111
-16
lines changed

subsys/bluetooth/controller/Kconfig.ll_sw_split

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ config BT_CTLR_SCAN_ENABLE_STRICT
499499

500500
config BT_CTLR_ISOAL_SN_STRICT
501501
bool "Enforce Strict Tx ISO Data Sequence Number use"
502-
depends on BT_CTLR_ADV_ISO || BT_CTLR_CONN_ISO
502+
depends on !BT_CTLR_ISOAL_PSN_IGNORE && (BT_CTLR_ADV_ISO || \
503+
BT_CTLR_CONN_ISO)
503504
default y
504505
help
505506
Enforce strict sequencing of released payloads based on the TX SDU's
@@ -517,6 +518,12 @@ config BT_CTLR_ISOAL_SN_STRICT
517518
dropped. This will result in better delivery of data to the receiver
518519
but at the cost of creating skews in the received stream of SDUs.
519520

521+
config BT_CTLR_ISOAL_PSN_IGNORE
522+
bool "Ignore Tx ISO Data Packet Sequence Number use"
523+
depends on BT_CTLR_ADV_ISO || BT_CTLR_CONN_ISO
524+
help
525+
Ignore the use of Tx ISO Data Packet Sequence Number.
526+
520527
config BT_CTLR_ZLI
521528
bool "Use Zero Latency IRQs"
522529
depends on ZERO_LATENCY_IRQS

subsys/bluetooth/controller/hci/hci.c

Lines changed: 93 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5657,8 +5657,6 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
56575657
struct bt_hci_iso_data_hdr *iso_data_hdr;
56585658
struct isoal_sdu_tx sdu_frag_tx;
56595659
struct bt_hci_iso_hdr *iso_hdr;
5660-
struct ll_iso_datapath *dp_in;
5661-
struct ll_iso_stream_hdr *hdr;
56625660
uint32_t *time_stamp;
56635661
uint16_t handle;
56645662
uint8_t pb_flag;
@@ -5668,8 +5666,6 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
56685666

56695667
iso_data_hdr = NULL;
56705668
*evt = NULL;
5671-
hdr = NULL;
5672-
dp_in = NULL;
56735669

56745670
if (buf->len < sizeof(*iso_hdr)) {
56755671
LOG_ERR("No HCI ISO header");
@@ -5747,16 +5743,49 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
57475743
* data path
57485744
*/
57495745
} else if (IS_CIS_HANDLE(handle)) {
5750-
struct ll_conn_iso_stream *cis =
5751-
ll_iso_stream_connected_get(handle);
5746+
struct ll_conn_iso_stream *cis;
5747+
struct ll_conn_iso_group *cig;
5748+
struct ll_iso_stream_hdr *hdr;
5749+
struct ll_iso_datapath *dp_in;
5750+
5751+
cis = ll_iso_stream_connected_get(handle);
57525752
if (!cis) {
57535753
return -EINVAL;
57545754
}
57555755

5756-
struct ll_conn_iso_group *cig = cis->group;
5757-
uint8_t event_offset;
5756+
cig = cis->group;
57585757

5759-
hdr = &(cis->hdr);
5758+
#if defined(CONFIG_BT_CTLR_ISOAL_PSN_IGNORE)
5759+
uint64_t event_count;
5760+
uint64_t pkt_seq_num;
5761+
5762+
/* Catch up local pkt_seq_num with internal pkt_seq_num */
5763+
event_count = cis->lll.event_count;
5764+
pkt_seq_num = event_count + 1U;
5765+
if (!(pb_flag & 0x01) &&
5766+
(((pkt_seq_num - cis->pkt_seq_num) &
5767+
BIT64_MASK(39)) <= BIT64_MASK(38))) {
5768+
cis->pkt_seq_num = pkt_seq_num;
5769+
} else {
5770+
pkt_seq_num = cis->pkt_seq_num;
5771+
}
5772+
5773+
/* Pre-increment, for next ISO data packet seq num comparison */
5774+
if (pb_flag & 0x10) {
5775+
cis->pkt_seq_num++;
5776+
}
5777+
5778+
/* Target next event to avoid overlapping with current event */
5779+
pkt_seq_num++;
5780+
sdu_frag_tx.target_event = pkt_seq_num;
5781+
sdu_frag_tx.grp_ref_point =
5782+
isoal_get_wrapped_time_us(cig->cig_ref_point,
5783+
((pkt_seq_num - event_count) *
5784+
cig->iso_interval *
5785+
ISO_INT_UNIT_US));
5786+
5787+
#else /* !CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
5788+
uint8_t event_offset;
57605789

57615790
/* We must ensure sufficient time for ISO-AL to fragment SDU and
57625791
* deliver PDUs to the TX queue. By checking ull_ref_get, we
@@ -5780,11 +5809,15 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
57805809
}
57815810

57825811
sdu_frag_tx.target_event = cis->lll.event_count + event_offset;
5783-
sdu_frag_tx.grp_ref_point = isoal_get_wrapped_time_us(cig->cig_ref_point,
5784-
(event_offset * cig->iso_interval *
5785-
ISO_INT_UNIT_US));
5812+
sdu_frag_tx.grp_ref_point =
5813+
isoal_get_wrapped_time_us(cig->cig_ref_point,
5814+
(event_offset *
5815+
cig->iso_interval *
5816+
ISO_INT_UNIT_US));
5817+
#endif /* !CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
57865818

57875819
/* Get controller's input data path for CIS */
5820+
hdr = &(cis->hdr);
57885821
dp_in = hdr->datapath_in;
57895822
if (!dp_in || dp_in->path_id != BT_HCI_DATAPATH_ID_HCI) {
57905823
LOG_ERR("Input data path not set for HCI");
@@ -5817,8 +5850,6 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
58175850
struct ll_adv_iso_set *adv_iso;
58185851
struct lll_adv_iso *lll_iso;
58195852
uint16_t stream_handle;
5820-
uint8_t target_event;
5821-
uint8_t event_offset;
58225853
uint16_t slen;
58235854

58245855
/* FIXME: Code only expects header present */
@@ -5844,6 +5875,53 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
58445875
return -EINVAL;
58455876
}
58465877

5878+
lll_iso = &adv_iso->lll;
5879+
5880+
#if defined(CONFIG_BT_CTLR_ISOAL_PSN_IGNORE)
5881+
uint64_t event_count;
5882+
uint64_t pkt_seq_num;
5883+
5884+
/* Catch up local pkt_seq_num with internal pkt_seq_num */
5885+
event_count = lll_iso->payload_count / lll_iso->bn;
5886+
pkt_seq_num = event_count;
5887+
if (!(pb_flag & 0x01) &&
5888+
(((pkt_seq_num - stream->pkt_seq_num) &
5889+
BIT64_MASK(39)) <= BIT64_MASK(38))) {
5890+
stream->pkt_seq_num = pkt_seq_num;
5891+
} else {
5892+
pkt_seq_num = stream->pkt_seq_num;
5893+
}
5894+
5895+
/* Pre-increment, for next ISO data packet seq num comparison */
5896+
if (pb_flag & 0x10) {
5897+
stream->pkt_seq_num++;
5898+
}
5899+
5900+
/* Target next event to avoid overlapping with current event */
5901+
/* FIXME: Implement ISO Tx ack generation early in done compared
5902+
* to currently only in prepare. I.e. to ensure upper
5903+
* layer has the number of completed packet before the
5904+
* next BIG event, so as to supply new ISO data packets.
5905+
* Without which upper layers need extra buffers to
5906+
* buffer next ISO data packet.
5907+
*
5908+
* Enable below increment once early Tx ack is
5909+
* implemented.
5910+
*
5911+
* pkt_seq_num++;
5912+
*/
5913+
sdu_frag_tx.target_event = pkt_seq_num;
5914+
sdu_frag_tx.grp_ref_point =
5915+
isoal_get_wrapped_time_us(adv_iso->big_ref_point,
5916+
(((pkt_seq_num + 1U) -
5917+
event_count) *
5918+
lll_iso->iso_interval *
5919+
ISO_INT_UNIT_US));
5920+
5921+
#else /* !CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
5922+
uint8_t target_event;
5923+
uint8_t event_offset;
5924+
58475925
/* Determine the target event and the first event offset after
58485926
* datapath setup.
58495927
* event_offset mitigates the possibility of first SDU being
@@ -5861,7 +5939,6 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
58615939
* BIG event by incrementing the previous elapsed big_ref_point
58625940
* by one additional ISO interval.
58635941
*/
5864-
lll_iso = &adv_iso->lll;
58655942
target_event = lll_iso->payload_count / lll_iso->bn;
58665943
event_offset = ull_ref_get(&adv_iso->ull) ? 0U : 1U;
58675944
event_offset += lll_iso->latency_prepare;
@@ -5872,6 +5949,7 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
58725949
((event_offset + 1U) *
58735950
lll_iso->iso_interval *
58745951
ISO_INT_UNIT_US));
5952+
#endif /* !CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
58755953

58765954
/* Start Fragmentation */
58775955
/* FIXME: need to ensure ISO-AL returns proper isoal_status.

subsys/bluetooth/controller/ll_sw/ull_central_iso.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,9 @@ uint8_t ull_central_iso_setup(uint16_t cis_handle,
883883
#endif /* !CONFIG_BT_CTLR_JIT_SCHEDULING */
884884

885885
cis->central.instant = instant;
886+
#if defined(CONFIG_BT_CTLR_ISOAL_PSN_IGNORE)
887+
cis->pkt_seq_num = 0U;
888+
#endif /* CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
886889
cis->lll.event_count = LLL_CONN_ISO_EVENT_COUNT_MAX;
887890
cis->lll.next_subevent = 0U;
888891
cis->lll.sn = 0U;

subsys/bluetooth/controller/ll_sw/ull_conn_iso_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ struct ll_conn_iso_stream {
4848
*/
4949
uint8_t terminate_reason;
5050
uint8_t cis_id;
51+
52+
#if defined(CONFIG_BT_CTLR_ISOAL_PSN_IGNORE)
53+
uint64_t pkt_seq_num:39;
54+
#endif /* CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
5155
};
5256

5357
struct ll_conn_iso_group {

subsys/bluetooth/controller/ll_sw/ull_peripheral_iso.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ uint8_t ull_peripheral_iso_setup(struct pdu_data_llctrl_cis_ind *ind,
326326
cis->sync_delay = sys_get_le24(ind->cis_sync_delay);
327327
cis->offset = cis_offset;
328328
memcpy(cis->lll.access_addr, ind->aa, sizeof(ind->aa));
329+
#if defined(CONFIG_BT_CTLR_ISOAL_PSN_IGNORE)
330+
cis->pkt_seq_num = 0U;
331+
#endif /* CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
329332
cis->lll.event_count = LLL_CONN_ISO_EVENT_COUNT_MAX;
330333
cis->lll.next_subevent = 0U;
331334
cis->lll.sn = 0U;

0 commit comments

Comments
 (0)