Skip to content

Commit 8fbbf2b

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: BIS initial implementation review rework
Changes here are related to review rework. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 61eb655 commit 8fbbf2b

File tree

10 files changed

+190
-184
lines changed

10 files changed

+190
-184
lines changed

subsys/bluetooth/controller/hci/hci.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6348,6 +6348,10 @@ static void le_per_adv_sync_report(struct pdu_data *pdu_data,
63486348
sizeof(*sep));
63496349

63506350
sep->sync_handle = sys_cpu_to_le16(node_rx->hdr.handle);
6351+
6352+
/* NOTE: both sep and bi struct store little-endian values,
6353+
* explicit endian-ness conversion not required.
6354+
*/
63516355
sep->num_bis = bi->num_bis;
63526356
sep->nse = bi->nse;
63536357
sep->iso_interval = bi->iso_interval;
@@ -6413,7 +6417,7 @@ static void le_big_sync_established(struct pdu_data *pdu,
64136417
return;
64146418
}
64156419

6416-
/* TODO: Fill latency */
6420+
/* FIXME: Fill latency */
64176421
sys_put_le32(0, sep->latency);
64186422

64196423
sep->nse = lll->nse;
@@ -6424,15 +6428,15 @@ static void le_big_sync_established(struct pdu_data *pdu,
64246428
sep->iso_interval = sys_cpu_to_le16(sync_iso->iso_interval);
64256429
sep->num_bis = lll->num_bis;
64266430

6427-
/* TODO: Connection handle list of all BISes in the BIG */
6431+
/* FIXME: Connection handle list of all BISes in the BIG */
64286432
sep->handle[0] = sys_cpu_to_le16(0);
64296433
}
64306434

64316435
static void le_sync_iso_pdu(struct pdu_data *pdu,
64326436
struct node_rx_pdu *node_rx,
64336437
struct net_buf *buf)
64346438
{
6435-
printk("Sync ISO PDU (%u)\n", pdu->len);
6439+
/* FIXME: integrate with ISOAL interface */
64366440
}
64376441

64386442
static void le_big_sync_lost(struct pdu_data *pdu,
@@ -6501,7 +6505,7 @@ static void le_big_complete(struct pdu_data *pdu_data,
65016505
return;
65026506
}
65036507

6504-
/* TODO: Fill sync delay and latency */
6508+
/* FIXME: Fill sync delay and latency */
65056509
sys_put_le24(0, sep->sync_delay);
65066510
sys_put_le24(0, sep->latency);
65076511

@@ -6513,7 +6517,7 @@ static void le_big_complete(struct pdu_data *pdu_data,
65136517
sep->max_pdu = sys_cpu_to_le16(lll->max_pdu);
65146518
sep->num_bis = lll->num_bis;
65156519

6516-
/* TODO: Connection handle list of all BISes in the BIG */
6520+
/* FIXME: Connection handle list of all BISes in the BIG */
65176521
sep->handle[0] = sys_cpu_to_le16(0);
65186522
}
65196523

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

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void prepare(void *param)
108108
p = param;
109109

110110
/* Instants elapsed */
111-
elapsed = p->lazy + 1;
111+
elapsed = p->lazy + 1U;
112112

113113
lll = p->param;
114114

@@ -121,7 +121,7 @@ static void create_prepare_bh(void *param)
121121
int err;
122122

123123
/* Invoke common pipeline handling of prepare */
124-
err = lll_prepare(lll_is_abort_cb, lll_abort_cb, create_prepare_cb, 0,
124+
err = lll_prepare(lll_is_abort_cb, lll_abort_cb, create_prepare_cb, 0U,
125125
param);
126126
LL_ASSERT(!err || err == -EINPROGRESS);
127127
}
@@ -131,7 +131,7 @@ static void prepare_bh(void *param)
131131
int err;
132132

133133
/* Invoke common pipeline handling of prepare */
134-
err = lll_prepare(lll_is_abort_cb, lll_abort_cb, prepare_cb, 0, param);
134+
err = lll_prepare(lll_is_abort_cb, lll_abort_cb, prepare_cb, 0U, param);
135135
LL_ASSERT(!err || err == -EINPROGRESS);
136136
}
137137

@@ -188,17 +188,17 @@ static int prepare_cb_common(struct lll_prepare_param *p)
188188
lll = p->param;
189189

190190
/* Deduce the latency */
191-
lll->latency_event = lll->latency_prepare - 1;
191+
lll->latency_event = lll->latency_prepare - 1U;
192192

193193
/* Calculate the current event counter value */
194-
event_counter = ((lll->payload_count / lll->bn) & 0xFFFF) +
194+
event_counter = (lll->payload_count / lll->bn) +
195195
(lll->latency_event * lll->bn);
196196

197197
/* Update BIS packet counter to next value */
198198
lll->payload_count += (lll->latency_prepare * lll->bn);
199199

200200
/* Reset accumulated latencies */
201-
lll->latency_prepare = 0;
201+
lll->latency_prepare = 0U;
202202

203203
/* Initialize to mandatory parameter values */
204204
lll->bis_curr = 1U;
@@ -215,12 +215,12 @@ static int prepare_cb_common(struct lll_prepare_param *p)
215215
* significant 2 octets and the BIS_Number for the specific BIS in the
216216
* least significant octet.
217217
*/
218-
memcpy(&crc_init[1], lll->base_crc_init, sizeof(uint16_t));
219218
crc_init[0] = lll->bis_curr;
219+
(void)memcpy(&crc_init[1], lll->base_crc_init, sizeof(uint16_t));
220220

221221
/* Calculate the radio channel to use for ISO event */
222222
data_chan_use = lll_chan_iso_event(event_counter, data_chan_id,
223-
&lll->data_chan_map[0],
223+
lll->data_chan_map,
224224
lll->data_chan_count,
225225
&lll->data_chan_prn_s,
226226
&lll->data_chan_remap_idx);
@@ -236,12 +236,9 @@ static int prepare_cb_common(struct lll_prepare_param *p)
236236

237237
phy = lll->phy;
238238
radio_phy_set(phy, lll->phy_flags);
239-
radio_pkt_configure(8, lll->max_pdu, (phy << 1));
239+
radio_pkt_configure(8U, lll->max_pdu, (phy << 1));
240240
radio_aa_set(access_addr);
241-
radio_crc_configure(((0x5bUL) | ((0x06UL) << 8) | ((0x00UL) << 16)),
242-
(((uint32_t)crc_init[2] << 16) |
243-
((uint32_t)crc_init[1] << 8) |
244-
((uint32_t)crc_init[0])));
241+
radio_crc_configure(PDU_CRC_POLYNOMIAL, sys_get_le24(crc_init));
245242
lll_chan_set(data_chan_use);
246243

247244
/* FIXME: get ISO data PDU */
@@ -273,9 +270,9 @@ static int prepare_cb_common(struct lll_prepare_param *p)
273270
if (lll->term_req) {
274271
if (!lll->term_ack) {
275272
lll->term_ack = 1U;
276-
lll->ctrl_expire = 6U;
273+
lll->ctrl_expire = CONN_ESTAB_COUNTDOWN;
277274
lll->ctrl_instant = event_counter +
278-
lll->ctrl_expire - 1;
275+
lll->ctrl_expire - 1U;
279276
lll->cssn++;
280277
}
281278

@@ -306,7 +303,8 @@ static int prepare_cb_common(struct lll_prepare_param *p)
306303
PDU_BIS_US(pdu->len, lll->enc, lll->phy,
307304
lll->phy_flags);
308305
radio_tmr_tifs_set(iss_us);
309-
radio_switch_complete_and_b2b_tx(lll->phy, 0, lll->phy, 0);
306+
radio_switch_complete_and_b2b_tx(lll->phy, lll->phy_flags,
307+
lll->phy, lll->phy_flags);
310308
}
311309

312310
ticks_at_event = p->ticks_at_expire;
@@ -317,12 +315,13 @@ static int prepare_cb_common(struct lll_prepare_param *p)
317315
ticks_at_start += HAL_TICKER_US_TO_TICKS(EVENT_OVERHEAD_START_US);
318316

319317
remainder = p->remainder;
320-
start_us = radio_tmr_start(1, ticks_at_start, remainder);
318+
start_us = radio_tmr_start(1U, ticks_at_start, remainder);
321319

322320
#if defined(HAL_RADIO_GPIO_HAVE_PA_PIN)
323321
radio_gpio_pa_setup();
324322

325-
radio_gpio_pa_lna_enable(start_us + radio_tx_ready_delay_get(phy, 1) -
323+
radio_gpio_pa_lna_enable(start_us +
324+
radio_tx_ready_delay_get(phy, PHY_FLAGS_S8) -
326325
HAL_RADIO_GPIO_PA_OFFSET);
327326
#else /* !HAL_RADIO_GPIO_HAVE_PA_PIN */
328327
ARG_UNUSED(start_us);
@@ -365,7 +364,10 @@ static void isr_tx_common(void *param,
365364
{
366365
struct pdu_bis *pdu = NULL;
367366
struct lll_adv_iso *lll;
367+
uint8_t access_addr[4];
368+
uint16_t data_chan_id;
368369
uint8_t data_chan_use;
370+
uint8_t crc_init[3];
369371
uint8_t bis;
370372

371373
lll = param;
@@ -393,9 +395,9 @@ static void isr_tx_common(void *param,
393395

394396
} else if (lll->bis_curr < lll->num_bis) {
395397
lll->bis_curr++;
396-
lll->ptc_curr = 0;
398+
lll->ptc_curr = 0U;
397399
lll->irc_curr = 1U;
398-
lll->bn_curr = 0;
400+
lll->bn_curr = 0U;
399401
/* transmit the (bn_curr)th PDU of bis_curr */
400402
lll->bn_curr++; /* post increment */
401403

@@ -433,10 +435,6 @@ static void isr_tx_common(void *param,
433435

434436
lll_isr_tx_status_reset();
435437

436-
uint8_t access_addr[4];
437-
uint16_t data_chan_id;
438-
uint8_t crc_init[3];
439-
440438
/* Calculate the Access Address for the BIS event */
441439
util_bis_aa_le32(bis, lll->seed_access_addr, access_addr);
442440
data_chan_id = lll_chan_id(access_addr);
@@ -446,14 +444,11 @@ static void isr_tx_common(void *param,
446444
* significant 2 octets and the BIS_Number for the specific BIS in the
447445
* least significant octet.
448446
*/
449-
memcpy(&crc_init[1], lll->base_crc_init, sizeof(uint16_t));
450447
crc_init[0] = bis;
448+
(void)memcpy(&crc_init[1], lll->base_crc_init, sizeof(uint16_t));
451449

452450
radio_aa_set(access_addr);
453-
radio_crc_configure(((0x5bUL) | ((0x06UL) << 8) | ((0x00UL) << 16)),
454-
(((uint32_t)crc_init[2] << 16) |
455-
((uint32_t)crc_init[1] << 8) |
456-
((uint32_t)crc_init[0])));
451+
radio_crc_configure(PDU_CRC_POLYNOMIAL, sys_get_le24(crc_init));
457452

458453
/* FIXME: get ISO data PDU */
459454
if (0) {
@@ -476,7 +471,7 @@ static void isr_tx_common(void *param,
476471
/* Calculate the radio channel to use for ISO event */
477472
data_chan_use =
478473
lll_chan_iso_subevent(data_chan_id,
479-
&lll->data_chan_map[0],
474+
lll->data_chan_map,
480475
lll->data_chan_count,
481476
&lll->data_chan_prn_s,
482477
&lll->data_chan_remap_idx);
@@ -499,7 +494,8 @@ static void isr_tx_common(void *param,
499494
PDU_BIS_US(pdu->len, lll->enc, lll->phy,
500495
lll->phy_flags);
501496
radio_tmr_tifs_set(iss_us);
502-
radio_switch_complete_and_b2b_tx(lll->phy, 0, lll->phy, 0);
497+
radio_switch_complete_and_b2b_tx(lll->phy, lll->phy_flags,
498+
lll->phy, lll->phy_flags);
503499

504500
radio_isr_set(isr_tx, lll);
505501
}
@@ -510,21 +506,15 @@ static void isr_tx_common(void *param,
510506

511507
static void isr_done_create(void *param)
512508
{
513-
struct event_done_extra *extra;
514-
515509
lll_isr_status_reset();
516510

517-
extra = ull_event_done_extra_get();
518-
LL_ASSERT(extra);
519-
520-
extra->type = EVENT_DONE_EXTRA_TYPE_ADV_ISO_COMPLETE;
511+
ull_done_extra_type_set(EVENT_DONE_EXTRA_TYPE_ADV_ISO_COMPLETE);
521512

522513
lll_isr_cleanup(param);
523514
}
524515

525516
static void isr_done_term(void *param)
526517
{
527-
struct event_done_extra *extra;
528518
struct lll_adv_iso *lll;
529519

530520
lll_isr_status_reset();
@@ -535,10 +525,7 @@ static void isr_done_term(void *param)
535525

536526
lll->ctrl_expire--;
537527
if (!lll->ctrl_expire) {
538-
extra = ull_event_done_extra_get();
539-
LL_ASSERT(extra);
540-
541-
extra->type = EVENT_DONE_EXTRA_TYPE_ADV_ISO_TERMINATE;
528+
ull_done_extra_type_set(EVENT_DONE_EXTRA_TYPE_ADV_ISO_TERMINATE);
542529
}
543530

544531
lll_isr_cleanup(param);

0 commit comments

Comments
 (0)