Skip to content

Commit 378a1e0

Browse files
ppryga-nordiccfriedt
authored andcommitted
Bluetooth: controller: remove unnecessary ull_adv_ext_hdr_data struct
After extracting from ull_adv_sync_pdu_set_clear functions: ull_adv_sync_pdu_alloc, ull_adv_sync_extra_data_set_clear Use of ull_adv_ext_hrd_data structure became unnecessary. The extra_data member of the structure was never used due to separate function responsible for setting extra_data content. In all cases content for extended advertising header fields may be passed to the ull_adv_sync_pdu_set_clear directly as void * pointer, instead of pointer to ull_adv_ext_hdr_data. This simplifies use of ull_adv_sync_pdu_set_clear as well as removes unneccesary code to handle special structure type. Signed-off-by: Piotr Pryga <[email protected]>
1 parent 4c3d76b commit 378a1e0

File tree

4 files changed

+39
-64
lines changed

4 files changed

+39
-64
lines changed

subsys/bluetooth/controller/ll_sw/ull_adv_internal.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,6 @@ enum ull_adv_pdu_extra_data_flag {
7575
#define ULL_ADV_PDU_HDR_FIELD_ACAD BIT(8)
7676
#define ULL_ADV_PDU_HDR_FIELD_AD_DATA BIT(9)
7777

78-
/* Helper type to store data for extended advertising
79-
* header fields and extra data.
80-
*/
81-
struct ull_adv_ext_hdr_data {
82-
void *field_data;
83-
84-
#if defined(CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY)
85-
void *extra_data;
86-
#endif /* CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY */
87-
};
88-
8978
/* helper function to handle adv done events */
9079
void ull_adv_done(struct node_rx_event_done *done);
9180

@@ -189,12 +178,9 @@ uint8_t ull_adv_sync_pdu_alloc(struct ll_adv_set *adv,
189178
/* helper function to set/clear common extended header format fields
190179
* for AUX_SYNC_IND PDU.
191180
*/
192-
uint8_t ull_adv_sync_pdu_set_clear(struct lll_adv_sync *lll_sync,
193-
struct pdu_adv *ter_pdu_prev,
194-
struct pdu_adv *ter_pdu,
195-
uint16_t hdr_add_fields,
196-
uint16_t hdr_rem_fields,
197-
struct ull_adv_ext_hdr_data *hdr_data);
181+
uint8_t ull_adv_sync_pdu_set_clear(struct lll_adv_sync *lll_sync, struct pdu_adv *ter_pdu_prev,
182+
struct pdu_adv *ter_pdu, uint16_t hdr_add_fields,
183+
uint16_t hdr_rem_fields, void *hdr_data);
198184

199185
/* helper function to update extra_data field */
200186
void ull_adv_sync_extra_data_set_clear(void *extra_data_prev,

subsys/bluetooth/controller/ll_sw/ull_adv_iso.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
5858
uint8_t packing, uint8_t framing, uint8_t encryption,
5959
uint8_t *bcode)
6060
{
61-
uint8_t field_data[1 + sizeof(uint8_t *)];
62-
struct ull_adv_ext_hdr_data hdr_data;
61+
uint8_t hdr_data[1 + sizeof(uint8_t *)];
6362
struct lll_adv_sync *lll_adv_sync;
6463
struct lll_adv_iso *lll_adv_iso;
6564
struct pdu_adv *pdu_prev, *pdu;
@@ -145,16 +144,14 @@ uint8_t ll_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
145144
}
146145

147146
/* Add ACAD to AUX_SYNC_IND */
148-
hdr_data.field_data = field_data;
149-
field_data[0] = sizeof(struct pdu_big_info) + 2;
150-
err = ull_adv_sync_pdu_set_clear(lll_adv_sync, pdu_prev, pdu,
151-
ULL_ADV_PDU_HDR_FIELD_ACAD, 0U,
152-
&hdr_data);
147+
hdr_data[0] = sizeof(struct pdu_big_info) + 2;
148+
err = ull_adv_sync_pdu_set_clear(lll_adv_sync, pdu_prev, pdu, ULL_ADV_PDU_HDR_FIELD_ACAD,
149+
0U, hdr_data);
153150
if (err) {
154151
return err;
155152
}
156153

157-
memcpy(&acad, &field_data[1], sizeof(acad));
154+
memcpy(&acad, &hdr_data[1], sizeof(acad));
158155
acad[0] = sizeof(struct pdu_big_info) + 1;
159156
acad[1] = BT_DATA_BIG_INFO;
160157

subsys/bluetooth/controller/ll_sw/ull_adv_sync.c

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ uint8_t ll_adv_sync_param_set(uint8_t handle, uint16_t interval, uint16_t flags)
408408
uint8_t ll_adv_sync_ad_data_set(uint8_t handle, uint8_t op, uint8_t len,
409409
uint8_t const *const data)
410410
{
411-
struct ull_adv_ext_hdr_data hdr_data;
412-
uint8_t field_data[1 + sizeof(data)];
411+
uint8_t hdr_data[1 + sizeof(data)];
413412
void *extra_data_prev, *extra_data;
414413
struct pdu_adv *pdu_prev, *pdu;
415414
struct lll_adv_sync *lll_sync;
@@ -435,9 +434,8 @@ uint8_t ll_adv_sync_ad_data_set(uint8_t handle, uint8_t op, uint8_t len,
435434
return BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER;
436435
}
437436

438-
hdr_data.field_data = field_data;
439-
field_data[0] = len;
440-
memcpy(&field_data[1], &data, sizeof(data));
437+
hdr_data[0] = len;
438+
memcpy(&hdr_data[1], &data, sizeof(data));
441439

442440
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_EXTRA_DATA_ALLOC_IF_EXIST, &pdu_prev, &pdu,
443441
&extra_data_prev, &extra_data, &ter_idx);
@@ -448,14 +446,12 @@ uint8_t ll_adv_sync_ad_data_set(uint8_t handle, uint8_t op, uint8_t len,
448446
#if defined(CONFIG_BT_CTLR_DF_ADV_CTE_TX)
449447
if (extra_data) {
450448
ull_adv_sync_extra_data_set_clear(extra_data_prev, extra_data,
451-
ULL_ADV_PDU_HDR_FIELD_AD_DATA,
452-
0, &hdr_data);
449+
ULL_ADV_PDU_HDR_FIELD_AD_DATA, 0, NULL);
453450
}
454451
#endif /* CONFIG_BT_CTLR_DF_ADV_CTE_TX */
455452

456-
err = ull_adv_sync_pdu_set_clear(lll_sync, pdu_prev, pdu,
457-
ULL_ADV_PDU_HDR_FIELD_AD_DATA,
458-
0, &hdr_data);
453+
err = ull_adv_sync_pdu_set_clear(lll_sync, pdu_prev, pdu, ULL_ADV_PDU_HDR_FIELD_AD_DATA, 0,
454+
hdr_data);
459455
if (err) {
460456
return err;
461457
}
@@ -857,26 +853,27 @@ uint8_t ull_adv_sync_pdu_alloc(struct ll_adv_set *adv,
857853
/* @brief Set or clear fields in extended advertising header and store
858854
* extra_data if requested.
859855
*
860-
* @param[in] adv Advertising set.
856+
* @param[in] lll_sync Reference to periodic advertising sync.
857+
* @param[in] ter_pdu_prev Pointer to previous PDU.
858+
* @param[in] ter_pdu_ Pointer to PDU to fill fileds.
861859
* @param[in] hdr_add_fields Flag with information which fields add.
862860
* @param[in] hdr_rem_fields Flag with information which fields remove.
863-
* @param[in] data Pointer to data to be added to header and
864-
* extra_data. Content depends on the value of
865-
* @p hdr_add_fields.
866-
* @param[out] ter_idx Index of new PDU.
861+
* @param[in] hdr_data Pointer to data to be added to header. Content
862+
* depends on the value of @p hdr_add_fields.
867863
*
868864
* @Note
869-
* @p data content depends on the flag provided by @p hdr_add_fields:
865+
* @p hdr_data content depends on the flag provided by @p hdr_add_fields:
870866
* - ULL_ADV_PDU_HDR_FIELD_CTE_INFO:
871-
* # @p data->field_data points to single byte with CTEInfo field
872-
* # @p data->extra_data points to memory where is struct lll_df_adv_cfg
873-
* for LLL.
867+
* # @p hdr_data points to single byte with CTEInfo field
874868
* - ULL_ADV_PDU_HDR_FIELD_AD_DATA:
875-
* # @p data->field_data points to memory where first byte
869+
* # @p hdr_data points to memory where first byte
876870
* is size of advertising data, following byte is a pointer to actual
877871
* advertising data.
878-
* # @p data->extra_data is NULL
879-
* - ULL_ADV_PDU_HDR_FIELD_AUX_PTR: # @p data parameter is not used
872+
* - ULL_ADV_PDU_HDR_FIELD_AUX_PTR:
873+
* # @p hdr_data parameter is not used
874+
* - ULL_ADV_PDU_HDR_FIELD_ACAD:
875+
* # @p hdr_data points to memory where first byte is size of ACAD, second
876+
* byte is used to return offset to ACAD field.
880877
*
881878
* @return Zero in case of success, other value in case of failure.
882879
*/
@@ -885,7 +882,7 @@ uint8_t ull_adv_sync_pdu_set_clear(struct lll_adv_sync *lll_sync,
885882
struct pdu_adv *ter_pdu,
886883
uint16_t hdr_add_fields,
887884
uint16_t hdr_rem_fields,
888-
struct ull_adv_ext_hdr_data *hdr_data)
885+
void *hdr_data)
889886
{
890887
struct pdu_adv_com_ext_adv *ter_com_hdr, *ter_com_hdr_prev;
891888
struct pdu_adv_ext_hdr *ter_hdr, ter_hdr_prev;
@@ -900,9 +897,6 @@ uint8_t ull_adv_sync_pdu_set_clear(struct lll_adv_sync *lll_sync,
900897
uint8_t cte_info;
901898
#endif /* CONFIG_BT_CTLR_DF_ADV_CTE_TX */
902899
uint8_t ad_len;
903-
void *value;
904-
905-
value = hdr_data ? hdr_data->field_data : NULL;
906900

907901
/* Get common pointers from reference to previous tertiary PDU data */
908902
ter_com_hdr_prev = (void *)&ter_pdu_prev->adv_ext_ind;
@@ -935,8 +929,8 @@ uint8_t ull_adv_sync_pdu_set_clear(struct lll_adv_sync *lll_sync,
935929
/* If requested add or update CTEInfo */
936930
if (hdr_add_fields & ULL_ADV_PDU_HDR_FIELD_CTE_INFO) {
937931
ter_hdr->cte_info = 1;
938-
cte_info = *(uint8_t *)value;
939-
value = (uint8_t *)value + 1;
932+
cte_info = *(uint8_t *)hdr_data;
933+
hdr_data = (uint8_t *)hdr_data + 1;
940934
ter_dptr += sizeof(struct pdu_cte_info);
941935
/* If CTEInfo exists in prev and is not requested to be removed */
942936
} else if (!(hdr_rem_fields & ULL_ADV_PDU_HDR_FIELD_CTE_INFO) &&
@@ -1004,11 +998,11 @@ uint8_t ull_adv_sync_pdu_set_clear(struct lll_adv_sync *lll_sync,
1004998

1005999
/* Add/Retain/Remove ACAD */
10061000
if (hdr_add_fields & ULL_ADV_PDU_HDR_FIELD_ACAD) {
1007-
acad_len = *(uint8_t *)value;
1008-
value = (uint8_t *)value + 1;
1001+
acad_len = *(uint8_t *)hdr_data;
1002+
hdr_data = (uint8_t *)hdr_data + 1;
10091003
/* return the pointer to ACAD offset */
1010-
memcpy(value, &ter_dptr, sizeof(ter_dptr));
1011-
value = (uint8_t *)value + sizeof(ter_dptr);
1004+
memcpy(hdr_data, &ter_dptr, sizeof(ter_dptr));
1005+
hdr_data = (uint8_t *)hdr_data + sizeof(ter_dptr);
10121006
ter_dptr += acad_len;
10131007
} else if (!(hdr_rem_fields & ULL_ADV_PDU_HDR_FIELD_ACAD)) {
10141008
acad_len = acad_len_prev;
@@ -1023,7 +1017,7 @@ uint8_t ull_adv_sync_pdu_set_clear(struct lll_adv_sync *lll_sync,
10231017

10241018
/* Get Adv data from function parameters */
10251019
if (hdr_add_fields & ULL_ADV_PDU_HDR_FIELD_AD_DATA) {
1026-
ad_data = value;
1020+
ad_data = hdr_data;
10271021
ad_len = *ad_data;
10281022
++ad_data;
10291023

subsys/bluetooth/controller/ll_sw/ull_df.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,15 @@ uint8_t ll_df_set_cl_cte_tx_enable(uint8_t adv_handle, uint8_t cte_enable)
320320
df_cfg->is_enabled = 0U;
321321
} else {
322322
struct pdu_cte_info cte_info;
323-
struct ull_adv_ext_hdr_data hdr_data;
323+
void *hdr_data;
324324

325325
if (df_cfg->is_enabled) {
326326
return BT_HCI_ERR_CMD_DISALLOWED;
327327
}
328328

329329
cte_info.type = df_cfg->cte_type;
330330
cte_info.time = df_cfg->cte_length;
331-
hdr_data.field_data = (uint8_t *)&cte_info;
332-
hdr_data.extra_data = df_cfg;
331+
hdr_data = (uint8_t *)&cte_info;
333332

334333
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_EXTRA_DATA_ALLOC_ALWAYS, &pdu_prev,
335334
&pdu, &extra_data_prev, &extra_data, &ter_idx);
@@ -340,12 +339,11 @@ uint8_t ll_df_set_cl_cte_tx_enable(uint8_t adv_handle, uint8_t cte_enable)
340339
if (extra_data) {
341340
ull_adv_sync_extra_data_set_clear(extra_data_prev, extra_data,
342341
ULL_ADV_PDU_HDR_FIELD_CTE_INFO, 0,
343-
&df_cfg);
342+
df_cfg);
344343
}
345344

346345
err = ull_adv_sync_pdu_set_clear(lll_sync, pdu_prev, pdu,
347-
ULL_ADV_PDU_HDR_FIELD_CTE_INFO,
348-
0, &hdr_data);
346+
ULL_ADV_PDU_HDR_FIELD_CTE_INFO, 0, hdr_data);
349347
if (err) {
350348
return err;
351349
}

0 commit comments

Comments
 (0)