qcacmn: Move WDS feature out of common code

Move WDS feature specific APIs out of common code
as these features are WIN specific. Keep the usage inside
common code under feature specific flags.

Change-Id: Id907a5e22c27fc47e8314449e154525684a27e85
diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c
index 0554c57..30586bc 100644
--- a/dp/wifi3.0/dp_main.c
+++ b/dp/wifi3.0/dp_main.c
@@ -60,6 +60,9 @@
 #endif
 #include "dp_ipa.h"
 #include "dp_cal_client_api.h"
+#ifdef FEATURE_WDS
+#include "dp_txrx_wds.h"
+#endif
 #ifdef CONFIG_MCL
 extern int con_mode_monitor;
 #ifndef REMOVE_PKT_LOG
@@ -124,11 +127,6 @@
 #define DP_INTR_POLL_TIMER_MS	10
 /* Generic AST entry aging timer value */
 #define DP_AST_AGING_TIMER_DEFAULT_MS	1000
-
-/* WDS AST entry aging timer value */
-#define DP_WDS_AST_AGING_TIMER_DEFAULT_MS	120000
-#define DP_WDS_AST_AGING_TIMER_CNT \
-((DP_WDS_AST_AGING_TIMER_DEFAULT_MS / DP_AST_AGING_TIMER_DEFAULT_MS) - 1)
 #define DP_MCS_LENGTH (6*MAX_MCS)
 
 #define DP_CURR_FW_STATS_AVAIL 19
@@ -466,7 +464,6 @@
 					enum cdp_txrx_ast_entry_type type,
 					uint32_t flags)
 {
-
 	return dp_peer_add_ast((struct dp_soc *)soc_hdl,
 				(struct dp_peer *)peer_hdl,
 				mac_addr,
@@ -646,7 +643,7 @@
 	 uint8_t *ast_mac_addr,
 	 struct cdp_ast_entry_info *ast_entry_info)
 {
-	struct dp_ast_entry *ast_entry;
+	struct dp_ast_entry *ast_entry = NULL;
 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
 
 	qdf_spin_lock_bh(&soc->ast_lock);
@@ -736,7 +733,7 @@
 
 {
 	struct dp_soc *soc = (struct dp_soc *)soc_handle;
-	struct dp_ast_entry *ast_entry;
+	struct dp_ast_entry *ast_entry = NULL;
 	txrx_ast_free_cb cb = NULL;
 	void *arg = NULL;
 
@@ -1022,31 +1019,32 @@
 		DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
 			DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
 				DP_PEER_ITERATE_ASE_LIST(peer, ase, tmp_ase) {
-					DP_PRINT_STATS("%6d mac_addr = %pM"
-							" peer_mac_addr = %pM"
-							" peer_id = %u"
-							" type = %s"
-							" next_hop = %d"
-							" is_active = %d"
-							" is_bss = %d"
-							" ast_idx = %d"
-							" ast_hash = %d"
-							" delete_in_progress = %d"
-							" pdev_id = %d"
-							" vdev_id = %d",
-							++num_entries,
-							ase->mac_addr.raw,
-							ase->peer->mac_addr.raw,
-							ase->peer->peer_ids[0],
-							type[ase->type],
-							ase->next_hop,
-							ase->is_active,
-							ase->is_bss,
-							ase->ast_idx,
-							ase->ast_hash_value,
-							ase->delete_in_progress,
-							ase->pdev_id,
-							ase->vdev_id);
+					DP_PRINT_STATS("%6d mac_addr = %pM",
+						       ++num_entries,
+						       ase->mac_addr.raw);
+					DP_PRINT_STATS(" peer_mac_addr = %pM",
+						       ase->peer->mac_addr.raw);
+					DP_PRINT_STATS(" peer_id = %u",
+						       ase->peer->peer_ids[0]);
+					DP_PRINT_STATS(" type = %s",
+						       type[ase->type]);
+					DP_PRINT_STATS(" next_hop = %d",
+						       ase->next_hop);
+					DP_PRINT_STATS(" is_active = %d",
+						       ase->is_active);
+					DP_PRINT_STATS(" is_bss = %d",
+						       ase->is_bss);
+					DP_PRINT_STATS(" ast_idx = %d",
+						       ase->ast_idx);
+					DP_PRINT_STATS(" ast_hash = %d",
+						       ase->ast_hash_value);
+					DP_PRINT_STATS("delete_in_progress= %d",
+						       ase->delete_in_progress
+						       );
+					DP_PRINT_STATS(" pdev_id = %d",
+						       ase->pdev_id);
+					DP_PRINT_STATS(" vdev_id = %d",
+						       ase->vdev_id);
 				}
 			}
 		}
@@ -2256,122 +2254,7 @@
 #endif /* QCA_WIFI_QCA8074_VP */
 #endif /* IPA_OFFLOAD */
 
-/*
- * dp_ast_aging_timer_fn() - Timer callback function for WDS aging
- * @soc: Datapath SOC handle
- *
- * This is a timer function used to age out stale AST nodes from
- * AST table
- */
-#ifdef FEATURE_WDS
-static void dp_ast_aging_timer_fn(void *soc_hdl)
-{
-	struct dp_soc *soc = (struct dp_soc *) soc_hdl;
-	struct dp_pdev *pdev;
-	struct dp_vdev *vdev;
-	struct dp_peer *peer;
-	struct dp_ast_entry *ase, *temp_ase;
-	int i;
-	bool check_wds_ase = false;
-
-	if (soc->wds_ast_aging_timer_cnt++ >= DP_WDS_AST_AGING_TIMER_CNT) {
-		soc->wds_ast_aging_timer_cnt = 0;
-		check_wds_ase = true;
-	}
-
-	 /* Peer list access lock */
-	qdf_spin_lock_bh(&soc->peer_ref_mutex);
-
-	/* AST list access lock */
-	qdf_spin_lock_bh(&soc->ast_lock);
-
-	for (i = 0; i < MAX_PDEV_CNT && soc->pdev_list[i]; i++) {
-		pdev = soc->pdev_list[i];
-		qdf_spin_lock_bh(&pdev->vdev_list_lock);
-		DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
-			DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
-				DP_PEER_ITERATE_ASE_LIST(peer, ase, temp_ase) {
-					/*
-					 * Do not expire static ast entries
-					 * and HM WDS entries
-					 */
-					if (ase->type !=
-					    CDP_TXRX_AST_TYPE_WDS &&
-					    ase->type !=
-					    CDP_TXRX_AST_TYPE_MEC &&
-					    ase->type !=
-					    CDP_TXRX_AST_TYPE_DA)
-						continue;
-
-					/* Expire MEC entry every n sec.
-					 * This needs to be expired in
-					 * case if STA backbone is made as
-					 * AP backbone, In this case it needs
-					 * to be re-added as a WDS entry.
-					 */
-					if (ase->is_active && ase->type ==
-					    CDP_TXRX_AST_TYPE_MEC) {
-						ase->is_active = FALSE;
-						continue;
-					} else if (ase->is_active &&
-						   check_wds_ase) {
-						ase->is_active = FALSE;
-						continue;
-					}
-
-					if (ase->type ==
-					    CDP_TXRX_AST_TYPE_MEC) {
-						DP_STATS_INC(soc,
-							     ast.aged_out, 1);
-						dp_peer_del_ast(soc, ase);
-					} else if (check_wds_ase) {
-						DP_STATS_INC(soc,
-							     ast.aged_out, 1);
-						dp_peer_del_ast(soc, ase);
-					}
-				}
-			}
-		}
-		qdf_spin_unlock_bh(&pdev->vdev_list_lock);
-	}
-
-	qdf_spin_unlock_bh(&soc->ast_lock);
-	qdf_spin_unlock_bh(&soc->peer_ref_mutex);
-
-	if (qdf_atomic_read(&soc->cmn_init_done))
-		qdf_timer_mod(&soc->ast_aging_timer,
-			      DP_AST_AGING_TIMER_DEFAULT_MS);
-}
-
-
-/*
- * dp_soc_wds_attach() - Setup WDS timer and AST table
- * @soc:		Datapath SOC handle
- *
- * Return: None
- */
-static void dp_soc_wds_attach(struct dp_soc *soc)
-{
-	soc->wds_ast_aging_timer_cnt = 0;
-	qdf_timer_init(soc->osdev, &soc->ast_aging_timer,
-		       dp_ast_aging_timer_fn, (void *)soc,
-		       QDF_TIMER_TYPE_WAKE_APPS);
-
-	qdf_timer_mod(&soc->ast_aging_timer, DP_AST_AGING_TIMER_DEFAULT_MS);
-}
-
-/*
- * dp_soc_wds_detach() - Detach WDS data structures and timers
- * @txrx_soc: DP SOC handle
- *
- * Return: None
- */
-static void dp_soc_wds_detach(struct dp_soc *soc)
-{
-	qdf_timer_stop(&soc->ast_aging_timer);
-	qdf_timer_free(&soc->ast_aging_timer);
-}
-#else
+#ifndef FEATURE_WDS
 static void dp_soc_wds_attach(struct dp_soc *soc)
 {
 }
