Skip to content

Commit ffc71f2

Browse files
committed
Bluetooth: controller: Fix missing data length update event
Fix missing generation of data length update HCI event when effective tx and rx timings change due to PHY update procedure. Fixes BT LL TS 5.1.0 test: LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI Change] Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 12365e8 commit ffc71f2

File tree

1 file changed

+79
-0
lines changed
  • subsys/bluetooth/controller/ll_sw

1 file changed

+79
-0
lines changed

subsys/bluetooth/controller/ll_sw/ctrl.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8405,6 +8405,7 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
84058405
} else if (((event_counter - conn->llcp.phy_upd_ind.instant) & 0xFFFF)
84068406
<= 0x7FFF) {
84078407
struct radio_pdu_node_rx *node_rx;
8408+
u16_t eff_tx_time, eff_rx_time;
84088409
u8_t old_tx, old_rx;
84098410

84108411
/* procedure request acked */
@@ -8413,11 +8414,52 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
84138414
/* apply new phy */
84148415
old_tx = conn->phy_tx;
84158416
old_rx = conn->phy_rx;
8417+
eff_tx_time = conn->max_tx_time;
8418+
eff_rx_time = conn->max_rx_time;
84168419
if (conn->llcp.phy_upd_ind.tx) {
8420+
u16_t tx_time;
8421+
84178422
conn->phy_tx = conn->llcp.phy_upd_ind.tx;
8423+
8424+
tx_time = RADIO_PKT_TIME(conn->max_tx_octets,
8425+
conn->phy_tx);
8426+
if (tx_time >=
8427+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0)) {
8428+
eff_tx_time = MIN(tx_time,
8429+
conn->default_tx_time);
8430+
#if defined(CONFIG_BT_CTLR_PHY_CODED)
8431+
eff_tx_time = MAX(eff_tx_time,
8432+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN,
8433+
conn->phy_tx));
8434+
#endif /* CONFIG_BT_CTLR_PHY_CODED */
8435+
} else {
8436+
eff_tx_time =
8437+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN,
8438+
0);
8439+
}
84188440
}
84198441
if (conn->llcp.phy_upd_ind.rx) {
8442+
u16_t rx_time;
8443+
84208444
conn->phy_rx = conn->llcp.phy_upd_ind.rx;
8445+
8446+
rx_time = RADIO_PKT_TIME(conn->max_rx_octets,
8447+
conn->phy_rx);
8448+
if (rx_time >=
8449+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0)) {
8450+
eff_rx_time = MIN(rx_time,
8451+
RADIO_PKT_TIME(LL_LENGTH_OCTETS_RX_MAX,
8452+
BIT(2)));
8453+
#if defined(CONFIG_BT_CTLR_PHY_CODED)
8454+
eff_rx_time = MAX(eff_rx_time,
8455+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN,
8456+
conn->phy_rx));
8457+
#endif /* CONFIG_BT_CTLR_PHY_CODED */
8458+
} else {
8459+
eff_rx_time =
8460+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN,
8461+
0);
8462+
}
84218463
}
84228464
conn->phy_flags = conn->phy_pref_flags;
84238465

@@ -8427,6 +8469,7 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
84278469
return;
84288470
}
84298471

8472+
/* Prepare the rx packet structure */
84308473
node_rx = packet_rx_reserve_get(2);
84318474
LL_ASSERT(node_rx);
84328475

@@ -8438,7 +8481,43 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
84388481
upd->tx = conn->phy_tx;
84398482
upd->rx = conn->phy_rx;
84408483

8484+
/* enqueue phy update structure into rx queue */
84418485
packet_rx_enqueue();
8486+
8487+
/* Update max tx and/or max rx if changed */
8488+
if ((eff_tx_time == conn->max_tx_time) &&
8489+
(eff_rx_time == conn->max_rx_time)) {
8490+
return;
8491+
}
8492+
conn->max_tx_time = eff_tx_time;
8493+
conn->max_rx_time = eff_rx_time;
8494+
8495+
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
8496+
/* Prepare the rx packet structure */
8497+
node_rx = packet_rx_reserve_get(2);
8498+
LL_ASSERT(node_rx);
8499+
node_rx->hdr.handle = conn->handle;
8500+
node_rx->hdr.type = NODE_RX_TYPE_DC_PDU;
8501+
8502+
/* prepare length rsp structure */
8503+
struct pdu_data *pdu_ctrl_rx = (void *)node_rx->pdu_data;
8504+
8505+
pdu_ctrl_rx->ll_id = PDU_DATA_LLID_CTRL;
8506+
pdu_ctrl_rx->len =
8507+
offsetof(struct pdu_data_llctrl, length_rsp) +
8508+
sizeof(struct pdu_data_llctrl_length_rsp);
8509+
pdu_ctrl_rx->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_LENGTH_RSP;
8510+
8511+
struct pdu_data_llctrl_length_req *lr =
8512+
(void *)&pdu_ctrl_rx->llctrl.length_rsp;
8513+
lr->max_rx_octets = conn->max_rx_octets;
8514+
lr->max_tx_octets = conn->max_tx_octets;
8515+
lr->max_rx_time = conn->max_rx_time;
8516+
lr->max_tx_time = conn->max_tx_time;
8517+
8518+
/* enqueue length rsp structure into rx queue */
8519+
packet_rx_enqueue();
8520+
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
84428521
}
84438522
}
84448523
#endif /* CONFIG_BT_CTLR_PHY */

0 commit comments

Comments
 (0)