From ee7e4cf08b7eed19f6db9b57eede921378a7b35f Mon Sep 17 00:00:00 2001 From: Jyoti Kumari Date: Wed, 4 May 2022 15:22:20 +0530 Subject: [PATCH] qcacmn: Skip STA scan on 6Ghz and 5ghz indoor chan if SAP is up Currently STA can scan and come up on 6Ghz or 5Ghz indoor channel if hardware is non-dbs and SAP is present As part of this change, do not allow STA to scan on 6Ghz and 5Ghz indoor channel for non-dbs hardware if SAP is present Change-Id: I97759f8b2c6a1c460d90fbb797a0e64d2532797c CRs-Fixed: 3186406 --- umac/scan/core/src/wlan_scan_main.h | 4 + umac/scan/core/src/wlan_scan_manager.c | 99 +++++++++++++++---- umac/scan/dispatcher/inc/wlan_scan_api.h | 9 ++ umac/scan/dispatcher/inc/wlan_scan_cfg.h | 22 +++++ umac/scan/dispatcher/src/wlan_scan_api.c | 11 +++ umac/scan/dispatcher/src/wlan_scan_ucfg_api.c | 4 + 6 files changed, 132 insertions(+), 17 deletions(-) diff --git a/umac/scan/core/src/wlan_scan_main.h b/umac/scan/core/src/wlan_scan_main.h index 929043151589..b4917c652156 100644 --- a/umac/scan/core/src/wlan_scan_main.h +++ b/umac/scan/core/src/wlan_scan_main.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -341,6 +342,8 @@ struct extscan_def_config { * @adaptive_dwell_time_mode_nc: adaptive dwell mode without connection * @honour_nl_scan_policy_flags: honour nl80211 scan policy flags * @extscan_adaptive_dwell_mode: Adaptive dwell mode during ext scan + * @skip_6g_and_indoor_freq: skip 6Ghz and 5Gh indoor freq channel for + * STA scan if hw is non-DBS and SAP is present * @scan_f_passive: passively scan all channels including active channels * @scan_f_bcast_probe: add wild card ssid prbreq even if ssid_list is specified * @scan_f_cck_rates: add cck rates to rates/xrates ie in prb req @@ -432,6 +435,7 @@ struct scan_default_params { enum scan_dwelltime_adaptive_mode adaptive_dwell_time_mode_nc; bool honour_nl_scan_policy_flags; enum scan_dwelltime_adaptive_mode extscan_adaptive_dwell_mode; + bool skip_6g_and_indoor_freq; union { struct { uint32_t scan_f_passive:1, diff --git a/umac/scan/core/src/wlan_scan_manager.c b/umac/scan/core/src/wlan_scan_manager.c index 3227a43aafda..3e2db7135001 100644 --- a/umac/scan/core/src/wlan_scan_manager.c +++ b/umac/scan/core/src/wlan_scan_manager.c @@ -803,6 +803,65 @@ static void scm_req_update_concurrency_params(struct wlan_objmgr_vdev *vdev, } } +/** + *scm_update_5g_chlist() - Modify channel list to skip 5Ghz channel + * @req: scan request + * + * Return: None + */ +static inline void scm_update_5g_chlist(struct scan_start_request *req) +{ + uint32_t i; + uint32_t num_scan_channels = 0; + qdf_freq_t freq; + + for (i = 0; i < req->scan_req.chan_list.num_chan; i++) { + freq = req->scan_req.chan_list.chan[i].freq; + if (WLAN_REG_IS_5GHZ_CH_FREQ(freq)) + continue; + + req->scan_req.chan_list.chan[num_scan_channels++] = + req->scan_req.chan_list.chan[i]; + } + if (num_scan_channels < req->scan_req.chan_list.num_chan) + scm_debug("5g chan skipped (%d, %d)", + req->scan_req.chan_list.num_chan, num_scan_channels); + req->scan_req.chan_list.num_chan = num_scan_channels; +} + +/** + * scm_filter_6g_and_indoor_freq() - Modify channel list to skip 6Ghz and 5Ghz + * indoor channel if hw mode is non dbs and SAP is present + * @pdev: pointer to pdev + * @req: scan request + * + * Return: None + */ +static void scm_filter_6g_and_indoor_freq(struct wlan_objmgr_pdev *pdev, + struct scan_start_request *req) +{ + uint32_t i; + uint32_t num_scan_channels; + qdf_freq_t freq; + + num_scan_channels = 0; + for (i = 0; i < req->scan_req.chan_list.num_chan; i++) { + freq = req->scan_req.chan_list.chan[i].freq; + if (WLAN_REG_IS_6GHZ_CHAN_FREQ(freq)) + continue; + + if (wlan_reg_is_freq_indoor(pdev, freq)) + continue; + + req->scan_req.chan_list.chan[num_scan_channels++] = + req->scan_req.chan_list.chan[i]; + } + if (num_scan_channels < req->scan_req.chan_list.num_chan) + scm_debug("6g and indoor channel chan skipped (%d, %d)", + req->scan_req.chan_list.num_chan, num_scan_channels); + req->scan_req.chan_list.num_chan = num_scan_channels; +} + /** * scm_scan_chlist_concurrency_modify() - modify chan list to skip 5G if * required @@ -817,31 +876,37 @@ static inline void scm_scan_chlist_concurrency_modify( struct wlan_objmgr_vdev *vdev, struct scan_start_request *req) { struct wlan_objmgr_psoc *psoc; - uint32_t i; - uint32_t num_scan_channels; + struct wlan_objmgr_pdev *pdev; + struct wlan_scan_obj *scan_obj; + + pdev = wlan_vdev_get_pdev(vdev); + if (!pdev) + return; psoc = wlan_vdev_get_psoc(vdev); if (!psoc) return; + + scan_obj = wlan_psoc_get_scan_obj(psoc); + if (!scan_obj) + return; + /* do this only for STA and P2P-CLI mode */ if (!(wlan_vdev_mlme_get_opmode(req->vdev) == QDF_STA_MODE) && !(wlan_vdev_mlme_get_opmode(req->vdev) == QDF_P2P_CLIENT_MODE)) return; - if (!policy_mgr_scan_trim_5g_chnls_for_dfs_ap(psoc)) - return; - num_scan_channels = 0; - for (i = 0; i < req->scan_req.chan_list.num_chan; i++) { - if (WLAN_REG_IS_5GHZ_CH_FREQ( - req->scan_req.chan_list.chan[i].freq)) { - continue; - } - req->scan_req.chan_list.chan[num_scan_channels++] = - req->scan_req.chan_list.chan[i]; - } - if (num_scan_channels < req->scan_req.chan_list.num_chan) - scm_debug("5g chan skipped (%d, %d)", - req->scan_req.chan_list.num_chan, num_scan_channels); - req->scan_req.chan_list.num_chan = num_scan_channels; + if (policy_mgr_scan_trim_5g_chnls_for_dfs_ap(psoc)) + scm_update_5g_chlist(req); + + /* + * Do not allow STA to scan on 6Ghz or indoor channel for non dbs + * hardware if SAP and skip_6g_and_indoor_freq_scan ini are present + */ + if (scan_obj->scan_def.skip_6g_and_indoor_freq && + !policy_mgr_is_hw_dbs_capable(psoc) && + (wlan_vdev_mlme_get_opmode(vdev) == QDF_STA_MODE) && + policy_mgr_mode_specific_connection_count(psoc, PM_SAP_MODE, NULL)) + scm_filter_6g_and_indoor_freq(pdev, req); } #else static inline diff --git a/umac/scan/dispatcher/inc/wlan_scan_api.h b/umac/scan/dispatcher/inc/wlan_scan_api.h index 4a39af7d2e18..84a54c6c0b9f 100644 --- a/umac/scan/dispatcher/inc/wlan_scan_api.h +++ b/umac/scan/dispatcher/inc/wlan_scan_api.h @@ -335,4 +335,13 @@ QDF_STATUS wlan_scan_start(struct scan_start_request *req); */ QDF_STATUS wlan_scan_cancel(struct scan_cancel_request *req); +/** + * wlan_scan_cfg_skip_6g_and_indoor_freq() - API to get 6g and indoor freq + * scan ini val + * @psoc: psoc object + * + * Return: skip 6g and indoor freq scan or not + */ +bool wlan_scan_cfg_skip_6g_and_indoor_freq( + struct wlan_objmgr_psoc *psoc); #endif diff --git a/umac/scan/dispatcher/inc/wlan_scan_cfg.h b/umac/scan/dispatcher/inc/wlan_scan_cfg.h index b9dc233d63b5..61f79cc39939 100644 --- a/umac/scan/dispatcher/inc/wlan_scan_cfg.h +++ b/umac/scan/dispatcher/inc/wlan_scan_cfg.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -1412,6 +1413,26 @@ enum scan_mode_6ghz { false, \ "scan allow bss with corrupted ie") +/* + * + * skip_6g_and_indoor_freq_scan - Skip scan on 6Ghz and indoor channel + * @Min: 0 + * @Max: 1 + * @Default: 0 + * + * This ini is used to skip 6Ghz and 5Gh indoor freq for STA scan if hw is + * non-DBS and SAP is present + * + * Related: scan + * + * Usage: External + * + * + */ +#define CFG_SKIP_6GHZ_AND_INDOOR_FREQ_SCAN CFG_INI_BOOL( \ + "skip_6g_and_indoor_freq_scan", \ + false, \ + "skip sta scan on 6Ghz and 5Ghz indoor channel") #define CFG_SCAN_ALL \ CFG(CFG_DROP_BCN_ON_CHANNEL_MISMATCH) \ CFG(CFG_DROP_BCN_ON_INVALID_FREQ) \ @@ -1449,6 +1470,7 @@ enum scan_mode_6ghz { CFG(CFG_6GHZ_SCAN_MODE) \ CFG(CFG_6GHZ_SCAN_MODE_DUTY_CYCLE) \ CFG(CFG_SCAN_ALLOW_BSS_WITH_CORRUPTED_IE) \ + CFG(CFG_SKIP_6GHZ_AND_INDOOR_FREQ_SCAN) \ CFG_SCAN_PNO #endif /* __CONFIG_SCAN_H */ diff --git a/umac/scan/dispatcher/src/wlan_scan_api.c b/umac/scan/dispatcher/src/wlan_scan_api.c index c4b77a972071..86015c58d1f5 100644 --- a/umac/scan/dispatcher/src/wlan_scan_api.c +++ b/umac/scan/dispatcher/src/wlan_scan_api.c @@ -430,3 +430,14 @@ req_free: return status; } + +bool wlan_scan_cfg_skip_6g_and_indoor_freq(struct wlan_objmgr_psoc *psoc) +{ + struct wlan_scan_obj *scan_obj; + + scan_obj = wlan_psoc_get_scan_obj(psoc); + if (!scan_obj) + return false; + + return scan_obj->scan_def.skip_6g_and_indoor_freq; +} diff --git a/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c b/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c index 7aab4712ca76..0e723d0a6da3 100644 --- a/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c +++ b/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c @@ -983,6 +983,10 @@ wlan_scan_global_init(struct wlan_objmgr_psoc *psoc, cfg_get(psoc, CFG_6GHZ_SCAN_MODE_DUTY_CYCLE); scan_obj->allow_bss_with_incomplete_ie = cfg_get(psoc, CFG_SCAN_ALLOW_BSS_WITH_CORRUPTED_IE); + + scan_obj->scan_def.skip_6g_and_indoor_freq = + cfg_get(psoc, CFG_SKIP_6GHZ_AND_INDOOR_FREQ_SCAN); + /* init scan id seed */ qdf_atomic_init(&scan_obj->scan_ids);