Bluetooth: controller: Add release of periodic advertising sync set

Add release of memory acquired for periodic advetising sync. set
when:
- advertising set is removed
- advertising parameters are changed and past PDU type was
  extended advertising PDU

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This commit is contained in:
Piotr Pryga 2021-02-03 03:02:28 -08:00 committed by Anas Nashif
commit 62819022bd
5 changed files with 33 additions and 2 deletions

View file

@ -219,6 +219,15 @@ static inline struct pdu_adv *lll_adv_sync_data_alloc(struct lll_adv_sync *lll,
#endif /* CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY */
}
static inline void lll_adv_sync_data_release(struct lll_adv_sync *lll)
{
#if IS_ENABLED(CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY)
lll_adv_and_extra_data_release(&lll->data);
#else
lll_adv_data_release(&lll->data);
#endif /* CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY */
}
static inline void lll_adv_sync_data_enqueue(struct lll_adv_sync *lll,
uint8_t idx)
{

View file

@ -291,9 +291,13 @@ uint8_t ll_adv_params_set(uint16_t interval, uint8_t adv_type,
if (is_new_set) {
pdu->type = pdu_adv_type[adv_type];
is_pdu_type_changed = 1;
/* check if new PDU type is different that past one */
} else if (pdu->type != pdu_adv_type[adv_type]) {
is_pdu_type_changed = 1;
/* If old PDU was extended advertising PDU, release
* auxiliary and periodic advertising sets.
*/
if (pdu->type == PDU_ADV_TYPE_EXT_IND) {
struct lll_adv_aux *lll_aux = adv->lll.aux;
@ -306,8 +310,14 @@ uint8_t ll_adv_params_set(uint16_t interval, uint8_t adv_type,
pdu->len = 0;
#if defined(CONFIG_BT_CTLR_ADV_PERIODIC)
/* FIXME: release periodic adv set */
LL_ASSERT(!adv->lll.sync);
if (adv->lll.sync) {
struct ll_adv_sync_set *sync;
sync = (void *)HDR_LLL2EVT(adv->lll.sync);
adv->lll.sync = NULL;
ull_adv_sync_release(sync);
}
#endif /* CONFIG_BT_CTLR_ADV_PERIODIC */
/* Release auxiliary channel set */

View file

@ -355,6 +355,9 @@ uint8_t ll_adv_aux_set_remove(uint8_t handle)
if (sync->is_enabled) {
return BT_HCI_ERR_CMD_DISALLOWED;
}
lll->sync = NULL;
ull_adv_sync_release(sync);
}
#endif /* CONFIG_BT_CTLR_ADV_PERIODIC */

View file

@ -101,6 +101,9 @@ uint8_t ull_adv_aux_hdr_set_clear(struct ll_adv_set *adv,
struct pdu_adv_adi *adi,
uint8_t *pri_idx);
/* helper function to release periodic advertising instance */
void ull_adv_sync_release(struct ll_adv_sync_set *sync);
/* helper function to set/clear common extended header format fields
* for AUX_SYNC_IND PDU.
*/

View file

@ -511,6 +511,12 @@ uint32_t ull_adv_sync_start(struct ll_adv_set *adv,
return ret;
}
void ull_adv_sync_release(struct ll_adv_sync_set *sync)
{
lll_adv_sync_data_release(&sync->lll);
sync_release(sync);
}
void ull_adv_sync_offset_get(struct ll_adv_set *adv)
{
static memq_link_t link;