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 <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2023-08-04 14:04:35 +05:30 committed by Carles Cufí
commit 291cd03818
6 changed files with 163 additions and 7 deletions

View file

@ -674,7 +674,14 @@ static void isr_rx(void *param)
cis_lll = param;
/* No Rx */
if (!trx_done) {
if (!trx_done ||
#if defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
((((cis_lll->event_count % 3U) < CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT) &&
((se_curr > cis_lll->nse) || (se_curr <= 2U))) ||
(((cis_lll->event_count % 3U) < (CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT + 1U)) &&
((se_curr > cis_lll->nse) || (se_curr <= 1U)))) ||
#endif
false) {
payload_count_flush(cis_lll);
goto isr_rx_next_subevent;

View file

@ -35,6 +35,19 @@ config TEST_FT_PER_SKIP_EVENTS_COUNT
help
Skip peripheral ISO events count where all subevents are skipped.
config TEST_FT_CEN_SKIP_SUBEVENTS
bool "Skip central role subevents to test Flush Timeout"
select TEST_FT_SKIP_SUBEVENTS
help
Skip central role subevent reception to test flush timeout
implementation.
config TEST_FT_CEN_SKIP_EVENTS_COUNT
int "Skip central ISO events count, all subevents in them"
depends on TEST_FT_CEN_SKIP_SUBEVENTS
help
Skip central ISO events count where all subevents are skipped.
config BT_CTLR_SCAN_UNRESERVED
default y if TEST_CONNECT_ACL_FIRST
help

View file

@ -0,0 +1,9 @@
CONFIG_TEST_USE_LEGACY_ADVERTISING=n
CONFIG_TEST_CONNECT_ACL_FIRST=y
CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS=y
CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT=1
CONFIG_BT_MAX_CONN=1
CONFIG_BT_ISO_MAX_CHAN=1
CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM=9
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_ISOAL_PSN_IGNORE=y

View file

@ -296,15 +296,19 @@ static void iso_recv(struct bt_iso_chan *chan, const struct bt_iso_recv_info *in
seq_num = sys_get_le32(buf->data);
if (info->flags & BT_ISO_FLAGS_VALID) {
if (seq_num != expected_seq_num[index]) {
FAIL("ISO data miss match, expected %u actual %u\n",
expected_seq_num[index], seq_num);
if (expected_seq_num[index]) {
FAIL("ISO data miss match, expected %u actual %u\n",
expected_seq_num[index], seq_num);
}
expected_seq_num[index] = seq_num;
}
expected_seq_num[index] += 1U;
#if defined(CONFIG_TEST_FT_SKIP_SUBEVENTS)
#if defined(CONFIG_TEST_FT_PER_SKIP_SUBEVENTS)
expected_seq_num[index] += ((CONFIG_TEST_FT_PER_SKIP_EVENTS_COUNT - 1U) * 2U);
#elif defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
expected_seq_num[index] += ((CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT - 1U) * 2U);
#endif
} else if (expected_seq_num[index] &&
expected_seq_num[index] < SEQ_NUM_MAX) {
@ -342,6 +346,7 @@ static struct bt_iso_chan_ops iso_ops = {
static void test_cis_central(void)
{
struct bt_iso_chan_io_qos iso_tx[CONFIG_BT_ISO_MAX_CHAN];
struct bt_iso_chan_io_qos iso_rx[CONFIG_BT_ISO_MAX_CHAN];
struct bt_iso_chan_qos iso_qos[CONFIG_BT_ISO_MAX_CHAN];
struct bt_iso_chan *channels[CONFIG_BT_ISO_MAX_CHAN];
struct bt_conn *conn_list[CONFIG_BT_MAX_CONN];
@ -372,8 +377,27 @@ static void test_cis_central(void)
}
iso_tx[i].path = NULL;
iso_qos[i].tx = &iso_tx[i];
iso_qos[i].rx = NULL;
if (!IS_ENABLED(CONFIG_TEST_FT_SKIP_SUBEVENTS) ||
IS_ENABLED(CONFIG_TEST_FT_PER_SKIP_SUBEVENTS)) {
iso_qos[i].tx = &iso_tx[i];
} else {
iso_qos[i].tx = NULL;
}
iso_rx[i].sdu = CONFIG_BT_ISO_RX_MTU;
iso_rx[i].phy = BT_GAP_LE_PHY_2M;
if (IS_ENABLED(CONFIG_TEST_FT_SKIP_SUBEVENTS)) {
iso_rx[i].rtn = 2U;
} else {
iso_rx[i].rtn = 0U;
}
iso_rx[i].path = NULL;
if (IS_ENABLED(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)) {
iso_qos[i].rx = &iso_rx[i];
} else {
iso_qos[i].rx = NULL;
}
iso_chan[i].ops = &iso_ops;
iso_chan[i].qos = &iso_qos[i];
@ -406,6 +430,12 @@ static void test_cis_central(void)
conn_count = 0U;
#if defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
expected_seq_num[chan] = (CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT - 1U) * 2U;
}
#endif
#if !defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
for (int i = 0; i < CONFIG_BT_MAX_CONN; i++) {
#else
@ -493,6 +523,7 @@ static void test_cis_central(void)
printk("connected to peer %d ISO channel.\n", chan);
}
#if !defined(CONFIG_TEST_FT_SKIP_SUBEVENTS) || defined(CONFIG_TEST_FT_PER_SKIP_SUBEVENTS)
for (uint16_t seq_num = 0U; seq_num < SEQ_NUM_MAX; seq_num++) {
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
@ -535,6 +566,9 @@ static void test_cis_central(void)
}
k_sleep(K_MSEC(1000));
#else
k_sleep(K_SECONDS(11));
#endif
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
printk("ISO disconnect channel %u...", chan);
@ -573,6 +607,16 @@ static void test_cis_central(void)
}
#endif
#if defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
if (expected_seq_num[chan] < SEQ_NUM_MAX) {
FAIL("ISO Data reception incomplete %u (%u).\n",
expected_seq_num[chan], SEQ_NUM_MAX);
return;
}
}
#endif
PASS("Central ISO tests Passed\n");
}
@ -613,6 +657,7 @@ static struct bt_iso_server iso_server = {
static void test_cis_peripheral(void)
{
struct bt_iso_chan_io_qos iso_tx_p[CONFIG_BT_ISO_MAX_CHAN];
int err;
printk("Bluetooth initializing...");
@ -624,7 +669,18 @@ static void test_cis_peripheral(void)
printk("success.\n");
for (int i = 0; i < CONFIG_BT_ISO_MAX_CHAN; i++) {
iso_rx_p[i].sdu = CONFIG_BT_ISO_TX_MTU;
iso_tx_p[i].sdu = CONFIG_BT_ISO_TX_MTU;
iso_tx_p[i].phy = BT_GAP_LE_PHY_2M;
if (IS_ENABLED(CONFIG_TEST_FT_SKIP_SUBEVENTS)) {
iso_tx_p[i].rtn = 2U;
} else {
iso_tx_p[i].rtn = 0U;
}
iso_tx_p[i].path = NULL;
iso_qos_p[i].tx = &iso_tx_p[i];
iso_rx_p[i].sdu = CONFIG_BT_ISO_RX_MTU;
iso_qos_p[i].rx = &iso_rx_p[i];
@ -698,7 +754,51 @@ static void test_cis_peripheral(void)
#if defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
}
#endif
#if defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
for (uint16_t seq_num = 0U; seq_num < SEQ_NUM_MAX; seq_num++) {
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
uint8_t iso_data[CONFIG_BT_ISO_TX_MTU] = { 0, };
struct net_buf *buf;
int ret;
buf = net_buf_alloc(&tx_pool,
K_MSEC(BUF_ALLOC_TIMEOUT));
if (!buf) {
FAIL("Data buffer allocate timeout on channel"
" %u\n", chan);
return;
}
net_buf_reserve(buf, BT_ISO_CHAN_SEND_RESERVE);
sys_put_le32(seq_num, iso_data);
net_buf_add_mem(buf, iso_data, sizeof(iso_data));
ret = k_sem_take(&sem_iso_data,
K_MSEC(BUF_ALLOC_TIMEOUT));
if (ret) {
FAIL("k_sem_take for ISO data sent failed.\n");
return;
}
printk("ISO send: seq_num %u, chan %u\n", seq_num, chan);
ret = bt_iso_chan_send(&iso_chan_p[chan], buf,
seq_num, BT_ISO_TIMESTAMP_NONE);
if (ret < 0) {
FAIL("Unable to send data on channel %u"
" : %d\n", chan, ret);
net_buf_unref(buf);
return;
}
}
if ((seq_num % 100) == 0) {
printk("Sending value %u\n", seq_num);
}
}
#endif
#if defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
#endif
@ -722,6 +822,7 @@ static void test_cis_peripheral(void)
}
printk("disconnected from peer device.\n");
#if !defined(CONFIG_TEST_FT_SKIP_SUBEVENTS) || defined(CONFIG_TEST_FT_PER_SKIP_SUBEVENTS)
#if defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
#else
@ -734,6 +835,7 @@ static void test_cis_peripheral(void)
}
#if defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
}
#endif
#endif
PASS("Peripheral ISO tests Passed\n");

View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Copyright 2020 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
# Basic Connected ISO test: a Central connects to 1 Peripheral and tests RTN=2,
# FT=2, skips 2 subevents in the central
simulation_id="connected_iso_acl_first_ft_cen_skip_2_se"
verbosity_level=2
EXECUTE_TIMEOUT=60
cd ${BSIM_OUT_PATH}/bin
Execute ./bs_${BOARD}_tests_bsim_bluetooth_ll_cis_prj_conf_overlay-acl_first_ft_cen_skip_2_se_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central
Execute ./bs_${BOARD}_tests_bsim_bluetooth_ll_cis_prj_conf_overlay-acl_first_ft_cen_skip_2_se_conf \
-v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=30e6 $@
wait_for_background_jobs

View file

@ -41,6 +41,7 @@ app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-acl_group_acl_first.conf co
app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-peripheral_cis.conf compile
app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-acl_first_ft_per_skip_2_se.conf compile
app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-acl_first_ft_per_skip_4_se.conf compile
app=tests/bsim/bluetooth/ll/cis conf_overlay=overlay-acl_first_ft_cen_skip_2_se.conf compile
app=tests/bsim/bluetooth/ll/edtt/hci_test_app \
conf_file=prj_dut_llcp.conf compile