Bluetooth: controller: Move ISO tx functionality to ull_iso.c
Moves the ISO tx pool and functions from ull_adv_iso.c to ull_iso.c as the pool and functions will be shared between BIS and CIS. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
e1aa633e67
commit
9c9253db5f
4 changed files with 115 additions and 72 deletions
|
@ -44,6 +44,7 @@
|
|||
#include "ull_filter.h"
|
||||
|
||||
#include "ull_internal.h"
|
||||
#include "ull_iso_internal.h"
|
||||
#include "ull_adv_internal.h"
|
||||
#include "ull_scan_internal.h"
|
||||
#include "ull_sync_internal.h"
|
||||
|
@ -403,6 +404,18 @@ int ll_init(struct k_sem *sem_rx)
|
|||
}
|
||||
#endif /* CONFIG_BT_CONN */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_ADV_ISO) || \
|
||||
defined(CONFIG_BT_CTLR_SYNC_ISO) || \
|
||||
defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) || \
|
||||
defined(CONFIG_BT_CTLR_CENTRAL_ISO)
|
||||
err = ull_iso_init();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_BT_CTLR_ADV_ISO || CONFIG_BT_CTLR_SYNC_ISO ||
|
||||
* CONFIG_BT_CTLR_PERIPHERAL_ISO || CONFIG_BT_CTLR_CENTRAL_ISO
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_ADV_ISO)
|
||||
err = ull_adv_iso_init();
|
||||
if (err) {
|
||||
|
@ -457,7 +470,17 @@ void ll_reset(void)
|
|||
LL_ASSERT(!err);
|
||||
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
|
||||
#if defined(CONFIG_BT_CTLR_ADV_ISO) || \
|
||||
defined(CONFIG_BT_CTLR_SYNC_ISO) || \
|
||||
defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) || \
|
||||
defined(CONFIG_BT_CTLR_CENTRAL_ISO)
|
||||
err = ull_iso_reset();
|
||||
LL_ASSERT(!err);
|
||||
#endif /* CONFIG_BT_CTLR_ADV_ISO || CONFIG_BT_CTLR_SYNC_ISO ||
|
||||
* CONFIG_BT_CTLR_PERIPHERAL_ISO || CONFIG_BT_CTLR_CENTRAL_ISO
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_ADV_ISO)
|
||||
/* Reset periodic sync sets */
|
||||
err = ull_adv_iso_reset();
|
||||
LL_ASSERT(!err);
|
||||
|
|
|
@ -36,18 +36,6 @@
|
|||
static struct ll_adv_iso ll_adv_iso[CONFIG_BT_CTLR_ADV_SET];
|
||||
static void *adv_iso_free;
|
||||
|
||||
static MFIFO_DEFINE(iso_tx, sizeof(struct lll_tx),
|
||||
CONFIG_BT_CTLR_ISO_TX_BUFFERS);
|
||||
|
||||
/* TODO: Share between BIS and CIS */
|
||||
static struct {
|
||||
void *free;
|
||||
uint8_t pool[CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE *
|
||||
CONFIG_BT_CTLR_ISO_TX_BUFFERS];
|
||||
} mem_iso_tx;
|
||||
|
||||
|
||||
static struct ll_adv_iso *adv_iso_by_bis_handle_get(uint16_t bis_handle);
|
||||
static uint32_t ull_adv_iso_start(struct ll_adv_iso *adv_iso,
|
||||
uint32_t ticks_anchor);
|
||||
static inline struct ll_adv_iso *ull_adv_iso_get(uint8_t handle);
|
||||
|
@ -259,9 +247,6 @@ int ull_adv_iso_reset(void)
|
|||
{
|
||||
int err;
|
||||
|
||||
/* Re-initialize the Tx mfifo */
|
||||
MFIFO_INIT(iso_tx);
|
||||
|
||||
err = init_reset();
|
||||
if (err) {
|
||||
return err;
|
||||
|
@ -270,40 +255,6 @@ int ull_adv_iso_reset(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void *ll_iso_tx_mem_acquire(void)
|
||||
{
|
||||
return mem_acquire(&mem_iso_tx.free);
|
||||
}
|
||||
|
||||
void ll_iso_tx_mem_release(void *tx)
|
||||
{
|
||||
mem_release(tx, &mem_iso_tx.free);
|
||||
}
|
||||
|
||||
int ll_iso_tx_mem_enqueue(uint16_t handle, void *tx)
|
||||
{
|
||||
struct lll_tx *lll_tx;
|
||||
struct ll_adv_iso *adv_iso;
|
||||
uint8_t idx;
|
||||
|
||||
adv_iso = adv_iso_by_bis_handle_get(handle);
|
||||
if (!adv_iso) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
idx = MFIFO_ENQUEUE_GET(iso_tx, (void **) &lll_tx);
|
||||
if (!lll_tx) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
lll_tx->handle = handle;
|
||||
lll_tx->node = tx;
|
||||
|
||||
MFIFO_ENQUEUE(iso_tx, idx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t ll_adv_iso_by_hci_handle_get(uint8_t hci_handle, uint8_t *handle)
|
||||
{
|
||||
struct ll_adv_iso *adv_iso;
|
||||
|
@ -350,23 +301,6 @@ uint8_t ll_adv_iso_by_hci_handle_new(uint8_t hci_handle, uint8_t *handle)
|
|||
return BT_HCI_ERR_MEM_CAPACITY_EXCEEDED;
|
||||
}
|
||||
|
||||
static struct ll_adv_iso *adv_iso_by_bis_handle_get(uint16_t bis_handle)
|
||||
{
|
||||
struct ll_adv_iso *adv_iso;
|
||||
uint8_t idx;
|
||||
|
||||
adv_iso = &ll_adv_iso[0];
|
||||
|
||||
for (idx = 0U; idx < CONFIG_BT_CTLR_ADV_SET; idx++, adv_iso++) {
|
||||
if (adv_iso->is_created &&
|
||||
(adv_iso->bis_handle == bis_handle)) {
|
||||
return adv_iso;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uint32_t ull_adv_iso_start(struct ll_adv_iso *adv_iso,
|
||||
uint32_t ticks_anchor)
|
||||
{
|
||||
|
@ -428,14 +362,10 @@ static inline struct ll_adv_iso *ull_adv_iso_get(uint8_t handle)
|
|||
|
||||
static int init_reset(void)
|
||||
{
|
||||
/* Initialize conn pool. */
|
||||
/* Initialize pool. */
|
||||
mem_init(ll_adv_iso, sizeof(struct ll_adv_iso),
|
||||
sizeof(ll_adv_iso) / sizeof(struct ll_adv_iso), &adv_iso_free);
|
||||
|
||||
/* Initialize tx pool. */
|
||||
mem_init(mem_iso_tx.pool, CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE,
|
||||
CONFIG_BT_CTLR_ISO_TX_BUFFERS, &mem_iso_tx.free);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,24 @@
|
|||
#define LOG_MODULE_NAME bt_ctlr_ull_iso
|
||||
#include "common/log.h"
|
||||
#include "hal/debug.h"
|
||||
#include "hal/ccm.h"
|
||||
#include "util/memq.h"
|
||||
#include "util/mem.h"
|
||||
#include "util/mfifo.h"
|
||||
#include "pdu.h"
|
||||
#include "lll.h"
|
||||
#include "lll_conn.h" /* for `struct lll_tx` */
|
||||
|
||||
static int init_reset(void);
|
||||
|
||||
static MFIFO_DEFINE(iso_tx, sizeof(struct lll_tx),
|
||||
CONFIG_BT_CTLR_ISO_TX_BUFFERS);
|
||||
|
||||
static struct {
|
||||
void *free;
|
||||
uint8_t pool[CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE *
|
||||
CONFIG_BT_CTLR_ISO_TX_BUFFERS];
|
||||
} mem_iso_tx;
|
||||
|
||||
/* Contains vendor specific argument, function to be implemented by vendors */
|
||||
__weak uint8_t ll_configure_data_path(uint8_t data_path_dir,
|
||||
|
@ -121,3 +139,67 @@ uint8_t ll_read_iso_link_quality(uint16_t handle,
|
|||
|
||||
return BT_HCI_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
|
||||
int ull_iso_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = init_reset();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ull_iso_reset(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
/* Re-initialize the Tx mfifo */
|
||||
MFIFO_INIT(iso_tx);
|
||||
|
||||
err = init_reset();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *ll_iso_tx_mem_acquire(void)
|
||||
{
|
||||
return mem_acquire(&mem_iso_tx.free);
|
||||
}
|
||||
|
||||
void ll_iso_tx_mem_release(void *tx)
|
||||
{
|
||||
mem_release(tx, &mem_iso_tx.free);
|
||||
}
|
||||
|
||||
int ll_iso_tx_mem_enqueue(uint16_t handle, void *tx)
|
||||
{
|
||||
struct lll_tx *lll_tx;
|
||||
uint8_t idx;
|
||||
|
||||
idx = MFIFO_ENQUEUE_GET(iso_tx, (void **) &lll_tx);
|
||||
if (!lll_tx) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
lll_tx->handle = handle;
|
||||
lll_tx->node = tx;
|
||||
|
||||
MFIFO_ENQUEUE(iso_tx, idx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int init_reset(void)
|
||||
{
|
||||
/* Initialize tx pool. */
|
||||
mem_init(mem_iso_tx.pool, CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE,
|
||||
CONFIG_BT_CTLR_ISO_TX_BUFFERS, &mem_iso_tx.free);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
8
subsys/bluetooth/controller/ll_sw/ull_iso_internal.h
Normal file
8
subsys/bluetooth/controller/ll_sw/ull_iso_internal.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
int ull_iso_init(void);
|
||||
int ull_iso_reset(void);
|
Loading…
Add table
Add a link
Reference in a new issue