Skip to content

Commit c5f9a2d

Browse files
Andries Kruithofjhedberg
authored andcommitted
[Backport-v2.2-branch] Bluetooth: controller: legacy: DLE timing
Fixes #23482. There is a bug in calculation of time for the DLE procedure: the preamble size is incorrect for the 2M phy This is for the legacy code, see PR #23570 for the split controller Signed-off-by: Andries Kruithof <[email protected]>
1 parent 7e4bcff commit c5f9a2d

File tree

1 file changed

+31
-28
lines changed
  • subsys/bluetooth/controller/ll_sw

1 file changed

+31
-28
lines changed

subsys/bluetooth/controller/ll_sw/ctrl.c

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@
6666
#define RADIO_PKT_TIME(octets, phy) \
6767
(((phy) & BIT(2)) ? \
6868
(80 + 256 + 16 + 24 + ((((2 + (octets) + 4) * 8) + 24 + 3) * 8)) : \
69-
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1)))
69+
(((octets) + 13 + PREAMBLE_SIZE(phy)) * 8 / \
70+
BIT(((phy) & 0x03) >> 1)))
7071
#else /* !CONFIG_BT_CTLR_PHY_CODED */
7172
#define RADIO_PKT_TIME(octets, phy) \
72-
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1))
73+
(((octets) + 13 + PREAMBLE_SIZE(phy)) * 8 / BIT(((phy) & 0x03) >> 1))
7374
#endif /* !CONFIG_BT_CTLR_PHY_CODED */
7475

7576
/* Inter Frame Space */
@@ -641,7 +642,8 @@ static void common_init(void)
641642
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
642643
/* Initialize the DLE defaults */
643644
_radio.default_tx_octets = PDU_DC_PAYLOAD_SIZE_MIN;
644-
_radio.default_tx_time = RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0);
645+
_radio.default_tx_time =
646+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0));
645647
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
646648

