Skip to content

Commit 701d524

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: controller: Fix memory alignment of PDU buffer reference
Align the PDU buffer reference in struct node_rx_pdu so that node rx type specific parameters, like, terminate and sync lost reason can be accessed without any memory alignment issues. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent d7d8ae7 commit 701d524

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

subsys/bluetooth/controller/ll_sw/lll.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,16 @@ struct node_rx_hdr {
290290
};
291291
};
292292

293+
/* Template node rx type with memory aligned offset to PDU buffer.
294+
* NOTE: offset to memory aligned pdu buffer location is used to reference
295+
* node rx type specific information, like, terminate or sync lost reason
296+
* from a dedicated node rx structure storage location.
297+
*/
293298
struct node_rx_pdu {
294299
struct node_rx_hdr hdr;
295-
uint8_t pdu[0];
300+
union {
301+
uint8_t pdu[0] __aligned(4);
302+
};
296303
};
297304

298305
enum {

subsys/bluetooth/controller/ll_sw/ull_conn_types.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,17 @@ struct ll_conn {
159159
uint8_t ack;
160160
uint8_t reason_own;
161161
uint8_t reason_peer;
162+
/* node rx type with memory aligned storage for terminate
163+
* reason.
164+
* HCI will reference the value using the pdu member of
165+
* struct node_rx_pdu.
166+
*/
162167
struct {
163168
struct node_rx_hdr hdr;
164-
uint8_t reason;
169+
union {
170+
uint8_t pdu[0] __aligned(4);
171+
uint8_t reason;
172+
};
165173
} node_rx;
166174
} llcp_terminate;
167175

subsys/bluetooth/controller/ll_sw/ull_sync_types.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@ struct ll_sync_set {
1818
uint16_t volatile timeout_reload; /* Non-zero when sync established */
1919
uint16_t timeout_expire;
2020

21+
/* node rx type with memory aligned storage for sync lost reason.
22+
* HCI will reference the value using the pdu member of
23+
* struct node_rx_pdu.
24+
*/
2125
struct {
2226
struct node_rx_hdr hdr;
23-
uint8_t reason;
27+
union {
28+
uint8_t pdu[0] __aligned(4);
29+
uint8_t reason;
30+
};
2431
} node_rx_lost;
2532
};
2633

0 commit comments

Comments
 (0)