xref: /wlan-driver/qca-wifi-host-cmn/dp/wifi3.0/dp_txrx_wds.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name #ifndef _DP_TXRX_WDS_H_
21*5113495bSYour Name #define _DP_TXRX_WDS_H_
22*5113495bSYour Name 
23*5113495bSYour Name #ifdef WIFI_MONITOR_SUPPORT
24*5113495bSYour Name #include "dp_htt.h"
25*5113495bSYour Name #include "dp_mon.h"
26*5113495bSYour Name #endif
27*5113495bSYour Name 
28*5113495bSYour Name /* host managed flag */
29*5113495bSYour Name #define DP_AST_FLAGS_HM 0x0020
30*5113495bSYour Name 
31*5113495bSYour Name /* WDS AST entry aging timer value */
32*5113495bSYour Name #define DP_WDS_AST_AGING_TIMER_DEFAULT_MS	120000
33*5113495bSYour Name #define DP_WDS_AST_AGING_TIMER_CNT \
34*5113495bSYour Name ((DP_WDS_AST_AGING_TIMER_DEFAULT_MS / DP_AST_AGING_TIMER_DEFAULT_MS) - 1)
35*5113495bSYour Name 
36*5113495bSYour Name /**
37*5113495bSYour Name  * dp_soc_wds_attach() - Setup WDS timer and AST table
38*5113495bSYour Name  * @soc: Datapath SOC handle
39*5113495bSYour Name  *
40*5113495bSYour Name  * Return: None
41*5113495bSYour Name  */
42*5113495bSYour Name void dp_soc_wds_attach(struct dp_soc *soc);
43*5113495bSYour Name 
44*5113495bSYour Name /**
45*5113495bSYour Name  * dp_soc_wds_detach() - Detach WDS data structures and timers
46*5113495bSYour Name  * @soc: DP SOC handle
47*5113495bSYour Name  *
48*5113495bSYour Name  * Return: None
49*5113495bSYour Name  */
50*5113495bSYour Name void dp_soc_wds_detach(struct dp_soc *soc);
51*5113495bSYour Name #ifdef QCA_PEER_MULTIQ_SUPPORT
52*5113495bSYour Name /**
53*5113495bSYour Name  * dp_peer_find_ast_index_by_flowq_id() - API to get ast idx for a given flowid
54*5113495bSYour Name  * @soc: soc handle
55*5113495bSYour Name  * @vdev_id: vdev ID
56*5113495bSYour Name  * @peer_mac_addr: mac address of the peer
57*5113495bSYour Name  * @flow_id: flow id to find ast index
58*5113495bSYour Name  * @tid: TID
59*5113495bSYour Name  *
60*5113495bSYour Name  * Return: ast index for a given flow id, -1 for fail cases
61*5113495bSYour Name  */
62*5113495bSYour Name int dp_peer_find_ast_index_by_flowq_id(struct cdp_soc_t *soc,
63*5113495bSYour Name 	       uint16_t vdev_id, uint8_t *peer_mac_addr,
64*5113495bSYour Name 	       uint8_t flow_id, uint8_t tid);
65*5113495bSYour Name #endif
66*5113495bSYour Name 
67*5113495bSYour Name /**
68*5113495bSYour Name  * dp_rx_da_learn() - Add AST entry based on DA lookup
69*5113495bSYour Name  *			This is a WAR for HK 1.0 and will
70*5113495bSYour Name  *			be removed in HK 2.0
71*5113495bSYour Name  *
72*5113495bSYour Name  * @soc: core txrx main context
73*5113495bSYour Name  * @rx_tlv_hdr: start address of rx tlvs
74*5113495bSYour Name  * @ta_peer: Transmitter peer entry
75*5113495bSYour Name  * @nbuf: nbuf to retrieve destination mac for which AST will be added
76*5113495bSYour Name  *
77*5113495bSYour Name  */
78*5113495bSYour Name void
79*5113495bSYour Name dp_rx_da_learn(struct dp_soc *soc,
80*5113495bSYour Name 	       uint8_t *rx_tlv_hdr,
81*5113495bSYour Name 	       struct dp_txrx_peer *ta_peer,
82*5113495bSYour Name 	       qdf_nbuf_t nbuf);
83*5113495bSYour Name 
84*5113495bSYour Name /**
85*5113495bSYour Name  * dp_tx_mec_handler() - Tx  MEC Notify Handler
86*5113495bSYour Name  * @vdev: pointer to dp dev handler
87*5113495bSYour Name  * @status : Tx completion status from HTT descriptor
88*5113495bSYour Name  *
89*5113495bSYour Name  * Handles MEC notify event sent from fw to Host
90*5113495bSYour Name  *
91*5113495bSYour Name  * Return: none
92*5113495bSYour Name  */
93*5113495bSYour Name void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status);
94*5113495bSYour Name #ifdef FEATURE_WDS
95*5113495bSYour Name #ifdef FEATURE_MCL_REPEATER
dp_tx_da_search_override(struct dp_vdev * vdev)96*5113495bSYour Name static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
97*5113495bSYour Name {
98*5113495bSYour Name 	if (vdev->mec_enabled)
99*5113495bSYour Name 		return true;
100*5113495bSYour Name 
101*5113495bSYour Name 	return false;
102*5113495bSYour Name }
103*5113495bSYour Name #else
dp_tx_da_search_override(struct dp_vdev * vdev)104*5113495bSYour Name static inline bool dp_tx_da_search_override(struct dp_vdev *vdev)
105*5113495bSYour Name {
106*5113495bSYour Name 	struct dp_soc *soc = vdev->pdev->soc;
107*5113495bSYour Name 
108*5113495bSYour Name 	/*
109*5113495bSYour Name 	 * If AST index override support is available (HKv2 etc),
110*5113495bSYour Name 	 * DA search flag be enabled always
111*5113495bSYour Name 	 *
112*5113495bSYour Name 	 * If AST index override support is not available (HKv1),
113*5113495bSYour Name 	 * DA search flag should be used for all modes except QWRAP
114*5113495bSYour Name 	 */
115*5113495bSYour Name 	if (soc->ast_override_support || !vdev->proxysta_vdev)
116*5113495bSYour Name 		return true;
117*5113495bSYour Name 
118*5113495bSYour Name 	return false;
119*5113495bSYour Name }
120*5113495bSYour Name #endif /* FEATURE_MCL_REPEATER */
121*5113495bSYour Name #endif /* FEATURE_WDS */
122*5113495bSYour Name #ifdef WDS_VENDOR_EXTENSION
123*5113495bSYour Name 
124*5113495bSYour Name /**
125*5113495bSYour Name  * dp_txrx_peer_wds_tx_policy_update() - API to set tx wds policy
126*5113495bSYour Name  *
127*5113495bSYour Name  * @soc: DP soc handle
128*5113495bSYour Name  * @vdev_id: id of vdev handle
129*5113495bSYour Name  * @peer_mac: peer mac address
130*5113495bSYour Name  * @wds_tx_ucast: policy for unicast transmission
131*5113495bSYour Name  * @wds_tx_mcast: policy for multicast transmission
132*5113495bSYour Name  *
133*5113495bSYour Name  * Return: void
134*5113495bSYour Name  */
135*5113495bSYour Name QDF_STATUS
136*5113495bSYour Name dp_txrx_peer_wds_tx_policy_update(struct cdp_soc_t *soc,  uint8_t vdev_id,
137*5113495bSYour Name 				  uint8_t *peer_mac, int wds_tx_ucast,
138*5113495bSYour Name 				  int wds_tx_mcast);
139*5113495bSYour Name 
140*5113495bSYour Name /**
141*5113495bSYour Name  * dp_txrx_set_wds_rx_policy() - API to store datapath
142*5113495bSYour Name  *                            config parameters
143*5113495bSYour Name  * @soc_hdl: datapath soc handle
144*5113495bSYour Name  * @vdev_id: id of datapath vdev handle
145*5113495bSYour Name  * @val: WDS rx policy value
146*5113495bSYour Name  *
147*5113495bSYour Name  * Return: status
148*5113495bSYour Name  */
149*5113495bSYour Name QDF_STATUS
150*5113495bSYour Name dp_txrx_set_wds_rx_policy(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
151*5113495bSYour Name 			  u_int32_t val);
152*5113495bSYour Name #endif
153*5113495bSYour Name 
154*5113495bSYour Name /**
155*5113495bSYour Name  * dp_hmwds_ast_add_notify() - schedules hmwds ast add status work
156*5113495bSYour Name  * @peer: DP peer
157*5113495bSYour Name  * @mac_addr: ast mac addr
158*5113495bSYour Name  * @type: ast type
159*5113495bSYour Name  * @err: QDF_STATUS error code
160*5113495bSYour Name  * @is_peer_map: notify is from peer map
161*5113495bSYour Name  *
162*5113495bSYour Name  * Return: void
163*5113495bSYour Name  */
164*5113495bSYour Name void dp_hmwds_ast_add_notify(struct dp_peer *peer,
165*5113495bSYour Name 			     uint8_t *mac_addr,
166*5113495bSYour Name 			     enum cdp_txrx_ast_entry_type type,
167*5113495bSYour Name 			     QDF_STATUS err,
168*5113495bSYour Name 			     bool is_peer_map);
169*5113495bSYour Name 
170*5113495bSYour Name #ifdef QCA_SUPPORT_WDS_EXTENDED
171*5113495bSYour Name /**
172*5113495bSYour Name  * dp_wds_ext_peer_learn() - function to send event to control
173*5113495bSYour Name  * path on receiving 1st 4-address frame from backhaul.
174*5113495bSYour Name  * @soc: DP soc
175*5113495bSYour Name  * @ta_peer: WDS repeater peer
176*5113495bSYour Name  *
177*5113495bSYour Name  * Return: void
178*5113495bSYour Name  */
dp_wds_ext_peer_learn(struct dp_soc * soc,struct dp_peer * ta_peer)179*5113495bSYour Name static inline void dp_wds_ext_peer_learn(struct dp_soc *soc,
180*5113495bSYour Name 					 struct dp_peer *ta_peer)
181*5113495bSYour Name {
182*5113495bSYour Name 	uint8_t wds_ext_src_mac[QDF_MAC_ADDR_SIZE];
183*5113495bSYour Name 
184*5113495bSYour Name 	if (ta_peer->vdev->wds_ext_enabled &&
185*5113495bSYour Name 	    !qdf_atomic_test_and_set_bit(WDS_EXT_PEER_INIT_BIT,
186*5113495bSYour Name 					 &ta_peer->txrx_peer->wds_ext.init)) {
187*5113495bSYour Name 		qdf_mem_copy(wds_ext_src_mac, &ta_peer->mac_addr.raw[0],
188*5113495bSYour Name 			     QDF_MAC_ADDR_SIZE);
189*5113495bSYour Name 		soc->cdp_soc.ol_ops->rx_wds_ext_peer_learn(
190*5113495bSYour Name 						soc->ctrl_psoc,
191*5113495bSYour Name 						ta_peer->peer_id,
192*5113495bSYour Name 						ta_peer->vdev->vdev_id,
193*5113495bSYour Name 						wds_ext_src_mac);
194*5113495bSYour Name 	}
195*5113495bSYour Name }
196*5113495bSYour Name #else
dp_wds_ext_peer_learn(struct dp_soc * soc,struct dp_peer * ta_peer)197*5113495bSYour Name static inline void dp_wds_ext_peer_learn(struct dp_soc *soc,
198*5113495bSYour Name 					 struct dp_peer *ta_peer)
199*5113495bSYour Name {
200*5113495bSYour Name }
201*5113495bSYour Name #endif
202*5113495bSYour Name 
203*5113495bSYour Name /**
204*5113495bSYour Name  * dp_rx_wds_add_or_update_ast() - Add or update the ast entry.
205*5113495bSYour Name  *
206*5113495bSYour Name  * @soc: core txrx main context
207*5113495bSYour Name  * @ta_peer: WDS repeater txrx peer
208*5113495bSYour Name  * @nbuf: network buffer
209*5113495bSYour Name  * @is_ad4_valid: 4-address valid flag
210*5113495bSYour Name  * @is_sa_valid: source address valid flag
211*5113495bSYour Name  * @is_chfrag_start: frag start flag
212*5113495bSYour Name  * @sa_idx: source-address index for peer
213*5113495bSYour Name  * @sa_sw_peer_id: software source-address peer-id
214*5113495bSYour Name  *
215*5113495bSYour Name  * Return: void:
216*5113495bSYour Name  */
217*5113495bSYour Name static inline void
dp_rx_wds_add_or_update_ast(struct dp_soc * soc,struct dp_txrx_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)218*5113495bSYour Name dp_rx_wds_add_or_update_ast(struct dp_soc *soc,
219*5113495bSYour Name 			    struct dp_txrx_peer *ta_peer,
220*5113495bSYour Name 			    qdf_nbuf_t nbuf, uint8_t is_ad4_valid,
221*5113495bSYour Name 			    uint8_t is_sa_valid, uint8_t is_chfrag_start,
222*5113495bSYour Name 			    uint16_t sa_idx, uint16_t sa_sw_peer_id)
223*5113495bSYour Name {
224*5113495bSYour Name 	struct dp_peer *sa_peer;
225*5113495bSYour Name 	struct dp_ast_entry *ast;
226*5113495bSYour Name 	uint32_t flags = DP_AST_FLAGS_HM;
227*5113495bSYour Name 	struct dp_pdev *pdev = ta_peer->vdev->pdev;
228*5113495bSYour Name 	uint8_t wds_src_mac[QDF_MAC_ADDR_SIZE];
229*5113495bSYour Name 	struct dp_peer *ta_base_peer;
230*5113495bSYour Name 
231*5113495bSYour Name 
232*5113495bSYour Name 	if (!(is_chfrag_start && is_ad4_valid))
233*5113495bSYour Name 		return;
234*5113495bSYour Name 
235*5113495bSYour Name 	if (qdf_unlikely(!is_sa_valid)) {
236*5113495bSYour Name 		qdf_mem_copy(wds_src_mac,
237*5113495bSYour Name 			     (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
238*5113495bSYour Name 			     QDF_MAC_ADDR_SIZE);
239*5113495bSYour Name 
240*5113495bSYour Name 		ta_base_peer = dp_peer_get_ref_by_id(soc, ta_peer->peer_id,
241*5113495bSYour Name 						     DP_MOD_ID_RX);
242*5113495bSYour Name 		if (ta_base_peer) {
243*5113495bSYour Name 			if (ta_peer->vdev->opmode == wlan_op_mode_ap)
244*5113495bSYour Name 				dp_wds_ext_peer_learn(soc, ta_base_peer);
245*5113495bSYour Name 
246*5113495bSYour Name 			dp_peer_add_ast(soc, ta_base_peer, wds_src_mac,
247*5113495bSYour Name 					CDP_TXRX_AST_TYPE_WDS, flags);
248*5113495bSYour Name 
249*5113495bSYour Name 			dp_peer_unref_delete(ta_base_peer, DP_MOD_ID_RX);
250*5113495bSYour Name 		}
251*5113495bSYour Name 		return;
252*5113495bSYour Name 	}
253*5113495bSYour Name 
254*5113495bSYour Name 	qdf_spin_lock_bh(&soc->ast_lock);
255*5113495bSYour Name 	ast = soc->ast_table[sa_idx];
256*5113495bSYour Name 
257*5113495bSYour Name 	if (!ast) {
258*5113495bSYour Name 		qdf_spin_unlock_bh(&soc->ast_lock);
259*5113495bSYour Name 		/*
260*5113495bSYour Name 		 * In HKv1, it is possible that HW retains the AST entry in
261*5113495bSYour Name 		 * GSE cache on 1 radio , even after the AST entry is deleted
262*5113495bSYour Name 		 * (on another radio).
263*5113495bSYour Name 		 *
264*5113495bSYour Name 		 * Due to this, host might still get sa_is_valid indications
265*5113495bSYour Name 		 * for frames with SA not really present in AST table.
266*5113495bSYour Name 		 *
267*5113495bSYour Name 		 * So we go ahead and send an add_ast command to FW in such
268*5113495bSYour Name 		 * cases where sa is reported still as valid, so that FW will
269*5113495bSYour Name 		 * invalidate this GSE cache entry and new AST entry gets
270*5113495bSYour Name 		 * cached.
271*5113495bSYour Name 		 */
272*5113495bSYour Name 		if (!soc->ast_override_support) {
273*5113495bSYour Name 			qdf_mem_copy(wds_src_mac,
274*5113495bSYour Name 				     (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
275*5113495bSYour Name 				     QDF_MAC_ADDR_SIZE);
276*5113495bSYour Name 
277*5113495bSYour Name 			ta_base_peer = dp_peer_get_ref_by_id(soc,
278*5113495bSYour Name 							     ta_peer->peer_id,
279*5113495bSYour Name 							     DP_MOD_ID_RX);
280*5113495bSYour Name 
281*5113495bSYour Name 			if (ta_base_peer) {
282*5113495bSYour Name 				dp_peer_add_ast(soc, ta_base_peer,
283*5113495bSYour Name 						wds_src_mac,
284*5113495bSYour Name 						CDP_TXRX_AST_TYPE_WDS,
285*5113495bSYour Name 						flags);
286*5113495bSYour Name 
287*5113495bSYour Name 				dp_peer_unref_delete(ta_base_peer,
288*5113495bSYour Name 						     DP_MOD_ID_RX);
289*5113495bSYour Name 			}
290*5113495bSYour Name 			return;
291*5113495bSYour Name 		} else {
292*5113495bSYour Name 			/* In HKv2 smart monitor case, when NAC client is
293*5113495bSYour Name 			 * added first and this client roams within BSS to
294*5113495bSYour Name 			 * connect to RE, since we have an AST entry for
295*5113495bSYour Name 			 * NAC we get sa_is_valid bit set. So we check if
296*5113495bSYour Name 			 * smart monitor is enabled and send add_ast command
297*5113495bSYour Name 			 * to FW.
298*5113495bSYour Name 			 */
299*5113495bSYour Name 			ta_base_peer = dp_peer_get_ref_by_id(soc,
300*5113495bSYour Name 							     ta_peer->peer_id,
301*5113495bSYour Name 							     DP_MOD_ID_RX);
302*5113495bSYour Name 			if (ta_base_peer) {
303*5113495bSYour Name 				dp_monitor_neighbour_peer_add_ast(pdev,
304*5113495bSYour Name 								  ta_base_peer,
305*5113495bSYour Name 								  wds_src_mac,
306*5113495bSYour Name 								  nbuf,
307*5113495bSYour Name 								  flags);
308*5113495bSYour Name 				dp_peer_unref_delete(ta_base_peer,
309*5113495bSYour Name 						     DP_MOD_ID_RX);
310*5113495bSYour Name 			}
311*5113495bSYour Name 			return;
312*5113495bSYour Name 		}
313*5113495bSYour Name 	}
314*5113495bSYour Name 
315*5113495bSYour Name 	/*
316*5113495bSYour Name 	 * Ensure we are updating the right AST entry by
317*5113495bSYour Name 	 * validating ast_idx.
318*5113495bSYour Name 	 * There is a possibility we might arrive here without
319*5113495bSYour Name 	 * AST MAP event , so this check is mandatory
320*5113495bSYour Name 	 */
321*5113495bSYour Name 	if (ast->is_mapped && (ast->ast_idx == sa_idx))
322*5113495bSYour Name 		ast->is_active = TRUE;
323*5113495bSYour Name 
324*5113495bSYour Name 	if (ast->peer_id != ta_peer->peer_id) {
325*5113495bSYour Name 		if ((ast->type == CDP_TXRX_AST_TYPE_WDS_HM) ||
326*5113495bSYour Name 		    (ast->type == CDP_TXRX_AST_TYPE_WDS_HM_SEC)) {
327*5113495bSYour Name 			qdf_spin_unlock_bh(&soc->ast_lock);
328*5113495bSYour Name 			return;
329*5113495bSYour Name 		}
330*5113495bSYour Name 
331*5113495bSYour Name 		if ((ast->type != CDP_TXRX_AST_TYPE_STATIC) &&
332*5113495bSYour Name 		    (ast->type != CDP_TXRX_AST_TYPE_SELF) &&
333*5113495bSYour Name 		    (ast->type != CDP_TXRX_AST_TYPE_STA_BSS)) {
334*5113495bSYour Name 			if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
335*5113495bSYour Name 				/* This case is when a STA roams from one
336*5113495bSYour Name 				 * repeater to another repeater, but these
337*5113495bSYour Name 				 * repeaters are connected to root AP on
338*5113495bSYour Name 				 * different radios.
339*5113495bSYour Name 				 * Ex: rptr1 connected to ROOT AP over 5G
340*5113495bSYour Name 				 * and rptr2 connected to ROOT AP over 2G
341*5113495bSYour Name 				 * radio
342*5113495bSYour Name 				 */
343*5113495bSYour Name 				dp_peer_del_ast(soc, ast);
344*5113495bSYour Name 				qdf_spin_unlock_bh(&soc->ast_lock);
345*5113495bSYour Name 				return;
346*5113495bSYour Name 			} else {
347*5113495bSYour Name 				/* this case is when a STA roams from one
348*5113495bSYour Name 				 * reapter to another repeater, but inside
349*5113495bSYour Name 				 * same radio.
350*5113495bSYour Name 				 */
351*5113495bSYour Name 				/* For HKv2 do not update the AST entry if
352*5113495bSYour Name 				 * new ta_peer is on STA vap as SRC port
353*5113495bSYour Name 				 * learning is disable on STA vap
354*5113495bSYour Name 				 */
355*5113495bSYour Name 				if (soc->ast_override_support &&
356*5113495bSYour Name 				    (ta_peer->vdev->opmode == wlan_op_mode_sta)) {
357*5113495bSYour Name 					dp_peer_del_ast(soc, ast);
358*5113495bSYour Name 					qdf_spin_unlock_bh(&soc->ast_lock);
359*5113495bSYour Name 					return;
360*5113495bSYour Name 				} else {
361*5113495bSYour Name 					ta_base_peer =
362*5113495bSYour Name 					dp_peer_get_ref_by_id(soc,
363*5113495bSYour Name 							      ta_peer->peer_id,
364*5113495bSYour Name 							      DP_MOD_ID_RX);
365*5113495bSYour Name 					if (ta_base_peer) {
366*5113495bSYour Name 						dp_wds_ext_peer_learn(soc,
367*5113495bSYour Name 								ta_base_peer);
368*5113495bSYour Name 						dp_peer_update_ast(soc,
369*5113495bSYour Name 								   ta_base_peer,
370*5113495bSYour Name 								   ast, flags);
371*5113495bSYour Name 
372*5113495bSYour Name 						dp_peer_unref_delete(ta_base_peer,
373*5113495bSYour Name 								DP_MOD_ID_RX);
374*5113495bSYour Name 					}
375*5113495bSYour Name 				}
376*5113495bSYour Name 				qdf_spin_unlock_bh(&soc->ast_lock);
377*5113495bSYour Name 				return;
378*5113495bSYour Name 			}
379*5113495bSYour Name 		}
380*5113495bSYour Name 		/*
381*5113495bSYour Name 		 * Do not kickout STA if it belongs to a different radio.
382*5113495bSYour Name 		 * For DBDC repeater, it is possible to arrive here
383*5113495bSYour Name 		 * for multicast loopback frames originated from connected
384*5113495bSYour Name 		 * clients and looped back (intrabss) by Root AP
385*5113495bSYour Name 		 */
386*5113495bSYour Name 		if (ast->pdev_id != ta_peer->vdev->pdev->pdev_id) {
387*5113495bSYour Name 			qdf_spin_unlock_bh(&soc->ast_lock);
388*5113495bSYour Name 			return;
389*5113495bSYour Name 		}
390*5113495bSYour Name 
391*5113495bSYour Name 		qdf_spin_unlock_bh(&soc->ast_lock);
392*5113495bSYour Name 		/*
393*5113495bSYour Name 		 * Kickout, when direct associated peer(SA) roams
394*5113495bSYour Name 		 * to another AP and reachable via TA peer
395*5113495bSYour Name 		 */
396*5113495bSYour Name 		sa_peer = dp_peer_get_ref_by_id(soc, ast->peer_id,
397*5113495bSYour Name 						DP_MOD_ID_RX);
398*5113495bSYour Name 		if (!sa_peer)
399*5113495bSYour Name 			return;
400*5113495bSYour Name 
401*5113495bSYour Name 		if ((sa_peer->vdev->opmode == wlan_op_mode_ap) &&
402*5113495bSYour Name 		    !sa_peer->delete_in_progress) {
403*5113495bSYour Name 			qdf_mem_copy(wds_src_mac,
404*5113495bSYour Name 				     (qdf_nbuf_data(nbuf) + QDF_MAC_ADDR_SIZE),
405*5113495bSYour Name 				     QDF_MAC_ADDR_SIZE);
406*5113495bSYour Name 			sa_peer->delete_in_progress = true;
407*5113495bSYour Name 			if (soc->cdp_soc.ol_ops->peer_sta_kickout) {
408*5113495bSYour Name 				soc->cdp_soc.ol_ops->peer_sta_kickout(
409*5113495bSYour Name 					soc->ctrl_psoc,
410*5113495bSYour Name 					sa_peer->vdev->pdev->pdev_id,
411*5113495bSYour Name 					wds_src_mac);
412*5113495bSYour Name 			}
413*5113495bSYour Name 		}
414*5113495bSYour Name 		dp_peer_unref_delete(sa_peer, DP_MOD_ID_RX);
415*5113495bSYour Name 		return;
416*5113495bSYour Name 	}
417*5113495bSYour Name 
418*5113495bSYour Name 	qdf_spin_unlock_bh(&soc->ast_lock);
419*5113495bSYour Name }
420*5113495bSYour Name 
421*5113495bSYour Name /**
422*5113495bSYour Name  * dp_rx_wds_srcport_learn() - Add or update the STA PEER which
423*5113495bSYour Name  *				is behind the WDS repeater.
424*5113495bSYour Name  * @soc: core txrx main context
425*5113495bSYour Name  * @rx_tlv_hdr: base address of RX TLV header
426*5113495bSYour Name  * @ta_peer: WDS repeater peer
427*5113495bSYour Name  * @nbuf: rx pkt
428*5113495bSYour Name  * @msdu_end_info:
429*5113495bSYour Name  *
430*5113495bSYour Name  * Return: void:
431*5113495bSYour Name  */
432*5113495bSYour Name static inline void
dp_rx_wds_srcport_learn(struct dp_soc * soc,uint8_t * rx_tlv_hdr,struct dp_txrx_peer * ta_peer,qdf_nbuf_t nbuf,struct hal_rx_msdu_metadata msdu_end_info)433*5113495bSYour Name dp_rx_wds_srcport_learn(struct dp_soc *soc,
434*5113495bSYour Name 			uint8_t *rx_tlv_hdr,
435*5113495bSYour Name 			struct dp_txrx_peer *ta_peer,
436*5113495bSYour Name 			qdf_nbuf_t nbuf,
437*5113495bSYour Name 			struct hal_rx_msdu_metadata msdu_end_info)
438*5113495bSYour Name {
439*5113495bSYour Name 	uint8_t sa_is_valid = qdf_nbuf_is_sa_valid(nbuf);
440*5113495bSYour Name 	uint8_t is_chfrag_start = 0;
441*5113495bSYour Name 	uint8_t is_ad4_valid = 0;
442*5113495bSYour Name 
443*5113495bSYour Name 	if (qdf_unlikely(!ta_peer))
444*5113495bSYour Name 		return;
445*5113495bSYour Name 
446*5113495bSYour Name 	is_chfrag_start = qdf_nbuf_is_rx_chfrag_start(nbuf);
447*5113495bSYour Name 	if (is_chfrag_start)
448*5113495bSYour Name 		is_ad4_valid = hal_rx_get_mpdu_mac_ad4_valid(soc->hal_soc, rx_tlv_hdr);
449*5113495bSYour Name 
450*5113495bSYour Name 
451*5113495bSYour Name 	/*
452*5113495bSYour Name 	 * Get the AST entry from HW SA index and mark it as active
453*5113495bSYour Name 	 */
454*5113495bSYour Name 	dp_rx_wds_add_or_update_ast(soc, ta_peer, nbuf, is_ad4_valid,
455*5113495bSYour Name 				    sa_is_valid, is_chfrag_start,
456*5113495bSYour Name 				    msdu_end_info.sa_idx, msdu_end_info.sa_sw_peer_id);
457*5113495bSYour Name }
458*5113495bSYour Name 
459*5113495bSYour Name #ifdef IPA_WDS_EASYMESH_FEATURE
460*5113495bSYour Name /**
461*5113495bSYour Name  * dp_rx_ipa_wds_srcport_learn() - Add or update the STA PEER which
462*5113495bSYour Name  *				is behind the WDS repeater.
463*5113495bSYour Name  *
464*5113495bSYour Name  * @soc: core txrx main context
465*5113495bSYour Name  * @ta_peer: WDS repeater peer
466*5113495bSYour Name  * @nbuf: rx pkt
467*5113495bSYour Name  * @msdu_end_info: msdu end info
468*5113495bSYour Name  * @ad4_valid: address4 valid bit
469*5113495bSYour Name  * @chfrag_start: Msdu start bit
470*5113495bSYour Name  *
471*5113495bSYour Name  * Return: void
472*5113495bSYour Name  */
473*5113495bSYour Name static inline void
dp_rx_ipa_wds_srcport_learn(struct dp_soc * soc,struct dp_peer * ta_peer,qdf_nbuf_t nbuf,struct hal_rx_msdu_metadata msdu_end_info,bool ad4_valid,bool chfrag_start)474*5113495bSYour Name dp_rx_ipa_wds_srcport_learn(struct dp_soc *soc,
475*5113495bSYour Name 			    struct dp_peer *ta_peer, qdf_nbuf_t nbuf,
476*5113495bSYour Name 			    struct hal_rx_msdu_metadata msdu_end_info,
477*5113495bSYour Name 			    bool ad4_valid, bool chfrag_start)
478*5113495bSYour Name {
479*5113495bSYour Name 	uint8_t sa_is_valid = qdf_nbuf_is_sa_valid(nbuf);
480*5113495bSYour Name 	uint8_t is_chfrag_start = (uint8_t)chfrag_start;
481*5113495bSYour Name 	uint8_t is_ad4_valid = (uint8_t)ad4_valid;
482*5113495bSYour Name 	struct dp_txrx_peer *peer = (struct dp_txrx_peer *)ta_peer;
483*5113495bSYour Name 
484*5113495bSYour Name 	if (qdf_unlikely(!ta_peer))
485*5113495bSYour Name 		return;
486*5113495bSYour Name 
487*5113495bSYour Name 	/*
488*5113495bSYour Name 	 * Get the AST entry from HW SA index and mark it as active
489*5113495bSYour Name 	 */
490*5113495bSYour Name 	dp_rx_wds_add_or_update_ast(soc, peer, nbuf, is_ad4_valid,
491*5113495bSYour Name 				    sa_is_valid, is_chfrag_start,
492*5113495bSYour Name 				    msdu_end_info.sa_idx,
493*5113495bSYour Name 				    msdu_end_info.sa_sw_peer_id);
494*5113495bSYour Name }
495*5113495bSYour Name #endif
496*5113495bSYour Name 
497*5113495bSYour Name /**
498*5113495bSYour Name  * dp_rx_ast_set_active() - set the active flag of the astentry
499*5113495bSYour Name  *				    corresponding to a hw index.
500*5113495bSYour Name  * @soc: core txrx main context
501*5113495bSYour Name  * @sa_idx: hw idx
502*5113495bSYour Name  * @is_active: active flag
503*5113495bSYour Name  *
504*5113495bSYour Name  */
dp_rx_ast_set_active(struct dp_soc * soc,uint16_t sa_idx,bool is_active)505*5113495bSYour Name static inline QDF_STATUS dp_rx_ast_set_active(struct dp_soc *soc,
506*5113495bSYour Name 					      uint16_t sa_idx, bool is_active)
507*5113495bSYour Name {
508*5113495bSYour Name 	struct dp_ast_entry *ast;
509*5113495bSYour Name 
510*5113495bSYour Name 	qdf_spin_lock_bh(&soc->ast_lock);
511*5113495bSYour Name 	ast = soc->ast_table[sa_idx];
512*5113495bSYour Name 
513*5113495bSYour Name 	if (!ast) {
514*5113495bSYour Name 		qdf_spin_unlock_bh(&soc->ast_lock);
515*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
516*5113495bSYour Name 	}
517*5113495bSYour Name 
518*5113495bSYour Name 	if (!ast->is_mapped) {
519*5113495bSYour Name 		qdf_spin_unlock_bh(&soc->ast_lock);
520*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
521*5113495bSYour Name 	}
522*5113495bSYour Name 
523*5113495bSYour Name 	/*
524*5113495bSYour Name 	 * Ensure we are updating the right AST entry by
525*5113495bSYour Name 	 * validating ast_idx.
526*5113495bSYour Name 	 * There is a possibility we might arrive here without
527*5113495bSYour Name 	 * AST MAP event , so this check is mandatory
528*5113495bSYour Name 	 */
529*5113495bSYour Name 	if (ast->ast_idx == sa_idx) {
530*5113495bSYour Name 		ast->is_active = is_active;
531*5113495bSYour Name 		qdf_spin_unlock_bh(&soc->ast_lock);
532*5113495bSYour Name 		return QDF_STATUS_SUCCESS;
533*5113495bSYour Name 	}
534*5113495bSYour Name 
535*5113495bSYour Name 	qdf_spin_unlock_bh(&soc->ast_lock);
536*5113495bSYour Name 	return QDF_STATUS_E_FAILURE;
537*5113495bSYour Name }
538*5113495bSYour Name #endif /* DP_TXRX_WDS*/
539