diff --git a/spectral/dispatcher/inc/wlan_spectral_public_structs.h b/spectral/dispatcher/inc/wlan_spectral_public_structs.h index 15963d7fb6..c4d2a465af 100644 --- a/spectral/dispatcher/inc/wlan_spectral_public_structs.h +++ b/spectral/dispatcher/inc/wlan_spectral_public_structs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011,2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2011,2017-2018 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -68,7 +68,7 @@ #define SPECTRAL_PARAM_STOP (22) #define SPECTRAL_PARAM_ENABLE (23) -#ifdef ATH_SPECTRAL_USE_EMU_DEFAULTS +#ifdef SPECTRAL_USE_EMU_DEFAULTS /* Use defaults from emulation */ #define SPECTRAL_SCAN_ACTIVE_DEFAULT (0x0) #define SPECTRAL_SCAN_ENABLE_DEFAULT (0x0) @@ -91,7 +91,8 @@ #define SPECTRAL_SCAN_DBM_ADJ_DEFAULT (0x0) #define SPECTRAL_SCAN_CHN_MASK_DEFAULT (0x1) #else -/* Static default values for spectral state and configuration. +/* + * Static default values for spectral state and configuration. * These definitions should be treated as temporary. Ideally, * we should get the defaults from firmware - this will be discussed. * @@ -118,12 +119,27 @@ #define SPECTRAL_SCAN_BIN_SCALE_DEFAULT (1) #define SPECTRAL_SCAN_DBM_ADJ_DEFAULT (1) #define SPECTRAL_SCAN_CHN_MASK_DEFAULT (1) -#endif /* ATH_SPECTRAL_USE_EMU_DEFAULTS */ +#endif /* SPECTRAL_USE_EMU_DEFAULTS */ /* The below two definitions apply only to pre-11ac chipsets */ #define SPECTRAL_SCAN_SHORT_REPORT_DEFAULT (1) #define SPECTRAL_SCAN_FFT_PERIOD_DEFAULT (1) +/** + * enum wlan_cfg80211_spectral_vendorcmd_handler_idx - Indices to cfg80211 + * spectral vendor command handlers + * @SPECTRAL_SCAN_START_HANDLER_IDX: Index to SPECTRAL_SCAN_START handler + * @SPECTRAL_SCAN_STOP_HANDLER_IDX: Index to SPECTRAL_SCAN_STOP handler + * @SPECTRAL_SCAN_GET_CONFIG_HANDLER_IDX: Index to SPECTRAL_SCAN_GET_CONFIG + * handler + * @SPECTRAL_SCAN_GET_DIAG_STATS_HANDLER_IDX: Index to + * SPECTRAL_SCAN_GET_DIAG_STATS handler + * @SPECTRAL_SCAN_GET_CAP_HANDLER_IDX: Index to SPECTRAL_SCAN_GET_CAP handler + * @SPECTRAL_SCAN_GET_STATUS_HANDLER_IDX: Index to SPECTRAL_SCAN_GET_STATUS + * handler + * @SPECTRAL_SCAN_VENDOR_CMD_HANDLER_MAX: Number of cfg80211 spectral + * vendor command handlers supported + */ enum wlan_cfg80211_spectral_vendorcmd_handler_idx { SPECTRAL_SCAN_START_HANDLER_IDX, SPECTRAL_SCAN_STOP_HANDLER_IDX, @@ -136,33 +152,33 @@ enum wlan_cfg80211_spectral_vendorcmd_handler_idx { /** * enum spectral_debug - Spectral debug level - * @ATH_DEBUG_SPECTRAL: Minimal SPECTRAL debug - * @ATH_DEBUG_SPECTRAL1: Normal SPECTRAL debug - * @ATH_DEBUG_SPECTRAL2: Maximal SPECTRAL debug - * @ATH_DEBUG_SPECTRAL3: Matched filterID display - * @ATH_DEBUG_SPECTRAL4: One time dump of FFT report + * @DEBUG_SPECTRAL: Minimal SPECTRAL debug + * @DEBUG_SPECTRAL1: Normal SPECTRAL debug + * @DEBUG_SPECTRAL2: Maximal SPECTRAL debug + * @DEBUG_SPECTRAL3: Matched filterID display + * @DEBUG_SPECTRAL4: One time dump of FFT report */ enum spectral_debug { - ATH_DEBUG_SPECTRAL = 0x00000100, - ATH_DEBUG_SPECTRAL1 = 0x00000200, - ATH_DEBUG_SPECTRAL2 = 0x00000400, - ATH_DEBUG_SPECTRAL3 = 0x00000800, - ATH_DEBUG_SPECTRAL4 = 0x00001000, + DEBUG_SPECTRAL = 0x00000100, + DEBUG_SPECTRAL1 = 0x00000200, + DEBUG_SPECTRAL2 = 0x00000400, + DEBUG_SPECTRAL3 = 0x00000800, + DEBUG_SPECTRAL4 = 0x00001000, }; /** - * enum SPECTRAL_CAPABILITY_TYPE - Spectral capability type + * enum spectral_capability_type - Spectral capability type * @SPECTRAL_CAP_PHYDIAG: Phydiag capability * @SPECTRAL_CAP_RADAR: Radar detection capability * @SPECTRAL_CAP_SPECTRAL_SCAN: Spectral capability * @SPECTRAL_CAP_ADVNCD_SPECTRAL_SCAN: Advanced spectral capability */ -typedef enum { +enum spectral_capability_type { SPECTRAL_CAP_PHYDIAG, SPECTRAL_CAP_RADAR, SPECTRAL_CAP_SPECTRAL_SCAN, SPECTRAL_CAP_ADVNCD_SPECTRAL_SCAN, -} SPECTRAL_CAPABILITY_TYPE; +}; /** * struct spectral_chan_stats - channel status info @@ -176,14 +192,14 @@ typedef enum { * @maxregpower_sec80: Max regulatory power of secondary 80 Mhz */ struct spectral_chan_stats { - int cycle_count; - int channel_load; - int per; - int noisefloor; - u_int16_t comp_usablity; - int8_t maxregpower; - u_int16_t comp_usablity_sec80; - int8_t maxregpower_sec80; + int cycle_count; + int channel_load; + int per; + int noisefloor; + uint16_t comp_usablity; + int8_t maxregpower; + uint16_t comp_usablity_sec80; + int8_t maxregpower_sec80; }; /** @@ -199,11 +215,11 @@ struct spectral_chan_stats { * mismatches in Search FFT report */ struct spectral_diag_stats { - u_int64_t spectral_mismatch; - u_int64_t spectral_sec80_sfft_insufflen; - u_int64_t spectral_no_sec80_sfft; - u_int64_t spectral_vhtseg1id_mismatch; - u_int64_t spectral_vhtseg2id_mismatch; + uint64_t spectral_mismatch; + uint64_t spectral_sec80_sfft_insufflen; + uint64_t spectral_no_sec80_sfft; + uint64_t spectral_vhtseg1id_mismatch; + uint64_t spectral_vhtseg2id_mismatch; }; /** @@ -214,14 +230,14 @@ struct spectral_diag_stats { * @advncd_spectral_cap: Advanced spectral capability */ struct spectral_caps { - u_int8_t phydiag_cap; - u_int8_t radar_cap; - u_int8_t spectral_cap; - u_int8_t advncd_spectral_cap; + uint8_t phydiag_cap; + uint8_t radar_cap; + uint8_t spectral_cap; + uint8_t advncd_spectral_cap; }; /** - * struct spectral_config + * struct spectral_config - spectral config parameters * @ss_fft_period: Skip interval for FFT reports * @ss_period: Spectral scan period * @ss_count: # of reports to return from ss_active @@ -279,30 +295,30 @@ struct spectral_caps { * @ss_nf_temp_data: temperature data taken during nf scan */ struct spectral_config { - u_int16_t ss_fft_period; - u_int16_t ss_period; - u_int16_t ss_count; - u_int16_t ss_short_report; - u_int8_t radar_bin_thresh_sel; - u_int16_t ss_spectral_pri; - u_int16_t ss_fft_size; - u_int16_t ss_gc_ena; - u_int16_t ss_restart_ena; - u_int16_t ss_noise_floor_ref; - u_int16_t ss_init_delay; - u_int16_t ss_nb_tone_thr; - u_int16_t ss_str_bin_thr; - u_int16_t ss_wb_rpt_mode; - u_int16_t ss_rssi_rpt_mode; - u_int16_t ss_rssi_thr; - u_int16_t ss_pwr_format; - u_int16_t ss_rpt_mode; - u_int16_t ss_bin_scale; - u_int16_t ss_dbm_adj; - u_int16_t ss_chn_mask; - int8_t ss_nf_cal[AH_MAX_CHAINS * 2]; - int8_t ss_nf_pwr[AH_MAX_CHAINS * 2]; - int32_t ss_nf_temp_data; + uint16_t ss_fft_period; + uint16_t ss_period; + uint16_t ss_count; + uint16_t ss_short_report; + uint8_t radar_bin_thresh_sel; + uint16_t ss_spectral_pri; + uint16_t ss_fft_size; + uint16_t ss_gc_ena; + uint16_t ss_restart_ena; + uint16_t ss_noise_floor_ref; + uint16_t ss_init_delay; + uint16_t ss_nb_tone_thr; + uint16_t ss_str_bin_thr; + uint16_t ss_wb_rpt_mode; + uint16_t ss_rssi_rpt_mode; + uint16_t ss_rssi_thr; + uint16_t ss_pwr_format; + uint16_t ss_rpt_mode; + uint16_t ss_bin_scale; + uint16_t ss_dbm_adj; + uint16_t ss_chn_mask; + int8_t ss_nf_cal[AH_MAX_CHAINS * 2]; + int8_t ss_nf_pwr[AH_MAX_CHAINS * 2]; + int32_t ss_nf_temp_data; }; /** @@ -315,11 +331,17 @@ struct spectral_scan_state { uint8_t is_enabled; }; -typedef enum _dcs_int_type { +/** + * enum dcs_int_type - Interference type indicated by DCS + * @SPECTRAL_DCS_INT_NONE: No interference + * @SPECTRAL_DCS_INT_CW: CW interference + * @SPECTRAL_DCS_INT_WIFI: WLAN interference + */ +enum dcs_int_type { SPECTRAL_DCS_INT_NONE, SPECTRAL_DCS_INT_CW, SPECTRAL_DCS_INT_WIFI -} DCS_INT_TYPE; +}; /** * struct INTERF_RSP - Interference record @@ -331,9 +353,9 @@ typedef enum _dcs_int_type { * @advncd_spectral_cap: Advanced spectral capability */ struct INTERF_RSP { - u_int8_t interf_type; - u_int16_t interf_min_freq; - u_int16_t interf_max_freq; + uint8_t interf_type; + uint16_t interf_min_freq; + uint16_t interf_max_freq; } __ATTRIB_PACKED; /** @@ -342,25 +364,25 @@ struct INTERF_RSP { * @interf: Array of interference records */ struct INTERF_SRC_RSP { - u_int16_t count; + uint16_t count; struct INTERF_RSP interf[MAX_INTERF]; } __ATTRIB_PACKED; /** - * struct spectral_classifier_params - + * struct spectral_classifier_params - spectral classifier parameters * @spectral_20_40_mode: Is AP in 20/40 mode? * @spectral_dc_index: DC index * @spectral_dc_in_mhz: DC in MHz * @upper_chan_in_mhz: Upper channel in MHz * @lower_chan_in_mhz: Lower channel in MHz */ -typedef struct spectral_classifier_params { +struct spectral_classifier_params { int spectral_20_40_mode; int spectral_dc_index; int spectral_dc_in_mhz; int upper_chan_in_mhz; int lower_chan_in_mhz; -} __ATTRIB_PACKED SPECTRAL_CLASSIFIER_PARAMS; +} __ATTRIB_PACKED; /** * struct spectral_samp_data - Spectral Analysis Messaging Protocol Data format @@ -403,32 +425,33 @@ typedef struct spectral_classifier_params { * segment * @ch_width: Channel width 20/40/80/160 MHz */ -typedef struct spectral_samp_data { - int16_t spectral_data_len; - int16_t spectral_data_len_sec80; - int16_t spectral_rssi; - int16_t spectral_rssi_sec80; - int8_t spectral_combined_rssi; - int8_t spectral_upper_rssi; - int8_t spectral_lower_rssi; - int8_t spectral_chain_ctl_rssi[MAX_SPECTRAL_CHAINS]; - int8_t spectral_chain_ext_rssi[MAX_SPECTRAL_CHAINS]; - u_int8_t spectral_max_scale; - int16_t spectral_bwinfo; - int32_t spectral_tstamp; - int16_t spectral_max_index; - int16_t spectral_max_index_sec80; - int16_t spectral_max_mag; - int16_t spectral_max_mag_sec80; - u_int8_t spectral_max_exp; - int32_t spectral_last_tstamp; - int16_t spectral_upper_max_index; - int16_t spectral_lower_max_index; - u_int8_t spectral_nb_upper; - u_int8_t spectral_nb_lower; - struct spectral_classifier_params classifier_params; - u_int16_t bin_pwr_count; - /* For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are +struct spectral_samp_data { + int16_t spectral_data_len; + int16_t spectral_data_len_sec80; + int16_t spectral_rssi; + int16_t spectral_rssi_sec80; + int8_t spectral_combined_rssi; + int8_t spectral_upper_rssi; + int8_t spectral_lower_rssi; + int8_t spectral_chain_ctl_rssi[MAX_SPECTRAL_CHAINS]; + int8_t spectral_chain_ext_rssi[MAX_SPECTRAL_CHAINS]; + uint8_t spectral_max_scale; + int16_t spectral_bwinfo; + int32_t spectral_tstamp; + int16_t spectral_max_index; + int16_t spectral_max_index_sec80; + int16_t spectral_max_mag; + int16_t spectral_max_mag_sec80; + uint8_t spectral_max_exp; + int32_t spectral_last_tstamp; + int16_t spectral_upper_max_index; + int16_t spectral_lower_max_index; + uint8_t spectral_nb_upper; + uint8_t spectral_nb_lower; + struct spectral_classifier_params classifier_params; + uint16_t bin_pwr_count; + /* + * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are * delivered. However, there can be additional bins reported for * AR900B version 2.0 and QCA9984 as described next: * @@ -444,16 +467,16 @@ typedef struct spectral_samp_data { * then 8 more bins (4 more on left side and 4 more on right side) * are added. */ - u_int8_t lb_edge_extrabins; - u_int8_t rb_edge_extrabins; - u_int16_t bin_pwr_count_sec80; - u_int8_t bin_pwr[MAX_NUM_BINS]; - u_int8_t bin_pwr_sec80[MAX_NUM_BINS]; - struct INTERF_SRC_RSP interf_list; - int16_t noise_floor; - int16_t noise_floor_sec80; - u_int32_t ch_width; -} __ATTRIB_PACKED SPECTRAL_SAMP_DATA; + uint8_t lb_edge_extrabins; + uint8_t rb_edge_extrabins; + uint16_t bin_pwr_count_sec80; + uint8_t bin_pwr[MAX_NUM_BINS]; + uint8_t bin_pwr_sec80[MAX_NUM_BINS]; + struct INTERF_SRC_RSP interf_list; + int16_t noise_floor; + int16_t noise_floor_sec80; + uint32_t ch_width; +} __ATTRIB_PACKED; /** * struct spectral_samp_msg - Spectral SAMP message @@ -467,17 +490,17 @@ typedef struct spectral_samp_data { * @macaddr: Indicates the device interface * @samp_data: SAMP Data */ -typedef struct spectral_samp_msg { - u_int32_t signature; - u_int16_t freq; - u_int16_t vhtop_ch_freq_seg1; - u_int16_t vhtop_ch_freq_seg2; - u_int16_t freq_loading; - u_int16_t dcs_enabled; - DCS_INT_TYPE int_type; - u_int8_t macaddr[6]; - SPECTRAL_SAMP_DATA samp_data; -} __ATTRIB_PACKED SPECTRAL_SAMP_MSG; +struct spectral_samp_msg { + uint32_t signature; + uint16_t freq; + uint16_t vhtop_ch_freq_seg1; + uint16_t vhtop_ch_freq_seg2; + uint16_t freq_loading; + uint16_t dcs_enabled; + enum dcs_int_type int_type; + uint8_t macaddr[6]; + struct spectral_samp_data samp_data; +} __ATTRIB_PACKED; #ifdef WIN32 #pragma pack(pop, spectral) @@ -486,5 +509,4 @@ typedef struct spectral_samp_msg { #undef __ATTRIB_PACKED #endif -#endif /* _WLAN_SPECTRAL_PUBLIC_STRUCTS_H_ */ - +#endif /* _WLAN_SPECTRAL_PUBLIC_STRUCTS_H_ */ diff --git a/target_if/spectral/target_if_spectral.c b/target_if/spectral/target_if_spectral.c index 6a65123676..93af3bccfd 100644 --- a/target_if/spectral/target_if_spectral.c +++ b/target_if/spectral/target_if_spectral.c @@ -39,22 +39,8 @@ * module. */ struct target_if_spectral_ops spectral_ops; -int spectral_debug_level = ATH_DEBUG_SPECTRAL; +int spectral_debug_level = DEBUG_SPECTRAL; -/** - * target_if_spectral_get_vdev() - Get pointer to vdev to be used for Spectral - * operations - * @spectral: Pointer to Spectral target_if internal private data - * - * Spectral operates on pdev. However, in order to retrieve some WLAN - * properties, a vdev is required. To facilitate this, the function returns the - * first vdev in our pdev. The caller should release the reference to the vdev - * once it is done using it. - * TODO: If the framework later provides an API to obtain the first active - * vdev, then it would be preferable to use this API. - * - * Return: Pointer to vdev on success, NULL on failure - */ struct wlan_objmgr_vdev * target_if_spectral_get_vdev(struct target_if_spectral *spectral) { @@ -66,7 +52,7 @@ target_if_spectral_get_vdev(struct target_if_spectral *spectral) qdf_assert_always(pdev); if (wlan_objmgr_pdev_try_get_ref(pdev, WLAN_SPECTRAL_ID) != - QDF_STATUS_SUCCESS) { + QDF_STATUS_SUCCESS) { qdf_print("%s: Unable to get pdev reference.\n", __func__); return NULL; } @@ -85,15 +71,15 @@ target_if_spectral_get_vdev(struct target_if_spectral *spectral) /** * target_if_send_vdev_spectral_configure_cmd() - Send WMI command to configure - * Spectral parameters + * spectral parameters * @spectral: Pointer to Spectral target_if internal private data * @param: Pointer to spectral_config giving the Spectral configuration * * Return: QDF_STATUS_SUCCESS on success, negative error code on failure */ -static int target_if_send_vdev_spectral_configure_cmd( - struct target_if_spectral *spectral, - struct spectral_config *param) +static int +target_if_send_vdev_spectral_configure_cmd(struct target_if_spectral *spectral, + struct spectral_config *param) { struct vdev_spectral_configure_params sparam; struct wlan_objmgr_pdev *pdev = NULL; @@ -149,12 +135,12 @@ static int target_if_send_vdev_spectral_configure_cmd( * * Return: QDF_STATUS_SUCCESS on success, negative error code on failure */ -static int target_if_send_vdev_spectral_enable_cmd( - struct target_if_spectral *spectral, - u_int8_t is_spectral_active_valid, - u_int8_t is_spectral_active, - u_int8_t is_spectral_enabled_valid, - u_int8_t is_spectral_enabled) +static int +target_if_send_vdev_spectral_enable_cmd(struct target_if_spectral *spectral, + uint8_t is_spectral_active_valid, + uint8_t is_spectral_active, + uint8_t is_spectral_enabled_valid, + uint8_t is_spectral_enabled) { struct vdev_spectral_enable_params param; struct wlan_objmgr_pdev *pdev = NULL; @@ -166,7 +152,6 @@ static int target_if_send_vdev_spectral_enable_cmd( qdf_assert_always(pdev); - vdev = target_if_spectral_get_vdev(spectral); if (!vdev) return QDF_STATUS_E_NOENT; @@ -196,76 +181,72 @@ static int target_if_send_vdev_spectral_enable_cmd( * * Return: QDF_STATUS_SUCCESS on success, negative error code on failure */ -static int target_if_spectral_info_init_defaults(struct target_if_spectral *spectral) +static int +target_if_spectral_info_init_defaults(struct target_if_spectral *spectral) { - struct target_if_spectral_param_state_info *info = &spectral->ol_info; + struct target_if_spectral_param_state_info *info = + &spectral->param_info; struct wlan_objmgr_vdev *vdev = NULL; /* State */ - info->osps_cache.osc_spectral_active = - SPECTRAL_SCAN_ACTIVE_DEFAULT; + info->osps_cache.osc_spectral_active = SPECTRAL_SCAN_ACTIVE_DEFAULT; - info->osps_cache.osc_spectral_enabled = - SPECTRAL_SCAN_ENABLE_DEFAULT; + info->osps_cache.osc_spectral_enabled = SPECTRAL_SCAN_ENABLE_DEFAULT; /* Parameters */ - info->osps_cache.osc_params.ss_count = - SPECTRAL_SCAN_COUNT_DEFAULT; + info->osps_cache.osc_params.ss_count = SPECTRAL_SCAN_COUNT_DEFAULT; - info->osps_cache.osc_params.ss_period = - SPECTRAL_SCAN_PERIOD_DEFAULT; + info->osps_cache.osc_params.ss_period = SPECTRAL_SCAN_PERIOD_DEFAULT; info->osps_cache.osc_params.ss_spectral_pri = - SPECTRAL_SCAN_PRIORITY_DEFAULT; + SPECTRAL_SCAN_PRIORITY_DEFAULT; info->osps_cache.osc_params.ss_fft_size = - SPECTRAL_SCAN_FFT_SIZE_DEFAULT; + SPECTRAL_SCAN_FFT_SIZE_DEFAULT; - info->osps_cache.osc_params.ss_gc_ena = - SPECTRAL_SCAN_GC_ENA_DEFAULT; + info->osps_cache.osc_params.ss_gc_ena = SPECTRAL_SCAN_GC_ENA_DEFAULT; info->osps_cache.osc_params.ss_restart_ena = - SPECTRAL_SCAN_RESTART_ENA_DEFAULT; + SPECTRAL_SCAN_RESTART_ENA_DEFAULT; info->osps_cache.osc_params.ss_noise_floor_ref = - SPECTRAL_SCAN_NOISE_FLOOR_REF_DEFAULT; + SPECTRAL_SCAN_NOISE_FLOOR_REF_DEFAULT; info->osps_cache.osc_params.ss_init_delay = - SPECTRAL_SCAN_INIT_DELAY_DEFAULT; + SPECTRAL_SCAN_INIT_DELAY_DEFAULT; info->osps_cache.osc_params.ss_nb_tone_thr = - SPECTRAL_SCAN_NB_TONE_THR_DEFAULT; + SPECTRAL_SCAN_NB_TONE_THR_DEFAULT; info->osps_cache.osc_params.ss_str_bin_thr = - SPECTRAL_SCAN_STR_BIN_THR_DEFAULT; + SPECTRAL_SCAN_STR_BIN_THR_DEFAULT; info->osps_cache.osc_params.ss_wb_rpt_mode = - SPECTRAL_SCAN_WB_RPT_MODE_DEFAULT; + SPECTRAL_SCAN_WB_RPT_MODE_DEFAULT; info->osps_cache.osc_params.ss_rssi_rpt_mode = - SPECTRAL_SCAN_RSSI_RPT_MODE_DEFAULT; + SPECTRAL_SCAN_RSSI_RPT_MODE_DEFAULT; info->osps_cache.osc_params.ss_rssi_thr = - SPECTRAL_SCAN_RSSI_THR_DEFAULT; + SPECTRAL_SCAN_RSSI_THR_DEFAULT; info->osps_cache.osc_params.ss_pwr_format = - SPECTRAL_SCAN_PWR_FORMAT_DEFAULT; + SPECTRAL_SCAN_PWR_FORMAT_DEFAULT; info->osps_cache.osc_params.ss_rpt_mode = - SPECTRAL_SCAN_RPT_MODE_DEFAULT; + SPECTRAL_SCAN_RPT_MODE_DEFAULT; info->osps_cache.osc_params.ss_bin_scale = - SPECTRAL_SCAN_BIN_SCALE_DEFAULT; + SPECTRAL_SCAN_BIN_SCALE_DEFAULT; - info->osps_cache.osc_params.ss_dbm_adj = - SPECTRAL_SCAN_DBM_ADJ_DEFAULT; + info->osps_cache.osc_params.ss_dbm_adj = SPECTRAL_SCAN_DBM_ADJ_DEFAULT; vdev = target_if_spectral_get_vdev(spectral); if (!vdev) return QDF_STATUS_E_NOENT; info->osps_cache.osc_params.ss_chn_mask = - wlan_vdev_mlme_get_rxchainmask(vdev); + wlan_vdev_mlme_get_rxchainmask(vdev); wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID); /* The cache is now valid */ @@ -274,27 +255,270 @@ static int target_if_spectral_info_init_defaults(struct target_if_spectral *spec return QDF_STATUS_SUCCESS; } +#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS /** - * ol_spectral_info_read() - Read Spectral parameters or the desired state - * information from the cache. + * target_if_log_read_spectral_active() - Helper function to log whether + * spectral is active after reading cache + * @function_name: Function name + * @output: whether spectral is active or not + * + * Helper function to log whether spectral is active after reading cache + * + * Return: none + */ +static void +target_if_log_read_spectral_active( + const char *function_name, + unsigned char output) +{ + qdf_print("%s: TARGET_IF_SPECTRAL_INFO_ACTIVE. " + "Returning val=%u\n", + function_name, output); +} + +/** + * target_if_log_read_spectral_enabled() - Helper function to log whether + * spectral is enabled after reading cache + * @function_name: Function name + * @output: whether spectral is enabled or not + * + * Helper function to log whether spectral is enabled after reading cache + * + * Return: none + */ +static void +target_if_log_read_spectral_enabled( + const char *function_name, + unsigned char output) +{ + qdf_print("%s: TARGET_IF_SPECTRAL_INFO_ENABLED. " + "Returning val=%u\n", + function_name, output); +} + +/** + * target_if_log_read_spectral_enabled() - Helper function to log spectral + * parameters after reading cache + * @function_name: Function name + * @pparam: Spectral parameters + * + * Helper function to log spectral parameters after reading cache + * + * Return: none + */ +static void +target_if_log_read_spectral_params( + const char *function_name, + struct spectral_config *pparam) +{ + qdf_print + ("%s: TARGET_IF_SPECTRAL_INFO_PARAMS. " + "Returning following params:\n" + "ss_count = %u\n" + "ss_period = %u\n" + "ss_spectral_pri = %u\n" + "ss_fft_size = %u\n" + "ss_gc_ena = %u\n" + "ss_restart_ena = %u\n" + "ss_noise_floor_ref = %d\n" + "ss_init_delay = %u\n" + "ss_nb_tone_thr = %u\n" + "ss_str_bin_thr = %u\n" + "ss_wb_rpt_mode = %u\n" + "ss_rssi_rpt_mode = %u\n" + "ss_rssi_thr = %d\n" + "ss_pwr_format = %u\n" + "ss_rpt_mode = %u\n" + "ss_bin_scale = %u\n" + "ss_dbm_adj = %u\n" + "ss_chn_mask = %u\n\n", function_name, + pparam->ss_count, + pparam->ss_period, + pparam->ss_spectral_pri, + pparam->ss_fft_size, + pparam->ss_gc_ena, + pparam->ss_restart_ena, + (int8_t)pparam->ss_noise_floor_ref, + pparam->ss_init_delay, + pparam->ss_nb_tone_thr, + pparam->ss_str_bin_thr, + pparam->ss_wb_rpt_mode, + pparam->ss_rssi_rpt_mode, + (int8_t)pparam->ss_rssi_thr, + pparam->ss_pwr_format, + pparam->ss_rpt_mode, + pparam->ss_bin_scale, + pparam->ss_dbm_adj, + pparam->ss_chn_mask); +} + +/** + * target_if_log_read_spectral_active_catch_validate() - Helper function to + * log whether spectral is active after intializing the cache + * @function_name: Function name + * @output: whether spectral is active or not + * + * Helper function to log whether spectral is active after intializing cache + * + * Return: none + */ +static void +target_if_log_read_spectral_active_catch_validate( + const char *function_name, + unsigned char output) +{ + qdf_print("%s: TARGET_IF_SPECTRAL_INFO_ACTIVE on " + "initial cache validation\n" + "Returning val=%u\n", + function_name, output); +} + +/** + * target_if_log_read_spectral_enabled_catch_validate() - Helper function to + * log whether spectral is enabled after intializing the cache + * @function_name: Function name + * @output: whether spectral is enabled or not + * + * Helper function to log whether spectral is enabled after intializing cache + * + * Return: none + */ +static void +target_if_log_read_spectral_enabled_catch_validate( + const char *function_name, + unsigned char output) +{ + qdf_print("%s: TARGET_IF_SPECTRAL_INFO_ENABLED on " + "initial cache validation\n" + "Returning val=%u\n", + function_name, output); +} + +/** + * target_if_log_read_spectral_params_catch_validate() - Helper function to + * log spectral parameters after intializing the cache + * @function_name: Function name + * @pparam: Spectral parameters + * + * Helper function to log spectral parameters after intializing the cache + * + * Return: none + */ +static void +target_if_log_read_spectral_params_catch_validate( + const char *function_name, + struct spectral_config *pparam) +{ + qdf_print("%s: TARGET_IF_SPECTRAL_INFO_PARAMS on " + "initial cache validation\n" + "Returning following params:\n" + "ss_count = %u\n" + "ss_period = %u\n" + "ss_spectral_pri = %u\n" + "ss_fft_size = %u\n" + "ss_gc_ena = %u\n" + "ss_restart_ena = %u\n" + "ss_noise_floor_ref = %d\n" + "ss_init_delay = %u\n" + "ss_nb_tone_thr = %u\n" + "ss_str_bin_thr = %u\n" + "ss_wb_rpt_mode = %u\n" + "ss_rssi_rpt_mode = %u\n" + "ss_rssi_thr = %d\n" + "ss_pwr_format = %u\n" + "ss_rpt_mode = %u\n" + "ss_bin_scale = %u\n" + "ss_dbm_adj = %u\n" + "ss_chn_mask = %u\n\n", + function_name, + pparam->ss_count, + pparam->ss_period, + pparam->ss_spectral_pri, + pparam->ss_fft_size, + pparam->ss_gc_ena, + pparam->ss_restart_ena, + (int8_t)pparam->ss_noise_floor_ref, + pparam->ss_init_delay, + pparam->ss_nb_tone_thr, + pparam->ss_str_bin_thr, + pparam->ss_wb_rpt_mode, + pparam->ss_rssi_rpt_mode, + (int8_t)pparam->ss_rssi_thr, + pparam->ss_pwr_format, + pparam->ss_rpt_mode, + pparam->ss_bin_scale, + pparam->ss_dbm_adj, pparam->ss_chn_mask); +} + +#else +static void +target_if_log_read_spectral_active( + const char *function_name, + unsigned char output) +{ +} + +static void +target_if_log_read_spectral_enabled( + const char *function_name, + unsigned char output) +{ +} + +static void +target_if_log_read_spectral_params( + const char *function_name, + struct spectral_config *pparam) +{ +} + +static void +target_if_log_read_spectral_active_catch_validate( + const char *function_name, + unsigned char output) +{ +} + +static void +target_if_log_read_spectral_enabled_catch_validate( + const char *function_name, + unsigned char output) +{ +} + +static void +target_if_log_read_spectral_params_catch_validate( + const char *function_name, + struct spectral_config *pparam) +{ +} +#endif + +/** + * target_if_spectral_info_read() - Read spectral information from the cache. * @spectral: Pointer to Spectral target_if internal private data - * @specifier: ol_spectral_info_spec enumeration specifying which information is - * required + * @specifier: target_if_spectral_info enumeration specifying which + * information is required * @output: Void output pointer into which the information will be read * @output_len: size of object pointed to by output pointer * + * Read spectral parameters or the desired state information from the cache. + * * Return: 0 on success, negative error code on failure */ -static int ol_spectral_info_read(struct target_if_spectral *spectral, - enum ol_spectral_info_spec specifier, - void *output, - int output_len) +static int +target_if_spectral_info_read( + struct target_if_spectral *spectral, + enum target_if_spectral_info specifier, + void *output, int output_len) { - /* Note: This function is designed to be able to accommodate + /* + * Note: This function is designed to be able to accommodate * WMI reads for defaults, non-cacheable information, etc * if required. */ - struct target_if_spectral_param_state_info *info = &spectral->ol_info; + struct target_if_spectral_param_state_info *info = + &spectral->param_info; int is_cacheable = 0; int init_def_retval = 0; @@ -302,28 +526,26 @@ static int ol_spectral_info_read(struct target_if_spectral *spectral, return -EINVAL; switch (specifier) { - case OL_SPECTRAL_INFO_SPEC_ACTIVE: - if (output_len != - sizeof(info->osps_cache.osc_spectral_active)) + case TARGET_IF_SPECTRAL_INFO_ACTIVE: + if (output_len != sizeof(info->osps_cache.osc_spectral_active)) return -EINVAL; is_cacheable = 1; break; - case OL_SPECTRAL_INFO_SPEC_ENABLED: - if (output_len != - sizeof(info->osps_cache.osc_spectral_enabled)) + case TARGET_IF_SPECTRAL_INFO_ENABLED: + if (output_len != sizeof(info->osps_cache.osc_spectral_enabled)) return -EINVAL; is_cacheable = 1; break; - case OL_SPECTRAL_INFO_SPEC_PARAMS: + case TARGET_IF_SPECTRAL_INFO_PARAMS: if (output_len != sizeof(info->osps_cache.osc_params)) return -EINVAL; is_cacheable = 1; break; default: - qdf_print("%s: Unknown ol_spectral_info_spec specifier\n", + qdf_print("%s: Unknown target_if_spectral_info specifier\n", __func__); return -EINVAL; } @@ -333,85 +555,39 @@ static int ol_spectral_info_read(struct target_if_spectral *spectral, if (is_cacheable) { if (info->osps_cache.osc_is_valid) { switch (specifier) { - case OL_SPECTRAL_INFO_SPEC_ACTIVE: + case TARGET_IF_SPECTRAL_INFO_ACTIVE: qdf_mem_copy( - output, - &info->osps_cache.osc_spectral_active, - sizeof(info->osps_cache.osc_spectral_active)); -#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS - qdf_print("%s: OL_SPECTRAL_INFO_SPEC_ACTIVE. " - "Returning val=%u\n", - __func__, - *((unsigned char *)output)); -#endif /* OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS */ + output, + &info->osps_cache.osc_spectral_active, + sizeof(info->osps_cache.osc_spectral_active)); + + target_if_log_read_spectral_active( + __func__, + *((unsigned char *)output)); break; - case OL_SPECTRAL_INFO_SPEC_ENABLED: + case TARGET_IF_SPECTRAL_INFO_ENABLED: qdf_mem_copy( - output, - &info->osps_cache.osc_spectral_enabled, - sizeof(info->osps_cache.osc_spectral_enabled)); -#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS - qdf_print("%s: OL_SPECTRAL_INFO_SPEC_ENABLED. " - "Returning val=%u\n", - __func__, - *((unsigned char *)output)); -#endif /* OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS */ + output, + &info->osps_cache.osc_spectral_enabled, + sizeof( + info->osps_cache.osc_spectral_enabled)); + target_if_log_read_spectral_enabled( + __func__, + *((unsigned char *)output)); break; - case OL_SPECTRAL_INFO_SPEC_PARAMS: + case TARGET_IF_SPECTRAL_INFO_PARAMS: qdf_mem_copy( - output, - &info->osps_cache.osc_params, - sizeof(info->osps_cache.osc_params)); -#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS - { - struct spectral_config *pparam = - (struct spectral_config *)output; + output, + &info->osps_cache.osc_params, + sizeof(info->osps_cache.osc_params)); - qdf_print("%s: OL_SPECTRAL_INFO_SPEC_PARAMS. " - "Returning following params:\n" - "ss_count = %u\n" - "ss_period = %u\n" - "ss_spectral_pri = %u\n" - "ss_fft_size = %u\n" - "ss_gc_ena = %u\n" - "ss_restart_ena = %u\n" - "ss_noise_floor_ref = %d\n" - "ss_init_delay = %u\n" - "ss_nb_tone_thr = %u\n" - "ss_str_bin_thr = %u\n" - "ss_wb_rpt_mode = %u\n" - "ss_rssi_rpt_mode = %u\n" - "ss_rssi_thr = %d\n" - "ss_pwr_format = %u\n" - "ss_rpt_mode = %u\n" - "ss_bin_scale = %u\n" - "ss_dbm_adj = %u\n" - "ss_chn_mask = %u\n\n", - __func__, - pparam->ss_count, - pparam->ss_period, - pparam->ss_spectral_pri, - pparam->ss_fft_size, - pparam->ss_gc_ena, - pparam->ss_restart_ena, - (int8_t)pparam->ss_noise_floor_ref, - pparam->ss_init_delay, - pparam->ss_nb_tone_thr, - pparam->ss_str_bin_thr, - pparam->ss_wb_rpt_mode, - pparam->ss_rssi_rpt_mode, - (int8_t)pparam->ss_rssi_thr, - pparam->ss_pwr_format, - pparam->ss_rpt_mode, - pparam->ss_bin_scale, - pparam->ss_dbm_adj, - pparam->ss_chn_mask); - } -#endif /* OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS */ - break; + target_if_log_read_spectral_params( + __func__, + (struct spectral_config *)output); + break; default: /* We can't reach this point */ @@ -424,7 +600,8 @@ static int ol_spectral_info_read(struct target_if_spectral *spectral, /* Cache is invalid */ - /* If WMI Reads are implemented to fetch defaults/non-cacheable info, + /* + * If WMI Reads are implemented to fetch defaults/non-cacheable info, * then the below implementation will change */ init_def_retval = target_if_spectral_info_init_defaults(spectral); @@ -437,83 +614,34 @@ static int ol_spectral_info_read(struct target_if_spectral *spectral, /* target_if_spectral_info_init_defaults() has set cache to valid */ switch (specifier) { - case OL_SPECTRAL_INFO_SPEC_ACTIVE: + case TARGET_IF_SPECTRAL_INFO_ACTIVE: qdf_mem_copy(output, &info->osps_cache.osc_spectral_active, sizeof(info->osps_cache.osc_spectral_active)); -#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS - qdf_print("%s: OL_SPECTRAL_INFO_SPEC_ACTIVE on " - "initial cache validation\n" - "Returning val=%u\n", - __func__, + + target_if_log_read_spectral_active_catch_validate( + __func__, *((unsigned char *)output)); -#endif /* OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS */ break; - case OL_SPECTRAL_INFO_SPEC_ENABLED: + case TARGET_IF_SPECTRAL_INFO_ENABLED: qdf_mem_copy(output, &info->osps_cache.osc_spectral_enabled, sizeof(info->osps_cache.osc_spectral_enabled)); -#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS - qdf_print("%s: OL_SPECTRAL_INFO_SPEC_ENABLED on " - "initial cache validation\n" - "Returning val=%u\n", - __func__, + + target_if_log_read_spectral_enabled_catch_validate( + __func__, *((unsigned char *)output)); -#endif /* OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS */ break; - case OL_SPECTRAL_INFO_SPEC_PARAMS: + case TARGET_IF_SPECTRAL_INFO_PARAMS: qdf_mem_copy(output, &info->osps_cache.osc_params, sizeof(info->osps_cache.osc_params)); -#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS - { - struct spectral_config *pparam = - (struct spectral_config *)output; - qdf_print("%s: OL_SPECTRAL_INFO_SPEC_PARAMS on " - "initial cache validation\n" - "Returning following params:\n" - "ss_count = %u\n" - "ss_period = %u\n" - "ss_spectral_pri = %u\n" - "ss_fft_size = %u\n" - "ss_gc_ena = %u\n" - "ss_restart_ena = %u\n" - "ss_noise_floor_ref = %d\n" - "ss_init_delay = %u\n" - "ss_nb_tone_thr = %u\n" - "ss_str_bin_thr = %u\n" - "ss_wb_rpt_mode = %u\n" - "ss_rssi_rpt_mode = %u\n" - "ss_rssi_thr = %d\n" - "ss_pwr_format = %u\n" - "ss_rpt_mode = %u\n" - "ss_bin_scale = %u\n" - "ss_dbm_adj = %u\n" - "ss_chn_mask = %u\n\n", - __func__, - pparam->ss_count, - pparam->ss_period, - pparam->ss_spectral_pri, - pparam->ss_fft_size, - pparam->ss_gc_ena, - pparam->ss_restart_ena, - (int8_t)pparam->ss_noise_floor_ref, - pparam->ss_init_delay, - pparam->ss_nb_tone_thr, - pparam->ss_str_bin_thr, - pparam->ss_wb_rpt_mode, - pparam->ss_rssi_rpt_mode, - (int8_t)pparam->ss_rssi_thr, - pparam->ss_pwr_format, - pparam->ss_rpt_mode, - pparam->ss_bin_scale, - pparam->ss_dbm_adj, - pparam->ss_chn_mask); - } -#endif /* OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS */ + target_if_log_read_spectral_params_catch_validate( + __func__, + (struct spectral_config *)output); break; @@ -527,194 +655,261 @@ static int ol_spectral_info_read(struct target_if_spectral *spectral, return 0; } +#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS /** - * ol_spectral_info_write() - Write Spectral parameters or the desired state - * information to the firmware, and update cache + * target_if_log_write_spectral_active() - Helper function to log inputs and + * return value of call to configure the Spectral 'active' configuration, + * TARGET_IF_SPECTRAL_INFO_ACTIVE into firmware + * @function_name: Function name in which this is called + * @pval: whether spectral is active or not + * @ret: return value of the firmware write function + * + * Return: none + */ +static void +target_if_log_write_spectral_active( + const char *function_name, + uint8_t pval, + int ret) +{ + qdf_print("%s: TARGET_IF_SPECTRAL_INFO_ACTIVE with " + "val=%u status=%d\n", + function_name, pval, ret); +} + +/** + * target_if_log_write_spectral_enabled() - Helper function to log inputs and + * return value of call to configure the Spectral 'enabled' configuration, + * TARGET_IF_SPECTRAL_INFO_ENABLED into firmware + * @function_name: Function name in which this is called + * @pval: whether spectral is enabled or not + * @ret: return value of the firmware write function + * + * Return: none + */ +static void +target_if_log_write_spectral_enabled( + const char *function_name, + uint8_t pval, + int ret) +{ + qdf_print("%s: TARGET_IF_SPECTRAL_INFO_ENABLED with " + "val=%u status=%d\n", + function_name, pval, ret); +} + +/** + * target_if_log_write_spectral_params() - Helper function to log inputs and + * return value of call to configure Spectral parameters, + * TARGET_IF_SPECTRAL_INFO_PARAMS into firmware + * @param: Spectral parameters + * @function_name: Function name in which this is called + * @ret: return value of the firmware write function + * + * Return: none + */ +static void +target_if_log_write_spectral_params( + struct spectral_config *param, + const char *function_name, + int ret) +{ + qdf_print("%s: TARGET_IF_SPECTRAL_INFO_PARAMS. " + "Params:\n" + "ss_count = %u\n" + "ss_period = %u\n" + "ss_spectral_pri = %u\n" + "ss_fft_size = %u\n" + "ss_gc_ena = %u\n" + "ss_restart_ena = %u\n" + "ss_noise_floor_ref = %d\n" + "ss_init_delay = %u\n" + "ss_nb_tone_thr = %u\n" + "ss_str_bin_thr = %u\n" + "ss_wb_rpt_mode = %u\n" + "ss_rssi_rpt_mode = %u\n" + "ss_rssi_thr = %d\n" + "ss_pwr_format = %u\n" + "ss_rpt_mode = %u\n" + "ss_bin_scale = %u\n" + "ss_dbm_adj = %u\n" + "ss_chn_mask = %u\n" + "status = %d\n\n", + function_name, + param->ss_count, + param->ss_period, + param->ss_spectral_pri, + param->ss_fft_size, + param->ss_gc_ena, + param->ss_restart_ena, + (int8_t)param->ss_noise_floor_ref, + param->ss_init_delay, + param->ss_nb_tone_thr, + param->ss_str_bin_thr, + param->ss_wb_rpt_mode, + param->ss_rssi_rpt_mode, + (int8_t)param->ss_rssi_thr, + param->ss_pwr_format, + param->ss_rpt_mode, + param->ss_bin_scale, + param->ss_dbm_adj, param->ss_chn_mask, ret); +} +#else +static void +target_if_log_write_spectral_active( + const char *function_name, + uint8_t pval, + int ret) +{ +} + +static void +target_if_log_write_spectral_enabled( + const char *function_name, + uint8_t pval, + int ret) +{ +} + +static void +target_if_log_write_spectral_params( + struct spectral_config *param, + const char *function_name, + int ret) +{ +} + +#endif + +/** + * target_if_spectral_info_write() - Write Spectral information to the + * firmware, and update cache * @spectral: Pointer to Spectral target_if internal private data - * @specifier: ol_spectral_info_spec enumeration specifying which information is - * involved + * @specifier: target_if_spectral_info enumeration specifying which + * information is involved * @input: void input pointer containing the information to be written * @input_len: size of object pointed to by input pointer * + * Write Spectral parameters or the desired state information to + * the firmware, and update cache + * * Return: 0 on success, negative error code on failure */ -static int ol_spectral_info_write(struct target_if_spectral *spectral, - enum ol_spectral_info_spec specifier, - void *input, - int input_len) +static int +target_if_spectral_info_write( + struct target_if_spectral *spectral, + enum target_if_spectral_info specifier, + void *input, int input_len) { - struct target_if_spectral_param_state_info *info = &spectral->ol_info; + struct target_if_spectral_param_state_info *info = + &spectral->param_info; int ret; - u_int8_t *pval = NULL; + uint8_t *pval = NULL; struct spectral_config *param = NULL; if (!input) return -EINVAL; - switch (specifier) { - case OL_SPECTRAL_INFO_SPEC_ACTIVE: - if (input_len != - sizeof(info->osps_cache.osc_spectral_active)) - return -EINVAL; - - pval = (u_int8_t *)input; - - qdf_spin_lock(&info->osps_lock); - ret = target_if_send_vdev_spectral_enable_cmd( - spectral, - 1, - *pval, - 0, - 0); - -#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS - qdf_print("%s: OL_SPECTRAL_INFO_SPEC_ACTIVE with " - "val=%u status=%d\n", - __func__, - *pval, - ret); -#endif /* OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS */ - - if (ret < 0) { - qdf_print( - "%s: target_if_send_vdev_spectral_enable_cmd " - "failed with error=%d\n", - __func__, - ret); - qdf_spin_unlock(&info->osps_lock); - return ret; - } - - info->osps_cache.osc_spectral_active = *pval; - qdf_spin_unlock(&info->osps_lock); - break; - - case OL_SPECTRAL_INFO_SPEC_ENABLED: - if (input_len != - sizeof(info->osps_cache.osc_spectral_enabled)) - return -EINVAL; - - pval = (u_int8_t *)input; - - qdf_spin_lock(&info->osps_lock); - ret = target_if_send_vdev_spectral_enable_cmd( - spectral, - 0, - 0, - 1, - *pval); - -#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS - qdf_print("%s: OL_SPECTRAL_INFO_SPEC_ENABLED with " - "val=%u status=%d\n", - __func__, - *pval, - ret); -#endif /* OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS */ - - if (ret < 0) { - qdf_print( - "%s: target_if_send_vdev_spectral_enable_cmd " - "failed with error=%d\n", - __func__, - ret); - qdf_spin_unlock(&info->osps_lock); - return ret; - } - - info->osps_cache.osc_spectral_enabled = *pval; - qdf_spin_unlock(&info->osps_lock); - break; - - case OL_SPECTRAL_INFO_SPEC_PARAMS: - if (input_len != sizeof(info->osps_cache.osc_params)) - return -EINVAL; - - param = (struct spectral_config *)input; - - qdf_spin_lock(&info->osps_lock); - ret = target_if_send_vdev_spectral_configure_cmd( - spectral, - param); - -#ifdef OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS - qdf_print("%s: OL_SPECTRAL_INFO_SPEC_PARAMS. " - "Params:\n" - "ss_count = %u\n" - "ss_period = %u\n" - "ss_spectral_pri = %u\n" - "ss_fft_size = %u\n" - "ss_gc_ena = %u\n" - "ss_restart_ena = %u\n" - "ss_noise_floor_ref = %d\n" - "ss_init_delay = %u\n" - "ss_nb_tone_thr = %u\n" - "ss_str_bin_thr = %u\n" - "ss_wb_rpt_mode = %u\n" - "ss_rssi_rpt_mode = %u\n" - "ss_rssi_thr = %d\n" - "ss_pwr_format = %u\n" - "ss_rpt_mode = %u\n" - "ss_bin_scale = %u\n" - "ss_dbm_adj = %u\n" - "ss_chn_mask = %u\n" - "status = %d\n\n", - __func__, - param->ss_count, - param->ss_period, - param->ss_spectral_pri, - param->ss_fft_size, - param->ss_gc_ena, - param->ss_restart_ena, - (int8_t)param->ss_noise_floor_ref, - param->ss_init_delay, - param->ss_nb_tone_thr, - param->ss_str_bin_thr, - param->ss_wb_rpt_mode, - param->ss_rssi_rpt_mode, - (int8_t)param->ss_rssi_thr, - param->ss_pwr_format, - param->ss_rpt_mode, - param->ss_bin_scale, - param->ss_dbm_adj, - param->ss_chn_mask, - ret); -#endif /* OL_SPECTRAL_DEBUG_CONFIG_INTERACTIONS */ - - if (ret < 0) { - qdf_print( - "%s: " - "target_if_send_vdev_spectral_configure_cmd " - "failed with error=%d\n", - __func__, - ret); - qdf_spin_unlock(&info->osps_lock); - return ret; - } - - qdf_mem_copy(&info->osps_cache.osc_params, - param, - sizeof(info->osps_cache.osc_params)); - qdf_spin_unlock(&info->osps_lock); - break; - - default: - qdf_print("%s: Unknown OL_SPECTRAL_INFO_SPEC_T " - "specifier\n", - __func__); + switch (specifier) { + case TARGET_IF_SPECTRAL_INFO_ACTIVE: + if (input_len != sizeof(info->osps_cache.osc_spectral_active)) return -EINVAL; + + pval = (uint8_t *)input; + + qdf_spin_lock(&info->osps_lock); + ret = target_if_send_vdev_spectral_enable_cmd(spectral, + 1, *pval, 0, 0); + + target_if_log_write_spectral_active( + __func__, + *pval, + ret); + + if (ret < 0) { + qdf_print("%s: target_if_send_vdev_spectral_enable_cmd " + "failed with error=%d\n", __func__, ret); + qdf_spin_unlock(&info->osps_lock); + return ret; } + info->osps_cache.osc_spectral_active = *pval; + qdf_spin_unlock(&info->osps_lock); + break; + + case TARGET_IF_SPECTRAL_INFO_ENABLED: + if (input_len != sizeof(info->osps_cache.osc_spectral_enabled)) + return -EINVAL; + + pval = (uint8_t *)input; + + qdf_spin_lock(&info->osps_lock); + ret = target_if_send_vdev_spectral_enable_cmd(spectral, + 0, 0, 1, *pval); + + target_if_log_write_spectral_enabled( + __func__, + *pval, + ret); + + if (ret < 0) { + qdf_print("%s: target_if_send_vdev_spectral_enable_cmd " + "failed with error=%d\n", __func__, ret); + qdf_spin_unlock(&info->osps_lock); + return ret; + } + + info->osps_cache.osc_spectral_enabled = *pval; + qdf_spin_unlock(&info->osps_lock); + break; + + case TARGET_IF_SPECTRAL_INFO_PARAMS: + if (input_len != sizeof(info->osps_cache.osc_params)) + return -EINVAL; + + param = (struct spectral_config *)input; + + qdf_spin_lock(&info->osps_lock); + ret = target_if_send_vdev_spectral_configure_cmd(spectral, + param); + + target_if_log_write_spectral_params( + param, + __func__, + ret); + + if (ret < 0) { + qdf_print("%s: " + "target_if_send_vdev_spectral_configure_cmd " + "failed with error=%d\n", __func__, ret); + qdf_spin_unlock(&info->osps_lock); + return ret; + } + + qdf_mem_copy(&info->osps_cache.osc_params, + param, sizeof(info->osps_cache.osc_params)); + qdf_spin_unlock(&info->osps_lock); + break; + + default: + qdf_print("%s: Unknown target_if_spectral_info " + "specifier\n", __func__); + return -EINVAL; + } + return 0; } /** - * target_if_spectral_get_tsf64() - Get the last TSF received in WMI buffer + * target_if_spectral_get_tsf64() - Function to get the TSF value * @arg: Pointer to handle for Spectral target_if internal private data * + * Get the last TSF received in WMI buffer + * * Return: TSF value */ -static u_int64_t target_if_spectral_get_tsf64(void *arg) +static uint64_t +target_if_spectral_get_tsf64(void *arg) { struct target_if_spectral *spectral = (struct target_if_spectral *)arg; @@ -722,17 +917,18 @@ static u_int64_t target_if_spectral_get_tsf64(void *arg) } /** - * target_if_spectral_get_capability() - Get whether a given Spectral hardware - * capability is available + * target_if_spectral_get_capability() - Function to get whether a + * given Spectral hardware capability is available * @arg: Pointer to handle for Spectral target_if internal private data * @type: Spectral hardware capability type * + * Get whether a given Spectral hardware capability is available + * * Return: True if the capability is available, false if the capability is not * available */ -u_int32_t target_if_spectral_get_capability( - void *arg, - SPECTRAL_CAPABILITY_TYPE type) +uint32_t +target_if_spectral_get_capability(void *arg, enum spectral_capability_type type) { int status = STATUS_FAIL; @@ -759,9 +955,11 @@ u_int32_t target_if_spectral_get_capability( * * Return: 0 */ -u_int32_t target_if_spectral_set_rxfilter(void *arg, int rxfilter) +uint32_t +target_if_spectral_set_rxfilter(void *arg, int rxfilter) { - /* Will not be required since enabling of spectral in firmware + /* + * Will not be required since enabling of spectral in firmware * will take care of this */ return 0; @@ -776,33 +974,39 @@ u_int32_t target_if_spectral_set_rxfilter(void *arg, int rxfilter) * * Return: 0 */ -u_int32_t target_if_spectral_get_rxfilter(void *arg) +uint32_t +target_if_spectral_get_rxfilter(void *arg) { - /* Will not be required since enabling of spectral in firmware + /* + * Will not be required since enabling of spectral in firmware * will take care of this */ return 0; } /** - * tgt_if_is_spectral_active() - Get whether Spectral is active + * target_if_sops_is_spectral_active() - Get whether Spectral is active * @arg: Pointer to handle for Spectral target_if internal private data * + * Function to check whether Spectral is active + * * Return: True if Spectral is active, false if Spectral is not active */ -u_int32_t tgt_if_is_spectral_active(void *arg) +uint32_t +target_if_sops_is_spectral_active(void *arg) { struct target_if_spectral *spectral = (struct target_if_spectral *)arg; - u_int8_t val = 0; + uint8_t val = 0; int ret; - ret = ol_spectral_info_read(spectral, - OL_SPECTRAL_INFO_SPEC_ACTIVE, - &val, - sizeof(val)); + ret = target_if_spectral_info_read( + spectral, + TARGET_IF_SPECTRAL_INFO_ACTIVE, + &val, sizeof(val)); if (ret != 0) { - /* Could not determine if Spectral is active. + /* + * Could not determine if Spectral is active. * Return false as a safe value. * XXX: Consider changing the function prototype * to be able to indicate failure to fetch value. @@ -814,24 +1018,28 @@ u_int32_t tgt_if_is_spectral_active(void *arg) } /** - * tgt_if_is_spectral_enabled() - Get whether Spectral is enabled + * target_if_sops_is_spectral_enabled() - Get whether Spectral is enabled * @arg: Pointer to handle for Spectral target_if internal private data * + * Function to check whether Spectral is enabled + * * Return: True if Spectral is enabled, false if Spectral is not enabled */ -u_int32_t tgt_if_is_spectral_enabled(void *arg) +uint32_t +target_if_sops_is_spectral_enabled(void *arg) { struct target_if_spectral *spectral = (struct target_if_spectral *)arg; - u_int8_t val = 0; + uint8_t val = 0; int ret; - ret = ol_spectral_info_read(spectral, - OL_SPECTRAL_INFO_SPEC_ENABLED, - &val, - sizeof(val)); + ret = target_if_spectral_info_read( + spectral, + TARGET_IF_SPECTRAL_INFO_ENABLED, + &val, sizeof(val)); if (ret != 0) { - /* Could not determine if Spectral is enabled. + /* + * Could not determine if Spectral is enabled. * Return false as a safe value. * XXX: Consider changing the function prototype * to be able to indicate failure to fetch value. @@ -843,100 +1051,110 @@ u_int32_t tgt_if_is_spectral_enabled(void *arg) } /** - * tgt_if_start_spectral_scan() - Start Spectral scan + * target_if_sops_start_spectral_scan() - Start Spectral scan * @arg: Pointer to handle for Spectral target_if internal private data * - * Return: 1 on success, 0 on failure + * Function to start spectral scan + * + * Return: 0 on success else failure */ -u_int32_t tgt_if_start_spectral_scan(void *arg) +uint32_t +target_if_sops_start_spectral_scan(void *arg) { struct target_if_spectral *spectral = (struct target_if_spectral *)arg; - u_int8_t val = 1; - u_int8_t enabled = 0; + uint8_t val = 1; + uint8_t enabled = 0; int ret; - ret = ol_spectral_info_read(spectral, - OL_SPECTRAL_INFO_SPEC_ENABLED, - &enabled, - sizeof(enabled)); + ret = target_if_spectral_info_read( + spectral, + TARGET_IF_SPECTRAL_INFO_ENABLED, + &enabled, sizeof(enabled)); if (ret != 0) { - /* Could not determine if Spectral is enabled. Assume we need + /* + * Could not determine if Spectral is enabled. Assume we need * to enable it */ enabled = 0; } if (!enabled) { - ret = ol_spectral_info_write(spectral, - OL_SPECTRAL_INFO_SPEC_ENABLED, - &val, - sizeof(val)); + ret = target_if_spectral_info_write( + spectral, + TARGET_IF_SPECTRAL_INFO_ENABLED, + &val, sizeof(val)); if (ret != 0) - return 0; + return ret; } - ret = ol_spectral_info_write(spectral, - OL_SPECTRAL_INFO_SPEC_ACTIVE, - &val, - sizeof(val)); + ret = target_if_spectral_info_write( + spectral, + TARGET_IF_SPECTRAL_INFO_ACTIVE, + &val, sizeof(val)); if (ret != 0) - return 0; + return ret; - return 1; + return 0; } /** - * tgt_if_stop_spectral_scan() - Stop Spectral scan + * target_if_sops_stop_spectral_scan() - Stop Spectral scan * @arg: Pointer to handle for Spectral target_if internal private data * - * Return: 1 on success, 0 on failure + * Function to stop spectral scan + * + * Return: 0 on success else failure */ -u_int32_t tgt_if_stop_spectral_scan(void *arg) +uint32_t +target_if_sops_stop_spectral_scan(void *arg) { struct target_if_spectral *spectral = (struct target_if_spectral *)arg; - u_int8_t val = 0; - int tempret, ret = 1; + uint8_t val = 0; + int tempret, ret = 0; - tempret = ol_spectral_info_write(spectral, - OL_SPECTRAL_INFO_SPEC_ACTIVE, - &val, - sizeof(val)); + tempret = target_if_spectral_info_write( + spectral, + TARGET_IF_SPECTRAL_INFO_ACTIVE, + &val, sizeof(val)); if (tempret != 0) - ret = 0; + ret = tempret; - tempret = ol_spectral_info_write(spectral, - OL_SPECTRAL_INFO_SPEC_ENABLED, - &val, - sizeof(val)); + tempret = target_if_spectral_info_write( + spectral, + TARGET_IF_SPECTRAL_INFO_ENABLED, + &val, sizeof(val)); if (tempret != 0) - ret = 0; + ret = tempret; return ret; } /** - * target_if_spectral_get_extension_channel() - Get the current Extension - * channel (in MHz) + * target_if_spectral_get_extension_channel() - Get the Extension channel * @arg: Pointer to handle for Spectral target_if internal private data * + * Function to get the current Extension channel (in MHz) + * * Return: Current Extension channel (in MHz) on success, 0 on failure or if * extension channel is not present. */ -u_int32_t target_if_spectral_get_extension_channel(void *arg) +uint32_t +target_if_spectral_get_extension_channel(void *arg) { - /* XXX: Once we expand to use cases where Spectral could be activated + /* + * XXX: Once we expand to use cases where Spectral could be activated * without a channel being set to VDEV, we need to consider returning a * negative value in case of failure and having all callers handle this. */ struct target_if_spectral *spectral = NULL; struct wlan_objmgr_vdev *vdev = NULL; - u_int16_t sec20chan_freq = 0; + uint16_t sec20chan_freq = 0; qdf_assert_always(arg); spectral = (struct target_if_spectral *)arg; @@ -956,14 +1174,18 @@ u_int32_t target_if_spectral_get_extension_channel(void *arg) } /** - * target_if_spectral_get_current_channel() - Get the current channel (in MHz) + * target_if_spectral_get_current_channel() - Get the current channel * @arg: Pointer to handle for Spectral target_if internal private data * + * Function to get the current channel (in MHz) + * * Return: Current channel (in MHz) on success, 0 on failure */ -u_int32_t target_if_spectral_get_current_channel(void *arg) +uint32_t +target_if_spectral_get_current_channel(void *arg) { - /* XXX: Once we expand to use cases where Spectral could be activated + /* + * XXX: Once we expand to use cases where Spectral could be activated * without a channel being set to VDEV, we need to consider returning a * negative value in case of failure and having all callers handle this. */ @@ -999,7 +1221,8 @@ u_int32_t target_if_spectral_get_current_channel(void *arg) * * Return: 0 */ -u_int32_t target_if_spectral_reset_hw(void *arg) +uint32_t +target_if_spectral_reset_hw(void *arg) { not_yet_implemented(); return 0; @@ -1016,7 +1239,8 @@ u_int32_t target_if_spectral_reset_hw(void *arg) * * Return: 0 */ -u_int32_t target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf) +uint32_t +target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf) { not_yet_implemented(); return 0; @@ -1032,7 +1256,8 @@ u_int32_t target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf) * * Return: 0 */ -int8_t target_if_spectral_get_ext_noisefloor(void *arg) +int8_t +target_if_spectral_get_ext_noisefloor(void *arg) { not_yet_implemented(); return 0; @@ -1047,61 +1272,54 @@ int8_t target_if_spectral_get_ext_noisefloor(void *arg) * * Return: 0 */ -int8_t target_if_spectral_get_ctl_noisefloor(void *arg) +int8_t +target_if_spectral_get_ctl_noisefloor(void *arg) { not_yet_implemented(); return 0; } /** - * target_if_spectral_configure_params() - Configure user supplied Spectral + * target_if_spectral_sops_configure_params() - Configure user supplied Spectral * parameters * @arg: Pointer to handle for Spectral target_if internal private data * @params: Spectral parameters * - * Return: 1 on success, 0 on failure. + * Function to configure spectral parameters + * + * Return: 0 on success else failure */ -u_int32_t target_if_spectral_configure_params( - void *arg, - struct spectral_config *params) +uint32_t +target_if_spectral_sops_configure_params( + void *arg, struct spectral_config *params) { struct target_if_spectral *spectral = (struct target_if_spectral *)arg; - int ret; - ret = ol_spectral_info_write(spectral, - OL_SPECTRAL_INFO_SPEC_PARAMS, - params, - sizeof(*params)); - - if (ret != 0) - return 0; - - return 1; + return target_if_spectral_info_write( + spectral, + TARGET_IF_SPECTRAL_INFO_PARAMS, + params, sizeof(*params)); } /** - * target_if_spectral_get_params() - Get user configured Spectral parameters + * target_if_spectral_sops_get_params() - Get user configured Spectral + * parameters * @arg: Pointer to handle for Spectral target_if internal private data * @params: Pointer to buffer into which Spectral parameters should be copied * - * Return: 1 on success, 0 on failure. + * Function to get the configured spectral parameters + * + * Return: 0 on success else failure */ -u_int32_t target_if_spectral_get_params( - void *arg, - struct spectral_config *params) +uint32_t +target_if_spectral_sops_get_params(void *arg, struct spectral_config *params) { struct target_if_spectral *spectral = (struct target_if_spectral *)arg; - int ret; - ret = ol_spectral_info_read(spectral, - OL_SPECTRAL_INFO_SPEC_PARAMS, - params, - sizeof(*params)); - - if (ret != 0) - return 0; - - return 1; + return target_if_spectral_info_read( + spectral, + TARGET_IF_SPECTRAL_INFO_PARAMS, + params, sizeof(*params)); } /** @@ -1113,7 +1331,8 @@ u_int32_t target_if_spectral_get_params( * * Return: 0 */ -static u_int32_t target_if_spectral_get_ent_mask(void *arg) +static uint32_t +target_if_spectral_get_ent_mask(void *arg) { not_yet_implemented(); return 0; @@ -1124,9 +1343,12 @@ static u_int32_t target_if_spectral_get_ent_mask(void *arg) * @arg: Pointer to handle for Spectral target_if internal private data * @addr: Pointer to buffer into which MAC address should be copied * + * Function to get the MAC address of the pdev + * * Return: 0 on success, -1 on failure */ -static u_int32_t target_if_spectral_get_macaddr(void *arg, char *addr) +static uint32_t +target_if_spectral_get_macaddr(void *arg, char *addr) { uint8_t *myaddr = NULL; struct target_if_spectral *spectral = (struct target_if_spectral *)arg; @@ -1143,14 +1365,15 @@ static u_int32_t target_if_spectral_get_macaddr(void *arg, char *addr) } /** - * init_spectral_capability() - Initialize Spectral capability + * target_if_init_spectral_capability() - Initialize Spectral capability * @spectral: Pointer to Spectral target_if internal private data * * This is a workaround. * * Return: None */ -void init_spectral_capability(struct target_if_spectral *spectral) +void +target_if_init_spectral_capability(struct target_if_spectral *spectral) { struct spectral_caps *pcap = &spectral->capability; @@ -1162,22 +1385,22 @@ void init_spectral_capability(struct target_if_spectral *spectral) pcap->advncd_spectral_cap = 1; } +#ifdef QCA_SUPPORT_SPECTRAL_SIMULATION /** - * target_if_init_spectral_ops_common() - Initialize Spectral target_if internal - * operations common to all Spectral chipset generations + * target_if_init_spectral_simulation_ops() - Initialize spectral target_if + * internal operations with functions related to spectral simulation + * @p_sops: spectral low level ops table + * + * Initialize spectral target_if internal operations with functions + * related to spectral simulation * * Return: None */ -static void target_if_init_spectral_ops_common(void) +static void +target_if_init_spectral_simulation_ops(struct target_if_spectral_ops *p_sops) { - struct target_if_spectral_ops *p_sops = &spectral_ops; - - p_sops->get_tsf64 = target_if_spectral_get_tsf64; - p_sops->get_capability = target_if_spectral_get_capability; - p_sops->set_rxfilter = target_if_spectral_set_rxfilter; - p_sops->get_rxfilter = target_if_spectral_get_rxfilter; -#ifdef QCA_SUPPORT_SPECTRAL_SIMULATION - /* Spectral simulation is currently intended for platform transitions + /* + * Spectral simulation is currently intended for platform transitions * where underlying HW support may not be available for some time. * Hence, we do not currently provide a runtime switch to turn the * simulation on or off. @@ -1187,59 +1410,98 @@ static void target_if_init_spectral_ops_common(void) * use of record and replay of samples would concern higher * level sample processing rather than lower level delivery. */ - p_sops->is_spectral_enabled = tif_spectral_sim_is_spectral_enabled; - p_sops->is_spectral_active = tif_spectral_sim_is_spectral_active; - p_sops->start_spectral_scan = tif_spectral_sim_start_spectral_scan; - p_sops->stop_spectral_scan = tif_spectral_sim_stop_spectral_scan; - p_sops->configure_spectral = tif_spectral_sim_configure_params; - p_sops->get_spectral_config = tif_spectral_sim_get_params; + p_sops->is_spectral_enabled = tif_spectral_sim_is_spectral_enabled; + p_sops->is_spectral_active = tif_spectral_sim_is_spectral_active; + p_sops->start_spectral_scan = tif_spectral_sim_start_spectral_scan; + p_sops->stop_spectral_scan = tif_spectral_sim_stop_spectral_scan; + p_sops->configure_spectral = + tif_spectral_sim_configure_params; + p_sops->get_spectral_config = tif_spectral_sim_get_params; +} + #else - p_sops->is_spectral_enabled = tgt_if_is_spectral_enabled; - p_sops->is_spectral_active = tgt_if_is_spectral_active; - p_sops->start_spectral_scan = tgt_if_start_spectral_scan; - p_sops->stop_spectral_scan = tgt_if_stop_spectral_scan; - p_sops->configure_spectral = target_if_spectral_configure_params; - p_sops->get_spectral_config = target_if_spectral_get_params; -#endif /* QCA_SUPPORT_SPECTRAL_SIMULATION */ - p_sops->get_extension_channel = - target_if_spectral_get_extension_channel; - p_sops->get_ctl_noisefloor = - target_if_spectral_get_ctl_noisefloor; - p_sops->get_ext_noisefloor = - target_if_spectral_get_ext_noisefloor; - p_sops->get_ent_spectral_mask = target_if_spectral_get_ent_mask; - p_sops->get_mac_address = target_if_spectral_get_macaddr; - p_sops->get_current_channel = - target_if_spectral_get_current_channel; - p_sops->reset_hw = target_if_spectral_reset_hw; - p_sops->get_chain_noise_floor = - target_if_spectral_get_chain_noise_floor; +/** + * target_if_init_spectral_simulation_ops() - Initialize spectral target_if + * internal operations + * @p_sops: spectral low level ops table + * + * Return: None + */ +static void +target_if_init_spectral_simulation_ops(struct target_if_spectral_ops *p_sops) +{ + p_sops->is_spectral_enabled = target_if_sops_is_spectral_enabled; + p_sops->is_spectral_active = target_if_sops_is_spectral_active; + p_sops->start_spectral_scan = target_if_sops_start_spectral_scan; + p_sops->stop_spectral_scan = target_if_sops_stop_spectral_scan; + p_sops->configure_spectral = target_if_spectral_sops_configure_params; + p_sops->get_spectral_config = target_if_spectral_sops_get_params; +} +#endif + +/** + * target_if_init_spectral_ops_common() - Initialize Spectral target_if internal + * operations common to all Spectral chipset generations + * + * Initializes target_if_spectral_ops common to all chipset generations + * + * Return: None + */ +static void +target_if_init_spectral_ops_common(void) +{ + struct target_if_spectral_ops *p_sops = &spectral_ops; + + p_sops->get_tsf64 = target_if_spectral_get_tsf64; + p_sops->get_capability = target_if_spectral_get_capability; + p_sops->set_rxfilter = target_if_spectral_set_rxfilter; + p_sops->get_rxfilter = target_if_spectral_get_rxfilter; + + target_if_init_spectral_simulation_ops(p_sops); + + p_sops->get_extension_channel = + target_if_spectral_get_extension_channel; + p_sops->get_ctl_noisefloor = target_if_spectral_get_ctl_noisefloor; + p_sops->get_ext_noisefloor = target_if_spectral_get_ext_noisefloor; + p_sops->get_ent_spectral_mask = target_if_spectral_get_ent_mask; + p_sops->get_mac_address = target_if_spectral_get_macaddr; + p_sops->get_current_channel = target_if_spectral_get_current_channel; + p_sops->reset_hw = target_if_spectral_reset_hw; + p_sops->get_chain_noise_floor = + target_if_spectral_get_chain_noise_floor; } /** * target_if_init_spectral_ops_gen2() - Initialize Spectral target_if internal * operations specific to Spectral chipset generation 2. * + * Initializes target_if_spectral_ops specific to Spectral chipset generation 2. + * * Return: None */ -static void target_if_init_spectral_ops_gen2(void) +static void +target_if_init_spectral_ops_gen2(void) { struct target_if_spectral_ops *p_sops = &spectral_ops; - p_sops->spectral_process_phyerr = spectral_process_phyerr_gen2; + p_sops->spectral_process_phyerr = target_if_process_phyerr_gen2; } /** * target_if_init_spectral_ops_gen3() - Initialize Spectral target_if internal * operations specific to Spectral chipset generation 3. * + * Initializes target_if_spectral_ops specific to Spectral chipset generation 3. + * * Return: None */ -static void target_if_init_spectral_ops_gen3(void) +static void +target_if_init_spectral_ops_gen3(void) { struct target_if_spectral_ops *p_sops = &spectral_ops; - p_sops->spectral_process_phyerr = spectral_process_phyerr_gen3; + p_sops->spectral_process_phyerr = + target_if_spectral_process_phyerr_gen3; } /** @@ -1247,9 +1509,13 @@ static void target_if_init_spectral_ops_gen3(void) * operations. * @spectral: Pointer to Spectral target_if internal private data * + * Initializes all function pointers in target_if_spectral_ops for + * all generations + * * Return: None */ -static void target_if_init_spectral_ops(struct target_if_spectral *spectral) +static void +target_if_init_spectral_ops(struct target_if_spectral *spectral) { target_if_init_spectral_ops_common(); if (spectral->spectral_gen == SPECTRAL_GEN2) @@ -1266,13 +1532,15 @@ static void target_if_init_spectral_ops(struct target_if_spectral *spectral) * invocation of spectral functions before they are registered. */ -static u_int64_t null_get_tsf64(void *arg) +static uint64_t +null_get_tsf64(void *arg) { spectral_ops_not_registered("get_tsf64"); return 0; } -static u_int32_t null_get_capability(void *arg, SPECTRAL_CAPABILITY_TYPE type) +static uint32_t +null_get_capability(void *arg, enum spectral_capability_type type) { /* * TODO : We should have conditional compilation to get the capability @@ -1285,114 +1553,126 @@ static u_int32_t null_get_capability(void *arg, SPECTRAL_CAPABILITY_TYPE type) return true; } -static u_int32_t null_set_rxfilter(void *arg, int rxfilter) +static uint32_t +null_set_rxfilter(void *arg, int rxfilter) { spectral_ops_not_registered("set_rxfilter"); return 1; } -static u_int32_t null_get_rxfilter(void *arg) +static uint32_t +null_get_rxfilter(void *arg) { spectral_ops_not_registered("get_rxfilter"); return 0; } -static u_int32_t null_is_spectral_active(void *arg) +static uint32_t +null_is_spectral_active(void *arg) { spectral_ops_not_registered("is_spectral_active"); return 1; } -static u_int32_t null_is_spectral_enabled(void *arg) +static uint32_t +null_is_spectral_enabled(void *arg) { spectral_ops_not_registered("is_spectral_enabled"); return 1; } -static u_int32_t null_start_spectral_scan(void *arg) +static uint32_t +null_start_spectral_scan(void *arg) { spectral_ops_not_registered("start_spectral_scan"); return 1; } -static u_int32_t null_stop_spectral_scan(void *arg) +static uint32_t +null_stop_spectral_scan(void *arg) { spectral_ops_not_registered("stop_spectral_scan"); return 1; } -static u_int32_t null_get_extension_channel(void *arg) +static uint32_t +null_get_extension_channel(void *arg) { spectral_ops_not_registered("get_extension_channel"); return 1; } -static int8_t null_get_ctl_noisefloor(void *arg) +static int8_t +null_get_ctl_noisefloor(void *arg) { spectral_ops_not_registered("get_ctl_noisefloor"); return 1; } -static int8_t null_get_ext_noisefloor(void *arg) +static int8_t +null_get_ext_noisefloor(void *arg) { spectral_ops_not_registered("get_ext_noisefloor"); return 0; } -static u_int32_t null_configure_spectral( - void *arg, - struct spectral_config *params) +static uint32_t +null_configure_spectral(void *arg, struct spectral_config *params) { spectral_ops_not_registered("configure_spectral"); return 0; } -static u_int32_t null_get_spectral_config( - void *arg, - struct spectral_config *params) +static uint32_t +null_get_spectral_config(void *arg, struct spectral_config *params) { spectral_ops_not_registered("get_spectral_config"); return 0; } -static u_int32_t null_get_ent_spectral_mask(void *arg) +static uint32_t +null_get_ent_spectral_mask(void *arg) { spectral_ops_not_registered("get_ent_spectral_mask"); return 0; } -static u_int32_t null_get_mac_address(void *arg, char *addr) +static uint32_t +null_get_mac_address(void *arg, char *addr) { spectral_ops_not_registered("get_mac_address"); return 0; } -static u_int32_t null_get_current_channel(void *arg) +static uint32_t +null_get_current_channel(void *arg) { spectral_ops_not_registered("get_current_channel"); return 0; } -static u_int32_t null_reset_hw(void *arg) +static uint32_t +null_reset_hw(void *arg) { spectral_ops_not_registered("get_current_channel"); return 0; } -static u_int32_t null_get_chain_noise_floor(void *arg, int16_t *nf_buf) +static uint32_t +null_get_chain_noise_floor(void *arg, int16_t *nf_buf) { spectral_ops_not_registered("get_chain_noise_floor"); return 0; } -static int null_spectral_process_phyerr( - struct target_if_spectral *spectral, - u_int8_t *data, - u_int32_t datalen, - struct target_if_spectral_rfqual_info *p_rfqual, - struct target_if_spectral_chan_info *p_chaninfo, - u_int64_t tsf64, - struct target_if_spectral_acs_stats *acs_stats) +static int +null_spectral_process_phyerr(struct target_if_spectral *spectral, + uint8_t *data, + uint32_t datalen, + struct target_if_spectral_rfqual_info *p_rfqual, + struct target_if_spectral_chan_info *p_chaninfo, + uint64_t tsf64, + struct target_if_spectral_acs_stats *acs_stats) { spectral_ops_not_registered("spectral_process_phyerr"); return 0; @@ -1404,31 +1684,34 @@ static int null_spectral_process_phyerr( * Spectral operations to dummy functions * @ps: Pointer to Spectral target_if internal private data * + * Initialize all the function pointers in target_if_spectral_ops with + * dummy functions. + * * Return: None */ -static void target_if_spectral_init_dummy_function_table( - struct target_if_spectral *ps) +static void +target_if_spectral_init_dummy_function_table(struct target_if_spectral *ps) { - struct target_if_spectral_ops *p_sops = GET_TIF_SPECTRAL_OPS(ps); + struct target_if_spectral_ops *p_sops = GET_TARGET_IF_SPECTRAL_OPS(ps); - p_sops->get_tsf64 = null_get_tsf64; - p_sops->get_capability = null_get_capability; - p_sops->set_rxfilter = null_set_rxfilter; - p_sops->get_rxfilter = null_get_rxfilter; - p_sops->is_spectral_enabled = null_is_spectral_enabled; - p_sops->is_spectral_active = null_is_spectral_active; - p_sops->start_spectral_scan = null_start_spectral_scan; - p_sops->stop_spectral_scan = null_stop_spectral_scan; - p_sops->get_extension_channel = null_get_extension_channel; - p_sops->get_ctl_noisefloor = null_get_ctl_noisefloor; - p_sops->get_ext_noisefloor = null_get_ext_noisefloor; - p_sops->configure_spectral = null_configure_spectral; - p_sops->get_spectral_config = null_get_spectral_config; - p_sops->get_ent_spectral_mask = null_get_ent_spectral_mask; - p_sops->get_mac_address = null_get_mac_address; - p_sops->get_current_channel = null_get_current_channel; - p_sops->reset_hw = null_reset_hw; - p_sops->get_chain_noise_floor = null_get_chain_noise_floor; + p_sops->get_tsf64 = null_get_tsf64; + p_sops->get_capability = null_get_capability; + p_sops->set_rxfilter = null_set_rxfilter; + p_sops->get_rxfilter = null_get_rxfilter; + p_sops->is_spectral_enabled = null_is_spectral_enabled; + p_sops->is_spectral_active = null_is_spectral_active; + p_sops->start_spectral_scan = null_start_spectral_scan; + p_sops->stop_spectral_scan = null_stop_spectral_scan; + p_sops->get_extension_channel = null_get_extension_channel; + p_sops->get_ctl_noisefloor = null_get_ctl_noisefloor; + p_sops->get_ext_noisefloor = null_get_ext_noisefloor; + p_sops->configure_spectral = null_configure_spectral; + p_sops->get_spectral_config = null_get_spectral_config; + p_sops->get_ent_spectral_mask = null_get_ent_spectral_mask; + p_sops->get_mac_address = null_get_mac_address; + p_sops->get_current_channel = null_get_current_channel; + p_sops->reset_hw = null_reset_hw; + p_sops->get_chain_noise_floor = null_get_chain_noise_floor; p_sops->spectral_process_phyerr = null_spectral_process_phyerr; } @@ -1440,30 +1723,31 @@ static void target_if_spectral_init_dummy_function_table( * * Return: None */ -static void target_if_spectral_register_funcs( - struct target_if_spectral *spectral, - struct target_if_spectral_ops *p) +static void +target_if_spectral_register_funcs(struct target_if_spectral *spectral, + struct target_if_spectral_ops *p) { - struct target_if_spectral_ops *p_sops = GET_TIF_SPECTRAL_OPS(spectral); + struct target_if_spectral_ops *p_sops = + GET_TARGET_IF_SPECTRAL_OPS(spectral); - p_sops->get_tsf64 = p->get_tsf64; - p_sops->get_capability = p->get_capability; - p_sops->set_rxfilter = p->set_rxfilter; - p_sops->get_rxfilter = p->get_rxfilter; - p_sops->is_spectral_enabled = p->is_spectral_enabled; - p_sops->is_spectral_active = p->is_spectral_active; - p_sops->start_spectral_scan = p->start_spectral_scan; - p_sops->stop_spectral_scan = p->stop_spectral_scan; - p_sops->get_extension_channel = p->get_extension_channel; - p_sops->get_ctl_noisefloor = p->get_ctl_noisefloor; - p_sops->get_ext_noisefloor = p->get_ext_noisefloor; - p_sops->configure_spectral = p->configure_spectral; - p_sops->get_spectral_config = p->get_spectral_config; - p_sops->get_ent_spectral_mask = p->get_ent_spectral_mask; - p_sops->get_mac_address = p->get_mac_address; - p_sops->get_current_channel = p->get_current_channel; - p_sops->reset_hw = p->reset_hw; - p_sops->get_chain_noise_floor = p->get_chain_noise_floor; + p_sops->get_tsf64 = p->get_tsf64; + p_sops->get_capability = p->get_capability; + p_sops->set_rxfilter = p->set_rxfilter; + p_sops->get_rxfilter = p->get_rxfilter; + p_sops->is_spectral_enabled = p->is_spectral_enabled; + p_sops->is_spectral_active = p->is_spectral_active; + p_sops->start_spectral_scan = p->start_spectral_scan; + p_sops->stop_spectral_scan = p->stop_spectral_scan; + p_sops->get_extension_channel = p->get_extension_channel; + p_sops->get_ctl_noisefloor = p->get_ctl_noisefloor; + p_sops->get_ext_noisefloor = p->get_ext_noisefloor; + p_sops->configure_spectral = p->configure_spectral; + p_sops->get_spectral_config = p->get_spectral_config; + p_sops->get_ent_spectral_mask = p->get_ent_spectral_mask; + p_sops->get_mac_address = p->get_mac_address; + p_sops->get_current_channel = p->get_current_channel; + p_sops->reset_hw = p->reset_hw; + p_sops->get_chain_noise_floor = p->get_chain_noise_floor; p_sops->spectral_process_phyerr = p->spectral_process_phyerr; } @@ -1471,60 +1755,64 @@ static void target_if_spectral_register_funcs( * target_if_spectral_clear_stats() - Clear Spectral stats * @spectral: Pointer to Spectral target_if internal private data * + * Function to clear spectral stats + * * Return: None */ -static void target_if_spectral_clear_stats(struct target_if_spectral *spectral) +static void +target_if_spectral_clear_stats(struct target_if_spectral *spectral) { - struct target_if_spectral_ops *p_sops = GET_TIF_SPECTRAL_OPS(spectral); + struct target_if_spectral_ops *p_sops = + GET_TARGET_IF_SPECTRAL_OPS(spectral); - qdf_mem_zero( - &spectral->ath_spectral_stats, - sizeof(struct target_if_spectral_stats)); - spectral->ath_spectral_stats.last_reset_tstamp = - p_sops->get_tsf64(spectral); + qdf_mem_zero(&spectral->spectral_stats, + sizeof(struct target_if_spectral_stats)); + spectral->spectral_stats.last_reset_tstamp = + p_sops->get_tsf64(spectral); } /** * target_if_spectral_check_hw_capability() - Check whether HW supports spectral * @spectral: Pointer to Spectral target_if internal private data * + * Function to check whether hardware supports spectral + * * Return: True if HW supports Spectral, false if HW does not support Spectral */ -static int target_if_spectral_check_hw_capability( - struct target_if_spectral *spectral) +static int +target_if_spectral_check_hw_capability(struct target_if_spectral *spectral) { struct target_if_spectral_ops *p_sops = NULL; - struct spectral_caps *pcap = NULL; + struct spectral_caps *pcap = NULL; int is_spectral_supported = true; - p_sops = GET_TIF_SPECTRAL_OPS(spectral); - pcap = &spectral->capability; + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); + pcap = &spectral->capability; if (p_sops->get_capability(spectral, SPECTRAL_CAP_PHYDIAG) == false) { is_spectral_supported = false; qdf_print("SPECTRAL : No PHYDIAG support\n"); return is_spectral_supported; } - pcap->phydiag_cap = 1; + pcap->phydiag_cap = 1; if (p_sops->get_capability(spectral, SPECTRAL_CAP_RADAR) == false) { is_spectral_supported = false; qdf_print("SPECTRAL : No RADAR support\n"); return is_spectral_supported; } - pcap->radar_cap = 1; + pcap->radar_cap = 1; - if ( - p_sops->get_capability(spectral, - SPECTRAL_CAP_SPECTRAL_SCAN) == false) { + if (p_sops->get_capability(spectral, + SPECTRAL_CAP_SPECTRAL_SCAN) == false) { is_spectral_supported = false; qdf_print("SPECTRAL : No SPECTRAL SUPPORT\n"); return is_spectral_supported; } - pcap->spectral_cap = 1; + pcap->spectral_cap = 1; if (p_sops->get_capability(spectral, SPECTRAL_CAP_ADVNCD_SPECTRAL_SCAN) - == false) { + == false) { qdf_print("SPECTRAL : No ADVANCED SPECTRAL SUPPORT\n"); } else { pcap->advncd_spectral_cap = 1; @@ -1544,8 +1832,8 @@ static int target_if_spectral_check_hw_capability( * * Return: None */ -static void target_if_spectral_init_param_defaults( - struct target_if_spectral *spectral) +static void +target_if_spectral_init_param_defaults(struct target_if_spectral *spectral) { struct spectral_config *params = &spectral->params; @@ -1581,26 +1869,50 @@ static void target_if_spectral_init_param_defaults( params->ss_fft_period = SPECTRAL_SCAN_FFT_PERIOD_DEFAULT; } +#ifdef QCA_SUPPORT_SPECTRAL_SIMULATION +/** + * target_if_spectral_detach_simulation() - De-initialize Spectral + * Simulation functionality + * @spectral: Pointer to Spectral target_if internal private data + * + * Function to de-initialize Spectral Simulation functionality + * + * Return: None + */ +static void +target_if_spectral_detach_simulation(struct target_if_spectral *spectral) +{ + target_if_spectral_sim_detach(spectral); +} + +#else +static void +target_if_spectral_detach_simulation(struct target_if_spectral *spectral) +{ +} +#endif + /** * target_if_spectral_detach() - De-initialize target_if Spectral * @pdev: Pointer to pdev object * + * Function to detach target_if spectral + * * Return: None */ -static void target_if_spectral_detach(struct target_if_spectral *spectral) +static void +target_if_spectral_detach(struct target_if_spectral *spectral) { qdf_print("spectral detach\n"); - qdf_spinlock_destroy(&spectral->ol_info.osps_lock); + qdf_spinlock_destroy(&spectral->param_info.osps_lock); -#ifdef QCA_SUPPORT_SPECTRAL_SIMULATION - target_if_spectral_sim_detach(spectral); -#endif /* QCA_SUPPORT_SPECTRAL_SIMULATION */ + target_if_spectral_detach_simulation(spectral); #ifdef SPECTRAL_USE_NETLINK_SOCKETS target_if_spectral_destroy_netlink(spectral); #endif - qdf_spinlock_destroy(&spectral->ath_spectral_lock); + qdf_spinlock_destroy(&spectral->spectral_lock); qdf_spinlock_destroy(&spectral->noise_pwr_reports_lock); if (spectral) { @@ -1609,15 +1921,46 @@ static void target_if_spectral_detach(struct target_if_spectral *spectral) } } +#ifdef QCA_SUPPORT_SPECTRAL_SIMULATION +/** + * target_if_spectral_attach_simulation() - Initialize Spectral Simulation + * functionality + * @spectral: Pointer to Spectral target_if internal private data + * + * Function to initialize spectral simulation functionality + * + * Return: 0 on success, negative error code on failure + */ +static int +target_if_spectral_attach_simulation(struct target_if_spectral *spectral) +{ + if (target_if_spectral_sim_attach(spectral)) { + qdf_mem_free(spectral); + return -EPERM; + } + return 0; +} + +#else +static int +target_if_spectral_attach_simulation(struct target_if_spectral *spectral) +{ + return 0; +} +#endif + /** * target_if_pdev_spectral_init() - Initialize target_if Spectral * functionality for the given pdev * @pdev: Pointer to pdev object * + * Function to initialize pointer to spectral target_if internal private data + * * Return: On success, pointer to Spectral target_if internal private data, on * failure, NULL */ -void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev) +void * +target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev) { struct target_if_spectral_ops *p_sops = NULL; struct target_if_spectral *spectral = NULL; @@ -1634,8 +1977,9 @@ void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev) return NULL; } #endif - spectral = (struct target_if_spectral *)qdf_mem_malloc( - sizeof(struct target_if_spectral)); + spectral = + (struct target_if_spectral *) + qdf_mem_malloc(sizeof(struct target_if_spectral)); if (!spectral) { qdf_print("SPECTRAL : Memory allocation failed\n"); return spectral; @@ -1648,7 +1992,7 @@ void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev) target_if_spectral_init_dummy_function_table(spectral); /* get spectral function table */ - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); /* TODO : Should this be called here of after ath_attach ? */ if (p_sops->get_capability(spectral, SPECTRAL_CAP_PHYDIAG)) qdf_print(KERN_INFO "HAL_CAP_PHYDIAG : Capable\n"); @@ -1662,7 +2006,7 @@ void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev) if (p_sops->get_capability(spectral, SPECTRAL_CAP_SPECTRAL_SCAN)) qdf_print(KERN_INFO "HAL_CAP_SPECTRAL_SCAN : Capable\n"); - qdf_spinlock_create(&spectral->ath_spectral_lock); + qdf_spinlock_create(&spectral->spectral_lock); qdf_spinlock_create(&spectral->noise_pwr_reports_lock); target_if_spectral_clear_stats(spectral); @@ -1681,16 +2025,16 @@ void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev) spectral->spectral_gen = SPECTRAL_GEN3; spectral->hdr_sig_exp = SPECTRAL_PHYERR_SIGNATURE_GEN3; spectral->tag_sscan_summary_exp = - TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3; + TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3; spectral->tag_sscan_fft_exp = TLV_TAG_SEARCH_FFT_REPORT_GEN3; spectral->tlvhdr_size = SPECTRAL_PHYERR_TLVSIZE_GEN3; } else { - spectral->spectral_gen = SPECTRAL_GEN2; - spectral->hdr_sig_exp = SPECTRAL_PHYERR_SIGNATURE_GEN2; - spectral->tag_sscan_summary_exp = - TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2; - spectral->tag_sscan_fft_exp = TLV_TAG_SEARCH_FFT_REPORT_GEN2; - spectral->tlvhdr_size = sizeof(SPECTRAL_PHYERR_TLV_GEN2); + spectral->spectral_gen = SPECTRAL_GEN2; + spectral->hdr_sig_exp = SPECTRAL_PHYERR_SIGNATURE_GEN2; + spectral->tag_sscan_summary_exp = + TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2; + spectral->tag_sscan_fft_exp = TLV_TAG_SEARCH_FFT_REPORT_GEN2; + spectral->tlvhdr_size = sizeof(struct spectral_phyerr_tlv_gen2); } #else spectral->spectral_gen = SPECTRAL_GEN3; @@ -1700,16 +2044,14 @@ void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev) spectral->tag_sscan_fft_exp = TLV_TAG_SEARCH_FFT_REPORT_GEN3; spectral->tlvhdr_size = SPECTRAL_PHYERR_TLVSIZE_GEN3; #endif -#ifdef QCA_SUPPORT_SPECTRAL_SIMULATION - if (target_if_spectral_sim_attach(spectral)) { - qdf_mem_free(spectral); + + if (target_if_spectral_attach_simulation(spectral) < 0) return NULL; - } -#endif /* QCA_SUPPORT_SPECTRAL_SIMULATION */ + target_if_init_spectral_ops(spectral); - qdf_spinlock_create(&spectral->ol_info.osps_lock); - spectral->ol_info.osps_cache.osc_is_valid = 0; + qdf_spinlock_create(&spectral->param_info.osps_lock); + spectral->param_info.osps_cache.osc_is_valid = 0; target_if_spectral_register_funcs(spectral, &spectral_ops); @@ -1717,7 +2059,8 @@ void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev) target_if_spectral_detach(spectral); spectral = NULL; } else { - /* TODO: Once the driver architecture transitions to chipset + /* + * TODO: Once the driver architecture transitions to chipset * versioning based checks, reflect this here. */ spectral->is_160_format = false; @@ -1729,8 +2072,8 @@ void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev) spectral->is_160_format = true; spectral->is_lb_edge_extrabins_format = true; spectral->is_rb_edge_extrabins_format = true; - } else if ((scn->soc->target_type == TARGET_TYPE_AR900B) && - (scn->soc->target_revision == AR900B_REV_2)) { + } else if ((scn->soc->target_type == TARGET_TYPE_AR900B) && + (scn->soc->target_revision == AR900B_REV_2)) { spectral->is_rb_edge_extrabins_format = true; } @@ -1752,9 +2095,12 @@ void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev) * functionality for the given pdev * @pdev: Pointer to pdev object * + * Function to de-initialize pointer to spectral target_if internal private data + * * Return: None */ -void target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev) +void +target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev) { struct target_if_spectral *spectral = NULL; @@ -1776,21 +2122,21 @@ void target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev) * * API to set spectral configurations * - * Return: 1 on success, 0 on failure + * Return: 0 on success else failure */ -int target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev, - const u_int32_t threshtype, - const u_int32_t value) +int +target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev, + const uint32_t threshtype, const uint32_t value) { struct spectral_config params; struct target_if_spectral_ops *p_sops = NULL; struct target_if_spectral *spectral = NULL; spectral = get_target_if_spectral_handle_from_pdev(pdev); - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); if (!spectral) { qdf_print("%s: spectral object is NULL\n", __func__); - return 0; + return -EPERM; } switch (threshtype) { @@ -1859,45 +2205,67 @@ int target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev, p_sops->configure_spectral(spectral, &spectral->params); /* only to validate the writes */ p_sops->get_spectral_config(spectral, ¶ms); - /* print_spectral_params(&spectral->params); */ - return 1; + return 0; } -static int get_fft_bin_count(int fft_len) +/** + * target_if_get_fft_bin_count() - Get fft bin count for a given fft length + * @fft_len: FFT length + * @pdev: Pointer to pdev object + * + * API to get fft bin count for a given fft length + * + * Return: FFt bin count + */ +static int +target_if_get_fft_bin_count(int fft_len) { int bin_count = 0; switch (fft_len) { case 5: - bin_count = 16; - break; + bin_count = 16; + break; case 6: - bin_count = 32; - break; + bin_count = 32; + break; case 7: - bin_count = 64; - break; + bin_count = 64; + break; case 8: - bin_count = 128; - break; + bin_count = 128; + break; case 9: - bin_count = 256; - break; + bin_count = 256; + break; default: - break; + break; } return bin_count; } -static void init_upper_lower_flags(struct target_if_spectral *spectral) +/** + * target_if_init_upper_lower_flags() - Initializes control and extension + * segment flags + * @fft_len: FFT length + * @pdev: Pointer to pdev object + * + * API to initialize the control and extension flags with the lower/upper + * segment based on the HT mode + * + * Return: FFt bin count + */ +static void +target_if_init_upper_lower_flags(struct target_if_spectral *spectral) { int current_channel = 0; int ext_channel = 0; - struct target_if_spectral_ops *p_sops = GET_TIF_SPECTRAL_OPS(spectral); + struct target_if_spectral_ops *p_sops = + GET_TARGET_IF_SPECTRAL_OPS(spectral); current_channel = p_sops->get_current_channel(spectral); - ext_channel = p_sops->get_extension_channel(spectral); + ext_channel = p_sops->get_extension_channel(spectral); if ((current_channel == 0) || (ext_channel == 0)) return; @@ -1906,20 +2274,20 @@ static void init_upper_lower_flags(struct target_if_spectral *spectral) /* HT40 mode */ if (ext_channel < current_channel) { spectral->lower_is_extension = 1; - spectral->upper_is_control = 1; - spectral->lower_is_control = 0; + spectral->upper_is_control = 1; + spectral->lower_is_control = 0; spectral->upper_is_extension = 0; } else { spectral->lower_is_extension = 0; - spectral->upper_is_control = 0; - spectral->lower_is_control = 1; + spectral->upper_is_control = 0; + spectral->lower_is_control = 1; spectral->upper_is_extension = 1; } } else { /* HT20 mode, lower is always control */ spectral->lower_is_extension = 0; - spectral->upper_is_control = 0; - spectral->lower_is_control = 1; + spectral->upper_is_control = 0; + spectral->lower_is_control = 1; spectral->upper_is_extension = 0; } } @@ -1932,16 +2300,17 @@ static void init_upper_lower_flags(struct target_if_spectral *spectral) * * API to get the current spectral configuration * - * Return: 1 on success, 0 on failure. + * Return: None */ -void target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev, - struct spectral_config *param) +void +target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev, + struct spectral_config *param) { struct target_if_spectral_ops *p_sops = NULL; struct target_if_spectral *spectral = NULL; spectral = get_target_if_spectral_handle_from_pdev(pdev); - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); qdf_mem_zero(param, sizeof(struct spectral_config)); p_sops->get_spectral_config(spectral, param); @@ -1958,13 +2327,13 @@ void target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev, * * Return: 0 on success, 1 on failure */ -int target_if_spectral_scan_enable_params( - struct target_if_spectral *spectral, - struct spectral_config *spectral_params) +int +target_if_spectral_scan_enable_params(struct target_if_spectral *spectral, + struct spectral_config *spectral_params) { - int extension_channel = 0; - int current_channel = 0; - struct target_if_spectral_ops *p_sops = NULL; + int extension_channel = 0; + int current_channel = 0; + struct target_if_spectral_ops *p_sops = NULL; struct wlan_objmgr_vdev *vdev = NULL; if (!spectral) { @@ -1972,7 +2341,7 @@ int target_if_spectral_scan_enable_params( return 1; } - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); if (!p_sops) { qdf_print("SPECTRAL : p_sops is NULL\n"); @@ -1980,17 +2349,17 @@ int target_if_spectral_scan_enable_params( } spectral->sc_spectral_noise_pwr_cal = - spectral_params->ss_spectral_pri ? 1 : 0; + spectral_params->ss_spectral_pri ? 1 : 0; /* check if extension channel is present */ - extension_channel = p_sops->get_extension_channel(spectral); - current_channel = p_sops->get_current_channel(spectral); + extension_channel = p_sops->get_extension_channel(spectral); + current_channel = p_sops->get_current_channel(spectral); vdev = target_if_spectral_get_vdev(spectral); if (!vdev) return 1; - spectral->ch_width = target_if_vdev_get_ch_width(vdev); + spectral->ch_width = target_if_vdev_get_ch_width(vdev); wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID); if (spectral->ch_width == CH_WIDTH_INVALID) @@ -2011,150 +2380,155 @@ int target_if_spectral_scan_enable_params( } if (spectral->ch_width == CH_WIDTH_20MHZ) { - /* qdf_print("SPECTRAL : (11AC) 20MHz Channel Width - * (Channel = %d)\n", current_channel); - */ - spectral->sc_spectral_20_40_mode = 0; + spectral->sc_spectral_20_40_mode = 0; - spectral->spectral_numbins = - get_fft_bin_count(spectral->params.ss_fft_size); - spectral->spectral_fft_len = - get_fft_bin_count(spectral->params.ss_fft_size); + spectral->spectral_numbins = + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); + spectral->spectral_fft_len = + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); spectral->spectral_data_len = - get_fft_bin_count(spectral->params.ss_fft_size); - /* Initialize classifier params to be sent to user + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); + /* + * Initialize classifier params to be sent to user * space classifier */ spectral->classifier_params.lower_chan_in_mhz = - current_channel; + current_channel; spectral->classifier_params.upper_chan_in_mhz = 0; } else if (spectral->ch_width == CH_WIDTH_40MHZ) { - /* qdf_print("SPECTRAL : (11AC) 40MHz Channel Width - * (Channel = %d)\n", current_channel); - */ - spectral->sc_spectral_20_40_mode = - 1; /* TODO : Remove this variable */ - spectral->spectral_numbins = - get_fft_bin_count(spectral->params.ss_fft_size); - spectral->spectral_fft_len = - get_fft_bin_count(spectral->params.ss_fft_size); + /* TODO : Remove this variable */ + spectral->sc_spectral_20_40_mode = 1; + spectral->spectral_numbins = + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); + spectral->spectral_fft_len = + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); spectral->spectral_data_len = - get_fft_bin_count(spectral->params.ss_fft_size); + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); - /* Initialize classifier params to be sent to user + /* + * Initialize classifier params to be sent to user * space classifier */ if (extension_channel < current_channel) { spectral->classifier_params.lower_chan_in_mhz = - extension_channel; + extension_channel; spectral->classifier_params.upper_chan_in_mhz = - current_channel; + current_channel; } else { spectral->classifier_params.lower_chan_in_mhz = - current_channel; + current_channel; spectral->classifier_params.upper_chan_in_mhz = - extension_channel; + extension_channel; } } else if (spectral->ch_width == CH_WIDTH_80MHZ) { - /* qdf_print("SPECTRAL : (11AC) 80MHz Channel Width - * (Channel = %d)\n", current_channel); - */ /* Set the FFT Size */ - spectral->sc_spectral_20_40_mode = - 0; /* TODO : Remove this variable */ - spectral->spectral_numbins = - get_fft_bin_count(spectral->params.ss_fft_size); - spectral->spectral_fft_len = - get_fft_bin_count(spectral->params.ss_fft_size); + /* TODO : Remove this variable */ + spectral->sc_spectral_20_40_mode = 0; + spectral->spectral_numbins = + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); + spectral->spectral_fft_len = + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); spectral->spectral_data_len = - get_fft_bin_count(spectral->params.ss_fft_size); + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); - /* Initialize classifier params to be sent to user + /* + * Initialize classifier params to be sent to user * space classifier */ spectral->classifier_params.lower_chan_in_mhz = - current_channel; + current_channel; spectral->classifier_params.upper_chan_in_mhz = 0; - /* Initialize classifier params to be sent to user + /* + * Initialize classifier params to be sent to user * space classifier */ if (extension_channel < current_channel) { spectral->classifier_params.lower_chan_in_mhz = - extension_channel; + extension_channel; spectral->classifier_params.upper_chan_in_mhz = - current_channel; + current_channel; } else { spectral->classifier_params.lower_chan_in_mhz = - current_channel; + current_channel; spectral->classifier_params.upper_chan_in_mhz = - extension_channel; + extension_channel; } } else if (spectral->ch_width == CH_WIDTH_160MHZ) { - /* qdf_print("SPECTRAL : (11AC) 160MHz Channel Width - * (Channel = %d)\n", current_channel); - */ /* Set the FFT Size */ /* The below applies to both 160 and 80+80 cases */ - spectral->sc_spectral_20_40_mode = - 0; /* TODO : Remove this variable */ - spectral->spectral_numbins = - get_fft_bin_count(spectral->params.ss_fft_size); - spectral->spectral_fft_len = - get_fft_bin_count(spectral->params.ss_fft_size); + /* TODO : Remove this variable */ + spectral->sc_spectral_20_40_mode = 0; + spectral->spectral_numbins = + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); + spectral->spectral_fft_len = + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); spectral->spectral_data_len = - get_fft_bin_count(spectral->params.ss_fft_size); + target_if_get_fft_bin_count( + spectral->params.ss_fft_size); - /* Initialize classifier params to be sent to user + /* + * Initialize classifier params to be sent to user * space classifier */ spectral->classifier_params.lower_chan_in_mhz = - current_channel; + current_channel; spectral->classifier_params.upper_chan_in_mhz = 0; - /* Initialize classifier params to be sent to user + /* + * Initialize classifier params to be sent to user * space classifier */ if (extension_channel < current_channel) { spectral->classifier_params.lower_chan_in_mhz = - extension_channel; + extension_channel; spectral->classifier_params.upper_chan_in_mhz = - current_channel; + current_channel; } else { spectral->classifier_params.lower_chan_in_mhz = - current_channel; + current_channel; spectral->classifier_params.upper_chan_in_mhz = - extension_channel; + extension_channel; } } if (spectral->spectral_numbins) { spectral->spectral_numbins += - spectral->lb_edge_extrabins; + spectral->lb_edge_extrabins; spectral->spectral_numbins += - spectral->rb_edge_extrabins; + spectral->rb_edge_extrabins; } if (spectral->spectral_fft_len) { spectral->spectral_fft_len += - spectral->lb_edge_extrabins; + spectral->lb_edge_extrabins; spectral->spectral_fft_len += - spectral->rb_edge_extrabins; + spectral->rb_edge_extrabins; } if (spectral->spectral_data_len) { spectral->spectral_data_len += - spectral->lb_edge_extrabins; + spectral->lb_edge_extrabins; spectral->spectral_data_len += - spectral->rb_edge_extrabins; + spectral->rb_edge_extrabins; } } else { - /* qdf_print("SPECTRAL : Legacy (Non-11AC)\n"); */ /* * The decision to find 20/40 mode is found based on the * presence of extension channel @@ -2163,98 +2537,80 @@ int target_if_spectral_scan_enable_params( */ if (extension_channel == 0) { - /* qdf_print("SPECTRAL : (Legacy) 20MHz Channel Width - * (Channel = %d)\n", current_channel); - */ - spectral->spectral_numbins = - SPECTRAL_HT20_NUM_BINS; - spectral->spectral_dc_index = - SPECTRAL_HT20_DC_INDEX; - spectral->spectral_fft_len = - SPECTRAL_HT20_FFT_LEN; - spectral->spectral_data_len = - SPECTRAL_HT20_TOTAL_DATA_LEN; - spectral->spectral_lower_max_index_offset = - -1; /* only valid in 20-40 mode */ - spectral->spectral_upper_max_index_offset = - -1; /* only valid in 20-40 mode */ - spectral->spectral_max_index_offset = - spectral->spectral_fft_len + 2; - spectral->sc_spectral_20_40_mode = 0; + spectral->spectral_numbins = SPECTRAL_HT20_NUM_BINS; + spectral->spectral_dc_index = SPECTRAL_HT20_DC_INDEX; + spectral->spectral_fft_len = SPECTRAL_HT20_FFT_LEN; + spectral->spectral_data_len = + SPECTRAL_HT20_TOTAL_DATA_LEN; + /* only valid in 20-40 mode */ + spectral->spectral_lower_max_index_offset = -1; + /* only valid in 20-40 mode */ + spectral->spectral_upper_max_index_offset = -1; + spectral->spectral_max_index_offset = + spectral->spectral_fft_len + 2; + spectral->sc_spectral_20_40_mode = 0; - /* Initialize classifier params to be sent to user + /* + * Initialize classifier params to be sent to user * space classifier */ spectral->classifier_params.lower_chan_in_mhz = - current_channel; + current_channel; spectral->classifier_params.upper_chan_in_mhz = 0; } else { - /* qdf_print("SPECTRAL : (Legacy) 40MHz Channel Width - * (Channel = %d)\n", current_channel); - */ - spectral->spectral_numbins = - SPECTRAL_HT40_TOTAL_NUM_BINS; - spectral->spectral_fft_len = - SPECTRAL_HT40_FFT_LEN; - spectral->spectral_data_len = - SPECTRAL_HT40_TOTAL_DATA_LEN; - spectral->spectral_dc_index = - SPECTRAL_HT40_DC_INDEX; - spectral->spectral_max_index_offset = - -1; /* only valid in 20 mode */ - spectral->spectral_lower_max_index_offset = - spectral->spectral_fft_len + 2; - spectral->spectral_upper_max_index_offset = - spectral->spectral_fft_len + 5; - spectral->sc_spectral_20_40_mode = 1; + spectral->spectral_numbins = + SPECTRAL_HT40_TOTAL_NUM_BINS; + spectral->spectral_fft_len = SPECTRAL_HT40_FFT_LEN; + spectral->spectral_data_len = + SPECTRAL_HT40_TOTAL_DATA_LEN; + spectral->spectral_dc_index = SPECTRAL_HT40_DC_INDEX; + /* only valid in 20 mode */ + spectral->spectral_max_index_offset = -1; + spectral->spectral_lower_max_index_offset = + spectral->spectral_fft_len + 2; + spectral->spectral_upper_max_index_offset = + spectral->spectral_fft_len + 5; + spectral->sc_spectral_20_40_mode = 1; - /* Initialize classifier params to be sent to user + /* + * Initialize classifier params to be sent to user * space classifier */ if (extension_channel < current_channel) { spectral->classifier_params.lower_chan_in_mhz = - extension_channel; + extension_channel; spectral->classifier_params.upper_chan_in_mhz = - current_channel; + current_channel; } else { spectral->classifier_params.lower_chan_in_mhz = - current_channel; + current_channel; spectral->classifier_params.upper_chan_in_mhz = - extension_channel; + extension_channel; } } } - spectral->send_single_packet = 0; + spectral->send_single_packet = 0; spectral->classifier_params.spectral_20_40_mode = - spectral->sc_spectral_20_40_mode; - spectral->classifier_params.spectral_dc_index = - spectral->spectral_dc_index; - spectral->spectral_sent_msg = 0; - spectral->classify_scan = 0; - spectral->num_spectral_data = 0; + spectral->sc_spectral_20_40_mode; + spectral->classifier_params.spectral_dc_index = + spectral->spectral_dc_index; + spectral->spectral_sent_msg = 0; + spectral->classify_scan = 0; + spectral->num_spectral_data = 0; if (!p_sops->is_spectral_active(spectral)) { p_sops->configure_spectral(spectral, spectral_params); p_sops->start_spectral_scan(spectral); - /* qdf_print("Enabled spectral scan on channel %d\n", - * p_sops->get_current_channel(spectral)); - */ } else { - /* qdf_print("Spectral scan is already ACTIVE on channel %d\n", - * p_sops->get_current_channel(spectral)); - */ } /* get current spectral configuration */ p_sops->get_spectral_config(spectral, &spectral->params); - init_upper_lower_flags(spectral); + target_if_init_upper_lower_flags(spectral); -#ifdef SPECTRAL_CLASSIFIER_IN_KERNEL - init_classifier(sc); -#endif return 0; } @@ -2266,7 +2622,8 @@ int target_if_spectral_scan_enable_params( * * Return: 0 in case of success, -1 on failure */ -int target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev) +int +target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev) { struct target_if_spectral_ops *p_sops = NULL; struct target_if_spectral *spectral = NULL; @@ -2277,24 +2634,17 @@ int target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev) __func__); return -EPERM; } - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); - qdf_spin_lock(&spectral->ath_spectral_lock); + qdf_spin_lock(&spectral->spectral_lock); target_if_spectral_scan_enable_params(spectral, &spectral->params); - qdf_spin_unlock(&spectral->ath_spectral_lock); + qdf_spin_unlock(&spectral->spectral_lock); return 0; } -/** - * target_if_stop_spectral_scan() - Stop spectral scan - * @pdev: Pointer to pdev object - * - * API to stop the current on-going spectral scan - * - * Return: None - */ -void target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev) +void +target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev) { struct target_if_spectral_ops *p_sops = NULL; struct target_if_spectral *spectral = NULL; @@ -2305,21 +2655,21 @@ void target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev) __func__); return; } - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); - qdf_spin_lock(&spectral->ath_spectral_lock); + qdf_spin_lock(&spectral->spectral_lock); p_sops->stop_spectral_scan(spectral); if (spectral->classify_scan) { SPECTRAL_TODO("Check if this logic is necessary"); - spectral->detects_control_channel = 0; + spectral->detects_control_channel = 0; spectral->detects_extension_channel = 0; - spectral->detects_above_dc = 0; - spectral->detects_below_dc = 0; - spectral->classify_scan = 0; + spectral->detects_above_dc = 0; + spectral->detects_below_dc = 0; + spectral->classify_scan = 0; } - spectral->send_single_packet = 0; - spectral->sc_spectral_scan = 0; + spectral->send_single_packet = 0; + spectral->sc_spectral_scan = 0; spectral->sc_spectral_noise_pwr_cal = 0; /* @@ -2328,23 +2678,26 @@ void target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev) * */ /* Reset Priority */ - spectral->params.ss_spectral_pri = 0; - qdf_spin_unlock(&spectral->ath_spectral_lock); + spectral->params.ss_spectral_pri = 0; + qdf_spin_unlock(&spectral->spectral_lock); } /** * target_if_is_spectral_active() - Get whether Spectral is active * @pdev: Pointer to pdev object * + * API to get whether Spectral is active + * * Return: True if Spectral is active, false if Spectral is not active */ -bool target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev) +bool +target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev) { struct target_if_spectral *spectral = NULL; struct target_if_spectral_ops *p_sops = NULL; spectral = get_target_if_spectral_handle_from_pdev(pdev); - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); return p_sops->is_spectral_active(spectral); } @@ -2352,15 +2705,18 @@ bool target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev) * target_if_is_spectral_enabled() - Get whether Spectral is enabled * @pdev: Pointer to pdev object * + * API to get whether Spectral is enabled + * * Return: True if Spectral is enabled, false if Spectral is not enabled */ -bool target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev) +bool +target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev) { struct target_if_spectral *spectral = NULL; struct target_if_spectral_ops *p_sops = NULL; spectral = get_target_if_spectral_handle_from_pdev(pdev); - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); return p_sops->is_spectral_enabled(spectral); } @@ -2369,12 +2725,14 @@ bool target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev) * @pdev: Pointer to pdev object * @debug_level: Debug level * + * API to set the debug level for Spectral + * * Return: 0 in case of success */ -int target_if_set_debug_level(struct wlan_objmgr_pdev *pdev, - u_int32_t debug_level) +int +target_if_set_debug_level(struct wlan_objmgr_pdev *pdev, uint32_t debug_level) { - spectral_debug_level = (ATH_DEBUG_SPECTRAL << debug_level); + spectral_debug_level = (DEBUG_SPECTRAL << debug_level); return 0; } @@ -2382,9 +2740,12 @@ int target_if_set_debug_level(struct wlan_objmgr_pdev *pdev, * target_if_get_debug_level() - Get debug level for Spectral * @pdev: Pointer to pdev object * + * API to get the debug level for Spectral + * * Return: Current debug level */ -u_int32_t target_if_get_debug_level(struct wlan_objmgr_pdev *pdev) +uint32_t +target_if_get_debug_level(struct wlan_objmgr_pdev *pdev) { return spectral_debug_level; } @@ -2394,11 +2755,12 @@ u_int32_t target_if_get_debug_level(struct wlan_objmgr_pdev *pdev) * @pdev: Pointer to pdev object * @outdata: Buffer into which data should be copied * + * API to get the spectral capability information + * * Return: void */ -void target_if_get_spectral_capinfo( - struct wlan_objmgr_pdev *pdev, - void *outdata) +void +target_if_get_spectral_capinfo(struct wlan_objmgr_pdev *pdev, void *outdata) { struct target_if_spectral *spectral = NULL; @@ -2412,10 +2774,12 @@ void target_if_get_spectral_capinfo( * @pdev: Pointer to pdev object * @outdata: Buffer into which data should be copied * + * API to get the spectral diagnostic statistics + * * Return: void */ -void target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, - void *outdata) +void +target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, void *outdata) { struct target_if_spectral *spectral = NULL; @@ -2424,83 +2788,79 @@ void target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, sizeof(struct spectral_diag_stats)); } -void target_if_register_wmi_spectral_cmd_ops( - struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops) +/** + * target_if_register_wmi_spectral_cmd_ops() - Register wmi_spectral_cmd_ops + * @cmd_ops: Pointer to the structure having wmi_spectral_cmd function pointers + * @pdev: Pointer to pdev object + * + * API for register wmi_spectral_cmd_ops in spectral internal data structure + * + * Return: void + */ +void +target_if_register_wmi_spectral_cmd_ops(struct wlan_objmgr_pdev *pdev, + struct wmi_spectral_cmd_ops *cmd_ops) { struct target_if_spectral *spectral = NULL; spectral = get_target_if_spectral_handle_from_pdev(pdev); spectral->param_wmi_cmd_ops.wmi_spectral_configure_cmd_send = - cmd_ops->wmi_spectral_configure_cmd_send; + cmd_ops->wmi_spectral_configure_cmd_send; spectral->param_wmi_cmd_ops.wmi_spectral_enable_cmd_send = - cmd_ops->wmi_spectral_enable_cmd_send; + cmd_ops->wmi_spectral_enable_cmd_send; } -/** - * target_if_sptrl_register_tx_ops() - Register Spectral target_if Tx Ops - * @tx_ops: Tx Ops - * - * Return: void - */ -void target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) +void +target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) { - tx_ops->sptrl_tx_ops.sptrlto_pdev_spectral_init = - target_if_pdev_spectral_init; - tx_ops->sptrl_tx_ops.sptrlto_pdev_spectral_deinit = - target_if_pdev_spectral_deinit; - tx_ops->sptrl_tx_ops.sptrlto_set_spectral_config = - target_if_set_spectral_config; - tx_ops->sptrl_tx_ops.sptrlto_get_spectral_config = - target_if_get_spectral_config; - tx_ops->sptrl_tx_ops.sptrlto_start_spectral_scan = - target_if_start_spectral_scan; - tx_ops->sptrl_tx_ops.sptrlto_stop_spectral_scan = - target_if_stop_spectral_scan; - tx_ops->sptrl_tx_ops.sptrlto_is_spectral_active = - target_if_is_spectral_active; - tx_ops->sptrl_tx_ops.sptrlto_is_spectral_enabled = - target_if_is_spectral_enabled; - tx_ops->sptrl_tx_ops.sptrlto_set_debug_level = - target_if_set_debug_level; - tx_ops->sptrl_tx_ops.sptrlto_get_debug_level = - target_if_get_debug_level; - tx_ops->sptrl_tx_ops.sptrlto_get_spectral_capinfo = - target_if_get_spectral_capinfo; + tx_ops->sptrl_tx_ops.sptrlto_pdev_spectral_init = + target_if_pdev_spectral_init; + tx_ops->sptrl_tx_ops.sptrlto_pdev_spectral_deinit = + target_if_pdev_spectral_deinit; + tx_ops->sptrl_tx_ops.sptrlto_set_spectral_config = + target_if_set_spectral_config; + tx_ops->sptrl_tx_ops.sptrlto_get_spectral_config = + target_if_get_spectral_config; + tx_ops->sptrl_tx_ops.sptrlto_start_spectral_scan = + target_if_start_spectral_scan; + tx_ops->sptrl_tx_ops.sptrlto_stop_spectral_scan = + target_if_stop_spectral_scan; + tx_ops->sptrl_tx_ops.sptrlto_is_spectral_active = + target_if_is_spectral_active; + tx_ops->sptrl_tx_ops.sptrlto_is_spectral_enabled = + target_if_is_spectral_enabled; + tx_ops->sptrl_tx_ops.sptrlto_set_debug_level = + target_if_set_debug_level; + tx_ops->sptrl_tx_ops.sptrlto_get_debug_level = + target_if_get_debug_level; + tx_ops->sptrl_tx_ops.sptrlto_get_spectral_capinfo = + target_if_get_spectral_capinfo; tx_ops->sptrl_tx_ops.sptrlto_get_spectral_diagstats = - target_if_get_spectral_diagstats; + target_if_get_spectral_diagstats; tx_ops->sptrl_tx_ops.sptrlto_register_wmi_spectral_cmd_ops = - target_if_register_wmi_spectral_cmd_ops; + target_if_register_wmi_spectral_cmd_ops; } EXPORT_SYMBOL(target_if_sptrl_register_tx_ops); -/** - * target_if_spectral_send_intf_found_msg() - Send message to application layer - * indicating that interference has been found - * @pdev: Pointer to pdev - * @cw_int: 1 if CW interference is found, 0 if WLAN interference is found - * @dcs_enabled: 1 if DCS is enabled, 0 if DCS is disabled - * - * Return: None - */ -void target_if_spectral_send_intf_found_msg( - struct wlan_objmgr_pdev *pdev, - u_int16_t cw_int, u_int32_t dcs_enabled) +void +target_if_spectral_send_intf_found_msg(struct wlan_objmgr_pdev *pdev, + uint16_t cw_int, uint32_t dcs_enabled) { #ifdef SPECTRAL_USE_NETLINK_SOCKETS - SPECTRAL_SAMP_MSG *msg = NULL; - struct target_if_spectral_ops *p_sops = NULL; + struct spectral_samp_msg *msg = NULL; + struct target_if_spectral_ops *p_sops = NULL; struct target_if_spectral *spectral = NULL; spectral = get_target_if_spectral_handle_from_pdev(pdev); - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); target_if_spectral_prep_skb(spectral); if (spectral->spectral_skb) { spectral->spectral_nlh = - (struct nlmsghdr *)spectral->spectral_skb->data; - msg = (SPECTRAL_SAMP_MSG *)NLMSG_DATA(spectral->spectral_nlh); + (struct nlmsghdr *)spectral->spectral_skb->data; + msg = (struct spectral_samp_msg *)NLMSG_DATA( + spectral->spectral_nlh); msg->int_type = cw_int ? - SPECTRAL_DCS_INT_CW : SPECTRAL_DCS_INT_WIFI; + SPECTRAL_DCS_INT_CW : SPECTRAL_DCS_INT_WIFI; msg->dcs_enabled = dcs_enabled; msg->signature = SPECTRAL_SIGNATURE; p_sops->get_mac_address(spectral, msg->macaddr); @@ -2509,4 +2869,3 @@ void target_if_spectral_send_intf_found_msg( #endif } EXPORT_SYMBOL(target_if_spectral_send_intf_found_msg); - diff --git a/target_if/spectral/target_if_spectral.h b/target_if/spectral/target_if_spectral.h index 618130d040..7ac386102b 100644 --- a/target_if/spectral/target_if_spectral.h +++ b/target_if/spectral/target_if_spectral.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011,2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2011,2017-2018 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -78,7 +78,8 @@ QDF_PRINT_INFO(QDF_PRINT_IDX_SHARED, QDF_MODULE_ID_SPECTRAL, level, ## args) #define SPECTRAL_HT40_FFT_LEN 128 #define SPECTRAL_HT40_DC_INDEX (SPECTRAL_HT40_FFT_LEN / 2) -/* Used for the SWAR to obtain approximate combined rssi +/* + * Used for the SWAR to obtain approximate combined rssi * in secondary 80Mhz segment */ #define OFFSET_CH_WIDTH_20 65 @@ -87,23 +88,23 @@ QDF_PRINT_INFO(QDF_PRINT_IDX_SHARED, QDF_MODULE_ID_SPECTRAL, level, ## args) #define OFFSET_CH_WIDTH_160 50 #ifdef BIG_ENDIAN_HOST -#define SPECTRAL_MSG_COPY_CHAR_ARRAY(destp, srcp, len) do { \ +#define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) do { \ int j; \ - u_int32_t *src, *dest; \ - src = (u_int32_t *)(srcp); \ - dest = (u_int32_t *)(destp); \ - for (j = 0; j < roundup((len), sizeof(u_int32_t)) / 4; j++) { \ + uint32_t *src, *dest; \ + src = (uint32_t *)(srcp); \ + dest = (uint32_t *)(destp); \ + for (j = 0; j < roundup((len), sizeof(uint32_t)) / 4; j++) { \ *(dest + j) = qdf_le32_to_cpu(*(src + j)); \ } \ } while (0) #else -#define SPECTRAL_MSG_COPY_CHAR_ARRAY(destp, srcp, len) \ +#define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) \ OS_MEMCPY((destp), (srcp), (len)); #endif /* 5 categories x (lower + upper) bands */ #define MAX_INTERF 10 -#define ATH_HOST_MAX_ANTENNA 3 +#define HOST_MAX_ANTENNA 3 /* Mask for time stamp from descriptor */ #define SPECTRAL_TSMASK 0xFFFFFFFF #define SPECTRAL_SIGNATURE 0xdeadbeef @@ -129,7 +130,7 @@ QDF_PRINT_INFO(QDF_PRINT_IDX_SHARED, QDF_MODULE_ID_SPECTRAL, level, ## args) * @peak_mag: Peak power seen in the bins * @peak_inx: Index of bin holding peak power */ -typedef struct spectral_search_fft_info_gen2 { +struct spectral_search_fft_info_gen2 { uint32_t relpwr_db; uint32_t num_str_bins_ib; uint32_t base_pwr; @@ -138,9 +139,10 @@ typedef struct spectral_search_fft_info_gen2 { uint32_t avgpwr_db; uint32_t peak_mag; int16_t peak_inx; -} SPECTRAL_SEARCH_FFT_INFO_GEN2; +}; -/* XXX Check if we should be handling the endinness difference in some +/* + * XXX Check if we should be handling the endinness difference in some * other way opaque to the host */ #ifdef BIG_ENDIAN_HOST @@ -151,11 +153,11 @@ typedef struct spectral_search_fft_info_gen2 { * @tag: tag * @length: length */ -typedef struct spectral_phyerr_tlv_gen2 { - u_int8_t signature; - u_int8_t tag; - u_int16_t length; -} __ATTRIB_PACK SPECTRAL_PHYERR_TLV_GEN2; +struct spectral_phyerr_tlv_gen2 { + uint8_t signature; + uint8_t tag; + uint16_t length; +} __ATTRIB_PACK; #else @@ -165,11 +167,11 @@ typedef struct spectral_phyerr_tlv_gen2 { * @tag: tag * @signature: signature */ -typedef struct spectral_phyerr_tlv_gen2 { - u_int16_t length; - u_int8_t tag; - u_int8_t signature; -} __ATTRIB_PACK SPECTRAL_PHYERR_TLV_GEN2; +struct spectral_phyerr_tlv_gen2 { + uint16_t length; + uint8_t tag; + uint8_t signature; +} __ATTRIB_PACK; #endif /* BIG_ENDIAN_HOST */ @@ -178,12 +180,13 @@ typedef struct spectral_phyerr_tlv_gen2 { * @hdr_a: Header[0:31] * @hdr_b: Header[32:63] */ -typedef struct spectral_phyerr_hdr_gen2 { - u_int32_t hdr_a; - u_int32_t hdr_b; -} SPECTRAL_PHYERR_HDR_GEN2; +struct spectral_phyerr_hdr_gen2 { + uint32_t hdr_a; + uint32_t hdr_b; +}; -/* Segment ID information for 80+80. +/* + * Segment ID information for 80+80. * * If the HW micro-architecture specification extends this DWORD for other * purposes, then redefine+rename accordingly. For now, the specification @@ -191,15 +194,15 @@ typedef struct spectral_phyerr_hdr_gen2 { * without mention of any generic terminology for the DWORD, or any reservation. * We use nomenclature accordingly. */ -typedef u_int32_t SPECTRAL_SEGID_INFO; +typedef uint32_t SPECTRAL_SEGID_INFO; /** * struct spectral_phyerr_fft_gen2 - fft info in phyerr event * @buf: fft report */ -typedef struct spectral_phyerr_fft_gen2 { - u_int8_t buf[0]; -} SPECTRAL_PHYERR_FFT_GEN2; +struct spectral_phyerr_fft_gen2 { + uint8_t buf[0]; +}; /* END of spectral GEN II HW specific details */ /* START of spectral GEN III HW specific details */ @@ -232,11 +235,11 @@ typedef struct spectral_phyerr_fft_gen2 { * @acs_stats: acs stats */ struct phyerr_info { - u_int8_t *data; - u_int32_t datalen; + uint8_t *data; + uint32_t datalen; struct target_if_spectral_rfqual_info *p_rfqual; struct target_if_spectral_chan_info *p_chaninfo; - u_int64_t tsf64; + uint64_t tsf64; struct target_if_spectral_acs_stats *acs_stats; }; @@ -283,21 +286,21 @@ struct spectral_search_fft_info_gen3 { * @buf: fft bins */ struct spectral_phyerr_fft_report_gen3 { - u_int32_t fft_timestamp; + uint32_t fft_timestamp; #ifdef BIG_ENDIAN_HOST - u_int8_t fft_hdr_sig; - u_int8_t fft_hdr_tag; - u_int16_t fft_hdr_length; + uint8_t fft_hdr_sig; + uint8_t fft_hdr_tag; + uint16_t fft_hdr_length; #else - u_int16_t fft_hdr_length; - u_int8_t fft_hdr_tag; - u_int8_t fft_hdr_sig; + uint16_t fft_hdr_length; + uint8_t fft_hdr_tag; + uint8_t fft_hdr_sig; #endif /* BIG_ENDIAN_HOST */ - u_int32_t hdr_a; - u_int32_t hdr_b; - u_int32_t hdr_c; - u_int32_t resv; - u_int8_t buf[0]; + uint32_t hdr_a; + uint32_t hdr_b; + uint32_t hdr_c; + uint32_t resv; + uint8_t buf[0]; } __ATTRIB_PACK; /* END of spectral GEN III HW specific details */ @@ -318,17 +321,17 @@ enum spectral_gen { #if ATH_PERF_PWR_OFFLOAD /** - * enum ol_spectral_info_spec - Enumerations for specifying which spectral + * enum target_if_spectral_info - Enumerations for specifying which spectral * information (among parameters and states) * is desired. - * @OL_SPECTRAL_INFO_SPEC_ACTIVE: Indicated whether spectral is active - * @OL_SPECTRAL_INFO_SPEC_ENABLED: Indicated whether spectral is enabled - * @OL_SPECTRAL_INFO_SPEC_PARAMS: Config params + * @TARGET_IF_SPECTRAL_INFO_ACTIVE: Indicated whether spectral is active + * @TARGET_IF_SPECTRAL_INFO_ENABLED: Indicated whether spectral is enabled + * @TARGET_IF_SPECTRAL_INFO_PARAMS: Config params */ -enum ol_spectral_info_spec { - OL_SPECTRAL_INFO_SPEC_ACTIVE, - OL_SPECTRAL_INFO_SPEC_ENABLED, - OL_SPECTRAL_INFO_SPEC_PARAMS, +enum target_if_spectral_info { + TARGET_IF_SPECTRAL_INFO_ACTIVE, + TARGET_IF_SPECTRAL_INFO_ENABLED, + TARGET_IF_SPECTRAL_INFO_PARAMS, }; #endif /* ATH_PERF_PWR_OFFLOAD */ @@ -343,9 +346,9 @@ struct target_if_spectral; * @chan_width: channel width in MHz */ struct target_if_spectral_chan_info { - u_int16_t center_freq1; - u_int16_t center_freq2; - u_int8_t chan_width; + uint16_t center_freq1; + uint16_t center_freq2; + uint8_t chan_width; }; /** @@ -390,7 +393,7 @@ struct target_if_spectral_rfqual_info { int16_t noise_floor[4]; }; -#define GET_TIF_SPECTRAL_OPS(spectral) \ +#define GET_TARGET_IF_SPECTRAL_OPS(spectral) \ ((struct target_if_spectral_ops *)(&((spectral)->spectral_ops))) /** @@ -416,33 +419,34 @@ struct target_if_spectral_rfqual_info { * @spectral_process_phyerr: Process phyerr event */ struct target_if_spectral_ops { - u_int64_t (*get_tsf64)(void *arg); - u_int32_t (*get_capability)(void *arg, SPECTRAL_CAPABILITY_TYPE type); - u_int32_t (*set_rxfilter)(void *arg, int rxfilter); - u_int32_t (*get_rxfilter)(void *arg); - u_int32_t (*is_spectral_active)(void *arg); - u_int32_t (*is_spectral_enabled)(void *arg); - u_int32_t (*start_spectral_scan)(void *arg); - u_int32_t (*stop_spectral_scan)(void *arg); - u_int32_t (*get_extension_channel)(void *arg); + uint64_t (*get_tsf64)(void *arg); + uint32_t (*get_capability)( + void *arg, enum spectral_capability_type type); + uint32_t (*set_rxfilter)(void *arg, int rxfilter); + uint32_t (*get_rxfilter)(void *arg); + uint32_t (*is_spectral_active)(void *arg); + uint32_t (*is_spectral_enabled)(void *arg); + uint32_t (*start_spectral_scan)(void *arg); + uint32_t (*stop_spectral_scan)(void *arg); + uint32_t (*get_extension_channel)(void *arg); int8_t (*get_ctl_noisefloor)(void *arg); int8_t (*get_ext_noisefloor)(void *arg); - u_int32_t (*configure_spectral)( + uint32_t (*configure_spectral)( void *arg, struct spectral_config *params); - u_int32_t (*get_spectral_config)( + uint32_t (*get_spectral_config)( void *arg, struct spectral_config *params); - u_int32_t (*get_ent_spectral_mask)(void *arg); - u_int32_t (*get_mac_address)(void *arg, char *addr); - u_int32_t (*get_current_channel)(void *arg); - u_int32_t (*reset_hw)(void *arg); - u_int32_t (*get_chain_noise_floor)(void *arg, int16_t *nf_buf); + uint32_t (*get_ent_spectral_mask)(void *arg); + uint32_t (*get_mac_address)(void *arg, char *addr); + uint32_t (*get_current_channel)(void *arg); + uint32_t (*reset_hw)(void *arg); + uint32_t (*get_chain_noise_floor)(void *arg, int16_t *nf_buf); int (*spectral_process_phyerr)(struct target_if_spectral *spectral, - u_int8_t *data, u_int32_t datalen, + uint8_t *data, uint32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual, struct target_if_spectral_chan_info *p_chaninfo, - u_int64_t tsf64, + uint64_t tsf64, struct target_if_spectral_acs_stats *acs_stats); }; @@ -461,17 +465,17 @@ struct target_if_spectral_ops { * @last_reset_tstamp: Last reset time stamp */ struct target_if_spectral_stats { - u_int32_t num_spectral_detects; - u_int32_t total_phy_errors; - u_int32_t owl_phy_errors; - u_int32_t pri_phy_errors; - u_int32_t ext_phy_errors; - u_int32_t dc_phy_errors; - u_int32_t early_ext_phy_errors; - u_int32_t bwinfo_errors; - u_int32_t datalen_discards; - u_int32_t rssi_discards; - u_int64_t last_reset_tstamp; + uint32_t num_spectral_detects; + uint32_t total_phy_errors; + uint32_t owl_phy_errors; + uint32_t pri_phy_errors; + uint32_t ext_phy_errors; + uint32_t dc_phy_errors; + uint32_t early_ext_phy_errors; + uint32_t bwinfo_errors; + uint32_t datalen_discards; + uint32_t rssi_discards; + uint64_t last_reset_tstamp; }; /** @@ -485,12 +489,12 @@ struct target_if_spectral_stats { * @se_list: List of spectral events */ struct target_if_spectral_event { - u_int32_t se_ts; - u_int64_t se_full_ts; - u_int8_t se_rssi; - u_int8_t se_bwinfo; - u_int8_t se_dur; - u_int8_t se_chanindex; + uint32_t se_ts; + uint64_t se_full_ts; + uint8_t se_rssi; + uint8_t se_bwinfo; + uint8_t se_dur; + uint8_t se_chanindex; STAILQ_ENTRY(spectral_event) se_list; }; @@ -527,21 +531,13 @@ struct target_if_spectral_chan_stats { int channel_load; int per; int noisefloor; - u_int16_t comp_usablity; + uint16_t comp_usablity; int8_t maxregpower; - u_int16_t comp_usablity_sec80; + uint16_t comp_usablity_sec80; int8_t maxregpower_sec80; }; #if ATH_PERF_PWR_OFFLOAD -/* Locking operations - * We have a separate set of definitions for offload to accommodate - * offload specific changes in the future. - */ -#define OL_SPECTRAL_LOCK_INIT(_lock) qdf_spinlock_create((_lock)) -#define OL_SPECTRAL_LOCK_DESTROY(_lock) qdf_spinlock_destroy((_lock)) -#define OL_SPECTRAL_LOCK(_lock) qdf_spin_lock((_lock)) -#define OL_SPECTRAL_UNLOCK(_lock) qdf_spin_unlock((_lock)) /** * struct target_if_spectral_cache - Cache used to minimize WMI operations @@ -558,10 +554,10 @@ struct target_if_spectral_chan_stats { * @osc_is_valid: Whether the cache is valid */ struct target_if_spectral_cache { - u_int8_t osc_spectral_enabled; - u_int8_t osc_spectral_active; + uint8_t osc_spectral_enabled; + uint8_t osc_spectral_active; struct spectral_config osc_params; - u_int8_t osc_is_valid; + uint8_t osc_is_valid; }; /** @@ -580,12 +576,13 @@ struct target_if_spectral_param_state_info { struct vdev_spectral_configure_params; struct vdev_spectral_enable_params; + /** -* struct wmi_spectral_cmd_ops - structure used holding the operations -* related to wmi commands on spectral parameters. -* @wmi_spectral_configure_cmd_send: -* @wmi_spectral_enable_cmd_send: -*/ + * struct wmi_spectral_cmd_ops - structure used holding the operations + * related to wmi commands on spectral parameters. + * @wmi_spectral_configure_cmd_send: + * @wmi_spectral_enable_cmd_send: + */ struct wmi_spectral_cmd_ops { QDF_STATUS (*wmi_spectral_configure_cmd_send)( void *wmi_hdl, @@ -600,13 +597,13 @@ struct wmi_spectral_cmd_ops { * @pdev: Pointer to pdev * @spectral_ops: Target if internal Spectral low level operations table * @capability: Spectral capabilities structure - * @ath_spectral_lock: Lock used for internal Spectral operations + * @spectral_lock: Lock used for internal Spectral operations * @spectral_curchan_radindex: Current channel spectral index * @spectral_extchan_radindex: Extension channel spectral index * @spectraldomain: Current Spectral domain * @spectral_proc_phyerr: Flags to process for PHY errors * @spectral_defaultparams: Default PHY params per Spectral stat - * @ath_spectral_stats: Spectral related stats + * @spectral_stats: Spectral related stats * @events: Events structure * @sc_spectral_ext_chan_ok: Can spectral be detected on the extension channel? * @sc_spectral_combined_rssi_ok: Can use combined spectral RSSI? @@ -654,7 +651,7 @@ struct wmi_spectral_cmd_ops { * @noise_pwr_chain_ext: Noise power report - extension channel * @chaninfo: Channel statistics * @tsf64: Latest TSF Value - * @ol_info: Offload architecture Spectral parameter cache information + * @param_info: Offload architecture Spectral parameter cache information * @ch_width: Indicates Channel Width 20/40/80/160 MHz with values 0, 1, 2, 3 * respectively * @diag_stats: Diagnostic statistics @@ -681,13 +678,13 @@ struct target_if_spectral { struct wlan_objmgr_pdev *pdev_obj; struct target_if_spectral_ops spectral_ops; struct spectral_caps capability; - qdf_spinlock_t ath_spectral_lock; + qdf_spinlock_t spectral_lock; int16_t spectral_curchan_radindex; int16_t spectral_extchan_radindex; - u_int32_t spectraldomain; - u_int32_t spectral_proc_phyerr; + uint32_t spectraldomain; + uint32_t spectral_proc_phyerr; struct spectral_config spectral_defaultparams; - struct target_if_spectral_stats ath_spectral_stats; + struct target_if_spectral_stats spectral_stats; struct target_if_spectral_event *events; unsigned int sc_spectral_ext_chan_ok:1, sc_spectral_combined_rssi_ok:1, @@ -698,11 +695,11 @@ struct target_if_spectral { int upper_is_extension; int lower_is_control; int lower_is_extension; - u_int8_t sc_spectraltest_ieeechan; + uint8_t sc_spectraltest_ieeechan; struct sock *spectral_sock; struct sk_buff *spectral_skb; struct nlmsghdr *spectral_nlh; - u_int32_t spectral_pid; + uint32_t spectral_pid; STAILQ_HEAD(, target_if_spectral_skb_event) spectral_skbq; qdf_spinlock_t spectral_skbqlock; @@ -710,7 +707,8 @@ struct target_if_spectral { int spectral_fft_len; int spectral_data_len; - /* For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are + /* + * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are * delivered. However, there can be additional bins reported for * AR900B version 2.0 and QCA9984 as described next: * @@ -748,23 +746,23 @@ struct target_if_spectral { int sc_scanning; int sc_spectral_scan; int sc_spectral_full_scan; - u_int64_t scan_start_tstamp; - u_int32_t last_tstamp; - u_int32_t first_tstamp; - u_int32_t spectral_samp_count; - u_int32_t sc_spectral_samp_count; + uint64_t scan_start_tstamp; + uint32_t last_tstamp; + uint32_t first_tstamp; + uint32_t spectral_samp_count; + uint32_t sc_spectral_samp_count; int noise_pwr_reports_reqd; int noise_pwr_reports_recv; qdf_spinlock_t noise_pwr_reports_lock; struct target_if_chain_noise_pwr_info - *noise_pwr_chain_ctl[ATH_HOST_MAX_ANTENNA]; + *noise_pwr_chain_ctl[HOST_MAX_ANTENNA]; struct target_if_chain_noise_pwr_info - *noise_pwr_chain_ext[ATH_HOST_MAX_ANTENNA]; - u_int64_t tsf64; + *noise_pwr_chain_ext[HOST_MAX_ANTENNA]; + uint64_t tsf64; #if ATH_PERF_PWR_OFFLOAD - struct target_if_spectral_param_state_info ol_info; + struct target_if_spectral_param_state_info param_info; #endif - u_int32_t ch_width; + uint32_t ch_width; struct spectral_diag_stats diag_stats; bool is_160_format; bool is_lb_edge_extrabins_format; @@ -774,10 +772,10 @@ struct target_if_spectral { void *simctx; #endif enum spectral_gen spectral_gen; - u_int8_t hdr_sig_exp; - u_int8_t tag_sscan_summary_exp; - u_int8_t tag_sscan_fft_exp; - u_int8_t tlvhdr_size; + uint8_t hdr_sig_exp; + uint8_t tag_sscan_summary_exp; + uint8_t tag_sscan_fft_exp; + uint8_t tlvhdr_size; struct wmi_spectral_cmd_ops param_wmi_cmd_ops; }; @@ -795,14 +793,51 @@ struct target_if_spectral_skb_event { STAILQ_ENTRY(target_if_spectral_skb_event) spectral_skb_list; }; -/* TODO:COMMENTS */ +/** + * struct target_if_samp_msg_params - Spectral Analysis Messaging Protocol + * data format + * @rssi: RSSI (except for secondary 80 segment) + * @rssi_sec80: RSSI for secondary 80 segment + * @lower_rssi: RSSI of lower band + * @upper_rssi: RSSI of upper band + * @chain_ctl_rssi: RSSI for control channel, for all antennas + * @chain_ext_rssi: RSSI for extension channel, for all antennas + * @bwinfo: bandwidth info + * @data_len: length of FFT data (except for secondary 80 segment) + * @data_len_sec80: length of FFT data for secondary 80 segment + * @tstamp: timestamp + * @last_tstamp: last time stamp + * @max_mag: maximum magnitude (except for secondary 80 segment) + * @max_mag_sec80: maximum magnitude for secondary 80 segment + * @max_index: index of max magnitude (except for secondary 80 segment) + * @max_index_sec80: index of max magnitude for secondary 80 segment + * @max_exp: max exp + * @peak: peak frequency (obsolete) + * @pwr_count: number of FFT bins (except for secondary 80 segment) + * @pwr_count_sec80: number of FFT bins in secondary 80 segment + * @nb_lower: This is deprecated + * @nb_upper: This is deprecated + * @max_upper_index: index of max mag in upper band + * @max_lower_index: index of max mag in lower band + * @bin_pwr_data: Contains FFT magnitudes (except for secondary 80 segment) + * @bin_pwr_data_sec80: Contains FFT magnitudes for the secondary 80 segment + * @freq: Center frequency of primary 20MHz channel in MHz + * @vhtop_ch_freq_seg1: VHT operation first segment center frequency in MHz + * @vhtop_ch_freq_seg2: VHT operation second segment center frequency in MHz + * @freq_loading: spectral control duty cycles + * @noise_floor: current noise floor (except for secondary 80 segment) + * @noise_floor_sec80: current noise floor for secondary 80 segment + * @interf_list: List of interfernce sources + * @classifier_params: classifier parameters + * @sc: classifier parameters + */ struct target_if_samp_msg_params { int8_t rssi; int8_t rssi_sec80; int8_t lower_rssi; int8_t upper_rssi; - int8_t chain_ctl_rssi[ATH_HOST_MAX_ANTENNA]; - int8_t chain_ext_rssi[ATH_HOST_MAX_ANTENNA]; + int8_t chain_ctl_rssi[HOST_MAX_ANTENNA]; + int8_t chain_ext_rssi[HOST_MAX_ANTENNA]; uint16_t bwinfo; uint16_t datalen; uint16_t datalen_sec80; @@ -820,90 +855,309 @@ struct target_if_samp_msg_params { int8_t nb_upper; uint16_t max_lower_index; uint16_t max_upper_index; - u_int8_t *bin_pwr_data; - u_int8_t *bin_pwr_data_sec80; - u_int16_t freq; - u_int16_t vhtop_ch_freq_seg1; - u_int16_t vhtop_ch_freq_seg2; - u_int16_t freq_loading; + uint8_t *bin_pwr_data; + uint8_t *bin_pwr_data_sec80; + uint16_t freq; + uint16_t vhtop_ch_freq_seg1; + uint16_t vhtop_ch_freq_seg2; + uint16_t freq_loading; int16_t noise_floor; int16_t noise_floor_sec80; struct INTERF_SRC_RSP interf_list; - SPECTRAL_CLASSIFIER_PARAMS classifier_params; + struct spectral_classifier_params classifier_params; struct ath_softc *sc; }; /* NETLINK related declarations */ #ifdef SPECTRAL_USE_NETLINK_SOCKETS -#if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE) - void spectral_nl_data_ready(struct sock *sk, int len); -#else - void spectral_nl_data_ready(struct sk_buff *skb); -#endif /* VERSION CHECK */ -#endif /* SPECTRAL_USE_NETLINK_SOCKETS defined */ - #if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE) void target_if_spectral_nl_data_ready(struct sock *sk, int len); #else void target_if_spectral_nl_data_ready(struct sk_buff *skb); -#endif -int target_if_spectral_dump_fft(u_int8_t *pfft, int fftlen); -void target_if_dbg_print_SAMP_param(struct target_if_samp_msg_params *p); +#endif /* VERSION CHECK */ +#endif /* SPECTRAL_USE_NETLINK_SOCKETS defined */ + +/** + * target_if_spectral_dump_fft() - Dump Spectral FFT + * @pfft: Pointer to Spectral Phyerr FFT + * @fftlen: FFT length + * + * Return: Success or failure + */ +int target_if_spectral_dump_fft(uint8_t *pfft, int fftlen); + +/** + * target_if_dbg_print_samp_param() - Print contents of SAMP struct + * @p: Pointer to SAMP message + * + * Return: Void + */ +void target_if_dbg_print_samp_param(struct target_if_samp_msg_params *p); + +/** + * target_if_get_offset_swar_sec80() - Get offset for SWAR according to + * the channel width + * @channel_width: Channel width + * + * Return: Offset for SWAR + */ uint32_t target_if_get_offset_swar_sec80(uint32_t channel_width); +/** + * target_if_sptrl_register_tx_ops() - Register Spectral target_if Tx Ops + * @tx_ops: Tx Ops + * + * Return: void + */ void target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops); + +/* Init's network namespace */ extern struct net init_net; + +/** + * target_if_spectral_init_netlink() - Initialize netlink data structures for + * spectral module + * @spectral : Pointer to spectral internal structure + * + * Return: Success/Failure + */ int target_if_spectral_init_netlink(struct target_if_spectral *spectral); + +/** + * target_if_spectral_init_netlink() - De-initialize netlink data structures for + * spectral module + * @spectral : Pointer to spectral internal structure + * + * Return: Success/Failure + */ int target_if_spectral_destroy_netlink(struct target_if_spectral *spectral); + +/** + * target_if_spectral_unicast_msg() - Passes unicast spectral message to host + * @spectral : Pointer to spectral internal structure + * + * Return: void + */ void target_if_spectral_unicast_msg(struct target_if_spectral *spectral); + +/** + * target_if_spectral_bcast_msg() - Passes broadcast spectral message to host + * @spectral : Pointer to spectral internal structure + * + * Return: void + */ void target_if_spectral_bcast_msg(struct target_if_spectral *spectral); + +/** + * target_if_spectral_prep_skb() - Prepare socket buffer + * @spectral : Pointer to spectral internal structure + * + * Prepare socket buffer to send the data to application layer + * + * Return: void + */ void target_if_spectral_prep_skb(struct target_if_spectral *spectral); -void target_if_spectral_skb_dequeue(unsigned long data); + +/** + * target_if_spectral_skb_dequeue() - Dequeue all the spectral queued socket + * buffers + * @data : unsigned long pointer to spectral internal structure. + * Have to be typecasted to struct target_if_spectral pointer type. + * + * Dequeue all the spectral queued socket buffers queued. + * Broadcasts spectral data after dequeing each sk_buff. + * + * Return: void + */ +void target_if_spectral_skb_dequeue(void *data); + +/** + * target_if_spectral_create_samp_msg() - Create the spectral samp message + * @spectral : Pointer to spectral internal structure + * @params : spectral samp message parameters + * + * API to create the spectral samp message + * + * Return: void + */ void target_if_spectral_create_samp_msg( struct target_if_spectral *spectral, struct target_if_samp_msg_params *params); -int spectral_process_phyerr_gen3( + +/** + * target_if_spectral_process_phyerr_gen3() - Process phyerror event for gen3 + * @spectral: Pointer to Spectral object + * @data: Pointer to phyerror event buffer + * @datalen: Data length + * @p_rfqual: RF quality info + * @p_chaninfo: Channel info + * @tsf64: 64 bit tsf timestamp + * @acs_stats: ACS stats + * + * Process phyerror event for gen3 + * + * Return: Success/Failure + */ +int target_if_spectral_process_phyerr_gen3( struct target_if_spectral *spectral, - u_int8_t *data, - u_int32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual, + uint8_t *data, + uint32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual, struct target_if_spectral_chan_info *p_chaninfo, - u_int64_t tsf64, + uint64_t tsf64, struct target_if_spectral_acs_stats *acs_stats); -int spectral_process_phyerr_gen2( + +/** + * target_if_process_phyerr_gen2() - Process PHY Error for gen2 + * @spectral: Pointer to Spectral object + * @data: Pointer to phyerror event buffer + * @datalen: Data length + * @p_rfqual: RF quality info + * @p_chaninfo: Channel info + * @tsf64: 64 bit tsf timestamp + * @acs_stats: ACS stats + * + * Process PHY Error for gen2 + * + * Return: Success/Failure + */ +int target_if_process_phyerr_gen2( struct target_if_spectral *spectral, - u_int8_t *data, - u_int32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual, + uint8_t *data, + uint32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual, struct target_if_spectral_chan_info *p_chaninfo, - u_int64_t tsf64, + uint64_t tsf64, struct target_if_spectral_acs_stats *acs_stats); + +/** + * target_if_spectral_send_intf_found_msg() - Indicate to application layer that + * interference has been found + * @pdev: Pointer to pdev + * @cw_int: 1 if CW interference is found, 0 if WLAN interference is found + * @dcs_enabled: 1 if DCS is enabled, 0 if DCS is disabled + * + * Send message to application layer + * indicating that interference has been found + * + * Return: None + */ void target_if_spectral_send_intf_found_msg( struct wlan_objmgr_pdev *pdev, - u_int16_t cw_int, u_int32_t dcs_enabled); + uint16_t cw_int, uint32_t dcs_enabled); + +/** + * target_if_stop_spectral_scan() - Stop spectral scan + * @pdev: Pointer to pdev object + * + * API to stop the current on-going spectral scan + * + * Return: None + */ void target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev); + +/** + * target_if_spectral_get_vdev() - Get pointer to vdev to be used for Spectral + * operations + * @spectral: Pointer to Spectral target_if internal private data + * + * Spectral operates on pdev. However, in order to retrieve some WLAN + * properties, a vdev is required. To facilitate this, the function returns the + * first vdev in our pdev. The caller should release the reference to the vdev + * once it is done using it. + * TODO: If the framework later provides an API to obtain the first active + * vdev, then it would be preferable to use this API. + * + * Return: Pointer to vdev on success, NULL on failure + */ struct wlan_objmgr_vdev *target_if_spectral_get_vdev( struct target_if_spectral *spectral); -int spectral_dump_header_gen2(SPECTRAL_PHYERR_HDR_GEN2 *phdr); -int8_t get_combined_rssi_sec80_segment_gen2( +/** + * target_if_spectral_dump_hdr_gen2() - Dump Spectral header for gen2 + * @phdr: Pointer to Spectral Phyerr Header + * + * Dump Spectral header + * + * Return: Success/Failure + */ +int target_if_spectral_dump_hdr_gen2(struct spectral_phyerr_hdr_gen2 *phdr); + +/** + * target_if_get_combrssi_sec80_seg_gen2() - Get approximate combined RSSI + * for Secondary 80 segment + * @spectral: Pointer to spectral object + * @p_sfft_sec80: Pointer to search fft info of secondary 80 segment + * + * Get approximate combined RSSI for Secondary 80 segment + * + * Return: Combined RSSI for secondary 80Mhz segment + */ +int8_t target_if_get_combrssi_sec80_seg_gen2( struct target_if_spectral *spectral, - SPECTRAL_SEARCH_FFT_INFO_GEN2 *p_sfft_sec80); -int spectral_dump_tlv_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, bool is_160_format); -int spectral_dump_phyerr_data_gen2( - u_int8_t *data, - u_int32_t datalen, + struct spectral_search_fft_info_gen2 *p_sfft_sec80); + +/** + * target_if_spectral_dump_tlv_gen2() - Dump Spectral TLV for gen2 + * @ptlv: Pointer to Spectral Phyerr TLV + * @is_160_format: Indicates 160 format + * + * Dump Spectral TLV for gen2 + * + * Return: Success/Failure + */ +int target_if_spectral_dump_tlv_gen2( + struct spectral_phyerr_tlv_gen2 *ptlv, bool is_160_format); + +/** + * target_if_spectral_dump_phyerr_data_gen2() - Dump Spectral + * related PHY Error for gen2 + * @data: Pointer to phyerror buffer + * @datalen: Data length + * @is_160_format: Indicates 160 format + * + * Dump Spectral related PHY Error for gen2 + * + * Return: Success/Failure + */ +int target_if_spectral_dump_phyerr_data_gen2( + uint8_t *data, + uint32_t datalen, bool is_160_format); -int spectral_dump_fft_report_gen3( + +/** + * target_if_dump_fft_report_gen3() - Dump FFT Report for gen3 + * @p_fft_report: Pointer to fft report + * @p_sfft: Pointer to search fft report + * + * Dump FFT Report for gen3 + * + * Return: Success/Failure + */ +int target_if_dump_fft_report_gen3( struct spectral_phyerr_fft_report_gen3 *p_fft_report, struct spectral_search_fft_info_gen3 *p_sfft); -void target_if_dbg_print_SAMP_msg(SPECTRAL_SAMP_MSG *pmsg); +/** + * target_if_dbg_print_samp_msg() - Print contents of SAMP Message + * @p: Pointer to SAMP message + * + * Print contents of SAMP Message + * + * Return: Void + */ +void target_if_dbg_print_samp_msg(struct spectral_samp_msg *pmsg); -/* START of spectral GEN III HW specific function declarations */ -/* [FIXME] fix the declaration */ -int process_search_fft_report_gen3( +/** + * target_if_process_sfft_report_gen3() - Process Search FFT Report for gen3 + * @p_fft_report: Pointer to fft report + * @p_sfft: Pointer to search fft report + * + * Process Search FFT Report for gen3 + * + * Return: Success/Failure + */ +int target_if_process_sfft_report_gen3( struct spectral_phyerr_fft_report_gen3 *p_fft_report, - struct spectral_search_fft_info_gen3 *p_fft_info); -/* END of spectral GEN III HW specific function declarations */ + struct spectral_search_fft_info_gen3 *p_fft_info); /** * target_if_send_phydata() - Send Spectral PHY data over netlink @@ -947,6 +1201,15 @@ struct target_if_spectral *get_target_if_spectral_handle_from_pdev( return spectral; } +/** + * target_if_vdev_get_chan_freq() - Get the operating channel frequency of a + * given vdev + * @pdev: Pointer to vdev + * + * Get the operating channel frequency of a given vdev + * + * Return: Operating channel frequency of a vdev + */ static inline int16_t target_if_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev) { @@ -958,6 +1221,15 @@ int16_t target_if_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev) vdev); } +/** + * target_if_vdev_get_ch_width() - Get the operating channel bandwidth of a + * given vdev + * @pdev: Pointer to vdev + * + * Get the operating channel bandwidth of a given vdev + * + * Return: channel bandwidth enumeration corresponding to the vdev + */ static inline enum phy_ch_width target_if_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev) { @@ -969,9 +1241,19 @@ enum phy_ch_width target_if_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev) vdev); } +/** + * target_if_vdev_get_sec20chan_freq_mhz() - Get the frequency of secondary + * 20 MHz channel for a given vdev + * @pdev: Pointer to vdev + * + * Get the frequency of secondary 20Mhz channel for a given vdev + * + * Return: Frequency of secondary 20Mhz channel for a given vdev + */ static inline -int target_if_vdev_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev, - uint16_t *sec20chan_freq) +int target_if_vdev_get_sec20chan_freq_mhz( + struct wlan_objmgr_vdev *vdev, + uint16_t *sec20chan_freq) { struct wlan_objmgr_psoc *psoc = NULL; @@ -990,7 +1272,7 @@ int target_if_vdev_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev, */ static inline void target_if_spectral_set_rxchainmask(struct wlan_objmgr_pdev *pdev, - u_int8_t spectral_rx_chainmask) + uint8_t spectral_rx_chainmask) { struct target_if_spectral *spectral = NULL; @@ -1016,53 +1298,61 @@ void target_if_spectral_set_rxchainmask(struct wlan_objmgr_pdev *pdev, static inline void target_if_spectral_process_phyerr( struct wlan_objmgr_pdev *pdev, - u_int8_t *data, u_int32_t datalen, + uint8_t *data, uint32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual, struct target_if_spectral_chan_info *p_chaninfo, - u_int64_t tsf64, + uint64_t tsf64, struct target_if_spectral_acs_stats *acs_stats) { struct target_if_spectral *spectral = NULL; struct target_if_spectral_ops *p_sops = NULL; spectral = get_target_if_spectral_handle_from_pdev(pdev); - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); p_sops->spectral_process_phyerr(spectral, data, datalen, p_rfqual, p_chaninfo, tsf64, acs_stats); } /** - * tgt_if_is_spectral_enabled() - Get whether Spectral is enabled + * target_if_sops_is_spectral_enabled() - Get whether Spectral is enabled * @arg: Pointer to handle for Spectral target_if internal private data * + * Function to check whether Spectral is enabled + * * Return: True if Spectral is enabled, false if Spectral is not enabled */ -u_int32_t tgt_if_is_spectral_enabled(void *arg); +uint32_t target_if_sops_is_spectral_enabled(void *arg); /** - * tgt_if_is_spectral_active() - Get whether Spectral is active + * target_if_sops_is_spectral_active() - Get whether Spectral is active * @arg: Pointer to handle for Spectral target_if internal private data * + * Function to check whether Spectral is active + * * Return: True if Spectral is active, false if Spectral is not active */ -u_int32_t tgt_if_is_spectral_active(void *arg); +uint32_t target_if_sops_is_spectral_active(void *arg); /** - * tgt_if_start_spectral_scan() - Start Spectral scan + * target_if_sops_start_spectral_scan() - Start Spectral scan * @arg: Pointer to handle for Spectral target_if internal private data * - * Return: 1 on success, 0 on failure + * Function to start spectral scan + * + * Return: 0 on success else failure */ -u_int32_t tgt_if_start_spectral_scan(void *arg); +uint32_t target_if_sops_start_spectral_scan(void *arg); /** - * tgt_if_stop_spectral_scan() - Stop Spectral scan + * target_if_sops_stop_spectral_scan() - Stop Spectral scan * @arg: Pointer to handle for Spectral target_if internal private data * - * Return: 1 on success, 0 on failure + * Function to stop spectral scan + * + * Return: 0 in case of success, -1 on failure */ -u_int32_t tgt_if_stop_spectral_scan(void *arg); +uint32_t target_if_sops_stop_spectral_scan(void *arg); /** * target_if_spectral_get_extension_channel() - Get the current Extension @@ -1072,7 +1362,7 @@ u_int32_t tgt_if_stop_spectral_scan(void *arg); * Return: Current Extension channel (in MHz) on success, 0 on failure or if * extension channel is not present. */ -u_int32_t target_if_spectral_get_extension_channel(void *arg); +uint32_t target_if_spectral_get_extension_channel(void *arg); /** * target_if_spectral_get_current_channel() - Get the current channel (in MHz) @@ -1080,7 +1370,7 @@ u_int32_t target_if_spectral_get_extension_channel(void *arg); * * Return: Current channel (in MHz) on success, 0 on failure */ -u_int32_t target_if_spectral_get_current_channel(void *arg); +uint32_t target_if_spectral_get_current_channel(void *arg); /** @@ -1092,7 +1382,7 @@ u_int32_t target_if_spectral_get_current_channel(void *arg); * * Return: 0 */ -u_int32_t target_if_spectral_reset_hw(void *arg); +uint32_t target_if_spectral_reset_hw(void *arg); /** * target_if_spectral_get_chain_noise_floor() - Get the Chain noise floor from @@ -1105,7 +1395,7 @@ u_int32_t target_if_spectral_reset_hw(void *arg); * * Return: 0 */ -u_int32_t target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf); +uint32_t target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf); /** * target_if_spectral_get_ext_noisefloor() - Get the extension channel @@ -1139,8 +1429,8 @@ int8_t target_if_spectral_get_ctl_noisefloor(void *arg); * Return: True if the capability is available, false if the capability is not * available */ -u_int32_t target_if_spectral_get_capability( - void *arg, SPECTRAL_CAPABILITY_TYPE type); +uint32_t target_if_spectral_get_capability( + void *arg, enum spectral_capability_type type); /** * target_if_spectral_set_rxfilter() - Set the RX Filter before Spectral start @@ -1152,17 +1442,17 @@ u_int32_t target_if_spectral_get_capability( * * Return: 0 */ -u_int32_t target_if_spectral_set_rxfilter(void *arg, int rxfilter); +uint32_t target_if_spectral_set_rxfilter(void *arg, int rxfilter); /** - * target_if_spectral_configure_params() - Configure user supplied Spectral - * parameters + * target_if_spectral_sops_configure_params() - Configure user supplied Spectral + * parameters * @arg: Pointer to handle for Spectral target_if internal private data * @params: Spectral parameters * - * Return: 1 on success, 0 on failure. + * Return: 0 in case of success, -1 on failure */ -u_int32_t target_if_spectral_configure_params( +uint32_t target_if_spectral_sops_configure_params( void *arg, struct spectral_config *params); /** @@ -1174,7 +1464,7 @@ u_int32_t target_if_spectral_configure_params( * * Return: 0 */ -u_int32_t target_if_spectral_get_rxfilter(void *arg); +uint32_t target_if_spectral_get_rxfilter(void *arg); /** * target_if_pdev_spectral_deinit() - De-initialize target_if Spectral @@ -1193,11 +1483,11 @@ void target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev); * * API to set spectral configurations * - * Return: 1 on success, 0 on failure + * Return: 0 in case of success, -1 on failure */ int target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev, - const u_int32_t threshtype, - const u_int32_t value); + const uint32_t threshtype, + const uint32_t value); /** * target_if_pdev_spectral_init() - Initialize target_if Spectral @@ -1210,25 +1500,25 @@ int target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev, void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev); /** - * target_if_spectral_get_params() - Get user configured Spectral parameters + * target_if_spectral_sops_get_params() - Get user configured Spectral + * parameters * @arg: Pointer to handle for Spectral target_if internal private data * @params: Pointer to buffer into which Spectral parameters should be copied * - * Return: 1 on success, 0 on failure. + * Return: 0 in case of success, -1 on failure */ -u_int32_t target_if_spectral_get_params( +uint32_t target_if_spectral_sops_get_params( void *arg, struct spectral_config *params); /** - * init_spectral_capability() - Initialize Spectral capability + * target_if_init_spectral_capability() - Initialize Spectral capability * @spectral: Pointer to Spectral target_if internal private data * * This is a workaround. * * Return: None */ -void init_spectral_capability( - struct target_if_spectral *spectral); +void target_if_init_spectral_capability(struct target_if_spectral *spectral); /** * target_if_start_spectral_scan() - Start spectral scan @@ -1239,6 +1529,7 @@ void init_spectral_capability( * Return: 0 in case of success, -1 on failure */ int target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev); + /** * target_if_get_spectral_config() - Get spectral configuration * @pdev: Pointer to pdev object @@ -1247,7 +1538,7 @@ int target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev); * * API to get the current spectral configuration * - * Return: 1 on success, 0 on failure. + * Return: 0 in case of success, -1 on failure */ void target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev, struct spectral_config *param); @@ -1290,7 +1581,7 @@ bool target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev); * Return: 0 in case of success */ int target_if_set_debug_level(struct wlan_objmgr_pdev *pdev, - u_int32_t debug_level); + uint32_t debug_level); /** * target_if_get_debug_level() - Get debug level for Spectral @@ -1298,7 +1589,7 @@ int target_if_set_debug_level(struct wlan_objmgr_pdev *pdev, * * Return: Current debug level */ -u_int32_t target_if_get_debug_level(struct wlan_objmgr_pdev *pdev); +uint32_t target_if_get_debug_level(struct wlan_objmgr_pdev *pdev); /** @@ -1334,7 +1625,7 @@ void target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, */ int target_if_spectral_send_tlv_to_host( struct target_if_spectral *spectral, - u_int8_t *data, u_int32_t datalen); + uint8_t *data, uint32_t datalen); void target_if_register_wmi_spectral_cmd_ops( struct wlan_objmgr_pdev *pdev, diff --git a/target_if/spectral/target_if_spectral_netlink.c b/target_if/spectral/target_if_spectral_netlink.c index d3b9f89048..1c31de7165 100644 --- a/target_if/spectral/target_if_spectral_netlink.c +++ b/target_if/spectral/target_if_spectral_netlink.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011,2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2011,2017-2018 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -27,83 +27,134 @@ #include #include - #ifdef SPECTRAL_USE_NETLINK_SOCKETS struct sock *target_if_spectral_nl_sock; static atomic_t spectral_nl_users = ATOMIC_INIT(0); #if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE) -void target_if_spectral_nl_data_ready(struct sock *sk, int len) +void +target_if_spectral_nl_data_ready(struct sock *sk, int len) { qdf_print("%s %d\n", __func__, __LINE__); } #else -void target_if_spectral_nl_data_ready(struct sk_buff *skb) +void +target_if_spectral_nl_data_ready(struct sk_buff *skb) { qdf_print("%s %d\n", __func__, __LINE__); } +#endif /* VERSION */ -#endif /* VERSION */ - -int target_if_spectral_init_netlink(struct target_if_spectral *spectral) -{ +/** + * target_if_spectral_init_nl_cfg() - Initialize netlink kernel + * configuration parameters + * @spectral : Pointer to netlink_kernel_cfg + * + * Initialize netlink kernel configuration parameters required + * for spectral module + * + * Return: None + */ #if KERNEL_VERSION(3, 6, 0) <= LINUX_VERSION_CODE - - struct netlink_kernel_cfg cfg = { - .groups = 1, - .input = target_if_spectral_nl_data_ready, - }; +static void +target_if_spectral_init_nl_cfg(struct netlink_kernel_cfg *cfg) +{ + cfg->groups = 1; + cfg->input = target_if_spectral_nl_data_ready; +} +#else +static void +target_if_spectral_init_nl_cfg(struct netlink_kernel_cfg *cfg) +{ +} #endif +/** + * target_if_spectral_create_nl_sock() - Create Netlink socket + * @spectral : Pointer to netlink_kernel_cfg + * + * Create Netlink socket required for spectral module + * + * Return: None + */ +#if KERNEL_VERSION(3, 7, 0) <= LINUX_VERSION_CODE +static void +target_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg) +{ + target_if_spectral_nl_sock = + (struct sock *)netlink_kernel_create(&init_net, + NETLINK_ATHEROS, cfg); +} +#elif KERNEL_VERSION(3, 6, 0) <= LINUX_VERSION_CODE +static void +target_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg) +{ + target_if_spectral_nl_sock = + (struct sock *)netlink_kernel_create(&init_net, + NETLINK_ATHEROS, + THIS_MODULE, cfg); +} +#elif (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE) +static void +target_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg) +{ + target_if_spectral_nl_sock = + (struct sock *)netlink_kernel_create( + NETLINK_ATHEROS, 1, + &target_if_spectral_nl_data_ready, + THIS_MODULE); +} +#else +#if (KERNEL_VERSION(3, 10, 0) <= LINUX_VERSION_CODE) +static void +target_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg) +{ + memset(cfg, 0, sizeof(*cfg)); + cfg->groups = 1; + cfg->input = &target_if_spectral_nl_data_ready; + target_if_spectral_nl_sock = + (struct sock *)netlink_kernel_create(&init_net, + NETLINK_ATHEROS, cfg); +} +#else +static void +target_if_spectral_create_nl_sock(struct netlink_kernel_cfg *cfg) +{ + target_if_spectral_nl_sock = + (struct sock *)netlink_kernel_create( + &init_net, + NETLINK_ATHEROS, 1, + &target_if_spectral_nl_data_ready, + NULL, THIS_MODULE); +} +#endif +#endif + +int +target_if_spectral_init_netlink(struct target_if_spectral *spectral) +{ + struct netlink_kernel_cfg cfg; + + memset(&cfg, 0, sizeof(cfg)); + + target_if_spectral_init_nl_cfg(&cfg); + if (!spectral) { - qdf_print("%s: sc_spectral is NULL\n", __func__); - return -EIO; + qdf_print("%s: sc_spectral is NULL\n", __func__); + return -EIO; } spectral->spectral_sent_msg = 0; if (!target_if_spectral_nl_sock) { -#if KERNEL_VERSION(3, 7, 0) <= LINUX_VERSION_CODE - target_if_spectral_nl_sock = (struct sock *)netlink_kernel_create( - &init_net, - NETLINK_ATHEROS, - &cfg); -#elif KERNEL_VERSION(3, 6, 0) <= LINUX_VERSION_CODE - target_if_spectral_nl_sock = (struct sock *)netlink_kernel_create( - &init_net, - NETLINK_ATHEROS, - THIS_MODULE, - &cfg); -#elif (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE) - target_if_spectral_nl_sock = ( - struct sock *)netlink_kernel_create(NETLINK_ATHEROS, - 1, - &target_if_spectral_nl_data_ready, - THIS_MODULE); -#else -#if (KERNEL_VERSION(3, 10, 0) <= LINUX_VERSION_CODE) - struct netlink_kernel_cfg cfg; + target_if_spectral_create_nl_sock(&cfg); - memset(&cfg, 0, sizeof(cfg)); - cfg.groups = 1; - cfg.input = &target_if_spectral_nl_data_ready; - target_if_spectral_nl_sock = (struct sock *)netlink_kernel_create( - &init_net, NETLINK_ATHEROS, &cfg); -#else - target_if_spectral_nl_sock = (struct sock *)netlink_kernel_create( - &init_net, - NETLINK_ATHEROS, - 1, - &target_if_spectral_nl_data_ready, - NULL, - THIS_MODULE); -#endif -#endif - if (!target_if_spectral_nl_sock) { - qdf_print("%s NETLINK_KERNEL_CREATE FAILED\n", __func__); - return -ENODEV; - } + if (!target_if_spectral_nl_sock) { + qdf_print("%s NETLINK_KERNEL_CREATE FAILED\n", + __func__); + return -ENODEV; + } } atomic_inc(&spectral_nl_users); spectral->spectral_sock = target_if_spectral_nl_sock; @@ -119,38 +170,26 @@ int target_if_spectral_init_netlink(struct target_if_spectral *spectral) return 0; } -int target_if_spectral_destroy_netlink(struct target_if_spectral *spectral) +int +target_if_spectral_destroy_netlink(struct target_if_spectral *spectral) { spectral->spectral_sock = NULL; if (atomic_dec_and_test(&spectral_nl_users)) { - sock_release(target_if_spectral_nl_sock->sk_socket); - target_if_spectral_nl_sock = NULL; + sock_release(target_if_spectral_nl_sock->sk_socket); + target_if_spectral_nl_sock = NULL; } return 0; } -#endif /* SPECTRAL_USE_NETLINK_SOCKETS */ +#endif /* SPECTRAL_USE_NETLINK_SOCKETS */ -static void spectral_process_noise_pwr_report( +static void +target_if_spectral_process_noise_pwr_report( struct target_if_spectral *spectral, - const SPECTRAL_SAMP_MSG *spec_samp_msg) + const struct spectral_samp_msg *spec_samp_msg) { int i, done; -/* - * qdf_print( - * "%s: #%d/%d datalen=%d tstamp=%x last_tstamp=%x " - * "rssi=%d nb_lower=%d peak=%d\n", - * __func__, spectral->noise_pwr_reports_recv, - * spectral->noise_pwr_reports_reqd, - * spec_samp_msg->samp_data.spectral_data_len, - * spec_samp_msg->samp_data.spectral_tstamp, - * spec_samp_msg->samp_data.spectral_last_tstamp, - * spec_samp_msg->samp_data.spectral_lower_rssi, - * spec_samp_msg->samp_data.spectral_nb_lower, - * spec_samp_msg->samp_data.spectral_lower_max_index); - */ - qdf_spin_lock(&spectral->noise_pwr_reports_lock); if (!spectral->noise_pwr_reports_reqd) { @@ -159,55 +198,41 @@ static void spectral_process_noise_pwr_report( } if (spectral->noise_pwr_reports_recv < - spectral->noise_pwr_reports_reqd) { + spectral->noise_pwr_reports_reqd) { spectral->noise_pwr_reports_recv++; -/* - * qdf_print( - * "#%d/%d: rssi=%3d,%3d,%3d %3d,%3d,%3d\n", - * spectral->noise_pwr_reports_recv, - * spectral->noise_pwr_reports_reqd, - * spec_samp_msg->samp_data.spectral_chain_ctl_rssi[0], - * spec_samp_msg->samp_data.spectral_chain_ctl_rssi[1], - * spec_samp_msg->samp_data.spectral_chain_ctl_rssi[2], - * spec_samp_msg->samp_data.spectral_chain_ext_rssi[0], - * spec_samp_msg->samp_data.spectral_chain_ext_rssi[1], - * spec_samp_msg->samp_data.spectral_chain_ext_rssi[2]); - */ + for (i = 0; i < HOST_MAX_ANTENNA; i++) { + uint32_t index; - for (i = 0; i < ATH_HOST_MAX_ANTENNA; i++) { - uint32_t index; - - if (spectral->noise_pwr_chain_ctl[i]) { - index = spectral->noise_pwr_chain_ctl[i]->rptcount++; - spectral->noise_pwr_chain_ctl[i]->pwr[index] = - spec_samp_msg->samp_data.spectral_chain_ctl_rssi[i]; + if (spectral->noise_pwr_chain_ctl[i]) { + index = + spectral->noise_pwr_chain_ctl[i]-> + rptcount++; + spectral->noise_pwr_chain_ctl[i]->pwr[index] = + spec_samp_msg->samp_data. + spectral_chain_ctl_rssi[i]; + } + if (spectral->noise_pwr_chain_ext[i]) { + index = + spectral->noise_pwr_chain_ext[i]-> + rptcount++; + spectral->noise_pwr_chain_ext[i]->pwr[index] = + spec_samp_msg->samp_data. + spectral_chain_ext_rssi[i]; + } } - if (spectral->noise_pwr_chain_ext[i]) { - index = spectral->noise_pwr_chain_ext[i]->rptcount++; - spectral->noise_pwr_chain_ext[i]->pwr[index] = - spec_samp_msg->samp_data.spectral_chain_ext_rssi[i]; - } - } } done = (spectral->noise_pwr_reports_recv >= - spectral->noise_pwr_reports_reqd); + spectral->noise_pwr_reports_reqd); qdf_spin_unlock(&spectral->noise_pwr_reports_lock); if (done) { - qdf_spin_lock(&spectral->ath_spectral_lock); + qdf_spin_lock(&spectral->spectral_lock); target_if_stop_spectral_scan(spectral->pdev_obj); spectral->sc_spectral_scan = 0; - qdf_spin_unlock(&spectral->ath_spectral_lock); - -/* - * qdf_print( - * "%s: done: %d/%d recv - set sc_spectral_scan = 0\n", - * __func__, spectral->noise_pwr_reports_recv, - * spectral->noise_pwr_reports_reqd); - */ + qdf_spin_unlock(&spectral->spectral_lock); } } @@ -219,89 +244,102 @@ static void spectral_process_noise_pwr_report( * */ -void target_if_spectral_create_samp_msg( - struct target_if_spectral *spectral, - struct target_if_samp_msg_params *params) +#ifdef SPECTRAL_CLASSIFIER_IN_KERNEL +static void +target_if_spectral_init_interf_list( + struct spectral_samp_data *data, + struct target_if_samp_msg_params *params) +{ + if (params->interf_list.count) + OS_MEMCPY(&data->interf_list, + ¶ms->interf_list, sizeof(struct INTERF_SRC_RSP)); + else + data->interf_list.count = 0; +} +#else +static void +target_if_spectral_init_interf_list( + struct spectral_samp_data *data, + struct target_if_samp_msg_params *params) +{ + data->interf_list.count = 0; +} +#endif + +void +target_if_spectral_create_samp_msg(struct target_if_spectral *spectral, + struct target_if_samp_msg_params *params) { /* * XXX : Non-Rentrant. Will be an issue with dual concurrent * operation on multi-processor system */ - int temp_samp_msg_len = 0; + int temp_samp_msg_len = 0; - static SPECTRAL_SAMP_MSG spec_samp_msg; + static struct spectral_samp_msg spec_samp_msg; - SPECTRAL_SAMP_MSG *msg = NULL; - SPECTRAL_SAMP_DATA *data = NULL; - u_int8_t *bin_pwr_data = NULL; - SPECTRAL_CLASSIFIER_PARAMS *cp = NULL; - SPECTRAL_CLASSIFIER_PARAMS *pcp = NULL; - struct target_if_spectral_ops *p_sops = NULL; + struct spectral_samp_msg *msg = NULL; + struct spectral_samp_data *data = NULL; + uint8_t *bin_pwr_data = NULL; + struct spectral_classifier_params *cp = NULL; + struct spectral_classifier_params *pcp = NULL; + struct target_if_spectral_ops *p_sops = NULL; struct target_if_spectral_skb_event *sp_skb_event = NULL; #ifdef SPECTRAL_USE_NETLINK_SOCKETS static int samp_msg_index; #endif - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); - temp_samp_msg_len = sizeof(SPECTRAL_SAMP_MSG) - - (MAX_NUM_BINS * sizeof(u_int8_t)); - temp_samp_msg_len += (params->pwr_count * sizeof(u_int8_t)); + temp_samp_msg_len = sizeof(struct spectral_samp_msg) - + (MAX_NUM_BINS * sizeof(uint8_t)); + temp_samp_msg_len += (params->pwr_count * sizeof(uint8_t)); if (spectral->ch_width == CH_WIDTH_160MHZ) - temp_samp_msg_len += - (params->pwr_count_sec80 * sizeof(u_int8_t)); - bin_pwr_data = params->bin_pwr_data; + temp_samp_msg_len += + (params->pwr_count_sec80 * sizeof(uint8_t)); + bin_pwr_data = params->bin_pwr_data; - memset(&spec_samp_msg, 0, sizeof(SPECTRAL_SAMP_MSG)); + memset(&spec_samp_msg, 0, sizeof(struct spectral_samp_msg)); data = &spec_samp_msg.samp_data; - spec_samp_msg.signature = SPECTRAL_SIGNATURE; - spec_samp_msg.freq = params->freq; - spec_samp_msg.freq_loading = params->freq_loading; - spec_samp_msg.samp_data.spectral_data_len = params->datalen; - spec_samp_msg.samp_data.spectral_rssi = params->rssi; - spec_samp_msg.samp_data.ch_width = spectral->ch_width; + spec_samp_msg.signature = SPECTRAL_SIGNATURE; + spec_samp_msg.freq = params->freq; + spec_samp_msg.freq_loading = params->freq_loading; + spec_samp_msg.samp_data.spectral_data_len = params->datalen; + spec_samp_msg.samp_data.spectral_rssi = params->rssi; + spec_samp_msg.samp_data.ch_width = spectral->ch_width; - spec_samp_msg.samp_data.spectral_combined_rssi = - (u_int8_t)params->rssi; - spec_samp_msg.samp_data.spectral_upper_rssi = params->upper_rssi; - spec_samp_msg.samp_data.spectral_lower_rssi = params->lower_rssi; + spec_samp_msg.samp_data.spectral_combined_rssi = + (uint8_t)params->rssi; + spec_samp_msg.samp_data.spectral_upper_rssi = params->upper_rssi; + spec_samp_msg.samp_data.spectral_lower_rssi = params->lower_rssi; - OS_MEMCPY( - spec_samp_msg.samp_data.spectral_chain_ctl_rssi, - params->chain_ctl_rssi, - sizeof(params->chain_ctl_rssi)); - OS_MEMCPY( - spec_samp_msg.samp_data.spectral_chain_ext_rssi, - params->chain_ext_rssi, - sizeof(params->chain_ext_rssi)); + OS_MEMCPY(spec_samp_msg.samp_data.spectral_chain_ctl_rssi, + params->chain_ctl_rssi, sizeof(params->chain_ctl_rssi)); + OS_MEMCPY(spec_samp_msg.samp_data.spectral_chain_ext_rssi, + params->chain_ext_rssi, sizeof(params->chain_ext_rssi)); - spec_samp_msg.samp_data.spectral_bwinfo = params->bwinfo; - spec_samp_msg.samp_data.spectral_tstamp = params->tstamp; - spec_samp_msg.samp_data.spectral_max_index = params->max_index; + spec_samp_msg.samp_data.spectral_bwinfo = params->bwinfo; + spec_samp_msg.samp_data.spectral_tstamp = params->tstamp; + spec_samp_msg.samp_data.spectral_max_index = params->max_index; /* Classifier in user space needs access to these */ - spec_samp_msg.samp_data.spectral_lower_max_index = - params->max_lower_index; - spec_samp_msg.samp_data.spectral_upper_max_index = - params->max_upper_index; - spec_samp_msg.samp_data.spectral_nb_lower = - params->nb_lower; - spec_samp_msg.samp_data.spectral_nb_upper = params->nb_upper; - spec_samp_msg.samp_data.spectral_last_tstamp = - params->last_tstamp; - spec_samp_msg.samp_data.spectral_max_mag = params->max_mag; - spec_samp_msg.samp_data.bin_pwr_count = - params->pwr_count; - spec_samp_msg.samp_data.lb_edge_extrabins = - spectral->lb_edge_extrabins; - spec_samp_msg.samp_data.rb_edge_extrabins = - spectral->rb_edge_extrabins; - spec_samp_msg.samp_data.spectral_combined_rssi = params->rssi; - spec_samp_msg.samp_data.spectral_max_scale = params->max_exp; + spec_samp_msg.samp_data.spectral_lower_max_index = + params->max_lower_index; + spec_samp_msg.samp_data.spectral_upper_max_index = + params->max_upper_index; + spec_samp_msg.samp_data.spectral_nb_lower = params->nb_lower; + spec_samp_msg.samp_data.spectral_nb_upper = params->nb_upper; + spec_samp_msg.samp_data.spectral_last_tstamp = params->last_tstamp; + spec_samp_msg.samp_data.spectral_max_mag = params->max_mag; + spec_samp_msg.samp_data.bin_pwr_count = params->pwr_count; + spec_samp_msg.samp_data.lb_edge_extrabins = spectral->lb_edge_extrabins; + spec_samp_msg.samp_data.rb_edge_extrabins = spectral->rb_edge_extrabins; + spec_samp_msg.samp_data.spectral_combined_rssi = params->rssi; + spec_samp_msg.samp_data.spectral_max_scale = params->max_exp; #ifdef SPECTRAL_USE_NETLINK_SOCKETS @@ -320,201 +358,222 @@ void target_if_spectral_create_samp_msg( */ spec_samp_msg.samp_data.noise_floor = params->noise_floor; -#endif /* SPECTRAL_USE_NETLINK_SOCKETS */ +#endif /* SPECTRAL_USE_NETLINK_SOCKETS */ /* Classifier in user space needs access to these */ - cp = &spec_samp_msg.samp_data.classifier_params; + cp = &spec_samp_msg.samp_data.classifier_params; pcp = ¶ms->classifier_params; - OS_MEMCPY(cp, pcp, sizeof(SPECTRAL_CLASSIFIER_PARAMS)); + OS_MEMCPY(cp, pcp, sizeof(struct spectral_classifier_params)); - SPECTRAL_MSG_COPY_CHAR_ARRAY( - &data->bin_pwr[0], - bin_pwr_data, - params->pwr_count); + SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(&data->bin_pwr[0], + bin_pwr_data, params->pwr_count); #ifdef SPECTRAL_USE_NETLINK_SOCKETS - spec_samp_msg.vhtop_ch_freq_seg1 = - params->vhtop_ch_freq_seg1; - spec_samp_msg.vhtop_ch_freq_seg2 = - params->vhtop_ch_freq_seg2; + spec_samp_msg.vhtop_ch_freq_seg1 = params->vhtop_ch_freq_seg1; + spec_samp_msg.vhtop_ch_freq_seg2 = params->vhtop_ch_freq_seg2; if (spectral->ch_width == CH_WIDTH_160MHZ) { - spec_samp_msg.samp_data.spectral_rssi_sec80 = params->rssi_sec80; - spec_samp_msg.samp_data.noise_floor_sec80 = params->noise_floor_sec80; + spec_samp_msg.samp_data.spectral_rssi_sec80 = + params->rssi_sec80; + spec_samp_msg.samp_data.noise_floor_sec80 = + params->noise_floor_sec80; - spec_samp_msg.samp_data.spectral_data_len_sec80 = - params->datalen_sec80; - spec_samp_msg.samp_data.spectral_max_index_sec80 = - params->max_index_sec80; - spec_samp_msg.samp_data.spectral_max_mag_sec80 = - params->max_mag_sec80; - spec_samp_msg.samp_data.bin_pwr_count_sec80 = - params->pwr_count_sec80; - SPECTRAL_MSG_COPY_CHAR_ARRAY(&data->bin_pwr_sec80[0], - (params->bin_pwr_data_sec80), - params->pwr_count_sec80); + spec_samp_msg.samp_data.spectral_data_len_sec80 = + params->datalen_sec80; + spec_samp_msg.samp_data.spectral_max_index_sec80 = + params->max_index_sec80; + spec_samp_msg.samp_data.spectral_max_mag_sec80 = + params->max_mag_sec80; + spec_samp_msg.samp_data.bin_pwr_count_sec80 = + params->pwr_count_sec80; + SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(&data->bin_pwr_sec80[0], + (params->bin_pwr_data_sec80), + params->pwr_count_sec80); - /* Note: REVERSE_ORDER is not a known use case for secondary 80 data at - * this point. - */ + /* + * Note: REVERSE_ORDER is not a known use case for + * secondary 80 data at this point. + */ } -#endif /* SPECTRAL_USE_NETLINK_SOCKETS */ +#endif /* SPECTRAL_USE_NETLINK_SOCKETS */ -#ifdef SPECTRAL_CLASSIFIER_IN_KERNEL - if (params->interf_list.count) - OS_MEMCPY( - &data->interf_list, - ¶ms->interf_list, - sizeof(struct INTERF_SRC_RSP)); - else -#endif - data->interf_list.count = 0; + target_if_spectral_init_interf_list(data, params); #ifdef SPECTRAL_USE_NETLINK_SOCKETS target_if_spectral_prep_skb(spectral); if (spectral->spectral_skb) { - p_sops->get_mac_address(spectral, spec_samp_msg.macaddr); - spectral->spectral_nlh = - (struct nlmsghdr *)spectral->spectral_skb->data; - memcpy(NLMSG_DATA(spectral->spectral_nlh), - &spec_samp_msg, - sizeof(SPECTRAL_SAMP_MSG)); - msg = (SPECTRAL_SAMP_MSG *)NLMSG_DATA(spectral->spectral_nlh); - /* Broadcast spectral data only if it is a edma supported device */ - if (!spectral->sc_spectral_non_edma) - target_if_spectral_bcast_msg(spectral); - samp_msg_index++; + p_sops->get_mac_address(spectral, spec_samp_msg.macaddr); + spectral->spectral_nlh = + (struct nlmsghdr *)spectral->spectral_skb->data; + memcpy(NLMSG_DATA(spectral->spectral_nlh), + &spec_samp_msg, sizeof(struct spectral_samp_msg)); + msg = (struct spectral_samp_msg *)NLMSG_DATA( + spectral->spectral_nlh); + /* + * Broadcast spectral data only + * if it is a edma supported device + */ + if (!spectral->sc_spectral_non_edma) + target_if_spectral_bcast_msg(spectral); + samp_msg_index++; } - /* Check if the device is non-edma and follow the required broadcast + /* + * Check if the device is non-edma and follow the required broadcast * path if true */ if (spectral->sc_spectral_non_edma) { - /* Allocating memory for the queue entity to hold the spectral socket - * buffer - */ - sp_skb_event = (struct target_if_spectral_skb_event - *)qdf_mem_malloc(sizeof(struct target_if_spectral_skb_event)); - - if (sp_skb_event) { - OS_MEMZERO( - sp_skb_event, - sizeof(struct target_if_spectral_skb_event)); - sp_skb_event->sp_skb = spectral->spectral_skb; - sp_skb_event->sp_nlh = spectral->spectral_nlh; - spectral->spectral_skb = NULL; - spectral->spectral_nlh = NULL; - - /* Queue spectral socket buffers to be broadcasted outside irq - * lock + /* + * Allocating memory for the queue entity to + * hold the spectral socket buffer */ - qdf_spin_lock(&spectral->spectral_skbqlock); - STAILQ_INSERT_TAIL( - &spectral->spectral_skbq, - sp_skb_event, - spectral_skb_list); - qdf_spin_unlock(&spectral->spectral_skbqlock); - } + sp_skb_event = (struct target_if_spectral_skb_event + *)qdf_mem_malloc( + sizeof( + struct target_if_spectral_skb_event)); + + if (sp_skb_event) { + OS_MEMZERO(sp_skb_event, + sizeof(struct target_if_spectral_skb_event)); + sp_skb_event->sp_skb = spectral->spectral_skb; + sp_skb_event->sp_nlh = spectral->spectral_nlh; + spectral->spectral_skb = NULL; + spectral->spectral_nlh = NULL; + + /* + * Queue spectral socket buffers to be broadcasted + * outside irq lock + */ + qdf_spin_lock(&spectral->spectral_skbqlock); + STAILQ_INSERT_TAIL(&spectral->spectral_skbq, + sp_skb_event, spectral_skb_list); + qdf_spin_unlock(&spectral->spectral_skbqlock); + } } #else /* * call the indicate function to pass the data to the net layer * Windows will pass to a spectral WIN32 service */ - msg = (SPECTRAL_SAMP_MSG *)qdf_mem_malloc(sizeof(SPECTRAL_SAMP_MSG)); + msg = (struct spectral_samp_msg *)qdf_mem_malloc( + sizeof(struct spectral_samp_msg)); if (msg) { - OS_MEMCPY(msg, &spec_samp_msg, sizeof(SPECTRAL_SAMP_MSG)); - ath_spectral_indicate( - params->sc, - (void *)msg, - sizeof(SPECTRAL_SAMP_MSG)); - OS_FREE(msg); - msg = NULL; + OS_MEMCPY(msg, &spec_samp_msg, + sizeof(struct spectral_samp_msg)); + ath_spectral_indicate(params->sc, (void *)msg, + sizeof(struct spectral_samp_msg)); + OS_FREE(msg); + msg = NULL; } else { - qdf_print("No buffer\n"); + qdf_print("No buffer\n"); } -#endif /* SPECTRAL_USE_NETLINK_SOCKETS */ +#endif /* SPECTRAL_USE_NETLINK_SOCKETS */ if (spectral->sc_spectral_noise_pwr_cal) - spectral_process_noise_pwr_report(spectral, &spec_samp_msg); + target_if_spectral_process_noise_pwr_report( + spectral, &spec_samp_msg); } #ifdef SPECTRAL_USE_NETLINK_SOCKETS -void target_if_spectral_prep_skb(struct target_if_spectral *spectral) +void +target_if_spectral_prep_skb(struct target_if_spectral *spectral) { spectral->spectral_skb = dev_alloc_skb(MAX_SPECTRAL_PAYLOAD); if (spectral->spectral_skb) { - skb_put(spectral->spectral_skb, MAX_SPECTRAL_PAYLOAD); - spectral->spectral_nlh = - (struct nlmsghdr *)spectral->spectral_skb->data; + skb_put(spectral->spectral_skb, MAX_SPECTRAL_PAYLOAD); + spectral->spectral_nlh = + (struct nlmsghdr *)spectral->spectral_skb->data; - OS_MEMZERO(spectral->spectral_nlh, sizeof(*spectral->spectral_nlh)); + OS_MEMZERO(spectral->spectral_nlh, + sizeof(*spectral->spectral_nlh)); - /* Possible bug that size of SPECTRAL_SAMP_MSG and SPECTRAL_MSG - * differ by 3 bytes so we miss 3 bytes - */ + /* + * Possible bug that size of struct spectral_samp_msg and + * SPECTRAL_MSG differ by 3 bytes so we miss 3 bytes + */ - spectral->spectral_nlh->nlmsg_len = - NLMSG_SPACE(sizeof(SPECTRAL_SAMP_MSG)); - spectral->spectral_nlh->nlmsg_pid = 0; - spectral->spectral_nlh->nlmsg_flags = 0; + spectral->spectral_nlh->nlmsg_len = + NLMSG_SPACE(sizeof(struct spectral_samp_msg)); + spectral->spectral_nlh->nlmsg_pid = 0; + spectral->spectral_nlh->nlmsg_flags = 0; } else { - spectral->spectral_skb = NULL; - spectral->spectral_nlh = NULL; + spectral->spectral_skb = NULL; + spectral->spectral_nlh = NULL; } } -void target_if_spectral_unicast_msg(struct target_if_spectral *spectral) +#if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE) +static inline void +target_if_init_spectral_skb_dst_pid( + struct target_if_spectral *spectral) +{ + NETLINK_CB(spectral->spectral_skb).dst_pid = + spectral->spectral_pid; +} +#else +static inline void +target_if_init_spectral_skb_dst_pid( + struct target_if_spectral *spectral) +{ +} +#endif /* VERSION - field depracated by newer kernel */ + +#if KERNEL_VERSION(3, 7, 0) > LINUX_VERSION_CODE +static inline void +target_if_init_spectral_skb_pid_portid( + struct target_if_spectral *spectral) +{ + NETLINK_CB(spectral->spectral_skb).pid = 0; /* from kernel */ +} +#else +static inline void +target_if_init_spectral_skb_pid_portid( + struct target_if_spectral *spectral) +{ + NETLINK_CB(spectral->spectral_skb).portid = 0; /* from kernel */ +} +#endif + +void +target_if_spectral_unicast_msg(struct target_if_spectral *spectral) { if (!spectral) { - qdf_print("%s Spectral is NULL\n", __func__); - return; + qdf_print("%s Spectral is NULL\n", __func__); + return; } if (!spectral->spectral_sock) { - qdf_print("%s Spectral Socket is invalid\n", __func__); - dev_kfree_skb(spectral->spectral_skb); - spectral->spectral_skb = NULL; - return; + qdf_print("%s Spectral Socket is invalid\n", __func__); + dev_kfree_skb(spectral->spectral_skb); + spectral->spectral_skb = NULL; + return; } if (spectral->spectral_skb) { -#if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE) - NETLINK_CB(spectral->spectral_skb).dst_pid = spectral->spectral_pid; -#endif /* VERSION - field depracated by newer kernel */ -#if KERNEL_VERSION(3, 7, 0) > LINUX_VERSION_CODE - NETLINK_CB(spectral->spectral_skb).pid = 0; /* from kernel */ -#else - NETLINK_CB(spectral->spectral_skb).portid = 0; /* from kernel */ -#endif - /* to mcast group 1<<0 */ - NETLINK_CB(spectral->spectral_skb).dst_group = 0; + target_if_init_spectral_skb_dst_pid(spectral); - netlink_unicast( - spectral->spectral_sock, - spectral->spectral_skb, - spectral->spectral_pid, - MSG_DONTWAIT); + target_if_init_spectral_skb_pid_portid(spectral); + + /* to mcast group 1<<0 */ + NETLINK_CB(spectral->spectral_skb).dst_group = 0; + + netlink_unicast(spectral->spectral_sock, + spectral->spectral_skb, + spectral->spectral_pid, MSG_DONTWAIT); } } -/* - * Function : target_if_spectral_bcast_msg - * Description : Passes the Spectral Message to Host - * Input : Pointer to spectral - * Output : Void - * - */ -void target_if_spectral_bcast_msg(struct target_if_spectral *spectral) +void +target_if_spectral_bcast_msg(struct target_if_spectral *spectral) { #if (KERNEL_VERSION(2, 6, 31) >= LINUX_VERSION_CODE) fd_set write_set; #endif - SPECTRAL_SAMP_MSG *msg = NULL; - struct nlmsghdr *nlh = NULL; + struct spectral_samp_msg *msg = NULL; + struct nlmsghdr *nlh = NULL; int status; #if (KERNEL_VERSION(2, 6, 31) >= LINUX_VERSION_CODE) @@ -522,7 +581,7 @@ void target_if_spectral_bcast_msg(struct target_if_spectral *spectral) #endif if (!spectral) - return; + return; if (!spectral->spectral_sock) { dev_kfree_skb(spectral->spectral_skb); @@ -531,15 +590,13 @@ void target_if_spectral_bcast_msg(struct target_if_spectral *spectral) } if (!spectral->spectral_skb) - return; + return; nlh = (struct nlmsghdr *)spectral->spectral_skb->data; - msg = (SPECTRAL_SAMP_MSG *)NLMSG_DATA(spectral->spectral_nlh); - /* print_samp_msg (msg, sc); */ - status = target_if_send_phydata( - spectral->pdev_obj, - spectral->spectral_sock, - spectral->spectral_skb); + msg = (struct spectral_samp_msg *)NLMSG_DATA(spectral->spectral_nlh); + status = target_if_send_phydata(spectral->pdev_obj, + spectral->spectral_sock, + spectral->spectral_skb); if (status == 0) spectral->spectral_sent_msg++; @@ -548,31 +605,29 @@ void target_if_spectral_bcast_msg(struct target_if_spectral *spectral) spectral->spectral_skb = NULL; } -void target_if_spectral_skb_dequeue(unsigned long data) +void +target_if_spectral_skb_dequeue(void *data) { - struct target_if_spectral *spectral = - (struct target_if_spectral *)data; + struct target_if_spectral *spectral = (struct target_if_spectral *)data; struct target_if_spectral_skb_event *sp_skb_event = NULL; qdf_spin_lock(&spectral->spectral_skbqlock); /* Deque all the spectral socket buffers queued */ while (!STAILQ_EMPTY(&spectral->spectral_skbq)) { - sp_skb_event = STAILQ_FIRST(&spectral->spectral_skbq); - if (sp_skb_event) { - spectral->spectral_skb = sp_skb_event->sp_skb; - spectral->spectral_nlh = sp_skb_event->sp_nlh; - STAILQ_REMOVE_HEAD( - &spectral->spectral_skbq, - spectral_skb_list); - qdf_spin_unlock(&spectral->spectral_skbqlock); - OS_FREE(sp_skb_event); - /* Broadcast spectral data after dequeing */ - target_if_spectral_bcast_msg(spectral); - qdf_spin_lock(&spectral->spectral_skbqlock); - } + sp_skb_event = STAILQ_FIRST(&spectral->spectral_skbq); + if (sp_skb_event) { + spectral->spectral_skb = sp_skb_event->sp_skb; + spectral->spectral_nlh = sp_skb_event->sp_nlh; + STAILQ_REMOVE_HEAD(&spectral->spectral_skbq, + spectral_skb_list); + qdf_spin_unlock(&spectral->spectral_skbqlock); + OS_FREE(sp_skb_event); + /* Broadcast spectral data after dequeing */ + target_if_spectral_bcast_msg(spectral); + qdf_spin_lock(&spectral->spectral_skbqlock); + } } qdf_spin_unlock(&spectral->spectral_skbqlock); } -#endif /* SPECTRAL_USE_NETLINK_SOCKETS */ - +#endif /* SPECTRAL_USE_NETLINK_SOCKETS */ diff --git a/target_if/spectral/target_if_spectral_phyerr.c b/target_if/spectral/target_if_spectral_phyerr.c index edbf233a32..c88ea8a285 100644 --- a/target_if/spectral/target_if_spectral_phyerr.c +++ b/target_if/spectral/target_if_spectral_phyerr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011,2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2011,2017-2018 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -32,32 +32,19 @@ #include extern int spectral_debug_level; -/* START of spectral GEN II HW specific function declarations */ -static int dump_summary_report_gen2( - SPECTRAL_PHYERR_TLV_GEN2 *ptlv, - int tlvlen, - bool is_160_format); -static int process_search_fft_report_gen2( - SPECTRAL_PHYERR_TLV_GEN2 *ptlv, - int tlvlen, - SPECTRAL_SEARCH_FFT_INFO_GEN2 *p_fft_info); -static int dump_adc_report_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, int tlvlen); -static int dump_search_fft_report_gen2( - SPECTRAL_PHYERR_TLV_GEN2 *ptlv, - int tlvlen, - bool is_160_format); -/* END of spectral GEN II HW specific function declarations */ - #if WLAN_SPECTRAL_ENABLE -/* - * Function : print_buf - * Description : Prints given buffer for given length - * Input : Pointer to buffer and length - * Output : Void +/** + * target_if_print_buf() - Prints given buffer for given length + * @pbuf: Pointer to buffer + * @len: length * + * Prints given buffer for given length + * + * Return: void */ -static void print_buf(u_int8_t *pbuf, int len) +static void +target_if_print_buf(uint8_t *pbuf, int len) { int i = 0; @@ -68,52 +55,44 @@ static void print_buf(u_int8_t *pbuf, int len) } } -/* - * Function : target_if_spectral_dump_fft - * Description : Dump Spectral FFT - * Input : Pointer to Spectral Phyerr FFT - * Output : Success/Failure - * - */ -int target_if_spectral_dump_fft(u_int8_t *pfft, int fftlen) +int +target_if_spectral_dump_fft(uint8_t *pfft, int fftlen) { int i = 0; - /* TODO : Do not delete the following print + /* + * TODO : Do not delete the following print * The scripts used to validate Spectral depend on this Print */ qdf_print("SPECTRAL : FFT Length is 0x%x (%d)\n", fftlen, fftlen); qdf_print("fft_data # "); - for (i = 0; i < fftlen; i++) { + for (i = 0; i < fftlen; i++) qdf_print("%d ", pfft[i]); - /* if (i % 32 == 31) - * qdf_print("\n"); - */ - } qdf_print("\n"); return 0; } -/* - * Function : target_if_spectral_send_tlv_to_host - * Description : Send the TLV information to Host - * Input : Pointer to the TLV - * Output : Success/Failure +/** + * target_if_spectral_send_tlv_to_host() - Send the TLV information to Host + * @spectral: Pointer to target_if spectral object + * @data: Pointer to the TLV + * @datalen: data length * + * Send the TLV information to Host + * + * Return: Success or failure */ - -int target_if_spectral_send_tlv_to_host( - struct target_if_spectral *spectral, - u_int8_t *data, - u_int32_t datalen) +int +target_if_spectral_send_tlv_to_host(struct target_if_spectral *spectral, + uint8_t *data, uint32_t datalen) { int status = true; target_if_spectral_prep_skb(spectral); if (spectral->spectral_skb) { spectral->spectral_nlh = - (struct nlmsghdr *)spectral->spectral_skb->data; + (struct nlmsghdr *)spectral->spectral_skb->data; memcpy(NLMSG_DATA(spectral->spectral_nlh), data, datalen); target_if_spectral_bcast_msg(spectral); } else { @@ -122,14 +101,8 @@ int target_if_spectral_send_tlv_to_host( return status; } -/* - * Function : dbg_print_SAMP_param - * Description : Print contents of SAMP struct - * Input : Pointer to SAMP message - * Output : Void - * - */ -void target_if_dbg_print_SAMP_param(struct target_if_samp_msg_params *p) +void +target_if_dbg_print_samp_param(struct target_if_samp_msg_params *p) { qdf_print("\nSAMP Packet : -------------------- START --------------" "------\n"); @@ -141,19 +114,13 @@ void target_if_dbg_print_SAMP_param(struct target_if_samp_msg_params *p) "-----\n"); } -/* - * Function : dbg_print_SAMP_msg - * Description : Print contents of SAMP Message - * Input : Pointer to SAMP message - * Output : Void - * - */ -void target_if_dbg_print_SAMP_msg(SPECTRAL_SAMP_MSG *ss_msg) +void +target_if_dbg_print_samp_msg(struct spectral_samp_msg *ss_msg) { int i = 0; - SPECTRAL_SAMP_DATA *p = &ss_msg->samp_data; - SPECTRAL_CLASSIFIER_PARAMS *pc = &p->classifier_params; + struct spectral_samp_data *p = &ss_msg->samp_data; + struct spectral_classifier_params *pc = &p->classifier_params; struct INTERF_SRC_RSP *pi = &p->interf_list; line(); @@ -194,19 +161,16 @@ void target_if_dbg_print_SAMP_msg(SPECTRAL_SAMP_MSG *ss_msg) qdf_print("inter count : %d\n", pi->count); for (i = 0; i < pi->count; i++) { - qdf_print("inter type : %d\n", pi->interf[i].interf_type); - qdf_print("min freq : %d\n", pi->interf[i].interf_min_freq); - qdf_print("max freq : %d\n", pi->interf[i].interf_max_freq); + qdf_print("inter type : %d\n", pi->interf[i].interf_type); + qdf_print("min freq : %d\n", + pi->interf[i].interf_min_freq); + qdf_print("max freq : %d\n", + pi->interf[i].interf_max_freq); } } -/* - * Function : get_offset_swar_sec80 - * Description : Get offset for SWAR according to the channel width - * Input : Channel width - * Output : Offset for SWAR algorithm - */ -uint32_t target_if_get_offset_swar_sec80(uint32_t channel_width) +uint32_t +target_if_get_offset_swar_sec80(uint32_t channel_width) { uint32_t offset = 0; @@ -230,27 +194,28 @@ uint32_t target_if_get_offset_swar_sec80(uint32_t channel_width) return offset; } -/* START of spectral GEN II HW specific functions */ - -/* - * Function : dump_summary_report_gen2 - * Description : Dump Spectral Summary Report - * Input : Pointer to Spectral Phyerr TLV and Length, flag indicating - * whether information provided by HW is in altered format for - * 802.11ac 160/80+80 MHz support (QCA9984 onwards). - * Output : Success/Failure +/** + * target_if_dump_summary_report_gen2() - Dump Spectral Summary Report for gen2 + * @ptlv: Pointer to Spectral Phyerr TLV + * @tlvlen: length + * @is_160_format: Indicates whether information provided by HW is in altered + * format for 802.11ac 160/80+80 MHz support (QCA9984 onwards) * + * Dump Spectral Summary Report for gen2 + * + * Return: Success/Failure */ -int dump_summary_report_gen2( - SPECTRAL_PHYERR_TLV_GEN2 *ptlv, - int tlvlen, - bool is_160_format) +static int +target_if_dump_summary_report_gen2(struct spectral_phyerr_tlv_gen2 *ptlv, + int tlvlen, bool is_160_format) { - /* For simplicity, everything is defined as uint32_t (except one). + /* + * For simplicity, everything is defined as uint32_t (except one). * Proper code will later use the right sizes. */ - /* For easy comparision between MDK team and OS team, the MDK script + /* + * For easy comparision between MDK team and OS team, the MDK script * variable names have been used */ @@ -268,132 +233,141 @@ int dump_summary_report_gen2( uint32_t ss_summary_C = 0; uint32_t ss_summary_D = 0; uint32_t ss_summary_E = 0; - SPECTRAL_PHYERR_HDR_GEN2 *phdr = - (SPECTRAL_PHYERR_HDR_GEN2 *)((u_int8_t *)ptlv + - sizeof(SPECTRAL_PHYERR_TLV_GEN2)); + struct spectral_phyerr_hdr_gen2 *phdr = + (struct spectral_phyerr_hdr_gen2 *)( + (uint8_t *)ptlv + + sizeof(struct spectral_phyerr_tlv_gen2)); qdf_print("SPECTRAL : SPECTRAL SUMMARY REPORT\n"); if (is_160_format) { - if (tlvlen != 20) { - qdf_print("SPECTRAL : Unexpected TLV length %d for Spectral " - "Summary Report! Hexdump follows\n", tlvlen); - print_buf((u_int8_t *)ptlv, tlvlen + 4); - return -EPERM; - } + if (tlvlen != 20) { + qdf_print + ("SPECTRAL : Unexpected TLV length %d for Spectral " + "Summary Report! Hexdump follows\n", tlvlen); + target_if_print_buf((uint8_t *)ptlv, tlvlen + 4); + return -EPERM; + } - /* Doing copy as the contents may not be aligned */ - qdf_mem_copy(&ss_summary_A, (u_int8_t *)phdr, sizeof(int)); - qdf_mem_copy( - &ss_summary_B, - (u_int8_t *)((u_int8_t *)phdr + sizeof(int)), - sizeof(int)); - qdf_mem_copy( - &ss_summary_C, - (u_int8_t *)((u_int8_t *)phdr + 2 * sizeof(int)), - sizeof(int)); - qdf_mem_copy( - &ss_summary_D, - (u_int8_t *)((u_int8_t *)phdr + 3 * sizeof(int)), - sizeof(int)); - qdf_mem_copy( - &ss_summary_E, - (u_int8_t *)((u_int8_t *)phdr + 4 * sizeof(int)), - sizeof(int)); + /* Doing copy as the contents may not be aligned */ + qdf_mem_copy(&ss_summary_A, (uint8_t *)phdr, sizeof(int)); + qdf_mem_copy(&ss_summary_B, + (uint8_t *)((uint8_t *)phdr + sizeof(int)), + sizeof(int)); + qdf_mem_copy(&ss_summary_C, + (uint8_t *)((uint8_t *)phdr + 2 * sizeof(int)), + sizeof(int)); + qdf_mem_copy(&ss_summary_D, + (uint8_t *)((uint8_t *)phdr + 3 * sizeof(int)), + sizeof(int)); + qdf_mem_copy(&ss_summary_E, + (uint8_t *)((uint8_t *)phdr + 4 * sizeof(int)), + sizeof(int)); - /*The following is adapted from MDK scripts for easier comparability */ + /* + * The following is adapted from MDK scripts for + * easier comparability + */ - recent_rfsat = ((ss_summary_A >> 8) & 0x1); - sscan_gidx = (ss_summary_A & 0xff); - qdf_print("sscan_gidx=%d, is_recent_rfsat=%d\n", - sscan_gidx, recent_rfsat); + recent_rfsat = ((ss_summary_A >> 8) & 0x1); + sscan_gidx = (ss_summary_A & 0xff); + qdf_print("sscan_gidx=%d, is_recent_rfsat=%d\n", + sscan_gidx, recent_rfsat); - /* First segment */ - agc_mb_gain = ((ss_summary_B >> 10) & 0x7f); - agc_total_gain = (ss_summary_B & 0x3ff); - nb_mask = ((ss_summary_C >> 22) & 0xff); - ob_flag = ((ss_summary_B >> 17) & 0x1); - peak_inx = (ss_summary_C & 0xfff); - if (peak_inx > 2047) - peak_inx = peak_inx - 4096; - peak_mag = ((ss_summary_C >> 12) & 0x3ff); + /* First segment */ + agc_mb_gain = ((ss_summary_B >> 10) & 0x7f); + agc_total_gain = (ss_summary_B & 0x3ff); + nb_mask = ((ss_summary_C >> 22) & 0xff); + ob_flag = ((ss_summary_B >> 17) & 0x1); + peak_inx = (ss_summary_C & 0xfff); + if (peak_inx > 2047) + peak_inx = peak_inx - 4096; + peak_mag = ((ss_summary_C >> 12) & 0x3ff); - qdf_print("agc_total_gain_segid0 = 0x%.2x, agc_mb_gain_segid0=%d\n", - agc_total_gain, agc_mb_gain); - qdf_print("nb_mask_segid0 = 0x%.2x, ob_flag_segid0=%d, " - "peak_index_segid0=%d, peak_mag_segid0=%d\n", - nb_mask, ob_flag, peak_inx, peak_mag); + qdf_print + ("agc_total_gain_segid0 = 0x%.2x, agc_mb_gain_segid0=%d\n", + agc_total_gain, agc_mb_gain); + qdf_print("nb_mask_segid0 = 0x%.2x, ob_flag_segid0=%d, " + "peak_index_segid0=%d, peak_mag_segid0=%d\n", nb_mask, + ob_flag, peak_inx, peak_mag); - /* Second segment */ - agc_mb_gain = ((ss_summary_D >> 10) & 0x7f); - agc_total_gain = (ss_summary_D & 0x3ff); - nb_mask = ((ss_summary_E >> 22) & 0xff); - ob_flag = ((ss_summary_D >> 17) & 0x1); - peak_inx = (ss_summary_E & 0xfff); - if (peak_inx > 2047) - peak_inx = peak_inx - 4096; - peak_mag = ((ss_summary_E >> 12) & 0x3ff); + /* Second segment */ + agc_mb_gain = ((ss_summary_D >> 10) & 0x7f); + agc_total_gain = (ss_summary_D & 0x3ff); + nb_mask = ((ss_summary_E >> 22) & 0xff); + ob_flag = ((ss_summary_D >> 17) & 0x1); + peak_inx = (ss_summary_E & 0xfff); + if (peak_inx > 2047) + peak_inx = peak_inx - 4096; + peak_mag = ((ss_summary_E >> 12) & 0x3ff); - qdf_print("agc_total_gain_segid1 = 0x%.2x, agc_mb_gain_segid1=%d\n", - agc_total_gain, agc_mb_gain); - qdf_print("nb_mask_segid1 = 0x%.2x, ob_flag_segid1=%d, " - "peak_index_segid1=%d, peak_mag_segid1=%d\n", - nb_mask, ob_flag, peak_inx, peak_mag); + qdf_print + ("agc_total_gain_segid1 = 0x%.2x, agc_mb_gain_segid1=%d\n", + agc_total_gain, agc_mb_gain); + qdf_print("nb_mask_segid1 = 0x%.2x, ob_flag_segid1=%d, " + "peak_index_segid1=%d, peak_mag_segid1=%d\n", nb_mask, + ob_flag, peak_inx, peak_mag); } else { - if (tlvlen != 8) { - qdf_print("SPECTRAL : Unexpected TLV length %d for Spectral " - "Summary Report! Hexdump follows\n", tlvlen); - print_buf((u_int8_t *)ptlv, tlvlen + 4); - return -EPERM; - } + if (tlvlen != 8) { + qdf_print + ("SPECTRAL : Unexpected TLV length %d for Spectral " + "Summary Report! Hexdump follows\n", tlvlen); + target_if_print_buf((uint8_t *)ptlv, tlvlen + 4); + return -EPERM; + } - /* Doing copy as the contents may not be aligned */ - qdf_mem_copy(&ss_summary_A, (u_int8_t *)phdr, sizeof(int)); - qdf_mem_copy( - &ss_summary_B, - (u_int8_t *)((u_int8_t *)phdr + sizeof(int)), - sizeof(int)); + /* Doing copy as the contents may not be aligned */ + qdf_mem_copy(&ss_summary_A, (uint8_t *)phdr, sizeof(int)); + qdf_mem_copy(&ss_summary_B, + (uint8_t *)((uint8_t *)phdr + sizeof(int)), + sizeof(int)); - nb_mask = ((ss_summary_B >> 22) & 0xff); - ob_flag = ((ss_summary_B >> 30) & 0x1); - peak_inx = (ss_summary_B & 0xfff); + nb_mask = ((ss_summary_B >> 22) & 0xff); + ob_flag = ((ss_summary_B >> 30) & 0x1); + peak_inx = (ss_summary_B & 0xfff); - if (peak_inx > 2047) - peak_inx = peak_inx - 4096; + if (peak_inx > 2047) + peak_inx = peak_inx - 4096; - peak_mag = ((ss_summary_B >> 12) & 0x3ff); - agc_mb_gain = ((ss_summary_A >> 24) & 0x7f); - agc_total_gain = (ss_summary_A & 0x3ff); - sscan_gidx = ((ss_summary_A >> 16) & 0xff); - recent_rfsat = ((ss_summary_B >> 31) & 0x1); + peak_mag = ((ss_summary_B >> 12) & 0x3ff); + agc_mb_gain = ((ss_summary_A >> 24) & 0x7f); + agc_total_gain = (ss_summary_A & 0x3ff); + sscan_gidx = ((ss_summary_A >> 16) & 0xff); + recent_rfsat = ((ss_summary_B >> 31) & 0x1); - qdf_print("nb_mask = 0x%.2x, ob_flag=%d, peak_index=%d, peak_mag=%d, " - "agc_mb_gain=%d, agc_total_gain=%d, sscan_gidx=%d, " - "recent_rfsat=%d\n", - nb_mask, ob_flag, peak_inx, peak_mag, agc_mb_gain, - agc_total_gain, sscan_gidx, recent_rfsat); + qdf_print + ("nb_mask = 0x%.2x, ob_flag=%d, peak_index=%d, " + "peak_mag=%d, " + "agc_mb_gain=%d, agc_total_gain=%d, sscan_gidx=%d, " + "recent_rfsat=%d\n", nb_mask, ob_flag, peak_inx, peak_mag, + agc_mb_gain, agc_total_gain, sscan_gidx, recent_rfsat); } return 0; } -/* - * Function : process_search_fft_report_gen2 - * Description : Process Search FFT Report - * Input : Pointer to Spectral Phyerr TLV and Length and pointer to - * search fft info - * Output : Success/Failure +/** + * target_if_process_sfft_report_gen2() - Process Search FFT Report + * @ptlv: Pointer to Spectral Phyerr TLV + * @tlvlen: length + * @p_fft_info: Pointer to search fft info * + * Dump Spectral Summary Report for gen2 + * + * Return: Success/Failure */ -int process_search_fft_report_gen2( - SPECTRAL_PHYERR_TLV_GEN2 *ptlv, - int tlvlen, - SPECTRAL_SEARCH_FFT_INFO_GEN2 *p_fft_info) +static int +target_if_process_sfft_report_gen2( + struct spectral_phyerr_tlv_gen2 *ptlv, + int tlvlen, + struct spectral_search_fft_info_gen2 *p_fft_info) { - /* For simplicity, everything is defined as uint32_t (except one). + /* + * For simplicity, everything is defined as uint32_t (except one). * Proper code will later use the right sizes. */ - /* For easy comparision between MDK team and OS team, the MDK script + /* + * For easy comparision between MDK team and OS team, the MDK script * variable names have been used */ uint32_t relpwr_db; @@ -408,32 +382,33 @@ int process_search_fft_report_gen2( uint32_t fft_summary_A = 0; uint32_t fft_summary_B = 0; - u_int8_t *tmp = (u_int8_t *)ptlv; - SPECTRAL_PHYERR_HDR_GEN2 *phdr = - (SPECTRAL_PHYERR_HDR_GEN2 *)(tmp + sizeof(SPECTRAL_PHYERR_TLV_GEN2)); + uint8_t *tmp = (uint8_t *)ptlv; + struct spectral_phyerr_hdr_gen2 *phdr = + (struct spectral_phyerr_hdr_gen2 *)( + tmp + + sizeof(struct spectral_phyerr_tlv_gen2)); /* Relook this */ if (tlvlen < 8) { qdf_print("SPECTRAL : Unexpected TLV length %d for Spectral " "Summary Report! Hexdump follows\n", tlvlen); - print_buf((u_int8_t *)ptlv, tlvlen + 4); + target_if_print_buf((uint8_t *)ptlv, tlvlen + 4); return -EPERM; } /* Doing copy as the contents may not be aligned */ - qdf_mem_copy(&fft_summary_A, (u_int8_t *)phdr, sizeof(int)); - qdf_mem_copy( - &fft_summary_B, - (u_int8_t *)((u_int8_t *)phdr + sizeof(int)), - sizeof(int)); + qdf_mem_copy(&fft_summary_A, (uint8_t *)phdr, sizeof(int)); + qdf_mem_copy(&fft_summary_B, + (uint8_t *)((uint8_t *)phdr + sizeof(int)), + sizeof(int)); - relpwr_db = ((fft_summary_B >> 26) & 0x3f); + relpwr_db = ((fft_summary_B >> 26) & 0x3f); num_str_bins_ib = fft_summary_B & 0xff; - base_pwr = ((fft_summary_A >> 14) & 0x1ff); + base_pwr = ((fft_summary_A >> 14) & 0x1ff); total_gain_info = ((fft_summary_A >> 23) & 0x1ff); - fft_chn_idx = ((fft_summary_A >> 12) & 0x3); - peak_inx = fft_summary_A & 0xfff; + fft_chn_idx = ((fft_summary_A >> 12) & 0x3); + peak_inx = fft_summary_A & 0xfff; if (peak_inx > 2047) peak_inx = peak_inx - 4096; @@ -443,33 +418,38 @@ int process_search_fft_report_gen2( /* Populate the Search FFT Info */ if (p_fft_info) { - p_fft_info->relpwr_db = relpwr_db; - p_fft_info->num_str_bins_ib = num_str_bins_ib; - p_fft_info->base_pwr = base_pwr; - p_fft_info->total_gain_info = total_gain_info; - p_fft_info->fft_chn_idx = fft_chn_idx; - p_fft_info->peak_inx = peak_inx; - p_fft_info->avgpwr_db = avgpwr_db; - p_fft_info->peak_mag = peak_mag; + p_fft_info->relpwr_db = relpwr_db; + p_fft_info->num_str_bins_ib = num_str_bins_ib; + p_fft_info->base_pwr = base_pwr; + p_fft_info->total_gain_info = total_gain_info; + p_fft_info->fft_chn_idx = fft_chn_idx; + p_fft_info->peak_inx = peak_inx; + p_fft_info->avgpwr_db = avgpwr_db; + p_fft_info->peak_mag = peak_mag; } return 0; } -/* - * Function : dump_adc_report_gen2 - * Description : Dump ADC Reports - * Input : Pointer to Spectral Phyerr TLV and Length - * Output : Success/Failure +/** + * target_if_dump_adc_report_gen2() - Dump ADC Reports for gen2 + * @ptlv: Pointer to Spectral Phyerr TLV + * @tlvlen: length * + * Dump ADC Reports for gen2 + * + * Return: Success/Failure */ -int dump_adc_report_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, int tlvlen) +static int +target_if_dump_adc_report_gen2( + struct spectral_phyerr_tlv_gen2 *ptlv, int tlvlen) { int i; uint32_t *pdata; uint32_t data; - /* For simplicity, everything is defined as uint32_t (except one). + /* + * For simplicity, everything is defined as uint32_t (except one). * Proper code will later use the right sizes. */ uint32_t samp_fmt; @@ -480,7 +460,7 @@ int dump_adc_report_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, int tlvlen) uint32_t adc_summary = 0; - u_int8_t *ptmp = (u_int8_t *)ptlv; + uint8_t *ptmp = (uint8_t *)ptlv; qdf_print("SPECTRAL : ADC REPORT\n"); @@ -488,11 +468,11 @@ int dump_adc_report_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, int tlvlen) if (tlvlen < 4) { qdf_print("Unexpected TLV length %d for ADC Report! Hexdump" " follows\n", tlvlen); - print_buf((u_int8_t *)ptlv, tlvlen + 4); + target_if_print_buf((uint8_t *)ptlv, tlvlen + 4); return -EPERM; } - qdf_mem_copy(&adc_summary, (u_int8_t *)(ptlv + 4), sizeof(int)); + qdf_mem_copy(&adc_summary, (uint8_t *)(ptlv + 4), sizeof(int)); samp_fmt = ((adc_summary >> 28) & 0x1); chn_idx = ((adc_summary >> 24) & 0x3); @@ -505,72 +485,76 @@ int dump_adc_report_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, int tlvlen) agc_mb_gain, agc_total_gain); for (i = 0; i < (tlvlen / 4); i++) { - pdata = (uint32_t *)(ptmp + 4 + i * 4); - data = *pdata; + pdata = (uint32_t *)(ptmp + 4 + i * 4); + data = *pdata; - /* Interpreting capture format 1 */ - if (1) { - uint8_t i1; - uint8_t q1; - uint8_t i2; - uint8_t q2; - int8_t si1; - int8_t sq1; - int8_t si2; - int8_t sq2; + /* Interpreting capture format 1 */ + if (1) { + uint8_t i1; + uint8_t q1; + uint8_t i2; + uint8_t q2; + int8_t si1; + int8_t sq1; + int8_t si2; + int8_t sq2; - i1 = data & 0xff; - q1 = (data >> 8) & 0xff; - i2 = (data >> 16) & 0xff; - q2 = (data >> 24) & 0xff; + i1 = data & 0xff; + q1 = (data >> 8) & 0xff; + i2 = (data >> 16) & 0xff; + q2 = (data >> 24) & 0xff; - if (i1 > 127) - si1 = i1 - 256; - else - si1 = i1; + if (i1 > 127) + si1 = i1 - 256; + else + si1 = i1; - if (q1 > 127) - sq1 = q1 - 256; - else - sq1 = q1; + if (q1 > 127) + sq1 = q1 - 256; + else + sq1 = q1; - if (i2 > 127) - si2 = i2 - 256; - else - si2 = i2; + if (i2 > 127) + si2 = i2 - 256; + else + si2 = i2; - if (q2 > 127) - sq2 = q2 - 256; - else - sq2 = q2; + if (q2 > 127) + sq2 = q2 - 256; + else + sq2 = q2; - qdf_print("SPECTRAL ADC : Interpreting capture format 1\n"); - qdf_print("adc_data_format_1 # %d %d %d\n", 2 * i, si1, sq1); - qdf_print("adc_data_format_1 # %d %d %d\n", - 2 * i + 1, si2, sq2); - } + qdf_print + ("SPECTRAL ADC : Interpreting capture format 1\n"); + qdf_print("adc_data_format_1 # %d %d %d\n", 2 * i, si1, + sq1); + qdf_print("adc_data_format_1 # %d %d %d\n", 2 * i + 1, + si2, sq2); + } - /* Interpreting capture format 0 */ - if (1) { - uint16_t i1; - uint16_t q1; - int16_t si1; - int16_t sq1; + /* Interpreting capture format 0 */ + if (1) { + uint16_t i1; + uint16_t q1; + int16_t si1; + int16_t sq1; - i1 = data & 0xffff; - q1 = (data >> 16) & 0xffff; - if (i1 > 32767) - si1 = i1 - 65536; - else - si1 = i1; + i1 = data & 0xffff; + q1 = (data >> 16) & 0xffff; + if (i1 > 32767) + si1 = i1 - 65536; + else + si1 = i1; - if (q1 > 32767) - sq1 = q1 - 65536; - else - sq1 = q1; - qdf_print("SPECTRAL ADC : Interpreting capture format 0\n"); - qdf_print("adc_data_format_2 # %d %d %d\n", i, si1, sq1); - } + if (q1 > 32767) + sq1 = q1 - 65536; + else + sq1 = q1; + qdf_print + ("SPECTRAL ADC : Interpreting capture format 0\n"); + qdf_print("adc_data_format_2 # %d %d %d\n", i, si1, + sq1); + } } qdf_print("\n"); @@ -578,27 +562,29 @@ int dump_adc_report_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, int tlvlen) return 0; } -/* - * Function : dump_search_fft_report_gen2 - * Description : Process Search FFT Report - * Input : Pointer to Spectral Phyerr TLV and Length, flag indicating - * whether information provided by HW is in altered format for - * 802.11ac 160/80+80 MHz support (QCA9984 onwards). - * Output : Success/Failure +/** + * target_if_dump_sfft_report_gen2() - Process Search FFT Report for gen2 + * @ptlv: Pointer to Spectral Phyerr TLV + * @tlvlen: length + * @is_160_format: Indicates 160 format * + * Process Search FFT Report for gen2 + * + * Return: Success/Failure */ -int dump_search_fft_report_gen2( - SPECTRAL_PHYERR_TLV_GEN2 *ptlv, - int tlvlen, - bool is_160_format) +static int +target_if_dump_sfft_report_gen2(struct spectral_phyerr_tlv_gen2 *ptlv, + int tlvlen, bool is_160_format) { int i; uint32_t fft_mag; - /* For simplicity, everything is defined as uint32_t (except one). + /* + * For simplicity, everything is defined as uint32_t (except one). * Proper code will later use the right sizes. */ - /* For easy comparision between MDK team and OS team, the MDK script + /* + * For easy comparision between MDK team and OS team, the MDK script * variable names have been used */ uint32_t relpwr_db; @@ -610,15 +596,17 @@ int dump_search_fft_report_gen2( int16_t peak_inx; uint32_t avgpwr_db; uint32_t peak_mag; - u_int8_t segid; + uint8_t segid; uint32_t fft_summary_A = 0; uint32_t fft_summary_B = 0; uint32_t fft_summary_C = 0; - u_int8_t *tmp = (u_int8_t *)ptlv; - SPECTRAL_PHYERR_HDR_GEN2 *phdr = - (SPECTRAL_PHYERR_HDR_GEN2 *)(tmp + sizeof(SPECTRAL_PHYERR_TLV_GEN2)); - u_int32_t segid_skiplen = 0; + uint8_t *tmp = (uint8_t *)ptlv; + struct spectral_phyerr_hdr_gen2 *phdr = + (struct spectral_phyerr_hdr_gen2 *)( + tmp + + sizeof(struct spectral_phyerr_tlv_gen2)); + uint32_t segid_skiplen = 0; if (is_160_format) segid_skiplen = sizeof(SPECTRAL_SEGID_INFO); @@ -629,29 +617,27 @@ int dump_search_fft_report_gen2( if (tlvlen < (8 + segid_skiplen)) { qdf_print("SPECTRAL : Unexpected TLV length %d for Spectral " "Summary Report! Hexdump follows\n", tlvlen); - print_buf((u_int8_t *)ptlv, tlvlen + 4); + target_if_print_buf((uint8_t *)ptlv, tlvlen + 4); return -EPERM; } /* Doing copy as the contents may not be aligned */ - qdf_mem_copy(&fft_summary_A, (u_int8_t *)phdr, sizeof(int)); - qdf_mem_copy( - &fft_summary_B, - (u_int8_t *)((u_int8_t *)phdr + sizeof(int)), - sizeof(int)); + qdf_mem_copy(&fft_summary_A, (uint8_t *)phdr, sizeof(int)); + qdf_mem_copy(&fft_summary_B, + (uint8_t *)((uint8_t *)phdr + sizeof(int)), + sizeof(int)); if (is_160_format) - qdf_mem_copy( - &fft_summary_C, - (u_int8_t *)((u_int8_t *)phdr + 2 * sizeof(int)), - sizeof(int)); + qdf_mem_copy(&fft_summary_C, + (uint8_t *)((uint8_t *)phdr + 2 * sizeof(int)), + sizeof(int)); - relpwr_db = ((fft_summary_B >> 26) & 0x3f); + relpwr_db = ((fft_summary_B >> 26) & 0x3f); num_str_bins_ib = fft_summary_B & 0xff; - base_pwr = ((fft_summary_A >> 14) & 0x1ff); + base_pwr = ((fft_summary_A >> 14) & 0x1ff); total_gain_info = ((fft_summary_A >> 23) & 0x1ff); - fft_chn_idx = ((fft_summary_A >> 12) & 0x3); - peak_inx = fft_summary_A & 0xfff; + fft_chn_idx = ((fft_summary_A >> 12) & 0x3); + peak_inx = fft_summary_A & 0xfff; if (peak_inx > 2047) peak_inx = peak_inx - 4096; @@ -672,8 +658,8 @@ int dump_search_fft_report_gen2( qdf_print("FFT bins:\n"); for (i = 0; i < (tlvlen - 8 - segid_skiplen); i++) { - fft_mag = ((u_int8_t *)ptlv)[12 + segid_skiplen + i]; - qdf_print("%d %d, ", i, fft_mag); + fft_mag = ((uint8_t *)ptlv)[12 + segid_skiplen + i]; + qdf_print("%d %d, ", i, fft_mag); } qdf_print("\n"); @@ -681,20 +667,36 @@ int dump_search_fft_report_gen2( return 0; } -/* - * Function : spectral_process_phyerr_gen2 - * Description : Process PHY Error - * Input : Pointer to buffer - * Output : Success/Failure +#ifdef SPECTRAL_DEBUG_SAMP_MSG +/** + * target_if_spectral_log_SAMP_param() - Log SAMP parameters + * @params: Reference to target_if_samp_msg_params * + * API to log spectral SAMP message parameters + * + * Return: None */ -int spectral_process_phyerr_gen2( - struct target_if_spectral *spectral, - u_int8_t *data, - u_int32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual, - struct target_if_spectral_chan_info *p_chaninfo, - u_int64_t tsf64, - struct target_if_spectral_acs_stats *acs_stats) +static void +target_if_spectral_log_SAMP_param(struct target_if_samp_msg_params *params) +{ + target_if_dbg_print_samp_param(params); +} + +#else +static void +target_if_spectral_log_SAMP_param(struct target_if_samp_msg_params *params) +{ +} +#endif + +int +target_if_process_phyerr_gen2(struct target_if_spectral *spectral, + uint8_t *data, + uint32_t datalen, + struct target_if_spectral_rfqual_info *p_rfqual, + struct target_if_spectral_chan_info *p_chaninfo, + uint64_t tsf64, + struct target_if_spectral_acs_stats *acs_stats) { /* * XXX : The classifier do not use all the members of the SAMP @@ -723,303 +725,309 @@ int spectral_process_phyerr_gen2( */ struct target_if_samp_msg_params params; - SPECTRAL_SEARCH_FFT_INFO_GEN2 search_fft_info; - SPECTRAL_SEARCH_FFT_INFO_GEN2 *p_sfft = &search_fft_info; - SPECTRAL_SEARCH_FFT_INFO_GEN2 search_fft_info_sec80; - SPECTRAL_SEARCH_FFT_INFO_GEN2 *p_sfft_sec80 = &search_fft_info_sec80; - u_int32_t segid_skiplen = 0; + struct spectral_search_fft_info_gen2 search_fft_info; + struct spectral_search_fft_info_gen2 *p_sfft = &search_fft_info; + struct spectral_search_fft_info_gen2 search_fft_info_sec80; + struct spectral_search_fft_info_gen2 *p_sfft_sec80 = + &search_fft_info_sec80; + uint32_t segid_skiplen = 0; - int8_t rssi_up = 0; + int8_t rssi_up = 0; int8_t rssi_low = 0; int8_t chn_idx_highest_enabled = 0; - int8_t chn_idx_lowest_enabled = 0; + int8_t chn_idx_lowest_enabled = 0; - u_int8_t control_rssi = 0; - u_int8_t extension_rssi = 0; - u_int8_t combined_rssi = 0; + uint8_t control_rssi = 0; + uint8_t extension_rssi = 0; + uint8_t combined_rssi = 0; - u_int32_t tstamp = 0; + uint32_t tstamp = 0; - struct target_if_spectral_ops *p_sops = GET_TIF_SPECTRAL_OPS(spectral); + struct target_if_spectral_ops *p_sops = + GET_TARGET_IF_SPECTRAL_OPS(spectral); - SPECTRAL_PHYERR_TLV_GEN2 *ptlv = (SPECTRAL_PHYERR_TLV_GEN2 *)data; - SPECTRAL_PHYERR_TLV_GEN2 *ptlv_sec80 = NULL; - SPECTRAL_PHYERR_FFT_GEN2 *pfft = NULL; - SPECTRAL_PHYERR_FFT_GEN2 *pfft_sec80 = NULL; + struct spectral_phyerr_tlv_gen2 *ptlv = + (struct spectral_phyerr_tlv_gen2 *)data; + struct spectral_phyerr_tlv_gen2 *ptlv_sec80 = NULL; + struct spectral_phyerr_fft_gen2 *pfft = NULL; + struct spectral_phyerr_fft_gen2 *pfft_sec80 = NULL; - u_int8_t segid = 0; - u_int8_t segid_sec80 = 0; + uint8_t segid = 0; + uint8_t segid_sec80 = 0; if (spectral->is_160_format) - segid_skiplen = sizeof(SPECTRAL_SEGID_INFO); + segid_skiplen = sizeof(SPECTRAL_SEGID_INFO); - pfft = (SPECTRAL_PHYERR_FFT_GEN2 *)(data + - sizeof(SPECTRAL_PHYERR_TLV_GEN2) + - sizeof(SPECTRAL_PHYERR_HDR_GEN2) + segid_skiplen); + pfft = (struct spectral_phyerr_fft_gen2 *)( + data + + sizeof(struct spectral_phyerr_tlv_gen2) + + sizeof(struct spectral_phyerr_hdr_gen2) + + segid_skiplen); - /* XXX Extend SPECTRAL_DPRINTK() to use spectral_debug_level, + /* + * XXX Extend SPECTRAL_DPRINTK() to use spectral_debug_level, * and use this facility inside spectral_dump_phyerr_data() * and supporting functions. */ - if (spectral_debug_level & ATH_DEBUG_SPECTRAL2) - spectral_dump_phyerr_data_gen2(data, datalen, spectral->is_160_format); + if (spectral_debug_level & DEBUG_SPECTRAL2) + target_if_spectral_dump_phyerr_data_gen2( + data, datalen, + spectral->is_160_format); - if (spectral_debug_level & ATH_DEBUG_SPECTRAL4) { - spectral_dump_phyerr_data_gen2(data, datalen, spectral->is_160_format); - spectral_debug_level = ATH_DEBUG_SPECTRAL; + if (spectral_debug_level & DEBUG_SPECTRAL4) { + target_if_spectral_dump_phyerr_data_gen2( + data, datalen, + spectral->is_160_format); + spectral_debug_level = DEBUG_SPECTRAL; } if (ptlv->signature != SPECTRAL_PHYERR_SIGNATURE_GEN2) { - /* EV# 118023: We tentatively disable the below print - * and provide stats instead. - */ - /* qdf_print("SPECTRAL : Mismatch\n"); */ - spectral->diag_stats.spectral_mismatch++; - return -EPERM; + /* + * EV# 118023: We tentatively disable the below print + * and provide stats instead. + */ + spectral->diag_stats.spectral_mismatch++; + return -EPERM; } OS_MEMZERO(¶ms, sizeof(params)); if (ptlv->tag == TLV_TAG_SEARCH_FFT_REPORT_GEN2) { - if (spectral->is_160_format) { - segid = *((SPECTRAL_SEGID_INFO *)( - (u_int8_t *)ptlv + - sizeof(SPECTRAL_PHYERR_TLV_GEN2) + - sizeof(SPECTRAL_PHYERR_HDR_GEN2))); + if (spectral->is_160_format) { + segid = *((SPECTRAL_SEGID_INFO *)( + (uint8_t *)ptlv + + sizeof(struct spectral_phyerr_tlv_gen2) + + sizeof(struct spectral_phyerr_hdr_gen2))); - if (segid != 0) { - spectral->diag_stats.spectral_vhtseg1id_mismatch++; - return -EPERM; + if (segid != 0) { + struct spectral_diag_stats *p_diag_stats = + &spectral->diag_stats; + p_diag_stats->spectral_vhtseg1id_mismatch++; + return -EPERM; + } } - } - process_search_fft_report_gen2(ptlv, ptlv->length, &search_fft_info); + target_if_process_sfft_report_gen2(ptlv, ptlv->length, + &search_fft_info); - tstamp = p_sops->get_tsf64(spectral) & SPECTRAL_TSMASK; + tstamp = p_sops->get_tsf64(spectral) & SPECTRAL_TSMASK; - combined_rssi = p_rfqual->rssi_comb; + combined_rssi = p_rfqual->rssi_comb; - if (spectral->upper_is_control) - rssi_up = control_rssi; - else - rssi_up = extension_rssi; + if (spectral->upper_is_control) + rssi_up = control_rssi; + else + rssi_up = extension_rssi; - if (spectral->lower_is_control) - rssi_low = control_rssi; - else - rssi_low = extension_rssi; + if (spectral->lower_is_control) + rssi_low = control_rssi; + else + rssi_low = extension_rssi; - params.rssi = p_rfqual->rssi_comb; - params.lower_rssi = rssi_low; - params.upper_rssi = rssi_up; + params.rssi = p_rfqual->rssi_comb; + params.lower_rssi = rssi_low; + params.upper_rssi = rssi_up; - if (spectral->sc_spectral_noise_pwr_cal) { - params.chain_ctl_rssi[0] = - p_rfqual->pc_rssi_info[0].rssi_pri20; - params.chain_ctl_rssi[1] = - p_rfqual->pc_rssi_info[1].rssi_pri20; - params.chain_ctl_rssi[2] = - p_rfqual->pc_rssi_info[2].rssi_pri20; - params.chain_ext_rssi[0] = - p_rfqual->pc_rssi_info[0].rssi_sec20; - params.chain_ext_rssi[1] = - p_rfqual->pc_rssi_info[1].rssi_sec20; - params.chain_ext_rssi[2] = - p_rfqual->pc_rssi_info[2].rssi_sec20; - } + if (spectral->sc_spectral_noise_pwr_cal) { + params.chain_ctl_rssi[0] = + p_rfqual->pc_rssi_info[0].rssi_pri20; + params.chain_ctl_rssi[1] = + p_rfqual->pc_rssi_info[1].rssi_pri20; + params.chain_ctl_rssi[2] = + p_rfqual->pc_rssi_info[2].rssi_pri20; + params.chain_ext_rssi[0] = + p_rfqual->pc_rssi_info[0].rssi_sec20; + params.chain_ext_rssi[1] = + p_rfqual->pc_rssi_info[1].rssi_sec20; + params.chain_ext_rssi[2] = + p_rfqual->pc_rssi_info[2].rssi_sec20; + } - /* - * XXX : This actually depends on the programmed chain mask - * There are three chains in Peregrine and 4 chains in Beeliner & - * Cascade - * This value decides the per-chain enable mask to select - * the input ADC for search FTT. - * For modes upto VHT80, if more than one chain is enabled, the - * max valid chain - * is used. LSB corresponds to chain zero. - * For VHT80_80 and VHT160, the lowest enabled chain is used for - * primary - * detection and highest enabled chain is used for secondary - * detection. - * - * XXX: The current algorithm do not use these control and extension - * channel - * Instead, it just relies on the combined RSSI values only. - * For fool-proof detection algorithm, we should take these RSSI - * values - * in to account. This is marked for future enhancements. - */ - chn_idx_highest_enabled = ((spectral->params.ss_chn_mask & 0x8) ? 3 : - (spectral->params.ss_chn_mask & 0x4) ? 2 : - (spectral->params.ss_chn_mask & 0x2) ? 1 : 0); - chn_idx_lowest_enabled = ((spectral->params.ss_chn_mask & 0x1) ? 0 : - (spectral->params.ss_chn_mask & 0x2) ? 1 : - (spectral->params.ss_chn_mask & 0x4) ? 2 : 3); - control_rssi = (u_int8_t) - p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_pri20; - extension_rssi = (u_int8_t) - p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_sec20; - - params.bwinfo = 0; - params.tstamp = 0; - params.max_mag = p_sfft->peak_mag; - - params.max_index = p_sfft->peak_inx; - params.max_exp = 0; - params.peak = 0; - params.bin_pwr_data = (u_int8_t *)pfft; - params.freq = p_sops->get_current_channel(spectral); - params.freq_loading = 0; - - params.interf_list.count = 0; - params.max_lower_index = 0; - params.max_upper_index = 0; - params.nb_lower = 0; - params.nb_upper = 0; - /* - * For modes upto VHT80, the noise floor is populated with the one - * corresponding - * to the highest enabled antenna chain - */ - params.noise_floor = - p_rfqual->noise_floor[chn_idx_highest_enabled]; - params.datalen = ptlv->length; - params.pwr_count = ptlv->length - - sizeof(SPECTRAL_PHYERR_HDR_GEN2) - segid_skiplen; - params.tstamp = (tsf64 & SPECTRAL_TSMASK); - - acs_stats->ctrl_nf = params.noise_floor; - acs_stats->ext_nf = params.noise_floor; - acs_stats->nfc_ctl_rssi = control_rssi; - acs_stats->nfc_ext_rssi = extension_rssi; - - if (spectral->is_160_format && - spectral->ch_width == CH_WIDTH_160MHZ) { - /* We expect to see one more Search FFT report, and it should - * be equal in size to the current one. + /* + * XXX : This actually depends on the programmed chain mask + * This value decides the per-chain enable mask to select + * the input ADC for search FTT. + * For modes upto VHT80, if more than one chain is + * enabled, the max valid chain + * is used. LSB corresponds to chain zero. + * For VHT80_80 and VHT160, the lowest enabled chain is + * used for primary + * detection and highest enabled chain is used for + * secondary detection. + * + * XXX : The current algorithm do not use these control and + * extension channel + * Instead, it just relies on the combined RSSI values + * only. + * For fool-proof detection algorithm, we should take + * these RSSI values in to account. + * This is marked for future enhancements. */ - if (datalen < (2 * (sizeof(SPECTRAL_PHYERR_TLV_GEN2) + - ptlv->length))) { - spectral->diag_stats.spectral_sec80_sfft_insufflen++; - return -EPERM; - } + chn_idx_highest_enabled = + ((spectral->params.ss_chn_mask & 0x8) ? 3 : + (spectral->params.ss_chn_mask & 0x4) ? 2 : + (spectral->params.ss_chn_mask & 0x2) ? 1 : 0); + chn_idx_lowest_enabled = + ((spectral->params.ss_chn_mask & 0x1) ? 0 : + (spectral->params.ss_chn_mask & 0x2) ? 1 : + (spectral->params.ss_chn_mask & 0x4) ? 2 : 3); + control_rssi = (uint8_t) + p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_pri20; + extension_rssi = (uint8_t) + p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_sec20; - ptlv_sec80 = (SPECTRAL_PHYERR_TLV_GEN2 *)( - data + - sizeof(SPECTRAL_PHYERR_TLV_GEN2) + - ptlv->length); + params.bwinfo = 0; + params.tstamp = 0; + params.max_mag = p_sfft->peak_mag; - if (ptlv_sec80->signature != SPECTRAL_PHYERR_SIGNATURE_GEN2) { - spectral->diag_stats.spectral_mismatch++; - return -EPERM; - } + params.max_index = p_sfft->peak_inx; + params.max_exp = 0; + params.peak = 0; + params.bin_pwr_data = (uint8_t *)pfft; + params.freq = p_sops->get_current_channel(spectral); + params.freq_loading = 0; - if (ptlv_sec80->tag != TLV_TAG_SEARCH_FFT_REPORT_GEN2) { - spectral->diag_stats.spectral_no_sec80_sfft++; - return -EPERM; - } + params.interf_list.count = 0; + params.max_lower_index = 0; + params.max_upper_index = 0; + params.nb_lower = 0; + params.nb_upper = 0; + /* + * For modes upto VHT80, the noise floor is populated with the + * one corresponding + * to the highest enabled antenna chain + */ + params.noise_floor = + p_rfqual->noise_floor[chn_idx_highest_enabled]; + params.datalen = ptlv->length; + params.pwr_count = ptlv->length - + sizeof(struct spectral_phyerr_hdr_gen2) - segid_skiplen; + params.tstamp = (tsf64 & SPECTRAL_TSMASK); - segid_sec80 = *((SPECTRAL_SEGID_INFO *)( - (u_int8_t *)ptlv_sec80 + - sizeof(SPECTRAL_PHYERR_TLV_GEN2) + - sizeof(SPECTRAL_PHYERR_HDR_GEN2))); + acs_stats->ctrl_nf = params.noise_floor; + acs_stats->ext_nf = params.noise_floor; + acs_stats->nfc_ctl_rssi = control_rssi; + acs_stats->nfc_ext_rssi = extension_rssi; - if (segid_sec80 != 1) { - spectral->diag_stats.spectral_vhtseg2id_mismatch++; - return -EPERM; - } + if (spectral->is_160_format && + spectral->ch_width == CH_WIDTH_160MHZ) { + /* + * We expect to see one more Search FFT report, and it + * should be equal in size to the current one. + */ + if (datalen < ( + 2 * ( + sizeof(struct spectral_phyerr_tlv_gen2) + + ptlv->length))) { + struct spectral_diag_stats *p_diag_stats = + &spectral->diag_stats; + p_diag_stats->spectral_sec80_sfft_insufflen++; + return -EPERM; + } - params.vhtop_ch_freq_seg1 = p_chaninfo->center_freq1; - params.vhtop_ch_freq_seg2 = p_chaninfo->center_freq2; + ptlv_sec80 = (struct spectral_phyerr_tlv_gen2 *)( + data + + sizeof(struct spectral_phyerr_tlv_gen2) + + ptlv->length); - process_search_fft_report_gen2( - ptlv_sec80, - ptlv_sec80->length, &search_fft_info_sec80); + if (ptlv_sec80->signature != + SPECTRAL_PHYERR_SIGNATURE_GEN2) { + spectral->diag_stats.spectral_mismatch++; + return -EPERM; + } - pfft_sec80 = (SPECTRAL_PHYERR_FFT_GEN2 *)( - ((u_int8_t *)ptlv_sec80) + - sizeof(SPECTRAL_PHYERR_TLV_GEN2) + - sizeof(SPECTRAL_PHYERR_HDR_GEN2) + + if (ptlv_sec80->tag != TLV_TAG_SEARCH_FFT_REPORT_GEN2) { + spectral->diag_stats.spectral_no_sec80_sfft++; + return -EPERM; + } + + segid_sec80 = *((SPECTRAL_SEGID_INFO *)( + (uint8_t *)ptlv_sec80 + + sizeof(struct spectral_phyerr_tlv_gen2) + + sizeof(struct spectral_phyerr_hdr_gen2))); + + if (segid_sec80 != 1) { + struct spectral_diag_stats *p_diag_stats = + &spectral->diag_stats; + p_diag_stats->spectral_vhtseg2id_mismatch++; + return -EPERM; + } + + params.vhtop_ch_freq_seg1 = p_chaninfo->center_freq1; + params.vhtop_ch_freq_seg2 = p_chaninfo->center_freq2; + + target_if_process_sfft_report_gen2( + ptlv_sec80, + ptlv_sec80->length, + &search_fft_info_sec80); + + pfft_sec80 = (struct spectral_phyerr_fft_gen2 *)( + ((uint8_t *)ptlv_sec80) + + sizeof(struct spectral_phyerr_tlv_gen2) + + sizeof(struct spectral_phyerr_hdr_gen2) + segid_skiplen); - /* XXX: Confirm. TBD at SoD. */ - params.rssi_sec80 = p_rfqual->rssi_comb; - if (spectral->is_sec80_rssi_war_required) - params.rssi_sec80 = - get_combined_rssi_sec80_segment_gen2( - spectral, - &search_fft_info_sec80); - /* XXX: Determine dynamically. TBD at SoD. */ - /* - * For VHT80_80/VHT160, the noise floor for primary 80MHz - * segment is populated with the - * lowest enabled antenna chain and the noise floor for - * secondary 80MHz segment is populated - * with the highest enabled antenna chain - */ - params.noise_floor_sec80 = - p_rfqual->noise_floor[chn_idx_highest_enabled]; - params.noise_floor = - p_rfqual->noise_floor[chn_idx_lowest_enabled]; + /* XXX: Confirm. TBD at SoD. */ + params.rssi_sec80 = p_rfqual->rssi_comb; + if (spectral->is_sec80_rssi_war_required) + params.rssi_sec80 = + target_if_get_combrssi_sec80_seg_gen2 + (spectral, &search_fft_info_sec80); + /* XXX: Determine dynamically. TBD at SoD. */ + /* + * For VHT80_80/VHT160, the noise floor for primary + * 80MHz segment is populated with the + * lowest enabled antenna chain and the noise floor for + * secondary 80MHz segment is populated + * with the highest enabled antenna chain + */ + params.noise_floor_sec80 = + p_rfqual->noise_floor[chn_idx_highest_enabled]; + params.noise_floor = + p_rfqual->noise_floor[chn_idx_lowest_enabled]; - params.max_mag_sec80 = p_sfft_sec80->peak_mag; - params.max_index_sec80 = p_sfft_sec80->peak_inx; - /* XXX Does this definition of datalen *still hold? */ - params.datalen_sec80 = ptlv_sec80->length; - params.pwr_count_sec80 = - ptlv_sec80->length - - sizeof(SPECTRAL_PHYERR_HDR_GEN2) - - segid_skiplen; - params.bin_pwr_data_sec80 = (u_int8_t *)pfft_sec80; - } - qdf_mem_copy( - ¶ms.classifier_params, - &spectral->classifier_params, - sizeof(struct spectral_classifier_params)); + params.max_mag_sec80 = p_sfft_sec80->peak_mag; + params.max_index_sec80 = p_sfft_sec80->peak_inx; + /* XXX Does this definition of datalen *still hold? */ + params.datalen_sec80 = ptlv_sec80->length; + params.pwr_count_sec80 = + ptlv_sec80->length - + sizeof(struct spectral_phyerr_hdr_gen2) - + segid_skiplen; + params.bin_pwr_data_sec80 = (uint8_t *)pfft_sec80; + } + qdf_mem_copy(¶ms.classifier_params, + &spectral->classifier_params, + sizeof(struct spectral_classifier_params)); -#ifdef SPECTRAL_DEBUG_SAMP_MSG - target_if_dbg_print_SAMP_param(¶ms); -#endif - target_if_spectral_create_samp_msg(spectral, ¶ms); + target_if_spectral_log_SAMP_param(¶ms); + target_if_spectral_create_samp_msg(spectral, ¶ms); } return 0; } -/* - * Function : spectral_dump_header_gen2 - * Description : Dump Spectral header - * Input : Pointer to Spectral Phyerr Header - * Output : Success/Failure - * - */ -int spectral_dump_header_gen2(SPECTRAL_PHYERR_HDR_GEN2 *phdr) +int +target_if_spectral_dump_hdr_gen2(struct spectral_phyerr_hdr_gen2 *phdr) { - u_int32_t a = 0; - u_int32_t b = 0; + uint32_t a = 0; + uint32_t b = 0; - qdf_mem_copy(&a, (u_int8_t *)phdr, sizeof(int)); - qdf_mem_copy( - &b, - (u_int8_t *)((u_int8_t *)phdr + sizeof(int)), sizeof(int)); + qdf_mem_copy(&a, (uint8_t *)phdr, sizeof(int)); + qdf_mem_copy(&b, + (uint8_t *)((uint8_t *)phdr + sizeof(int)), + sizeof(int)); qdf_print("SPECTRAL : HEADER A 0x%x (%d)\n", a, a); qdf_print("SPECTRAL : HEADER B 0x%x (%d)\n", b, b); return 0; } -/* - * Function : get_combined_rssi_sec80_segment_gen2 - * Description : Get approximate combined RSSI for Secondary 80 segment - * Input : Pointer to spectral and pointer to search fft info - * of secondary 80 segment - * Output : Combined RSSI for secondary 80Mhz segment - * - */ -int8_t get_combined_rssi_sec80_segment_gen2( +int8_t +target_if_get_combrssi_sec80_seg_gen2( struct target_if_spectral *spectral, - SPECTRAL_SEARCH_FFT_INFO_GEN2 *p_sfft_sec80) + struct spectral_search_fft_info_gen2 *p_sfft_sec80) { uint32_t avgpwr_db = 0; uint32_t total_gain_db = 0; @@ -1039,20 +1047,14 @@ int8_t get_combined_rssi_sec80_segment_gen2( return comb_rssi; } -/* - * Function : spectral_dump_tlv_gen2 - * Description : Dump Spectral TLV - * Input : Pointer to Spectral Phyerr TLV, flag indicating whether - * information provided by HW is in altered format for 802.11ac - * 160/80+80 MHz support (QCA9984 onwards). - * Output : Success/Failure - * - */ -int spectral_dump_tlv_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, bool is_160_format) +int +target_if_spectral_dump_tlv_gen2( + struct spectral_phyerr_tlv_gen2 *ptlv, bool is_160_format) { int ret = 0; - /* TODO : Do not delete the following print + /* + * TODO : Do not delete the following print * The scripts used to validate Spectral depend on this Print */ qdf_print("SPECTRAL : TLV Length is 0x%x (%d)\n", @@ -1060,18 +1062,19 @@ int spectral_dump_tlv_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, bool is_160_format) switch (ptlv->tag) { case TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2: - ret = dump_summary_report_gen2( + ret = + target_if_dump_summary_report_gen2( ptlv, ptlv->length, is_160_format); break; case TLV_TAG_SEARCH_FFT_REPORT_GEN2: - ret = dump_search_fft_report_gen2( - ptlv, ptlv->length, is_160_format); + ret = + target_if_dump_sfft_report_gen2(ptlv, ptlv->length, + is_160_format); break; case TLV_TAG_ADC_REPORT_GEN2: - ret = dump_adc_report_gen2( - ptlv, ptlv->length); + ret = target_if_dump_adc_report_gen2(ptlv, ptlv->length); break; default: @@ -1083,85 +1086,73 @@ int spectral_dump_tlv_gen2(SPECTRAL_PHYERR_TLV_GEN2 *ptlv, bool is_160_format) return ret; } -/* - * Function : spectral_dump_phyerr_data_gen2 - * Description : Dump Spectral related PHY Error TLVs - * Input : Pointer to buffer, flag indicating whether information - * provided by HW is in altered format for 802.11ac 160/80+80 MHz - * support (QCA9984 onwards). - * Output : Success/Failure - * - */ -int spectral_dump_phyerr_data_gen2(u_int8_t *data, u_int32_t datalen, - bool is_160_format) +int +target_if_spectral_dump_phyerr_data_gen2(uint8_t *data, uint32_t datalen, + bool is_160_format) { - SPECTRAL_PHYERR_TLV_GEN2 *ptlv = NULL; - u_int32_t bytes_processed = 0; - u_int32_t bytes_remaining = datalen; - u_int32_t curr_tlv_complete_size = 0; + struct spectral_phyerr_tlv_gen2 *ptlv = NULL; + uint32_t bytes_processed = 0; + uint32_t bytes_remaining = datalen; + uint32_t curr_tlv_complete_size = 0; - if (datalen < sizeof(SPECTRAL_PHYERR_TLV_GEN2)) { - qdf_print("DRIVER: Total PHY error data length %u too short to contain" - " any TLVs\n", datalen); - return -EPERM; + if (datalen < sizeof(struct spectral_phyerr_tlv_gen2)) { + qdf_print + ("DRIVER: Total PHY error data length %u too short to " + "contain any TLVs\n", datalen); + return -EPERM; } while (bytes_processed < datalen) { - if (bytes_remaining < sizeof(SPECTRAL_PHYERR_TLV_GEN2)) { - qdf_print("DRIVER: Remaining PHY error data length %u too " - "short to contain a TLV\n", bytes_remaining); - return -EPERM; - } + if (bytes_remaining < sizeof(struct spectral_phyerr_tlv_gen2)) { + qdf_print + ("DRIVER: Remaining PHY error data length %u too " + "short to contain a TLV\n", bytes_remaining); + return -EPERM; + } - ptlv = (SPECTRAL_PHYERR_TLV_GEN2 *)(data + bytes_processed); + ptlv = (struct spectral_phyerr_tlv_gen2 *)(data + + bytes_processed); - if (ptlv->signature != SPECTRAL_PHYERR_SIGNATURE_GEN2) { - qdf_print("DRIVER : Invalid signature 0x%x!\n", - ptlv->signature); - return -EPERM; - } + if (ptlv->signature != SPECTRAL_PHYERR_SIGNATURE_GEN2) { + qdf_print("DRIVER : Invalid signature 0x%x!\n", + ptlv->signature); + return -EPERM; + } - curr_tlv_complete_size = sizeof(SPECTRAL_PHYERR_TLV_GEN2) + - ptlv->length; + curr_tlv_complete_size = + sizeof(struct spectral_phyerr_tlv_gen2) + + ptlv->length; - if (curr_tlv_complete_size > bytes_remaining) { - qdf_print("DRIVER : Current indicated complete TLV size %u " - "greater than number of bytes remaining to be " - "processed %u", - curr_tlv_complete_size, - bytes_remaining); - return -EPERM; - } + if (curr_tlv_complete_size > bytes_remaining) { + qdf_print + ("DRIVER : Current indicated complete TLV size %u " + "greater than number of bytes remaining to be " + "processed %u", curr_tlv_complete_size, + bytes_remaining); + return -EPERM; + } - if (spectral_dump_tlv_gen2(ptlv, is_160_format) == -1) - return -EPERM; + if (target_if_spectral_dump_tlv_gen2(ptlv, is_160_format) == -1) + return -EPERM; - bytes_processed += curr_tlv_complete_size; - bytes_remaining = datalen - bytes_processed; + bytes_processed += curr_tlv_complete_size; + bytes_remaining = datalen - bytes_processed; } return 0; } -/* END of spectral GEN II HW specific functions */ - -/* START of spectral GEN III HW specific functions */ - -/* - * Function : process_search_fft_report_gen3 - * Description : Process Search FFT Report - * Input : Pointer to Spectral fft report and pointer to search fft info - * Output : Success/Failure - * - */ -int process_search_fft_report_gen3( +int +target_if_process_sfft_report_gen3( struct spectral_phyerr_fft_report_gen3 *p_fft_report, - struct spectral_search_fft_info_gen3 *p_sfft) + struct spectral_search_fft_info_gen3 *p_sfft) { - /* For simplicity, everything is defined as uint32_t (except one). + /* + * For simplicity, everything is defined as uint32_t (except one). * Proper code will later use the right sizes. */ - /* For easy comparision between MDK team and OS team, the MDK script + /* + * For easy comparision between MDK team and OS team, the MDK script * variable names have been used */ int32_t peak_sidx; @@ -1169,90 +1160,57 @@ int process_search_fft_report_gen3( /* Populate the Search FFT Info */ if (p_sfft) { - p_sfft->timestamp = p_fft_report->fft_timestamp; + p_sfft->timestamp = p_fft_report->fft_timestamp; - p_sfft->fft_detector_id = get_bitfield( - p_fft_report->hdr_a, - 2, - 0); - p_sfft->fft_num = get_bitfield( - p_fft_report->hdr_a, - 3, - 2); - p_sfft->fft_radar_check = get_bitfield( - p_fft_report->hdr_a, - 12, - 5); + p_sfft->fft_detector_id = get_bitfield(p_fft_report->hdr_a, + 2, 0); + p_sfft->fft_num = get_bitfield(p_fft_report->hdr_a, 3, 2); + p_sfft->fft_radar_check = get_bitfield(p_fft_report->hdr_a, + 12, 5); - peak_sidx = get_bitfield( - p_fft_report->hdr_a, - 11, - 17); - p_sfft->fft_peak_sidx = unsigned_to_signed(peak_sidx, 11); - p_sfft->fft_chn_idx = get_bitfield( - p_fft_report->hdr_a, - 3, - 28); + peak_sidx = get_bitfield(p_fft_report->hdr_a, 11, 17); + p_sfft->fft_peak_sidx = unsigned_to_signed(peak_sidx, 11); + p_sfft->fft_chn_idx = get_bitfield(p_fft_report->hdr_a, 3, 28); - p_sfft->fft_base_pwr_db = get_bitfield( - p_fft_report->hdr_b, - 9, - 0); - p_sfft->fft_total_gain_db = get_bitfield( - p_fft_report->hdr_b, - 8, - 9); + p_sfft->fft_base_pwr_db = get_bitfield(p_fft_report->hdr_b, + 9, 0); + p_sfft->fft_total_gain_db = get_bitfield(p_fft_report->hdr_b, + 8, 9); - p_sfft->fft_num_str_bins_ib = get_bitfield( - p_fft_report->hdr_c, - 8, - 0); - peak_mag = get_bitfield( - p_fft_report->hdr_c, - 10, - 8); - p_sfft->fft_peak_mag = unsigned_to_signed(peak_mag, 10); - p_sfft->fft_avgpwr_db = get_bitfield( - p_fft_report->hdr_c, - 7, - 18); - p_sfft->fft_relpwr_db = get_bitfield( - p_fft_report->hdr_c, - 7, - 25); + p_sfft->fft_num_str_bins_ib = get_bitfield(p_fft_report->hdr_c, + 8, 0); + peak_mag = get_bitfield(p_fft_report->hdr_c, 10, 8); + p_sfft->fft_peak_mag = unsigned_to_signed(peak_mag, 10); + p_sfft->fft_avgpwr_db = get_bitfield(p_fft_report->hdr_c, + 7, 18); + p_sfft->fft_relpwr_db = get_bitfield(p_fft_report->hdr_c, + 7, 25); } return 0; } -/* - * Function : spectral_dump_fft_report_gen3 - * Description : Process Search FFT Report - * Input : Pointer to Spectral fft report and pointer to search fft info - * Output : Success/Failure - * - */ -int spectral_dump_fft_report_gen3( - struct spectral_phyerr_fft_report_gen3 *p_fft_report, - struct spectral_search_fft_info_gen3 *p_sfft) +int +target_if_dump_fft_report_gen3(struct spectral_phyerr_fft_report_gen3 + *p_fft_report, + struct spectral_search_fft_info_gen3 *p_sfft) { int i = 0; int fft_mag = 0; int fft_hdr_length = (p_fft_report->fft_hdr_length * 4); - int report_len = (fft_hdr_length + 8); - int fft_bin_len = (fft_hdr_length - 16); + int report_len = (fft_hdr_length + 8); + int fft_bin_len = (fft_hdr_length - 16); qdf_print("##############################################" "###############\n"); qdf_print("Spectral search fft_report\n"); qdf_print("fft_timestamp = 0x%x\n" - "fft_hdr_length = %d(32 bit words)\n" - "fft_hdr_tag = 0x%x\n" - "fft_hdr_sig = 0x%x\n", - p_fft_report->fft_timestamp, - p_fft_report->fft_hdr_length, - p_fft_report->fft_hdr_tag, - p_fft_report->fft_hdr_sig); + "fft_hdr_length = %d(32 bit words)\n" + "fft_hdr_tag = 0x%x\n" + "fft_hdr_sig = 0x%x\n", + p_fft_report->fft_timestamp, + p_fft_report->fft_hdr_length, + p_fft_report->fft_hdr_tag, p_fft_report->fft_hdr_sig); qdf_print("Length field in search fft report is %d(0x%x) bytes\n", fft_hdr_length, fft_hdr_length); @@ -1262,34 +1220,34 @@ int spectral_dump_fft_report_gen3( fft_bin_len); qdf_print("fft_detector_id = %u\n" - "fft_num = %u\n" - "fft_radar_check = %u\n" - "fft_peak_sidx = %d\n" - "fft_chn_idx = %u\n" - "fft_base_pwr_db = %u\n" - "fft_total_gain_db = %u\n" - "fft_num_str_bins_ib = %u\n" - "fft_peak_mag = %d\n" - "fft_avgpwr_db = %u\n" - "fft_relpwr_db = %u\n", - p_sfft->fft_detector_id, - p_sfft->fft_num, - p_sfft->fft_radar_check, - p_sfft->fft_peak_sidx, - p_sfft->fft_chn_idx, - p_sfft->fft_base_pwr_db, - p_sfft->fft_total_gain_db, - p_sfft->fft_num_str_bins_ib, - p_sfft->fft_peak_mag, - p_sfft->fft_avgpwr_db, - p_sfft->fft_relpwr_db); + "fft_num = %u\n" + "fft_radar_check = %u\n" + "fft_peak_sidx = %d\n" + "fft_chn_idx = %u\n" + "fft_base_pwr_db = %u\n" + "fft_total_gain_db = %u\n" + "fft_num_str_bins_ib = %u\n" + "fft_peak_mag = %d\n" + "fft_avgpwr_db = %u\n" + "fft_relpwr_db = %u\n", + p_sfft->fft_detector_id, + p_sfft->fft_num, + p_sfft->fft_radar_check, + p_sfft->fft_peak_sidx, + p_sfft->fft_chn_idx, + p_sfft->fft_base_pwr_db, + p_sfft->fft_total_gain_db, + p_sfft->fft_num_str_bins_ib, + p_sfft->fft_peak_mag, + p_sfft->fft_avgpwr_db, p_sfft->fft_relpwr_db); qdf_print("FFT bins:\n"); for (i = 0; i < (fft_hdr_length - 16); i++) { - fft_mag = ((u_int8_t *)p_fft_report)[SPECTRAL_FFT_BINS_POS + i]; - qdf_print("%d: %d, ", i, fft_mag); - if (i % 16 == 0) - qdf_print("\n"); + fft_mag = + ((uint8_t *)p_fft_report)[SPECTRAL_FFT_BINS_POS + i]; + qdf_print("%d: %d, ", i, fft_mag); + if (i % 16 == 0) + qdf_print("\n"); } qdf_print("\n"); qdf_print("###########################################################" @@ -1298,9 +1256,18 @@ int spectral_dump_fft_report_gen3( return 0; } -static int consume_searchfft_report_gen3( - struct target_if_spectral *spectral, - struct phyerr_info *pinfo) +/** + * target_if_consume_sfft_report_gen3() - Process fft report for gen3 + * @spectral: Pointer to spectral object + * @pinfo: Pointer to phyerror info + * + * Process fft report for gen3 + * + * Return: Success/Failure + */ +static int +target_if_consume_sfft_report_gen3(struct target_if_spectral *spectral, + struct phyerr_info *pinfo) { /* * XXX : The classifier do not use all the members of the SAMP @@ -1329,10 +1296,10 @@ static int consume_searchfft_report_gen3( */ /* Unpack the arguments */ - u_int32_t datalen = pinfo->datalen; + uint32_t datalen = pinfo->datalen; struct target_if_spectral_rfqual_info *p_rfqual = pinfo->p_rfqual; struct target_if_spectral_chan_info *p_chaninfo = pinfo->p_chaninfo; - u_int64_t tsf64 = pinfo->tsf64; + uint64_t tsf64 = pinfo->tsf64; struct target_if_spectral_acs_stats *acs_stats = pinfo->acs_stats; struct target_if_samp_msg_params params; @@ -1341,28 +1308,30 @@ static int consume_searchfft_report_gen3( int8_t rssi_up = 0; int8_t rssi_low = 0; int8_t chn_idx_highest_enabled = 0; - int8_t chn_idx_lowest_enabled = 0; - u_int8_t control_rssi = 0; - u_int8_t extension_rssi = 0; - u_int32_t tstamp = 0; + int8_t chn_idx_lowest_enabled = 0; + uint8_t control_rssi = 0; + uint8_t extension_rssi = 0; + uint32_t tstamp = 0; int fft_hdr_length = 0; - int report_len = 0; + int report_len = 0; int fft_bin_len = 0; - struct target_if_spectral_ops *p_sops = GET_TIF_SPECTRAL_OPS(spectral); + struct target_if_spectral_ops *p_sops = + GET_TARGET_IF_SPECTRAL_OPS(spectral); struct spectral_phyerr_fft_report_gen3 *p_fft_report = - (struct spectral_phyerr_fft_report_gen3 *)(pinfo->data); + (struct spectral_phyerr_fft_report_gen3 *)(pinfo->data); OS_MEMZERO(¶ms, sizeof(params)); fft_hdr_length = p_fft_report->fft_hdr_length * 4; if (fft_hdr_length < 16) { - qdf_print("SPECTRAL : Unexpected TLV length %u for FFT Report! Hexdump" - " follows\n", fft_hdr_length); - goto fail; + qdf_print + ("SPECTRAL : Unexpected TLV length %u for FFT Report! " + "Hexdump follows\n", fft_hdr_length); + goto fail; } - report_len = (fft_hdr_length + 8); - fft_bin_len = (fft_hdr_length - 16); + report_len = (fft_hdr_length + 8); + fft_bin_len = (fft_hdr_length - 16); if (datalen < report_len) { qdf_print("DRIVER: Total PHY error data length %u too short to" " contain the search fft report of length %u\n", @@ -1370,7 +1339,7 @@ static int consume_searchfft_report_gen3( goto fail; } - process_search_fft_report_gen3(p_fft_report, p_sfft); + target_if_process_sfft_report_gen3(p_fft_report, p_sfft); if (p_sfft->fft_detector_id != 0) { qdf_print("Expected segid is 0 but we got %d\n", @@ -1379,8 +1348,8 @@ static int consume_searchfft_report_gen3( goto fail; } - if (spectral_debug_level & (ATH_DEBUG_SPECTRAL2 | ATH_DEBUG_SPECTRAL4)) - spectral_dump_fft_report_gen3(p_fft_report, p_sfft); + if (spectral_debug_level & (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4)) + target_if_dump_fft_report_gen3(p_fft_report, p_sfft); tstamp = p_sops->get_tsf64(spectral) & SPECTRAL_TSMASK; @@ -1394,18 +1363,17 @@ static int consume_searchfft_report_gen3( else rssi_low = extension_rssi; - params.rssi = p_rfqual->rssi_comb; - params.lower_rssi = rssi_low; - params.upper_rssi = rssi_up; + params.rssi = p_rfqual->rssi_comb; + params.lower_rssi = rssi_low; + params.upper_rssi = rssi_up; if (spectral->sc_spectral_noise_pwr_cal) { - /* qdf_print("SPECTRAL : Needs to verified with FW\n"); */ - params.chain_ctl_rssi[0] = p_rfqual->pc_rssi_info[0].rssi_pri20; - params.chain_ctl_rssi[1] = p_rfqual->pc_rssi_info[1].rssi_pri20; - params.chain_ctl_rssi[2] = p_rfqual->pc_rssi_info[2].rssi_pri20; - params.chain_ext_rssi[0] = p_rfqual->pc_rssi_info[0].rssi_sec20; - params.chain_ext_rssi[1] = p_rfqual->pc_rssi_info[1].rssi_sec20; - params.chain_ext_rssi[2] = p_rfqual->pc_rssi_info[2].rssi_sec20; + params.chain_ctl_rssi[0] = p_rfqual->pc_rssi_info[0].rssi_pri20; + params.chain_ctl_rssi[1] = p_rfqual->pc_rssi_info[1].rssi_pri20; + params.chain_ctl_rssi[2] = p_rfqual->pc_rssi_info[2].rssi_pri20; + params.chain_ext_rssi[0] = p_rfqual->pc_rssi_info[0].rssi_sec20; + params.chain_ext_rssi[1] = p_rfqual->pc_rssi_info[1].rssi_sec20; + params.chain_ext_rssi[2] = p_rfqual->pc_rssi_info[2].rssi_sec20; } /* @@ -1429,154 +1397,147 @@ static int consume_searchfft_report_gen3( * values * in to account. This is marked for future enhancements. */ - /* qdf_print("SPECTRAL : TBD (Chainmask changes for 8x8)\n"); */ chn_idx_highest_enabled = ((spectral->params.ss_chn_mask & 0x8) ? 3 : - (spectral->params.ss_chn_mask & 0x4) ? 2 : - (spectral->params.ss_chn_mask & 0x2) ? 1 : 0); - chn_idx_lowest_enabled = ((spectral->params.ss_chn_mask & 0x1) ? 0 : - (spectral->params.ss_chn_mask & 0x2) ? 1 : - (spectral->params.ss_chn_mask & 0x4) ? 2 : 3); - control_rssi = (u_int8_t) - p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_pri20; - extension_rssi = (u_int8_t) - p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_sec20; + (spectral->params.ss_chn_mask & 0x4) ? 2 : + (spectral->params.ss_chn_mask & 0x2) ? 1 : + 0); + chn_idx_lowest_enabled = + ((spectral->params.ss_chn_mask & 0x1) ? 0 : + (spectral->params.ss_chn_mask & 0x2) ? 1 : + (spectral->params.ss_chn_mask & 0x4) ? 2 : 3); + control_rssi = (uint8_t) + p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_pri20; + extension_rssi = (uint8_t) + p_rfqual->pc_rssi_info[chn_idx_highest_enabled].rssi_sec20; - params.bwinfo = 0; - params.tstamp = 0; - params.max_mag = p_sfft->fft_peak_mag; + params.bwinfo = 0; + params.tstamp = 0; + params.max_mag = p_sfft->fft_peak_mag; /* params.max_index = p_sfft->peak_inx; */ - params.max_exp = 0; - params.peak = 0; - params.bin_pwr_data = (u_int8_t *)((uint8_t *)p_fft_report + - SPECTRAL_FFT_BINS_POS); - params.freq = p_sops->get_current_channel(spectral); + params.max_exp = 0; + params.peak = 0; + params.bin_pwr_data = (uint8_t *)((uint8_t *)p_fft_report + + SPECTRAL_FFT_BINS_POS); + params.freq = p_sops->get_current_channel(spectral); params.freq_loading = 0; params.interf_list.count = 0; - params.max_lower_index = 0; - params.max_upper_index = 0; - params.nb_lower = 0; - params.nb_upper = 0; + params.max_lower_index = 0; + params.max_upper_index = 0; + params.nb_lower = 0; + params.nb_upper = 0; /* * For modes upto VHT80, the noise floor is populated with the one * corresponding * to the highest enabled antenna chain */ - params.noise_floor = - p_rfqual->noise_floor[chn_idx_highest_enabled]; - params.datalen = (fft_hdr_length * 4); - params.pwr_count = fft_bin_len; - params.tstamp = (tsf64 & SPECTRAL_TSMASK); + params.noise_floor = p_rfqual->noise_floor[chn_idx_highest_enabled]; + params.datalen = (fft_hdr_length * 4); + params.pwr_count = fft_bin_len; + params.tstamp = (tsf64 & SPECTRAL_TSMASK); - acs_stats->ctrl_nf = params.noise_floor; - acs_stats->ext_nf = params.noise_floor; - acs_stats->nfc_ctl_rssi = control_rssi; - acs_stats->nfc_ext_rssi = extension_rssi; + acs_stats->ctrl_nf = params.noise_floor; + acs_stats->ext_nf = params.noise_floor; + acs_stats->nfc_ctl_rssi = control_rssi; + acs_stats->nfc_ext_rssi = extension_rssi; if (spectral->ch_width == CH_WIDTH_160MHZ) { - /* We expect to see one more Search FFT report, and it should be - * equal in size to the current one. - */ - if (datalen != (2 * report_len)) { - spectral->diag_stats.spectral_sec80_sfft_insufflen++; - goto fail; + /* + * We expect to see one more Search FFT report, and it should be + * equal in size to the current one. + */ + if (datalen != (2 * report_len)) { + spectral->diag_stats.spectral_sec80_sfft_insufflen++; + goto fail; + } + + p_fft_report = (struct spectral_phyerr_fft_report_gen3 *)( + (uint8_t *)p_fft_report + report_len); + + if (p_fft_report->fft_hdr_sig != + SPECTRAL_PHYERR_SIGNATURE_GEN3) { + spectral->diag_stats.spectral_mismatch++; + goto fail; + } + + if (p_fft_report->fft_hdr_tag != + TLV_TAG_SEARCH_FFT_REPORT_GEN3) { + spectral->diag_stats.spectral_no_sec80_sfft++; + goto fail; + } + + fft_hdr_length = p_fft_report->fft_hdr_length * 4; + report_len = (fft_hdr_length + 8); + fft_bin_len = (fft_hdr_length - 16); + + target_if_process_sfft_report_gen3(p_fft_report, p_sfft); + + if (p_sfft->fft_detector_id != 1) { + qdf_print("Expected segid is 1 but we got %d\n", + p_sfft->fft_detector_id); + spectral->diag_stats.spectral_vhtseg2id_mismatch++; + goto fail; + } + + if (spectral_debug_level & + (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4)) + target_if_dump_fft_report_gen3(p_fft_report, p_sfft); + + params.vhtop_ch_freq_seg1 = p_chaninfo->center_freq1; + params.vhtop_ch_freq_seg2 = p_chaninfo->center_freq2; + + /* XXX: Confirm. TBD at SoD. */ + params.rssi_sec80 = p_rfqual->rssi_comb; + + /* XXX: Determine dynamically. TBD at SoD. */ + + /* + * For VHT80_80/VHT160, the noise floor for primary 80MHz + * segment is populated with the + * lowest enabled antenna chain and the noise floor for + * secondary 80MHz segment is populated + * with the highest enabled antenna chain + */ + params.noise_floor_sec80 = + p_rfqual->noise_floor[chn_idx_highest_enabled]; + params.noise_floor = + p_rfqual->noise_floor[chn_idx_lowest_enabled]; + + params.max_mag_sec80 = p_sfft->fft_peak_mag; + /* params.max_index_sec80 = p_sfft->peak_inx; */ + /* XXX Does this definition of datalen *still hold? */ + params.datalen_sec80 = fft_hdr_length; + params.pwr_count_sec80 = fft_bin_len; + params.bin_pwr_data_sec80 = (uint8_t *)( + (uint8_t *)p_fft_report + + SPECTRAL_FFT_BINS_POS); } - p_fft_report = (struct spectral_phyerr_fft_report_gen3 *)( - (uint8_t *)p_fft_report + report_len); + qdf_mem_copy(¶ms.classifier_params, + &spectral->classifier_params, + sizeof(struct spectral_classifier_params)); - if (p_fft_report->fft_hdr_sig != SPECTRAL_PHYERR_SIGNATURE_GEN3) { - spectral->diag_stats.spectral_mismatch++; - goto fail; - } - - if (p_fft_report->fft_hdr_tag != TLV_TAG_SEARCH_FFT_REPORT_GEN3) { - spectral->diag_stats.spectral_no_sec80_sfft++; - goto fail; - } - - fft_hdr_length = p_fft_report->fft_hdr_length * 4; - report_len = (fft_hdr_length + 8); - fft_bin_len = (fft_hdr_length - 16); - - process_search_fft_report_gen3(p_fft_report, p_sfft); - - if (p_sfft->fft_detector_id != 1) { - qdf_print("Expected segid is 1 but we got %d\n", - p_sfft->fft_detector_id); - spectral->diag_stats.spectral_vhtseg2id_mismatch++; - goto fail; - } - - if (spectral_debug_level & (ATH_DEBUG_SPECTRAL2 | ATH_DEBUG_SPECTRAL4)) - spectral_dump_fft_report_gen3(p_fft_report, p_sfft); - - params.vhtop_ch_freq_seg1 = p_chaninfo->center_freq1; - params.vhtop_ch_freq_seg2 = p_chaninfo->center_freq2; - - /* XXX: Confirm. TBD at SoD. */ - params.rssi_sec80 = p_rfqual->rssi_comb; - - /* if (spectral->is_sec80_rssi_war_required) { */ - /* params.rssi_sec80 = get_combined_rssi_sec80_segment_gen3(spectral, - * &search_fft_info_sec80); - */ - /* } */ - /* XXX: Determine dynamically. TBD at SoD. */ - - /* - * For VHT80_80/VHT160, the noise floor for primary 80MHz segment is - * populated with the - * lowest enabled antenna chain and the noise floor for secondary 80MHz - * segment is populated - * with the highest enabled antenna chain - */ - params.noise_floor_sec80 = - p_rfqual->noise_floor[chn_idx_highest_enabled]; - params.noise_floor = - p_rfqual->noise_floor[chn_idx_lowest_enabled]; - - params.max_mag_sec80 = p_sfft->fft_peak_mag; - /* params.max_index_sec80 = p_sfft->peak_inx; */ - /* XXX Does this definition of datalen *still hold? */ - params.datalen_sec80 = fft_hdr_length; - params.pwr_count_sec80 = fft_bin_len; - params.bin_pwr_data_sec80 = (u_int8_t *)( - (uint8_t *)p_fft_report + SPECTRAL_FFT_BINS_POS); - } - - qdf_mem_copy( - ¶ms.classifier_params, - &spectral->classifier_params, - sizeof(struct spectral_classifier_params)); -#ifdef SPECTRAL_DEBUG_SAMP_MSG - target_if_dbg_print_SAMP_param(¶ms); -#endif + target_if_spectral_log_SAMP_param(¶ms); target_if_spectral_create_samp_msg(spectral, ¶ms); return 0; -fail: + fail: qdf_print("Error in function %s while processing search fft report\n", __func__); - print_buf((uint8_t *)p_fft_report, fft_hdr_length + 8); + target_if_print_buf((uint8_t *)p_fft_report, fft_hdr_length + 8); return -EPERM; } -/* - * Function : spectral_process_phyerr_gen3 - * Descrip_tion : Process PHY Error - * Input : Pointer to buffer - * Output : Success/Failure - * - */ -int spectral_process_phyerr_gen3( +int +target_if_spectral_process_phyerr_gen3( struct target_if_spectral *spectral, - u_int8_t *data, - u_int32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual, + uint8_t *data, + uint32_t datalen, + struct target_if_spectral_rfqual_info *p_rfqual, struct target_if_spectral_chan_info *p_chaninfo, - u_int64_t tsf64, + uint64_t tsf64, struct target_if_spectral_acs_stats *acs_stats) { uint8_t tag = 0; @@ -1584,7 +1545,8 @@ int spectral_process_phyerr_gen3( struct phyerr_info pinfo; int ret = 0; - /* pack arguments in a structure as there are + /* + * pack arguments in a structure as there are * more than 3 arguments */ pinfo.data = data; @@ -1594,8 +1556,7 @@ int spectral_process_phyerr_gen3( pinfo.tsf64 = tsf64; pinfo.acs_stats = acs_stats; - if (spectral_debug_level & - (ATH_DEBUG_SPECTRAL2 | ATH_DEBUG_SPECTRAL4)) { + if (spectral_debug_level & (DEBUG_SPECTRAL2 | DEBUG_SPECTRAL4)) { qdf_print("Printing the spectral phyerr buffer for debug " "purpose\n"); qdf_print("Dalalength of buffer = 0x%x(%d)\n", @@ -1605,9 +1566,10 @@ int spectral_process_phyerr_gen3( #endif } - /* Peek into the data to figure out whether - * 1) Signature matches the expected value - * 2) What is inside the package (TAG ID is used for finding this) + /* + * Peek into the data to figure out whether + * 1) Signature matches the expected value + * 2) What is inside the package (TAG ID is used for finding this) */ tag = *(data + PHYERR_HDR_TAG_POS); signature = *(data + PHYERR_HDR_SIG_POS); @@ -1622,13 +1584,14 @@ int spectral_process_phyerr_gen3( switch (tag) { case TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3: - /* Place holder + /* + * Place holder * We don't use spectral scan report as of now */ break; case TLV_TAG_SEARCH_FFT_REPORT_GEN3: - ret = consume_searchfft_report_gen3(spectral, &pinfo); + ret = target_if_consume_sfft_report_gen3(spectral, &pinfo); break; default: @@ -1636,12 +1599,10 @@ int spectral_process_phyerr_gen3( break; } -end: - if (spectral_debug_level & ATH_DEBUG_SPECTRAL4) - spectral_debug_level = ATH_DEBUG_SPECTRAL; + end: + if (spectral_debug_level & DEBUG_SPECTRAL4) + spectral_debug_level = DEBUG_SPECTRAL; return ret; } -/* END of spectral GEN III HW specific functions */ - -#endif /* WLAN_SPECTRAL_ENABLE */ +#endif diff --git a/target_if/spectral/target_if_spectral_sim.c b/target_if/spectral/target_if_spectral_sim.c index e93cdada7e..564f14cb65 100644 --- a/target_if/spectral/target_if_spectral_sim.c +++ b/target_if/spectral/target_if_spectral_sim.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015,2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2015,2017-2018 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -541,7 +541,7 @@ OS_TIMER_FUNC(spectral_sim_phyerrdelivery_handler) OS_GET_TIMER_ARG(spectral, struct target_if_spectral *); qdf_assert_always(spectral); - p_sops = GET_TIF_SPECTRAL_OPS(spectral); + p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); qdf_assert_always(spectral); simctx = (ath_spectralsim_context *)spectral->simctx;