Sfoglia il codice sorgente

qcacld-3.0: Iterate all links in hdd_get_adapter_by_vdev()

In the hdd_get_adapter_by_vdev() check all the links to find
the adapter that matches the input vdev_id.
Change the function prototype to return pointer of link info
instead of adapter and rename API as hdd_get_link_info_by_vdev().
Callers can get adapter in the link info structure.

Change-Id: Iec5b5b476f74a35054802510093f81e158be2d65
CRs-Fixed: 3451007
Vinod Kumar Pirla 2 anni fa
parent
commit
31deabadb3

+ 5 - 5
core/hdd/inc/wlan_hdd_main.h

@@ -2649,17 +2649,17 @@ QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx);
 QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx);
 
 /**
- * hdd_get_adapter_by_vdev() - Return adapter with the given vdev id
+ * hdd_get_link_info_by_vdev() - Return link info with the given vdev id
  * @hdd_ctx: hdd context.
- * @vdev_id: vdev id for the adapter to get.
+ * @vdev_id: vdev id for the link info to get.
  *
- * This function is used to get the adapter with provided vdev id
+ * This function is used to get the link info with provided vdev id
  *
  * Return: adapter pointer if found
  *
  */
-struct hdd_adapter *hdd_get_adapter_by_vdev(struct hdd_context *hdd_ctx,
-					    uint32_t vdev_id);
+struct wlan_hdd_link_info *
+hdd_get_link_info_by_vdev(struct hdd_context *hdd_ctx, uint32_t vdev_id);
 
 /**
  * hdd_adapter_get_by_reference() - Return adapter with the given reference

+ 5 - 4
core/hdd/src/wlan_hdd_apf.c

@@ -423,10 +423,10 @@ hdd_apf_read_memory_callback(void *hdd_context,
 			     struct wmi_apf_read_memory_resp_event_params *evt)
 {
 	struct hdd_context *hdd_ctx = hdd_context;
-	struct hdd_adapter *adapter;
 	struct hdd_apf_context *context;
 	uint8_t *buf_ptr;
 	uint32_t pkt_offset;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_enter();
 
@@ -436,10 +436,11 @@ hdd_apf_read_memory_callback(void *hdd_context,
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id);
-	if (hdd_validate_adapter(adapter))
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, evt->vdev_id);
+	if (!link_info || hdd_validate_adapter(link_info->adapter))
 		return;
-	context = &adapter->apf_context;
+
+	context = &link_info->adapter->apf_context;
 
 	if (context->magic != APF_CONTEXT_MAGIC) {
 		/* The caller presumably timed out, nothing to do */

+ 14 - 14
core/hdd/src/wlan_hdd_bcn_recv.c

@@ -131,6 +131,7 @@ static QDF_STATUS hdd_send_bcn_recv_info(hdd_handle_t hdd_handle,
 	uint32_t data_len;
 	int flags = cds_get_gfp_flags();
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	enum qca_nl80211_vendor_subcmds_index index =
 		QCA_NL80211_VENDOR_SUBCMD_BEACON_REPORTING_INDEX;
 
@@ -139,14 +140,14 @@ static QDF_STATUS hdd_send_bcn_recv_info(hdd_handle_t hdd_handle,
 
 	data_len = get_beacon_report_data_len(beacon_report);
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, beacon_report->vdev_id);
-	if (hdd_validate_adapter(adapter))
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, beacon_report->vdev_id);
+	if (!link_info || hdd_validate_adapter(link_info->adapter))
 		return QDF_STATUS_E_FAILURE;
 
+	adapter = link_info->adapter;
 	vendor_event = wlan_cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
 							&adapter->wdev,