@@ -2380,7 +2263,6 @@
 {
 }
 #endif
-
 /*
  * dp_soc_reset_ring_map() - Reset cpu ring map
  * @soc: Datapath soc handler
@@ -2950,6 +2832,7 @@
 	hal_reo_setup(soc->hal_soc, &reo_params);
 
 	qdf_atomic_set(&soc->cmn_init_done, 1);
+
 	dp_soc_wds_attach(soc);
 
 	qdf_nbuf_queue_init(&soc->htt_stats.msg);
@@ -4866,6 +4749,7 @@
 		callback(cb_context);
 }
 
+#ifdef FEATURE_AST
 /*
  * dp_peer_delete_ast_entries(): Delete all AST entries for a peer
  * @soc - datapath soc handle
@@ -4873,7 +4757,6 @@
  *
  * Delete the AST entries belonging to a peer
  */
-#ifdef FEATURE_AST
 static inline void dp_peer_delete_ast_entries(struct dp_soc *soc,
 					      struct dp_peer *peer)
 {
@@ -4890,7 +4773,6 @@
 {
 }
 #endif
-
 #if ATH_SUPPORT_WRAP
 static inline struct dp_peer *dp_peer_can_reuse(struct dp_vdev *vdev,
 						uint8_t *peer_mac_addr)
@@ -4941,8 +4823,7 @@
 	else
 		ast_entry = dp_peer_ast_hash_find_soc(soc, peer_mac_addr);
 
-	if (ast_entry && ast_entry->next_hop &&
-	    !ast_entry->delete_in_progress)
+	if (ast_entry && ast_entry->next_hop && !ast_entry->delete_in_progress)
 		dp_peer_del_ast(soc, ast_entry);
 
 	qdf_spin_unlock_bh(&soc->ast_lock);
@@ -5007,9 +4888,7 @@
 		     QDF_MAC_ADDR_SIZE)) {
 			ast_type = CDP_TXRX_AST_TYPE_SELF;
 		}
