@@ -86,9 +86,6 @@ static void *sync_free;
86
86
static struct k_sem sem_ticker_cb ;
87
87
#endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */
88
88
89
- static memq_link_t link_lll_prepare ;
90
- static struct mayfly mfy_lll_prepare = { 0 , 0 , & link_lll_prepare , NULL , lll_sync_prepare };
91
-
92
89
uint8_t ll_sync_create (uint8_t options , uint8_t sid , uint8_t adv_addr_type ,
93
90
uint8_t * adv_addr , uint16_t skip ,
94
91
uint16_t sync_timeout , uint8_t sync_cte_type )
@@ -720,7 +717,7 @@ void ull_sync_setup(struct ll_scan_set *scan, struct ll_scan_aux_set *aux,
720
717
}
721
718
ticks_slot_offset += HAL_TICKER_US_TO_TICKS (EVENT_OVERHEAD_START_US );
722
719
723
- mfy_lll_prepare . fp = lll_sync_create_prepare ;
720
+ sync -> lll_sync_prepare = lll_sync_create_prepare ;
724
721
725
722
ret = ticker_start (TICKER_INSTANCE_ID_CTLR , TICKER_USER_ID_ULL_HIGH ,
726
723
(TICKER_ID_SCAN_SYNC_BASE + sync_handle ),
@@ -758,12 +755,14 @@ void ull_sync_setup_complete(struct ll_scan_set *scan)
758
755
void ull_sync_established_report (memq_link_t * link , struct node_rx_hdr * rx )
759
756
{
760
757
struct node_rx_pdu * rx_establ ;
761
- struct ll_sync_set * ull_sync ;
758
+ struct ll_sync_set * sync ;
762
759
struct node_rx_ftr * ftr ;
763
760
struct node_rx_sync * se ;
764
761
struct lll_sync * lll ;
765
762
766
763
ftr = & rx -> rx_ftr ;
764
+ lll = ftr -> param ;
765
+ sync = HDR_LLL2ULL (lll );
767
766
768
767
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING )
769
768
enum sync_status sync_status ;
@@ -773,8 +772,6 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
773
772
#else
774
773
struct pdu_cte_info * rx_cte_info ;
775
774
776
- lll = ftr -> param ;
777
-
778
775
rx_cte_info = pdu_cte_info_get ((struct pdu_adv * )((struct node_rx_pdu * )rx )-> pdu );
779
776
if (rx_cte_info != NULL ) {
780
777
sync_status = lll_sync_cte_is_allowed (lll -> cte_type , lll -> filter_policy ,
@@ -794,15 +791,10 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
794
791
if (1 ) {
795
792
#endif /* !CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING */
796
793
797
- /* Set the sync handle corresponding to the LLL context passed in the node rx
798
- * footer field.
799
- */
800
- lll = ftr -> param ;
801
- ull_sync = HDR_LLL2ULL (lll );
802
-
803
794
/* Prepare and dispatch sync notification */
804
- rx_establ = (void * )ull_sync -> node_rx_sync_estab ;
795
+ rx_establ = (void * )sync -> node_rx_sync_estab ;
805
796
rx_establ -> hdr .type = NODE_RX_TYPE_SYNC ;
797
+ rx_establ -> hdr .handle = ull_sync_handle_get (sync );
806
798
se = (void * )rx_establ -> pdu ;
807
799
808
800
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING )
@@ -812,7 +804,7 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
812
804
813
805
#if !defined(CONFIG_BT_CTLR_CTEINLINE_SUPPORT )
814
806
/* Notify done event handler to terminate sync scan if required. */
815
- ull_sync -> is_term = (sync_status == SYNC_STAT_TERM );
807
+ sync -> is_term = (sync_status == SYNC_STAT_TERM );
816
808
#endif /* !CONFIG_BT_CTLR_CTEINLINE_SUPPORT */
817
809
#else
818
810
se -> status = BT_HCI_ERR_SUCCESS ;
@@ -836,8 +828,9 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
836
828
837
829
if (1 ) {
838
830
#endif /* !CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING */
831
+
839
832
/* Switch sync event prepare function to one reposnsible for regular PDUs receive */
840
- mfy_lll_prepare . fp = lll_sync_prepare ;
833
+ sync -> lll_sync_prepare = lll_sync_prepare ;
841
834
842
835
/* Change node type to appropriately handle periodic
843
836
* advertising PDU report.
@@ -1128,6 +1121,9 @@ static void ticker_cb(uint32_t ticks_at_expire, uint32_t ticks_drift,
1128
1121
uint32_t remainder , uint16_t lazy , uint8_t force ,
1129
1122
void * param )
1130
1123
{
1124
+ static memq_link_t link_lll_prepare ;
1125
+ static struct mayfly mfy_lll_prepare = {
1126
+ 0 , 0 , & link_lll_prepare , NULL , NULL };
1131
1127
static struct lll_prepare_param p ;
1132
1128
struct ll_sync_set * sync = param ;
1133
1129
struct lll_sync * lll ;
@@ -1152,9 +1148,11 @@ static void ticker_cb(uint32_t ticks_at_expire, uint32_t ticks_drift,
1152
1148
p .force = force ;
1153
1149
p .param = lll ;
1154
1150
mfy_lll_prepare .param = & p ;
1151
+ mfy_lll_prepare .fp = sync -> lll_sync_prepare ;
1155
1152
1156
1153
/* Kick LLL prepare */
1157
- ret = mayfly_enqueue (TICKER_USER_ID_ULL_HIGH , TICKER_USER_ID_LLL , 0 , & mfy_lll_prepare );
1154
+ ret = mayfly_enqueue (TICKER_USER_ID_ULL_HIGH , TICKER_USER_ID_LLL , 0 ,
1155
+ & mfy_lll_prepare );
1158
1156
LL_ASSERT (!ret );
1159
1157
1160
1158
DEBUG_RADIO_PREPARE_O (1 );
@@ -1235,9 +1233,17 @@ static void ticker_stop_sync_lost_op_cb(uint32_t status, void *param)
1235
1233
1236
1234
static void sync_lost (void * param )
1237
1235
{
1238
- struct ll_sync_set * sync = param ;
1236
+ struct ll_sync_set * sync ;
1239
1237
struct node_rx_pdu * rx ;
1240
1238
1239
+ /* sync established was not generated yet, no free node rx */
1240
+ sync = param ;
1241
+ if (sync -> lll_sync_prepare != lll_sync_prepare ) {
1242
+ sync_expire (param );
1243
+
1244
+ return ;
1245
+ }
1246
+
1241
1247
/* Generate Periodic advertising sync lost */
1242
1248
rx = (void * )& sync -> node_rx_lost ;
1243
1249
rx -> hdr .handle = ull_sync_handle_get (sync );
0 commit comments