瀏覽代碼

qcacld-3.0: Register Open/close session callbacks once

Open/close session callbacks are common for all the device modes
supported, so register once during the start_modules.

Change-Id: Ia94857ce4cc608be30e9974ddde8a6261d45f6e3
CRs-Fixed: 2555919
Arun Kumar Khandavalli 5 年之前
父節點
當前提交
42b4487910

+ 26 - 2
core/hdd/inc/wlan_hdd_main.h

@@ -2238,8 +2238,16 @@ hdd_get_adapter_by_rand_macaddr(struct hdd_context *hdd_ctx,
  */
 bool hdd_is_vdev_in_conn_state(struct hdd_adapter *adapter);
 
-int hdd_vdev_create(struct hdd_adapter *adapter,
-		    csr_roam_complete_cb callback, void *ctx);
+/**
+ * hdd_vdev_create() - Create the vdev in the firmware
+ * @adapter: hdd adapter
+ *
+ * This function will create the vdev in the firmware
+ *
+ * Return: 0 when the vdev create is sent to firmware or -EINVAL when
+ * there is a failure to send the command.
+ */
+int hdd_vdev_create(struct hdd_adapter *adapter);
 int hdd_vdev_destroy(struct hdd_adapter *adapter);
 int hdd_vdev_ready(struct hdd_adapter *adapter);
 
@@ -4000,4 +4008,20 @@ int hdd_psoc_idle_shutdown(struct device *dev);
  */
 int hdd_psoc_idle_restart(struct device *dev);
 
+/**
+ * hdd_common_roam_callback() - common sme roam callback
+ * @psoc: Object Manager Psoc
+ * @session_id: session id for which callback is called
+ * @roam_info: pointer to roam info
+ * @roam_status: roam status
+ * @roam_result: roam result
+ *
+ * Return: QDF_STATUS enumeration
+ */
+QDF_STATUS hdd_common_roam_callback(struct wlan_objmgr_psoc *psoc,
+				    uint8_t session_id,
+				    struct csr_roam_info *roam_info,
+				    uint32_t roam_id,
+				    eRoamCmdStatus roam_status,
+				    eCsrRoamResult roam_result);
 #endif /* end #if !defined(WLAN_HDD_MAIN_H) */

+ 49 - 15
core/hdd/src/wlan_hdd_main.c

@@ -172,8 +172,8 @@
 #include <wlan_hdd_debugfs_coex.h>
 #include "wlan_blm_ucfg_api.h"
 #include "ol_txrx.h"
-#include "nan_ucfg_api.h"
 #include "wlan_hdd_sta_info.h"
+#include "mac_init_api.h"
 
 #ifdef MODULE
 #define WLAN_MODULE_NAME  module_name(THIS_MODULE)
@@ -350,6 +350,45 @@ struct sock *cesium_nl_srv_sock;
 static void wlan_hdd_auto_shutdown_cb(void);
 #endif
 
+QDF_STATUS hdd_common_roam_callback(struct wlan_objmgr_psoc *psoc,
+				     uint8_t session_id,
+				    struct csr_roam_info *roam_info,
+				    uint32_t roam_id,
+				    eRoamCmdStatus roam_status,
+				    eCsrRoamResult roam_result)
+{
+	struct hdd_context *hdd_ctx;
+	struct hdd_adapter *adapter;
+
+	adapter = wlan_hdd_get_adapter_from_vdev(psoc, session_id);
+	if (!adapter)
+		return QDF_STATUS_E_INVAL;
+
+	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+	if (!hdd_ctx)
+		return QDF_STATUS_E_INVAL;
+
+	switch (adapter->device_mode) {
+	case QDF_STA_MODE:
+	case QDF_NDI_MODE:
+	case QDF_P2P_CLIENT_MODE:
+	case QDF_P2P_DEVICE_MODE:
+		hdd_sme_roam_callback(adapter, roam_info, roam_id, roam_status,
+				      roam_result);
+		break;
+	case QDF_SAP_MODE:
+	case QDF_P2P_GO_MODE:
+		wlansap_roam_callback(adapter->session.ap.sap_context,
+				      roam_info, roam_id, roam_status,
+				      roam_result);
+		break;
+	default:
+		hdd_err("Wrong device mode");
+		break;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
 /**
  * hdd_mic_flush_work() - disable and flush pending mic work
  * @adapter: Pointer to hdd adapter
@@ -4406,15 +4445,9 @@ release_vdev:
 }
 
 static int hdd_set_sme_session_param(struct hdd_adapter *adapter,
-			struct sme_session_params *session_param,
-			csr_roam_complete_cb callback,
-			void *callback_ctx)
+				     struct sme_session_params *session_param)
 {
-	session_param->session_close_cb = hdd_sme_close_session_callback;
-	session_param->callback = callback;
-	session_param->callback_ctx = callback_ctx;
 	session_param->vdev = adapter->vdev;
-
 	return 0;
 }
 
@@ -4453,8 +4486,7 @@ bool hdd_is_vdev_in_conn_state(struct hdd_adapter *adapter)
 	return 0;
 }
 
-int hdd_vdev_create(struct hdd_adapter *adapter,
-		    csr_roam_complete_cb callback, void *ctx)
+int hdd_vdev_create(struct hdd_adapter *adapter)
 {
 	QDF_STATUS status;
 	int errno;
@@ -4473,8 +4505,7 @@ int hdd_vdev_create(struct hdd_adapter *adapter,
 		return errno;
 	}
 
-	errno = hdd_set_sme_session_param(adapter, &sme_session_params,
-					  callback, ctx);
+	errno = hdd_set_sme_session_param(adapter, &sme_session_params);
 	if (errno) {
 		hdd_err("failed to populating SME params");
 		goto objmgr_vdev_destroy_procedure;
@@ -10345,7 +10376,7 @@ int hdd_start_station_adapter(struct hdd_adapter *adapter)
 		return qdf_status_to_os_return(QDF_STATUS_SUCCESS);
 	}
 
-	ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter);
+	ret = hdd_vdev_create(adapter);
 	if (ret) {
 		hdd_err("failed to create vdev: %d", ret);
 		return ret;
@@ -10412,8 +10443,7 @@ int hdd_start_ap_adapter(struct hdd_adapter *adapter)
 		return qdf_status_to_os_return(QDF_STATUS_E_FAILURE);
 	}
 
-	ret = hdd_vdev_create(adapter, wlansap_roam_callback,
-			      adapter->session.ap.sap_context);
+	ret = hdd_vdev_create(adapter);
 	if (ret) {
 		hdd_err("failed to create vdev, status:%d", ret);
 		hdd_sap_destroy_ctx(adapter);
@@ -12965,6 +12995,10 @@ int hdd_register_cb(struct hdd_context *hdd_ctx)
 	sme_set_md_bl_evt_cb(mac_handle, hdd_md_bl_evt_cb, (void *)hdd_ctx);
 #endif /* WLAN_FEATURE_MOTION_DETECTION */
 
+	mac_register_sesssion_open_close_cb(hdd_ctx->mac_handle,
+					    hdd_sme_close_session_callback,
+					    hdd_common_roam_callback);
+
 	hdd_exit();
 
 	return ret;

+ 1 - 1
core/hdd/src/wlan_hdd_nan_datapath.c

@@ -460,7 +460,7 @@ int hdd_init_nan_data_mode(struct hdd_adapter *adapter)
 	bool bval = false;
 	uint8_t enable_sifs_burst = 0;
 
-	ret_val = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter);
+	ret_val = hdd_vdev_create(adapter);
 	if (ret_val) {
 		hdd_err("failed to create vdev: %d", ret_val);
 		return ret_val;

+ 2 - 0
core/mac/inc/ani_global.h

@@ -822,6 +822,8 @@ struct mac_context {
 #endif
 	bool obss_scan_offload;
 	bool bcn_reception_stats;
+	csr_session_close_cb session_close_cb;
+	csr_roam_complete_cb session_roam_complete_cb;
 };
 
 #ifdef FEATURE_WLAN_TDLS

+ 11 - 1
core/mac/inc/mac_init_api.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-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
@@ -101,4 +101,14 @@ QDF_STATUS mac_open(struct wlan_objmgr_psoc *psoc, mac_handle_t *mac_handle,
  */
 QDF_STATUS mac_close(mac_handle_t mac_handle);
 
+/**
+ * mac_register_sesssion_open_close_cb() - register open/close session cb
+ * @mac_handle: Opaque handle to the MAC context
+ * @close_session: callback to be registered with SME for closing the session
+ * @callback: Common callback to hdd for all modes
+ */
+void mac_register_sesssion_open_close_cb(mac_handle_t mac_handle,
+					 csr_session_close_cb close_session,
+					 csr_roam_complete_cb callback);
+
 #endif /* __MAC_INIT_API_H */

+ 10 - 0
core/mac/src/sys/legacy/src/system/src/mac_init_api.c

@@ -186,3 +186,13 @@ QDF_STATUS mac_close(mac_handle_t mac_handle)
 
 	return QDF_STATUS_SUCCESS;
 }
+
+void mac_register_sesssion_open_close_cb(mac_handle_t mac_handle,
+					 csr_session_close_cb close_session,
+					 csr_roam_complete_cb callback)
+{
+	struct mac_context *mac = MAC_CONTEXT(mac_handle);
+
+	mac->session_close_cb = close_session;
+	mac->session_roam_complete_cb = callback;
+}

+ 2 - 1
core/sme/inc/csr_api.h

@@ -1295,7 +1295,8 @@ struct wep_update_default_key_idx {
 	uint8_t default_idx;
 };
 
-typedef QDF_STATUS (*csr_roam_complete_cb)(void *context,
+typedef QDF_STATUS (*csr_roam_complete_cb)(struct wlan_objmgr_psoc *psoc,
+					   uint8_t session_id,
 					   struct csr_roam_info *param,
 					   uint32_t roam_id,
 					   eRoamCmdStatus roam_status,

+ 0 - 3
core/sme/inc/csr_internal.h

@@ -542,9 +542,6 @@ struct csr_roam_session {
 	/* For BT-AMP station, this serve as BSSID for self-BSS. */
 	struct qdf_mac_addr self_mac_addr;
 
-	csr_session_close_cb session_close_cb;
-	csr_roam_complete_cb callback;
-	void *pContext;
 	eCsrConnectState connectState;
 	struct rsn_caps rsn_caps;
 	tCsrRoamConnectedProfile connectedProfile;

+ 0 - 8
core/sme/inc/sme_api.h

@@ -210,18 +210,10 @@ struct sme_5g_band_pref_params {
 
 /**
  * struct sme_session_params: Session creation params passed by HDD layer
- * @session_open_cb: callback to be registered with SME for opening the session
- * @session_close_cb: callback to be registered with SME for closing the session
- * @callback: callback to be invoked for roaming events
  * @vdev: pointer to vdev object
- * @callback_ctx: user-supplied context to be passed back on roaming events
  */
 struct sme_session_params {
-	csr_session_open_cb  session_open_cb;
-	csr_session_close_cb session_close_cb;
-	csr_roam_complete_cb callback;
 	struct wlan_objmgr_vdev *vdev;
-	void *callback_ctx;
 };
 
 #define MAX_CANDIDATE_INFO 10

+ 5 - 10
core/sme/src/csr/csr_api_roam.c

@@ -3874,7 +3874,7 @@ QDF_STATUS csr_roam_call_callback(struct mac_context *mac, uint32_t sessionId,
 	if (eCSR_ROAM_ASSOCIATION_COMPLETION == u1)
 		csr_dump_connection_stats(mac, pSession, roam_info, u1, u2);
 
-	if (pSession->callback) {
+	if (mac->session_roam_complete_cb) {
 		if (roam_info) {
 			roam_info->sessionId = (uint8_t) sessionId;
 			/*
@@ -3888,8 +3888,8 @@ QDF_STATUS csr_roam_call_callback(struct mac_context *mac, uint32_t sessionId,
 				(roam_info->reasonCode == eSIR_BEACON_MISSED) ?
 				0 : roam_info->reasonCode;
 		}
-		status = pSession->callback(pSession->pContext, roam_info,
-					roamId, u1, u2);
+		status = mac->session_roam_complete_cb(mac->psoc, sessionId, roam_info,
+						       roamId, u1, u2);
 	}
 	/*
 	 * EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
@@ -17330,9 +17330,6 @@ QDF_STATUS csr_create_vdev(struct mac_context *mac_ctx,
 	/* Initialize FT related data structures only in STA mode */
 	sme_ft_open(MAC_HANDLE(mac_ctx), session->sessionId);
 
-	session->session_close_cb = session_param->session_close_cb;
-	session->callback = session_param->callback;
-	session->pContext = session_param->callback_ctx;
 
 	qdf_mem_copy(&session->self_mac_addr, mac_addr,
 		     sizeof(struct qdf_mac_addr));
@@ -17555,13 +17552,13 @@ QDF_STATUS csr_roam_vdev_delete(struct mac_context *mac_ctx,
 	 * as expected by firmware and should not be flushed.
 	 */
 	csr_purge_vdev_all_scan_ser_cmd_list(mac_ctx, vdev_id);
-	if (!session->session_close_cb) {
+	if (!mac_ctx->session_close_cb) {
 		sme_err("no close session callback registered");
 		return QDF_STATUS_E_FAILURE;
 	}
 	status = csr_issue_vdev_del_req(mac_ctx, vdev_id,
 					session->self_mac_addr.bytes,
-					session->session_close_cb, NULL);
+					mac_ctx->session_close_cb, NULL);
 	return status;
 }
 
@@ -17576,8 +17573,6 @@ static void csr_init_session(struct mac_context *mac, uint32_t sessionId)
 
 	pSession->sessionActive = false;
 	pSession->sessionId = WLAN_UMAC_VDEV_ID_MAX;
-	pSession->callback = NULL;
-	pSession->pContext = NULL;
 	pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
 	csr_saved_scan_cmd_free_fields(mac, pSession);
 	csr_free_roam_profile(mac, sessionId);