647649
#if defined(CONFIG_BT_CTLR_PHY)
@@ -2245,8 +2247,8 @@ isr_rx_conn_pkt_ctrl_rej_dle(struct radio_pdu_node_rx *node_rx,
22452247
lr->max_rx_octets = conn->max_rx_octets;
22462248
lr->max_tx_octets = conn->max_tx_octets;
22472249
#if !defined(CONFIG_BT_CTLR_PHY)
2248-
lr->max_rx_time = RADIO_PKT_TIME(conn->max_rx_octets, 0);
2249-
lr->max_tx_time = RADIO_PKT_TIME(conn->max_tx_octets, 0);
2250+
lr->max_rx_time = RADIO_PKT_TIME(conn->max_rx_octets, BIT(0));
2251+
lr->max_tx_time = RADIO_PKT_TIME(conn->max_tx_octets, BIT(0));
22502252
#else /* CONFIG_BT_CTLR_PHY */
22512253
lr->max_rx_time = conn->max_rx_time;
22522254
lr->max_tx_time = conn->max_tx_time;
@@ -2464,7 +2466,7 @@ static inline u8_t isr_rx_conn_pkt_ctrl_dle(struct pdu_data *pdu_data_rx,
24642466
* peer max_rx_time
24652467
*/
24662468
if (lr->max_rx_time >=
2467-
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0)) {
2469+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0))) {
24682470
eff_tx_time =
24692471
MIN(lr->max_rx_time,
24702472
_radio.conn_curr->default_tx_time);
@@ -2480,7 +2482,7 @@ static inline u8_t isr_rx_conn_pkt_ctrl_dle(struct pdu_data *pdu_data_rx,
24802482
* peer max_tx_time
24812483
*/
24822484
if (lr->max_tx_time >=
2483-
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0)) {
2485+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0))) {
24842486
eff_rx_time =
24852487
MIN(lr->max_tx_time,
24862488
RADIO_PKT_TIME(LL_LENGTH_OCTETS_RX_MAX,
@@ -2610,8 +2612,8 @@ static inline u8_t isr_rx_conn_pkt_ctrl_dle(struct pdu_data *pdu_data_rx,
26102612
lr->max_tx_octets = eff_tx_octets;
26112613

26122614
#if !defined(CONFIG_BT_CTLR_PHY)
2613-
lr->max_rx_time = RADIO_PKT_TIME(eff_rx_octets, 0);
2614-
lr->max_tx_time = RADIO_PKT_TIME(eff_tx_octets, 0);
2615+
lr->max_rx_time = RADIO_PKT_TIME(eff_rx_octets, BIT(0));
2616+
lr->max_tx_time = RADIO_PKT_TIME(eff_tx_octets, BIT(0));
26152617
#else /* CONFIG_BT_CTLR_PHY */
26162618
lr->max_rx_time = eff_rx_time;
26172619
lr->max_tx_time = eff_tx_time;
@@ -4849,23 +4851,24 @@ static inline void isr_close_conn(void)
48494851
rx_time = conn->max_rx_time;
48504852
}
48514853
#else /* !CONFIG_BT_CTLR_DATA_LENGTH */
4852-
tx_time = MAX(RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0),
4854+
tx_time = MAX(RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0)),
48534855
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN,
48544856
conn->phy_tx));
4855-
rx_time = MAX(RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0),
4857+
rx_time = MAX(RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0)),
48564858
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN,
48574859
conn->phy_rx));
48584860
#endif /* !CONFIG_BT_CTLR_DATA_LENGTH */
48594861
#else /* !CONFIG_BT_CTLR_PHY */
48604862
ready_delay = (conn->role) ?
48614863
radio_rx_ready_delay_get(0, 0) :
48624864
radio_tx_ready_delay_get(0, 0);
4863-
tx_time = RADIO_PKT_TIME(conn->max_tx_octets, 0);
4865+
tx_time = RADIO_PKT_TIME(conn->max_tx_octets, BIT(0));
48644866
if (conn->evt_len_adv) {
48654867
rx_time = RADIO_PKT_TIME(conn->llcp_length.rx_octets,
4866-
0);
4868+
BIT(0));
48674869
} else {
4868-
rx_time = RADIO_PKT_TIME(conn->max_rx_octets, 0);
4870+
rx_time = RADIO_PKT_TIME(conn->max_rx_octets,
4871+
BIT(0));
48694872
}
48704873
#endif /* !CONFIG_BT_CTLR_PHY */
48714874

