forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/wl_cfgscan.c
old mode 100644new mode 100755
....@@ -135,6 +135,10 @@
135135 void wl_cfgscan_scan_abort(struct bcm_cfg80211 *cfg);
136136 static void _wl_cfgscan_cancel_scan(struct bcm_cfg80211 *cfg);
137137
138
+#if defined (WL_SCHED_SCAN) && defined (SCHED_SCAN_DELAYED_WORK)
139
+void wl_cfg80211_stop_pno(struct bcm_cfg80211 *cfg, struct net_device *dev);
140
+#endif /* WL_SCHED_SCAN */
141
+
138142 #ifdef ESCAN_CHANNEL_CACHE
139143 void reset_roam_cache(struct bcm_cfg80211 *cfg);
140144 void add_roam_cache(struct bcm_cfg80211 *cfg, wl_bss_info_t *bi);
....@@ -640,10 +644,10 @@
640644
641645 if (cfg->autochannel && ndev) {
642646 #if defined(BSSCACHE)
643
- wl_ext_get_best_channel(ndev, &cfg->g_bss_cache_ctrl,
647
+ wl_ext_get_best_channel(ndev, &cfg->g_bss_cache_ctrl, ioctl_version,
644648 &cfg->best_2g_ch, &cfg->best_5g_ch, &cfg->best_6g_ch);
645649 #else
646
- wl_ext_get_best_channel(ndev, bss_list,
650
+ wl_ext_get_best_channel(ndev, bss_list, ioctl_version,
647651 &cfg->best_2g_ch, &cfg->best_5g_ch, &cfg->best_6g_ch);
648652 #endif
649653 }
....@@ -2640,14 +2644,8 @@
26402644 }
26412645
26422646 #ifdef WL_EXT_IAPSTA
2643
- err = wl_ext_in4way_sync(ndev, STA_FAKE_SCAN_IN_CONNECT, WL_EXT_STATUS_SCANNING, NULL);
2644
- if (err) {
2645
- wl_event_msg_t msg;
2647
+ if (wl_ext_in4way_sync(ndev, STA_FAKE_SCAN_IN_CONNECT, WL_EXT_STATUS_SCANNING, NULL)) {
26462648 mutex_lock(&cfg->scan_sync);
2647
- bzero(&msg, sizeof(wl_event_msg_t));
2648
- msg.event_type = hton32(WLC_E_ESCAN_RESULT);
2649
- msg.status = hton32(WLC_E_STATUS_SUCCESS);
2650
- wl_cfg80211_event(ndev, &msg, NULL);
26512649 goto scan_success;
26522650 }
26532651 #endif
....@@ -2987,11 +2985,19 @@
29872985
29882986 if (cfg->bss_list && (cfg->bss_list->count == 0)) {
29892987 WL_INFORM_MEM(("bss list empty. report sched_scan_stop\n"));
2988
+
2989
+#if defined (WL_SCHED_SCAN) && defined (SCHED_SCAN_DELAYED_WORK)
2990
+ wl_cfg80211_stop_pno(cfg, bcmcfg_to_prmry_ndev(cfg));
2991
+ /* schedule the work to indicate sched scan stop to cfg layer */
2992
+ schedule_delayed_work(&cfg->sched_scan_stop_work, 0);
2993
+#else
29902994 /* Indicated sched scan stopped so that user space
29912995 * can do a full scan incase found match is empty.
29922996 */
29932997 CFG80211_SCHED_SCAN_STOPPED(wiphy, cfg->sched_scan_req);
29942998 cfg->sched_scan_req = NULL;
2999
+#endif
3000
+
29953001 }
29963002 }
29973003 #endif /* WL_SCHED_SCAN */
....@@ -3932,10 +3938,23 @@
39323938 #endif /* LINUX_VER > 4.11 */
39333939 {
39343940 struct bcm_cfg80211 *cfg = wiphy_priv(wiphy);
3941
+#if defined (WL_SCHED_SCAN) && !defined (SCHED_SCAN_DELAYED_WORK)
39353942 dhd_pub_t *dhdp = (dhd_pub_t *)(cfg->pub);
3943
+#endif
3944
+
3945
+#if defined (WL_SCHED_SCAN) && defined (SCHED_SCAN_DELAYED_WORK)
3946
+ struct net_device *pri_ndev;
3947
+#endif
39363948
39373949 WL_DBG(("Enter \n"));
39383950 WL_PNO((">>> SCHED SCAN STOP\n"));
3951
+
3952
+#if defined (WL_SCHED_SCAN) && defined (SCHED_SCAN_DELAYED_WORK)
3953
+ pri_ndev = bcmcfg_to_prmry_ndev(cfg);
3954
+ wl_cfg80211_stop_pno(cfg, dev);
3955
+
3956
+ cancel_delayed_work(&cfg->sched_scan_stop_work);
3957
+#else
39393958
39403959 #if defined(BCMDONGLEHOST)
39413960 if (dhd_dev_pno_stop_for_ssid(dev) < 0) {
....@@ -3949,16 +3968,81 @@
39493968 }
39503969 #endif /* BCMDONGLEHOST */
39513970
3971
+#endif
3972
+
39523973 mutex_lock(&cfg->scan_sync);
39533974 if (cfg->sched_scan_req) {
3975
+#if defined (WL_SCHED_SCAN) && defined (SCHED_SCAN_DELAYED_WORK)
3976
+ if (cfg->sched_scan_running && wl_get_drv_status(cfg, SCANNING, pri_ndev)) {
3977
+ /* If targetted escan for PNO is running, abort it */
3978
+ WL_INFORM_MEM(("abort targetted escan\n"));
3979
+ _wl_cfgscan_cancel_scan(cfg);
3980
+ wl_clr_drv_status(cfg, SCANNING, pri_ndev);
3981
+ } else {
3982
+ WL_INFORM_MEM(("pno escan state:%d\n",
3983
+ cfg->sched_scan_running));
3984
+ }
3985
+#else
39543986 WL_PNO((">>> Sched scan running. Aborting it..\n"));
39553987 _wl_cfgscan_cancel_scan(cfg);
3988
+#endif
39563989 }
39573990 cfg->sched_scan_req = NULL;
39583991 cfg->sched_scan_running = FALSE;
39593992 mutex_unlock(&cfg->scan_sync);
39603993
39613994 return 0;
3995
+}
3996
+#if defined (WL_SCHED_SCAN) && defined (SCHED_SCAN_DELAYED_WORK)
3997
+void
3998
+wl_cfgscan_sched_scan_stop_work(struct work_struct *work)
3999
+{
4000
+ struct bcm_cfg80211 *cfg = NULL;
4001
+ struct wiphy *wiphy = NULL;
4002
+ struct delayed_work *dw = to_delayed_work(work);
4003
+
4004
+ GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
4005
+ cfg = container_of(dw, struct bcm_cfg80211, sched_scan_stop_work);
4006
+ GCC_DIAGNOSTIC_POP();
4007
+
4008
+ /* Hold rtnl_lock -> scan_sync lock to be in sync with cfg80211_ops path */
4009
+ rtnl_lock();
4010
+ mutex_lock(&cfg->scan_sync);
4011
+ if (cfg->sched_scan_req) {
4012
+ wiphy = cfg->sched_scan_req->wiphy;
4013
+ /* Indicate sched scan stopped so that user space
4014
+ * can do a full scan incase found match is empty.
4015
+ */
4016
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
4017
+ cfg80211_sched_scan_stopped_rtnl(wiphy, cfg->sched_scan_req->reqid);
4018
+#else
4019
+ cfg80211_sched_scan_stopped_rtnl(wiphy);
4020
+#endif /* KERNEL > 4.12.0 */
4021
+ cfg->sched_scan_req = NULL;
4022
+ }
4023
+ mutex_unlock(&cfg->scan_sync);
4024
+ rtnl_unlock();
4025
+}
4026
+#endif
4027
+#endif /* WL_SCHED_SCAN */
4028
+
4029
+#if defined (WL_SCHED_SCAN) && defined (SCHED_SCAN_DELAYED_WORK)
4030
+void
4031
+wl_cfg80211_stop_pno(struct bcm_cfg80211 *cfg, struct net_device *dev)
4032
+{
4033
+#if defined(BCMDONGLEHOST)
4034
+ dhd_pub_t *dhdp = (dhd_pub_t *)(cfg->pub);
4035
+
4036
+ if (dhd_dev_pno_stop_for_ssid(dev) < 0) {
4037
+ WL_ERR(("PNO Stop for SSID failed"));
4038
+ } else {
4039
+ /*
4040
+ * purposefully logging here to make sure that
4041
+ * firmware configuration was successful
4042
+ */
4043
+ DBG_EVENT_LOG(dhdp, WIFI_EVENT_DRIVER_PNO_REMOVE);
4044
+ }
4045
+#endif /* BCMDONGLEHOST */
39624046 }
39634047 #endif /* WL_SCHED_SCAN */
39644048
....@@ -4750,12 +4834,18 @@
47504834 */
47514835 if (cfg->sched_scan_req) {
47524836 WL_ERR(("sched_scan stopped\n"));
4837
+#if defined (WL_SCHED_SCAN) && defined (SCHED_SCAN_DELAYED_WORK)
4838
+ wl_cfg80211_stop_pno(cfg, bcmcfg_to_prmry_ndev(cfg));
4839
+ /* schedule the work to indicate sched scan stop to cfg layer */
4840
+ schedule_delayed_work(&cfg->sched_scan_stop_work, 0);
4841
+#else
47534842 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0))
47544843 cfg80211_sched_scan_stopped(wiphy, cfg->sched_scan_req->reqid);
47554844 #else
47564845 cfg80211_sched_scan_stopped(wiphy);
47574846 #endif /* KERNEL > 4.11.0 */
47584847 cfg->sched_scan_req = NULL;
4848
+#endif
47594849 } else {
47604850 WL_ERR(("sched scan req null!\n"));
47614851 }
....@@ -5564,7 +5654,7 @@
55645654 }
55655655 #endif /* ESCAN_CHANNEL_CACHE */
55665656
5567
- WL_SCAN(("channel cnt:%d\n", info->chan_cnt));
5657
+ WL_DBG_MEM(("channel cnt:%d\n", info->chan_cnt));
55685658 return BCME_OK;
55695659 }
55705660
....@@ -5586,7 +5676,7 @@
55865676
55875677 s32
55885678 wl_cfgscan_get_band_freq_list(struct bcm_cfg80211 *cfg, int band,
5589
- uint32 *list, uint32 *num_channels)
5679
+ uint16 *list, uint32 *num_channels)
55905680 {
55915681 s32 err = BCME_OK;
55925682 uint32 i, freq, list_count, count = 0;
....@@ -5608,16 +5698,13 @@
56085698 list_count = ((wl_chanspec_list_v1_t *)list)->count;
56095699 for (i = 0; i < list_count; i++) {
56105700 chspec = dtoh32(((wl_chanspec_list_v1_t *)list)->chspecs[i].chanspec);
5611
- if (!CHSPEC_IS20(chspec)) {
5612
- continue;
5613
- }
56145701 chaninfo = dtoh32(((wl_chanspec_list_v1_t *)list)->chspecs[i].chaninfo);
56155702 freq = wl_channel_to_frequency(wf_chspec_ctlchan(chspec),
56165703 CHSPEC_BAND(chspec));
56175704 if (((band & WIFI_BAND_BG) && CHSPEC_IS2G(chspec)) ||
56185705 ((band & WIFI_BAND_6GHZ) && CHSPEC_IS6G(chspec))) {
56195706 /* add 2g/6g channels */
5620
- list[count] = freq;
5707
+ list[i] = freq;
56215708 count++;
56225709 }
56235710 /* handle 5g separately */
....@@ -5632,7 +5719,7 @@
56325719 continue;
56335720 }
56345721
5635
- list[count] = freq;
5722
+ list[i] = freq;
56365723 count++;
56375724 }
56385725 }