Răsfoiți Sursa

qcacld-3.0: Use get/put to refer vdev [2/4]

Any direct reference to adapter->vdev outside the initial
assignment should use get/put to properly refer the vdev.
      core/hdd/src/wlan_hdd_power.c

Change-Id: I68a093c92e57b7076cf4f41e9f69f747f0c7e6ec
CRs-Fixed: 2714025
Paul Zhang 4 ani în urmă
părinte
comite
9ba5a2bc01
1 a modificat fișierele cu 188 adăugiri și 41 ștergeri
  1. 188 41
      core/hdd/src/wlan_hdd_power.c

+ 188 - 41
core/hdd/src/wlan_hdd_power.c

@@ -84,7 +84,7 @@
 #include <wlan_hdd_sar_limits.h>
 #include "wlan_pkt_capture_ucfg_api.h"
 #include "wlan_hdd_thermal.h"
-
+#include "wlan_hdd_object_manager.h"
 /* Preprocessor definitions and constants */
 #ifdef QCA_WIFI_NAPIER_EMULATION
 #define HDD_SSR_BRING_UP_TIME 3000000
@@ -178,10 +178,18 @@ int wlan_hdd_rx_thread_suspend(struct hdd_context *hdd_ctx)
 static void hdd_enable_gtk_offload(struct hdd_adapter *adapter)
 {
 	QDF_STATUS status;
+	struct wlan_objmgr_vdev *vdev;
 
-	status = ucfg_pmo_enable_gtk_offload_in_fwr(adapter->vdev);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+
+	status = ucfg_pmo_enable_gtk_offload_in_fwr(vdev);
 	if (status != QDF_STATUS_SUCCESS)
 		hdd_info("Failed to enable gtk offload");
+	hdd_objmgr_put_vdev(vdev);
 }
 
 /**
@@ -196,6 +204,7 @@ static void hdd_disable_gtk_offload(struct hdd_adapter *adapter)
 {
 	struct pmo_gtk_rsp_req gtk_rsp_request;
 	QDF_STATUS status;
+	struct wlan_objmgr_vdev *vdev;
 
 	/* ensure to get gtk rsp first before disable it*/
 	gtk_rsp_request.callback = wlan_hdd_cfg80211_update_replay_counter_cb;
@@ -203,16 +212,24 @@ static void hdd_disable_gtk_offload(struct hdd_adapter *adapter)
 	/* Passing as void* as PMO does not know legacy HDD adapter type */
 	gtk_rsp_request.callback_context = (void *)adapter;
 
-	status = ucfg_pmo_get_gtk_rsp(adapter->vdev, &gtk_rsp_request);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+
+	status = ucfg_pmo_get_gtk_rsp(vdev, &gtk_rsp_request);
 	if (status != QDF_STATUS_SUCCESS) {
 		hdd_err("Failed to send get gtk rsp status:%d", status);
-		return;
+		goto put_vdev;
 	}
 
 	hdd_debug("send get_gtk_rsp successful");
-	status = ucfg_pmo_disable_gtk_offload_in_fwr(adapter->vdev);
+	status = ucfg_pmo_disable_gtk_offload_in_fwr(vdev);
 	if (status != QDF_STATUS_SUCCESS)
 		hdd_info("Failed to disable gtk offload");
+put_vdev:
+	hdd_objmgr_put_vdev(vdev);
 }
 
 #ifdef WLAN_NS_OFFLOAD
@@ -379,6 +396,7 @@ void hdd_enable_ns_offload(struct hdd_adapter *adapter,
 {
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 	struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc;
+	struct wlan_objmgr_vdev *vdev;
 	struct inet6_dev *in6_dev;
 	struct pmo_ns_req *ns_req;
 	QDF_STATUS status;
@@ -440,15 +458,21 @@ void hdd_enable_ns_offload(struct hdd_adapter *adapter,
 		goto free_req;
 	}
 
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		goto free_req;
+	}
 	/* enable ns request */
-	status = ucfg_pmo_enable_ns_offload_in_fwr(adapter->vdev, trigger);
+	status = ucfg_pmo_enable_ns_offload_in_fwr(vdev, trigger);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("Failed to enable ns offload; status:%d", status);
-		goto free_req;
+		goto put_vdev;
 	}
 
 	hdd_wlan_offload_event(SIR_IPV6_NS_OFFLOAD, SIR_OFFLOAD_ENABLE);
-
+put_vdev:
+	hdd_objmgr_put_vdev(vdev);
 free_req:
 	qdf_mem_free(ns_req);
 
