Skip to content
Permalink
Browse files

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>
  • Loading branch information...
cvinayak authored and nashif committed Apr 30, 2019
1 parent 23269d9 commit 54e78b9041fdc6da10baeb32c1ab0e34768173b1
@@ -153,10 +153,5 @@ void lll_conn_isr_abort(void *param);
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_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,
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);

extern void ull_conn_lll_ack_enqueue(u16_t handle, struct node_tx *tx);
@@ -50,9 +50,6 @@ static u16_t trx_cnt;
static u8_t mic_state;
#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 err;
@@ -69,8 +66,6 @@ int lll_conn_reset(void)
{
int err;

MFIFO_INIT(conn_ack);

err = init_reset();
if (err) {
return err;
@@ -302,18 +297,9 @@ void lll_conn_isr_rx(void *param)
#endif /* CONFIG_BT_CTLR_PROFILE_ISR */

if (tx_release) {
struct lll_tx *tx;
u8_t idx;

LL_ASSERT(lll->handle != 0xFFFF);

idx = MFIFO_ENQUEUE_GET(conn_ack, (void **)&tx);
LL_ASSERT(tx);

tx->handle = lll->handle;
tx->node = tx_release;

MFIFO_ENQUEUE(conn_ack, idx);
ull_conn_lll_ack_enqueue(lll->handle, tx_release);

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;
}

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)
{
return 0;
@@ -978,7 +978,7 @@ void ull_rx_put(memq_link_t *link, void *rx)
* last element index in Tx ack FIFO.
*/
#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
ARG_UNUSED(rx_hdr);
#endif
@@ -1279,7 +1279,7 @@ static inline void rx_demux_conn_tx_ack(u8_t ack_last, u16_t handle,
do {
#endif /* CONFIG_BT_CTLR_LOW_LAT_ULL */
/* Dequeue node */
lll_conn_ack_dequeue();
ull_conn_ack_dequeue();

if (handle != 0xFFFF) {
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);
}

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 (!link)
@@ -1346,7 +1346,7 @@ static void rx_demux(void *param)
LL_ASSERT(rx);

#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);
if (link_tx) {
rx_demux_conn_tx_ack(rx->ack_last, handle,
@@ -1373,7 +1373,7 @@ static void rx_demux(void *param)
u8_t ack_last;
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) {
rx_demux_conn_tx_ack(ack_last, handle,
link, node_tx);
@@ -101,6 +101,8 @@ static void ticker_op_cb(u32_t status, void *params);
CONN_TX_CTRL_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 {
void *free;
@@ -569,6 +571,9 @@ int ull_conn_reset(void)
/* Re-initialize the Tx mfifo */
MFIFO_INIT(conn_tx);

/* Re-initialize the Tx Ack mfifo */
MFIFO_INIT(conn_ack);

/* Reset the current conn update conn context pointer */
conn_upd_curr = NULL;

@@ -1238,6 +1243,95 @@ void ull_conn_link_tx_release(void *link)
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,
struct node_tx *tx)
{
@@ -1331,7 +1425,7 @@ static void ticker_op_stop_cb(u32_t status, void *param)
{
u32_t retval;
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);

@@ -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_lll_enqueue(struct ll_conn *conn, u8_t count);
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,
struct node_tx *tx);
u8_t ull_conn_llcp_req(void *conn);

0 comments on commit 54e78b9

Please sign in to comment.
You can’t perform that action at this time.