drivers: wifi: Add RPU recovery retry mechanism

In case RPU is stuck in consecutive recovery over a time period then
that means it's not recoverable through RPU recovery, only thing left to
do is to trigger a system reboot. This feature is disabled by default,
so, either application can do their own implementatio or enable this
feature in the driver along with configurable retries and window period.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This commit is contained in:
Chaitanya Tata 2024-07-14 01:57:29 +05:30 committed by Carles Cufí
parent 6f7fbf8451
commit 9b105698ed
3 changed files with 34 additions and 1 deletions

View file

@ -714,6 +714,22 @@ config NRF_WIFI_RPU_RECOVERY_QUIET_PERIOD_MS
help
Quiet period in milliseconds after RPU recovery is triggered. During
this period, no new RPU recovery will be triggered.
config NRF_WIFI_RPU_RECOVERY_MAX_RETRIES
int "Maximum number of consecutive RPU recovery retries, 0 to disable"
default 0
help
Maximum number of consecutive RPU recovery retries before giving up
and resetting the system. Set to 0 to keep retrying indefinitely.
config NRF_WIFI_RPU_RECOVERY_RETRY_WINDOW_S
int "RPU recovery retry window in seconds"
default 900
help
Window in seconds during which the number of consecutive RPU recovery
retries are counted. If the number of consecutive RPU recovery retries
exceeds NRF_WIFI_RPU_RECOVERY_MAX_RETRIES within this window, the system
will be reset.
endif # NRF_WIFI_RPU_RECOVERY
config NRF_WIFI_FEAT_WMM

View file

@ -112,6 +112,7 @@ struct nrf_wifi_ctx_zep {
#ifdef CONFIG_NRF_WIFI_RPU_RECOVERY
bool rpu_recovery_in_progress;
unsigned long last_rpu_recovery_time_ms;
unsigned int rpu_recovery_retries;
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */
};

View file

@ -18,6 +18,8 @@
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL);
#include <zephyr/sys/reboot.h>
#include "net_private.h"
#include "util.h"
@ -111,13 +113,27 @@ static void nrf_wifi_rpu_recovery_work_handler(struct k_work *work)
return;
}
#ifdef CONFIG_NRF_WIFI_RPU_RECOVERY_DEBUG
LOG_ERR("%s: Starting RPU recovery", __func__);
#else
LOG_DBG("%s: Starting RPU recovery", __func__);
#endif
k_mutex_lock(&rpu_ctx_zep->rpu_lock, K_FOREVER);
#if CONFIG_NRF_WIFI_RPU_RECOVERY_MAX_RETRIES > 0
if (!rpu_ctx_zep->last_rpu_recovery_time_ms ||
(k_uptime_get() - rpu_ctx_zep->last_rpu_recovery_time_ms) <
CONFIG_NRF_WIFI_RPU_RECOVERY_RETRY_WINDOW_S * MSEC_PER_SEC) {
if (rpu_ctx_zep->rpu_recovery_retries >=
CONFIG_NRF_WIFI_RPU_RECOVERY_MAX_RETRIES) {
LOG_ERR("%s: Maximum recovery retries reached, rebooting system",
__func__);
sys_reboot(SYS_REBOOT_COLD);
}
rpu_ctx_zep->rpu_recovery_retries++;
} else {
rpu_ctx_zep->rpu_recovery_retries = 0;
}
#endif
rpu_ctx_zep->rpu_recovery_in_progress = true;
#ifdef CONFIG_NRF_WIFI_RPU_RECOVERY_DEBUG
LOG_ERR("%s: Bringing the interface down", __func__);