diff --git a/init_deinit/dispatcher/inc/dispatcher_init_deinit.h b/init_deinit/dispatcher/inc/dispatcher_init_deinit.h index e0f23b132a..9c115df57d 100644 --- a/init_deinit/dispatcher/inc/dispatcher_init_deinit.h +++ b/init_deinit/dispatcher/inc/dispatcher_init_deinit.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2018,2020 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -29,9 +29,25 @@ #include #include -/* Function pointer for spectral pdev open handler */ -typedef QDF_STATUS (*spectral_pdev_open_handler)( - struct wlan_objmgr_pdev *pdev); +/** + * struct dispatcher_spectral_ops - Spectral ops table + * @spectral_pdev_open_handler: Spectral pdev open handler + * @spectral_psoc_open_handler: Spectral psoc open handler + * @spectral_psoc_close_handler: Spectral psoc close handler + * @spectral_psoc_enable_handler: Spectral psoc enable handler + * @spectral_psoc_disable_handler: Spectral psoc disable handler + */ +struct dispatcher_spectral_ops { + QDF_STATUS(*spectral_pdev_open_handler)(struct wlan_objmgr_pdev *pdev); + QDF_STATUS(*spectral_psoc_open_handler)( + struct wlan_objmgr_psoc *psoc); + QDF_STATUS(*spectral_psoc_close_handler)( + struct wlan_objmgr_psoc *psoc); + QDF_STATUS(*spectral_psoc_enable_handler)( + struct wlan_objmgr_psoc *psoc); + QDF_STATUS(*spectral_psoc_disable_handler)( + struct wlan_objmgr_psoc *psoc); +}; /** * dispatcher_init(): API to init all new components @@ -182,15 +198,15 @@ QDF_STATUS dispatcher_pdev_open(struct wlan_objmgr_pdev *pdev); QDF_STATUS dispatcher_pdev_close(struct wlan_objmgr_pdev *pdev); /** - * dispatcher_register_spectral_pdev_open_handler(): - * API to register spectral pdev open handler - * @handler: pdev open handler + * dispatcher_register_spectral_ops_handler(): API to register spectral + * operations + * @sops: pointer to Spectral ops table * - * This API registers spectral pdev open handler. + * This API registers spectral pdev open handler, psoc enable handler and + * psoc disable handler, psoc open handler and psoc close handler. * - * Return: none + * Return: QDF_STATUS */ -QDF_STATUS dispatcher_register_spectral_pdev_open_handler(QDF_STATUS (*handler) - (struct wlan_objmgr_pdev *pdev)); - +QDF_STATUS +dispatcher_register_spectral_ops_handler(struct dispatcher_spectral_ops *sops); #endif /* End of !defined(__DISPATCHER_INIT_H) */ diff --git a/init_deinit/dispatcher/src/dispatcher_init_deinit.c b/init_deinit/dispatcher/src/dispatcher_init_deinit.c index 79d3a10421..7859f5abb3 100644 --- a/init_deinit/dispatcher/src/dispatcher_init_deinit.c +++ b/init_deinit/dispatcher/src/dispatcher_init_deinit.c @@ -90,7 +90,7 @@ * their actual handlers are ready */ -spectral_pdev_open_handler dispatcher_spectral_pdev_open_handler_cb; +struct dispatcher_spectral_ops ops_spectral; #ifdef WLAN_CFR_ENABLE static QDF_STATUS dispatcher_init_cfr(void) @@ -322,26 +322,48 @@ static QDF_STATUS dispatcher_regulatory_psoc_close(struct wlan_objmgr_psoc return regulatory_psoc_close(psoc); } -#if defined(WLAN_CONV_SPECTRAL_ENABLE) && defined(SPECTRAL_MODULIZED_ENABLE) -QDF_STATUS dispatcher_register_spectral_pdev_open_handler( - spectral_pdev_open_handler handler) +#ifdef WLAN_CONV_SPECTRAL_ENABLE +#ifdef SPECTRAL_MODULIZED_ENABLE +QDF_STATUS +dispatcher_register_spectral_ops_handler(struct dispatcher_spectral_ops *sops) { - dispatcher_spectral_pdev_open_handler_cb = handler; + qdf_mem_copy(&ops_spectral, sops, + qdf_min(sizeof(*sops), sizeof(ops_spectral))); return QDF_STATUS_SUCCESS; } -qdf_export_symbol(dispatcher_register_spectral_pdev_open_handler); -static QDF_STATUS dispatcher_spectral_pdev_open(struct wlan_objmgr_pdev - *pdev) +qdf_export_symbol(dispatcher_register_spectral_ops_handler); + +static QDF_STATUS dispatcher_spectral_pdev_open(struct wlan_objmgr_pdev *pdev) { - return dispatcher_spectral_pdev_open_handler_cb(pdev); + return ops_spectral.spectral_pdev_open_handler(pdev); } static QDF_STATUS dispatcher_spectral_pdev_close(struct wlan_objmgr_pdev *pdev) { return QDF_STATUS_SUCCESS; } + +static QDF_STATUS spectral_psoc_open(struct wlan_objmgr_psoc *psoc) +{ + return ops_spectral.spectral_psoc_open_handler(psoc); +} + +static QDF_STATUS spectral_psoc_close(struct wlan_objmgr_psoc *psoc) +{ + return ops_spectral.spectral_psoc_close_handler(psoc); +} + +static QDF_STATUS spectral_psoc_enable(struct wlan_objmgr_psoc *psoc) +{ + return ops_spectral.spectral_psoc_enable_handler(psoc); +} + +static QDF_STATUS spectral_psoc_disable(struct wlan_objmgr_psoc *psoc) +{ + return ops_spectral.spectral_psoc_disable_handler(psoc); +} #else static QDF_STATUS dispatcher_spectral_pdev_open(struct wlan_objmgr_pdev *pdev) @@ -353,6 +375,58 @@ static QDF_STATUS dispatcher_spectral_pdev_close(struct wlan_objmgr_pdev *pdev) { return QDF_STATUS_SUCCESS; } + +static QDF_STATUS spectral_psoc_open(struct wlan_objmgr_psoc *psoc) +{ + return wlan_spectral_psoc_open(psoc); +} + +static QDF_STATUS spectral_psoc_close(struct wlan_objmgr_psoc *psoc) +{ + return wlan_spectral_psoc_close(psoc); +} + +static QDF_STATUS spectral_psoc_enable(struct wlan_objmgr_psoc *psoc) +{ + return wlan_spectral_psoc_enable(psoc); +} + +static QDF_STATUS spectral_psoc_disable(struct wlan_objmgr_psoc *psoc) +{ + return wlan_spectral_psoc_disable(psoc); +} +#endif +#else +static QDF_STATUS dispatcher_spectral_pdev_open(struct wlan_objmgr_pdev + *pdev) +{ + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS dispatcher_spectral_pdev_close(struct wlan_objmgr_pdev *pdev) +{ + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS spectral_psoc_open(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS spectral_psoc_close(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS spectral_psoc_enable(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS spectral_psoc_disable(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} #endif static QDF_STATUS dispatcher_regulatory_pdev_open(struct wlan_objmgr_pdev @@ -1031,6 +1105,8 @@ qdf_export_symbol(dispatcher_disable); QDF_STATUS dispatcher_psoc_open(struct wlan_objmgr_psoc *psoc) { + QDF_STATUS status; + if (QDF_STATUS_SUCCESS != wlan_mgmt_txrx_psoc_open(psoc)) goto out; @@ -1058,8 +1134,14 @@ QDF_STATUS dispatcher_psoc_open(struct wlan_objmgr_psoc *psoc) if (QDF_STATUS_SUCCESS != dcs_psoc_open(psoc)) goto dcs_psoc_open_fail; + status = spectral_psoc_open(psoc); + if (status != QDF_STATUS_SUCCESS && status != QDF_STATUS_COMP_DISABLED) + goto spectral_psoc_open_fail; + return QDF_STATUS_SUCCESS; +spectral_psoc_open_fail: + dcs_psoc_close(psoc); dcs_psoc_open_fail: dispatcher_coex_psoc_close(psoc); coex_psoc_open_fail: @@ -1084,6 +1166,8 @@ qdf_export_symbol(dispatcher_psoc_open); QDF_STATUS dispatcher_psoc_close(struct wlan_objmgr_psoc *psoc) { + QDF_STATUS status; + QDF_BUG(QDF_STATUS_SUCCESS == dcs_psoc_close(psoc)); QDF_BUG(QDF_STATUS_SUCCESS == dispatcher_coex_psoc_close(psoc)); @@ -1102,12 +1186,18 @@ QDF_STATUS dispatcher_psoc_close(struct wlan_objmgr_psoc *psoc) QDF_BUG(QDF_STATUS_SUCCESS == wlan_mgmt_txrx_psoc_close(psoc)); + status = spectral_psoc_close(psoc); + QDF_BUG((status == QDF_STATUS_SUCCESS) || + (status == QDF_STATUS_COMP_DISABLED)); + return QDF_STATUS_SUCCESS; } qdf_export_symbol(dispatcher_psoc_close); QDF_STATUS dispatcher_psoc_enable(struct wlan_objmgr_psoc *psoc) { + QDF_STATUS status; + if (QDF_STATUS_SUCCESS != wlan_serialization_psoc_enable(psoc)) goto out; @@ -1141,8 +1231,14 @@ QDF_STATUS dispatcher_psoc_enable(struct wlan_objmgr_psoc *psoc) if (QDF_STATUS_SUCCESS != wlan_mlme_psoc_enable(psoc)) goto mlme_psoc_enable_fail; + status = spectral_psoc_enable(psoc); + if (status != QDF_STATUS_SUCCESS && status != QDF_STATUS_COMP_DISABLED) + goto spectral_psoc_enable_fail; + return QDF_STATUS_SUCCESS; +spectral_psoc_enable_fail: + wlan_mlme_psoc_disable(psoc); mlme_psoc_enable_fail: dispatcher_dbr_psoc_disable(psoc); dbr_psoc_enable_fail: @@ -1170,6 +1266,8 @@ qdf_export_symbol(dispatcher_psoc_enable); QDF_STATUS dispatcher_psoc_disable(struct wlan_objmgr_psoc *psoc) { + QDF_STATUS status; + QDF_BUG(QDF_STATUS_SUCCESS == wlan_mlme_psoc_disable(psoc)); QDF_BUG(QDF_STATUS_SUCCESS == dispatcher_dbr_psoc_disable(psoc)); @@ -1190,6 +1288,10 @@ QDF_STATUS dispatcher_psoc_disable(struct wlan_objmgr_psoc *psoc) QDF_BUG(QDF_STATUS_SUCCESS == wlan_serialization_psoc_disable(psoc)); + status = spectral_psoc_disable(psoc); + QDF_BUG((status == QDF_STATUS_SUCCESS) || + (status == QDF_STATUS_COMP_DISABLED)); + return QDF_STATUS_SUCCESS; } qdf_export_symbol(dispatcher_psoc_disable); diff --git a/spectral/core/spectral_common.c b/spectral/core/spectral_common.c index aa006ff796..3a1471146f 100644 --- a/spectral/core/spectral_common.c +++ b/spectral/core/spectral_common.c @@ -483,6 +483,8 @@ spectral_ctx_deinit(struct spectral_context *sc) sc->sptrlc_ucfg_phyerr_config = NULL; sc->sptrlc_pdev_spectral_init = NULL; sc->sptrlc_pdev_spectral_deinit = NULL; + sc->sptrlc_psoc_spectral_init = NULL; + sc->sptrlc_psoc_spectral_deinit = NULL; sc->sptrlc_set_spectral_config = NULL; sc->sptrlc_get_spectral_config = NULL; sc->sptrlc_start_spectral_scan = NULL; diff --git a/spectral/core/spectral_defs_i.h b/spectral/core/spectral_defs_i.h index fdcd1bbdb4..e687746009 100644 --- a/spectral/core/spectral_defs_i.h +++ b/spectral/core/spectral_defs_i.h @@ -93,16 +93,21 @@ struct pdev_spectral { uint32_t spectral_pid; }; -struct wmi_spectral_cmd_ops; +struct spectral_wmi_ops; +struct spectral_tgt_ops; + /** * struct spectral_context - spectral global context * @psoc_obj: Reference to psoc global object + * @psoc_target_handle: Reference to psoc target_if object * @spectral_legacy_cbacks: Spectral legacy callbacks * * Call back functions to invoke independent of OL/DA * @sptrlc_ucfg_phyerr_config: ucfg handler for phyerr - * @sptrlc_pdev_spectral_init: Init spectral - * @sptrlc_pdev_spectral_deinit: Deinit spectral + * @sptrlc_pdev_spectral_init: Init pdev Spectral + * @sptrlc_pdev_spectral_deinit: Deinit pdev Spectral + * @sptrlc_psoc_spectral_init: Spectral psoc init + * @sptrlc_psoc_spectral_deinit: Spectral psoc deinit * @sptrlc_set_spectral_config: Set spectral configurations * @sptrlc_get_spectral_config: Get spectral configurations * @sptrlc_start_spectral_scan: Start spectral scan @@ -113,7 +118,8 @@ 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 + * @sptrlc_register_spectral_wmi_ops: Register Spectral WMI operations + * @ptrlc_register_spectral_tgt_ops: Register Spectral target operations * @sptrlc_register_netlink_cb: Register Netlink callbacks * @sptrlc_use_nl_bcast: Check whether to use Netlink broadcast/unicast * @sptrlc_deregister_netlink_cb: De-register Netlink callbacks @@ -122,6 +128,7 @@ struct wmi_spectral_cmd_ops; */ struct spectral_context { struct wlan_objmgr_psoc *psoc_obj; + void *psoc_target_handle; struct spectral_legacy_cbacks legacy_cbacks; QDF_STATUS (*sptrlc_spectral_control) (struct wlan_objmgr_pdev *pdev, @@ -130,6 +137,8 @@ struct spectral_context { void *ad); void * (*sptrlc_pdev_spectral_init)(struct wlan_objmgr_pdev *pdev); void (*sptrlc_pdev_spectral_deinit)(struct wlan_objmgr_pdev *pdev); + void * (*sptrlc_psoc_spectral_init)(struct wlan_objmgr_psoc *psoc); + void (*sptrlc_psoc_spectral_deinit)(struct wlan_objmgr_psoc *psoc); QDF_STATUS (*sptrlc_set_spectral_config) (struct wlan_objmgr_pdev *pdev, const struct spectral_cp_param *param, @@ -159,9 +168,12 @@ struct spectral_context { QDF_STATUS (*sptrlc_get_spectral_diagstats) (struct wlan_objmgr_pdev *pdev, struct spectral_diag_stats *stats); - void (*sptrlc_register_wmi_spectral_cmd_ops)( - struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops); + QDF_STATUS (*sptrlc_register_spectral_wmi_ops)( + struct wlan_objmgr_psoc *psoc, + struct spectral_wmi_ops *wmi_ops); + QDF_STATUS (*sptrlc_register_spectral_tgt_ops)( + struct wlan_objmgr_psoc *psoc, + struct spectral_tgt_ops *tgt_ops); void (*sptrlc_register_netlink_cb)( struct wlan_objmgr_pdev *pdev, struct spectral_nl_cb *nl_cb); diff --git a/spectral/core/spectral_module.c b/spectral/core/spectral_module.c index eabff65f6b..6f27f5f83e 100644 --- a/spectral/core/spectral_module.c +++ b/spectral/core/spectral_module.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011,2017-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2011,2017-2020 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -26,6 +26,14 @@ MODULE_LICENSE("Dual BSD/GPL"); +struct dispatcher_spectral_ops sops = { + .spectral_pdev_open_handler = spectral_pdev_open, + .spectral_psoc_open_handler = wlan_spectral_psoc_open, + .spectral_psoc_close_handler = wlan_spectral_psoc_close, + .spectral_psoc_enable_handler = wlan_spectral_psoc_enable, + .spectral_psoc_disable_handler = wlan_spectral_psoc_disable, +}; + /** * spectral_init_module() - Initialize Spectral module * @@ -43,9 +51,7 @@ int spectral_init_module(void) /* register spectral rxops */ wlan_lmac_if_sptrl_set_rx_ops_register_cb (wlan_lmac_if_sptrl_register_rx_ops); - /* register spectral pdev open handler */ - dispatcher_register_spectral_pdev_open_handler( - spectral_pdev_open); + dispatcher_register_spectral_ops_handler(&sops); return 0; } diff --git a/spectral/core/spectral_offload.c b/spectral/core/spectral_offload.c index 7db9dd3861..0b60945544 100644 --- a/spectral/core/spectral_offload.c +++ b/spectral/core/spectral_offload.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -48,6 +48,8 @@ spectral_ctx_init_ol(struct spectral_context *sc) sc->sptrlc_spectral_control = tgt_spectral_control; sc->sptrlc_pdev_spectral_init = tgt_pdev_spectral_init; sc->sptrlc_pdev_spectral_deinit = tgt_pdev_spectral_deinit; + sc->sptrlc_psoc_spectral_init = tgt_psoc_spectral_init; + sc->sptrlc_psoc_spectral_deinit = tgt_psoc_spectral_deinit; sc->sptrlc_set_spectral_config = tgt_set_spectral_config; sc->sptrlc_get_spectral_config = tgt_get_spectral_config; sc->sptrlc_start_spectral_scan = tgt_start_spectral_scan; @@ -58,8 +60,8 @@ spectral_ctx_init_ol(struct spectral_context *sc) sc->sptrlc_get_debug_level = tgt_get_debug_level; sc->sptrlc_get_spectral_capinfo = tgt_get_spectral_capinfo; sc->sptrlc_get_spectral_diagstats = tgt_get_spectral_diagstats; - sc->sptrlc_register_wmi_spectral_cmd_ops = - tgt_register_wmi_spectral_cmd_ops; + sc->sptrlc_register_spectral_wmi_ops = tgt_register_spectral_wmi_ops; + sc->sptrlc_register_spectral_tgt_ops = tgt_register_spectral_tgt_ops; sc->sptrlc_register_netlink_cb = tgt_spectral_register_nl_cb; sc->sptrlc_use_nl_bcast = tgt_spectral_use_nl_bcast; sc->sptrlc_deregister_netlink_cb = tgt_spectral_deregister_nl_cb; diff --git a/spectral/dispatcher/inc/wlan_spectral_tgt_api.h b/spectral/dispatcher/inc/wlan_spectral_tgt_api.h index 97cc62a449..c1ae3f5c97 100644 --- a/spectral/dispatcher/inc/wlan_spectral_tgt_api.h +++ b/spectral/dispatcher/inc/wlan_spectral_tgt_api.h @@ -25,15 +25,26 @@ #include "../../core/spectral_cmn_api_i.h" /** - * tgt_get_target_handle() - Get target_if handle + * tgt_get_pdev_target_handle() - Get pdev target_if handle * @pdev: Pointer to pdev * - * Get handle to target_if internal Spectral data + * Get handle to pdev target_if internal Spectral data * - * Return: Handle to target_if internal Spectral data on success, NULL on + * Return: Handle to pdev target_if internal Spectral data on success, NULL on * failure */ -void *tgt_get_target_handle(struct wlan_objmgr_pdev *pdev); +void *tgt_get_pdev_target_handle(struct wlan_objmgr_pdev *pdev); + +/** + * tgt_get_psoc_target_handle() - Get psoc target_if handle + * @psoc: Pointer to psoc + * + * Get handle to psoc target_if internal Spectral data + * + * Return: Handle to psoc target_if internal Spectral data on success, NULL on + * failure + */ +void *tgt_get_psoc_target_handle(struct wlan_objmgr_psoc *psoc); /** * tgt_spectral_control()- handler for demultiplexing requests from higher layer @@ -65,6 +76,23 @@ void *tgt_pdev_spectral_init(struct wlan_objmgr_pdev *pdev); */ void tgt_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev); +/** + * tgt_psoc_spectral_init() - implementation for spectral init + * @psoc: Pointer to psoc + * + * Return: On success, pointer to Spectral psoc target_if internal private data, + * on failure, NULL + */ +void *tgt_psoc_spectral_init(struct wlan_objmgr_psoc *psoc); + +/** + * tgt_psoc_spectral_deinit() - implementation for spectral de-init + * @psoc: Pointer to psoc + * + * Return: None + */ +void tgt_psoc_spectral_deinit(struct wlan_objmgr_psoc *psoc); + /** * tgt_set_spectral_config() - Set spectral config * @pdev: Pointer to pdev object @@ -195,17 +223,30 @@ QDF_STATUS tgt_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, struct spectral_diag_stats *stats); /** - * tgt_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 + * tgt_register_spectral_wmi_ops() - Register Spectral WMI operations + * @psoc: Pointer to psoc bject + * @wmi_ops: Pointer to the structure having Spectral WMI operations * - * Implementation to register wmi_spectral_cmd_ops in spectral + * Implementation to register Spectral WMI operations in spectral * internal data structure * - * Return: void + * Return: QDF_STATUS */ -void tgt_register_wmi_spectral_cmd_ops(struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops); +QDF_STATUS tgt_register_spectral_wmi_ops(struct wlan_objmgr_psoc *psoc, + struct spectral_wmi_ops *wmi_ops); + +/** + * tgt_register_spectral_tgt_ops() - Register Spectral target operations + * @psoc: Pointer to psoc bject + * @tgt_ops: Pointer to the structure having Spectral target operations + * + * Implementation to register Spectral target operations in spectral + * internal data structure + * + * Return: QDF_STATUS + */ +QDF_STATUS tgt_register_spectral_tgt_ops(struct wlan_objmgr_psoc *psoc, + struct spectral_tgt_ops *tgt_ops); /** * tgt_spectral_register_nl_cb() - Register Netlink callbacks @@ -283,4 +324,22 @@ tgt_spectral_get_target_type(struct wlan_objmgr_psoc *psoc); QDF_STATUS tgt_set_spectral_dma_debug(struct wlan_objmgr_pdev *pdev, enum spectral_dma_debug dma_debug_type, bool dma_debug_enable); + +/** + * tgt_spectral_register_events() - Register Spectral WMI event handlers + * @psoc: Pointer to psoc object + * + * Return: QDF_STATUS of operation + */ +QDF_STATUS +tgt_spectral_register_events(struct wlan_objmgr_psoc *psoc); + +/** + * tgt_spectral_unregister_events() - Unregister Spectral WMI event handlers + * @psoc: Pointer to psoc object + * + * Return: QDF_STATUS of operation + */ +QDF_STATUS +tgt_spectral_unregister_events(struct wlan_objmgr_psoc *psoc); #endif /* _WLAN_SPECTRAL_TGT_API_H_ */ diff --git a/spectral/dispatcher/inc/wlan_spectral_utils_api.h b/spectral/dispatcher/inc/wlan_spectral_utils_api.h index 3d1b159e82..3774ad1f86 100644 --- a/spectral/dispatcher/inc/wlan_spectral_utils_api.h +++ b/spectral/dispatcher/inc/wlan_spectral_utils_api.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -25,7 +25,8 @@ /* Forward declaration */ struct direct_buf_rx_data; -struct wmi_spectral_cmd_ops; +struct spectral_wmi_ops; +struct spectral_tgt_ops; /** * wlan_spectral_is_feature_disabled() - Check if spectral feature is disabled @@ -71,19 +72,32 @@ void wlan_lmac_if_sptrl_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops); /** -* wlan_register_wmi_spectral_cmd_ops() - Register operations related to wmi -* commands on spectral parameters -* @pdev - the physical device object -* @cmd_ops - pointer to the structure holding the operations -* related to wmi commands on spectral parameters -* -* API to register operations related to wmi commands on spectral parameters -* -* Return: None + * wlan_register_spectral_wmi_ops() - Register Spectral WMI operations + * @psoc - Pointer to psoc object + * @wmi_ops - pointer to the structure holding the Spectral WMI + * operations + * + * API to register Spectral WMI operations + * + * Return: QDF_STATUS */ -void -wlan_register_wmi_spectral_cmd_ops(struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops); +QDF_STATUS +wlan_register_spectral_wmi_ops(struct wlan_objmgr_psoc *psoc, + struct spectral_wmi_ops *wmi_ops); + +/** + * wlan_register_spectral_tgt_ops() - Register Spectral target operations + * @psoc - Pointer to psoc object + * @tgt_ops - pointer to the structure holding the Spectral target + * operations + * + * API to register Spectral target operations + * + * Return: QDF_STATUS + */ +QDF_STATUS +wlan_register_spectral_tgt_ops(struct wlan_objmgr_psoc *psoc, + struct spectral_tgt_ops *tgt_ops); /** * struct spectral_legacy_cbacks - Spectral legacy callbacks @@ -164,6 +178,50 @@ spectral_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev); */ QDF_STATUS spectral_pdev_open(struct wlan_objmgr_pdev *pdev); +/** + * wlan_spectral_psoc_open() - Spectral psoc open handler + * @psoc: pointer to psoc object + * + * API to execute operations on psoc open + * + * Return: QDF_STATUS_SUCCESS upon successful registration, + * QDF_STATUS_E_FAILURE upon failure + */ +QDF_STATUS wlan_spectral_psoc_open(struct wlan_objmgr_psoc *psoc); + +/** + * wlan_spectral_psoc_close() - Spectral psoc close handler + * @psoc: pointer to psoc object + * + * API to execute operations on psoc close + * + * Return: QDF_STATUS_SUCCESS upon successful registration, + * QDF_STATUS_E_FAILURE upon failure + */ +QDF_STATUS wlan_spectral_psoc_close(struct wlan_objmgr_psoc *psoc); + +/** + * wlan_spectral_psoc_enable() - Spectral psoc enable handler + * @psoc: pointer to psoc object + * + * API to execute operations on psoc enable + * + * Return: QDF_STATUS_SUCCESS upon successful registration, + * QDF_STATUS_E_FAILURE upon failure + */ +QDF_STATUS wlan_spectral_psoc_enable(struct wlan_objmgr_psoc *psoc); + +/** + * wlan_spectral_psoc_disable() - Spectral psoc disable handler + * @psoc: pointer to psoc object + * + * API to execute operations on psoc disable + * + * Return: QDF_STATUS_SUCCESS upon successful registration, + * QDF_STATUS_E_FAILURE upon failure + */ +QDF_STATUS wlan_spectral_psoc_disable(struct wlan_objmgr_psoc *psoc); + /** * spectral_register_dbr() - register Spectral event handler with DDMA * @pdev: pointer to pdev object diff --git a/spectral/dispatcher/src/wlan_spectral_tgt_api.c b/spectral/dispatcher/src/wlan_spectral_tgt_api.c index c42373e28c..4749b02885 100644 --- a/spectral/dispatcher/src/wlan_spectral_tgt_api.c +++ b/spectral/dispatcher/src/wlan_spectral_tgt_api.c @@ -29,7 +29,7 @@ #endif void * -tgt_get_target_handle(struct wlan_objmgr_pdev *pdev) +tgt_get_pdev_target_handle(struct wlan_objmgr_pdev *pdev) { struct pdev_spectral *ps; @@ -46,6 +46,26 @@ tgt_get_target_handle(struct wlan_objmgr_pdev *pdev) return ps->psptrl_target_handle; } +void * +tgt_get_psoc_target_handle(struct wlan_objmgr_psoc *psoc) +{ + struct spectral_context *sc; + + if (!psoc) { + spectral_err("psoc is NULL!"); + return NULL; + } + + sc = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_UMAC_COMP_SPECTRAL); + if (!sc) { + spectral_err("psoc Spectral object is NULL!"); + return NULL; + } + + return sc->psoc_target_handle; +} + QDF_STATUS tgt_spectral_control( struct wlan_objmgr_pdev *pdev, @@ -84,6 +104,29 @@ tgt_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev) psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_pdev_spectral_deinit(pdev); } +void * +tgt_psoc_spectral_init(struct wlan_objmgr_psoc *psoc) +{ + if (!psoc) { + spectral_err("psoc is null"); + return NULL; + } + + return psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_psoc_spectral_init( + psoc); +} + +void +tgt_psoc_spectral_deinit(struct wlan_objmgr_psoc *psoc) +{ + if (!psoc) { + spectral_err("psoc is null"); + return; + } + + psoc->soc_cb.tx_ops.sptrl_tx_ops.sptrlto_psoc_spectral_deinit(psoc); +} + QDF_STATUS tgt_set_spectral_config(struct wlan_objmgr_pdev *pdev, const struct spectral_cp_param *param, @@ -199,20 +242,47 @@ tgt_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, pdev, stats); } -void -tgt_register_wmi_spectral_cmd_ops( - struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops) +QDF_STATUS +tgt_register_spectral_wmi_ops(struct wlan_objmgr_psoc *psoc, + struct spectral_wmi_ops *wmi_ops) { - struct wlan_objmgr_psoc *psoc = NULL; struct wlan_lmac_if_sptrl_tx_ops *psptrl_tx_ops = NULL; - psoc = wlan_pdev_get_psoc(pdev); + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + if (!wmi_ops) { + spectral_err("WMI operations table is null"); + return QDF_STATUS_E_INVAL; + } 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_spectral_wmi_ops(psoc, wmi_ops); +} + +QDF_STATUS +tgt_register_spectral_tgt_ops(struct wlan_objmgr_psoc *psoc, + struct spectral_tgt_ops *tgt_ops) +{ + struct wlan_lmac_if_sptrl_tx_ops *psptrl_tx_ops; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + if (!tgt_ops) { + spectral_err("Target operations table is null"); + return QDF_STATUS_E_INVAL; + } + + psptrl_tx_ops = &psoc->soc_cb.tx_ops.sptrl_tx_ops; + + return psptrl_tx_ops->sptrlto_register_spectral_tgt_ops(psoc, + tgt_ops); } void @@ -393,3 +463,34 @@ QDF_STATUS tgt_set_spectral_dma_debug(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_SUCCESS; } #endif + +QDF_STATUS +tgt_spectral_register_events(struct wlan_objmgr_psoc *psoc) +{ + struct wlan_lmac_if_sptrl_tx_ops *psptrl_tx_ops; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + psptrl_tx_ops = &psoc->soc_cb.tx_ops.sptrl_tx_ops; + + return psptrl_tx_ops->sptrlto_register_events(psoc); +} + +QDF_STATUS +tgt_spectral_unregister_events(struct wlan_objmgr_psoc *psoc) +{ + struct wlan_lmac_if_sptrl_tx_ops *psptrl_tx_ops; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + psptrl_tx_ops = &psoc->soc_cb.tx_ops.sptrl_tx_ops; + + return psptrl_tx_ops->sptrlto_unregister_events(psoc); +} + diff --git a/spectral/dispatcher/src/wlan_spectral_utils_api.c b/spectral/dispatcher/src/wlan_spectral_utils_api.c index 5c96f5ad46..63c976bf6a 100644 --- a/spectral/dispatcher/src/wlan_spectral_utils_api.c +++ b/spectral/dispatcher/src/wlan_spectral_utils_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -193,7 +193,10 @@ wlan_lmac_if_sptrl_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops) struct wlan_lmac_if_sptrl_rx_ops *sptrl_rx_ops = &rx_ops->sptrl_rx_ops; /* Spectral rx ops */ - sptrl_rx_ops->sptrlro_get_target_handle = tgt_get_target_handle; + sptrl_rx_ops->sptrlro_get_pdev_target_handle = + tgt_get_pdev_target_handle; + sptrl_rx_ops->sptrlro_get_psoc_target_handle = + tgt_get_psoc_target_handle; sptrl_rx_ops->sptrlro_vdev_get_chan_freq = spectral_vdev_get_chan_freq; sptrl_rx_ops->sptrlro_vdev_get_chan_freq_seg2 = spectral_vdev_get_chan_freq_seg2; @@ -204,26 +207,122 @@ wlan_lmac_if_sptrl_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops) wlan_spectral_is_feature_disabled; } -void -wlan_register_wmi_spectral_cmd_ops(struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops) +QDF_STATUS +wlan_register_spectral_wmi_ops(struct wlan_objmgr_psoc *psoc, + struct spectral_wmi_ops *wmi_ops) { struct spectral_context *sc; - if (!pdev) { - spectral_err("PDEV is NULL!"); - return; + if (!psoc) { + spectral_err("psoc is NULL!"); + return QDF_STATUS_E_INVAL; } - sc = spectral_get_spectral_ctx_from_pdev(pdev); + sc = spectral_get_spectral_ctx_from_psoc(psoc); if (!sc) { spectral_err("spectral context is NULL!"); - return; + return QDF_STATUS_E_FAILURE; } - return sc->sptrlc_register_wmi_spectral_cmd_ops(pdev, cmd_ops); + return sc->sptrlc_register_spectral_wmi_ops(psoc, wmi_ops); +} + +qdf_export_symbol(wlan_register_spectral_wmi_ops); + +QDF_STATUS +wlan_register_spectral_tgt_ops(struct wlan_objmgr_psoc *psoc, + struct spectral_tgt_ops *tgt_ops) +{ + struct spectral_context *sc; + + if (!psoc) { + spectral_err("psoc is NULL!"); + return QDF_STATUS_E_INVAL; + } + + sc = spectral_get_spectral_ctx_from_psoc(psoc); + if (!sc) { + spectral_err("spectral context is NULL!"); + return QDF_STATUS_E_FAILURE; + } + + return sc->sptrlc_register_spectral_tgt_ops(psoc, tgt_ops); +} + +qdf_export_symbol(wlan_register_spectral_tgt_ops); + +/** + * wlan_spectral_psoc_target_attach() - Spectral psoc target attach + * @psoc: pointer to psoc object + * + * API to initialize Spectral psoc target object + * + * Return: QDF_STATUS_SUCCESS upon successful registration, + * QDF_STATUS_E_FAILURE upon failure + */ +static QDF_STATUS +wlan_spectral_psoc_target_attach(struct wlan_objmgr_psoc *psoc) +{ + struct spectral_context *sc = NULL; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_FAILURE; + } + + sc = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_UMAC_COMP_SPECTRAL); + if (!sc) { + spectral_err("Spectral context is null"); + return QDF_STATUS_E_NOMEM; + } + + if (sc->sptrlc_psoc_spectral_init) { + void *target_handle; + + target_handle = sc->sptrlc_psoc_spectral_init(psoc); + if (!target_handle) { + spectral_err("Spectral psoc lmac object is NULL!"); + return QDF_STATUS_E_FAILURE; + } + sc->psoc_target_handle = target_handle; + } + + return QDF_STATUS_SUCCESS; +} + +/** + * wlan_spectral_psoc_target_detach() - Spectral psoc target detach + * @psoc: pointer to psoc object + * + * API to destroy Spectral psoc target object + * + * Return: QDF_STATUS_SUCCESS upon successful registration, + * QDF_STATUS_E_FAILURE upon failure + */ +static QDF_STATUS +wlan_spectral_psoc_target_detach(struct wlan_objmgr_psoc *psoc) +{ + struct spectral_context *sc = NULL; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_FAILURE; + } + + sc = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_UMAC_COMP_SPECTRAL); + if (!sc) { + spectral_err("Spectral context is null"); + return QDF_STATUS_E_INVAL; + } + + if (sc->sptrlc_psoc_spectral_deinit) + sc->sptrlc_psoc_spectral_deinit(psoc); + sc->psoc_target_handle = NULL; + + return QDF_STATUS_SUCCESS; } -qdf_export_symbol(wlan_register_wmi_spectral_cmd_ops); #ifdef DIRECT_BUF_RX_ENABLE bool spectral_dbr_event_handler(struct wlan_objmgr_pdev *pdev, @@ -283,3 +382,63 @@ QDF_STATUS spectral_unregister_dbr(struct wlan_objmgr_pdev *pdev) } qdf_export_symbol(spectral_unregister_dbr); + +QDF_STATUS wlan_spectral_psoc_open(struct wlan_objmgr_psoc *psoc) +{ + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + if (wlan_spectral_is_feature_disabled(psoc)) { + spectral_info("Spectral is disabled"); + return QDF_STATUS_COMP_DISABLED; + } + + return wlan_spectral_psoc_target_attach(psoc); +} + +QDF_STATUS wlan_spectral_psoc_close(struct wlan_objmgr_psoc *psoc) +{ + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + if (wlan_spectral_is_feature_disabled(psoc)) { + spectral_info("Spectral is disabled"); + return QDF_STATUS_COMP_DISABLED; + } + + return wlan_spectral_psoc_target_detach(psoc); +} + +QDF_STATUS wlan_spectral_psoc_enable(struct wlan_objmgr_psoc *psoc) +{ + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + if (wlan_spectral_is_feature_disabled(psoc)) { + spectral_info("Spectral is disabled"); + return QDF_STATUS_COMP_DISABLED; + } + + return tgt_spectral_register_events(psoc); +} + +QDF_STATUS wlan_spectral_psoc_disable(struct wlan_objmgr_psoc *psoc) +{ + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + if (wlan_spectral_is_feature_disabled(psoc)) { + spectral_info("Spectral is disabled"); + return QDF_STATUS_COMP_DISABLED; + } + + return tgt_spectral_unregister_events(psoc); +} diff --git a/target_if/spectral/target_if_spectral.c b/target_if/spectral/target_if_spectral.c index 3d70ec6380..a0c3435803 100644 --- a/target_if/spectral/target_if_spectral.c +++ b/target_if/spectral/target_if_spectral.c @@ -41,6 +41,7 @@ */ struct target_if_spectral_ops spectral_ops; int spectral_debug_level = DEBUG_SPECTRAL; +struct spectral_tgt_ops ops_tgt; static void target_if_spectral_get_firstvdev_pdev(struct wlan_objmgr_pdev *pdev, void *obj, void *arg) @@ -100,8 +101,10 @@ 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_psoc *psoc; struct wlan_objmgr_pdev *pdev = NULL; struct wlan_objmgr_vdev *vdev = NULL; + struct target_if_psoc_spectral *psoc_spectral; qdf_assert_always(spectral && param); @@ -109,6 +112,18 @@ target_if_send_vdev_spectral_configure_cmd(struct target_if_spectral *spectral, qdf_assert_always(pdev); + psoc = wlan_pdev_get_psoc(pdev); + if (!psoc) { + spectral_err("psoc is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc); + if (!psoc_spectral) { + spectral_err("psoc spectral object is null"); + return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); + } + vdev = target_if_spectral_get_vdev(spectral); if (!vdev) return QDF_STATUS_E_NOENT; @@ -137,10 +152,11 @@ target_if_send_vdev_spectral_configure_cmd(struct target_if_spectral *spectral, sparam.dbm_adj = param->ss_dbm_adj; sparam.chn_mask = param->ss_chn_mask; sparam.mode = smode; - sparam.center_freq = param->ss_frequency.cfreq1; + sparam.center_freq1 = param->ss_frequency.cfreq1; + sparam.center_freq2 = param->ss_frequency.cfreq2; sparam.chan_width = spectral->ch_width[smode]; - return spectral->param_wmi_cmd_ops.wmi_spectral_configure_cmd_send( + return psoc_spectral->wmi_ops.wmi_spectral_configure_cmd_send( GET_WMI_HDL_FROM_PDEV(pdev), &sparam); } @@ -166,8 +182,10 @@ target_if_send_vdev_spectral_enable_cmd(struct target_if_spectral *spectral, uint8_t is_spectral_enabled) { struct vdev_spectral_enable_params param; + struct wlan_objmgr_psoc *psoc; struct wlan_objmgr_pdev *pdev = NULL; struct wlan_objmgr_vdev *vdev = NULL; + struct target_if_psoc_spectral *psoc_spectral; qdf_assert_always(spectral); @@ -175,6 +193,18 @@ target_if_send_vdev_spectral_enable_cmd(struct target_if_spectral *spectral, qdf_assert_always(pdev); + psoc = wlan_pdev_get_psoc(pdev); + if (!psoc) { + spectral_err("psoc is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc); + if (!psoc_spectral) { + spectral_err("psoc spectral object is null"); + return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); + } + vdev = target_if_spectral_get_vdev(spectral); if (!vdev) return QDF_STATUS_E_NOENT; @@ -190,7 +220,7 @@ target_if_send_vdev_spectral_enable_cmd(struct target_if_spectral *spectral, param.enabled = is_spectral_enabled; param.mode = smode; - return spectral->param_wmi_cmd_ops.wmi_spectral_enable_cmd_send( + return psoc_spectral->wmi_ops.wmi_spectral_enable_cmd_send( GET_WMI_HDL_FROM_PDEV(pdev), ¶m); } @@ -2419,6 +2449,74 @@ target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev) return; } +/** + * target_if_psoc_spectral_deinit() - De-initialize target_if Spectral + * functionality for the given psoc + * @psoc: Pointer to psoc object + * + * Function to de-initialize pointer to psoc spectral target_if internal + * private data + * + * Return: None + */ +static void +target_if_psoc_spectral_deinit(struct wlan_objmgr_psoc *psoc) +{ + struct target_if_psoc_spectral *psoc_spectral; + + if (!psoc) { + spectral_err("psoc is null"); + return; + } + + psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc); + if (!psoc_spectral) { + spectral_err("Spectral target_if psoc object is null"); + return; + } + + qdf_mem_free(psoc_spectral); +} + +/** + * target_if_psoc_spectral_init() - Initialize target_if Spectral + * functionality for the given psoc + * @psoc: Pointer to psoc object + * + * Function to initialize pointer to psoc spectral target_if internal + * private data + * + * Return: On success, pointer to Spectral psoc target_if internal + * private data, on failure, NULL + */ +static void * +target_if_psoc_spectral_init(struct wlan_objmgr_psoc *psoc) +{ + struct target_if_psoc_spectral *psoc_spectral = NULL; + + if (!psoc) { + spectral_err("psoc is null"); + goto fail; + } + + psoc_spectral = (struct target_if_psoc_spectral *)qdf_mem_malloc( + sizeof(struct target_if_psoc_spectral)); + if (!psoc_spectral) { + spectral_err("Spectral lmac psoc object allocation failed"); + goto fail; + } + + psoc_spectral->psoc_obj = psoc; + + return psoc_spectral; + +fail: + if (psoc_spectral) + target_if_psoc_spectral_deinit(psoc); + + return psoc_spectral; +} + /* target_if_spectral_find_agile_width() - Given a channel width enum, find the * corresponding translation for Agile channel width. * @spectral: pointer to Spectral object @@ -3364,205 +3462,6 @@ target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_SUCCESS; } -/** - * target_if_spectral_init_fft_bin_markers_res_80p80() - Initialize boundaries - * of primary 80, 5 MHz and secondary 80 FFT bins in restricted 80+80 operation - * - * @spectral: Pointer to Spectral object - * - * Function to initialize boundaries of primary 80, 5 MHz and secondary 80 - * FFT bins in restricted 80+80 operation. - * - * Return: QDF_STATUS - */ -static QDF_STATUS -target_if_spectral_init_fft_bin_markers_res_80p80( - struct target_if_spectral *spectral) -{ - struct spectral_fft_bin_markers_165mhz *marker; - int16_t primary_chan_freq; - uint32_t cfreq2; - struct wlan_objmgr_vdev *vdev; - - if (!spectral) { - spectral_err("Spectral object is null"); - return QDF_STATUS_E_INVAL; - } - - vdev = target_if_spectral_get_vdev(spectral); - if (!vdev) { - spectral_info("First vdev is NULL"); - return QDF_STATUS_E_INVAL; - } - primary_chan_freq = target_if_vdev_get_chan_freq(vdev); - cfreq2 = target_if_vdev_get_chan_freq_seg2(vdev); - wlan_objmgr_vdev_release_ref(vdev, WLAN_SPECTRAL_ID); - if (cfreq2 < 0) { - spectral_err("cfreq2 is invalid"); - return QDF_STATUS_E_INVAL; - } - - marker = spectral->rparams.marker[SPECTRAL_REPORT_MODE_2]; - marker[SPECTRAL_FFT_SIZE_5].start_5mhz = 8; - marker[SPECTRAL_FFT_SIZE_5].num_5mhz = 1; - marker[SPECTRAL_FFT_SIZE_6].start_5mhz = 16; - marker[SPECTRAL_FFT_SIZE_6].num_5mhz = 1; - marker[SPECTRAL_FFT_SIZE_7].start_5mhz = 32; - marker[SPECTRAL_FFT_SIZE_7].num_5mhz = 2; - marker[SPECTRAL_FFT_SIZE_8].start_5mhz = 64; - marker[SPECTRAL_FFT_SIZE_8].num_5mhz = 4; - marker[SPECTRAL_FFT_SIZE_9].start_5mhz = 128; - marker[SPECTRAL_FFT_SIZE_9].num_5mhz = 8; - marker[SPECTRAL_FFT_SIZE_10].start_5mhz = 256; - marker[SPECTRAL_FFT_SIZE_10].num_5mhz = 16; - - marker = spectral->rparams.marker[SPECTRAL_REPORT_MODE_3]; - marker[SPECTRAL_FFT_SIZE_5].start_5mhz = 16; - marker[SPECTRAL_FFT_SIZE_5].num_5mhz = 1; - marker[SPECTRAL_FFT_SIZE_6].start_5mhz = 32; - marker[SPECTRAL_FFT_SIZE_6].num_5mhz = 1; - marker[SPECTRAL_FFT_SIZE_7].start_5mhz = 64; - marker[SPECTRAL_FFT_SIZE_7].num_5mhz = 2; - marker[SPECTRAL_FFT_SIZE_8].start_5mhz = 128; - marker[SPECTRAL_FFT_SIZE_8].num_5mhz = 4; - marker[SPECTRAL_FFT_SIZE_9].start_5mhz = 256; - marker[SPECTRAL_FFT_SIZE_9].num_5mhz = 8; - marker[SPECTRAL_FFT_SIZE_10].start_5mhz = 512; - marker[SPECTRAL_FFT_SIZE_10].num_5mhz = 16; - - if (primary_chan_freq < cfreq2) { - marker = spectral->rparams.marker[SPECTRAL_REPORT_MODE_2]; - - marker[SPECTRAL_FFT_SIZE_5].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_5].num_pri80 = 8; - marker[SPECTRAL_FFT_SIZE_5].start_sec80 = 9; - marker[SPECTRAL_FFT_SIZE_5].num_sec80 = 8; - - marker[SPECTRAL_FFT_SIZE_6].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_6].num_pri80 = 16; - marker[SPECTRAL_FFT_SIZE_6].start_sec80 = 17; - marker[SPECTRAL_FFT_SIZE_6].num_sec80 = 16; - - marker[SPECTRAL_FFT_SIZE_7].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_7].num_pri80 = 32; - marker[SPECTRAL_FFT_SIZE_7].start_sec80 = 34; - marker[SPECTRAL_FFT_SIZE_7].num_sec80 = 32; - - marker[SPECTRAL_FFT_SIZE_8].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_8].num_pri80 = 64; - marker[SPECTRAL_FFT_SIZE_8].start_sec80 = 68; - marker[SPECTRAL_FFT_SIZE_8].num_sec80 = 64; - - marker[SPECTRAL_FFT_SIZE_9].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_9].num_pri80 = 128; - marker[SPECTRAL_FFT_SIZE_9].start_sec80 = 136; - marker[SPECTRAL_FFT_SIZE_9].num_sec80 = 128; - - marker[SPECTRAL_FFT_SIZE_10].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_10].num_pri80 = 256; - marker[SPECTRAL_FFT_SIZE_10].start_sec80 = 272; - marker[SPECTRAL_FFT_SIZE_10].num_sec80 = 256; - - marker = spectral->rparams.marker[SPECTRAL_REPORT_MODE_3]; - - marker[SPECTRAL_FFT_SIZE_5].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_5].num_pri80 = 16; - marker[SPECTRAL_FFT_SIZE_5].start_sec80 = 17; - marker[SPECTRAL_FFT_SIZE_5].num_sec80 = 15; - - marker[SPECTRAL_FFT_SIZE_6].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_6].num_pri80 = 32; - marker[SPECTRAL_FFT_SIZE_6].start_sec80 = 33; - marker[SPECTRAL_FFT_SIZE_6].num_sec80 = 31; - - marker[SPECTRAL_FFT_SIZE_7].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_7].num_pri80 = 64; - marker[SPECTRAL_FFT_SIZE_7].start_sec80 = 66; - marker[SPECTRAL_FFT_SIZE_7].num_sec80 = 62; - - marker[SPECTRAL_FFT_SIZE_8].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_8].num_pri80 = 128; - marker[SPECTRAL_FFT_SIZE_8].start_sec80 = 132; - marker[SPECTRAL_FFT_SIZE_8].num_sec80 = 124; - - marker[SPECTRAL_FFT_SIZE_9].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_9].num_pri80 = 256; - marker[SPECTRAL_FFT_SIZE_9].start_sec80 = 264; - marker[SPECTRAL_FFT_SIZE_9].num_sec80 = 248; - - marker[SPECTRAL_FFT_SIZE_10].start_pri80 = 0; - marker[SPECTRAL_FFT_SIZE_10].num_pri80 = 512; - marker[SPECTRAL_FFT_SIZE_10].start_sec80 = 528; - marker[SPECTRAL_FFT_SIZE_10].num_sec80 = 496; - } else { - marker = spectral->rparams.marker[SPECTRAL_REPORT_MODE_2]; - - marker[SPECTRAL_FFT_SIZE_5].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_5].num_sec80 = 8; - marker[SPECTRAL_FFT_SIZE_5].start_pri80 = 9; - marker[SPECTRAL_FFT_SIZE_5].num_pri80 = 8; - - marker[SPECTRAL_FFT_SIZE_6].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_6].num_sec80 = 16; - marker[SPECTRAL_FFT_SIZE_6].start_pri80 = 17; - marker[SPECTRAL_FFT_SIZE_6].num_pri80 = 16; - - marker[SPECTRAL_FFT_SIZE_7].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_7].num_sec80 = 32; - marker[SPECTRAL_FFT_SIZE_7].start_pri80 = 34; - marker[SPECTRAL_FFT_SIZE_7].num_pri80 = 32; - - marker[SPECTRAL_FFT_SIZE_8].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_8].num_sec80 = 64; - marker[SPECTRAL_FFT_SIZE_8].start_pri80 = 68; - marker[SPECTRAL_FFT_SIZE_8].num_pri80 = 64; - - marker[SPECTRAL_FFT_SIZE_9].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_9].num_sec80 = 128; - marker[SPECTRAL_FFT_SIZE_9].start_pri80 = 136; - marker[SPECTRAL_FFT_SIZE_9].num_pri80 = 128; - - marker[SPECTRAL_FFT_SIZE_10].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_10].num_sec80 = 256; - marker[SPECTRAL_FFT_SIZE_10].start_pri80 = 272; - marker[SPECTRAL_FFT_SIZE_10].num_pri80 = 256; - - marker = spectral->rparams.marker[SPECTRAL_REPORT_MODE_3]; - - marker[SPECTRAL_FFT_SIZE_5].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_5].num_sec80 = 16; - marker[SPECTRAL_FFT_SIZE_5].start_pri80 = 17; - marker[SPECTRAL_FFT_SIZE_5].num_pri80 = 15; - - marker[SPECTRAL_FFT_SIZE_6].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_6].num_sec80 = 32; - marker[SPECTRAL_FFT_SIZE_6].start_pri80 = 33; - marker[SPECTRAL_FFT_SIZE_6].num_pri80 = 31; - - marker[SPECTRAL_FFT_SIZE_7].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_7].num_sec80 = 64; - marker[SPECTRAL_FFT_SIZE_7].start_pri80 = 66; - marker[SPECTRAL_FFT_SIZE_7].num_pri80 = 62; - - marker[SPECTRAL_FFT_SIZE_8].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_8].num_sec80 = 128; - marker[SPECTRAL_FFT_SIZE_8].start_pri80 = 132; - marker[SPECTRAL_FFT_SIZE_8].num_pri80 = 124; - - marker[SPECTRAL_FFT_SIZE_9].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_9].num_sec80 = 256; - marker[SPECTRAL_FFT_SIZE_9].start_pri80 = 264; - marker[SPECTRAL_FFT_SIZE_9].num_pri80 = 248; - - marker[SPECTRAL_FFT_SIZE_10].start_sec80 = 0; - marker[SPECTRAL_FFT_SIZE_10].num_sec80 = 512; - marker[SPECTRAL_FFT_SIZE_10].start_pri80 = 528; - marker[SPECTRAL_FFT_SIZE_10].num_pri80 = 496; - } - - return QDF_STATUS_SUCCESS; -} - /** * target_if_spectral_scan_enable_params() - Enable use of desired Spectral * parameters @@ -3634,17 +3533,6 @@ target_if_spectral_scan_enable_params(struct target_if_spectral *spectral, return 1; } - if (spectral->ch_width[smode] == CH_WIDTH_80P80MHZ && - wlan_psoc_nif_fw_ext_cap_get( - psoc, WLAN_SOC_RESTRICTED_80P80_SUPPORT)) { - status = target_if_spectral_init_fft_bin_markers_res_80p80( - spectral); - if (QDF_IS_STATUS_ERROR(status)) { - spectral_err("Unable to initialize FFT bin boundaries"); - return 1; - } - } - if (spectral->capability.advncd_spectral_cap) { spectral->lb_edge_extrabins = 0; spectral->rb_edge_extrabins = 0; @@ -3886,6 +3774,7 @@ target_if_spectral_scan_enable_params(struct target_if_spectral *spectral, p_sops->start_spectral_scan(spectral, smode, err); spectral->timestamp_war.timestamp_war_offset[smode] = 0; spectral->timestamp_war.last_fft_timestamp[smode] = 0; + spectral->rparams.marker[smode].is_valid = false; } /* get current spectral configuration */ @@ -4794,26 +4683,54 @@ target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, } /** - * 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 + * target_if_register_spectral_wmi_ops() - Register Spectral WMI operations + * @psoc: Pointer to psoc object + * @wmi_ops: Pointer to the structure having Spectral WMI operations * - * API for register wmi_spectral_cmd_ops in spectral internal data structure + * API for registering Spectral WMI operations in + * spectral internal data structure * - * Return: void + * Return: QDF_STATUS */ -void -target_if_register_wmi_spectral_cmd_ops(struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops) +static QDF_STATUS +target_if_register_spectral_wmi_ops(struct wlan_objmgr_psoc *psoc, + struct spectral_wmi_ops *wmi_ops) { - struct target_if_spectral *spectral = - get_target_if_spectral_handle_from_pdev(pdev); + struct target_if_psoc_spectral *psoc_spectral; - if (!spectral) { + psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc); + if (!psoc_spectral) { spectral_err("Spectral LMAC object is null"); - return; + return QDF_STATUS_E_INVAL; } - spectral->param_wmi_cmd_ops = *cmd_ops; + + psoc_spectral->wmi_ops = *wmi_ops; + + return QDF_STATUS_SUCCESS; +} + +/** + * target_if_register_spectral_tgt_ops() - Register Spectral target operations + * @psoc: Pointer to psoc object + * @tgt_ops: Pointer to the structure having Spectral target operations + * + * API for registering Spectral target operations in + * spectral internal data structure + * + * Return: QDF_STATUS + */ +static QDF_STATUS +target_if_register_spectral_tgt_ops(struct wlan_objmgr_psoc *psoc, + struct spectral_tgt_ops *tgt_ops) +{ + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + ops_tgt = *tgt_ops; + + return QDF_STATUS_SUCCESS; } /** @@ -4931,6 +4848,521 @@ target_if_sptrl_debug_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) } #endif +#if defined(WLAN_CONV_SPECTRAL_ENABLE) && defined(SPECTRAL_MODULIZED_ENABLE) +/** + * target_if_spectral_wmi_unified_register_event_handler() - Wrapper function to + * register WMI event handler + * @psoc: Pointer to psoc object + * @event_id: Event id + * @handler_func: Handler function + * @rx_ctx: Context of WMI event processing + * + * Wrapper function to register WMI event handler + * + * Return: 0 for success else failure + */ +static int +target_if_spectral_wmi_unified_register_event_handler( + struct wlan_objmgr_psoc *psoc, + wmi_conv_event_id event_id, + wmi_unified_event_handler handler_func, + uint8_t rx_ctx) +{ + wmi_unified_t wmi_handle; + struct target_if_psoc_spectral *psoc_spectral; + + if (!psoc) { + spectral_err("psoc is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc); + if (!wmi_handle) { + spectral_err("WMI handle is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc); + if (!psoc_spectral) { + spectral_err("spectral object is null"); + return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); + } + + return psoc_spectral->wmi_ops.wmi_unified_register_event_handler( + wmi_handle, event_id, handler_func, rx_ctx); +} + +/** + * target_if_spectral_wmi_unified_unregister_event_handler() - Wrapper function + * to unregister WMI event handler + * @psoc: Pointer to psoc object + * @event_id: Event id + * + * Wrapper function to unregister WMI event handler + * + * Return: 0 for success else failure + */ +static int +target_if_spectral_wmi_unified_unregister_event_handler( + struct wlan_objmgr_psoc *psoc, + wmi_conv_event_id event_id) +{ + wmi_unified_t wmi_handle; + struct target_if_psoc_spectral *psoc_spectral; + + if (!psoc) { + spectral_err("psoc is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc); + if (!wmi_handle) { + spectral_err("WMI handle is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc); + if (!psoc_spectral) { + spectral_err("spectral object is null"); + return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); + } + + return psoc_spectral->wmi_ops.wmi_unified_unregister_event_handler( + wmi_handle, event_id); +} + +/** + * target_if_spectral_wmi_extract_pdev_sscan_fw_cmd_fixed_param() - Wrapper + * function to extract fixed parameters from start scan response event + * @psoc: Pointer to psoc object + * @evt_buf: Event buffer + * @param: Start scan response parameters + * + * Wrapper function to extract fixed parameters from start scan response event + * + * Return: QDF_STATUS + */ +static QDF_STATUS +target_if_spectral_wmi_extract_pdev_sscan_fw_cmd_fixed_param( + struct wlan_objmgr_psoc *psoc, + uint8_t *evt_buf, + struct spectral_startscan_resp_params *param) +{ + wmi_unified_t wmi_handle; + struct target_if_psoc_spectral *psoc_spectral; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + if (!evt_buf) { + spectral_err("WMI event buffer is null"); + return QDF_STATUS_E_INVAL; + } + + if (!param) { + spectral_err("Spectral startscan response parameters is null"); + return QDF_STATUS_E_INVAL; + } + + wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc); + if (!wmi_handle) { + spectral_err("WMI handle is null"); + return QDF_STATUS_E_INVAL; + } + + psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc); + if (!psoc_spectral) { + spectral_err("spectral object is null"); + return QDF_STATUS_E_FAILURE; + } + + return psoc_spectral->wmi_ops.wmi_extract_pdev_sscan_fw_cmd_fixed_param( + wmi_handle, evt_buf, param); +} + +/** + * target_if_spectral_wmi_extract_pdev_sscan_fft_bin_index() - Wrapper + * function to extract start and end indices of primary 80 MHz, 5 MHz and + * secondary 80 MHz FFT bins + * @psoc: Pointer to psoc object + * @evt_buf: Event buffer + * @param: FFT bin start and end indices + * + * Wrapper function to extract start and end indices of primary 80 MHz, 5 MHz + * and secondary 80 MHz FFT bins + * + * Return: QDF_STATUS + */ +static QDF_STATUS +target_if_spectral_wmi_extract_pdev_sscan_fft_bin_index( + struct wlan_objmgr_psoc *psoc, + uint8_t *evt_buf, + struct spectral_fft_bin_markers_160_165mhz *param) +{ + wmi_unified_t wmi_handle; + struct target_if_psoc_spectral *psoc_spectral; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + if (!evt_buf) { + spectral_err("WMI event buffer is null"); + return QDF_STATUS_E_INVAL; + } + + if (!param) { + spectral_err("Spectral FFT bin markers is null"); + return QDF_STATUS_E_INVAL; + } + + wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc); + if (!wmi_handle) { + spectral_err("WMI handle is null"); + return QDF_STATUS_E_INVAL; + } + + psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc); + if (!psoc_spectral) { + spectral_err("spectral object is null"); + return QDF_STATUS_E_FAILURE; + } + + return psoc_spectral->wmi_ops.wmi_extract_pdev_sscan_fft_bin_index( + wmi_handle, evt_buf, param); +} + +/** + * target_if_spectral_get_psoc_from_scn_handle() - Wrapper function to get psoc + * object from scn handle + * @scn: scn handle + * + * Wrapper function to get psoc object from scn handle + * + * Return: Pointer to psoc object + */ +static struct wlan_objmgr_psoc * +target_if_spectral_get_psoc_from_scn_handle(ol_scn_t scn) +{ + if (!scn) { + spectral_err("scn is null"); + return NULL; + } + + return ops_tgt.tgt_get_psoc_from_scn_hdl(scn); +} +#else +/** + * target_if_spectral_wmi_unified_register_event_handler() - Wrapper function to + * register WMI event handler + * @psoc: Pointer to psoc object + * @event_id: Event id + * @handler_func: Handler function + * @rx_ctx: Context of WMI event processing + * + * Wrapper function to register WMI event handler + * + * Return: 0 for success else failure + */ +static int +target_if_spectral_wmi_unified_register_event_handler( + struct wlan_objmgr_psoc *psoc, + wmi_conv_event_id event_id, + wmi_unified_event_handler handler_func, + uint8_t rx_ctx) +{ + wmi_unified_t wmi_handle; + + if (!psoc) { + spectral_err("psoc is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc); + if (!wmi_handle) { + spectral_err("WMI handle is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + return wmi_unified_register_event_handler(wmi_handle, event_id, + handler_func, rx_ctx); +} + +/** + * target_if_spectral_wmi_unified_unregister_event_handler() - Wrapper function + * to unregister WMI event handler + * @psoc: Pointer to psoc object + * @event_id: Event id + * + * Wrapper function to unregister WMI event handler + * + * Return: 0 for success else failure + */ +static int +target_if_spectral_wmi_unified_unregister_event_handler( + struct wlan_objmgr_psoc *psoc, + wmi_conv_event_id event_id) +{ + wmi_unified_t wmi_handle; + + if (!psoc) { + spectral_err("psoc is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc); + if (!wmi_handle) { + spectral_err("WMI handle is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + return wmi_unified_unregister_event_handler(wmi_handle, event_id); +} + +/** + * target_if_spectral_wmi_extract_pdev_sscan_fw_cmd_fixed_param() - Wrapper + * function to extract fixed parameters from start scan response event + * @psoc: Pointer to psoc object + * @evt_buf: Event buffer + * @param: Start scan response parameters + * + * Wrapper function to extract fixed parameters from start scan response event + * + * Return: QDF_STATUS + */ +static QDF_STATUS +target_if_spectral_wmi_extract_pdev_sscan_fw_cmd_fixed_param( + struct wlan_objmgr_psoc *psoc, + uint8_t *evt_buf, + struct spectral_startscan_resp_params *param) +{ + wmi_unified_t wmi_handle; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + if (!evt_buf) { + spectral_err("WMI event buffer is null"); + return QDF_STATUS_E_INVAL; + } + + if (!param) { + spectral_err("Spectral startscan response parameters is null"); + return QDF_STATUS_E_INVAL; + } + + wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc); + if (!wmi_handle) { + spectral_err("WMI handle is null"); + return QDF_STATUS_E_INVAL; + } + + return wmi_extract_pdev_sscan_fw_cmd_fixed_param(wmi_handle, evt_buf, + param); +} + +/** + * target_if_spectral_wmi_extract_pdev_sscan_fft_bin_index() - Wrapper + * function to extract start and end indices of primary 80 MHz, 5 MHz and + * secondary 80 MHz FFT bins + * @psoc: Pointer to psoc object + * @evt_buf: Event buffer + * @param: FFT bin start and end indices + * + * Wrapper function to extract start and end indices of primary 80 MHz, 5 MHz + * and secondary 80 MHz FFT bins + * + * Return: QDF_STATUS + */ +static QDF_STATUS +target_if_spectral_wmi_extract_pdev_sscan_fft_bin_index( + struct wlan_objmgr_psoc *psoc, + uint8_t *evt_buf, + struct spectral_fft_bin_markers_160_165mhz *param) +{ + wmi_unified_t wmi_handle; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + if (!evt_buf) { + spectral_err("WMI event buffer is null"); + return QDF_STATUS_E_INVAL; + } + + if (!param) { + spectral_err("Spectral FFT bin markers is null"); + return QDF_STATUS_E_INVAL; + } + + wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc); + if (!wmi_handle) { + spectral_err("WMI handle is null"); + return QDF_STATUS_E_INVAL; + } + + return wmi_extract_pdev_sscan_fft_bin_index(wmi_handle, evt_buf, param); +} + +/** + * target_if_spectral_get_psoc_from_scn_handle() - Wrapper function to get psoc + * object from scn handle + * @scn: scn handle + * + * Wrapper function to get psoc object from scn handle + * + * Return: Pointer to psoc object + */ +static struct wlan_objmgr_psoc * +target_if_spectral_get_psoc_from_scn_handle(ol_scn_t scn) +{ + if (!scn) { + spectral_err("scn is null"); + return NULL; + } + + return target_if_get_psoc_from_scn_hdl(scn); +} +#endif + +/** + * target_if_spectral_fw_param_event_handler() - WMI event handler to + * process start scan response event + * @scn: Pointer to scn object + * @data_buf: Pointer to event buffer + * @data_len: Length of event buffer + * + * Return: 0 for success, else failure + */ +static int +target_if_spectral_fw_param_event_handler(ol_scn_t scn, uint8_t *data_buf, + uint32_t data_len) +{ + QDF_STATUS status; + struct wlan_objmgr_psoc *psoc; + struct wlan_objmgr_pdev *pdev; + struct wmi_unified *wmi_handle; + struct spectral_startscan_resp_params event_params = {0}; + struct target_if_psoc_spectral *psoc_spectral; + struct target_if_spectral *spectral; + + if (!scn) { + spectral_err("scn handle is null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + if (!data_buf) { + spectral_err("WMI event buffer null"); + return qdf_status_to_os_return(QDF_STATUS_E_INVAL); + } + + psoc = target_if_spectral_get_psoc_from_scn_handle(scn); + if (!psoc) { + spectral_err("psoc is null"); + return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); + } + + psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc); + if (!psoc_spectral) { + spectral_err("spectral object is null"); + return QDF_STATUS_E_FAILURE; + } + + wmi_handle = GET_WMI_HDL_FROM_PSOC(psoc); + if (!wmi_handle) { + spectral_err("WMI handle is null"); + return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); + } + + status = target_if_spectral_wmi_extract_pdev_sscan_fw_cmd_fixed_param( + psoc, data_buf, &event_params); + if (QDF_IS_STATUS_ERROR(status)) { + spectral_err("unable to extract sscan fw fixed params"); + return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); + } + + pdev = wlan_objmgr_get_pdev_by_id(psoc, event_params.pdev_id, + WLAN_SPECTRAL_ID); + if (!pdev) { + spectral_err("pdev is null"); + return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); + } + + spectral = get_target_if_spectral_handle_from_pdev(pdev); + if (!spectral) { + spectral_err("spectral object is null"); + wlan_objmgr_pdev_release_ref(pdev, WLAN_SPECTRAL_ID); + return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); + } + + if (event_params.num_fft_bin_index == 1) { + status = + target_if_spectral_wmi_extract_pdev_sscan_fft_bin_index( + psoc, data_buf, + &spectral->rparams.marker[event_params.smode]); + if (QDF_IS_STATUS_ERROR(status)) { + spectral_err("unable to extract sscan fw fixed params"); + wlan_objmgr_pdev_release_ref(pdev, WLAN_SPECTRAL_ID); + return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); + } + } else { + spectral->rparams.marker[event_params.smode].is_valid = false; + } + + wlan_objmgr_pdev_release_ref(pdev, WLAN_SPECTRAL_ID); + + return qdf_status_to_os_return(QDF_STATUS_SUCCESS); +} + +static QDF_STATUS +target_if_spectral_register_events(struct wlan_objmgr_psoc *psoc) +{ + int ret; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + ret = target_if_spectral_wmi_unified_register_event_handler( + psoc, + wmi_pdev_sscan_fw_param_eventid, + target_if_spectral_fw_param_event_handler, + WMI_RX_UMAC_CTX); + + if (ret) + spectral_debug("event handler not supported, ret=%d", ret); + + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS +target_if_spectral_unregister_events(struct wlan_objmgr_psoc *psoc) +{ + int ret; + + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_INVAL; + } + + ret = target_if_spectral_wmi_unified_unregister_event_handler( + psoc, wmi_pdev_sscan_fw_param_eventid); + + if (ret) + spectral_debug("Unregister WMI event handler failed, ret = %d", + ret); + + return QDF_STATUS_SUCCESS; +} + void target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) { @@ -4938,6 +5370,10 @@ target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) 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_psoc_spectral_init = + target_if_psoc_spectral_init; + tx_ops->sptrl_tx_ops.sptrlto_psoc_spectral_deinit = + target_if_psoc_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 = @@ -4958,8 +5394,10 @@ target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) target_if_get_spectral_capinfo; tx_ops->sptrl_tx_ops.sptrlto_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; + tx_ops->sptrl_tx_ops.sptrlto_register_spectral_wmi_ops = + target_if_register_spectral_wmi_ops; + tx_ops->sptrl_tx_ops.sptrlto_register_spectral_tgt_ops = + target_if_register_spectral_tgt_ops; tx_ops->sptrl_tx_ops.sptrlto_register_netlink_cb = target_if_register_netlink_cb; tx_ops->sptrl_tx_ops.sptrlto_use_nl_bcast = @@ -4970,6 +5408,11 @@ target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) target_if_process_spectral_report; tx_ops->sptrl_tx_ops.sptrlto_direct_dma_support = target_if_spectral_direct_dma_support; + tx_ops->sptrl_tx_ops.sptrlto_register_events = + target_if_spectral_register_events; + tx_ops->sptrl_tx_ops.sptrlto_unregister_events = + target_if_spectral_unregister_events; + target_if_sptrl_debug_register_tx_ops(tx_ops); } qdf_export_symbol(target_if_sptrl_register_tx_ops); diff --git a/target_if/spectral/target_if_spectral.h b/target_if/spectral/target_if_spectral.h index ddfa4d63ca..50cee54ba6 100644 --- a/target_if/spectral/target_if_spectral.h +++ b/target_if/spectral/target_if_spectral.h @@ -40,6 +40,7 @@ #endif #include +#include #define FREQ_OFFSET_10MHZ (10) #define FREQ_OFFSET_40MHZ (40) @@ -501,31 +502,6 @@ struct spectral_fft_bin_len_adj_swar { enum spectral_fftbin_size_war fftbin_size_war; }; -/** - * struct spectral_fft_bin_markers_165mhz - Stores the start index and length of - * FFT bins in 165 MHz/Restricted 80p80 mode - * @start_pri80: Starting index of FFT bins corresponding to primary 80 MHz - * in 165 MHz/Restricted 80p80 mode - * @num_pri80: Number of FFT bins corresponding to primary 80 MHz - * in 165 MHz/Restricted 80p80 mode - * @start_5mhz: Starting index of FFT bins corresponding to extra 5 MHz - * in 165 MHz/Restricted 80p80 mode - * @num_5mhz: Number of FFT bins corresponding to extra 5 MHz - * in 165 MHz/Restricted 80p80 mode - * @start_sec80: Starting index of FFT bins corresponding to secondary 80 MHz - * in 165 MHz/Restricted 80p80 mode - * @num_sec80: Number of FFT bins corresponding to secondary 80 MHz - * in 165 MHz/Restricted 80p80 mode - */ -struct spectral_fft_bin_markers_165mhz { - size_t start_pri80; - size_t num_pri80; - size_t start_5mhz; - size_t num_5mhz; - size_t start_sec80; - size_t num_sec80; -}; - /** * struct spectral_report_params - Parameters related to format of Spectral * report. @@ -551,8 +527,8 @@ struct spectral_report_params { enum phy_ch_width max_agile_ch_width; enum spectral_scan_mode detid_mode_table[SPECTRAL_DETECTOR_ID_MAX]; uint8_t num_spectral_detectors; - struct spectral_fft_bin_markers_165mhz - marker[SPECTRAL_REPORT_MODE_MAX][SPECTRAL_FFT_SIZE_MAX]; + struct spectral_fft_bin_markers_160_165mhz + marker[SPECTRAL_SCAN_MODE_MAX]; }; /** @@ -846,21 +822,49 @@ 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. + * struct spectral_wmi_ops - structure used holding the operations + * related to Spectral WMI * @wmi_spectral_configure_cmd_send: Configure Spectral parameters * @wmi_spectral_enable_cmd_send: Enable/Disable Spectral * @wmi_spectral_crash_inject: Inject FW crash + * @wmi_extract_pdev_sscan_fw_cmd_fixed_param: Extract Fixed params from + * start scan response event + * @wmi_extract_pdev_sscan_fft_bin_index: Extract TLV which describes FFT + * bin indices from start scan response event + * @wmi_unified_register_event_handler: Register WMI event handler + * @wmi_unified_unregister_event_handler: Unregister WMI event handler */ -struct wmi_spectral_cmd_ops { +struct spectral_wmi_ops { QDF_STATUS (*wmi_spectral_configure_cmd_send)( wmi_unified_t wmi_hdl, struct vdev_spectral_configure_params *param); QDF_STATUS (*wmi_spectral_enable_cmd_send)( wmi_unified_t wmi_hdl, struct vdev_spectral_enable_params *param); - QDF_STATUS(*wmi_spectral_crash_inject)( + QDF_STATUS (*wmi_spectral_crash_inject)( wmi_unified_t wmi_handle, struct crash_inject *param); + QDF_STATUS (*wmi_extract_pdev_sscan_fw_cmd_fixed_param)( + wmi_unified_t wmi_handle, uint8_t *evt_buf, + struct spectral_startscan_resp_params *param); + QDF_STATUS (*wmi_extract_pdev_sscan_fft_bin_index)( + wmi_unified_t wmi_handle, uint8_t *evt_buf, + struct spectral_fft_bin_markers_160_165mhz *param); + int (*wmi_unified_register_event_handler)( + wmi_unified_t wmi_handle, + wmi_conv_event_id event_id, + wmi_unified_event_handler handler_func, + uint8_t rx_ctx); + int (*wmi_unified_unregister_event_handler)(wmi_unified_t wmi_handle, + wmi_conv_event_id event_id); +}; + +/** + * struct spectral_tgt_ops - structure used holding the operations + * related to target operations + * @tgt_get_psoc_from_scn_hdl: Function to get psoc from scn + */ +struct spectral_tgt_ops { + struct wlan_objmgr_psoc *(*tgt_get_psoc_from_scn_hdl)(void *scn_handle); }; /** @@ -1067,7 +1071,6 @@ struct target_if_spectral { 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; struct spectral_nl_cb nl_cb; bool use_nl_bcast; int (*send_phy_data)(struct wlan_objmgr_pdev *pdev, @@ -1084,6 +1087,16 @@ struct target_if_spectral { struct spectral_param_min_max param_min_max; }; +/** + * struct target_if_psoc_spectral - Target if psoc Spectral object + * @psoc_obj: psoc object + * @wmi_ops: Spectral WMI operations + */ +struct target_if_psoc_spectral { + struct wlan_objmgr_psoc *psoc_obj; + struct spectral_wmi_ops wmi_ops; +}; + /** * struct target_if_samp_msg_params - Spectral Analysis Messaging Protocol * data format @@ -1428,11 +1441,37 @@ struct target_if_spectral *get_target_if_spectral_handle_from_pdev( } spectral = (struct target_if_spectral *) - psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_get_target_handle( + psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_get_pdev_target_handle( pdev); return spectral; } +/** + * get_target_if_spectral_handle_from_psoc() - Get handle to psoc target_if + * internal Spectral data + * @psoc: Pointer to psoc + * + * Return: Handle to target_if psoc internal Spectral data on success, NULL on + * failure + */ +static inline +struct target_if_psoc_spectral *get_target_if_spectral_handle_from_psoc( + struct wlan_objmgr_psoc *psoc) +{ + struct target_if_psoc_spectral *psoc_spectral; + + if (!psoc) { + spectral_err("psoc is null"); + return NULL; + } + + psoc_spectral = (struct target_if_psoc_spectral *) + psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_get_psoc_target_handle( + psoc); + + return psoc_spectral; +} + /** * target_if_vdev_get_chan_freq() - Get the operating channel frequency of a * given vdev @@ -2148,10 +2187,6 @@ QDF_STATUS target_if_get_spectral_capinfo(struct wlan_objmgr_pdev *pdev, QDF_STATUS target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, struct spectral_diag_stats *stats); -void target_if_register_wmi_spectral_cmd_ops( - struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops); - QDF_STATUS target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral, enum spectral_scan_mode smode, diff --git a/target_if/spectral/target_if_spectral_netlink.c b/target_if/spectral/target_if_spectral_netlink.c index 6f4b14ed08..b833620e86 100644 --- a/target_if/spectral/target_if_spectral_netlink.c +++ b/target_if/spectral/target_if_spectral_netlink.c @@ -78,6 +78,8 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral, spec_samp_msg->agile_freq2 = params->agile_freq2; } spec_samp_msg->freq_loading = params->freq_loading; + spec_samp_msg->vhtop_ch_freq_seg1 = params->vhtop_ch_freq_seg1; + spec_samp_msg->vhtop_ch_freq_seg2 = params->vhtop_ch_freq_seg2; samp_data->spectral_mode = params->smode; samp_data->spectral_data_len = params->datalen; samp_data->spectral_rssi = params->rssi; @@ -183,8 +185,6 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral, } samp_data = &spec_samp_msg->samp_data; - spec_samp_msg->vhtop_ch_freq_seg1 = params->vhtop_ch_freq_seg1; - spec_samp_msg->vhtop_ch_freq_seg2 = params->vhtop_ch_freq_seg2; samp_data->spectral_rssi_sec80 = params->rssi_sec80; samp_data->noise_floor_sec80 = diff --git a/target_if/spectral/target_if_spectral_phyerr.c b/target_if/spectral/target_if_spectral_phyerr.c index effffba421..13840a78d3 100644 --- a/target_if/spectral/target_if_spectral_phyerr.c +++ b/target_if/spectral/target_if_spectral_phyerr.c @@ -161,15 +161,37 @@ target_if_spectral_dump_fft(uint8_t *pfft, int fftlen) QDF_STATUS target_if_spectral_fw_hang(struct target_if_spectral *spectral) { struct crash_inject param; + struct wlan_objmgr_pdev *pdev; + struct wlan_objmgr_psoc *psoc; + struct target_if_psoc_spectral *psoc_spectral; if (!spectral) { spectral_err("Spectral LMAC object is null"); return QDF_STATUS_E_INVAL; } + + pdev = spectral->pdev_obj; + if (!pdev) { + spectral_err("pdev is null"); + return QDF_STATUS_E_FAILURE; + } + + psoc = wlan_pdev_get_psoc(pdev); + if (!psoc) { + spectral_err("psoc is null"); + return QDF_STATUS_E_FAILURE; + } + + psoc_spectral = get_target_if_spectral_handle_from_psoc(psoc); + if (!psoc_spectral) { + spectral_err("spectral psoc object is null"); + return QDF_STATUS_E_FAILURE; + } + qdf_mem_set(¶m, sizeof(param), 0); param.type = 1; //RECOVERY_SIM_ASSERT - return spectral->param_wmi_cmd_ops.wmi_spectral_crash_inject( + return psoc_spectral->wmi_ops.wmi_spectral_crash_inject( GET_WMI_HDL_FROM_PDEV(spectral->pdev_obj), ¶m); } @@ -1984,6 +2006,7 @@ target_if_consume_spectral_report_gen3( [spectral_mode]) && !spectral->rparams. fragmentation_160[spectral_mode]) { struct wlan_objmgr_psoc *psoc; + struct spectral_fft_bin_markers_160_165mhz *marker; qdf_assert_always(spectral->pdev_obj); psoc = wlan_pdev_get_psoc(spectral->pdev_obj); @@ -2000,34 +2023,21 @@ target_if_consume_spectral_report_gen3( params.max_mag_sec80 = p_sfft->fft_peak_mag; params.datalen = fft_hdr_length * 2; params.datalen_sec80 = fft_hdr_length * 2; + + marker = &spectral->rparams.marker[spectral_mode]; + qdf_assert_always(marker->is_valid); + params.bin_pwr_data = temp + + marker->start_pri80 * fft_bin_size; + params.pwr_count = marker->num_pri80; + params.bin_pwr_data_sec80 = temp + + marker->start_sec80 * fft_bin_size; + params.pwr_count_sec80 = marker->num_sec80; if (spectral->ch_width[spectral_mode] == CH_WIDTH_80P80MHZ && wlan_psoc_nif_fw_ext_cap_get( psoc, WLAN_SOC_RESTRICTED_80P80_SUPPORT)) { - struct spectral_fft_bin_markers_165mhz *marker; - enum spectral_report_mode rpt_mode; - enum spectral_fft_size fft_size; - - rpt_mode = spectral->params[spectral_mode]. - ss_rpt_mode; - fft_size = spectral->params[spectral_mode]. - ss_fft_size; - marker = &spectral->rparams.marker - [rpt_mode][fft_size]; - params.bin_pwr_data = temp + - marker->start_pri80 * fft_bin_size; - params.pwr_count = marker->num_pri80; params.bin_pwr_data_5mhz = temp + marker->start_5mhz * fft_bin_size; params.pwr_count_5mhz = marker->num_5mhz; - params.bin_pwr_data_sec80 = temp + - marker->start_sec80 * fft_bin_size; - params.pwr_count_sec80 = marker->num_sec80; - } else { - params.bin_pwr_data = temp; - params.pwr_count = fft_bin_count / 2; - params.pwr_count_sec80 = fft_bin_count / 2; - params.bin_pwr_data_sec80 = temp + - (fft_bin_count / 2) * fft_bin_size; } } else { params.bin_pwr_data = temp; diff --git a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h index 30750a3480..bafeeba9d1 100644 --- a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h +++ b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h @@ -574,11 +574,14 @@ struct wlan_lmac_if_cfr_tx_ops { #endif /* WLAN_CFR_ENABLE */ #ifdef WLAN_CONV_SPECTRAL_ENABLE -struct wmi_spectral_cmd_ops; +struct spectral_wmi_ops; +struct spectral_tgt_ops; /** * struct wlan_lmac_if_sptrl_tx_ops - Spectral south bound Tx operations - * @sptrlto_spectral_init: Initialize LMAC/target_if Spectral - * @sptrlto_spectral_deinit: De-initialize LMAC/target_if Spectral + * @sptrlto_pdev_spectral_init: Initialize target_if pdev Spectral object + * @sptrlto_pdev_spectral_deinit: De-initialize target_if pdev Spectral object + * @sptrlto_psoc_spectral_init: Initialize target_if psoc Spectral object + * @sptrlto_psoc_spectral_deinit: De-initialize target_if psoc Spectral object * @sptrlto_set_spectral_config: Set Spectral configuration * @sptrlto_get_spectral_config: Get Spectral configuration * @sptrlto_start_spectral_scan: Start Spectral Scan @@ -595,6 +598,8 @@ struct wmi_spectral_cmd_ops; * @sptrlto_clear_chaninfo: Clear channel information * @sptrlto_get_spectral_capinfo: Get Spectral capability information * @sptrlto_get_spectral_diagstats: Get Spectral diagnostic statistics + * @sptrlto_register_spectral_wmi_ops: Register Spectral WMI operations + * @sptrlto_register_spectral_tgt_ops: Register Spectral target operations * @sptrlto_register_netlink_cb: Register Spectral Netlink callbacks * @sptrlto_use_nl_bcast: Get whether to use Netlink broadcast/unicast * @sptrlto_deregister_netlink_cb: De-register Spectral Netlink callbacks @@ -605,10 +610,14 @@ struct wmi_spectral_cmd_ops; * on the previous state * @sptrlto_check_and_do_dbr_buff_debug: Start/Stop Spectral buffer debug based * on the previous state + * @sptrlto_register_events: Registration of WMI events for Spectral + * @sptrlto_unregister_events: Unregistration of WMI events for Spectral **/ struct wlan_lmac_if_sptrl_tx_ops { void *(*sptrlto_pdev_spectral_init)(struct wlan_objmgr_pdev *pdev); void (*sptrlto_pdev_spectral_deinit)(struct wlan_objmgr_pdev *pdev); + void *(*sptrlto_psoc_spectral_init)(struct wlan_objmgr_psoc *psoc); + void (*sptrlto_psoc_spectral_deinit)(struct wlan_objmgr_psoc *psoc); QDF_STATUS (*sptrlto_set_spectral_config) (struct wlan_objmgr_pdev *pdev, const struct spectral_cp_param *param, @@ -639,9 +648,12 @@ struct wlan_lmac_if_sptrl_tx_ops { QDF_STATUS (*sptrlto_get_spectral_diagstats) (struct wlan_objmgr_pdev *pdev, struct spectral_diag_stats *stats); - void (*sptrlto_register_wmi_spectral_cmd_ops)( - struct wlan_objmgr_pdev *pdev, - struct wmi_spectral_cmd_ops *cmd_ops); + QDF_STATUS (*sptrlto_register_spectral_wmi_ops)( + struct wlan_objmgr_psoc *psoc, + struct spectral_wmi_ops *wmi_ops); + QDF_STATUS (*sptrlto_register_spectral_tgt_ops)( + struct wlan_objmgr_psoc *psoc, + struct spectral_tgt_ops *tgt_ops); void (*sptrlto_register_netlink_cb)( struct wlan_objmgr_pdev *pdev, struct spectral_nl_cb *nl_cb); @@ -659,7 +671,8 @@ struct wlan_lmac_if_sptrl_tx_ops { struct wlan_objmgr_pdev *pdev); QDF_STATUS (*sptrlto_check_and_do_dbr_buff_debug)( struct wlan_objmgr_pdev *pdev); - + QDF_STATUS (*sptrlto_register_events)(struct wlan_objmgr_psoc *psoc); + QDF_STATUS (*sptrlto_unregister_events)(struct wlan_objmgr_psoc *psoc); }; #endif /* WLAN_CONV_SPECTRAL_ENABLE */ @@ -1371,12 +1384,16 @@ struct wlan_lmac_if_cfr_rx_ops { /** * struct wlan_lmac_if_sptrl_rx_ops - Spectral south bound Rx operations * - * @sptrlro_get_target_handle: Get Spectral handle for target/LMAC private data + * @sptrlro_get_pdev_target_handle: Get Spectral handle for pdev target + * private data + * @sptrlro_get_psoc_target_handle: Get Spectral handle for psoc target + * private data * @sptrlro_vdev_get_chan_freq_seg2: Get secondary 80 center frequency * @sptrlro_spectral_is_feature_disabled: Check if spectral feature is disabled */ struct wlan_lmac_if_sptrl_rx_ops { - void * (*sptrlro_get_target_handle)(struct wlan_objmgr_pdev *pdev); + void * (*sptrlro_get_pdev_target_handle)(struct wlan_objmgr_pdev *pdev); + void * (*sptrlro_get_psoc_target_handle)(struct wlan_objmgr_psoc *psoc); int16_t (*sptrlro_vdev_get_chan_freq)(struct wlan_objmgr_vdev *vdev); int16_t (*sptrlro_vdev_get_chan_freq_seg2) (struct wlan_objmgr_vdev *vdev); diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index c234a2790a..9806ae1305 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -2026,6 +2026,36 @@ QDF_STATUS wmi_unified_vdev_spectral_enable_cmd_send( wmi_unified_t wmi_handle, struct vdev_spectral_enable_params *param); +#ifdef WLAN_CONV_SPECTRAL_ENABLE +/** + * wmi_extract_pdev_sscan_fw_cmd_fixed_param() - Extract fixed params + * from start scan response event + * @wmi_handle: handle to WMI. + * @evt_buf: Event buffer + * @param: pointer to hold fixed params from fw params event + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_extract_pdev_sscan_fw_cmd_fixed_param( + wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct spectral_startscan_resp_params *param); + +/** + * wmi_extract_pdev_sscan_fft_bin_index() - Extract FFT bin indexes + * from start scan response event + * @wmi_handle: handle to WMI. + * @evt_buf: Event buffer + * @param: pointer to hold FFT bin indexes from fw params event + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_extract_pdev_sscan_fft_bin_index( + wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct spectral_fft_bin_markers_160_165mhz *param); +#endif /* WLAN_CONV_SPECTRAL_ENABLE */ + #if defined(WLAN_SUPPORT_FILS) || defined(CONFIG_BAND_6GHZ) /** * wmi_unified_vdev_fils_enable_cmd_send() - WMI send fils enable command diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h index f7be144d00..0beb50eec7 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -28,6 +28,9 @@ #ifdef FEATURE_WLAN_TDLS #include #endif +#ifdef WLAN_CONV_SPECTRAL_ENABLE +#include +#endif /* WLAN_CONV_SPECTRAL_ENABLE */ #define MAC_MAX_KEY_LENGTH 32 #define MAC_PN_LENGTH 8 @@ -2956,7 +2959,8 @@ struct simulation_test_params { * @dbm_adj: DBM adjust * @chn_mask: chain mask * @mode: Mode - * @center_freq: Center frequency + * @center_freq1: Center frequency 1 + * @center_freq2: Center frequency 2 * @chan_freq: Primary channel frequency * @chan_width: Channel width */ @@ -2981,7 +2985,8 @@ struct vdev_spectral_configure_params { uint16_t dbm_adj; uint16_t chn_mask; uint16_t mode; - uint16_t center_freq; + uint16_t center_freq1; + uint16_t center_freq2; uint16_t chan_freq; uint16_t chan_width; }; @@ -3004,6 +3009,49 @@ struct vdev_spectral_enable_params { uint8_t mode; }; +#ifdef WLAN_CONV_SPECTRAL_ENABLE +/** + * struct spectral_fft_bin_markers_160_165mhz - Stores the start index + * and length of FFT bins in 165 MHz/Restricted 80p80 or 160 MHz + * mode in targets with a single Spectral detector + * @is_valid: Indicates whether this structure holds valid data + * @start_pri80: Starting index of FFT bins corresponding to primary 80 MHz + * in 165 MHz/Restricted 80p80 or 160 MHz mode + * @num_pri80: Number of FFT bins corresponding to primary 80 MHz + * in 165 MHz/Restricted 80p80 or 160 MHz mode + * @start_5mhz: Starting index of FFT bins corresponding to extra 5 MHz + * in 165 MHz/Restricted 80p80 mode + * @num_5mhz: Number of FFT bins corresponding to extra 5 MHz + * in 165 MHz/Restricted 80p80 mode + * @start_sec80: Starting index of FFT bins corresponding to secondary 80 MHz + * in 165 MHz/Restricted 80p80 or 160 MHz mode + * @num_sec80: Number of FFT bins corresponding to secondary 80 MHz + * in 165 MHz/Restricted 80p80 or 160 MHz mode + */ +struct spectral_fft_bin_markers_160_165mhz { + bool is_valid; + uint16_t start_pri80; + uint16_t num_pri80; + uint16_t start_5mhz; + uint16_t num_5mhz; + uint16_t start_sec80; + uint16_t num_sec80; +}; + +/** + * struct spectral_startscan_resp_params - Params from the event send by + * FW as a response to the scan start command + * @pdev_id: Pdev id + * @smode: Spectral scan mode + * @num_fft_bin_index: Number of TLVs with FFT bin start and end indices + */ +struct spectral_startscan_resp_params { + uint32_t pdev_id; + enum spectral_scan_mode smode; + uint8_t num_fft_bin_index; +}; +#endif + /** * struct pdev_set_regdomain_params - PDEV set reg domain params * @currentRDinuse: Current Reg domain @@ -4648,6 +4696,7 @@ typedef enum { #endif wmi_roam_scan_chan_list_id, wmi_muedca_params_config_eventid, + wmi_pdev_sscan_fw_param_eventid, wmi_events_max, } wmi_conv_event_id; diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index c562b3b250..07860f100d 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -77,6 +77,10 @@ #include "wlan_pkt_capture_public_structs.h" #endif +#ifdef WLAN_CONV_SPECTRAL_ENABLE +#include "wlan_spectral_public_structs.h" +#endif /* WLAN_CONV_SPECTRAL_ENABLE */ + #define WMI_UNIFIED_MAX_EVENT 0x100 #ifdef WMI_EXT_DBG @@ -1207,6 +1211,18 @@ QDF_STATUS (*send_simulation_test_cmd)(wmi_unified_t wmi_handle, QDF_STATUS (*send_smart_ant_enable_tx_feedback_cmd)(wmi_unified_t wmi_handle, struct smart_ant_enable_tx_feedback_params *param); +#ifdef WLAN_CONV_SPECTRAL_ENABLE +QDF_STATUS (*extract_pdev_sscan_fw_cmd_fixed_param)( + wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct spectral_startscan_resp_params *params); + +QDF_STATUS (*extract_pdev_sscan_fft_bin_index)( + wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct spectral_fft_bin_markers_160_165mhz *params); +#endif /* WLAN_CONV_SPECTRAL_ENABLE */ + QDF_STATUS (*send_vdev_spectral_configure_cmd)(wmi_unified_t wmi_handle, struct vdev_spectral_configure_params *param); diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index 771a1d9f76..181bc259f5 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -2522,6 +2522,34 @@ QDF_STATUS wmi_extract_dbr_ring_cap_service_ready_ext2( return QDF_STATUS_E_FAILURE; } +#ifdef WLAN_CONV_SPECTRAL_ENABLE +QDF_STATUS wmi_extract_pdev_sscan_fw_cmd_fixed_param( + wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct spectral_startscan_resp_params *param) +{ + if (wmi_handle->ops->extract_pdev_sscan_fw_cmd_fixed_param) + return wmi_handle->ops->extract_pdev_sscan_fw_cmd_fixed_param( + wmi_handle, + evt_buf, param); + + return QDF_STATUS_E_FAILURE; +} + +QDF_STATUS wmi_extract_pdev_sscan_fft_bin_index( + wmi_unified_t wmi_handle, + uint8_t *evt_buf, + struct spectral_fft_bin_markers_160_165mhz *param) +{ + if (wmi_handle->ops->extract_pdev_sscan_fft_bin_index) + return wmi_handle->ops->extract_pdev_sscan_fft_bin_index( + wmi_handle, + evt_buf, param); + + return QDF_STATUS_E_FAILURE; +} +#endif /* WLAN_CONV_SPECTRAL_ENABLE */ + QDF_STATUS wmi_extract_spectral_scaling_params_service_ready_ext( wmi_unified_t wmi_handle, uint8_t *evt_buf, uint8_t idx, diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 7705cf7c86..7352e5ba4f 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -6512,10 +6512,11 @@ static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle, cmd->spectral_scan_dBm_adj = param->dbm_adj; cmd->spectral_scan_chn_mask = param->chn_mask; cmd->spectral_scan_mode = param->mode; - cmd->spectral_scan_center_freq = param->center_freq; + cmd->spectral_scan_center_freq1 = param->center_freq1; + cmd->spectral_scan_center_freq2 = param->center_freq2; + cmd->spectral_scan_chan_width = param->chan_width; /* Not used, fill with zeros */ cmd->spectral_scan_chan_freq = 0; - cmd->spectral_scan_chan_width = 0; wmi_mtrace(WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID, cmd->vdev_id, 0); ret = wmi_unified_cmd_send(wmi_handle, buf, len, @@ -6549,7 +6550,8 @@ static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle, WMI_LOGI("spectral_scan_dBm_adj = %u", param->dbm_adj); WMI_LOGI("spectral_scan_chn_mask = %u", param->chn_mask); WMI_LOGI("spectral_scan_mode = %u", param->mode); - WMI_LOGI("spectral_scan_center_freq = %u", param->center_freq); + WMI_LOGI("spectral_scan_center_freq1 = %u", param->center_freq1); + WMI_LOGI("spectral_scan_center_freq2 = %u", param->center_freq2); WMI_LOGI("spectral_scan_chan_freq = %u", param->chan_freq); WMI_LOGI("spectral_scan_chan_width = %u", param->chan_width); WMI_LOGI("%s: Status: %d", __func__, ret); @@ -6622,6 +6624,87 @@ static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle, return ret; } +#ifdef WLAN_CONV_SPECTRAL_ENABLE +static QDF_STATUS +extract_pdev_sscan_fw_cmd_fixed_param_tlv( + wmi_unified_t wmi_handle, + uint8_t *event, struct spectral_startscan_resp_params *param) +{ + WMI_PDEV_SSCAN_FW_PARAM_EVENTID_param_tlvs *param_buf; + wmi_pdev_sscan_fw_cmd_fixed_param *ev; + + if (!wmi_handle) { + WMI_LOGE("WMI handle is null"); + return QDF_STATUS_E_INVAL; + } + + if (!event) { + WMI_LOGE("WMI event is null"); + return QDF_STATUS_E_INVAL; + } + + if (!param) { + WMI_LOGE("Spectral startscan response params is null"); + return QDF_STATUS_E_INVAL; + } + + param_buf = (WMI_PDEV_SSCAN_FW_PARAM_EVENTID_param_tlvs *)event; + if (!param_buf) + return QDF_STATUS_E_INVAL; + + ev = param_buf->fixed_param; + if (!ev) + return QDF_STATUS_E_INVAL; + + param->pdev_id = wmi_handle->ops->convert_target_pdev_id_to_host( + wmi_handle, + ev->pdev_id); + param->smode = ev->spectral_scan_mode; + param->num_fft_bin_index = param_buf->num_fft_bin_index; + WMI_LOGD("%s:pdev id %u scan mode %u num_fft_bin_index %u", __func__, + param->pdev_id, param->smode, param->num_fft_bin_index); + + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS +extract_pdev_sscan_fft_bin_index_tlv( + wmi_unified_t wmi_handle, uint8_t *event, + struct spectral_fft_bin_markers_160_165mhz *param) +{ + WMI_PDEV_SSCAN_FW_PARAM_EVENTID_param_tlvs *param_buf; + wmi_pdev_sscan_fft_bin_index *ev; + + param_buf = (WMI_PDEV_SSCAN_FW_PARAM_EVENTID_param_tlvs *)event; + if (!param_buf) + return QDF_STATUS_E_INVAL; + + ev = param_buf->fft_bin_index; + if (!ev) + return QDF_STATUS_E_INVAL; + + param->start_pri80 = WMI_SSCAN_PRI80_START_BIN_GET(ev->pri80_bins); + param->num_pri80 = WMI_SSCAN_PRI80_END_BIN_GET(ev->pri80_bins) - + param->start_pri80 + 1; + param->start_sec80 = WMI_SSCAN_SEC80_START_BIN_GET(ev->sec80_bins); + param->num_sec80 = WMI_SSCAN_SEC80_END_BIN_GET(ev->sec80_bins) - + param->start_sec80 + 1; + param->start_5mhz = WMI_SSCAN_MID_5MHZ_START_BIN_GET(ev->mid_5mhz_bins); + param->num_5mhz = WMI_SSCAN_MID_5MHZ_END_BIN_GET(ev->mid_5mhz_bins) - + param->start_5mhz + 1; + param->is_valid = true; + + WMI_LOGD("%s:start_pri80 %u, num_pri80 %u", __func__, + param->start_pri80, param->num_pri80); + WMI_LOGD("%s:start_sec80 %u, num_sec80 %u", __func__, + param->start_sec80, param->num_sec80); + WMI_LOGD("%s:start_5mhz %u, num_5mhz %u", __func__, + param->start_5mhz, param->num_5mhz); + + return QDF_STATUS_SUCCESS; +} +#endif /* WLAN_CONV_SPECTRAL_ENABLE */ + /** * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params * @param wmi_handle : handle to WMI. @@ -13846,6 +13929,12 @@ struct wmi_ops tlv_ops = { send_vdev_spectral_configure_cmd_tlv, .send_vdev_spectral_enable_cmd = send_vdev_spectral_enable_cmd_tlv, +#ifdef WLAN_CONV_SPECTRAL_ENABLE + .extract_pdev_sscan_fw_cmd_fixed_param = + extract_pdev_sscan_fw_cmd_fixed_param_tlv, + .extract_pdev_sscan_fft_bin_index = + extract_pdev_sscan_fft_bin_index_tlv, +#endif /* WLAN_CONV_SPECTRAL_ENABLE */ .send_thermal_mitigation_param_cmd = send_thermal_mitigation_param_cmd_tlv, .send_process_update_edca_param_cmd = @@ -14415,6 +14504,8 @@ event_ids[wmi_roam_scan_chan_list_id] = WMI_ROAM_SCAN_CHANNEL_LIST_EVENTID; event_ids[wmi_muedca_params_config_eventid] = WMI_MUEDCA_PARAMS_CONFIG_EVENTID; + event_ids[wmi_pdev_sscan_fw_param_eventid] = + WMI_PDEV_SSCAN_FW_PARAM_EVENTID; } /**