diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf index a7487118694a0..13b4268e1656a 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y @@ -40,7 +40,11 @@ CONFIG_BT_ISO_PERIPHERAL=n # ISO Streams CONFIG_BT_ISO_MAX_CHAN=4 -CONFIG_BT_ISO_TX_BUF_COUNT=1 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=12 CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf index 0d78cf862eedb..8cc6ac936c9c2 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf @@ -1,7 +1,7 @@ CONFIG_IPC_SERVICE=y CONFIG_MBOX=y -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf index f7e1f8fc6737d..19b78f03302ca 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y @@ -39,7 +39,11 @@ CONFIG_BT_ISO_PERIPHERAL=y # ISO Streams CONFIG_BT_ISO_MAX_CHAN=4 -CONFIG_BT_ISO_TX_BUF_COUNT=1 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=12 CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller @@ -82,8 +86,8 @@ CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM=6 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=y -CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf index b183a4c9825fc..3859fc011f867 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf index 925eac8e34e63..5f10718be2496 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_CBPRINTF_REDUCED_INTEGRAL=y CONFIG_ISR_TABLES_LOCAL_DECLARATION=y @@ -46,7 +46,11 @@ CONFIG_BT_ISO_PERIPHERAL=y CONFIG_BT_ISO_TX_MTU=310 CONFIG_BT_ISO_RX_MTU=310 CONFIG_BT_ISO_MAX_CHAN=4 -CONFIG_BT_ISO_TX_BUF_COUNT=1 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=8 CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller @@ -100,8 +104,8 @@ CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_CTLR_ADV_PERIODIC=y CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER=y CONFIG_BT_CTLR_ADV_ISO=y -CONFIG_BT_CTLR_ADV_ISO_SET=2 -CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=4 +CONFIG_BT_CTLR_ADV_ISO_SET=1 +CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=2 CONFIG_BT_CTLR_ADV_ISO_STREAM_MAX=2 CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 @@ -118,16 +122,16 @@ CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=y -CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y # ISO Transmissions -CONFIG_BT_CTLR_ISOAL_SOURCES=4 -CONFIG_BT_CTLR_ISO_TX_BUFFERS=12 +CONFIG_BT_CTLR_ISOAL_SOURCES=2 +CONFIG_BT_CTLR_ISO_TX_BUFFERS=8 CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 # ISO Receptions diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf index 67c5854c9c0c7..8bcce089c6ea8 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y @@ -20,11 +20,18 @@ CONFIG_BT_OBSERVER=n CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y CONFIG_BT_ISO_BROADCASTER=y -CONFIG_BT_ISO_MAX_CHAN=4 -CONFIG_BT_ISO_TX_BUF_COUNT=1 CONFIG_BT_CENTRAL=n CONFIG_BT_PERIPHERAL=n +# ISO Streams +CONFIG_BT_ISO_MAX_CHAN=4 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=12 +CONFIG_BT_ISO_RX_BUF_COUNT=1 + # ISO Broadcast Controller CONFIG_BT_LL_SW_SPLIT=y CONFIG_BT_CTLR_ADV_PERIODIC=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf index 505b9d352ba0e..2a450dfdf2e47 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y @@ -35,7 +35,11 @@ CONFIG_BT_ISO_PERIPHERAL=n # ISO Streams CONFIG_BT_ISO_MAX_CHAN=2 -CONFIG_BT_ISO_TX_BUF_COUNT=1 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=12 CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller @@ -46,8 +50,8 @@ CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=n -CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf index 05c9a9d39033e..31eb9f6669e4f 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y @@ -35,7 +35,11 @@ CONFIG_BT_ISO_PERIPHERAL=y # ISO Streams CONFIG_BT_ISO_MAX_CHAN=2 -CONFIG_BT_ISO_TX_BUF_COUNT=1 +# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count +# is used in the context of IPC which falls into a "Newton's Cradle" effect +# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT) +# buffers get throttled. Hence, always have the value equal or greater. +CONFIG_BT_ISO_TX_BUF_COUNT=12 CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller @@ -46,8 +50,8 @@ CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=191 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=n CONFIG_BT_CTLR_PERIPHERAL_ISO=y -CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf index 51ca53e83f233..872da8f681b88 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024 CONFIG_IDLE_STACK_SIZE=256 CONFIG_MAIN_STACK_SIZE=512 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 -CONFIG_HEAP_MEM_POOL_SIZE=8192 +CONFIG_HEAP_MEM_POOL_SIZE=6144 CONFIG_BT=y CONFIG_BT_HCI_RAW=y diff --git a/samples/bluetooth/hci_ipc/overlay-nrf5340_cpunet_iso_nrf21540_ek-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/overlay-nrf5340_cpunet_iso_nrf21540_ek-bt_ll_sw_split.conf new file mode 100644 index 0000000000000..12ab4e53eb935 --- /dev/null +++ b/samples/bluetooth/hci_ipc/overlay-nrf5340_cpunet_iso_nrf21540_ek-bt_ll_sw_split.conf @@ -0,0 +1,6 @@ +# Reduce from 310 bytes, in nrf5340_cpunet_iso-bt_ll_sw_split.conf +# to be able to fit in 64KB RAM, in case needed in the future. + +# Example: +# CONFIG_BT_ISO_TX_MTU=247 +# CONFIG_BT_ISO_RX_MTU=251 diff --git a/samples/bluetooth/hci_ipc/sample.yaml b/samples/bluetooth/hci_ipc/sample.yaml index dd9edc4e9eeb7..b758b25476880 100644 --- a/samples/bluetooth/hci_ipc/sample.yaml +++ b/samples/bluetooth/hci_ipc/sample.yaml @@ -87,6 +87,7 @@ tests: tags: bluetooth extra_args: - CONF_FILE="nrf5340_cpunet_iso-bt_ll_sw_split.conf" + - EXTRA_CONF_FILE="overlay-nrf5340_cpunet_iso_nrf21540_ek-bt_ll_sw_split.conf" - DTC_OVERLAY_FILE="./boards/nrf5340_audio_dk_nrf5340_cpunet_nrf21540_ek.overlay" platform_allow: - nrf5340_audio_dk/nrf5340/cpunet diff --git a/subsys/bluetooth/controller/Kconfig.ll_sw_split b/subsys/bluetooth/controller/Kconfig.ll_sw_split index 9399545b42ce9..7546660ecb37a 100644 --- a/subsys/bluetooth/controller/Kconfig.ll_sw_split +++ b/subsys/bluetooth/controller/Kconfig.ll_sw_split @@ -437,6 +437,17 @@ config BT_CTLR_ADV_RESERVE_MAX corresponding to the Advertising Data present at the time of the start/enable of Advertising is used. +config BT_CTLR_ADV_AUX_SLOT_WINDOW_DRIFT + bool "Drift Extended Advertising Auxiliary PDUs within a slot window" + depends on BT_TICKER_EXT && \ + BT_BROADCASTER && \ + BT_CTLR_ADV_EXT + default y if BT_CTLR_SYNC_ISO || BT_CTLR_CONN_ISO + help + Drift Extended Advertising Auxiliary PDUs within a slot window to + avoid overlapping with other periodically scheduled states/roles; and + be placed before or after such overlapping states/roles. + config BT_CTLR_ADV_ISO_RESERVE_MAX bool "Use maximum Broadcast ISO event time reservation" depends on BT_CTLR_ADV_ISO diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c index 7478bf7332be7..41ee575f44768 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c @@ -71,11 +71,18 @@ static void ticker_cb(uint32_t ticks_at_expire, uint32_t ticks_drift, static struct ll_adv_aux_set ll_adv_aux_pool[CONFIG_BT_CTLR_ADV_AUX_SET]; static void *adv_aux_free; -#if defined(CONFIG_BT_CTLR_ADV_PERIODIC) && defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO) +#if defined(CONFIG_BT_CTLR_ADV_AUX_SLOT_WINDOW_DRIFT) || \ + (defined(CONFIG_BT_CTLR_ADV_PERIODIC) && \ + defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO)) +#if defined(CONFIG_BT_CTLR_ADV_PERIODIC) && \ + defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO) static void ticker_update_op_cb(uint32_t status, void *param); +#endif /* CONFIG_BT_CTLR_ADV_PERIODIC && CONFIG_BT_TICKER_EXT_EXPIRE_INFO */ static struct ticker_ext ll_adv_aux_ticker_ext[CONFIG_BT_CTLR_ADV_AUX_SET]; -#endif /* !CONFIG_BT_CTLR_ADV_PERIODIC && CONFIG_BT_TICKER_EXT_EXPIRE_INFO */ +#endif /* CONFIG_BT_CTLR_ADV_AUX_SLOT_WINDOW_DRIFT || + * (CONFIG_BT_CTLR_ADV_PERIODIC && CONFIG_BT_TICKER_EXT_EXPIRE_INFO) + */ #endif /* (CONFIG_BT_CTLR_ADV_AUX_SET > 0) */ static uint16_t did_unique[PDU_ADV_SID_COUNT]; @@ -2600,6 +2607,12 @@ uint32_t ull_adv_aux_start(struct ll_adv_aux_set *aux, uint32_t ticks_anchor, aux_handle = ull_adv_aux_handle_get(aux); interval_us = aux->interval * PERIODIC_INT_UNIT_US; +#if defined(CONFIG_BT_CTLR_ADV_AUX_SLOT_WINDOW_DRIFT) + ll_adv_aux_ticker_ext[aux_handle].ticks_slot_window = + ULL_ADV_RANDOM_DELAY + aux->ull.ticks_slot; + ll_adv_aux_ticker_ext[aux_handle].is_drift_in_window = 1U; +#endif /* CONFIG_BT_CTLR_ADV_AUX_SLOT_WINDOW_DRIFT */ + #if defined(CONFIG_BT_CTLR_ADV_PERIODIC) && defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO) if (aux->lll.adv->sync) { const struct ll_adv_sync_set *sync = HDR_LLL2ULL(aux->lll.adv->sync); @@ -2612,14 +2625,22 @@ uint32_t ull_adv_aux_start(struct ll_adv_aux_set *aux, uint32_t ticks_anchor, } ll_adv_aux_ticker_ext[aux_handle].ext_timeout_func = ticker_cb; +#endif /* !CONFIG_BT_CTLR_ADV_PERIODIC || !CONFIG_BT_TICKER_EXT_EXPIRE_INFO */ +#if defined(CONFIG_BT_CTLR_ADV_AUX_SLOT_WINDOW_DRIFT) || \ + (defined(CONFIG_BT_CTLR_ADV_PERIODIC) && \ + defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO)) ret_cb = TICKER_STATUS_BUSY; ret = ticker_start_ext( -#else /* !CONFIG_BT_CTLR_ADV_PERIODIC || !CONFIG_BT_TICKER_EXT_EXPIRE_INFO */ +#else /* !CONFIG_BT_CTLR_ADV_AUX_SLOT_WINDOW_DRIFT && + * !(CONFIG_BT_CTLR_ADV_PERIODIC && CONFIG_BT_TICKER_EXT_EXPIRE_INFO) + */ ret_cb = TICKER_STATUS_BUSY; ret = ticker_start( -#endif /* !CONFIG_BT_CTLR_ADV_PERIODIC || !CONFIG_BT_TICKER_EXT_EXPIRE_INFO */ +#endif /* !CONFIG_BT_CTLR_ADV_AUX_SLOT_WINDOW_DRIFT && + * !(CONFIG_BT_CTLR_ADV_PERIODIC && CONFIG_BT_TICKER_EXT_EXPIRE_INFO) + */ TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_THREAD, (TICKER_ID_ADV_AUX_BASE + aux_handle), ticks_anchor, 0U, @@ -2628,10 +2649,14 @@ uint32_t ull_adv_aux_start(struct ll_adv_aux_set *aux, uint32_t ticks_anchor, (aux->ull.ticks_slot + ticks_slot_overhead), ticker_cb, aux, ull_ticker_status_give, (void *)&ret_cb -#if defined(CONFIG_BT_CTLR_ADV_PERIODIC) && defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO) +#if defined(CONFIG_BT_CTLR_ADV_AUX_SLOT_WINDOW_DRIFT) || \ + (defined(CONFIG_BT_CTLR_ADV_PERIODIC) && \ + defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO)) , &ll_adv_aux_ticker_ext[aux_handle] -#endif /* !CONFIG_BT_CTLR_ADV_PERIODIC || !CONFIG_BT_TICKER_EXT_EXPIRE_INFO */ +#endif /* CONFIG_BT_CTLR_ADV_AUX_SLOT_WINDOW_DRIFT || + * (CONFIG_BT_CTLR_ADV_PERIODIC && CONFIG_BT_TICKER_EXT_EXPIRE_INFO) + */ ); ret = ull_ticker_status_take(ret, &ret_cb); diff --git a/subsys/bluetooth/controller/ticker/ticker.c b/subsys/bluetooth/controller/ticker/ticker.c index c4a36e3cf567c..622134b486bf7 100644 --- a/subsys/bluetooth/controller/ticker/ticker.c +++ b/subsys/bluetooth/controller/ticker/ticker.c @@ -805,12 +805,17 @@ static uint32_t ticker_dequeue(struct ticker_instance *instance, uint8_t id) * The following rules are checked: * 1) If the periodic latency is not yet exhausted, node is skipped * 2) If the node has highest possible priority, node is never skipped - * 2) If the node will starve next node due to slot reservation + * 3) If the node will starve next node due to slot reservation * overlap, node is skipped if: * a) Next node has higher priority than current node * b) Next node has more accumulated latency than the current node * c) Next node is 'older' than current node and has same priority * d) Next node has force flag set, and the current does not + * 4) If using ticks slot window, + * a) current node can be rescheduled later in the ticks slot window + * 5) If using ticks slot window under yield (build time configuration), + * a) Current node can be rescheduled later in the ticks slot window when + * next node can not be rescheduled later in its ticks slot window * * @param nodes Pointer to ticker node array * @param ticker Pointer to ticker to resolve @@ -946,21 +951,23 @@ static uint8_t ticker_resolve_collision(struct ticker_node *nodes, * the ticks_slot_window. */ uint8_t next_not_ticks_slot_window = - (!TICKER_HAS_SLOT_WINDOW(ticker_next) || - ((acc_ticks_to_expire + - ticker_next->ext_data->ticks_slot_window - - ticker_next->ticks_slot) < - ticker->ticks_slot)); + !TICKER_HAS_SLOT_WINDOW(ticker_next) || + (ticker_next->ext_data->is_drift_in_window && + TICKER_HAS_SLOT_WINDOW(ticker)) || + ((acc_ticks_to_expire + + ticker_next->ext_data->ticks_slot_window - + ticker_next->ticks_slot) < + ticker->ticks_slot); /* Can the current ticker with ticks_slot_window be * scheduled after the colliding ticker? */ uint8_t curr_has_ticks_slot_window = - (TICKER_HAS_SLOT_WINDOW(ticker) && - ((acc_ticks_to_expire + - ticker_next->ticks_slot) < - (ticker->ext_data->ticks_slot_window - - ticker->ticks_slot))); + TICKER_HAS_SLOT_WINDOW(ticker) && + ((acc_ticks_to_expire + + ticker_next->ticks_slot) <= + (ticker->ext_data->ticks_slot_window - + ticker->ticks_slot)); #else /* !CONFIG_BT_TICKER_EXT_SLOT_WINDOW_YIELD */ #if defined(CONFIG_BT_TICKER_PRIORITY_SET) @@ -982,7 +989,7 @@ static uint8_t ticker_resolve_collision(struct ticker_node *nodes, (TICKER_HAS_SLOT_WINDOW(ticker) && !ticker->ticks_slot && ((acc_ticks_to_expire + - ticker_next->ticks_slot) < + ticker_next->ticks_slot) <= (ticker->ext_data->ticks_slot_window))); #endif /* !CONFIG_BT_TICKER_EXT_SLOT_WINDOW_YIELD */ @@ -2478,7 +2485,8 @@ static uint8_t ticker_job_reschedule_in_window(struct ticker_instance *instance) LL_ASSERT(ticker_resched->ticks_to_expire == 0U); /* Window start after intersection with already active node */ - window_start_ticks = instance->ticks_slot_previous; + window_start_ticks = instance->ticks_slot_previous + + HAL_TICKER_RESCHEDULE_MARGIN; /* If drift was applied to this node, this must be * taken into consideration. Reduce the window with @@ -2551,9 +2559,10 @@ static uint8_t ticker_job_reschedule_in_window(struct ticker_instance *instance) */ if (((window_start_ticks + ticks_slot) <= ticks_slot_window) && - (window_end_ticks > (ticks_start_offset + + (window_end_ticks >= (ticks_start_offset + ticks_slot))) { - if (!ticker_resched->ticks_slot) { + if (!ticker_resched->ticks_slot || + ext_data->is_drift_in_window) { /* Place at start of window */ ticks_to_expire = window_start_ticks; } else { @@ -2590,6 +2599,9 @@ static uint8_t ticker_job_reschedule_in_window(struct ticker_instance *instance) ticks_slot))) { /* Re-scheduled node fits before this node */ break; + } else { + /* Not inside the window */ + ticks_to_expire = 0U; } /* We din't find a valid slot for re-scheduling - try @@ -2597,12 +2609,32 @@ static uint8_t ticker_job_reschedule_in_window(struct ticker_instance *instance) */ ticks_start_offset += ticks_to_expire_offset; window_start_ticks = ticks_start_offset + - ticker_next->ticks_slot; + ticker_next->ticks_slot + + HAL_TICKER_RESCHEDULE_MARGIN; ticks_to_expire_offset = 0U; - if (!ticker_resched->ticks_slot) { - /* Try at the end of the next node */ - ticks_to_expire = window_start_ticks; + if (!ticker_resched->ticks_slot || + ext_data->is_drift_in_window) { + if (!ticker_resched->ticks_slot || + (window_start_ticks <= (ticks_slot_window - + ticks_slot))) { + /* Try at the end of the next node */ + ticks_to_expire = window_start_ticks; + } + } else if (IS_ENABLED(CONFIG_BT_TICKER_EXT_SLOT_WINDOW_YIELD) && + (ticker_resched->ticks_periodic < + ticker_next->ticks_periodic)) { + uint32_t ticks_slot_with_margin = ticker_resched->ticks_slot + + HAL_TICKER_RESCHEDULE_MARGIN; + + /* Try to place it before the overlap and be + * rescheduled to its next periodic interval + * for collision resolution. + */ + if (ticks_start_offset > ticks_slot_with_margin) { + ticks_to_expire = ticks_start_offset - + ticks_slot_with_margin; + } } else { /* Try at the end of the slot window. This * ensures that ticker with slot window and that diff --git a/subsys/bluetooth/controller/ticker/ticker.h b/subsys/bluetooth/controller/ticker/ticker.h index f75cd21b80ae6..aa666036ab01c 100644 --- a/subsys/bluetooth/controller/ticker/ticker.h +++ b/subsys/bluetooth/controller/ticker/ticker.h @@ -229,15 +229,24 @@ uint8_t ticker_priority_set(uint8_t instance_index, uint8_t user_id, #if defined(CONFIG_BT_TICKER_EXT) struct ticker_ext { #if !defined(CONFIG_BT_TICKER_SLOT_AGNOSTIC) - uint32_t ticks_slot_window;/* Window in which the slot - * reservation may be re-scheduled - * to avoid collision - */ - uint32_t ticks_drift; /* Actual drift since last expiry */ - uint8_t reschedule_state; /* State of re-scheduling of the - * node. See defines - * TICKER_RESCHEDULE_STATE_XXX - */ + uint32_t ticks_slot_window; /* Window in which the slot + * reservation may be re-scheduled + * to avoid collision + */ + uint32_t ticks_drift; /* Actual drift since last expiry, + * includes any ticker update interface + * made changes plus drift due to + * reschedule when not + * is_jitter_in_window, otherwise is only + * the value of drift due to reschedule + */ + uint8_t reschedule_state:3; /* State of re-scheduling of the + * node. See defines + * TICKER_RESCHEDULE_STATE_XXX + */ + uint8_t is_drift_in_window:1; /* Drift in slot window, to be placed + * after an overlapping ticker + */ #endif /* CONFIG_BT_TICKER_SLOT_AGNOSTIC */ #if defined(CONFIG_BT_TICKER_EXT_EXPIRE_INFO) diff --git a/tests/bsim/bluetooth/host/adv/periodic/src/common.h b/tests/bsim/bluetooth/host/adv/periodic/src/common.h index b5bc9583ebd5d..02a8fea70e810 100644 --- a/tests/bsim/bluetooth/host/adv/periodic/src/common.h +++ b/tests/bsim/bluetooth/host/adv/periodic/src/common.h @@ -27,7 +27,7 @@ #include #include -#define WAIT_SECONDS 30 /* seconds */ +#define WAIT_SECONDS 15 /* seconds */ #define WAIT_TIME (WAIT_SECONDS * USEC_PER_SEC) /* microseconds*/ #define CREATE_FLAG(flag) static atomic_t flag = (atomic_t)false diff --git a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn_privacy.sh b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn_privacy.sh index 1fe7b38d61ca7..c3c4316ef5a68 100755 --- a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn_privacy.sh +++ b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn_privacy.sh @@ -9,6 +9,7 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source simulation_id="per_adv_conn_privacy" verbosity_level=2 +EXECUTE_TIMEOUT=60 cd ${BSIM_OUT_PATH}/bin diff --git a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_long_data.sh b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_long_data.sh index b660ba2598fb6..732e8aa13dd89 100755 --- a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_long_data.sh +++ b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_long_data.sh @@ -9,6 +9,7 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source simulation_id="per_adv_long_data" verbosity_level=2 +EXECUTE_TIMEOUT=60 cd ${BSIM_OUT_PATH}/bin