diff --git a/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h b/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h index 56d430fd5001..abe53065e7fa 100644 --- a/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h +++ b/components/mlme/dispatcher/inc/wlan_mlme_ucfg_api.h @@ -3878,4 +3878,12 @@ ucfg_mlme_get_peer_phymode(struct wlan_objmgr_psoc *psoc, uint8_t *mac, * Return: True if full_roam_scan_period is in expected range, false otherwise. */ bool ucfg_mlme_validate_full_roam_scan_period(uint32_t full_roam_scan_period); + +/** + * ucfg_mlme_validate_scan_period() - Validate if scan period is in valid range + * @value: Scan period in msec + * + * Return: True if roam_scan_period is in expected range, false otherwise. + */ +bool ucfg_mlme_validate_scan_period(uint32_t roam_scan_period); #endif /* _WLAN_MLME_UCFG_API_H_ */ diff --git a/components/mlme/dispatcher/src/wlan_mlme_ucfg_api.c b/components/mlme/dispatcher/src/wlan_mlme_ucfg_api.c index 964371982639..b195e4169d8a 100644 --- a/components/mlme/dispatcher/src/wlan_mlme_ucfg_api.c +++ b/components/mlme/dispatcher/src/wlan_mlme_ucfg_api.c @@ -1682,3 +1682,19 @@ bool ucfg_mlme_validate_full_roam_scan_period(uint32_t full_roam_scan_period) return is_valid; } + +bool ucfg_mlme_validate_scan_period(uint32_t roam_scan_period) +{ + bool is_valid = true; + + if (!cfg_in_range(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD, + roam_scan_period)) { + mlme_legacy_err("Roam scan period value %d msec is out of range (Min: %d msec Max: %d msec)", + roam_scan_period, + cfg_min(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD), + cfg_max(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD)); + is_valid = false; + } + + return is_valid; +} diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 99e63ed2d9eb..a89b4a1141b5 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -4124,6 +4124,7 @@ roam_control_policy[QCA_ATTR_ROAM_CONTROL_MAX + 1] = { [QCA_ATTR_ROAM_CONTROL_CLEAR_ALL] = {.type = NLA_FLAG}, [QCA_ATTR_ROAM_CONTROL_TRIGGERS] = {.type = NLA_U32}, [QCA_ATTR_ROAM_CONTROL_SELECTION_CRITERIA] = {.type = NLA_NESTED}, + [QCA_ATTR_ROAM_CONTROL_SCAN_PERIOD] = {.type = NLA_U32}, }; /** @@ -4288,6 +4289,38 @@ hdd_send_roam_cand_sel_criteria_to_sme(struct hdd_context *hdd_ctx, return status; } +/** + * hdd_send_roam_scan_period_to_sme() - Send roam scan period to SME + * @hdd_ctx: HDD context + * @vdev_id: vdev id + * @roam_scan_period: Roam scan period in seconds + * + * Validate the roam scan period and send it to firmware if valid. + * + * Return: QDF_STATUS + */ +static QDF_STATUS +hdd_send_roam_scan_period_to_sme(struct hdd_context *hdd_ctx, + uint8_t vdev_id, + uint32_t roam_scan_period) +{ + QDF_STATUS status; + + if (!ucfg_mlme_validate_scan_period(roam_scan_period * 1000)) + return QDF_STATUS_E_INVAL; + + hdd_debug("Received Command to Set roam scan period (Empty Scan refresh period) = %d", + roam_scan_period); + + status = sme_update_empty_scan_refresh_period(hdd_ctx->mac_handle, + vdev_id, + roam_scan_period * 1000); + if (QDF_IS_STATUS_ERROR(status)) + hdd_err("Failed to set scan period"); + + return status; +} + /** * hdd_set_roam_with_control_config() - Set roam control configuration * @hdd_ctx: HDD context @@ -4373,6 +4406,15 @@ hdd_set_roam_with_control_config(struct hdd_context *hdd_ctx, hdd_err("failed to set candidate selection criteria"); } + attr = tb2[QCA_ATTR_ROAM_CONTROL_SCAN_PERIOD]; + if (attr) { + hdd_debug("Parse and send scan period to firmware"); + status = hdd_send_roam_scan_period_to_sme(hdd_ctx, vdev_id, + nla_get_u32(attr)); + if (QDF_IS_STATUS_ERROR(status)) + hdd_err("failed to send scan period to firmware"); + } + return qdf_status_to_os_return(status); } diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index 2ae86562314c..70fab802d039 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -3065,12 +3065,7 @@ static int drv_cmd_set_roam_scan_period(struct hdd_adapter *adapter, goto exit; } - if (!cfg_in_range(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD, - roam_scan_period)) { - hdd_err("Roam scan period value %d is out of range (Min: %d Max: %d)", - roam_scan_period, - (cfg_min(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD) / 1000), - (cfg_max(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD) / 1000)); + if (!ucfg_mlme_validate_scan_period(roam_scan_period * 1000)) { ret = -EINVAL; goto exit; }