Bluetooth: controller: llcp: fix issue re. missing ack of terminate ind

On remote terminate on central the conn clean-up would happen before ack
of terminate ind was sent to peer.
Now clean-up is 'postponed' until subsequent event.
Also now data tx is paused on rx of terminate ind to ensure no data is
tx'ed after rx of terminate ind

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
This commit is contained in:
Erik Brockhoff 2022-06-21 13:26:49 +02:00 committed by Carles Cufí
commit 8b1d50b981
4 changed files with 76 additions and 24 deletions

View file

@ -1479,32 +1479,33 @@ void ull_conn_done(struct node_rx_event_done *done)
}
#endif /* CONFIG_BT_CTLR_LE_ENC */
/* Peripheral received terminate ind or
/* Legacy LLCP:
* Peripheral received terminate ind or
* Central received ack for the transmitted terminate ind or
* Central transmitted ack for the received terminate ind or
* there has been MIC failure
* Refactored LLCP:
* reason_final is set exactly under the above conditions
*/
reason_final = conn->llcp_terminate.reason_final;
if (reason_final && (
#if defined(CONFIG_BT_PERIPHERAL)
lll->role ||
#else /* CONFIG_BT_PERIPHERAL */
0 ||
#endif /* CONFIG_BT_PERIPHERAL */
#if defined(CONFIG_BT_CENTRAL)
#if defined(CONFIG_BT_LL_SW_LLCP_LEGACY)
(((conn->llcp_terminate.req -
conn->llcp_terminate.ack) & 0xFF) ==
TERM_ACKED) ||
conn->central.terminate_ack ||
(reason_final == BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL)
#else /* CONFIG_BT_LL_SW_LLCP_LEGACY */
1
#endif /* CONFIG_BT_LL_SW_LLCP_LEGACY */
#else /* CONFIG_BT_CENTRAL */
1
#if defined(CONFIG_BT_CENTRAL)
(((conn->llcp_terminate.req -
conn->llcp_terminate.ack) & 0xFF) ==
TERM_ACKED) ||
conn->central.terminate_ack ||
(reason_final == BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL) ||
#endif /* CONFIG_BT_CENTRAL */
)) {
#if defined(CONFIG_BT_PERIPHERAL)
lll->role
#else /* CONFIG_BT_PERIPHERAL */
false
#endif /* CONFIG_BT_PERIPHERAL */
#else /* defined(CONFIG_BT_LL_SW_LLCP_LEGACY) */
true
#endif /* !defined(CONFIG_BT_LL_SW_LLCP_LEGACY) */
)) {
conn_cleanup(conn, reason_final);
return;