Skip to content

Commit bef9d14

Browse files
ppryga-nordiccfriedt
authored andcommitted
Bluetooth: controller: simplify arg list of ull_adv_sync_pdu_alloc
ull_adv_sync_pdu_alloc function was extracted from ull_adv_sync_pdu_- -set_clear function. The arguments list of ull_adv_sync_pdu_alloc was derived from source function but the acutal functionality is only part of what it was before. The ull_adv_sync_pdu_alloc does not change extended advertising PDU header fileds. The hdr_add_fields and hdr_rem_fields arguments were used to allocate or not allocate memory for extra_data related with new periodic advertising PDU. Also hrd_data pointer was not used by the function. The function arguments list was simplified. New enum ull_adv_pdu_extra_data_flag was introduced to provide named flags for extra_data memory management. Signed-off-by: Piotr Pryga <[email protected]>
1 parent 946ad14 commit bef9d14

File tree

4 files changed

+28
-32
lines changed

4 files changed

+28
-32
lines changed

subsys/bluetooth/controller/ll_sw/ull_adv_internal.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ uint8_t ull_adv_time_update(struct ll_adv_set *adv, struct pdu_adv *pdu,
5050

5151
#if defined(CONFIG_BT_CTLR_ADV_EXT)
5252

53+
/* Enumeration provides flags for management of memory for extra_data
54+
* related with advertising PDUs.
55+
*/
56+
enum ull_adv_pdu_extra_data_flag {
57+
/* Allocate extra_data memory if it was available in former PDU */
58+
ULL_ADV_PDU_EXTRA_DATA_ALLOC_IF_EXIST,
59+
/* Allocate extra_data memory no matter if it was available */
60+
ULL_ADV_PDU_EXTRA_DATA_ALLOC_ALWAYS,
61+
/* Never allocate new memory for extra_data */
62+
ULL_ADV_PDU_EXTRA_DATA_ALLOC_NEVER
63+
};
64+
5365
/* Below are BT Spec v5.2, Vol 6, Part B Section 2.3.4 Table 2.12 defined */
5466
#define ULL_ADV_PDU_HDR_FIELD_ADVA BIT(0)
5567
#define ULL_ADV_PDU_HDR_FIELD_TARGETA BIT(1)
@@ -170,14 +182,9 @@ void ull_adv_sync_info_fill(struct ll_adv_sync_set *sync,
170182
* previous and new PDU for further processing.
171183
*/
172184
uint8_t ull_adv_sync_pdu_alloc(struct ll_adv_set *adv,
173-
uint16_t hdr_add_fields,
174-
uint16_t hdr_rem_fields,
175-
struct ull_adv_ext_hdr_data *hdr_data,
176-
struct pdu_adv **ter_pdu_prev,
177-
struct pdu_adv **ter_pdu_new,
178-
void **extra_data_prev,
179-
void **extra_data_new,
180-
uint8_t *ter_idx);
185+
enum ull_adv_pdu_extra_data_flag extra_data_flags,
186+
struct pdu_adv **ter_pdu_prev, struct pdu_adv **ter_pdu_new,
187+
void **extra_data_prev, void **extra_data_new, uint8_t *ter_idx);
181188

182189
/* helper function to set/clear common extended header format fields
183190
* for AUX_SYNC_IND PDU.

subsys/bluetooth/controller/ll_sw/ull_adv_iso.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
139139
}
140140

141141
/* Allocate next PDU */
142-
err = ull_adv_sync_pdu_alloc(adv, 0, 0, NULL, &pdu_prev, &pdu,
142+
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_EXTRA_DATA_ALLOC_IF_EXIST, &pdu_prev, &pdu,
143143
&extra_data_prev, &extra_data, &ter_idx);
144144
if (err) {
145145
return err;
@@ -254,7 +254,7 @@ uint8_t ll_big_terminate(uint8_t big_handle, uint8_t reason)
254254
adv = HDR_LLL2ULL(lll_adv);
255255

256256
/* Allocate next PDU */
257-
err = ull_adv_sync_pdu_alloc(adv, 0, 0, NULL, &pdu_prev, &pdu,
257+
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_EXTRA_DATA_ALLOC_IF_EXIST, &pdu_prev, &pdu,
258258
&extra_data_prev, &extra_data, &ter_idx);
259259
if (err) {
260260
return err;

subsys/bluetooth/controller/ll_sw/ull_adv_sync.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ uint8_t ll_adv_sync_param_set(uint8_t handle, uint16_t interval, uint16_t flags)
382382

383383
sync->interval = interval;
384384

385-
err = ull_adv_sync_pdu_alloc(adv, 0, 0, NULL, &pdu_prev, &pdu,
385+
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_EXTRA_DATA_ALLOC_IF_EXIST, &pdu_prev, &pdu,
386386
&extra_data_prev, &extra_data, &ter_idx);
387387
if (err) {
388388
return err;
@@ -439,8 +439,7 @@ uint8_t ll_adv_sync_ad_data_set(uint8_t handle, uint8_t op, uint8_t len,
439439
field_data[0] = len;
440440
memcpy(&field_data[1], &data, sizeof(data));
441441

442-
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_HDR_FIELD_AD_DATA, 0,
443-
&hdr_data, &pdu_prev, &pdu,
442+
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_EXTRA_DATA_ALLOC_IF_EXIST, &pdu_prev, &pdu,
444443
&extra_data_prev, &extra_data, &ter_idx);
445444
if (err) {
446445
return err;
@@ -798,14 +797,9 @@ void ull_adv_sync_offset_get(struct ll_adv_set *adv)
798797
}
799798

800799
uint8_t ull_adv_sync_pdu_alloc(struct ll_adv_set *adv,
801-
uint16_t hdr_add_fields,
802-
uint16_t hdr_rem_fields,
803-
struct ull_adv_ext_hdr_data *hdr_data,
804-
struct pdu_adv **ter_pdu_prev,
805-
struct pdu_adv **ter_pdu_new,
806-
void **extra_data_prev,
807-
void **extra_data_new,
808-
uint8_t *ter_idx)
800+
enum ull_adv_pdu_extra_data_flag extra_data_flag,
801+
struct pdu_adv **ter_pdu_prev, struct pdu_adv **ter_pdu_new,
802+
void **extra_data_prev, void **extra_data_new, uint8_t *ter_idx)
809803
{
810804
struct pdu_adv *pdu_prev, *pdu_new;
811805
struct lll_adv_sync *lll_sync;
@@ -824,9 +818,8 @@ uint8_t ull_adv_sync_pdu_alloc(struct ll_adv_set *adv,
824818

825819
#if defined(CONFIG_BT_CTLR_DF_ADV_CTE_TX)
826820
/* Get reference to new periodic advertising PDU data buffer */
827-
if ((hdr_add_fields & ULL_ADV_PDU_HDR_FIELD_CTE_INFO) ||
828-
(!(hdr_rem_fields & ULL_ADV_PDU_HDR_FIELD_CTE_INFO) &&
829-
ed_prev)) {
821+
if (extra_data_flag == ULL_ADV_PDU_EXTRA_DATA_ALLOC_ALWAYS ||
822+
(extra_data_flag == ULL_ADV_PDU_EXTRA_DATA_ALLOC_IF_EXIST && ed_prev)) {
830823
/* If there was an extra data in past PDU data or it is required
831824
* by the hdr_add_fields then allocate memmory for it.
832825
*/

subsys/bluetooth/controller/ll_sw/ull_df.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,8 @@ uint8_t ll_df_set_cl_cte_tx_enable(uint8_t adv_handle, uint8_t cte_enable)
297297
return BT_HCI_ERR_CMD_DISALLOWED;
298298
}
299299

300-
err = ull_adv_sync_pdu_alloc(adv, 0,
301-
ULL_ADV_PDU_HDR_FIELD_CTE_INFO,
302-
NULL, &pdu_prev, &pdu,
303-
&extra_data_prev, &extra_data,
304-
&ter_idx);
300+
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_EXTRA_DATA_ALLOC_NEVER, &pdu_prev,
301+
&pdu, &extra_data_prev, &extra_data, &ter_idx);
305302
if (err) {
306303
return err;
307304
}
@@ -334,9 +331,8 @@ uint8_t ll_df_set_cl_cte_tx_enable(uint8_t adv_handle, uint8_t cte_enable)
334331
hdr_data.field_data = (uint8_t *)&cte_info;
335332
hdr_data.extra_data = df_cfg;
336333

337-
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_HDR_FIELD_CTE_INFO, 0, NULL,
338-
&pdu_prev, &pdu, &extra_data_prev, &extra_data,
339-
&ter_idx);
334+
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_EXTRA_DATA_ALLOC_ALWAYS, &pdu_prev,
335+
&pdu, &extra_data_prev, &extra_data, &ter_idx);
340336
if (err) {
341337
return err;
342338
}

0 commit comments

Comments
 (0)