Bluetooth: controller: Remove redundant flags for advertising set

There's not need to mark advertising set as created by either legacy
or advertising command since this is determined by current so-called
HCI advertising mode which determines whether host uses legacy or
extended advertising commands.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This commit is contained in:
Andrzej Kaczmarek 2020-06-30 14:43:02 +02:00 committed by Carles Cufí
commit c6db3c275a
7 changed files with 27 additions and 40 deletions

View file

@ -20,7 +20,14 @@ uint8_t ll_addr_set(uint8_t addr_type, uint8_t const *const p_bdaddr);
#if defined(CONFIG_BT_CTLR_ADV_EXT)
#if defined(CONFIG_BT_HCI_RAW)
int ll_adv_cmds_set(uint8_t adv_cmds);
#endif
int ll_adv_cmds_is_ext(void);
#else
static inline int ll_adv_cmds_is_ext(void)
{
return 1;
}
#endif /* CONFIG_BT_HCI_RAW */
uint8_t ll_adv_params_set(uint8_t handle, uint16_t evt_prop, uint32_t interval,
uint8_t adv_type, uint8_t own_addr_type,
uint8_t direct_addr_type, uint8_t const *const direct_addr,

View file

@ -15,6 +15,7 @@
#include "util/memq.h"
#include "pdu.h"
#include "ll.h"
#include "lll.h"
#include "lll_adv.h"
@ -52,14 +53,10 @@ uint8_t *ll_addr_get(uint8_t addr_type, uint8_t *bdaddr)
uint8_t ll_addr_set(uint8_t addr_type, uint8_t const *const bdaddr)
{
if (IS_ENABLED(CONFIG_BT_BROADCASTER)) {
uint32_t status = ull_adv_is_enabled(0);
#if defined(CONFIG_BT_CTLR_ADV_EXT)
if ((status & (ULL_ADV_ENABLED_BITMASK_ENABLED |
ULL_ADV_ENABLED_BITMASK_EXTENDED)) ==
ULL_ADV_ENABLED_BITMASK_ENABLED) {
if (ull_adv_is_enabled(0) && !ll_adv_cmds_is_ext()) {
#else /* !CONFIG_BT_CTLR_ADV_EXT */
if (status) {
if (ull_adv_is_enabled(0)) {
#endif /* !CONFIG_BT_CTLR_ADV_EXT */
return BT_HCI_ERR_CMD_DISALLOWED;
}

View file

@ -101,6 +101,11 @@ int ll_adv_cmds_set(uint8_t adv_cmds)
return 0;
}
int ll_adv_cmds_is_ext(void)
{
return ll_adv_cmds == LL_ADV_CMDS_EXT;
}
#endif
#if defined(CONFIG_BT_CTLR_ADV_EXT)
@ -182,16 +187,11 @@ uint8_t ll_adv_params_set(uint16_t interval, uint8_t adv_type,
adv->lll.phy_p = phy_p;
}
/* Mark the adv set as created by extended advertising cmd */
adv->is_created = ULL_ADV_CREATED_BITMASK_CREATED |
ULL_ADV_CREATED_BITMASK_EXTENDED;
} else {
adv->lll.phy_p = PHY_1M;
/* Mark the adv set as created by legacy advertising cmd */
adv->is_created = ULL_ADV_CREATED_BITMASK_CREATED;
}
adv->is_created = 1;
#endif /* CONFIG_BT_CTLR_ADV_EXT */
/* remember params so that set adv/scan data and adv enable
@ -628,9 +628,7 @@ uint8_t ll_adv_enable(uint8_t enable)
if (!priv) {
uint8_t const *tx_addr;
#if defined(CONFIG_BT_CTLR_ADV_EXT)
if ((adv->is_created &
ULL_ADV_CREATED_BITMASK_EXTENDED) &&
pdu_adv->tx_addr) {
if (ll_adv_cmds_is_ext() && pdu_adv->tx_addr) {
tx_addr = ll_adv_aux_random_addr_get(adv, NULL);
} else
#endif /* CONFIG_BT_CTLR_ADV_EXT */
@ -840,7 +838,7 @@ uint8_t ll_adv_enable(uint8_t enable)
}
#if defined(CONFIG_BT_CTLR_ADV_EXT)
if (adv->is_created & ULL_ADV_CREATED_BITMASK_EXTENDED) {
if (ll_adv_cmds_is_ext()) {
struct node_rx_pdu *node_rx_adv_term;
void *link_adv_term;
@ -1307,21 +1305,13 @@ inline struct ll_adv_set *ull_adv_is_enabled_get(uint8_t handle)
return adv;
}
uint32_t ull_adv_is_enabled(uint8_t handle)
int ull_adv_is_enabled(uint8_t handle)
{
struct ll_adv_set *adv;
adv = ull_adv_is_enabled_get(handle);
if (!adv) {
return 0;
}
#if defined(CONFIG_BT_CTLR_ADV_EXT)
return ULL_ADV_ENABLED_BITMASK_ENABLED |
((uint32_t)adv->is_created << 1);
#else /* !CONFIG_BT_CTLR_ADV_EXT */
return ULL_ADV_ENABLED_BITMASK_ENABLED;
#endif /* !CONFIG_BT_CTLR_ADV_EXT */
return adv != NULL;
}
uint32_t ull_adv_filter_pol_get(uint8_t handle)

View file

@ -6,14 +6,8 @@
#define ULL_ADV_RANDOM_DELAY HAL_TICKER_US_TO_TICKS(10000)
/* Bitmask values used in is_created field of adv set */
#define ULL_ADV_CREATED_BITMASK_CREATED BIT(0)
#define ULL_ADV_CREATED_BITMASK_EXTENDED BIT(1)
/* Bitmask value returned by ull_adv_is_enabled() */
#define ULL_ADV_ENABLED_BITMASK_ENABLED BIT(0)
#define ULL_ADV_ENABLED_BITMASK_CREATED (ULL_ADV_CREATED_BITMASK_CREATED << 1)
#define ULL_ADV_ENABLED_BITMASK_EXTENDED (ULL_ADV_CREATED_BITMASK_EXTENDED << 1)
#if defined(CONFIG_BT_CTLR_ADV_SET)
#define BT_CTLR_ADV_SET CONFIG_BT_CTLR_ADV_SET
@ -34,8 +28,8 @@ uint16_t ull_adv_handle_get(struct ll_adv_set *adv);
/* Return ll_adv_set context if enabled */
struct ll_adv_set *ull_adv_is_enabled_get(uint8_t handle);
/* Return flags, for now just: enabled */
uint32_t ull_adv_is_enabled(uint8_t handle);
/* Return enabled status of a set */
int ull_adv_is_enabled(uint8_t handle);
/* Return filter policy used */
uint32_t ull_adv_filter_pol_get(uint8_t handle);

View file

@ -18,7 +18,7 @@ struct ll_adv_set {
uint32_t interval;
uint8_t rnd_addr[BDADDR_SIZE];
uint8_t sid:4;
uint8_t is_created:2;
uint8_t is_created:1;
uint16_t event_counter;
uint16_t max_events;
uint32_t ticks_remain_duration;

View file

@ -589,8 +589,7 @@ void ull_filter_adv_pdu_update(struct ll_adv_set *adv, struct pdu_adv *pdu)
} else {
pdu->tx_addr = adv->own_addr_type & 0x1;
#if defined(CONFIG_BT_CTLR_ADV_EXT)
if ((adv->is_created & ULL_ADV_CREATED_BITMASK_EXTENDED) &&
pdu->tx_addr) {
if (ll_adv_cmds_is_ext() && pdu->tx_addr) {
ll_adv_aux_random_addr_get(adv, adva);
} else
#endif /* CONFIG_BT_CTLR_ADV_EXT */

View file

@ -216,7 +216,7 @@ void ull_slave_setup(memq_link_t *link, struct node_rx_hdr *rx,
}
#if defined(CONFIG_BT_CTLR_ADV_EXT)
if (adv->is_created & ULL_ADV_CREATED_BITMASK_EXTENDED) {
if (ll_adv_cmds_is_ext()) {
/* Enqueue connection or CSA event */
ll_rx_put(link, rx);