From ad945a9209da98409cefa9f67ae49c0f7ec3da24 Mon Sep 17 00:00:00 2001 From: Mahammadyunus Patil Date: Wed, 20 Nov 2024 18:50:52 +0530 Subject: [PATCH] nrf_wifi: Add support to read battery voltage This commit introduces support for reading and displaying the battery voltage. Signed-off-by: Mahammadyunus Patil --- .../fw_if/umac_if/inc/radio_test/fmac_api.h | 107 +- drivers/nrf_wifi/fw_if/umac_if/src/event.c | 1758 ++++++++--------- .../fw_if/umac_if/src/radio_test/fmac_api.c | 1172 ++++++----- .../nrf_wifi/hw_if/hal/inc/fw/phy_rf_params.h | 676 ++++--- 4 files changed, 1788 insertions(+), 1925 deletions(-) diff --git a/drivers/nrf_wifi/fw_if/umac_if/inc/radio_test/fmac_api.h b/drivers/nrf_wifi/fw_if/umac_if/inc/radio_test/fmac_api.h index e86ecf77..ed8e038f 100644 --- a/drivers/nrf_wifi/fw_if/umac_if/inc/radio_test/fmac_api.h +++ b/drivers/nrf_wifi/fw_if/umac_if/inc/radio_test/fmac_api.h @@ -16,18 +16,17 @@ #ifndef __FMAC_API_H__ #define __FMAC_API_H__ -#include "osal_api.h" -#include "host_rpu_umac_if.h" #include "host_rpu_data_if.h" #include "host_rpu_sys_if.h" +#include "host_rpu_umac_if.h" +#include "osal_api.h" -#include "fmac_structs.h" +#include "fmac_api_common.h" +#include "fmac_bb.h" #include "fmac_cmd.h" #include "fmac_event.h" +#include "fmac_structs.h" #include "fmac_vif.h" -#include "fmac_bb.h" -#include "fmac_api_common.h" - /** * @brief Initialize the UMAC IF layer. @@ -42,8 +41,7 @@ * * @return Pointer to the context of the UMAC IF layer. */ -struct nrf_wifi_fmac_priv *nrf_wifi_fmac_init_rt(void); - +struct nrf_wifi_fmac_priv* nrf_wifi_fmac_init_rt(void); /** * @brief Initialize the RPU for radio tests. @@ -56,8 +54,8 @@ struct nrf_wifi_fmac_priv *nrf_wifi_fmac_init_rt(void); * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_radio_test_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - struct rpu_conf_params *params); +enum nrf_wifi_status nrf_wifi_fmac_radio_test_init(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + struct rpu_conf_params* params); /** * @brief Start TX tests in radio test mode. @@ -70,8 +68,8 @@ enum nrf_wifi_status nrf_wifi_fmac_radio_test_init(struct nrf_wifi_fmac_dev_ctx * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_radio_test_prog_tx(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - struct rpu_conf_params *params); +enum nrf_wifi_status nrf_wifi_fmac_radio_test_prog_tx(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + struct rpu_conf_params* params); /** * @brief Start RX tests in radio test mode. @@ -84,9 +82,8 @@ enum nrf_wifi_status nrf_wifi_fmac_radio_test_prog_tx(struct nrf_wifi_fmac_dev_c * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_radio_test_prog_rx(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - struct rpu_conf_params *params); - +enum nrf_wifi_status nrf_wifi_fmac_radio_test_prog_rx(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + struct rpu_conf_params* params); /** * @brief Start RF test capture in radio test mode. @@ -105,15 +102,12 @@ enum nrf_wifi_status nrf_wifi_fmac_radio_test_prog_rx(struct nrf_wifi_fmac_dev_c * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_rf_test_rx_cap(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - enum nrf_wifi_rf_test rf_test_type, - void *cap_data, - unsigned short int num_samples, - unsigned short int capture_timeout, - unsigned char lna_gain, - unsigned char bb_gain, - unsigned char *timeout_status); - +enum nrf_wifi_status nrf_wifi_fmac_rf_test_rx_cap(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + enum nrf_wifi_rf_test rf_test_type, + void* cap_data, unsigned short int num_samples, + unsigned short int capture_timeout, + unsigned char lna_gain, unsigned char bb_gain, + unsigned char* timeout_status); /** * @brief Start/Stop RF TX tone test in radio test mode. @@ -128,12 +122,9 @@ enum nrf_wifi_status nrf_wifi_fmac_rf_test_rx_cap(struct nrf_wifi_fmac_dev_ctx * * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_rf_test_tx_tone(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - unsigned char enable, - signed char tone_freq, - signed char tx_power); - - +enum nrf_wifi_status nrf_wifi_fmac_rf_test_tx_tone(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + unsigned char enable, signed char tone_freq, + signed char tx_power); /** * @brief Start/Stop RF DPD test in radio test mode. @@ -146,10 +137,8 @@ enum nrf_wifi_status nrf_wifi_fmac_rf_test_tx_tone(struct nrf_wifi_fmac_dev_ctx * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_rf_test_dpd(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - unsigned char enable); - - +enum nrf_wifi_status nrf_wifi_fmac_rf_test_dpd(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + unsigned char enable); /** * @brief Get temperature in Fahrenheit using temperature sensor. @@ -161,9 +150,7 @@ enum nrf_wifi_status nrf_wifi_fmac_rf_test_dpd(struct nrf_wifi_fmac_dev_ctx *fma * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_rf_get_temp(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); - - +enum nrf_wifi_status nrf_wifi_fmac_rf_get_temp(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx); /** * @brief Get RF RSSI status. @@ -175,8 +162,20 @@ enum nrf_wifi_status nrf_wifi_fmac_rf_get_temp(struct nrf_wifi_fmac_dev_ctx *fma * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_rf_get_rf_rssi(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); +enum nrf_wifi_status nrf_wifi_fmac_rf_get_rf_rssi(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx); +/** + * @brief Retrieves the battery voltage in volts. + * @param fmac_dev_ctx Pointer to the UMAC IF context for a RPU WLAN device. + * + * This function is used to send a command to: + * - The RPU firmware to to acquire the battery voltage using + * the radio test mode. + * + * @retval NRF_WIFI_STATUS_SUCCESS On Success + * @retval NRF_WIFI_STATUS_FAIL On failure to execute command + */ +enum nrf_wifi_status nrf_wifi_fmac_rf_get_bat_volt(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx); /** * @brief Set XO adjustment value. @@ -189,8 +188,8 @@ enum nrf_wifi_status nrf_wifi_fmac_rf_get_rf_rssi(struct nrf_wifi_fmac_dev_ctx * * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_set_xo_val(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - unsigned char value); +enum nrf_wifi_status nrf_wifi_fmac_set_xo_val(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + unsigned char value); /** * @brief Get XO calibrated value. @@ -203,8 +202,7 @@ enum nrf_wifi_status nrf_wifi_fmac_set_xo_val(struct nrf_wifi_fmac_dev_ctx *fmac * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_rf_test_compute_xo(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); - +enum nrf_wifi_status nrf_wifi_fmac_rf_test_compute_xo(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx); /** * @brief De-initialize the UMAC IF layer. @@ -216,8 +214,7 @@ enum nrf_wifi_status nrf_wifi_fmac_rf_test_compute_xo(struct nrf_wifi_fmac_dev_c * - De-initializes the HAL layer. * - Frees the context for the UMAC IF layer. */ -void nrf_wifi_fmac_deinit_rt(struct nrf_wifi_fmac_priv *fpriv); - +void nrf_wifi_fmac_deinit_rt(struct nrf_wifi_fmac_priv* fpriv); /** * @brief Removes a RPU instance. @@ -225,8 +222,7 @@ void nrf_wifi_fmac_deinit_rt(struct nrf_wifi_fmac_priv *fpriv); * * This function handles the removal of an RPU instance at the UMAC IF layer. */ -void nrf_wifi_fmac_dev_rem_rt(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); - +void nrf_wifi_fmac_dev_rem_rt(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx); /** * @brief Initialize a RPU instance. @@ -245,18 +241,15 @@ void nrf_wifi_fmac_dev_rem_rt(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); * @retval NRF_WIFI_STATUS_SUCCESS On Success * @retval NRF_WIFI_STATUS_FAIL On failure to execute command */ -enum nrf_wifi_status nrf_wifi_fmac_dev_init_rt(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, +enum nrf_wifi_status +nrf_wifi_fmac_dev_init_rt(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, #if defined(NRF_WIFI_LOW_POWER) || defined(__DOXYGEN__) - int sleep_type, + int sleep_type, #endif /* NRF_WIFI_LOW_POWER */ - unsigned int phy_calib, - enum op_band op_band, - bool beamforming, - struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl, - struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params, - struct nrf_wifi_board_params *board_params, - unsigned char *country_code); - + unsigned int phy_calib, enum op_band op_band, bool beamforming, + struct nrf_wifi_tx_pwr_ctrl_params* tx_pwr_ctrl, + struct nrf_wifi_tx_pwr_ceil_params* tx_pwr_ceil_params, + struct nrf_wifi_board_params* board_params, unsigned char* country_code); /** * @brief De-initialize a RPU instance. @@ -264,7 +257,7 @@ enum nrf_wifi_status nrf_wifi_fmac_dev_init_rt(struct nrf_wifi_fmac_dev_ctx *fma * * This function de-initializes the firmware of an RPU instance. */ -void nrf_wifi_fmac_dev_deinit_rt(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx); +void nrf_wifi_fmac_dev_deinit_rt(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx); /** * @} diff --git a/drivers/nrf_wifi/fw_if/umac_if/src/event.c b/drivers/nrf_wifi/fw_if/umac_if/src/event.c index a349b3f8..0b8ab9d2 100644 --- a/drivers/nrf_wifi/fw_if/umac_if/src/event.c +++ b/drivers/nrf_wifi/fw_if/umac_if/src/event.c @@ -9,1127 +9,1003 @@ * FMAC IF Layer of the Wi-Fi driver. */ -#include "queue.h" -#include "host_rpu_umac_if.h" #include "hal_mem.h" +#include "host_rpu_umac_if.h" +#include "queue.h" #ifndef NRF70_OFFLOADED_RAW_TX +#include "fmac_ap.h" +#include "fmac_peer.h" #include "fmac_rx.h" #include "fmac_tx.h" -#include "fmac_peer.h" -#include "fmac_ap.h" #endif /* !NRF70_OFFLOADED_RAW_TX */ #include "fmac_cmd.h" #include "fmac_util.h" #ifdef NRF70_DATA_TX static enum nrf_wifi_status -nrf_wifi_fmac_if_carr_state_event_proc(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - unsigned char *umac_head, - enum nrf_wifi_fmac_if_carr_state carr_state) +nrf_wifi_fmac_if_carr_state_event_proc(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + unsigned char* umac_head, + enum nrf_wifi_fmac_if_carr_state carr_state) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_fmac_vif_ctx *vif_ctx = NULL; - unsigned char if_idx = 0; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; - struct nrf_wifi_fmac_priv_def *def_priv = NULL; - - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - def_priv = wifi_fmac_priv(fmac_dev_ctx->fpriv); - - if (!fmac_dev_ctx || !umac_head) { - nrf_wifi_osal_log_err("%s: Invalid parameters", - __func__); - - goto out; - } - - if (!def_priv->callbk_fns.if_carr_state_chg_callbk_fn) { - nrf_wifi_osal_log_dbg("%s: No callback handler registered", - __func__); - - status = NRF_WIFI_STATUS_SUCCESS; - goto out; - } - - if_idx = ((struct nrf_wifi_data_carrier_state *)umac_head)->wdev_id; - - if (if_idx >= MAX_NUM_VIFS) { - nrf_wifi_osal_log_err("%s: Invalid wdev_id recd from UMAC %d", - __func__, - if_idx); - goto out; - } - - vif_ctx = def_dev_ctx->vif_ctx[if_idx]; - - status = def_priv->callbk_fns.if_carr_state_chg_callbk_fn(vif_ctx->os_vif_ctx, - carr_state); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: IF carrier state change failed for VIF idx = %d", - __func__, - if_idx); - goto out; - } + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_fmac_vif_ctx* vif_ctx = NULL; + unsigned char if_idx = 0; + struct nrf_wifi_fmac_dev_ctx_def* def_dev_ctx = NULL; + struct nrf_wifi_fmac_priv_def* def_priv = NULL; + + def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + def_priv = wifi_fmac_priv(fmac_dev_ctx->fpriv); + + if (!fmac_dev_ctx || !umac_head) + { + nrf_wifi_osal_log_err("%s: Invalid parameters", __func__); + + goto out; + } + + if (!def_priv->callbk_fns.if_carr_state_chg_callbk_fn) + { + nrf_wifi_osal_log_dbg("%s: No callback handler registered", __func__); + + status = NRF_WIFI_STATUS_SUCCESS; + goto out; + } + + if_idx = ((struct nrf_wifi_data_carrier_state*) umac_head)->wdev_id; + + if (if_idx >= MAX_NUM_VIFS) + { + nrf_wifi_osal_log_err("%s: Invalid wdev_id recd from UMAC %d", __func__, if_idx); + goto out; + } + + vif_ctx = def_dev_ctx->vif_ctx[if_idx]; + + status = def_priv->callbk_fns.if_carr_state_chg_callbk_fn(vif_ctx->os_vif_ctx, carr_state); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: IF carrier state change failed for VIF idx = %d", __func__, + if_idx); + goto out; + } out: - return status; + return status; } #endif /* NRF70_DATA_TX */ #ifdef NRF70_STA_MODE -static void umac_event_connect(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - void *event_data) +static void umac_event_connect(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, void* event_data) { - unsigned char if_index = 0; - int peer_id = -1; - struct nrf_wifi_fmac_vif_ctx *vif_ctx = NULL; - struct nrf_wifi_umac_event_new_station *event = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; - - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - event = (struct nrf_wifi_umac_event_new_station *)event_data; - - if_index = event->umac_hdr.ids.wdev_id; - - vif_ctx = def_dev_ctx->vif_ctx[if_index]; - if (if_index >= MAX_NUM_VIFS) { - nrf_wifi_osal_log_err("%s: Invalid wdev_id recd from UMAC %d", - __func__, - if_index); - return; - } - - if (event->umac_hdr.cmd_evnt == NRF_WIFI_UMAC_EVENT_NEW_STATION) { - if (vif_ctx->if_type == 2) { - nrf_wifi_osal_mem_cpy(vif_ctx->bssid, - event->mac_addr, - NRF_WIFI_ETH_ADDR_LEN); - } - peer_id = nrf_wifi_fmac_peer_get_id(fmac_dev_ctx, event->mac_addr); - - if (peer_id == -1) { - peer_id = nrf_wifi_fmac_peer_add(fmac_dev_ctx, - if_index, - event->mac_addr, - event->is_sta_legacy, - event->wme); - - if (peer_id == -1) { - nrf_wifi_osal_log_err("%s:Can't add new station.", - __func__); - return; - } - } - } else if (event->umac_hdr.cmd_evnt == NRF_WIFI_UMAC_EVENT_DEL_STATION) { - peer_id = nrf_wifi_fmac_peer_get_id(fmac_dev_ctx, event->mac_addr); - if (peer_id != -1) { - nrf_wifi_fmac_peer_remove(fmac_dev_ctx, - if_index, - peer_id); - } - } - - return; - + unsigned char if_index = 0; + int peer_id = -1; + struct nrf_wifi_fmac_vif_ctx* vif_ctx = NULL; + struct nrf_wifi_umac_event_new_station* event = NULL; + struct nrf_wifi_fmac_dev_ctx_def* def_dev_ctx = NULL; + + def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + event = (struct nrf_wifi_umac_event_new_station*) event_data; + + if_index = event->umac_hdr.ids.wdev_id; + + vif_ctx = def_dev_ctx->vif_ctx[if_index]; + if (if_index >= MAX_NUM_VIFS) + { + nrf_wifi_osal_log_err("%s: Invalid wdev_id recd from UMAC %d", __func__, if_index); + return; + } + + if (event->umac_hdr.cmd_evnt == NRF_WIFI_UMAC_EVENT_NEW_STATION) + { + if (vif_ctx->if_type == 2) + { + nrf_wifi_osal_mem_cpy(vif_ctx->bssid, event->mac_addr, NRF_WIFI_ETH_ADDR_LEN); + } + peer_id = nrf_wifi_fmac_peer_get_id(fmac_dev_ctx, event->mac_addr); + + if (peer_id == -1) + { + peer_id = nrf_wifi_fmac_peer_add(fmac_dev_ctx, if_index, event->mac_addr, + event->is_sta_legacy, event->wme); + + if (peer_id == -1) + { + nrf_wifi_osal_log_err("%s:Can't add new station.", __func__); + return; + } + } + } + else if (event->umac_hdr.cmd_evnt == NRF_WIFI_UMAC_EVENT_DEL_STATION) + { + peer_id = nrf_wifi_fmac_peer_get_id(fmac_dev_ctx, event->mac_addr); + if (peer_id != -1) + { + nrf_wifi_fmac_peer_remove(fmac_dev_ctx, if_index, peer_id); + } + } + + return; } #endif /* NRF70_STA_MODE */ -static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - void *event_data, - unsigned int event_len) +static enum nrf_wifi_status umac_event_ctrl_process(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + void* event_data, unsigned int event_len) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_SUCCESS; - struct nrf_wifi_umac_hdr *umac_hdr = NULL; + enum nrf_wifi_status status = NRF_WIFI_STATUS_SUCCESS; + struct nrf_wifi_umac_hdr* umac_hdr = NULL; #if !defined(NRF70_RADIO_TEST) && !defined(NRF70_OFFLOADED_RAW_TX) - struct nrf_wifi_fmac_vif_ctx *vif_ctx = NULL; - struct nrf_wifi_fmac_callbk_fns *callbk_fns = NULL; - struct nrf_wifi_umac_event_vif_state *evnt_vif_state = NULL; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; - struct nrf_wifi_fmac_priv_def *def_priv = NULL; - bool more_res = false; + struct nrf_wifi_fmac_vif_ctx* vif_ctx = NULL; + struct nrf_wifi_fmac_callbk_fns* callbk_fns = NULL; + struct nrf_wifi_umac_event_vif_state* evnt_vif_state = NULL; + struct nrf_wifi_fmac_dev_ctx_def* def_dev_ctx = NULL; + struct nrf_wifi_fmac_priv_def* def_priv = NULL; + bool more_res = false; #elif NRF70_RADIO_TEST - struct nrf_wifi_reg *get_reg_event = NULL; - struct nrf_wifi_event_regulatory_change *reg_change_event = NULL; + struct nrf_wifi_reg* get_reg_event = NULL; + struct nrf_wifi_event_regulatory_change* reg_change_event = NULL; #elif NRF70_OFFLOADED_RAW_TX - struct nrf_wifi_off_raw_tx_fmac_dev_ctx *def_dev_ctx_off_raw_tx = NULL; - struct nrf_wifi_reg *get_reg_event = NULL; + struct nrf_wifi_off_raw_tx_fmac_dev_ctx* def_dev_ctx_off_raw_tx = NULL; + struct nrf_wifi_reg* get_reg_event = NULL; #endif /* !NRF70_RADIO_TEST && !NRF70_OFFLOADED_RAW_TX */ - unsigned char if_id = 0; - unsigned int event_num = 0; + unsigned char if_id = 0; + unsigned int event_num = 0; - if (!fmac_dev_ctx || !event_data) { - nrf_wifi_osal_log_err("%s: Invalid parameters", - __func__); - goto out; - } + if (!fmac_dev_ctx || !event_data) + { + nrf_wifi_osal_log_err("%s: Invalid parameters", __func__); + goto out; + } #if !defined(NRF70_RADIO_TEST) && !defined(NRF70_OFFLOADED_RAW_TX) - def_priv = wifi_fmac_priv(fmac_dev_ctx->fpriv); - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + def_priv = wifi_fmac_priv(fmac_dev_ctx->fpriv); + def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - if (!def_priv || !def_dev_ctx) { - goto out; - } + if (!def_priv || !def_dev_ctx) + { + goto out; + } #endif /* !NRF70_RADIO_TEST && !NRF70_OFFLOADED_RAW_TX */ #ifdef NRF70_OFFLOADED_RAW_TX - def_dev_ctx_off_raw_tx = wifi_dev_priv(fmac_dev_ctx); + def_dev_ctx_off_raw_tx = wifi_dev_priv(fmac_dev_ctx); #endif /* NRF70_OFFLOADED_RAW_TX */ - umac_hdr = event_data; - if_id = umac_hdr->ids.wdev_id; - event_num = umac_hdr->cmd_evnt; + umac_hdr = event_data; + if_id = umac_hdr->ids.wdev_id; + event_num = umac_hdr->cmd_evnt; - if (if_id >= MAX_NUM_VIFS) { - nrf_wifi_osal_log_err("%s: Invalid wdev_id recd from UMAC %d", - __func__, - if_id); + if (if_id >= MAX_NUM_VIFS) + { + nrf_wifi_osal_log_err("%s: Invalid wdev_id recd from UMAC %d", __func__, if_id); - goto out; - } + goto out; + } #if !defined(NRF70_RADIO_TEST) && !defined(NRF70_OFFLOADED_RAW_TX) - vif_ctx = def_dev_ctx->vif_ctx[if_id]; - callbk_fns = &def_priv->callbk_fns; + vif_ctx = def_dev_ctx->vif_ctx[if_id]; + callbk_fns = &def_priv->callbk_fns; #endif /* !NRF70_RADIO_TEST && !NRF70_OFFLOADED_RAW_TX */ #ifdef CONFIG_NRF_WIFI_CMD_EVENT_LOG - nrf_wifi_osal_log_info("%s: Event %d received from UMAC\n", - __func__, - event_num); + nrf_wifi_osal_log_info("%s: Event %d received from UMAC\n", __func__, event_num); #else - nrf_wifi_osal_log_dbg("%s: Event %d received from UMAC", - __func__, - event_num); + nrf_wifi_osal_log_dbg("%s: Event %d received from UMAC", __func__, event_num); #endif /* CONFIG_NRF_WIFI_CMD_EVENT_LOG */ - switch (umac_hdr->cmd_evnt) { - case NRF_WIFI_UMAC_EVENT_GET_REG: + switch (umac_hdr->cmd_evnt) + { + case NRF_WIFI_UMAC_EVENT_GET_REG: #ifdef NRF70_STA_MODE - if (callbk_fns->event_get_reg) - callbk_fns->event_get_reg(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); + if (callbk_fns->event_get_reg) + callbk_fns->event_get_reg(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); #endif /* NRF70_STA_MODE */ #ifdef NRF70_RADIO_TEST - get_reg_event = (struct nrf_wifi_reg *)event_data; + get_reg_event = (struct nrf_wifi_reg*) event_data; - nrf_wifi_osal_mem_cpy(&fmac_dev_ctx->alpha2, - &get_reg_event->nrf_wifi_alpha2, - sizeof(get_reg_event->nrf_wifi_alpha2)); - fmac_dev_ctx->alpha2_valid = true; + nrf_wifi_osal_mem_cpy(&fmac_dev_ctx->alpha2, &get_reg_event->nrf_wifi_alpha2, + sizeof(get_reg_event->nrf_wifi_alpha2)); + fmac_dev_ctx->alpha2_valid = true; #endif /* NRF70_RADIO_TEST */ #ifdef NRF70_OFFLOADED_RAW_TX - get_reg_event = (struct nrf_wifi_reg *)event_data; + get_reg_event = (struct nrf_wifi_reg*) event_data; - nrf_wifi_osal_mem_cpy(&def_dev_ctx_off_raw_tx->country_code, - &get_reg_event->nrf_wifi_alpha2, - sizeof(get_reg_event->nrf_wifi_alpha2)); - fmac_dev_ctx->alpha2_valid = true; + nrf_wifi_osal_mem_cpy(&def_dev_ctx_off_raw_tx->country_code, + &get_reg_event->nrf_wifi_alpha2, + sizeof(get_reg_event->nrf_wifi_alpha2)); + fmac_dev_ctx->alpha2_valid = true; #endif /* NRF70_OFFLOADED_RAW_TX */ - break; - case NRF_WIFI_UMAC_EVENT_REG_CHANGE: + break; + case NRF_WIFI_UMAC_EVENT_REG_CHANGE: #ifdef NRF70_STA_MODE - if (callbk_fns->reg_change_callbk_fn) - callbk_fns->reg_change_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); + if (callbk_fns->reg_change_callbk_fn) + callbk_fns->reg_change_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); #endif /* NRF70_STA_MODE */ #ifdef NRF70_RADIO_TEST - reg_change_event = (struct nrf_wifi_event_regulatory_change *)event_data; + reg_change_event = (struct nrf_wifi_event_regulatory_change*) event_data; - fmac_dev_ctx->reg_change = nrf_wifi_osal_mem_zalloc(sizeof(*reg_change_event)); + fmac_dev_ctx->reg_change = nrf_wifi_osal_mem_zalloc(sizeof(*reg_change_event)); - if (!fmac_dev_ctx->reg_change) { - nrf_wifi_osal_log_err("%s: Failed to allocate memory for reg_change", - __func__); - goto out; - } + if (!fmac_dev_ctx->reg_change) + { + nrf_wifi_osal_log_err("%s: Failed to allocate memory for reg_change", __func__); + goto out; + } - nrf_wifi_osal_mem_cpy(fmac_dev_ctx->reg_change, - reg_change_event, - sizeof(*reg_change_event)); - fmac_dev_ctx->reg_set_status = true; + nrf_wifi_osal_mem_cpy(fmac_dev_ctx->reg_change, reg_change_event, + sizeof(*reg_change_event)); + fmac_dev_ctx->reg_set_status = true; #endif /* NRF70_RADIO_TEST */ - break; + break; #if !defined(NRF70_RADIO_TEST) && !defined(NRF70_OFFLOADED_RAW_TX) - case NRF_WIFI_UMAC_EVENT_TRIGGER_SCAN_START: - if (callbk_fns->scan_start_callbk_fn) - callbk_fns->scan_start_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_SCAN_DONE: - if (callbk_fns->scan_done_callbk_fn) - callbk_fns->scan_done_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_SCAN_ABORTED: - if (callbk_fns->scan_abort_callbk_fn) - callbk_fns->scan_abort_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_SCAN_DISPLAY_RESULT: - if (umac_hdr->seq != 0) - more_res = true; - - if (callbk_fns->disp_scan_res_callbk_fn) - callbk_fns->disp_scan_res_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len, - more_res); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_IFFLAGS_STATUS: - evnt_vif_state = (struct nrf_wifi_umac_event_vif_state *)event_data; - - if (evnt_vif_state->status < 0) { - nrf_wifi_osal_log_err("%s: Failed to set interface flags: %d", - __func__, - evnt_vif_state->status); - goto out; - } - vif_ctx->ifflags = true; - break; + case NRF_WIFI_UMAC_EVENT_TRIGGER_SCAN_START: + if (callbk_fns->scan_start_callbk_fn) + callbk_fns->scan_start_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_SCAN_DONE: + if (callbk_fns->scan_done_callbk_fn) + callbk_fns->scan_done_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_SCAN_ABORTED: + if (callbk_fns->scan_abort_callbk_fn) + callbk_fns->scan_abort_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_SCAN_DISPLAY_RESULT: + if (umac_hdr->seq != 0) + more_res = true; + + if (callbk_fns->disp_scan_res_callbk_fn) + callbk_fns->disp_scan_res_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len, + more_res); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_IFFLAGS_STATUS: + evnt_vif_state = (struct nrf_wifi_umac_event_vif_state*) event_data; + + if (evnt_vif_state->status < 0) + { + nrf_wifi_osal_log_err("%s: Failed to set interface flags: %d", __func__, + evnt_vif_state->status); + goto out; + } + vif_ctx->ifflags = true; + break; #ifdef NRF70_STA_MODE - case NRF_WIFI_UMAC_EVENT_TWT_SLEEP: - if (callbk_fns->twt_sleep_callbk_fn) - callbk_fns->twt_sleep_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_SCAN_RESULT: - if (umac_hdr->seq != 0) - more_res = true; - - if (callbk_fns->scan_res_callbk_fn) - callbk_fns->scan_res_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len, - more_res); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_AUTHENTICATE: - if (callbk_fns->auth_resp_callbk_fn) - callbk_fns->auth_resp_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_ASSOCIATE: - if (callbk_fns->assoc_resp_callbk_fn) - callbk_fns->assoc_resp_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_DEAUTHENTICATE: - if (callbk_fns->deauth_callbk_fn) - callbk_fns->deauth_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_DISASSOCIATE: - if (callbk_fns->disassoc_callbk_fn) - callbk_fns->disassoc_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_FRAME: - if (callbk_fns->mgmt_rx_callbk_fn) - callbk_fns->mgmt_rx_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_GET_TX_POWER: - if (callbk_fns->tx_pwr_get_callbk_fn) - callbk_fns->tx_pwr_get_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_GET_CHANNEL: - if (callbk_fns->chnl_get_callbk_fn) - callbk_fns->chnl_get_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_GET_STATION: - if (callbk_fns->get_station_callbk_fn) - callbk_fns->get_station_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_NEW_INTERFACE: - if (callbk_fns->get_interface_callbk_fn) - callbk_fns->get_interface_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_COOKIE_RESP: - if (callbk_fns->cookie_rsp_callbk_fn) - callbk_fns->cookie_rsp_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_FRAME_TX_STATUS: - if (callbk_fns->mgmt_tx_status) - callbk_fns->mgmt_tx_status(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_UNPROT_DEAUTHENTICATE: - case NRF_WIFI_UMAC_EVENT_UNPROT_DISASSOCIATE: - if (callbk_fns->unprot_mlme_mgmt_rx_callbk_fn) - callbk_fns->unprot_mlme_mgmt_rx_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_SET_INTERFACE: - if (callbk_fns->set_if_callbk_fn) - callbk_fns->set_if_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_CONFIG_TWT: - if (callbk_fns->twt_config_callbk_fn) - callbk_fns->twt_config_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_TEARDOWN_TWT: - if (callbk_fns->twt_teardown_callbk_fn) - callbk_fns->twt_teardown_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_NEW_WIPHY: - if (callbk_fns->event_get_wiphy) - callbk_fns->event_get_wiphy(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_CMD_STATUS: + case NRF_WIFI_UMAC_EVENT_TWT_SLEEP: + if (callbk_fns->twt_sleep_callbk_fn) + callbk_fns->twt_sleep_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_SCAN_RESULT: + if (umac_hdr->seq != 0) + more_res = true; + + if (callbk_fns->scan_res_callbk_fn) + callbk_fns->scan_res_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len, more_res); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_AUTHENTICATE: + if (callbk_fns->auth_resp_callbk_fn) + callbk_fns->auth_resp_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_ASSOCIATE: + if (callbk_fns->assoc_resp_callbk_fn) + callbk_fns->assoc_resp_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_DEAUTHENTICATE: + if (callbk_fns->deauth_callbk_fn) + callbk_fns->deauth_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_DISASSOCIATE: + if (callbk_fns->disassoc_callbk_fn) + callbk_fns->disassoc_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_FRAME: + if (callbk_fns->mgmt_rx_callbk_fn) + callbk_fns->mgmt_rx_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_GET_TX_POWER: + if (callbk_fns->tx_pwr_get_callbk_fn) + callbk_fns->tx_pwr_get_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_GET_CHANNEL: + if (callbk_fns->chnl_get_callbk_fn) + callbk_fns->chnl_get_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_GET_STATION: + if (callbk_fns->get_station_callbk_fn) + callbk_fns->get_station_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_NEW_INTERFACE: + if (callbk_fns->get_interface_callbk_fn) + callbk_fns->get_interface_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_COOKIE_RESP: + if (callbk_fns->cookie_rsp_callbk_fn) + callbk_fns->cookie_rsp_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_FRAME_TX_STATUS: + if (callbk_fns->mgmt_tx_status) + callbk_fns->mgmt_tx_status(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_UNPROT_DEAUTHENTICATE: + case NRF_WIFI_UMAC_EVENT_UNPROT_DISASSOCIATE: + if (callbk_fns->unprot_mlme_mgmt_rx_callbk_fn) + callbk_fns->unprot_mlme_mgmt_rx_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_SET_INTERFACE: + if (callbk_fns->set_if_callbk_fn) + callbk_fns->set_if_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_CONFIG_TWT: + if (callbk_fns->twt_config_callbk_fn) + callbk_fns->twt_config_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_TEARDOWN_TWT: + if (callbk_fns->twt_teardown_callbk_fn) + callbk_fns->twt_teardown_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_NEW_WIPHY: + if (callbk_fns->event_get_wiphy) + callbk_fns->event_get_wiphy(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_CMD_STATUS: #if CONFIG_WIFI_NRF70_LOG_LEVEL >= NRF_WIFI_LOG_LEVEL_DBG - struct nrf_wifi_umac_event_cmd_status *cmd_status = - (struct nrf_wifi_umac_event_cmd_status *)event_data; + struct nrf_wifi_umac_event_cmd_status* cmd_status = + (struct nrf_wifi_umac_event_cmd_status*) event_data; #endif - nrf_wifi_osal_log_dbg("%s: Command %d -> status %d", - __func__, - cmd_status->cmd_id, - cmd_status->cmd_status); - break; - case NRF_WIFI_UMAC_EVENT_BEACON_HINT: - case NRF_WIFI_UMAC_EVENT_CONNECT: - case NRF_WIFI_UMAC_EVENT_DISCONNECT: - /* Nothing to be done */ - break; - case NRF_WIFI_UMAC_EVENT_GET_POWER_SAVE_INFO: - if (callbk_fns->event_get_ps_info) - callbk_fns->event_get_ps_info(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; + nrf_wifi_osal_log_dbg("%s: Command %d -> status %d", __func__, cmd_status->cmd_id, + cmd_status->cmd_status); + break; + case NRF_WIFI_UMAC_EVENT_BEACON_HINT: + case NRF_WIFI_UMAC_EVENT_CONNECT: + case NRF_WIFI_UMAC_EVENT_DISCONNECT: + /* Nothing to be done */ + break; + case NRF_WIFI_UMAC_EVENT_GET_POWER_SAVE_INFO: + if (callbk_fns->event_get_ps_info) + callbk_fns->event_get_ps_info(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; #ifdef NRF70_STA_MODE - case NRF_WIFI_UMAC_EVENT_NEW_STATION: - case NRF_WIFI_UMAC_EVENT_DEL_STATION: - umac_event_connect(fmac_dev_ctx, - event_data); - break; + case NRF_WIFI_UMAC_EVENT_NEW_STATION: + case NRF_WIFI_UMAC_EVENT_DEL_STATION: + umac_event_connect(fmac_dev_ctx, event_data); + break; #endif /* NRF70_STA_MODE */ #ifdef NRF70_P2P_MODE - case NRF_WIFI_UMAC_EVENT_REMAIN_ON_CHANNEL: - if (callbk_fns->roc_callbk_fn) - callbk_fns->roc_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - case NRF_WIFI_UMAC_EVENT_CANCEL_REMAIN_ON_CHANNEL: - if (callbk_fns->roc_cancel_callbk_fn) - callbk_fns->roc_cancel_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; + case NRF_WIFI_UMAC_EVENT_REMAIN_ON_CHANNEL: + if (callbk_fns->roc_callbk_fn) + callbk_fns->roc_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + case NRF_WIFI_UMAC_EVENT_CANCEL_REMAIN_ON_CHANNEL: + if (callbk_fns->roc_cancel_callbk_fn) + callbk_fns->roc_cancel_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; #endif /* NRF70_P2P_MODE */ - case NRF_WIFI_UMAC_EVENT_GET_CONNECTION_INFO: - if (callbk_fns->get_conn_info_callbk_fn) - callbk_fns->get_conn_info_callbk_fn(vif_ctx->os_vif_ctx, - event_data, - event_len); - else - nrf_wifi_osal_log_err("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; + case NRF_WIFI_UMAC_EVENT_GET_CONNECTION_INFO: + if (callbk_fns->get_conn_info_callbk_fn) + callbk_fns->get_conn_info_callbk_fn(vif_ctx->os_vif_ctx, event_data, event_len); + else + nrf_wifi_osal_log_err("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; #endif /* NRF70_STA_MODE */ #endif /* !NRF70_RADIO_TEST && !NRF70_OFFLOADED_RAW_TX */ - default: - nrf_wifi_osal_log_dbg("%s: No callback registered for event %d", - __func__, - umac_hdr->cmd_evnt); - break; - } + default: + nrf_wifi_osal_log_dbg("%s: No callback registered for event %d", __func__, + umac_hdr->cmd_evnt); + break; + } - nrf_wifi_osal_log_dbg("%s: Event %d processed", - __func__, - event_num); + nrf_wifi_osal_log_dbg("%s: Event %d processed", __func__, event_num); out: - return status; + return status; } #if !defined(NRF70_RADIO_TEST) && !defined(NRF70_OFFLOADED_RAW_TX) static enum nrf_wifi_status -nrf_wifi_fmac_data_event_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - void *umac_head) +nrf_wifi_fmac_data_event_process(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, void* umac_head) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_SUCCESS; - int event = -1; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; + enum nrf_wifi_status status = NRF_WIFI_STATUS_SUCCESS; + int event = -1; + struct nrf_wifi_fmac_dev_ctx_def* def_dev_ctx = NULL; - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - if (!fmac_dev_ctx) { - goto out; - } + if (!fmac_dev_ctx) + { + goto out; + } - if (!umac_head) { - nrf_wifi_osal_log_err("%s: Invalid parameters", - __func__); - goto out; - } + if (!umac_head) + { + nrf_wifi_osal_log_err("%s: Invalid parameters", __func__); + goto out; + } - event = ((struct nrf_wifi_umac_head *)umac_head)->cmd; + event = ((struct nrf_wifi_umac_head*) umac_head)->cmd; #ifdef CONFIG_NRF_WIFI_CMD_EVENT_LOG - nrf_wifi_osal_log_info("%s: Event %d received from UMAC\n", - __func__, - event); + nrf_wifi_osal_log_info("%s: Event %d received from UMAC\n", __func__, event); #else - nrf_wifi_osal_log_dbg("%s: Event %d received from UMAC", - __func__, - event); + nrf_wifi_osal_log_dbg("%s: Event %d received from UMAC", __func__, event); #endif /* CONFIG_NRF_WIFI_CMD_EVENT_LOG */ - switch (event) { - case NRF_WIFI_CMD_RX_BUFF: + switch (event) + { + case NRF_WIFI_CMD_RX_BUFF: #ifdef NRF70_RX_DONE_WQ_ENABLED - struct nrf_wifi_rx_buff *config = nrf_wifi_osal_mem_zalloc( - sizeof(struct nrf_wifi_rx_buff)); - if (!config) { - nrf_wifi_osal_log_err("%s: Failed to allocate memory (RX)", - __func__); - status = NRF_WIFI_STATUS_FAIL; - break; - } - nrf_wifi_osal_mem_cpy(config, - umac_head, - sizeof(struct nrf_wifi_rx_buff)); - status = nrf_wifi_utils_q_enqueue(def_dev_ctx->rx_config.rx_tasklet_event_q, - config); - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: Failed to enqueue RX buffer", - __func__); - nrf_wifi_osal_mem_free(config); - break; - } - nrf_wifi_osal_tasklet_schedule(def_dev_ctx->rx_tasklet); + struct nrf_wifi_rx_buff* config = nrf_wifi_osal_mem_zalloc(sizeof(struct nrf_wifi_rx_buff)); + if (!config) + { + nrf_wifi_osal_log_err("%s: Failed to allocate memory (RX)", __func__); + status = NRF_WIFI_STATUS_FAIL; + break; + } + nrf_wifi_osal_mem_cpy(config, umac_head, sizeof(struct nrf_wifi_rx_buff)); + status = nrf_wifi_utils_q_enqueue(def_dev_ctx->rx_config.rx_tasklet_event_q, config); + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: Failed to enqueue RX buffer", __func__); + nrf_wifi_osal_mem_free(config); + break; + } + nrf_wifi_osal_tasklet_schedule(def_dev_ctx->rx_tasklet); #else - status = nrf_wifi_fmac_rx_event_process(fmac_dev_ctx, - umac_head); + status = nrf_wifi_fmac_rx_event_process(fmac_dev_ctx, umac_head); #endif /* NRF70_RX_DONE_WQ_ENABLED */ - break; + break; #ifdef NRF70_DATA_TX - case NRF_WIFI_CMD_TX_BUFF_DONE: + case NRF_WIFI_CMD_TX_BUFF_DONE: #ifdef NRF70_TX_DONE_WQ_ENABLED - struct nrf_wifi_tx_buff_done *config = nrf_wifi_osal_mem_zalloc( - sizeof(struct nrf_wifi_tx_buff_done)); - if (!config) { - nrf_wifi_osal_log_err("%s: Failed to allocate memory (TX)", - __func__); - status = NRF_WIFI_STATUS_FAIL; - break; - } - nrf_wifi_osal_mem_cpy(config, - umac_head, - sizeof(struct nrf_wifi_tx_buff_done)); - status = nrf_wifi_utils_q_enqueue(def_dev_ctx->tx_config.tx_done_tasklet_event_q, - config); - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: Failed to enqueue TX buffer", - __func__); - nrf_wifi_osal_mem_free(config); - break; - } - nrf_wifi_osal_tasklet_schedule(def_dev_ctx->tx_done_tasklet); + struct nrf_wifi_tx_buff_done* config = + nrf_wifi_osal_mem_zalloc(sizeof(struct nrf_wifi_tx_buff_done)); + if (!config) + { + nrf_wifi_osal_log_err("%s: Failed to allocate memory (TX)", __func__); + status = NRF_WIFI_STATUS_FAIL; + break; + } + nrf_wifi_osal_mem_cpy(config, umac_head, sizeof(struct nrf_wifi_tx_buff_done)); + status = nrf_wifi_utils_q_enqueue(def_dev_ctx->tx_config.tx_done_tasklet_event_q, config); + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: Failed to enqueue TX buffer", __func__); + nrf_wifi_osal_mem_free(config); + break; + } + nrf_wifi_osal_tasklet_schedule(def_dev_ctx->tx_done_tasklet); #else - status = nrf_wifi_fmac_tx_done_event_process(fmac_dev_ctx, - umac_head); + status = nrf_wifi_fmac_tx_done_event_process(fmac_dev_ctx, umac_head); #endif /* NRF70_TX_DONE_WQ_ENABLED */ - break; - case NRF_WIFI_CMD_CARRIER_ON: - status = nrf_wifi_fmac_if_carr_state_event_proc(fmac_dev_ctx, - umac_head, - NRF_WIFI_FMAC_IF_CARR_STATE_ON); - break; - case NRF_WIFI_CMD_CARRIER_OFF: - status = nrf_wifi_fmac_if_carr_state_event_proc(fmac_dev_ctx, - umac_head, - NRF_WIFI_FMAC_IF_CARR_STATE_OFF); - break; + break; + case NRF_WIFI_CMD_CARRIER_ON: + status = nrf_wifi_fmac_if_carr_state_event_proc(fmac_dev_ctx, umac_head, + NRF_WIFI_FMAC_IF_CARR_STATE_ON); + break; + case NRF_WIFI_CMD_CARRIER_OFF: + status = nrf_wifi_fmac_if_carr_state_event_proc(fmac_dev_ctx, umac_head, + NRF_WIFI_FMAC_IF_CARR_STATE_OFF); + break; #endif /* NRF70_DATA_TX */ #ifdef NRF70_AP_MODE - case NRF_WIFI_CMD_PM_MODE: - status = sap_client_update_pmmode(fmac_dev_ctx, - umac_head); - break; - case NRF_WIFI_CMD_PS_GET_FRAMES: - status = sap_client_ps_get_frames(fmac_dev_ctx, - umac_head); - break; + case NRF_WIFI_CMD_PM_MODE: + status = sap_client_update_pmmode(fmac_dev_ctx, umac_head); + break; + case NRF_WIFI_CMD_PS_GET_FRAMES: + status = sap_client_ps_get_frames(fmac_dev_ctx, umac_head); + break; #endif /* NRF70_AP_MODE */ - default: - break; - } + default: + break; + } out: - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: Failed for event = %d", - __func__, - event); - } + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: Failed for event = %d", __func__, event); + } - return status; + return status; } - static enum nrf_wifi_status -nrf_wifi_fmac_data_events_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - struct host_rpu_msg *rpu_msg) +nrf_wifi_fmac_data_events_process(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + struct host_rpu_msg* rpu_msg) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - unsigned char *umac_head = NULL; - int host_rpu_length_left = 0; - - if (!fmac_dev_ctx || !rpu_msg) { - goto out; - } - - umac_head = (unsigned char *)rpu_msg->msg; - host_rpu_length_left = rpu_msg->hdr.len - sizeof(struct host_rpu_msg); - - while (host_rpu_length_left > 0) { - status = nrf_wifi_fmac_data_event_process(fmac_dev_ctx, - umac_head); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: umac_process_data_event failed", - __func__); - goto out; - } - - host_rpu_length_left -= ((struct nrf_wifi_umac_head *)umac_head)->len; - umac_head += ((struct nrf_wifi_umac_head *)umac_head)->len; - } + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + unsigned char* umac_head = NULL; + int host_rpu_length_left = 0; + + if (!fmac_dev_ctx || !rpu_msg) + { + goto out; + } + + umac_head = (unsigned char*) rpu_msg->msg; + host_rpu_length_left = rpu_msg->hdr.len - sizeof(struct host_rpu_msg); + + while (host_rpu_length_left > 0) + { + status = nrf_wifi_fmac_data_event_process(fmac_dev_ctx, umac_head); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: umac_process_data_event failed", __func__); + goto out; + } + + host_rpu_length_left -= ((struct nrf_wifi_umac_head*) umac_head)->len; + umac_head += ((struct nrf_wifi_umac_head*) umac_head)->len; + } out: - return status; + return status; } #elif NRF70_RADIO_TEST -static enum nrf_wifi_status umac_event_rf_test_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - void *event) +static enum nrf_wifi_status umac_event_rf_test_process(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + void* event) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_event_rftest *rf_test_event = NULL; - struct nrf_wifi_temperature_params rf_test_get_temperature; - struct nrf_wifi_rf_get_rf_rssi rf_get_rf_rssi; - struct nrf_wifi_rf_test_xo_calib xo_calib_params; - struct nrf_wifi_rf_get_xo_value rf_get_xo_value_params; - struct nrf_wifi_fmac_dev_ctx_rt *def_dev_ctx; - struct nrf_wifi_rf_test_capture_params rf_test_capture_params; - - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - - if (!event) { - nrf_wifi_osal_log_err("%s: Invalid parameters", - __func__); - goto out; - } - - rf_test_event = ((struct nrf_wifi_event_rftest *)event); - - if (rf_test_event->rf_test_info.rfevent[0] != def_dev_ctx->rf_test_type) { - nrf_wifi_osal_log_err("%s: Invalid event type (%d) recd for RF test type (%d)", - __func__, - rf_test_event->rf_test_info.rfevent[0], - def_dev_ctx->rf_test_type); - goto out; - } - - switch (rf_test_event->rf_test_info.rfevent[0]) { - case NRF_WIFI_RF_TEST_EVENT_RX_ADC_CAP: - case NRF_WIFI_RF_TEST_EVENT_RX_STAT_PKT_CAP: - case NRF_WIFI_RF_TEST_EVENT_RX_DYN_PKT_CAP: - status = hal_rpu_mem_read(fmac_dev_ctx->hal_dev_ctx, - def_dev_ctx->rf_test_cap_data, - RPU_MEM_RF_TEST_CAP_BASE, - def_dev_ctx->rf_test_cap_sz); - - nrf_wifi_osal_mem_cpy(&rf_test_capture_params, - (const unsigned char *)&rf_test_event->rf_test_info.rfevent[0], - sizeof(rf_test_capture_params)); - - def_dev_ctx->capture_status = rf_test_capture_params.capture_status; - - break; - case NRF_WIFI_RF_TEST_EVENT_TX_TONE_START: - case NRF_WIFI_RF_TEST_EVENT_DPD_ENABLE: - break; - - case NRF_WIFI_RF_TEST_GET_TEMPERATURE: - nrf_wifi_osal_mem_cpy(&rf_test_get_temperature, - (const unsigned char *)&rf_test_event->rf_test_info.rfevent[0], - sizeof(rf_test_get_temperature)); - - if (rf_test_get_temperature.readTemperatureStatus) { - nrf_wifi_osal_log_err("Temperature reading failed"); - } else { - nrf_wifi_osal_log_info("The temperature is = %d degree celsius", - rf_test_get_temperature.temperature); - } - break; - case NRF_WIFI_RF_TEST_EVENT_RF_RSSI: - nrf_wifi_osal_mem_cpy(&rf_get_rf_rssi, - (const unsigned char *)&rf_test_event->rf_test_info.rfevent[0], - sizeof(rf_get_rf_rssi)); - - nrf_wifi_osal_log_info("RF RSSI value is = %d", - rf_get_rf_rssi.agc_status_val); - break; - case NRF_WIFI_RF_TEST_EVENT_XO_CALIB: - nrf_wifi_osal_mem_cpy(&xo_calib_params, - (const unsigned char *)&rf_test_event->rf_test_info.rfevent[0], - sizeof(xo_calib_params)); - - nrf_wifi_osal_log_info("XO value configured is = %d", - xo_calib_params.xo_val); - break; - case NRF_WIFI_RF_TEST_XO_TUNE: - nrf_wifi_osal_mem_cpy(&rf_get_xo_value_params, - (const unsigned char *)&rf_test_event->rf_test_info.rfevent[0], - sizeof(rf_get_xo_value_params)); - - nrf_wifi_osal_log_info("Best XO value is = %d", - rf_get_xo_value_params.xo_value); - break; - default: - break; - } - - def_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; - status = NRF_WIFI_STATUS_SUCCESS; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_event_rftest* rf_test_event = NULL; + struct nrf_wifi_temperature_params rf_test_get_temperature; + struct nrf_wifi_rf_get_rf_rssi rf_get_rf_rssi; + struct nrf_wifi_rf_test_xo_calib xo_calib_params; + struct nrf_wifi_rf_get_xo_value rf_get_xo_value_params; + struct nrf_wifi_fmac_dev_ctx_rt* def_dev_ctx; + struct nrf_wifi_rf_test_capture_params rf_test_capture_params; + struct nrf_wifi_bat_volt_params bat_volt_params; + double voltage; + + def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + + if (!event) + { + nrf_wifi_osal_log_err("%s: Invalid parameters", __func__); + goto out; + } + + rf_test_event = ((struct nrf_wifi_event_rftest*) event); + + if (rf_test_event->rf_test_info.rfevent[0] != def_dev_ctx->rf_test_type) + { + nrf_wifi_osal_log_err("%s: Invalid event type (%d) recd for RF test type (%d)", __func__, + rf_test_event->rf_test_info.rfevent[0], def_dev_ctx->rf_test_type); + goto out; + } + + switch (rf_test_event->rf_test_info.rfevent[0]) + { + case NRF_WIFI_RF_TEST_EVENT_RX_ADC_CAP: + case NRF_WIFI_RF_TEST_EVENT_RX_STAT_PKT_CAP: + case NRF_WIFI_RF_TEST_EVENT_RX_DYN_PKT_CAP: + status = hal_rpu_mem_read(fmac_dev_ctx->hal_dev_ctx, def_dev_ctx->rf_test_cap_data, + RPU_MEM_RF_TEST_CAP_BASE, def_dev_ctx->rf_test_cap_sz); + + nrf_wifi_osal_mem_cpy(&rf_test_capture_params, + (const unsigned char*) &rf_test_event->rf_test_info.rfevent[0], + sizeof(rf_test_capture_params)); + + def_dev_ctx->capture_status = rf_test_capture_params.capture_status; + + break; + case NRF_WIFI_RF_TEST_EVENT_TX_TONE_START: + case NRF_WIFI_RF_TEST_EVENT_DPD_ENABLE: + break; + + case NRF_WIFI_RF_TEST_GET_TEMPERATURE: + nrf_wifi_osal_mem_cpy(&rf_test_get_temperature, + (const unsigned char*) &rf_test_event->rf_test_info.rfevent[0], + sizeof(rf_test_get_temperature)); + + if (rf_test_get_temperature.readTemperatureStatus) + { + nrf_wifi_osal_log_err("Temperature reading failed"); + } + else + { + nrf_wifi_osal_log_info("The temperature is = %d degree celsius", + rf_test_get_temperature.temperature); + } + break; + case NRF_WIFI_RF_TEST_EVENT_RF_RSSI: + nrf_wifi_osal_mem_cpy(&rf_get_rf_rssi, + (const unsigned char*) &rf_test_event->rf_test_info.rfevent[0], + sizeof(rf_get_rf_rssi)); + + nrf_wifi_osal_log_info("RF RSSI value is = %d", rf_get_rf_rssi.agc_status_val); + break; + case NRF_WIFI_RF_TEST_EVENT_GET_BAT_VOLT: + nrf_wifi_osal_mem_cpy(fmac_dev_ctx->fpriv->opriv, &bat_volt_params, + (const unsigned char*) &rf_test_event->rf_test_info.rfevent[0], + sizeof(bat_volt_params)); + if (bat_volt_params.cmd_status) + { + nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv, "Volatge reading failed"); + } + else + { + voltage = BAT_CONST_1 + (BAT_CONST_2 * bat_volt_params.voltage); + nrf_wifi_osal_log_info(fmac_dev_ctx->fpriv->opriv, "The battery voltage is = %lf Volts", + voltage); + } + break; + case NRF_WIFI_RF_TEST_EVENT_XO_CALIB: + nrf_wifi_osal_mem_cpy(&xo_calib_params, + (const unsigned char*) &rf_test_event->rf_test_info.rfevent[0], + sizeof(xo_calib_params)); + + nrf_wifi_osal_log_info("XO value configured is = %d", xo_calib_params.xo_val); + break; + case NRF_WIFI_RF_TEST_XO_TUNE: + nrf_wifi_osal_mem_cpy(&rf_get_xo_value_params, + (const unsigned char*) &rf_test_event->rf_test_info.rfevent[0], + sizeof(rf_get_xo_value_params)); + + nrf_wifi_osal_log_info("Best XO value is = %d", rf_get_xo_value_params.xo_value); + break; + default: + break; + } + + def_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; + status = NRF_WIFI_STATUS_SUCCESS; out: - return status; + return status; } - #endif /* !NRF70_RADIO_TEST && !NRF70_OFFLOADED_RAW_TX */ - -static enum nrf_wifi_status umac_event_stats_process(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - void *event) +static enum nrf_wifi_status umac_event_stats_process(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + void* event) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_umac_event_stats *stats = NULL; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_umac_event_stats* stats = NULL; - if (!event) { - nrf_wifi_osal_log_err("%s: Invalid parameters", - __func__); - goto out; - } + if (!event) + { + nrf_wifi_osal_log_err("%s: Invalid parameters", __func__); + goto out; + } - if (!fmac_dev_ctx->stats_req) { - nrf_wifi_osal_log_err("%s: Stats recd when req was not sent!", - __func__); - goto out; - } + if (!fmac_dev_ctx->stats_req) + { + nrf_wifi_osal_log_err("%s: Stats recd when req was not sent!", __func__); + goto out; + } - stats = ((struct nrf_wifi_umac_event_stats *)event); + stats = ((struct nrf_wifi_umac_event_stats*) event); - nrf_wifi_osal_mem_cpy(fmac_dev_ctx->fw_stats, - &stats->fw, - sizeof(*fmac_dev_ctx->fw_stats)); + nrf_wifi_osal_mem_cpy(fmac_dev_ctx->fw_stats, &stats->fw, sizeof(*fmac_dev_ctx->fw_stats)); - fmac_dev_ctx->stats_req = false; + fmac_dev_ctx->stats_req = false; - status = NRF_WIFI_STATUS_SUCCESS; + status = NRF_WIFI_STATUS_SUCCESS; out: - return status; + return status; } #ifdef NRF70_SYSTEM_WITH_RAW_MODES static enum nrf_wifi_status -nrf_wifi_fmac_if_mode_set_event_proc(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - struct nrf_wifi_event_raw_config_mode *mode_event) +nrf_wifi_fmac_if_mode_set_event_proc(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + struct nrf_wifi_event_raw_config_mode* mode_event) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_SUCCESS; - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx; - struct tx_config *config; - struct nrf_wifi_fmac_vif_ctx *vif; - unsigned char if_idx = mode_event->if_index; - - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - config = &def_dev_ctx->tx_config; - vif = def_dev_ctx->vif_ctx[if_idx]; - - if (!mode_event->status) { - vif->mode = mode_event->op_mode; + enum nrf_wifi_status status = NRF_WIFI_STATUS_SUCCESS; + struct nrf_wifi_fmac_dev_ctx_def* def_dev_ctx; + struct tx_config* config; + struct nrf_wifi_fmac_vif_ctx* vif; + unsigned char if_idx = mode_event->if_index; + + def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + config = &def_dev_ctx->tx_config; + vif = def_dev_ctx->vif_ctx[if_idx]; + + if (!mode_event->status) + { + vif->mode = mode_event->op_mode; #ifdef NRF70_RAW_DATA_TX - vif->txinjection_mode = false; + vif->txinjection_mode = false; #endif /* NRF70_RAW_DATA_TX */ #ifdef NRF70_PROMISC_DATA_RX - vif->promisc_mode = false; + vif->promisc_mode = false; #endif /* NRF70_PROMISC_DATA_RX */ - if ((mode_event->op_mode & NRF_WIFI_STA_MODE) - == NRF_WIFI_STA_MODE) { - mode_event->op_mode ^= NRF_WIFI_STA_MODE; - vif->if_type = NRF_WIFI_IFTYPE_STATION; - config->peers[MAX_PEERS].peer_id = -1; - config->peers[MAX_PEERS].if_idx = -1; - -#if defined(NRF70_RAW_DATA_TX) && defined (NRF70_PROMISC_DATA_RX) - if ((mode_event->op_mode ^ - (NRF_WIFI_PROMISCUOUS_MODE | - NRF_WIFI_TX_INJECTION_MODE)) == 0) { - vif->if_type - = NRF_WIFI_STA_PROMISC_TX_INJECTOR; - config->peers[MAX_PEERS].peer_id - = MAX_PEERS; - config->peers[MAX_PEERS].if_idx - = if_idx; - vif->txinjection_mode = true; - vif->promisc_mode = true; - } + if ((mode_event->op_mode & NRF_WIFI_STA_MODE) == NRF_WIFI_STA_MODE) + { + mode_event->op_mode ^= NRF_WIFI_STA_MODE; + vif->if_type = NRF_WIFI_IFTYPE_STATION; + config->peers[MAX_PEERS].peer_id = -1; + config->peers[MAX_PEERS].if_idx = -1; + +#if defined(NRF70_RAW_DATA_TX) && defined(NRF70_PROMISC_DATA_RX) + if ((mode_event->op_mode ^ (NRF_WIFI_PROMISCUOUS_MODE | NRF_WIFI_TX_INJECTION_MODE)) == + 0) + { + vif->if_type = NRF_WIFI_STA_PROMISC_TX_INJECTOR; + config->peers[MAX_PEERS].peer_id = MAX_PEERS; + config->peers[MAX_PEERS].if_idx = if_idx; + vif->txinjection_mode = true; + vif->promisc_mode = true; + } #endif /* NRF70_RAW_DATA_TX && defined NRF70_PROMISC_DATA_RX */ #ifdef NRF70_RAW_DATA_TX - if ((mode_event->op_mode ^ - NRF_WIFI_TX_INJECTION_MODE) == 0) { - config->peers[MAX_PEERS].peer_id - = MAX_PEERS; - config->peers[MAX_PEERS].if_idx - = if_idx; - vif->if_type = NRF_WIFI_STA_TX_INJECTOR; - vif->txinjection_mode = true; - } + if ((mode_event->op_mode ^ NRF_WIFI_TX_INJECTION_MODE) == 0) + { + config->peers[MAX_PEERS].peer_id = MAX_PEERS; + config->peers[MAX_PEERS].if_idx = if_idx; + vif->if_type = NRF_WIFI_STA_TX_INJECTOR; + vif->txinjection_mode = true; + } #endif /* NRF70_RAW_DATA_TX */ #ifdef NRF70_PROMISC_DATA_RX - if ((mode_event->op_mode ^ - NRF_WIFI_PROMISCUOUS_MODE) == 0) { - vif->if_type = NRF_WIFI_STA_PROMISC; - vif->promisc_mode = true; - } + if ((mode_event->op_mode ^ NRF_WIFI_PROMISCUOUS_MODE) == 0) + { + vif->if_type = NRF_WIFI_STA_PROMISC; + vif->promisc_mode = true; + } #endif /* NRF70_PROMISC_DATA_RX */ - goto out; - } + goto out; + } #ifdef NRF70_RAW_DATA_RX - if ((mode_event->op_mode & NRF_WIFI_MONITOR_MODE) - == NRF_WIFI_MONITOR_MODE) { - mode_event->op_mode ^= NRF_WIFI_MONITOR_MODE; - vif->if_type = NRF_WIFI_IFTYPE_MONITOR; - config->peers[MAX_PEERS].peer_id = -1; - config->peers[MAX_PEERS].if_idx = -1; + if ((mode_event->op_mode & NRF_WIFI_MONITOR_MODE) == NRF_WIFI_MONITOR_MODE) + { + mode_event->op_mode ^= NRF_WIFI_MONITOR_MODE; + vif->if_type = NRF_WIFI_IFTYPE_MONITOR; + config->peers[MAX_PEERS].peer_id = -1; + config->peers[MAX_PEERS].if_idx = -1; #ifdef NRF70_RAW_DATA_TX - if ((mode_event->op_mode ^ - NRF_WIFI_TX_INJECTION_MODE) == 0) { - config->peers[MAX_PEERS].peer_id - = MAX_PEERS; - config->peers[MAX_PEERS].if_idx - = if_idx; - vif->if_type = NRF_WIFI_MONITOR_TX_INJECTOR; - vif->txinjection_mode = true; - } + if ((mode_event->op_mode ^ NRF_WIFI_TX_INJECTION_MODE) == 0) + { + config->peers[MAX_PEERS].peer_id = MAX_PEERS; + config->peers[MAX_PEERS].if_idx = if_idx; + vif->if_type = NRF_WIFI_MONITOR_TX_INJECTOR; + vif->txinjection_mode = true; + } #endif - goto out; - } + goto out; + } #endif - } else { - nrf_wifi_osal_log_err("%s: Set mode failed!", - __func__); - status = NRF_WIFI_STATUS_FAIL; - } + } + else + { + nrf_wifi_osal_log_err("%s: Set mode failed!", __func__); + status = NRF_WIFI_STATUS_FAIL; + } out: - return status; + return status; } #endif /* NRF70_SYSTEM_WITH_RAW_MODES */ -static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - struct host_rpu_msg *rpu_msg) +static enum nrf_wifi_status umac_process_sys_events(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + struct host_rpu_msg* rpu_msg) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - unsigned char *sys_head = NULL; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + unsigned char* sys_head = NULL; #ifdef NRF70_RADIO_TEST - struct nrf_wifi_fmac_dev_ctx_rt *def_dev_ctx_rt; - struct nrf_wifi_umac_event_err_status *umac_status; + struct nrf_wifi_fmac_dev_ctx_rt* def_dev_ctx_rt; + struct nrf_wifi_umac_event_err_status* umac_status; #elif NRF70_OFFLOADED_RAW_TX - struct nrf_wifi_off_raw_tx_fmac_dev_ctx *def_dev_ctx_off_raw_tx; - struct nrf_wifi_umac_event_err_status *umac_status; + struct nrf_wifi_off_raw_tx_fmac_dev_ctx* def_dev_ctx_off_raw_tx; + struct nrf_wifi_umac_event_err_status* umac_status; #else - struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx; + struct nrf_wifi_fmac_dev_ctx_def* def_dev_ctx; #endif /* NRF70_RADIO_TEST */ - if (!fmac_dev_ctx || !rpu_msg) { - return status; - } + if (!fmac_dev_ctx || !rpu_msg) + { + return status; + } #ifdef NRF70_RADIO_TEST - def_dev_ctx_rt = wifi_dev_priv(fmac_dev_ctx); + def_dev_ctx_rt = wifi_dev_priv(fmac_dev_ctx); #elif NRF70_OFFLOADED_RAW_TX - def_dev_ctx_off_raw_tx = wifi_dev_priv(fmac_dev_ctx); + def_dev_ctx_off_raw_tx = wifi_dev_priv(fmac_dev_ctx); #else - def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); #endif - sys_head = (unsigned char *)rpu_msg->msg; - - switch (((struct nrf_wifi_sys_head *)sys_head)->cmd_event) { - case NRF_WIFI_EVENT_STATS: - status = umac_event_stats_process(fmac_dev_ctx, - sys_head); - break; - case NRF_WIFI_EVENT_INIT_DONE: - fmac_dev_ctx->fw_init_done = 1; - status = NRF_WIFI_STATUS_SUCCESS; - break; - case NRF_WIFI_EVENT_DEINIT_DONE: - fmac_dev_ctx->fw_deinit_done = 1; - status = NRF_WIFI_STATUS_SUCCESS; - break; + sys_head = (unsigned char*) rpu_msg->msg; + + switch (((struct nrf_wifi_sys_head*) sys_head)->cmd_event) + { + case NRF_WIFI_EVENT_STATS: + status = umac_event_stats_process(fmac_dev_ctx, sys_head); + break; + case NRF_WIFI_EVENT_INIT_DONE: + fmac_dev_ctx->fw_init_done = 1; + status = NRF_WIFI_STATUS_SUCCESS; + break; + case NRF_WIFI_EVENT_DEINIT_DONE: + fmac_dev_ctx->fw_deinit_done = 1; + status = NRF_WIFI_STATUS_SUCCESS; + break; #ifdef NRF70_RADIO_TEST - case NRF_WIFI_EVENT_RF_TEST: - status = umac_event_rf_test_process(fmac_dev_ctx, - sys_head); - break; - case NRF_WIFI_EVENT_RADIOCMD_STATUS: - umac_status = ((struct nrf_wifi_umac_event_err_status *)sys_head); - def_dev_ctx_rt->radio_cmd_status = umac_status->status; - def_dev_ctx_rt->radio_cmd_done = true; - status = NRF_WIFI_STATUS_SUCCESS; - break; + case NRF_WIFI_EVENT_RF_TEST: + status = umac_event_rf_test_process(fmac_dev_ctx, sys_head); + break; + case NRF_WIFI_EVENT_RADIOCMD_STATUS: + umac_status = ((struct nrf_wifi_umac_event_err_status*) sys_head); + def_dev_ctx_rt->radio_cmd_status = umac_status->status; + def_dev_ctx_rt->radio_cmd_done = true; + status = NRF_WIFI_STATUS_SUCCESS; + break; #endif /* NRF70_RADIO_TEST */ #ifdef NRF70_OFFLOADED_RAW_TX - case NRF_WIFI_EVENT_OFFLOADED_RAWTX_STATUS: - umac_status = ((struct nrf_wifi_umac_event_err_status *)sys_head); - def_dev_ctx_off_raw_tx->off_raw_tx_cmd_status = umac_status->status; - def_dev_ctx_off_raw_tx->off_raw_tx_cmd_done = false; - status = NRF_WIFI_STATUS_SUCCESS; - break; + case NRF_WIFI_EVENT_OFFLOADED_RAWTX_STATUS: + umac_status = ((struct nrf_wifi_umac_event_err_status*) sys_head); + def_dev_ctx_off_raw_tx->off_raw_tx_cmd_status = umac_status->status; + def_dev_ctx_off_raw_tx->off_raw_tx_cmd_done = false; + status = NRF_WIFI_STATUS_SUCCESS; + break; #endif #ifdef NRF70_RAW_DATA_TX - case NRF_WIFI_EVENT_RAW_TX_DONE: - status = nrf_wifi_fmac_rawtx_done_event_process(fmac_dev_ctx, - (struct nrf_wifi_event_raw_tx_done *)sys_head); - break; + case NRF_WIFI_EVENT_RAW_TX_DONE: + status = nrf_wifi_fmac_rawtx_done_event_process( + fmac_dev_ctx, (struct nrf_wifi_event_raw_tx_done*) sys_head); + break; #endif #ifdef NRF70_SYSTEM_WITH_RAW_MODES - case NRF_WIFI_EVENT_MODE_SET_DONE: - status = nrf_wifi_fmac_if_mode_set_event_proc(fmac_dev_ctx, - (struct nrf_wifi_event_raw_config_mode *)sys_head); - break; + case NRF_WIFI_EVENT_MODE_SET_DONE: + status = nrf_wifi_fmac_if_mode_set_event_proc( + fmac_dev_ctx, (struct nrf_wifi_event_raw_config_mode*) sys_head); + break; #endif #if defined(NRF70_RAW_DATA_TX) || defined(NRF70_RAW_DATA_RX) - case NRF_WIFI_EVENT_CHANNEL_SET_DONE: - struct nrf_wifi_event_set_channel *channel_event; - - channel_event = (struct nrf_wifi_event_set_channel *)sys_head; - if (!channel_event->status) { - def_dev_ctx->vif_ctx[channel_event->if_index]->channel = - channel_event->chan_num; - } - status = NRF_WIFI_STATUS_SUCCESS; - break; + case NRF_WIFI_EVENT_CHANNEL_SET_DONE: + struct nrf_wifi_event_set_channel* channel_event; + + channel_event = (struct nrf_wifi_event_set_channel*) sys_head; + if (!channel_event->status) + { + def_dev_ctx->vif_ctx[channel_event->if_index]->channel = channel_event->chan_num; + } + status = NRF_WIFI_STATUS_SUCCESS; + break; #endif /* NRF70_RAW_DATA_TX */ #if defined(NRF70_RAW_DATA_RX) || defined(NRF70_PROMISC_DATA_RX) - case NRF_WIFI_EVENT_FILTER_SET_DONE: - struct nrf_wifi_event_raw_config_filter *filter_event; - - filter_event = (struct nrf_wifi_event_raw_config_filter *)sys_head; - if (!filter_event->status) { - def_dev_ctx->vif_ctx[filter_event->if_index]->packet_filter = - filter_event->filter; - } - status = NRF_WIFI_STATUS_SUCCESS; - break; + case NRF_WIFI_EVENT_FILTER_SET_DONE: + struct nrf_wifi_event_raw_config_filter* filter_event; + + filter_event = (struct nrf_wifi_event_raw_config_filter*) sys_head; + if (!filter_event->status) + { + def_dev_ctx->vif_ctx[filter_event->if_index]->packet_filter = filter_event->filter; + } + status = NRF_WIFI_STATUS_SUCCESS; + break; #endif /* NRF70_RAW_DATA_RX || NRF70_PROMISC_DATA_RX */ - default: - nrf_wifi_osal_log_err("%s: Unknown event recd: %d", - __func__, - ((struct nrf_wifi_sys_head *)sys_head)->cmd_event); - break; - } - return status; + default: + nrf_wifi_osal_log_err("%s: Unknown event recd: %d", __func__, + ((struct nrf_wifi_sys_head*) sys_head)->cmd_event); + break; + } + return status; } - -enum nrf_wifi_status nrf_wifi_fmac_event_callback(void *mac_dev_ctx, - void *rpu_event_data, - unsigned int rpu_event_len) +enum nrf_wifi_status nrf_wifi_fmac_event_callback(void* mac_dev_ctx, void* rpu_event_data, + unsigned int rpu_event_len) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; - struct host_rpu_msg *rpu_msg = NULL; - struct nrf_wifi_umac_hdr *umac_hdr = NULL; - unsigned int umac_msg_len = 0; - int umac_msg_type = NRF_WIFI_UMAC_EVENT_UNSPECIFIED; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx = NULL; + struct host_rpu_msg* rpu_msg = NULL; + struct nrf_wifi_umac_hdr* umac_hdr = NULL; + unsigned int umac_msg_len = 0; + int umac_msg_type = NRF_WIFI_UMAC_EVENT_UNSPECIFIED; - fmac_dev_ctx = (struct nrf_wifi_fmac_dev_ctx *)mac_dev_ctx; + fmac_dev_ctx = (struct nrf_wifi_fmac_dev_ctx*) mac_dev_ctx; - rpu_msg = (struct host_rpu_msg *)rpu_event_data; - umac_hdr = (struct nrf_wifi_umac_hdr *)rpu_msg->msg; - umac_msg_len = rpu_msg->hdr.len; - umac_msg_type = umac_hdr->cmd_evnt; + rpu_msg = (struct host_rpu_msg*) rpu_event_data; + umac_hdr = (struct nrf_wifi_umac_hdr*) rpu_msg->msg; + umac_msg_len = rpu_msg->hdr.len; + umac_msg_type = umac_hdr->cmd_evnt; #ifdef CONFIG_NRF_WIFI_CMD_EVENT_LOG - nrf_wifi_osal_log_info("%s: Event type %d recd\n", - __func__, - rpu_msg->type); + nrf_wifi_osal_log_info("%s: Event type %d recd\n", __func__, rpu_msg->type); #else - nrf_wifi_osal_log_dbg("%s: Event type %d recd", - __func__, - rpu_msg->type); + nrf_wifi_osal_log_dbg("%s: Event type %d recd", __func__, rpu_msg->type); #endif /* CONFIG_NRF_WIFI_CMD_EVENT_LOG */ - switch (rpu_msg->type) { + switch (rpu_msg->type) + { #if !defined(NRF70_RADIO_TEST) && !defined(NRF70_OFFLOADED_RAW_TX) - case NRF_WIFI_HOST_RPU_MSG_TYPE_DATA: - status = nrf_wifi_fmac_data_events_process(fmac_dev_ctx, - rpu_msg); - break; + case NRF_WIFI_HOST_RPU_MSG_TYPE_DATA: + status = nrf_wifi_fmac_data_events_process(fmac_dev_ctx, rpu_msg); + break; #endif /* !NRF70_RADIO_TEST && !NRF70_OFFLOADED_RAW_TX */ - case NRF_WIFI_HOST_RPU_MSG_TYPE_UMAC: - status = umac_event_ctrl_process(fmac_dev_ctx, - rpu_msg->msg, - rpu_msg->hdr.len); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: umac_event_ctrl_process failed", - __func__); - goto out; - } - break; - case NRF_WIFI_HOST_RPU_MSG_TYPE_SYSTEM: - status = umac_process_sys_events(fmac_dev_ctx, - rpu_msg); - break; - default: - goto out; - } + case NRF_WIFI_HOST_RPU_MSG_TYPE_UMAC: + status = umac_event_ctrl_process(fmac_dev_ctx, rpu_msg->msg, rpu_msg->hdr.len); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: umac_event_ctrl_process failed", __func__); + goto out; + } + break; + case NRF_WIFI_HOST_RPU_MSG_TYPE_SYSTEM: + status = umac_process_sys_events(fmac_dev_ctx, rpu_msg); + break; + default: + goto out; + } out: - return status; + return status; } diff --git a/drivers/nrf_wifi/fw_if/umac_if/src/radio_test/fmac_api.c b/drivers/nrf_wifi/fw_if/umac_if/src/radio_test/fmac_api.c index df276423..4528d0c7 100644 --- a/drivers/nrf_wifi/fw_if/umac_if/src/radio_test/fmac_api.c +++ b/drivers/nrf_wifi/fw_if/umac_if/src/radio_test/fmac_api.c @@ -9,754 +9,716 @@ * FMAC IF Layer of the Wi-Fi driver. */ -#include "host_rpu_umac_if.h" #include "fmac_api.h" -#include "hal_api.h" +#include "fmac_bb.h" +#include "fmac_cmd.h" +#include "fmac_event.h" +#include "fmac_peer.h" +#include "fmac_rx.h" #include "fmac_structs.h" -#include "fmac_api.h" +#include "fmac_tx.h" #include "fmac_util.h" -#include "fmac_peer.h" #include "fmac_vif.h" -#include "fmac_tx.h" -#include "fmac_rx.h" -#include "fmac_cmd.h" -#include "fmac_event.h" -#include "fmac_bb.h" +#include "hal_api.h" +#include "host_rpu_umac_if.h" #include "util.h" #define RADIO_CMD_STATUS_TIMEOUT 5000 - -static enum nrf_wifi_status nrf_wifi_fmac_fw_init_rt(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - struct nrf_wifi_phy_rf_params *rf_params, - bool rf_params_valid, +static enum nrf_wifi_status +nrf_wifi_fmac_fw_init_rt(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + struct nrf_wifi_phy_rf_params* rf_params, bool rf_params_valid, #ifdef NRF_WIFI_LOW_POWER - int sleep_type, + int sleep_type, #endif /* NRF_WIFI_LOW_POWER */ - unsigned int phy_calib, - enum op_band op_band, - bool beamforming, - struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl, - struct nrf_wifi_board_params *board_params, - unsigned char *country_code) + unsigned int phy_calib, enum op_band op_band, bool beamforming, + struct nrf_wifi_tx_pwr_ctrl_params* tx_pwr_ctrl, + struct nrf_wifi_board_params* board_params, unsigned char* country_code) { - unsigned long start_time_us = 0; - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - - if (!fmac_dev_ctx) { - nrf_wifi_osal_log_err("%s: Invalid device context", - __func__); - goto out; - } - - status = umac_cmd_init(fmac_dev_ctx, - rf_params, - rf_params_valid, + unsigned long start_time_us = 0; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + + if (!fmac_dev_ctx) + { + nrf_wifi_osal_log_err("%s: Invalid device context", __func__); + goto out; + } + + status = + umac_cmd_init(fmac_dev_ctx, rf_params, rf_params_valid, #ifdef NRF_WIFI_LOW_POWER - sleep_type, + sleep_type, #endif /* NRF_WIFI_LOW_POWER */ - phy_calib, - op_band, - beamforming, - tx_pwr_ctrl, - board_params, - country_code); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: UMAC init failed", - __func__); - goto out; - } - start_time_us = nrf_wifi_osal_time_get_curr_us(); - while (!fmac_dev_ctx->fw_init_done) { - nrf_wifi_osal_sleep_ms(1); + phy_calib, op_band, beamforming, tx_pwr_ctrl, board_params, country_code); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: UMAC init failed", __func__); + goto out; + } + start_time_us = nrf_wifi_osal_time_get_curr_us(); + while (!fmac_dev_ctx->fw_init_done) + { + nrf_wifi_osal_sleep_ms(1); #define MAX_INIT_WAIT (5 * 1000 * 1000) - if (nrf_wifi_osal_time_elapsed_us(start_time_us) >= MAX_INIT_WAIT) { - break; - } - } + if (nrf_wifi_osal_time_elapsed_us(start_time_us) >= MAX_INIT_WAIT) + { + break; + } + } - if (!fmac_dev_ctx->fw_init_done) { - nrf_wifi_osal_log_err("%s: UMAC init timed out", - __func__); - status = NRF_WIFI_STATUS_FAIL; - goto out; - } + if (!fmac_dev_ctx->fw_init_done) + { + nrf_wifi_osal_log_err("%s: UMAC init timed out", __func__); + status = NRF_WIFI_STATUS_FAIL; + goto out; + } - status = NRF_WIFI_STATUS_SUCCESS; + status = NRF_WIFI_STATUS_SUCCESS; out: - return status; + return status; } -static void nrf_wifi_fmac_fw_deinit_rt(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx) -{ -} +static void nrf_wifi_fmac_fw_deinit_rt(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx) {} -void nrf_wifi_fmac_dev_rem_rt(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx) +void nrf_wifi_fmac_dev_rem_rt(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx) { - nrf_wifi_hal_dev_rem(fmac_dev_ctx->hal_dev_ctx); + nrf_wifi_hal_dev_rem(fmac_dev_ctx->hal_dev_ctx); - nrf_wifi_osal_mem_free(fmac_dev_ctx); + nrf_wifi_osal_mem_free(fmac_dev_ctx); } - -enum nrf_wifi_status nrf_wifi_fmac_dev_init_rt(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, +enum nrf_wifi_status +nrf_wifi_fmac_dev_init_rt(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, #ifdef NRF_WIFI_LOW_POWER - int sleep_type, + int sleep_type, #endif /* NRF_WIFI_LOW_POWER */ - unsigned int phy_calib, - enum op_band op_band, - bool beamforming, - struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl_params, - struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params, - struct nrf_wifi_board_params *board_params, - unsigned char *country_code) + unsigned int phy_calib, enum op_band op_band, bool beamforming, + struct nrf_wifi_tx_pwr_ctrl_params* tx_pwr_ctrl_params, + struct nrf_wifi_tx_pwr_ceil_params* tx_pwr_ceil_params, + struct nrf_wifi_board_params* board_params, unsigned char* country_code) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_fmac_otp_info otp_info; - struct nrf_wifi_phy_rf_params phy_rf_params; - - if (!fmac_dev_ctx) { - nrf_wifi_osal_log_err("%s: Invalid device context", - __func__); - goto out; - } - - status = nrf_wifi_hal_dev_init(fmac_dev_ctx->hal_dev_ctx); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: nrf_wifi_hal_dev_init failed", - __func__); - goto out; - } - - fmac_dev_ctx->tx_pwr_ceil_params = nrf_wifi_osal_mem_alloc(sizeof(*tx_pwr_ceil_params)); - nrf_wifi_osal_mem_cpy(fmac_dev_ctx->tx_pwr_ceil_params, - tx_pwr_ceil_params, - sizeof(*tx_pwr_ceil_params)); - - nrf_wifi_osal_mem_set(&otp_info, - 0xFF, - sizeof(otp_info)); - - status = nrf_wifi_hal_otp_info_get(fmac_dev_ctx->hal_dev_ctx, - &otp_info.info, - &otp_info.flags); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: Fetching of RPU OTP information failed", - __func__); - goto out; - } - - status = nrf_wifi_fmac_rf_params_get(fmac_dev_ctx, - &phy_rf_params); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: RF parameters get failed", - __func__); - goto out; - } - - status = nrf_wifi_fmac_fw_init_rt(fmac_dev_ctx, - &phy_rf_params, - true, + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_fmac_otp_info otp_info; + struct nrf_wifi_phy_rf_params phy_rf_params; + + if (!fmac_dev_ctx) + { + nrf_wifi_osal_log_err("%s: Invalid device context", __func__); + goto out; + } + + status = nrf_wifi_hal_dev_init(fmac_dev_ctx->hal_dev_ctx); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: nrf_wifi_hal_dev_init failed", __func__); + goto out; + } + + fmac_dev_ctx->tx_pwr_ceil_params = nrf_wifi_osal_mem_alloc(sizeof(*tx_pwr_ceil_params)); + nrf_wifi_osal_mem_cpy(fmac_dev_ctx->tx_pwr_ceil_params, tx_pwr_ceil_params, + sizeof(*tx_pwr_ceil_params)); + + nrf_wifi_osal_mem_set(&otp_info, 0xFF, sizeof(otp_info)); + + status = nrf_wifi_hal_otp_info_get(fmac_dev_ctx->hal_dev_ctx, &otp_info.info, &otp_info.flags); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: Fetching of RPU OTP information failed", __func__); + goto out; + } + + status = nrf_wifi_fmac_rf_params_get(fmac_dev_ctx, &phy_rf_params); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: RF parameters get failed", __func__); + goto out; + } + + status = nrf_wifi_fmac_fw_init_rt(fmac_dev_ctx, &phy_rf_params, true, #ifdef NRF_WIFI_LOW_POWER - sleep_type, + sleep_type, #endif /* NRF_WIFI_LOW_POWER */ - phy_calib, - op_band, - beamforming, - tx_pwr_ctrl_params, - board_params, - country_code); - - if (status == NRF_WIFI_STATUS_FAIL) { - nrf_wifi_osal_log_err("%s: nrf_wifi_fmac_fw_init failed", - __func__); - goto out; - } + phy_calib, op_band, beamforming, tx_pwr_ctrl_params, + board_params, country_code); + + if (status == NRF_WIFI_STATUS_FAIL) + { + nrf_wifi_osal_log_err("%s: nrf_wifi_fmac_fw_init failed", __func__); + goto out; + } out: - return status; + return status; } -void nrf_wifi_fmac_dev_deinit_rt(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx) +void nrf_wifi_fmac_dev_deinit_rt(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx) { - nrf_wifi_osal_mem_free(fmac_dev_ctx->tx_pwr_ceil_params); - nrf_wifi_fmac_fw_deinit_rt(fmac_dev_ctx); + nrf_wifi_osal_mem_free(fmac_dev_ctx->tx_pwr_ceil_params); + nrf_wifi_fmac_fw_deinit_rt(fmac_dev_ctx); } -struct nrf_wifi_fmac_priv *nrf_wifi_fmac_init_rt(void) +struct nrf_wifi_fmac_priv* nrf_wifi_fmac_init_rt(void) { - struct nrf_wifi_fmac_priv *fpriv = NULL; - struct nrf_wifi_hal_cfg_params hal_cfg_params; - - fpriv = nrf_wifi_osal_mem_zalloc(sizeof(*fpriv)); - - if (!fpriv) { - nrf_wifi_osal_log_err("%s: Unable to allocate fpriv", - __func__); - goto out; - } + struct nrf_wifi_fmac_priv* fpriv = NULL; + struct nrf_wifi_hal_cfg_params hal_cfg_params; + fpriv = nrf_wifi_osal_mem_zalloc(sizeof(*fpriv)); - nrf_wifi_osal_mem_set(&hal_cfg_params, - 0, - sizeof(hal_cfg_params)); + if (!fpriv) + { + nrf_wifi_osal_log_err("%s: Unable to allocate fpriv", __func__); + goto out; + } + nrf_wifi_osal_mem_set(&hal_cfg_params, 0, sizeof(hal_cfg_params)); - hal_cfg_params.max_cmd_size = MAX_NRF_WIFI_UMAC_CMD_SIZE; - hal_cfg_params.max_event_size = MAX_EVENT_POOL_LEN; + hal_cfg_params.max_cmd_size = MAX_NRF_WIFI_UMAC_CMD_SIZE; + hal_cfg_params.max_event_size = MAX_EVENT_POOL_LEN; - fpriv->hpriv = nrf_wifi_hal_init(&hal_cfg_params, - &nrf_wifi_fmac_event_callback, - NULL); + fpriv->hpriv = nrf_wifi_hal_init(&hal_cfg_params, &nrf_wifi_fmac_event_callback, NULL); - if (!fpriv->hpriv) { - nrf_wifi_osal_log_err("%s: Unable to do HAL init", - __func__); - nrf_wifi_osal_mem_free(fpriv); - fpriv = NULL; - goto out; - } + if (!fpriv->hpriv) + { + nrf_wifi_osal_log_err("%s: Unable to do HAL init", __func__); + nrf_wifi_osal_mem_free(fpriv); + fpriv = NULL; + goto out; + } out: - return fpriv; + return fpriv; } - -void nrf_wifi_fmac_deinit_rt(struct nrf_wifi_fmac_priv *fpriv) +void nrf_wifi_fmac_deinit_rt(struct nrf_wifi_fmac_priv* fpriv) { - nrf_wifi_hal_deinit(fpriv->hpriv); + nrf_wifi_hal_deinit(fpriv->hpriv); - nrf_wifi_osal_mem_free(fpriv); + nrf_wifi_osal_mem_free(fpriv); } -enum nrf_wifi_status wait_for_radio_cmd_status(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - unsigned int timeout) +enum nrf_wifi_status wait_for_radio_cmd_status(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + unsigned int timeout) { - unsigned int count = 0; - enum nrf_wifi_cmd_status radio_cmd_status; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; - - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - do { - nrf_wifi_osal_sleep_ms(1); - count++; - } while ((!rt_dev_ctx->radio_cmd_done) && - (count < timeout)); - - if (count == timeout) { - nrf_wifi_osal_log_err("%s: Timed out (%d secs)", - __func__, - timeout / 1000); - goto out; - } - - radio_cmd_status = rt_dev_ctx->radio_cmd_status; - - if (radio_cmd_status != NRF_WIFI_UMAC_CMD_SUCCESS) { - nrf_wifi_osal_log_err("%s: Radio test command failed with status %d", - __func__, - radio_cmd_status); - goto out; - } - return NRF_WIFI_STATUS_SUCCESS; + unsigned int count = 0; + enum nrf_wifi_cmd_status radio_cmd_status; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; + + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + do + { + nrf_wifi_osal_sleep_ms(1); + count++; + } while ((!rt_dev_ctx->radio_cmd_done) && (count < timeout)); + + if (count == timeout) + { + nrf_wifi_osal_log_err("%s: Timed out (%d secs)", __func__, timeout / 1000); + goto out; + } + + radio_cmd_status = rt_dev_ctx->radio_cmd_status; + + if (radio_cmd_status != NRF_WIFI_UMAC_CMD_SUCCESS) + { + nrf_wifi_osal_log_err("%s: Radio test command failed with status %d", __func__, + radio_cmd_status); + goto out; + } + return NRF_WIFI_STATUS_SUCCESS; out: - return NRF_WIFI_STATUS_FAIL; + return NRF_WIFI_STATUS_FAIL; } -enum nrf_wifi_status nrf_wifi_fmac_radio_test_init(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - struct rpu_conf_params *params) +enum nrf_wifi_status nrf_wifi_fmac_radio_test_init(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + struct rpu_conf_params* params) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_radio_test_init_info init_params; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_radio_test_init_info init_params; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - nrf_wifi_osal_mem_set(&init_params, - 0, - sizeof(init_params)); + nrf_wifi_osal_mem_set(&init_params, 0, sizeof(init_params)); - nrf_wifi_osal_mem_cpy(init_params.rf_params, - params->rf_params, - NRF_WIFI_RF_PARAMS_SIZE); + nrf_wifi_osal_mem_cpy(init_params.rf_params, params->rf_params, NRF_WIFI_RF_PARAMS_SIZE); - nrf_wifi_osal_mem_cpy(&init_params.chan, - ¶ms->chan, - sizeof(init_params.chan)); + nrf_wifi_osal_mem_cpy(&init_params.chan, ¶ms->chan, sizeof(init_params.chan)); - init_params.phy_threshold = params->phy_threshold; - init_params.phy_calib = params->phy_calib; + init_params.phy_threshold = params->phy_threshold; + init_params.phy_calib = params->phy_calib; - rt_dev_ctx->radio_cmd_done = false; - status = umac_cmd_prog_init(fmac_dev_ctx, - &init_params); + rt_dev_ctx->radio_cmd_done = false; + status = umac_cmd_prog_init(fmac_dev_ctx, &init_params); - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: Unable to init radio test", - __func__); - goto out; - } + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: Unable to init radio test", __func__); + goto out; + } - status = wait_for_radio_cmd_status(fmac_dev_ctx, - RADIO_CMD_STATUS_TIMEOUT); - if (status != NRF_WIFI_STATUS_SUCCESS) { - goto out; - } + status = wait_for_radio_cmd_status(fmac_dev_ctx, RADIO_CMD_STATUS_TIMEOUT); + if (status != NRF_WIFI_STATUS_SUCCESS) + { + goto out; + } out: - return status; + return status; } - -enum nrf_wifi_status nrf_wifi_fmac_radio_test_prog_tx(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - struct rpu_conf_params *params) +enum nrf_wifi_status nrf_wifi_fmac_radio_test_prog_tx(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + struct rpu_conf_params* params) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; - - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - - rt_dev_ctx->radio_cmd_done = false; - status = umac_cmd_prog_tx(fmac_dev_ctx, - params); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: Unable to program radio test TX", - __func__); - goto out; - } - - status = wait_for_radio_cmd_status(fmac_dev_ctx, - RADIO_CMD_STATUS_TIMEOUT); - if (status != NRF_WIFI_STATUS_SUCCESS) { - goto out; - } + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; + + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + + rt_dev_ctx->radio_cmd_done = false; + status = umac_cmd_prog_tx(fmac_dev_ctx, params); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: Unable to program radio test TX", __func__); + goto out; + } + + status = wait_for_radio_cmd_status(fmac_dev_ctx, RADIO_CMD_STATUS_TIMEOUT); + if (status != NRF_WIFI_STATUS_SUCCESS) + { + goto out; + } out: - return status; + return status; } - -enum nrf_wifi_status nrf_wifi_fmac_radio_test_prog_rx(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - struct rpu_conf_params *params) +enum nrf_wifi_status nrf_wifi_fmac_radio_test_prog_rx(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + struct rpu_conf_params* params) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct rpu_conf_rx_radio_test_params rx_params; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct rpu_conf_rx_radio_test_params rx_params; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - nrf_wifi_osal_mem_set(&rx_params, - 0, - sizeof(rx_params)); + nrf_wifi_osal_mem_set(&rx_params, 0, sizeof(rx_params)); - rx_params.nss = params->nss; + rx_params.nss = params->nss; - nrf_wifi_osal_mem_cpy(rx_params.rf_params, - params->rf_params, - NRF_WIFI_RF_PARAMS_SIZE); + nrf_wifi_osal_mem_cpy(rx_params.rf_params, params->rf_params, NRF_WIFI_RF_PARAMS_SIZE); - nrf_wifi_osal_mem_cpy(&rx_params.chan, - ¶ms->chan, - sizeof(rx_params.chan)); + nrf_wifi_osal_mem_cpy(&rx_params.chan, ¶ms->chan, sizeof(rx_params.chan)); - rx_params.phy_threshold = params->phy_threshold; - rx_params.phy_calib = params->phy_calib; - rx_params.rx = params->rx; + rx_params.phy_threshold = params->phy_threshold; + rx_params.phy_calib = params->phy_calib; + rx_params.rx = params->rx; - rt_dev_ctx->radio_cmd_done = false; - status = umac_cmd_prog_rx(fmac_dev_ctx, - &rx_params); + rt_dev_ctx->radio_cmd_done = false; + status = umac_cmd_prog_rx(fmac_dev_ctx, &rx_params); - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: Unable to program radio test RX", - __func__); - goto out; - } + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: Unable to program radio test RX", __func__); + goto out; + } - status = wait_for_radio_cmd_status(fmac_dev_ctx, - RADIO_CMD_STATUS_TIMEOUT); - if (status != NRF_WIFI_STATUS_SUCCESS) { - goto out; - } + status = wait_for_radio_cmd_status(fmac_dev_ctx, RADIO_CMD_STATUS_TIMEOUT); + if (status != NRF_WIFI_STATUS_SUCCESS) + { + goto out; + } out: - return status; + return status; } - -enum nrf_wifi_status nrf_wifi_fmac_rf_test_rx_cap(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - enum nrf_wifi_rf_test rf_test_type, - void *cap_data, - unsigned short int num_samples, - unsigned short int capture_timeout , - unsigned char lna_gain, - unsigned char bb_gain, - unsigned char *capture_status) +enum nrf_wifi_status nrf_wifi_fmac_rf_test_rx_cap(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + enum nrf_wifi_rf_test rf_test_type, + void* cap_data, unsigned short int num_samples, + unsigned short int capture_timeout, + unsigned char lna_gain, unsigned char bb_gain, + unsigned char* capture_status) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_rf_test_capture_params rf_test_cap_params; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; - unsigned int count = 0; - - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - - nrf_wifi_osal_mem_set(&rf_test_cap_params, - 0, - sizeof(rf_test_cap_params)); - - rf_test_cap_params.test = rf_test_type; - rf_test_cap_params.cap_len = num_samples; - rf_test_cap_params.cap_time = capture_timeout; - rf_test_cap_params.lna_gain = lna_gain; - rf_test_cap_params.bb_gain = bb_gain; - - rt_dev_ctx->rf_test_type = rf_test_type; - rt_dev_ctx->rf_test_cap_data = cap_data; - rt_dev_ctx->rf_test_cap_sz = (num_samples * 3); - rt_dev_ctx->capture_status = 0; - - status = umac_cmd_prog_rf_test(fmac_dev_ctx, - &rf_test_cap_params, - sizeof(rf_test_cap_params)); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_test_cap failed", - __func__); - - goto out; - } - - do { - nrf_wifi_osal_sleep_ms(100); - count++; - } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && - (count < (RX_CAPTURE_TIMEOUT_CONST * capture_timeout))); - - if (count == (RX_CAPTURE_TIMEOUT_CONST * capture_timeout)) { - nrf_wifi_osal_log_err("%s: Timed out", - __func__); - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; - rt_dev_ctx->rf_test_cap_data = NULL; - status = NRF_WIFI_STATUS_FAIL; - goto out; - } - *capture_status = rt_dev_ctx->capture_status; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_rf_test_capture_params rf_test_cap_params; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; + unsigned int count = 0; + + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + + nrf_wifi_osal_mem_set(&rf_test_cap_params, 0, sizeof(rf_test_cap_params)); + + rf_test_cap_params.test = rf_test_type; + rf_test_cap_params.cap_len = num_samples; + rf_test_cap_params.cap_time = capture_timeout; + rf_test_cap_params.lna_gain = lna_gain; + rf_test_cap_params.bb_gain = bb_gain; + + rt_dev_ctx->rf_test_type = rf_test_type; + rt_dev_ctx->rf_test_cap_data = cap_data; + rt_dev_ctx->rf_test_cap_sz = (num_samples * 3); + rt_dev_ctx->capture_status = 0; + + status = umac_cmd_prog_rf_test(fmac_dev_ctx, &rf_test_cap_params, sizeof(rf_test_cap_params)); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_test_cap failed", __func__); + + goto out; + } + + do + { + nrf_wifi_osal_sleep_ms(100); + count++; + } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && + (count < (RX_CAPTURE_TIMEOUT_CONST * capture_timeout))); + + if (count == (RX_CAPTURE_TIMEOUT_CONST * capture_timeout)) + { + nrf_wifi_osal_log_err("%s: Timed out", __func__); + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; + rt_dev_ctx->rf_test_cap_data = NULL; + status = NRF_WIFI_STATUS_FAIL; + goto out; + } + *capture_status = rt_dev_ctx->capture_status; out: - return status; + return status; } - -enum nrf_wifi_status nrf_wifi_fmac_rf_test_tx_tone(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - unsigned char enable, - signed char tone_freq, - signed char tx_power) +enum nrf_wifi_status nrf_wifi_fmac_rf_test_tx_tone(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + unsigned char enable, signed char tone_freq, + signed char tx_power) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_rf_test_tx_params rf_test_tx_params; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; - unsigned int count = 0; - - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - - nrf_wifi_osal_mem_set(&rf_test_tx_params, - 0, - sizeof(rf_test_tx_params)); - - rf_test_tx_params.test = NRF_WIFI_RF_TEST_TX_TONE; - rf_test_tx_params.tone_freq = tone_freq; - rf_test_tx_params.tx_pow = tx_power; - rf_test_tx_params.enabled = enable; - - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_TX_TONE; - rt_dev_ctx->rf_test_cap_data = NULL; - rt_dev_ctx->rf_test_cap_sz = 0; - - status = umac_cmd_prog_rf_test(fmac_dev_ctx, - &rf_test_tx_params, - sizeof(rf_test_tx_params)); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_test_tx_tone failed", - __func__); - - goto out; - } - - do { - nrf_wifi_osal_sleep_ms(100); - count++; - } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && - (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); - - if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) { - nrf_wifi_osal_log_err("%s: Timed out", - __func__); - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; - rt_dev_ctx->rf_test_cap_data = NULL; - status = NRF_WIFI_STATUS_FAIL; - goto out; - } + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_rf_test_tx_params rf_test_tx_params; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; + unsigned int count = 0; -out: - return status; -} + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + nrf_wifi_osal_mem_set(&rf_test_tx_params, 0, sizeof(rf_test_tx_params)); -enum nrf_wifi_status nrf_wifi_fmac_rf_test_dpd(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - unsigned char enable) -{ - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_rf_test_dpd_params rf_test_dpd_params; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; - unsigned int count = 0; - - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - - nrf_wifi_osal_mem_set(&rf_test_dpd_params, - 0, - sizeof(rf_test_dpd_params)); - - rf_test_dpd_params.test = NRF_WIFI_RF_TEST_DPD; - rf_test_dpd_params.enabled = enable; - - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_DPD; - rt_dev_ctx->rf_test_cap_data = NULL; - rt_dev_ctx->rf_test_cap_sz = 0; - - status = umac_cmd_prog_rf_test(fmac_dev_ctx, - &rf_test_dpd_params, - sizeof(rf_test_dpd_params)); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_test_dpd failed", - __func__); - - goto out; - } - - do { - nrf_wifi_osal_sleep_ms(100); - count++; - } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && - (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); - - if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) { - nrf_wifi_osal_log_err("%s: Timed out", - __func__); - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; - rt_dev_ctx->rf_test_cap_data = NULL; - status = NRF_WIFI_STATUS_FAIL; - goto out; - } + rf_test_tx_params.test = NRF_WIFI_RF_TEST_TX_TONE; + rf_test_tx_params.tone_freq = tone_freq; + rf_test_tx_params.tx_pow = tx_power; + rf_test_tx_params.enabled = enable; + + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_TX_TONE; + rt_dev_ctx->rf_test_cap_data = NULL; + rt_dev_ctx->rf_test_cap_sz = 0; + + status = umac_cmd_prog_rf_test(fmac_dev_ctx, &rf_test_tx_params, sizeof(rf_test_tx_params)); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_test_tx_tone failed", __func__); + + goto out; + } + + do + { + nrf_wifi_osal_sleep_ms(100); + count++; + } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && + (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); + + if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) + { + nrf_wifi_osal_log_err("%s: Timed out", __func__); + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; + rt_dev_ctx->rf_test_cap_data = NULL; + status = NRF_WIFI_STATUS_FAIL; + goto out; + } out: - return status; + return status; } - -enum nrf_wifi_status nrf_wifi_fmac_rf_get_temp(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx) +enum nrf_wifi_status nrf_wifi_fmac_rf_test_dpd(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + unsigned char enable) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_temperature_params rf_test_get_temperature; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; - unsigned int count = 0; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_rf_test_dpd_params rf_test_dpd_params; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; + unsigned int count = 0; - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - nrf_wifi_osal_mem_set(&rf_test_get_temperature, - 0, - sizeof(rf_test_get_temperature)); + nrf_wifi_osal_mem_set(&rf_test_dpd_params, 0, sizeof(rf_test_dpd_params)); - rf_test_get_temperature.test = NRF_WIFI_RF_TEST_GET_TEMPERATURE; + rf_test_dpd_params.test = NRF_WIFI_RF_TEST_DPD; + rf_test_dpd_params.enabled = enable; - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_GET_TEMPERATURE; - rt_dev_ctx->rf_test_cap_data = NULL; - rt_dev_ctx->rf_test_cap_sz = 0; + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_DPD; + rt_dev_ctx->rf_test_cap_data = NULL; + rt_dev_ctx->rf_test_cap_sz = 0; - status = umac_cmd_prog_rf_test(fmac_dev_ctx, - &rf_test_get_temperature, - sizeof(rf_test_get_temperature)); + status = umac_cmd_prog_rf_test(fmac_dev_ctx, &rf_test_dpd_params, sizeof(rf_test_dpd_params)); - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_get_temperature failed", - __func__); + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_test_dpd failed", __func__); - goto out; - } + goto out; + } - do { - nrf_wifi_osal_sleep_ms(100); - count++; - } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && - (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); + do + { + nrf_wifi_osal_sleep_ms(100); + count++; + } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && + (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); - if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) { - nrf_wifi_osal_log_err("%s: Timed out", - __func__); - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; - rt_dev_ctx->rf_test_cap_data = NULL; - status = NRF_WIFI_STATUS_FAIL; - goto out; - } + if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) + { + nrf_wifi_osal_log_err("%s: Timed out", __func__); + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; + rt_dev_ctx->rf_test_cap_data = NULL; + status = NRF_WIFI_STATUS_FAIL; + goto out; + } out: - return status; + return status; } -enum nrf_wifi_status nrf_wifi_fmac_rf_get_rf_rssi(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx) +enum nrf_wifi_status nrf_wifi_fmac_rf_get_temp(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_rf_get_rf_rssi rf_get_rf_rssi_params; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; - unsigned int count = 0; - - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - - nrf_wifi_osal_mem_set(&rf_get_rf_rssi_params, - 0, - sizeof(rf_get_rf_rssi_params)); - - rf_get_rf_rssi_params.test = NRF_WIFI_RF_TEST_RF_RSSI; - rf_get_rf_rssi_params.lna_gain = 3; - rf_get_rf_rssi_params.bb_gain = 10; - - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_RF_RSSI; - rt_dev_ctx->rf_test_cap_data = NULL; - rt_dev_ctx->rf_test_cap_sz = 0; - - status = umac_cmd_prog_rf_test(fmac_dev_ctx, - &rf_get_rf_rssi_params, - sizeof(rf_get_rf_rssi_params)); - - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_get_rf_rssi failed", - __func__); - - goto out; - } - - do { - nrf_wifi_osal_sleep_ms(100); - count++; - } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && - (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); - - if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) { - nrf_wifi_osal_log_err("%s: Timed out", - __func__); - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; - rt_dev_ctx->rf_test_cap_data = NULL; - status = NRF_WIFI_STATUS_FAIL; - goto out; - } + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_temperature_params rf_test_get_temperature; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; + unsigned int count = 0; + + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + + nrf_wifi_osal_mem_set(&rf_test_get_temperature, 0, sizeof(rf_test_get_temperature)); + + rf_test_get_temperature.test = NRF_WIFI_RF_TEST_GET_TEMPERATURE; + + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_GET_TEMPERATURE; + rt_dev_ctx->rf_test_cap_data = NULL; + rt_dev_ctx->rf_test_cap_sz = 0; + + status = umac_cmd_prog_rf_test(fmac_dev_ctx, &rf_test_get_temperature, + sizeof(rf_test_get_temperature)); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_get_temperature failed", __func__); + + goto out; + } + + do + { + nrf_wifi_osal_sleep_ms(100); + count++; + } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && + (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); + + if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) + { + nrf_wifi_osal_log_err("%s: Timed out", __func__); + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; + rt_dev_ctx->rf_test_cap_data = NULL; + status = NRF_WIFI_STATUS_FAIL; + goto out; + } out: - return status; + return status; } - -enum nrf_wifi_status nrf_wifi_fmac_set_xo_val(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, - unsigned char value) +enum nrf_wifi_status nrf_wifi_fmac_rf_get_bat_volt(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_rf_test_xo_calib nrf_wifi_rf_test_xo_calib_params; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; - unsigned int count = 0; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_temperature_params rf_test_get_temperature; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; + unsigned int count = 0; + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + nrf_wifi_osal_mem_set(fmac_dev_ctx->fpriv->opriv, &rf_test_get_temperature, 0, + sizeof(rf_test_get_temperature)); + rf_test_get_temperature.test = NRF_WIFI_RF_TEST_GET_BAT_VOLT; + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_GET_BAT_VOLT; + rt_dev_ctx->rf_test_cap_data = NULL; + rt_dev_ctx->rf_test_cap_sz = 0; + status = umac_cmd_prog_rf_test(fmac_dev_ctx, &rf_test_get_temperature, + sizeof(rf_test_get_temperature)); + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv, + "%s: umac_cmd_prog_rf_get_temperature failed", __func__); + goto out; + } + do + { + nrf_wifi_osal_sleep_ms(fmac_dev_ctx->fpriv->opriv, 100); + count++; + } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && + (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); + if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) + { + nrf_wifi_osal_log_err(fmac_dev_ctx->fpriv->opriv, "%s: Timed out", __func__); + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; + rt_dev_ctx->rf_test_cap_data = NULL; + status = NRF_WIFI_STATUS_FAIL; + goto out; + } +out: + return status; +} - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); +enum nrf_wifi_status nrf_wifi_fmac_rf_get_rf_rssi(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_rf_get_rf_rssi rf_get_rf_rssi_params; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; + unsigned int count = 0; - nrf_wifi_osal_mem_set(&nrf_wifi_rf_test_xo_calib_params, - 0, - sizeof(nrf_wifi_rf_test_xo_calib_params)); + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - nrf_wifi_rf_test_xo_calib_params.test = NRF_WIFI_RF_TEST_XO_CALIB; - nrf_wifi_rf_test_xo_calib_params.xo_val = value; + nrf_wifi_osal_mem_set(&rf_get_rf_rssi_params, 0, sizeof(rf_get_rf_rssi_params)); + rf_get_rf_rssi_params.test = NRF_WIFI_RF_TEST_RF_RSSI; + rf_get_rf_rssi_params.lna_gain = 3; + rf_get_rf_rssi_params.bb_gain = 10; - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_XO_CALIB; - rt_dev_ctx->rf_test_cap_data = NULL; - rt_dev_ctx->rf_test_cap_sz = 0; + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_RF_RSSI; + rt_dev_ctx->rf_test_cap_data = NULL; + rt_dev_ctx->rf_test_cap_sz = 0; - status = umac_cmd_prog_rf_test(fmac_dev_ctx, - &nrf_wifi_rf_test_xo_calib_params, - sizeof(nrf_wifi_rf_test_xo_calib_params)); + status = + umac_cmd_prog_rf_test(fmac_dev_ctx, &rf_get_rf_rssi_params, sizeof(rf_get_rf_rssi_params)); - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: umac_cmd_prog_set_xo_val failed", - __func__); + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_get_rf_rssi failed", __func__); - goto out; - } + goto out; + } - do { - nrf_wifi_osal_sleep_ms(100); - count++; - } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && - (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); + do + { + nrf_wifi_osal_sleep_ms(100); + count++; + } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && + (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); - if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) { - nrf_wifi_osal_log_err("%s: Timed out", - __func__); - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; - rt_dev_ctx->rf_test_cap_data = NULL; - status = NRF_WIFI_STATUS_FAIL; - goto out; - } + if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) + { + nrf_wifi_osal_log_err("%s: Timed out", __func__); + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; + rt_dev_ctx->rf_test_cap_data = NULL; + status = NRF_WIFI_STATUS_FAIL; + goto out; + } out: - return status; + return status; } +enum nrf_wifi_status nrf_wifi_fmac_set_xo_val(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx, + unsigned char value) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_rf_test_xo_calib nrf_wifi_rf_test_xo_calib_params; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; + unsigned int count = 0; + + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + + nrf_wifi_osal_mem_set(&nrf_wifi_rf_test_xo_calib_params, 0, + sizeof(nrf_wifi_rf_test_xo_calib_params)); + + nrf_wifi_rf_test_xo_calib_params.test = NRF_WIFI_RF_TEST_XO_CALIB; + nrf_wifi_rf_test_xo_calib_params.xo_val = value; + + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_XO_CALIB; + rt_dev_ctx->rf_test_cap_data = NULL; + rt_dev_ctx->rf_test_cap_sz = 0; + + status = umac_cmd_prog_rf_test(fmac_dev_ctx, &nrf_wifi_rf_test_xo_calib_params, + sizeof(nrf_wifi_rf_test_xo_calib_params)); + + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: umac_cmd_prog_set_xo_val failed", __func__); + + goto out; + } + + do + { + nrf_wifi_osal_sleep_ms(100); + count++; + } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && + (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); + + if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) + { + nrf_wifi_osal_log_err("%s: Timed out", __func__); + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; + rt_dev_ctx->rf_test_cap_data = NULL; + status = NRF_WIFI_STATUS_FAIL; + goto out; + } + +out: + return status; +} -enum nrf_wifi_status nrf_wifi_fmac_rf_test_compute_xo(struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx) +enum nrf_wifi_status nrf_wifi_fmac_rf_test_compute_xo(struct nrf_wifi_fmac_dev_ctx* fmac_dev_ctx) { - enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; - struct nrf_wifi_rf_get_xo_value rf_get_xo_value_params; - struct nrf_wifi_fmac_dev_ctx_rt *rt_dev_ctx = NULL; - unsigned int count = 0; + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + struct nrf_wifi_rf_get_xo_value rf_get_xo_value_params; + struct nrf_wifi_fmac_dev_ctx_rt* rt_dev_ctx = NULL; + unsigned int count = 0; - rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); + rt_dev_ctx = wifi_dev_priv(fmac_dev_ctx); - nrf_wifi_osal_mem_set(&rf_get_xo_value_params, - 0, - sizeof(rf_get_xo_value_params)); + nrf_wifi_osal_mem_set(&rf_get_xo_value_params, 0, sizeof(rf_get_xo_value_params)); - rf_get_xo_value_params.test = NRF_WIFI_RF_TEST_XO_TUNE; + rf_get_xo_value_params.test = NRF_WIFI_RF_TEST_XO_TUNE; - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_XO_TUNE; - rt_dev_ctx->rf_test_cap_data = NULL; - rt_dev_ctx->rf_test_cap_sz = 0; + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_XO_TUNE; + rt_dev_ctx->rf_test_cap_data = NULL; + rt_dev_ctx->rf_test_cap_sz = 0; - status = umac_cmd_prog_rf_test(fmac_dev_ctx, - &rf_get_xo_value_params, - sizeof(rf_get_xo_value_params)); + status = umac_cmd_prog_rf_test(fmac_dev_ctx, &rf_get_xo_value_params, + sizeof(rf_get_xo_value_params)); - if (status != NRF_WIFI_STATUS_SUCCESS) { - nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_get_xo_value failed", - __func__); + if (status != NRF_WIFI_STATUS_SUCCESS) + { + nrf_wifi_osal_log_err("%s: umac_cmd_prog_rf_get_xo_value failed", __func__); - goto out; - } + goto out; + } - do { - nrf_wifi_osal_sleep_ms(100); - count++; - } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && - (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); + do + { + nrf_wifi_osal_sleep_ms(100); + count++; + } while ((rt_dev_ctx->rf_test_type != NRF_WIFI_RF_TEST_MAX) && + (count < NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT)); - if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) { - nrf_wifi_osal_log_err("%s: Timed out", - __func__); - rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; - rt_dev_ctx->rf_test_cap_data = NULL; - status = NRF_WIFI_STATUS_FAIL; - goto out; - } + if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_TIMEOUT) + { + nrf_wifi_osal_log_err("%s: Timed out", __func__); + rt_dev_ctx->rf_test_type = NRF_WIFI_RF_TEST_MAX; + rt_dev_ctx->rf_test_cap_data = NULL; + status = NRF_WIFI_STATUS_FAIL; + goto out; + } out: - return status; + return status; } diff --git a/drivers/nrf_wifi/hw_if/hal/inc/fw/phy_rf_params.h b/drivers/nrf_wifi/hw_if/hal/inc/fw/phy_rf_params.h index d24c9e69..bc608fb7 100644 --- a/drivers/nrf_wifi/hw_if/hal/inc/fw/phy_rf_params.h +++ b/drivers/nrf_wifi/hw_if/hal/inc/fw/phy_rf_params.h @@ -17,20 +17,25 @@ #define NUM_PCB_LOSS_OFFSET 4 #ifdef NRF70_RADIO_TEST -#define NRF_WIFI_DEF_RF_PARAMS "007077003F032424001000002800323500000C0008087D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF080808080408120100000000A1A10178000000080050003B020726181818181A120A140E0600" +#define NRF_WIFI_DEF_RF_PARAMS \ + "007077003F032424001000002800323500000C0008087D8105010071630300EED501001F6F00003B350100F52E00" \ + "00E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF080808080408120100000000A1A1017800" \ + "0000080050003B020726181818181A120A140E0600" #define MAX_TX_PWR_SYS_TEST 30 #define MAX_TX_PWR_RADIO_TEST 24 #else -#define NRF_WIFI_DEF_RF_PARAMS "007077003F032424001000002800323500000CF008087D8105010071630300EED501001F6F00003B350100F52E0000E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF080808080408120100000000A1A10178000000080050003B020726181818181A120A140E0600" +#define NRF_WIFI_DEF_RF_PARAMS \ + "007077003F032424001000002800323500000CF008087D8105010071630300EED501001F6F00003B350100F52E00" \ + "00E35E0000B7B6000066EFFEFFB5F60000896200007A840200E28FFCFF080808080408120100000000A1A1017800" \ + "0000080050003B020726181818181A120A140E0600" #endif - #define NRF_WIFI_PHY_CALIB_FLAG_RXDC 1 #ifdef NRF70_PASSIVE_SCAN_ONLY - /* Disable TX DC Calibration for passive scan alone mode */ - #define NRF_WIFI_PHY_CALIB_FLAG_TXDC 0 +/* Disable TX DC Calibration for passive scan alone mode */ +#define NRF_WIFI_PHY_CALIB_FLAG_TXDC 0 #else - #define NRF_WIFI_PHY_CALIB_FLAG_TXDC 2 +#define NRF_WIFI_PHY_CALIB_FLAG_TXDC 2 #endif #define NRF_WIFI_PHY_CALIB_FLAG_TXPOW 0 #define NRF_WIFI_PHY_CALIB_FLAG_TXIQ 8 @@ -38,41 +43,31 @@ #define NRF_WIFI_PHY_CALIB_FLAG_DPD 32 #define NRF_WIFI_PHY_CALIB_FLAG_ENHANCED_TXDC 64 -#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_RXDC (1<<16) +#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_RXDC (1 << 16) #ifdef NRF70_PASSIVE_SCAN_ONLY - /* Disable TX DC Calibration for passive scan alone mode */ - #define NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXDC (0<<16) +/* Disable TX DC Calibration for passive scan alone mode */ +#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXDC (0 << 16) #else - #define NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXDC (2<<16) +#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXDC (2 << 16) #endif -#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXPOW (0<<16) -#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXIQ (0<<16) -#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_RXIQ (0<<16) -#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_DPD (0<<16) - -#define NRF_WIFI_DEF_PHY_CALIB (NRF_WIFI_PHY_CALIB_FLAG_RXDC |\ - NRF_WIFI_PHY_CALIB_FLAG_TXDC |\ - NRF_WIFI_PHY_CALIB_FLAG_RXIQ |\ - NRF_WIFI_PHY_CALIB_FLAG_TXIQ |\ - NRF_WIFI_PHY_CALIB_FLAG_TXPOW |\ - NRF_WIFI_PHY_CALIB_FLAG_DPD |\ - NRF_WIFI_PHY_CALIB_FLAG_ENHANCED_TXDC |\ - NRF_WIFI_PHY_SCAN_CALIB_FLAG_RXDC |\ - NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXDC |\ - NRF_WIFI_PHY_SCAN_CALIB_FLAG_RXIQ |\ - NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXIQ |\ - NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXPOW |\ - NRF_WIFI_PHY_SCAN_CALIB_FLAG_DPD) +#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXPOW (0 << 16) +#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXIQ (0 << 16) +#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_RXIQ (0 << 16) +#define NRF_WIFI_PHY_SCAN_CALIB_FLAG_DPD (0 << 16) + +#define NRF_WIFI_DEF_PHY_CALIB \ + (NRF_WIFI_PHY_CALIB_FLAG_RXDC | NRF_WIFI_PHY_CALIB_FLAG_TXDC | NRF_WIFI_PHY_CALIB_FLAG_RXIQ | \ + NRF_WIFI_PHY_CALIB_FLAG_TXIQ | NRF_WIFI_PHY_CALIB_FLAG_TXPOW | NRF_WIFI_PHY_CALIB_FLAG_DPD | \ + NRF_WIFI_PHY_CALIB_FLAG_ENHANCED_TXDC | NRF_WIFI_PHY_SCAN_CALIB_FLAG_RXDC | \ + NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXDC | NRF_WIFI_PHY_SCAN_CALIB_FLAG_RXIQ | \ + NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXIQ | NRF_WIFI_PHY_SCAN_CALIB_FLAG_TXPOW | \ + NRF_WIFI_PHY_SCAN_CALIB_FLAG_DPD) /* Temperature based calibration params */ -#define NRF_WIFI_DEF_PHY_TEMP_CALIB (NRF_WIFI_PHY_CALIB_FLAG_RXDC |\ - NRF_WIFI_PHY_CALIB_FLAG_TXDC |\ - NRF_WIFI_PHY_CALIB_FLAG_ENHANCED_TXDC |\ - NRF_WIFI_PHY_CALIB_FLAG_RXIQ |\ - NRF_WIFI_PHY_CALIB_FLAG_TXIQ |\ - NRF_WIFI_PHY_CALIB_FLAG_TXPOW |\ - NRF_WIFI_PHY_CALIB_FLAG_DPD) - +#define NRF_WIFI_DEF_PHY_TEMP_CALIB \ + (NRF_WIFI_PHY_CALIB_FLAG_RXDC | NRF_WIFI_PHY_CALIB_FLAG_TXDC | \ + NRF_WIFI_PHY_CALIB_FLAG_ENHANCED_TXDC | NRF_WIFI_PHY_CALIB_FLAG_RXIQ | \ + NRF_WIFI_PHY_CALIB_FLAG_TXIQ | NRF_WIFI_PHY_CALIB_FLAG_TXPOW | NRF_WIFI_PHY_CALIB_FLAG_DPD) #define NRF_WIFI_TEMP_CALIB_PERIOD (1024 * 1024) /* micro seconds */ #define NRF_WIFI_TEMP_CALIB_THRESHOLD (40) @@ -81,8 +76,10 @@ /* Battery voltage changes base calibrations and voltage thresholds */ #define NRF_WIFI_DEF_PHY_VBAT_CALIB (NRF_WIFI_PHY_CALIB_FLAG_DPD) #define NRF_WIFI_VBAT_VERYLOW (8) /* Corresponds to (2.5+8*0.07)=3.06V */ -#define NRF_WIFI_VBAT_LOW (12) /* Correspond to (2.5+12*0.07)=3.34V */ -#define NRF_WIFI_VBAT_HIGH (14) /* Correspond to (2.5+14*0.07)=3.48V */ +#define NRF_WIFI_VBAT_LOW (12) /* Correspond to (2.5+12*0.07)=3.34V */ +#define NRF_WIFI_VBAT_HIGH (14) /* Correspond to (2.5+14*0.07)=3.48V */ +#define BAT_CONST_1 (2.5) +#define BAT_CONST_2 (0.07) /** Package type information written to the OTP memory */ #define QFN_PACKAGE_INFO 0x5146 @@ -94,10 +91,10 @@ #define PD_ADJUST_VAL 0 #ifdef NRF70_PASSIVE_SCAN_ONLY - /** The byte is repurposed and bit-0 is used to enable TX power optimizations */ - #define CTRL_PWR_OPTIMIZATIONS 1 +/** The byte is repurposed and bit-0 is used to enable TX power optimizations */ +#define CTRL_PWR_OPTIMIZATIONS 1 #else - #define CTRL_PWR_OPTIMIZATIONS 0 +#define CTRL_PWR_OPTIMIZATIONS 0 #endif /** RX gain adjustment value for both 2.4GHz and 5 GHz bands */ #define RX_GAIN_OFFSET_HB_LOW_CHAN 0 @@ -106,17 +103,15 @@ /** End of package independent params */ - /** QFN Package dependent params */ /** XO adjustment value */ #define QFN_XO_VAL 0x2A - /** Systematic error between set power and measured power in dBm */ #define QFN_DSSS_BKF 3 #define QFN_OFDM_BKF 3 -#define QFN_SYSTEM_OFFSET_LB ( ( QFN_DSSS_BKF << 4 ) | QFN_OFDM_BKF ) +#define QFN_SYSTEM_OFFSET_LB ((QFN_DSSS_BKF << 4) | QFN_OFDM_BKF) #define QFN_SYSTEM_OFFSET_HB_CHAN_LOW 3 #define QFN_SYSTEM_OFFSET_HB_CHAN_MID 3 #define QFN_SYSTEM_OFFSET_HB_CHAN_HIGH 3 @@ -167,17 +162,15 @@ #define QFN_LB_VBT_LT_LOW 0x00 #define QFN_HB_VBT_LT_LOW 0xFC - /** CSP Package dependent params */ /** XO adjustment value */ #define CSP_XO_VAL 0x2A - /** Systematic error between set power and measured power in dBm in 2.4G band */ #define CSP_DSSS_BKF 4 #define CSP_OFDM_BKF 5 -#define CSP_SYSTEM_OFFSET_LB ( ( CSP_DSSS_BKF << 4 ) | CSP_OFDM_BKF ) +#define CSP_SYSTEM_OFFSET_LB ((CSP_DSSS_BKF << 4) | CSP_OFDM_BKF) /** Systematic error between set power and measured power in dBm in 5G band */ #define CSP_SYSTEM_OFFSET_HB_CHAN_LOW 5 @@ -230,111 +223,117 @@ #define CSP_LB_VBT_LT_LOW 0x00 #define CSP_HB_VBT_LT_LOW 0xF8 - /** XO adjustment value */ -struct nrf_wifi_xo_freq_offset { - unsigned char xo_freq_offset; +struct nrf_wifi_xo_freq_offset +{ + unsigned char xo_freq_offset; } __NRF_WIFI_PKD; /** Power detector adjustment factor for MCS7 */ -struct nrf_wifi_pd_adst_val { - /** PD adjustment value corresponding to Channel 7 */ - signed char pd_adjt_lb_chan; - /** PD adjustment value corresponding to Channel 36 */ - signed char pd_adjt_hb_low_chan; - /** PD adjustment value corresponding to Channel 100 */ - signed char pd_adjt_hb_mid_chan; - /** PD adjustment value corresponding to Channel 165 */ - signed char pd_adjt_hb_high_chan; +struct nrf_wifi_pd_adst_val +{ + /** PD adjustment value corresponding to Channel 7 */ + signed char pd_adjt_lb_chan; + /** PD adjustment value corresponding to Channel 36 */ + signed char pd_adjt_hb_low_chan; + /** PD adjustment value corresponding to Channel 100 */ + signed char pd_adjt_hb_mid_chan; + /** PD adjustment value corresponding to Channel 165 */ + signed char pd_adjt_hb_high_chan; } __NRF_WIFI_PKD; /** TX power systematic offset is the difference between set power * and the measured power */ -struct nrf_wifi_tx_pwr_systm_offset { - /** Systematic adjustment value corresponding to Channel 7 */ - signed char syst_off_lb_chan; - /** Systematic adjustment value corresponding to Channel 36 */ - signed char syst_off_hb_low_chan; - /** Systematic adjustment value corresponding to Channel 100 */ - signed char syst_off_hb_mid_chan; - /** Systematic adjustment value corresponding to Channel 165 */ - signed char syst_off_hb_high_chan; +struct nrf_wifi_tx_pwr_systm_offset +{ + /** Systematic adjustment value corresponding to Channel 7 */ + signed char syst_off_lb_chan; + /** Systematic adjustment value corresponding to Channel 36 */ + signed char syst_off_hb_low_chan; + /** Systematic adjustment value corresponding to Channel 100 */ + signed char syst_off_hb_mid_chan; + /** Systematic adjustment value corresponding to Channel 165 */ + signed char syst_off_hb_high_chan; } __NRF_WIFI_PKD; /** Max TX power value for which both EVM and SEM pass */ -struct nrf_wifi_tx_pwr_ceil { - /** Max output power for 11b for channel 7 */ - signed char max_dsss_pwr; - /** Max output power for MCS7 for channel 7 */ - signed char max_lb_mcs7_pwr; - /** Max output power for MCS0 for channel 7 */ - signed char max_lb_mcs0_pwr; - /** Max output power for MCS7 for channel 36 */ - signed char max_hb_low_chan_mcs7_pwr; - /** Max output power for MCS7 for channel 100 */ - signed char max_hb_mid_chan_mcs7_pwr; - /** Max output power for MCS7 for channel 165 */ - signed char max_hb_high_chan_mcs7_pwr; - /** Max output power for MCS0 for channel 36 */ - signed char max_hb_low_chan_mcs0_pwr; - /** Max output power for MCS0 for channel 100 */ - signed char max_hb_mid_chan_mcs0_pwr; - /** Max output power for MCS0 for channel 165 */ - signed char max_hb_high_chan_mcs0_pwr; +struct nrf_wifi_tx_pwr_ceil +{ + /** Max output power for 11b for channel 7 */ + signed char max_dsss_pwr; + /** Max output power for MCS7 for channel 7 */ + signed char max_lb_mcs7_pwr; + /** Max output power for MCS0 for channel 7 */ + signed char max_lb_mcs0_pwr; + /** Max output power for MCS7 for channel 36 */ + signed char max_hb_low_chan_mcs7_pwr; + /** Max output power for MCS7 for channel 100 */ + signed char max_hb_mid_chan_mcs7_pwr; + /** Max output power for MCS7 for channel 165 */ + signed char max_hb_high_chan_mcs7_pwr; + /** Max output power for MCS0 for channel 36 */ + signed char max_hb_low_chan_mcs0_pwr; + /** Max output power for MCS0 for channel 100 */ + signed char max_hb_mid_chan_mcs0_pwr; + /** Max output power for MCS0 for channel 165 */ + signed char max_hb_high_chan_mcs0_pwr; } __NRF_WIFI_PKD; /** RX gain adjustment offsets */ -struct nrf_wifi_rx_gain_offset { - /** Channel 7 */ - signed char rx_gain_lb_chan; - /** Channel 36 */ - signed char rx_gain_hb_low_chan; - /** Channel 100 */ - signed char rx_gain_hb_mid_chan; - /** Channel 165 */ - signed char rx_gain_hb_high_chan; +struct nrf_wifi_rx_gain_offset +{ + /** Channel 7 */ + signed char rx_gain_lb_chan; + /** Channel 36 */ + signed char rx_gain_hb_low_chan; + /** Channel 100 */ + signed char rx_gain_hb_mid_chan; + /** Channel 165 */ + signed char rx_gain_hb_high_chan; } __NRF_WIFI_PKD; /** Voltage and temperature dependent backoffs */ -struct nrf_wifi_temp_volt_depend_params { - /** Maximum chip temperature in centigrade */ - signed char max_chip_temp; - /** Minimum chip temperature in centigrade */ - signed char min_chip_temp; - /** TX power backoff at high temperature in 2.4GHz */ - signed char lb_max_pwr_bkf_hi_temp; - /** TX power backoff at low temperature in 2.4GHz */ - signed char lb_max_pwr_bkf_low_temp; - /** TX power backoff at high temperature in 5GHz */ - signed char hb_max_pwr_bkf_hi_temp; - /** TX power backoff at low temperature in 5GHz */ - signed char hb_max_pwr_bkf_low_temp; - /** Voltage back off value in LowBand when VBAT< VBAT_VERYLOW */ - signed char lb_vbt_lt_vlow; - /** Voltage back off value in HighBand when VBAT< VBAT_VERYLOW */ - signed char hb_vbt_lt_vlow; - /** Voltage back off value in LowBand when VBAT< VBAT_LOW */ - signed char lb_vbt_lt_low; - /** Voltage back off value in HighBand when VBAT< VBAT_LOW */ - signed char hb_vbt_lt_low; - /** Reserved bytes */ - signed char reserved[4]; +struct nrf_wifi_temp_volt_depend_params +{ + /** Maximum chip temperature in centigrade */ + signed char max_chip_temp; + /** Minimum chip temperature in centigrade */ + signed char min_chip_temp; + /** TX power backoff at high temperature in 2.4GHz */ + signed char lb_max_pwr_bkf_hi_temp; + /** TX power backoff at low temperature in 2.4GHz */ + signed char lb_max_pwr_bkf_low_temp; + /** TX power backoff at high temperature in 5GHz */ + signed char hb_max_pwr_bkf_hi_temp; + /** TX power backoff at low temperature in 5GHz */ + signed char hb_max_pwr_bkf_low_temp; + /** Voltage back off value in LowBand when VBAT< VBAT_VERYLOW */ + signed char lb_vbt_lt_vlow; + /** Voltage back off value in HighBand when VBAT< VBAT_VERYLOW */ + signed char hb_vbt_lt_vlow; + /** Voltage back off value in LowBand when VBAT< VBAT_LOW */ + signed char lb_vbt_lt_low; + /** Voltage back off value in HighBand when VBAT< VBAT_LOW */ + signed char hb_vbt_lt_low; + /** Reserved bytes */ + signed char reserved[4]; } __NRF_WIFI_PKD; /** The top-level structure holds substructures, * each containing information related to the * first 42 bytes of RF parameters. */ -struct nrf_wifi_phy_rf_params { - unsigned char reserved[6]; - struct nrf_wifi_xo_freq_offset xo_offset; - struct nrf_wifi_pd_adst_val pd_adjust_val; - struct nrf_wifi_tx_pwr_systm_offset syst_tx_pwr_offset; - struct nrf_wifi_tx_pwr_ceil max_pwr_ceil; - struct nrf_wifi_rx_gain_offset rx_gain_offset; - struct nrf_wifi_temp_volt_depend_params temp_volt_backoff; - unsigned char phy_params[NRF_WIFI_RF_PARAMS_SIZE - NRF_WIFI_RF_PARAMS_CONF_SIZE]; +struct nrf_wifi_phy_rf_params +{ + unsigned char reserved[6]; + struct nrf_wifi_xo_freq_offset xo_offset; + struct nrf_wifi_pd_adst_val pd_adjust_val; + struct nrf_wifi_tx_pwr_systm_offset syst_tx_pwr_offset; + struct nrf_wifi_tx_pwr_ceil max_pwr_ceil; + struct nrf_wifi_rx_gain_offset rx_gain_offset; + struct nrf_wifi_temp_volt_depend_params temp_volt_backoff; + unsigned char phy_params[NRF_WIFI_RF_PARAMS_SIZE - NRF_WIFI_RF_PARAMS_CONF_SIZE]; } __NRF_WIFI_PKD; /** The byte offsets of RF parameters indicate the start offset @@ -342,13 +341,14 @@ struct nrf_wifi_phy_rf_params { * parameters, power ceiling parameters, RX gain adjustment parameters, * and temperature and voltage-based power backoff values. */ -enum RF_PARAMS_OFFSETS { - NRF_WIFI_XO_FREQ_BYTE_OFFSET = 6, - NRF_WIFI_PD_ADST_VAL_BYTE_OFFSET = 7, - NRF_WIFI_TX_PWR_SYSTM_BYTE_OFFSET = 11, - NRF_WIFI_TX_PWR_CEIL_BYTE_OFFSET = 15, - NRF_WIFI_RX_GAIN_BYTE_OFFSET = 24, - NRF_WIFI_VT_DEPEND_PARAMS_BYTE_OFFSET = 28 +enum RF_PARAMS_OFFSETS +{ + NRF_WIFI_XO_FREQ_BYTE_OFFSET = 6, + NRF_WIFI_PD_ADST_VAL_BYTE_OFFSET = 7, + NRF_WIFI_TX_PWR_SYSTM_BYTE_OFFSET = 11, + NRF_WIFI_TX_PWR_CEIL_BYTE_OFFSET = 15, + NRF_WIFI_RX_GAIN_BYTE_OFFSET = 24, + NRF_WIFI_VT_DEPEND_PARAMS_BYTE_OFFSET = 28 }; /** RF Params from byte starting with offset @@ -359,71 +359,75 @@ enum RF_PARAMS_OFFSETS { * channel frequency, we have divided them in to * LOW BAND, MID BAND and HIGH BAND */ -enum MAX_POWER_OFFSETS { - NRF_WIFI_MAX_OP_PWR_DSSS_OFST, - NRF_WIFI_MAX_OP_PWR_2PT4GHZ_OFDM_MCS7, - NRF_WIFI_MAX_OP_PWR_2PT4GHZ_OFDM_MCS0, - NRF_WIFI_MAX_OP_PWR_5GHZ_LB_MCS7, - NRF_WIFI_MAX_OP_PWR_5GHZ_MID_MCS7, - NRF_WIFI_MAX_OP_PWR_5GHZ_HI_MCS7, - NRF_WIFI_MAX_OP_PWR_5GHZ_LB_MCS0, - NRF_WIFI_MAX_OP_PWR_5GHZ_MID_MCS0, - NRF_WIFI_MAX_OP_PWR_5GHZ_HI_MCS0 +enum MAX_POWER_OFFSETS +{ + NRF_WIFI_MAX_OP_PWR_DSSS_OFST, + NRF_WIFI_MAX_OP_PWR_2PT4GHZ_OFDM_MCS7, + NRF_WIFI_MAX_OP_PWR_2PT4GHZ_OFDM_MCS0, + NRF_WIFI_MAX_OP_PWR_5GHZ_LB_MCS7, + NRF_WIFI_MAX_OP_PWR_5GHZ_MID_MCS7, + NRF_WIFI_MAX_OP_PWR_5GHZ_HI_MCS7, + NRF_WIFI_MAX_OP_PWR_5GHZ_LB_MCS0, + NRF_WIFI_MAX_OP_PWR_5GHZ_MID_MCS0, + NRF_WIFI_MAX_OP_PWR_5GHZ_HI_MCS0 }; /** The byte offsets of RF parameters indicate the start offset * of PCB loss for 2.4 GHz and 5 GHz bands. */ -enum PCB_LOSS_BYTE_OFFSETS { - PCB_LOSS_BYTE_2G_OFST = 185, - PCB_LOSS_BYTE_5G_BAND1_OFST, - PCB_LOSS_BYTE_5G_BAND2_OFST, - PCB_LOSS_BYTE_5G_BAND3_OFST +enum PCB_LOSS_BYTE_OFFSETS +{ + PCB_LOSS_BYTE_2G_OFST = 185, + PCB_LOSS_BYTE_5G_BAND1_OFST, + PCB_LOSS_BYTE_5G_BAND2_OFST, + PCB_LOSS_BYTE_5G_BAND3_OFST }; /** The byte offsets of RF parameters indicate the start offset * of antenna gain for 2.4 GHz and 5 GHz bands. */ -enum ANT_GAIN_OFFSETS { - ANT_GAIN_2G_OFST = 181, - ANT_GAIN_5G_BAND1_OFST, - ANT_GAIN_5G_BAND2_OFST, - ANT_GAIN_5G_BAND3_OFST, - NUM_ANT_GAIN = 4 +enum ANT_GAIN_OFFSETS +{ + ANT_GAIN_2G_OFST = 181, + ANT_GAIN_5G_BAND1_OFST, + ANT_GAIN_5G_BAND2_OFST, + ANT_GAIN_5G_BAND3_OFST, + NUM_ANT_GAIN = 4 }; /** The byte offsets of RF parameters indicate the start offset * of band edge backoffs for different frame formats and * different sub-bands of 2.4 GHz and 5 GHz frequency band. */ -enum EDGE_BACKOFF_OFFSETS { - BAND_2G_LW_ED_BKF_DSSS_OFST = 155, - BAND_2G_LW_ED_BKF_HT_OFST, - BAND_2G_LW_ED_BKF_HE_OFST, - BAND_2G_UW_ED_BKF_DSSS_OFST, - BAND_2G_UW_ED_BKF_HT_OFST, - BAND_2G_UW_ED_BKF_HE_OFST, - BAND_UNII_1_LW_ED_BKF_HT_OFST, - BAND_UNII_1_LW_ED_BKF_HE_OFST, - BAND_UNII_1_UW_ED_BKF_HT_OFST, - BAND_UNII_1_UW_ED_BKF_HE_OFST, - BAND_UNII_2A_LW_ED_BKF_HT_OFST, - BAND_UNII_2A_LW_ED_BKF_HE_OFST, - BAND_UNII_2A_UW_ED_BKF_HT_OFST, - BAND_UNII_2A_UW_ED_BKF_HE_OFST, - BAND_UNII_2C_LW_ED_BKF_HT_OFST, - BAND_UNII_2C_LW_ED_BKF_HE_OFST, - BAND_UNII_2C_UW_ED_BKF_HT_OFST, - BAND_UNII_2C_UW_ED_BKF_HE_OFST, - BAND_UNII_3_LW_ED_BKF_HT_OFST, - BAND_UNII_3_LW_ED_BKF_HE_OFST, - BAND_UNII_3_UW_ED_BKF_HT_OFST, - BAND_UNII_3_UW_ED_BKF_HE_OFST, - BAND_UNII_4_LW_ED_BKF_HT_OFST, - BAND_UNII_4_LW_ED_BKF_HE_OFST, - BAND_UNII_4_UW_ED_BKF_HT_OFST, - BAND_UNII_4_UW_ED_BKF_HE_OFST, - NUM_EDGE_BACKOFF = 26 +enum EDGE_BACKOFF_OFFSETS +{ + BAND_2G_LW_ED_BKF_DSSS_OFST = 155, + BAND_2G_LW_ED_BKF_HT_OFST, + BAND_2G_LW_ED_BKF_HE_OFST, + BAND_2G_UW_ED_BKF_DSSS_OFST, + BAND_2G_UW_ED_BKF_HT_OFST, + BAND_2G_UW_ED_BKF_HE_OFST, + BAND_UNII_1_LW_ED_BKF_HT_OFST, + BAND_UNII_1_LW_ED_BKF_HE_OFST, + BAND_UNII_1_UW_ED_BKF_HT_OFST, + BAND_UNII_1_UW_ED_BKF_HE_OFST, + BAND_UNII_2A_LW_ED_BKF_HT_OFST, + BAND_UNII_2A_LW_ED_BKF_HE_OFST, + BAND_UNII_2A_UW_ED_BKF_HT_OFST, + BAND_UNII_2A_UW_ED_BKF_HE_OFST, + BAND_UNII_2C_LW_ED_BKF_HT_OFST, + BAND_UNII_2C_LW_ED_BKF_HE_OFST, + BAND_UNII_2C_UW_ED_BKF_HT_OFST, + BAND_UNII_2C_UW_ED_BKF_HE_OFST, + BAND_UNII_3_LW_ED_BKF_HT_OFST, + BAND_UNII_3_LW_ED_BKF_HE_OFST, + BAND_UNII_3_UW_ED_BKF_HT_OFST, + BAND_UNII_3_UW_ED_BKF_HE_OFST, + BAND_UNII_4_LW_ED_BKF_HT_OFST, + BAND_UNII_4_LW_ED_BKF_HE_OFST, + BAND_UNII_4_UW_ED_BKF_HT_OFST, + BAND_UNII_4_UW_ED_BKF_HE_OFST, + NUM_EDGE_BACKOFF = 26 }; #ifdef NRF70_RADIO_TEST @@ -433,137 +437,163 @@ enum EDGE_BACKOFF_OFFSETS { #define RX_CAPTURE_TIMEOUT_CONST 11 #define CAPTURE_DURATION_IN_SEC 600 -enum nrf_wifi_rf_test { - NRF_WIFI_RF_TEST_RX_ADC_CAP, - NRF_WIFI_RF_TEST_RX_STAT_PKT_CAP, - NRF_WIFI_RF_TEST_RX_DYN_PKT_CAP, - NRF_WIFI_RF_TEST_TX_TONE, - NRF_WIFI_RF_TEST_DPD, - NRF_WIFI_RF_TEST_RF_RSSI, - NRF_WIFI_RF_TEST_SLEEP, - NRF_WIFI_RF_TEST_GET_TEMPERATURE, - NRF_WIFI_RF_TEST_XO_CALIB, - NRF_WIFI_RF_TEST_XO_TUNE, - NRF_WIFI_RF_TEST_MAX, +enum nrf_wifi_rf_test +{ + NRF_WIFI_RF_TEST_RX_ADC_CAP, + NRF_WIFI_RF_TEST_RX_STAT_PKT_CAP, + NRF_WIFI_RF_TEST_RX_DYN_PKT_CAP, + NRF_WIFI_RF_TEST_TX_TONE, + NRF_WIFI_RF_TEST_DPD, + NRF_WIFI_RF_TEST_RF_RSSI, + NRF_WIFI_RF_TEST_SLEEP, + NRF_WIFI_RF_TEST_GET_TEMPERATURE, + NRF_WIFI_RF_TEST_XO_CALIB, + NRF_WIFI_RF_TEST_XO_TUNE, + NRF_WIFI_RF_TEST_GET_BAT_VOLT, + NRF_WIFI_RF_TEST_MAX, }; -enum nrf_wifi_rf_test_event { - NRF_WIFI_RF_TEST_EVENT_RX_ADC_CAP, - NRF_WIFI_RF_TEST_EVENT_RX_STAT_PKT_CAP, - NRF_WIFI_RF_TEST_EVENT_RX_DYN_PKT_CAP, - NRF_WIFI_RF_TEST_EVENT_TX_TONE_START, - NRF_WIFI_RF_TEST_EVENT_DPD_ENABLE, - NRF_WIFI_RF_TEST_EVENT_RF_RSSI, - NRF_WIFI_RF_TEST_EVENT_SLEEP, - NRF_WIFI_RF_TEST_EVENT_TEMP_MEAS, - NRF_WIFI_RF_TEST_EVENT_XO_CALIB, - NRF_WIFI_RF_TEST_EVENT_MAX, +enum nrf_wifi_rf_test_event +{ + NRF_WIFI_RF_TEST_EVENT_RX_ADC_CAP, + NRF_WIFI_RF_TEST_EVENT_RX_STAT_PKT_CAP, + NRF_WIFI_RF_TEST_EVENT_RX_DYN_PKT_CAP, + NRF_WIFI_RF_TEST_EVENT_TX_TONE_START, + NRF_WIFI_RF_TEST_EVENT_DPD_ENABLE, + NRF_WIFI_RF_TEST_EVENT_RF_RSSI, + NRF_WIFI_RF_TEST_EVENT_SLEEP, + NRF_WIFI_RF_TEST_EVENT_TEMP_MEAS, + NRF_WIFI_RF_TEST_EVENT_XO_CALIB, + NRF_WIFI_RF_TEST_EVENT_XO_TUNE, + NRF_WIFI_RF_TEST_EVENT_GET_BAT_VOLT, + NRF_WIFI_RF_TEST_EVENT_MAX, }; /* Holds the RX capture related info */ -struct nrf_wifi_rf_test_capture_params { - unsigned char test; - - /* Number of samples to be captured. */ - unsigned short int cap_len; - - /* Capture timeout in seconds. */ - unsigned short int cap_time; - - /* Capture status codes: - *0: Capture successful after WLAN packet detection - *1: Capture failed after WLAN packet detection - *2: Capture timedout as no WLAN packets are detected - */ - unsigned char capture_status; - - /* LNA Gain to be configured. It is a 3 bit value. The mapping is, - * '0' = 24dB - * '1' = 18dB - * '2' = 12dB - * '3' = 0dB - * '4' = -12dB - */ - unsigned char lna_gain; - - /* Baseband Gain to be configured. It is a 5 bit value. - * It supports 64dB range.The increment happens lineraly 2dB/step - */ - unsigned char bb_gain; +struct nrf_wifi_rf_test_capture_params +{ + unsigned char test; + + /* Number of samples to be captured. */ + unsigned short int cap_len; + + /* Capture timeout in seconds. */ + unsigned short int cap_time; + + /* Capture status codes: + *0: Capture successful after WLAN packet detection + *1: Capture failed after WLAN packet detection + *2: Capture timedout as no WLAN packets are detected + */ + unsigned char capture_status; + + /* LNA Gain to be configured. It is a 3 bit value. The mapping is, + * '0' = 24dB + * '1' = 18dB + * '2' = 12dB + * '3' = 0dB + * '4' = -12dB + */ + unsigned char lna_gain; + + /* Baseband Gain to be configured. It is a 5 bit value. + * It supports 64dB range.The increment happens lineraly 2dB/step + */ + unsigned char bb_gain; } __NRF_WIFI_PKD; /* Struct to hold the events from RF test SW. */ -struct nrf_wifi_rf_test_capture_meas { - unsigned char test; +struct nrf_wifi_rf_test_capture_meas +{ + unsigned char test; - /* Mean of I samples. Format: Q.11 */ - signed short mean_I; + /* Mean of I samples. Format: Q.11 */ + signed short mean_I; - /* Mean of Q samples. Format: Q.11 */ - signed short mean_Q; + /* Mean of Q samples. Format: Q.11 */ + signed short mean_Q; - /* RMS of I samples */ - unsigned int rms_I; + /* RMS of I samples */ + unsigned int rms_I; - /* RMS of Q samples */ - unsigned int rms_Q; + /* RMS of Q samples */ + unsigned int rms_Q; } __NRF_WIFI_PKD; /* Holds the transmit related info */ -struct nrf_wifi_rf_test_tx_params { - unsigned char test; +struct nrf_wifi_rf_test_tx_params +{ + unsigned char test; - /* Desired tone frequency in MHz in steps of 1 MHz from -10 MHz to +10 MHz. */ - signed char tone_freq; + /* Desired tone frequency in MHz in steps of 1 MHz from -10 MHz to +10 MHz. */ + signed char tone_freq; - /* Desired TX power in the range -16 dBm to +24 dBm. - * in steps of 2 dBm - */ - signed char tx_pow; + /* Desired TX power in the range -16 dBm to +24 dBm. + * in steps of 2 dBm + */ + signed char tx_pow; - /* Set 1 for staring tone transmission. */ - unsigned char enabled; + /* Set 1 for staring tone transmission. */ + unsigned char enabled; } __NRF_WIFI_PKD; -struct nrf_wifi_rf_test_dpd_params { - unsigned char test; - unsigned char enabled; +struct nrf_wifi_rf_test_dpd_params +{ + unsigned char test; + unsigned char enabled; } __NRF_WIFI_PKD; -struct nrf_wifi_temperature_params { - unsigned char test; +struct nrf_wifi_temperature_params +{ + unsigned char test; - /** Current measured temperature */ - signed int temperature; + /** Current measured temperature */ + signed int temperature; + + /** Temperature measurment status. + * 0: Reading successful + * 1: Reading failed + */ + unsigned int readTemperatureStatus; +} __NRF_WIFI_PKD; - /** Temperature measurment status. - * 0: Reading successful - * 1: Reading failed - */ - unsigned int readTemperatureStatus; +/* Structure to hold battery voltage parameters */ +struct nrf_wifi_bat_volt_params +{ + unsigned char test; + /** Measured battery voltage in volts. */ + unsigned char voltage; + /** Status of the voltage measurement command. + * 0: Reading successful + * 1: Reading failed + */ + unsigned int cmd_status; } __NRF_WIFI_PKD; -struct nrf_wifi_rf_get_rf_rssi { - unsigned char test; - unsigned char lna_gain; - unsigned char bb_gain; - unsigned char agc_status_val; +struct nrf_wifi_rf_get_rf_rssi +{ + unsigned char test; + unsigned char lna_gain; + unsigned char bb_gain; + unsigned char agc_status_val; } __NRF_WIFI_PKD; -struct nrf_wifi_rf_test_xo_calib { - unsigned char test; +struct nrf_wifi_rf_test_xo_calib +{ + unsigned char test; - /* XO value in the range between 0 to 127 */ - unsigned char xo_val; + /* XO value in the range between 0 to 127 */ + unsigned char xo_val; } __NRF_WIFI_PKD; -struct nrf_wifi_rf_get_xo_value { - unsigned char test; +struct nrf_wifi_rf_get_xo_value +{ + unsigned char test; - /* Optimal XO value computed. */ - unsigned char xo_value; + /* Optimal XO value computed. */ + unsigned char xo_value; } __NRF_WIFI_PKD; #endif /* NRF70_RADIO_TEST */ @@ -573,53 +603,55 @@ struct nrf_wifi_rf_get_xo_value { * in both frequency bands for different data rates. */ -struct nrf_wifi_tx_pwr_ceil_params { - /** Maximum power permitted while transmitting DSSS rates in 2.4G band. - * Resolution is 0.25dBm. - */ - unsigned char max_pwr_2g_dsss; - /** Maximum power permitted while transmitting MCS0 rate in 2.4G band. - * Resolution is 0.25dBm. - */ - unsigned char max_pwr_2g_mcs0; - /** Maximum power permitted while transmitting MCS7 rate in 2.4G band. - * Resolution is 0.25dBm. - */ - unsigned char max_pwr_2g_mcs7; +struct nrf_wifi_tx_pwr_ceil_params +{ + /** Maximum power permitted while transmitting DSSS rates in 2.4G band. + * Resolution is 0.25dBm. + */ + unsigned char max_pwr_2g_dsss; + /** Maximum power permitted while transmitting MCS0 rate in 2.4G band. + * Resolution is 0.25dBm. + */ + unsigned char max_pwr_2g_mcs0; + /** Maximum power permitted while transmitting MCS7 rate in 2.4G band. + * Resolution is 0.25dBm. + */ + unsigned char max_pwr_2g_mcs7; #ifndef NRF70_2_4G_ONLY - /** Maximum power permitted while transmitting MCS0 rate in 5G lowband. - * Low band corresponds to ch: 36 to 64 Resolution is 0.25dBm. - */ - unsigned char max_pwr_5g_low_mcs0; - /** Maximum power permitted while transmitting MCS7 rate in 5G lowband. - * Low band corresponds to ch: 36 to 64, resolution is 0.25dBm. - */ - unsigned char max_pwr_5g_low_mcs7; - /** Maximum power permitted while transmitting MCS0 rate in 5G midband. - * Mid band corresponds to ch: 96 to 132, resolution is 0.25dBm. - */ - unsigned char max_pwr_5g_mid_mcs0; - /** Maximum power permitted while transmitting MCS7 rate in 5G midband. - * Mid band corresponds to ch: 96 to 132, resolution is 0.25dBm. - */ - unsigned char max_pwr_5g_mid_mcs7; - /** Maximum power permitted while transmitting MCS0 rate in 5G highband. - * High band corresponds to ch: 136 to 177, resolution is 0.25dBm. - */ - unsigned char max_pwr_5g_high_mcs0; - /** Maximum power permitted while transmitting MCS7 rate in 5G highband. - * High band corresponds to ch: 136 to 177, resolution is 0.25dBm. - */ - unsigned char max_pwr_5g_high_mcs7; + /** Maximum power permitted while transmitting MCS0 rate in 5G lowband. + * Low band corresponds to ch: 36 to 64 Resolution is 0.25dBm. + */ + unsigned char max_pwr_5g_low_mcs0; + /** Maximum power permitted while transmitting MCS7 rate in 5G lowband. + * Low band corresponds to ch: 36 to 64, resolution is 0.25dBm. + */ + unsigned char max_pwr_5g_low_mcs7; + /** Maximum power permitted while transmitting MCS0 rate in 5G midband. + * Mid band corresponds to ch: 96 to 132, resolution is 0.25dBm. + */ + unsigned char max_pwr_5g_mid_mcs0; + /** Maximum power permitted while transmitting MCS7 rate in 5G midband. + * Mid band corresponds to ch: 96 to 132, resolution is 0.25dBm. + */ + unsigned char max_pwr_5g_mid_mcs7; + /** Maximum power permitted while transmitting MCS0 rate in 5G highband. + * High band corresponds to ch: 136 to 177, resolution is 0.25dBm. + */ + unsigned char max_pwr_5g_high_mcs0; + /** Maximum power permitted while transmitting MCS7 rate in 5G highband. + * High band corresponds to ch: 136 to 177, resolution is 0.25dBm. + */ + unsigned char max_pwr_5g_high_mcs7; #endif /* NRF70_2_4G_ONLY */ } __NRF_WIFI_PKD; /* FT Prog version info */ -enum ft_prog_ver { - FT_PROG_VER1 = 1, - FT_PROG_VER2 = 2, - FT_PROG_VER3 = 3 +enum ft_prog_ver +{ + FT_PROG_VER1 = 1, + FT_PROG_VER2 = 2, + FT_PROG_VER3 = 3 }; /* FT Prog version dependent back off values