-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bluetooth: Controller: ISO Sync Receiver with ticks_slot_window #75760
Bluetooth: Controller: ISO Sync Receiver with ticks_slot_window #75760
Conversation
f90eb08
to
27e3f8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR adds a lot of new code that is very hard to read due to the additional Kconfig options (#if defined
generally makes things harder to read).
Additionally the general lack of documentation for internal functions and their behavior and the long functions make it nearly impossible to actually understand what is going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always get sad when I see more Kconfig options for the LL :( It's already way too hard to configure, and we keep adding more and more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Kconfig's have been added incrementally, atleast trying to keep existing features not being disturbed too much. Most internal once should get hidden under the Advanced Features
but some of them are being be used outside. But hopefully will make them defaults in the future when the options form matured options in default builds of samples. Least or seldom used Kconfigs can be delete there after.
depends on BT_BROADCASTER && BT_CTLR_ADV_EXT | ||
select BT_TICKER_EXT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reasoning behind select
ing BT_TICKER_EXT
rather than depending on it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will fix this to be depends on
config BT_CTLR_SYNC_ISO_SLOT_WINDOW_JITTER | ||
bool "Wrap ISO Synchronized Receiver event around overlapping roles" | ||
depends on BT_CTLR_SYNC_ISO && !BT_CTLR_SYNC_ISO_RESERVE_MAX | ||
select BT_TICKER_EXT | ||
help | ||
Wrap ISO Synchronized Receiver event around overlapping roles using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may just be unaware, but what are roles
in this context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roles
/ states
are defined in BT Spec LINK LAYER STATES
section, for example central
peripheral
are the two roles in connection state.
@@ -742,8 +759,22 @@ config BT_CTLR_CENTRAL_RESERVE_MAX | |||
Note, currently this value is only used to space multiple central | |||
connections and not for actual ticker time reservations. | |||
|
|||
config BT_CTLR_PERIPHERAL_RESERVE_MAX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be placed next to BT_CTLR_PERIPHERAL_ISO_EARLY_CIG_START
to group the BT_CTLR_PERIPHERAL*
configs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that is peripheral ISO related. Where as this new one is related to normal peripheral ACL scheduling.
struct { | ||
uint8_t initiated:1; | ||
uint8_t cancelled:1; | ||
uint8_t forced:1; | ||
}; | ||
|
||
struct { | ||
uint8_t initiated:1; | ||
uint8_t cancelled:1; | ||
uint8_t forced:1; | ||
} central; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between these 2 structs now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnamed struct is now used by a common code block and hence did not want to have a named reference as central
or peripheral
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to put that in a comment, as that is non-obvious. Looks more like a merge conflict gone wrong :P
payload_offset = (lll->latency_event * lll->bn) + | ||
(lll->bn_curr - 1U); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are adding multiplying 2 uint8_ts and adding it to another uint8 and store the result in a uint8 without any checks for overflow.
This looks dangerous to me, and suggest to either store the result in a uint16 and check the result, or add an assert for the other values to ensure that we don't get an overflow here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressing here: #75638
@@ -699,10 +769,15 @@ static void isr_rx(void *param) | |||
lll->bn_curr = 1U; | |||
lll->irc_curr++; | |||
|
|||
payload_offset = (lll->latency_event * lll->bn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto: Nothing to prevent an overflow here.
This is, IMO, a general issue in the controller as values are rarely checked.
if (latency_event--) { | ||
goto isr_rx_done_latency_event; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reasoning behind using goto
here instead of a while (latency_event--)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was a quick hack... will fix this
/* Pick the ticker expiry latency, to calculate ticks_at_expire | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* Pick the ticker expiry latency, to calculate ticks_at_expire | |
*/ | |
/* Pick the ticker expiry latency, to calculate ticks_at_expire */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you've still (mis?)configured your editor to use 80 instead of 100 line length with autoformatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, it doesn't look like these new Kconfig options are ever tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I will add modified bsim tests to cover the enhancements, the bap_broadcast_sink variant with XO clock drifts to have ACL connection in a sink drift over the BIG sync events, and measure SDU drops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reviewing, valuable inputs, and as always it takes me some time to refine the implementation, hope you retain your patience :-)
depends on BT_BROADCASTER && BT_CTLR_ADV_EXT | ||
select BT_TICKER_EXT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will fix this to be depends on
config BT_CTLR_SYNC_ISO_SLOT_WINDOW_JITTER | ||
bool "Wrap ISO Synchronized Receiver event around overlapping roles" | ||
depends on BT_CTLR_SYNC_ISO && !BT_CTLR_SYNC_ISO_RESERVE_MAX | ||
select BT_TICKER_EXT | ||
help | ||
Wrap ISO Synchronized Receiver event around overlapping roles using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roles
/ states
are defined in BT Spec LINK LAYER STATES
section, for example central
peripheral
are the two roles in connection state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Kconfig's have been added incrementally, atleast trying to keep existing features not being disturbed too much. Most internal once should get hidden under the Advanced Features
but some of them are being be used outside. But hopefully will make them defaults in the future when the options form matured options in default builds of samples. Least or seldom used Kconfigs can be delete there after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I will add modified bsim tests to cover the enhancements, the bap_broadcast_sink variant with XO clock drifts to have ACL connection in a sink drift over the BIG sync events, and measure SDU drops.
@@ -742,8 +759,22 @@ config BT_CTLR_CENTRAL_RESERVE_MAX | |||
Note, currently this value is only used to space multiple central | |||
connections and not for actual ticker time reservations. | |||
|
|||
config BT_CTLR_PERIPHERAL_RESERVE_MAX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that is peripheral ISO related. Where as this new one is related to normal peripheral ACL scheduling.
struct { | ||
uint8_t initiated:1; | ||
uint8_t cancelled:1; | ||
uint8_t forced:1; | ||
}; | ||
|
||
struct { | ||
uint8_t initiated:1; | ||
uint8_t cancelled:1; | ||
uint8_t forced:1; | ||
} central; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnamed struct is now used by a common code block and hence did not want to have a named reference as central
or peripheral
.
drift_us %= lll->sub_interval; | ||
drift_us = lll->sub_interval - drift_us; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am trying to calculate a remaining sub_interval
of a remainder (modulus) of sub_interval
of drift_us
... now you see I am not good at explaining :-(...
static int is_abort_cb(void *next, void *curr, lll_prepare_cb_t *resume_cb) | ||
{ | ||
#if defined(CONFIG_BT_CTLR_SYNC_ISO_SLOT_WINDOW_JITTER) | ||
if (!next) { | ||
*resume_cb = resume_prepare_cb; | ||
|
||
return -EAGAIN; | ||
} | ||
#endif /* CONFIG_BT_CTLR_SYNC_ISO_SLOT_WINDOW_JITTER */ | ||
|
||
return -ECANCELED; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok... it is not documented...i agree... i should...
0 - pre-emptee succeeds to continue radio use, and pre-emptor is informed
-EAGAIN - pre-emptee looses and requests a resumption later, and pre-emptor will be scheduled
-ECANCELED - pre-emptee looses and be aborted, and pre-emptor will be scheduled
if (latency_event--) { | ||
goto isr_rx_done_latency_event; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was a quick hack... will fix this
760de75
to
0ada552
Compare
0ada552
to
f9ac084
Compare
rebased to ensure CI is passing, keeping this PR draft and will be sending smaller PRs with considerations to already provided review comments here. |
f9ac084
to
03732f1
Compare
2141ac7
to
26363ee
Compare
Simplify ticker reschedule_in_window implementation. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Remove ticks_elapsed use in reschedule_in_window as it has already been used in the bottom half processing. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Introduce ticker reschedule with jitter so that role like BIG can start after overlapping ACL and receive subsequent subevents. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Add implementation for ISO Sync Receiver to use ticks slot window feature. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Add implementation to support resumption of cancelled prepare. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Added implementation to have ISO Sync Receiver resume its subevents after being aborted by other overlapping events. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Introduce BT_CTLR_PERIPHERAL_RESERVE_MAX Kconfig option so that disabling this option will use minimum time reservation and exercise the peripheral connection event continuation using is_abort_cb mechanism. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Fix BT_CTLR_SCAN_AUX_SYNC_RESERVE_MIN such that event is not aborted when near supervision timeout conditions. Relates to commit ddf0499 ("Bluetooth: Controller: Add abort fairness in overlapping Periodic Sync"). Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Fix incorrect elapsed events value when event prepare are aborted in the pipeline. This caused premature supervision timeouts. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Add implementation for Extended Advertising Auxiliary PDUs to use ticks slot window feature. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
26363ee
to
0c4ab4b
Compare
@cvinayak what was the reason for closing this? |
This PR contained a mix of some fundamental changes to nRF specific Low Level scheduling (for which I will need new bsim tests, only tested using manual bsim samples); and, commits that fix/improve inter-operability with Sony Xperia and Samsung S24 phones. The fix/improvement commits are now in #77921 (which is also draft, as I need to complete handling of Also, I would like #78894 to be merged ahead. To summarize the order:
|
Add implementation for ISO Sync Receiver to use ticks slot
window feature.
Added implementation to have ISO Sync Receiver resume its
subevents after being aborted by other overlapping events.
Introduce BT_CTLR_PERIPHERAL_RESERVE_MAX Kconfig option so
that disabling this option will use minimum time reservation
and exercise the peripheral connection event continuation
using is_abort_cb mechanism.
Add implementation for Extended Advertising Auxiliary PDUs
to use ticks slot window feature.
May fix #56201.