-
 		dp_peer_add_ast(soc, peer, peer_mac_addr, ast_type, 0);
-
 		/*
 		* Control path maintains a node count which is incremented
 		* for every new peer create command. Since new peer is not being
@@ -5063,9 +4942,7 @@
 			 QDF_MAC_ADDR_SIZE)) {
 		ast_type = CDP_TXRX_AST_TYPE_SELF;
 	}
-
 	dp_peer_add_ast(soc, peer, peer_mac_addr, ast_type, 0);
-
 	qdf_spinlock_create(&peer->peer_info_lock);
 
 	dp_peer_rx_bufq_resources_init(peer);
@@ -8035,75 +7912,6 @@
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * dp_txrx_set_wds_rx_policy() - API to store datapath
- *                            config parameters
- * @vdev_handle - datapath vdev handle
- * @cfg: ini parameter handle
- *
- * Return: status
- */
-#ifdef WDS_VENDOR_EXTENSION
-void
-dp_txrx_set_wds_rx_policy(
-		struct cdp_vdev *vdev_handle,
-		u_int32_t val)
-{
-	struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
-	struct dp_peer *peer;
-	if (vdev->opmode == wlan_op_mode_ap) {
-		/* for ap, set it on bss_peer */
-		TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
-			if (peer->bss_peer) {
-				peer->wds_ecm.wds_rx_filter = 1;
-				peer->wds_ecm.wds_rx_ucast_4addr = (val & WDS_POLICY_RX_UCAST_4ADDR) ? 1:0;
-				peer->wds_ecm.wds_rx_mcast_4addr = (val & WDS_POLICY_RX_MCAST_4ADDR) ? 1:0;
-				break;
-			}
-		}
-	} else if (vdev->opmode == wlan_op_mode_sta) {
-		peer = TAILQ_FIRST(&vdev->peer_list);
-		peer->wds_ecm.wds_rx_filter = 1;
-		peer->wds_ecm.wds_rx_ucast_4addr = (val & WDS_POLICY_RX_UCAST_4ADDR) ? 1:0;
-		peer->wds_ecm.wds_rx_mcast_4addr = (val & WDS_POLICY_RX_MCAST_4ADDR) ? 1:0;
-	}
-}
-
-/**
- * dp_txrx_peer_wds_tx_policy_update() - API to set tx wds policy
- *
- * @peer_handle - datapath peer handle
- * @wds_tx_ucast: policy for unicast transmission
- * @wds_tx_mcast: policy for multicast transmission
- *
- * Return: void
- */
-void
-dp_txrx_peer_wds_tx_policy_update(struct cdp_peer *peer_handle,
-		int wds_tx_ucast, int wds_tx_mcast)
-{
-	struct dp_peer *peer = (struct dp_peer *)peer_handle;
-	if (wds_tx_ucast || wds_tx_mcast) {
-		peer->wds_enabled = 1;
-		peer->wds_ecm.wds_tx_ucast_4addr = wds_tx_ucast;
-		peer->wds_ecm.wds_tx_mcast_4addr = wds_tx_mcast;
-	} else {
-		peer->wds_enabled = 0;
-		peer->wds_ecm.wds_tx_ucast_4addr = 0;
-		peer->wds_ecm.wds_tx_mcast_4addr = 0;
-	}
-
-	QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
-			FL("Policy Update set to :\
-				peer->wds_enabled %d\
-				peer->wds_ecm.wds_tx_ucast_4addr %d\
-				peer->wds_ecm.wds_tx_mcast_4addr %d"),
-				peer->wds_enabled, peer->wds_ecm.wds_tx_ucast_4addr,
-				peer->wds_ecm.wds_tx_mcast_4addr);
-	return;
-}
-#endif
-
 static struct cdp_wds_ops dp_ops_wds = {
 	.vdev_set_wds = dp_vdev_set_wds,
 #ifdef WDS_VENDOR_EXTENSION
@@ -8223,9 +8031,9 @@
 #ifdef FEATURE_AST
 static void dp_peer_teardown_wifi3(struct cdp_vdev *vdev_hdl, void *peer_hdl)
 {
-	struct dp_vdev *vdev = (struct dp_vdev *) vdev_hdl;
-	struct dp_peer *peer = (struct dp_peer *) peer_hdl;
-	struct dp_soc *soc = (struct dp_soc *) vdev->pdev->soc;
+	struct dp_vdev *vdev = (struct dp_vdev *)vdev_hdl;
+	struct dp_peer *peer = (struct dp_peer *)peer_hdl;
+	struct dp_soc *soc = (struct dp_soc *)vdev->pdev->soc;
 
 	/*
 	 * For BSS peer, new peer is not created on alloc_node if the
@@ -8236,9 +8044,8 @@
 	 * for bss_peer, unless only 2 reference remains (peer map reference
 	 * and peer hash table reference).
 	 */
-	if (peer->bss_peer && (qdf_atomic_read(&peer->ref_cnt) > 2)) {
+	if (peer->bss_peer && (qdf_atomic_read(&peer->ref_cnt) > 2))
 		return;
-	}
 
 	qdf_spin_lock_bh(&soc->ast_lock);
 	peer->delete_in_progress = true;
diff --git a/dp/wifi3.0/dp_peer.c b/dp/wifi3.0/dp_peer.c
index 60b0924..48974e9 100644
--- a/dp/wifi3.0/dp_peer.c
+++ b/dp/wifi3.0/dp_peer.c
@@ -59,7 +59,6 @@
 	union dp_align_mac_addr *mac_addr1,
 	union dp_align_mac_addr *mac_addr2)
 {
-	return !((mac_addr1->align4.bytes_abcd == mac_addr2->align4.bytes_abcd)
 		/*
 		 * Intentionally use & rather than &&.
 		 * because the operands are binary rather than generic boolean,
@@ -68,8 +67,8 @@
 		 * but using & has the advantage of no conditional branching,
 		 * which is a more significant benefit.
 		 */
-		&
-		(mac_addr1->align4.bytes_ef == mac_addr2->align4.bytes_ef));
+	return !((mac_addr1->align4.bytes_abcd == mac_addr2->align4.bytes_abcd)
+		 & (mac_addr1->align4.bytes_ef == mac_addr2->align4.bytes_ef));
 }
 
 static int dp_peer_ast_table_attach(struct dp_soc *soc)
@@ -117,9 +116,9 @@
 	return 0; /* success */
 }
 
