Skip to content

Commit 1bb3a57

Browse files
kapbhjukkar
authored andcommitted
[nrf fromlist] drivers: wifi: Add RPU recovery info
Add RPU recovery information in wifi utils. It helps to debug watchdog recovery. Upstream PR #: 81575 Signed-off-by: Kapil Bhatt <[email protected]> (cherry picked from commit 62ed74e)
1 parent c83539c commit 1bb3a57

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

drivers/wifi/nrf_wifi/inc/fmac_main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ struct nrf_wifi_ctx_zep {
113113
bool rpu_recovery_in_progress;
114114
unsigned long last_rpu_recovery_time_ms;
115115
unsigned int rpu_recovery_retries;
116+
int rpu_recovery_success;
117+
int rpu_recovery_failure;
116118
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */
117119
};
118120

drivers/wifi/nrf_wifi/src/net_if.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static void nrf_wifi_rpu_recovery_work_handler(struct k_work *work)
7474
nrf_wifi_rpu_recovery_work);
7575
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
7676
int ret;
77+
bool recovery_fail = false;
7778

7879
if (!vif_ctx_zep) {
7980
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
@@ -143,6 +144,8 @@ static void nrf_wifi_rpu_recovery_work_handler(struct k_work *work)
143144
/* This indirectly does a cold-boot of RPU */
144145
ret = net_if_down(vif_ctx_zep->zep_net_if_ctx);
145146
if (ret) {
147+
rpu_ctx_zep->rpu_recovery_failure++;
148+
recovery_fail = true;
146149
LOG_ERR("%s: net_if_down failed: %d", __func__, ret);
147150
/* Continue with the recovery */
148151
}
@@ -158,6 +161,9 @@ static void nrf_wifi_rpu_recovery_work_handler(struct k_work *work)
158161
}
159162
rpu_ctx_zep->rpu_recovery_in_progress = false;
160163
rpu_ctx_zep->last_rpu_recovery_time_ms = k_uptime_get();
164+
if (!recovery_fail) {
165+
rpu_ctx_zep->rpu_recovery_success++;
166+
}
161167
k_mutex_unlock(&rpu_ctx_zep->rpu_lock);
162168
#ifdef CONFIG_NRF_WIFI_RPU_RECOVERY_DEBUG
163169
LOG_ERR("%s: RPU recovery done", __func__);

drivers/wifi/nrf_wifi/src/wifi_util.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,52 @@ static int nrf_wifi_util_trigger_rpu_recovery(const struct shell *sh,
915915
k_mutex_unlock(&ctx->rpu_lock);
916916
return ret;
917917
}
918+
919+
static int nrf_wifi_util_rpu_recovery_info(const struct shell *sh,
920+
size_t argc,
921+
const char *argv[])
922+
{
923+
struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL;
924+
struct nrf_wifi_hal_dev_ctx *hal_dev_ctx = NULL;
925+
unsigned long current_time_ms = nrf_wifi_osal_time_get_curr_ms();
926+
int ret;
927+
928+
k_mutex_lock(&ctx->rpu_lock, K_FOREVER);
929+
if (!ctx || !ctx->rpu_ctx) {
930+
shell_fprintf(sh,
931+
SHELL_ERROR,
932+
"RPU context not initialized\n");
933+
ret = -ENOEXEC;
934+
goto unlock;
935+
}
936+
937+
fmac_dev_ctx = ctx->rpu_ctx;
938+
hal_dev_ctx = fmac_dev_ctx->hal_dev_ctx;
939+
940+
shell_fprintf(sh,
941+
SHELL_INFO,
942+
"wdt_irq_received: %d\n"
943+
"wdt_irq_ignored: %d\n"
944+
"last_wakeup_now_asserted_time_ms: %lu milliseconds\n"
945+
"last_wakeup_now_deasserted_time_ms: %lu milliseconds\n"
946+
"last_rpu_sleep_opp_time_ms: %lu milliseconds\n"
947+
"current time: %lu milliseconds\n"
948+
"rpu_recovery_success: %d\n"
949+
"rpu_recovery_failure: %d\n\n",
950+
hal_dev_ctx->wdt_irq_received,
951+
hal_dev_ctx->wdt_irq_ignored,
952+
hal_dev_ctx->last_wakeup_now_asserted_time_ms,
953+
hal_dev_ctx->last_wakeup_now_deasserted_time_ms,
954+
hal_dev_ctx->last_rpu_sleep_opp_time_ms,
955+
current_time_ms,
956+
ctx->rpu_recovery_success,
957+
ctx->rpu_recovery_failure);
958+
959+
ret = 0;
960+
unlock:
961+
k_mutex_unlock(&ctx->rpu_lock);
962+
return ret;
963+
}
918964
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */
919965

920966
SHELL_STATIC_SUBCMD_SET_CREATE(
@@ -1013,6 +1059,12 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
10131059
nrf_wifi_util_trigger_rpu_recovery,
10141060
1,
10151061
0),
1062+
SHELL_CMD_ARG(rpu_recovery_info,
1063+
NULL,
1064+
"Dump RPU recovery information",
1065+
nrf_wifi_util_rpu_recovery_info,
1066+
1,
1067+
0),
10161068
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */
10171069
SHELL_SUBCMD_SET_END);
10181070

0 commit comments

Comments
 (0)