Bluetooth: Controller: Use the received coding scheme when scanning
Use the received coding scheme when scanning for correctly calculating the receive chain delay and on-air PDU time. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
cee9ce6b8e
commit
6911e7e1d8
@ -281,6 +281,7 @@ struct node_rx_ftr {
|
||||
uint32_t radio_end_us;
|
||||
uint8_t rssi;
|
||||
#if defined(CONFIG_BT_CTLR_ADV_EXT) && defined(CONFIG_BT_OBSERVER)
|
||||
uint8_t phy_flags:1;
|
||||
uint8_t scan_req:1;
|
||||
uint8_t scan_rsp:1;
|
||||
#endif /* CONFIG_BT_CTLR_ADV_EXT && CONFIG_BT_OBSERVER */
|
||||
|
||||
@ -69,7 +69,8 @@ static inline bool isr_rx_scan_check(struct lll_scan *lll, uint8_t irkmatch_ok,
|
||||
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);
|
||||
uint8_t rl_idx, uint8_t rssi_ready,
|
||||
uint8_t phy_flags_rx);
|
||||
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
static inline bool isr_scan_init_check(struct lll_scan *lll,
|
||||
@ -84,7 +85,8 @@ static inline bool isr_scan_tgta_rpa_check(struct lll_scan *lll,
|
||||
bool *dir_report);
|
||||
static inline bool isr_scan_rsp_adva_matches(struct pdu_adv *srsp);
|
||||
static int isr_rx_scan_report(struct lll_scan *lll, uint8_t rssi_ready,
|
||||
uint8_t rl_idx, bool dir_report);
|
||||
uint8_t phy_flags_rx, uint8_t rl_idx,
|
||||
bool dir_report);
|
||||
|
||||
int lll_scan_init(void)
|
||||
{
|
||||
@ -607,6 +609,7 @@ static void ticker_op_start_cb(uint32_t status, void *param)
|
||||
static void isr_rx(void *param)
|
||||
{
|
||||
struct node_rx_pdu *node_rx;
|
||||
uint8_t phy_flags_rx;
|
||||
struct lll_scan *lll;
|
||||
struct pdu_adv *pdu;
|
||||
uint8_t devmatch_ok;
|
||||
@ -631,8 +634,10 @@ static void isr_rx(void *param)
|
||||
irkmatch_ok = radio_ar_has_match();
|
||||
irkmatch_id = radio_ar_match_get();
|
||||
rssi_ready = radio_rssi_is_ready();
|
||||
phy_flags_rx = radio_phy_flags_rx_get();
|
||||
} else {
|
||||
crc_ok = devmatch_ok = irkmatch_ok = rssi_ready = 0U;
|
||||
crc_ok = devmatch_ok = irkmatch_ok = rssi_ready =
|
||||
phy_flags_rx = 0U;
|
||||
devmatch_id = irkmatch_id = 0xFF;
|
||||
}
|
||||
|
||||
@ -681,7 +686,8 @@ static void isr_rx(void *param)
|
||||
int err;
|
||||
|
||||
err = isr_rx_pdu(lll, pdu, devmatch_ok, devmatch_id,
|
||||
irkmatch_ok, irkmatch_id, rl_idx, rssi_ready);
|
||||
irkmatch_ok, irkmatch_id, rl_idx, rssi_ready,
|
||||
phy_flags_rx);
|
||||
if (!err) {
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
|
||||
lll_prof_send();
|
||||
@ -1008,7 +1014,8 @@ static inline bool isr_rx_scan_check(struct lll_scan *lll, uint8_t irkmatch_ok,
|
||||
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)
|
||||
uint8_t rl_idx, uint8_t rssi_ready,
|
||||
uint8_t phy_flags_rx)
|
||||
{
|
||||
bool dir_report = false;
|
||||
|
||||
@ -1190,7 +1197,7 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx,
|
||||
radio_switch_complete_and_rx(0);
|
||||
|
||||
/* save the adv packet */
|
||||
err = isr_rx_scan_report(lll, rssi_ready,
|
||||
err = isr_rx_scan_report(lll, rssi_ready, phy_flags_rx,
|
||||
irkmatch_ok ? rl_idx : FILTER_IDX_NONE,
|
||||
false);
|
||||
if (err) {
|
||||
@ -1294,7 +1301,7 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx,
|
||||
uint32_t err;
|
||||
|
||||
/* save the scan response packet */
|
||||
err = isr_rx_scan_report(lll, rssi_ready,
|
||||
err = isr_rx_scan_report(lll, rssi_ready, phy_flags_rx,
|
||||
irkmatch_ok ? rl_idx :
|
||||
FILTER_IDX_NONE,
|
||||
dir_report);
|
||||
@ -1385,7 +1392,8 @@ static inline bool isr_scan_rsp_adva_matches(struct pdu_adv *srsp)
|
||||
}
|
||||
|
||||
static int isr_rx_scan_report(struct lll_scan *lll, uint8_t rssi_ready,
|
||||
uint8_t rl_idx, bool dir_report)
|
||||
uint8_t phy_flags_rx, uint8_t rl_idx,
|
||||
bool dir_report)
|
||||
{
|
||||
struct node_rx_pdu *node_rx;
|
||||
int err = 0;
|
||||
@ -1442,11 +1450,13 @@ static int isr_rx_scan_report(struct lll_scan *lll, uint8_t rssi_ready,
|
||||
ftr->ticks_anchor = radio_tmr_start_get();
|
||||
ftr->radio_end_us =
|
||||
radio_tmr_end_get() -
|
||||
radio_rx_chain_delay_get(lll->phy, 1);
|
||||
|
||||
ftr->aux_sched = lll_scan_aux_setup(lll,
|
||||
pdu_adv_rx,
|
||||
lll->phy);
|
||||
radio_rx_chain_delay_get(lll->phy,
|
||||
phy_flags_rx);
|
||||
ftr->phy_flags = phy_flags_rx;
|
||||
ftr->aux_sched =
|
||||
lll_scan_aux_setup(lll, pdu_adv_rx,
|
||||
lll->phy,
|
||||
phy_flags_rx);
|
||||
if (ftr->aux_sched) {
|
||||
err = -EBUSY;
|
||||
}
|
||||
|
||||
@ -56,9 +56,10 @@ static void isr_rx_lll_schedule(void *param);
|
||||
static void isr_rx(struct lll_scan *lll_scan, struct lll_scan_aux *lll_aux,
|
||||
uint8_t phy_aux);
|
||||
static int isr_rx_pdu(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
uint8_t phy_aux, uint8_t devmatch_ok,
|
||||
uint8_t devmatch_id, uint8_t irkmatch_ok,
|
||||
uint8_t irkmatch_id, uint8_t rl_idx, uint8_t rssi_ready);
|
||||
uint8_t phy_aux, uint8_t phy_aux_flags_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);
|
||||
static void isr_tx_scan_req_ull_schedule(void *param);
|
||||
static void isr_tx_scan_req_lll_schedule(void *param);
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
@ -109,7 +110,7 @@ void lll_scan_aux_prepare(void *param)
|
||||
}
|
||||
|
||||
uint8_t lll_scan_aux_setup(struct lll_scan *lll, struct pdu_adv *pdu,
|
||||
uint8_t pdu_phy)
|
||||
uint8_t pdu_phy, uint8_t pdu_phy_flags_rx)
|
||||
{
|
||||
struct pdu_adv_com_ext_adv *pri_com_hdr;
|
||||
struct pdu_adv_ext_hdr *pri_hdr;
|
||||
@ -179,7 +180,7 @@ uint8_t lll_scan_aux_setup(struct lll_scan *lll, struct pdu_adv *pdu,
|
||||
/* Calculate the minimum overhead to decide if LLL or ULL scheduling
|
||||
* to be used for auxiliary PDU reception.
|
||||
*/
|
||||
overhead_us = PKT_AC_US(pdu->len, pdu_phy);
|
||||
overhead_us = PDU_AC_US(pdu->len, pdu_phy, pdu_phy_flags_rx);
|
||||
overhead_us += lll_radio_rx_ready_delay_get(phy, 1);
|
||||
overhead_us += window_widening_us;
|
||||
overhead_us += EVENT_JITTER_US;
|
||||
@ -206,8 +207,9 @@ uint8_t lll_scan_aux_setup(struct lll_scan *lll, struct pdu_adv *pdu,
|
||||
ftr->param = lll;
|
||||
ftr->aux_ptr = aux_ptr;
|
||||
ftr->radio_end_us = radio_tmr_end_get() -
|
||||
radio_rx_chain_delay_get(pdu_phy, 1) -
|
||||
PKT_AC_US(pdu->len, pdu_phy);
|
||||
radio_rx_chain_delay_get(pdu_phy,
|
||||
pdu_phy_flags_rx) -
|
||||
PDU_AC_US(pdu->len, pdu_phy, pdu_phy_flags_rx);
|
||||
|
||||
/* Primary scanner switched to auxliary PDU scanning */
|
||||
lll->is_aux_sched = 1U;
|
||||
@ -594,6 +596,7 @@ static void isr_rx_lll_schedule(void *param)
|
||||
static void isr_rx(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
uint8_t phy_aux)
|
||||
{
|
||||
uint8_t phy_aux_flags_rx;
|
||||
uint8_t devmatch_ok;
|
||||
uint8_t devmatch_id;
|
||||
uint8_t irkmatch_ok;
|
||||
@ -617,8 +620,10 @@ static void isr_rx(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
irkmatch_ok = radio_ar_has_match();
|
||||
irkmatch_id = radio_ar_match_get();
|
||||
rssi_ready = radio_rssi_is_ready();
|
||||
phy_aux_flags_rx = radio_phy_flags_rx_get();
|
||||
} else {
|
||||
crc_ok = devmatch_ok = irkmatch_ok = rssi_ready = 0U;
|
||||
crc_ok = devmatch_ok = irkmatch_ok = rssi_ready =
|
||||
phy_aux_flags_rx = 0U;
|
||||
devmatch_id = irkmatch_id = 0xFF;
|
||||
}
|
||||
|
||||
@ -644,8 +649,9 @@ static void isr_rx(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
rl_idx = FILTER_IDX_NONE;
|
||||
#endif /* CONFIG_BT_CTLR_PRIVACY */
|
||||
|
||||
err = isr_rx_pdu(lll, lll_aux, phy_aux, devmatch_ok, devmatch_id,
|
||||
irkmatch_ok, irkmatch_ok, rl_idx, rssi_ready);
|
||||
err = isr_rx_pdu(lll, lll_aux, phy_aux, phy_aux_flags_rx, devmatch_ok,
|
||||
devmatch_id, irkmatch_ok, irkmatch_ok, rl_idx,
|
||||
rssi_ready);
|
||||
if (!err) {
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
|
||||
lll_prof_send();
|
||||
@ -679,9 +685,10 @@ isr_rx_do_close:
|
||||
}
|
||||
|
||||
static int isr_rx_pdu(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
uint8_t phy_aux, uint8_t devmatch_ok,
|
||||
uint8_t devmatch_id, uint8_t irkmatch_ok,
|
||||
uint8_t irkmatch_id, uint8_t rl_idx, uint8_t rssi_ready)
|
||||
uint8_t phy_aux, uint8_t phy_aux_flags_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)
|
||||
{
|
||||
struct node_rx_pdu *node_rx;
|
||||
struct node_rx_ftr *ftr;
|
||||
@ -821,7 +828,8 @@ static int isr_rx_pdu(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
radio_gpio_pa_setup();
|
||||
radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() +
|
||||
EVENT_IFS_US -
|
||||
radio_rx_chain_delay_get(phy_aux, 1) -
|
||||
radio_rx_chain_delay_get(phy_aux,
|
||||
phy_aux_flags_rx) -
|
||||
CONFIG_BT_CTLR_GPIO_PA_OFFSET);
|
||||
#endif /* CONFIG_BT_CTLR_GPIO_PA_PIN */
|
||||
|
||||
@ -864,7 +872,8 @@ static int isr_rx_pdu(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
ftr->param = lll;
|
||||
ftr->ticks_anchor = radio_tmr_start_get();
|
||||
ftr->radio_end_us = conn_space_us -
|
||||
radio_rx_chain_delay_get(phy_aux, 1);
|
||||
radio_rx_chain_delay_get(phy_aux,
|
||||
phy_aux_flags_rx);
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PRIVACY)
|
||||
ftr->rl_idx = irkmatch_ok ? rl_idx : FILTER_IDX_NONE;
|
||||
@ -966,7 +975,8 @@ static int isr_rx_pdu(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
radio_gpio_pa_setup();
|
||||
radio_gpio_pa_lna_enable(radio_tmr_tifs_base_get() +
|
||||
EVENT_IFS_US -
|
||||
radio_rx_chain_delay_get(phy_aux, 1) -
|
||||
radio_rx_chain_delay_get(phy_aux,
|
||||
phy_aux_flags_rx) -
|
||||
CONFIG_BT_CTLR_GPIO_PA_OFFSET);
|
||||
#endif /* CONFIG_BT_CTLR_GPIO_PA_PIN */
|
||||
|
||||
@ -988,7 +998,8 @@ static int isr_rx_pdu(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
}
|
||||
ftr->ticks_anchor = radio_tmr_start_get();
|
||||
ftr->radio_end_us = radio_tmr_end_get() -
|
||||
radio_rx_chain_delay_get(phy_aux, 1);
|
||||
radio_rx_chain_delay_get(phy_aux,
|
||||
phy_aux_flags_rx);
|
||||
ftr->rssi = (rssi_ready) ? radio_rssi_get() :
|
||||
BT_HCI_LE_RSSI_NOT_AVAILABLE;
|
||||
ftr->scan_req = 1U;
|
||||
@ -1039,7 +1050,9 @@ static int isr_rx_pdu(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
|
||||
ftr->ticks_anchor = radio_tmr_start_get();
|
||||
ftr->radio_end_us = radio_tmr_end_get() -
|
||||
radio_rx_chain_delay_get(phy_aux, 1);
|
||||
radio_rx_chain_delay_get(phy_aux,
|
||||
phy_aux_flags_rx);
|
||||
ftr->phy_flags = phy_aux_flags_rx;
|
||||
ftr->rssi = (rssi_ready) ? radio_rssi_get() :
|
||||
BT_HCI_LE_RSSI_NOT_AVAILABLE;
|
||||
ftr->scan_req = 0U;
|
||||
@ -1048,7 +1061,8 @@ static int isr_rx_pdu(struct lll_scan *lll, struct lll_scan_aux *lll_aux,
|
||||
ftr->rl_idx = irkmatch_ok ? rl_idx : FILTER_IDX_NONE;
|
||||
#endif /* CONFIG_BT_CTLR_PRIVACY */
|
||||
|
||||
ftr->aux_sched = lll_scan_aux_setup(lll, pdu, phy_aux);
|
||||
ftr->aux_sched = lll_scan_aux_setup(lll, pdu, phy_aux,
|
||||
phy_aux_flags_rx);
|
||||
|
||||
node_rx->hdr.type = NODE_RX_TYPE_EXT_AUX_REPORT;
|
||||
|
||||
|
||||
@ -14,4 +14,4 @@ void lll_scan_prepare_connect_req(struct lll_scan *lll, struct pdu_adv *pdu_tx,
|
||||
uint8_t *adv_addr, uint8_t init_tx_addr,
|
||||
uint8_t *init_addr, uint32_t *conn_space_us);
|
||||
uint8_t lll_scan_aux_setup(struct lll_scan *lll, struct pdu_adv *pdu,
|
||||
uint8_t pdu_phy);
|
||||
uint8_t pdu_phy, uint8_t pdu_phy_flags_rx);
|
||||
|
||||
@ -368,7 +368,7 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx)
|
||||
|
||||
/* Calculate the aux offset from start of the scan window */
|
||||
aux_offset_us += ftr->radio_end_us;
|
||||
aux_offset_us -= PKT_AC_US(pdu->len, phy);
|
||||
aux_offset_us -= PDU_AC_US(pdu->len, phy, ftr->phy_flags);
|
||||
aux_offset_us -= EVENT_JITTER_US;
|
||||
aux_offset_us -= ready_delay_us;
|
||||
aux_offset_us -= window_widening_us;
|
||||
|
||||
@ -454,7 +454,7 @@ void ull_sync_setup(struct ll_scan_set *scan, struct ll_scan_aux_set *aux,
|
||||
sync_offset_us += (uint32_t)si->offs * lll->window_size_event_us;
|
||||
/* offs_adjust may be 1 only if sync setup by LL_PERIODIC_SYNC_IND */
|
||||
sync_offset_us += (si->offs_adjust ? OFFS_ADJUST_US : 0U);
|
||||
sync_offset_us -= PKT_AC_US(pdu->len, lll->phy);
|
||||
sync_offset_us -= PDU_AC_US(pdu->len, lll->phy, ftr->phy_flags);
|
||||
sync_offset_us -= EVENT_TICKER_RES_MARGIN_US;
|
||||
sync_offset_us -= EVENT_JITTER_US;
|
||||
sync_offset_us -= ready_delay_us;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user