Quellcode durchsuchen

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
Jeff Johnson vor 6 Jahren
Ursprung
Commit
297a398c27
3 geänderte Dateien mit 77 neuen und 77 gelöschten Zeilen
  1. 51 5
      core/sme/inc/nan_api.h
  2. 0 3
      core/sme/inc/sme_api.h
  3. 26 69
      core/sme/src/nan/nan_api.c

+ 51 - 5
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__ */

+ 0 - 3
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);

+ 26 - 69
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;
-
-	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);
-		}
+	tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
+
+	sme_debug("Received eWNI_SME_NAN_EVENT");
+
+	if (!mac) {
+		sme_err("Invalid MAC handle");
+		return;
+	}
+
+	if (!event) {
+		sme_err("NULL event");
+		return;
 	}
 
-	return status;
+	if (mac->sme.nan_callback)
+		mac->sme.nan_callback(mac->hdd_handle, event);
 }