Skip to content

Commit

Permalink
[nrf fromlist] drivers: wifi: Add RPU recovery info
Browse files Browse the repository at this point in the history
Add RPU recovery information in wifi utils.
It helps to debug watchdog recovery.

Upstream PR #: 81575

Signed-off-by: Kapil Bhatt <[email protected]>
  • Loading branch information
kapbh committed Dec 2, 2024
1 parent 9293910 commit 2d04b9a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/wifi/nrf_wifi/inc/fmac_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ struct nrf_wifi_ctx_zep {
bool rpu_recovery_in_progress;
unsigned long last_rpu_recovery_time_ms;
unsigned int rpu_recovery_retries;
int rpu_recovery_success;
int rpu_recovery_failure;
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */
};

Expand Down
6 changes: 6 additions & 0 deletions drivers/wifi/nrf_wifi/src/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ static void nrf_wifi_rpu_recovery_work_handler(struct k_work *work)
nrf_wifi_rpu_recovery_work);
struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
int ret;
bool recovery_fail = false;

if (!vif_ctx_zep) {
LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
Expand Down Expand Up @@ -143,6 +144,8 @@ static void nrf_wifi_rpu_recovery_work_handler(struct k_work *work)
/* This indirectly does a cold-boot of RPU */
ret = net_if_down(vif_ctx_zep->zep_net_if_ctx);
if (ret) {
rpu_ctx_zep->rpu_recovery_failure++;
recovery_fail = true;
LOG_ERR("%s: net_if_down failed: %d", __func__, ret);
/* Continue with the recovery */
}
Expand All @@ -158,6 +161,9 @@ static void nrf_wifi_rpu_recovery_work_handler(struct k_work *work)
}
rpu_ctx_zep->rpu_recovery_in_progress = false;
rpu_ctx_zep->last_rpu_recovery_time_ms = k_uptime_get();
if (!recovery_fail) {
rpu_ctx_zep->rpu_recovery_success++;
}
k_mutex_unlock(&rpu_ctx_zep->rpu_lock);
#ifdef CONFIG_NRF_WIFI_RPU_RECOVERY_DEBUG
LOG_ERR("%s: RPU recovery done", __func__);
Expand Down
52 changes: 52 additions & 0 deletions drivers/wifi/nrf_wifi/src/wifi_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,52 @@ static int nrf_wifi_util_trigger_rpu_recovery(const struct shell *sh,
k_mutex_unlock(&ctx->rpu_lock);
return ret;
}

static int nrf_wifi_util_rpu_recovery_info(const struct shell *sh,
size_t argc,
const char *argv[])
{

Check notice on line 922 in drivers/wifi/nrf_wifi/src/wifi_util.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/wifi_util.c:922 -static int nrf_wifi_util_rpu_recovery_info(const struct shell *sh, - size_t argc, - const char *argv[]) +static int nrf_wifi_util_rpu_recovery_info(const struct shell *sh, size_t argc, const char *argv[])
struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL;
struct nrf_wifi_hal_dev_ctx *hal_dev_ctx = NULL;
unsigned long current_time_ms = nrf_wifi_osal_time_get_curr_ms();
int ret;

k_mutex_lock(&ctx->rpu_lock, K_FOREVER);
if (!ctx || !ctx->rpu_ctx) {
shell_fprintf(sh,
SHELL_ERROR,
"RPU context not initialized\n");
ret = -ENOEXEC;

Check notice on line 933 in drivers/wifi/nrf_wifi/src/wifi_util.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/wifi_util.c:933 - shell_fprintf(sh, - SHELL_ERROR, - "RPU context not initialized\n"); + shell_fprintf(sh, SHELL_ERROR, "RPU context not initialized\n");
goto unlock;
}

fmac_dev_ctx = ctx->rpu_ctx;
hal_dev_ctx = fmac_dev_ctx->hal_dev_ctx;

shell_fprintf(sh,
SHELL_INFO,
"wdt_irq_received: %d\n"

Check notice on line 942 in drivers/wifi/nrf_wifi/src/wifi_util.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/wifi_util.c:942 - shell_fprintf(sh, - SHELL_INFO, + shell_fprintf(sh, SHELL_INFO,
"wdt_irq_ignored: %d\n"
"last_wakeup_now_asserted_time_ms: %lu milliseconds\n"
"last_wakeup_now_deasserted_time_ms: %lu milliseconds\n"
"last_rpu_sleep_opp_time_ms: %lu milliseconds\n"
"current time: %lu milliseconds\n"
"rpu_recovery_success: %d\n"
"rpu_recovery_failure: %d\n\n",
hal_dev_ctx->wdt_irq_received,
hal_dev_ctx->wdt_irq_ignored,
hal_dev_ctx->last_wakeup_now_asserted_time_ms,
hal_dev_ctx->last_wakeup_now_deasserted_time_ms,
hal_dev_ctx->last_rpu_sleep_opp_time_ms,
current_time_ms,
ctx->rpu_recovery_success,
ctx->rpu_recovery_failure);

Check notice on line 958 in drivers/wifi/nrf_wifi/src/wifi_util.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/wifi_util.c:958 - hal_dev_ctx->wdt_irq_received, - hal_dev_ctx->wdt_irq_ignored, + hal_dev_ctx->wdt_irq_received, hal_dev_ctx->wdt_irq_ignored, hal_dev_ctx->last_wakeup_now_asserted_time_ms, hal_dev_ctx->last_wakeup_now_deasserted_time_ms, - hal_dev_ctx->last_rpu_sleep_opp_time_ms, - current_time_ms, - ctx->rpu_recovery_success, - ctx->rpu_recovery_failure); + hal_dev_ctx->last_rpu_sleep_opp_time_ms, current_time_ms, + ctx->rpu_recovery_success, ctx->rpu_recovery_failure);
ret = 0;
unlock:
k_mutex_unlock(&ctx->rpu_lock);
return ret;
}
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */

SHELL_STATIC_SUBCMD_SET_CREATE(
Expand Down Expand Up @@ -1013,6 +1059,12 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
nrf_wifi_util_trigger_rpu_recovery,
1,
0),
SHELL_CMD_ARG(rpu_recovery_info,
NULL,
"Dump RPU recovery information",
nrf_wifi_util_rpu_recovery_info,
1,
0),
#endif /* CONFIG_NRF_WIFI_RPU_RECOVERY */

Check notice on line 1068 in drivers/wifi/nrf_wifi/src/wifi_util.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrf_wifi/src/wifi_util.c:1068 - nrf_wifi_util_tx_rate, - 2, - 1), + nrf_wifi_util_tx_rate, 2, 1), #ifdef CONFIG_NRF_WIFI_LOW_POWER - SHELL_CMD_ARG(sleep_state, - NULL, - "Display current sleep status", - nrf_wifi_util_show_host_rpu_ps_ctrl_state, - 1, - 0), + SHELL_CMD_ARG(sleep_state, NULL, "Display current sleep status", + nrf_wifi_util_show_host_rpu_ps_ctrl_state, 1, 0), #endif /* CONFIG_NRF_WIFI_LOW_POWER */ - SHELL_CMD_ARG(show_vers, - NULL, - "Display the driver and the firmware versions", - nrf_wifi_util_show_vers, - 1, - 0), + SHELL_CMD_ARG(show_vers, NULL, "Display the driver and the firmware versions", + nrf_wifi_util_show_vers, 1, 0), #if !defined(CONFIG_NRF70_RADIO_TEST) && !defined(CONFIG_NRF70_OFFLOADED_RAW_TX) - SHELL_CMD_ARG(rpu_stats, - NULL, + SHELL_CMD_ARG(rpu_stats, NULL, "Display RPU stats " "Parameters: umac or lmac or phy or all (default)", - nrf_wifi_util_dump_rpu_stats, - 1, - 1), + nrf_wifi_util_dump_rpu_stats, 1, 1), #endif /* !CONFIG_NRF70_RADIO_TEST && !CONFIG_NRF70_OFFLOADED_RAW_TX*/ #ifdef CONFIG_NRF_WIFI_RPU_RECOVERY - SHELL_CMD_ARG(rpu_recovery_test, - NULL, - "Trigger RPU recovery", - nrf_wifi_util_trigger_rpu_recovery, - 1, - 0), - SHELL_CMD_ARG(rpu_recovery_info, - NULL, - "Dump RPU recovery information", - nrf_wifi_util_rpu_recovery_info, - 1, - 0), + SHELL_CMD_ARG(rpu_recovery_test, NULL, "Trigger RPU recovery", + nrf_wifi_util_trigger_rpu_recovery, 1, 0), + SHELL_CMD_ARG(rpu_recovery_info, NULL, "Dump RPU recovery information", + nrf_wifi_util_rpu_recovery_info, 1, 0),
SHELL_SUBCMD_SET_END);

Expand Down

0 comments on commit 2d04b9a

Please sign in to comment.