Skip to content

Commit

Permalink
drivers: wifi: Add support to query inactivity timer
Browse files Browse the repository at this point in the history
In SAP mode, WPA supplicant need to know the current inactivity timer
value for a STA for kicking stale stations.

Rework the event processing to handle both inactivity and signal info
cases.

Fixes SHEL-2681.

Signed-off-by: Chaitanya Tata <[email protected]>
  • Loading branch information
krish2718 authored and carlescufi committed May 2, 2024
1 parent ccaded6 commit 1086cf8
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
3 changes: 3 additions & 0 deletions drivers/wifi/nrf700x/inc/fmac_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ struct nrf_wifi_vif_ctx_zep {
unsigned long rssi_record_timestamp_us;
signed short rssi;
#endif /* CONFIG_NRF700X_STA_MODE */
#ifdef CONFIG_NRF700X_AP_MODE
int inactive_time_sec;
#endif /* CONFIG_NRF700X_AP_MODE */
};

struct nrf_wifi_vif_ctx_map {
Expand Down
1 change: 1 addition & 0 deletions drivers/wifi/nrf700x/inc/wpa_supp_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,6 @@ int nrf_wifi_supp_register_mgmt_frame(void *if_priv,
int nrf_wifi_wpa_supp_sta_set_flags(void *if_priv, const u8 *addr,
unsigned int total_flags, unsigned int flags_or,
unsigned int flags_and);
int nrf_wifi_wpa_supp_sta_get_inact_sec(void *if_priv, const u8 *addr);
#endif /* CONFIG_NRF700X_AP_MODE */
#endif /* __ZEPHYR_WPA_SUPP_IF_H__ */
1 change: 1 addition & 0 deletions drivers/wifi/nrf700x/src/fmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ static const struct zep_wpa_supp_dev_ops wpa_supp_ops = {
.sta_remove = nrf_wifi_wpa_supp_sta_remove,
.register_mgmt_frame = nrf_wifi_supp_register_mgmt_frame,
.sta_set_flags = nrf_wifi_wpa_supp_sta_set_flags,
.get_inact_sec = nrf_wifi_wpa_supp_sta_get_inact_sec,
#endif /* CONFIG_NRF700X_AP_MODE */
};
#endif /* CONFIG_NRF700X_STA_MODE */
Expand Down
63 changes: 58 additions & 5 deletions drivers/wifi/nrf700x/src/wpa_supp_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,17 +1214,23 @@ void nrf_wifi_wpa_supp_event_proc_get_sta(void *if_priv,

if (!if_priv || !info) {
LOG_ERR("%s: Invalid params", __func__);
k_sem_give(&wait_for_event_sem);
return;
goto out;
}

vif_ctx_zep = if_priv;
signal_info = vif_ctx_zep->signal_info;
if (!vif_ctx_zep) {
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
goto out;
}

#ifdef CONFIG_NRF700X_AP_MODE
vif_ctx_zep->inactive_time_sec = info->sta_info.inactive_time;
#endif /* CONFIG_NRF700X_AP_MODE */

signal_info = vif_ctx_zep->signal_info;
/* Semaphore timedout */
if (!signal_info) {
LOG_DBG("%s: Get station Semaphore timedout", __func__);
return;
goto out;
}

if (info->sta_info.valid_fields & NRF_WIFI_STA_INFO_SIGNAL_VALID) {
Expand Down Expand Up @@ -1252,6 +1258,7 @@ void nrf_wifi_wpa_supp_event_proc_get_sta(void *if_priv,
signal_info->current_txrate = info->sta_info.tx_bitrate.bitrate * 100;
}
}
out:
k_sem_give(&wait_for_event_sem);
}

Expand Down Expand Up @@ -2739,4 +2746,50 @@ int nrf_wifi_wpa_supp_sta_set_flags(void *if_priv, const u8 *addr,
k_mutex_unlock(&vif_ctx_zep->vif_lock);
return ret;
}

int nrf_wifi_wpa_supp_sta_get_inact_sec(void *if_priv, const u8 *addr)
{
struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
int ret = -1, sem_ret;
int inactive_time_sec = -1;

if (!if_priv || !addr) {
LOG_ERR("%s: Invalid params", __func__);
return ret;
}

vif_ctx_zep = if_priv;
rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;
if (!rpu_ctx_zep) {
LOG_DBG("%s: rpu_ctx_zep is NULL", __func__);
return ret;
}

k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER);
if (!rpu_ctx_zep->rpu_ctx) {
LOG_DBG("%s: RPU context not initialized", __func__);
goto out;
}

status = nrf_wifi_fmac_get_station(rpu_ctx_zep->rpu_ctx, vif_ctx_zep->vif_idx,
(unsigned char *) addr);
if (status != NRF_WIFI_STATUS_SUCCESS) {
LOG_ERR("%s: nrf_wifi_fmac_get_station failed", __func__);
goto out;
}

sem_ret = k_sem_take(&wait_for_event_sem, K_MSEC(RPU_RESP_EVENT_TIMEOUT));
if (sem_ret) {
LOG_ERR("%s: Timed out to get station info, ret = %d", __func__, sem_ret);
ret = NRF_WIFI_STATUS_FAIL;
goto out;
}

inactive_time_sec = vif_ctx_zep->inactive_time_sec;
out:
k_mutex_unlock(&vif_ctx_zep->vif_lock);
return inactive_time_sec;
}
#endif /* CONFIG_NRF700X_AP_MODE */

0 comments on commit 1086cf8

Please sign in to comment.