From 18aa9fa4a4e3698aa8cec3b7848f8114c2776c95 Mon Sep 17 00:00:00 2001 From: gaurank kathpalia Date: Wed, 8 Apr 2020 19:11:39 +0530 Subject: [PATCH] qcacld-3.0: Force SAP on default channel Currently the driver fails the ACS process if no channel is found suitable for SAP by ACS and thus hotspot cannot be enabled. Fix is to force SAP to come up on some default channel, this behaviour would be controlled via an ini to that customers can choose whether to opt for this behaviour or not. Change-Id: I8a63cf0c5d42802e33f4ad67a33d148a4da54d2a CRs-Fixed: 2658297 --- components/mlme/core/src/wlan_mlme_main.c | 2 ++ components/mlme/dispatcher/inc/cfg_mlme_acs.h | 28 +++++++++++++++++-- .../dispatcher/inc/wlan_mlme_public_struct.h | 3 ++ core/sap/src/sap_api_link_cntl.c | 20 +++++++------ core/sap/src/sap_fsm.c | 17 +++++++++-- core/sap/src/sap_internal.h | 4 ++- 6 files changed, 60 insertions(+), 14 deletions(-) diff --git a/components/mlme/core/src/wlan_mlme_main.c b/components/mlme/core/src/wlan_mlme_main.c index 2e9b565f592e..74b22d2c6010 100644 --- a/components/mlme/core/src/wlan_mlme_main.c +++ b/components/mlme/core/src/wlan_mlme_main.c @@ -1305,6 +1305,8 @@ static void mlme_init_acs_cfg(struct wlan_objmgr_psoc *psoc, cfg_get(psoc, CFG_AUTO_CHANNEL_SELECT_WEIGHT); acs->is_vendor_acs_support = cfg_get(psoc, CFG_USER_AUTO_CHANNEL_SELECTION); + acs->force_sap_start = + cfg_get(psoc, CFG_ACS_FORCE_START_SAP); acs->is_acs_support_for_dfs_ltecoex = cfg_get(psoc, CFG_USER_ACS_DFS_LTE); acs->is_external_acs_policy = diff --git a/components/mlme/dispatcher/inc/cfg_mlme_acs.h b/components/mlme/dispatcher/inc/cfg_mlme_acs.h index c387e401cee1..b71c33c803a6 100644 --- a/components/mlme/dispatcher/inc/cfg_mlme_acs.h +++ b/components/mlme/dispatcher/inc/cfg_mlme_acs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2020 The Linux Foundation. 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 @@ -179,12 +179,36 @@ "5940-7105=0, 5965=100, 6045=100, 6125=100, 6205=100, 6285=100, 6365=100, 6605=100, 6685=100, 6765=100, 6845=100", \ "Used to specify the channel weights") +/* + * + * force_start_sap- Enable the SAP even if no channel is suitable for SAP + * @Min: 0 + * @Max: 1 + * @Default: 0 + * + * This ini is used to enable the SAP even if no channel is found suitable + * for SAP by ACS. + * + * Related: NA + * + * Supported Feature: ACS + * + * Usage: Internal + * + * + */ +#define CFG_ACS_FORCE_START_SAP CFG_INI_BOOL( \ + "force_start_sap", \ + 0, \ + "Force start SAP") + #define CFG_ACS_ALL \ CFG(CFG_ACS_WITH_MORE_PARAM) \ CFG(CFG_AUTO_CHANNEL_SELECT_WEIGHT) \ CFG(CFG_USER_AUTO_CHANNEL_SELECTION) \ CFG(CFG_USER_ACS_DFS_LTE) \ CFG(CFG_EXTERNAL_ACS_POLICY) \ - CFG(CFG_NORMALIZE_ACS_WEIGHT) + CFG(CFG_NORMALIZE_ACS_WEIGHT) \ + CFG(CFG_ACS_FORCE_START_SAP) #endif /* __CFG_MLME_ACS_H */ diff --git a/components/mlme/dispatcher/inc/wlan_mlme_public_struct.h b/components/mlme/dispatcher/inc/wlan_mlme_public_struct.h index dbb225a45d97..ea4af764fd23 100644 --- a/components/mlme/dispatcher/inc/wlan_mlme_public_struct.h +++ b/components/mlme/dispatcher/inc/wlan_mlme_public_struct.h @@ -1227,6 +1227,8 @@ struct acs_weight_range { * @normalize_weight_num_chan: Number of freq items for normalization. * @normalize_weight_range: Frequency range for weight normalization * @num_weight_range: num of ranges provided by user + * @force_sap_start: Force SAP start when no channel is found suitable + * by ACS */ struct wlan_mlme_acs { bool is_acs_with_more_param; @@ -1238,6 +1240,7 @@ struct wlan_mlme_acs { uint16_t normalize_weight_num_chan; struct acs_weight_range normalize_weight_range[MAX_ACS_WEIGHT_RANGE]; uint16_t num_weight_range; + bool force_sap_start; }; /* diff --git a/core/sap/src/sap_api_link_cntl.c b/core/sap/src/sap_api_link_cntl.c index fbec547fabc2..f93f5969d3f5 100644 --- a/core/sap/src/sap_api_link_cntl.c +++ b/core/sap/src/sap_api_link_cntl.c @@ -319,21 +319,24 @@ QDF_STATUS wlansap_pre_start_bss_acs_scan_callback(mac_handle_t mac_handle, wlan_sap_filter_non_preferred_channels(mac_ctx->pdev, sap_ctx); if (!sap_ctx->acs_cfg->ch_list_count) { - sap_err("No channel left for SAP operation, hotspot fail"); - sap_ctx->chan_freq = SAP_CHANNEL_NOT_SELECTED; - sap_ctx->acs_cfg->pri_ch_freq = SAP_CHANNEL_NOT_SELECTED; - sap_config_acs_result(mac_handle, sap_ctx, 0); + oper_channel = + sap_select_default_oper_chan(mac_ctx, + sap_ctx->acs_cfg); + sap_ctx->chan_freq = oper_channel; + sap_ctx->acs_cfg->pri_ch_freq = oper_channel; + sap_config_acs_result(mac_handle, sap_ctx, + sap_ctx->acs_cfg->ht_sec_ch_freq); sap_ctx->sap_state = eSAP_ACS_CHANNEL_SELECTED; - sap_ctx->sap_status = eSAP_START_BSS_CHANNEL_NOT_SELECTED; + sap_ctx->sap_status = eSAP_STATUS_SUCCESS; goto close_session; - } if (eCSR_SCAN_SUCCESS != scan_status) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR, FL("CSR scan_status = eCSR_SCAN_ABORT/FAILURE (%d), choose default channel"), scan_status); oper_channel = - sap_select_default_oper_chan(sap_ctx->acs_cfg); + sap_select_default_oper_chan(mac_ctx, + sap_ctx->acs_cfg); wlansap_set_acs_ch_freq(sap_ctx, oper_channel); sap_ctx->acs_cfg->pri_ch_freq = oper_channel; sap_config_acs_result(mac_handle, sap_ctx, @@ -351,7 +354,8 @@ QDF_STATUS wlansap_pre_start_bss_acs_scan_callback(mac_handle_t mac_handle, if (oper_channel == SAP_CHANNEL_NOT_SELECTED) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO, FL("No suitable channel, so select default channel")); - oper_channel = sap_select_default_oper_chan(sap_ctx->acs_cfg); + oper_channel = sap_select_default_oper_chan(mac_ctx, + sap_ctx->acs_cfg); } wlansap_set_acs_ch_freq(sap_ctx, oper_channel); diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c index 514c6a94bbba..d705b5312b94 100644 --- a/core/sap/src/sap_fsm.c +++ b/core/sap/src/sap_fsm.c @@ -666,13 +666,24 @@ sap_chan_bond_dfs_sub_chan(struct sap_context *sap_context, return false; } -uint32_t sap_select_default_oper_chan(struct sap_acs_cfg *acs_cfg) +uint32_t sap_select_default_oper_chan(struct mac_context *mac_ctx, + struct sap_acs_cfg *acs_cfg) { uint16_t i; - if (!acs_cfg || !acs_cfg->freq_list || !acs_cfg->ch_list_count) + if (!acs_cfg) return 0; + if (!acs_cfg->ch_list_count || !acs_cfg->freq_list) { + if (mac_ctx->mlme_cfg->acs.force_sap_start) { + sap_debug("SAP forced, freq selected %d", + acs_cfg->master_freq_list[0]); + return acs_cfg->master_freq_list[0]; + } else { + sap_debug("No channel left for operation"); + return 0; + } + } /* * There could be both 2.4Ghz and 5ghz channels present in the list * based upon the Hw mode received from hostapd, it is always better @@ -954,7 +965,7 @@ QDF_STATUS sap_channel_sel(struct sap_context *sap_context) FL("SAP Configuring default ch, Ch_freq=%d"), sap_context->chan_freq); default_op_freq = sap_select_default_oper_chan( - sap_context->acs_cfg); + mac_ctx, sap_context->acs_cfg); wlansap_set_acs_ch_freq(sap_context, default_op_freq); if (sap_context->freq_list) { diff --git a/core/sap/src/sap_internal.h b/core/sap/src/sap_internal.h index 06432a26fdf5..c39b152ecf7d 100644 --- a/core/sap/src/sap_internal.h +++ b/core/sap/src/sap_internal.h @@ -452,6 +452,7 @@ static inline uint8_t sap_indicate_radar(struct sap_context *sap_ctx) /** * sap_select_default_oper_chan() - Select AP mode default operating channel + * @mac_ctx: mac context * @acs_cfg: pointer to ACS config info * * Select AP mode default operating channel based on ACS hw mode and channel @@ -460,7 +461,8 @@ static inline uint8_t sap_indicate_radar(struct sap_context *sap_ctx) * * Return: Selected operating channel frequency */ -uint32_t sap_select_default_oper_chan(struct sap_acs_cfg *acs_cfg); +uint32_t sap_select_default_oper_chan(struct mac_context *mac_ctx, + struct sap_acs_cfg *acs_cfg); /* * sap_is_dfs_cac_wait_state() - check if sap is in cac wait state