Bluetooth: controller: Implements BIG terminate command

Implements the BIG terminate command that terminates a
BIG and returns the appropriate events.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2020-11-04 17:22:33 +01:00 committed by Carles Cufí
commit 41fe6d72a1
4 changed files with 65 additions and 13 deletions

View file

@ -28,7 +28,7 @@
#include "hal/ccm.h"
#include "ll_sw/pdu.h"
#include "ll_sw/lll.h"
#include "ll_sw/lll_adv.h"
#include "lll_adv.h"
#include "ll_sw/lll_scan.h"
#include "ll_sw/lll_sync.h"
#include "ll_sw/lll_conn.h"
@ -1438,12 +1438,13 @@ static void le_create_big_test(struct net_buf *buf, struct net_buf **evt)
*evt = cmd_status(status);
}
static void le_terminate_big(struct net_buf *buf, struct net_buf **evt)
static void le_terminate_big(struct net_buf *buf, struct net_buf **evt,
void **node_rx)
{
struct bt_hci_cp_le_terminate_big *cmd = (void *)buf->data;
uint8_t status;
status = ll_big_terminate(cmd->big_handle, cmd->reason);
status = ll_big_terminate(cmd->big_handle, cmd->reason, node_rx);
*evt = cmd_status(status);
}
@ -3169,7 +3170,7 @@ static int controller_cmd_handle(uint16_t ocf, struct net_buf *cmd,
break;
case BT_OCF(BT_HCI_OP_LE_TERMINATE_BIG):
le_terminate_big(cmd, evt);
le_terminate_big(cmd, evt, node_rx);
break;
#endif /* CONFIG_BT_CTLR_ADV_ISO */
#endif /* CONFIG_BT_BROADCASTER */

View file

@ -107,7 +107,7 @@ uint8_t ll_big_test_create(uint8_t big_handle, uint8_t adv_handle,
uint16_t max_pdu, uint8_t phy, uint8_t packing,
uint8_t framing, uint8_t bn, uint8_t irc,
uint8_t pto, uint8_t encryption, uint8_t *bcode);
uint8_t ll_big_terminate(uint8_t big_handle, uint8_t reason);
uint8_t ll_big_terminate(uint8_t big_handle, uint8_t reason, void **node_rx);
uint8_t ll_scan_params_set(uint8_t type, uint16_t interval, uint16_t window,
uint8_t own_addr_type, uint8_t filter_policy);

View file

@ -256,7 +256,7 @@ uint32_t ull_adv_iso_start(struct ll_adv_iso *adv_iso, uint32_t ticks_anchor)
iso_interval_us = adv_iso->sdu_interval;
ret_cb = TICKER_STATUS_BUSY;
ret = ticker_start(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_THREAD,
ret = ticker_start(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_ULL_HIGH,
(TICKER_ID_ADV_ISO_BASE + adv_iso->bis_handle),
ticks_anchor, 0,
HAL_TICKER_US_TO_TICKS(iso_interval_us),
@ -401,7 +401,7 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
*rx = node_rx;
return 0;
return BT_HCI_ERR_SUCCESS;
}
uint8_t ll_big_test_create(uint8_t big_handle, uint8_t adv_handle,
@ -432,18 +432,61 @@ uint8_t ll_big_test_create(uint8_t big_handle, uint8_t adv_handle,
return BT_HCI_ERR_CMD_DISALLOWED;
}
uint8_t ll_big_terminate(uint8_t big_handle, uint8_t reason)
static void tx_lll_flush(void *param)
{
/* TODO: LLL support for ADV ISO */
/* TODO: Send terminate complete event to host */
#if 0
/* TODO: Flush TX */
struct ll_adv_iso *lll = param;
#endif
}
static void ticker_op_stop_cb(uint32_t status, void *param)
{
uint32_t retval;
static memq_link_t link;
static struct mayfly mfy = {0, 0, &link, NULL, tx_lll_flush};
LL_ASSERT(status == TICKER_STATUS_SUCCESS);
mfy.param = param;
/* Flush pending tx PDUs in LLL (using a mayfly) */
retval = mayfly_enqueue(TICKER_USER_ID_ULL_LOW, TICKER_USER_ID_LLL, 0,
&mfy);
LL_ASSERT(!retval);
}
uint8_t ll_big_terminate(uint8_t big_handle, uint8_t reason, void **rx)
{
struct ll_adv_iso *adv_iso;
struct node_rx_pdu *node_rx;
uint32_t ret;
adv_iso = ull_adv_iso_get(big_handle);
if (!adv_iso) {
return BT_HCI_ERR_CMD_DISALLOWED;
return BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER;
}
/* TODO: Implement */
ARG_UNUSED(reason);
/* TODO: Terminate all BIS data paths */
return BT_HCI_ERR_CMD_DISALLOWED;
ret = ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_ULL_HIGH,
TICKER_ID_ADV_ISO_BASE + adv_iso->bis_handle,
ticker_op_stop_cb, adv_iso);
adv_iso->is_created = 0U;
/* Prepare BIG terminate event */
node_rx = (void *)&adv_iso->node_rx_terminate;
node_rx->hdr.type = NODE_RX_TYPE_BIG_TERMINATE;
node_rx->hdr.handle = big_handle;
node_rx->hdr.rx_ftr.param = adv_iso;
*((uint8_t *)node_rx->pdu) = reason;
*rx = node_rx;
return BT_HCI_ERR_SUCCESS;
}

View file

@ -84,7 +84,15 @@ struct ll_adv_iso {
uint8_t bcode[16];
struct node_rx_hdr *node_rx_complete;
struct node_rx_hdr node_rx_complete;
struct {
struct node_rx_hdr node_rx_hdr_terminate;
union {
uint8_t pdu[0] __aligned(4);
uint8_t reason;
};
} node_rx_terminate;
struct pdu_bis pdu;
};