Parcourir la source

Merge "qcacld-3.0: Access vdev by reference" into wlan-cld3.driver.lnx.2.0

CNSS_WLAN Service il y a 4 ans
Parent
commit
b4bc49ee69

+ 21 - 9
core/hdd/src/wlan_hdd_cfg80211.c

@@ -17428,6 +17428,7 @@ static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy,
 	struct qdf_mac_addr bssid = QDF_MAC_ADDR_BCAST_INIT;
 	struct hdd_ap_ctx *ap_ctx;
 	struct wlan_crypto_key *crypto_key;
+	struct wlan_objmgr_vdev *vdev;
 	int ret;
 	QDF_STATUS status;
 
@@ -17457,20 +17458,28 @@ static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy,
 
 	if (0 != ret)
 		return ret;
-	crypto_key = wlan_crypto_get_key(adapter->vdev, key_index);
+
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return -EINVAL;
+
+	crypto_key = wlan_crypto_get_key(vdev, key_index);
 	if (!crypto_key) {
 		hdd_err("Invalid NULL key info");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 	hdd_debug("unicast %d, multicast %d cipher %d",
 		  unicast, multicast, crypto_key->cipher_type);
-	if (!IS_WEP_CIPHER(crypto_key->cipher_type))
-		return 0;
+	if (!IS_WEP_CIPHER(crypto_key->cipher_type)) {
+		ret = 0;
+		goto out;
+	}
 
 	if ((adapter->device_mode == QDF_STA_MODE) ||
 	    (adapter->device_mode == QDF_P2P_CLIENT_MODE)) {
 		ret =
-		wlan_cfg80211_crypto_add_key(adapter->vdev, (unicast ?
+		wlan_cfg80211_crypto_add_key(vdev, (unicast ?
 					     WLAN_CRYPTO_KEY_TYPE_UNICAST :
 					     WLAN_CRYPTO_KEY_TYPE_GROUP),
 					     key_index);
@@ -17480,16 +17489,19 @@ static int __wlan_hdd_cfg80211_set_default_key(struct wiphy *wiphy,
 
 	if (adapter->device_mode == QDF_SAP_MODE ||
 	    adapter->device_mode == QDF_P2P_GO_MODE) {
-		status = wlan_cfg80211_set_default_key(adapter->vdev, key_index,
+		status = wlan_cfg80211_set_default_key(vdev, key_index,
 						       &bssid);
 		if (QDF_IS_STATUS_ERROR(status)) {
 			hdd_err("ret fail status %d", ret);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto out;
 		}
 		ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
 		ap_ctx->wep_def_key_idx = key_index;
 	}
 
+out:
+	hdd_objmgr_put_vdev(vdev);
 	return ret;
 }
 
@@ -21419,7 +21431,7 @@ static QDF_STATUS wlan_hdd_del_pmksa_cache(struct hdd_adapter *adapter,
 		return QDF_STATUS_E_FAILURE;
 
 	qdf_copy_macaddr(&pmksa.bssid, &pmk_cache->BSSID);
-	result = wlan_crypto_set_del_pmksa(adapter->vdev, &pmksa, false);
+	result = wlan_crypto_set_del_pmksa(vdev, &pmksa, false);
 	hdd_objmgr_put_vdev(vdev);
 
 	return result;
@@ -21434,7 +21446,7 @@ QDF_STATUS wlan_hdd_flush_pmksa_cache(struct hdd_adapter *adapter)
 	if (!vdev)
 		return QDF_STATUS_E_FAILURE;
 
-	result = wlan_crypto_set_del_pmksa(adapter->vdev, NULL, false);
+	result = wlan_crypto_set_del_pmksa(vdev, NULL, false);
 	hdd_objmgr_put_vdev(vdev);
 
 	return result;

+ 7 - 8
core/hdd/src/wlan_hdd_cfr.c

@@ -28,6 +28,7 @@
 #include "osif_sync.h"
 #include "wlan_hdd_cfr.h"
 #include "wlan_cfr_ucfg_api.h"
+#include "wlan_hdd_object_manager.h"
 
 const struct nla_policy cfr_config_policy[
 		QCA_WLAN_VENDOR_ATTR_PEER_CFR_MAX + 1] = {
@@ -401,7 +402,6 @@ wlan_cfg80211_peer_enh_cfr_capture(struct hdd_adapter *adapter,
 	struct cfr_wlanconfig_param params = { 0 };
 	struct wlan_objmgr_vdev *vdev;
 	bool is_start_capture = false;
-	QDF_STATUS status;
 	int ret = 0;
 
 	if (tb[QCA_WLAN_VENDOR_ATTR_PEER_CFR_ENABLE]) {
@@ -415,19 +415,17 @@ wlan_cfg80211_peer_enh_cfr_capture(struct hdd_adapter *adapter,
 		return -EINVAL;
 	}
 
-	vdev = adapter->vdev;
-	status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_CFR_ID);
-	if (QDF_IS_STATUS_ERROR(status)) {
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
 		hdd_err("can't get vdev");
-		return qdf_status_to_os_return(status);
+		return -EINVAL;
 	}
 
 	if (is_start_capture) {
 		ret = wlan_cfg80211_cfr_set_config(vdev, tb);
 		if (ret) {
 			hdd_err("set config failed");
-			wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
-			return ret;
+			goto out;
 		}
 		params.en_cfg = nla_get_u32(tb[
 			QCA_WLAN_VENDOR_ATTR_PEER_CFR_ENABLE_GROUP_BITMAP]);
@@ -445,7 +443,8 @@ wlan_cfg80211_peer_enh_cfr_capture(struct hdd_adapter *adapter,
 		hdd_debug("stop indication done");
 	}
 
-	wlan_objmgr_vdev_release_ref(vdev, WLAN_CFR_ID);
+out:
+	hdd_objmgr_put_vdev(vdev);
 	return ret;
 }
 #else

+ 16 - 5
core/hdd/src/wlan_hdd_debugfs_offload.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2020 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
@@ -33,6 +33,7 @@
 #include "wlan_pmo_ns_public_struct.h"
 #include "wlan_pmo_mc_addr_filtering_public_struct.h"
 #include "wlan_pmo_ucfg_api.h"
+#include "wlan_hdd_object_manager.h"
 
 /* IPv6 address string */
 #define IPV6_MAC_ADDRESS_STR_LEN 47  /* Including null terminator */
@@ -136,10 +137,15 @@ wlan_hdd_arp_offload_info_debugfs(struct hdd_context *hdd_ctx,
 	ssize_t length = 0;
 	int ret_val;
 	struct pmo_arp_offload_params info = {0};
+	struct wlan_objmgr_vdev *vdev;
 	QDF_STATUS status;
 
-	status = ucfg_pmo_get_arp_offload_params(adapter->vdev,
-						 &info);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return 0;
+
+	status = ucfg_pmo_get_arp_offload_params(vdev, &info);
+	hdd_objmgr_put_vdev(vdev);
 	if (!QDF_IS_STATUS_SUCCESS(status)) {
 		ret_val = scnprintf(buf, buf_avail_len,
 				    "\nARP OFFLOAD QUERY FAILED\n");
@@ -225,11 +231,16 @@ wlan_hdd_ns_offload_info_debugfs(struct hdd_context *hdd_ctx,
 	ssize_t length = 0;
 	int ret;
 	struct pmo_ns_offload_params info = {0};
+	struct wlan_objmgr_vdev *vdev;
 	QDF_STATUS status;
 	uint32_t i;
 
-	status = ucfg_pmo_get_ns_offload_params(adapter->vdev,
-						&info);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return 0;
+
+	status = ucfg_pmo_get_ns_offload_params(vdev, &info);
+	hdd_objmgr_put_vdev(vdev);
 	if (!QDF_IS_STATUS_SUCCESS(status)) {
 		ret = scnprintf(buf, buf_avail_len,
 				"\nNS OFFLOAD QUERY FAILED\n");

+ 19 - 5
core/hdd/src/wlan_hdd_ftm_time_sync.c

@@ -16,12 +16,14 @@
 
 #include "wlan_hdd_ftm_time_sync.h"
 #include "ftm_time_sync_ucfg_api.h"
+#include "wlan_hdd_object_manager.h"
 
 static ssize_t hdd_ftm_time_sync_show(struct device *dev,
 				      struct device_attribute *attr, char *buf)
 {
 	struct hdd_station_ctx *hdd_sta_ctx;
 	struct hdd_adapter *adapter;
+	struct wlan_objmgr_vdev *vdev;
 	ssize_t size = 0;
 
 	struct net_device *net_dev = qdf_container_of(dev, struct net_device,
@@ -32,9 +34,14 @@ static ssize_t hdd_ftm_time_sync_show(struct device *dev,
 		return scnprintf(buf, PAGE_SIZE, "Invalid device\n");
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return -EINVAL;
+
 	if (adapter->device_mode == QDF_STA_MODE)
-		return ucfg_ftm_time_sync_show(adapter->vdev, buf);
+		size = ucfg_ftm_time_sync_show(vdev, buf);
 
+	hdd_objmgr_put_vdev(vdev);
 	return size;
 }
 
@@ -47,13 +54,18 @@ hdd_ftm_time_sync_sta_state_notify(struct hdd_adapter *adapter,
 	struct hdd_station_ctx *hdd_sta_ctx;
 	struct wlan_objmgr_psoc *psoc;
 	struct net_device *net_dev;
+	struct wlan_objmgr_vdev *vdev;
 
-	psoc = wlan_vdev_get_psoc(adapter->vdev);
-	if (!psoc)
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
 		return;
 
+	psoc = wlan_vdev_get_psoc(vdev);
+	if (!psoc)
+		goto out;
+
 	if (!ucfg_is_ftm_time_sync_enable(psoc))
-		return;
+		goto out;
 
 	net_dev = adapter->dev;
 
@@ -68,6 +80,8 @@ hdd_ftm_time_sync_sta_state_notify(struct hdd_adapter *adapter,
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 	ucfg_ftm_time_sync_update_sta_connect_state(
-						adapter->vdev, state,
+						vdev, state,
 						hdd_sta_ctx->conn_info.bssid);
+out:
+	hdd_objmgr_put_vdev(vdev);
 }

+ 9 - 1
core/hdd/src/wlan_hdd_hostapd_wext.c

@@ -45,6 +45,8 @@
 #include "wlan_mlme_ucfg_api.h"
 #include "wlan_reg_ucfg_api.h"
 #include "wlan_hdd_sta_info.h"
+#include "wlan_hdd_object_manager.h"
+
 #define WE_WLAN_VERSION     1
 
 /* WEXT limitation: MAX allowed buf len for any *
@@ -2574,6 +2576,7 @@ __iw_get_peer_rssi(struct net_device *dev, struct iw_request_info *info,
 	char macaddrarray[MAC_ADDRESS_STR_LEN];
 	struct hdd_adapter *adapter = netdev_priv(dev);
 	struct qdf_mac_addr macaddress = QDF_MAC_ADDR_BCAST_INIT;
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter();
 
@@ -2603,9 +2606,14 @@ __iw_get_peer_rssi(struct net_device *dev, struct iw_request_info *info,
 			hdd_err("String to Hex conversion Failed");
 	}
 
-	rssi_info = wlan_cfg80211_mc_cp_stats_get_peer_rssi(adapter->vdev,
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return -EINVAL;
+
+	rssi_info = wlan_cfg80211_mc_cp_stats_get_peer_rssi(vdev,
 							    macaddress.bytes,
 							    &ret);
+	hdd_objmgr_put_vdev(vdev);
 	if (ret || !rssi_info) {
 		wlan_cfg80211_mc_cp_stats_free_stats_event(rssi_info);
 		return ret;

+ 13 - 7
core/hdd/src/wlan_hdd_main.c

@@ -5035,10 +5035,9 @@ int hdd_vdev_destroy(struct hdd_adapter *adapter)
 	ucfg_pmo_del_wow_pattern(vdev);
 	status = ucfg_reg_11d_vdev_delete_update(vdev);
 	ucfg_scan_vdev_set_disable(vdev, REASON_VDEV_DOWN);
-	hdd_objmgr_put_vdev(vdev);
-
 	/* Disable serialization for vdev before sending vdev delete */
-	wlan_ser_vdev_queue_disable(adapter->vdev);
+	wlan_ser_vdev_queue_disable(vdev);
+	hdd_objmgr_put_vdev(vdev);
 
 	qdf_spin_lock_bh(&adapter->vdev_lock);
 	adapter->vdev = NULL;
@@ -5086,7 +5085,7 @@ hdd_store_nss_chains_cfg_in_vdev(struct hdd_adapter *adapter)
 	vdev = hdd_objmgr_get_vdev(adapter);
 	/* Store the nss chain config into the vdev */
 	if (vdev) {
-		sme_store_nss_chains_cfg_in_vdev(adapter->vdev, &vdev_ini_cfg);
+		sme_store_nss_chains_cfg_in_vdev(vdev, &vdev_ini_cfg);
 		hdd_objmgr_put_vdev(vdev);
 	} else {
 		hdd_err("Vdev is NULL");
@@ -5257,7 +5256,7 @@ int hdd_vdev_create(struct hdd_adapter *adapter)
 		wlan_vdev_set_max_peer_count(vdev, HDD_MAX_VDEV_PEER_COUNT);
 		ucfg_mlme_get_bigtk_support(hdd_ctx->psoc, &target_bigtk_support);
 		if (target_bigtk_support)
-			mlme_set_bigtk_support(adapter->vdev, true);
+			mlme_set_bigtk_support(vdev, true);
 		hdd_objmgr_put_vdev(vdev);
 	}
 
@@ -7795,6 +7794,7 @@ QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx)
 	eConnectionState conn_state;
 	bool value;
 	uint8_t chan;
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter();
 
@@ -7884,10 +7884,16 @@ QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx)
 			if (wlan_hdd_is_session_type_monitor(
 			    QDF_MONITOR_MODE) &&
 			    ucfg_pkt_capture_get_mode(hdd_ctx->psoc)) {
-				ucfg_pkt_capture_register_callbacks(
-						adapter->vdev,
+				vdev = hdd_objmgr_get_vdev(adapter);
+				if (vdev) {
+					ucfg_pkt_capture_register_callbacks(
+						vdev,
 						hdd_mon_rx_packet_cbk,
 						adapter);
+					hdd_objmgr_put_vdev(vdev);
+				} else {
+					hdd_err("vdev is null");
+				}
 				break;
 			}
 			chan = wlan_reg_freq_to_chan(hdd_ctx->pdev,

+ 74 - 9
core/hdd/src/wlan_hdd_ocb.c

@@ -42,6 +42,7 @@
 #include <cdp_txrx_handle.h>
 #include <cdp_txrx_ocb.h>
 #include "ol_txrx.h"
+#include "wlan_hdd_object_manager.h"
 
 /* Structure definitions for WLAN_SET_DOT11P_CHANNEL_SCHED */
 #define AIFSN_MIN		(2)
@@ -368,6 +369,7 @@ static int hdd_ocb_set_config_req(struct hdd_adapter *adapter,
 		.priv_size = sizeof(*priv),
 		.timeout_ms = WLAN_WAIT_TIME_OCB_CMD,
 	};
+	struct wlan_objmgr_vdev *vdev;
 
 	if (hdd_ocb_validate_config(adapter, config)) {
 		hdd_err("The configuration is invalid");
@@ -381,14 +383,21 @@ static int hdd_ocb_set_config_req(struct hdd_adapter *adapter,
 	}
 	cookie = osif_request_cookie(request);
 
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		rc = -EINVAL;
+		goto end;
+	}
+
 	hdd_debug("Disabling queues");
 	wlan_hdd_netif_queue_control(adapter,
 				     WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
 				     WLAN_CONTROL_PATH);
 
-	status = ucfg_ocb_set_channel_config(adapter->vdev, config,
+	status = ucfg_ocb_set_channel_config(vdev, config,
 					     hdd_ocb_set_config_callback,
 					     cookie);
+	hdd_objmgr_put_vdev(vdev);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("Failed to set channel config.");
 		rc = qdf_status_to_os_return(status);
@@ -966,6 +975,7 @@ static int __wlan_hdd_cfg80211_ocb_set_utc_time(struct wiphy *wiphy,
 	struct nlattr *utc_attr;
 	struct nlattr *time_error_attr;
 	struct ocb_utc_param *utc;
+	struct wlan_objmgr_vdev *vdev;
 	int rc = -EINVAL;
 
 	hdd_enter_dev(dev);
@@ -1024,14 +1034,21 @@ static int __wlan_hdd_cfg80211_ocb_set_utc_time(struct wiphy *wiphy,
 	qdf_mem_copy(utc->time_error, nla_data(time_error_attr),
 		SIZE_UTC_TIME_ERROR);
 
-	if (ucfg_ocb_set_utc_time(adapter->vdev, utc) !=
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		rc = -EINVAL;
+		goto out;
+	}
+
+	if (ucfg_ocb_set_utc_time(vdev, utc) !=
 			QDF_STATUS_SUCCESS) {
 		hdd_err("Error while setting UTC time");
 		rc = -EINVAL;
 	} else {
 		rc = 0;
 	}
-
+	hdd_objmgr_put_vdev(vdev);
+out:
 	qdf_mem_free(utc);
 	return rc;
 }
@@ -1085,6 +1102,7 @@ __wlan_hdd_cfg80211_ocb_start_timing_advert(struct wiphy *wiphy,
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
 	struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_OCB_START_TIMING_ADVERT_MAX + 1];
 	struct ocb_timing_advert_param *timing_advert;
+	struct wlan_objmgr_vdev *vdev;
 	int rc = -EINVAL;
 
 	hdd_enter_dev(dev);
@@ -1143,13 +1161,20 @@ __wlan_hdd_cfg80211_ocb_start_timing_advert(struct wiphy *wiphy,
 		goto fail;
 	}
 
-	if (ucfg_ocb_start_timing_advert(adapter->vdev, timing_advert) !=
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		rc = -EINVAL;
+		goto fail;
+	}
+
+	if (ucfg_ocb_start_timing_advert(vdev, timing_advert) !=
 			QDF_STATUS_SUCCESS) {
 		hdd_err("Error while starting timing advert");
 		rc = -EINVAL;
 	} else {
 		rc = 0;
 	}
+	hdd_objmgr_put_vdev(vdev);
 
 fail:
 	if (timing_advert->template_value)
@@ -1207,6 +1232,7 @@ __wlan_hdd_cfg80211_ocb_stop_timing_advert(struct wiphy *wiphy,
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
 	struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_OCB_STOP_TIMING_ADVERT_MAX + 1];
 	struct ocb_timing_advert_param *timing_advert;
+	struct wlan_objmgr_vdev *vdev;
 	int rc = -EINVAL;
 
 	hdd_enter_dev(dev);
@@ -1247,13 +1273,20 @@ __wlan_hdd_cfg80211_ocb_stop_timing_advert(struct wiphy *wiphy,
 	timing_advert->chan_freq = nla_get_u32(
 		tb[QCA_WLAN_VENDOR_ATTR_OCB_STOP_TIMING_ADVERT_CHANNEL_FREQ]);
 
-	if (ucfg_ocb_stop_timing_advert(adapter->vdev, timing_advert) !=
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		rc = -EINVAL;
+		goto fail;
+	}
+
+	if (ucfg_ocb_stop_timing_advert(vdev, timing_advert) !=
 			QDF_STATUS_SUCCESS) {
 		hdd_err("Error while stopping timing advert");
 		rc = -EINVAL;
 	} else {
 		rc = 0;
 	}
+	hdd_objmgr_put_vdev(vdev);
 
 fail:
 	qdf_mem_free(timing_advert);
@@ -1394,6 +1427,7 @@ __wlan_hdd_cfg80211_ocb_get_tsf_timer(struct wiphy *wiphy,
 		.priv_size = sizeof(*priv),
 		.timeout_ms = WLAN_WAIT_TIME_OCB_CMD,
 	};
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter_dev(dev);
 
@@ -1418,10 +1452,17 @@ __wlan_hdd_cfg80211_ocb_get_tsf_timer(struct wiphy *wiphy,
 	}
 	cookie = osif_request_cookie(request);
 
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		rc = -EINVAL;
+		goto end;
+	}
+
 	tsf_request.vdev_id = adapter->vdev_id;
-	status = ucfg_ocb_get_tsf_timer(adapter->vdev, &tsf_request,
+	status = ucfg_ocb_get_tsf_timer(vdev, &tsf_request,
 					hdd_ocb_get_tsf_timer_callback,
 					cookie);
+	hdd_objmgr_put_vdev(vdev);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("Failed to get tsf timer.");
 		rc = qdf_status_to_os_return(status);
@@ -1622,6 +1663,7 @@ static int __wlan_hdd_cfg80211_dcc_get_stats(struct wiphy *wiphy,
 		.timeout_ms = WLAN_WAIT_TIME_OCB_CMD,
 		.dealloc = hdd_dcc_get_stats_dealloc,
 	};
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter_dev(dev);
 
@@ -1679,9 +1721,16 @@ static int __wlan_hdd_cfg80211_dcc_get_stats(struct wiphy *wiphy,
 	dcc_request.request_array_len = request_array_len;
 	dcc_request.request_array = request_array;
 
-	status = ucfg_ocb_dcc_get_stats(adapter->vdev, &dcc_request,
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		rc = -EINVAL;
+		goto end;
+	}
+
+	status = ucfg_ocb_dcc_get_stats(vdev, &dcc_request,
 					hdd_dcc_get_stats_callback,
 					cookie);
+	hdd_objmgr_put_vdev(vdev);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("Failed to get DCC stats.");
 		rc = qdf_status_to_os_return(status);
@@ -1762,6 +1811,7 @@ static int __wlan_hdd_cfg80211_dcc_clear_stats(struct wiphy *wiphy,
 	struct net_device *dev = wdev->netdev;
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
 	struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_DCC_CLEAR_STATS_MAX + 1];
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter_dev(dev);
 
@@ -1793,13 +1843,20 @@ static int __wlan_hdd_cfg80211_dcc_clear_stats(struct wiphy *wiphy,
 		return -EINVAL;
 	}
 
-	if (ucfg_ocb_dcc_clear_stats(adapter->vdev, adapter->vdev_id,
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return -EINVAL;
+
+	if (ucfg_ocb_dcc_clear_stats(
+		vdev, adapter->vdev_id,
 		nla_get_u32(
 			tb[QCA_WLAN_VENDOR_ATTR_DCC_CLEAR_STATS_BITMAP])) !=
 			QDF_STATUS_SUCCESS) {
 		hdd_err("Failed to clear DCC stats.");
+		hdd_objmgr_put_vdev(vdev);
 		return -EINVAL;
 	}
+	hdd_objmgr_put_vdev(vdev);
 
 	return 0;
 }
@@ -1897,6 +1954,7 @@ static int __wlan_hdd_cfg80211_dcc_update_ndl(struct wiphy *wiphy,
 		.priv_size = sizeof(*priv),
 		.timeout_ms = WLAN_WAIT_TIME_OCB_CMD,
 	};
+	struct wlan_objmgr_vdev *vdev;
 
 	hdd_enter_dev(dev);
 
@@ -1962,9 +2020,16 @@ static int __wlan_hdd_cfg80211_dcc_update_ndl(struct wiphy *wiphy,
 	dcc_request.dcc_ndl_active_state_list_len = ndl_active_state_array_len;
 	dcc_request.dcc_ndl_active_state_list = ndl_active_state_array;
 
-	status = ucfg_ocb_dcc_update_ndl(adapter->vdev, &dcc_request,
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		rc = -EINVAL;
+		goto end;
+	}
+
+	status = ucfg_ocb_dcc_update_ndl(vdev, &dcc_request,
 					 hdd_dcc_update_ndl_callback,
 					 cookie);
+	hdd_objmgr_put_vdev(vdev);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("Failed to update NDL.");
 		rc = qdf_status_to_os_return(status);

+ 8 - 2
core/hdd/src/wlan_hdd_spectralscan.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2020 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
@@ -34,6 +34,7 @@
 #include "wlan_hdd_spectralscan.h"
 #include <wlan_spectral_ucfg_api.h>
 #include "wma.h"
+#include "wlan_hdd_object_manager.h"
 #ifdef CNSS_GENL
 #include <net/cnss_nl.h>
 #endif
@@ -584,6 +585,7 @@ QDF_STATUS wlan_spectral_update_rx_chainmask(struct hdd_adapter *adapter)
 	uint32_t chainmask;
 	uint8_t home_chan;
 	uint8_t pdev_id;
+	struct wlan_objmgr_vdev *vdev;
 
 	spectral_get_version(adapter->hdd_ctx->pdev, &version, &sub_version);
 	if (version != SPECTRAL_VERSION_3)
@@ -593,7 +595,11 @@ QDF_STATUS wlan_spectral_update_rx_chainmask(struct hdd_adapter *adapter)
 	pdev_id = wlan_objmgr_pdev_get_pdev_id(adapter->hdd_ctx->pdev);
 	wma_get_rx_chainmask(pdev_id, &chainmask_2g, &chainmask_5g);
 	chainmask = home_chan > MAX_24GHZ_CHANNEL ? chainmask_5g : chainmask_2g;
-	wlan_vdev_mlme_set_rxchainmask(adapter->vdev, chainmask);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return QDF_STATUS_E_FAILURE;
+	wlan_vdev_mlme_set_rxchainmask(vdev, chainmask);
+	hdd_objmgr_put_vdev(vdev);
 
 	return QDF_STATUS_SUCCESS;
 }

+ 44 - 18
core/hdd/src/wlan_hdd_stats.c

@@ -44,6 +44,7 @@
 #include "wlan_hdd_sta_info.h"
 #include "cdp_txrx_misc.h"
 #include "cdp_txrx_host_stats.h"
+#include "wlan_hdd_object_manager.h"
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) && !defined(WITH_BACKPORTS)
 #define HDD_INFO_SIGNAL                 STATION_INFO_SIGNAL
@@ -4778,6 +4779,7 @@ static int wlan_hdd_get_sta_stats(struct wiphy *wiphy,
 	int link_speed_rssi_mid = 0;
 	int link_speed_rssi_low = 0;
 	uint32_t link_speed_rssi_report = 0;
+	struct wlan_objmgr_vdev *vdev;
 
 	qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD,
 		   TRACE_CODE_HDD_CFG80211_GET_STA,
@@ -4909,13 +4911,18 @@ static int wlan_hdd_get_sta_stats(struct wiphy *wiphy,
 		bool tx_rate_calc, rx_rate_calc;
 		uint8_t tx_nss_max, rx_nss_max;
 
+		vdev = hdd_objmgr_get_vdev(adapter);
+		if (!vdev)
+			/* Keep GUI happy */
+			return 0;
 		/*
 		 * Take static NSS for reporting max rates. NSS from the FW
 		 * is not reliable as it changes as per the environment
 		 * quality.
 		 */
-		tx_nss_max = wlan_vdev_mlme_get_nss(adapter->vdev);
-		rx_nss_max = wlan_vdev_mlme_get_nss(adapter->vdev);
+		tx_nss_max = wlan_vdev_mlme_get_nss(vdev);
+		rx_nss_max = wlan_vdev_mlme_get_nss(vdev);
+		hdd_objmgr_put_vdev(vdev);
 
 		hdd_check_and_update_nss(hdd_ctx, &tx_nss_max, &rx_nss_max);
 
@@ -5621,15 +5628,19 @@ QDF_STATUS wlan_hdd_get_mib_stats(struct hdd_adapter *adapter)
 {
 	int ret = 0;
 	struct stats_event *stats;
+	struct wlan_objmgr_vdev *vdev;
 
 	if (!adapter) {
 		hdd_err("Invalid context, adapter");
 		return QDF_STATUS_E_FAULT;
 	}
 
-	stats = wlan_cfg80211_mc_cp_stats_get_mib_stats(
-			adapter->vdev,
-			&ret);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return QDF_STATUS_E_FAULT;
+
+	stats = wlan_cfg80211_mc_cp_stats_get_mib_stats(vdev, &ret);
+	hdd_objmgr_put_vdev(vdev);
 	if (ret || !stats) {
 		wlan_cfg80211_mc_cp_stats_free_stats_event(stats);
 		return ret;
@@ -5647,6 +5658,7 @@ QDF_STATUS wlan_hdd_get_rssi(struct hdd_adapter *adapter, int8_t *rssi_value)
 	int ret = 0, i;
 	struct hdd_station_ctx *sta_ctx;
 	struct stats_event *rssi_info;
+	struct wlan_objmgr_vdev *vdev;
 
 	if (!adapter) {
 		hdd_err("Invalid context, adapter");
@@ -5675,10 +5687,17 @@ QDF_STATUS wlan_hdd_get_rssi(struct hdd_adapter *adapter, int8_t *rssi_value)
 		return QDF_STATUS_SUCCESS;
 	}
 
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev) {
+		*rssi_value = adapter->rssi;
+		return QDF_STATUS_SUCCESS;
+	}
+
 	rssi_info = wlan_cfg80211_mc_cp_stats_get_peer_rssi(
-			adapter->vdev,
+			vdev,
 			sta_ctx->conn_info.bssid.bytes,
 			&ret);
+	hdd_objmgr_put_vdev(vdev);
 	if (ret || !rssi_info) {
 		wlan_cfg80211_mc_cp_stats_free_stats_event(rssi_info);
 		return ret;
@@ -6041,12 +6060,16 @@ int wlan_hdd_get_station_stats(struct hdd_adapter *adapter)
 	struct stats_event *stats;
 	struct wlan_mlme_nss_chains *dynamic_cfg;
 	uint32_t tx_nss, rx_nss;
+	struct wlan_objmgr_vdev *vdev;
 
-	stats = wlan_cfg80211_mc_cp_stats_get_station_stats(adapter->vdev,
-							    &ret);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return -EINVAL;
+
+	stats = wlan_cfg80211_mc_cp_stats_get_station_stats(vdev, &ret);
 	if (ret || !stats) {
 		wlan_cfg80211_mc_cp_stats_free_stats_event(stats);
-		return ret;
+		goto out;
 	}
 
 	/* save summary stats to legacy location */
@@ -6087,11 +6110,12 @@ int wlan_hdd_get_station_stats(struct hdd_adapter *adapter)
 	adapter->hdd_stats.peer_stats.fcs_count =
 		stats->peer_adv_stats->fcs_count;
 
-	dynamic_cfg = mlme_get_dynamic_vdev_config(adapter->vdev);
+	dynamic_cfg = mlme_get_dynamic_vdev_config(vdev);
 	if (!dynamic_cfg) {
 		hdd_err("nss chain dynamic config NULL");
 		wlan_cfg80211_mc_cp_stats_free_stats_event(stats);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	switch (hdd_conn_get_connected_band(&adapter->session.station)) {
@@ -6104,15 +6128,15 @@ int wlan_hdd_get_station_stats(struct hdd_adapter *adapter)
 		rx_nss = dynamic_cfg->rx_nss[NSS_CHAINS_BAND_5GHZ];
 		break;
 	default:
-		tx_nss = wlan_vdev_mlme_get_nss(adapter->vdev);
-		rx_nss = wlan_vdev_mlme_get_nss(adapter->vdev);
+		tx_nss = wlan_vdev_mlme_get_nss(vdev);
+		rx_nss = wlan_vdev_mlme_get_nss(vdev);
 	}
 	/* Intersection of self and AP's NSS capability */
-	if (tx_nss > wlan_vdev_mlme_get_nss(adapter->vdev))
-		tx_nss = wlan_vdev_mlme_get_nss(adapter->vdev);
+	if (tx_nss > wlan_vdev_mlme_get_nss(vdev))
+		tx_nss = wlan_vdev_mlme_get_nss(vdev);
 
-	if (rx_nss > wlan_vdev_mlme_get_nss(adapter->vdev))
-		rx_nss = wlan_vdev_mlme_get_nss(adapter->vdev);
+	if (rx_nss > wlan_vdev_mlme_get_nss(vdev))
+		rx_nss = wlan_vdev_mlme_get_nss(vdev);
 
 	/* save class a stats to legacy location */
 	adapter->hdd_stats.class_a_stat.tx_nss = tx_nss;
@@ -6142,7 +6166,9 @@ int wlan_hdd_get_station_stats(struct hdd_adapter *adapter)
 		     sizeof(stats->vdev_chain_rssi[0].chain_rssi));
 	wlan_cfg80211_mc_cp_stats_free_stats_event(stats);
 
-	return 0;
+out:
+	hdd_objmgr_put_vdev(vdev);
+	return ret;
 }
 
 struct temperature_priv {

+ 8 - 1
core/hdd/src/wlan_hdd_tx_rx.c

@@ -71,6 +71,7 @@
 #include "nan_public_structs.h"
 #include "nan_ucfg_api.h"
 #include <wlan_hdd_sar_limits.h>
+#include "wlan_hdd_object_manager.h"
 
 #if defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(QCA_LL_PDEV_TX_FLOW_CONTROL)
 /*
@@ -855,8 +856,14 @@ void hdd_tx_rx_collect_connectivity_stats_info(struct sk_buff *skb,
 static bool hdd_is_xmit_allowed_on_ndi(struct hdd_adapter *adapter)
 {
 	enum nan_datapath_state state;
+	struct wlan_objmgr_vdev *vdev;
+
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return false;
 
-	state = ucfg_nan_get_ndi_state(adapter->vdev);
+	state = ucfg_nan_get_ndi_state(vdev);
+	hdd_objmgr_put_vdev(vdev);
 	return (state == NAN_DATA_NDI_CREATED_STATE ||
 		state == NAN_DATA_CONNECTED_STATE ||
 		state == NAN_DATA_CONNECTING_STATE ||

+ 5 - 1
core/hdd/src/wlan_hdd_wmm.c

@@ -57,6 +57,7 @@
 #include "sme_api.h"
 #include "wlan_mlme_ucfg_api.h"
 #include "cfg_ucfg_api.h"
+#include "wlan_hdd_object_manager.h"
 
 #define HDD_WMM_UP_TO_AC_MAP_SIZE 8
 #define DSCP(x)	x
@@ -1521,12 +1522,15 @@ static void hdd_wmm_do_implicit_qos(struct work_struct *work)
 QDF_STATUS hdd_send_dscp_up_map_to_fw(struct hdd_adapter *adapter)
 {
 	uint32_t *dscp_to_up_map = adapter->dscp_to_up_map;
-	struct wlan_objmgr_vdev *vdev = adapter->vdev;
+	struct wlan_objmgr_vdev *vdev;
 	int ret;
 
+	vdev = hdd_objmgr_get_vdev(adapter);
+
 	if (vdev) {
 		/* Send DSCP to TID map table to FW */
 		ret = os_if_fwol_send_dscp_up_map_to_fw(vdev, dscp_to_up_map);
+		hdd_objmgr_put_vdev(vdev);
 		if (ret && ret != -EOPNOTSUPP)
 			return QDF_STATUS_E_FAILURE;
 	}

+ 32 - 8
core/hdd/src/wlan_hdd_wowl.c

@@ -28,6 +28,7 @@
 #include <wlan_hdd_includes.h>
 #include <wlan_hdd_wowl.h>
 #include <wlan_pmo_wow_public_struct.h>
+#include "wlan_hdd_object_manager.h"
 
 /* Preprocessor Definitions and Constants */
 #define WOWL_INTER_PTRN_TOKENIZER   ';'
@@ -106,6 +107,7 @@ bool hdd_add_wowl_ptrn(struct hdd_adapter *adapter, const char *ptrn)
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 	uint8_t num_filters;
 	bool invalid_ptrn = false;
+	struct wlan_objmgr_vdev *vdev;
 
 	status = hdd_get_num_wow_filters(hdd_ctx, &num_filters);
 	if (QDF_IS_STATUS_ERROR(status))
@@ -224,9 +226,15 @@ bool hdd_add_wowl_ptrn(struct hdd_adapter *adapter, const char *ptrn)
 		wow_pattern.pattern_id = empty_slot;
 		wow_pattern.pattern_byte_offset = 0;
 
+		vdev = hdd_objmgr_get_vdev(adapter);
+		if (!vdev) {
+			hdd_err("vdev is null");
+			qdf_mem_free(g_hdd_wowl_ptrns[empty_slot]);
+			g_hdd_wowl_ptrns[empty_slot] = NULL;
+			return false;
+		}
 		/* Register the pattern downstream */
-		status = ucfg_pmo_add_wow_user_pattern(
-					adapter->vdev, &wow_pattern);
+		status = ucfg_pmo_add_wow_user_pattern(vdev, &wow_pattern);
 		if (QDF_IS_STATUS_ERROR(status)) {
 			/* Add failed, so invalidate the local storage */
 			hdd_err("sme_wowl_add_bcast_pattern failed with error code (%d)",
@@ -234,7 +242,7 @@ bool hdd_add_wowl_ptrn(struct hdd_adapter *adapter, const char *ptrn)
 			qdf_mem_free(g_hdd_wowl_ptrns[empty_slot]);
 			g_hdd_wowl_ptrns[empty_slot] = NULL;
 		}
-
+		hdd_objmgr_put_vdev(vdev);
 		dump_hdd_wowl_ptrn(&wow_pattern);
 
 next_ptrn:
@@ -268,6 +276,7 @@ bool hdd_del_wowl_ptrn(struct hdd_adapter *adapter, const char *ptrn)
 	QDF_STATUS status;
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 	uint8_t num_filters;
+	struct wlan_objmgr_vdev *vdev;
 
 	status = hdd_get_num_wow_filters(hdd_ctx, &num_filters);
 	if (QDF_IS_STATUS_ERROR(status))
@@ -288,7 +297,12 @@ bool hdd_del_wowl_ptrn(struct hdd_adapter *adapter, const char *ptrn)
 	if (!patternFound)
 		return false;
 
-	status = ucfg_pmo_del_wow_user_pattern(adapter->vdev, id);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return false;
+
+	status = ucfg_pmo_del_wow_user_pattern(vdev, id);
+	hdd_objmgr_put_vdev(vdev);
 	if (QDF_IS_STATUS_ERROR(status))
 		return false;
 
@@ -319,6 +333,7 @@ bool hdd_add_wowl_ptrn_debugfs(struct hdd_adapter *adapter, uint8_t pattern_idx,
 	struct pmo_wow_add_pattern wow_pattern;
 	QDF_STATUS qdf_ret_status;
 	uint16_t pattern_len, mask_len, i;
+	struct wlan_objmgr_vdev *vdev;
 
 	if (pattern_idx > (WOWL_MAX_PTRNS_ALLOWED - 1)) {
 		hdd_err("WoW pattern index %d is out of range (0 ~ %d)",
@@ -392,9 +407,13 @@ bool hdd_add_wowl_ptrn_debugfs(struct hdd_adapter *adapter, uint8_t pattern_idx,
 		pattern_mask += 2;
 	}
 
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return false;
+
 	/* Register the pattern downstream */
-	qdf_ret_status = ucfg_pmo_add_wow_user_pattern(
-				adapter->vdev, &wow_pattern);
+	qdf_ret_status = ucfg_pmo_add_wow_user_pattern(vdev, &wow_pattern);
+	hdd_objmgr_put_vdev(vdev);
 	if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) {
 		hdd_err("pmo_wow_user_pattern failed with error code (%d).",
 			  qdf_ret_status);
@@ -424,6 +443,7 @@ bool hdd_add_wowl_ptrn_debugfs(struct hdd_adapter *adapter, uint8_t pattern_idx,
 bool hdd_del_wowl_ptrn_debugfs(struct hdd_adapter *adapter,
 			       uint8_t pattern_idx)
 {
+	struct wlan_objmgr_vdev *vdev;
 	QDF_STATUS qdf_ret_status;
 
 	if (pattern_idx > (WOWL_MAX_PTRNS_ALLOWED - 1)) {
@@ -440,8 +460,12 @@ bool hdd_del_wowl_ptrn_debugfs(struct hdd_adapter *adapter,
 		return false;
 	}
 
-	qdf_ret_status = ucfg_pmo_del_wow_user_pattern(
-				adapter->vdev, pattern_idx);
+	vdev = hdd_objmgr_get_vdev(adapter);
+	if (!vdev)
+		return false;
+
+	qdf_ret_status = ucfg_pmo_del_wow_user_pattern(vdev, pattern_idx);
+	hdd_objmgr_put_vdev(vdev);
 	if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) {
 		hdd_err("sme_wowl_del_bcast_pattern failed with error code (%d).",
 			 qdf_ret_status);