qcacmn: Cleanup in Spectral time stamp WAR logic
Add a function to encapsulate Spectral time stamp WAR logic which corrects the Spectral time stamp reported by target. Change-Id: I490c9f2109f36831cd8de47b8165749e93d9b5cb CRs-Fixed: 2600170
This commit is contained in:

committed by
nshrivas

parent
17ecd7493a
commit
d0113009aa
@@ -2094,6 +2094,28 @@ target_if_spectral_report_params_init(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* target_if_spectral_timestamp_war_init() - Initialize Spectral timestamp WAR
|
||||
* related info
|
||||
* @twar: Pointer to Spectral timstamp WAR related info
|
||||
*
|
||||
* Function to Initialize parameters related to Spectral timestamp WAR
|
||||
*
|
||||
* Return: void
|
||||
*/
|
||||
static void
|
||||
target_if_spectral_timestamp_war_init(struct spectral_timestamp_war *twar)
|
||||
{
|
||||
enum spectral_scan_mode smode;
|
||||
|
||||
smode = SPECTRAL_SCAN_MODE_NORMAL;
|
||||
for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++) {
|
||||
twar->last_fft_timestamp[smode] = 0;
|
||||
twar->timestamp_war_offset[smode] = 0;
|
||||
}
|
||||
twar->target_reset_count = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* target_if_pdev_spectral_init() - Initialize target_if Spectral
|
||||
* functionality for the given pdev
|
||||
@@ -2219,12 +2241,10 @@ target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev)
|
||||
return NULL;
|
||||
|
||||
target_if_init_spectral_ops(spectral);
|
||||
target_if_spectral_timestamp_war_init(&spectral->timestamp_war);
|
||||
|
||||
/* Spectral mode specific init */
|
||||
spectral->target_reset_count = 0;
|
||||
for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++) {
|
||||
spectral->last_fft_timestamp[smode] = 0;
|
||||
spectral->timestamp_war_offset[smode] = 0;
|
||||
spectral->params_valid[smode] = false;
|
||||
qdf_spinlock_create(&spectral->param_info[smode].osps_lock);
|
||||
spectral->param_info[smode].osps_cache.osc_is_valid = 0;
|
||||
@@ -3269,8 +3289,8 @@ target_if_spectral_scan_enable_params(struct target_if_spectral *spectral,
|
||||
if (!p_sops->is_spectral_active(spectral, smode)) {
|
||||
p_sops->configure_spectral(spectral, spectral_params, smode);
|
||||
p_sops->start_spectral_scan(spectral, smode, err);
|
||||
spectral->timestamp_war_offset[smode] = 0;
|
||||
spectral->last_fft_timestamp[smode] = 0;
|
||||
spectral->timestamp_war.timestamp_war_offset[smode] = 0;
|
||||
spectral->timestamp_war.last_fft_timestamp[smode] = 0;
|
||||
}
|
||||
|
||||
/* get current spectral configuration */
|
||||
|
@@ -507,6 +507,18 @@ struct spectral_report_params {
|
||||
uint8_t fft_report_hdr_len;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct spectral_timestamp_swar - Spectral time stamp WAR related parameters
|
||||
* @timestamp_war_offset: Offset to be added to correct timestamp
|
||||
* @target_reset_count: Number of times target exercised the reset routine
|
||||
* @last_fft_timestamp: last fft report timestamp
|
||||
*/
|
||||
struct spectral_timestamp_war {
|
||||
uint32_t timestamp_war_offset[SPECTRAL_SCAN_MODE_MAX];
|
||||
uint64_t target_reset_count;
|
||||
uint32_t last_fft_timestamp[SPECTRAL_SCAN_MODE_MAX];
|
||||
};
|
||||
|
||||
#if ATH_PERF_PWR_OFFLOAD
|
||||
/**
|
||||
* enum target_if_spectral_info - Enumerations for specifying which spectral
|
||||
@@ -890,14 +902,12 @@ struct spectral_param_properties {
|
||||
* @use_nl_bcast: Whether to use Netlink broadcast/unicast
|
||||
* @send_phy_data: Send data to the application layer for a particular msg type
|
||||
* @len_adj_swar: Spectral fft bin length adjustment SWAR related info
|
||||
* @last_fft_timestamp: last fft report timestamp
|
||||
* @timestamp_war_offset: Offset to be added to correct timestamp
|
||||
* @timestamp_war: Spectral time stamp WAR related info
|
||||
* @dbr_ring_debug: Whether Spectral DBR ring debug is enabled
|
||||
* @dbr_buff_debug: Whether Spectral DBR buffer debug is enabled
|
||||
* @direct_dma_support: Whether Direct-DMA is supported on the current radio
|
||||
* @prev_tstamp: Timestamp of the previously received sample, which has to be
|
||||
* compared with the current tstamp to check descrepancy
|
||||
* @target_reset_count: Number of times target excercised the reset routine
|
||||
* @rparams: Parameters related to Spectral report structure
|
||||
*/
|
||||
struct target_if_spectral {
|
||||
@@ -1006,17 +1016,14 @@ struct target_if_spectral {
|
||||
int (*send_phy_data)(struct wlan_objmgr_pdev *pdev,
|
||||
enum spectral_msg_type smsg_type);
|
||||
struct spectral_fft_bin_len_adj_swar len_adj_swar;
|
||||
struct spectral_timestamp_war timestamp_war;
|
||||
enum spectral_160mhz_report_delivery_state state_160mhz_delivery;
|
||||
void *spectral_report_cache;
|
||||
uint32_t last_fft_timestamp[SPECTRAL_SCAN_MODE_MAX];
|
||||
uint32_t timestamp_war_offset[SPECTRAL_SCAN_MODE_MAX];
|
||||
uint16_t fft_size_min;
|
||||
uint16_t fft_size_max;
|
||||
bool dbr_ring_debug;
|
||||
bool dbr_buff_debug;
|
||||
bool direct_dma_support;
|
||||
uint32_t prev_tstamp;
|
||||
uint32_t target_reset_count;
|
||||
struct spectral_report_params rparams;
|
||||
};
|
||||
|
||||
|
@@ -1719,6 +1719,44 @@ static void target_if_spectral_verify_ts(struct target_if_spectral *spectral,
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* target_if_spectral_get_adjusted_timestamp() - Adjust Spectral time
|
||||
* stamp to account for reset in time stamp due to target reset
|
||||
* @twar: Spectral time stamp WAR related information
|
||||
* @raw_timestamp: Spectral time stamp reported by target
|
||||
* @reset_delay: Reset delay at target
|
||||
* @smode: Spectral scan mode
|
||||
*
|
||||
* Correct time stamp to account for reset in time stamp due to target reset
|
||||
*
|
||||
* Return: Adjusted time stamp
|
||||
*/
|
||||
static uint32_t
|
||||
target_if_spectral_get_adjusted_timestamp(struct spectral_timestamp_war *twar,
|
||||
uint32_t raw_timestamp,
|
||||
uint32_t reset_delay,
|
||||
enum spectral_scan_mode smode) {
|
||||
qdf_assert_always(smode < SPECTRAL_SCAN_MODE_MAX);
|
||||
|
||||
if (reset_delay) {
|
||||
enum spectral_scan_mode m =
|
||||
SPECTRAL_SCAN_MODE_NORMAL;
|
||||
|
||||
/* Adjust the offset for all the Spectral modes.
|
||||
* Target will be sending the non zero reset delay for
|
||||
* the first Spectral report after reset. This delay is
|
||||
* common for all the Spectral modes.
|
||||
*/
|
||||
for (; m < SPECTRAL_SCAN_MODE_MAX; m++)
|
||||
twar->timestamp_war_offset[m] += (reset_delay +
|
||||
twar->last_fft_timestamp[m]);
|
||||
twar->target_reset_count++;
|
||||
}
|
||||
twar->last_fft_timestamp[smode] = raw_timestamp;
|
||||
|
||||
return raw_timestamp + twar->timestamp_war_offset[smode];
|
||||
}
|
||||
|
||||
int
|
||||
target_if_consume_spectral_report_gen3(
|
||||
struct target_if_spectral *spectral,
|
||||
@@ -1749,7 +1787,6 @@ target_if_consume_spectral_report_gen3(
|
||||
* 1. Order of FFT bin values
|
||||
*
|
||||
*/
|
||||
uint64_t tsf64 = 0;
|
||||
struct target_if_samp_msg_params params = {0};
|
||||
struct spectral_search_fft_info_gen3 search_fft_info;
|
||||
struct spectral_search_fft_info_gen3 *p_sfft = &search_fft_info;
|
||||
@@ -1847,33 +1884,19 @@ target_if_consume_spectral_report_gen3(
|
||||
fft_hdr_length - spectral->rparams.fft_report_hdr_len,
|
||||
spectral->params[params.smode].ss_rpt_mode,
|
||||
&spectral->len_adj_swar);
|
||||
params.last_raw_timestamp =
|
||||
spectral->last_fft_timestamp[params.smode];
|
||||
params.reset_delay = 0;
|
||||
|
||||
if (report->reset_delay) {
|
||||
enum spectral_scan_mode mode =
|
||||
SPECTRAL_SCAN_MODE_NORMAL;
|
||||
|
||||
/* Adjust the offset for all the Spectral modes.
|
||||
* Target will be sending the non zero reset delay for
|
||||
* the first Spectral report after reset. This delay is
|
||||
* common for all the Spectral modes.
|
||||
*/
|
||||
for (; mode < SPECTRAL_SCAN_MODE_MAX; mode++)
|
||||
spectral->timestamp_war_offset[mode] +=
|
||||
(report->reset_delay +
|
||||
spectral->last_fft_timestamp[mode]);
|
||||
params.reset_delay = report->reset_delay;
|
||||
spectral->target_reset_count++;
|
||||
}
|
||||
params.target_reset_count = spectral->target_reset_count;
|
||||
params.timestamp_war_offset =
|
||||
spectral->timestamp_war_offset[params.smode];
|
||||
tsf64 = p_sfft->timestamp;
|
||||
params.raw_timestamp = tsf64;
|
||||
spectral->last_fft_timestamp[params.smode] = p_sfft->timestamp;
|
||||
tsf64 += spectral->timestamp_war_offset[params.smode];
|
||||
params.last_raw_timestamp = spectral->timestamp_war.
|
||||
last_fft_timestamp[params.smode];
|
||||
params.reset_delay = report->reset_delay;
|
||||
params.raw_timestamp = p_sfft->timestamp;
|
||||
params.tstamp = target_if_spectral_get_adjusted_timestamp(
|
||||
&spectral->timestamp_war,
|
||||
p_sfft->timestamp, report->reset_delay,
|
||||
params.smode);
|
||||
params.timestamp_war_offset = spectral->timestamp_war.
|
||||
timestamp_war_offset[params.smode];
|
||||
params.target_reset_count = spectral->timestamp_war.
|
||||
target_reset_count;
|
||||
|
||||
/* Take care of state transitions for 160 MHz and 80p80 */
|
||||
if (spectral->ch_width == CH_WIDTH_160MHZ) {
|
||||
@@ -1930,7 +1953,6 @@ target_if_consume_spectral_report_gen3(
|
||||
report->noisefloor[chn_idx_lowest_enabled];
|
||||
params.datalen = (fft_hdr_length * 4);
|
||||
params.pwr_count = fft_bin_count;
|
||||
params.tstamp = (tsf64 & SPECTRAL_TSMASK);
|
||||
|
||||
target_if_spectral_verify_ts(spectral, report->data,
|
||||
params.tstamp);
|
||||
|
Reference in New Issue
Block a user