diff --git a/components/mlme/core/src/wlan_mlme_main.c b/components/mlme/core/src/wlan_mlme_main.c index 5bd458cf74..898dcbd459 100644 --- a/components/mlme/core/src/wlan_mlme_main.c +++ b/components/mlme/core/src/wlan_mlme_main.c @@ -533,6 +533,25 @@ static void mlme_init_emlsr_mode(struct wlan_objmgr_psoc *psoc, } #endif +#if defined(WLAN_FEATURE_SR) +/** + * mlme_init_sr_ini_cfg() - initialize SR(Spatial Reuse) ini + * @psoc: Pointer to PSOC + * @gen: pointer to generic CFG items + * + * Return: None + */ +static void mlme_init_sr_ini_cfg(struct wlan_objmgr_psoc *psoc, + struct wlan_mlme_generic *gen) +{ + gen->sr_enable_modes = cfg_get(psoc, CFG_SR_ENABLE_MODES); +} +#else +static void mlme_init_sr_ini_cfg(struct wlan_objmgr_psoc *psoc, + struct wlan_mlme_generic *gen) +{} +#endif + static void mlme_init_generic_cfg(struct wlan_objmgr_psoc *psoc, struct wlan_mlme_generic *gen) { @@ -597,6 +616,7 @@ static void mlme_init_generic_cfg(struct wlan_objmgr_psoc *psoc, gen->tx_retry_multiplier = cfg_get(psoc, CFG_TX_RETRY_MULTIPLIER); gen->enable_he_mcs0_for_6ghz_mgmt = cfg_get(psoc, CFG_ENABLE_HE_MCS0_MGMT_6GHZ); + mlme_init_sr_ini_cfg(psoc, gen); mlme_init_wds_config_cfg(psoc, gen); mlme_init_mgmt_hw_tx_retry_count_cfg(psoc, gen); mlme_init_relaxed_6ghz_conn_policy(psoc, gen); diff --git a/components/mlme/dispatcher/inc/cfg_mlme_generic.h b/components/mlme/dispatcher/inc/cfg_mlme_generic.h index 6898d053c3..fa56c1e4ad 100644 --- a/components/mlme/dispatcher/inc/cfg_mlme_generic.h +++ b/components/mlme/dispatcher/inc/cfg_mlme_generic.h @@ -1023,6 +1023,41 @@ enum debug_packet_log_type { "", \ "Set mgmt action frame hw tx retry count") +#if defined(WLAN_FEATURE_SR) +/* + * + * sr_enable_modes - Modes for which SR(Spatial Reuse) feature can be enabled + * @Min: 0x00 + * @Max: 0xf + * @Default: 0x1 + * + * This ini is used to check for which mode SR feature is enabled + * + * Bit 0: Enable/Disable SR feature for STA + * Bit 1: Enable/Disable SR feature for SAP + * Bit 2: Enable/Disable SR feature for P2P CLI + * Bit 3: Enable/Disable SR feature for P2P GO + * + * Related: None + * + * Supported Feature: STA/SAP + * + * Usage: External + * + * + */ +#define CFG_SR_ENABLE_MODES CFG_INI_UINT( \ + "sr_enable_modes",\ + 0x0,\ + 0xf,\ + 0x1,\ + CFG_VALUE_OR_DEFAULT, \ + "To decide for which mode SR feature is enabled") +#define CFG_SR_ENABLE_MODES_ALL CFG(CFG_SR_ENABLE_MODES) +#else +#define CFG_SR_ENABLE_MODES_ALL +#endif + #define CFG_GENERIC_ALL \ CFG(CFG_ENABLE_DEBUG_PACKET_LOG) \ CFG(CFG_PMF_SA_QUERY_MAX_RETRIES) \ @@ -1062,5 +1097,6 @@ enum debug_packet_log_type { CFG(CFG_TX_RETRY_MULTIPLIER) \ CFG(CFG_MGMT_FRAME_HW_TX_RETRY_COUNT) \ CFG_RELAX_6GHZ_CONN_POLICY \ - CFG_EMLSR_MODE_ENABLED + CFG_EMLSR_MODE_ENABLED \ + CFG_SR_ENABLE_MODES_ALL #endif /* __CFG_MLME_GENERIC_H */ diff --git a/components/mlme/dispatcher/inc/wlan_mlme_api.h b/components/mlme/dispatcher/inc/wlan_mlme_api.h index 5e76736713..6491573628 100644 --- a/components/mlme/dispatcher/inc/wlan_mlme_api.h +++ b/components/mlme/dispatcher/inc/wlan_mlme_api.h @@ -3984,4 +3984,17 @@ wlan_mlme_get_ch_width_from_phymode(enum wlan_phymode phy_mode); */ enum phy_ch_width wlan_mlme_get_peer_ch_width(struct wlan_objmgr_psoc *psoc, uint8_t *mac); + +#if defined(WLAN_FEATURE_SR) +/** + * wlan_mlme_get_sr_enable_modes() - get mode for which SR is enabled + * + * @psoc: psoc context + * @val: pointer to hold the value of SR(Spatial Reuse) enable modes + * + * Return: void + */ +void +wlan_mlme_get_sr_enable_modes(struct wlan_objmgr_psoc *psoc, uint8_t *val); +#endif #endif /* _WLAN_MLME_API_H_ */ diff --git a/components/mlme/dispatcher/inc/wlan_mlme_public_struct.h b/components/mlme/dispatcher/inc/wlan_mlme_public_struct.h index c4e72d4693..82f5e06dab 100644 --- a/components/mlme/dispatcher/inc/wlan_mlme_public_struct.h +++ b/components/mlme/dispatcher/inc/wlan_mlme_public_struct.h @@ -1362,6 +1362,7 @@ struct wlan_user_mcc_quota { * @enable_emlsr_mode: 11BE eMLSR mode support * @safe_mode_enable: safe mode to bypass some strict 6 GHz checks for * connection, bypass strict power levels + * @sr_enable_modes: modes for which SR(Spatial Reuse) is enabled */ struct wlan_mlme_generic { uint32_t band_capability; @@ -1420,6 +1421,9 @@ struct wlan_mlme_generic { struct wlan_user_mcc_quota user_mcc_quota; #endif bool safe_mode_enable; +#if defined(WLAN_FEATURE_SR) + uint32_t sr_enable_modes; +#endif }; /* diff --git a/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h b/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h index 219c2f9e26..5b32e04c9c 100644 --- a/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h +++ b/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h @@ -4798,4 +4798,28 @@ ucfg_mlme_get_peer_ch_width(struct wlan_objmgr_psoc *psoc, uint8_t *mac) */ enum wlan_phymode ucfg_mlme_get_vdev_phy_mode(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id); + +#if defined(WLAN_FEATURE_SR) +/** + * ucfg_mlme_get_sr_enable_modes() - check for which mode SR is enabled + * + * @psoc: pointer to psoc object + * @val: SR(Spatial Reuse) enable modes + * + * Return: void + */ +static inline void +ucfg_mlme_get_sr_enable_modes(struct wlan_objmgr_psoc *psoc, + uint8_t *val) +{ + wlan_mlme_get_sr_enable_modes(psoc, val); +} +#else +static inline void +ucfg_mlme_get_sr_enable_modes(struct wlan_objmgr_psoc *psoc, + uint8_t *val) +{ + *val = 0; +} +#endif #endif /* _WLAN_MLME_UCFG_API_H_ */ diff --git a/components/mlme/dispatcher/src/wlan_mlme_api.c b/components/mlme/dispatcher/src/wlan_mlme_api.c index 647adf647c..a3981a0606 100644 --- a/components/mlme/dispatcher/src/wlan_mlme_api.c +++ b/components/mlme/dispatcher/src/wlan_mlme_api.c @@ -1051,6 +1051,19 @@ QDF_STATUS mlme_update_tgt_he_caps_in_cfg(struct wlan_objmgr_psoc *psoc, return status; } +#ifdef WLAN_FEATURE_SR +void +wlan_mlme_get_sr_enable_modes(struct wlan_objmgr_psoc *psoc, uint8_t *val) +{ + struct wlan_mlme_psoc_ext_obj *mlme_obj = mlme_get_psoc_ext_obj(psoc); + + if (!mlme_obj) { + *val = cfg_default(CFG_SR_ENABLE_MODES); + return; + } + *val = mlme_obj->cfg.gen.sr_enable_modes; +} +#endif #endif #ifdef WLAN_FEATURE_11BE diff --git a/core/hdd/src/wlan_hdd_he.c b/core/hdd/src/wlan_hdd_he.c index e90901a18e..7de0213c39 100644 --- a/core/hdd/src/wlan_hdd_he.c +++ b/core/hdd/src/wlan_hdd_he.c @@ -32,6 +32,7 @@ #include "wlan_mlme_ucfg_api.h" #include "spatial_reuse_ucfg_api.h" #include "cdp_txrx_host_stats.h" +#include "wlan_policy_mgr_i.h" const struct nla_policy wlan_hdd_sr_policy[QCA_WLAN_VENDOR_ATTR_SR_MAX + 1] = { @@ -601,6 +602,7 @@ static int __wlan_hdd_cfg80211_sr_operations(struct wiphy *wiphy, struct sk_buff *skb; struct cdp_pdev_obss_pd_stats_tlv stats; ol_txrx_soc_handle soc; + uint8_t sr_device_modes; hdd_enter_dev(wdev->netdev); if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam() || @@ -608,6 +610,16 @@ static int __wlan_hdd_cfg80211_sr_operations(struct wiphy *wiphy, hdd_err("Command not allowed in FTM or Monitor mode"); return -EPERM; } + /** + * Reject command if SR concurrency is not allowed and + * only STA mode is set in ini to enable SR. + **/ + ucfg_mlme_get_sr_enable_modes(hdd_ctx->psoc, &sr_device_modes); + if (!(sr_device_modes & (1 << adapter->device_mode))) { + hdd_debug("SR operation not allowed for mode %d", + adapter->device_mode); + return -EINVAL; + } ret = wlan_hdd_validate_context(hdd_ctx); if (0 != ret)