Skip to content

Commit 6dbc446

Browse files
erbr-otfabiobaltieri
authored andcommitted
Bluetooth: controller: use RX node piggy-back for NTF when possible
When possible re-use the already allocated RX node for notifications. Store (retain) RX node and Link element on RX if NTF could occur. Pass link element to LLCP (ull_cp_rx()) together with RX node. New RX node type RETAIN introduced to signal retention When no RX node is available allocate one and hold off TX on procedures until such time that a node is available for NTF. In case waiting for NTF buffer avail is needed, allocate and store TX node to use for TX once NTF becomes available. CIS Established (incl. timeout handling) is now handled entirely as a specific event driven by ull_conn_iso - ie removal of procedure check of cis->established and cis->expire, as this is doubling mechanism in the conn_iso context. Unit test and helpers updated to handle new node type. Function ull_cp_release_ntf() was used only in unit test, so moved to helper context. Updating release_ntf to handle the fact that with piggy-backing in test context the node used for NTF can be from two different memory pools Signed-off-by: Erik Brockhoff <[email protected]>
1 parent 80426dd commit 6dbc446

File tree

26 files changed

+858
-822
lines changed

26 files changed

+858
-822
lines changed

subsys/bluetooth/controller/ll_sw/lll.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ enum node_rx_type {
316316
NODE_RX_TYPE_DTM_IQ_SAMPLE_REPORT,
317317
NODE_RX_TYPE_IQ_SAMPLE_REPORT_ULL_RELEASE,
318318
NODE_RX_TYPE_IQ_SAMPLE_REPORT_LLL_RELEASE,
319+
/* Signals retention (ie non-release) of rx node */
320+
NODE_RX_TYPE_RETAIN,
319321

320322
#if defined(CONFIG_BT_CTLR_USER_EXT)
321323
/* No entries shall be added after the NODE_RX_TYPE_USER_START/END */

subsys/bluetooth/controller/ll_sw/ull.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2829,7 +2829,8 @@ static inline int rx_demux_rx(memq_link_t *link, struct node_rx_hdr *rx)
28292829

28302830
(void)memq_dequeue(memq_ull_rx.tail, &memq_ull_rx.head, NULL);
28312831

2832-
if (rx) {
2832+
/* Only schedule node if not marked as retain by LLCP */
2833+
if (rx && rx->type != NODE_RX_TYPE_RETAIN) {
28332834
ll_rx_put_sched(link, rx);
28342835
}
28352836
}

subsys/bluetooth/controller/ll_sw/ull_conn.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,7 @@ int ull_conn_rx(memq_link_t *link, struct node_rx_pdu **rx)
11441144
#endif /* CONFIG_BT_CTLR_RX_ENQUEUE_HOLD */
11451145

11461146
#if !defined(CONFIG_BT_LL_SW_LLCP_LEGACY)
1147+
/* Handle possibly pending NTF/complete */
11471148
ull_cp_tx_ntf(conn);
11481149
#endif /* CONFIG_BT_LL_SW_LLCP_LEGACY */
11491150

@@ -1158,13 +1159,13 @@ int ull_conn_rx(memq_link_t *link, struct node_rx_pdu **rx)
11581159
nack = ctrl_rx(link, rx, pdu_rx, conn);
11591160
return nack;
11601161
#else /* CONFIG_BT_LL_SW_LLCP_LEGACY */
1161-
ARG_UNUSED(link);
11621162
ARG_UNUSED(pdu_rx);
11631163

1164-
ull_cp_rx(conn, *rx);
1165-
11661164
/* Mark buffer for release */
11671165
(*rx)->hdr.type = NODE_RX_TYPE_RELEASE;
1166+
1167+
ull_cp_rx(conn, link, *rx);
1168+
11681169
return 0;
11691170
#endif /* CONFIG_BT_LL_SW_LLCP_LEGACY */
11701171
}
@@ -1555,6 +1556,7 @@ void ull_conn_done(struct node_rx_event_done *done)
15551556
#endif /* CONFIG_BT_CTLR_RX_ENQUEUE_HOLD */
15561557

15571558
#if !defined(CONFIG_BT_LL_SW_LLCP_LEGACY)
1559+
/* Handle possibly pending NTF/complete */
15581560
ull_cp_tx_ntf(conn);
15591561
#endif /* CONFIG_BT_LL_SW_LLCP_LEGACY */
15601562

subsys/bluetooth/controller/ll_sw/ull_llcp.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,17 @@ void llcp_tx_resume_data(struct ll_conn *conn, enum llcp_tx_q_pause_data_mask re
279279
}
280280
}
281281

282+
void llcp_rx_node_retain(struct proc_ctx *ctx)
283+
{
284+
LL_ASSERT(ctx->node_ref.rx);
285+
286+
/* Mark RX node to NOT release */
287+
ctx->node_ref.rx->hdr.type = NODE_RX_TYPE_RETAIN;
288+
289+
/* store link element reference to use once this node is moved up */
290+
ctx->node_ref.rx->hdr.link = ctx->node_ref.link;
291+
}
292+
282293
/*
283294
* LLCP Procedure Creation
284295
*/
@@ -296,7 +307,8 @@ static struct proc_ctx *create_procedure(enum llcp_proc proc, struct llcp_mem_po
296307
ctx->collision = 0U;
297308
ctx->done = 0U;
298309
ctx->rx_greedy = 0U;
299-
ctx->tx_ack = NULL;
310+
ctx->node_ref.rx = NULL;
311+
ctx->node_ref.tx_ack = NULL;
300312

301313
/* Clear procedure data */
302314
memset((void *)&ctx->data, 0, sizeof(ctx->data));
@@ -575,12 +587,6 @@ void ull_cp_release_tx(struct ll_conn *conn, struct node_tx *tx)
575587
tx_release(tx);
576588
}
577589

