From 34451a9970988d7e1147dfba7528bf5e494ff394 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Tue, 16 Mar 2021 11:46:30 +0530 Subject: [PATCH] Bluetooth: controller: Conditional compile adv addr used by initiator Conditional compile adv_addr which is only used by controller when supporting initiator/central role. Signed-off-by: Vinayak Kariappa Chettimada --- subsys/bluetooth/controller/ll_sw/lll_adv.h | 5 ++++- subsys/bluetooth/controller/ll_sw/lll_scan.h | 14 ++++++++++---- .../controller/ll_sw/nordic/lll/lll_scan.c | 4 ++++ subsys/bluetooth/controller/ll_sw/ull_conn.c | 3 +++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/lll_adv.h b/subsys/bluetooth/controller/ll_sw/lll_adv.h index d1d94ba16b1..5baaec68561 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_adv.h +++ b/subsys/bluetooth/controller/ll_sw/lll_adv.h @@ -61,7 +61,10 @@ struct lll_adv { struct lll_hdr hdr; #if defined(CONFIG_BT_PERIPHERAL) - /* NOTE: conn context has to be after lll_hdr */ + /* NOTE: conn context SHALL be after lll_hdr, + * check ull_conn_setup how it access the connection LLL + * context. + */ struct lll_conn *conn; uint8_t is_hdcd:1; #endif /* CONFIG_BT_PERIPHERAL */ diff --git a/subsys/bluetooth/controller/ll_sw/lll_scan.h b/subsys/bluetooth/controller/ll_sw/lll_scan.h index 5085d6bb662..972d3332295 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_scan.h +++ b/subsys/bluetooth/controller/ll_sw/lll_scan.h @@ -8,8 +8,13 @@ struct lll_scan { struct lll_hdr hdr; #if defined(CONFIG_BT_CENTRAL) - /* NOTE: conn context has to be after lll_hdr */ + /* NOTE: conn context SHALL be after lll_hdr, + * check ull_conn_setup how it access the connection LLL + * context. + */ struct lll_conn *conn; + + uint8_t adv_addr[BDADDR_SIZE]; uint32_t conn_win_offset_us; uint16_t conn_timeout; #endif /* CONFIG_BT_CENTRAL */ @@ -17,9 +22,11 @@ struct lll_scan { uint8_t state:1; uint8_t chan:2; uint8_t filter_policy:2; - uint8_t adv_addr_type:1; - uint8_t init_addr_type:1; uint8_t type:1; + uint8_t init_addr_type:1; +#if defined(CONFIG_BT_CENTRAL) + uint8_t adv_addr_type:1; +#endif /* CONFIG_BT_CENTRAL */ #if defined(CONFIG_BT_CTLR_ADV_EXT) uint16_t duration_reload; @@ -35,7 +42,6 @@ struct lll_scan { #endif /* CONFIG_BT_CTLR_PRIVACY */ uint8_t init_addr[BDADDR_SIZE]; - uint8_t adv_addr[BDADDR_SIZE]; uint16_t interval; uint32_t ticks_window; diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c index 27a7df0815f..33f46bedf64 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c @@ -66,10 +66,12 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx, uint8_t devmatch_ok, uint8_t devmatch_id, uint8_t irkmatch_ok, uint8_t irkmatch_id, uint8_t rl_idx, uint8_t rssi_ready); +#if defined(CONFIG_BT_CENTRAL) static inline bool isr_scan_init_check(struct lll_scan *lll, struct pdu_adv *pdu, uint8_t rl_idx); static inline bool isr_scan_init_adva_check(struct lll_scan *lll, struct pdu_adv *pdu, uint8_t rl_idx); +#endif /* CONFIG_BT_CENTRAL */ static inline bool isr_scan_tgta_check(struct lll_scan *lll, bool init, struct pdu_adv *pdu, uint8_t rl_idx, bool *dir_report); @@ -1104,6 +1106,7 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx, return -ECANCELED; } +#if defined(CONFIG_BT_CENTRAL) static inline bool isr_scan_init_check(struct lll_scan *lll, struct pdu_adv *pdu, uint8_t rl_idx) { @@ -1133,6 +1136,7 @@ static inline bool isr_scan_init_adva_check(struct lll_scan *lll, return ((lll->adv_addr_type == pdu->tx_addr) && !memcmp(lll->adv_addr, &pdu->adv_ind.addr[0], BDADDR_SIZE)); } +#endif /* CONFIG_BT_CENTRAL */ static inline bool isr_scan_tgta_check(struct lll_scan *lll, bool init, struct pdu_adv *pdu, uint8_t rl_idx, diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn.c b/subsys/bluetooth/controller/ll_sw/ull_conn.c index a49da213819..8d464fad76d 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn.c @@ -811,6 +811,9 @@ void ull_conn_setup(memq_link_t *link, struct node_rx_hdr *rx) ftr = &(rx->rx_ftr); + /* NOTE: LLL conn context SHALL be after lll_hdr in + * struct lll_adv and struct lll_scan. + */ lll = *((struct lll_conn **)((uint8_t *)ftr->param + sizeof(struct lll_hdr))); switch (lll->role) {