Skip to content
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: Implement PAST Support #78894

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lutb-ot
Copy link
Contributor

@lutb-ot lutb-ot commented Sep 23, 2024

Implements:

  • LLCP PDU Flow and unittests for Periodic Sync Indication
  • Implements PAST support in ULL
  • PAST bsim tests
  • Fix PAST support bap_scan_delegator

platform_allow:
- nrf52_bsim
- nrf5340bsim/nrf5340/
- nrf5340bsim/nrf5340/cpuapp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to build for the nrf5340bsim/nrf5340/cpuapp you'll need to use sysbuild (you can check other bsim tests building for it)

tests/bluetooth/controller/mock_ctrl/src/ull_sync.c Outdated Show resolved Hide resolved
Copy link
Contributor

@cvinayak cvinayak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial comments, will do re-review after these comments are addressed and CI jobs are passing.

subsys/bluetooth/controller/Kconfig Outdated Show resolved Hide resolved
subsys/bluetooth/controller/hci/hci.c Outdated Show resolved Hide resolved
Copy link
Contributor

@cvinayak cvinayak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a very quick pass, the changes LGTM, I do not see any objections from my side. Just get the CI happy :-)

Copy link
Contributor

@cvinayak cvinayak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick.... use Bluetooth and Controller with B and C in commit title and message body etc... (BT Spec documentation uses so).

@cvinayak cvinayak dismissed their stale review September 25, 2024 10:12

I change requests have been addressed.

@lutb-ot lutb-ot marked this pull request as ready for review September 25, 2024 18:25
cvinayak
cvinayak previously approved these changes Sep 25, 2024
Copy link
Collaborator

@Thalley Thalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work. Great that you've added a bunch of tests for this

Most comments are code style and security related

subsys/bluetooth/audio/bap_scan_delegator.c Outdated Show resolved Hide resolved
subsys/bluetooth/controller/CMakeLists.txt Outdated Show resolved Hide resolved
subsys/bluetooth/controller/hci/hci.c Outdated Show resolved Hide resolved
subsys/bluetooth/controller/hci/hci.c Outdated Show resolved Hide resolved
tests/bluetooth/controller/mock_ctrl/src/ull_adv_sync.c Outdated Show resolved Hide resolved
tests/bsim/bluetooth/audio/src/bap_scan_delegator_test.c Outdated Show resolved Hide resolved
Comment on lines 8 to 9
CONFIG_BT_ISO_BROADCASTER=y
CONFIG_BT_ISO_SYNC_RECEIVER=y
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ISO needed for this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, same as earlier message.

Comment on lines +40 to +50
#define FAIL(...) \
do { \
bst_result = Failed; \
bs_trace_error_time_line(__VA_ARGS__); \
} while (0)

#define PASS(...) \
do { \
bst_result = Passed; \
bs_trace_info_time(1, __VA_ARGS__); \
} while (0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider having a look at the https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/bsim/babblekit and https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/bluetooth/common/testlib to see if you can reduce the overhead here by using the predefined test helpers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how it is done everywhere, so it should probably be a separate PR for fixing and cleaning this up everywhere in both host and controller bsim tests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your point, although I don't necessarily agree. We do not need to follow the structure of older tests if new tests could use frameworks that were not available when the older tests were written.

It's OK to keep as is, but could have saved you time to use the frameworks we have now :)

subsys/bluetooth/controller/ll_sw/ull_adv_types.h Outdated Show resolved Hide resolved
subsys/bluetooth/controller/ll_sw/ull_sync_types.h Outdated Show resolved Hide resolved
subsys/bluetooth/controller/ll_sw/ull_conn_types.h Outdated Show resolved Hide resolved
INVALID_SYNC_HANDLE;
ctx->data.periodic_sync.adv_handle = adv_sync ? ull_adv_sync_handle_get(adv_sync) :
INVALID_ADV_HANDLE;
ctx->data.periodic_sync.id = service_data;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to use service_data instead of id in the periodic_sync struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason it is called ID is because of the naming in the Spec:

"ID shall be set to an identifier provided by the Host. This is for use by higher-level protocols and its value is not specified or used by this specification."

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, interesting. I'm having trouble finding where it's defined that the id here is the same value as the service_data provided by the host. I believe it's correct that it is, but haven't found where that's explicitly stated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen it explicitly stated anywhere in the Spec. However, it is the only host parameter in HCI_LE_­Periodic_­Advertising_­Sync_­Transfer and HCI_LE_­Periodic_­Advertising_­Sync_­Transfer with the correct range and description, but it is not explicitly stated anywhere.

subsys/bluetooth/controller/ll_sw/ull_llcp.c Show resolved Hide resolved
subsys/bluetooth/controller/ll_sw/ull_sync.c Outdated Show resolved Hide resolved
@lutb-ot lutb-ot force-pushed the add_past_support branch 2 times, most recently from 0813c81 to 4a2e12d Compare October 7, 2024 10:59
Copy link
Collaborator

@Thalley Thalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more blocking comments from me, but we should really get @cvinayak to do another review and respond to some of the outstanding comments before I'll approve

cvinayak
cvinayak previously approved these changes Oct 8, 2024
Copy link
Contributor

@cvinayak cvinayak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No definite change requests from my end. LGTM.

Comment on lines 42 to 44
CONFIG_BT_CTLR_SYNC_ISO_STREAM_COUNT=1
CONFIG_BT_CTLR_CONN_ISO_STREAMS=1
CONFIG_BT_CTLR_CONN_ISO_GROUPS=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lutb-ot you should make sca available for PAST support too.

Background, periodic sync needs sca but uses it as local variable to calculate window widening. But a ISO sync is established using an inherited sca value, hence sca was stored in lll_sync context. Now that PAST feature will need the sca to be remembered, i think we should make the sca field available in the lll_sync context? or wait, if this is for window widening, then it would be calculated only once, do we really need it to be present in lll_sync context?

subsys/bluetooth/controller/ll_sw/ull_sync.c Outdated Show resolved Hide resolved
subsys/bluetooth/controller/ll_sw/ull_conn.c Show resolved Hide resolved
PDU_SYNC_INFO_SCA_CHM_SCA_BIT_MASK) >>
PDU_SYNC_INFO_SCA_CHM_SCA_BIT_POS;

lll->sca = sca;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont you need conditional compiles here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole function is already flaged with CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER.

@kruithofa kruithofa removed their request for review October 15, 2024 11:07
Adding PDU flow for Periodic Sync Indication

Signed-off-by: Lucas Mathias Balling <[email protected]>
Added LLCP PDU Periodic Sync Indication unittests

Signed-off-by: Lucas Mathias Balling <[email protected]>
@lutb-ot lutb-ot force-pushed the add_past_support branch 2 times, most recently from 66b4b23 to 1d91fa8 Compare October 22, 2024 20:08
Implement PAST support in ULL and fixed test after changed
dependencies in ull_sync_internal.c

Signed-off-by: Lucas Mathias Balling <[email protected]>
Implemented:
  * Central sync to broadcaster, connects to peripheral and
    transfers sync. Peripheral Syncs to PA
  * Broadcaster acting Central connects to peripheral
    and transfers sync. Peripheral sync to PA
  * Moved previous bis tests to test_bis.c and
    new PAST tests was added in test_past.c

Signed-off-by: Lucas Mathias Balling <[email protected]>
Fixed PAST support for bap_scan_delegator

Signed-off-by: Lucas Mathias Balling <[email protected]>
@Thalley Thalley requested a review from cvinayak October 22, 2024 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

5 participants