Skip to content

Commit 291cd03

Browse files
cvinayakcarlescufi
authored andcommitted
tests: bsim: Bluetooth: Test RTN=2, FT=2, Cen skip 2 SE in Controller
Test RTN=2, FT=2 in Controller with 2 subevents dropped by central. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent a7d2fdd commit 291cd03

File tree

6 files changed

+163
-7
lines changed

6 files changed

+163
-7
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,14 @@ static void isr_rx(void *param)
674674
cis_lll = param;
675675

676676
/* No Rx */
677-
if (!trx_done) {
677+
if (!trx_done ||
678+
#if defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
679+
((((cis_lll->event_count % 3U) < CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT) &&
680+
((se_curr > cis_lll->nse) || (se_curr <= 2U))) ||
681+
(((cis_lll->event_count % 3U) < (CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT + 1U)) &&
682+
((se_curr > cis_lll->nse) || (se_curr <= 1U)))) ||
683+
#endif
684+
false) {
678685
payload_count_flush(cis_lll);
679686

680687
goto isr_rx_next_subevent;

tests/bsim/bluetooth/ll/cis/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ config TEST_FT_PER_SKIP_EVENTS_COUNT
3535
help
3636
Skip peripheral ISO events count where all subevents are skipped.
3737

38+
config TEST_FT_CEN_SKIP_SUBEVENTS
39+
bool "Skip central role subevents to test Flush Timeout"
40+
select TEST_FT_SKIP_SUBEVENTS
41+
help
42+
Skip central role subevent reception to test flush timeout
43+
implementation.
44+
45+
config TEST_FT_CEN_SKIP_EVENTS_COUNT
46+
int "Skip central ISO events count, all subevents in them"
47+
depends on TEST_FT_CEN_SKIP_SUBEVENTS
48+
help
49+
Skip central ISO events count where all subevents are skipped.
50+
3851
config BT_CTLR_SCAN_UNRESERVED
3952
default y if TEST_CONNECT_ACL_FIRST
4053
help
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CONFIG_TEST_USE_LEGACY_ADVERTISING=n
2+
CONFIG_TEST_CONNECT_ACL_FIRST=y
3+
CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS=y
4+
CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT=1
5+
CONFIG_BT_MAX_CONN=1
6+
CONFIG_BT_ISO_MAX_CHAN=1
7+
CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM=9
8+
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
9+
CONFIG_BT_CTLR_ISOAL_PSN_IGNORE=y

tests/bsim/bluetooth/ll/cis/src/main.c

Lines changed: 108 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,19 @@ static void iso_recv(struct bt_iso_chan *chan, const struct bt_iso_recv_info *in
296296
seq_num = sys_get_le32(buf->data);
297297
if (info->flags & BT_ISO_FLAGS_VALID) {
298298
if (seq_num != expected_seq_num[index]) {
299-
FAIL("ISO data miss match, expected %u actual %u\n",
300-
expected_seq_num[index], seq_num);
299+
if (expected_seq_num[index]) {
300+
FAIL("ISO data miss match, expected %u actual %u\n",
301+
expected_seq_num[index], seq_num);
302+
}
301303
expected_seq_num[index] = seq_num;
302304
}
303305

304306
expected_seq_num[index] += 1U;
305307

306-
#if defined(CONFIG_TEST_FT_SKIP_SUBEVENTS)
308+
#if defined(CONFIG_TEST_FT_PER_SKIP_SUBEVENTS)
307309
expected_seq_num[index] += ((CONFIG_TEST_FT_PER_SKIP_EVENTS_COUNT - 1U) * 2U);
310+
#elif defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
311+
expected_seq_num[index] += ((CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT - 1U) * 2U);
308312
#endif
309313
} else if (expected_seq_num[index] &&
310314
expected_seq_num[index] < SEQ_NUM_MAX) {
@@ -342,6 +346,7 @@ static struct bt_iso_chan_ops iso_ops = {
342346
static void test_cis_central(void)
343347
{
344348
struct bt_iso_chan_io_qos iso_tx[CONFIG_BT_ISO_MAX_CHAN];
349+
struct bt_iso_chan_io_qos iso_rx[CONFIG_BT_ISO_MAX_CHAN];
345350
struct bt_iso_chan_qos iso_qos[CONFIG_BT_ISO_MAX_CHAN];
346351
struct bt_iso_chan *channels[CONFIG_BT_ISO_MAX_CHAN];
347352
struct bt_conn *conn_list[CONFIG_BT_MAX_CONN];
@@ -372,8 +377,27 @@ static void test_cis_central(void)
372377
}
373378
iso_tx[i].path = NULL;
374379

375-
iso_qos[i].tx = &iso_tx[i];
376-
iso_qos[i].rx = NULL;
380+
if (!IS_ENABLED(CONFIG_TEST_FT_SKIP_SUBEVENTS) ||
381+
IS_ENABLED(CONFIG_TEST_FT_PER_SKIP_SUBEVENTS)) {
382+
iso_qos[i].tx = &iso_tx[i];
383+
} else {
384+
iso_qos[i].tx = NULL;
385+
}
386+
387+
iso_rx[i].sdu = CONFIG_BT_ISO_RX_MTU;
388+
iso_rx[i].phy = BT_GAP_LE_PHY_2M;
389+
if (IS_ENABLED(CONFIG_TEST_FT_SKIP_SUBEVENTS)) {
390+
iso_rx[i].rtn = 2U;
391+
} else {
392+
iso_rx[i].rtn = 0U;
393+
}
394+
iso_rx[i].path = NULL;
395+
396+
if (IS_ENABLED(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)) {
397+
iso_qos[i].rx = &iso_rx[i];
398+
} else {
399+
iso_qos[i].rx = NULL;
400+
}
377401

378402
iso_chan[i].ops = &iso_ops;
379403
iso_chan[i].qos = &iso_qos[i];
@@ -406,6 +430,12 @@ static void test_cis_central(void)
406430

407431
conn_count = 0U;
408432

433+
#if defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
434+
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
435+
expected_seq_num[chan] = (CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT - 1U) * 2U;
436+
}
437+
#endif
438+
409439
#if !defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
410440
for (int i = 0; i < CONFIG_BT_MAX_CONN; i++) {
411441
#else
@@ -493,6 +523,7 @@ static void test_cis_central(void)
493523
printk("connected to peer %d ISO channel.\n", chan);
494524
}
495525

526+
#if !defined(CONFIG_TEST_FT_SKIP_SUBEVENTS) || defined(CONFIG_TEST_FT_PER_SKIP_SUBEVENTS)
496527
for (uint16_t seq_num = 0U; seq_num < SEQ_NUM_MAX; seq_num++) {
497528

498529
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
@@ -535,6 +566,9 @@ static void test_cis_central(void)
535566
}
536567

537568
k_sleep(K_MSEC(1000));
569+
#else
570+
k_sleep(K_SECONDS(11));
571+
#endif
538572

539573
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
540574
printk("ISO disconnect channel %u...", chan);
@@ -573,6 +607,16 @@ static void test_cis_central(void)
573607
}
574608
#endif
575609

610+
#if defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
611+
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
612+
if (expected_seq_num[chan] < SEQ_NUM_MAX) {
613+
FAIL("ISO Data reception incomplete %u (%u).\n",
614+
expected_seq_num[chan], SEQ_NUM_MAX);
615+
return;
616+
}
617+
}
618+
#endif
619+
576620
PASS("Central ISO tests Passed\n");
577621
}
578622

@@ -613,6 +657,7 @@ static struct bt_iso_server iso_server = {
613657

614658
static void test_cis_peripheral(void)
615659
{
660+
struct bt_iso_chan_io_qos iso_tx_p[CONFIG_BT_ISO_MAX_CHAN];
616661
int err;
617662

618663
printk("Bluetooth initializing...");
@@ -624,7 +669,18 @@ static void test_cis_peripheral(void)
624669
printk("success.\n");
625670

626671
for (int i = 0; i < CONFIG_BT_ISO_MAX_CHAN; i++) {
627-
iso_rx_p[i].sdu = CONFIG_BT_ISO_TX_MTU;
672+
iso_tx_p[i].sdu = CONFIG_BT_ISO_TX_MTU;
673+
iso_tx_p[i].phy = BT_GAP_LE_PHY_2M;
674+
if (IS_ENABLED(CONFIG_TEST_FT_SKIP_SUBEVENTS)) {
675+
iso_tx_p[i].rtn = 2U;
676+
} else {
677+
iso_tx_p[i].rtn = 0U;
678+
}
679+
iso_tx_p[i].path = NULL;
680+
681+
iso_qos_p[i].tx = &iso_tx_p[i];
682+
683+
iso_rx_p[i].sdu = CONFIG_BT_ISO_RX_MTU;
628684

629685
iso_qos_p[i].rx = &iso_rx_p[i];
630686

@@ -698,7 +754,51 @@ static void test_cis_peripheral(void)
698754

699755
#if defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
700756
}
757+
#endif
758+
759+
#if defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
760+
for (uint16_t seq_num = 0U; seq_num < SEQ_NUM_MAX; seq_num++) {
761+
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
762+
uint8_t iso_data[CONFIG_BT_ISO_TX_MTU] = { 0, };
763+
struct net_buf *buf;
764+
int ret;
701765

766+
buf = net_buf_alloc(&tx_pool,
767+
K_MSEC(BUF_ALLOC_TIMEOUT));
768+
if (!buf) {
769+
FAIL("Data buffer allocate timeout on channel"
770+
" %u\n", chan);
771+
return;
772+
}
773+
net_buf_reserve(buf, BT_ISO_CHAN_SEND_RESERVE);
774+
sys_put_le32(seq_num, iso_data);
775+
net_buf_add_mem(buf, iso_data, sizeof(iso_data));
776+
777+
ret = k_sem_take(&sem_iso_data,
778+
K_MSEC(BUF_ALLOC_TIMEOUT));
779+
if (ret) {
780+
FAIL("k_sem_take for ISO data sent failed.\n");
781+
return;
782+
}
783+
784+
printk("ISO send: seq_num %u, chan %u\n", seq_num, chan);
785+
ret = bt_iso_chan_send(&iso_chan_p[chan], buf,
786+
seq_num, BT_ISO_TIMESTAMP_NONE);
787+
if (ret < 0) {
788+
FAIL("Unable to send data on channel %u"
789+
" : %d\n", chan, ret);
790+
net_buf_unref(buf);
791+
return;
792+
}
793+
}
794+
795+
if ((seq_num % 100) == 0) {
796+
printk("Sending value %u\n", seq_num);
797+
}
798+
}
799+
#endif
800+
801+
#if defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
702802
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
703803
#endif
704804

@@ -722,6 +822,7 @@ static void test_cis_peripheral(void)
722822
}
723823
printk("disconnected from peer device.\n");
724824

825+
#if !defined(CONFIG_TEST_FT_SKIP_SUBEVENTS) || defined(CONFIG_TEST_FT_PER_SKIP_SUBEVENTS)
725826
#if defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
726827
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
727828
#else
@@ -734,6 +835,7 @@ static void test_cis_peripheral(void)
734835
}
735836
#if defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
736837
}
838+
#endif
737839
#endif
738840

