Bluetooth: controller: Remove redundant tmp role implementation
Remove the redundant proof of concept template temporary role implementation from the repository. Relates to #12860. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
2b9458c378
commit
4c77bf6194
11 changed files with 4 additions and 752 deletions
|
@ -127,15 +127,6 @@ if(CONFIG_BT_LL_SW_SPLIT)
|
|||
CONFIG_BT_CTLR_DTM
|
||||
ll_sw/nordic/lll/lll_test.c
|
||||
)
|
||||
if(CONFIG_BT_TMP)
|
||||
zephyr_library_sources(
|
||||
ll_sw/ull_tmp.c
|
||||
)
|
||||
zephyr_library_sources_ifdef(
|
||||
CONFIG_BT_LLL_VENDOR_NORDIC
|
||||
ll_sw/nordic/lll/lll_tmp.c
|
||||
)
|
||||
endif()
|
||||
if(CONFIG_BT_LLL_VENDOR_NORDIC)
|
||||
zephyr_library_include_directories(
|
||||
ll_sw/nordic/lll
|
||||
|
|
|
@ -1,246 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2019 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <toolchain.h>
|
||||
#include <zephyr/types.h>
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_DEBUG_PINS)
|
||||
#if defined(CONFIG_PRINTK)
|
||||
#undef CONFIG_PRINTK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "hal/ccm.h"
|
||||
|
||||
#include "util/mfifo.h"
|
||||
#include "util/memq.h"
|
||||
|
||||
#include "ticker/ticker.h"
|
||||
|
||||
#include "pdu.h"
|
||||
|
||||
#include "lll.h"
|
||||
#include "lll_conn.h"
|
||||
#include "lll_tmp.h"
|
||||
#include "lll_internal.h"
|
||||
|
||||
#include "common/log.h"
|
||||
#include <soc.h>
|
||||
#include "hal/debug.h"
|
||||
|
||||
static MFIFO_DEFINE(tmp_ack, sizeof(struct lll_tx),
|
||||
CONFIG_BT_TMP_TX_COUNT_MAX);
|
||||
|
||||
static int _init_reset(void);
|
||||
static int _prepare_cb(struct lll_prepare_param *prepare_param);
|
||||
static int _is_abort_cb(void *next, int prio, void *curr,
|
||||
lll_prepare_cb_t *resume_cb, int *resume_prio);
|
||||
static void _abort_cb(struct lll_prepare_param *prepare_param, void *param);
|
||||
static int _emulate_tx_rx(void *param);
|
||||
|
||||
int lll_tmp_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = _init_reset();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lll_tmp_reset(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
MFIFO_INIT(tmp_ack);
|
||||
|
||||
err = _init_reset();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void lll_tmp_prepare(void *param)
|
||||
{
|
||||
struct lll_prepare_param *p = param;
|
||||
int err;
|
||||
|
||||
printk("\t\tlll_tmp_prepare (%p) enter.\n", p->param);
|
||||
|
||||
err = lll_clk_on();
|
||||
printk("\t\tlll_clk_on: %d.\n", err);
|
||||
|
||||
err = lll_prepare(_is_abort_cb, _abort_cb, _prepare_cb, 0, p);
|
||||
|
||||
printk("\t\tlll_tmp_prepare (%p) exit (%d).\n", p->param, err);
|
||||
}
|
||||
|
||||
u8_t lll_tmp_ack_last_idx_get(void)
|
||||
{
|
||||
return mfifo_tmp_ack.l;
|
||||
}
|
||||
|
||||
memq_link_t *lll_tmp_ack_peek(u16_t *handle, struct node_tx **node_tx)
|
||||
{
|
||||
struct lll_tx *tx;
|
||||
|
||||
tx = MFIFO_DEQUEUE_GET(tmp_ack);
|
||||
if (!tx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*handle = tx->handle;
|
||||
*node_tx = tx->node;
|
||||
|
||||
return (*node_tx)->link;
|
||||
}
|
||||
|
||||
memq_link_t *lll_tmp_ack_by_last_peek(u8_t last, u16_t *handle,
|
||||
struct node_tx **node_tx)
|
||||
{
|
||||
struct lll_tx *tx;
|
||||
|
||||
tx = mfifo_dequeue_get(mfifo_tmp_ack.m, mfifo_tmp_ack.s,
|
||||
mfifo_tmp_ack.f, last);
|
||||
if (!tx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*handle = tx->handle;
|
||||
*node_tx = tx->node;
|
||||
|
||||
return (*node_tx)->link;
|
||||
}
|
||||
|
||||
void *lll_tmp_ack_dequeue(void)
|
||||
{
|
||||
return MFIFO_DEQUEUE(tmp_ack);
|
||||
}
|
||||
|
||||
static int _init_reset(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _prepare_cb(struct lll_prepare_param *prepare_param)
|
||||
{
|
||||
int err;
|
||||
|
||||
printk("\t\t_prepare (%p) enter: expected %u, actual %u.\n",
|
||||
prepare_param->param, prepare_param->ticks_at_expire,
|
||||
ticker_ticks_now_get());
|
||||
DEBUG_RADIO_PREPARE_A(1);
|
||||
|
||||
err = _emulate_tx_rx(prepare_param);
|
||||
|
||||
DEBUG_RADIO_PREPARE_A(1);
|
||||
printk("\t\t_prepare (%p) exit (%d).\n", prepare_param->param, err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int _is_abort_cb(void *next, int prio, void *curr,
|
||||
lll_prepare_cb_t *resume_cb, int *resume_prio)
|
||||
{
|
||||
static u8_t toggle;
|
||||
|
||||
toggle++;
|
||||
|
||||
return toggle & 0x01;
|
||||
}
|
||||
|
||||
static void _abort_cb(struct lll_prepare_param *prepare_param, void *param)
|
||||
{
|
||||
int err;
|
||||
|
||||
printk("\t\t_abort (%p) enter.\n", param);
|
||||
|
||||
/* NOTE: This is not a prepare being cancelled */
|
||||
if (!prepare_param) {
|
||||
/* Perform event abort here.
|
||||
* After event has been cleanly aborted, clean up resources
|
||||
* and dispatch event done.
|
||||
*/
|
||||
|
||||
/* Current event is done, pass NULL to lll_done(). */
|
||||
param = NULL;
|
||||
}
|
||||
|
||||
/* NOTE: Else clean the top half preparations of the aborted event
|
||||
* currently in preparation pipeline.
|
||||
*/
|
||||
err = lll_clk_off();
|
||||
printk("\t\tlll_clk_off: %d.\n", err);
|
||||
|
||||
lll_done(param);
|
||||
printk("\t\tlll_done (%p).\n", param);
|
||||
|
||||
printk("\t\t_abort (%p) exit.\n", param);
|
||||
}
|
||||
|
||||
static int _emulate_tx_rx(void *param)
|
||||
{
|
||||
struct lll_prepare_param *prepare_param = param;
|
||||
struct lll_tmp *tmp = prepare_param->param;
|
||||
struct node_tx *node_tx;
|
||||
bool is_ull_rx = false;
|
||||
memq_link_t *link;
|
||||
void *free;
|
||||
|
||||
/* Tx */
|
||||
link = memq_dequeue(tmp->memq_tx.tail, &tmp->memq_tx.head,
|
||||
(void **)&node_tx);
|
||||
while (link) {
|
||||
struct lll_tx *tx;
|
||||
u8_t idx;
|
||||
|
||||
idx = MFIFO_ENQUEUE_GET(tmp_ack, (void **)&tx);
|
||||
LL_ASSERT(tx);
|
||||
|
||||
tx->handle = ull_tmp_handle_get(tmp);
|
||||
tx->node = node_tx;
|
||||
|
||||
node_tx->link = link;
|
||||
|
||||
printk("\t\t_emulate_tx_rx: h= %u.\n", tx->handle);
|
||||
|
||||
MFIFO_ENQUEUE(tmp_ack, idx);
|
||||
|
||||
link = memq_dequeue(tmp->memq_tx.tail, &tmp->memq_tx.head,
|
||||
(void **)&node_tx);
|
||||
}
|
||||
|
||||
/* Rx */
|
||||
free = ull_pdu_rx_alloc_peek(2);
|
||||
if (free) {
|
||||
struct node_rx_hdr *hdr = free;
|
||||
void *_free;
|
||||
|
||||
_free = ull_pdu_rx_alloc();
|
||||
LL_ASSERT(free == _free);
|
||||
|
||||
hdr->type = NODE_RX_TYPE_DC_PDU;
|
||||
|
||||
ull_rx_put(hdr->link, hdr);
|
||||
|
||||
is_ull_rx = true;
|
||||
} else {
|
||||
printk("\t\tOUT OF PDU RX MEMORY.\n");
|
||||
}
|
||||
|
||||
if (is_ull_rx) {
|
||||
ull_rx_sched();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2019 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
struct lll_tmp {
|
||||
struct lll_hdr hdr;
|
||||
|
||||
MEMQ_DECLARE(tx);
|
||||
memq_link_t _link; /* Dedicated thread allocatable */
|
||||
memq_link_t *link_free; /* Thread allocatable reference */
|
||||
};
|
||||
|
||||
int lll_tmp_init(void);
|
||||
void lll_tmp_prepare(void *param);
|
||||
|
||||
u8_t lll_tmp_ack_last_idx_get(void);
|
||||
memq_link_t *lll_tmp_ack_peek(u16_t *handle, struct node_tx **node_tx);
|
||||
memq_link_t *lll_tmp_ack_by_last_peek(u8_t last, u16_t *handle,
|
||||
struct node_tx **node_tx);
|
||||
void *lll_tmp_ack_dequeue(void);
|
||||
|
||||
extern u16_t ull_tmp_handle_get(struct lll_tmp *tmp);
|
|
@ -1,5 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2019 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
|
@ -36,7 +36,6 @@
|
|||
#include "lll_adv.h"
|
||||
#include "lll_scan.h"
|
||||
#include "lll_conn.h"
|
||||
#include "lll_tmp.h"
|
||||
#include "ull_adv_types.h"
|
||||
#include "ull_scan_types.h"
|
||||
#include "ull_conn_types.h"
|
||||
|
@ -44,7 +43,6 @@
|
|||
#include "ull_adv_internal.h"
|
||||
#include "ull_scan_internal.h"
|
||||
#include "ull_conn_internal.h"
|
||||
#include "ull_tmp_internal.h"
|
||||
|
||||
#define LOG_MODULE_NAME bt_ctlr_llsw_ull
|
||||
#include "common/log.h"
|
||||
|
@ -79,12 +77,6 @@
|
|||
#define BT_CONN_TICKER_NODES 0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_TMP)
|
||||
#define BT_TMP_TICKER_NODES ((TICKER_ID_TMP_LAST) - (TICKER_ID_TMP_BASE) + 1)
|
||||
#else
|
||||
#define BT_TMP_TICKER_NODES 0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SOC_FLASH_NRF_RADIO_SYNC)
|
||||
#define FLASH_TICKER_NODES 1 /* No. of tickers reserved for flashing */
|
||||
#define FLASH_TICKER_USER_APP_OPS 1 /* No. of additional ticker operations */
|
||||
|
@ -97,7 +89,6 @@
|
|||
BT_ADV_TICKER_NODES + \
|
||||
BT_SCAN_TICKER_NODES + \
|
||||
BT_CONN_TICKER_NODES + \
|
||||
BT_TMP_TICKER_NODES + \
|
||||
FLASH_TICKER_NODES)
|
||||
#define TICKER_USER_APP_OPS (TICKER_USER_THREAD_OPS + \
|
||||
FLASH_TICKER_USER_APP_OPS)
|
||||
|
@ -198,10 +189,6 @@ static inline int _init_reset(void);
|
|||
static inline void _done_alloc(void);
|
||||
static inline void _rx_alloc(u8_t max);
|
||||
static void _rx_demux(void *param);
|
||||
#if defined(CONFIG_BT_TMP)
|
||||
static inline void _rx_demux_tx_ack(u16_t handle, memq_link_t *link,
|
||||
struct node_tx *node_tx);
|
||||
#endif /* CONFIG_BT_TMP */
|
||||
static inline void _rx_demux_rx(memq_link_t *link, struct node_rx_hdr *rx);
|
||||
static inline void _rx_demux_event_done(memq_link_t *link,
|
||||
struct node_rx_hdr *rx);
|
||||
|
@ -299,19 +286,6 @@ int ll_init(struct k_sem *sem_rx)
|
|||
}
|
||||
#endif /* CONFIG_BT_CONN */
|
||||
|
||||
/* Initialize state/roles */
|
||||
#if defined(CONFIG_BT_TMP)
|
||||
err = lll_tmp_init();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = ull_tmp_init();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_BT_TMP */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -359,12 +333,6 @@ void ll_reset(void)
|
|||
MFIFO_INIT(tx_ack);
|
||||
#endif /* CONFIG_BT_CONN */
|
||||
|
||||
#if defined(CONFIG_BT_TMP)
|
||||
/* Reset tmp */
|
||||
err = ull_tmp_reset();
|
||||
LL_ASSERT(!err);
|
||||
#endif /* CONFIG_BT_TMP */
|
||||
|
||||
/* Re-initialize ULL internals */
|
||||
|
||||
/* Re-initialize the prep mfifo */
|
||||
|
@ -958,11 +926,9 @@ void ull_rx_put(memq_link_t *link, void *rx)
|
|||
*/
|
||||
#if defined(CONFIG_BT_CONN)
|
||||
rx_hdr->ack_last = lll_conn_ack_last_idx_get();
|
||||
#elif defined(CONFIG_BT_TMP)
|
||||
rx_hdr->ack_last = lll_tmp_ack_last_idx_get();
|
||||
#else /* !CONFIG_BT_TMP */
|
||||
#else
|
||||
ARG_UNUSED(rx_hdr);
|
||||
#endif /* !CONFIG_BT_TMP */
|
||||
#endif
|
||||
|
||||
/* Enqueue the Rx object */
|
||||
memq_enqueue(link, rx, &memq_ull_rx.tail);
|
||||
|
@ -1300,16 +1266,6 @@ static inline void _rx_demux_conn_tx_ack(u8_t ack_last, u16_t handle,
|
|||
}
|
||||
#endif /* CONFIG_BT_CONN */
|
||||
|
||||
#if defined(CONFIG_BT_TMP)
|
||||
static inline void _rx_demux_tx_ack(u16_t handle, memq_link_t *link,
|
||||
struct node_tx *node_tx)
|
||||
{
|
||||
lll_tmp_ack_dequeue();
|
||||
|
||||
ull_tmp_link_tx_release(link);
|
||||
}
|
||||
#endif /* CONFIG_BT_TMP */
|
||||
|
||||
static void _rx_demux(void *param)
|
||||
{
|
||||
memq_link_t *link;
|
||||
|
@ -1335,13 +1291,7 @@ static void _rx_demux(void *param)
|
|||
_rx_demux_conn_tx_ack(rx->ack_last, handle,
|
||||
link_tx, node_tx);
|
||||
} else
|
||||
#elif defined(CONFIG_BT_TMP)
|
||||
link_tx = lll_tmp_ack_by_last_peek(rx->ack_last,
|
||||
&handle, &node_tx);
|
||||
if (link_tx) {
|
||||
_rx_demux_tx_ack(handle, link_tx, node_tx);
|
||||
} else
|
||||
#endif /* CONFIG_BT_TMP */
|
||||
#endif
|
||||
{
|
||||
_rx_demux_rx(link, rx);
|
||||
}
|
||||
|
@ -1356,16 +1306,7 @@ static void _rx_demux(void *param)
|
|||
_rx_demux_conn_tx_ack(ack_last, handle,
|
||||
link, node_tx);
|
||||
}
|
||||
#elif defined(CONFIG_BT_TMP)
|
||||
} else {
|
||||
struct node_tx *node_tx;
|
||||
u16_t handle;
|
||||
|
||||
link = lll_tmp_ack_peek(&handle, &node_tx);
|
||||
if (link) {
|
||||
_rx_demux_tx_ack(handle, link, node_tx);
|
||||
}
|
||||
#endif /* CONFIG_BT_TMP */
|
||||
#endif
|
||||
}
|
||||
} while (link);
|
||||
}
|
||||
|
|
|
@ -1,325 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2019 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <toolchain.h>
|
||||
#include <zephyr/types.h>
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_DEBUG_PINS)
|
||||
#if defined(CONFIG_PRINTK)
|
||||
#undef CONFIG_PRINTK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "hal/ccm.h"
|
||||
|
||||
#include "util/mem.h"
|
||||
#include "util/mfifo.h"
|
||||
#include "util/memq.h"
|
||||
#include "util/mayfly.h"
|
||||
|
||||
#include "ticker/ticker.h"
|
||||
|
||||
#include "pdu.h"
|
||||
|
||||
#include "lll.h"
|
||||
#include "lll_conn.h"
|
||||
#include "lll_tmp.h"
|
||||
#include "ull_internal.h"
|
||||
#include "ull_tmp.h"
|
||||
#include "ull_tmp_internal.h"
|
||||
|
||||
#define LOG_MODULE_NAME bt_ctlr_llsw_ull_tmp
|
||||
#include "common/log.h"
|
||||
#include <soc.h>
|
||||
#include "hal/debug.h"
|
||||
|
||||
#define TMP_TICKER_TICKS_PERIOD 32768
|
||||
#define TMP_TICKER_TICKS_SLOT 327
|
||||
|
||||
#define TMP_TX_POOL_SIZE ((CONFIG_BT_TMP_TX_SIZE_MAX) * \
|
||||
(CONFIG_BT_TMP_TX_COUNT_MAX))
|
||||
|
||||
/* NOTE: structure accessed by Thread and ULL */
|
||||
struct ull_tmp {
|
||||
struct ull_hdr hdr;
|
||||
|
||||
u8_t is_enabled:1;
|
||||
};
|
||||
|
||||
struct tmp {
|
||||
struct ull_tmp ull;
|
||||
struct lll_tmp lll;
|
||||
};
|
||||
|
||||
static struct tmp tmp_inst[CONFIG_BT_TMP_MAX];
|
||||
|
||||
static MFIFO_DEFINE(tmp_tx, sizeof(struct lll_tx),
|
||||
CONFIG_BT_TMP_TX_COUNT_MAX);
|
||||
|
||||
static struct {
|
||||
void *free;
|
||||
u8_t pool[TMP_TX_POOL_SIZE];
|
||||
} mem_tmp_tx;
|
||||
|
||||
static struct {
|
||||
void *free;
|
||||
u8_t pool[sizeof(memq_link_t) * CONFIG_BT_TMP_TX_COUNT_MAX];
|
||||
} mem_link_tx;
|
||||
|
||||
static int _init_reset(void);
|
||||
static void _ticker_cb(u32_t ticks_at_expire, u32_t remainder,
|
||||
u16_t lazy, void *param);
|
||||
static void _tx_demux(void);
|
||||
|
||||
int ull_tmp_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = _init_reset();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ull_tmp_reset(void)
|
||||
{
|
||||
u16_t handle;
|
||||
int err;
|
||||
|
||||
handle = CONFIG_BT_TMP_MAX;
|
||||
while (handle--) {
|
||||
ull_tmp_disable(handle);
|
||||
}
|
||||
|
||||
/* Re-initialize the Tx mfifo */
|
||||
MFIFO_INIT(tmp_tx);
|
||||
|
||||
err = _init_reset();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u16_t ull_tmp_handle_get(struct lll_tmp *tmp)
|
||||
{
|
||||
return ((u8_t *)CONTAINER_OF(tmp, struct tmp, lll) -
|
||||
(u8_t *)&tmp_inst[0]) / sizeof(struct tmp);
|
||||
|
||||
}
|
||||
|
||||
int ull_tmp_enable(u16_t handle)
|
||||
{
|
||||
u32_t tmp_ticker_anchor;
|
||||
u8_t tmp_ticker_id;
|
||||
struct tmp *inst;
|
||||
int ret;
|
||||
|
||||
if (handle >= CONFIG_BT_TMP_MAX) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
inst = &tmp_inst[handle];
|
||||
if (inst->ull.is_enabled) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
ull_hdr_init(&inst->ull.hdr);
|
||||
lll_hdr_init(&inst->lll, inst);
|
||||
|
||||
if (!inst->lll.link_free) {
|
||||
inst->lll.link_free = &inst->lll._link;
|
||||
}
|
||||
|
||||
memq_init(inst->lll.link_free, &inst->lll.memq_tx.head,
|
||||
&inst->lll.memq_tx.tail);
|
||||
|
||||
tmp_ticker_id = TICKER_ID_TMP_BASE + handle;
|
||||
tmp_ticker_anchor = ticker_ticks_now_get();
|
||||
|
||||
ret = ticker_start(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_THREAD,
|
||||
tmp_ticker_id,
|
||||
tmp_ticker_anchor,
|
||||
0,
|
||||
TMP_TICKER_TICKS_PERIOD,
|
||||
TICKER_NULL_REMAINDER,
|
||||
TICKER_NULL_LAZY,
|
||||
TMP_TICKER_TICKS_SLOT,
|
||||
_ticker_cb, inst,
|
||||
NULL, NULL);
|
||||
if (ret) {
|
||||
goto enable_cleanup;
|
||||
}
|
||||
|
||||
inst->lll.link_free = NULL;
|
||||
inst->ull.is_enabled = 1;
|
||||
|
||||
enable_cleanup:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ull_tmp_disable(u16_t handle)
|
||||
{
|
||||
u8_t tmp_ticker_id;
|
||||
struct tmp *inst;
|
||||
int ret;
|
||||
|
||||
if (handle >= CONFIG_BT_TMP_MAX) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
inst = &tmp_inst[handle];
|
||||
if (!inst->ull.is_enabled) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
tmp_ticker_id = TICKER_ID_TMP_BASE + handle;
|
||||
|
||||
ret = ticker_stop(TICKER_INSTANCE_ID_CTLR, TICKER_USER_ID_THREAD,
|
||||
tmp_ticker_id,
|
||||
NULL, NULL);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = ull_disable(&inst->lll);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
inst->ull.is_enabled = 0;
|
||||
inst->lll.link_free = memq_deinit(&inst->lll.memq_tx.head,
|
||||
&inst->lll.memq_tx.tail);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ull_tmp_data_send(u16_t handle, u8_t size, u8_t *data)
|
||||
{
|
||||
struct lll_tx *tx;
|
||||
struct node_tx *node_tx;
|
||||
struct tmp *inst;
|
||||
u8_t idx;
|
||||
|
||||
if (handle >= CONFIG_BT_TMP_MAX) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
inst = &tmp_inst[handle];
|
||||
if (!inst->ull.is_enabled) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (size > CONFIG_BT_TMP_TX_SIZE_MAX) {
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
idx = MFIFO_ENQUEUE_GET(tmp_tx, (void **) &tx);
|
||||
if (!tx) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
tx->node = mem_acquire(&mem_tmp_tx.free);
|
||||
if (!tx->node) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
tx->handle = handle;
|
||||
|
||||
node_tx = tx->node;
|
||||
memcpy(node_tx->pdu, data, size);
|
||||
|
||||
MFIFO_ENQUEUE(tmp_tx, idx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ull_tmp_link_tx_release(memq_link_t *link)
|
||||
{
|
||||
mem_release(link, &mem_link_tx.free);
|
||||
}
|
||||
|
||||
static int _init_reset(void)
|
||||
{
|
||||
/* Initialize tx pool. */
|
||||
mem_init(mem_tmp_tx.pool, CONFIG_BT_TMP_TX_SIZE_MAX,
|
||||
CONFIG_BT_TMP_TX_COUNT_MAX, &mem_tmp_tx.free);
|
||||
|
||||
/* Initialize tx link pool. */
|
||||
mem_init(mem_link_tx.pool, sizeof(memq_link_t),
|
||||
CONFIG_BT_TMP_TX_COUNT_MAX, &mem_link_tx.free);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _ticker_cb(u32_t ticks_at_expire, u32_t remainder,
|
||||
u16_t lazy, void *param)
|
||||
{
|
||||
static memq_link_t _link;
|
||||
static struct mayfly _mfy = {0, 0, &_link, NULL, lll_tmp_prepare};
|
||||
static struct lll_prepare_param p;
|
||||
struct tmp *inst = param;
|
||||
u32_t ret;
|
||||
u8_t ref;
|
||||
|
||||
printk("\t_ticker_cb (%p) enter: %u, %u, %u.\n", param,
|
||||
ticks_at_expire, remainder, lazy);
|
||||
DEBUG_RADIO_PREPARE_A(1);
|
||||
|
||||
/* Increment prepare reference count */
|
||||
ref = ull_ref_inc(&inst->ull.hdr);
|
||||
LL_ASSERT(ref);
|
||||
|
||||
/* Append timing parameters */
|
||||
p.ticks_at_expire = ticks_at_expire;
|
||||
p.remainder = remainder;
|
||||
p.lazy = lazy;
|
||||
p.param = &inst->lll;
|
||||
_mfy.param = &p;
|
||||
|
||||
ret = mayfly_enqueue(TICKER_USER_ID_ULL_HIGH, TICKER_USER_ID_LLL,
|
||||
0, &_mfy);
|
||||
LL_ASSERT(!ret);
|
||||
|
||||
/* De-mux tx FIFO */
|
||||
_tx_demux();
|
||||
|
||||
DEBUG_RADIO_PREPARE_A(1);
|
||||
printk("\t_ticker_cb (%p) exit.\n", param);
|
||||
}
|
||||
|
||||
static void _tx_demux(void)
|
||||
{
|
||||
struct lll_tx *tx;
|
||||
|
||||
tx = MFIFO_DEQUEUE_GET(tmp_tx);
|
||||
while (tx) {
|
||||
memq_link_t *link;
|
||||
struct tmp *inst;
|
||||
|
||||
inst = &tmp_inst[tx->handle];
|
||||
|
||||
printk("\t_ticker_cb (%p) tx_demux (%p): h = 0x%x, n=%p.\n",
|
||||
inst, tx, tx->handle, tx->node);
|
||||
|
||||
link = mem_acquire(&mem_link_tx.free);
|
||||
LL_ASSERT(link);
|
||||
|
||||
memq_enqueue(link, tx->node, &inst->lll.memq_tx.tail);
|
||||
|
||||
MFIFO_DEQUEUE(tmp_tx);
|
||||
|
||||
tx = MFIFO_DEQUEUE_GET(tmp_tx);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2019 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
int ull_tmp_enable(u16_t handle);
|
||||
int ull_tmp_disable(u16_t handle);
|
||||
|
||||
int ull_tmp_data_send(u16_t handle, u8_t size, u8_t *data);
|
|
@ -1,9 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2019 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
int ull_tmp_init(void);
|
||||
int ull_tmp_reset(void);
|
||||
void ull_tmp_link_tx_release(memq_link_t *link);
|
|
@ -1417,11 +1417,6 @@ SHELL_CREATE_STATIC_SUBCMD_SET(bt_cmds) {
|
|||
#endif /* CONFIG_BT_CTLR_ADV_EXT */
|
||||
#if defined(CONFIG_BT_LL_SW_SPLIT)
|
||||
SHELL_CMD(ull_reset, NULL, HELP_NONE, cmd_ull_reset),
|
||||
#if defined(CONFIG_BT_TMP)
|
||||
SHELL_CMD(ull_tmp_enable, NULL, "<on off> [handle]",
|
||||
cmd_ull_tmp_enable),
|
||||
SHELL_CMD(ull_tmp_send, NULL, "[handle]", cmd_ull_tmp_send),
|
||||
#endif /* CONFIG_BT_TMP */
|
||||
#endif /* CONFIG_BT_LL_SW_SPLIT */
|
||||
SHELL_SUBCMD_SET_END
|
||||
};
|
||||
|
|
|
@ -351,58 +351,4 @@ int cmd_ull_reset(const struct shell *shell, size_t argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_TMP)
|
||||
#include "../controller/ll_sw/ull_tmp.h"
|
||||
|
||||
int cmd_ull_tmp_enable(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
u16_t handle = 0;
|
||||
int enable;
|
||||
int err;
|
||||
|
||||
if (argc < 2) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
if (!strcmp(argv[1], "on")) {
|
||||
enable = 1;
|
||||
} else if (!strcmp(argv[1], "off")) {
|
||||
enable = 0;
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
handle = strtoul(argv[2], NULL, 16);
|
||||
}
|
||||
|
||||
if (enable) {
|
||||
err = ull_tmp_enable(handle);
|
||||
} else {
|
||||
err = ull_tmp_disable(handle);
|
||||
}
|
||||
|
||||
shell_print(shell, "Done (%d).", err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int cmd_ull_tmp_send(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
u16_t handle = 0;
|
||||
int err;
|
||||
|
||||
if (argc > 1) {
|
||||
handle = strtoul(argv[1], NULL, 16);
|
||||
}
|
||||
|
||||
err = ull_tmp_data_send(handle, 0, NULL);
|
||||
|
||||
shell_print(shell, "Done (%d).", err);
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_BT_TMP */
|
||||
#endif /* CONFIG_BT_LL_SW_SPLIT */
|
||||
|
|
|
@ -23,6 +23,4 @@ int cmd_test_rx(const struct shell *shell, size_t argc, char *argv[]);
|
|||
int cmd_test_end(const struct shell *shell, size_t argc, char *argv[]);
|
||||
|
||||
int cmd_ull_reset(const struct shell *shell, size_t argc, char *argv[]);
|
||||
int cmd_ull_tmp_enable(const struct shell *shell, size_t argc, char *argv[]);
|
||||
int cmd_ull_tmp_send(const struct shell *shell, size_t argc, char *argv[]);
|
||||
#endif /* __LL_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue