qcacld-3.0: Don't allow SAP to switch to DFS channel if master mode is disable

Previously, if force SCC is enabled and Standalone SAP starts
on non-DFS channel, it starts with master mode Disable. If it
is switched to DFS channel it will switch without CAC.

As a fix, if SAP is started on non-DFS channel with force SCC,
don't allow it to switch to DFS channel if master mode is disabled.

Change-Id: I1822f67a5480d6c16fa980c9c6b262341af7c2de
CRs-Fixed: 2827237
This commit is contained in:
Deeksha Gupta 2020-12-03 14:05:43 +05:30 • committed by snandini
commit 6d9d9c56b2
4 changed files with 66 additions and 27 deletions

View file

@ -3216,7 +3216,19 @@ void policy_mgr_check_and_stop_opportunistic_timer(
void policy_mgr_set_weight_of_dfs_passive_channels_to_zero(
struct wlan_objmgr_psoc *psoc, uint32_t *pcl,
uint32_t *len, uint8_t *weight_list, uint32_t weight_len);
/**
* policy_mgr_is_sap_allowed_on_dfs_chan() - check if sap allowed on dfs channel
* @pdev: id of objmgr pdev
* @vdev_id: vdev id
* @channel: channel number
* This function is used to check if sta_sap_scc_on_dfs_chan ini is set,
* DFS master capability is assumed disabled in the driver.
*
* Return: true if sap is allowed on dfs channel,
* otherwise false
*/
bool policy_mgr_is_sap_allowed_on_dfs_chan(struct wlan_objmgr_pdev *pdev,
uint8_t vdev_id, uint8_t channel);
/**
* policy_mgr_is_sta_sap_scc_allowed_on_dfs_chan() - check if sta+sap scc
* allowed on dfs chan

View file

@ -3940,6 +3940,40 @@ bool policy_mgr_is_force_scc(struct wlan_objmgr_psoc *psoc)
QDF_MCC_TO_SCC_WITH_PREFERRED_BAND));
}
bool policy_mgr_is_sap_allowed_on_dfs_chan(struct wlan_objmgr_pdev *pdev,
uint8_t vdev_id, uint8_t channel)
{
struct wlan_objmgr_psoc *psoc;
uint32_t sta_sap_scc_on_dfs_chan;
uint32_t sta_cnt, gc_cnt;
psoc = wlan_pdev_get_psoc(pdev);
if (!psoc)
return false;
sta_sap_scc_on_dfs_chan =
policy_mgr_is_sta_sap_scc_allowed_on_dfs_chan(psoc);
sta_cnt = policy_mgr_mode_specific_connection_count(psoc,
PM_STA_MODE, NULL);
gc_cnt = policy_mgr_mode_specific_connection_count(psoc,
PM_P2P_CLIENT_MODE, NULL);
policy_mgr_debug("sta_sap_scc_on_dfs_chan %u, sta_cnt %u, gc_cnt %u",
sta_sap_scc_on_dfs_chan, sta_cnt, gc_cnt);
/* if sta_sap_scc_on_dfs_chan ini is set, DFS master capability is
* assumed disabled in the driver.
*/
if ((wlan_reg_get_channel_state(pdev, channel) == CHANNEL_STATE_DFS) &&
!sta_cnt && !gc_cnt && sta_sap_scc_on_dfs_chan &&
!policy_mgr_get_dfs_master_dynamic_enabled(psoc, vdev_id)) {
policy_mgr_err("SAP not allowed on DFS channel if no dfs master capability!!");
return false;
}
return true;
}
bool policy_mgr_is_sta_sap_scc_allowed_on_dfs_chan(
struct wlan_objmgr_psoc *psoc)
{

View file

@ -23280,8 +23280,9 @@ static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy,
{
struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
struct hdd_context *hdd_ctx;
int ret;
int ret, channel;
enum phy_ch_width ch_width;
bool status;
if (wlan_hdd_validate_vdev_id(adapter->vdev_id))
return -EINVAL;
@ -23295,6 +23296,15 @@ static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy,
if ((QDF_P2P_GO_MODE != adapter->device_mode) &&
(QDF_SAP_MODE != adapter->device_mode))
return -ENOTSUPP;
channel = ieee80211_frequency_to_channel(
csa_params->chandef.chan->center_freq);
status = policy_mgr_is_sap_allowed_on_dfs_chan(hdd_ctx->pdev,
adapter->vdev_id, channel);
if (!status)
return -EINVAL;
wlan_hdd_set_sap_csa_reason(hdd_ctx->psoc, adapter->vdev_id,
CSA_REASON_USER_INITIATED);

View file

@ -6424,8 +6424,7 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
int status;
struct sme_sta_inactivity_timeout *sta_inactivity_timer;
uint8_t channel, mandt_chnl_list = 0;
bool sta_sap_scc_on_dfs_chan;
uint16_t sta_cnt, gc_cnt, sap_cnt;
uint16_t sta_cnt, sap_cnt;
bool val;
struct wireless_dev *wdev = dev->ieee80211_ptr;
struct cfg80211_chan_def new_chandef;
@ -6520,30 +6519,10 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
adapter->session.ap.sap_config.ch_params.mhz_freq_seg1 =
chandef->center_freq2;
sta_sap_scc_on_dfs_chan =
policy_mgr_is_sta_sap_scc_allowed_on_dfs_chan(
hdd_ctx->psoc);
sta_cnt = policy_mgr_mode_specific_connection_count(hdd_ctx->psoc,
PM_STA_MODE, NULL);
gc_cnt = policy_mgr_mode_specific_connection_count(hdd_ctx->psoc,
PM_P2P_CLIENT_MODE, NULL);
sap_cnt = policy_mgr_mode_specific_connection_count(hdd_ctx->psoc,
PM_SAP_MODE, NULL);
hdd_debug("sta_sap_scc_on_dfs_chan %u, sta_cnt %u gc_cnt %u",
sta_sap_scc_on_dfs_chan, sta_cnt, gc_cnt);
/* if sta_sap_scc_on_dfs_chan ini is set, DFS master capability is
* assumed disabled in the driver.
*/
if ((wlan_reg_get_channel_state(hdd_ctx->pdev, channel) ==
CHANNEL_STATE_DFS) && !sta_cnt && !gc_cnt &&
sta_sap_scc_on_dfs_chan &&
!ucfg_policy_mgr_get_dfs_master_dynamic_enabled(
hdd_ctx->psoc, adapter->vdev_id)) {
hdd_err("SAP not allowed on DFS channel if no dfs master capability!!");
status = policy_mgr_is_sap_allowed_on_dfs_chan(hdd_ctx->pdev,
adapter->vdev_id, channel);
if (!status)
return -EINVAL;
}
vdev_opmode = wlan_vdev_mlme_get_opmode(adapter->vdev);
ucfg_mlme_get_srd_master_mode_for_vdev(hdd_ctx->psoc, vdev_opmode,
@ -6589,6 +6568,10 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
sap_cfg->SapHw_mode = eCSR_DOT11_MODE_abg;
}
sta_cnt = policy_mgr_mode_specific_connection_count(hdd_ctx->psoc,
PM_STA_MODE, NULL);
sap_cnt = policy_mgr_mode_specific_connection_count(hdd_ctx->psoc,
PM_SAP_MODE, NULL);
/* Disable NAN Disc before starting P2P GO or STA+SAP or SAP+SAP */
if (adapter->device_mode == QDF_P2P_GO_MODE || sta_cnt ||
(sap_cnt > (MAX_SAP_NUM_CONCURRENCY_WITH_NAN - 1))) {