Parcourir la source

qcacld-3.0: Add hdd api to check if vdev is associated

Currently there is no hdd api to check if vdev is associated
to some ap.
Add hdd api to check if vdev is associated with the help of
connection manager api for the same purpose.

Change-Id: I696980bc4235b738be8bdde5cfe4bf4157b45b6a
CRs-Fixed: 2852471
Ashish Kumar Dhanotiya il y a 4 ans
Parent
commit
2533300a9c

+ 2 - 2
core/hdd/inc/wlan_hdd_assoc.h

@@ -244,12 +244,12 @@ bool hdd_adapter_is_connected_sta(struct hdd_adapter *adapter);
 
 /**
  * hdd_conn_get_connected_band() - get current connection radio band
- * @sta_ctx:    pointer to global HDD Station context
+ * @adapter: HDD adapter
  *
  * Return: BAND_2G or BAND_5G based on current AP connection
  *      BAND_ALL if not connected
  */
-enum band_info hdd_conn_get_connected_band(struct hdd_station_ctx *sta_ctx);
+enum band_info hdd_conn_get_connected_band(struct hdd_adapter *adapter);
 
 /**
  * hdd_get_sta_connection_in_progress() - get STA for which connection

+ 7 - 9
core/hdd/src/wlan_hdd_assoc.c

@@ -401,11 +401,12 @@ bool hdd_adapter_is_connected_sta(struct hdd_adapter *adapter)
 	}
 }
 
-enum band_info hdd_conn_get_connected_band(struct hdd_station_ctx *sta_ctx)
+enum band_info hdd_conn_get_connected_band(struct hdd_adapter *adapter)
 {
+	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 	uint32_t sta_freq = 0;
 
-	if (eConnectionState_Associated == sta_ctx->conn_info.conn_state)
+	if (hdd_cm_is_vdev_associated(adapter))
 		sta_freq = sta_ctx->conn_info.chan_freq;
 
 	if (wlan_reg_is_24ghz_ch_freq(sta_freq))
@@ -466,8 +467,7 @@ struct hdd_adapter *hdd_get_sta_connection_in_progress(
 					hdd_adapter_dev_put_debug(next_adapter,
 								  dbgid);
 				return adapter;
-			} else if ((eConnectionState_Associated ==
-				   hdd_sta_ctx->conn_info.conn_state) &&
+			} else if (hdd_cm_is_vdev_associated(adapter) &&
 				   sme_is_sta_key_exchange_in_progress(
 							hdd_ctx->mac_handle,
 							adapter->vdev_id)) {
@@ -1551,7 +1551,7 @@ static void hdd_send_association_event(struct net_device *dev,
 		ucfg_tdls_notify_sta_disconnect(adapter->vdev_id, true, false,
 						adapter->vdev);
 
-	if (eConnectionState_Associated == sta_ctx->conn_info.conn_state) {
+	if (hdd_cm_is_vdev_associated(adapter)) {
 		struct oem_channel_info chan_info = {0};
 
 		if (!roam_info || !roam_info->bss_desc) {
@@ -1651,8 +1651,7 @@ static void hdd_send_association_event(struct net_device *dev,
 	if (cds_is_load_or_unload_in_progress()) {
 		hdd_wext_send_event(dev, we_event, &wrqu, msg);
 #ifdef FEATURE_WLAN_ESE
-		if (eConnectionState_Associated ==
-			 sta_ctx->conn_info.conn_state) {
+		if (hdd_cm_is_vdev_associated(adapter)) {
 			if ((roam_profile->AuthType.authType[0] ==
 			     eCSR_AUTH_TYPE_CCKM_RSN) ||
 			    (roam_profile->AuthType.authType[0] ==
@@ -3481,10 +3480,9 @@ static void
 hdd_roam_mic_error_indication_handler(struct hdd_adapter *adapter,
 				      struct csr_roam_info *roam_info)
 {
-	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 	tSirMicFailureInfo *mic_failure_info;
 
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state)
+	if (!hdd_cm_is_vdev_associated(adapter))
 		return;
 
 	mic_failure_info = roam_info->u.pMICFailureInfo;

+ 2 - 2
core/hdd/src/wlan_hdd_bss_transition.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2021 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
@@ -146,7 +146,7 @@ __wlan_hdd_cfg80211_fetch_bss_transition_status(struct wiphy *wiphy,
 		return ret;
 
 	if (adapter->device_mode != QDF_STA_MODE ||
-	    hdd_sta_ctx->conn_info.conn_state != eConnectionState_Associated) {
+	    !hdd_cm_is_vdev_associated(adapter)) {
 		hdd_err("Command is either not invoked for STA mode (device mode: %d) or STA is not associated (Connection state: %d)",
 			adapter->device_mode, hdd_sta_ctx->conn_info.conn_state);
 		return -EINVAL;

+ 3 - 5
core/hdd/src/wlan_hdd_cfg.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2021 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
@@ -1366,8 +1366,7 @@ static QDF_STATUS hdd_get_sta_tx_nss(struct hdd_adapter *adapter,
 			hdd_debug("nss chain dynamic config NULL");
 			return QDF_STATUS_E_INVAL;
 		}
-		operating_band = hdd_conn_get_connected_band(
-						&adapter->session.station);
+		operating_band = hdd_conn_get_connected_band(adapter);
 		switch (operating_band) {
 		case BAND_2G:
 			*tx_nss = dynamic_cfg->tx_nss[NSS_CHAINS_BAND_2GHZ];
@@ -1485,8 +1484,7 @@ static QDF_STATUS hdd_get_sta_rx_nss(struct hdd_adapter *adapter,
 			hdd_debug("nss chain dynamic config NULL");
 			return QDF_STATUS_E_INVAL;
 		}
-		operating_band = hdd_conn_get_connected_band(
-						&adapter->session.station);
+		operating_band = hdd_conn_get_connected_band(adapter);
 		switch (operating_band) {
 		case BAND_2G:
 			*rx_nss = dynamic_cfg->rx_nss[NSS_CHAINS_BAND_2GHZ];

+ 7 - 12
core/hdd/src/wlan_hdd_cfg80211.c

@@ -11796,8 +11796,7 @@ static int __wlan_hdd_cfg80211_get_link_properties(struct wiphy *wiphy,
 	if (adapter->device_mode == QDF_STA_MODE ||
 	    adapter->device_mode == QDF_P2P_CLIENT_MODE) {
 		hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-		if ((hdd_sta_ctx->conn_info.conn_state !=
-			eConnectionState_Associated) ||
+		if (!hdd_cm_is_vdev_associated(adapter) ||
 		    qdf_mem_cmp(hdd_sta_ctx->conn_info.bssid.bytes,
 			peer_mac, QDF_MAC_ADDR_SIZE)) {
 			hdd_err("Not Associated to mac "QDF_MAC_ADDR_FMT,
@@ -13524,8 +13523,6 @@ static int __wlan_hdd_cfg80211_set_fast_roaming(struct wiphy *wiphy,
 	int ret;
 	QDF_STATUS qdf_status;
 	unsigned long rc;
-	struct hdd_station_ctx *hdd_sta_ctx =
-		WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 	mac_handle_t mac_handle;
 
 	hdd_enter_dev(dev);
@@ -13568,7 +13565,7 @@ static int __wlan_hdd_cfg80211_set_fast_roaming(struct wiphy *wiphy,
 
 	ret = qdf_status_to_os_return(qdf_status);
 
-	if (eConnectionState_Associated == hdd_sta_ctx->conn_info.conn_state &&
+	if (hdd_cm_is_vdev_associated(adapter) &&
 	    QDF_IS_STATUS_SUCCESS(qdf_status) && !is_fast_roam_enabled) {
 		INIT_COMPLETION(adapter->lfr_fw_status.disable_lfr_event);
 		/*
@@ -14059,7 +14056,6 @@ static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
 	struct nlattr *tb[STATS_SET_MAX + 1];
 	struct net_device   *dev = wdev->netdev;
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
-	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 	struct hdd_context *hdd_ctx = wiphy_priv(wiphy);
 	struct set_arp_stats_params arp_stats_params = {0};
 	int err = 0;
@@ -14086,7 +14082,7 @@ static int __wlan_hdd_cfg80211_set_nud_stats(struct wiphy *wiphy,
 		return -EINVAL;
 	}
 
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_debug("Not Associated");
 		return 0;
 	}
@@ -20544,7 +20540,6 @@ static void wlan_hdd_wait_for_roaming(mac_handle_t mac_handle,
 {
 	struct hdd_context *hdd_ctx;
 	unsigned long rc;
-	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 	QDF_STATUS status;
 
 	if (adapter->device_mode != QDF_STA_MODE)
@@ -20553,7 +20548,7 @@ static void wlan_hdd_wait_for_roaming(mac_handle_t mac_handle,
 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 
 	/* Return if not in connected state */
