Skip to content

Conversation

@andrzej-kaczmarek
Copy link
Contributor

This adds support to scan complete periodic adv trains including mixed scheduling from ULL/LLL if necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Rename is_aux_sched to aux_lll_sched in LLL context for consistency.

Suggested change
if (ftr->aux_lll_sched) {
lll->aux_lll_sched = ftr->aux_lll_sched;
if (ftr->aux_lll_sched) {

@cvinayak cvinayak added this to the v2.7.0 milestone Aug 26, 2021
Copy link
Contributor

@ppryga-nordic ppryga-nordic left a comment

Choose a reason for hiding this comment

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

I'm wondering about one situation. What in case the scanner is synchronized to periodic advertisement, there is a chain of e.g. 6 PDUs. 4th AUX_CHAIN_IND PDU is received with wrong CRC. node_rx is set to type: NODE_RX_TYPE_EXT_AUX_RELEASE but no report is generated to inform host about incomplete data and no more IQ reports.

See 7.7.65.21 LE Connectionless IQ Report event:

This event is also used by the Controller to report that it has insufficient
resources to report IQ samples for all received Constant Tone Extensions and
has failed to sample at least once. In this case Packet_Status shall be set to
0xFF and Sample_Count to 0x00.

Copy link
Contributor

Choose a reason for hiding this comment

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

This function declaration should go into nordic/lll/lll_sync_interna.h. There is no such file, so please create a new one.

Copy link
Contributor

Choose a reason for hiding this comment

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

The function may be changed to static. It is used in lll_sync.c only.

Copy link
Contributor

Choose a reason for hiding this comment

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

err here overlaps with err declared at the beginning of the function.

Copy link
Contributor

Choose a reason for hiding this comment

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

what about this?

@cvinayak
Copy link
Contributor

I'm wondering about one situation. What in case the scanner is synchronized to periodic advertisement, there is a chain of e.g. 6 PDUs. 4th AUX_CHAIN_IND PDU is received with wrong CRC. node_rx is set to type: NODE_RX_TYPE_EXT_AUX_RELEASE but no report is generated to inform host about incomplete data and no more IQ reports.

See 7.7.65.21 LE Connectionless IQ Report event:

This event is also used by the Controller to report that it has insufficient
resources to report IQ samples for all received Constant Tone Extensions and
has failed to sample at least once. In this case Packet_Status shall be set to
0xFF and Sample_Count to 0x00.

Yes, I noticed this when making changes towards NODE_RX_TYPE_RELEASE handling in ull.c. We have to address the incomplete data status in separate PR as a bug fix.

@ppryga-nordic
Copy link
Contributor

The PR has to be merged after: #37930

@ppryga-nordic
Copy link
Contributor

ppryga-nordic commented Aug 26, 2021

I've just spot one more thing.
There is not enough node_rx buffers for LLL to ULL when per. adv. scan and direction finding are enabled.
Default value of BT_CTLR_ADV_EXT_RX_CNT is set to 0 if CONFIG_BT_MAX_CONN is not set (selected by CONFIG_BT_PERIPHERAL or CONFIG_BT_CENTRAL) or 1 in other case.

Max number of node_rx required to single per. adv. event (when DF is also enabled) is 16x2 (per. adv. reports, cte IQ reports).
Including shortest possible duration between chained PDUs to be T_MAFS, single event may last ~8.5ms (16 * ~530us).

I suggest to change the BT_CTLR_ADV_EXT_RX_CNT to 32. @cvinayak what is your opinion?

This is solved by commit: a1b8d14

@cvinayak
Copy link
Contributor

I suggest to change the BT_CTLR_ADV_EXT_RX_CNT to 32. @cvinayak what is your opinion?

Set the required number conditionally based on features enabled (Do not want increased RAM when Periodic and/or DF is not used).

@andrzej-kaczmarek
Copy link
Contributor Author

@cvinayak @ppryga I pushed additional commit that addresses main issue i.e. moving sync specific code from lll_scan_aux to lll_sync. There's just one extra branch in prepare_cb that depends on scan/sync context since the same ticker is used by both, but it can be compiled out if periodic advertising sync is not enabled as it just calls code from lll_sync if needed. I'll start addressing remaining comments now.

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.

Did a quick pass, looks good. Will do some testing and review early tomorrow, and will get back.

Copy link
Contributor

@ppryga-nordic ppryga-nordic left a comment

Choose a reason for hiding this comment

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

I went over last commit very briefly. I'll continue that in the morning.

@ppryga-nordic
Copy link
Contributor

No more comments from my site.

@andrzej-kaczmarek
Copy link
Contributor Author

@ppryga @cvinayak All comments are fixed, I hope I did not miss anything. I also added few #ifdefs in ull_scan_aux.c to compile out code for sync paths if periodic advertising is not enabled. PR is now also rebased on latest main.

Copy link
Contributor

@ppryga-nordic ppryga-nordic left a comment

Choose a reason for hiding this comment

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

There are some not addressed comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

The function may be changed to static. It is used in lll_sync.c only.

Copy link
Contributor

Choose a reason for hiding this comment

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

what about this?

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 more stressing change requests from my side. I could not get to testing, but will do when I can get to it in my todo. Any functional issues can be address when discovered as bug fixes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking aloud, no change required. Application ecosystems with known max data length may want the count to be configurable to reduce RAM.

Copy link
Contributor

@ppryga-nordic ppryga-nordic left a comment

Choose a reason for hiding this comment

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

Tested with use of direction_finding_connectionless_rx. Changes approved.

Periodic advertising reports can have 255 bytes of payload so need to
use that value by default if periodic advertising is enabled.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
We should decide on flush immediately vs. from disabled_cb based on
ull_hdr reference count instead of last rxd node - if ull_hdr has
non-zero ref, then done event is still pending and we should flush
from there.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
aux->rx_last cannot be NULL since it's always set after acquire to a
valid node so the flow in flush() can be simplified.

rx parameter is only used to update PDU chain, then it's overwritten,
so we can instead update PDU chain in caller since there's only one
place when this should happen.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
This adds complete support for scanning for periodic advertising trains.

AUX_SYNC_IND is always scheduled from ULL as usual, then code for aux
scanning is reused to allow for AUX_CHAIN_IND scanning scheduled from
both ULL and LLL, depending on AuxPtr.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
We use 1st node enqueued in aux context to retrieve lll scan/sync
struct, but that only works if we buffer PDUs in aux context. It's
better to store parent lll struct as explicit member in aux context
as this also works if we skip buffering.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
Periodic advertising reports can be reated directly from single PDU
as they do not require any information from superior PDU, so we can
dispatch them immediately instead of buffering in aux context and
flushing at the end of chain.

This also resolves proper order of Periodic advertising and IQ reports.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
AdvA, TargetA, ADI and SyncInfo are RFU in periodic advertising PDUs so
we should ignore them when present in PDU.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
Periodic advertising PDUs are now dispatched immediately one by one
(i.e. without list of PDUs as when flushed from aux context) so we
do not need to iterate such a list.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
This updates DF to properly receive CTE in per adv chains scanning.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
Periodic advertising train scanner implemented in lll_scan_aux adds lots
of branches that cannot be compiled out with periodic advertising sync
disabled.

This commit moves sync parts of the code from lll_scan_aux to lll_sync.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
This seems not to be needed anymore, it's only written.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
We need more RX nodes when scanning either extended/periodic advertising
trains and CTE samples so pudate those values based on observer and DF
features enabled.

The number of nodes for non-DF allows to scan complete chain for each
aux scan set (assuming max data length and optimal fragmentation by
advertiser), for DF it allows to scan max possible PDUs and CTE samples.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
This was changes when sync chain handling was done in lll_scan_aux, we
can now revert to original code.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
Add todos for few useful improvements that can be done later.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
'err' is already defined in parent scope, we can use. Just need to set
it back to 0 before returning from function.

Signed-off-by: Andrzej Kaczmarek <[email protected]>
@andrzej-kaczmarek
Copy link
Contributor Author

rebased due to conflict after #37934 was merged

@nashif nashif merged commit f2f99c0 into zephyrproject-rtos:main Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants