@@ -566,6 +566,53 @@ static void adv_timeout_expire(struct work_struct *work)
566
566
hci_dev_unlock (hdev );
567
567
}
568
568
569
+ static bool is_interleave_scanning (struct hci_dev * hdev )
570
+ {
571
+ return hdev -> interleave_scan_state != INTERLEAVE_SCAN_NONE ;
572
+ }
573
+
574
+ static int hci_passive_scan_sync (struct hci_dev * hdev );
575
+
576
+ static void interleave_scan_work (struct work_struct * work )
577
+ {
578
+ struct hci_dev * hdev = container_of (work , struct hci_dev ,
579
+ interleave_scan .work );
580
+ unsigned long timeout ;
581
+
582
+ if (hdev -> interleave_scan_state == INTERLEAVE_SCAN_ALLOWLIST ) {
583
+ timeout = msecs_to_jiffies (hdev -> advmon_allowlist_duration );
584
+ } else if (hdev -> interleave_scan_state == INTERLEAVE_SCAN_NO_FILTER ) {
585
+ timeout = msecs_to_jiffies (hdev -> advmon_no_filter_duration );
586
+ } else {
587
+ bt_dev_err (hdev , "unexpected error" );
588
+ return ;
589
+ }
590
+
591
+ hci_passive_scan_sync (hdev );
592
+
593
+ hci_dev_lock (hdev );
594
+
595
+ switch (hdev -> interleave_scan_state ) {
596
+ case INTERLEAVE_SCAN_ALLOWLIST :
597
+ bt_dev_dbg (hdev , "next state: allowlist" );
598
+ hdev -> interleave_scan_state = INTERLEAVE_SCAN_NO_FILTER ;
599
+ break ;
600
+ case INTERLEAVE_SCAN_NO_FILTER :
601
+ bt_dev_dbg (hdev , "next state: no filter" );
602
+ hdev -> interleave_scan_state = INTERLEAVE_SCAN_ALLOWLIST ;
603
+ break ;
604
+ case INTERLEAVE_SCAN_NONE :
605
+ bt_dev_err (hdev , "unexpected error" );
606
+ }
607
+
608
+ hci_dev_unlock (hdev );
609
+
610
+ /* Don't continue interleaving if it was canceled */
611
+ if (is_interleave_scanning (hdev ))
612
+ queue_delayed_work (hdev -> req_workqueue ,
613
+ & hdev -> interleave_scan , timeout );
614
+ }
615
+
569
616
void hci_cmd_sync_init (struct hci_dev * hdev )
570
617
{
571
618
INIT_WORK (& hdev -> cmd_sync_work , hci_cmd_sync_work );
@@ -577,6 +624,7 @@ void hci_cmd_sync_init(struct hci_dev *hdev)
577
624
INIT_WORK (& hdev -> reenable_adv_work , reenable_adv );
578
625
INIT_DELAYED_WORK (& hdev -> le_scan_disable , le_scan_disable );
579
626
INIT_DELAYED_WORK (& hdev -> adv_instance_expire , adv_timeout_expire );
627
+ INIT_DELAYED_WORK (& hdev -> interleave_scan , interleave_scan_work );
580
628
}
581
629
582
630
static void _hci_cmd_sync_cancel_entry (struct hci_dev * hdev ,
@@ -2110,11 +2158,6 @@ static void hci_start_interleave_scan(struct hci_dev *hdev)
2110
2158
& hdev -> interleave_scan , 0 );
2111
2159
}
2112
2160
2113
- static bool is_interleave_scanning (struct hci_dev * hdev )
2114
- {
2115
- return hdev -> interleave_scan_state != INTERLEAVE_SCAN_NONE ;
2116
- }
2117
-
2118
2161
static void cancel_interleave_scan (struct hci_dev * hdev )
2119
2162
{
2120
2163
bt_dev_dbg (hdev , "cancelling interleave scan" );
0 commit comments