@@ -461,6 +485,7 @@ void hdd_disable_ns_offload(struct hdd_adapter *adapter,
 {
 	QDF_STATUS status;
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter();
 
@@ -471,18 +496,26 @@ void hdd_disable_ns_offload(struct hdd_adapter *adapter,
 		goto out;
 	}
 
-	status = ucfg_pmo_flush_ns_offload_req(adapter->vdev);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		goto out;
+	}
+
+	status = ucfg_pmo_flush_ns_offload_req(vdev);
 	if (status != QDF_STATUS_SUCCESS) {
 		hdd_err("Failed to flush NS Offload");
-		goto out;
+		goto put_vdev;
 	}
 
-	status = ucfg_pmo_disable_ns_offload_in_fwr(adapter->vdev, trigger);
+	status = ucfg_pmo_disable_ns_offload_in_fwr(vdev, trigger);
 	if (status != QDF_STATUS_SUCCESS)
 		hdd_err("Failed to disable NS Offload");
 	else
 		hdd_wlan_offload_event(SIR_IPV6_NS_OFFLOAD,
 			SIR_OFFLOAD_DISABLE);
+put_vdev:
+	hdd_objmgr_put_vdev(vdev);
 out:
 	hdd_exit();
 
@@ -539,70 +572,112 @@ void hdd_ipv6_notifier_work_queue(struct work_struct *work)
 static void hdd_enable_hw_filter(struct hdd_adapter *adapter)
 {
 	QDF_STATUS status;
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter();
 
-	status = ucfg_pmo_enable_hw_filter_in_fwr(adapter->vdev);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+
+	status = ucfg_pmo_enable_hw_filter_in_fwr(vdev);
 	if (status != QDF_STATUS_SUCCESS)
 		hdd_info("Failed to enable hardware filter");
 
+	hdd_objmgr_put_vdev(vdev);
 	hdd_exit();
 }
 
 static void hdd_disable_hw_filter(struct hdd_adapter *adapter)
 {
 	QDF_STATUS status;
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter();
 
-	status = ucfg_pmo_disable_hw_filter_in_fwr(adapter->vdev);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+
+	status = ucfg_pmo_disable_hw_filter_in_fwr(vdev);
 	if (status != QDF_STATUS_SUCCESS)
 		hdd_info("Failed to disable hardware filter");
 
+	hdd_objmgr_put_vdev(vdev);
+
 	hdd_exit();
 }
 
 static void hdd_enable_action_frame_patterns(struct hdd_adapter *adapter)
 {
 	QDF_STATUS status;
-
+	struct wlan_objmgr_vdev *vdev;
 	hdd_enter();
 
-	status = ucfg_pmo_enable_action_frame_patterns(adapter->vdev,
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+
+	status = ucfg_pmo_enable_action_frame_patterns(vdev,
 						       QDF_SYSTEM_SUSPEND);
 	if (QDF_IS_STATUS_ERROR(status))
 		hdd_info("Failed to enable action frame patterns");
 
+	hdd_objmgr_put_vdev(vdev);
+
 	hdd_exit();
 }
 
 static void hdd_disable_action_frame_patterns(struct hdd_adapter *adapter)
 {
 	QDF_STATUS status;
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter();
 
-	status = ucfg_pmo_disable_action_frame_patterns(adapter->vdev);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+
+	status = ucfg_pmo_disable_action_frame_patterns(vdev);
 	if (QDF_IS_STATUS_ERROR(status))
 		hdd_info("Failed to disable action frame patterns");
 
+	hdd_objmgr_put_vdev(vdev);
+
 	hdd_exit();
 }
 
 void hdd_enable_host_offloads(struct hdd_adapter *adapter,
 	enum pmo_offload_trigger trigger)
 {
+	struct wlan_objmgr_vdev *vdev;
+
 	hdd_enter();
 
-	if (!ucfg_pmo_is_vdev_supports_offload(adapter->vdev)) {
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		goto out;
+	}
+
+	if (!ucfg_pmo_is_vdev_supports_offload(vdev)) {
 		hdd_debug("offload is not supported on vdev opmode %d",
 			  adapter->device_mode);
-		goto out;
+		goto put_vdev;
 	}
 
-	if (!ucfg_pmo_is_vdev_connected(adapter->vdev)) {
+	if (!ucfg_pmo_is_vdev_connected(vdev)) {
 		hdd_debug("offload is not supported on disconnected vdevs");
-		goto out;
+		goto put_vdev;
 	}
 
 	hdd_debug("enable offloads");
@@ -613,6 +688,8 @@ void hdd_enable_host_offloads(struct hdd_adapter *adapter,
 	if (adapter->device_mode != QDF_NDI_MODE)
 		hdd_enable_hw_filter(adapter);
 	hdd_enable_action_frame_patterns(adapter);
+put_vdev:
+	hdd_objmgr_put_vdev(vdev);
 out:
 	hdd_exit();
 
@@ -621,17 +698,25 @@ out:
 void hdd_disable_host_offloads(struct hdd_adapter *adapter,
 	enum pmo_offload_trigger trigger)
 {
+	struct wlan_objmgr_vdev *vdev;
+
 	hdd_enter();
 
-	if (!ucfg_pmo_is_vdev_supports_offload(adapter->vdev)) {
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		goto out;
+	}
+
+	if (!ucfg_pmo_is_vdev_supports_offload(vdev)) {
 		hdd_info("offload is not supported on this vdev opmode: %d",
 				adapter->device_mode);
-			goto out;
+			goto put_vdev;
 	}
 
-	if (!ucfg_pmo_is_vdev_connected(adapter->vdev)) {
+	if (!ucfg_pmo_is_vdev_connected(vdev)) {
 		hdd_info("vdev is not connected");
-		goto out;
+		goto put_vdev;
 	}
 
 	hdd_debug("disable offloads");
@@ -641,6 +726,9 @@ void hdd_disable_host_offloads(struct hdd_adapter *adapter,
 	hdd_disable_mc_addr_filtering(adapter, trigger);
 	hdd_disable_hw_filter(adapter);
 	hdd_disable_action_frame_patterns(adapter);
+
+put_vdev:
+	hdd_objmgr_put_vdev(vdev);
 out:
 	hdd_exit();
 
@@ -985,11 +1073,18 @@ void hdd_enable_arp_offload(struct hdd_adapter *adapter,
 	QDF_STATUS status;
 	struct pmo_arp_req *arp_req;
 	struct in_ifaddr *ifa;
+	struct wlan_objmgr_vdev *vdev;
 
 	arp_req = qdf_mem_malloc(sizeof(*arp_req));
 	if (!arp_req)
 		return;
 
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		goto free_req;
+	}
+
 	arp_req->psoc = psoc;
 	arp_req->vdev_id = adapter->vdev_id;
 	arp_req->trigger = trigger;
@@ -997,14 +1092,14 @@ void hdd_enable_arp_offload(struct hdd_adapter *adapter,
 	status = ucfg_pmo_check_arp_offload(psoc, trigger, adapter->vdev_id);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_debug("ARP offload not required");
-		goto free_req;
+		goto put_vdev;
 	}
 
 	ifa = hdd_get_ipv4_local_interface(adapter);
 	if (!ifa || !ifa->ifa_local) {
 		hdd_info("IP Address is not assigned");
 		status = QDF_STATUS_NOT_INITIALIZED;
-		goto free_req;
+		goto put_vdev;
 	}
 
 	arp_req->ipv4_addr = (uint32_t)ifa->ifa_local;
@@ -1012,17 +1107,19 @@ void hdd_enable_arp_offload(struct hdd_adapter *adapter,
 	status = ucfg_pmo_cache_arp_offload_req(arp_req);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("failed to cache arp offload req; status:%d", status);
-		goto free_req;
+		goto put_vdev;
 	}
 
-	status = ucfg_pmo_enable_arp_offload_in_fwr(adapter->vdev, trigger);
+	status = ucfg_pmo_enable_arp_offload_in_fwr(vdev, trigger);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("failed arp offload config in fw; status:%d", status);
-		goto free_req;
+		goto put_vdev;
 	}
 
 	hdd_wlan_offload_event(PMO_IPV4_ARP_REPLY_OFFLOAD, PMO_OFFLOAD_ENABLE);
 
+put_vdev:
+	hdd_objmgr_put_vdev(vdev);
 free_req:
 	qdf_mem_free(arp_req);
 }
@@ -1032,6 +1129,7 @@ void hdd_disable_arp_offload(struct hdd_adapter *adapter,
 {
 	QDF_STATUS status;
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+	struct wlan_objmgr_vdev *vdev;
 
 	status = ucfg_pmo_check_arp_offload(hdd_ctx->psoc, trigger,
 					    adapter->vdev_id);
@@ -1040,19 +1138,26 @@ void hdd_disable_arp_offload(struct hdd_adapter *adapter,
 		return;
 	}
 
-	status = ucfg_pmo_flush_arp_offload_req(adapter->vdev);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_err("vdev is NULL");
+		return;
+	}
+
+	status = ucfg_pmo_flush_arp_offload_req(vdev);
 	if (status != QDF_STATUS_SUCCESS) {
+		hdd_objmgr_put_vdev(vdev);
 		hdd_err("Failed to flush arp Offload");
 		return;
 	}
 
-	status = ucfg_pmo_disable_arp_offload_in_fwr(adapter->vdev,
-						     trigger);
+	status = ucfg_pmo_disable_arp_offload_in_fwr(vdev, trigger);
 	if (status == QDF_STATUS_SUCCESS)
 		hdd_wlan_offload_event(PMO_IPV4_ARP_REPLY_OFFLOAD,
 			PMO_OFFLOAD_DISABLE);
 	else
 		hdd_info("fail to disable arp offload");
+	hdd_objmgr_put_vdev(vdev);
 }
 
 void hdd_enable_mc_addr_filtering(struct hdd_adapter *adapter,
@@ -1308,6 +1413,7 @@ QDF_STATUS hdd_wlan_shutdown(void)
 {
 	struct hdd_context *hdd_ctx;
 	struct hdd_adapter *adapter;
+	struct wlan_objmgr_vdev *vdev;
 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
 
 	hdd_info("WLAN driver shutting down!");
@@ -1338,8 +1444,15 @@ QDF_STATUS hdd_wlan_shutdown(void)
 
 	if (ucfg_pkt_capture_get_mode(hdd_ctx->psoc)) {
 		adapter = hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE);
-		if (adapter)
-			ucfg_pkt_capture_resume_mon_thread(adapter->vdev);
+		if (adapter) {
+			vdev = hdd_objmgr_get_vdev(adapter);
+			if (vdev) {
+				ucfg_pkt_capture_resume_mon_thread(vdev);
+				hdd_objmgr_put_vdev(vdev);
+			} else {
+				hdd_err("vdev is NULL");
+			}
+		}
 	}
 
 	/*
@@ -1688,6 +1801,7 @@ static int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
 	struct hdd_context *hdd_ctx = wiphy_priv(wiphy);
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 	struct hdd_adapter *adapter;
+	struct wlan_objmgr_vdev *vdev;
 	int exit_code;
 
 	hdd_enter();
@@ -1743,8 +1857,15 @@ static int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
 
 	if (ucfg_pkt_capture_get_mode(hdd_ctx->psoc)) {
 		adapter = hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE);
-		if (adapter)
-			ucfg_pkt_capture_resume_mon_thread(adapter->vdev);
+		if (adapter) {
+			vdev = hdd_objmgr_get_vdev(adapter);
+			if (vdev) {
+				ucfg_pkt_capture_resume_mon_thread(vdev);
+				hdd_objmgr_put_vdev(vdev);
+			} else {
+				hdd_err("vdev is NULL");
+			}
+		}
 	}
 
 	qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD,
@@ -1830,6 +1951,7 @@ static int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
 	struct hdd_context *hdd_ctx = wiphy_priv(wiphy);
 	struct hdd_adapter *adapter;
 	mac_handle_t mac_handle;
+	struct wlan_objmgr_vdev *vdev;
 	int rc;
 
 	hdd_enter();
@@ -1958,9 +2080,18 @@ static int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
 
 	if (ucfg_pkt_capture_get_mode(hdd_ctx->psoc)) {
 		adapter = hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE);
-		if (adapter)
-			if (ucfg_pkt_capture_suspend_mon_thread(adapter->vdev))
+		if (adapter) {
+			vdev = hdd_objmgr_get_vdev(adapter);
+			if (!vdev) {
+				hdd_err("vdev is NULL");
+				goto resume_dp_thread;
+			}
+			if (ucfg_pkt_capture_suspend_mon_thread(vdev)) {
+				hdd_objmgr_put_vdev(vdev);
 				goto resume_dp_thread;
+			}
+			hdd_objmgr_put_vdev(vdev);
+		}
 	}
 
 	qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD,
@@ -1984,8 +2115,15 @@ resume_dp_thread:
 	/* Resume packet capture MON thread */
 	if (ucfg_pkt_capture_get_mode(hdd_ctx->psoc)) {
 		adapter = hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE);
-		if (adapter)
-			ucfg_pkt_capture_resume_mon_thread(adapter->vdev);
+		if (adapter) {
+			vdev = hdd_objmgr_get_vdev(adapter);
+			if (vdev) {
+				ucfg_pkt_capture_resume_mon_thread(vdev);
+				hdd_objmgr_put_vdev(vdev);
+			} else {
+				hdd_err("vdev is NULL");
+			}
+		}
 	}
 
 resume_ol_rx:
@@ -2312,7 +2450,16 @@ int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
 static void wlan_hdd_get_tx_power(struct hdd_adapter *adapter, int *dbm)
 
 {
-	wlan_cfg80211_mc_cp_stats_get_tx_power(adapter->vdev, dbm);
+	struct wlan_objmgr_vdev *vdev;
+
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		hdd_info("vdev is NULL");
+		return;
+	}
+
+	wlan_cfg80211_mc_cp_stats_get_tx_power(vdev, dbm);
+	hdd_objmgr_put_vdev(vdev);
 }
 
 #ifdef FEATURE_ANI_LEVEL_REQUEST