-static int dp_log2_ceil(unsigned value)
+static int dp_log2_ceil(unsigned int value)
 {
-	unsigned tmp = value;
+	unsigned int tmp = value;
 	int log2 = -1;
 
 	while (tmp) {
@@ -1043,12 +1042,18 @@
 	return 0xff;
 }
 
-
 uint8_t dp_peer_ast_get_next_hop(struct dp_soc *soc,
 				struct dp_ast_entry *ast_entry)
 {
 	return 0xff;
 }
+
+int dp_peer_update_ast(struct dp_soc *soc, struct dp_peer *peer,
+		       struct dp_ast_entry *ast_entry, uint32_t flags)
+{
+	return 1;
+}
+
 #endif
 
 void dp_peer_ast_send_wds_del(struct dp_soc *soc,
@@ -1488,7 +1493,6 @@
 
 		}
 	}
-
 	dp_peer_map_ast(soc, peer, peer_mac_addr,
 			hw_peer_id, vdev_id, ast_hash);
 }
diff --git a/dp/wifi3.0/dp_rx.c b/dp/wifi3.0/dp_rx.c
index 07fa54e..6caec24 100644
--- a/dp/wifi3.0/dp_rx.c
+++ b/dp/wifi3.0/dp_rx.c
@@ -29,6 +29,9 @@
 #include "dp_internal.h"
 #include "dp_rx_mon.h"
 #include "dp_ipa.h"
+#ifdef FEATURE_WDS
+#include "dp_txrx_wds.h"
+#endif
 
 #ifdef ATH_RX_PRI_SAVE
 #define DP_RX_TID_SAVE(_nbuf, _tid) \
@@ -358,47 +361,7 @@
 }
 #endif
 
