Commit 8373f19b authored by Troels Nilsson's avatar Troels Nilsson Committed by Carles Cufi
Browse files

Bluetooth: Controller: Add tests covering ticker without remainder support

Update Kconfig to not select BT_TICKER_REMAINDER_SUPPORT for nrf54L

Add BSim tests to cover using a ticker without BT_TICKER_REMAINDER_SUPPORT
and expire info enabled

Signed-off-by: default avatarTroels Nilsson <trnn@demant.com>
parent df67f4ec
Loading
Loading
Loading
Loading
+5 −4
Changes for subsys/bluetooth/controller/Kconfig.ll_sw_split: 5 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -61,12 +61,13 @@ config BT_LLL_VENDOR_NORDIC
	select BT_CTLR_TIFS_HW_SUPPORT
	select BT_CTLR_ULL_LLL_PRIO_SUPPORT

	select BT_TICKER_REMAINDER_SUPPORT
	select BT_TICKER_REMAINDER_SUPPORT if !SOC_COMPATIBLE_NRF54LX
	select BT_TICKER_UPDATE if BT_BROADCASTER || BT_CONN || \
				   (BT_OBSERVER && BT_CTLR_ADV_EXT)
	select BT_TICKER_START_REMAINDER if BT_CTLR_CENTRAL_ISO
	select BT_TICKER_REMAINDER_GET if BT_BROADCASTER && BT_CTLR_ADV_EXT
	select BT_TICKER_LAZY_GET if BT_CTLR_ADV_PERIODIC || BT_CTLR_CENTRAL_ISO || BT_CTLR_SYNC_TRANSFER_SENDER
	select BT_TICKER_START_REMAINDER if BT_TICKER_REMAINDER_SUPPORT && BT_CTLR_CENTRAL_ISO
	select BT_TICKER_REMAINDER_GET if BT_TICKER_REMAINDER_SUPPORT && \
					  (BT_BROADCASTER && BT_CTLR_ADV_EXT)
	select BT_TICKER_LAZY_GET if BT_CTLR_ADV_PERIODIC || BT_CTLR_CONN_ISO || BT_CTLR_SYNC_TRANSFER_SENDER

	select BT_TICKER_PREFER_START_BEFORE_STOP if BT_TICKER_SLOT_AGNOSTIC

+1 −0
Changes for tests/bsim/bluetooth/compile.nrf5340bsim_nrf5340_cpuapp.sh: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ app=tests/bsim/bluetooth/ll/conn conf_file=prj_split_privacy.conf sysbuild=1 co
app=tests/bsim/bluetooth/ll/throughput sysbuild=1 compile
app=tests/bsim/bluetooth/ll/multiple_id sysbuild=1 compile
app=tests/bsim/bluetooth/ll/bis sysbuild=1 compile
app=tests/bsim/bluetooth/ll/bis conf_overlay=overlay-ticker_expire_info.conf sysbuild=1 compile
app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-acl_group.conf sysbuild=1 compile

run_in_background ${ZEPHYR_BASE}/tests/bsim/bluetooth/samples/compile.sh
+2 −0
Changes for tests/bsim/bluetooth/compile.nrf54l15bsim_nrf54l15_cpuapp.sh: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ source ${ZEPHYR_BASE}/tests/bsim/compile.source

app=tests/bsim/bluetooth/ll/throughput compile
app=tests/bsim/bluetooth/ll/multiple_id compile
app=tests/bsim/bluetooth/ll/bis compile
app=tests/bsim/bluetooth/ll/bis conf_overlay=overlay-ticker_expire_info.conf compile

run_in_background ${ZEPHYR_BASE}/tests/bsim/bluetooth/samples/compile.sh
run_in_background ${ZEPHYR_BASE}/tests/bsim/bluetooth/audio/compile.sh
+32 −2
Changes for tests/bsim/bluetooth/ll/bis/src/test_bis.c: 32 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -149,7 +149,14 @@ bool ll_data_path_sink_create(uint16_t handle, struct ll_iso_datapath *datapath,
}
#endif /* CONFIG_BT_CTLR_ISO_VENDOR_DATA_PATH */

#define BUF_ALLOC_TIMEOUT_MS (30) /* milliseconds */
/* Have timeout unit sufficient to wait for all enqueued SDU to be transmitted.
 * We retry allocation by yielding out of the system work queue to mitigate
 * deadlock.
 */
#define BUF_ALLOC_TIMEOUT_MS       (10)   /* milliseconds */
#define BUF_ALLOC_RETRY_TIMEOUT_US (1000) /* microseconds */
#define BUF_ALLOC_RETRY_COUNT      (10U)

NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ISO_TX_BUF_COUNT,
			  BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU),
			  CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL);
@@ -162,6 +169,7 @@ static void iso_send(struct k_work *work)
{
	static uint8_t iso_data[CONFIG_BT_ISO_TX_MTU];
	static bool data_initialized;
	static uint8_t retry_yield_wq;
	struct net_buf *buf;
	size_t iso_data_len;
	int ret;
@@ -176,10 +184,22 @@ static void iso_send(struct k_work *work)

	buf = net_buf_alloc(&tx_pool, K_MSEC(BUF_ALLOC_TIMEOUT_MS));
	if (!buf) {
		/* Blocking in system work qeueue causes deadlock, hence yield
		 * and try getting the buffer again.
		 */
		if (retry_yield_wq) {
			retry_yield_wq--;

			k_work_schedule(&iso_send_work, K_USEC(BUF_ALLOC_RETRY_TIMEOUT_US));
		} else {
			FAIL("Data buffer allocate timeout on channel\n");
		}

		return;
	}

	retry_yield_wq = BUF_ALLOC_RETRY_COUNT;

	net_buf_reserve(buf, BT_ISO_CHAN_SEND_RESERVE);
	sys_put_le16(seq_num, iso_data);
	iso_data_len = MAX(sizeof(seq_num), ((seq_num % CONFIG_BT_ISO_TX_MTU) + 1));
@@ -193,7 +213,17 @@ static void iso_send(struct k_work *work)
		return;
	}

	k_work_schedule(&iso_send_work, K_USEC(9970));
	/* Ideally we can wait 10 ms to enqueue next SDU, but to mitigate clock
	 * drift between OS clock and Bluetooth Sleep Clock, lets send/enqueue
	 * early towards the Controller so that the SDU is not considered stale
	 * by the Controller.
	 *
	 * As we use `net_buf_alloc()` which will indirectly wait for Number of
	 * Completed Packet event processing in the Host leading to availability
	 * of next buffer, sending early will eventually get sync-ed with the
	 * interval at which the Controller is sending the SDU on-air.
	 */
	k_work_schedule(&iso_send_work, K_USEC(9900));
}
#endif /* !CONFIG_TEST_LL_INTERFACE */

+1 −0
Changes for tests/bsim/bluetooth/tests.nrf5340bsim_nrf5340_cpuapp.txt: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_encrypted_split_privacy.sh
tests/bsim/bluetooth/ll/throughput/
tests/bsim/bluetooth/ll/multiple_id/
tests/bsim/bluetooth/ll/bis/tests_scripts/broadcast_iso.sh
tests/bsim/bluetooth/ll/bis/tests_scripts/broadcast_iso_ticker_expire_info.sh
tests/bsim/bluetooth/samples/central_hr_peripheral_hr/
tests/bsim/bluetooth/audio_samples/
tests/bsim/bluetooth/audio/
Loading