From 297a398c27edb68b44b4a7dbfe16c53adcfb7c1a Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Wed, 17 Oct 2018 15:14:38 -0700 Subject: [PATCH] qcacld-3.0: Refine the SME NAN public interface Update the SME NAN public interface as follows: 1) Move the sme_nan_event() prototype to nan_api.h 2) Fully document the interfaces (not the implementations) 3) Utilize the new mac_handle_t abstraction 4) Clean up local coding style violations Change-Id: I7ae6fff6e4a44570463383e9f6f50731fa594192 CRs-Fixed: 2335643 --- core/sme/inc/nan_api.h | 56 +++++++++++++++++++++-- core/sme/inc/sme_api.h | 3 -- core/sme/src/nan/nan_api.c | 93 ++++++++++---------------------------- 3 files changed, 76 insertions(+), 76 deletions(-) diff --git a/core/sme/inc/nan_api.h b/core/sme/inc/nan_api.h index eb63cb2b5073..5abba03df56e 100644 --- a/core/sme/inc/nan_api.h +++ b/core/sme/inc/nan_api.h @@ -38,17 +38,63 @@ typedef struct sNanRequestReq { const uint8_t *request_data; } tNanRequestReq, *tpNanRequestReq; -void sme_nan_register_callback(tHalHandle hHal, nan_callback callback); -void sme_nan_deregister_callback(tHalHandle hHal); +/** + * sme_nan_register_callback() - Register NAN Callback function + * @mac_handle: Opaque handle to the MAC context + * @callback: Callback function to be registered + * + * Function to be called by HDD to register the NAN Response callback + * function with the sme layer. + * + * Return: void + */ +void sme_nan_register_callback(mac_handle_t mac_handle, nan_callback callback); + +/** + * sme_nan_deregister_callback() - NAN De-register cb function + * @mac_handle: Opaque handle to the MAC context + * + * Function to be called by HDD to deregister the NAN Response + * callback function with the sme layer. + * + * Return: void + */ +void sme_nan_deregister_callback(mac_handle_t mac_handle); + +/** + * sme_nan_request() - Process a NAN request + * @input: Nan Request structure ptr + * + * This function gets called when HDD receives NAN vendor command + * from userspace + * + * Return: QDF_STATUS + */ QDF_STATUS sme_nan_request(tpNanRequestReq input); -#else -static inline void sme_nan_register_callback(tHalHandle hHal, + +/** + * sme_nan_event() - Process a NAN event + * @mac_handle: Opaque handle to the MAC context + * @event: NAN event received from firmware + * + * This callback function will be called when SME received eWNI_SME_NAN_EVENT + * event from WMA + * + * Return: void + */ +void sme_nan_event(mac_handle_t mac_handle, tSirNanEvent *event); + +#else /* WLAN_FEATURE_NAN */ + +static inline void sme_nan_register_callback(mac_handle_t mac_handle, nan_callback callback) { } -static inline void sme_nan_deregister_callback(tHalHandle hHal) + +static inline void sme_nan_deregister_callback(mac_handle_t mac_handle) { } + #endif /* WLAN_FEATURE_NAN */ #endif /* __NAN_API_H__ */ diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 6cab3a68dc24..af1b6666dff9 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -1212,9 +1212,6 @@ QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx, bool key_mgmt_offload_enabled, struct pmkid_mode_bits *pmkid_modes); #endif -#ifdef WLAN_FEATURE_NAN -QDF_STATUS sme_nan_event(tHalHandle hHal, void *pMsg); -#endif /* WLAN_FEATURE_NAN */ QDF_STATUS sme_get_link_status(mac_handle_t mac_handle, csr_link_status_callback callback, void *context, uint8_t session_id); diff --git a/core/sme/src/nan/nan_api.c b/core/sme/src/nan/nan_api.c index 1c7a0423f00a..43ac3af91021 100644 --- a/core/sme/src/nan/nan_api.c +++ b/core/sme/src/nan/nan_api.c @@ -25,60 +25,28 @@ #include "cfg_api.h" #include "wma_types.h" -/** - * sme_nan_register_callback() - - * This function gets called when HDD wants register nan rsp callback with - * sme layer. - * - * @hHal: Hal handle - * @callback: which needs to be registered. - * - * Return: void - */ -void sme_nan_register_callback(tHalHandle hHal, nan_callback callback) +void sme_nan_register_callback(mac_handle_t mac_handle, nan_callback callback) { - tpAniSirGlobal pMac = NULL; + tpAniSirGlobal mac = MAC_CONTEXT(mac_handle); - if (NULL == hHal) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("hHal is not valid")); + if (!mac) { + sme_err("Invalid MAC handle"); return; } - pMac = PMAC_STRUCT(hHal); - pMac->sme.nan_callback = callback; + mac->sme.nan_callback = callback; } -/** - * sme_nan_deregister_callback() - NAN De-register cb function - * @h_hal: Hal handle - * - * De-register nan rsp callback with sme layer. - * - * Return: void - */ -void sme_nan_deregister_callback(tHalHandle h_hal) +void sme_nan_deregister_callback(mac_handle_t mac_handle) { - tpAniSirGlobal pmac; + tpAniSirGlobal mac = MAC_CONTEXT(mac_handle); - if (!h_hal) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("hHal is not valid")); + if (!mac) { + sme_err("Invalid MAC handle"); return; } - pmac = PMAC_STRUCT(h_hal); - pmac->sme.nan_callback = NULL; + mac->sme.nan_callback = NULL; } - -/** - * sme_nan_request() - - * This function gets called when HDD receives NAN vendor command - * from userspace - * - * @input: Nan Request structure ptr - * - * Return: QDF_STATUS - */ QDF_STATUS sme_nan_request(tpNanRequestReq input) { struct scheduler_msg msg = {0}; @@ -104,8 +72,7 @@ QDF_STATUS sme_nan_request(tpNanRequestReq input) QDF_MODULE_ID_WMA, QDF_MODULE_ID_WMA, &msg)) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - "Not able to post WMA_NAN_REQUEST message to WMA"); + sme_err("Not able to post WMA_NAN_REQUEST message to WMA"); qdf_mem_free(data); return QDF_STATUS_SUCCESS; } @@ -113,32 +80,22 @@ QDF_STATUS sme_nan_request(tpNanRequestReq input) return QDF_STATUS_SUCCESS; } -/** - * sme_nan_event() - - * This callback function will be called when SME received eWNI_SME_NAN_EVENT - * event from WMA - * - * @hHal: HAL handle for device - * @pMsg: Message body passed from WMA; includes NAN header - * - * Return: QDF_STATUS - */ -QDF_STATUS sme_nan_event(tHalHandle hHal, void *pMsg) +void sme_nan_event(mac_handle_t mac_handle, tSirNanEvent *event) { - tpAniSirGlobal pMac = PMAC_STRUCT(hHal); - QDF_STATUS status = QDF_STATUS_SUCCESS; + tpAniSirGlobal mac = MAC_CONTEXT(mac_handle); - if (NULL == pMsg) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("msg ptr is NULL")); - status = QDF_STATUS_E_FAILURE; - } else { - sme_debug("Received eWNI_SME_NAN_EVENT"); - if (pMac->sme.nan_callback) { - pMac->sme.nan_callback(pMac->hdd_handle, - (tSirNanEvent *) pMsg); - } + sme_debug("Received eWNI_SME_NAN_EVENT"); + + if (!mac) { + sme_err("Invalid MAC handle"); + return; } - return status; + if (!event) { + sme_err("NULL event"); + return; + } + + if (mac->sme.nan_callback) + mac->sme.nan_callback(mac->hdd_handle, event); }