From 5943765644ba1fde7d0f4ee845b2d778f13b620d Mon Sep 17 00:00:00 2001 From: Krunal Soni Date: Tue, 21 Nov 2017 13:42:14 -0800 Subject: [PATCH] qcacld-3.0: Rename few SAP APIs & introduce the new wrapper APIs wlansap_open(), wlansap_close(), wlansap_start(), and wlansap_stop() APIs are not doing what their names' suggest. Rename these APIs such a way that they reflect the true meaning of it. Introduce two new APIs to create and destroy the sap context. CRs-Fixed: 2147974 Change-Id: Ie0475df480d1b19e796ddf3b639de3078a5a61a0 --- core/hdd/src/wlan_hdd_hostapd.c | 27 ++++++++++++++++++++---- core/hdd/src/wlan_hdd_hostapd.h | 22 +++++++++++++++++++- core/sap/inc/sap_api.h | 37 +++++++++++++++++---------------- core/sap/src/sap_module.c | 12 +++++------ 4 files changed, 69 insertions(+), 29 deletions(-) diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 374c56b97d79..7a99f66dd58e 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -236,7 +236,7 @@ hdd_hostapd_init_sap_session(struct hdd_adapter *adapter, if (reinit) sap_ctx = adapter->session.ap.sap_context; else - sap_ctx = wlansap_open(); + sap_ctx = sap_create_ctx(); if (!sap_ctx) { hdd_err("can't allocate the sap_ctx"); @@ -251,7 +251,7 @@ hdd_hostapd_init_sap_session(struct hdd_adapter *adapter, hdd_err("failed to create objmgr vdev"); goto error; } - status = wlansap_start(sap_ctx, adapter->device_mode, + status = sap_init_ctx(sap_ctx, adapter->device_mode, adapter->mac_addr.bytes, adapter->session_id); if (QDF_IS_STATUS_ERROR(status)) { @@ -291,7 +291,7 @@ int hdd_hostapd_deinit_sap_session(struct hdd_adapter *adapter) return 0; } - if (!QDF_IS_STATUS_SUCCESS(wlansap_stop(sap_ctx))) { + if (!QDF_IS_STATUS_SUCCESS(sap_deinit_ctx(sap_ctx))) { hdd_err("Error stopping the sap session"); status = -EINVAL; } @@ -299,7 +299,7 @@ int hdd_hostapd_deinit_sap_session(struct hdd_adapter *adapter) hdd_err("objmgr vdev destroy failed"); status = -EINVAL; } - if (!QDF_IS_STATUS_SUCCESS(wlansap_close(sap_ctx))) { + if (!QDF_IS_STATUS_SUCCESS(sap_destroy_ctx(sap_ctx))) { hdd_err("Error closing the sap session"); status = -EINVAL; } @@ -6131,6 +6131,25 @@ void hdd_set_ap_ops(struct net_device *dev) dev->netdev_ops = &net_ops_struct; } +bool hdd_sap_create_ctx(struct hdd_adapter *adapter) +{ + hdd_debug("creating sap context"); + adapter->session.ap.sap_context = sap_create_ctx(); + if (adapter->session.ap.sap_context) + return true; + + return false; +} + +bool hdd_sap_destroy_ctx(struct hdd_adapter *adapter) +{ + hdd_debug("destroying sap context"); + sap_destroy_ctx(adapter->session.ap.sap_context); + adapter->session.ap.sap_context = NULL; + + return true; +} + QDF_STATUS hdd_init_ap_mode(struct hdd_adapter *adapter, bool reinit) { struct hdd_hostapd_state *phostapdBuf; diff --git a/core/hdd/src/wlan_hdd_hostapd.h b/core/hdd/src/wlan_hdd_hostapd.h index 6df37d963a1d..65467ea77a3c 100644 --- a/core/hdd/src/wlan_hdd_hostapd.h +++ b/core/hdd/src/wlan_hdd_hostapd.h @@ -139,7 +139,7 @@ int hdd_hostapd_deinit_sap_session(struct hdd_adapter *adapter); * @adapter: SAP/GO adapter * * This API will do - * 1) wlansap_open(), wlansap_start() + * 1) sap_create_ctx(), wlansap_start() * 2) creates and stores the vdev objects * * Return: 0 if success else non-zero value. @@ -173,6 +173,26 @@ void hdd_deinit_ap_mode(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, bool rtnl_held); void hdd_set_ap_ops(struct net_device *dev); +/** + * hdd_sap_create_ctx() - Wrapper API to create SAP context + * @adapter: pointer to adapter + * + * This wrapper API can be called to create the sap context. It will + * eventually calls SAP API to create the sap context + * + * Return: true or false based on overall success or failure + */ +bool hdd_sap_create_ctx(struct hdd_adapter *adapter); +/** + * hdd_sap_destroy_ctx() - Wrapper API to destroy SAP context + * @adapter: pointer to adapter + * + * This wrapper API can be called to destroy the sap context. It will + * eventually calls SAP API to destroy the sap context + * + * Return: true or false based on overall success or failure + */ +bool hdd_sap_destroy_ctx(struct hdd_adapter *adapter); int hdd_hostapd_stop(struct net_device *dev); int hdd_sap_context_init(struct hdd_context *hdd_ctx); void hdd_sap_context_destroy(struct hdd_context *hdd_ctx); diff --git a/core/sap/inc/sap_api.h b/core/sap/inc/sap_api.h index 9afe04e5154f..dcd6f7f8a3df 100644 --- a/core/sap/inc/sap_api.h +++ b/core/sap/inc/sap_api.h @@ -784,7 +784,7 @@ typedef struct { * struct sap_context - per-BSS Context for SAP * * struct sap_context is used to share per-BSS context between SAP and - * its clients. A context is generated by wlansap_open() and is + * its clients. A context is generated by sap_create_ctx() and is * destroyed by wlansap_close(). During the lifetime of the BSS the * SAP context is passed as the primary parameter to SAP APIs. Note * that by design the contents of the structure are opaque to the @@ -793,61 +793,62 @@ typedef struct { struct sap_context; /** - * wlansap_open() - WLAN SAP open function call + * sap_create_ctx() - API to create the sap context * - * Called at BSS initialization to generate a context for the BSS. SAP - * will initialize all its internal resources and will wait for the - * call to wlan_start() to register with the other modules. + * This API assigns the sap context from global sap context pool + * stored in gp_sap_ctx[i] array. * * Return: Pointer to the SAP context, or NULL if a context could not * be allocated */ -struct sap_context *wlansap_open(void); +struct sap_context *sap_create_ctx(void); /** - * wlansap_close - close per-BSS SAP + * sap_destroy_ctx - API to destroy the sap context * @sap_ctx: Pointer to the SAP context * - * Called during BSS close procedure. SAP will clean up all the - * internal resources. + * This API puts back the given sap context to global sap context pool which + * makes current sap session's sap context invalid. * * Return: The result code associated with performing the operation * QDF_STATUS_E_FAULT: Pointer to SAP cb is NULL; * access would cause a page fault * QDF_STATUS_SUCCESS: Success */ -QDF_STATUS wlansap_close(struct sap_context *sap_ctx); +QDF_STATUS sap_destroy_ctx(struct sap_context *sap_ctx); /** - * wlansap_start - start per-BSS SAP + * sap_init_ctx - Initialize the sap context * @sap_ctx: Pointer to the SAP context * @mode: Device mode * @addr: MAC address of the SAP * @session_id: Pointer to the session id * - * Called as part of the BSS start procedure. SAP will use this call - * to perform all activities needed to start the BSS. + * sap_create_ctx() allocates the sap context which is uninitialized. + * This API needs to be called to properly initialize the sap context + * which is just created. * * Return: The result code associated with performing the operation * QDF_STATUS_E_FAULT: BSS could not be started * QDF_STATUS_SUCCESS: Success */ -QDF_STATUS wlansap_start(struct sap_context *sap_ctx, +QDF_STATUS sap_init_ctx(struct sap_context *sap_ctx, enum QDF_OPMODE mode, uint8_t *addr, uint32_t session_id); /** - * wlansap_stop() - stop per-BSS SAP + * sap_deinit_ctx() - De-initialize the sap context * @sap_ctx: Pointer to the SAP context * - * Called as part of the BSS stop procedure. SAP will use this call - * to perform all activities needed to stop the BSS. + * When SAP session is about to close, this API needs to be called + * to de-initialize all the members of sap context structure, so that + * nobody can accidently start using the sap context. * * Return: The result code associated with performing the operation * QDF_STATUS_E_FAULT: BSS could not be stopped * QDF_STATUS_SUCCESS: Success */ -QDF_STATUS wlansap_stop(struct sap_context *sap_ctx); +QDF_STATUS sap_deinit_ctx(struct sap_context *sap_ctx); /** * sap_is_auto_channel_select() - is channel AUTO_CHANNEL_SELECT diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c index 7716d333429e..c3728d515257 100644 --- a/core/sap/src/sap_module.c +++ b/core/sap/src/sap_module.c @@ -251,7 +251,7 @@ void wlansap_context_put(struct sap_context *ctx) qdf_mutex_release(&sap_context_lock); } -struct sap_context *wlansap_open(void) +struct sap_context *sap_create_ctx(void) { struct sap_context *sap_ctx; QDF_STATUS status; @@ -279,9 +279,9 @@ struct sap_context *wlansap_open(void) QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, FL("Exit")); return sap_ctx; -} /* wlansap_open */ +} /* sap_create_ctx */ -QDF_STATUS wlansap_start(struct sap_context *sap_ctx, +QDF_STATUS sap_init_ctx(struct sap_context *sap_ctx, enum QDF_OPMODE mode, uint8_t *addr, uint32_t session_id) { @@ -355,7 +355,7 @@ QDF_STATUS wlansap_start(struct sap_context *sap_ctx, return QDF_STATUS_SUCCESS; } -QDF_STATUS wlansap_stop(struct sap_context *sap_ctx) +QDF_STATUS sap_deinit_ctx(struct sap_context *sap_ctx) { tHalHandle hal; tpAniSirGlobal pmac; @@ -393,7 +393,7 @@ QDF_STATUS wlansap_stop(struct sap_context *sap_ctx) return QDF_STATUS_SUCCESS; } -QDF_STATUS wlansap_close(struct sap_context *sap_ctx) +QDF_STATUS sap_destroy_ctx(struct sap_context *sap_ctx) { QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, "wlansap_close invoked"); @@ -407,7 +407,7 @@ QDF_STATUS wlansap_close(struct sap_context *sap_ctx) QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, FL("Enter")); /* * wlansap_context_put will release actual sap_ctx memory - * allocated during wlansap_open + * allocated during sap_create_ctx */ wlansap_context_put(sap_ctx); QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, FL("Exit"));