-/**
- * dp_rx_da_learn() - Add AST entry based on DA lookup
- *			This is a WAR for HK 1.0 and will
- *			be removed in HK 2.0
- *
- * @soc: core txrx main context
- * @rx_tlv_hdr	: start address of rx tlvs
- * @ta_peer	: Transmitter peer entry
- * @nbuf	: nbuf to retrieve destination mac for which AST will be added
- *
- */
-#ifdef FEATURE_WDS
-static void
-dp_rx_da_learn(struct dp_soc *soc,
-	       uint8_t *rx_tlv_hdr,
-	       struct dp_peer *ta_peer,
-	       qdf_nbuf_t nbuf)
-{
-	/* For HKv2 DA port learing is not needed */
-	if (qdf_likely(soc->ast_override_support))
-		return;
-
-	if (qdf_unlikely(!ta_peer))
-		return;
-
-	if (qdf_unlikely(ta_peer->vdev->opmode != wlan_op_mode_ap))
-		return;
-
-	if (!soc->da_war_enabled)
-		return;
-
-	if (qdf_unlikely(!qdf_nbuf_is_da_valid(nbuf) &&
-			 !qdf_nbuf_is_da_mcbc(nbuf))) {
-		dp_peer_add_ast(soc,
-				ta_peer,
-				qdf_nbuf_data(nbuf),
-				CDP_TXRX_AST_TYPE_DA,
-				IEEE80211_NODE_F_WDS_HM);
-	}
-}
-#else
+#ifndef FEATURE_WDS
 static void
 dp_rx_da_learn(struct dp_soc *soc,
 	       uint8_t *rx_tlv_hdr,
@@ -407,8 +370,7 @@
 {
 }
 #endif
-
-/**
+/*
  * dp_rx_intrabss_fwd() - Implements the Intra-BSS forwarding logic
  *
  * @soc: core txrx main context
@@ -1487,85 +1449,7 @@
 	return true;
 }
 
-#ifdef WDS_VENDOR_EXTENSION
-int dp_wds_rx_policy_check(uint8_t *rx_tlv_hdr,
-			   struct dp_vdev *vdev,
-			   struct dp_peer *peer)
-{
-	struct dp_peer *bss_peer;
-	int fr_ds, to_ds, rx_3addr, rx_4addr;
-	int rx_policy_ucast, rx_policy_mcast;
-	int rx_mcast = hal_rx_msdu_end_da_is_mcbc_get(rx_tlv_hdr);
-
-	if (vdev->opmode == wlan_op_mode_ap) {
-		TAILQ_FOREACH(bss_peer, &vdev->peer_list, peer_list_elem) {
-			if (bss_peer->bss_peer) {
-				/* if wds policy check is not enabled on this vdev, accept all frames */
-				if (!bss_peer->wds_ecm.wds_rx_filter) {
-					return 1;
-				}
-				break;
-			}
-		}
-		rx_policy_ucast = bss_peer->wds_ecm.wds_rx_ucast_4addr;
-		rx_policy_mcast = bss_peer->wds_ecm.wds_rx_mcast_4addr;
-	} else {             /* sta mode */
-		if (!peer->wds_ecm.wds_rx_filter) {
-			return 1;
-		}
-		rx_policy_ucast = peer->wds_ecm.wds_rx_ucast_4addr;
-		rx_policy_mcast = peer->wds_ecm.wds_rx_mcast_4addr;
-	}
-
-	/* ------------------------------------------------
-	 *                       self
-	 * peer-             rx  rx-
-	 * wds  ucast mcast dir policy accept note
-	 * ------------------------------------------------
-	 * 1     1     0     11  x1     1      AP configured to accept ds-to-ds Rx ucast from wds peers, constraint met; so, accept
-	 * 1     1     0     01  x1     0      AP configured to accept ds-to-ds Rx ucast from wds peers, constraint not met; so, drop
-	 * 1     1     0     10  x1     0      AP configured to accept ds-to-ds Rx ucast from wds peers, constraint not met; so, drop
-	 * 1     1     0     00  x1     0      bad frame, won't see it
-	 * 1     0     1     11  1x     1      AP configured to accept ds-to-ds Rx mcast from wds peers, constraint met; so, accept
-	 * 1     0     1     01  1x     0      AP configured to accept ds-to-ds Rx mcast from wds peers, constraint not met; so, drop
-	 * 1     0     1     10  1x     0      AP configured to accept ds-to-ds Rx mcast from wds peers, constraint not met; so, drop
-	 * 1     0     1     00  1x     0      bad frame, won't see it
-	 * 1     1     0     11  x0     0      AP configured to accept from-ds Rx ucast from wds peers, constraint not met; so, drop
-	 * 1     1     0     01  x0     0      AP configured to accept from-ds Rx ucast from wds peers, constraint not met; so, drop
-	 * 1     1     0     10  x0     1      AP configured to accept from-ds Rx ucast from wds peers, constraint met; so, accept
-	 * 1     1     0     00  x0     0      bad frame, won't see it
-	 * 1     0     1     11  0x     0      AP configured to accept from-ds Rx mcast from wds peers, constraint not met; so, drop
-	 * 1     0     1     01  0x     0      AP configured to accept from-ds Rx mcast from wds peers, constraint not met; so, drop
-	 * 1     0     1     10  0x     1      AP configured to accept from-ds Rx mcast from wds peers, constraint met; so, accept
-	 * 1     0     1     00  0x     0      bad frame, won't see it
-	 *
-	 * 0     x     x     11  xx     0      we only accept td-ds Rx frames from non-wds peers in mode.
-	 * 0     x     x     01  xx     1
-	 * 0     x     x     10  xx     0
-	 * 0     x     x     00  xx     0      bad frame, won't see it
-	 * ------------------------------------------------
-	 */
-
-	fr_ds = hal_rx_mpdu_get_fr_ds(rx_tlv_hdr);
-	to_ds = hal_rx_mpdu_get_to_ds(rx_tlv_hdr);
-	rx_3addr = fr_ds ^ to_ds;
-	rx_4addr = fr_ds & to_ds;
-
-	if (vdev->opmode == wlan_op_mode_ap) {
-		if ((!peer->wds_enabled && rx_3addr && to_ds) ||
-				(peer->wds_enabled && !rx_mcast && (rx_4addr == rx_policy_ucast)) ||
-				(peer->wds_enabled && rx_mcast && (rx_4addr == rx_policy_mcast))) {
-			return 1;
-		}
-	} else {           /* sta mode */
-		if ((!rx_mcast && (rx_4addr == rx_policy_ucast)) ||
-				(rx_mcast && (rx_4addr == rx_policy_mcast))) {
-			return 1;
-		}
-	}
-	return 0;
-}
-#else
+#ifndef WDS_VENDOR_EXTENSION
 int dp_wds_rx_policy_check(uint8_t *rx_tlv_hdr,
 			   struct dp_vdev *vdev,
 			   struct dp_peer *peer)
diff --git a/dp/wifi3.0/dp_rx.h b/dp/wifi3.0/dp_rx.h
index 85cf92e..859091d 100644
--- a/dp/wifi3.0/dp_rx.h
+++ b/dp/wifi3.0/dp_rx.h
@@ -562,254 +562,6 @@
 
 }
 
