Commit c6db3c27 authored by Andrzej Kaczmarek's avatar Andrzej Kaczmarek Committed by Carles Cufi
Browse files

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: default avatarAndrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
parent ae987f3f
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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,
+3 −6
Original line number Diff line number Diff line
@@ -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;
		}
+11 −21
Original line number Diff line number Diff line
@@ -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)
+2 −8
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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;
Loading