Skip to content

Commit

Permalink
samples: wifi: radio_test: Add timeout feature for capture mode
Browse files Browse the repository at this point in the history
[SHEL-2811]: Added command to get user-specified timeout
in seconds.Rx samples will be displayed only when the
capture occurs before the timeout lapses.

Signed-off-by: Mahammadyunus Patil <[email protected]>
  • Loading branch information
imapa authored and prsi98 committed Aug 4, 2024
1 parent 266e189 commit 8f2ac92
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 5 deletions.
2 changes: 2 additions & 0 deletions nrf_wifi/fw_if/umac_if/inc/fw/host_rpu_sys_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,8 @@ struct rpu_conf_params {
unsigned char bb_gain;
/** Number of RX samples to be captured */
unsigned short int capture_length;
/** Capture timeout in seconds */
unsigned short int capture_timeout;
/** Configure WLAN to bypass regulatory */
unsigned char bypass_regulatory;
/** Two letter country code (00: Default for WORLD) */
Expand Down
4 changes: 3 additions & 1 deletion nrf_wifi/fw_if/umac_if/inc/radio_test/fmac_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ enum nrf_wifi_status nrf_wifi_fmac_rf_test_rx_cap(struct nrf_wifi_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 bb_gain,
unsigned char *timeout_status);


/**
Expand Down
2 changes: 2 additions & 0 deletions nrf_wifi/fw_if/umac_if/inc/radio_test/fmac_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ struct nrf_wifi_fmac_dev_ctx_rt {
bool radio_cmd_done;
/** Firmware RF test command status. */
enum nrf_wifi_radio_test_err_status radio_cmd_status;
/** Firmware RF test RX capture event status */
unsigned char capture_status;
};

/**
Expand Down
7 changes: 7 additions & 0 deletions nrf_wifi/fw_if/umac_if/src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ static enum nrf_wifi_status umac_event_rf_test_process(struct nrf_wifi_fmac_dev_
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);

Expand Down Expand Up @@ -749,6 +750,12 @@ static enum nrf_wifi_status umac_event_rf_test_process(struct nrf_wifi_fmac_dev_
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:
Expand Down
12 changes: 8 additions & 4 deletions nrf_wifi/fw_if/umac_if/src/radio_test/fmac_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#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,
Expand Down Expand Up @@ -388,8 +387,10 @@ enum nrf_wifi_status nrf_wifi_fmac_rf_test_rx_cap(struct nrf_wifi_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 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;
Expand All @@ -404,12 +405,14 @@ enum nrf_wifi_status nrf_wifi_fmac_rf_test_rx_cap(struct nrf_wifi_fmac_dev_ctx *

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,
Expand All @@ -426,16 +429,17 @@ enum nrf_wifi_status nrf_wifi_fmac_rf_test_rx_cap(struct nrf_wifi_fmac_dev_ctx *
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));
(count < (RX_CAPTURE_TIMEOUT_CONST * capture_timeout)));

if (count == NRF_WIFI_FMAC_RF_TEST_EVNT_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;
Expand Down
18 changes: 18 additions & 0 deletions nrf_wifi/hw_if/hal/inc/fw/phy_rf_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define NRF_WIFI_PHY_CALIB_FLAG_TXIQ 8
#define NRF_WIFI_PHY_CALIB_FLAG_RXIQ 16
#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_TXDC (2<<16)
Expand All @@ -45,6 +46,7 @@
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 |\
Expand Down Expand Up @@ -395,6 +397,12 @@ enum EDGE_BACKOFF_OFFSETS {
};

#ifdef CONFIG_NRF700X_RADIO_TEST

#define MAX_CAPTURE_LEN 16383
#define MIN_CAPTURE_LEN 0
#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,
Expand Down Expand Up @@ -429,6 +437,16 @@ struct nrf_wifi_rf_test_capture_params {
/* 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
Expand Down

0 comments on commit 8f2ac92

Please sign in to comment.