diff --git a/spectral/core/spectral_cmn_api_i.h b/spectral/core/spectral_cmn_api_i.h index 20766f738f70..ed66871d52ad 100644 --- a/spectral/core/spectral_cmn_api_i.h +++ b/spectral/core/spectral_cmn_api_i.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -23,7 +23,7 @@ #include "spectral_defs_i.h" /** - * wlan_spectral_psoc_obj_create_handler(): handler for psoc object create + * wlan_spectral_psoc_obj_create_handler() - handler for psoc object create * @psoc: reference to global psoc object * @arg: reference to argument provided during registration of handler * @@ -35,10 +35,10 @@ * QDF_STATUS_E_NOMEM on failure of spectral object allocation */ QDF_STATUS wlan_spectral_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc, - void *arg); + void *arg); /** - * wlan_spectral_psoc_obj_destroy_handler(): handler for psoc object delete + * wlan_spectral_psoc_obj_destroy_handler() - handler for psoc object delete * @psoc: reference to global psoc object * @arg: reference to argument provided during registration of handler * @@ -53,7 +53,7 @@ QDF_STATUS wlan_spectral_psoc_obj_destroy_handler(struct wlan_objmgr_psoc *psoc, void *arg); /** - * wlan_spectral_pdev_obj_create_handler(): handler for pdev object create + * wlan_spectral_pdev_obj_create_handler() - handler for pdev object create * @pdev: reference to global pdev object * @arg: reference to argument provided during registration of handler * @@ -68,7 +68,7 @@ QDF_STATUS wlan_spectral_pdev_obj_create_handler(struct wlan_objmgr_pdev *pdev, void *arg); /** - * wlan_spectral_pdev_obj_destroy_handler(): handler for pdev object delete + * wlan_spectral_pdev_obj_destroy_handler() - handler for pdev object delete * @pdev: reference to global pdev object * @arg: reference to argument provided during registration of handler * @@ -83,7 +83,7 @@ QDF_STATUS wlan_spectral_pdev_obj_destroy_handler(struct wlan_objmgr_pdev *pdev, void *arg); /** - * spectral_control_cmn(): common handler for demultiplexing requests from + * spectral_control_cmn()- common handler for demultiplexing requests from * higher layer * @pdev: reference to global pdev object * @id: spectral config command id @@ -97,12 +97,10 @@ QDF_STATUS wlan_spectral_pdev_obj_destroy_handler(struct wlan_objmgr_pdev *pdev, * * Return: 0 success else failure */ -int spectral_control_cmn( - struct wlan_objmgr_pdev *pdev, - u_int id, - void *indata, - u_int32_t insize, - void *outdata, u_int32_t *outsize); +int spectral_control_cmn(struct wlan_objmgr_pdev *pdev, + u_int id, + void *indata, + uint32_t insize, void *outdata, uint32_t *outsize); /** * spectral_control_ol(): Offload handler for demultiplexing requests from @@ -121,7 +119,7 @@ int spectral_control_cmn( */ int spectral_control_ol( struct wlan_objmgr_pdev *pdev, u_int id, - void *indata, u_int32_t insize, void *outdata, u_int32_t *outsize); + void *indata, uint32_t insize, void *outdata, uint32_t *outsize); /** * spectral_get_spectral_ctx_from_pdev() - API to get spectral context object @@ -133,9 +131,8 @@ int spectral_control_ol( * * Return : Reference to spectral_context object */ -static inline -struct spectral_context *spectral_get_spectral_ctx_from_pdev( - struct wlan_objmgr_pdev *pdev) +static inline struct spectral_context * +spectral_get_spectral_ctx_from_pdev(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; struct spectral_context *sc = NULL; @@ -160,9 +157,8 @@ struct spectral_context *spectral_get_spectral_ctx_from_pdev( * * Return : Reference to spectral_context object */ -static inline -struct spectral_context *spectral_get_spectral_ctx_from_psoc( - struct wlan_objmgr_psoc *psoc) +static inline struct spectral_context * +spectral_get_spectral_ctx_from_psoc(struct wlan_objmgr_psoc *psoc) { struct spectral_context *sc = NULL; @@ -185,9 +181,8 @@ struct spectral_context *spectral_get_spectral_ctx_from_psoc( * * Return : Reference to spectral_context object */ -static inline -struct spectral_context *spectral_get_spectral_ctx_from_vdev( - struct wlan_objmgr_vdev *vdev) +static inline struct spectral_context * +spectral_get_spectral_ctx_from_vdev(struct wlan_objmgr_vdev *vdev) { struct wlan_objmgr_psoc *psoc = NULL; struct spectral_context *sc = NULL; @@ -201,5 +196,4 @@ struct spectral_context *spectral_get_spectral_ctx_from_vdev( return sc; } -#endif /* _SPECTRAL_CMN_API_I_H_*/ - +#endif /* _SPECTRAL_CMN_API_I_H_ */ diff --git a/spectral/core/spectral_common.c b/spectral/core/spectral_common.c index 4edfe38c58ab..cbaf7f6fb6a0 100644 --- a/spectral/core/spectral_common.c +++ b/spectral/core/spectral_common.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 @@ -68,45 +68,55 @@ spectral_get_vdev(struct wlan_objmgr_pdev *pdev) } #ifndef CONFIG_MCL -static void spectral_register_cfg80211_handlers(struct wlan_objmgr_pdev *pdev) +/** + * spectral_register_cfg80211_handlers() - Register spectral cfg80211 handlers + * @pdev: Pointer to pdev + * + * Register spectral cfg80211 handlers + * Handlers can be different for WIN and MCL + * + * Return: None + */ +static void +spectral_register_cfg80211_handlers(struct wlan_objmgr_pdev *pdev) { wlan_cfg80211_register_spectral_cmd_handler( - pdev, - SPECTRAL_SCAN_START_HANDLER_IDX, - wlan_cfg80211_spectral_scan_config_and_start); + pdev, + SPECTRAL_SCAN_START_HANDLER_IDX, + wlan_cfg80211_spectral_scan_config_and_start); wlan_cfg80211_register_spectral_cmd_handler( - pdev, - SPECTRAL_SCAN_STOP_HANDLER_IDX, - wlan_cfg80211_spectral_scan_stop); + pdev, + SPECTRAL_SCAN_STOP_HANDLER_IDX, + wlan_cfg80211_spectral_scan_stop); wlan_cfg80211_register_spectral_cmd_handler( - pdev, - SPECTRAL_SCAN_GET_CONFIG_HANDLER_IDX, - wlan_cfg80211_spectral_scan_get_config); + pdev, + SPECTRAL_SCAN_GET_CONFIG_HANDLER_IDX, + wlan_cfg80211_spectral_scan_get_config); wlan_cfg80211_register_spectral_cmd_handler( - pdev, - SPECTRAL_SCAN_GET_DIAG_STATS_HANDLER_IDX, - wlan_cfg80211_spectral_scan_get_diag_stats); + pdev, + SPECTRAL_SCAN_GET_DIAG_STATS_HANDLER_IDX, + wlan_cfg80211_spectral_scan_get_diag_stats); wlan_cfg80211_register_spectral_cmd_handler( - pdev, - SPECTRAL_SCAN_GET_CAP_HANDLER_IDX, - wlan_cfg80211_spectral_scan_get_cap); + pdev, + SPECTRAL_SCAN_GET_CAP_HANDLER_IDX, + wlan_cfg80211_spectral_scan_get_cap); wlan_cfg80211_register_spectral_cmd_handler( - pdev, - SPECTRAL_SCAN_GET_STATUS_HANDLER_IDX, - wlan_cfg80211_spectral_scan_get_status); + pdev, + SPECTRAL_SCAN_GET_STATUS_HANDLER_IDX, + wlan_cfg80211_spectral_scan_get_status); } #else -static void spectral_register_cfg80211_handlers(struct wlan_objmgr_pdev *pdev) +static void +spectral_register_cfg80211_handlers(struct wlan_objmgr_pdev *pdev) { } #endif -int spectral_control_cmn( - struct wlan_objmgr_pdev *pdev, - u_int id, - void *indata, - u_int32_t insize, - void *outdata, u_int32_t *outsize) +int +spectral_control_cmn(struct wlan_objmgr_pdev *pdev, + u_int id, + void *indata, + uint32_t insize, void *outdata, uint32_t *outsize) { int error = 0; int temp_debug; @@ -115,7 +125,7 @@ int spectral_control_cmn( struct spectral_config *spectralparams; struct spectral_context *sc; struct wlan_objmgr_vdev *vdev = NULL; - u_int8_t vdev_rxchainmask = 0; + uint8_t vdev_rxchainmask = 0; if (!pdev) { spectral_err("PDEV is NULL!\n"); @@ -131,353 +141,387 @@ int spectral_control_cmn( switch (id) { case SPECTRAL_SET_CONFIG: - { - if (insize < sizeof(struct spectral_config) || !indata) { - error = -EINVAL; - break; - } - sp_in = (struct spectral_config *)indata; - if (sp_in->ss_count != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_SCAN_COUNT, - sp_in->ss_count)) - error = -EINVAL; - } - - if (sp_in->ss_fft_period != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_FFT_PERIOD, - sp_in->ss_fft_period)) - error = -EINVAL; - } - - if (sp_in->ss_period != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_SCAN_PERIOD, - sp_in->ss_period)) - error = -EINVAL; - } - - if (sp_in->ss_short_report != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_SHORT_REPORT, - (u_int32_t)(sp_in->ss_short_report ? 1 : 0))) - error = -EINVAL; - } - - if (sp_in->ss_spectral_pri != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_SPECT_PRI, - (u_int32_t)(sp_in->ss_spectral_pri))) - error = -EINVAL; - } - - if (sp_in->ss_fft_size != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_FFT_SIZE, - sp_in->ss_fft_size)) - error = -EINVAL; - } - - if (sp_in->ss_gc_ena != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_GC_ENA, - sp_in->ss_gc_ena)) - error = -EINVAL; - } - - if (sp_in->ss_restart_ena != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_RESTART_ENA, - sp_in->ss_restart_ena)) - error = -EINVAL; - } - - if (sp_in->ss_noise_floor_ref != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_NOISE_FLOOR_REF, - sp_in->ss_noise_floor_ref)) - error = -EINVAL; - } - - if (sp_in->ss_init_delay != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_INIT_DELAY, - sp_in->ss_init_delay)) - error = -EINVAL; - } - - if (sp_in->ss_nb_tone_thr != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_NB_TONE_THR, - sp_in->ss_nb_tone_thr)) - error = -EINVAL; - } - - if (sp_in->ss_str_bin_thr != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_STR_BIN_THR, - sp_in->ss_str_bin_thr)) - error = -EINVAL; - } - - if (sp_in->ss_wb_rpt_mode != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_WB_RPT_MODE, - sp_in->ss_wb_rpt_mode)) - error = -EINVAL; - } - - if (sp_in->ss_rssi_rpt_mode != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_RSSI_RPT_MODE, - sp_in->ss_rssi_rpt_mode)) - error = -EINVAL; - } - - if (sp_in->ss_rssi_thr != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_RSSI_THR, - sp_in->ss_rssi_thr)) - error = -EINVAL; - } - - if (sp_in->ss_pwr_format != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_PWR_FORMAT, - sp_in->ss_pwr_format)) - error = -EINVAL; - } - - if (sp_in->ss_rpt_mode != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_RPT_MODE, - sp_in->ss_rpt_mode)) - error = -EINVAL; - } - - if (sp_in->ss_bin_scale != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_BIN_SCALE, - sp_in->ss_bin_scale)) - error = -EINVAL; - } - - if (sp_in->ss_dbm_adj != SPECTRAL_PHYERR_PARAM_NOVAL) { - if (!sc->sptrlc_set_spectral_config( - pdev, - SPECTRAL_PARAM_DBM_ADJ, - sp_in->ss_dbm_adj)) - error = -EINVAL; - } - - if (sp_in->ss_chn_mask != SPECTRAL_PHYERR_PARAM_NOVAL) { - /* Check if any of the inactive Rx antenna chains is - * set active in - * spectral chainmask - */ - vdev = spectral_get_vdev(pdev); - if (!vdev) { - error = -ENOENT; - break; - } - - vdev_rxchainmask = wlan_vdev_mlme_get_rxchainmask(vdev); - wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID); - - if (!(sp_in->ss_chn_mask & vdev_rxchainmask)) { - qdf_print("Invalid Spectral Chainmask - " - "Inactive Rx antenna chain cannot " - "be an active spectral chain\n"); + { + if (insize < sizeof(struct spectral_config) || + !indata) { error = -EINVAL; break; - } else if (!sc->sptrlc_set_spectral_config(pdev, - SPECTRAL_PARAM_CHN_MASK, sp_in->ss_chn_mask)) { - error = -EINVAL; + } + sp_in = (struct spectral_config *)indata; + if (sp_in->ss_count != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_SCAN_COUNT, + sp_in->ss_count)) + error = -EINVAL; + } + + if (sp_in->ss_fft_period != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_FFT_PERIOD, + sp_in->ss_fft_period)) + error = -EINVAL; + } + + if (sp_in->ss_period != SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_SCAN_PERIOD, + sp_in->ss_period)) + error = -EINVAL; + } + + if (sp_in->ss_short_report != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_SHORT_REPORT, + (uint32_t) + (sp_in->ss_short_report ? 1 : 0))) + error = -EINVAL; + } + + if (sp_in->ss_spectral_pri != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_SPECT_PRI, + (uint32_t)(sp_in->ss_spectral_pri))) + error = -EINVAL; + } + + if (sp_in->ss_fft_size != SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_FFT_SIZE, + sp_in->ss_fft_size)) + error = -EINVAL; + } + + if (sp_in->ss_gc_ena != SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_GC_ENA, + sp_in->ss_gc_ena)) + error = -EINVAL; + } + + if (sp_in->ss_restart_ena != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_RESTART_ENA, + sp_in->ss_restart_ena)) + error = -EINVAL; + } + + if (sp_in->ss_noise_floor_ref != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_NOISE_FLOOR_REF, + sp_in->ss_noise_floor_ref)) + error = -EINVAL; + } + + if (sp_in->ss_init_delay != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_INIT_DELAY, + sp_in->ss_init_delay)) + error = -EINVAL; + } + + if (sp_in->ss_nb_tone_thr != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_NB_TONE_THR, + sp_in->ss_nb_tone_thr)) + error = -EINVAL; + } + + if (sp_in->ss_str_bin_thr != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_STR_BIN_THR, + sp_in->ss_str_bin_thr)) + error = -EINVAL; + } + + if (sp_in->ss_wb_rpt_mode != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_WB_RPT_MODE, + sp_in->ss_wb_rpt_mode)) + error = -EINVAL; + } + + if (sp_in->ss_rssi_rpt_mode != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_RSSI_RPT_MODE, + sp_in->ss_rssi_rpt_mode)) + error = -EINVAL; + } + + if (sp_in->ss_rssi_thr != SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_RSSI_THR, + sp_in->ss_rssi_thr)) + error = -EINVAL; + } + + if (sp_in->ss_pwr_format != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_PWR_FORMAT, + sp_in->ss_pwr_format)) + error = -EINVAL; + } + + if (sp_in->ss_rpt_mode != SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_RPT_MODE, + sp_in->ss_rpt_mode)) + error = -EINVAL; + } + + if (sp_in->ss_bin_scale != + SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_BIN_SCALE, + sp_in->ss_bin_scale)) + error = -EINVAL; + } + + if (sp_in->ss_dbm_adj != SPECTRAL_PHYERR_PARAM_NOVAL) { + if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_DBM_ADJ, + sp_in->ss_dbm_adj)) + error = -EINVAL; + } + + if (sp_in->ss_chn_mask != SPECTRAL_PHYERR_PARAM_NOVAL) { + /* + * Check if any of the inactive Rx antenna + * chains is set active in spectral chainmask + */ + vdev = spectral_get_vdev(pdev); + if (!vdev) { + error = -ENOENT; + break; + } + + vdev_rxchainmask = + wlan_vdev_mlme_get_rxchainmask(vdev); + wlan_objmgr_vdev_release_ref(vdev, + WLAN_SPECTRAL_ID); + + if (!(sp_in->ss_chn_mask & vdev_rxchainmask)) { + qdf_print + ("Invalid Spectral Chainmask - " + "Inactive Rx antenna chain cannot " + "be an active spectral chain\n"); + error = -EINVAL; + break; + } else if (sc->sptrlc_set_spectral_config( + pdev, + SPECTRAL_PARAM_CHN_MASK, + sp_in->ss_chn_mask)) { + error = -EINVAL; + } } } - } - break; + break; case SPECTRAL_GET_CONFIG: - { - if (!outdata || !outsize || (*outsize < sizeof( - struct spectral_config))) { - error = -EINVAL; - break; + { + if (!outdata || !outsize || + (*outsize < sizeof(struct spectral_config))) { + error = -EINVAL; + break; + } + *outsize = sizeof(struct spectral_config); + sc->sptrlc_get_spectral_config(pdev, &sp_out); + spectralparams = (struct spectral_config *)outdata; + spectralparams->ss_fft_period = sp_out.ss_fft_period; + spectralparams->ss_period = sp_out.ss_period; + spectralparams->ss_count = sp_out.ss_count; + spectralparams->ss_short_report = + sp_out.ss_short_report; + spectralparams->ss_spectral_pri = + sp_out.ss_spectral_pri; + spectralparams->ss_fft_size = sp_out.ss_fft_size; + spectralparams->ss_gc_ena = sp_out.ss_gc_ena; + spectralparams->ss_restart_ena = sp_out.ss_restart_ena; + spectralparams->ss_noise_floor_ref = + sp_out.ss_noise_floor_ref; + spectralparams->ss_init_delay = sp_out.ss_init_delay; + spectralparams->ss_nb_tone_thr = sp_out.ss_nb_tone_thr; + spectralparams->ss_str_bin_thr = sp_out.ss_str_bin_thr; + spectralparams->ss_wb_rpt_mode = sp_out.ss_wb_rpt_mode; + spectralparams->ss_rssi_rpt_mode = + sp_out.ss_rssi_rpt_mode; + spectralparams->ss_rssi_thr = sp_out.ss_rssi_thr; + spectralparams->ss_pwr_format = sp_out.ss_pwr_format; + spectralparams->ss_rpt_mode = sp_out.ss_rpt_mode; + spectralparams->ss_bin_scale = sp_out.ss_bin_scale; + spectralparams->ss_dbm_adj = sp_out.ss_dbm_adj; + spectralparams->ss_chn_mask = sp_out.ss_chn_mask; } - *outsize = sizeof(struct spectral_config); - sc->sptrlc_get_spectral_config(pdev, &sp_out); - spectralparams = (struct spectral_config *)outdata; - spectralparams->ss_fft_period = sp_out.ss_fft_period; - spectralparams->ss_period = sp_out.ss_period; - spectralparams->ss_count = sp_out.ss_count; - spectralparams->ss_short_report = sp_out.ss_short_report; - spectralparams->ss_spectral_pri = sp_out.ss_spectral_pri; - spectralparams->ss_fft_size = sp_out.ss_fft_size; - spectralparams->ss_gc_ena = sp_out.ss_gc_ena; - spectralparams->ss_restart_ena = sp_out.ss_restart_ena; - spectralparams->ss_noise_floor_ref = sp_out.ss_noise_floor_ref; - spectralparams->ss_init_delay = sp_out.ss_init_delay; - spectralparams->ss_nb_tone_thr = sp_out.ss_nb_tone_thr; - spectralparams->ss_str_bin_thr = sp_out.ss_str_bin_thr; - spectralparams->ss_wb_rpt_mode = sp_out.ss_wb_rpt_mode; - spectralparams->ss_rssi_rpt_mode = sp_out.ss_rssi_rpt_mode; - spectralparams->ss_rssi_thr = sp_out.ss_rssi_thr; - spectralparams->ss_pwr_format = sp_out.ss_pwr_format; - spectralparams->ss_rpt_mode = sp_out.ss_rpt_mode; - spectralparams->ss_bin_scale = sp_out.ss_bin_scale; - spectralparams->ss_dbm_adj = sp_out.ss_dbm_adj; - spectralparams->ss_chn_mask = sp_out.ss_chn_mask; - } - break; + break; case SPECTRAL_IS_ACTIVE: - { - if (!outdata || !outsize || *outsize < sizeof(u_int32_t)) { - error = -EINVAL; - break; + { + if (!outdata || !outsize || + *outsize < sizeof(uint32_t)) { + error = -EINVAL; + break; + } + *outsize = sizeof(uint32_t); + *((uint32_t *)outdata) = + (uint32_t)sc->sptrlc_is_spectral_active(pdev); } - *outsize = sizeof(u_int32_t); - *((u_int32_t *)outdata) = - (u_int32_t)sc->sptrlc_is_spectral_active(pdev); - } - break; + break; case SPECTRAL_IS_ENABLED: - { - if (!outdata || !outsize || *outsize < sizeof(u_int32_t)) { - error = -EINVAL; - break; + { + if (!outdata || !outsize || + *outsize < sizeof(uint32_t)) { + error = -EINVAL; + break; + } + *outsize = sizeof(uint32_t); + *((uint32_t *)outdata) = + (uint32_t)sc->sptrlc_is_spectral_enabled(pdev); } - *outsize = sizeof(u_int32_t); - *((u_int32_t *)outdata) = - (u_int32_t)sc->sptrlc_is_spectral_enabled(pdev); - } - break; + break; case SPECTRAL_SET_DEBUG_LEVEL: - { - if (insize < sizeof(u_int32_t) || !indata) { - error = -EINVAL; - break; + { + if (insize < sizeof(uint32_t) || !indata) { + error = -EINVAL; + break; + } + temp_debug = *(uint32_t *)indata; + sc->sptrlc_set_debug_level(pdev, temp_debug); } - temp_debug = *(u_int32_t *)indata; - sc->sptrlc_set_debug_level(pdev, temp_debug); - } - break; + break; -case SPECTRAL_GET_DEBUG_LEVEL: - { - if (!outdata || !outsize || *outsize < sizeof(u_int32_t)) { - error = -EINVAL; - break; + case SPECTRAL_GET_DEBUG_LEVEL: + { + if (!outdata || !outsize || + *outsize < sizeof(uint32_t)) { + error = -EINVAL; + break; + } + *outsize = sizeof(uint32_t); + *((uint32_t *)outdata) = + (uint32_t)sc->sptrlc_get_debug_level(pdev); } - *outsize = sizeof(u_int32_t); - *((u_int32_t *)outdata) = - (u_int32_t)sc->sptrlc_get_debug_level(pdev); - } - break; + break; case SPECTRAL_ACTIVATE_SCAN: - { - sc->sptrlc_start_spectral_scan(pdev); - } - break; + { + sc->sptrlc_start_spectral_scan(pdev); + } + break; case SPECTRAL_STOP_SCAN: - { - sc->sptrlc_stop_spectral_scan(pdev); - } - break; + { + sc->sptrlc_stop_spectral_scan(pdev); + } + break; case SPECTRAL_GET_CAPABILITY_INFO: - { - if (!outdata || !outsize || - *outsize < sizeof(struct spectral_caps)) { - error = -EINVAL; - break; + { + if (!outdata || !outsize || + *outsize < sizeof(struct spectral_caps)) { + error = -EINVAL; + break; + } + *outsize = sizeof(struct spectral_caps); + sc->sptrlc_get_spectral_capinfo(pdev, outdata); } - *outsize = sizeof(struct spectral_caps); - sc->sptrlc_get_spectral_capinfo(pdev, outdata); - } - break; + break; case SPECTRAL_GET_DIAG_STATS: - { - if (!outdata || !outsize || - (*outsize < sizeof(struct spectral_diag_stats))) { - error = -EINVAL; - break; + { + if (!outdata || !outsize || + (*outsize < sizeof(struct spectral_diag_stats))) { + error = -EINVAL; + break; + } + *outsize = sizeof(struct spectral_diag_stats); + sc->sptrlc_get_spectral_diagstats(pdev, outdata); } - *outsize = sizeof(struct spectral_diag_stats); - sc->sptrlc_get_spectral_diagstats(pdev, outdata); - } - break; + break; case SPECTRAL_GET_CHAN_WIDTH: - { - u_int32_t chan_width; + { + uint32_t chan_width; - vdev = spectral_get_vdev(pdev); - if (!vdev) - return -ENOENT; + vdev = spectral_get_vdev(pdev); + if (!vdev) + return -ENOENT; - chan_width = spectral_vdev_get_ch_width(vdev); - wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID); + chan_width = spectral_vdev_get_ch_width(vdev); + wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID); - if (!outdata || !outsize || - *outsize < sizeof(chan_width)) { - error = -EINVAL; - break; + if (!outdata || !outsize || + *outsize < sizeof(chan_width)) { + error = -EINVAL; + break; + } + *outsize = sizeof(chan_width); + *((uint32_t *)outdata) = (uint32_t)chan_width; } - *outsize = sizeof(chan_width); - *((u_int32_t *)outdata) = (u_int32_t)chan_width; - } - break; + break; default: - error = -EINVAL; - break; + error = -EINVAL; + break; } -bad: + bad: return error; } -static void spectral_ctx_deinit(struct spectral_context *sc) +/** + * spectral_ctx_deinit() - De-initialize function pointers from spectral context + * @sc - Reference to spectral_context object + * + * Return: None + */ +static void +spectral_ctx_deinit(struct spectral_context *sc) { if (sc) { - sc->sptrlc_ucfg_phyerr_config = NULL; - sc->sptrlc_pdev_spectral_init = NULL; - sc->sptrlc_pdev_spectral_deinit = NULL; - sc->sptrlc_set_spectral_config = NULL; - sc->sptrlc_get_spectral_config = NULL; - sc->sptrlc_start_spectral_scan = NULL; - sc->sptrlc_stop_spectral_scan = NULL; - sc->sptrlc_is_spectral_active = NULL; - sc->sptrlc_is_spectral_enabled = NULL; - sc->sptrlc_set_debug_level = NULL; - sc->sptrlc_get_debug_level = NULL; - sc->sptrlc_get_spectral_capinfo = NULL; + sc->sptrlc_ucfg_phyerr_config = NULL; + sc->sptrlc_pdev_spectral_init = NULL; + sc->sptrlc_pdev_spectral_deinit = NULL; + sc->sptrlc_set_spectral_config = NULL; + sc->sptrlc_get_spectral_config = NULL; + sc->sptrlc_start_spectral_scan = NULL; + sc->sptrlc_stop_spectral_scan = NULL; + sc->sptrlc_is_spectral_active = NULL; + sc->sptrlc_is_spectral_enabled = NULL; + sc->sptrlc_set_debug_level = NULL; + sc->sptrlc_get_debug_level = NULL; + sc->sptrlc_get_spectral_capinfo = NULL; sc->sptrlc_get_spectral_diagstats = NULL; } } @@ -491,8 +535,8 @@ wlan_spectral_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc, void *arg) spectral_err("PSOC is NULL\n"); return QDF_STATUS_E_FAILURE; } - sc = (struct spectral_context *)qdf_mem_malloc( - sizeof(struct spectral_context)); + sc = (struct spectral_context *) + qdf_mem_malloc(sizeof(struct spectral_context)); if (!sc) { spectral_err("Failed to allocate spectral_ctx object\n"); return QDF_STATUS_E_NOMEM; @@ -511,9 +555,9 @@ wlan_spectral_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc, void *arg) return QDF_STATUS_SUCCESS; } -QDF_STATUS wlan_spectral_psoc_obj_destroy_handler( - struct wlan_objmgr_psoc *psoc, - void *arg) +QDF_STATUS +wlan_spectral_psoc_obj_destroy_handler(struct wlan_objmgr_psoc *psoc, + void *arg) { struct spectral_context *sc = NULL; @@ -521,13 +565,11 @@ QDF_STATUS wlan_spectral_psoc_obj_destroy_handler( spectral_err("PSOC is NULL\n"); return QDF_STATUS_E_FAILURE; } - sc = wlan_objmgr_psoc_get_comp_private_obj( - psoc, - WLAN_UMAC_COMP_SPECTRAL); + sc = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_UMAC_COMP_SPECTRAL); if (sc) { - wlan_objmgr_psoc_component_obj_detach( - psoc, - WLAN_UMAC_COMP_SPECTRAL, + wlan_objmgr_psoc_component_obj_detach(psoc, + WLAN_UMAC_COMP_SPECTRAL, (void *)sc); /* Deinitilise function pointers from spectral context */ spectral_ctx_deinit(sc); @@ -548,8 +590,8 @@ wlan_spectral_pdev_obj_create_handler(struct wlan_objmgr_pdev *pdev, void *arg) spectral_err("PDEV is NULL\n"); return QDF_STATUS_E_FAILURE; } - ps = (struct pdev_spectral *)qdf_mem_malloc( - sizeof(struct pdev_spectral)); + ps = (struct pdev_spectral *) + qdf_mem_malloc(sizeof(struct pdev_spectral)); if (!ps) { spectral_err("Failed to allocate pdev_spectral object\n"); return QDF_STATUS_E_NOMEM; @@ -576,13 +618,14 @@ wlan_spectral_pdev_obj_create_handler(struct wlan_objmgr_pdev *pdev, void *arg) (void *)ps, QDF_STATUS_SUCCESS); return QDF_STATUS_SUCCESS; -cleanup: + cleanup: qdf_mem_free(ps); return QDF_STATUS_E_FAILURE; } QDF_STATUS -wlan_spectral_pdev_obj_destroy_handler(struct wlan_objmgr_pdev *pdev, void *arg) +wlan_spectral_pdev_obj_destroy_handler(struct wlan_objmgr_pdev *pdev, + void *arg) { struct pdev_spectral *ps = NULL; struct spectral_context *sc = NULL; @@ -596,20 +639,17 @@ wlan_spectral_pdev_obj_destroy_handler(struct wlan_objmgr_pdev *pdev, void *arg) spectral_err("Spectral context is NULL!\n"); return QDF_STATUS_E_FAILURE; } - ps = wlan_objmgr_pdev_get_comp_private_obj( - pdev, - WLAN_UMAC_COMP_SPECTRAL); + ps = wlan_objmgr_pdev_get_comp_private_obj(pdev, + WLAN_UMAC_COMP_SPECTRAL); if (ps) { if (sc->sptrlc_pdev_spectral_deinit) sc->sptrlc_pdev_spectral_deinit(pdev); ps->psptrl_target_handle = NULL; - wlan_objmgr_pdev_component_obj_detach( - pdev, - WLAN_UMAC_COMP_SPECTRAL, + wlan_objmgr_pdev_component_obj_detach(pdev, + WLAN_UMAC_COMP_SPECTRAL, (void *)ps); qdf_mem_free(ps); } return QDF_STATUS_SUCCESS; } - diff --git a/spectral/core/spectral_da_api_i.h b/spectral/core/spectral_da_api_i.h index c0dca87dbd75..5cc48b02490c 100644 --- a/spectral/core/spectral_da_api_i.h +++ b/spectral/core/spectral_da_api_i.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -23,11 +23,14 @@ #include "spectral_defs_i.h" /** - * spectral_ctx_init_da() - Internal function to initialise spectral context + * spectral_ctx_init_da() - Internal function to initialize spectral context * with direct attach specific functions * @sc : spectral context * - * Return : void + * Internal function to initialize spectral context with direct attach + * specific functions + * + * Return : None */ void spectral_ctx_init_da(struct spectral_context *sc); diff --git a/spectral/core/spectral_defs_i.h b/spectral/core/spectral_defs_i.h index 986c567d8f04..54b51903431f 100644 --- a/spectral/core/spectral_defs_i.h +++ b/spectral/core/spectral_defs_i.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -60,16 +60,16 @@ QDF_PRINT_INFO(QDF_PRINT_IDX_SHARED, QDF_MODULE_ID_SPECTRAL, level, ## args) * @psptrl_target_handle: reference to spectral lmac object */ struct pdev_spectral { - struct wlan_objmgr_pdev *psptrl_pdev; - struct sock *psptrl_nl_sock; - void *psptrl_target_handle; + struct wlan_objmgr_pdev *psptrl_pdev; + struct sock *psptrl_nl_sock; + void *psptrl_target_handle; }; struct wmi_spectral_cmd_ops; /** - * struct spectral_context : spectral global context - * - * @psoc_obj: Reference to psoc global object + * struct spectral_context - spectral global context + * @psoc_obj: Reference to psoc global object + * @spectral_legacy_cbacks: Spectral legacy callbacks * * Call back functions to invoke independent of OL/DA * @sptrlc_ucfg_phyerr_config: ucfg handler for phyerr @@ -85,38 +85,39 @@ struct wmi_spectral_cmd_ops; * @sptrlc_get_debug_level: Get debug level * @sptrlc_get_spectral_capinfo: Get spectral capability info * @sptrlc_get_spectral_diagstats: Get spectral diag status + * @sptrlc_register_wmi_spectral_cmd_ops: Register wmi_spectral_cmd operations */ struct spectral_context { struct wlan_objmgr_psoc *psoc_obj; struct spectral_legacy_cbacks legacy_cbacks; - int (*sptrlc_spectral_control)(struct wlan_objmgr_pdev *pdev, u_int id, - void *indata, u_int32_t insize, - void *outdata, u_int32_t *outsize); + int (*sptrlc_spectral_control)(struct wlan_objmgr_pdev *pdev, + u_int id, void *indata, + uint32_t insize, void *outdata, + uint32_t *outsize); int (*sptrlc_ucfg_phyerr_config)(struct wlan_objmgr_pdev *pdev, void *ad); void * (*sptrlc_pdev_spectral_init)(struct wlan_objmgr_pdev *pdev); void (*sptrlc_pdev_spectral_deinit)(struct wlan_objmgr_pdev *pdev); - int (*sptrlc_set_spectral_config)( - struct wlan_objmgr_pdev *pdev, - const u_int32_t threshtype, const u_int32_t value); + int (*sptrlc_set_spectral_config)(struct wlan_objmgr_pdev *pdev, + const uint32_t threshtype, + const uint32_t value); void (*sptrlc_get_spectral_config)( - struct wlan_objmgr_pdev *pdev, - struct spectral_config *sptrl_config); + struct wlan_objmgr_pdev *pdev, + struct spectral_config *sptrl_config); int (*sptrlc_start_spectral_scan)(struct wlan_objmgr_pdev *pdev); void (*sptrlc_stop_spectral_scan)(struct wlan_objmgr_pdev *pdev); bool (*sptrlc_is_spectral_active)(struct wlan_objmgr_pdev *pdev); bool (*sptrlc_is_spectral_enabled)(struct wlan_objmgr_pdev *pdev); int (*sptrlc_set_debug_level)(struct wlan_objmgr_pdev *pdev, - u_int32_t debug_level); - u_int32_t (*sptrlc_get_debug_level)(struct wlan_objmgr_pdev *pdev); + uint32_t debug_level); + uint32_t (*sptrlc_get_debug_level)(struct wlan_objmgr_pdev *pdev); void (*sptrlc_get_spectral_capinfo)(struct wlan_objmgr_pdev *pdev, - void *outdata); + void *outdata); void (*sptrlc_get_spectral_diagstats)(struct wlan_objmgr_pdev *pdev, - void *outdata); + void *outdata); void (*sptrlc_register_wmi_spectral_cmd_ops)( - struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops); + struct wlan_objmgr_pdev *pdev, + struct wmi_spectral_cmd_ops *cmd_ops); }; -#endif /* _SPECTRAL_DEFS_I_H_ */ - +#endif /* _SPECTRAL_DEFS_I_H_ */ diff --git a/spectral/core/spectral_direct_attach.c b/spectral/core/spectral_direct_attach.c index aef45d6e98d0..8087760adf04 100644 --- a/spectral/core/spectral_direct_attach.c +++ b/spectral/core/spectral_direct_attach.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 @@ -19,8 +19,23 @@ #include "spectral_cmn_api_i.h" -int spectral_control_da(struct wlan_objmgr_pdev *pdev, u_int id, void *indata, - u_int32_t insize, void *outdata, u_int32_t *outsize) +/** + * spectral_control_da()- handler for demultiplexing requests from higher layer + * @pdev: reference to global pdev object + * @id: spectral config command id + * @indata: reference to input data + * @insize: input data size + * @outdata: reference to output data + * @outsize: output data size + * + * This function processes the spectral config command + * and appropriate handlers are invoked. + * + * Return: 0 success else failure + */ +int +spectral_control_da(struct wlan_objmgr_pdev *pdev, u_int id, void *indata, + uint32_t insize, void *outdata, uint32_t *outsize) { struct spectral_context *sc; int error = 0; @@ -34,32 +49,29 @@ int spectral_control_da(struct wlan_objmgr_pdev *pdev, u_int id, void *indata, spectral_err("spectral context is NULL!\n"); return -EPERM; } - switch (id) { -#if ATH_SUPPORT_RAW_ADC_CAPTURE - case SPECTRAL_ADC_ENABLE_TEST_ADDAC_MODE: - error = spectral_enter_raw_capture_mode(dev, indata); - break; - case SPECTRAL_ADC_DISABLE_TEST_ADDAC_MODE: - error = spectral_exit_raw_capture_mode(dev); - break; - case SPECTRAL_ADC_RETRIEVE_DATA: - error = spectral_retrieve_raw_capture(dev, outdata, outsize); - break; -#endif - default: - error = spectral_control_cmn( - pdev, - id, - indata, - insize, - outdata, - outsize); - break; - } + + /* + * Note: Add handling for the cases SPECTRAL_ADC_ENABLE_TEST_ADDAC_MODE + * SPECTRAL_ADC_DISABLE_TEST_ADDAC_MODE and SPECTRAL_ADC_RETRIEVE_DATA, + * when raw ADC capture is needed. + * This is only applicable for direct attach chipsets. + */ + error = spectral_control_cmn(pdev, + id, + indata, insize, outdata, outsize); + return error; } -static void *pdev_spectral_init_da(struct wlan_objmgr_pdev *pdev) +/** + * pdev_spectral_init_da() - offload implementation for spectral init + * @pdev: Pointer to pdev + * + * Return: On success, pointer to Spectral target_if internal private data, on + * failure, NULL + */ +static void * +pdev_spectral_init_da(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -69,7 +81,14 @@ static void *pdev_spectral_init_da(struct wlan_objmgr_pdev *pdev) pdev); } -static void pdev_spectral_deinit_da(struct wlan_objmgr_pdev *pdev) +/** + * pdev_spectral_deinit_da() - offload implementation for spectral de-init + * @pdev: Pointer to pdev + * + * Return: None + */ +static void +pdev_spectral_deinit_da(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -78,32 +97,61 @@ static void pdev_spectral_deinit_da(struct wlan_objmgr_pdev *pdev) psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_pdev_spectral_deinit(pdev); } -static int set_spectral_config_da( - struct wlan_objmgr_pdev *pdev, - const u_int32_t threshtype, const u_int32_t value) +/** + * set_spectral_config_da() - Set spectral config + * @pdev: Pointer to pdev object + * @threshtype: spectral parameter type + * @value: value to be configured for the given spectral parameter + * + * DA implementation for setting spectral config + * + * Return: 0 on success else failure + */ +static int +set_spectral_config_da(struct wlan_objmgr_pdev *pdev, + const uint32_t threshtype, const uint32_t value) { struct wlan_objmgr_psoc *psoc = NULL; psoc = wlan_pdev_get_psoc(pdev); return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_set_spectral_config( - pdev, - threshtype, - value); + pdev, threshtype, value); } -static void get_spectral_config_da(struct wlan_objmgr_pdev *pdev, - struct spectral_config *sptrl_config) +/** + * get_spectral_config_da() - Get spectral configuration + * @pdev: Pointer to pdev object + * @param: Pointer to spectral_config structure in which the configuration + * should be returned + * + * DA implementation for getting the current spectral configuration + * + * Return: None + */ +static void +get_spectral_config_da(struct wlan_objmgr_pdev *pdev, + struct spectral_config *sptrl_config) { struct wlan_objmgr_psoc *psoc = NULL; psoc = wlan_pdev_get_psoc(pdev); - psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_get_spectral_config(pdev, - sptrl_config); + psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_get_spectral_config( + pdev, + sptrl_config); } -static int start_spectral_scan_da(struct wlan_objmgr_pdev *pdev) +/** + * start_spectral_scan_da() - Start spectral scan + * @pdev: Pointer to pdev object + * + * DA implementation for starting spectral scan + * + * Return: 0 in case of success, -1 on failure + */ +static int +start_spectral_scan_da(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -113,7 +161,16 @@ static int start_spectral_scan_da(struct wlan_objmgr_pdev *pdev) pdev); } -static void stop_spectral_scan_da(struct wlan_objmgr_pdev *pdev) +/** + * stop_spectral_scan_da() - Stop spectral scan + * @pdev: Pointer to pdev object + * + * DA implementation for stop spectral scan + * + * Return: None + */ +static void +stop_spectral_scan_da(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -122,7 +179,16 @@ static void stop_spectral_scan_da(struct wlan_objmgr_pdev *pdev) psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_stop_spectral_scan(pdev); } -static bool is_spectral_active_da(struct wlan_objmgr_pdev *pdev) +/** + * is_spectral_active_da() - Get whether Spectral is active + * @pdev: Pointer to pdev object + * + * DA implementation to get whether Spectral is active + * + * Return: True if Spectral is active, false if Spectral is not active + */ +static bool +is_spectral_active_da(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -132,7 +198,16 @@ static bool is_spectral_active_da(struct wlan_objmgr_pdev *pdev) pdev); } -static bool is_spectral_enabled_da(struct wlan_objmgr_pdev *pdev) +/** + * is_spectral_enabled_da() - Get whether Spectral is active + * @pdev: Pointer to pdev object + * + * DA implementation to get whether Spectral is active + * + * Return: True if Spectral is active, false if Spectral is not active + */ +static bool +is_spectral_enabled_da(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -142,18 +217,37 @@ static bool is_spectral_enabled_da(struct wlan_objmgr_pdev *pdev) pdev); } -static int set_debug_level_da(struct wlan_objmgr_pdev *pdev, - u_int32_t debug_level) +/** + * set_debug_level_da() - Set debug level for Spectral + * @pdev: Pointer to pdev object + * @debug_level: Debug level + * + * DA implementation to set the debug level for Spectral + * + * Return: 0 in case of success + */ +static int +set_debug_level_da(struct wlan_objmgr_pdev *pdev, uint32_t debug_level) { struct wlan_objmgr_psoc *psoc = NULL; psoc = wlan_pdev_get_psoc(pdev); - return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_set_debug_level(pdev, + return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_set_debug_level( + pdev, debug_level); } -static u_int32_t get_debug_level_da(struct wlan_objmgr_pdev *pdev) +/** + * get_debug_level_da() - Get debug level for Spectral + * @pdev: Pointer to pdev object + * + * DA implementation to get the debug level for Spectral + * + * Return: Current debug level + */ +static uint32_t +get_debug_level_da(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -162,33 +256,59 @@ static u_int32_t get_debug_level_da(struct wlan_objmgr_pdev *pdev) return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_get_debug_level(pdev); } -static void get_spectral_capinfo_da(struct wlan_objmgr_pdev *pdev, - void *outdata) +/** + * get_spectral_capinfo_da() - Get Spectral capability information + * @pdev: Pointer to pdev object + * @outdata: Buffer into which data should be copied + * + * DA implementation to get the spectral capability information + * + * Return: void + */ +static void +get_spectral_capinfo_da(struct wlan_objmgr_pdev *pdev, void *outdata) { struct wlan_objmgr_psoc *psoc = NULL; psoc = wlan_pdev_get_psoc(pdev); return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_get_spectral_capinfo( - pdev, - outdata); + pdev, outdata); } -static void get_spectral_diagstats_da(struct wlan_objmgr_pdev *pdev, - void *outdata) +/** + * get_spectral_diagstats_da() - Get Spectral diagnostic statistics + * @pdev: Pointer to pdev object + * @outdata: Buffer into which data should be copied + * + * DA implementation to get the spectral diagnostic statistics + * + * Return: void + */ +static void +get_spectral_diagstats_da(struct wlan_objmgr_pdev *pdev, void *outdata) { struct wlan_objmgr_psoc *psoc = NULL; psoc = wlan_pdev_get_psoc(pdev); return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_get_spectral_diagstats( - pdev, - outdata); + pdev, outdata); } -static void register_wmi_spectral_cmd_ops_da( - struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops) +/** + * register_wmi_spectral_cmd_ops_da() - Register wmi_spectral_cmd_ops + * @cmd_ops: Pointer to the structure having wmi_spectral_cmd function pointers + * @pdev: Pointer to pdev object + * + * DA implementation to register wmi_spectral_cmd_ops in spectral + * internal data structure + * + * Return: void + */ +static void +register_wmi_spectral_cmd_ops_da(struct wlan_objmgr_pdev *pdev, + struct wmi_spectral_cmd_ops *cmd_ops) { struct wlan_objmgr_psoc *psoc = NULL; struct wlan_lmac_if_sptrl_tx_ops *psptrl_tx_ops = NULL; @@ -197,32 +317,30 @@ static void register_wmi_spectral_cmd_ops_da( psptrl_tx_ops = &psoc->soc_cb.tx_ops.sptrl_tx_ops; - return psptrl_tx_ops->sptrlto_register_wmi_spectral_cmd_ops( - pdev, - cmd_ops); + return psptrl_tx_ops->sptrlto_register_wmi_spectral_cmd_ops(pdev, + cmd_ops); } - -void spectral_ctx_init_da(struct spectral_context *sc) +void +spectral_ctx_init_da(struct spectral_context *sc) { if (!sc) { spectral_err("spectral context is null!\n"); return; } - sc->sptrlc_spectral_control = spectral_control_da; - sc->sptrlc_pdev_spectral_init = pdev_spectral_init_da; - sc->sptrlc_pdev_spectral_deinit = pdev_spectral_deinit_da; - sc->sptrlc_set_spectral_config = set_spectral_config_da; - sc->sptrlc_get_spectral_config = get_spectral_config_da; - sc->sptrlc_start_spectral_scan = start_spectral_scan_da; - sc->sptrlc_stop_spectral_scan = stop_spectral_scan_da; - sc->sptrlc_is_spectral_active = is_spectral_active_da; - sc->sptrlc_is_spectral_enabled = is_spectral_enabled_da; - sc->sptrlc_set_debug_level = set_debug_level_da; - sc->sptrlc_get_debug_level = get_debug_level_da; - sc->sptrlc_get_spectral_capinfo = get_spectral_capinfo_da; + sc->sptrlc_spectral_control = spectral_control_da; + sc->sptrlc_pdev_spectral_init = pdev_spectral_init_da; + sc->sptrlc_pdev_spectral_deinit = pdev_spectral_deinit_da; + sc->sptrlc_set_spectral_config = set_spectral_config_da; + sc->sptrlc_get_spectral_config = get_spectral_config_da; + sc->sptrlc_start_spectral_scan = start_spectral_scan_da; + sc->sptrlc_stop_spectral_scan = stop_spectral_scan_da; + sc->sptrlc_is_spectral_active = is_spectral_active_da; + sc->sptrlc_is_spectral_enabled = is_spectral_enabled_da; + sc->sptrlc_set_debug_level = set_debug_level_da; + sc->sptrlc_get_debug_level = get_debug_level_da; + sc->sptrlc_get_spectral_capinfo = get_spectral_capinfo_da; sc->sptrlc_get_spectral_diagstats = get_spectral_diagstats_da; sc->sptrlc_register_wmi_spectral_cmd_ops = - register_wmi_spectral_cmd_ops_da; + register_wmi_spectral_cmd_ops_da; } - diff --git a/spectral/core/spectral_module.c b/spectral/core/spectral_module.c index 2283f05b9bcf..153a8c57fdb1 100644 --- a/spectral/core/spectral_module.c +++ b/spectral/core/spectral_module.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 @@ -34,9 +34,9 @@ spectral_init_module(void) { qdf_print("qca_spectral module loaded\n"); wlan_spectral_init(); - /* register spectral rxops*/ - wlan_lmac_if_sptrl_set_rx_ops_register_cb( - wlan_lmac_if_sptrl_register_rx_ops); + /* register spectral rxops */ + wlan_lmac_if_sptrl_set_rx_ops_register_cb + (wlan_lmac_if_sptrl_register_rx_ops); return 0; } @@ -54,4 +54,3 @@ spectral_exit_module(void) module_init(spectral_init_module); module_exit(spectral_exit_module); - diff --git a/spectral/core/spectral_offload.c b/spectral/core/spectral_offload.c index e7a21fed0acb..3c43f9cfffe1 100644 --- a/spectral/core/spectral_offload.c +++ b/spectral/core/spectral_offload.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -20,12 +20,25 @@ #include "spectral_cmn_api_i.h" #include "spectral_ol_api_i.h" -int spectral_control_ol( - struct wlan_objmgr_pdev *pdev, - u_int id, - void *indata, - u_int32_t insize, - void *outdata, u_int32_t *outsize) +/** + * spectral_control_ol()- handler for demultiplexing requests from higher layer + * @pdev: reference to global pdev object + * @id: spectral config command id + * @indata: reference to input data + * @insize: input data size + * @outdata: reference to output data + * @outsize: output data size + * + * This function processes the spectral config command + * and appropriate handlers are invoked. + * + * Return: 0 success else failure + */ +int +spectral_control_ol(struct wlan_objmgr_pdev *pdev, + u_int id, + void *indata, + uint32_t insize, void *outdata, uint32_t *outsize) { struct spectral_context *sc; @@ -41,7 +54,15 @@ int spectral_control_ol( return spectral_control_cmn(pdev, id, indata, insize, outdata, outsize); } -static void *pdev_spectral_init_ol(struct wlan_objmgr_pdev *pdev) +/** + * pdev_spectral_init_ol() - offload implementation for spectral init + * @pdev: Pointer to pdev + * + * Return: On success, pointer to Spectral target_if internal private data, on + * failure, NULL + */ +static void * +pdev_spectral_init_ol(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -50,7 +71,14 @@ static void *pdev_spectral_init_ol(struct wlan_objmgr_pdev *pdev) pdev); } -static void pdev_spectral_deinit_ol(struct wlan_objmgr_pdev *pdev) +/** + * pdev_spectral_deinit_ol() - offload implementation for spectral de-init + * @pdev: Pointer to pdev + * + * Return: None + */ +static void +pdev_spectral_deinit_ol(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -58,29 +86,59 @@ static void pdev_spectral_deinit_ol(struct wlan_objmgr_pdev *pdev) psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_pdev_spectral_deinit(pdev); } -static int set_spectral_config_ol( - struct wlan_objmgr_pdev *pdev, - const u_int32_t threshtype, const u_int32_t value) +/** + * set_spectral_config_ol() - Set spectral config + * @pdev: Pointer to pdev object + * @threshtype: spectral parameter type + * @value: value to be configured for the given spectral parameter + * + * Offload implementation for setting spectral config + * + * Return: 0 on success else failure + */ +static int +set_spectral_config_ol(struct wlan_objmgr_pdev *pdev, + const uint32_t threshtype, const uint32_t value) { struct wlan_objmgr_psoc *psoc = NULL; psoc = wlan_pdev_get_psoc(pdev); return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_set_spectral_config( - pdev, - threshtype, value); + pdev, threshtype, value); } -static void get_spectral_config_ol(struct wlan_objmgr_pdev *pdev, - struct spectral_config *sptrl_config) +/** + * get_spectral_config_ol() - Get spectral configuration + * @pdev: Pointer to pdev object + * @param: Pointer to spectral_config structure in which the configuration + * should be returned + * + * Offload implementation for getting the current spectral configuration + * + * Return: None + */ +static void +get_spectral_config_ol(struct wlan_objmgr_pdev *pdev, + struct spectral_config *sptrl_config) { struct wlan_objmgr_psoc *psoc = NULL; psoc = wlan_pdev_get_psoc(pdev); - psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_get_spectral_config(pdev, + psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_get_spectral_config( + pdev, sptrl_config); } -static int start_spectral_scan_ol(struct wlan_objmgr_pdev *pdev) +/** + * start_spectral_scan_ol() - Start spectral scan + * @pdev: Pointer to pdev object + * + * Offload implementation for starting spectral scan + * + * Return: 0 in case of success, -1 on failure + */ +static int +start_spectral_scan_ol(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -89,7 +147,16 @@ static int start_spectral_scan_ol(struct wlan_objmgr_pdev *pdev) pdev); } -static void stop_spectral_scan_ol(struct wlan_objmgr_pdev *pdev) +/** + * stop_spectral_scan_ol() - Stop spectral scan + * @pdev: Pointer to pdev object + * + * Offload implementation for stop spectral scan + * + * Return: None + */ +static void +stop_spectral_scan_ol(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -97,7 +164,16 @@ static void stop_spectral_scan_ol(struct wlan_objmgr_pdev *pdev) psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_stop_spectral_scan(pdev); } -static bool is_spectral_active_ol(struct wlan_objmgr_pdev *pdev) +/** + * is_spectral_active_ol() - Get whether Spectral is active + * @pdev: Pointer to pdev object + * + * Offload implementation to get whether Spectral is active + * + * Return: True if Spectral is active, false if Spectral is not active + */ +static bool +is_spectral_active_ol(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -106,7 +182,16 @@ static bool is_spectral_active_ol(struct wlan_objmgr_pdev *pdev) pdev); } -static bool is_spectral_enabled_ol(struct wlan_objmgr_pdev *pdev) +/** + * is_spectral_enabled_ol() - Get whether Spectral is active + * @pdev: Pointer to pdev object + * + * Offload implementation to get whether Spectral is active + * + * Return: True if Spectral is active, false if Spectral is not active + */ +static bool +is_spectral_enabled_ol(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -115,17 +200,36 @@ static bool is_spectral_enabled_ol(struct wlan_objmgr_pdev *pdev) pdev); } -static int set_debug_level_ol(struct wlan_objmgr_pdev *pdev, - u_int32_t debug_level) +/** + * set_debug_level_ol() - Set debug level for Spectral + * @pdev: Pointer to pdev object + * @debug_level: Debug level + * + * Offload implementation to set the debug level for Spectral + * + * Return: 0 in case of success + */ +static int +set_debug_level_ol(struct wlan_objmgr_pdev *pdev, uint32_t debug_level) { struct wlan_objmgr_psoc *psoc = NULL; psoc = wlan_pdev_get_psoc(pdev); - return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_set_debug_level(pdev, + return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_set_debug_level( + pdev, debug_level); } -static u_int32_t get_debug_level_ol(struct wlan_objmgr_pdev *pdev) +/** + * get_debug_level_ol() - Get debug level for Spectral + * @pdev: Pointer to pdev object + * + * Offload implementation to get the debug level for Spectral + * + * Return: Current debug level + */ +static uint32_t +get_debug_level_ol(struct wlan_objmgr_pdev *pdev) { struct wlan_objmgr_psoc *psoc = NULL; @@ -133,31 +237,57 @@ static u_int32_t get_debug_level_ol(struct wlan_objmgr_pdev *pdev) return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_get_debug_level(pdev); } -static void get_spectral_capinfo_ol(struct wlan_objmgr_pdev *pdev, - void *outdata) +/** + * get_spectral_capinfo_ol() - Get Spectral capability information + * @pdev: Pointer to pdev object + * @outdata: Buffer into which data should be copied + * + * Offload implementation to get the spectral capability information + * + * Return: void + */ +static void +get_spectral_capinfo_ol(struct wlan_objmgr_pdev *pdev, void *outdata) { struct wlan_objmgr_psoc *psoc = NULL; psoc = wlan_pdev_get_psoc(pdev); return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_get_spectral_capinfo( - pdev, - outdata); + pdev, outdata); } -static void get_spectral_diagstats_ol(struct wlan_objmgr_pdev *pdev, - void *outdata) +/** + * get_spectral_diagstats_ol() - Get Spectral diagnostic statistics + * @pdev: Pointer to pdev object + * @outdata: Buffer into which data should be copied + * + * Offload implementation to get the spectral diagnostic statistics + * + * Return: void + */ +static void +get_spectral_diagstats_ol(struct wlan_objmgr_pdev *pdev, void *outdata) { struct wlan_objmgr_psoc *psoc = NULL; psoc = wlan_pdev_get_psoc(pdev); return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_get_spectral_diagstats( - pdev, - outdata); + pdev, outdata); } -static void register_wmi_spectral_cmd_ops_ol( - struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops) +/** + * register_wmi_spectral_cmd_ops_ol() - Register wmi_spectral_cmd_ops + * @cmd_ops: Pointer to the structure having wmi_spectral_cmd function pointers + * @pdev: Pointer to pdev object + * + * Offload implementation to register wmi_spectral_cmd_ops in spectral + * internal data structure + * + * Return: void + */ +static void +register_wmi_spectral_cmd_ops_ol(struct wlan_objmgr_pdev *pdev, + struct wmi_spectral_cmd_ops *cmd_ops) { struct wlan_objmgr_psoc *psoc = NULL; struct wlan_lmac_if_sptrl_tx_ops *psptrl_tx_ops = NULL; @@ -166,31 +296,30 @@ static void register_wmi_spectral_cmd_ops_ol( psptrl_tx_ops = &psoc->soc_cb.tx_ops.sptrl_tx_ops; - return psptrl_tx_ops->sptrlto_register_wmi_spectral_cmd_ops( - pdev, - cmd_ops); + return psptrl_tx_ops->sptrlto_register_wmi_spectral_cmd_ops(pdev, + cmd_ops); } -void spectral_ctx_init_ol(struct spectral_context *sc) +void +spectral_ctx_init_ol(struct spectral_context *sc) { if (!sc) { spectral_err("spectral context is null!\n"); return; } - sc->sptrlc_spectral_control = spectral_control_ol; - sc->sptrlc_pdev_spectral_init = pdev_spectral_init_ol; - sc->sptrlc_pdev_spectral_deinit = pdev_spectral_deinit_ol; - sc->sptrlc_set_spectral_config = set_spectral_config_ol; - sc->sptrlc_get_spectral_config = get_spectral_config_ol; - sc->sptrlc_start_spectral_scan = start_spectral_scan_ol; - sc->sptrlc_stop_spectral_scan = stop_spectral_scan_ol; - sc->sptrlc_is_spectral_active = is_spectral_active_ol; - sc->sptrlc_is_spectral_enabled = is_spectral_enabled_ol; - sc->sptrlc_set_debug_level = set_debug_level_ol; - sc->sptrlc_get_debug_level = get_debug_level_ol; - sc->sptrlc_get_spectral_capinfo = get_spectral_capinfo_ol; + sc->sptrlc_spectral_control = spectral_control_ol; + sc->sptrlc_pdev_spectral_init = pdev_spectral_init_ol; + sc->sptrlc_pdev_spectral_deinit = pdev_spectral_deinit_ol; + sc->sptrlc_set_spectral_config = set_spectral_config_ol; + sc->sptrlc_get_spectral_config = get_spectral_config_ol; + sc->sptrlc_start_spectral_scan = start_spectral_scan_ol; + sc->sptrlc_stop_spectral_scan = stop_spectral_scan_ol; + sc->sptrlc_is_spectral_active = is_spectral_active_ol; + sc->sptrlc_is_spectral_enabled = is_spectral_enabled_ol; + sc->sptrlc_set_debug_level = set_debug_level_ol; + sc->sptrlc_get_debug_level = get_debug_level_ol; + sc->sptrlc_get_spectral_capinfo = get_spectral_capinfo_ol; sc->sptrlc_get_spectral_diagstats = get_spectral_diagstats_ol; sc->sptrlc_register_wmi_spectral_cmd_ops = - register_wmi_spectral_cmd_ops_ol; + register_wmi_spectral_cmd_ops_ol; } - diff --git a/spectral/core/spectral_ol_api_i.h b/spectral/core/spectral_ol_api_i.h index 654165498822..0ac69348b2ec 100644 --- a/spectral/core/spectral_ol_api_i.h +++ b/spectral/core/spectral_ol_api_i.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -23,11 +23,14 @@ #include "spectral_defs_i.h" /** - * spectral_ctx_init_ol() - Internal function to initialise spectral context + * spectral_ctx_init_ol() - Internal function to initialize spectral context * with offload specific functions * @sc : spectral context * - * Return : void + * Internal function to initialize spectral context with offload specific + * functions + * + * Return : None */ void spectral_ctx_init_ol(struct spectral_context *sc);