From d76b54a1c5433eb971de2f4b91c982011f06e05b Mon Sep 17 00:00:00 2001 From: Arun Kumar Khandavalli Date: Tue, 27 Aug 2019 16:39:18 +0530 Subject: [PATCH] qcacmn: Move psoc object to common component Presently PSOC object is initialized differently between WIN/MCL. With this implementation the psoc creation and destroy will be moved to common code. Change-Id: I7aa8f47f3fe1d88c6c37ab3184a81fbc7dedb789 CRs-Fixed: 2547533 --- umac/mlme/include/wlan_mlme_cmn.h | 31 +++++ umac/mlme/include/wlan_psoc_mlme.h | 35 +++++ .../dispatcher/inc/wlan_psoc_mlme_main.h | 43 ++++++ .../dispatcher/src/wlan_cmn_mlme_main.c | 55 ++++++-- .../dispatcher/src/wlan_psoc_mlme_main.c | 126 ++++++++++++++++++ .../dispatcher/inc/wlan_psoc_mlme_api.h | 59 ++++++++ .../dispatcher/src/wlan_psoc_mlme_api.c | 62 +++++++++ 7 files changed, 398 insertions(+), 13 deletions(-) create mode 100644 umac/mlme/include/wlan_psoc_mlme.h create mode 100644 umac/mlme/mlme_objmgr/dispatcher/inc/wlan_psoc_mlme_main.h create mode 100644 umac/mlme/mlme_objmgr/dispatcher/src/wlan_psoc_mlme_main.c create mode 100644 umac/mlme/psoc_mgr/dispatcher/inc/wlan_psoc_mlme_api.h create mode 100644 umac/mlme/psoc_mgr/dispatcher/src/wlan_psoc_mlme_api.c diff --git a/umac/mlme/include/wlan_mlme_cmn.h b/umac/mlme/include/wlan_mlme_cmn.h index eee5f24486..753ed9d7b9 100644 --- a/umac/mlme/include/wlan_mlme_cmn.h +++ b/umac/mlme/include/wlan_mlme_cmn.h @@ -20,11 +20,16 @@ #ifndef _WLAN_MLME_CMN_H_ #define _WLAN_MLME_CMN_H_ +#include #include #include /** * struct vdev_mlme_ext_ops - VDEV MLME legacy callbacks structure + * @mlme_psoc_ext_hdl_create: callback to invoke creation of legacy + * psoc object + * @mlme_psoc_ext_hdl_destroy: callback to invoke destroy of legacy + * psoc object * @mlme_pdev_ext_hdl_create: callback to invoke creation of legacy * pdev object * @mlme_pdev_ext_hdl_destroy: callback to invoke destroy of legacy @@ -44,6 +49,10 @@ * required by serialization */ struct mlme_ext_ops { + QDF_STATUS (*mlme_psoc_ext_hdl_create)( + struct psoc_mlme_obj *psoc_mlme); + QDF_STATUS (*mlme_psoc_ext_hdl_destroy)( + struct psoc_mlme_obj *pdev_mlme); QDF_STATUS (*mlme_pdev_ext_hdl_create)( struct pdev_mlme_obj *pdev_mlme); QDF_STATUS (*mlme_pdev_ext_hdl_destroy)( @@ -65,6 +74,28 @@ struct mlme_ext_ops { uint8_t cmd_type); }; +/** + * mlme_psoc_ops_ext_hdl_create() - Alloc PSOC mlme ext handle + * @psoc_mlme: PSOC MLME comp object + * + * API to allocate PSOC MLME ext handle + * + * Return: SUCCESS on successful allocation + * Else FAILURE + */ +QDF_STATUS mlme_psoc_ops_ext_hdl_create(struct psoc_mlme_obj *psoc_mlme); + +/** + * mlme_psoc_ops_ext_hdl_destroy() - Destroy PSOC mlme ext handle + * @psoc_mlme: PSOC MLME comp object + * + * API to free psoc MLME ext handle + * + * Return: SUCCESS on successful free + * Else FAILURE + */ +QDF_STATUS mlme_psoc_ops_ext_hdl_destroy(struct psoc_mlme_obj *psoc_mlme); + /** * mlme_pdev_ops_ext_hdl_create - Alloc PDEV mlme ext handle * @pdev_mlme_obj: PDEV MLME comp object diff --git a/umac/mlme/include/wlan_psoc_mlme.h b/umac/mlme/include/wlan_psoc_mlme.h new file mode 100644 index 0000000000..3ab23a27ce --- /dev/null +++ b/umac/mlme/include/wlan_psoc_mlme.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 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: Define PSOC MLME structure + */ +#ifndef _WLAN_PSOC_MLME_H_ +#define _WLAN_PSOC_MLME_H_ + +#include + +/** + * struct psoc_mlme_obj - PSOC MLME component object + * @psoc: PSOC object + * @ext_psoc_ptr: extended psoc mlme pointer + */ +struct psoc_mlme_obj { + struct wlan_objmgr_psoc *psoc; + mlme_psoc_ext_t *ext_psoc_ptr; +}; + +#endif diff --git a/umac/mlme/mlme_objmgr/dispatcher/inc/wlan_psoc_mlme_main.h b/umac/mlme/mlme_objmgr/dispatcher/inc/wlan_psoc_mlme_main.h new file mode 100644 index 0000000000..db6a19066f --- /dev/null +++ b/umac/mlme/mlme_objmgr/dispatcher/inc/wlan_psoc_mlme_main.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019 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: Define PSOC MLME structure + */ +#ifndef _WLAN_PSOC_MLME_MAIN_H_ +#define _WLAN_PSOC_MLME_MAIN_H_ + +/** + * wlan_psoc_mlme_init() - Initializes PSOC MLME component + * + * Registers callbacks with object manager for create/destroy + * + * Return: SUCCESS on successful initialization + * FAILURE, if initialization fails + */ +QDF_STATUS wlan_psoc_mlme_init(void); + +/** + * wlan_psoc_mlme_deinit() - Uninitializes PSOC MLME component + * + * Unregisters callbacks with object manager for create/destroy + * + * Return: SUCCESS on successful de-initialization + * FAILURE, if de-initialization fails + */ +QDF_STATUS wlan_psoc_mlme_deinit(void); + +#endif diff --git a/umac/mlme/mlme_objmgr/dispatcher/src/wlan_cmn_mlme_main.c b/umac/mlme/mlme_objmgr/dispatcher/src/wlan_cmn_mlme_main.c index 5054286c2d..f65fd314ad 100644 --- a/umac/mlme/mlme_objmgr/dispatcher/src/wlan_cmn_mlme_main.c +++ b/umac/mlme/mlme_objmgr/dispatcher/src/wlan_cmn_mlme_main.c @@ -18,13 +18,14 @@ * DOC: Implements MLME global APIs */ -#include "wlan_objmgr_cmn.h" -#include "include/wlan_mlme_cmn.h" -#include "include/wlan_pdev_mlme.h" -#include "include/wlan_vdev_mlme.h" -#include "include/wlan_mlme_cmn.h" -#include "wlan_pdev_mlme_main.h" -#include "wlan_vdev_mlme_main.h" +#include +#include +#include +#include +#include +#include +#include +#include struct mlme_ext_ops *glbl_ops; mlme_get_global_ops_cb glbl_ops_cb; @@ -33,6 +34,10 @@ QDF_STATUS wlan_cmn_mlme_init(void) { QDF_STATUS status; + status = wlan_psoc_mlme_init(); + if (status != QDF_STATUS_SUCCESS) + return status; + status = wlan_pdev_mlme_init(); if (status != QDF_STATUS_SUCCESS) return status; @@ -59,14 +64,38 @@ QDF_STATUS wlan_cmn_mlme_deinit(void) if (status != QDF_STATUS_SUCCESS) return status; + status = wlan_psoc_mlme_deinit(); + if (status != QDF_STATUS_SUCCESS) + return status; + return QDF_STATUS_SUCCESS; } +QDF_STATUS mlme_psoc_ops_ext_hdl_create(struct psoc_mlme_obj *psoc_mlme) +{ + QDF_STATUS ret = QDF_STATUS_SUCCESS; + + if (glbl_ops && glbl_ops->mlme_psoc_ext_hdl_create) + ret = glbl_ops->mlme_psoc_ext_hdl_create(psoc_mlme); + + return ret; +} + +QDF_STATUS mlme_psoc_ops_ext_hdl_destroy(struct psoc_mlme_obj *psoc_mlme) +{ + QDF_STATUS ret = QDF_STATUS_SUCCESS; + + if (glbl_ops && glbl_ops->mlme_psoc_ext_hdl_destroy) + ret = glbl_ops->mlme_psoc_ext_hdl_destroy(psoc_mlme); + + return ret; +} + QDF_STATUS mlme_pdev_ops_ext_hdl_create(struct pdev_mlme_obj *pdev_mlme) { QDF_STATUS ret = QDF_STATUS_SUCCESS; - if ((glbl_ops) && glbl_ops->mlme_pdev_ext_hdl_create) + if (glbl_ops && glbl_ops->mlme_pdev_ext_hdl_create) ret = glbl_ops->mlme_pdev_ext_hdl_create(pdev_mlme); return ret; @@ -76,7 +105,7 @@ QDF_STATUS mlme_pdev_ops_ext_hdl_destroy(struct pdev_mlme_obj *pdev_mlme) { QDF_STATUS ret = QDF_STATUS_SUCCESS; - if ((glbl_ops) && glbl_ops->mlme_pdev_ext_hdl_destroy) + if (glbl_ops && glbl_ops->mlme_pdev_ext_hdl_destroy) ret = glbl_ops->mlme_pdev_ext_hdl_destroy(pdev_mlme); return ret; @@ -86,7 +115,7 @@ QDF_STATUS mlme_vdev_ops_ext_hdl_create(struct vdev_mlme_obj *vdev_mlme) { QDF_STATUS ret = QDF_STATUS_SUCCESS; - if ((glbl_ops) && glbl_ops->mlme_vdev_ext_hdl_create) + if (glbl_ops && glbl_ops->mlme_vdev_ext_hdl_create) ret = glbl_ops->mlme_vdev_ext_hdl_create(vdev_mlme); return ret; @@ -96,7 +125,7 @@ QDF_STATUS mlme_vdev_ops_ext_hdl_post_create(struct vdev_mlme_obj *vdev_mlme) { QDF_STATUS ret = QDF_STATUS_SUCCESS; - if ((glbl_ops) && glbl_ops->mlme_vdev_ext_hdl_post_create) + if (glbl_ops && glbl_ops->mlme_vdev_ext_hdl_post_create) ret = glbl_ops->mlme_vdev_ext_hdl_post_create(vdev_mlme); return ret; @@ -106,7 +135,7 @@ QDF_STATUS mlme_vdev_ops_ext_hdl_destroy(struct vdev_mlme_obj *vdev_mlme) { QDF_STATUS ret = QDF_STATUS_SUCCESS; - if ((glbl_ops) && glbl_ops->mlme_vdev_ext_hdl_destroy) + if (glbl_ops && glbl_ops->mlme_vdev_ext_hdl_destroy) ret = glbl_ops->mlme_vdev_ext_hdl_destroy(vdev_mlme); return ret; @@ -128,7 +157,7 @@ QDF_STATUS mlme_vdev_ops_multivdev_restart_fw_cmd_send( { QDF_STATUS ret = QDF_STATUS_SUCCESS; - if ((glbl_ops) && glbl_ops->mlme_multivdev_restart_fw_send) + if (glbl_ops && glbl_ops->mlme_multivdev_restart_fw_send) glbl_ops->mlme_multivdev_restart_fw_send(pdev); return ret; diff --git a/umac/mlme/mlme_objmgr/dispatcher/src/wlan_psoc_mlme_main.c b/umac/mlme/mlme_objmgr/dispatcher/src/wlan_psoc_mlme_main.c new file mode 100644 index 0000000000..21ea246f7c --- /dev/null +++ b/umac/mlme/mlme_objmgr/dispatcher/src/wlan_psoc_mlme_main.c @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2019 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: Implements PSOC MLME APIs + */ + +#include +#include +#include +#include +#include +#include +#include + +static QDF_STATUS mlme_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc, + void *arg) +{ + struct psoc_mlme_obj *psoc_mlme; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + psoc_mlme = qdf_mem_malloc(sizeof(struct psoc_mlme_obj)); + if (!psoc_mlme) { + mlme_err("Failed to allocate PSOS mlme Object"); + return QDF_STATUS_E_NOMEM; + } + + psoc_mlme->psoc = psoc; + + status = mlme_psoc_ops_ext_hdl_create(psoc_mlme); + if (QDF_IS_STATUS_ERROR(status)) { + mlme_err("Failed to allocate psoc ext handle"); + goto init_failed; + } + + status = wlan_objmgr_psoc_component_obj_attach(psoc, + WLAN_UMAC_COMP_MLME, + psoc_mlme, + QDF_STATUS_SUCCESS); + if (QDF_IS_STATUS_ERROR(status)) { + mlme_err("Failed to attach psoc_ctx with psoc"); + goto init_failed; + } + + return status; +init_failed: + qdf_mem_free(psoc_mlme); + + return status; +} + +static QDF_STATUS mlme_psoc_obj_destroy_handler(struct wlan_objmgr_psoc *psoc, + void *arg) +{ + struct psoc_mlme_obj *psoc_mlme; + + psoc_mlme = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_UMAC_COMP_MLME); + if (!psoc_mlme) { + mlme_err(" PSOC MLME component object is NULL"); + return QDF_STATUS_E_FAILURE; + } + + wlan_objmgr_psoc_component_obj_detach(psoc, WLAN_UMAC_COMP_MLME, + psoc_mlme); + + mlme_psoc_ops_ext_hdl_destroy(psoc_mlme); + + qdf_mem_free(psoc_mlme); + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS wlan_psoc_mlme_init(void) +{ + if (wlan_objmgr_register_psoc_create_handler + (WLAN_UMAC_COMP_MLME, + mlme_psoc_obj_create_handler, NULL) + != QDF_STATUS_SUCCESS) + return QDF_STATUS_E_FAILURE; + + if (wlan_objmgr_register_psoc_destroy_handler + (WLAN_UMAC_COMP_MLME, + mlme_psoc_obj_destroy_handler, NULL) + != QDF_STATUS_SUCCESS) { + if (wlan_objmgr_unregister_psoc_create_handler + (WLAN_UMAC_COMP_MLME, + mlme_psoc_obj_create_handler, NULL) + != QDF_STATUS_SUCCESS) + return QDF_STATUS_E_FAILURE; + + return QDF_STATUS_E_FAILURE; + } + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS wlan_psoc_mlme_deinit(void) +{ + if (wlan_objmgr_unregister_psoc_create_handler + (WLAN_UMAC_COMP_MLME, + mlme_psoc_obj_create_handler, NULL) + != QDF_STATUS_SUCCESS) + return QDF_STATUS_E_FAILURE; + + if (wlan_objmgr_unregister_psoc_destroy_handler + (WLAN_UMAC_COMP_MLME, + mlme_psoc_obj_destroy_handler, NULL) + != QDF_STATUS_SUCCESS) + return QDF_STATUS_E_FAILURE; + + return QDF_STATUS_SUCCESS; +} diff --git a/umac/mlme/psoc_mgr/dispatcher/inc/wlan_psoc_mlme_api.h b/umac/mlme/psoc_mgr/dispatcher/inc/wlan_psoc_mlme_api.h new file mode 100644 index 0000000000..f9911ab14c --- /dev/null +++ b/umac/mlme/psoc_mgr/dispatcher/inc/wlan_psoc_mlme_api.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019 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: Define PSOC MLME public APIs + */ + +#ifndef _WLAN_PSOC_MLME_API_H_ +#define _WLAN_PSOC_MLME_API_H_ + +/** + * wlan_psoc_mlme_get_cmpt_obj() - Returns PSOC MLME component object + * @psoc: PSOC object + * + * Retrieves MLME component object from PSOC object + * + * Return: comp handle on SUCCESS + * NULL, if it fails to retrieve + */ +struct psoc_mlme_obj *wlan_psoc_mlme_get_cmpt_obj( + struct wlan_objmgr_psoc *psoc); + +/** + * wlan_psoc_mlme_get_ext_hdl() - Returns legacy handle + * @psoc: PSOC object + * + * Retrieves legacy handle from psoc mlme component object + * + * Return: legacy handle on SUCCESS + * NULL, if it fails to retrieve + */ +mlme_psoc_ext_t *wlan_psoc_mlme_get_ext_hdl(struct wlan_objmgr_psoc *psoc); + +/** + * wlan_psoc_mlme_set_ext_hdl() - Set legacy handle + * @psoc_mlme: psoc_mlme object + * psoc_ext_hdl: PSOC level legacy handle + * + * Sets legacy handle in psoc mlme component object + * + * Return: Void + */ +void wlan_psoc_mlme_set_ext_hdl(struct psoc_mlme_obj *psoc_mlme, + mlme_psoc_ext_t *psoc_ext_hdl); + +#endif diff --git a/umac/mlme/psoc_mgr/dispatcher/src/wlan_psoc_mlme_api.c b/umac/mlme/psoc_mgr/dispatcher/src/wlan_psoc_mlme_api.c new file mode 100644 index 0000000000..508d017531 --- /dev/null +++ b/umac/mlme/psoc_mgr/dispatcher/src/wlan_psoc_mlme_api.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019 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: Implements PSOC MLME public APIs + */ + +#include +#include +#include +#include +#include + +struct psoc_mlme_obj *wlan_psoc_mlme_get_cmpt_obj(struct wlan_objmgr_psoc *psoc) +{ + struct psoc_mlme_obj *psoc_mlme; + + psoc_mlme = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_UMAC_COMP_MLME); + if (!psoc_mlme) { + mlme_err("PSOC MLME component object is NULL"); + return NULL; + } + + return psoc_mlme; +} + +qdf_export_symbol(wlan_psoc_mlme_get_cmpt_obj); + +mlme_psoc_ext_t *wlan_psoc_mlme_get_ext_hdl(struct wlan_objmgr_psoc *psoc) +{ + struct psoc_mlme_obj *psoc_mlme; + + psoc_mlme = wlan_psoc_mlme_get_cmpt_obj(psoc); + if (psoc_mlme) + return psoc_mlme->ext_psoc_ptr; + + return NULL; +} + +qdf_export_symbol(wlan_psoc_mlme_get_ext_hdl); + +void wlan_psoc_mlme_set_ext_hdl(struct psoc_mlme_obj *psoc_mlme, + mlme_psoc_ext_t *psoc_ext_hdl) +{ + psoc_mlme->ext_psoc_ptr = psoc_ext_hdl; +} + +qdf_export_symbol(wlan_psoc_mlme_set_ext_hdl);