Skip to content

Commit

Permalink
Bluetooth: Mesh: Move ext adv sector to vector
Browse files Browse the repository at this point in the history
Obviously, it looks obscure by putting it in a sector,
so, let's move to vector.

refs: #57883

Signed-off-by: Lingao Meng <[email protected]>
  • Loading branch information
LingaoM authored and carlescufi committed Oct 20, 2023
1 parent 1b22324 commit c2b2641
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 137 deletions.
3 changes: 0 additions & 3 deletions cmake/linker_script/common/common-ram.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ if(CONFIG_UVB)
zephyr_iterable_section(NAME uvb_node GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN 4)
endif()

if(CONFIG_BT_MESH_ADV_EXT)
zephyr_iterable_section(NAME bt_mesh_ext_adv GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN 4)
endif()

if(CONFIG_LOG)
zephyr_iterable_section(NAME log_mpsc_pbuf GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN 4)
Expand Down
4 changes: 0 additions & 4 deletions include/zephyr/linker/common-ram.ld
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
#endif
#endif /* NETWORKING */

#if defined(CONFIG_BT_MESH)
ITERABLE_SECTION_RAM(bt_mesh_ext_adv, 4)
#endif

#if defined(CONFIG_GEN_SW_ISR_TABLE) && defined(CONFIG_DYNAMIC_INTERRUPTS)
SECTION_DATA_PROLOGUE(sw_isr_table,,)
{
Expand Down
38 changes: 22 additions & 16 deletions subsys/bluetooth/mesh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,22 @@ menuconfig BT_MESH_ADV_EXT

if BT_MESH_ADV_EXT

config BT_MESH_SIMULT_ADV_SETS
int "Maximum number of parallel advertising sets that can be used by the Bluetooth Mesh stack"
config BT_MESH_RELAY_ADV_SETS
int "Maximum of simultaneous relay message support"
default 0
range 0 BT_EXT_ADV_MAX_ADV_SET
depends on BT_MESH_RELAY || BT_MESH_PB_ADV
depends on BT_MESH_RELAY
help
Maximum of simultaneous message support. Requires controller support
Maximum of simultaneous relay message support. Requires controller support
multiple advertising sets.

config BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET
bool "Use the main advertising set to relay messages"
depends on BT_MESH_SIMULT_ADV_SETS > 0
depends on BT_MESH_RELAY_ADV_SETS > 0
help
When this option is enabled, there is a message that needs to be
relayed, all relay advertising sets defined by
CONFIG_BT_MESH_SIMULT_ADV_SETS are busy with relaying messages
CONFIG_BT_MESH_RELAY_ADV_SETS are busy with relaying messages
and the main advertising set is not busy with sending local
messages, the stack will use the main advertising set to relay
the message. This maximizes the utilization efficiency of
Expand Down Expand Up @@ -192,16 +192,15 @@ config BT_MESH_UNPROV_BEACON_INT

if BT_MESH_PB_ADV

config BT_MESH_PB_ADV_RETRANS_TIMEOUT
int "Timeout value of retransmit provisioning PDUs"
default 500
range 100 800
config BT_MESH_PB_ADV_USE_RELAY_SETS
bool "Use relay advertising sets to send provisioning PDUs"
depends on BT_MESH_RELAY_ADV_SETS > 0
help
Timeout value of retransmit provisioning PDUs.
Use relay advertising sets to send provisioning PDUs

config BT_MESH_PB_ADV_TRANS_PDU_RETRANSMIT_COUNT
int "Link Open and Transaction PDU retransmit count"
default 7 if BT_MESH_SIMULT_ADV_SETS > 0
default 7 if BT_MESH_PB_ADV_USE_RELAY_SETS
default 0
range 0 7
help
Expand All @@ -210,21 +209,28 @@ config BT_MESH_PB_ADV_TRANS_PDU_RETRANSMIT_COUNT

config BT_MESH_PB_ADV_TRANS_ACK_RETRANSMIT_COUNT
int "Link Ack and Transaction Ack retransmit count"
default 0
default 2
range 0 7
help
Controls the number of retransmissions of original Link Open and Transaction Acknowledgment PDU,
Controls the number of retransmissions of original Link Ack and Transaction Acknowledgment PDU,
in addition to the first transmission.

config BT_MESH_PB_ADV_LINK_CLOSE_RETRANSMIT_COUNT
int "Link Close retransmit count"
default 7 if BT_MESH_SIMULT_ADV_SETS > 0
default 7 if BT_MESH_PB_ADV_USE_RELAY_SETS
default 2
range 0 7
help
Controls the number of retransmissions of original Link Close,
in addition to the first transmission.

config BT_MESH_PB_ADV_RETRANS_TIMEOUT
int "Timeout value of retransmit provisioning PDUs"
default 500
range 100 800
help
Timeout value of retransmit provisioning PDUs.

endif # BT_MESH_PB_ADV

if BT_CONN
Expand Down Expand Up @@ -401,7 +407,7 @@ config BT_MESH_RELAY_BUF_COUNT
of packet drops. When considering the message latency, also consider
the values of BT_MESH_RELAY_RETRANSMIT_COUNT and
BT_MESH_RELAY_RETRANSMIT_INTERVAL. A higher number of
BT_MESH_SIMULT_ADV_SETS allows the increase in the number of buffers
BT_MESH_RELAY_ADV_SETS allows the increase in the number of buffers
while maintaining the latency.

endif # BT_MESH_RELAY
Expand Down
41 changes: 21 additions & 20 deletions subsys/bluetooth/mesh/adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const uint8_t bt_mesh_adv_type[BT_MESH_ADV_TYPES] = {

static bool active_scanning;
static K_FIFO_DEFINE(bt_mesh_adv_queue);
static K_FIFO_DEFINE(bt_mesh_simult_queue);
static K_FIFO_DEFINE(bt_mesh_relay_queue);
static K_FIFO_DEFINE(bt_mesh_friend_queue);

void bt_mesh_adv_send_start(uint16_t duration, int err, struct bt_mesh_adv *adv)
Expand Down Expand Up @@ -157,7 +157,7 @@ struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type,
tag, xmit, timeout);
}