@@ -8428,12 +8431,12 @@ static inline int event_len_prep(struct connection *conn)
84288431
#endif /* !CONFIG_BT_CTLR_PHY */
84298432
) {
84308433
lr->max_rx_time =
8431-
RADIO_PKT_TIME(LL_LENGTH_OCTETS_RX_MAX, 0);
8434+
RADIO_PKT_TIME(LL_LENGTH_OCTETS_RX_MAX, BIT(0));
84328435
#if defined(CONFIG_BT_CTLR_PHY)
84338436
lr->max_tx_time = conn->default_tx_time;
84348437
#else /* !CONFIG_BT_CTLR_PHY */
84358438
lr->max_tx_time =
8436-
RADIO_PKT_TIME(conn->default_tx_octets, 0);
8439+
RADIO_PKT_TIME(conn->default_tx_octets, BIT(0));
84378440
#endif /* !CONFIG_BT_CTLR_PHY */
84388441

84398442
#if defined(CONFIG_BT_CTLR_PHY)
@@ -8637,8 +8640,8 @@ static inline int event_len_prep(struct connection *conn)
86378640
lr->max_rx_octets = conn->max_rx_octets;
86388641
lr->max_tx_octets = tx_octets;
86398642
#if !defined(CONFIG_BT_CTLR_PHY)
8640-
lr->max_rx_time = RADIO_PKT_TIME(conn->max_rx_octets, 0);
8641-
lr->max_tx_time = RADIO_PKT_TIME(tx_octets, 0);
8643+
lr->max_rx_time = RADIO_PKT_TIME(conn->max_rx_octets, BIT(0));
8644+
lr->max_tx_time = RADIO_PKT_TIME(tx_octets, BIT(0));
86428645
#else /* CONFIG_BT_CTLR_PHY */
86438646
lr->max_rx_time = conn->max_rx_time;
86448647
lr->max_tx_time = tx_time;
@@ -8862,7 +8865,7 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
88628865
u16_t tx_time = RADIO_PKT_TIME(conn->max_tx_octets,
88638866
conn->phy_tx);
88648867
if (tx_time >=
8865-
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0)) {
8868+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0))) {
88668869
eff_tx_time = MIN(tx_time,
88678870
conn->default_tx_time);
88688871
#if defined(CONFIG_BT_CTLR_PHY_CODED)
@@ -8873,7 +8876,7 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
88738876
} else {
88748877
eff_tx_time =
88758878
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN,
8876-
0);
8879+
BIT(0));
88778880
}
88788881
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
88798882
}
@@ -8885,7 +8888,7 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
88858888
u16_t rx_time = RADIO_PKT_TIME(conn->max_rx_octets,
88868889
conn->phy_rx);
88878890
if (rx_time >=
8888-
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0)) {
8891+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0))) {
88898892
eff_rx_time = MIN(rx_time,
88908893
RADIO_PKT_TIME(LL_LENGTH_OCTETS_RX_MAX,
88918894
BIT(2)));
@@ -8897,7 +8900,7 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
88978900
} else {
88988901
eff_rx_time =
88998902
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN,
8900-
0);
8903+
BIT(0));
89018904
}
89028905
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
89038906
}
@@ -11043,9 +11046,9 @@ static void length_resp_send(struct connection *conn,
1104311046

1104411047
#if !defined(CONFIG_BT_CTLR_PHY)
1104511048
pdu_ctrl_tx->llctrl.length_rsp.max_rx_time =
11046-
RADIO_PKT_TIME(eff_rx_octets, 0);
11049+
RADIO_PKT_TIME(eff_rx_octets, BIT(0));
1104711050
pdu_ctrl_tx->llctrl.length_rsp.max_tx_time =
11048-
RADIO_PKT_TIME(eff_tx_octets, 0);
11051+
RADIO_PKT_TIME(eff_tx_octets, BIT(0));
1104911052
#else /* CONFIG_BT_CTLR_PHY */
1105011053
pdu_ctrl_tx->llctrl.length_rsp.max_rx_time = eff_rx_time;
1105111054
pdu_ctrl_tx->llctrl.length_rsp.max_tx_time = eff_tx_time;
@@ -11536,9 +11539,9 @@ u32_t radio_adv_enable(u16_t interval, u8_t chan_map, u8_t filter_policy,
1153611539
#if defined(CONFIG_BT_CTLR_PHY)
1153711540
conn->default_tx_time = _radio.default_tx_time;
1153811541
conn->max_tx_time =
11539-
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0);
11542+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0));
1154011543
conn->max_rx_time =
11541-
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0);
11544+
RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0));
1154211545
#endif /* CONFIG_BT_CTLR_PHY */
1154311546
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
1154411547

@@ -12075,8 +12078,8 @@ u32_t radio_connect_enable(u8_t adv_addr_type, u8_t *adv_addr, u16_t interval,
1207512078

1207612079
#if defined(CONFIG_BT_CTLR_PHY)
1207712080
conn->default_tx_time = _radio.default_tx_time;
12078-
conn->max_tx_time = RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0);
12079-
conn->max_rx_time = RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, 0);
12081+
conn->max_tx_time = RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0));
12082+
conn->max_rx_time = RADIO_PKT_TIME(PDU_DC_PAYLOAD_SIZE_MIN, BIT(0));
1208012083
#endif /* CONFIG_BT_CTLR_PHY */
1208112084
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
1208212085

0 commit comments

Comments
 (0)