From e728680f11e958e74dd0a32e0147ba1c1738c2f4 Mon Sep 17 00:00:00 2001 From: Jayachandran Sreekumaran Date: Tue, 10 May 2022 16:18:03 +0530 Subject: [PATCH] qcacld-3.0: Add spatial reuse feature support Add SAP mode support for non-srg spatial reuse. Change-Id: Ic575eefd0d36b6750d826c9bccbd53f07ae9ea75 CRs-Fixed: 3213404 --- Kbuild | 20 ++++++ .../dispatcher/inc/spatial_reuse_api.h | 40 +++++++++++ .../dispatcher/inc/spatial_reuse_ucfg_api.h | 64 +++++++++++++++++ .../dispatcher/src/spatial_reuse_api.c | 42 +++++++++++ .../dispatcher/src/spatial_reuse_ucfg_api.c | 62 ++++++++++++++++ core/hdd/src/wlan_hdd_assoc.c | 1 + core/hdd/src/wlan_hdd_cm_connect.c | 2 + core/hdd/src/wlan_hdd_cm_disconnect.c | 2 + core/hdd/src/wlan_hdd_hostapd.c | 66 +++++++++++++++++ core/hdd/src/wlan_hdd_hostapd.h | 21 ++++++ core/mac/src/include/parser_api.h | 43 ++++++++++- .../src/pe/lim/lim_process_sme_req_messages.c | 7 ++ .../src/pe/lim/lim_send_management_frames.c | 4 ++ .../src/pe/lim/lim_send_sme_rsp_messages.c | 38 ++++++++++ core/mac/src/pe/sch/sch_beacon_gen.c | 10 +++ .../src/sys/legacy/src/utils/src/parser_api.c | 27 +++++++ core/wma/inc/wma_internal.h | 19 +++++ core/wma/src/wma_dev_if.c | 2 + core/wma/src/wma_features.c | 71 +++++++++++++++++++ 19 files changed, 540 insertions(+), 1 deletion(-) create mode 100644 components/spatial_reuse/dispatcher/inc/spatial_reuse_api.h create mode 100644 components/spatial_reuse/dispatcher/inc/spatial_reuse_ucfg_api.h create mode 100644 components/spatial_reuse/dispatcher/src/spatial_reuse_api.c create mode 100644 components/spatial_reuse/dispatcher/src/spatial_reuse_ucfg_api.c diff --git a/Kbuild b/Kbuild index 28d1415f4f..b299130e21 100644 --- a/Kbuild +++ b/Kbuild @@ -2530,6 +2530,22 @@ $(call add-wlan-objs,son,$(WLAN_SON_OBJS)) ####################################################### +######################### SPATIAL_REUSE ######################### +SR_UCFG_DIR := components/spatial_reuse/dispatcher/src +SR_UCFG_INC := -I$(WLAN_ROOT)/components/spatial_reuse/dispatcher/inc +SR_TGT_DIR := $(WLAN_COMMON_ROOT)/target_if/spatial_reuse/src +SR_TGT_INC := -I$(WLAN_COMMON_INC)/target_if/spatial_reuse/inc/ + +ifeq ($(CONFIG_WLAN_FEATURE_11AX), y) +WLAN_SR_OBJS := $(SR_UCFG_DIR)/spatial_reuse_ucfg_api.o \ + $(SR_UCFG_DIR)/spatial_reuse_api.o \ + $(SR_TGT_DIR)/target_if_spatial_reuse.o +endif + +$(call add-wlan-objs,spatial_reuse,$(WLAN_SR_OBJS)) + +####################################################### + ###### COEX ######## COEX_OS_IF_SRC := os_if/coex/src COEX_TGT_SRC := components/target_if/coex/src @@ -3019,7 +3035,11 @@ INCS += $(SON_CORE_INC) INCS += $(SON_UCFG_INC) INCS += $(SON_TGT_INC) INCS += $(SON_OS_IF_INC) +################ SPATIAL_REUSE ################ +INCS += $(SR_UCFG_INC) +INCS += $(SR_TGT_INC) ########################################## + INCS += $(UMAC_OBJMGR_INC) INCS += $(UMAC_MGMT_TXRX_INC) INCS += $(PMO_INC) diff --git a/components/spatial_reuse/dispatcher/inc/spatial_reuse_api.h b/components/spatial_reuse/dispatcher/inc/spatial_reuse_api.h new file mode 100644 index 0000000000..d4cea7cee7 --- /dev/null +++ b/components/spatial_reuse/dispatcher/inc/spatial_reuse_api.h @@ -0,0 +1,40 @@ +/* + * 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 above + * copyright notice and this permission notice appear in all copies. + + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * DOC : contains interface prototypes for spatial_reuse api + */ + +#ifndef _SPATIAL_REUSE_API_H_ +#define _SPATIAL_REUSE_API_H_ + +#include +#include +#include + +/** + * wlan_spatial_reuse_config_set() - Set spatial reuse config + * @vdev: objmgr manager vdev + * @sr_ctrl: spatial reuse control + * @non_srg_max_pd_offset: non-srg max pd offset + * + * Return: QDF_STATUS + */ +QDF_STATUS wlan_spatial_reuse_config_set(struct wlan_objmgr_vdev *vdev, + uint8_t sr_ctrl, + uint8_t non_srg_max_pd_offset); + +#endif diff --git a/components/spatial_reuse/dispatcher/inc/spatial_reuse_ucfg_api.h b/components/spatial_reuse/dispatcher/inc/spatial_reuse_ucfg_api.h new file mode 100644 index 0000000000..adcbcbe18d --- /dev/null +++ b/components/spatial_reuse/dispatcher/inc/spatial_reuse_ucfg_api.h @@ -0,0 +1,64 @@ +/* + * 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 above + * copyright notice and this permission notice appear in all copies. + + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * DOC : contains interface prototypes for OS_IF layer + */ +#ifndef _SPATIAL_REUSE_UCFG_API_H_ +#define _SPATIAL_REUSE_UCFG_API_H_ + +#include +#include + +/** + * ucfg_spatial_reuse_get_sr_config() - Spatial reuse config get + * + * @vdev: object manager vdev + * @sr_ctrl: spatial reuse sr control + * @non_srg_max_pd_offset: non-srg max pd offset + * @he_spr_enabled: spatial reuse enabled + * + * Return: void + */ +void ucfg_spatial_reuse_get_sr_config(struct wlan_objmgr_vdev *vdev, + uint8_t *sr_ctrl, + uint8_t *non_srg_max_pd_offset, + bool *he_spr_enabled); +/** + * ucfg_spatial_reuse_get_sr_config() - Spatial reuse config set + * + * @vdev: object manager vdev + * @sr_ctrl: spatial reuse sr control + * @non_srg_max_pd_offset: non-srg max pd offset + * @he_spr_enabled: Spatial reuse enabled + * + * Return: void + */ +void ucfg_spatial_reuse_set_sr_config(struct wlan_objmgr_vdev *vdev, + uint8_t sr_ctrl, + uint8_t non_srg_max_pd_offset); +/** + * ucfg_spatial_reuse_send_sr_config() - Send spatial reuse config to fw + * + * @vdev: object manager vdev + * @enable: spatial reuse config to be enabled or not + * + * Return: void + */ +void ucfg_spatial_reuse_send_sr_config(struct wlan_objmgr_vdev *vdev, + bool enable); +#endif + diff --git a/components/spatial_reuse/dispatcher/src/spatial_reuse_api.c b/components/spatial_reuse/dispatcher/src/spatial_reuse_api.c new file mode 100644 index 0000000000..8a22a75aed --- /dev/null +++ b/components/spatial_reuse/dispatcher/src/spatial_reuse_api.c @@ -0,0 +1,42 @@ +/* + * 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 above + * copyright notice and this permission notice appear in all copies. + + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * DOC : contains interface prototypes for spatial_reuse api + */ + +#include + +QDF_STATUS wlan_spatial_reuse_config_set(struct wlan_objmgr_vdev *vdev, + uint8_t sr_ctrl, + uint8_t non_srg_max_pd_offset) +{ + struct wlan_lmac_if_tx_ops *tx_ops; + struct wlan_objmgr_psoc *psoc = wlan_vdev_get_psoc(vdev); + + if (!psoc) + return QDF_STATUS_E_NULL_VALUE; + + tx_ops = wlan_psoc_get_lmac_if_txops(psoc); + if (!tx_ops) + return QDF_STATUS_E_NULL_VALUE; + + if (tx_ops->spatial_reuse_tx_ops.send_cfg) + return tx_ops->spatial_reuse_tx_ops.send_cfg(vdev, sr_ctrl, + non_srg_max_pd_offset); + + return QDF_STATUS_E_NULL_VALUE; +} diff --git a/components/spatial_reuse/dispatcher/src/spatial_reuse_ucfg_api.c b/components/spatial_reuse/dispatcher/src/spatial_reuse_ucfg_api.c new file mode 100644 index 0000000000..581af86b62 --- /dev/null +++ b/components/spatial_reuse/dispatcher/src/spatial_reuse_ucfg_api.c @@ -0,0 +1,62 @@ +/* + * 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 above + * copyright notice and this permission notice appear in all copies. + + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * DOC : contains interface prototypes for OS_IF layer + */ + +#include +#include +#include + +void ucfg_spatial_reuse_get_sr_config(struct wlan_objmgr_vdev *vdev, + uint8_t *sr_ctrl, + uint8_t *non_srg_max_pd_offset, + bool *he_spr_enabled) +{ + *sr_ctrl = wlan_vdev_mlme_get_sr_ctrl(vdev); + *non_srg_max_pd_offset = wlan_vdev_mlme_get_pd_offset(vdev); + *he_spr_enabled = wlan_vdev_mlme_get_he_spr_enabled(vdev); +} + +void ucfg_spatial_reuse_set_sr_config(struct wlan_objmgr_vdev *vdev, + uint8_t sr_ctrl, + uint8_t non_srg_max_pd_offset) +{ + wlan_vdev_mlme_set_sr_ctrl(vdev, sr_ctrl); + wlan_vdev_mlme_set_pd_offset(vdev, non_srg_max_pd_offset); +} + +void ucfg_spatial_reuse_send_sr_config(struct wlan_objmgr_vdev *vdev, + bool enable) +{ + uint8_t sr_ctrl = 0; + uint8_t non_srg_max_pd_offset = 0; + + if (enable && (!wlan_vdev_mlme_get_he_spr_enabled(vdev))) { + sr_ctrl = wlan_vdev_mlme_get_sr_ctrl(vdev); + non_srg_max_pd_offset = wlan_vdev_mlme_get_pd_offset(vdev); + if (sr_ctrl && non_srg_max_pd_offset) { + wlan_spatial_reuse_config_set(vdev, sr_ctrl, + non_srg_max_pd_offset); + wlan_vdev_mlme_set_he_spr_enabled(vdev, true); + } + } else if (!enable && wlan_vdev_mlme_get_he_spr_enabled(vdev)) { + wlan_spatial_reuse_config_set(vdev, sr_ctrl, + non_srg_max_pd_offset); + wlan_vdev_mlme_set_he_spr_enabled(vdev, false); + } +} diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index dfe118864a..456e38554f 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -2121,6 +2121,7 @@ static void hdd_roam_channel_switch_handler(struct hdd_adapter *adapter, policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->psoc); wlan_twt_concurrency_update(hdd_ctx); + hdd_update_he_obss_pd(adapter, NULL, true); } #ifdef WLAN_FEATURE_HOST_ROAM diff --git a/core/hdd/src/wlan_hdd_cm_connect.c b/core/hdd/src/wlan_hdd_cm_connect.c index 1351b8b9e6..fe1809c13f 100644 --- a/core/hdd/src/wlan_hdd_cm_connect.c +++ b/core/hdd/src/wlan_hdd_cm_connect.c @@ -746,6 +746,7 @@ hdd_cm_connect_failure_post_user_update(struct wlan_objmgr_vdev *vdev, WLAN_CONTROL_PATH); hdd_periodic_sta_stats_start(adapter); wlan_twt_concurrency_update(hdd_ctx); + hdd_update_he_obss_pd(adapter, NULL, false); } static void hdd_cm_connect_failure(struct wlan_objmgr_vdev *vdev, @@ -1351,6 +1352,7 @@ hdd_cm_connect_success_post_user_update(struct wlan_objmgr_vdev *vdev, } hdd_periodic_sta_stats_start(adapter); wlan_twt_concurrency_update(hdd_ctx); + hdd_update_he_obss_pd(adapter, NULL, true); } static void hdd_cm_connect_success(struct wlan_objmgr_vdev *vdev, diff --git a/core/hdd/src/wlan_hdd_cm_disconnect.c b/core/hdd/src/wlan_hdd_cm_disconnect.c index 4116ef0911..1ffe95c84c 100644 --- a/core/hdd/src/wlan_hdd_cm_disconnect.c +++ b/core/hdd/src/wlan_hdd_cm_disconnect.c @@ -49,6 +49,7 @@ #include "wlan_hdd_cfr.h" #include "wlan_roam_debug.h" #include "wma_api.h" +#include "wlan_hdd_hostapd.h" void hdd_handle_disassociation_event(struct hdd_adapter *adapter, struct qdf_mac_addr *peer_macaddr) @@ -449,6 +450,7 @@ hdd_cm_disconnect_complete_post_user_update(struct wlan_objmgr_vdev *vdev, hdd_cm_set_default_wlm_mode(adapter); __hdd_cm_disconnect_handler_post_user_update(adapter, vdev); wlan_twt_concurrency_update(hdd_ctx); + hdd_update_he_obss_pd(adapter, NULL, false); hdd_cm_reset_udp_qos_upgrade_config(adapter); return QDF_STATUS_SUCCESS; diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index eb4ec31892..cc6b13df1d 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -106,6 +106,7 @@ #ifdef WLAN_FEATURE_11BE_MLO #include #endif +#include "spatial_reuse_ucfg_api.h" #include "wlan_hdd_son.h" #include "wlan_hdd_mcc_quota.h" #include "wlan_hdd_wds.h" @@ -6495,6 +6496,7 @@ error: free: wlan_twt_concurrency_update(hdd_ctx); + hdd_update_he_obss_pd(adapter, NULL, true); if (deliver_start_evt) { status = ucfg_if_mgr_deliver_event( vdev, @@ -6662,6 +6664,7 @@ static int __wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy, false); wlan_twt_concurrency_update(hdd_ctx); wlan_set_sap_user_config_freq(adapter->vdev, 0); + hdd_update_he_obss_pd(adapter, NULL, false); status = ucfg_if_mgr_deliver_event(adapter->vdev, WLAN_IF_MGR_EV_AP_STOP_BSS_COMPLETE, NULL); @@ -7144,6 +7147,66 @@ wlan_util_get_centre_freq(struct wireless_dev *wdev, unsigned int link_id) return wdev->chandef.chan->center_freq; } #endif + +#if defined WLAN_FEATURE_11AX +void hdd_update_he_obss_pd(struct hdd_adapter *adapter, + struct cfg80211_ap_settings *params, + bool iface_start) +{ + struct wlan_objmgr_vdev *vdev, *conc_vdev; + uint8_t vdev_id = adapter->vdev_id; + uint8_t mac_id; + struct wlan_objmgr_psoc *psoc; + uint32_t conc_vdev_id; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \ + defined(CFG80211_SPATIAL_REUSE_EXT_BACKPORT) + struct ieee80211_he_obss_pd *obss_pd; +#endif + + vdev = hdd_objmgr_get_vdev_by_user(adapter, WLAN_OSIF_ID); + if (!vdev) + return; + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \ + defined(CFG80211_SPATIAL_REUSE_EXT_BACKPORT) + if (params && params->he_obss_pd.enable) { + obss_pd = ¶ms->he_obss_pd; + ucfg_spatial_reuse_set_sr_config(vdev, + obss_pd->sr_ctrl, + obss_pd->non_srg_max_offset); + hdd_debug("obss_pd_enable: %d, sr_ctrl: %d, non_srg_max_offset: %d", + obss_pd->enable, obss_pd->sr_ctrl, + obss_pd->non_srg_max_offset); + } +#endif + + psoc = wlan_vdev_get_psoc(vdev); + policy_mgr_get_mac_id_by_session_id(psoc, vdev_id, &mac_id); + conc_vdev_id = policy_mgr_get_conc_vdev_on_same_mac(psoc, vdev_id, + mac_id); + if (conc_vdev_id != WLAN_INVALID_VDEV_ID) { + conc_vdev = + wlan_objmgr_get_vdev_by_id_from_psoc( + psoc, conc_vdev_id, + WLAN_HDD_ID_OBJ_MGR); + if (!conc_vdev) + goto release_ref; + + if (iface_start) { + ucfg_spatial_reuse_send_sr_config(conc_vdev, false); + hdd_debug("disable obss pd for vdev:%d", conc_vdev_id); + } else { + ucfg_spatial_reuse_send_sr_config(conc_vdev, true); + hdd_debug("enable obss pd for vdev:%d", conc_vdev_id); + } + wlan_objmgr_vdev_release_ref(conc_vdev, WLAN_HDD_ID_OBJ_MGR); + } + +release_ref: + hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_ID); +} +#endif + /** * __wlan_hdd_cfg80211_start_ap() - start soft ap mode * @wiphy: Pointer to wiphy structure @@ -7458,6 +7521,9 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, */ wlan_hdd_update_twt_responder(hdd_ctx, params); + /* Enable/disable non-srg obss pd spatial reuse */ + hdd_update_he_obss_pd(adapter, params, true); + hdd_place_marker(adapter, "TRY TO START", NULL); status = wlan_hdd_cfg80211_start_bss(adapter, diff --git a/core/hdd/src/wlan_hdd_hostapd.h b/core/hdd/src/wlan_hdd_hostapd.h index d39a38b3b9..f58d377478 100644 --- a/core/hdd/src/wlan_hdd_hostapd.h +++ b/core/hdd/src/wlan_hdd_hostapd.h @@ -449,6 +449,27 @@ void hdd_stop_sap_due_to_invalid_channel(struct work_struct *work); */ bool hdd_is_any_sta_connecting(struct hdd_context *hdd_ctx); +#ifdef WLAN_FEATURE_11AX +/** + * hdd_update_he_obss_pd() - Enable or disable spatial reuse + * based on user space input and concurrency combination. + * @adapter: Pointer to hostapd adapter + * @params: Pointer to AP configuration from cfg80211 + * @iface_start: Interface start or not + * + * Return: void + */ +void hdd_update_he_obss_pd(struct hdd_adapter *adapter, + struct cfg80211_ap_settings *params, + bool iface_start); +#else +static inline void hdd_update_he_obss_pd(struct hdd_adapter *adapter, + struct cfg80211_ap_settings *params, + bool iface_start) +{ +} +#endif + #ifdef WLAN_FEATURE_11BE_MLO /** * wlan_hdd_mlo_reset() - reset mlo configuration if start bss fails diff --git a/core/mac/src/include/parser_api.h b/core/mac/src/include/parser_api.h index 42d206b53f..fcfc89c61c 100644 --- a/core/mac/src/include/parser_api.h +++ b/core/mac/src/include/parser_api.h @@ -1258,6 +1258,15 @@ void update_fils_data(struct sir_fils_indication *fils_ind, tDot11fIEfils_indication * fils_indication); #endif #ifdef WLAN_FEATURE_11AX +/** + * populate_dot11f_he_caps() - populate he capabilities IE + * in beacon/probe response structure + * @mac_context: pointer to mac context + * @pe_session: pointer to pe session + * @he_cap: he capability IE + * + * Return: QDF_STATUS + */ QDF_STATUS populate_dot11f_he_caps(struct mac_context *, struct pe_session *, tDot11fIEhe_cap *); @@ -1273,10 +1282,34 @@ QDF_STATUS populate_dot11f_he_caps_by_band(struct mac_context *mac_ctx, bool is_2g, tDot11fIEhe_cap *he_cap); + +/** + * populate_dot11f_he_operation() - populate he operation IE + * in beacon/probe response structure + * @mac_context: pointer to mac context + * @pe_session: pointer to pe session + * @he_op: he operation IE + * + * Return: QDF_STATUS + */ QDF_STATUS populate_dot11f_he_operation(struct mac_context *, struct pe_session *, tDot11fIEhe_op *); + /** - * populate_dot11f_he_6ghz_cap() - pouldate HE 6GHz caps IE + * populate_dot11f_sr_info() - populate tDot11fIEspatial_reuse to + * beacon/probe response structure. + * @mac_context: pointer to mac context + * @pe_session: pointer to pe session + * @sr_info: spatial reuse IE + * + * Return: QDF_STATUS + */ +QDF_STATUS populate_dot11f_sr_info(struct mac_context *mac_ctx, + struct pe_session *session, + tDot11fIEspatial_reuse *sr_info); + +/** + * populate_dot11f_he_6ghz_cap() - populdate HE 6GHz caps IE * @mac_ctx: Global MAC context * @session: PE session * @he_6g_cap: pointer to HE 6GHz IE @@ -1336,6 +1369,14 @@ static inline QDF_STATUS populate_dot11f_he_bss_color_change( { return QDF_STATUS_SUCCESS; } + +static inline QDF_STATUS populate_dot11f_sr_info( + struct mac_context *mac_ctx, + struct pe_session *session, + tDot11fIEspatial_reuse *sr_info) +{ + return QDF_STATUS_SUCCESS; +} #endif #if defined(WLAN_FEATURE_11AX) && defined(WLAN_SUPPORT_TWT) diff --git a/core/mac/src/pe/lim/lim_process_sme_req_messages.c b/core/mac/src/pe/lim/lim_process_sme_req_messages.c index 452ed9aa31..427a945ff0 100644 --- a/core/mac/src/pe/lim/lim_process_sme_req_messages.c +++ b/core/mac/src/pe/lim/lim_process_sme_req_messages.c @@ -69,6 +69,7 @@ #include #include "cfg_ucfg_api.h" #include "wlan_twt_cfg_ext_api.h" +#include /* SME REQ processing function templates */ static bool __lim_process_sme_sys_ready_ind(struct mac_context *, uint32_t *); @@ -9358,6 +9359,12 @@ void lim_process_set_he_bss_color(struct mac_context *mac_ctx, uint32_t *msg_buf beacon_params.bss_color = session_entry->he_op.bss_color; session_entry->bss_color_changing = 1; + if (wlan_vdev_mlme_get_he_spr_enabled(session_entry->vdev)) { + /* Disable spatial reuse during BSS color change */ + wlan_spatial_reuse_config_set(session_entry->vdev, 0, 0); + wlan_vdev_mlme_set_he_spr_enabled(session_entry->vdev, false); + } + if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) != QDF_STATUS_SUCCESS) { pe_err("Unable to set op mode IE in beacon"); diff --git a/core/mac/src/pe/lim/lim_send_management_frames.c b/core/mac/src/pe/lim/lim_send_management_frames.c index db05b79c14..a1b110a262 100644 --- a/core/mac/src/pe/lim/lim_send_management_frames.c +++ b/core/mac/src/pe/lim/lim_send_management_frames.c @@ -875,6 +875,8 @@ lim_send_probe_rsp_mgmt_frame(struct mac_context *mac_ctx, &frm->he_cap); populate_dot11f_he_operation(mac_ctx, pe_session, &frm->he_op); + populate_dot11f_sr_info(mac_ctx, pe_session, + &frm->spatial_reuse); populate_dot11f_he_6ghz_cap(mac_ctx, pe_session, &frm->he_6ghz_band_cap); } @@ -1738,6 +1740,8 @@ lim_send_assoc_rsp_mgmt_frame(struct mac_context *mac_ctx, lim_is_session_he_capable(pe_session)) { populate_dot11f_he_caps(mac_ctx, pe_session, &frm.he_cap); + populate_dot11f_sr_info(mac_ctx, pe_session, + &frm.spatial_reuse); populate_dot11f_he_operation(mac_ctx, pe_session, &frm.he_op); populate_dot11f_he_6ghz_cap(mac_ctx, pe_session, diff --git a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c index 89144602fd..92d600837e 100644 --- a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c +++ b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c @@ -57,6 +57,7 @@ #include "wma.h" #include <../../core/src/wlan_cm_vdev_api.h> #include +#include void lim_send_sme_rsp(struct mac_context *mac_ctx, uint16_t msg_type, tSirResultCodes result_code, uint8_t vdev_id) @@ -2288,6 +2289,37 @@ lim_send_bss_color_change_ie_update(struct mac_context *mac_ctx, session->he_bss_color_change.countdown); } +static void +lim_update_spatial_reuse(struct pe_session *session) +{ + struct wlan_objmgr_psoc *psoc; + uint32_t conc_vdev_id; + uint8_t mac_id, sr_ctrl, non_srg_pd_max_offset; + uint8_t vdev_id = session->vdev_id; + + sr_ctrl = wlan_vdev_mlme_get_sr_ctrl(session->vdev); + non_srg_pd_max_offset = wlan_vdev_mlme_get_pd_offset(session->vdev); + if (non_srg_pd_max_offset && sr_ctrl && + !wlan_vdev_mlme_get_he_spr_enabled(session->vdev)) { + psoc = wlan_vdev_get_psoc(session->vdev); + policy_mgr_get_mac_id_by_session_id(psoc, + vdev_id, + &mac_id); + conc_vdev_id = policy_mgr_get_conc_vdev_on_same_mac(psoc, + vdev_id, + mac_id); + if (conc_vdev_id == WLAN_INVALID_VDEV_ID) { + /* + * Enable spatial reuse only if no concurrent + * vdev running on same mac + */ + wlan_spatial_reuse_config_set(session->vdev, sr_ctrl, + non_srg_pd_max_offset); + wlan_vdev_mlme_set_he_spr_enabled(session->vdev, true); + } + } +} + static void lim_handle_bss_color_change_ie(struct mac_context *mac_ctx, struct pe_session *session) @@ -2305,6 +2337,12 @@ lim_handle_bss_color_change_ie(struct mac_context *mac_ctx, session->he_bss_color_change.countdown--; } else { session->bss_color_changing = 0; + /* + * On OBSS color collision detection, spatial reuse + * gets disabled. Enable spatial reuse if it was + * enabled during AP start + */ + lim_update_spatial_reuse(session); qdf_mem_zero(&beacon_params, sizeof(beacon_params)); session->he_op.bss_col_disabled = 0; session->he_op.bss_color = diff --git a/core/mac/src/pe/sch/sch_beacon_gen.c b/core/mac/src/pe/sch/sch_beacon_gen.c index b66115e5b3..14eddd8625 100644 --- a/core/mac/src/pe/sch/sch_beacon_gen.c +++ b/core/mac/src/pe/sch/sch_beacon_gen.c @@ -744,6 +744,8 @@ sch_set_fixed_beacon_fields(struct mac_context *mac_ctx, struct pe_session *sess &bcn_2->he_cap); populate_dot11f_he_operation(mac_ctx, session, &bcn_2->he_op); + populate_dot11f_sr_info(mac_ctx, session, + &bcn_2->spatial_reuse); populate_dot11f_he_6ghz_cap(mac_ctx, session, &bcn_2->he_6ghz_band_cap); populate_dot11f_he_bss_color_change(mac_ctx, session, @@ -1294,6 +1296,14 @@ void lim_update_probe_rsp_template_ie_bitmap_beacon2(struct mac_context *mac, sizeof(beacon2->he_op)); } + if (beacon2->spatial_reuse.present) { + set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, + DOT11F_EID_SPATIAL_REUSE); + qdf_mem_copy((void *)&prb_rsp->spatial_reuse, + (void *)&beacon2->spatial_reuse, + sizeof(beacon2->spatial_reuse)); + } + if (beacon2->he_6ghz_band_cap.present) { set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, DOT11F_EID_HE_6GHZ_BAND_CAP); diff --git a/core/mac/src/sys/legacy/src/utils/src/parser_api.c b/core/mac/src/sys/legacy/src/utils/src/parser_api.c index 657a4b645f..5dee726a98 100644 --- a/core/mac/src/sys/legacy/src/utils/src/parser_api.c +++ b/core/mac/src/sys/legacy/src/utils/src/parser_api.c @@ -49,6 +49,7 @@ #include "wlan_reg_services_api.h" #include "wlan_cm_roam_api.h" #include "wlan_mlo_mgr_sta.h" +#include #ifdef WLAN_FEATURE_11BE_MLO #include #include @@ -7085,6 +7086,32 @@ populate_dot11f_he_operation(struct mac_context *mac_ctx, return QDF_STATUS_SUCCESS; } +QDF_STATUS +populate_dot11f_sr_info(struct mac_context *mac_ctx, + struct pe_session *session, + tDot11fIEspatial_reuse *sr_info) +{ + uint8_t non_srg_pd_offset; + uint8_t sr_ctrl = wlan_vdev_mlme_get_sr_ctrl(session->vdev); + bool sr_enabled = wlan_vdev_mlme_get_he_spr_enabled(session->vdev); + + if (!sr_enabled || !sr_ctrl || + (sr_ctrl & WLAN_HE_NON_SRG_PD_SR_DISALLOWED) || + !(sr_ctrl & WLAN_HE_NON_SRG_OFFSET_PRESENT)) + return QDF_STATUS_SUCCESS; + + non_srg_pd_offset = wlan_vdev_mlme_get_pd_offset(session->vdev); + sr_info->present = 1; + sr_info->psr_disallow = 1; + sr_info->non_srg_pd_sr_disallow = 0; + sr_info->srg_info_present = 0; + sr_info->non_srg_offset_present = 1; + sr_info->srg_info_present = 0; + sr_info->non_srg_offset.info.non_srg_pd_max_offset = non_srg_pd_offset; + + return QDF_STATUS_SUCCESS; +} + QDF_STATUS populate_dot11f_he_6ghz_cap(struct mac_context *mac_ctx, struct pe_session *session, diff --git a/core/wma/inc/wma_internal.h b/core/wma/inc/wma_internal.h index a0cbd09305..7267d0c6d4 100644 --- a/core/wma/inc/wma_internal.h +++ b/core/wma/inc/wma_internal.h @@ -1335,6 +1335,25 @@ static inline QDF_STATUS wma_set_tsf_gpio_pin(WMA_HANDLE handle, uint32_t pin) return QDF_STATUS_E_INVAL; } #endif + +#ifdef WLAN_FEATURE_11AX +/** + * wma_spr_update() - enable/disable spatial reuse + * @wma: wma handle + * @vdev_id: vdev id + * @enable: indicates spatial reuse enable/disable + * + * Return: QDF_STATUS_SUCCESS for success or error code + */ +QDF_STATUS wma_spr_update(tp_wma_handle wma, uint8_t vdev_id, bool enable); +#else +static inline QDF_STATUS wma_spr_update(tp_wma_handle wma, uint8_t vdev_id, + bool enable) +{ + return QDF_STATUS_SUCCESS; +} +#endif + QDF_STATUS wma_set_wisa_params(tp_wma_handle wma, struct sir_wisa_params *wisa); #ifdef DHCP_SERVER_OFFLOAD diff --git a/core/wma/src/wma_dev_if.c b/core/wma/src/wma_dev_if.c index 6a56f0522f..98ddfc4f31 100644 --- a/core/wma/src/wma_dev_if.c +++ b/core/wma/src/wma_dev_if.c @@ -1284,6 +1284,7 @@ QDF_STATUS wma_vdev_start_resp_handler(struct vdev_mlme_obj *vdev_mlme, wma_dcs_clear_vdev_starting(mac_ctx, rsp->vdev_id); wma_dcs_wlan_interference_mitigation_enable(mac_ctx, iface->mac_id, rsp); + wma_spr_update(wma, rsp->vdev_id, true); } #ifdef FEATURE_AP_MCC_CH_AVOIDANCE @@ -2304,6 +2305,7 @@ void wma_send_del_bss_response(tp_wma_handle wma, struct del_bss_resp *resp) vdev_id); cdp_fc_vdev_unpause(soc, vdev_id, OL_TXQ_PAUSE_REASON_VDEV_STOP, 0); wma_vdev_clear_pause_bit(vdev_id, PAUSE_TYPE_HOST); + wma_spr_update(wma, vdev_id, false); qdf_atomic_set(&iface->bss_status, WMA_BSS_STATUS_STOPPED); wma_debug("(type %d subtype %d) BSS is stopped", iface->type, iface->sub_type); diff --git a/core/wma/src/wma_features.c b/core/wma/src/wma_features.c index 8fafd79f73..3d14a89193 100644 --- a/core/wma/src/wma_features.c +++ b/core/wma/src/wma_features.c @@ -637,6 +637,77 @@ QDF_STATUS wma_process_dhcp_ind(WMA_HANDLE handle, &peer_set_param_fp); } +#if defined WLAN_FEATURE_11AX + +#define NON_SRG_PD_SR_DISALLOWED 0x02 +#define NON_SRG_OFFSET_PRESENT 0x04 +#define NON_SRG_SPR_ENABLE_POS 24 +#define NON_SRG_PARAM_VAL_DBM_UNIT 0x20 +#define NON_SRG_SPR_ENABLE 0x80 + +QDF_STATUS wma_spr_update(tp_wma_handle wma, + uint8_t vdev_id, + bool enable) +{ + struct pdev_params pparam; + uint32_t val = 0; + wmi_unified_t wmi_handle = wma->wmi_handle; + uint8_t mac_id; + uint32_t conc_vdev_id; + struct wlan_objmgr_vdev *vdev; + uint8_t sr_ctrl, non_srg_pd_max_offset; + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(wma->psoc, vdev_id, + WLAN_LEGACY_WMA_ID); + if (!vdev) { + wma_err("Can't get vdev by vdev_id:%d", vdev_id); + return QDF_STATUS_E_INVAL; + } + + sr_ctrl = wlan_vdev_mlme_get_sr_ctrl(vdev); + non_srg_pd_max_offset = wlan_vdev_mlme_get_pd_offset(vdev); + if (!(sr_ctrl & NON_SRG_PD_SR_DISALLOWED) && + (sr_ctrl & NON_SRG_OFFSET_PRESENT)) { + policy_mgr_get_mac_id_by_session_id(wma->psoc, + vdev_id, + &mac_id); + conc_vdev_id = + policy_mgr_get_conc_vdev_on_same_mac(wma->psoc, + vdev_id, + mac_id); + if (conc_vdev_id != WLAN_INVALID_VDEV_ID) { + wma_debug("Concurrent intf present,SR PD not enabled"); + goto release_ref; + } + qdf_mem_zero(&pparam, sizeof(pparam)); + pparam.param_id = WMI_PDEV_PARAM_SET_CMD_OBSS_PD_THRESHOLD; + if (enable) { + val = NON_SRG_SPR_ENABLE; + val |= NON_SRG_PARAM_VAL_DBM_UNIT; + val = val << NON_SRG_SPR_ENABLE_POS; + val |= non_srg_pd_max_offset; + wlan_vdev_mlme_set_he_spr_enabled(vdev, true); + } else { + wlan_vdev_mlme_set_he_spr_enabled(vdev, false); + } + + pparam.param_value = val; + + wma_debug("non-srg param val: %u, enable: %d", + pparam.param_value, enable); + + wmi_unified_pdev_param_send(wmi_handle, &pparam, + WMA_WILDCARD_PDEV_ID); + } else { + wma_debug("Spatial reuse not enabled"); + } + +release_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_WMA_ID); + return QDF_STATUS_SUCCESS; +} +#endif + #if defined(WLAN_FEATURE_11BE) static enum wlan_phymode wma_eht_chan_phy_mode(uint32_t freq, uint8_t dot11_mode, uint16_t bw_val,