Skip to content

Commit 2fc54ae

Browse files
cvinayakkartben
authored andcommitted
Bluetooth: Controller: Fix nRF CCM disable on connection event abort
Fix missing nRF CCM disable on connection event abort. There can be a problem on nRF SoC for example when a S8 "encrypted" reception is aborted, and a 2M "cleartext" reception starts; slow CCM (that is not stopped as part of radio disable) will corrupt a fast received "cleartext" when the same current free rx buffer is reused in the Controller. This is not a problem when the connection being abort-ee is on a faster PHY than the abort-er. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent d2ebe9c commit 2fc54ae

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,12 @@ uint32_t radio_ccm_mic_is_valid(void)
25112511
return (NRF_CCM->MICSTATUS != 0);
25122512
}
25132513

2514+
void radio_ccm_disable(void)
2515+
{
2516+
nrf_ccm_task_trigger(NRF_CCM, NRF_CCM_TASK_STOP);
2517+
nrf_ccm_disable(NRF_CCM);
2518+
}
2519+
25142520
#if defined(CONFIG_BT_CTLR_PRIVACY)
25152521
static uint8_t MALIGN(4) _aar_scratch[3];
25162522

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ void *radio_ccm_tx_pkt_set(struct ccm *ccm, void *pkt);
179179
void *radio_ccm_iso_tx_pkt_set(struct ccm *ccm, uint8_t pdu_type, void *pkt);
180180
uint32_t radio_ccm_is_done(void);
181181
uint32_t radio_ccm_mic_is_valid(void);
182+
void radio_ccm_disable(void);
182183

183184
void radio_ar_configure(uint32_t nirk, void *irk, uint8_t flags);
184185
uint32_t radio_ar_match_get(void);

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,15 @@ static void abort_cb(struct lll_prepare_param *prepare_param, void *param)
429429
radio_isr_set(isr_done, cis_lll);
430430
radio_disable();
431431

432+
#if defined(CONFIG_BT_CTLR_LE_ENC)
433+
/* Get reference to ACL context */
434+
const struct lll_conn *conn_lll = ull_conn_lll_get(cis_lll->acl_handle);
435+
436+
if (conn_lll->enc_rx) {
437+
radio_ccm_disable();
438+
}
439+
#endif /* CONFIG_BT_CTLR_LE_ENC */
440+
432441
return;
433442
}
434443

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ void lll_conn_abort_cb(struct lll_prepare_param *prepare_param, void *param)
228228
*/
229229
radio_isr_set(isr_done, param);
230230
radio_disable();
231+
232+
#if defined(CONFIG_BT_CTLR_LE_ENC)
233+
if (lll->enc_rx) {
234+
radio_ccm_disable();
235+
}
236+
#endif /* CONFIG_BT_CTLR_LE_ENC */
237+
231238
return;
232239
}
233240

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_peripheral_iso.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,15 @@ static void abort_cb(struct lll_prepare_param *prepare_param, void *param)
445445
radio_isr_set(isr_done, cis_lll);
446446
radio_disable();
447447

448+
#if defined(CONFIG_BT_CTLR_LE_ENC)
449+
/* Get reference to ACL context */
450+
const struct lll_conn *conn_lll = ull_conn_lll_get(cis_lll->acl_handle);
451+
452+
if (conn_lll->enc_rx) {
453+
radio_ccm_disable();
454+
}
455+
#endif /* CONFIG_BT_CTLR_LE_ENC */
456+
448457
return;
449458
}
450459

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,15 @@ static void abort_cb(struct lll_prepare_param *prepare_param, void *param)
482482
if (!prepare_param) {
483483
radio_isr_set(isr_done, param);
484484
radio_disable();
485+
486+
if (IS_ENABLED(CONFIG_BT_CTLR_BROADCAST_ISO_ENC)) {
487+
const struct lll_sync_iso *lll = param;
488+
489+
if (lll->enc) {
490+
radio_ccm_disable();
491+
}
492+
}
493+
485494
return;
486495
}
487496

0 commit comments

Comments
 (0)