Skip to content

Commit 1cf1d75

Browse files
cvinayakgalak
authored andcommitted
Bluetooth: Controller: Fix Data Length Update node Rx reservations
Reserve a minimum node rx of 2 that can happen when local central initiated PHY Update reserves 2 node rx, one for PHY Update complete and another for Data Length Update complete notification. Otherwise, a peripheral only needs 1 additional node rx to generate Data Length Update complete when PHY Update completes. Relates to #36381. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent e43afd1 commit 1cf1d75

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed

subsys/bluetooth/controller/ll_sw/ull.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,20 @@ static struct {
312312
* Increasing this by times the max. simultaneous connection count will permit
313313
* simultaneous parallel PHY update or Connection Update procedures amongst
314314
* active connections.
315+
* Minimum node rx of 2 that can be reserved happens when local central
316+
* initiated PHY Update reserves 2 node rx, one for PHY update complete and
317+
* another for Data Length Update complete notification. Otherwise, a
318+
* peripheral only needs 1 additional node rx to generate Data Length Update
319+
* complete when PHY Update completes; node rx for PHY update complete is
320+
* reserved as the received PHY Update Ind PDU.
315321
*/
316-
#if defined(CONFIG_BT_CTLR_PHY) && defined(CONFIG_BT_CTLR_DATA_LENGTH)
317-
#define LL_PDU_RX_CNT 3
322+
#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_CTLR_PHY) && \
323+
defined(CONFIG_BT_CTLR_DATA_LENGTH)
324+
#define LL_PDU_RX_CNT (2 * (CONFIG_BT_CTLR_LLCP_CONN))
325+
#elif defined(CONFIG_BT_CONN)
326+
#define LL_PDU_RX_CNT (CONFIG_BT_CTLR_LLCP_CONN)
318327
#else
319-
#define LL_PDU_RX_CNT 2
328+
#define LL_PDU_RX_CNT 0
320329
#endif
321330

322331
/* No. of node rx for LLL to ULL.

subsys/bluetooth/controller/ll_sw/ull_conn.c

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4047,6 +4047,21 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn,
40474047
struct node_rx_pdu *rx;
40484048
uint8_t old_tx, old_rx;
40494049

4050+
/* Acquire additional rx node for Data length notification as
4051+
* a peripheral.
4052+
*/
4053+
if (IS_ENABLED(CONFIG_BT_PERIPHERAL) &&
4054+
IS_ENABLED(CONFIG_BT_CTLR_DATA_LENGTH) &&
4055+
conn->lll.role) {
4056+
rx = ll_pdu_rx_alloc();
4057+
if (!rx) {
4058+
return;
4059+
}
4060+
4061+
rx->hdr.link->mem = conn->llcp_rx;
4062+
conn->llcp_rx = rx;
4063+
}
4064+
40504065
#if defined(CONFIG_BT_PERIPHERAL) && defined(CONFIG_BT_CTLR_LE_ENC)
40514066
if (conn->lll.role && (conn->slave.llcp_type != LLCP_NONE)) {
40524067
/* Local peripheral initiated PHY update completed while
@@ -5457,23 +5472,27 @@ static inline uint8_t phy_upd_ind_recv(struct ll_conn *conn, memq_link_t *link,
54575472
conn->llcp.phy_upd_ind.instant = instant;
54585473
conn->llcp.phy_upd_ind.initiate = 0U;
54595474

5475+
/* Reserve the Rx-ed PHY Update Indication PDU in the connection
5476+
* context, by appending to the LLCP node rx list. We do not mark it
5477+
* for release in ULL, i.e., by returning *rx as NULL.
5478+
* PHY Update notification to HCI layer will use node rx from this
5479+
* list when at the instant.
5480+
* If data length update is supported in the Controller, then, at the
5481+
* instant we attempt to acquire an additional free node rx for Data
5482+
* Length Update notification.
5483+
*/
54605484
link->mem = conn->llcp_rx;
54615485
(*rx)->hdr.link = link;
54625486
conn->llcp_rx = *rx;
54635487
*rx = NULL;
54645488

5465-
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
5466-
/* reserve rx node for DLE event generation */
5467-
struct node_rx_pdu *rx_dle = ll_pdu_rx_alloc();
5468-
5469-
LL_ASSERT(rx_dle);
5470-
rx_dle->hdr.link->mem = conn->llcp_rx;
5471-
conn->llcp_rx = rx_dle;
5472-
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
5473-
5489+
/* Transition to PHY Update Ind received state and wait for the
5490+
* instant.
5491+
*/
54745492
conn->llcp_type = LLCP_PHY_UPD;
54755493
conn->llcp_ack -= 2U;
54765494

5495+
/* Enforce packet timing restrictions until the instant */
54775496
if (conn->llcp.phy_upd_ind.tx) {
54785497
conn->lll.phy_tx_time = conn->llcp.phy_upd_ind.tx;
54795498
}

0 commit comments

Comments
 (0)