Skip to content

Commit 528f787

Browse files
cvinayaknashif
authored andcommitted
Bluetooth: controller: Fix handling zero length L2CAP start frame
Added a fix handling L2CAP start frame with payload length of zero which otherwise sent zero length data start PDU on air. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent db50b4e commit 528f787

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

subsys/bluetooth/controller/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,12 @@ config BT_CTLR_FAST_ENC
561561
Maximum CPU time in Radio ISR will increase if this feature is
562562
selected.
563563

564+
config BT_CTLR_LLID_DATA_START_EMPTY
565+
bool "Handle zero length L2CAP start frame"
566+
default y if BT_HCI_RAW
567+
help
568+
Handle zero length L2CAP start frame.
569+
564570
config BT_CTLR_TX_RETRY_DISABLE
565571
bool "Disable Tx Retry"
566572
help

subsys/bluetooth/controller/ll_sw/ctrl.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9202,6 +9202,26 @@ static void packet_tx_enqueue(u8_t max)
92029202
pdu_data_q_tx->handle);
92039203

92049204
if (conn->handle == pdu_data_q_tx->handle) {
9205+
if (IS_ENABLED(CONFIG_BT_CTLR_LLID_DATA_START_EMPTY)) {
9206+
struct pdu_data *p;
9207+
9208+
p = (void *)node_tx_new->pdu_data;
9209+
if ((p->ll_id == PDU_DATA_LLID_DATA_START) &&
9210+
!p->len) {
9211+
conn->start_empty = 1U;
9212+
pdu_node_tx_release(conn->handle,
9213+
node_tx_new);
9214+
goto packet_tx_enqueue_release;
9215+
} else if (p->len && conn->start_empty) {
9216+
conn->start_empty = 0U;
9217+
if (p->ll_id ==
9218+
PDU_DATA_LLID_DATA_CONTINUE) {
9219+
p->ll_id =
9220+
PDU_DATA_LLID_DATA_START;
9221+
}
9222+
}
9223+
}
9224+
92059225
if (conn->pkt_tx_data == 0) {
92069226
conn->pkt_tx_data = node_tx_new;
92079227

@@ -9229,6 +9249,7 @@ static void packet_tx_enqueue(u8_t max)
92299249
pdu_node_tx_release(pdu_data_q_tx->handle, node_tx_new);
92309250
}
92319251

9252+
packet_tx_enqueue_release:
92329253
first = _radio.packet_tx_first + 1;
92339254
if (first == _radio.packet_tx_count) {
92349255
first = 0U;

subsys/bluetooth/controller/ll_sw/ctrl_internal.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,6 @@ struct connection {
272272
} llcp_phy;
273273
#endif /* CONFIG_BT_CTLR_PHY */
274274

275-
u8_t sn:1;
276-
u8_t nesn:1;
277-
u8_t pause_rx:1;
278-
u8_t pause_tx:1;
279-
u8_t enc_rx:1;
280-
u8_t enc_tx:1;
281-
u8_t refresh:1;
282-
u8_t empty:1;
283-
284275
struct ccm ccm_rx;
285276
struct ccm ccm_tx;
286277

@@ -292,6 +283,18 @@ struct connection {
292283
u8_t packet_tx_head_len;
293284
u8_t packet_tx_head_offset;
294285

286+
u8_t sn:1;
287+
u8_t nesn:1;
288+
u8_t pause_rx:1;
289+
u8_t pause_tx:1;
290+
u8_t enc_rx:1;
291+
u8_t enc_tx:1;
292+
u8_t refresh:1;
293+
u8_t empty:1;
294+
295+
/* Detect empty L2CAP start frame */
296+
u8_t start_empty:1;
297+
295298
#if defined(CONFIG_BT_CTLR_CONN_RSSI)
296299
u8_t rssi_latest;
297300
u8_t rssi_reported;

0 commit comments

Comments
 (0)