|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright (c) 2011,2017-2020 The Linux Foundation. All rights reserved.
|
|
|
+ * Copyright (c) 2011,2017-2021 The Linux Foundation. All rights reserved.
|
|
|
*
|
|
|
*
|
|
|
* Permission to use, copy, modify, and/or distribute this software for
|
|
@@ -27,6 +27,186 @@
|
|
|
#include <wlan_osif_priv.h>
|
|
|
#include <reg_services_public_struct.h>
|
|
|
|
|
|
+#ifdef OPTIMIZED_SAMP_MESSAGE
|
|
|
+QDF_STATUS
|
|
|
+target_if_spectral_fill_samp_msg(struct target_if_spectral *spectral,
|
|
|
+ struct target_if_samp_msg_params *params)
|
|
|
+{
|
|
|
+ struct spectral_samp_msg *spec_samp_msg;
|
|
|
+ struct per_session_det_map *det_map;
|
|
|
+ enum spectral_msg_type msg_type;
|
|
|
+ QDF_STATUS ret;
|
|
|
+ uint16_t dest_det_idx;
|
|
|
+ enum spectral_scan_mode spectral_mode;
|
|
|
+
|
|
|
+ if (!spectral) {
|
|
|
+ spectral_err_rl("Spectral LMAC object is null");
|
|
|
+ return QDF_STATUS_E_NULL_VALUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!params) {
|
|
|
+ spectral_err_rl("SAMP msg params structure is null");
|
|
|
+ return QDF_STATUS_E_NULL_VALUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (params->hw_detector_id > SPECTRAL_DETECTOR_ID_MAX) {
|
|
|
+ spectral_err_rl("Invalid detector ID");
|
|
|
+ return QDF_STATUS_E_FAILURE;
|
|
|
+ }
|
|
|
+ det_map = &spectral->det_map[params->hw_detector_id];
|
|
|
+
|
|
|
+ spectral_mode =
|
|
|
+ spectral->rparams.detid_mode_table[params->hw_detector_id];
|
|
|
+ if (spectral_mode >= SPECTRAL_SCAN_MODE_MAX) {
|
|
|
+ spectral_err_rl("No valid Spectral mode for detector id %u",
|
|
|
+ params->hw_detector_id);
|
|
|
+ return QDF_STATUS_E_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = target_if_get_spectral_msg_type(spectral_mode,
|
|
|
+ &msg_type);
|
|
|
+ if (QDF_IS_STATUS_ERROR(ret)) {
|
|
|
+ spectral_err_rl("Invalid spectral msg type");
|
|
|
+ return QDF_STATUS_E_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ spec_samp_msg = spectral->nl_cb.get_sbuff(spectral->pdev_obj,
|
|
|
+ msg_type,
|
|
|
+ det_map->buf_type);
|
|
|
+ if (!spec_samp_msg) {
|
|
|
+ spectral_err_rl("Spectral SAMP message is NULL");
|
|
|
+ return QDF_STATUS_E_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (dest_det_idx = 0; dest_det_idx < det_map->num_dest_det_info;
|
|
|
+ dest_det_idx++) {
|
|
|
+ struct per_session_dest_det_info *map_det_info;
|
|
|
+ struct spectral_fft_bin_len_adj_swar *swar;
|
|
|
+ struct samp_freq_span_info *span_info;
|
|
|
+ struct samp_detector_info *detector_info;
|
|
|
+ uint8_t dest_detector_id;
|
|
|
+ uint8_t span_id;
|
|
|
+ uint8_t *bin_pwr_data;
|
|
|
+ uint32_t *binptr_32;
|
|
|
+ uint16_t *binptr_16;
|
|
|
+ uint16_t pwr_16;
|
|
|
+ size_t pwr_count;
|
|
|
+ uint16_t idx;
|
|
|
+
|
|
|
+ swar = &spectral->len_adj_swar;
|
|
|
+
|
|
|
+ map_det_info = &det_map->dest_det_info[dest_det_idx];
|
|
|
+ span_id = map_det_info->freq_span_id;
|
|
|
+ span_info = &spec_samp_msg->freq_span_info[span_id];
|
|
|
+ span_info->num_detectors++;
|
|
|
+
|
|
|
+ dest_detector_id = map_det_info->det_id;
|
|
|
+ detector_info = &span_info->detector_info[dest_detector_id];
|
|
|
+
|
|
|
+ detector_info->start_frequency = map_det_info->start_freq;
|
|
|
+ detector_info->end_frequency = map_det_info->end_freq;
|
|
|
+ detector_info->start_bin_idx = map_det_info->dest_start_bin_idx;
|
|
|
+ detector_info->end_bin_idx = map_det_info->dest_end_bin_idx;
|
|
|
+
|
|
|
+ detector_info->rssi = params->rssi;
|
|
|
+
|
|
|
+ detector_info->last_raw_timestamp = params->last_raw_timestamp;
|
|
|
+ detector_info->reset_delay = params->reset_delay;
|
|
|
+ detector_info->raw_timestamp = params->raw_timestamp;
|
|
|
+ detector_info->timestamp = params->timestamp;
|
|
|
+ detector_info->timestamp_war_offset = spectral->timestamp_war.
|
|
|
+ timestamp_war_offset[spectral_mode];
|
|
|
+
|
|
|
+ detector_info->max_magnitude = params->max_mag;
|
|
|
+
|
|
|
+ detector_info->noise_floor = params->noise_floor;
|
|
|
+ detector_info->agc_total_gain = params->agc_total_gain;
|
|
|
+ detector_info->gainchange = params->gainchange;
|
|
|
+ detector_info->is_sec80 = map_det_info->is_sec80;
|
|
|
+ /* In 165MHz, Pri80 indication to be set for Span ID 0 only */
|
|
|
+ if (span_id == SPECTRAL_FREQ_SPAN_ID_0)
|
|
|
+ detector_info->pri80ind = params->pri80ind;
|
|
|
+
|
|
|
+ bin_pwr_data = ¶ms->bin_pwr_data
|
|
|
+ [map_det_info->src_start_bin_idx];
|
|
|
+ pwr_count = detector_info->end_bin_idx -
|
|
|
+ detector_info->start_bin_idx + 1;
|
|
|
+ spec_samp_msg->bin_pwr_count += pwr_count;
|
|
|
+ /*
|
|
|
+ * To check whether FFT bin values exceed 8 bits, we add a
|
|
|
+ * check before copying values to samp_data->bin_pwr.
|
|
|
+ * If it crosses 8 bits, we cap the values to maximum value
|
|
|
+ * supported by 8 bits ie. 255. This needs to be done as the
|
|
|
+ * destination array in SAMP message is 8 bits. This is a
|
|
|
+ * temporary solution till an array of 16 bits is used for
|
|
|
+ * SAMP message.
|
|
|
+ */
|
|
|
+ if (swar->fftbin_size_war ==
|
|
|
+ SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE) {
|
|
|
+ binptr_32 = (uint32_t *)bin_pwr_data;
|
|
|
+ for (idx = 0; idx < pwr_count; idx++) {
|
|
|
+ /* Read only the first 2 bytes of the DWORD */
|
|
|
+ pwr_16 = *((uint16_t *)binptr_32++);
|
|
|
+ if (qdf_unlikely(pwr_16 > MAX_FFTBIN_VALUE))
|
|
|
+ pwr_16 = MAX_FFTBIN_VALUE;
|
|
|
+ spec_samp_msg->bin_pwr
|
|
|
+ [detector_info->start_bin_idx + idx]
|
|
|
+ = pwr_16;
|
|
|
+ }
|
|
|
+ } else if (swar->fftbin_size_war ==
|
|
|
+ SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE) {
|
|
|
+ binptr_16 = (uint16_t *)bin_pwr_data;
|
|
|
+ for (idx = 0; idx < pwr_count; idx++) {
|
|
|
+ pwr_16 = *(binptr_16++);
|
|
|
+ if (qdf_unlikely(pwr_16 > MAX_FFTBIN_VALUE))
|
|
|
+ pwr_16 = MAX_FFTBIN_VALUE;
|
|
|
+ spec_samp_msg->bin_pwr
|
|
|
+ [detector_info->start_bin_idx + idx]
|
|
|
+ = pwr_16;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ qdf_mem_copy(&spec_samp_msg->bin_pwr
|
|
|
+ [detector_info->start_bin_idx],
|
|
|
+ bin_pwr_data, pwr_count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (det_map->send_to_upper_layers) {
|
|
|
+ /* Fill per-report information */
|
|
|
+ struct per_session_report_info *rpt_info;
|
|
|
+ struct target_if_spectral_ops *p_sops;
|
|
|
+
|
|
|
+ p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
|
|
|
+
|
|
|
+ rpt_info = &spectral->report_info[spectral_mode];
|
|
|
+ spec_samp_msg->signature = SPECTRAL_SIGNATURE;
|
|
|
+ p_sops->get_mac_address(spectral, spec_samp_msg->macaddr);
|
|
|
+ spec_samp_msg->spectral_mode = spectral_mode;
|
|
|
+ spec_samp_msg->target_reset_count =
|
|
|
+ spectral->timestamp_war.target_reset_count;
|
|
|
+ spec_samp_msg->operating_bw = rpt_info->operating_bw;
|
|
|
+ spec_samp_msg->pri20_freq = rpt_info->pri20_freq;
|
|
|
+ spec_samp_msg->cfreq1 = rpt_info->cfreq1;
|
|
|
+ spec_samp_msg->cfreq2 = rpt_info->cfreq2;
|
|
|
+ spec_samp_msg->sscan_cfreq1 = rpt_info->sscan_cfreq1;
|
|
|
+ spec_samp_msg->sscan_cfreq2 = rpt_info->sscan_cfreq2;
|
|
|
+ spec_samp_msg->sscan_bw = rpt_info->sscan_bw;
|
|
|
+ spec_samp_msg->fft_width = FFT_BIN_SIZE_1BYTE;
|
|
|
+ spec_samp_msg->num_freq_spans = rpt_info->num_spans;
|
|
|
+
|
|
|
+ if (spectral->send_phy_data(spectral->pdev_obj,
|
|
|
+ msg_type) == 0)
|
|
|
+ spectral->spectral_sent_msg++;
|
|
|
+ if (spectral->spectral_gen == SPECTRAL_GEN3)
|
|
|
+ reset_160mhz_delivery_state_machine(spectral,
|
|
|
+ spectral_mode);
|
|
|
+ }
|
|
|
+
|
|
|
+ return QDF_STATUS_SUCCESS;
|
|
|
+}
|
|
|
+#endif /* OPTIMIZED_SAMP_MESSAGE */
|
|
|
+
|
|
|
+#ifndef OPTIMIZED_SAMP_MESSAGE
|
|
|
void
|
|
|
target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
|
|
|
struct target_if_samp_msg_params *params)
|
|
@@ -304,3 +484,4 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
|
|
|
spectral, params->smode,
|
|
|
SPECTRAL_DETECTOR_ID_INVALID);
|
|
|
}
|
|
|
+#endif
|