578-
void ull_cp_release_ntf(struct node_rx_pdu *ntf)
579-
{
580-
ntf->hdr.next = NULL;
581-
ll_rx_mem_release((void **)&ntf);
582-
}
583-
584590
static int prt_elapse(uint16_t *expire, uint16_t elapsed_event)
585591
{
586592
if (*expire != 0U) {
@@ -1662,13 +1668,13 @@ void ull_cp_tx_ack(struct ll_conn *conn, struct node_tx *tx)
16621668
struct proc_ctx *ctx;
16631669

16641670
ctx = llcp_lr_peek(conn);
1665-
if (ctx && ctx->tx_ack == tx) {
1671+
if (ctx && ctx->node_ref.tx_ack == tx) {
16661672
/* TX ack re. local request */
16671673
llcp_lr_tx_ack(conn, ctx, tx);
16681674
}
16691675

16701676
ctx = llcp_rr_peek(conn);
1671-
if (ctx && ctx->tx_ack == tx) {
1677+
if (ctx && ctx->node_ref.tx_ack == tx) {
16721678
/* TX ack re. remote response */
16731679
llcp_rr_tx_ack(conn, ctx, tx);
16741680
}
@@ -1691,7 +1697,7 @@ void ull_cp_tx_ntf(struct ll_conn *conn)
16911697
}
16921698
}
16931699

1694-
void ull_cp_rx(struct ll_conn *conn, struct node_rx_pdu *rx)
1700+
void ull_cp_rx(struct ll_conn *conn, memq_link_t *link, struct node_rx_pdu *rx)
16951701
{
16961702
struct proc_ctx *ctx_l;
16971703
struct proc_ctx *ctx_r;
@@ -1762,7 +1768,7 @@ void ull_cp_rx(struct ll_conn *conn, struct node_rx_pdu *rx)
17621768
*/
17631769

17641770
/* Process PDU in remote procedure */
1765-
llcp_rr_rx(conn, ctx_r, rx);
1771+
llcp_rr_rx(conn, ctx_r, link, rx);
17661772
} else if (unexpected_r) {
17671773
/* Local active procedure
17681774
* Expected local procedure PDU
@@ -1771,7 +1777,7 @@ void ull_cp_rx(struct ll_conn *conn, struct node_rx_pdu *rx)
17711777
*/
17721778

17731779
/* Process PDU in local procedure */
1774-
llcp_lr_rx(conn, ctx_l, rx);
1780+
llcp_lr_rx(conn, ctx_l, link, rx);
17751781
} else {
17761782
/* Local active procedure
17771783
* Expected local procedure PDU
@@ -1799,15 +1805,15 @@ void ull_cp_rx(struct ll_conn *conn, struct node_rx_pdu *rx)
17991805

18001806
/* Process PDU as a new remote request */
18011807
LL_ASSERT(pdu_valid);
1802-
llcp_rr_new(conn, rx, true);
1808+
llcp_rr_new(conn, link, rx, true);
18031809
} else {
18041810
/* Local active procedure
18051811
* Expected local procedure PDU
18061812
* No remote active procedure
18071813
*/
18081814

18091815
/* Process PDU in local procedure */
1810-
llcp_lr_rx(conn, ctx_l, rx);
1816+
llcp_lr_rx(conn, ctx_l, link, rx);
18111817
}
18121818
}
18131819
} else if (ctx_r) {
@@ -1816,14 +1822,14 @@ void ull_cp_rx(struct ll_conn *conn, struct node_rx_pdu *rx)
18161822
*/
18171823

18181824
/* Process PDU in remote procedure */
1819-
llcp_rr_rx(conn, ctx_r, rx);
1825+
llcp_rr_rx(conn, ctx_r, link, rx);
18201826
} else {
18211827
/* No local active procedure
18221828
* No remote active procedure
18231829
*/
18241830

18251831
/* Process PDU as a new remote request */
1826-
llcp_rr_new(conn, rx, pdu_valid);
1832+
llcp_rr_new(conn, link, rx, pdu_valid);
18271833
}
18281834
}
18291835

subsys/bluetooth/controller/ll_sw/ull_llcp.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ void ull_cp_update_tx_buffer_queue(struct ll_conn *conn);
3535
*/
3636
void ull_cp_release_tx(struct ll_conn *conn, struct node_tx *tx);
3737

38-
/**
39-
*
40-
*/
41-
void ull_cp_release_ntf(struct node_rx_pdu *ntf);
42-
4338
/**
4439
* @brief Procedure Response Timeout Check
4540
* @param elapsed_event The number of elapsed events.
@@ -68,7 +63,7 @@ void ull_cp_tx_ntf(struct ll_conn *conn);
6863
/**
6964
* @brief Handle received LL Control PDU.
7065
*/
71-
void ull_cp_rx(struct ll_conn *conn, struct node_rx_pdu *rx);
66+
void ull_cp_rx(struct ll_conn *conn, memq_link_t *link, struct node_rx_pdu *rx);
7267

7368
#if defined(CONFIG_BT_CTLR_LE_PING)
7469
/**

0 commit comments

Comments
 (0)