739841
PASS("Peripheral ISO tests Passed\n");
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2020 Nordic Semiconductor ASA
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
6+
7+
# Basic Connected ISO test: a Central connects to 1 Peripheral and tests RTN=2,
8+
# FT=2, skips 2 subevents in the central
9+
simulation_id="connected_iso_acl_first_ft_cen_skip_2_se"
10+
verbosity_level=2
11+
EXECUTE_TIMEOUT=60
12+
13+
cd ${BSIM_OUT_PATH}/bin
14+
15+
Execute ./bs_${BOARD}_tests_bsim_bluetooth_ll_cis_prj_conf_overlay-acl_first_ft_cen_skip_2_se_conf \
16+
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central
17+
18+
Execute ./bs_${BOARD}_tests_bsim_bluetooth_ll_cis_prj_conf_overlay-acl_first_ft_cen_skip_2_se_conf \
19+
-v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral
20+
21+
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
22+
-D=2 -sim_length=30e6 $@
23+
24+
wait_for_background_jobs

tests/bsim/bluetooth/ll/compile.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-acl_group_acl_first.conf co
4141
app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-peripheral_cis.conf compile
4242
app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-acl_first_ft_per_skip_2_se.conf compile
4343
app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-acl_first_ft_per_skip_4_se.conf compile
44+
app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-acl_first_ft_cen_skip_2_se.conf compile
4445

4546
app=tests/bsim/bluetooth/ll/edtt/hci_test_app \
4647
conf_file=prj_dut_llcp.conf compile

0 commit comments

Comments
 (0)