Bluetooth: controller: Move LLL-to-ULL Tx Ack API to ULL

Move the LLL-to-ULL Tx Ack queue API to ULL files.

Fixes #49.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2019-04-30 14:23:39 +05:30 committed by Anas Nashif
commit 54e78b9041
5 changed files with 110 additions and 103 deletions

View file

@ -153,10 +153,5 @@ void lll_conn_isr_abort(void *param);
void lll_conn_rx_pkt_set(struct lll_conn *lll); void lll_conn_rx_pkt_set(struct lll_conn *lll);
void lll_conn_tx_pkt_set(struct lll_conn *lll, struct pdu_data *pdu_data_tx); void lll_conn_tx_pkt_set(struct lll_conn *lll, struct pdu_data *pdu_data_tx);
void lll_conn_pdu_tx_prep(struct lll_conn *lll, struct pdu_data **pdu_data_tx); void lll_conn_pdu_tx_prep(struct lll_conn *lll, struct pdu_data **pdu_data_tx);
u8_t lll_conn_ack_last_idx_get(void);
memq_link_t *lll_conn_ack_peek(u8_t *ack_last, u16_t *handle, extern void ull_conn_lll_ack_enqueue(u16_t handle, struct node_tx *tx);
struct node_tx **node_tx);
memq_link_t *lll_conn_ack_by_last_peek(u8_t last, u16_t *handle,
struct node_tx **node_tx);
void *lll_conn_ack_dequeue(void);
void lll_conn_tx_flush(void *param);

View file

