Commit aa11d9ca authored by Vinayak Kariappa Chettimada's avatar Vinayak Kariappa Chettimada Committed by Carles Cufi
Browse files

Bluetooth: controller: Add the BIG terminate event generation



Add the BIG terminate event generation.

Signed-off-by: default avatarVinayak Kariappa Chettimada <vich@nordicsemi.no>
parent aff7d831
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -6510,6 +6510,22 @@ static void le_big_complete(struct pdu_data *pdu_data,
	/* TODO: Connection handle list of all BISes in the BIG */
	sep->handle[0] = sys_cpu_to_le16(0);
}

static void le_big_terminate(struct pdu_data *pdu,
			     struct node_rx_pdu *node_rx,
			     struct net_buf *buf)
{
	struct bt_hci_evt_le_big_terminate *sep;

	if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) ||
	    !(le_event_mask & BT_EVT_MASK_LE_BIG_TERMINATED)) {
		return;
	}

	sep = meta_evt(buf, BT_HCI_EVT_LE_BIG_TERMINATE, sizeof(*sep));
	sep->big_handle = sys_cpu_to_le16(node_rx->hdr.handle);
	sep->reason = *((uint8_t *)pdu);
}
#endif /* CONFIG_BT_CTLR_ADV_ISO */
#endif /* CONFIG_BT_CTLR_ADV_EXT */
#endif /* CONFIG_BT_BROADCASTER */
@@ -6892,6 +6908,9 @@ static void encode_control(struct node_rx_pdu *node_rx,
	case NODE_RX_TYPE_BIG_COMPLETE:
		le_big_complete(pdu_data, node_rx, buf);
		break;
	case NODE_RX_TYPE_BIG_TERMINATE:
		le_big_terminate(pdu_data, node_rx, buf);
		break;
#endif /* CONFIG_BT_CTLR_ADV_ISO */
#endif /* CONFIG_BT_CTLR_ADV_EXT */
#endif /* CONFIG_BT_BROADCASTER */
@@ -7341,6 +7360,7 @@ uint8_t hci_get_class(struct node_rx_pdu *node_rx)
		case NODE_RX_TYPE_EXT_ADV_TERMINATE:
#if defined(CONFIG_BT_CTLR_ADV_ISO)
		case NODE_RX_TYPE_BIG_COMPLETE:
		case NODE_RX_TYPE_BIG_TERMINATE:
#endif /* CONFIG_BT_CTLR_ADV_ISO */
#endif /* CONFIG_BT_BROADCASTER */

+8 −0
Original line number Diff line number Diff line
@@ -1133,6 +1133,7 @@ void ll_rx_dequeue(void)

#if defined(CONFIG_BT_CTLR_ADV_ISO)
	case NODE_RX_TYPE_BIG_COMPLETE:
	case NODE_RX_TYPE_BIG_TERMINATE:
#endif /* CONFIG_BT_CTLR_ADV_ISO */

#if defined(CONFIG_BT_OBSERVER)
@@ -1264,6 +1265,7 @@ void ll_rx_mem_release(void **node_rx)
			break;
#if defined(CONFIG_BT_CTLR_ADV_ISO)
		case NODE_RX_TYPE_BIG_COMPLETE:
		case NODE_RX_TYPE_BIG_TERMINATE:
			/* Nothing to release */
			break;
#endif /* CONFIG_BT_CTLR_ADV_ISO */
@@ -2532,6 +2534,7 @@ static inline int rx_demux_rx(memq_link_t *link, struct node_rx_hdr *rx)

#if defined(CONFIG_BT_OBSERVER) || \
	defined(CONFIG_BT_CTLR_ADV_PERIODIC) || \
	defined(CONFIG_BT_CTLR_ADV_ISO) || \
	defined(CONFIG_BT_CTLR_SYNC_ISO) || \
	defined(CONFIG_BT_CTLR_SCAN_REQ_NOTIFY) || \
	defined(CONFIG_BT_CTLR_PROFILE_ISR) || \
@@ -2543,6 +2546,10 @@ static inline int rx_demux_rx(memq_link_t *link, struct node_rx_hdr *rx)
	case NODE_RX_TYPE_SYNC_CHM_COMPLETE:
#endif /* CONFIG_BT_CTLR_ADV_PERIODIC */

#if defined(CONFIG_BT_CTLR_ADV_ISO)
	case NODE_RX_TYPE_BIG_TERMINATE:
#endif /* CONFIG_BT_CTLR_ADV_ISO */

#if defined(CONFIG_BT_OBSERVER)
	case NODE_RX_TYPE_REPORT:
#if defined(CONFIG_BT_CTLR_SYNC_ISO)
@@ -2575,6 +2582,7 @@ static inline int rx_demux_rx(memq_link_t *link, struct node_rx_hdr *rx)
	break;
#endif /* CONFIG_BT_OBSERVER ||
	* CONFIG_BT_CTLR_ADV_PERIODIC ||
	* CONFIG_BT_CTLR_ADV_ISO ||
	* CONFIG_BT_CTLR_SYNC_ISO ||
	* CONFIG_BT_CTLR_SCAN_REQ_NOTIFY ||
	* CONFIG_BT_CTLR_PROFILE_ISR ||
+40 −17
Original line number Diff line number Diff line
@@ -79,9 +79,10 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
	struct pdu_big_info *big_info;
	uint8_t pdu_big_info_size;
	uint32_t ticks_anchor_iso;
	memq_link_t *link_cmplt;
	memq_link_t *link_term;
	struct ll_adv_set *adv;
	uint16_t iso_interval;
	memq_link_t *link;
	uint8_t ter_idx;
	uint8_t *acad;
	uint32_t ret;
@@ -149,8 +150,15 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
		}
	}

	link = ll_rx_link_alloc();
	if (!link) {
	link_cmplt = ll_rx_link_alloc();
	if (!link_cmplt) {
		return BT_HCI_ERR_MEM_CAPACITY_EXCEEDED;
	}

	link_term = ll_rx_link_alloc();
	if (!link_term) {
		ll_rx_link_release(link_cmplt);

		return BT_HCI_ERR_MEM_CAPACITY_EXCEEDED;
	}

@@ -230,7 +238,8 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
					 ULL_ADV_PDU_HDR_FIELD_ACAD, 0U,
					 &hdr_data);
	if (err) {
		ll_rx_link_release(link);
		ll_rx_link_release(link_cmplt);
		ll_rx_link_release(link_term);

		return err;
	}
@@ -279,7 +288,8 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
	lll_adv_iso->adv = &adv->lll;

	/* Store the link buffer for ISO create and terminate complete event */
	adv_iso->node_rx_complete.hdr.link = link;
	adv_iso->node_rx_complete.hdr.link = link_cmplt;
	adv_iso->node_rx_terminate.hdr.link = link_term;

	/* Initialise LLL header members */
	lll_hdr_init(lll_adv_iso, adv_iso);
@@ -368,13 +378,7 @@ uint8_t ll_big_terminate(uint8_t big_handle, uint8_t reason)

	/* TODO: Terminate all BIS data paths */

	ret = ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_THREAD,
			  (TICKER_ID_ADV_ISO_BASE + lll_adv_iso->handle),
			  ticker_op_stop_cb, adv_iso);

	lll_adv_iso->adv = NULL;
	lll_adv_sync->iso = NULL;

	/* FIXME: Generate after terminate procedure completes */
	/* Prepare BIG terminate event */
	node_rx = (void *)&adv_iso->node_rx_terminate;
	node_rx->hdr.type = NODE_RX_TYPE_BIG_TERMINATE;
@@ -382,6 +386,13 @@ uint8_t ll_big_terminate(uint8_t big_handle, uint8_t reason)
	node_rx->hdr.rx_ftr.param = adv_iso;
	*((uint8_t *)node_rx->pdu) = reason;

	ret = ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_THREAD,
			  (TICKER_ID_ADV_ISO_BASE + lll_adv_iso->handle),
			  ticker_op_stop_cb, adv_iso);

	lll_adv_iso->adv = NULL;
	lll_adv_sync->iso = NULL;

	return BT_HCI_ERR_SUCCESS;
}

@@ -722,12 +733,24 @@ static void ticker_op_cb(uint32_t status, void *param)

static void tx_lll_flush(void *param)
{
	/* TODO: LLL support for ADV ISO */
	/* TODO: Send terminate complete event to host */
#if 0
	struct ll_adv_iso_set *adv_iso = param;
	struct node_rx_pdu *rx;
	memq_link_t *link;

	/* TODO: Flush TX */
	struct lll_adv_iso *lll = param;
#endif

	/* Get the terminate structure reserved in the ISO context.
	 * The terminate reason and connection handle should already be
	 * populated before this mayfly function was scheduled.
	 */
	rx = (void *)&adv_iso->node_rx_terminate;
	link = rx->hdr.link;
	LL_ASSERT(link);
	rx->hdr.link = NULL;

	/* Enqueue the terminate towards ULL context */
	ull_rx_put(link, rx);
	ull_rx_sched();
}

static void ticker_op_stop_cb(uint32_t status, void *param)
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ struct ll_adv_iso_set {
		struct node_rx_hdr hdr;
	} node_rx_complete;
	struct {
		struct node_rx_hdr node_rx_hdr_terminate;
		struct node_rx_hdr hdr;
		union {
			uint8_t    pdu[0] __aligned(4);
			uint8_t    reason;