Skip to content

Commit d011dd1

Browse files
cvinayakdanieldegrasse
authored andcommitted
Bluetooth: Controller: nRF53x: Fix up ISO Rx Buffer size
Fix up the bus fault by not violating the MAXPACKETSIZE value range of NRF_CCM h/w peripheral. Fix up relates to commit 9201179 ("Bluetooth: Controller: nRF53x: Fix NRF_CCM MAXPACKETSIZE value"). Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent e420d44 commit d011dd1

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,16 +2214,11 @@ static void *radio_ccm_ext_rx_pkt_set(struct ccm *cnf, uint8_t phy, uint8_t pdu_
22142214
!defined(CONFIG_SOC_COMPATIBLE_NRF54LX) && \
22152215
(!defined(CONFIG_BT_CTLR_DATA_LENGTH_MAX) || \
22162216
(CONFIG_BT_CTLR_DATA_LENGTH_MAX < ((HAL_RADIO_PDU_LEN_MAX) - 4U)))
2217-
2218-
#define NRF_CCM_WORKAROUND_XXXX_MAXPACKETSIZE_EXTRA 1U
2219-
22202217
const uint8_t max_len = (NRF_RADIO->PCNF1 & RADIO_PCNF1_MAXLEN_Msk) >>
22212218
RADIO_PCNF1_MAXLEN_Pos;
22222219

22232220
/* MAXPACKETSIZE value 0x001B (27) - 0x00FB (251) bytes */
2224-
NRF_CCM->MAXPACKETSIZE =
2225-
MAX(MIN((max_len - 4U + NRF_CCM_WORKAROUND_XXXX_MAXPACKETSIZE_EXTRA), 0x00FB),
2226-
0x001B);
2221+
NRF_CCM->MAXPACKETSIZE = CLAMP((max_len - PDU_MIC_SIZE), 0x001B, 0x00FB);
22272222
#endif
22282223

22292224
#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)
@@ -2402,7 +2397,7 @@ static void *radio_ccm_ext_tx_pkt_set(struct ccm *cnf, uint8_t pdu_type, void *p
24022397
RADIO_PCNF1_MAXLEN_Pos;
24032398

24042399
/* MAXPACKETSIZE value 0x001B (27) - 0x00FB (251) bytes */
2405-
NRF_CCM->MAXPACKETSIZE = max_len - 4U;
2400+
NRF_CCM->MAXPACKETSIZE = CLAMP((max_len - PDU_MIC_SIZE), 0x001B, 0x00FB);
24062401
#endif
24072402

24082403
#if defined(CONFIG_SOC_COMPATIBLE_NRF54LX)

subsys/bluetooth/controller/ll_sw/nordic/lll/pdu_vendor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#define OCTET3_LEN 1U
1111
#endif /* !CONFIG_BT_CTLR_DATA_LENGTH_CLEAR */
1212

13+
/* Minimum vendor specific Rx payload buffer allocation */
14+
#define LL_VND_OCTETS_RX_MIN 27
15+
1316
/* Presence of vendor Data PDU struct octet3 */
1417
struct pdu_data_vnd_octet3 {
1518
union {

subsys/bluetooth/controller/ll_sw/openisa/lll/pdu_vendor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
/* Minimum vendor specific Rx payload buffer allocation */
8+
#define LL_VND_OCTETS_RX_MIN 0
9+
710
/* No vendor Data PDU struct octet3 */
811
struct pdu_data_vnd_octet3 {
912
union {

subsys/bluetooth/controller/ll_sw/ull_iso.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include <stddef.h>
88

9-
#include <soc.h>
109
#include <zephyr/kernel.h>
1110
#include <zephyr/sys/byteorder.h>
1211
#include <zephyr/bluetooth/hci_types.h>
@@ -119,8 +118,15 @@ static void ticker_resume_cb(uint32_t ticks_at_expire, uint32_t ticks_drift,
119118
void *param);
120119

121120
#define NODE_RX_HEADER_SIZE (offsetof(struct node_rx_pdu, pdu))
121+
#define ISO_RX_HEADER_SIZE (offsetof(struct pdu_bis, payload))
122+
123+
/* Ensure both BIS and CIS PDU headers are of equal size */
124+
BUILD_ASSERT(ISO_RX_HEADER_SIZE == offsetof(struct pdu_cis, payload));
125+
122126
/* ISO LL conformance tests require a PDU size of maximum 251 bytes + header */
123-
#define ISO_RX_BUFFER_SIZE (2 + 251)
127+
#define ISO_RX_BUFFER_SIZE (ISO_RX_HEADER_SIZE + \
128+
MAX(MAX(LL_BIS_OCTETS_RX_MAX, LL_CIS_OCTETS_RX_MAX), \
129+
LL_VND_OCTETS_RX_MIN))
124130

125131
/* Declare the ISO rx node RXFIFO. This is a composite pool-backed MFIFO for
126132
* rx_nodes. The declaration constructs the following data structures:

0 commit comments

Comments
 (0)