-							data_len,
-							index, flags);
+							data_len, index, flags);
 	if (!vendor_event) {
 		hdd_err("wlan_cfg80211_vendor_event_alloc failed");
 		return QDF_STATUS_E_FAILURE;
@@ -441,14 +442,16 @@ void hdd_beacon_recv_pause_indication(hdd_handle_t hdd_handle,
 	int flags;
 	uint32_t abort_reason;
 	bool do_not_resume;
+	struct wlan_hdd_link_info *link_info;
 
 	if (wlan_hdd_validate_context(hdd_ctx))
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (hdd_validate_adapter(adapter))
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info || hdd_validate_adapter(link_info->adapter))
 		return;
 
+	adapter = link_info->adapter;
 	data_len = get_pause_ind_data_len(is_disconnected);
 	flags = cds_get_gfp_flags();
 
@@ -464,18 +467,16 @@ void hdd_beacon_recv_pause_indication(hdd_handle_t hdd_handle,
 	}
 
 	do_not_resume =
-		sme_is_beacon_reporting_do_not_resume(
-						hdd_ctx->mac_handle,
-						adapter->deflink->vdev_id);
+		sme_is_beacon_reporting_do_not_resume(hdd_ctx->mac_handle,
+						      link_info->vdev_id);
 
 	if (is_disconnected) {
 		abort_reason =
 		     QCA_WLAN_VENDOR_BEACON_REPORTING_PAUSE_REASON_DISCONNECTED;
 		/* Deregister callbacks and Reset bcn recv start flag */
 		if (sme_is_beacon_report_started(hdd_ctx->mac_handle,
-						 adapter->deflink->vdev_id))
-			hdd_handle_beacon_reporting_stop_op(hdd_ctx,
-							    adapter);
+						 link_info->vdev_id))
+			hdd_handle_beacon_reporting_stop_op(hdd_ctx, adapter);
 	} else {
 		/*
 		 * In case of scan, Check that auto resume of beacon reporting
@@ -489,8 +490,7 @@ void hdd_beacon_recv_pause_indication(hdd_handle_t hdd_handle,
 		 * connected AP's beacon to userspace.
 		 */
 		if (do_not_resume)
-			hdd_handle_beacon_reporting_stop_op(hdd_ctx,
-							    adapter);
+			hdd_handle_beacon_reporting_stop_op(hdd_ctx, adapter);
 
 		switch (type) {
 		case SCAN_EVENT_TYPE_STARTED:

+ 76 - 74
core/hdd/src/wlan_hdd_cfg80211.c

@@ -5657,15 +5657,15 @@ hdd_send_roam_triggers_to_sme(struct hdd_context *hdd_ctx,
 {
 	QDF_STATUS status;
 	struct wlan_roam_triggers triggers;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter NULL");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return QDF_STATUS_E_FAILURE;
 	}
 
-	if (adapter->device_mode != QDF_STA_MODE) {
+	if (link_info->adapter->device_mode != QDF_STA_MODE) {
 		hdd_err("Roam trigger bitmap supported only in STA mode");
 		return QDF_STATUS_E_FAILURE;
 	}
@@ -5688,7 +5688,7 @@ hdd_send_roam_triggers_to_sme(struct hdd_context *hdd_ctx,
 	 */
 	if (hdd_is_roaming_in_progress(hdd_ctx)) {
 		mlme_set_roam_trigger_bitmap(hdd_ctx->psoc,
-					     adapter->deflink->vdev_id,
+					     link_info->vdev_id,
 					     triggers.trigger_bitmap);
 		hdd_err("Reject set roam trigger as roaming is in progress");
 
@@ -5967,21 +5967,21 @@ hdd_set_roam_with_control_config(struct hdd_context *hdd_ctx,
 	bool is_wtc_param_updated = false;
 	uint32_t band_mask;
 	uint16_t threshold;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	uint8_t roam_control_enable = false;
 
 	hdd_enter();
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (hdd_validate_adapter(adapter))
-		return QDF_STATUS_E_FAILURE;
-
 	/* The command must carry PARAM_ROAM_CONTROL_CONFIG */
 	if (!tb[PARAM_ROAM_CONTROL_CONFIG]) {
 		hdd_err("Attribute CONTROL_CONFIG is not present");
 		return -EINVAL;
 	}
 
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info || hdd_validate_adapter(link_info->adapter))
+		return QDF_STATUS_E_FAILURE;
+
 	if (wlan_cfg80211_nla_parse_nested(tb2, QCA_ATTR_ROAM_CONTROL_MAX,
 					   tb[PARAM_ROAM_CONTROL_CONFIG],
 					   roam_control_policy)) {
@@ -6186,10 +6186,9 @@ hdd_set_roam_with_control_config(struct hdd_context *hdd_ctx,
 	attr = tb2[QCA_ATTR_ROAM_CONTROL_RX_LINKSPEED_THRESHOLD];
 	if (attr) {
 		threshold = nla_get_u16(attr);
-		status = hdd_set_roam_rx_linkspeed_threshold(
-							hdd_ctx->psoc,
-							adapter->deflink->vdev,
-							threshold);
+		status = hdd_set_roam_rx_linkspeed_threshold(hdd_ctx->psoc,
+							     link_info->vdev,
+							     threshold);
 	}
 
 	if (is_wtc_param_updated) {
@@ -6403,7 +6402,7 @@ hdd_roam_control_config_fill_data(struct hdd_context *hdd_ctx, uint8_t vdev_id,
 	uint32_t full_roam_scan_period, roam_band, vendor_band_mask;
 	uint8_t num_channels = 0;
 	uint32_t i = 0, freq_list[NUM_CHANNELS] = { 0 };
-	struct hdd_adapter *hdd_adapter = NULL;
+	struct wlan_hdd_link_info *link_info;
 
 	config = nla_nest_start(skb, PARAM_ROAM_CONTROL_CONFIG);
 	if (!config) {
@@ -6442,14 +6441,14 @@ hdd_roam_control_config_fill_data(struct hdd_context *hdd_ctx, uint8_t vdev_id,
 	}
 
 	if (tb[QCA_ATTR_ROAM_CONTROL_FREQ_LIST_SCHEME]) {
-		hdd_adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-		if (!hdd_adapter) {
-			hdd_info("HDD adapter is NULL");
+		link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+		if (!link_info) {
+			hdd_info("Invalid vdev");
 			return -EINVAL;
 		}
 
 		hdd_debug("Get roam scan frequencies req received");
-		status = hdd_get_roam_scan_freq(hdd_adapter,
+		status = hdd_get_roam_scan_freq(link_info->adapter,
 						hdd_ctx->mac_handle,
 						freq_list, &num_channels);
 		if (QDF_IS_STATUS_ERROR(status)) {
@@ -7928,16 +7927,16 @@ void hdd_cfr_data_send_nl_event(uint8_t vdev_id, uint32_t pid,
 	uint32_t len, ret;
 	struct sk_buff *vendor_event;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
-	struct nlmsghdr *nlhdr = NULL;
+	struct wlan_hdd_link_info *link_info;
+	struct nlmsghdr *nlhdr;
 
 	if (!hdd_ctx) {
 		hdd_err("HDD context is NULL");
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
 		hdd_err("adapter NULL for vdev id %d", vdev_id);
 		return;
 	}
@@ -7945,7 +7944,7 @@ void hdd_cfr_data_send_nl_event(uint8_t vdev_id, uint32_t pid,
 	hdd_debug("vdev id %d pid %d data len %d", vdev_id, pid, data_len);
 	len = nla_total_size(data_len) + NLMSG_HDRLEN;
 	vendor_event = wlan_cfg80211_vendor_event_alloc(
-			hdd_ctx->wiphy, &adapter->wdev, len,
+			hdd_ctx->wiphy, &link_info->adapter->wdev, len,
 			QCA_NL80211_VENDOR_SUBCMD_PEER_CFR_CAPTURE_CFG_INDEX,
 			GFP_KERNEL);
 
@@ -7982,22 +7981,22 @@ void hdd_send_roam_scan_ch_list_event(struct hdd_context *hdd_ctx,
 				      uint8_t *buf)
 {
 	struct sk_buff *vendor_event;
-	struct hdd_adapter *adapter;
 	uint32_t len, ret;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx) {
 		hdd_err_rl("hdd context is null");
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter)
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info)
 		return;
 
 	len = nla_total_size(buf_len) + NLMSG_HDRLEN;
 	vendor_event =
 		wlan_cfg80211_vendor_event_alloc(
-			hdd_ctx->wiphy, &(adapter->wdev), len,
+			hdd_ctx->wiphy, &link_info->adapter->wdev, len,
 			QCA_NL80211_VENDOR_SUBCMD_UPDATE_STA_INFO_INDEX,
 			GFP_KERNEL);
 
@@ -9832,23 +9831,25 @@ hdd_latency_level_event_handler_cb(const struct latency_level_data *event_data,
 	struct hdd_adapter *hdd_adapter;
 	uint32_t latency_host_flags = 0;
 	QDF_STATUS status;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_enter();
 
 	if (wlan_hdd_validate_context(hdd_ctx))
 		return;
 
-	hdd_adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!hdd_adapter) {
-		hdd_err("adapter is NULL vdev_id = %d", vdev_id);
+	if (!event_data) {
+		hdd_err("Invalid latency level event data");
 		return;
 	}
 
-	if (!event_data) {
-		hdd_err("Invalid latency level event data");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("adapter is NULL vdev_id = %d", vdev_id);
 		return;
 	}
 
+	hdd_adapter = link_info->adapter;
 	if (hdd_adapter->multi_ll_resp_expected) {
 		request =
 			osif_request_get(hdd_adapter->multi_ll_response_cookie);
@@ -16559,16 +16560,16 @@ void wlan_hdd_rso_cmd_status_cb(hdd_handle_t hdd_handle,
 				struct rso_cmd_status *rso_status)
 {
 	struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, rso_status->vdev_id);
-	if (!adapter) {
-		hdd_err("adapter NULL");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, rso_status->vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
 
-	adapter->lfr_fw_status.is_disabled = rso_status->status;
-	complete(&adapter->lfr_fw_status.disable_lfr_event);
+	link_info->adapter->lfr_fw_status.is_disabled = rso_status->status;
+	complete(&link_info->adapter->lfr_fw_status.disable_lfr_event);
 }
 
 /**
@@ -18241,14 +18242,14 @@ static int wlan_hdd_fill_intf_info(struct sk_buff *skb,
 	struct nlattr *attr;
 	uint32_t freq;
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *hdd_adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (!hdd_ctx)
 		goto error;
 
-	hdd_adapter = hdd_get_adapter_by_vdev(hdd_ctx, info->vdev_id);
-	if (!hdd_adapter)
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, info->vdev_id);
+	if (!link_info)
 		goto error;
 
 	attr = nla_nest_start(skb, index);
@@ -18258,7 +18259,7 @@ static int wlan_hdd_fill_intf_info(struct sk_buff *skb,
 	freq = sme_chn_to_freq(info->channel);
 
 	if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_MAC_IFACE_INFO_IFINDEX,
-	    hdd_adapter->dev->ifindex) ||
+	    link_info->adapter->dev->ifindex) ||
 	    nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_MAC_IFACE_INFO_FREQ, freq))
 		goto error;
 
@@ -21780,16 +21781,18 @@ QDF_STATUS wlan_hdd_send_key_vdev(struct wlan_objmgr_vdev *vdev,
 	int errno;
 	bool ft_mode = false;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
+	uint8_t vdev_id;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is NULL");
 		return QDF_STATUS_E_NULL_VALUE;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
-	if (!adapter) {
-		hdd_err("adapter is NULL for vdev %d", wlan_vdev_get_id(vdev));
+	vdev_id = wlan_vdev_get_id(vdev);
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("adapter is NULL for vdev %d", vdev_id);
 		return QDF_STATUS_E_NULL_VALUE;
 	}
 
@@ -21813,16 +21816,15 @@ QDF_STATUS wlan_hdd_send_key_vdev(struct wlan_objmgr_vdev *vdev,
 					  ucast_cipher, cipher_cap);
 
 	cdp_peer_flush_frags(cds_get_context(QDF_MODULE_ID_SOC),
-			     wlan_vdev_get_id(vdev), mac_address.bytes);
+			     vdev_id, mac_address.bytes);
 
-	errno = wlan_hdd_add_key_sta(hdd_ctx->pdev, adapter, pairwise,
-				     key_index, &ft_mode);
+	errno = wlan_hdd_add_key_sta(hdd_ctx->pdev, link_info->adapter,
+				     pairwise, key_index, &ft_mode);
 	if (ft_mode)
 		return QDF_STATUS_SUCCESS;
 
 	if (!errno)
-		wma_update_set_key(wlan_vdev_get_id(vdev), pairwise, key_index,
-				   cipher_type);
+		wma_update_set_key(vdev_id, pairwise, key_index, cipher_type);
 	else
 		status = QDF_STATUS_E_FAILURE;
 
@@ -21908,7 +21910,6 @@ static int wlan_hdd_add_key_all_mlo_vdev(mac_handle_t mac_handle,
 					 struct hdd_adapter *adapter)
 {
 	QDF_STATUS status;
-	struct hdd_adapter *link_adapter;
 	struct hdd_context *hdd_ctx;
 	struct wlan_objmgr_vdev *wlan_vdev_list[WLAN_UMAC_MLO_MAX_VDEVS];
 	struct wlan_objmgr_vdev *link_vdev;
@@ -21916,6 +21917,8 @@ static int wlan_hdd_add_key_all_mlo_vdev(mac_handle_t mac_handle,
 	struct wlan_objmgr_peer *peer = NULL;
 	int errno = 0;
 	uint16_t link, vdev_count = 0;
+	uint8_t vdev_id;
+	struct wlan_hdd_link_info *link_info;
 
 	/* if vdev mlme is mlo & pairwaise is set to true set same info for
 	 * both the links.
@@ -21925,11 +21928,9 @@ static int wlan_hdd_add_key_all_mlo_vdev(mac_handle_t mac_handle,
 	mlo_sta_get_vdev_list(vdev, &vdev_count, wlan_vdev_list);
 	for (link = 0; link < vdev_count; link++) {
 		link_vdev = wlan_vdev_list[link];
-
-		link_adapter = hdd_get_adapter_by_vdev(
-						hdd_ctx,
-						wlan_vdev_get_id(link_vdev));
-		if (!link_adapter) {
+		vdev_id = wlan_vdev_get_id(link_vdev);
+		link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+		if (!link_info) {
 			mlo_release_vdev_ref(link_vdev);
 			continue;
 		}
@@ -21977,7 +21978,8 @@ static int wlan_hdd_add_key_all_mlo_vdev(mac_handle_t mac_handle,
 add_key:
 		errno = wlan_hdd_add_key_vdev(mac_handle, link_vdev, key_index,
 					      pairwise, peer_mac.bytes,
-					      params, link_id, link_adapter);
+					      params, link_id,
+					      link_info->adapter);
 		mlo_release_vdev_ref(link_vdev);
 	}
 
@@ -21993,10 +21995,10 @@ static int wlan_hdd_add_key_mlo_vdev(mac_handle_t mac_handle,
 {
 	int errno = 0;
 	struct wlan_objmgr_vdev *link_vdev;
-	struct hdd_adapter *link_adapter = NULL;
 	struct hdd_context *hdd_ctx;
 	uint8_t vdev_id;
 	QDF_STATUS status;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!wlan_vdev_mlme_is_mlo_vdev(vdev))
 		return errno;
@@ -22022,11 +22024,11 @@ static int wlan_hdd_add_key_mlo_vdev(mac_handle_t mac_handle,
 
 	if (pairwise && link_id == -1 && link_vdev) {
 		hdd_ctx = WLAN_HDD_GET_CTX(adapter);
-		link_adapter =
-		      hdd_get_adapter_by_vdev(hdd_ctx,
-					      wlan_vdev_get_id(link_vdev));
+		link_info =
+		      hdd_get_link_info_by_vdev(hdd_ctx,
+						wlan_vdev_get_id(link_vdev));
 		link_id = wlan_vdev_get_link_id(link_vdev);
-		if (!link_adapter) {
+		if (!link_info) {
 			ucfg_tdls_put_tdls_link_vdev(link_vdev,
 						     WLAN_OSIF_TDLS_ID);
 			hdd_err("couldn't set tdls key, link_id %d", link_id);
@@ -22035,7 +22037,7 @@ static int wlan_hdd_add_key_mlo_vdev(mac_handle_t mac_handle,
 
 		errno = wlan_hdd_add_key_vdev(mac_handle, link_vdev, key_index,
 					      pairwise, mac_addr, params,
-					      link_id, link_adapter);
+					      link_id, link_info->adapter);
 		ucfg_tdls_put_tdls_link_vdev(link_vdev, WLAN_OSIF_TDLS_ID);
 
 		return errno;
@@ -22059,16 +22061,16 @@ static int wlan_hdd_add_key_mlo_vdev(mac_handle_t mac_handle,
 	}
 
 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
-	link_adapter = hdd_get_adapter_by_vdev(hdd_ctx,
-					       wlan_vdev_get_id(link_vdev));
-	if (!link_adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx,
+					      wlan_vdev_get_id(link_vdev));
+	if (!link_info) {
 		hdd_err("couldn't set key for link_id:%d", link_id);
 		goto release_ref;
 	}
 
 	errno = wlan_hdd_add_key_vdev(mac_handle, link_vdev, key_index,
 				      pairwise, mac_addr, params,
-				      link_id, link_adapter);
+				      link_id, link_info->adapter);
 
 release_ref:
 	wlan_key_put_link_vdev(link_vdev, WLAN_MLO_MGR_ID);
@@ -26339,7 +26341,7 @@ static int __wlan_hdd_cfg80211_get_channel(struct wiphy *wiphy,
 	bool is_legacy_phymode = false;
 	struct wlan_objmgr_vdev *vdev;
 	uint32_t chan_freq;
-	struct hdd_adapter *link_adapter;
+	struct wlan_hdd_link_info *link_info;
 	uint8_t vdev_id;
 
 	hdd_enter_dev(wdev->netdev);
@@ -26394,9 +26396,9 @@ static int __wlan_hdd_cfg80211_get_channel(struct wiphy *wiphy,
 
 	if (adapter->device_mode == QDF_STA_MODE) {
 		vdev_id = wlan_vdev_get_id(vdev);
-		link_adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-		if (link_adapter &&
-		    !hdd_cm_is_vdev_associated(link_adapter)) {
+		link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+		if (!link_info ||
+		    !hdd_cm_is_vdev_associated(link_info->adapter)) {
 			wlan_key_put_link_vdev(vdev, WLAN_OSIF_ID);
 			return -EBUSY;
 		}

+ 54 - 46
core/hdd/src/wlan_hdd_cm_connect.c

@@ -223,7 +223,7 @@ void hdd_cm_update_rssi_snr_by_bssid(struct hdd_adapter *adapter)
 void hdd_cm_handle_assoc_event(struct wlan_objmgr_vdev *vdev, uint8_t *peer_mac)
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_station_ctx *sta_ctx;
 	int ret;
 
@@ -232,14 +232,14 @@ void hdd_cm_handle_assoc_event(struct wlan_objmgr_vdev *vdev, uint8_t *peer_mac)
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
+	if (!link_info) {
 		hdd_err("adapter is NULL for vdev %d", wlan_vdev_get_id(vdev));
 		return;
 	}
 
-	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
-	ret = hdd_objmgr_set_peer_mlme_state(adapter->deflink->vdev,
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
+	ret = hdd_objmgr_set_peer_mlme_state(link_info->vdev,
 					     WLAN_ASSOC_STATE);
 	if (ret)
 		hdd_err("Peer object " QDF_MAC_ADDR_FMT " fail to set associated state",
@@ -252,7 +252,7 @@ void hdd_cm_handle_assoc_event(struct wlan_objmgr_vdev *vdev, uint8_t *peer_mac)
 	ucfg_dp_bus_bw_compute_timer_start(hdd_ctx->psoc);
 
 	if (ucfg_pkt_capture_get_pktcap_mode(hdd_ctx->psoc))
-		ucfg_pkt_capture_record_channel(adapter->deflink->vdev);
+		ucfg_pkt_capture_record_channel(link_info->vdev);
 }
 
 /**
@@ -840,19 +840,21 @@ hdd_cm_connect_failure_pre_user_update(struct wlan_objmgr_vdev *vdev,
 	struct hdd_adapter *adapter;
 	struct hdd_station_ctx *hdd_sta_ctx;
 	uint32_t time_buffer_size;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is NULL");
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, rsp->vdev_id);
+	if (!link_info) {
 		hdd_err("adapter is NULL vdev %d", rsp->vdev_id);
 		return;
 	}
 
-	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
+	adapter = link_info->adapter;
+	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
 	time_buffer_size = sizeof(hdd_sta_ctx->conn_info.connect_time);
 	qdf_mem_zero(hdd_sta_ctx->conn_info.connect_time, time_buffer_size);
 	hdd_init_scan_reject_params(hdd_ctx);
@@ -871,6 +873,7 @@ hdd_cm_connect_failure_post_user_update(struct wlan_objmgr_vdev *vdev,
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	bool is_roam = rsp->is_reassoc;
 
 	if (!hdd_ctx) {
@@ -878,8 +881,8 @@ hdd_cm_connect_failure_post_user_update(struct wlan_objmgr_vdev *vdev,
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, rsp->vdev_id);
+	if (!link_info) {
 		hdd_err("adapter is NULL for vdev %d", rsp->vdev_id);
 		return;
 	}
@@ -889,9 +892,10 @@ hdd_cm_connect_failure_post_user_update(struct wlan_objmgr_vdev *vdev,
 		hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT);
 	}
 
+	adapter = link_info->adapter;
 	wlan_hdd_connectivity_fail_event(vdev, rsp);
 	hdd_clear_roam_profile_ie(adapter);
-	ucfg_cm_reset_key(hdd_ctx->pdev, adapter->deflink->vdev_id);
+	ucfg_cm_reset_key(hdd_ctx->pdev, link_info->vdev_id);
 	hdd_wmm_dscp_initial_state(adapter);
 	hdd_debug("Disabling queues");
 	wlan_hdd_netif_queue_control(adapter,
@@ -1389,6 +1393,7 @@ hdd_cm_connect_success_pre_user_update(struct wlan_objmgr_vdev *vdev,
 	uint32_t time_buffer_size;
 	struct hdd_adapter *assoc_link_adapter;
 	bool is_immediate_power_save;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (!hdd_ctx) {
@@ -1396,13 +1401,14 @@ hdd_cm_connect_success_pre_user_update(struct wlan_objmgr_vdev *vdev,
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
-	if (!adapter) {
-		hdd_err("adapter is NULL");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
 
-	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
+	adapter = link_info->adapter;
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
 	mac_handle = hdd_adapter_get_mac_handle(adapter);
 
 	wlan_hdd_ft_set_key_delay(vdev);
@@ -1500,7 +1506,7 @@ hdd_cm_connect_success_pre_user_update(struct wlan_objmgr_vdev *vdev,
 		uapsd_mask =
 			vdev_mlme->ext_vdev_ptr->connect_info.uapsd_per_ac_bitmask;
 
-	cdp_hl_fc_set_td_limit(soc, adapter->deflink->vdev_id,
+	cdp_hl_fc_set_td_limit(soc, link_info->vdev_id,
 			       sta_ctx->conn_info.chan_freq);
 	hdd_wmm_assoc(adapter, false, uapsd_mask);
 
@@ -1544,7 +1550,7 @@ hdd_cm_connect_success_pre_user_update(struct wlan_objmgr_vdev *vdev,
 			&rsp->bssid,
 			ePeerConnected,
 			vdev_mlme->ext_vdev_ptr->connect_info.timing_meas_cap,
-			adapter->deflink->vdev_id,
+			link_info->vdev_id,
 			&vdev_mlme->ext_vdev_ptr->connect_info.chan_info,
 			adapter->device_mode);
 	}
@@ -1552,7 +1558,7 @@ hdd_cm_connect_success_pre_user_update(struct wlan_objmgr_vdev *vdev,
 	if (ucfg_ipa_is_enabled() && !is_auth_required)
 		ucfg_ipa_wlan_evt(hdd_ctx->pdev, adapter->dev,
 				  adapter->device_mode,
-				  adapter->deflink->vdev_id,
+				  link_info->vdev_id,
 				  WLAN_IPA_STA_CONNECT,
 				  rsp->bssid.bytes,
 				  WLAN_REG_IS_24GHZ_CH_FREQ(
@@ -1564,8 +1570,7 @@ hdd_cm_connect_success_pre_user_update(struct wlan_objmgr_vdev *vdev,
 	wlan_hdd_auto_shutdown_enable(hdd_ctx, false);
 
 	DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
-		adapter->deflink->vdev_id,
-		QDF_TRACE_DEFAULT_PDEV_ID,
+		link_info->vdev_id, QDF_TRACE_DEFAULT_PDEV_ID,
 		QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
 
 	if (is_roam)
@@ -1579,6 +1584,7 @@ hdd_cm_connect_success_post_user_update(struct wlan_objmgr_vdev *vdev,
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	bool is_roam = rsp->is_reassoc;
 
 	if (!hdd_ctx) {
@@ -1586,8 +1592,8 @@ hdd_cm_connect_success_post_user_update(struct wlan_objmgr_vdev *vdev,
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, rsp->vdev_id);
+	if (!link_info) {
 		hdd_err("adapter is NULL for vdev %d", rsp->vdev_id);
 		return;
 	}
@@ -1598,6 +1604,7 @@ hdd_cm_connect_success_post_user_update(struct wlan_objmgr_vdev *vdev,
 		hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT);
 	}
 
+	adapter = link_info->adapter;
 	hdd_cm_clear_pmf_stats(adapter);
 
 	if (adapter->device_mode == QDF_STA_MODE) {
@@ -1725,29 +1732,30 @@ hdd_cm_get_scan_ie_params(struct wlan_objmgr_vdev *vdev,
 			  enum dot11_mode_filter *dot11mode_filter)
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
+	struct hdd_scan_info *scan_info;
 
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is NULL");
 		return QDF_STATUS_E_INVAL;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
+	if (!link_info) {
 		hdd_err("adapter is NULL for vdev %d", wlan_vdev_get_id(vdev));
 		return QDF_STATUS_E_INVAL;
 	}
 
-	if (adapter->device_mode == QDF_P2P_CLIENT_MODE) {
-		scan_ie->ptr =
-			&adapter->scan_info.scan_add_ie.addIEdata[0];
-		scan_ie->len = adapter->scan_info.scan_add_ie.length;
-	} else if (adapter->scan_info.default_scan_ies) {
-		scan_ie->ptr = adapter->scan_info.default_scan_ies;
-		scan_ie->len = adapter->scan_info.default_scan_ies_len;
-	} else if (adapter->scan_info.scan_add_ie.length) {
-		scan_ie->ptr = adapter->scan_info.scan_add_ie.addIEdata;
-		scan_ie->len = adapter->scan_info.scan_add_ie.length;
+	scan_info = &link_info->adapter->scan_info;
+	if (link_info->adapter->device_mode == QDF_P2P_CLIENT_MODE) {
+		scan_ie->ptr = &scan_info->scan_add_ie.addIEdata[0];
+		scan_ie->len = scan_info->scan_add_ie.length;
+	} else if (scan_info->default_scan_ies) {
+		scan_ie->ptr = scan_info->default_scan_ies;
+		scan_ie->len = scan_info->default_scan_ies_len;
+	} else if (scan_info->scan_add_ie.length) {
+		scan_ie->ptr = scan_info->scan_add_ie.addIEdata;
+		scan_ie->len = scan_info->scan_add_ie.length;
 	}
 
 	*dot11mode_filter = hdd_get_dot11mode_filter(hdd_ctx);
@@ -1767,15 +1775,15 @@ QDF_STATUS hdd_cm_save_gtk(struct wlan_objmgr_vdev *vdev,
 	uint8_t replay_ctr_def[REPLAY_CTR_LEN] = {0};
 	uint8_t *replay_ctr;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is NULL");
 		return QDF_STATUS_E_INVAL;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, rsp->vdev_id);
+	if (!link_info) {
 		hdd_err("adapter is NULL for vdev %d", rsp->vdev_id);
 		return QDF_STATUS_E_INVAL;
 	}
@@ -1793,8 +1801,8 @@ QDF_STATUS hdd_cm_save_gtk(struct wlan_objmgr_vdev *vdev,
 	} else {
 		return QDF_STATUS_SUCCESS;
 	}
-	wlan_hdd_save_gtk_offload_params(adapter, kck, kck_len, kek, kek_len,
-					 replay_ctr, true);
+	wlan_hdd_save_gtk_offload_params(link_info->adapter, kck, kck_len,
+					 kek, kek_len, replay_ctr, true);
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -1808,15 +1816,15 @@ QDF_STATUS hdd_cm_save_gtk(struct wlan_objmgr_vdev *vdev,
 	uint8_t kck_len = 0;
 	uint8_t *replay_ctr;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is NULL");
 		return QDF_STATUS_E_INVAL;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, rsp->vdev_id);
+	if (!link_info) {
 		hdd_err("adapter is NULL for vdev %d", rsp->vdev_id);
 		return QDF_STATUS_E_INVAL;
 	}
@@ -1830,8 +1838,8 @@ QDF_STATUS hdd_cm_save_gtk(struct wlan_objmgr_vdev *vdev,
 	} else {
 		return QDF_STATUS_SUCCESS;
 	}
-	wlan_hdd_save_gtk_offload_params(adapter, kck, kck_len, kek, kek_len,
-					 replay_ctr, true);
+	wlan_hdd_save_gtk_offload_params(link_info->adapter, kck, kck_len,
+					 kek, kek_len, replay_ctr, true);
 
 	return QDF_STATUS_SUCCESS;
 }

+ 13 - 9
core/hdd/src/wlan_hdd_cm_disconnect.c

@@ -338,18 +338,20 @@ hdd_cm_disconnect_complete_pre_user_update(struct wlan_objmgr_vdev *vdev,
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is NULL");
 		return QDF_STATUS_E_INVAL;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
+	if (!link_info) {
 		hdd_err("adapter is NULL for vdev %d", wlan_vdev_get_id(vdev));
 		return QDF_STATUS_E_INVAL;
 	}
 
+	adapter = link_info->adapter;
 	hdd_conn_set_authenticated(adapter, false);
 	hdd_napi_serialize(0);
 	hdd_disable_and_flush_mc_addr_list(adapter, pmo_peer_disconnect);
@@ -357,7 +359,7 @@ hdd_cm_disconnect_complete_pre_user_update(struct wlan_objmgr_vdev *vdev,
 
 	hdd_handle_disassociation_event(adapter, &rsp->req.req.bssid);
 
-	wlan_rec_conn_info(adapter->deflink->vdev_id,
+	wlan_rec_conn_info(link_info->vdev_id,
 			   DEBUG_CONN_DISCONNECT_HANDLER,
 			   rsp->req.req.bssid.bytes,
 			   rsp->req.cm_id,
@@ -530,18 +532,20 @@ hdd_cm_disconnect_complete_post_user_update(struct wlan_objmgr_vdev *vdev,
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is NULL");
 		return QDF_STATUS_E_INVAL;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
+	if (!link_info) {
 		hdd_err("adapter is NULL for vdev %d", wlan_vdev_get_id(vdev));
 		return QDF_STATUS_E_INVAL;
 	}
 
+	adapter = link_info->adapter;
 	if (adapter->device_mode == QDF_STA_MODE) {
 	/* Inform FTM TIME SYNC about the disconnection with the AP */
 		hdd_ftm_time_sync_sta_state_notify(
@@ -628,20 +632,20 @@ QDF_STATUS hdd_cm_netif_queue_control(struct wlan_objmgr_vdev *vdev,
 				      enum netif_reason_type reason)
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is NULL");
 		return QDF_STATUS_E_INVAL;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, wlan_vdev_get_id(vdev));
+	if (!link_info) {
 		hdd_err("adapter is NULL for vdev %d", wlan_vdev_get_id(vdev));
 		return QDF_STATUS_E_INVAL;
 	}
 
-	wlan_hdd_netif_queue_control(adapter, action, reason);
+	wlan_hdd_netif_queue_control(link_info->adapter, action, reason);
 
 	return QDF_STATUS_SUCCESS;
 }

+ 61 - 55
core/hdd/src/wlan_hdd_dcs.c

@@ -256,7 +256,8 @@ static void hdd_dcs_cb(struct wlan_objmgr_psoc *psoc, uint8_t mac_id,
 		       uint8_t interference_type, void *arg)
 {
 	struct hdd_context *hdd_ctx = (struct hdd_context *)arg;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
+	struct sap_context *sap_ctx;
 	uint32_t count;
 	uint32_t list[MAX_NUMBER_OF_CONC_CONNECTIONS];
 	uint32_t index;
@@ -282,36 +283,36 @@ static void hdd_dcs_cb(struct wlan_objmgr_psoc *psoc, uint8_t mac_id,
 
 	count = policy_mgr_get_sap_go_count_on_mac(psoc, list, mac_id);
 	for (index = 0; index < count; index++) {
-		adapter = hdd_get_adapter_by_vdev(hdd_ctx, list[index]);
-		if (!adapter) {
+		link_info = hdd_get_link_info_by_vdev(hdd_ctx, list[index]);
+		if (!link_info) {
 			hdd_err("vdev_id %u does not exist with host",
 				list[index]);
 			return;
 		}
 
-		if (wlansap_dcs_is_wlan_interference_mitigation_enabled(
-			WLAN_HDD_GET_SAP_CTX_PTR(adapter->deflink))) {
-			hdd_debug("DCS triggers ACS on vdev_id=%u, mac_id=%u",
-				  list[index], mac_id);
-			/*
-			 * Select Random channel for low latency sap as
-			 * ACS can't select channel of same MAC from which
-			 * CSA is triggered because same MAC frequencies
-			 * will not be present in scan list and results and
-			 * selecting freq of other MAC may cause MCC with
-			 * other modes if present.
-			 */
-			if (wlan_mlme_get_ap_policy(adapter->deflink->vdev) !=
-			    HOST_CONCURRENT_AP_POLICY_UNSPECIFIED) {
-				status = hdd_dcs_select_random_chan(
-						hdd_ctx->pdev,
-						adapter->deflink->vdev);
-				if (QDF_IS_STATUS_SUCCESS(status))
-					return;
-			}
-			wlan_hdd_cfg80211_start_acs(adapter);
-			return;
+		sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(link_info);
+		if (!wlansap_dcs_is_wlan_interference_mitigation_enabled(sap_ctx))
+			continue;
+
+		hdd_debug("DCS triggers ACS on vdev_id=%u, mac_id=%u",
+			  list[index], mac_id);
+		/*
+		 * Select Random channel for low latency sap as
+		 * ACS can't select channel of same MAC from which
+		 * CSA is triggered because same MAC frequencies
+		 * will not be present in scan list and results and
+		 * selecting freq of other MAC may cause MCC with
+		 * other modes if present.
+		 */
+		if (wlan_mlme_get_ap_policy(link_info->vdev) !=
+		    HOST_CONCURRENT_AP_POLICY_UNSPECIFIED) {
+			status = hdd_dcs_select_random_chan(hdd_ctx->pdev,
+							    link_info->vdev);
+			if (QDF_IS_STATUS_SUCCESS(status))
+				return;
 		}
+		wlan_hdd_cfg80211_start_acs(link_info->adapter);
+		return;
 	}
 }
 
@@ -335,18 +336,18 @@ static qdf_freq_t hdd_dcs_afc_sel_chan_cb(void *arg,
 					  enum phy_ch_width *pref_bw)
 {
 	struct hdd_context *hdd_ctx = (struct hdd_context *)arg;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct sap_context *sap_ctx;
 	qdf_freq_t target_freq;
 
 	if (!hdd_ctx)
 		return 0;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter)
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info)
 		return 0;
 
-	sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(adapter->deflink);
+	sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(link_info);
 	if (!sap_ctx)
 		return 0;
 
@@ -384,7 +385,7 @@ QDF_STATUS hdd_dcs_hostapd_set_chan(struct hdd_context *hdd_ctx,
 	uint8_t mac_id;
 	uint32_t list[MAX_NUMBER_OF_CONC_CONNECTIONS];
 	uint32_t conn_index, count;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	uint32_t dcs_ch = wlan_reg_freq_to_chan(hdd_ctx->pdev, dcs_ch_freq);
 
 	status = policy_mgr_get_mac_id_by_session_id(hdd_ctx->psoc, vdev_id,
@@ -402,41 +403,44 @@ QDF_STATUS hdd_dcs_hostapd_set_chan(struct hdd_context *hdd_ctx,
 	 * The CSA triggered by DCS will be done in serial.
 	 */
 	for (conn_index = 0; conn_index < count; conn_index++) {
-		adapter = hdd_get_adapter_by_vdev(hdd_ctx, list[conn_index]);
-		if (!adapter) {
+		link_info =
+			hdd_get_link_info_by_vdev(hdd_ctx, list[conn_index]);
+		if (!link_info) {
 			hdd_err("vdev_id %u does not exist with host",
 				list[conn_index]);
 			return QDF_STATUS_E_INVAL;
 		}
 
-		ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter->deflink);
-		sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(adapter->deflink);
+		ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(link_info);
+		sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(link_info);
 		if (ap_ctx->operating_chan_freq != dcs_ch_freq)
 			wlansap_dcs_set_vdev_starting(sap_ctx, true);
 		else
 			wlansap_dcs_set_vdev_starting(sap_ctx, false);
 	}
 	for (conn_index = 0; conn_index < count; conn_index++) {
-		adapter = hdd_get_adapter_by_vdev(hdd_ctx, list[conn_index]);
-		if (!adapter) {
+		link_info =
+			hdd_get_link_info_by_vdev(hdd_ctx, list[conn_index]);
+		if (!link_info) {
 			hdd_err("vdev_id %u does not exist with host",
 				list[conn_index]);
 			return QDF_STATUS_E_INVAL;
 		}
 
-		ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter->deflink);
-		if (ap_ctx->operating_chan_freq != dcs_ch_freq) {
-			hdd_ctx->acs_policy.acs_chan_freq = AUTO_CHANNEL_SELECT;
-			hdd_debug("dcs triggers old ch:%d new ch:%d",
-				  ap_ctx->operating_chan_freq, dcs_ch_freq);
-			wlan_hdd_set_sap_csa_reason(hdd_ctx->psoc,
-						    adapter->deflink->vdev_id,
-						    CSA_REASON_DCS);
-			status = hdd_switch_sap_channel(adapter, dcs_ch, true);
-			if (status == QDF_STATUS_SUCCESS)
-				status = QDF_STATUS_E_PENDING;
-			return status;
-		}
+		ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(link_info);
+		if (ap_ctx->operating_chan_freq == dcs_ch_freq)
+			continue;
+
+		hdd_ctx->acs_policy.acs_chan_freq = AUTO_CHANNEL_SELECT;
+		hdd_debug("dcs triggers old ch:%d new ch:%d",
+			  ap_ctx->operating_chan_freq, dcs_ch_freq);
+		wlan_hdd_set_sap_csa_reason(hdd_ctx->psoc,
+					    link_info->vdev_id, CSA_REASON_DCS);
+		status = hdd_switch_sap_channel(link_info->adapter,
+						dcs_ch, true);
+		if (status == QDF_STATUS_SUCCESS)
+			status = QDF_STATUS_E_PENDING;
+		return status;
 	}
 
 	return QDF_STATUS_SUCCESS;
@@ -459,8 +463,9 @@ static void hdd_dcs_hostapd_enable_wlan_interference_mitigation(
 {
 	QDF_STATUS status;
 	uint8_t mac_id;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_ap_ctx *ap_ctx;
+	struct sap_context *sap_ctx;
 
 	status = policy_mgr_get_mac_id_by_session_id(hdd_ctx->psoc, vdev_id,
 						     &mac_id);
@@ -468,15 +473,16 @@ static void hdd_dcs_hostapd_enable_wlan_interference_mitigation(
 		hdd_err("get mac id failed");
 		return;
 	}
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
+
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
 		hdd_err("vdev_id %u does not exist with host", vdev_id);
 		return;
 	}
 
-	ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter->deflink);
-	if (wlansap_dcs_is_wlan_interference_mitigation_enabled(
-			WLAN_HDD_GET_SAP_CTX_PTR(adapter->deflink)) &&
+	ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(link_info);
+	sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(link_info);
+	if (wlansap_dcs_is_wlan_interference_mitigation_enabled(sap_ctx) &&
 	    !WLAN_REG_IS_24GHZ_CH_FREQ(ap_ctx->operating_chan_freq))
 		ucfg_config_dcs_event_data(hdd_ctx->psoc, mac_id, true);
 }

+ 19 - 16
core/hdd/src/wlan_hdd_hostapd.c

@@ -5596,7 +5596,7 @@ hdd_handle_acs_2g_preferred_sap_conc(struct wlan_objmgr_psoc *psoc,
 	struct hdd_hostapd_state *hostapd_state;
 	uint8_t go_vdev_id = WLAN_UMAC_VDEV_ID_MAX;
 	qdf_freq_t go_ch_freq = 0, go_new_ch_freq;
-	struct hdd_adapter *go_adapter;
+	struct wlan_hdd_link_info *go_link_info;
 
 	if (adapter->device_mode != QDF_SAP_MODE)
 		return;
@@ -5642,17 +5642,19 @@ hdd_handle_acs_2g_preferred_sap_conc(struct wlan_objmgr_psoc *psoc,
 		hdd_err("no available 5G channel");
 		return;
 	}
-	go_adapter = hdd_get_adapter_by_vdev(adapter->hdd_ctx, go_vdev_id);
-	if (hdd_validate_adapter(go_adapter))
+
+	go_link_info = hdd_get_link_info_by_vdev(adapter->hdd_ctx, go_vdev_id);
+	if (!go_link_info || hdd_validate_adapter(go_link_info->adapter))
 		return;
 
 	wlan_hdd_set_sap_csa_reason(psoc, go_vdev_id,
 				    CSA_REASON_SAP_ACS);
-	hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(go_adapter->deflink);
+	hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(go_link_info);
 	qdf_event_reset(&hostapd_state->qdf_event);
 
-	ret = hdd_softap_set_channel_change(go_adapter->dev, go_new_ch_freq,
-					    CH_WIDTH_80MHZ, false);
+	ret = hdd_softap_set_channel_change(go_link_info->adapter->dev,
+					    go_new_ch_freq, CH_WIDTH_80MHZ,
+					    false);
 	if (ret) {
 		hdd_err("CSA failed to %d, ret %d", go_new_ch_freq, ret);
 		return;
@@ -5695,7 +5697,7 @@ hdd_handle_p2p_go_for_3rd_ap_conc(struct wlan_objmgr_psoc *psoc,
 	struct hdd_hostapd_state *hostapd_state;
 	uint8_t go_vdev_id;
 	qdf_freq_t go_ch_freq, go_new_ch_freq;
-	struct hdd_adapter *go_adapter;
+	struct wlan_hdd_link_info *go_link_info;
 
 	if (adapter->device_mode != QDF_SAP_MODE)
 		return false;
@@ -5742,17 +5744,18 @@ hdd_handle_p2p_go_for_3rd_ap_conc(struct wlan_objmgr_psoc *psoc,
 		return false;
 	}
 
-	go_adapter = hdd_get_adapter_by_vdev(adapter->hdd_ctx, go_vdev_id);
-	if (hdd_validate_adapter(go_adapter))
+	go_link_info = hdd_get_link_info_by_vdev(adapter->hdd_ctx, go_vdev_id);
+	if (!go_link_info || hdd_validate_adapter(go_link_info->adapter))
 		return false;
 
 	wlan_hdd_set_sap_csa_reason(psoc, go_vdev_id,
 				    CSA_REASON_SAP_FIX_CH_CONC_WITH_GO);
-	hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(go_adapter->deflink);
+	hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(go_link_info);
 	qdf_event_reset(&hostapd_state->qdf_event);
 
-	ret = hdd_softap_set_channel_change(go_adapter->dev, go_new_ch_freq,
-					    CH_WIDTH_80MHZ, false);
+	ret = hdd_softap_set_channel_change(go_link_info->adapter->dev,
+					    go_new_ch_freq, CH_WIDTH_80MHZ,
+					    false);
 	if (ret) {
 		hdd_err("CSA failed to %d, ret %d", go_new_ch_freq, ret);
 		return false;
@@ -7254,18 +7257,18 @@ wlan_hdd_get_sap_ch_params(struct hdd_context *hdd_ctx,
 			   uint8_t vdev_id, uint32_t freq,
 			   struct ch_params *ch_params)
 {
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx || !ch_params) {
 		hdd_err("invalid hdd_ctx or ch_params");
 		return QDF_STATUS_E_INVAL;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter)
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info)
 		return QDF_STATUS_E_INVAL;
 
-	if (!wlan_sap_get_ch_params(WLAN_HDD_GET_SAP_CTX_PTR(adapter->deflink),
+	if (!wlan_sap_get_ch_params(WLAN_HDD_GET_SAP_CTX_PTR(link_info),
 				    ch_params))
 		wlan_reg_set_channel_params_for_pwrmode(hdd_ctx->pdev, freq, 0,
 							ch_params,

+ 151 - 109
core/hdd/src/wlan_hdd_main.c

@@ -618,11 +618,16 @@ void wlan_hdd_txrx_pause_cb(uint8_t vdev_id,
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx)
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info)
+		return;
+
+	adapter =  link_info->adapter;
 	wlan_hdd_mod_fc_timer(adapter, action);
 	wlan_hdd_netif_queue_control(adapter, action, reason);
 }
@@ -3768,17 +3773,20 @@ int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate)
 static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev(
 			struct wlan_objmgr_psoc *psoc, uint8_t vdev_id)
 {
-	struct hdd_adapter *adapter = NULL;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	struct hdd_adapter *adapter;
+	enum policy_mgr_con_mode mode;
+	struct wlan_hdd_link_info *link_info;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("Adapter is NULL");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return PM_MAX_NUM_OF_MODE;
 	}
 
-	return	policy_mgr_convert_device_mode_to_qdf_type(
-			adapter->device_mode);
+	adapter = link_info->adapter;
+	mode = policy_mgr_convert_device_mode_to_qdf_type(adapter->device_mode);
+	return mode;
 }
 
 /**
@@ -5578,7 +5586,7 @@ vdev_ref:
 static void hdd_set_mac_addr_event_cb(uint8_t vdev_id, uint8_t status)
 {
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct osif_request *req;
 	uint32_t *fw_response_status;
 
@@ -5588,13 +5596,13 @@ static void hdd_set_mac_addr_event_cb(uint8_t vdev_id, uint8_t status)
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
 		hdd_err("No adapter found for VDEV ID:%d", vdev_id);
 		return;
 	}
 
-	req = osif_request_get(adapter->set_mac_addr_req_ctx);
+	req = osif_request_get(link_info->adapter->set_mac_addr_req_ctx);
 	if (!req) {
 		osif_err("Obsolete request for VDEV ID:%d", vdev_id);
 		return;
@@ -6491,26 +6499,28 @@ QDF_STATUS hdd_sme_close_session_callback(uint8_t vdev_id)
 {
 	struct hdd_adapter *adapter;
 	struct hdd_context *hdd_ctx;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (!hdd_ctx)
 		return QDF_STATUS_E_FAILURE;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("NULL adapter");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return QDF_STATUS_E_INVAL;
 	}
 
+	adapter = link_info->adapter;
 	if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) {
 		hdd_err("Invalid magic");
 		return QDF_STATUS_NOT_INITIALIZED;
 	}
 
 	clear_bit(SME_SESSION_OPENED, &adapter->event_flags);
-	qdf_spin_lock_bh(&adapter->deflink->vdev_lock);
-	adapter->deflink->vdev_id = WLAN_UMAC_VDEV_ID_MAX;
-	qdf_spin_unlock_bh(&adapter->deflink->vdev_lock);
+	qdf_spin_lock_bh(&link_info->vdev_lock);
+	link_info->vdev_id = WLAN_UMAC_VDEV_ID_MAX;
+	qdf_spin_unlock_bh(&link_info->vdev_lock);
 
 	/*
 	 * We can be blocked while waiting for scheduled work to be
@@ -6520,7 +6530,7 @@ QDF_STATUS hdd_sme_close_session_callback(uint8_t vdev_id)
 	 * valid, before signaling completion
 	 */
 	if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)
-		complete(&adapter->deflink->vdev_destroy_event);
+		complete(&link_info->vdev_destroy_event);
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -6601,17 +6611,17 @@ static int hdd_vdev_destroy_event_wait(struct hdd_context *hdd_ctx,
 	long rc;
 	QDF_STATUS status;
 	uint8_t vdev_id;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	vdev_id = wlan_vdev_get_id(vdev);
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is NULL, return");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return -EINVAL;
 	}
 
 	/* close sme session (destroy vdev in firmware via legacy API) */
-	INIT_COMPLETION(adapter->deflink->vdev_destroy_event);
+	INIT_COMPLETION(link_info->vdev_destroy_event);
 	status = sme_vdev_delete(hdd_ctx->mac_handle, vdev);
 	if (QDF_IS_STATUS_ERROR(status)) {
 		hdd_err("vdev %d: failed to delete with status:%d",
@@ -6621,11 +6631,11 @@ static int hdd_vdev_destroy_event_wait(struct hdd_context *hdd_ctx,
 
 	/* block on a completion variable until sme session is closed */
 	rc = wait_for_completion_timeout(
-			&adapter->deflink->vdev_destroy_event,
+			&link_info->vdev_destroy_event,
 			msecs_to_jiffies(SME_CMD_VDEV_CREATE_DELETE_TIMEOUT));
 	if (!rc) {
 		hdd_err("vdev %d: timed out waiting for delete", vdev_id);
-		clear_bit(SME_SESSION_OPENED, &adapter->event_flags);
+		clear_bit(SME_SESSION_OPENED, &link_info->adapter->event_flags);
 		sme_cleanup_session(hdd_ctx->mac_handle, vdev_id);
 		cds_flush_logs(WLAN_LOG_TYPE_FATAL,
 			       WLAN_LOG_INDICATOR_HOST_DRIVER,
@@ -9759,20 +9769,29 @@ struct hdd_adapter *hdd_get_adapter_by_macaddr(struct hdd_context *hdd_ctx,
 	return NULL;
 }
 
-struct hdd_adapter *hdd_get_adapter_by_vdev(struct hdd_context *hdd_ctx,
-					    uint32_t vdev_id)
+struct wlan_hdd_link_info *
+hdd_get_link_info_by_vdev(struct hdd_context *hdd_ctx, uint32_t vdev_id)
 {
 	struct hdd_adapter *adapter, *next_adapter = NULL;
 	wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_GET_ADAPTER_BY_VDEV;
+	uint8_t link_idx;
+	struct wlan_hdd_link_info *link_info;
+
+	if (vdev_id == WLAN_INVALID_VDEV_ID)
+		return NULL;
 
 	hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter,
 					   dbgid) {
-		if (adapter->deflink->vdev_id == vdev_id) {
-			hdd_adapter_dev_put_debug(adapter, dbgid);
-			if (next_adapter)
-				hdd_adapter_dev_put_debug(next_adapter,
-							  dbgid);
-			return adapter;
+		hdd_adapter_for_each_link_entry(adapter, link_idx) {
+			link_info = hdd_adapter_get_link_info_ptr(adapter,
+								  link_idx);
+			if (link_info->vdev_id == vdev_id) {
+				hdd_adapter_dev_put_debug(adapter, dbgid);
+				if (next_adapter)
+					hdd_adapter_dev_put_debug(next_adapter,
+								  dbgid);
+				return link_info;
+			}
 		}
 		hdd_adapter_dev_put_debug(adapter, dbgid);
 	}
@@ -9883,19 +9902,19 @@ struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx,
 enum QDF_OPMODE hdd_get_device_mode(uint32_t vdev_id)
 {
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (!hdd_ctx)
 		return QDF_MAX_NO_OF_MODE;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("Invalid HDD adapter");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return QDF_MAX_NO_OF_MODE;
 	}
 
-	return adapter->device_mode;
+	return link_info->adapter->device_mode;
 }
 
 uint32_t hdd_get_operating_chan_freq(struct hdd_context *hdd_ctx,
@@ -10913,7 +10932,7 @@ bool wlan_hdd_sta_get_dot11mode(hdd_cb_handle context, uint8_t vdev_id,
 				enum qca_wlan_802_11_mode *dot11_mode)
 {
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_station_ctx *sta_ctx;
 	enum csr_cfgdot11mode mode;
 
@@ -10921,14 +10940,14 @@ bool wlan_hdd_sta_get_dot11mode(hdd_cb_handle context, uint8_t vdev_id,
 	if (!hdd_ctx)
 		return false;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter)
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info)
 		return false;
 
-	if (!hdd_cm_is_vdev_associated(adapter))
+	if (!hdd_cm_is_vdev_associated(link_info->adapter))
 		return false;
 
-	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
 	mode = sta_ctx->conn_info.dot11mode;
 	*dot11_mode = hdd_convert_cfgdot11mode_to_80211mode(mode);
 	return true;
@@ -10947,7 +10966,7 @@ bool wlan_hdd_get_ap_client_count(hdd_cb_handle context, uint8_t vdev_id,
 				  uint16_t *client_count)
 {
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_ap_ctx *ap_ctx;
 	enum qca_wlan_802_11_mode i;
 
@@ -10956,13 +10975,14 @@ bool wlan_hdd_get_ap_client_count(hdd_cb_handle context, uint8_t vdev_id,
 		hdd_err("hdd ctx is null");
 		return false;
 	}
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return false;
 	}
 
-	ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter->deflink);
+	ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(link_info);
 	if (!ap_ctx->ap_active)
 		return false;
 	for (i = QCA_WLAN_802_11_MODE_11B; i < QCA_WLAN_802_11_MODE_INVALID;
@@ -10982,7 +11002,7 @@ static inline
 bool wlan_hdd_sta_ndi_connected(hdd_cb_handle context, uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_station_ctx *sta_ctx;
 
 	hdd_ctx = hdd_cb_handle_to_context(context);
@@ -10991,13 +11011,13 @@ bool wlan_hdd_sta_ndi_connected(hdd_cb_handle context, uint8_t vdev_id)
 		return false;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return false;
 	}
 
-	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
 	if (sta_ctx->conn_info.conn_state != eConnectionState_NdiConnected)
 		return false;
 
@@ -11055,19 +11075,20 @@ static inline bool wlan_hdd_is_roaming_in_progress(hdd_cb_handle context)
 static inline bool hdd_is_ap_active(hdd_cb_handle context, uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = hdd_cb_handle_to_context(context);
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is null");
 		return false;
 	}
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return false;
 	}
-	return WLAN_HDD_GET_AP_CTX_PTR(adapter->deflink)->ap_active;
+	return WLAN_HDD_GET_AP_CTX_PTR(link_info)->ap_active;
 }
 
 /**
@@ -11106,19 +11127,20 @@ int wlan_hdd_napi_apply_throughput_policy(hdd_cb_handle context,
 static inline bool hdd_is_link_adapter(hdd_cb_handle context, uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = hdd_cb_handle_to_context(context);
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is null");
 		return false;
 	}
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return false;
 	}
-	return hdd_adapter_is_link_adapter(adapter);
+	return hdd_adapter_is_link_adapter(link_info->adapter);
 }
 
 /**
@@ -11132,18 +11154,19 @@ static inline
 uint32_t hdd_get_pause_map(hdd_cb_handle context, uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx = hdd_cb_handle_to_context(context);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is null");
 		return 0;
 	}
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return 0;
 	}
-	return adapter->pause_map;
+	return link_info->adapter->pause_map;
 }
 
 /**
@@ -11277,19 +11300,20 @@ static inline void wlan_hdd_send_mscs_action_frame(hdd_cb_handle context,
 						   uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = hdd_cb_handle_to_context(context);
 	if (!hdd_ctx) {
 		hdd_err("hdd_ctx is null");
 		return;
 	}
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
-	hdd_send_mscs_action_frame(hdd_ctx, adapter);
+	hdd_send_mscs_action_frame(hdd_ctx, link_info->adapter);
 }
 
 #else
@@ -12541,6 +12565,7 @@ void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind)
 		(struct ieee80211_mgmt *)frame_ind->frameBuf;
 	struct wlan_objmgr_vdev *vdev;
 	wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_INDICATE_MGMT_FRAME;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (wlan_hdd_validate_context(hdd_ctx))
@@ -12553,10 +12578,11 @@ void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind)
 
 	if (SME_SESSION_ID_ANY == frame_ind->sessionId) {
 		for (i = 0; i < WLAN_MAX_VDEVS; i++) {
-			adapter =
-				hdd_get_adapter_by_vdev(hdd_ctx, i);
-			if (adapter)
+			link_info = hdd_get_link_info_by_vdev(hdd_ctx, i);
+			if (link_info) {
+				adapter = link_info->adapter;
 				break;
+			}
 		}
 	} else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) {
 		num_adapters = 0;
@@ -12599,8 +12625,15 @@ void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind)
 
 		adapter = NULL;
 	} else {
-		adapter = hdd_get_adapter_by_vdev(hdd_ctx,
-						  frame_ind->sessionId);
+		link_info = hdd_get_link_info_by_vdev(hdd_ctx,
+						      frame_ind->sessionId);
+
+		if (!link_info) {
+			hdd_err("Invalid vdev");
+			return;
+		}
+
+		adapter = link_info->adapter;
 	}
 
 	if ((adapter) &&
@@ -14698,9 +14731,9 @@ static void wlan_hdd_p2p_lo_event_callback(void *context,
 {
 	struct hdd_context *hdd_ctx = context;
 	struct sk_buff *vendor_event;
-	struct hdd_adapter *adapter;
 	enum qca_nl80211_vendor_subcmds_index index =
 		QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_enter();
 
@@ -14709,8 +14742,8 @@ static void wlan_hdd_p2p_lo_event_callback(void *context,
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, evt->vdev_id);
+	if (!link_info) {
 		hdd_err("Cannot find adapter by vdev_id = %d",
 				evt->vdev_id);
 		return;
@@ -14718,7 +14751,7 @@ static void wlan_hdd_p2p_lo_event_callback(void *context,
 
 	vendor_event =
 		wlan_cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
-						 &adapter->wdev,
+						 &link_info->adapter->wdev,
 						 sizeof(uint32_t) +
 						 NLMSG_HDRLEN,
 						 index, GFP_KERNEL);
@@ -16334,9 +16367,10 @@ void hdd_wlan_update_target_info(struct hdd_context *hdd_ctx, void *context)
  */
 QDF_STATUS hdd_md_host_evt_cb(void *ctx, struct sir_md_evt *event)
 {
-	struct hdd_adapter *adapter = NULL;
+	struct hdd_adapter *adapter;
 	struct hdd_context *hdd_ctx;
 	struct sme_motion_det_en motion_det;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!ctx || !event)
 		return QDF_STATUS_E_INVAL;
@@ -16345,12 +16379,14 @@ QDF_STATUS hdd_md_host_evt_cb(void *ctx, struct sir_md_evt *event)
 	if (wlan_hdd_validate_context(hdd_ctx))
 		return QDF_STATUS_E_INVAL;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, event->vdev_id);
-	if (!adapter || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, event->vdev_id);
+	if (!link_info ||
+	    WLAN_HDD_ADAPTER_MAGIC != link_info->adapter->magic) {
 		hdd_err("Invalid adapter or adapter has invalid magic");
 		return QDF_STATUS_E_INVAL;
 	}
 
+	adapter = link_info->adapter;
 	/* When motion is detected, reset the motion_det_in_progress flag */
 	if (event->status)
 		adapter->motion_det_in_progress = false;
@@ -16380,8 +16416,8 @@ QDF_STATUS hdd_md_host_evt_cb(void *ctx, struct sir_md_evt *event)
  */
 QDF_STATUS hdd_md_bl_evt_cb(void *ctx, struct sir_md_bl_evt *event)
 {
-	struct hdd_adapter *adapter = NULL;
 	struct hdd_context *hdd_ctx;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!ctx || !event)
 		return QDF_STATUS_E_INVAL;
@@ -16390,8 +16426,9 @@ QDF_STATUS hdd_md_bl_evt_cb(void *ctx, struct sir_md_bl_evt *event)
 	if (wlan_hdd_validate_context(hdd_ctx))
 		return QDF_STATUS_E_INVAL;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, event->vdev_id);
-	if (!adapter || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, event->vdev_id);
+	if (!link_info ||
+	    WLAN_HDD_ADAPTER_MAGIC != link_info->adapter->magic) {
 		hdd_err("Invalid adapter or adapter has invalid magic");
 		return QDF_STATUS_E_INVAL;
 	}
@@ -16399,7 +16436,8 @@ QDF_STATUS hdd_md_bl_evt_cb(void *ctx, struct sir_md_bl_evt *event)
 	hdd_debug("Motion Detection Baseline CB vdev id=%u, baseline val = %d",
 		  event->vdev_id, event->bl_baseline_value);
 
-	adapter->motion_det_baseline_value = event->bl_baseline_value;
+	link_info->adapter->motion_det_baseline_value =
+						event->bl_baseline_value;
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -17844,6 +17882,7 @@ static void wlan_hdd_state_ctrl_param_destroy(void)
 static void hdd_send_scan_done_complete_cb(uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_adapter *adapter;
 	struct sk_buff *vendor_event;
 	uint32_t len;
@@ -17852,12 +17891,13 @@ static void hdd_send_scan_done_complete_cb(uint8_t vdev_id)
 	if (!hdd_ctx)
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("No adapter found for vdev id:%d", vdev_id);
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev id:%d", vdev_id);
 		return;
 	}
 
+	adapter = link_info->adapter;
 	len = NLMSG_HDRLEN;
 	vendor_event =
 		wlan_cfg80211_vendor_event_alloc(
@@ -20039,11 +20079,11 @@ int wlan_hdd_send_mcc_latency(struct hdd_adapter *adapter, int set_value)
 	return 0;
 }
 
-struct hdd_adapter *wlan_hdd_get_adapter_from_vdev(struct wlan_objmgr_psoc
-					      *psoc, uint8_t vdev_id)
+struct hdd_adapter *
+wlan_hdd_get_adapter_from_vdev(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id)
 {
-	struct hdd_adapter *adapter = NULL;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	struct wlan_hdd_link_info *link_info;
 
 	/*
 	 * Currently PSOC is not being used. But this logic will
@@ -20051,11 +20091,13 @@ struct hdd_adapter *wlan_hdd_get_adapter_from_vdev(struct wlan_objmgr_psoc
 	 * HDD context per PSOC in place. This would break if
 	 * multiple vdev objects reuse the vdev id.
 	 */
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter)
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
 		hdd_err("Get adapter by vdev id failed");
+		return NULL;
+	}
 
-	return adapter;
+	return link_info->adapter;
 }
 
 int hdd_get_rssi_snr_by_bssid(struct hdd_adapter *adapter, const uint8_t *bssid,
@@ -20122,16 +20164,15 @@ int hdd_reset_limit_off_chan(struct hdd_adapter *adapter)
 void hdd_hidden_ssid_enable_roaming(hdd_handle_t hdd_handle, uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle);
-	struct hdd_adapter *adapter;
-
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
+	struct wlan_hdd_link_info *link_info;
 
-	if (!adapter) {
-		hdd_err("Adapter is null");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
 	/* enable roaming on all adapters once hdd get hidden ssid rsp */
-	wlan_hdd_enable_roaming(adapter, RSO_START_BSS);
+	wlan_hdd_enable_roaming(link_info->adapter, RSO_START_BSS);
 }
 
 #ifdef WLAN_FEATURE_PKT_CAPTURE
@@ -20282,26 +20323,27 @@ wlan_hdd_add_monitor_check(struct hdd_context *hdd_ctx,
 
 void hdd_sme_monitor_mode_callback(uint8_t vdev_id)
 {
-	struct hdd_adapter *adapter;
 	struct hdd_context *hdd_ctx;
+	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (!hdd_ctx)
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
 		hdd_err_rl("NULL adapter");
 		return;
 	}
 
+	adapter = link_info->adapter;
 	if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) {
 		hdd_err_rl("Invalid magic");
 		return;
 	}
 
-	if (adapter->magic == WLAN_HDD_ADAPTER_MAGIC)
-		qdf_event_set(&adapter->qdf_monitor_mode_vdev_up_event);
+	qdf_event_set(&adapter->qdf_monitor_mode_vdev_up_event);
 
 	hdd_debug("monitor mode vdev up completed");
 	adapter->monitor_mode_vdev_up_in_progress = false;

+ 12 - 12
core/hdd/src/wlan_hdd_medium_assess.c

@@ -131,20 +131,20 @@ static void hdd_cca_notification_cb(uint8_t vdev_id,
 				    int status)
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct sk_buff *event;
 
 	if (wlan_hdd_validate_context(hdd_ctx))
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
 		hdd_err("Failed to find adapter of vdev %d", vdev_id);
 		return;
 	}
 
 	event = wlan_cfg80211_vendor_event_alloc(
-				hdd_ctx->wiphy, &adapter->wdev,
+				hdd_ctx->wiphy, &link_info->adapter->wdev,
 				get_cca_report_len(),
 				QCA_NL80211_VENDOR_SUBCMD_MEDIUM_ASSESS_INDEX,
 				GFP_KERNEL);
@@ -339,7 +339,7 @@ static void hdd_congestion_notification_report(uint8_t vdev_id,
 					       uint8_t congestion)
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct sk_buff *event;
 	enum qca_nl80211_vendor_subcmds_index index =
 		QCA_NL80211_VENDOR_SUBCMD_MEDIUM_ASSESS_INDEX;
@@ -347,14 +347,14 @@ static void hdd_congestion_notification_report(uint8_t vdev_id,
 	if (wlan_hdd_validate_context(hdd_ctx))
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
 		hdd_err("Failed to find adapter of vdev %d", vdev_id);
 		return;
 	}
 
 	event = wlan_cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
-						 &adapter->wdev,
+						 &link_info->adapter->wdev,
 						 get_congestion_report_len(),
 						 index, GFP_KERNEL);
 	if (!event) {
@@ -701,7 +701,7 @@ static void hdd_medium_assess_expire_handler(void *arg)
 	struct wlan_objmgr_vdev *vdev;
 	struct request_info info = {0};
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	uint8_t vdev_id = INVALID_VDEV_ID, pdev_id;
 	uint8_t index, i;
 
@@ -723,13 +723,13 @@ static void hdd_medium_assess_expire_handler(void *arg)
 	if (vdev_id == INVALID_VDEV_ID)
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
 		hdd_err("Failed to find adapter of vdev %d", vdev_id);
 		return;
 	}
 
-	vdev = hdd_objmgr_get_vdev_by_user(adapter->deflink, WLAN_CP_STATS_ID);
+	vdev = hdd_objmgr_get_vdev_by_user(link_info, WLAN_CP_STATS_ID);
 	if (!vdev)
 		return;
 

+ 42 - 54
core/hdd/src/wlan_hdd_nan_datapath.c

@@ -873,6 +873,7 @@ int hdd_ndi_delete(uint8_t vdev_id, const char *iface_name,
 {
 	int ret;
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_station_ctx *sta_ctx;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	struct wlan_objmgr_vdev *vdev;
@@ -881,19 +882,16 @@ int hdd_ndi_delete(uint8_t vdev_id, const char *iface_name,
 		return -EINVAL;
 
 	/* check if adapter by vdev_id is valid NDI */
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter || !WLAN_HDD_IS_NDI(adapter)) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info || !WLAN_HDD_IS_NDI(link_info->adapter)) {
 		hdd_err("NAN data interface %s is not available", iface_name);
 		return -EINVAL;
 	}
 
-	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
-	if (!sta_ctx) {
-		hdd_err("sta_ctx is NULL");
-		return -EINVAL;
-	}
+	adapter = link_info->adapter;
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
 
-	vdev = hdd_objmgr_get_vdev_by_user(adapter->deflink, WLAN_OSIF_NAN_ID);
+	vdev = hdd_objmgr_get_vdev_by_user(link_info, WLAN_OSIF_NAN_ID);
 	if (!vdev) {
 		hdd_err("vdev is NULL");
 		return -EINVAL;
@@ -920,6 +918,7 @@ void hdd_ndi_drv_ndi_create_rsp_handler(uint8_t vdev_id,
 {
 	struct hdd_context *hdd_ctx;
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_station_ctx *sta_ctx;
 	struct csr_roam_info *roam_info;
 	uint16_t ndp_inactivity_timeout = 0;
@@ -934,17 +933,14 @@ void hdd_ndi_drv_ndi_create_rsp_handler(uint8_t vdev_id,
 	if (!hdd_ctx)
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
 
-	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
-	if (!sta_ctx) {
-		hdd_err("sta_ctx is null");
-		return;
-	}
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
+	adapter = link_info->adapter;
 
 	roam_info = qdf_mem_malloc(sizeof(*roam_info));
 	if (!roam_info)
@@ -952,8 +948,7 @@ void hdd_ndi_drv_ndi_create_rsp_handler(uint8_t vdev_id,
 
 	if (ndi_rsp->status == QDF_STATUS_SUCCESS) {
 		hdd_alert("NDI interface successfully created");
-		vdev = hdd_objmgr_get_vdev_by_user(adapter->deflink,
-						   WLAN_OSIF_NAN_ID);
+		vdev = hdd_objmgr_get_vdev_by_user(link_info, WLAN_OSIF_NAN_ID);
 		if (!vdev) {
 			qdf_mem_free(roam_info);
 			hdd_err("vdev is NULL");
@@ -994,10 +989,9 @@ void hdd_ndi_drv_ndi_create_rsp_handler(uint8_t vdev_id,
 				goto error;
 			}
 		}
-		status = sme_send_multi_pdev_vdev_set_params(
-						    MLME_VDEV_SETPARAM,
-						    adapter->deflink->vdev_id,
-						    setparam, index);
+		status = sme_send_multi_pdev_vdev_set_params(MLME_VDEV_SETPARAM,
+							     link_info->vdev_id,
+							     setparam, index);
 		if (QDF_IS_STATUS_ERROR(status))
 			hdd_err("failed to send vdev set params");
 	} else {
@@ -1017,26 +1011,27 @@ error:
 void hdd_ndi_close(uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (!hdd_ctx)
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
 
-	adapter->is_virtual_iface = true;
-	hdd_close_ndi(adapter);
+	link_info->adapter->is_virtual_iface = true;
+	hdd_close_ndi(link_info->adapter);
 }
 
 void hdd_ndi_drv_ndi_delete_rsp_handler(uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx;
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_station_ctx *sta_ctx;
 	struct qdf_mac_addr bc_mac_addr = QDF_MAC_ADDR_BCAST_INIT;
 
@@ -1044,17 +1039,14 @@ void hdd_ndi_drv_ndi_delete_rsp_handler(uint8_t vdev_id)
 	if (!hdd_ctx)
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
 
-	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
-	if (!sta_ctx) {
-		hdd_err("sta_ctx is null");
-		return;
-	}
+	adapter = link_info->adapter;
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
 
 	hdd_delete_peer(sta_ctx, &bc_mac_addr);
 
@@ -1114,6 +1106,7 @@ int hdd_ndp_new_peer_handler(uint8_t vdev_id, uint16_t sta_id,
 {
 	struct hdd_context *hdd_ctx;
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_station_ctx *sta_ctx;
 	struct csr_roam_info *roam_info;
 	struct wlan_objmgr_vdev *vdev;
@@ -1122,17 +1115,14 @@ int hdd_ndp_new_peer_handler(uint8_t vdev_id, uint16_t sta_id,
 	if (!hdd_ctx)
 		return -EINVAL;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return -EINVAL;
 	}
 
-	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
-	if (!sta_ctx) {
-		hdd_err("sta_ctx is null");
-		return -EINVAL;
-	}
+	adapter = link_info->adapter;
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
 
 	/* save peer in ndp ctx */
 	if (!hdd_save_peer(sta_ctx, peer_mac_addr)) {
@@ -1160,7 +1150,7 @@ int hdd_ndp_new_peer_handler(uint8_t vdev_id, uint16_t sta_id,
 		hdd_disable_rx_ol_in_concurrency(true);
 	}
 
-	vdev = hdd_objmgr_get_vdev_by_user(adapter->deflink, WLAN_DP_ID);
+	vdev = hdd_objmgr_get_vdev_by_user(link_info, WLAN_DP_ID);
 	if (vdev) {
 		ucfg_dp_bus_bw_compute_prev_txrx_stats(vdev);
 		hdd_objmgr_put_vdev_by_user(vdev, WLAN_DP_ID);
@@ -1227,30 +1217,28 @@ void hdd_ndp_peer_departed_handler(uint8_t vdev_id, uint16_t sta_id,
 {
 	struct hdd_context *hdd_ctx;
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_station_ctx *sta_ctx;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (!hdd_ctx)
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
 
-	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
-	if (!sta_ctx) {
-		hdd_err("sta_ctx is null");
-		return;
-	}
+	adapter = link_info->adapter;
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
 
 	hdd_delete_peer(sta_ctx, peer_mac_addr);
 
 	if (last_peer) {
 		hdd_debug("No more ndp peers.");
 		ucfg_nan_clear_peer_mc_list(hdd_ctx->psoc,
-					    adapter->deflink->vdev,
+					    link_info->vdev,
 					    peer_mac_addr);
 		hdd_cleanup_ndi(hdd_ctx, adapter);
 		qdf_event_set(&adapter->peer_cleanup_done);

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

@@ -128,6 +128,7 @@ void hdd_nud_failure_work(hdd_cb_handle context, uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx;
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct osif_vdev_sync *vdev_sync;
 
 	hdd_ctx = hdd_cb_handle_to_context(context);
@@ -135,12 +136,14 @@ void hdd_nud_failure_work(hdd_cb_handle context, uint8_t vdev_id)
 		hdd_err("hdd_ctx is null");
 		return;
 	}
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
 
+	adapter = link_info->adapter;
 	if (osif_vdev_sync_op_start(adapter->dev, &vdev_sync))
 		return;
 

+ 12 - 10
core/hdd/src/wlan_hdd_oemdata.c

@@ -1176,7 +1176,7 @@ void hdd_oem_event_async_cb(const struct oem_data *oem_event_data)
 	uint32_t len;
 	int ret;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct wireless_dev *wdev = NULL;
 
 	hdd_enter();
@@ -1189,9 +1189,9 @@ void hdd_oem_event_async_cb(const struct oem_data *oem_event_data)
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, oem_event_data->vdev_id);
-	if (adapter)
-		wdev = &(adapter->wdev);
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, oem_event_data->vdev_id);
+	if (link_info)
+		wdev = &link_info->adapter->wdev;
 
 	len = nla_total_size(oem_event_data->data_len) + NLMSG_HDRLEN;
 	vendor_event = wlan_cfg80211_vendor_event_alloc(
@@ -1224,8 +1224,8 @@ void hdd_oem_event_handler_cb(const struct oem_data *oem_event_data,
 	int ret;
 	struct oem_data *oem_data;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *hdd_adapter = hdd_get_adapter_by_vdev(hdd_ctx,
-								  vdev_id);
+	struct wlan_hdd_link_info *link_info;
+	struct hdd_adapter *hdd_adapter;
 	struct wireless_dev *wdev = NULL;
 
 	hdd_enter();
@@ -1234,14 +1234,16 @@ void hdd_oem_event_handler_cb(const struct oem_data *oem_event_data,
 	if (ret)
 		return;
 
-	if (hdd_validate_adapter(hdd_adapter))
-		return;
-
 	if (!oem_event_data || !(oem_event_data->data)) {
 		hdd_err("Invalid oem event data");
 		return;
 	}
 
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info || hdd_validate_adapter(link_info->adapter))
+		return;
+
+	hdd_adapter = link_info->adapter;
 	if (hdd_adapter->response_expected) {
 		request = osif_request_get(hdd_adapter->cookie);
 		if (!request) {
@@ -1259,7 +1261,7 @@ void hdd_oem_event_handler_cb(const struct oem_data *oem_event_data,
 
 		qdf_mem_copy(oem_data->data, oem_event_data->data,
 			     oem_data->data_len);
-		oem_data->vdev_id = hdd_adapter->deflink->vdev_id;
+		oem_data->vdev_id = link_info->vdev_id;
 		osif_request_complete(request);
 		osif_request_put(request);
 	} else {

+ 49 - 51
core/hdd/src/wlan_hdd_stats.c

@@ -1054,11 +1054,11 @@ static void
 hdd_cache_ll_iface_stats(struct hdd_context *hdd_ctx,
 			 struct wifi_interface_stats *if_stat)
 {
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, if_stat->vdev_id);
-	if (!adapter) {
-		hdd_err("Invalid adapter for LL_STATS");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, if_stat->vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
 	/*
@@ -1069,7 +1069,7 @@ hdd_cache_ll_iface_stats(struct hdd_context *hdd_ctx,
 	 * required.
 	 */
 	hdd_nofl_debug("Copying iface stats into the adapter");
-	adapter->ll_iface_stats = *if_stat;
+	link_info->adapter->ll_iface_stats = *if_stat;
 }
 #else
 static void
@@ -1725,7 +1725,7 @@ void wlan_hdd_cfg80211_link_layer_stats_callback(hdd_handle_t hdd_handle,
 {
 	struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle);
 	struct hdd_ll_stats_priv *priv;
-	struct hdd_adapter *adapter = NULL;
+	struct wlan_hdd_link_info *link_info;
 	int status;
 	struct osif_request *request;
 
@@ -1758,14 +1758,15 @@ void wlan_hdd_cfg80211_link_layer_stats_callback(hdd_handle_t hdd_handle,
 			return;
 		}
 
-		adapter = hdd_get_adapter_by_vdev(hdd_ctx, results->ifaceId);
-		if (!adapter) {
+		link_info =
+			hdd_get_link_info_by_vdev(hdd_ctx, results->ifaceId);
+		if (!link_info) {
 			hdd_debug_rl("invalid vdev_id %d sent by FW",
 				     results->ifaceId);
 			/* for peer stats FW doesn't update the vdev_id info*/
-			adapter = hdd_get_adapter_by_vdev(hdd_ctx,
-							  priv->vdev_id);
-			if (!adapter) {
+			link_info = hdd_get_link_info_by_vdev(hdd_ctx,
+							      priv->vdev_id);
+			if (!link_info) {
 				hdd_err("invalid vdev %d", priv->vdev_id);
 				osif_request_put(request);
 				return;
@@ -1774,7 +1775,8 @@ void wlan_hdd_cfg80211_link_layer_stats_callback(hdd_handle_t hdd_handle,
 		wlan_hdd_update_ll_stats_request_bitmap(hdd_ctx, request,
 							results);
 		if (results->rspId == DEBUGFS_LLSTATS_REQID) {
-			hdd_debugfs_process_ll_stats(adapter, results, request);
+			hdd_debugfs_process_ll_stats(link_info->adapter,
+						     results, request);
 		 } else {
 			hdd_process_ll_stats(results, request);
 		}
@@ -1793,7 +1795,7 @@ void hdd_lost_link_info_cb(hdd_handle_t hdd_handle,
 {
 	struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle);
 	int status;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_station_ctx *sta_ctx;
 
 	status = wlan_hdd_validate_context(hdd_ctx);
@@ -1810,17 +1812,16 @@ void hdd_lost_link_info_cb(hdd_handle_t hdd_handle,
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, lost_link_info->vdev_id);
-	if (!adapter) {
-		hdd_err("invalid adapter");
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, lost_link_info->vdev_id);
+	if (!link_info) {
+		hdd_err("invalid vdev");
 		return;
 	}
 
-	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
 
-	adapter->deflink->rssi_on_disconnect = lost_link_info->rssi;
-	hdd_debug("rssi on disconnect %d",
-		  adapter->deflink->rssi_on_disconnect);
+	link_info->rssi_on_disconnect = lost_link_info->rssi;
+	hdd_debug("rssi on disconnect %d", link_info->rssi_on_disconnect);
 
 	sta_ctx->cache_conn_info.signal = lost_link_info->rssi;
 }
@@ -3322,7 +3323,7 @@ void wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,
 	struct hdd_context *hdd_ctx;
 	struct sk_buff *skb;
 	uint32_t param_id, index;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct wifi_peer_stat *peer_stats;
 	uint8_t *results;
 	int status;
@@ -3339,11 +3340,9 @@ void wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,
 	if (0 != status)
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->ifaceId);
-
-	if (!adapter) {
-		hdd_err("vdev_id %d does not exist with host.",
-			rsp->ifaceId);
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, rsp->ifaceId);
+	if (!link_info) {
+		hdd_err("vdev_id %d does not exist with host.", rsp->ifaceId);
 		return;
 	}
 
@@ -4111,7 +4110,7 @@ void wlan_hdd_cfg80211_stats_ext_callback(hdd_handle_t hdd_handle,
 	struct sk_buff *vendor_event;
 	int status;
 	int ret_val;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	enum qca_nl80211_vendor_subcmds_index index =
 		QCA_NL80211_VENDOR_SUBCMD_STATS_EXT_INDEX;
 
@@ -4119,8 +4118,8 @@ void wlan_hdd_cfg80211_stats_ext_callback(hdd_handle_t hdd_handle,
 	if (status)
 		return;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, data->vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, data->vdev_id);
+	if (!link_info) {
 		hdd_err("vdev_id %d does not exist with host", data->vdev_id);
 		return;
 	}
@@ -4137,7 +4136,7 @@ void wlan_hdd_cfg80211_stats_ext_callback(hdd_handle_t hdd_handle,
 	}
 
 	ret_val = nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_IFINDEX,
-			      adapter->dev->ifindex);
+			      link_info->adapter->dev->ifindex);
 	if (ret_val) {
 		hdd_err("QCA_WLAN_VENDOR_ATTR_IFINDEX put fail");
 		wlan_cfg80211_vendor_free_skb(vendor_event);
@@ -4469,7 +4468,7 @@ wlan_hdd_cfg80211_roam_events_callback(struct roam_stats_event *roam_stats,
 	int status;
 	uint32_t data_size, roam_event_type = 0;
 	struct sk_buff *vendor_event;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	status = wlan_hdd_validate_context(hdd_ctx);
 	if (status) {
@@ -4482,9 +4481,8 @@ wlan_hdd_cfg80211_roam_events_callback(struct roam_stats_event *roam_stats,
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx,
-					  roam_stats->vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, roam_stats->vdev_id);
+	if (!link_info) {
 		hdd_err("vdev_id %d does not exist with host",
 			roam_stats->vdev_id);
 		return;
@@ -4499,7 +4497,7 @@ wlan_hdd_cfg80211_roam_events_callback(struct roam_stats_event *roam_stats,
 	data_size += NLMSG_HDRLEN;
 	vendor_event =
 		wlan_cfg80211_vendor_event_alloc(hdd_ctx->wiphy,
-						 &adapter->wdev,
+						 &link_info->adapter->wdev,
 						 data_size,
 						 SUBCMD_ROAM_EVENTS_INDEX,
 						 GFP_KERNEL);
@@ -7874,7 +7872,7 @@ int wlan_hdd_get_temperature(struct hdd_adapter *adapter, int *temperature)
 void wlan_hdd_display_tx_multiq_stats(hdd_cb_handle context, uint8_t vdev_id)
 {
 	struct hdd_context *hdd_ctx;
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	struct hdd_tx_rx_stats *stats;
 	uint32_t total_inv_sk_and_skb_hash = 0;
 	uint32_t total_qselect_existing_skb_hash = 0;
@@ -7887,12 +7885,13 @@ void wlan_hdd_display_tx_multiq_stats(hdd_cb_handle context, uint8_t vdev_id)
 		hdd_err("hdd_ctx is null");
 		return;
 	}
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
-		hdd_err("adapter is null");
+
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return;
 	}
-	stats = &adapter->hdd_stats.tx_rx_stats;
+	stats = &link_info->adapter->hdd_stats.tx_rx_stats;
 
 	for (i = 0; i < NUM_CPUS; i++) {
 		total_inv_sk_and_skb_hash +=
@@ -7925,35 +7924,34 @@ void wlan_hdd_display_tx_multiq_stats(hdd_cb_handle context, uint8_t vdev_id)
 static void hdd_lost_link_cp_stats_info_cb(void *stats_ev)
 {
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	struct hdd_adapter *adapter;
 	struct stats_event *ev = stats_ev;
-	uint8_t i;
+	uint8_t i, vdev_id;
 	int8_t rssi;
 	struct hdd_station_ctx *sta_ctx;
+	struct wlan_hdd_link_info *link_info;
 
 	if (wlan_hdd_validate_context(hdd_ctx))
 		return;
 
 	for (i = 0; i < ev->num_summary_stats; i++) {
-		adapter = hdd_get_adapter_by_vdev(
-					hdd_ctx,
-					ev->vdev_summary_stats[i].vdev_id);
-		if (!adapter) {
-			hdd_debug("invalid adapter");
+		vdev_id = ev->vdev_summary_stats[i].vdev_id;
+		link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+		if (!link_info) {
+			hdd_debug("invalid vdev");
 			continue;
 		}
 
-		sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter->deflink);
+		sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
 
 		rssi = ev->vdev_summary_stats[i].stats.rssi;
 		if (rssi == 0) {
 			hdd_debug_rl("Invalid RSSI value sent by FW");
 			return;
 		}
-		adapter->deflink->rssi_on_disconnect = rssi;
+		link_info->rssi_on_disconnect = rssi;
 		hdd_debug("rssi %d for " QDF_MAC_ADDR_FMT,
-			  adapter->deflink->rssi_on_disconnect,
-			  QDF_MAC_ADDR_REF(adapter->mac_addr.bytes));
+			  link_info->rssi_on_disconnect,
+			  QDF_MAC_ADDR_REF(link_info->adapter->mac_addr.bytes));
 
 		sta_ctx->cache_conn_info.signal = rssi;
 	}

+ 6 - 5
core/hdd/src/wlan_hdd_tdls.c

@@ -948,21 +948,22 @@ int wlan_hdd_tdls_antenna_switch(struct hdd_context *hdd_ctx,
 QDF_STATUS hdd_tdls_register_peer(void *userdata, uint32_t vdev_id,
 				  const uint8_t *mac, uint8_t qos)
 {
-	struct hdd_adapter *adapter;
 	struct hdd_context *hddctx;
+	struct wlan_hdd_link_info *link_info;
 
 	hddctx = userdata;
 	if (!hddctx) {
 		hdd_err("Invalid hddctx");
 		return QDF_STATUS_E_INVAL;
 	}
-	adapter = hdd_get_adapter_by_vdev(hddctx, vdev_id);
-	if (!adapter) {
-		hdd_err("Invalid adapter");
+
+	link_info = hdd_get_link_info_by_vdev(hddctx, vdev_id);
+	if (!link_info) {
+		hdd_err("Invalid vdev");
 		return QDF_STATUS_E_FAILURE;
 	}
 
-	return hdd_roam_register_tdlssta(adapter, mac, qos);
+	return hdd_roam_register_tdlssta(link_info->adapter, mac, qos);
 }
 
 void hdd_init_tdls_config(struct tdls_start_params *tdls_cfg)

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

@@ -3136,6 +3136,7 @@ int hdd_get_tsf_cb(void *pcb_cxt, struct stsf *ptsf)
 {
 	struct hdd_context *hddctx;
 	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 	int ret;
 	uint64_t tsf_sync_soc_time;
 	QDF_TIMER_STATE capture_req_timer_status;
@@ -3152,13 +3153,13 @@ int hdd_get_tsf_cb(void *pcb_cxt, struct stsf *ptsf)
 	if (0 != ret)
 		return -EINVAL;
 
-	adapter = hdd_get_adapter_by_vdev(hddctx, ptsf->vdev_id);
-
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hddctx, ptsf->vdev_id);
+	if (!link_info) {
 		hdd_err("failed to find adapter");
 		return -EINVAL;
 	}
 
+	adapter = link_info->adapter;
 	/* Intercept tsf report and check if it is for uplink delay.
 	 * If yes, return in advance and skip the legacy BSS TSF
 	 * report. Otherwise continue on to the legacy BSS TSF

+ 16 - 14
core/hdd/src/wlan_hdd_tx_rx.c

@@ -362,11 +362,13 @@ void hdd_get_tx_resource(uint8_t vdev_id,
 	struct hdd_adapter *adapter;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	uint16_t timer_value = WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME;
+	struct wlan_hdd_link_info *link_info;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter)
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info)
 		return;
 
+	adapter = link_info->adapter;
 	if (adapter->device_mode == QDF_P2P_GO_MODE ||
 	    adapter->device_mode == QDF_SAP_MODE)
 		timer_value = WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME;
@@ -399,13 +401,13 @@ unsigned int
 hdd_get_tx_flow_low_watermark(hdd_cb_handle cb_ctx, uint8_t intf_id)
 {
 	struct hdd_context *hdd_ctx = hdd_cb_handle_to_context(cb_ctx);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, intf_id);
-	if (!adapter)
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, intf_id);
+	if (!link_info)
 		return 0;
 
-	return adapter->tx_flow_low_watermark;
+	return link_info->adapter->tx_flow_low_watermark;
 }
 #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
 
@@ -725,14 +727,14 @@ void hdd_tsf_timestamp_rx(hdd_cb_handle ctx, qdf_nbuf_t netbuf)
 void hdd_get_tsf_time_cb(uint8_t vdev_id, uint64_t input_time,
 			 uint64_t *tsf_time)
 {
-	struct hdd_adapter *adapter;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	struct wlan_hdd_link_info *link_info;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter)
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info)
 		return;
 
-	hdd_get_tsf_time(adapter, input_time, tsf_time);
+	hdd_get_tsf_time(link_info->adapter, input_time, tsf_time);
 }
 #endif
 
@@ -1358,7 +1360,7 @@ void hdd_tx_queue_cb(hdd_handle_t hdd_handle, uint32_t vdev_id,
 		     enum netif_reason_type reason)
 {
 	struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle);
-	struct hdd_adapter *adapter;
+	struct wlan_hdd_link_info *link_info;
 
 	/*
 	 * Validating the context is not required here.
@@ -1372,14 +1374,14 @@ void hdd_tx_queue_cb(hdd_handle_t hdd_handle, uint32_t vdev_id,
 		return;
 	}
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (!adapter) {
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info) {
 		hdd_err("vdev_id %d does not exist with host", vdev_id);
 		return;
 	}
 	hdd_debug("Tx Queue action %d on vdev %d", action, vdev_id);
 
-	wlan_hdd_netif_queue_control(adapter, action, reason);
+	wlan_hdd_netif_queue_control(link_info->adapter, action, reason);
 }
 
 #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL

+ 5 - 4
core/hdd/src/wlan_hdd_wifi_pos_pasn.c

@@ -332,7 +332,6 @@ wlan_hdd_cfg80211_send_set_ltf_keyseed_mlo_vdev(struct hdd_context *hdd_ctx,
 						struct wlan_crypto_ltf_keyseed_data *data,
 						int link_id)
 {
-	struct hdd_adapter *link_adapter;
 	struct wlan_objmgr_vdev *link_vdev;
 	struct wlan_objmgr_peer *peer;
 	uint16_t link, vdev_count = 0;
@@ -340,6 +339,8 @@ wlan_hdd_cfg80211_send_set_ltf_keyseed_mlo_vdev(struct hdd_context *hdd_ctx,
 	struct qdf_mac_addr original_mac;
 	struct wlan_objmgr_vdev *wlan_vdev_list[WLAN_UMAC_MLO_MAX_VDEVS] = {0};
 	QDF_STATUS status;
+	uint8_t vdev_id;
+	struct wlan_hdd_link_info *link_info;
 
 	if (!wlan_vdev_mlme_is_mlo_vdev(vdev))
 		return QDF_STATUS_SUCCESS;
@@ -350,10 +351,10 @@ wlan_hdd_cfg80211_send_set_ltf_keyseed_mlo_vdev(struct hdd_context *hdd_ctx,
 
 	for (link = 0; link < vdev_count; link++) {
 		link_vdev = wlan_vdev_list[link];
+		vdev_id = wlan_vdev_get_id(link_vdev);
 
-		link_adapter = hdd_get_adapter_by_vdev(
-					hdd_ctx, wlan_vdev_get_id(link_vdev));
-		if (!link_adapter) {
+		link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+		if (!link_info) {
 			mlo_release_vdev_ref(link_vdev);
 			continue;
 		}

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

@@ -2625,15 +2625,17 @@ bool hdd_wmm_is_acm_allowed(uint8_t vdev_id)
 	struct hdd_adapter *adapter;
 	struct hdd_wmm_ac_status *wmm_ac_status;
 	struct hdd_context *hdd_ctx;
+	struct wlan_hdd_link_info *link_info;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (!hdd_ctx)
 		return false;
 
-	adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
-	if (hdd_validate_adapter(adapter))
+	link_info = hdd_get_link_info_by_vdev(hdd_ctx, vdev_id);
+	if (!link_info || hdd_validate_adapter(link_info->adapter))
 		return false;
 
+	adapter = link_info->adapter;
 	wmm_ac_status = adapter->hdd_wmm_status.ac_status;
 
 	if (hdd_wmm_is_active(adapter) &&