-/**
- * dp_rx_wds_add_or_update_ast() - Add or update the ast entry.
- *
- * @soc: core txrx main context
- * @ta_peer: WDS repeater peer
- * @mac_addr: mac address of the peer
- * @is_ad4_valid: 4-address valid flag
- * @is_sa_valid: source address valid flag
- * @is_chfrag_start: frag start flag
- * @sa_idx: source-address index for peer
- * @sa_sw_peer_id: software source-address peer-id
- *
- * Return: void:
- */
-#ifdef FEATURE_WDS
-static inline void
-dp_rx_wds_add_or_update_ast(struct dp_soc *soc, struct dp_peer *ta_peer,
-			    qdf_nbuf_t nbuf, uint8_t is_ad4_valid,
-			    uint8_t is_sa_valid, uint8_t is_chfrag_start,
-			    uint16_t sa_idx, uint16_t sa_sw_peer_id)
-{
-	struct dp_peer *sa_peer;
-	struct dp_ast_entry *ast;
-	uint32_t flags = IEEE80211_NODE_F_WDS_HM;
-	uint32_t ret = 0;
-	struct dp_neighbour_peer *neighbour_peer = NULL;
-	struct dp_pdev *pdev = ta_peer->vdev->pdev;
-	uint8_t wds_src_mac[QDF_MAC_ADDR_SIZE];
-
-	/* For AP mode : Do wds source port learning only if it is a
-	 * 4-address mpdu
-	 *
-	 * For STA mode : Frames from RootAP backend will be in 3-address mode,
-	 * till RootAP does the WDS source port learning; Hence in repeater/STA
-	 * mode, we enable learning even in 3-address mode , to avoid RootAP
-	 * backbone getting wrongly learnt as MEC on repeater
-	 */
-	if (ta_peer->vdev->opmode != wlan_op_mode_sta) {
-		if (!(is_chfrag_start && is_ad4_valid))
-			return;
-	} else {
-		/* For HKv2 Source port learing is not needed in STA mode
-		 * as we have support in HW
-		 */
-		if (soc->ast_override_support)
-			return;
-	}
-
-	if (qdf_unlikely(!is_sa_valid)) {
-		qdf_mem_copy(wds_src_mac,
-			     (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
-			     QDF_MAC_ADDR_SIZE);
-
-		ret = dp_peer_add_ast(soc,
-					ta_peer,
-					wds_src_mac,
-					CDP_TXRX_AST_TYPE_WDS,
-					flags);
-		return;
-	}
-
-	qdf_spin_lock_bh(&soc->ast_lock);
-	ast = soc->ast_table[sa_idx];
-	qdf_spin_unlock_bh(&soc->ast_lock);
-
-	if (!ast) {
-		/*
-		 * In HKv1, it is possible that HW retains the AST entry in
-		 * GSE cache on 1 radio , even after the AST entry is deleted
-		 * (on another radio).
-		 *
-		 * Due to this, host might still get sa_is_valid indications
-		 * for frames with SA not really present in AST table.
-		 *
-		 * So we go ahead and send an add_ast command to FW in such
-		 * cases where sa is reported still as valid, so that FW will
-		 * invalidate this GSE cache entry and new AST entry gets
-		 * cached.
-		 */
-		if (!soc->ast_override_support) {
-			qdf_mem_copy(wds_src_mac,
-				     (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
-				     QDF_MAC_ADDR_SIZE);
-
-			ret = dp_peer_add_ast(soc,
-					      ta_peer,
-					      wds_src_mac,
-					      CDP_TXRX_AST_TYPE_WDS,
-					      flags);
-			return;
-		} else {
-			/* In HKv2 smart monitor case, when NAC client is
-			 * added first and this client roams within BSS to
-			 * connect to RE, since we have an AST entry for
-			 * NAC we get sa_is_valid bit set. So we check if
-			 * smart monitor is enabled and send add_ast command
-			 * to FW.
-			 */
-			if (pdev->neighbour_peers_added) {
-				qdf_mem_copy(wds_src_mac,
-					     (qdf_nbuf_data(nbuf) +
-					      QDF_MAC_ADDR_SIZE),
-					     QDF_MAC_ADDR_SIZE);
-
-				qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
-				TAILQ_FOREACH(neighbour_peer,
-					      &pdev->neighbour_peers_list,
-					      neighbour_peer_list_elem) {
-					if (!qdf_mem_cmp(&neighbour_peer->neighbour_peers_macaddr,
-							 wds_src_mac,
-							 QDF_MAC_ADDR_SIZE)) {
-						ret = dp_peer_add_ast(soc,
-								      ta_peer,
-								      wds_src_mac,
-								      CDP_TXRX_AST_TYPE_WDS,
-								      flags);
-						QDF_TRACE(QDF_MODULE_ID_DP,
-							  QDF_TRACE_LEVEL_INFO,
-							  "sa valid and nac roamed to wds");
-						break;
-					}
-				}
-				qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
-			}
-			return;
-		}
-	}
-
-
-	if ((ast->type == CDP_TXRX_AST_TYPE_WDS_HM) ||
-	    (ast->type == CDP_TXRX_AST_TYPE_WDS_HM_SEC))
-		return;
-
-	/*
-	 * Ensure we are updating the right AST entry by
-	 * validating ast_idx.
-	 * There is a possibility we might arrive here without
-	 * AST MAP event , so this check is mandatory
-	 */
-	if (ast->is_mapped && (ast->ast_idx == sa_idx))
-		ast->is_active = TRUE;
-
-	if (sa_sw_peer_id != ta_peer->peer_ids[0]) {
-		sa_peer = ast->peer;
-
-		if ((ast->type != CDP_TXRX_AST_TYPE_STATIC) &&
-		    (ast->type != CDP_TXRX_AST_TYPE_SELF) &&
-			(ast->type != CDP_TXRX_AST_TYPE_STA_BSS)) {
-			if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
-				/* This case is when a STA roams from one
-				 * repeater to another repeater, but these
-				 * repeaters are connected to root AP on
-				 * different radios.
-				 * Ex: rptr1 connected to ROOT AP over 5G
-				 * and rptr2 connected to ROOT AP over 2G
-				 * radio
-				 */
-				qdf_spin_lock_bh(&soc->ast_lock);
-				dp_peer_del_ast(soc, ast);
-				qdf_spin_unlock_bh(&soc->ast_lock);
-			} else {
-				/* this case is when a STA roams from one
-				 * reapter to another repeater, but inside
-				 * same radio.
-				 */
-				qdf_spin_lock_bh(&soc->ast_lock);
-				dp_peer_update_ast(soc, ta_peer, ast, flags);
-				qdf_spin_unlock_bh(&soc->ast_lock);
-				return;
-			}
-		}
-		/*
-		 * Do not kickout STA if it belongs to a different radio.
-		 * For DBDC repeater, it is possible to arrive here
-		 * for multicast loopback frames originated from connected
-		 * clients and looped back (intrabss) by Root AP
-		 */
-		if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
-			return;
-		}
-
-		/*
-		 * Kickout, when direct associated peer(SA) roams
-		 * to another AP and reachable via TA peer
-		 */
-		if ((sa_peer->vdev->opmode == wlan_op_mode_ap) &&
-		    !sa_peer->delete_in_progress) {
-			sa_peer->delete_in_progress = true;
-			if (soc->cdp_soc.ol_ops->peer_sta_kickout) {
-				soc->cdp_soc.ol_ops->peer_sta_kickout(
-						sa_peer->vdev->pdev->ctrl_pdev,
-						wds_src_mac);
-			}
-		}
-	}
-}
-
-/**
- * dp_rx_wds_srcport_learn() - Add or update the STA PEER which
- *				is behind the WDS repeater.
- *
- * @soc: core txrx main context
- * @rx_tlv_hdr: base address of RX TLV header
- * @ta_peer: WDS repeater peer
- * @nbuf: rx pkt
- *
- * Return: void:
- */
-static inline void
-dp_rx_wds_srcport_learn(struct dp_soc *soc,
-			uint8_t *rx_tlv_hdr,
-			struct dp_peer *ta_peer,
-			qdf_nbuf_t nbuf)
-{
-	uint16_t sa_sw_peer_id = hal_rx_msdu_end_sa_sw_peer_id_get(rx_tlv_hdr);
-	uint8_t sa_is_valid = hal_rx_msdu_end_sa_is_valid_get(rx_tlv_hdr);
-	uint16_t sa_idx;
-	uint8_t is_chfrag_start = 0;
-	uint8_t is_ad4_valid = 0;
-
-	if (qdf_unlikely(!ta_peer))
-		return;
-
-	is_chfrag_start = qdf_nbuf_is_rx_chfrag_start(nbuf);
-	if (is_chfrag_start)
-		is_ad4_valid = hal_rx_get_mpdu_mac_ad4_valid(rx_tlv_hdr);
-
-	/*
-	 * Get the AST entry from HW SA index and mark it as active
-	 */
-	sa_idx = hal_rx_msdu_end_sa_idx_get(rx_tlv_hdr);
-
-	dp_rx_wds_add_or_update_ast(soc, ta_peer, nbuf, is_ad4_valid,
-				    sa_is_valid, is_chfrag_start,
-				    sa_idx, sa_sw_peer_id);
-
-	return;
-}
-#else
-static inline void
-dp_rx_wds_srcport_learn(struct dp_soc *soc,
-		uint8_t *rx_tlv_hdr,
-		struct dp_peer *ta_peer,
-		qdf_nbuf_t nbuf)
-{
-}
-#endif
-
 uint8_t dp_rx_process_invalid_peer(struct dp_soc *soc, qdf_nbuf_t nbuf);
 void dp_rx_process_invalid_peer_wrapper(struct dp_soc *soc,
 		qdf_nbuf_t mpdu, bool mpdu_done);
@@ -994,41 +746,19 @@
 	return QDF_STATUS_E_DEFRAG_ERROR;
 }
 
-/*
- * dp_rx_ast_set_active() - set the active flag of the astentry
- *				    corresponding to a hw index.
- * @soc: core txrx main context
- * @sa_idx: hw idx
- * @is_active: active flag
- *
- */
-#ifdef FEATURE_WDS
-static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
-{
-	struct dp_ast_entry *ast;
-	qdf_spin_lock_bh(&soc->ast_lock);
-	ast = soc->ast_table[sa_idx];
-
-	/*
-	 * Ensure we are updating the right AST entry by
-	 * validating ast_idx.
-	 * There is a possibility we might arrive here without
-	 * AST MAP event , so this check is mandatory
-	 */
-	if (ast && ast->is_mapped && (ast->ast_idx == sa_idx)) {
-		ast->is_active = is_active;
-		qdf_spin_unlock_bh(&soc->ast_lock);
-		return QDF_STATUS_SUCCESS;
-	}
-
-	qdf_spin_unlock_bh(&soc->ast_lock);
-	return QDF_STATUS_E_FAILURE;
-}
-#else
+#ifndef FEATURE_WDS
 static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc, uint16_t sa_idx, bool is_active)
 {
 	return QDF_STATUS_SUCCESS;
 }
