From f75980c0dbaad0095f8d58dab4df9b0eb243f872 Mon Sep 17 00:00:00 2001 From: Ajay Parida Date: Thu, 24 Oct 2024 15:57:58 +0530 Subject: [PATCH] nrf_wifi: Add support to get current temperature Add command/event to retrieve current temperature. Signed-off-by: Ajay Parida --- nrf_wifi/fw_if/umac_if/inc/fmac_api_common.h | 13 +++++++ nrf_wifi/fw_if/umac_if/inc/fmac_cmd.h | 2 ++ .../fw_if/umac_if/inc/fmac_structs_common.h | 4 +++ .../fw_if/umac_if/inc/fw/host_rpu_sys_if.h | 24 +++++++++++++ nrf_wifi/fw_if/umac_if/src/cmd.c | 32 +++++++++++++++++ nrf_wifi/fw_if/umac_if/src/event.c | 36 +++++++++++++++++++ nrf_wifi/fw_if/umac_if/src/fmac_api_common.c | 33 +++++++++++++++++ 7 files changed, 144 insertions(+) diff --git a/nrf_wifi/fw_if/umac_if/inc/fmac_api_common.h b/nrf_wifi/fw_if/umac_if/inc/fmac_api_common.h index 64e909b65b..e440ec2b4d 100644 --- a/nrf_wifi/fw_if/umac_if/inc/fmac_api_common.h +++ b/nrf_wifi/fw_if/umac_if/inc/fmac_api_common.h @@ -362,6 +362,19 @@ enum nrf_wifi_status nrf_wifi_fmac_set_packet_filter(void *dev_ctx, unsigned cha unsigned short buffer_size); #endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */ +/** + * @brief Issue a request to get current temperature from the RPU. + * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. + * @param current_temp Pointer to memory where the current temp is to be copied. + * + * This function is used to send a command to + * instruct the firmware to return the current temperature. The RPU will + * send the event with the current temperature. + * + * @return Command execution status + */ +enum nrf_wifi_status nrf_wifi_fmac_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, + int *current_temp); /** * @} */ diff --git a/nrf_wifi/fw_if/umac_if/inc/fmac_cmd.h b/nrf_wifi/fw_if/umac_if/inc/fmac_cmd.h index e6bb059535..38b4a1757d 100644 --- a/nrf_wifi/fw_if/umac_if/inc/fmac_cmd.h +++ b/nrf_wifi/fw_if/umac_if/inc/fmac_cmd.h @@ -73,4 +73,6 @@ enum nrf_wifi_status umac_cmd_prog_stats_get(struct nrf_wifi_fmac_dev_ctx *fmac_ #endif /* CONFIG_NRF700X_RADIO_TEST */ int stat_type); +enum nrf_wifi_status umac_cmd_prog_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); + #endif /* __FMAC_CMD_H__ */ diff --git a/nrf_wifi/fw_if/umac_if/inc/fmac_structs_common.h b/nrf_wifi/fw_if/umac_if/inc/fmac_structs_common.h index b5222f9628..c73da28375 100644 --- a/nrf_wifi/fw_if/umac_if/inc/fmac_structs_common.h +++ b/nrf_wifi/fw_if/umac_if/inc/fmac_structs_common.h @@ -176,6 +176,10 @@ struct nrf_wifi_fmac_dev_ctx { struct nrf_wifi_event_regulatory_change *reg_change; /** TX power ceiling parameters */ struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params; + /** current temp request status */ + int temp_get_status; + /** current temperature */ + int current_temp; /** Data pointer to mode specific parameters */ char priv[]; }; diff --git a/nrf_wifi/fw_if/umac_if/inc/fw/host_rpu_sys_if.h b/nrf_wifi/fw_if/umac_if/inc/fw/host_rpu_sys_if.h index 3db3f0056d..8d262654c8 100644 --- a/nrf_wifi/fw_if/umac_if/inc/fw/host_rpu_sys_if.h +++ b/nrf_wifi/fw_if/umac_if/inc/fw/host_rpu_sys_if.h @@ -161,6 +161,8 @@ enum nrf_wifi_sys_commands { NRF_WIFI_CMD_RAW_CONFIG_FILTER, /** Command to configure packet injector mode or Raw Tx mode */ NRF_WIFI_CMD_RAW_TX_PKT, + /** Command to get RPU temperature */ + NRF_WIFI_CMD_GET_TEMP, }; /** @@ -192,6 +194,8 @@ enum nrf_wifi_sys_events { NRF_WIFI_EVENT_FILTER_SET_DONE, /** Tx done event for the Raw Tx */ NRF_WIFI_EVENT_RAW_TX_DONE, + /** Response to NRF_WIFI_CMD_GET_TEMP */ + NRF_WIFI_EVENT_CURRENT_TEMP, }; /** @@ -1597,4 +1601,24 @@ struct nrf_wifi_event_deinit_done { struct nrf_wifi_sys_head sys_head; } __NRF_WIFI_PKD; +/** + * @brief This structure represents the command used to get the RPU temperature. + */ +struct nrf_wifi_cmd_get_temperature { + /** UMAC header, @ref nrf_wifi_sys_head */ + struct nrf_wifi_sys_head sys_head; +} __NRF_WIFI_PKD; + +/** + * @brief This structure represents an event that provides the current RPU temperature + * in degree celsius. + * + */ +struct nrf_wifi_event_current_temperature { + /** UMAC header, @ref nrf_wifi_sys_head */ + struct nrf_wifi_sys_head sys_head; + /** Current temperature value in degree celsius */ + int current_temperature; +} __NRF_WIFI_PKD; + #endif /* __HOST_RPU_SYS_IF_H__ */ diff --git a/nrf_wifi/fw_if/umac_if/src/cmd.c b/nrf_wifi/fw_if/umac_if/src/cmd.c index 04116048c7..3c0056b69d 100644 --- a/nrf_wifi/fw_if/umac_if/src/cmd.c +++ b/nrf_wifi/fw_if/umac_if/src/cmd.c @@ -541,3 +541,35 @@ enum nrf_wifi_status umac_cmd_prog_stats_get(struct nrf_wifi_fmac_dev_ctx *fmac_ out: return status; } + +enum nrf_wifi_status umac_cmd_prog_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct host_rpu_msg *umac_cmd = NULL; + struct nrf_wifi_cmd_get_temperature *umac_cmd_data = NULL; + int len = 0; + + len = sizeof(*umac_cmd_data); + + umac_cmd = umac_cmd_alloc(fmac_dev_ctx, + NRF_WIFI_HOST_RPU_MSG_TYPE_SYSTEM, + len); + + if (!umac_cmd) { + nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv, + "%s: umac_cmd_alloc failed", + __func__); + goto out; + } + + umac_cmd_data = (struct nrf_wifi_cmd_get_temperature *)(umac_cmd->msg); + + umac_cmd_data->sys_head.cmd_event = NRF_WIFI_CMD_GET_TEMP; + umac_cmd_data->sys_head.len = len; + + status = nrf_wifi_hal_ctrl_cmd_send(fmac_dev_ctx->hal_dev_ctx, + umac_cmd, + (sizeof(*umac_cmd) + len)); +out: + return status; +} diff --git a/nrf_wifi/fw_if/umac_if/src/event.c b/nrf_wifi/fw_if/umac_if/src/event.c index 6e58ec7d46..639be03cd5 100644 --- a/nrf_wifi/fw_if/umac_if/src/event.c +++ b/nrf_wifi/fw_if/umac_if/src/event.c @@ -1008,6 +1008,38 @@ nrf_wifi_fmac_if_mode_set_event_proc(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, } #endif /* CONFIG_NRF700X_SYSTEM_WITH_RAW_MODES */ +static enum nrf_wifi_status umac_event_current_temp_proc(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, + void *event) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_event_current_temperature *event_current_temp = NULL; + + if (!event) { + nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv, + "%s: Invalid parameters", + __func__); + goto out; + } + + if (!fmac_dev_ctx->temp_get_status) { + nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv, + "%s: Temperature recevied when req was not sent!", + __func__); + goto out; + } + + event_current_temp = ((struct nrf_wifi_event_current_temperature *)event); + + fmac_dev_ctx->current_temp = event_current_temp->current_temperature; + + fmac_dev_ctx->temp_get_status = false; + + status = NRF_WIFI_STATUS_SUCCESS; + +out: + return status; +} + static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, struct host_rpu_msg *rpu_msg) { @@ -1092,6 +1124,10 @@ static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx status = NRF_WIFI_STATUS_SUCCESS; break; #endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */ + case NRF_WIFI_EVENT_CURRENT_TEMP: + status = umac_event_current_temp_proc(fmac_dev_ctx, + sys_head); + break; default: nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv, "%s: Unknown event recd: %d", diff --git a/nrf_wifi/fw_if/umac_if/src/fmac_api_common.c b/nrf_wifi/fw_if/umac_if/src/fmac_api_common.c index 2da71209cc..0f98c0af1e 100644 --- a/nrf_wifi/fw_if/umac_if/src/fmac_api_common.c +++ b/nrf_wifi/fw_if/umac_if/src/fmac_api_common.c @@ -1301,3 +1301,36 @@ enum nrf_wifi_status nrf_wifi_fmac_set_packet_filter(void *dev_ctx, unsigned cha return status; } #endif /* CONFIG_NRF700X_RAW_DATA_RX || CONFIG_NRF700X_PROMISC_DATA_RX */ + +enum nrf_wifi_status nrf_wifi_fmac_temp_get(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, + int *current_temp) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + unsigned char count = 0; + + fmac_dev_ctx->temp_get_status = true; + + status = umac_cmd_prog_temp_get(fmac_dev_ctx); + + if (status != NRF_WIFI_STATUS_SUCCESS) { + goto out; + } + + do { + nrf_wifi_osal_sleep_ms(fmac_dev_ctx->fpriv->opriv, + 1); + count++; + } while ((fmac_dev_ctx->temp_get_status == true) && + (count < NRF_WIFI_FMAC_STATS_RECV_TIMEOUT)); + + if (count == NRF_WIFI_FMAC_STATS_RECV_TIMEOUT) { + nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv, + "%s: Timed out", + __func__); + goto out; + } + + *current_temp = fmac_dev_ctx->current_temp; +out: + return status; +}