Bluetooth: Controller: Review rework flush timeout support
Review rework changed related to flush timeout support. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
27c92fe238
commit
a178aa9855
9 changed files with 178 additions and 125 deletions
|
@ -5762,6 +5762,18 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
|
|||
/* Catch up local pkt_seq_num with internal pkt_seq_num */
|
||||
event_count = cis->lll.event_count;
|
||||
pkt_seq_num = event_count + 1U;
|
||||
/* If pb_flag is BT_ISO_START (0b00) or BT_ISO_SINGLE (0b10)
|
||||
* then we simply check that the pb_flag is an even value, and
|
||||
* then pkt_seq_num is a future sequence number value compare
|
||||
* to last recorded number in cis->pkt_seq_num.
|
||||
*
|
||||
* When (pkt_seq_num - stream->pkt_seq_num) is negative then
|
||||
* BIT64(39) will be set (2's compliment value). The diff value
|
||||
* less than or equal to BIT64_MASK(38) means the diff value is
|
||||
* positive and hence pkt_seq_num is greater than
|
||||
* stream->pkt_seq_num. This calculation is valid for when value
|
||||
* rollover too.
|
||||
*/
|
||||
if (!(pb_flag & 0x01) &&
|
||||
(((pkt_seq_num - cis->pkt_seq_num) &
|
||||
BIT64_MASK(39)) <= BIT64_MASK(38))) {
|
||||
|
@ -5770,12 +5782,17 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
|
|||
pkt_seq_num = cis->pkt_seq_num;
|
||||
}
|
||||
|
||||
/* Pre-increment, for next ISO data packet seq num comparison */
|
||||
/* Pre-increment, when pg_flag is BT_ISO_SINGLE (0b10) or
|
||||
* BT_ISO_END (0b11) then we simple check if pb_flag has bit 1
|
||||
* is set, for next ISO data packet seq num comparison.
|
||||
*/
|
||||
if (pb_flag & 0x10) {
|
||||
cis->pkt_seq_num++;
|
||||
}
|
||||
|
||||
/* Target next event to avoid overlapping with current event */
|
||||
/* Target next ISO event to avoid overlapping with, if any,
|
||||
* current ISO event
|
||||
*/
|
||||
pkt_seq_num++;
|
||||
sdu_frag_tx.target_event = pkt_seq_num;
|
||||
sdu_frag_tx.grp_ref_point =
|
||||
|
@ -5817,7 +5834,7 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
|
|||
#endif /* !CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
|
||||
|
||||
/* Get controller's input data path for CIS */
|
||||
hdr = &(cis->hdr);
|
||||
hdr = &cis->hdr;
|
||||
dp_in = hdr->datapath_in;
|
||||
if (!dp_in || dp_in->path_id != BT_HCI_DATAPATH_ID_HCI) {
|
||||
LOG_ERR("Input data path not set for HCI");
|
||||
|
@ -5884,6 +5901,18 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
|
|||
/* Catch up local pkt_seq_num with internal pkt_seq_num */
|
||||
event_count = lll_iso->payload_count / lll_iso->bn;
|
||||
pkt_seq_num = event_count;
|
||||
/* If pb_flag is BT_ISO_START (0b00) or BT_ISO_SINGLE (0b10)
|
||||
* then we simply check that the pb_flag is an even value, and
|
||||
* then pkt_seq_num is a future sequence number value compare
|
||||
* to last recorded number in cis->pkt_seq_num.
|
||||
*
|
||||
* When (pkt_seq_num - stream->pkt_seq_num) is negative then
|
||||
* BIT64(39) will be set (2's compliment value). The diff value
|
||||
* less than or equal to BIT64_MASK(38) means the diff value is
|
||||
* positive and hence pkt_seq_num is greater than
|
||||
* stream->pkt_seq_num. This calculation is valid for when value
|
||||
* rollover too.
|
||||
*/
|
||||
if (!(pb_flag & 0x01) &&
|
||||
(((pkt_seq_num - stream->pkt_seq_num) &
|
||||
BIT64_MASK(39)) <= BIT64_MASK(38))) {
|
||||
|
@ -5892,12 +5921,17 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
|
|||
pkt_seq_num = stream->pkt_seq_num;
|
||||
}
|
||||
|
||||
/* Pre-increment, for next ISO data packet seq num comparison */
|
||||
/* Pre-increment, when pg_flag is BT_ISO_SINGLE (0b10) or
|
||||
* BT_ISO_END (0b11) then we simple check if pb_flag has bit 1
|
||||
* is set, for next ISO data packet seq num comparison.
|
||||
*/
|
||||
if (pb_flag & 0x10) {
|
||||
stream->pkt_seq_num++;
|
||||
}
|
||||
|
||||
/* Target next event to avoid overlapping with current event */
|
||||
/* Target next ISO event to avoid overlapping with, if any,
|
||||
* current ISO event
|
||||
*/
|
||||
/* FIXME: Implement ISO Tx ack generation early in done compared
|
||||
* to currently only in prepare. I.e. to ensure upper
|
||||
* layer has the number of completed packet before the
|
||||
|
|
|
@ -15,8 +15,10 @@ struct lll_conn_iso_stream_rxtx {
|
|||
uint64_t ft:8; /* Flush timeout (FT) */
|
||||
uint64_t bn:4; /* Burst number (BN) */
|
||||
uint64_t phy:3; /* PHY */
|
||||
uint64_t rfu:1;
|
||||
uint8_t bn_curr:4; /* Current burst number */
|
||||
uint64_t rfu0:1;
|
||||
|
||||
uint8_t bn_curr:4; /* Current burst number */
|
||||
uint8_t rfu1:4;
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_LE_ENC)
|
||||
struct ccm ccm;
|
||||
|
@ -73,20 +75,26 @@ struct lll_conn_iso_group {
|
|||
struct lll_hdr hdr;
|
||||
|
||||
uint16_t handle; /* CIG handle (internal) */
|
||||
uint8_t num_cis:5; /* Number of CISes in this CIG */
|
||||
uint8_t role:1; /* 0: CENTRAL, 1: PERIPHERAL*/
|
||||
uint8_t paused:1; /* 1: CIG is paused */
|
||||
|
||||
/* ISO interval to calculate timestamp under FT > 1 */
|
||||
uint32_t iso_interval_us;
|
||||
/* Resumption information */
|
||||
uint16_t resume_cis; /* CIS handle to schedule at resume */
|
||||
|
||||
/* ISO group information */
|
||||
uint32_t num_cis:5; /* Number of CISes in this CIG */
|
||||
uint32_t role:1; /* 0: CENTRAL, 1: PERIPHERAL*/
|
||||
uint32_t paused:1; /* 1: CIG is paused */
|
||||
uint32_t rfu0:1;
|
||||
|
||||
/* ISO interval to calculate timestamp under FT > 1,
|
||||
* maximum ISO interval of 4 seconds can be represented in 22-bits.
|
||||
*/
|
||||
uint32_t iso_interval_us:22;
|
||||
uint32_t rfu1:2;
|
||||
|
||||
/* Accumulates LLL prepare callback latencies */
|
||||
uint16_t latency_prepare;
|
||||
uint16_t latency_event;
|
||||
|
||||
/* Resumption information */
|
||||
uint16_t resume_cis; /* CIS handle to schedule at resume */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PERIPHERAL_ISO)
|
||||
/* Window widening. Relies on vendor specific conversion macros, e.g.
|
||||
* EVENT_US_FRAC_TO_TICKS().
|
||||
|
|
|
@ -48,7 +48,7 @@ static void isr_prepare_subevent(void *param);
|
|||
static void isr_done(void *param);
|
||||
static void payload_count_flush(struct lll_conn_iso_stream *cis_lll);
|
||||
static void payload_count_flush_or_inc_on_close(struct lll_conn_iso_stream *cis_lll);
|
||||
static void payload_count_lazy(struct lll_conn_iso_stream *cis_lll, uint16_t lazy);
|
||||
static void payload_count_lazy_update(struct lll_conn_iso_stream *cis_lll, uint16_t lazy);
|
||||
|
||||
static uint16_t next_cis_chan_remap_idx;
|
||||
static uint16_t next_cis_chan_prn_s;
|
||||
|
@ -183,7 +183,7 @@ static int prepare_cb(struct lll_prepare_param *p)
|
|||
se_curr = 1U;
|
||||
|
||||
/* Adjust the SN and NESN for skipped CIG events */
|
||||
payload_count_lazy(cis_lll, lazy);
|
||||
payload_count_lazy_update(cis_lll, lazy);
|
||||
|
||||
/* Start setting up of Radio h/w */
|
||||
radio_reset();
|
||||
|
@ -370,7 +370,7 @@ static int prepare_cb(struct lll_prepare_param *p)
|
|||
cis_lll = ull_conn_iso_lll_stream_get_by_group(cig_lll, &cis_handle);
|
||||
if (cis_lll && cis_lll->active) {
|
||||
/* Adjust sn and nesn for skipped CIG events */
|
||||
payload_count_lazy(cis_lll, lazy);
|
||||
payload_count_lazy_update(cis_lll, lazy);
|
||||
|
||||
/* Adjust sn and nesn for canceled events */
|
||||
if (err) {
|
||||
|
@ -676,11 +676,20 @@ static void isr_rx(void *param)
|
|||
/* No Rx */
|
||||
if (!trx_done ||
|
||||
#if defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
|
||||
/* Used by test code,
|
||||
* to skip a number of events in every 3 event count when current subevent is less than
|
||||
* or equal to 2 or when current subevent has completed all its NSE number of subevents.
|
||||
* OR
|
||||
* to skip a (number + 1) of events in every 3 event count when current subevent is less
|
||||
* than or equal to 1 or when current subevent has completed all its NSE number of
|
||||
* 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
|
||||
#endif /* CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS */
|
||||
false) {
|
||||
payload_count_flush(cis_lll);
|
||||
|
||||
|
@ -1230,7 +1239,7 @@ payload_count_flush_or_inc_on_close_rx:
|
|||
}
|
||||
}
|
||||
|
||||
static void payload_count_lazy(struct lll_conn_iso_stream *cis_lll, uint16_t lazy)
|
||||
static void payload_count_lazy_update(struct lll_conn_iso_stream *cis_lll, uint16_t lazy)
|
||||
{
|
||||
if (cis_lll->tx.bn) {
|
||||
uint16_t tx_lazy;
|
||||
|
|
|
@ -474,6 +474,14 @@ static void isr_rx(void *param)
|
|||
/* No Rx */
|
||||
if (!trx_done ||
|
||||
#if defined(CONFIG_TEST_FT_PER_SKIP_SUBEVENTS)
|
||||
/* Used by test code,
|
||||
* to skip a number of events in every 3 event count when current subevent is less than
|
||||
* or equal to 2 or when current subevent has completed all its NSE number of subevents.
|
||||
* OR
|
||||
* to skip a (number + 1) of events in every 3 event count when current subevent is less
|
||||
* than or equal to 1 or when current subevent has completed all its NSE number of
|
||||
* subevents.
|
||||
*/
|
||||
((((cis_lll->event_count % 3U) < CONFIG_TEST_FT_PER_SKIP_EVENTS_COUNT) &&
|
||||
((se_curr > cis_lll->nse) || (se_curr <= 2U))) ||
|
||||
(((cis_lll->event_count % 3U) < (CONFIG_TEST_FT_PER_SKIP_EVENTS_COUNT + 1U)) &&
|
||||
|
|
|
@ -352,7 +352,7 @@ static void test_cis_central(void)
|
|||
struct bt_conn *conn_list[CONFIG_BT_MAX_CONN];
|
||||
struct bt_iso_cig_param cig_param;
|
||||
struct bt_iso_cig *cig;
|
||||
uint8_t conn_count;
|
||||
int conn_count;
|
||||
int err;
|
||||
|
||||
printk("Bluetooth initializing...");
|
||||
|
@ -370,12 +370,12 @@ static void test_cis_central(void)
|
|||
for (int i = 0; i < CONFIG_BT_ISO_MAX_CHAN; i++) {
|
||||
iso_tx[i].sdu = CONFIG_BT_ISO_TX_MTU;
|
||||
iso_tx[i].phy = BT_GAP_LE_PHY_2M;
|
||||
iso_tx[i].path = NULL;
|
||||
if (IS_ENABLED(CONFIG_TEST_FT_SKIP_SUBEVENTS)) {
|
||||
iso_tx[i].rtn = 2U;
|
||||
} else {
|
||||
iso_tx[i].rtn = 0U;
|
||||
}
|
||||
iso_tx[i].path = NULL;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_TEST_FT_SKIP_SUBEVENTS) ||
|
||||
IS_ENABLED(CONFIG_TEST_FT_PER_SKIP_SUBEVENTS)) {
|
||||
|
@ -386,12 +386,12 @@ static void test_cis_central(void)
|
|||
|
||||
iso_rx[i].sdu = CONFIG_BT_ISO_RX_MTU;
|
||||
iso_rx[i].phy = BT_GAP_LE_PHY_2M;
|
||||
iso_rx[i].path = NULL;
|
||||
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];
|
||||
|
@ -413,12 +413,12 @@ static void test_cis_central(void)
|
|||
cig_param.sca = BT_GAP_SCA_UNKNOWN;
|
||||
cig_param.packing = 0U;
|
||||
cig_param.framing = 0U;
|
||||
cig_param.interval = ISO_INTERVAL_US;
|
||||
if (IS_ENABLED(CONFIG_TEST_FT_SKIP_SUBEVENTS)) {
|
||||
cig_param.latency = ISO_LATENCY_FT_MS;
|
||||
} else {
|
||||
cig_param.latency = ISO_LATENCY_MS;
|
||||
}
|
||||
cig_param.interval = ISO_INTERVAL_US;
|
||||
|
||||
printk("Create CIG...");
|
||||
err = bt_iso_cig_create(&cig_param, &cig);
|
||||
|
@ -428,10 +428,10 @@ static void test_cis_central(void)
|
|||
}
|
||||
printk("success.\n");
|
||||
|
||||
conn_count = 0U;
|
||||
conn_count = 0;
|
||||
|
||||
#if defined(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)
|
||||
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
|
||||
for (int chan = 0; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
|
||||
expected_seq_num[chan] = (CONFIG_TEST_FT_CEN_SKIP_EVENTS_COUNT - 1U) * 2U;
|
||||
}
|
||||
#endif
|
||||
|
@ -443,8 +443,8 @@ static void test_cis_central(void)
|
|||
#endif
|
||||
|
||||
struct bt_conn *conn;
|
||||
uint8_t conn_index;
|
||||
uint8_t chan;
|
||||
int conn_index;
|
||||
int chan;
|
||||
|
||||
printk("Start scanning (%d)...", i);
|
||||
err = bt_le_scan_start(BT_LE_SCAN_CUSTOM, NULL);
|
||||
|
@ -494,12 +494,12 @@ static void test_cis_central(void)
|
|||
#if defined(CONFIG_TEST_CONNECT_ACL_FIRST)
|
||||
}
|
||||
|
||||
for (uint8_t chan = 0U, conn_index = 0U;
|
||||
for (int chan = 0, conn_index = 0;
|
||||
(conn_index < conn_count) && (chan < CONFIG_BT_ISO_MAX_CHAN);
|
||||
conn_index++, chan++) {
|
||||
|
||||
#elif defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
|
||||
for (uint8_t chan = 0U, conn_index = 0U;
|
||||
for (int chan = 0, conn_index = 0;
|
||||
(chan < CONFIG_BT_ISO_MAX_CHAN); chan++) {
|
||||
#endif
|
||||
|
||||
|
@ -523,70 +523,67 @@ 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++) {
|
||||
if (!IS_ENABLED(CONFIG_TEST_FT_SKIP_SUBEVENTS) ||
|
||||
IS_ENABLED(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++) {
|
||||
uint8_t iso_data[CONFIG_BT_ISO_TX_MTU] = { 0, };
|
||||
struct net_buf *buf;
|
||||
int ret;
|
||||
for (int chan = 0; 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));
|
||||
buf = net_buf_alloc(&tx_pool, K_MSEC(BUF_ALLOC_TIMEOUT));
|
||||
if (!buf) {
|
||||
FAIL("Data buffer allocate timeout on channel %d\n", chan);
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
net_buf_reserve(buf, BT_ISO_CHAN_SEND_RESERVE);
|
||||
sys_put_le16(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 %d\n", seq_num, chan);
|
||||
ret = bt_iso_chan_send(&iso_chan[chan], buf,
|
||||
seq_num, BT_ISO_TIMESTAMP_NONE);
|
||||
if (ret < 0) {
|
||||
FAIL("Unable to send data on channel %d : %d\n", chan, ret);
|
||||
net_buf_unref(buf);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
printk("ISO send: seq_num %u, chan %u\n", seq_num, chan);
|
||||
ret = bt_iso_chan_send(&iso_chan[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);
|
||||
}
|
||||
}
|
||||
|
||||
if ((seq_num % 100) == 0) {
|
||||
printk("Sending value %u\n", seq_num);
|
||||
}
|
||||
k_sleep(K_MSEC(1000));
|
||||
} else {
|
||||
k_sleep(K_SECONDS(11));
|
||||
}
|
||||
|
||||
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);
|
||||
for (int chan = 0; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
|
||||
printk("ISO disconnect channel %d...", chan);
|
||||
err = bt_iso_chan_disconnect(&iso_chan[chan]);
|
||||
if (err) {
|
||||
FAIL("Failed to disconnect channel %u (%d)\n",
|
||||
chan, err);
|
||||
FAIL("Failed to disconnect channel %d (%d)\n", chan, err);
|
||||
return;
|
||||
}
|
||||
printk("success\n");
|
||||
|
||||
printk("Waiting for ISO channel disconnect %u...", chan);
|
||||
printk("Waiting for ISO channel disconnect %d...", chan);
|
||||
err = k_sem_take(&sem_iso_disc, K_FOREVER);
|
||||
if (err) {
|
||||
FAIL("failed (err %d)\n", err);
|
||||
return;
|
||||
}
|
||||
printk("disconnected to peer %u ISO channel.\n", chan);
|
||||
printk("disconnected to peer %d ISO channel.\n", chan);
|
||||
}
|
||||
|
||||
bt_conn_foreach(BT_CONN_TYPE_LE, disconnect, NULL);
|
||||
|
@ -607,15 +604,15 @@ 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;
|
||||
if (IS_ENABLED(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)) {
|
||||
for (int chan = 0; 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");
|
||||
}
|
||||
|
@ -671,12 +668,12 @@ static void test_cis_peripheral(void)
|
|||
for (int i = 0; i < CONFIG_BT_ISO_MAX_CHAN; i++) {
|
||||
iso_tx_p[i].sdu = CONFIG_BT_ISO_TX_MTU;
|
||||
iso_tx_p[i].phy = BT_GAP_LE_PHY_2M;
|
||||
iso_tx_p[i].path = NULL;
|
||||
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];
|
||||
|
||||
|
@ -741,7 +738,7 @@ static void test_cis_peripheral(void)
|
|||
printk("connected to peer central.\n");
|
||||
|
||||
#if defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
|
||||
for (uint8_t chan = 0U; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
|
||||
for (int chan = 0; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
|
||||
#endif
|
||||
|
||||
printk("Waiting for ISO channel connection...");
|
||||
|
@ -756,50 +753,47 @@ static void test_cis_peripheral(void)
|
|||
}
|
||||
#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;
|
||||
if (IS_ENABLED(CONFIG_TEST_FT_CEN_SKIP_SUBEVENTS)) {
|
||||
for (uint16_t seq_num = 0U; seq_num < SEQ_NUM_MAX; seq_num++) {
|
||||
for (int chan = 0; 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));
|
||||
buf = net_buf_alloc(&tx_pool, K_MSEC(BUF_ALLOC_TIMEOUT));
|
||||
if (!buf) {
|
||||
FAIL("Data buffer allocate timeout on channel %d\n", chan);
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
net_buf_reserve(buf, BT_ISO_CHAN_SEND_RESERVE);
|
||||
sys_put_le16(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 %d\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 %d : %d\n", chan, ret);
|
||||
net_buf_unref(buf);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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++) {
|
||||
for (int chan = 0; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
|
||||
#endif
|
||||
|
||||
printk("Waiting for ISO channel disconnect...");
|
||||
|
@ -824,13 +818,13 @@ static void test_cis_peripheral(void)
|
|||
|
||||
#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++) {
|
||||
for (int chan = 0; chan < CONFIG_BT_ISO_MAX_CHAN; chan++) {
|
||||
#else
|
||||
uint8_t chan = 0U;
|
||||
int chan = 0;
|
||||
#endif
|
||||
if (expected_seq_num[chan] < SEQ_NUM_MAX) {
|
||||
FAIL("ISO Data reception incomplete %u (%u).\n",
|
||||
expected_seq_num[chan], SEQ_NUM_MAX);
|
||||
FAIL("ISO Data reception incomplete %u (%u).\n", expected_seq_num[chan],
|
||||
SEQ_NUM_MAX);
|
||||
return;
|
||||
}
|
||||
#if defined(CONFIG_TEST_MULTIPLE_PERIPERAL_CIS)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2020 Nordic Semiconductor ASA
|
||||
# Copyright 2023 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2020 Nordic Semiconductor ASA
|
||||
# Copyright 2023 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2020 Nordic Semiconductor ASA
|
||||
# Copyright 2023 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2020 Nordic Semiconductor ASA
|
||||
# Copyright 2023 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue