From 16207c7605858eb6c6a4c5e22ef7f77b913efe30 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Thu, 12 Sep 2024 16:11:49 +0200 Subject: [PATCH] Bluetooth: Controller: Define a macro to validate aux offset value Define a macro to validate aux offset value as it is checked both in LLL and ULL execution contexts. Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/ll_sw/lll_scan_aux.h | 3 +++ subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c | 2 +- subsys/bluetooth/controller/ll_sw/ull_scan_aux.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/lll_scan_aux.h b/subsys/bluetooth/controller/ll_sw/lll_scan_aux.h index 6430abbd24c1f55..7d2446c227e071a 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_scan_aux.h +++ b/subsys/bluetooth/controller/ll_sw/lll_scan_aux.h @@ -4,6 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define AUX_OFFSET_IS_VALID(_offset_us, _win_size_us, _pdu_us) \ + (((_offset_us) + (_win_size_us)) >= ((_pdu_us) + (EVENT_MAFS_US))) + int lll_scan_aux_init(void); int lll_scan_aux_reset(void); void lll_scan_aux_prepare(void *param); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c index 3c4c591d228455f..657d6ddfbb5fb64 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c @@ -186,7 +186,7 @@ uint8_t lll_scan_aux_setup(struct pdu_adv *pdu, uint8_t pdu_phy, /* Skip reception if invalid aux offset */ pdu_us = PDU_AC_US(pdu->len, pdu_phy, pdu_phy_flags_rx); - if (unlikely((aux_offset_us + window_size_us) < (pdu_us + EVENT_MAFS_US))) { + if (unlikely(!AUX_OFFSET_IS_VALID(aux_offset_us, window_size_us, pdu_us))) { return 0U; } diff --git a/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c b/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c index 864a8240d35658f..4b6090175245242 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c @@ -524,7 +524,7 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_pdu *rx) /* Skip reception if invalid aux offset */ pdu_us = PDU_AC_US(pdu->len, phy, ftr->phy_flags); - if (unlikely((aux_offset_us + window_size_us) < (pdu_us + EVENT_MAFS_US))) { + if (unlikely(!AUX_OFFSET_IS_VALID(aux_offset_us, window_size_us, pdu_us))) { goto ull_scan_aux_rx_flush; }