#if CONFIG_BT_MESH_SIMULT_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE
#if CONFIG_BT_MESH_RELAY_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE
static struct net_buf *process_events(struct k_poll_event *ev, int count)
{
for (; count; ev++, count--) {
Expand Down Expand Up @@ -189,7 +189,7 @@ struct net_buf *bt_mesh_adv_buf_get(k_timeout_t timeout)
#if defined(CONFIG_BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET)
K_POLL_EVENT_STATIC_INITIALIZER(K_POLL_TYPE_FIFO_DATA_AVAILABLE,
K_POLL_MODE_NOTIFY_ONLY,
&bt_mesh_simult_queue,
&bt_mesh_relay_queue,
0),
#endif /* CONFIG_BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET */
};
Expand All @@ -202,44 +202,44 @@ struct net_buf *bt_mesh_adv_buf_get(k_timeout_t timeout)
return process_events(events, ARRAY_SIZE(events));
}

struct net_buf *bt_mesh_adv_buf_get_by_tag(enum bt_mesh_adv_tags tags, k_timeout_t timeout)
struct net_buf *bt_mesh_adv_buf_get_by_tag(enum bt_mesh_adv_tag_bit tags, k_timeout_t timeout)
{
if (IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) &&
tags & BT_MESH_ADV_TAG_FRIEND_BIT) {
tags & BT_MESH_ADV_TAG_BIT_FRIEND) {
return net_buf_get(&bt_mesh_friend_queue, timeout);
}

if (tags & BT_MESH_ADV_TAG_LOCAL_BIT) {
return bt_mesh_adv_buf_get(timeout);
#if CONFIG_BT_MESH_RELAY_ADV_SETS
if (!(tags & BT_MESH_ADV_TAG_BIT_LOCAL)) {
return net_buf_get(&bt_mesh_relay_queue, timeout);
}

#if CONFIG_BT_MESH_SIMULT_ADV_SETS
return net_buf_get(&bt_mesh_simult_queue, timeout);
#endif

return bt_mesh_adv_buf_get(timeout);
}
#else /* !(CONFIG_BT_MESH_SIMULT_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) */
#else /* !(CONFIG_BT_MESH_RELAY_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) */
struct net_buf *bt_mesh_adv_buf_get(k_timeout_t timeout)
{
return net_buf_get(&bt_mesh_adv_queue, timeout);
}

struct net_buf *bt_mesh_adv_buf_get_by_tag(enum bt_mesh_adv_tags tags, k_timeout_t timeout)
struct net_buf *bt_mesh_adv_buf_get_by_tag(enum bt_mesh_adv_tag_bit tags, k_timeout_t timeout)
{
ARG_UNUSED(tags);

return bt_mesh_adv_buf_get(timeout);
}
#endif /* CONFIG_BT_MESH_SIMULT_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE */
#endif /* CONFIG_BT_MESH_RELAY_ADV_SETS || CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE */

void bt_mesh_adv_buf_get_cancel(void)
{
LOG_DBG("");

k_fifo_cancel_wait(&bt_mesh_adv_queue);

#if CONFIG_BT_MESH_SIMULT_ADV_SETS
k_fifo_cancel_wait(&bt_mesh_simult_queue);
#endif /* CONFIG_BT_MESH_SIMULT_ADV_SETS */
#if CONFIG_BT_MESH_RELAY_ADV_SETS
k_fifo_cancel_wait(&bt_mesh_relay_queue);
#endif /* CONFIG_BT_MESH_RELAY_ADV_SETS */

if (IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE)) {
k_fifo_cancel_wait(&bt_mesh_friend_queue);
Expand Down Expand Up @@ -267,11 +267,12 @@ void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
return;
}

#if CONFIG_BT_MESH_SIMULT_ADV_SETS
#if CONFIG_BT_MESH_RELAY_ADV_SETS
if (BT_MESH_ADV(buf)->tag == BT_MESH_ADV_TAG_RELAY ||
BT_MESH_ADV(buf)->tag == BT_MESH_ADV_TAG_PROV) {
net_buf_put(&bt_mesh_simult_queue, net_buf_ref(buf));
bt_mesh_adv_buf_simult_ready();
(IS_ENABLED(CONFIG_BT_MESH_PB_ADV_USE_RELAY_SETS) &&
BT_MESH_ADV(buf)->tag == BT_MESH_ADV_TAG_PROV)) {
net_buf_put(&bt_mesh_relay_queue, net_buf_ref(buf));
bt_mesh_adv_buf_relay_ready();
return;
}
#endif
Expand Down
18 changes: 9 additions & 9 deletions subsys/bluetooth/mesh/adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ enum bt_mesh_adv_tag {
BT_MESH_ADV_TAG_PROV,
};

enum bt_mesh_adv_tags {
BT_MESH_ADV_TAG_LOCAL_BIT = BIT(BT_MESH_ADV_TAG_LOCAL),
BT_MESH_ADV_TAG_RELAY_BIT = BIT(BT_MESH_ADV_TAG_RELAY),
BT_MESH_ADV_TAG_PROXY_BIT = BIT(BT_MESH_ADV_TAG_PROXY),
BT_MESH_ADV_TAG_FRIEND_BIT = BIT(BT_MESH_ADV_TAG_FRIEND),
BT_MESH_ADV_TAG_PROV_BIT = BIT(BT_MESH_ADV_TAG_PROV),
enum bt_mesh_adv_tag_bit {
BT_MESH_ADV_TAG_BIT_LOCAL = BIT(BT_MESH_ADV_TAG_LOCAL),
BT_MESH_ADV_TAG_BIT_RELAY = BIT(BT_MESH_ADV_TAG_RELAY),
BT_MESH_ADV_TAG_BIT_PROXY = BIT(BT_MESH_ADV_TAG_PROXY),
BT_MESH_ADV_TAG_BIT_FRIEND = BIT(BT_MESH_ADV_TAG_FRIEND),
BT_MESH_ADV_TAG_BIT_PROV = BIT(BT_MESH_ADV_TAG_PROV),
};

struct bt_mesh_adv {
Expand Down Expand Up @@ -66,7 +66,7 @@ void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,

struct net_buf *bt_mesh_adv_buf_get(k_timeout_t timeout);

struct net_buf *bt_mesh_adv_buf_get_by_tag(enum bt_mesh_adv_tags tags, k_timeout_t timeout);
struct net_buf *bt_mesh_adv_buf_get_by_tag(enum bt_mesh_adv_tag_bit tags, k_timeout_t timeout);

void bt_mesh_adv_gatt_update(void);

Expand All @@ -82,9 +82,9 @@ int bt_mesh_adv_enable(void);

void bt_mesh_adv_buf_local_ready(void);

void bt_mesh_adv_buf_simult_ready(void);
void bt_mesh_adv_buf_relay_ready(void);

void bt_mesh_adv_buf_terminate(struct net_buf *buf);
void bt_mesh_adv_buf_terminate(const struct net_buf *buf);

void bt_mesh_adv_buf_friend_ready(void);

Expand Down
Loading

0 comments on commit c2b2641

Please sign in to comment.