@ -50,9 +50,6 @@ static u16_t trx_cnt;
static u8_t mic_state; static u8_t mic_state;
#endif /* CONFIG_BT_CTLR_LE_ENC */ #endif /* CONFIG_BT_CTLR_LE_ENC */
static MFIFO_DEFINE(conn_ack, sizeof(struct lll_tx),
CONFIG_BT_CTLR_TX_BUFFERS);
int lll_conn_init(void) int lll_conn_init(void)
{ {
int err; int err;
@ -69,8 +66,6 @@ int lll_conn_reset(void)
{ {
int err; int err;
MFIFO_INIT(conn_ack);
err = init_reset(); err = init_reset();
if (err) { if (err) {
return err; return err;
@ -302,18 +297,9 @@ lll_conn_isr_rx_exit:
#endif /* CONFIG_BT_CTLR_PROFILE_ISR */ #endif /* CONFIG_BT_CTLR_PROFILE_ISR */
if (tx_release) { if (tx_release) {
struct lll_tx *tx;
u8_t idx;
LL_ASSERT(lll->handle != 0xFFFF); LL_ASSERT(lll->handle != 0xFFFF);
idx = MFIFO_ENQUEUE_GET(conn_ack, (void **)&tx); ull_conn_lll_ack_enqueue(lll->handle, tx_release);
LL_ASSERT(tx);
tx->handle = lll->handle;
tx->node = tx_release;
MFIFO_ENQUEUE(conn_ack, idx);
is_ull_rx = 1U; is_ull_rx = 1U;
} }
@ -624,81 +610,6 @@ void lll_conn_pdu_tx_prep(struct lll_conn *lll, struct pdu_data **pdu_data_tx)
*pdu_data_tx = p; *pdu_data_tx = p;
} }
u8_t lll_conn_ack_last_idx_get(void)
{
return mfifo_conn_ack.l;
}
memq_link_t *lll_conn_ack_peek(u8_t *ack_last, u16_t *handle,
struct node_tx **node_tx)
{
struct lll_tx *tx;
tx = MFIFO_DEQUEUE_GET(conn_ack);
if (!tx) {
return NULL;
}
*ack_last = mfifo_conn_ack.l;
*handle = tx->handle;
*node_tx = tx->node;
return (*node_tx)->link;
}
memq_link_t *lll_conn_ack_by_last_peek(u8_t last, u16_t *handle,
struct node_tx **node_tx)
{
struct lll_tx *tx;
tx = mfifo_dequeue_get(mfifo_conn_ack.m, mfifo_conn_ack.s,
mfifo_conn_ack.f, last);
if (!tx) {
return NULL;
}
*handle = tx->handle;
*node_tx = tx->node;
return (*node_tx)->link;
}
void *lll_conn_ack_dequeue(void)
{
return MFIFO_DEQUEUE(conn_ack);
}
void lll_conn_tx_flush(void *param)
{
struct lll_conn *lll = param;
struct node_tx *node_tx;
memq_link_t *link;
link = memq_dequeue(lll->memq_tx.tail, &lll->memq_tx.head,
(void **)&node_tx);
while (link) {
struct pdu_data *p;
struct lll_tx *tx;
u8_t idx;
idx = MFIFO_ENQUEUE_GET(conn_ack, (void **)&tx);
LL_ASSERT(tx);
tx->handle = 0xFFFF;
tx->node = node_tx;
link->next = node_tx->next;
node_tx->link = link;
p = (void *)node_tx->pdu;
p->ll_id = PDU_DATA_LLID_RESV;
MFIFO_ENQUEUE(conn_ack, idx);
link = memq_dequeue(lll->memq_tx.tail, &lll->memq_tx.head,
(void **)&node_tx);
}
}
static int init_reset(void) static int init_reset(void)
{ {
return 0; return 0;

View file

@ -978,7 +978,7 @@ void ull_rx_put(memq_link_t *link, void *rx)
* last element index in Tx ack FIFO. * last element index in Tx ack FIFO.
*/ */
#if defined(CONFIG_BT_CONN) #if defined(CONFIG_BT_CONN)
rx_hdr->ack_last = lll_conn_ack_last_idx_get(); rx_hdr->ack_last = ull_conn_ack_last_idx_get();
#else #else
ARG_UNUSED(rx_hdr); ARG_UNUSED(rx_hdr);
#endif #endif
@ -1279,7 +1279,7 @@ static inline void rx_demux_conn_tx_ack(u8_t ack_last, u16_t handle,
do { do {
#endif /* CONFIG_BT_CTLR_LOW_LAT_ULL */ #endif /* CONFIG_BT_CTLR_LOW_LAT_ULL */
/* Dequeue node */ /* Dequeue node */
lll_conn_ack_dequeue(); ull_conn_ack_dequeue();
if (handle != 0xFFFF) { if (handle != 0xFFFF) {
struct ll_conn *conn; struct ll_conn *conn;
@ -1309,7 +1309,7 @@ static inline void rx_demux_conn_tx_ack(u8_t ack_last, u16_t handle,
ull_conn_tx_demux(1); ull_conn_tx_demux(1);
} }
link = lll_conn_ack_by_last_peek(ack_last, &handle, &node_tx); link = ull_conn_ack_by_last_peek(ack_last, &handle, &node_tx);
#if defined(CONFIG_BT_CTLR_LOW_LAT_ULL) #if defined(CONFIG_BT_CTLR_LOW_LAT_ULL)
if (!link) if (!link)
@ -1346,7 +1346,7 @@ static void rx_demux(void *param)
LL_ASSERT(rx); LL_ASSERT(rx);
#if defined(CONFIG_BT_CONN) #if defined(CONFIG_BT_CONN)
link_tx = lll_conn_ack_by_last_peek(rx->ack_last, link_tx = ull_conn_ack_by_last_peek(rx->ack_last,
&handle, &node_tx); &handle, &node_tx);
if (link_tx) { if (link_tx) {
rx_demux_conn_tx_ack(rx->ack_last, handle, rx_demux_conn_tx_ack(rx->ack_last, handle,
@ -1373,7 +1373,7 @@ static void rx_demux(void *param)
u8_t ack_last; u8_t ack_last;
u16_t handle; u16_t handle;
link = lll_conn_ack_peek(&ack_last, &handle, &node_tx); link = ull_conn_ack_peek(&ack_last, &handle, &node_tx);
if (link) { if (link) {
rx_demux_conn_tx_ack(ack_last, handle, rx_demux_conn_tx_ack(ack_last, handle,
link, node_tx); link, node_tx);

View file

@ -101,6 +101,8 @@ static void ticker_op_cb(u32_t status, void *params);
CONN_TX_CTRL_BUFFERS) CONN_TX_CTRL_BUFFERS)
static MFIFO_DEFINE(conn_tx, sizeof(struct lll_tx), CONFIG_BT_CTLR_TX_BUFFERS); static MFIFO_DEFINE(conn_tx, sizeof(struct lll_tx), CONFIG_BT_CTLR_TX_BUFFERS);
static MFIFO_DEFINE(conn_ack, sizeof(struct lll_tx), CONFIG_BT_CTLR_TX_BUFFERS);
static struct { static struct {
void *free; void *free;
@ -569,6 +571,9 @@ int ull_conn_reset(void)
/* Re-initialize the Tx mfifo */ /* Re-initialize the Tx mfifo */
MFIFO_INIT(conn_tx); MFIFO_INIT(conn_tx);
/* Re-initialize the Tx Ack mfifo */
MFIFO_INIT(conn_ack);
/* Reset the current conn update conn context pointer */ /* Reset the current conn update conn context pointer */
conn_upd_curr = NULL; conn_upd_curr = NULL;
@ -1238,6 +1243,95 @@ void ull_conn_link_tx_release(void *link)
mem_release(link, &mem_link_tx.free); mem_release(link, &mem_link_tx.free);
} }
u8_t ull_conn_ack_last_idx_get(void)
{
return mfifo_conn_ack.l;
}
memq_link_t *ull_conn_ack_peek(u8_t *ack_last, u16_t *handle,
struct node_tx **tx)
{
struct lll_tx *lll_tx;
lll_tx = MFIFO_DEQUEUE_GET(conn_ack);
if (!lll_tx) {
return NULL;
}
*ack_last = mfifo_conn_ack.l;
*handle = lll_tx->handle;
*tx = lll_tx->node;
return (*tx)->link;
}
memq_link_t *ull_conn_ack_by_last_peek(u8_t last, u16_t *handle,
struct node_tx **tx)
{
struct lll_tx *lll_tx;
lll_tx = mfifo_dequeue_get(mfifo_conn_ack.m, mfifo_conn_ack.s,
mfifo_conn_ack.f, last);
if (!lll_tx) {
return NULL;
}
*handle = lll_tx->handle;
*tx = lll_tx->node;
return (*tx)->link;
}
void *ull_conn_ack_dequeue(void)
{
return MFIFO_DEQUEUE(conn_ack);
}
void ull_conn_lll_ack_enqueue(u16_t handle, struct node_tx *tx)
{
struct lll_tx *lll_tx;
u8_t idx;
idx = MFIFO_ENQUEUE_GET(conn_ack, (void **)&lll_tx);
LL_ASSERT(lll_tx);
lll_tx->handle = handle;
lll_tx->node = tx;
MFIFO_ENQUEUE(conn_ack, idx);
}
void ull_conn_lll_tx_flush(void *param)
{
struct lll_conn *lll = param;
struct node_tx *tx;
memq_link_t *link;
link = memq_dequeue(lll->memq_tx.tail, &lll->memq_tx.head,
(void **)&tx);
while (link) {
struct pdu_data *p;
struct lll_tx *lll_tx;
u8_t idx;
idx = MFIFO_ENQUEUE_GET(conn_ack, (void **)&lll_tx);
LL_ASSERT(lll_tx);
lll_tx->handle = 0xFFFF;
lll_tx->node = tx;
link->next = tx->next;
tx->link = link;
p = (void *)tx->pdu;
p->ll_id = PDU_DATA_LLID_RESV;
MFIFO_ENQUEUE(conn_ack, idx);
link = memq_dequeue(lll->memq_tx.tail, &lll->memq_tx.head,
(void **)&tx);
}
}
void ull_conn_tx_ack(struct ll_conn *conn, memq_link_t *link, void ull_conn_tx_ack(struct ll_conn *conn, memq_link_t *link,
struct node_tx *tx) struct node_tx *tx)
{ {
@ -1331,7 +1425,7 @@ static void ticker_op_stop_cb(u32_t status, void *param)
{ {
u32_t retval; u32_t retval;
static memq_link_t link; static memq_link_t link;
static struct mayfly mfy = {0, 0, &link, NULL, lll_conn_tx_flush}; static struct mayfly mfy = {0, 0, &link, NULL, ull_conn_lll_tx_flush};
LL_ASSERT(status == TICKER_STATUS_SUCCESS); LL_ASSERT(status == TICKER_STATUS_SUCCESS);

View file

@ -38,6 +38,13 @@ void ull_conn_done(struct node_rx_event_done *done);
void ull_conn_tx_demux(u8_t count); void ull_conn_tx_demux(u8_t count);
void ull_conn_tx_lll_enqueue(struct ll_conn *conn, u8_t count); void ull_conn_tx_lll_enqueue(struct ll_conn *conn, u8_t count);
void ull_conn_link_tx_release(void *link); void ull_conn_link_tx_release(void *link);
u8_t ull_conn_ack_last_idx_get(void);
memq_link_t *ull_conn_ack_peek(u8_t *ack_last, u16_t *handle,
struct node_tx **tx);
memq_link_t *ull_conn_ack_by_last_peek(u8_t last, u16_t *handle,
struct node_tx **tx);
void *ull_conn_ack_dequeue(void);
void ull_conn_lll_tx_flush(void *param);
void ull_conn_tx_ack(struct ll_conn *conn, memq_link_t *link, void ull_conn_tx_ack(struct ll_conn *conn, memq_link_t *link,
struct node_tx *tx); struct node_tx *tx);
u8_t ull_conn_llcp_req(void *conn); u8_t ull_conn_llcp_req(void *conn);