Skip to content

Commit e90ba89

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: controller: Fixes to pass DLE/PHY conformance tests
Added implementation to pause data PDU transmission during PHY update procedure in order to comply to BT Spec. v5.1 Vol.6, Part B, Section 5.1.10.1 Packet transmit time restrictions. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 7b68ec8 commit e90ba89

File tree

4 files changed

+54
-13
lines changed

4 files changed

+54
-13
lines changed

subsys/bluetooth/controller/ll_sw/ull_adv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ u8_t ll_adv_enable(u8_t enable)
650650

651651
#if defined(CONFIG_BT_CTLR_PHY)
652652
conn->llcp_phy.req = conn->llcp_phy.ack = 0;
653+
conn->llcp_phy.pause_tx = 0U;
653654
conn->phy_pref_tx = ull_conn_default_phy_tx_get();
654655
conn->phy_pref_rx = ull_conn_default_phy_rx_get();
655656
conn->phy_pref_flags = 0;

subsys/bluetooth/controller/ll_sw/ull_conn.c

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,11 +1191,18 @@ void ull_conn_tx_lll_enqueue(struct ll_conn *conn, u8_t count)
11911191
struct node_tx *tx;
11921192

11931193
tx = conn->tx_head;
1194+
while (tx &&
1195+
((
11941196
#if defined(CONFIG_BT_CTLR_LE_ENC)
1195-
while (tx && (!conn->pause_tx || (tx == conn->tx_ctrl)) && count--) {
1196-
#else /* !CONFIG_BT_CTLR_LE_ENC */
1197-
while (tx && count--) {
1198-
#endif /* !CONFIG_BT_CTLR_LE_ENC */
1197+
!conn->pause_tx &&
1198+
#endif /* CONFIG_BT_CTLR_LE_ENC */
1199+
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
1200+
!conn->llcp_length.pause_tx &&
1201+
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
1202+
#if defined(CONFIG_BT_CTLR_PHY)
1203+
!conn->llcp_phy.pause_tx &&
1204+
#endif /* CONFIG_BT_CTLR_PHY */
1205+
1) || (tx == conn->tx_ctrl)) && count--) {
11991206
struct node_tx *tx_lll;
12001207
memq_link_t *link;
12011208

@@ -1412,11 +1419,15 @@ static void ctrl_tx_enqueue(struct ll_conn *conn, struct node_tx *tx)
14121419
/* data/ctrl packet is in the head */
14131420
conn->tx_head &&
14141421
#if defined(CONFIG_BT_CTLR_LE_ENC)
1415-
/* data PDU tx is not paused */
1416-
!conn->pause_tx) {
1417-
#else /* !CONFIG_BT_CTLR_LE_ENC */
1422+
!conn->pause_tx &&
1423+
#endif /* CONFIG_BT_CTLR_LE_ENC */
1424+
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
1425+
!conn->llcp_length.pause_tx &&
1426+
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
1427+
#if defined(CONFIG_BT_CTLR_PHY)
1428+
!conn->llcp_phy.pause_tx &&
1429+
#endif /* CONFIG_BT_CTLR_PHY */
14181430
1) {
1419-
#endif /* !CONFIG_BT_CTLR_LE_ENC */
14201431
/* data or ctrl may have been transmitted once, but not acked
14211432
* by peer, hence place this new ctrl after head
14221433
*/
@@ -2621,6 +2632,9 @@ static inline void event_phy_req_prep(struct ll_conn *conn)
26212632
conn->phy_pref_rx = conn->llcp_phy.rx;
26222633
conn->phy_pref_flags = conn->llcp_phy.flags;
26232634

2635+
/* pause data packet tx */
2636+
conn->llcp_phy.pause_tx = 1;
2637+
26242638
/* place the phy req packet as next in tx queue */
26252639
pdu_ctrl_tx = (void *)tx->pdu;
26262640
pdu_ctrl_tx->ll_id = PDU_DATA_LLID_CTRL;
@@ -3485,6 +3499,7 @@ static inline void reject_ind_phy_upd_recv(struct ll_conn *conn,
34853499
if (rej_ext_ind->error_code != BT_HCI_ERR_LL_PROC_COLLISION) {
34863500
/* Procedure complete */
34873501
conn->llcp_phy.ack = conn->llcp_phy.req;
3502+
conn->llcp_phy.pause_tx = 0U;
34883503

34893504
/* Reset packet timing restrictions */
34903505
conn->lll.phy_tx_time = conn->lll.phy_tx;
@@ -3703,6 +3718,11 @@ static inline int length_req_rsp_recv(struct ll_conn *conn, memq_link_t *link,
37033718

37043719
/* check if change in rx octets */
37053720
if (eff_rx_octets != conn->lll.max_rx_octets) {
3721+
/* FIXME: If we want to resize Rx Pool, decide to
3722+
* nack as required when implementing. Also,
3723+
* closing the current event may be needed.
3724+
*/
3725+
37063726
/* accept the effective tx */
37073727
conn->lll.max_tx_octets = eff_tx_octets;
37083728

@@ -3730,8 +3750,6 @@ static inline int length_req_rsp_recv(struct ll_conn *conn, memq_link_t *link,
37303750
(*rx)->hdr.link = link;
37313751
conn->llcp_rx = *rx;
37323752
*rx = NULL;
3733-
3734-
/* FIXME: Close current event */
37353753
} else {
37363754
/* Procedure complete */
37373755
conn->llcp_length.ack = conn->llcp_length.req;
@@ -3745,6 +3763,9 @@ static inline int length_req_rsp_recv(struct ll_conn *conn, memq_link_t *link,
37453763
eff_rx_time == conn->lll.max_rx_time &&
37463764
#endif /* CONFIG_BT_CTLR_PHY */
37473765
(1)) {
3766+
/* Mark for buffer for release */
3767+
(*rx)->hdr.type = NODE_RX_TYPE_DC_PDU_RELEASE;
3768+
37483769
goto send_length_resp;
37493770
}
37503771

@@ -3863,6 +3884,9 @@ static int phy_rsp_send(struct ll_conn *conn, struct node_rx_pdu *rx,
38633884
conn->llcp_phy.tx &= p->rx_phys;
38643885
conn->llcp_phy.rx &= p->tx_phys;
38653886

3887+
/* pause data packet tx */
3888+
conn->llcp_phy.pause_tx = 1;
3889+
38663890
pdu_ctrl_tx = (void *)tx->pdu;
38673891
pdu_ctrl_tx->ll_id = PDU_DATA_LLID_CTRL;
38683892
pdu_ctrl_tx->len = offsetof(struct pdu_data_llctrl, phy_rsp) +
@@ -3901,6 +3925,7 @@ static inline u8_t phy_upd_ind_recv(struct ll_conn *conn, memq_link_t *link,
39013925

39023926
/* Procedure complete */
39033927
conn->llcp_phy.ack = conn->llcp_phy.req;
3928+
conn->llcp_phy.pause_tx = 0U;
39043929
conn->procedure_expire = 0U;
39053930

39063931
/* Ignore event generation if not local cmd initiated */
@@ -3941,11 +3966,12 @@ static inline u8_t phy_upd_ind_recv(struct ll_conn *conn, memq_link_t *link,
39413966

39423967
if ((conn->llcp_phy.ack != conn->llcp_phy.req) &&
39433968
(conn->llcp_phy.state == LLCP_PHY_STATE_RSP_WAIT)) {
3944-
conn->llcp_phy.ack = conn->llcp_phy.req;
3945-
conn->llcp.phy_upd_ind.cmd = conn->llcp_phy.cmd;
3946-
39473969
/* Procedure complete, just wait for instant */
3970+
conn->llcp_phy.ack = conn->llcp_phy.req;
3971+
conn->llcp_phy.pause_tx = 0U;
39483972
conn->procedure_expire = 0U;
3973+
3974+
conn->llcp.phy_upd_ind.cmd = conn->llcp_phy.cmd;
39493975
}
39503976

39513977
conn->llcp.phy_upd_ind.tx = ind->s_to_m_phy;
@@ -4082,10 +4108,15 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx,
40824108
phys = conn->llcp_phy.tx | lll->phy_tx;
40834109
lll->phy_tx_time = phy_tx_time[phys];
40844110
}
4111+
4112+
/* resume data packet tx */
4113+
conn->llcp_phy.pause_tx = 0;
40854114
break;
40864115

40874116
case PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND:
40884117
conn->lll.phy_tx_time = conn->llcp.phy_upd_ind.tx;
4118+
/* resume data packet tx */
4119+
conn->llcp_phy.pause_tx = 0;
40894120
break;
40904121
#endif /* CONFIG_BT_CTLR_PHY */
40914122

@@ -4873,6 +4904,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
48734904

48744905
/* Procedure complete */
48754906
conn->llcp_phy.ack = conn->llcp_phy.req;
4907+
conn->llcp_phy.pause_tx = 0;
48764908

48774909
/* Reset packet timing restrictions */
48784910
lll->phy_tx_time = lll->phy_tx;
@@ -5006,6 +5038,9 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
50065038
conn->llcp_phy.tx &= p->rx_phys;
50075039
conn->llcp_phy.rx &= p->tx_phys;
50085040

5041+
/* pause data packet tx */
5042+
conn->llcp_phy.pause_tx = 1;
5043+
50095044
/* Mark for buffer for release */
50105045
(*rx)->hdr.type = NODE_RX_TYPE_DC_PDU_RELEASE;
50115046
}
@@ -5031,6 +5066,9 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
50315066
conn->llcp_phy.tx &= p->rx_phys;
50325067
conn->llcp_phy.rx &= p->tx_phys;
50335068

5069+
/* pause data packet tx */
5070+
conn->llcp_phy.pause_tx = 1;
5071+
50345072
/* Procedure timeout is stopped */
50355073
conn->procedure_expire = 0U;
50365074
}

subsys/bluetooth/controller/ll_sw/ull_conn_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ struct ll_conn {
181181
#define LLCP_PHY_STATE_UPD 3
182182
u8_t tx:3;
183183
u8_t rx:3;
184+
u8_t pause_tx:1;
184185
u8_t flags:1;
185186
u8_t cmd:1;
186187
} llcp_phy;

subsys/bluetooth/controller/ll_sw/ull_master.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ u8_t ll_create_connection(u16_t scan_interval, u16_t scan_window,
221221

222222
#if defined(CONFIG_BT_CTLR_PHY)
223223
conn->llcp_phy.req = conn->llcp_phy.ack = 0U;
224+
conn->llcp_phy.pause_tx = 0U;
224225
conn->phy_pref_tx = ull_conn_default_phy_tx_get();
225226
conn->phy_pref_rx = ull_conn_default_phy_rx_get();
226227
conn->phy_pref_flags = 0U;

0 commit comments

Comments
 (0)