+
+static inline void
+dp_rx_wds_srcport_learn(struct dp_soc *soc,
+			uint8_t *rx_tlv_hdr,
+			struct dp_peer *ta_peer,
+			qdf_nbuf_t nbuf)
+{
+}
 #endif
 
 /*
diff --git a/dp/wifi3.0/dp_rx_err.c b/dp/wifi3.0/dp_rx_err.c
index aaff522..918dfdb 100644
--- a/dp/wifi3.0/dp_rx_err.c
+++ b/dp/wifi3.0/dp_rx_err.c
@@ -28,6 +28,9 @@
 #include <cds_ieee80211_common.h>
 #endif
 #include "dp_rx_defrag.h"
+#ifdef FEATURE_WDS
+#include "dp_txrx_wds.h"
+#endif
 #include <enet.h>	/* LLC_SNAP_HDR_LEN */
 #include "qdf_net_types.h"
 
@@ -49,7 +52,7 @@
 					qdf_nbuf_t nbuf)
 {
 	struct dp_vdev *vdev = peer->vdev;
-	struct dp_ast_entry *ase;
+	struct dp_ast_entry *ase = NULL;
 	uint16_t sa_idx = 0;
 	uint8_t *data;
 
@@ -118,10 +121,11 @@
 				ase->is_mapped = TRUE;
 			}
 		}
-	} else
+	} else {
 		ase = dp_peer_ast_hash_find_by_pdevid(soc,
 						      &data[QDF_MAC_ADDR_SIZE],
 						      vdev->pdev->pdev_id);
+	}
 
 	if (ase) {
 
@@ -784,7 +788,6 @@
 		dp_err_rl("mcast Policy Check Drop pkt");
 		goto drop_nbuf;
 	}
-
 	/* WDS Source Port Learning */
 	if (qdf_likely(vdev->rx_decap_type == htt_cmn_pkt_type_ethernet &&
 		vdev->wds_enabled))
diff --git a/dp/wifi3.0/dp_tx.c b/dp/wifi3.0/dp_tx.c
index 4ecc2b7..59175f9 100644
--- a/dp/wifi3.0/dp_tx.c
+++ b/dp/wifi3.0/dp_tx.c
@@ -32,6 +32,9 @@
 #endif
 #include "enet.h"
 #include "dp_internal.h"
+#ifdef FEATURE_WDS
+#include "dp_txrx_wds.h"
+#endif
 
 #define DP_TX_QUEUE_MASK 0x3
 
@@ -2555,57 +2558,6 @@
 	}
 }
 
-/**
- * dp_tx_mec_handler() - Tx  MEC Notify Handler
- * @vdev: pointer to dp dev handler
- * @status : Tx completion status from HTT descriptor
- *
- * Handles MEC notify event sent from fw to Host
- *
- * Return: none
- */
-#ifdef FEATURE_WDS
-void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status)
-{
-
-	struct dp_soc *soc;
-	uint32_t flags = IEEE80211_NODE_F_WDS_HM;
-	struct dp_peer *peer;
-	uint8_t mac_addr[QDF_MAC_ADDR_SIZE], i;
-
-	if (!vdev->mec_enabled)
-		return;
-
-	/* MEC required only in STA mode */
-	if (vdev->opmode != wlan_op_mode_sta)
-		return;
-
-	soc = vdev->pdev->soc;
-	peer = vdev->vap_bss_peer;
-
-	if (!peer) {
-		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
-				FL("peer is NULL"));
-		return;
-	}
-
-	QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
-			"%s Tx MEC Handler",
-			__func__);
-
-	for (i = 0; i < QDF_MAC_ADDR_SIZE; i++)
-		mac_addr[(QDF_MAC_ADDR_SIZE - 1) - i] =
-					status[(QDF_MAC_ADDR_SIZE - 2) + i];
-
-	if (qdf_mem_cmp(mac_addr, vdev->mac_addr.raw, QDF_MAC_ADDR_SIZE))
-		dp_peer_add_ast(soc,
-				peer,
-				mac_addr,
-				CDP_TXRX_AST_TYPE_MEC,
-				flags);
-}
-#endif
-
 #ifdef MESH_MODE_SUPPORT
 /**
  * dp_tx_comp_fill_tx_completion_stats() - Fill per packet Tx completion stats
@@ -3521,24 +3473,7 @@
 	return QDF_STATUS_SUCCESS;
 }
 
-#ifdef FEATURE_WDS
-static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
-{
-	struct dp_soc *soc = vdev->pdev->soc;
-
-	/*
-	 * If AST index override support is available (HKv2 etc),
-	 * DA search flag be enabled always
-	 *
-	 * If AST index override support is not available (HKv1),
-	 * DA search flag should be used for all modes except QWRAP
-	 */
-	if (soc->ast_override_support || !vdev->proxysta_vdev)
-		return true;
-
-	return false;
-}
-#else
+#ifndef FEATURE_WDS
 static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
 {
 	return false;
diff --git a/dp/wifi3.0/dp_tx.h b/dp/wifi3.0/dp_tx.h
index a88a0f2..9e7999a 100644
--- a/dp/wifi3.0/dp_tx.h
+++ b/dp/wifi3.0/dp_tx.h
@@ -196,9 +196,7 @@
 QDF_STATUS
 dp_tx_prepare_send_me(struct dp_vdev *vdev, qdf_nbuf_t nbuf);
 
-#ifdef FEATURE_WDS
-void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status);
-#else
+#ifndef FEATURE_WDS
 static inline void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status)
 {
 	return;