-	if (sta_ctx->conn_info.conn_state != eConnectionState_Associated)
+	if (!hdd_cm_is_vdev_associated(adapter))
 		return;
 
 	ucfg_if_mgr_deliver_event(adapter->vdev,
@@ -21183,7 +21178,7 @@ static int __wlan_hdd_cfg80211_disconnect(struct wiphy *wiphy,
 	qdf_mutex_release(&adapter->disconnection_status_lock);
 
 	/* Issue disconnect request to SME, if station is in connected state */
-	if ((sta_ctx->conn_info.conn_state == eConnectionState_Associated) ||
+	if (hdd_cm_is_vdev_associated(adapter) ||
 	    (sta_ctx->conn_info.conn_state == eConnectionState_Connecting)) {
 		eCsrRoamDisconnectReason reasonCode =
 			eCSR_DISCONNECT_REASON_UNSPECIFIED;
@@ -22475,7 +22470,7 @@ __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
 		   adapter->vdev_id, sta_ctx->conn_info.conn_state);
 
 	/* Added for debug on reception of Re-assoc Req. */
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_err("Called with Ie of length = %zu when not associated",
 		       ftie->ie_len);
 		hdd_err("Should be Re-assoc Req IEs");
@@ -24503,7 +24498,7 @@ static int __wlan_hdd_cfg80211_set_bitrate_mask(struct wiphy *wiphy,
 
 	vdev_id = adapter->vdev_id;
 
-	connected_band = hdd_conn_get_connected_band(&adapter->session.station);
+	connected_band = hdd_conn_get_connected_band(adapter);
 
 	switch (connected_band) {
 	case BAND_2G:

+ 8 - 0
core/hdd/src/wlan_hdd_cm_api.h

@@ -222,4 +222,12 @@ static inline void hdd_cm_clear_pmf_stats(struct hdd_adapter *adapter)
 void hdd_cm_save_connect_status(struct hdd_adapter *adapter,
 				uint32_t reason_code);
 
+/**
+ * hdd_cm_is_vdev_associated() - Checks if vdev is associated or not
+ * @adapter: pointer to the adapter structure
+ *
+ * Returns: True if vdev is associated else false
+ */
+bool hdd_cm_is_vdev_associated(struct hdd_adapter *adapter);
+
 #endif

+ 34 - 0
core/hdd/src/wlan_hdd_cm_connect.c

@@ -42,6 +42,39 @@
 #include "sme_qos_internal.h"
 #include "wlan_hdd_scan.h"
 
+#ifdef FEATURE_CM_ENABLE
+bool hdd_cm_is_vdev_associated(struct hdd_adapter *adapter)
+{
+	struct wlan_objmgr_vdev *vdev;
+	bool is_vdev_active;
+
+	vdev = hdd_objmgr_get_vdev_by_user(adapter, WLAN_OSIF_CM_ID);
+
+	if (!vdev) {
+		mlme_err("vdev_id: %d: vdev not found", adapter->vdev_id);
+		return false;
+	}
+
+	if (wlan_vdev_mlme_get_opmode(vdev) != QDF_STA_MODE &&
+	    wlan_vdev_mlme_get_opmode(vdev) != QDF_P2P_CLIENT_MODE) {
+		hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_CM_ID);
+		return false;
+	}
+	is_vdev_active = ucfg_cm_is_vdev_active(vdev);
+
+	hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_CM_ID);
+
+	return is_vdev_active;
+}
+#else
+bool hdd_cm_is_vdev_associated(struct hdd_adapter *adapter)
+{
+	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+
+	return (sta_ctx->conn_info.conn_state == eConnectionState_Associated);
+}
+#endif
+
 void hdd_cm_update_rssi_snr_by_bssid(struct hdd_adapter *adapter)
 {
 	struct hdd_station_ctx *sta_ctx;
@@ -657,6 +690,7 @@ hdd_cm_connect_success_pre_user_update(struct wlan_objmgr_vdev *vdev,
 	hdd_cm_save_connect_status(adapter, rsp->status_code);
 
 	hdd_init_scan_reject_params(hdd_ctx);
+	hdd_start_tsf_sync(adapter);
 
 	hdd_cm_save_connect_info(adapter, rsp);
 

+ 1 - 0
core/hdd/src/wlan_hdd_cm_disconnect.c

@@ -112,6 +112,7 @@ void __hdd_cm_disconnect_handler_pre_user_update(struct hdd_adapter *adapter)
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 
+	hdd_stop_tsf_sync(adapter);
 	if (ucfg_ipa_is_enabled() &&
 	    QDF_IS_STATUS_SUCCESS(wlan_hdd_validate_mac_address(
 				  &sta_ctx->conn_info.bssid)))

+ 2 - 2
core/hdd/src/wlan_hdd_debugfs_offload.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2021 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
@@ -390,7 +390,7 @@ wlan_hdd_debugfs_update_filters_info(struct hdd_context *hdd_ctx,
 	}
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (hdd_sta_ctx->conn_info.conn_state != eConnectionState_Associated) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		ret_val = scnprintf(buf + len, buf_avail_len - len,
 				    "\nSTA is not connected\n");
 		if (ret_val <= 0)

+ 5 - 5
core/hdd/src/wlan_hdd_ioctl.c

@@ -598,7 +598,7 @@ int hdd_reassoc(struct hdd_adapter *adapter, const uint8_t *bssid,
 	 * So check both the HDD state and SME state here.
 	 * If not associated, no need to proceed with reassoc
 	 */
-	if ((eConnectionState_Associated != sta_ctx->conn_info.conn_state) ||
+	if (!hdd_cm_is_vdev_associated(adapter) ||
 	    (!sme_is_conn_state_connected(hdd_ctx->mac_handle,
 	    adapter->vdev_id))) {
 		hdd_warn("Not associated");
@@ -833,7 +833,7 @@ hdd_sendactionframe(struct hdd_adapter *adapter, const uint8_t *bssid,
 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 
 	/* if not associated, no need to send action frame */
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_warn("Not associated");
 		ret = -EINVAL;
 		goto exit;
@@ -2483,7 +2483,7 @@ static int wlan_hdd_get_link_status(struct hdd_adapter *adapter)
 	}
 
 	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		/* If not associated, then expected link status return
 		 * value is 0
 		 */
@@ -4561,7 +4561,7 @@ static int drv_cmd_fast_reassoc(struct hdd_adapter *adapter,
 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 
 	/* if not associated, no need to proceed with reassoc */
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_warn("Not associated!");
 		ret = -EINVAL;
 		goto exit;
@@ -4996,7 +4996,7 @@ static int drv_cmd_get_tsm_stats(struct hdd_adapter *adapter,
 	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 
 	/* if not associated, return error */
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_err("Not associated!");
 		ret = -EINVAL;
 		goto exit;

+ 2 - 4
core/hdd/src/wlan_hdd_ipa.c

@@ -72,8 +72,7 @@ void hdd_ipa_set_tx_flow_info(void)
 		switch (adapter->device_mode) {
 		case QDF_STA_MODE:
 			sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-			if (eConnectionState_Associated ==
-			    sta_ctx->conn_info.conn_state) {
+			if (hdd_cm_is_vdev_associated(adapter)) {
 				staChannel = wlan_reg_freq_to_chan(
 						hdd_ctx->pdev,
 						sta_ctx->conn_info.chan_freq);
@@ -86,8 +85,7 @@ void hdd_ipa_set_tx_flow_info(void)
 			break;
 		case QDF_P2P_CLIENT_MODE:
 			sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-			if (eConnectionState_Associated ==
-			    sta_ctx->conn_info.conn_state) {
+			if (hdd_cm_is_vdev_associated(adapter)) {
 				p2pChannel = wlan_reg_freq_to_chan(
 					hdd_ctx->pdev,
 					sta_ctx->conn_info.chan_freq);

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

@@ -515,8 +515,7 @@ hdd_process_sta_mic_error(struct hdd_adapter *adapter)
 
 	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 
-	if (eConnectionState_Associated !=
-	    sta_ctx->conn_info.conn_state)
+	if (!hdd_cm_is_vdev_associated(adapter))
 		return;
 
 	info = adapter->mic_work.info;
@@ -932,8 +931,7 @@ uint32_t hdd_get_adapter_home_channel(struct hdd_adapter *adapter)
 		home_chan_freq = adapter->session.ap.operating_chan_freq;
 	} else if ((adapter->device_mode == QDF_STA_MODE ||
 		    adapter->device_mode == QDF_P2P_CLIENT_MODE) &&
-		   adapter->session.station.conn_info.conn_state ==
-		   eConnectionState_Associated) {
+		   hdd_cm_is_vdev_associated(adapter)) {
 		home_chan_freq = adapter->session.station.conn_info.chan_freq;
 	}
 
@@ -10395,8 +10393,7 @@ static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx)
 
 		if ((adapter->device_mode == QDF_STA_MODE ||
 		     adapter->device_mode == QDF_P2P_CLIENT_MODE) &&
-		    WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.conn_state
-		    != eConnectionState_Associated) {
+		    !hdd_cm_is_vdev_associated(adapter)) {
 			hdd_adapter_dev_put_debug(adapter, dbgid);
 			continue;
 		}
@@ -15656,9 +15653,7 @@ void wlan_hdd_auto_shutdown_enable(struct hdd_context *hdd_ctx, bool enable)
 		hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter,
 						   next_adapter, dbgid) {
 			if (adapter->device_mode == QDF_STA_MODE) {
-				if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)->
-				    conn_info.conn_state ==
-				    eConnectionState_Associated) {
+				if (hdd_cm_is_vdev_associated(adapter)) {
 					sta_connected = true;
 					hdd_adapter_dev_put_debug(adapter,
 								  dbgid);
@@ -15764,8 +15759,7 @@ bool hdd_is_any_adapter_connected(struct hdd_context *hdd_ctx)
 	hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter,
 					   dbgid) {
 		if (hdd_adapter_is_sta(adapter) &&
-		    WLAN_HDD_GET_STATION_CTX_PTR(adapter)->
-			conn_info.conn_state == eConnectionState_Associated) {
+		    hdd_cm_is_vdev_associated(adapter)) {
 			hdd_adapter_dev_put_debug(adapter, dbgid);
 			if (next_adapter)
 				hdd_adapter_dev_put_debug(next_adapter,
@@ -18145,8 +18139,7 @@ static QDF_STATUS hdd_is_connection_in_progress_iterator(
 		(QDF_P2P_DEVICE_MODE == adapter->device_mode)) {
 		hdd_sta_ctx =
 			WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-		if ((eConnectionState_Associated ==
-		    hdd_sta_ctx->conn_info.conn_state)
+		if (hdd_cm_is_vdev_associated(adapter)
 		    && sme_is_sta_key_exchange_in_progress(
 		    mac_handle, adapter->vdev_id)) {
 			sta_mac = (uint8_t *)&(adapter->mac_addr.bytes[0]);

+ 3 - 11
core/hdd/src/wlan_hdd_nud_tracking.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2021 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
@@ -324,7 +324,6 @@ hdd_is_roam_after_nud_enabled(struct hdd_config *config)
 static void __hdd_nud_failure_work(struct hdd_adapter *adapter)
 {
 	struct hdd_context *hdd_ctx;
-	eConnectionState conn_state;
 	int status;
 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
 
@@ -339,10 +338,7 @@ static void __hdd_nud_failure_work(struct hdd_adapter *adapter)
 	if (0 != status)
 		return;
 
-	conn_state = (WLAN_HDD_GET_STATION_CTX_PTR(adapter))
-		      ->conn_info.conn_state;
-
-	if (eConnectionState_Associated != conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_debug("Not in Connected State");
 		return;
 	}
@@ -453,7 +449,6 @@ static void hdd_nud_filter_netevent(struct neighbour *neigh)
 	int status;
 	struct hdd_adapter *adapter;
 	struct hdd_context *hdd_ctx;
-	eConnectionState conn_state;
 	const struct net_device *netdev = neigh->dev;
 
 	hdd_enter();
@@ -483,10 +478,7 @@ static void hdd_nud_filter_netevent(struct neighbour *neigh)
 	if (adapter->device_mode != QDF_STA_MODE)
 		return;
 
-	conn_state = (WLAN_HDD_GET_STATION_CTX_PTR(adapter))
-		->conn_info.conn_state;
-
-	if (eConnectionState_Associated != conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_debug("Not in Connected State");
 		return;
 	}

+ 4 - 6
core/hdd/src/wlan_hdd_power.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2021 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
@@ -1285,7 +1285,7 @@ static void hdd_update_conn_state_mask(struct hdd_adapter *adapter,
 
 	conn_state = sta_ctx->conn_info.conn_state;
 
-	if (conn_state == eConnectionState_Associated)
+	if (hdd_cm_is_vdev_associated(adapter))
 		*conn_state_mask |= (1 << adapter->vdev_id);
 }
 
@@ -2463,8 +2463,7 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
 		struct hdd_station_ctx *sta_ctx =
 			WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 
-		if (eConnectionState_Associated ==
-		    sta_ctx->conn_info.conn_state)
+		if (hdd_cm_is_vdev_associated(adapter))
 			qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssid);
 	}
 
@@ -2707,8 +2706,7 @@ static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
 			hdd_debug("Roaming is in progress, rej this req");
 			return -EINVAL;
 		}
-		if (sta_ctx->conn_info.conn_state !=
-		    eConnectionState_Associated) {
+		if (!hdd_cm_is_vdev_associated(adapter)) {
 			hdd_debug("Not associated");
 			return 0;
 		}

+ 3 - 9
core/hdd/src/wlan_hdd_scan.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2021 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
@@ -502,10 +502,7 @@ static int __wlan_hdd_cfg80211_scan(struct wiphy *wiphy,
 
 	enable_connected_scan = ucfg_scan_is_connected_scan_enabled(
 							hdd_ctx->psoc);
-	if ((eConnectionState_Associated ==
-			WLAN_HDD_GET_STATION_CTX_PTR(adapter)->
-						conn_info.conn_state) &&
-	    (!enable_connected_scan)) {
+	if (hdd_cm_is_vdev_associated(adapter) && !enable_connected_scan) {
 		hdd_info("enable_connected_scan is false, Aborting scan");
 		if (wlan_hdd_enqueue_blocked_scan_request(dev, request, source))
 			return -EAGAIN;
@@ -1323,10 +1320,7 @@ static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
 
 	enable_connected_scan = ucfg_scan_is_connected_scan_enabled(
 							hdd_ctx->psoc);
-	if ((eConnectionState_Associated ==
-				WLAN_HDD_GET_STATION_CTX_PTR(adapter)->
-							conn_info.conn_state) &&
-	    (!enable_connected_scan)) {
+	if (hdd_cm_is_vdev_associated(adapter) && !enable_connected_scan) {
 		hdd_info("enable_connected_scan is false, Aborting scan");
 		return -EBUSY;
 	}

+ 8 - 11
core/hdd/src/wlan_hdd_stats.c

@@ -267,7 +267,7 @@ static int copy_station_stats_to_adapter(struct hdd_adapter *adapter,
 		goto out;
 	}
 
-	switch (hdd_conn_get_connected_band(&adapter->session.station)) {
+	switch (hdd_conn_get_connected_band(adapter)) {
 	case BAND_2G:
 		tx_nss = dynamic_cfg->tx_nss[NSS_CHAINS_BAND_2GHZ];
 		rx_nss = dynamic_cfg->rx_nss[NSS_CHAINS_BAND_2GHZ];
@@ -760,16 +760,14 @@ bool hdd_get_interface_info(struct hdd_adapter *adapter,
 				  adapter->vdev_id);
 			info->state = WIFI_ASSOCIATING;
 		}
-		if ((eConnectionState_Associated ==
-		     sta_ctx->conn_info.conn_state) &&
-		    (!sta_ctx->conn_info.is_authenticated)) {
+		if (hdd_cm_is_vdev_associated(adapter) &&
+		    !sta_ctx->conn_info.is_authenticated) {
 			hdd_err("client " QDF_MAC_ADDR_FMT
 				" is in the middle of WPS/EAPOL exchange.",
 				QDF_MAC_ADDR_REF(adapter->mac_addr.bytes));
 			info->state = WIFI_AUTHENTICATING;
 		}
-		if (eConnectionState_Associated ==
-		    sta_ctx->conn_info.conn_state) {
+		if (hdd_cm_is_vdev_associated(adapter)) {
 			info->state = WIFI_ASSOCIATED;
 			qdf_copy_macaddr(&info->bssid,
 					 &sta_ctx->conn_info.bssid);
@@ -5284,7 +5282,7 @@ static int wlan_hdd_get_sta_stats(struct wiphy *wiphy,
 		   TRACE_CODE_HDD_CFG80211_GET_STA,
 		   adapter->vdev_id, 0);
 
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_debug("Not associated");
 		/*To keep GUI happy */
 		return 0;
@@ -5943,8 +5941,7 @@ static bool hdd_is_rcpi_applicable(struct hdd_adapter *adapter,
 	if (adapter->device_mode == QDF_STA_MODE ||
 	    adapter->device_mode == QDF_P2P_CLIENT_MODE) {
 		hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-		if (hdd_sta_ctx->conn_info.conn_state !=
-		    eConnectionState_Associated)
+		if (!hdd_cm_is_vdev_associated(adapter))
 			return false;
 
 		if (hdd_sta_ctx->hdd_reassoc_scenario) {
@@ -6192,7 +6189,7 @@ QDF_STATUS wlan_hdd_get_rssi(struct hdd_adapter *adapter, int8_t *rssi_value)
 
 	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_debug("Not associated!, rssi on disconnect %d",
 			  adapter->rssi_on_disconnect);
 		*rssi_value = adapter->rssi_on_disconnect;
@@ -6441,7 +6438,7 @@ int wlan_hdd_get_link_speed(struct hdd_adapter *adapter, uint32_t *link_speed)
 		return -ENOTSUPP;
 	}
 
-	if (eConnectionState_Associated != hdd_stactx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		/* we are not connected so we don't have a classAstats */
 		*link_speed = 0;
 	} else {

+ 2 - 2
core/hdd/src/wlan_hdd_sysfs_connect_info.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2021, 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 above
@@ -318,7 +318,7 @@ static ssize_t wlan_hdd_connect_info(struct hdd_adapter *adapter, uint8_t *buf,
 	int ret_val;
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (hdd_sta_ctx->conn_info.conn_state != eConnectionState_Associated) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		ret_val = scnprintf(buf, buf_avail_len,
 				    "\nSTA is not connected\n");
 		if (ret_val >= 0)

+ 4 - 7
core/hdd/src/wlan_hdd_tsf.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2021 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
@@ -104,13 +104,10 @@ static
 enum hdd_tsf_get_state hdd_tsf_check_conn_state(struct hdd_adapter *adapter)
 {
 	enum hdd_tsf_get_state ret = TSF_RETURN;
-	struct hdd_station_ctx *hdd_sta_ctx;
 
 	if (adapter->device_mode == QDF_STA_MODE ||
 			adapter->device_mode == QDF_P2P_CLIENT_MODE) {
-		hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-		if (hdd_sta_ctx->conn_info.conn_state !=
-				eConnectionState_Associated) {
+		if (!hdd_cm_is_vdev_associated(adapter)) {
 			hdd_err("failed to cap tsf, not connect with ap");
 			ret = TSF_STA_NOT_CONNECTED_NO_TSF;
 		}
@@ -1192,7 +1189,7 @@ static ssize_t __hdd_wlan_tsf_show(struct device *dev,
 				 "TSF sync is not initialized\n");
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (eConnectionState_Associated != hdd_sta_ctx->conn_info.conn_state &&
+	if (!hdd_cm_is_vdev_associated(adapter) &&
 	    (adapter->device_mode == QDF_STA_MODE ||
 	    adapter->device_mode == QDF_P2P_CLIENT_MODE))
 		return scnprintf(buf, PAGE_SIZE, "NOT connected\n");
@@ -1354,7 +1351,7 @@ static ssize_t __hdd_wlan_tsf_show(struct device *dev,
 				 "TSF sync is not initialized\n");
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (eConnectionState_Associated != hdd_sta_ctx->conn_info.conn_state &&
+	if (!hdd_cm_is_vdev_associated(adapter) &&
 	    (adapter->device_mode == QDF_STA_MODE ||
 	    adapter->device_mode == QDF_P2P_CLIENT_MODE))
 		return scnprintf(buf, PAGE_SIZE, "NOT connected\n");

+ 7 - 7
core/hdd/src/wlan_hdd_twt.c

@@ -308,7 +308,7 @@ int hdd_test_config_twt_setup_session(struct hdd_adapter *adapter,
 	}
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (hdd_sta_ctx->conn_info.conn_state != eConnectionState_Associated) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_err_rl("Invalid state, vdev %d mode %d state %d",
 			   adapter->vdev_id, adapter->device_mode,
 			   hdd_sta_ctx->conn_info.conn_state);
@@ -366,7 +366,7 @@ int hdd_test_config_twt_terminate_session(struct hdd_adapter *adapter,
 	}
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (hdd_sta_ctx->conn_info.conn_state != eConnectionState_Associated) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_err_rl("Invalid state, vdev %d mode %d state %d",
 			   adapter->vdev_id, adapter->device_mode,
 			   hdd_sta_ctx->conn_info.conn_state);
@@ -1205,7 +1205,7 @@ static int hdd_twt_setup_session(struct hdd_adapter *adapter,
 	}
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (hdd_sta_ctx->conn_info.conn_state != eConnectionState_Associated) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_err_rl("Invalid state, vdev %d mode %d state %d",
 			   adapter->vdev_id, adapter->device_mode,
 			   hdd_sta_ctx->conn_info.conn_state);
@@ -1426,7 +1426,7 @@ static int hdd_twt_terminate_session(struct hdd_adapter *adapter,
 	}
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (hdd_sta_ctx->conn_info.conn_state != eConnectionState_Associated) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_err_rl("Invalid state, vdev %d mode %d state %d",
 			   adapter->vdev_id, adapter->device_mode,
 			   hdd_sta_ctx->conn_info.conn_state);
@@ -1690,7 +1690,7 @@ static int hdd_twt_pause_session(struct hdd_adapter *adapter,
 	}
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (hdd_sta_ctx->conn_info.conn_state != eConnectionState_Associated) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_err_rl("Invalid state, vdev %d mode %d state %d",
 			   adapter->vdev_id, adapter->device_mode,
 			   hdd_sta_ctx->conn_info.conn_state);
@@ -1829,7 +1829,7 @@ static int hdd_twt_nudge_session(struct hdd_adapter *adapter,
 	}
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (hdd_sta_ctx->conn_info.conn_state != eConnectionState_Associated) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_err_rl("Invalid state, vdev %d mode %d state %d",
 			   adapter->vdev_id, adapter->device_mode,
 			   hdd_sta_ctx->conn_info.conn_state);
@@ -2039,7 +2039,7 @@ static int hdd_twt_resume_session(struct hdd_adapter *adapter,
 	}
 
 	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (hdd_sta_ctx->conn_info.conn_state != eConnectionState_Associated) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_err_rl("Invalid state, vdev %d mode %d state %d",
 			   adapter->vdev_id, adapter->device_mode,
 			   hdd_sta_ctx->conn_info.conn_state);

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

@@ -918,8 +918,7 @@ void hdd_get_transmit_mac_addr(struct hdd_adapter *adapter, struct sk_buff *skb,
 			qdf_copy_macaddr(mac_addr_tx_allowed,
 					 (struct qdf_mac_addr *)skb->data);
 	} else {
-		if (sta_ctx->conn_info.conn_state ==
-		    eConnectionState_Associated)
+		if (hdd_cm_is_vdev_associated(adapter))
 			qdf_copy_macaddr(mac_addr_tx_allowed,
 					 &sta_ctx->conn_info.bssid);
 	}

+ 5 - 8
core/hdd/src/wlan_hdd_wext.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2021 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
@@ -6514,8 +6514,7 @@ static int __iw_get_char_setnone(struct net_device *dev,
 		enable_snr_monitoring =
 				ucfg_scan_is_snr_monitor_enabled(hdd_ctx->psoc);
 		if (!enable_snr_monitoring ||
-		    eConnectionState_Associated !=
-		    sta_ctx->conn_info.conn_state) {
+		    !hdd_cm_is_vdev_associated(adapter)) {
 			hdd_err("getSNR failed: Enable SNR Monitoring-%d, ConnectionState-%d",
 				enable_snr_monitoring,
 				sta_ctx->conn_info.conn_state);
@@ -7489,7 +7488,6 @@ static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
 			  union iwreq_data *wrqu, char *extra)
 {
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
-	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 	hdd_wlan_wmm_status_e *wmm_status = (hdd_wlan_wmm_status_e *) extra;
 	int params[HDD_WLAN_WMM_PARAM_COUNT];
 	struct sme_qos_wmmtspecinfo tspec;
@@ -7517,7 +7515,7 @@ static int __iw_add_tspec(struct net_device *dev, struct iw_request_info *info,
 		return -EPERM;
 
 	/* we must be associated in order to add a tspec */
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		*wmm_status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
 		return 0;
 	}
@@ -7812,7 +7810,6 @@ static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
 			  union iwreq_data *wrqu, char *extra)
 {
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
-	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 	struct hdd_context *hdd_ctx;
 	int ret;
 
@@ -7836,7 +7833,7 @@ static int __iw_set_fties(struct net_device *dev, struct iw_request_info *info,
 		return -EINVAL;
 	}
 	/* Added for debug on reception of Re-assoc Req. */
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		hdd_debug("Called with Ie of length = %d when not associated",
 		       wrqu->data.length);
 		hdd_debug("Should be Re-assoc Req IEs");
@@ -8273,7 +8270,7 @@ static int __iw_get_statistics(struct net_device *dev,
 		return ret;
 
 	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-	if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) {
+	if (!hdd_cm_is_vdev_associated(adapter)) {
 		wrqu->data.length = 0;
 		return 0;
 	}