Skip to content

Commit 0139338

Browse files
cvinayakcfriedt
authored andcommitted
Bluetooth: Controller: Update AD Data PDU allocation configurability
Update the calculation for configurable amount of shared PDUs across advertising sets. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 41bb453 commit 0139338

File tree

1 file changed

+57
-8
lines changed
  • subsys/bluetooth/controller/ll_sw/nordic/lll

1 file changed

+57
-8
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.c

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,64 @@ static inline bool isr_rx_ci_adva_check(uint8_t tx_addr, uint8_t *addr,
102102
#endif
103103

104104
#define PDU_MEM_SIZE PDU_ADV_MEM_SIZE
105-
#define PDU_MEM_COUNT_MIN (BT_CTLR_ADV_SET + \
106-
(BT_CTLR_ADV_SET * PAYLOAD_FRAG_COUNT) + \
107-
(BT_CTLR_ADV_AUX_SET * PAYLOAD_FRAG_COUNT) + \
108-
(BT_CTLR_ADV_SYNC_SET * PAYLOAD_FRAG_COUNT))
109-
#define PDU_MEM_FIFO_COUNT ((BT_CTLR_ADV_SET * PAYLOAD_FRAG_COUNT * 2) + \
110-
(CONFIG_BT_CTLR_ADV_DATA_BUF_MAX * \
105+
106+
/* AD data and Scan Response Data need 2 PDU buffers each in the double buffer
107+
* implementation. Allocate 3 PDU buffers plus CONFIG_BT_CTLR_ADV_DATA_BUF_MAX
108+
* defined buffer count as the minimum number of buffers that meet the legacy
109+
* advertising needs. Add 1 each for Extended and Periodic Advertising, needed
110+
* extra for double buffers for these is kept as configurable, by increasing
111+
* CONFIG_BT_CTLR_ADV_DATA_BUF_MAX.
112+
*/
113+
#define PDU_MEM_COUNT_MIN ((BT_CTLR_ADV_SET * 3) + \
114+
((BT_CTLR_ADV_AUX_SET + \
115+
BT_CTLR_ADV_SYNC_SET) * \
111116
PAYLOAD_FRAG_COUNT))
112-
#define PDU_MEM_COUNT (PDU_MEM_COUNT_MIN + PDU_MEM_FIFO_COUNT)
113-
#define PDU_POOL_SIZE (PDU_MEM_SIZE * PDU_MEM_COUNT)
117+
118+
/* Maximum advertising PDU buffers to allocate, which is the sum of minimum
119+
* plus configured additional count in CONFIG_BT_CTLR_ADV_DATA_BUF_MAX.
120+
*/
121+
#if defined(CONFIG_BT_CTLR_ADV_EXT)
122+
#if defined(CONFIG_BT_CTLR_ADV_PERIODIC)
123+
/* NOTE: When Periodic Advertising is supported then one additional PDU buffer
124+
* plus the additional CONFIG_BT_CTLR_ADV_DATA_BUF_MAX amount of buffers
125+
* is allocated.
126+
* Set CONFIG_BT_CTLR_ADV_DATA_BUF_MAX to (BT_CTLR_ADV_AUX_SET +
127+
* BT_CTLR_ADV_SYNC_SET) if
128+
* PDU data is updated more frequently compare to the advertising
129+
* interval with random delay included.
130+
*/
131+
#define PDU_MEM_COUNT_MAX (PDU_MEM_COUNT_MIN + \
132+
((1 + CONFIG_BT_CTLR_ADV_DATA_BUF_MAX) * \
133+
PAYLOAD_FRAG_COUNT))
134+
#else /* !CONFIG_BT_CTLR_ADV_PERIODIC */
135+
/* NOTE: When Extended Advertising is supported but no Periodic Advertising
136+
* then additional CONFIG_BT_CTLR_ADV_DATA_BUF_MAX amount of buffers is
137+
* allocated.
138+
* Set CONFIG_BT_CTLR_ADV_DATA_BUF_MAX to BT_CTLR_ADV_AUX_SET if
139+
* PDU data is updated more frequently compare to the advertising
140+
* interval with random delay included.
141+
*/
142+
#define PDU_MEM_COUNT_MAX (PDU_MEM_COUNT_MIN + \
143+
(CONFIG_BT_CTLR_ADV_DATA_BUF_MAX * \
144+
PAYLOAD_FRAG_COUNT))
145+
#endif /* !CONFIG_BT_CTLR_ADV_PERIODIC */
146+
#else /* !CONFIG_BT_CTLR_ADV_EXT */
147+
/* NOTE: When Extended Advertising is not supported then
148+
* CONFIG_BT_CTLR_ADV_DATA_BUF_MAX is restricted to 1 in Kconfig file.
149+
*/
150+
#define PDU_MEM_COUNT_MAX (PDU_MEM_COUNT_MIN + CONFIG_BT_CTLR_ADV_DATA_BUF_MAX)
151+
#endif /* !CONFIG_BT_CTLR_ADV_EXT */
152+
153+
/* FIFO element count, that returns the consumed advertising PDUs (AD and Scan
154+
* Response). 1 each for primary channel PDU (AD and Scan Response), plus one
155+
* each for Extended Advertising and Periodic Advertising times the number of
156+
* chained fragments that would get returned.
157+
*/
158+
#define PDU_MEM_FIFO_COUNT (BT_CTLR_ADV_SET + 1 +\
159+
((BT_CTLR_ADV_AUX_SET + BT_CTLR_ADV_SYNC_SET) * \
160+
PAYLOAD_FRAG_COUNT))
161+
162+
#define PDU_POOL_SIZE (PDU_MEM_SIZE * PDU_MEM_COUNT_MAX)
114163

115164
/* Free AD data PDU buffer pool */
116165
static struct {

0 commit comments

Comments
 (0)