diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index b10cfb24467a..e453dfd1e805 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -4520,7 +4520,6 @@ static int drv_cmd_set_scan_home_away_time(struct hdd_adapter *adapter, int ret = 0; uint8_t *value = command; uint16_t home_away_time = cfg_default(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME); - uint16_t current_home_away_time; /* input value is in units of msec */ @@ -4553,13 +4552,10 @@ static int drv_cmd_set_scan_home_away_time(struct hdd_adapter *adapter, hdd_debug("Received Command to Set scan away time = %d", home_away_time); - ucfg_mlme_get_home_away_time(hdd_ctx->psoc, ¤t_home_away_time); - if (current_home_away_time != home_away_time) { - sme_update_roam_scan_home_away_time(hdd_ctx->mac_handle, - adapter->vdev_id, - home_away_time, - true); - } + sme_update_roam_scan_home_away_time(hdd_ctx->mac_handle, + adapter->vdev_id, + home_away_time, + true); exit: return ret; @@ -4572,9 +4568,19 @@ static int drv_cmd_get_scan_home_away_time(struct hdd_adapter *adapter, struct hdd_priv_data *priv_data) { int ret = 0; - uint16_t val = sme_get_roam_scan_home_away_time(hdd_ctx->mac_handle); + uint16_t val; char extra[32]; uint8_t len = 0; + QDF_STATUS status; + + status = sme_get_roam_scan_home_away_time(hdd_ctx->mac_handle, + adapter->vdev_id, + &val); + if (QDF_IS_STATUS_ERROR(status)) + return qdf_status_to_os_return(status); + + hdd_debug("vdev_id: %u, scan home away time: %u", + adapter->vdev_id, val); len = scnprintf(extra, sizeof(extra), "%s %d", command, val); len = QDF_MIN(priv_data->total_len, len + 1); diff --git a/core/sme/inc/csr_neighbor_roam.h b/core/sme/inc/csr_neighbor_roam.h index 9432f1743643..9a5f728c23b2 100644 --- a/core/sme/inc/csr_neighbor_roam.h +++ b/core/sme/inc/csr_neighbor_roam.h @@ -67,6 +67,7 @@ typedef struct sCsrNeighborRoamCfgParams { uint32_t full_roam_scan_period; bool enable_scoring_for_roam; uint8_t roam_rssi_diff; + uint16_t roam_scan_home_away_time; } tCsrNeighborRoamCfgParams, *tpCsrNeighborRoamCfgParams; #define CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX 255 diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 4bee18a78293..c89e217faa59 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -765,14 +765,24 @@ QDF_STATUS sme_hide_ssid(mac_handle_t mac_handle, uint8_t sessionId, QDF_STATUS sme_update_roam_scan_n_probes(mac_handle_t mac_handle, uint8_t sessionId, const uint8_t nProbes); -QDF_STATUS sme_update_roam_scan_home_away_time(mac_handle_t mac_handle, - uint8_t sessionId, - const uint16_t nRoamScanHomeAwayTime, - const bool bSendOffloadCmd); + +/** + * sme_update_roam_scan_home_away_time() - Update roam scan Home away time + * @mac_handle: Opaque handle to the global MAC context + * @vdev_id: vdev identifier + * @roam_scan_home_away_time: Scan home away time + * @send_offload_cmd: If it's true, the command is sent to firmware, + * otherwise the command is not sent to firmware + * + * Return: QDF_STATUS + */ +QDF_STATUS +sme_update_roam_scan_home_away_time(mac_handle_t mac_handle, uint8_t vdev_id, + const uint16_t roam_scan_home_away_time, + const bool send_offload_cmd); bool sme_get_roam_intra_band(mac_handle_t mac_handle); uint8_t sme_get_roam_scan_n_probes(mac_handle_t mac_handle); -uint16_t sme_get_roam_scan_home_away_time(mac_handle_t mac_handle); /** * sme_update_roam_rssi_diff() - Update RoamRssiDiff @@ -785,6 +795,19 @@ uint16_t sme_get_roam_scan_home_away_time(mac_handle_t mac_handle); */ QDF_STATUS sme_update_roam_rssi_diff(mac_handle_t mac_handle, uint8_t vdev_id, uint8_t roam_rssi_diff); + +/** + * sme_get_roam_scan_home_away_time() - get Roam scan home away time + * @mac_handle: The handle returned by mac_open + * @vdev_id: vdev identifier + * @roam_scan_home_away_time: Buffer to fill the roam scan home away time. + * Valid only if the return status is success. + * + * Return: QDF_STATUS + */ +QDF_STATUS sme_get_roam_scan_home_away_time(mac_handle_t mac_handle, + uint8_t vdev_id, + uint16_t *roam_scan_home_away_time); QDF_STATUS sme_update_wes_mode(mac_handle_t mac_handle, bool isWESModeEnabled, uint8_t sessionId); QDF_STATUS sme_set_roam_scan_control(mac_handle_t mac_handle, uint8_t sessionId, diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 35fdc5d96af6..338d0872a0fb 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -5754,50 +5754,50 @@ QDF_STATUS sme_update_roam_scan_n_probes(mac_handle_t mac_handle, return status; } -/* - * sme_update_roam_scan_home_away_time() - - * Function to update roam scan Home away time - * This function is called through dynamic setConfig callback function - * to update roam scan home away time - * - * mac_handle: Opaque handle to the global MAC context - * sessionId - Session Identifier - * nRoamScanAwayTime Scan home away time - * bSendOffloadCmd If true then send offload command to firmware - * If false then command is not sent to firmware - * Return Success or failure - */ -QDF_STATUS sme_update_roam_scan_home_away_time( - mac_handle_t mac_handle, - uint8_t sessionId, - const uint16_t nRoamScanHomeAwayTime, - const bool bSendOffloadCmd) +QDF_STATUS +sme_update_roam_scan_home_away_time(mac_handle_t mac_handle, uint8_t vdev_id, + const uint16_t roam_scan_home_away_time, + const bool send_offload_cmd) { struct mac_context *mac = MAC_CONTEXT(mac_handle); - QDF_STATUS status = QDF_STATUS_SUCCESS; + QDF_STATUS status; + tCsrNeighborRoamControlInfo *neighbor_roam_info; + if (vdev_id >= WLAN_MAX_VDEVS) { + sme_err("Invalid vdev_id: %d", vdev_id); + return QDF_STATUS_E_INVAL; + } MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME, - NO_SESSION, 0)); - status = sme_acquire_global_lock(&mac->sme); - if (QDF_IS_STATUS_SUCCESS(status)) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, - "%s: gRoamScanHomeAwayTime is changed from %d to %d", - __func__, - mac->mlme_cfg->lfr.roam_scan_home_away_time, - nRoamScanHomeAwayTime); - mac->mlme_cfg->lfr.roam_scan_home_away_time = - nRoamScanHomeAwayTime; + vdev_id, 0)); - if (mac->mlme_cfg->lfr.roam_scan_offload_enabled && - bSendOffloadCmd) { - csr_roam_offload_scan(mac, sessionId, - ROAM_SCAN_OFFLOAD_UPDATE_CFG, - REASON_HOME_AWAY_TIME_CHANGED); - } - sme_release_global_lock(&mac->sme); + status = sme_acquire_global_lock(&mac->sme); + if (QDF_IS_STATUS_ERROR(status)) { + sme_err("Failed to acquire sme lock; status: %d", status); + return status; } - return status; + neighbor_roam_info = &mac->roam.neighborRoamInfo[vdev_id]; + + if (neighbor_roam_info->cfgParams.roam_scan_home_away_time == + roam_scan_home_away_time) { + sme_debug("Not updated as current value is :%u", + roam_scan_home_away_time); + sme_release_global_lock(&mac->sme); + return QDF_STATUS_SUCCESS; + } + + sme_debug("gRoamScanHomeAwayTime is changed from %d to %d", + neighbor_roam_info->cfgParams.roam_scan_home_away_time, + roam_scan_home_away_time); + neighbor_roam_info->cfgParams.roam_scan_home_away_time = + roam_scan_home_away_time; + if (mac->mlme_cfg->lfr.roam_scan_offload_enabled && send_offload_cmd) + csr_roam_offload_scan(mac, vdev_id, + ROAM_SCAN_OFFLOAD_UPDATE_CFG, + REASON_HOME_AWAY_TIME_CHANGED); + sme_release_global_lock(&mac->sme); + + return QDF_STATUS_SUCCESS; } /** @@ -5870,18 +5870,30 @@ uint8_t sme_get_roam_scan_n_probes(mac_handle_t mac_handle) return mac->mlme_cfg->lfr.roam_scan_n_probes; } -/* - * sme_get_roam_scan_home_away_time() - - * get Roam scan home away time - * - * mac_handle: Opaque handle to the global MAC context - * Return Success or failure - */ -uint16_t sme_get_roam_scan_home_away_time(mac_handle_t mac_handle) +QDF_STATUS sme_get_roam_scan_home_away_time(mac_handle_t mac_handle, + uint8_t vdev_id, + uint16_t *roam_scan_home_away_time) { struct mac_context *mac = MAC_CONTEXT(mac_handle); + QDF_STATUS status; + tCsrNeighborRoamControlInfo *neighbor_roam_info; - return mac->mlme_cfg->lfr.roam_scan_home_away_time; + if (vdev_id >= WLAN_MAX_VDEVS) { + sme_err("Invalid vdev_id: %d", vdev_id); + return QDF_STATUS_E_INVAL; + } + + status = sme_acquire_global_lock(&mac->sme); + if (QDF_IS_STATUS_ERROR(status)) { + sme_err("Failed to acquire sme lock; status: %d", status); + return status; + } + neighbor_roam_info = &mac->roam.neighborRoamInfo[vdev_id]; + *roam_scan_home_away_time = + neighbor_roam_info->cfgParams.roam_scan_home_away_time; + sme_release_global_lock(&mac->sme); + + return status; } QDF_STATUS sme_update_roam_rssi_diff(mac_handle_t mac_handle, uint8_t vdev_id, diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c index 36199af98736..927fb967ec89 100644 --- a/core/sme/src/csr/csr_api_roam.c +++ b/core/sme/src/csr/csr_api_roam.c @@ -18301,7 +18301,7 @@ csr_create_roam_scan_offload_request(struct mac_context *mac_ctx, mac_ctx->roam.roamSession[session_id].connectedProfile.mdid; req_buf->sessionId = session_id; req_buf->nProbes = mac_ctx->mlme_cfg->lfr.roam_scan_n_probes; - req_buf->HomeAwayTime = mac_ctx->mlme_cfg->lfr.roam_scan_home_away_time; + req_buf->HomeAwayTime = roam_info->cfgParams.roam_scan_home_away_time; /* * Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),