diff --git a/target_if/spatial_reuse/inc/target_if_spatial_reuse.h b/target_if/spatial_reuse/inc/target_if_spatial_reuse.h index 8e6f8e135e..766fd8731d 100644 --- a/target_if/spatial_reuse/inc/target_if_spatial_reuse.h +++ b/target_if/spatial_reuse/inc/target_if_spatial_reuse.h @@ -27,21 +27,6 @@ #include #if defined WLAN_FEATURE_SR - -#define NON_SRG_PD_SR_DISALLOWED 0x02 -#define NON_SRG_OFFSET_PRESENT 0x04 -#define NON_SRG_SPR_ENABLE 1 -#define NON_SRG_SPR_ENABLE_POS 31 -#define NON_SRG_SPR_ENABLE_SIZE 1 -#define NON_SRG_PARAM_VAL_DBM_UNIT 1 -#define NON_SRG_PARAM_VAL_DBM_POS 29 -#define NON_SRG_PARAM_VAL_DBM_SIZE 1 -#define NON_SRG_MAX_PD_OFFSET_POS 0 -#define NON_SRG_MAX_PD_OFFSET_SIZE 8 -#define NON_SR_PD_THRESHOLD_MIN -82 -#define NON_SR_PD_THRESHOLD_DISABLED 0x80 -#define WILDCARD_PDEV_ID 0x0 - /** * target_if_spatial_reuse_register_tx_ops - tx_ops registration * @tx_ops: wlan_lmac_if_tx_ops diff --git a/target_if/spatial_reuse/src/target_if_spatial_reuse.c b/target_if/spatial_reuse/src/target_if_spatial_reuse.c index ebb90dc90f..8290233b0d 100644 --- a/target_if/spatial_reuse/src/target_if_spatial_reuse.c +++ b/target_if/spatial_reuse/src/target_if_spatial_reuse.c @@ -16,12 +16,13 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ - #include #include #include #include #include +#include +#include static QDF_STATUS spatial_reuse_send_cfg(struct wlan_objmgr_vdev *vdev, uint8_t sr_ctrl, @@ -42,9 +43,9 @@ static QDF_STATUS spatial_reuse_send_cfg(struct wlan_objmgr_vdev *vdev, (sr_ctrl & NON_SRG_OFFSET_PRESENT)) { QDF_SET_BITS(pparam.param_value, NON_SRG_SPR_ENABLE_POS, NON_SRG_SPR_ENABLE_SIZE, NON_SRG_SPR_ENABLE); - QDF_SET_BITS(pparam.param_value, NON_SRG_PARAM_VAL_DBM_POS, + QDF_SET_BITS(pparam.param_value, SR_PARAM_VAL_DBM_POS, NON_SRG_PARAM_VAL_DBM_SIZE, - NON_SRG_PARAM_VAL_DBM_UNIT); + SR_PARAM_VAL_DBM_UNIT); QDF_SET_BITS(pparam.param_value, NON_SRG_MAX_PD_OFFSET_POS, NON_SRG_MAX_PD_OFFSET_SIZE, non_srg_max_pd_offset); @@ -73,9 +74,92 @@ spatial_reuse_send_sr_prohibit_cfg(struct wlan_objmgr_vdev *vdev, return wmi_unified_vdev_param_sr_prohibit_send(wmi_handle, &srp_param); } +static QDF_STATUS +spatial_reuse_send_pd_threshold(struct wlan_objmgr_pdev *pdev, + uint8_t vdev_id, + uint32_t val) +{ + struct vdev_set_params vdev_param; + struct wmi_unified *wmi_handle; + bool sr_supported; + + wmi_handle = lmac_get_pdev_wmi_handle(pdev); + if (!wmi_handle) + return QDF_STATUS_E_INVAL; + + sr_supported = + wmi_service_enabled(wmi_handle, + wmi_service_srg_srp_spatial_reuse_support); + + if (sr_supported) { + qdf_mem_zero(&vdev_param, sizeof(vdev_param)); + vdev_param.vdev_id = vdev_id; + vdev_param.param_id = WMI_VDEV_PARAM_SET_CMD_OBSS_PD_THRESHOLD; + vdev_param.param_value = val; + return wmi_unified_vdev_set_param_send(wmi_handle, &vdev_param); + } else { + mlme_debug("Target doesn't support SR operations"); + } + return QDF_STATUS_SUCCESS; +} + +/** + * spatial_reuse_set_sr_enable_disable: To send wmi command to enable/disable SR + * + * @vdev: object manager vdev + * @pdev: object manager pdev + * @is_sr_enable: sr enable/disable + * @pd_threshold: pd threshold + * + * Return: Success/Failure + */ +static QDF_STATUS +spatial_reuse_set_sr_enable_disable(struct wlan_objmgr_vdev *vdev, + struct wlan_objmgr_pdev *pdev, + bool is_sr_enable, int32_t pd_threshold) +{ + uint32_t val = 0; + uint8_t sr_ctrl; + struct wlan_objmgr_psoc *psoc; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + psoc = wlan_pdev_get_psoc(pdev); + if (!psoc) + return QDF_STATUS_E_NOENT; + + sr_ctrl = wlan_vdev_mlme_get_sr_ctrl(vdev); + if ((!(sr_ctrl & NON_SRG_PD_SR_DISALLOWED) && + (sr_ctrl & NON_SRG_OFFSET_PRESENT)) || + (sr_ctrl & SRG_INFO_PRESENT)) { + if (is_sr_enable) { + wlan_mlme_update_sr_data(vdev, &val, pd_threshold, + is_sr_enable); + wlan_vdev_obj_lock(vdev); + wlan_vdev_mlme_set_he_spr_enabled(vdev, true); + wlan_vdev_obj_unlock(vdev); + } else { + wlan_vdev_obj_lock(vdev); + wlan_vdev_mlme_set_he_spr_enabled(vdev, false); + wlan_vdev_obj_unlock(vdev); + } + + mlme_debug("non-srg param val: %u, enable: %d", + val, is_sr_enable); + status = + spatial_reuse_send_pd_threshold(pdev, vdev->vdev_objmgr.vdev_id, + val); + } else { + mlme_debug("Spatial reuse not enabled"); + } + + return status; +} + void target_if_spatial_reuse_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) { tx_ops->spatial_reuse_tx_ops.send_cfg = spatial_reuse_send_cfg; tx_ops->spatial_reuse_tx_ops.send_sr_prohibit_cfg = spatial_reuse_send_sr_prohibit_cfg; + tx_ops->spatial_reuse_tx_ops.target_if_set_sr_enable_disable = + spatial_reuse_set_sr_enable_disable; } diff --git a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h index 7d3baf622d..afd3f2adf5 100644 --- a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h +++ b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h @@ -1480,7 +1480,11 @@ struct wlan_lmac_if_spatial_reuse_tx_ops { uint8_t non_srg_max_pd_offset); QDF_STATUS (*send_sr_prohibit_cfg)(struct wlan_objmgr_vdev *vdev, bool he_siga_val15_allowed); - }; + QDF_STATUS(*target_if_set_sr_enable_disable)( + struct wlan_objmgr_vdev *vdev, + struct wlan_objmgr_pdev *pdev, + bool is_sr_enable, int32_t pd_threshold); +}; #endif #ifdef WLAN_FEATURE_COAP diff --git a/umac/mlme/include/wlan_vdev_mlme.h b/umac/mlme/include/wlan_vdev_mlme.h index 374fe050be..9cfebde0dd 100644 --- a/umac/mlme/include/wlan_vdev_mlme.h +++ b/umac/mlme/include/wlan_vdev_mlme.h @@ -344,6 +344,7 @@ struct vdev_mlme_proto { * @he_spr_sr_ctrl: Spatial reuse SR control * @he_spr_non_srg_pd_max_offset: Non-SRG PD max offset * @he_spr_enabled: Spatial reuse enabled or not + * @pd_threshold: pd threshold sent by userspace */ struct vdev_mlme_mgmt_generic { uint32_t rts_threshold; @@ -370,10 +371,11 @@ struct vdev_mlme_mgmt_generic { uint8_t bssid[QDF_MAC_ADDR_SIZE]; uint32_t phy_mode; bool special_vdev_mode; -#ifdef WLAN_FEATURE_11AX +#ifdef WLAN_FEATURE_SR uint8_t he_spr_sr_ctrl; uint8_t he_spr_non_srg_pd_max_offset; bool he_spr_enabled; + int32_t pd_threshold; #endif }; diff --git a/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mlme_api.h b/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mlme_api.h index 04d841f701..4027330224 100644 --- a/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mlme_api.h +++ b/umac/mlme/vdev_mgr/dispatcher/inc/wlan_vdev_mlme_api.h @@ -24,6 +24,30 @@ #include +#define WLAN_INVALID_VDEV_ID 255 +#define WILDCARD_PDEV_ID 0x0 + +#ifdef WLAN_FEATURE_SR +#define PSR_DISALLOWED 1 +#define NON_SRG_SPR_ENABLE_SIZE 1 +#define SR_PARAM_VAL_DBM_UNIT 1 +#define SR_PARAM_VAL_DBM_POS 29 +#define NON_SRG_PARAM_VAL_DBM_SIZE 1 +#define NON_SRG_MAX_PD_OFFSET_POS 0 +#define NON_SRG_MAX_PD_OFFSET_SIZE 8 +#define NON_SR_PD_THRESHOLD_MIN -82 +#define SRG_SPR_ENABLE_POS 30 +#define SRG_THRESHOLD_MAX_PD_POS 8 +#define NON_SRG_PD_SR_DISALLOWED 0x02 +#define HE_SIG_VAL_15_ALLOWED 0x10 +#define NON_SRG_OFFSET_PRESENT 0x04 +#define SRG_INFO_PRESENT 0x08 +#define NON_SRG_SPR_ENABLE_POS 31 +#define NON_SRG_SPR_ENABLE 0x80 +#define NON_SR_PD_THRESHOLD_DISABLED 0x80 +#endif + + /** * wlan_mlme_peer_param_id - peer param id in mlme layer * @WLAN_MLME_PEER_BW_PUNCTURE: update puncture 20 MHz bitmap @@ -291,4 +315,26 @@ wlan_vdev_mlme_get_is_mlo_vdev(struct wlan_objmgr_psoc *psoc, return false; } #endif +#ifdef WLAN_FEATURE_SR +/** + * wlan_mlme_update_sr_data() - Updates SR values + * + * @vdev: Object manager VDEV object + * @val: SR value + * @pd_threshold: pd threshold sent by userspace + * @is_sr_enable: SR enable/disable from userspace + * + * API to Update SR value based on AP advertisement and provided by userspace + * + * Return: true/flase + */ +void +wlan_mlme_update_sr_data(struct wlan_objmgr_vdev *vdev, int *val, + int32_t pd_threshold, bool is_sr_enable); +#else +static inline void +wlan_mlme_update_sr_data(struct wlan_objmgr_vdev *vdev, int *val, + int32_t pd_threshold, bool is_sr_enable) +{} +#endif #endif diff --git a/umac/mlme/vdev_mgr/dispatcher/src/wlan_vdev_mlme_api.c b/umac/mlme/vdev_mgr/dispatcher/src/wlan_vdev_mlme_api.c index ac4a858ddf..ca51c20c35 100644 --- a/umac/mlme/vdev_mgr/dispatcher/src/wlan_vdev_mlme_api.c +++ b/umac/mlme/vdev_mgr/dispatcher/src/wlan_vdev_mlme_api.c @@ -26,6 +26,9 @@ #include #include #include +#include "wlan_objmgr_vdev_obj.h" +#include "wlan_policy_mgr_api.h" +#include "wlan_policy_mgr_i.h" struct vdev_mlme_obj *wlan_vdev_mlme_get_cmpt_obj(struct wlan_objmgr_vdev *vdev) { @@ -396,3 +399,52 @@ wlan_vdev_mlme_get_is_mlo_vdev(struct wlan_objmgr_psoc *psoc, return is_mlo_vdev; } #endif +#ifdef WLAN_FEATURE_SR +void +wlan_mlme_update_sr_data(struct wlan_objmgr_vdev *vdev, int *val, + int32_t pd_threshold, bool is_sr_enable) +{ + uint8_t non_srg_pd_threshold; + /*To do initialization removal*/ + uint8_t srg_pd_threshold = 0; + + non_srg_pd_threshold = + wlan_vdev_mlme_get_pd_offset(vdev) + NON_SR_PD_THRESHOLD_MIN; + /* + * To do + * set srg_pd_min and max offset in lim_update_vdev_sr_elements + * srp_ie->srg_info.info.srg_pd_min_offset. + * Get here and chcek provided threshold is in range or not + */ + + /** + * Update non_srg_pd_threshold with provide + * pd_threshold, if pd threshold is with in the + * range else keep the same as advertised by AP. + */ + if (pd_threshold && non_srg_pd_threshold > pd_threshold) + non_srg_pd_threshold = pd_threshold; + /* bit | purpose + * ----------------- + * 0 - 7 | Param Value for non-SRG based Spatial Reuse + * 8 - 15| Param value for SRG based Spatial Reuse + * 16 - 28| Reserved + * 29 | Param value is in dBm units rather than dB units + * 30 | Enable/Disable SRG based spatial reuse. + * | If set to 0, ignore bits 8-15. + * 16 - 28| Reserved + * 29 | Param value is in dBm units rather than dB units + * 30 | Enable/Disable SRG based spatial reuse. + * | If set to 0, ignore bits 8-15. + * 31 | Enable/Disable Non-SRG based spatial reuse. + * | If set to 0, ignore bits 0-7. + */ + *val |= + (uint8_t)(non_srg_pd_threshold << NON_SRG_MAX_PD_OFFSET_POS); + *val |= + (uint8_t)(srg_pd_threshold << SRG_THRESHOLD_MAX_PD_POS); + *val |= SR_PARAM_VAL_DBM_UNIT << SR_PARAM_VAL_DBM_POS; + *val |= is_sr_enable << NON_SRG_SPR_ENABLE_POS; + *val |= is_sr_enable << SRG_SPR_ENABLE_POS; +} +#endif