From 2de9f012bd73bc9e2c74558514ce50c473ad72af Mon Sep 17 00:00:00 2001 From: Harprit Chhabada Date: Tue, 30 Oct 2018 15:10:52 -0700 Subject: [PATCH] qcacmn: Clean scan active and passive dwell time apis Create ucfg apis in scan components for calling from hdd. Move the scan apis to new file, wlan_scan_api.c Change-Id: Iec08eddbba3066a4d781c988624d47749a75610a CRs-Fixed: 2342892 --- umac/scan/core/src/wlan_scan_main.h | 12 ++- umac/scan/dispatcher/inc/wlan_scan_api.h | 69 ++++++++++++++++++ umac/scan/dispatcher/inc/wlan_scan_ucfg_api.h | 66 +++++++++++------ umac/scan/dispatcher/src/wlan_scan_api.c | 68 +++++++++++++++++ umac/scan/dispatcher/src/wlan_scan_ucfg_api.c | 73 +++++-------------- 5 files changed, 206 insertions(+), 82 deletions(-) create mode 100644 umac/scan/dispatcher/inc/wlan_scan_api.h create mode 100644 umac/scan/dispatcher/src/wlan_scan_api.c diff --git a/umac/scan/core/src/wlan_scan_main.h b/umac/scan/core/src/wlan_scan_main.h index ee8a292716..7b8b7cde7d 100644 --- a/umac/scan/core/src/wlan_scan_main.h +++ b/umac/scan/core/src/wlan_scan_main.h @@ -510,15 +510,23 @@ struct wlan_scan_obj { * * Return: scan object */ +#define wlan_psoc_get_scan_obj(psoc) \ + wlan_psoc_get_scan_obj_fl(psoc, \ + __func__, __LINE__) + static inline struct wlan_scan_obj * -wlan_psoc_get_scan_obj(struct wlan_objmgr_psoc *psoc) +wlan_psoc_get_scan_obj_fl(struct wlan_objmgr_psoc *psoc, + const char *func, uint32_t line) { struct wlan_scan_obj *scan_obj; scan_obj = (struct wlan_scan_obj *) wlan_objmgr_psoc_get_comp_private_obj(psoc, WLAN_UMAC_COMP_SCAN); - + if (!scan_obj) { + scm_err("%s:%u, Failed to get scan object", func, line); + return NULL; + } return scan_obj; } diff --git a/umac/scan/dispatcher/inc/wlan_scan_api.h b/umac/scan/dispatcher/inc/wlan_scan_api.h new file mode 100644 index 0000000000..cb5505b9af --- /dev/null +++ b/umac/scan/dispatcher/inc/wlan_scan_api.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017-2018 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 + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * DOC: contains scan api + */ + +#ifndef _WLAN_SCAN_API_H_ +#define _WLAN_SCAN_API_H_ + +#include +#include +#include +#include "../../core/src/wlan_scan_main.h" + +/** + * wlan_scan_cfg_set_active_dwelltime() - API to set scan active dwelltime + * @psoc: pointer to psoc object + * @dwell_time: scan active dwell time + * + * Return: none + */ +void wlan_scan_cfg_set_active_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t dwell_time); +/** + * wlan_scan_cfg_get_active_dwelltime() - API to get active dwelltime + * @psoc: pointer to psoc object + * @dwell_time: scan active dwelltime + * + * Return: scan active dwell time + */ +void wlan_scan_cfg_get_active_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t *dwell_time); + +/** + * wlan_scan_cfg_set_passive_dwelltime() - API to set scan passive dwelltime + * @psoc: pointer to psoc object + * @dwell_time: scan passive dwell time + * + * Return: none + */ +void wlan_scan_cfg_set_passive_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t dwell_time); +/** + * wlan_scan_cfg_get_passive_dwelltime() - API to get passive dwelltime + * @psoc: pointer to psoc object + * @dwell_time: scan passive dwelltime + * + * Return: scan passive dwell time + */ +void wlan_scan_cfg_get_passive_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t *dwell_time); + +#endif diff --git a/umac/scan/dispatcher/inc/wlan_scan_ucfg_api.h b/umac/scan/dispatcher/inc/wlan_scan_ucfg_api.h index 2a9b55018c..f4fad6d83e 100644 --- a/umac/scan/dispatcher/inc/wlan_scan_ucfg_api.h +++ b/umac/scan/dispatcher/inc/wlan_scan_ucfg_api.h @@ -28,6 +28,7 @@ #include #include #include +#include "wlan_scan_api.h" /** * ucfg_scan_register_requester() - assigns requester ID to caller and @@ -629,41 +630,58 @@ void ucfg_scan_set_vdev_del_in_progress(struct wlan_objmgr_vdev *vdev); void ucfg_scan_clear_vdev_del_in_progress(struct wlan_objmgr_vdev *vdev); /** - * wlan_scan_cfg_set_active_dwelltime() - API to set scan active dwelltime + * ucfg_scan_cfg_set_active_dwelltime() - API to set scan active dwelltime * @psoc: pointer to psoc object * @dwell_time: scan active dwell time * * Return: none */ -void wlan_scan_cfg_set_active_dwelltime(struct wlan_objmgr_psoc *psoc, - uint32_t dwell_time); -/** - * wlan_scan_cfg_get_active_dwelltime() - API to get active dwelltime - * @psoc: pointer to psoc object - * @dwell_time: scan active dwelltime - * - * Return: scan active dwell time - */ -void wlan_scan_cfg_get_active_dwelltime(struct wlan_objmgr_psoc *psoc, - uint32_t *dwell_time); +static inline +void ucfg_scan_cfg_set_active_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t dwell_time) +{ + return wlan_scan_cfg_set_active_dwelltime(psoc, dwell_time); +} /** - * wlan_scan_cfg_set_passive_dwelltime() - API to set scan active dwelltime - * @psoc: pointer to psoc object - * @dwell_time: scan active dwell time - * - * Return: none - */ -void wlan_scan_cfg_set_passive_dwelltime(struct wlan_objmgr_psoc *psoc, - uint32_t dwell_time); -/** - * wlan_scan_cfg_get_passive_dwelltime() - API to get active dwelltime + * ucfg_scan_cfg_get_active_dwelltime() - API to get active dwelltime * @psoc: pointer to psoc object * @dwell_time: scan active dwelltime * * Return: scan active dwell time */ -void wlan_scan_cfg_get_passive_dwelltime(struct wlan_objmgr_psoc *psoc, - uint32_t *dwell_time); +static inline +void ucfg_scan_cfg_get_active_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t *dwell_time) +{ + return wlan_scan_cfg_get_active_dwelltime(psoc, dwell_time); +} + +/** + * ucfg_scan_cfg_set_passive_dwelltime() - API to set scan passive dwelltime + * @psoc: pointer to psoc object + * @dwell_time: scan passive dwell time + * + * Return: none + */ +static inline +void ucfg_scan_cfg_set_passive_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t dwell_time) +{ + return wlan_scan_cfg_set_passive_dwelltime(psoc, dwell_time); +} +/** + * ucfg_scan_cfg_get_passive_dwelltime() - API to get passive dwelltime + * @psoc: pointer to psoc object + * @dwell_time: scan passive dwelltime + * + * Return: scan passive dwell time + */ +static inline +void ucfg_scan_cfg_get_passive_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t *dwell_time) +{ + return wlan_scan_cfg_get_passive_dwelltime(psoc, dwell_time); +} #endif diff --git a/umac/scan/dispatcher/src/wlan_scan_api.c b/umac/scan/dispatcher/src/wlan_scan_api.c new file mode 100644 index 0000000000..1aa8356723 --- /dev/null +++ b/umac/scan/dispatcher/src/wlan_scan_api.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017-2018 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 + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * DOC: This file contains all SCAN component's APIs + */ + +#include "cfg_ucfg_api.h" +#include "wlan_scan_api.h" + +void wlan_scan_cfg_get_passive_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t *dwell_time) +{ + struct wlan_scan_obj *scan_obj; + + scan_obj = wlan_psoc_get_scan_obj(psoc); + if (!scan_obj) + return; + *dwell_time = scan_obj->scan_def.passive_dwell; +} + +void wlan_scan_cfg_set_passive_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t dwell_time) +{ + struct wlan_scan_obj *scan_obj; + + scan_obj = wlan_psoc_get_scan_obj(psoc); + if (!scan_obj) + return; + scan_obj->scan_def.passive_dwell = dwell_time; +} + +void wlan_scan_cfg_get_active_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t *dwell_time) +{ + struct wlan_scan_obj *scan_obj; + + scan_obj = wlan_psoc_get_scan_obj(psoc); + if (!scan_obj) + return; + *dwell_time = scan_obj->scan_def.active_dwell; +} + +void wlan_scan_cfg_set_active_dwelltime(struct wlan_objmgr_psoc *psoc, + uint32_t dwell_time) +{ + struct wlan_scan_obj *scan_obj; + + scan_obj = wlan_psoc_get_scan_obj(psoc); + if (!scan_obj) + return; + scan_obj->scan_def.active_dwell = dwell_time; +} diff --git a/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c b/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c index 35431de67a..6d6bd72b39 100644 --- a/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c +++ b/umac/scan/dispatcher/src/wlan_scan_ucfg_api.c @@ -987,6 +987,8 @@ ucfg_scan_set_wide_band_scan(struct wlan_objmgr_pdev *pdev, bool enable) } pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); scan_obj = wlan_pdev_get_scan_obj(pdev); + if (!scan_obj) + return QDF_STATUS_E_FAILURE; scm_debug("set wide_band_scan to %d", enable); scan_obj->pdev_info[pdev_id].wide_band_scan = enable; @@ -1005,6 +1007,8 @@ bool ucfg_scan_get_wide_band_scan(struct wlan_objmgr_pdev *pdev) } pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); scan_obj = wlan_pdev_get_scan_obj(pdev); + if (!scan_obj) + return QDF_STATUS_E_FAILURE; return scan_obj->pdev_info[pdev_id].wide_band_scan; } @@ -1023,6 +1027,8 @@ ucfg_scan_config_hidden_ssid_for_bssid(struct wlan_objmgr_pdev *pdev, } pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev); scan_obj = wlan_pdev_get_scan_obj(pdev); + if (!scan_obj) + return QDF_STATUS_E_FAILURE; scm_debug("Configure bsssid:%pM ssid:%.*s", bssid, ssid->length, ssid->ssid); @@ -1166,6 +1172,9 @@ ucfg_scan_register_requester(struct wlan_objmgr_psoc *psoc, return 0; } scan = wlan_psoc_get_scan_obj(psoc); + if (!scan) + return 0; + requesters = scan->requesters; qdf_spin_lock_bh(&scan->lock); for (i = 0; i < WLAN_MAX_REQUESTORS; ++i) { @@ -1216,6 +1225,8 @@ ucfg_scan_unregister_requester(struct wlan_objmgr_psoc *psoc, return; } scan = wlan_psoc_get_scan_obj(psoc); + if (!scan) + return; requesters = scan->requesters; scm_debug("reqid: %d", requester); @@ -1240,6 +1251,9 @@ ucfg_get_scan_requester_name(struct wlan_objmgr_psoc *psoc, return "null"; } scan = wlan_psoc_get_scan_obj(psoc); + if (!scan) + return "null"; + requesters = scan->requesters; if ((idx < WLAN_MAX_REQUESTORS) && @@ -1341,62 +1355,6 @@ ucfg_scan_register_event_handler(struct wlan_objmgr_pdev *pdev, return QDF_STATUS_SUCCESS; } -void wlan_scan_cfg_get_passive_dwelltime(struct wlan_objmgr_psoc *psoc, - uint32_t *dwell_time) -{ - struct wlan_scan_obj *scan_obj; - - scan_obj = wlan_psoc_get_scan_obj(psoc); - if (!scan_obj) { - scm_err("Failed to get scan object"); - return; - } - - *dwell_time = scan_obj->scan_def.passive_dwell; -} - -void wlan_scan_cfg_set_passive_dwelltime(struct wlan_objmgr_psoc *psoc, - uint32_t dwell_time) -{ - struct wlan_scan_obj *scan_obj; - - scan_obj = wlan_psoc_get_scan_obj(psoc); - if (!scan_obj) { - scm_err("Failed to get scan object"); - return; - } - - scan_obj->scan_def.passive_dwell = dwell_time; -} - -void wlan_scan_cfg_get_active_dwelltime(struct wlan_objmgr_psoc *psoc, - uint32_t *dwell_time) -{ - struct wlan_scan_obj *scan_obj; - - scan_obj = wlan_psoc_get_scan_obj(psoc); - if (!scan_obj) { - scm_err("Failed to get scan object"); - return; - } - - *dwell_time = scan_obj->scan_def.active_dwell; -} - -void wlan_scan_cfg_set_active_dwelltime(struct wlan_objmgr_psoc *psoc, - uint32_t dwell_time) -{ - struct wlan_scan_obj *scan_obj; - - scan_obj = wlan_psoc_get_scan_obj(psoc); - if (!scan_obj) { - scm_err("Failed to get scan object"); - return; - } - - scan_obj->scan_def.active_dwell = dwell_time; -} - static QDF_STATUS wlan_scan_global_init(struct wlan_objmgr_psoc *psoc, struct wlan_scan_obj *scan_obj) @@ -1509,6 +1467,9 @@ ucfg_scan_unregister_event_handler(struct wlan_objmgr_pdev *pdev, return; } scan = wlan_pdev_get_scan_obj(pdev); + if (!scan) + return; + pdev_ev_handler = wlan_pdev_get_pdev_scan_ev_handlers(pdev); cb_handler = &(pdev_ev_handler->cb_handlers[0]);