xref: /wlan-driver/qca-wifi-host-cmn/target_if/dp/src/target_if_dp.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2019-2020 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 /**
21*5113495bSYour Name  * DOC: defines DP interaction with FW using WMI
22*5113495bSYour Name  */
23*5113495bSYour Name 
24*5113495bSYour Name #include <qdf_status.h>
25*5113495bSYour Name #include "target_if_dp.h"
26*5113495bSYour Name #include <init_deinit_lmac.h>
27*5113495bSYour Name #ifdef WLAN_FEATURE_PEER_TXQ_FLUSH_CONF
28*5113495bSYour Name #include <wmi_unified_param.h>
29*5113495bSYour Name #include <wlan_objmgr_peer_obj.h>
30*5113495bSYour Name #endif
31*5113495bSYour Name 
target_if_get_active_mac_phy_number(struct wlan_objmgr_psoc * psoc)32*5113495bSYour Name uint32_t target_if_get_active_mac_phy_number(struct wlan_objmgr_psoc *psoc)
33*5113495bSYour Name {
34*5113495bSYour Name 	struct target_psoc_info *psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
35*5113495bSYour Name 	struct target_supported_modes *hw_modes;
36*5113495bSYour Name 	uint32_t i, phy_bit_map, mac_phy_cnt, max_mac_phy_cnt = 0;
37*5113495bSYour Name 
38*5113495bSYour Name 	if (!psoc_info) {
39*5113495bSYour Name 		target_if_err("invalid psoc info");
40*5113495bSYour Name 		return 0;
41*5113495bSYour Name 	}
42*5113495bSYour Name 	hw_modes = &psoc_info->info.hw_modes;
43*5113495bSYour Name 	for (i = 0; i < hw_modes->num_modes; i++) {
44*5113495bSYour Name 		phy_bit_map = hw_modes->phy_bit_map[i];
45*5113495bSYour Name 		mac_phy_cnt = 0;
46*5113495bSYour Name 		while (phy_bit_map) {
47*5113495bSYour Name 			mac_phy_cnt++;
48*5113495bSYour Name 			phy_bit_map &= (phy_bit_map - 1);
49*5113495bSYour Name 		}
50*5113495bSYour Name 		if (mac_phy_cnt > max_mac_phy_cnt)
51*5113495bSYour Name 			max_mac_phy_cnt = mac_phy_cnt;
52*5113495bSYour Name 	}
53*5113495bSYour Name 
54*5113495bSYour Name 	return max_mac_phy_cnt;
55*5113495bSYour Name }
56*5113495bSYour Name 
57*5113495bSYour Name void
target_if_peer_set_default_routing(struct cdp_ctrl_objmgr_psoc * psoc,uint8_t pdev_id,uint8_t * peer_macaddr,uint8_t vdev_id,bool hash_based,uint8_t ring_num,uint8_t lmac_peer_id_msb)58*5113495bSYour Name target_if_peer_set_default_routing(struct cdp_ctrl_objmgr_psoc *psoc,
59*5113495bSYour Name 				   uint8_t pdev_id, uint8_t *peer_macaddr,
60*5113495bSYour Name 				   uint8_t vdev_id,
61*5113495bSYour Name 				   bool hash_based, uint8_t ring_num,
62*5113495bSYour Name 				   uint8_t lmac_peer_id_msb)
63*5113495bSYour Name {
64*5113495bSYour Name 	uint32_t value;
65*5113495bSYour Name 	struct peer_set_params param;
66*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
67*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev =
68*5113495bSYour Name 		wlan_objmgr_get_pdev_by_id((struct wlan_objmgr_psoc *)psoc,
69*5113495bSYour Name 					   pdev_id, WLAN_PDEV_TARGET_IF_ID);
70*5113495bSYour Name 
71*5113495bSYour Name 	if (!pdev) {
72*5113495bSYour Name 		target_if_err("pdev with id %d is NULL", pdev_id);
73*5113495bSYour Name 		return;
74*5113495bSYour Name 	}
75*5113495bSYour Name 
76*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
77*5113495bSYour Name 	if (!pdev_wmi_handle) {
78*5113495bSYour Name 		wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
79*5113495bSYour Name 		target_if_err("pdev wmi handle NULL");
80*5113495bSYour Name 		return;
81*5113495bSYour Name 	}
82*5113495bSYour Name 
83*5113495bSYour Name 	qdf_mem_zero(&param, sizeof(param));
84*5113495bSYour Name 
85*5113495bSYour Name 	/* TODO: Need bit definitions for ring number and hash based routing
86*5113495bSYour Name 	 * fields in common wmi header file
87*5113495bSYour Name 	 */
88*5113495bSYour Name 	value = ((hash_based) ? 1 : 0) | (ring_num << 1);
89*5113495bSYour Name 
90*5113495bSYour Name 	if (lmac_peer_id_msb)
91*5113495bSYour Name 		QDF_SET_BITS(value, PEER_ROUTING_LMAC_ID_INDEX,
92*5113495bSYour Name 			     PEER_ROUTING_LMAC_ID_BITS, lmac_peer_id_msb);
93*5113495bSYour Name 
94*5113495bSYour Name 	param.param_id = WMI_HOST_PEER_SET_DEFAULT_ROUTING;
95*5113495bSYour Name 	param.vdev_id = vdev_id;
96*5113495bSYour Name 	param.param_value = value;
97*5113495bSYour Name 
98*5113495bSYour Name 	if (wmi_set_peer_param_send(pdev_wmi_handle, peer_macaddr, &param)) {
99*5113495bSYour Name 		target_if_err("Unable to set default routing for peer "
100*5113495bSYour Name 				QDF_MAC_ADDR_FMT,
101*5113495bSYour Name 				QDF_MAC_ADDR_REF(peer_macaddr));
102*5113495bSYour Name 	}
103*5113495bSYour Name 	wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
104*5113495bSYour Name }
105*5113495bSYour Name 
106*5113495bSYour Name #ifdef SERIALIZE_QUEUE_SETUP
107*5113495bSYour Name static QDF_STATUS
target_if_rx_reorder_queue_setup(struct scheduler_msg * msg)108*5113495bSYour Name target_if_rx_reorder_queue_setup(struct scheduler_msg *msg)
109*5113495bSYour Name {
110*5113495bSYour Name 	struct rx_reorder_queue_setup_params param;
111*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
112*5113495bSYour Name 	struct reorder_q_setup *q_params;
113*5113495bSYour Name 	QDF_STATUS status;
114*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev;
115*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
116*5113495bSYour Name 
117*5113495bSYour Name 	if (!(msg->bodyptr)) {
118*5113495bSYour Name 		target_if_err("rx_reorder: Invalid message body");
119*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
120*5113495bSYour Name 	}
121*5113495bSYour Name 
122*5113495bSYour Name 	q_params = msg->bodyptr;
123*5113495bSYour Name 	psoc = (struct wlan_objmgr_psoc *)q_params->psoc;
124*5113495bSYour Name 
125*5113495bSYour Name 	pdev = wlan_objmgr_get_pdev_by_id(psoc, q_params->pdev_id,
126*5113495bSYour Name 					  WLAN_PDEV_TARGET_IF_ID);
127*5113495bSYour Name 
128*5113495bSYour Name 	if (!pdev) {
129*5113495bSYour Name 		target_if_err("pdev with id %d is NULL", q_params->pdev_id);
130*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
131*5113495bSYour Name 	}
132*5113495bSYour Name 
133*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
134*5113495bSYour Name 	if (!pdev_wmi_handle) {
135*5113495bSYour Name 		target_if_err("pdev wmi handle NULL");
136*5113495bSYour Name 		status = QDF_STATUS_E_FAILURE;
137*5113495bSYour Name 		goto out;
138*5113495bSYour Name 	}
139*5113495bSYour Name 
140*5113495bSYour Name 	param.tid = q_params->tid;
141*5113495bSYour Name 	param.vdev_id = q_params->vdev_id;
142*5113495bSYour Name 	param.peer_macaddr = q_params->peer_mac;
143*5113495bSYour Name 	param.hw_qdesc_paddr_lo = q_params->hw_qdesc_paddr & 0xffffffff;
144*5113495bSYour Name 	param.hw_qdesc_paddr_hi = (uint64_t)q_params->hw_qdesc_paddr >> 32;
145*5113495bSYour Name 	param.queue_no = q_params->queue_no;
146*5113495bSYour Name 	param.ba_window_size_valid = q_params->ba_window_size_valid;
147*5113495bSYour Name 	param.ba_window_size = q_params->ba_window_size;
148*5113495bSYour Name 
149*5113495bSYour Name 	status = wmi_unified_peer_rx_reorder_queue_setup_send(pdev_wmi_handle,
150*5113495bSYour Name 							      &param);
151*5113495bSYour Name out:
152*5113495bSYour Name 	wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
153*5113495bSYour Name 	qdf_mem_free(q_params);
154*5113495bSYour Name 
155*5113495bSYour Name 	return status;
156*5113495bSYour Name }
157*5113495bSYour Name 
158*5113495bSYour Name static QDF_STATUS
target_if_multi_rx_reorder_queue_setup(struct scheduler_msg * msg)159*5113495bSYour Name target_if_multi_rx_reorder_queue_setup(struct scheduler_msg *msg)
160*5113495bSYour Name {
161*5113495bSYour Name 	struct multi_rx_reorder_queue_setup_params param = {0};
162*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
163*5113495bSYour Name 	struct multi_reorder_q_setup *q_params;
164*5113495bSYour Name 	QDF_STATUS status;
165*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev;
166*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
167*5113495bSYour Name 	int tid;
168*5113495bSYour Name 
169*5113495bSYour Name 	if (!(msg->bodyptr)) {
170*5113495bSYour Name 		target_if_err("rx_reorder: Invalid message body");
171*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
172*5113495bSYour Name 	}
173*5113495bSYour Name 
174*5113495bSYour Name 	q_params = msg->bodyptr;
175*5113495bSYour Name 	psoc = (struct wlan_objmgr_psoc *)q_params->psoc;
176*5113495bSYour Name 
177*5113495bSYour Name 	pdev = wlan_objmgr_get_pdev_by_id(psoc, q_params->pdev_id,
178*5113495bSYour Name 					  WLAN_PDEV_TARGET_IF_ID);
179*5113495bSYour Name 	if (!pdev) {
180*5113495bSYour Name 		target_if_err("pdev with id %d is NULL", q_params->pdev_id);
181*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
182*5113495bSYour Name 	}
183*5113495bSYour Name 
184*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
185*5113495bSYour Name 	if (!pdev_wmi_handle) {
186*5113495bSYour Name 		target_if_err("pdev wmi handle NULL");
187*5113495bSYour Name 		status = QDF_STATUS_E_FAILURE;
188*5113495bSYour Name 		goto out;
189*5113495bSYour Name 	}
190*5113495bSYour Name 
191*5113495bSYour Name 	param.tid_bitmap = q_params->tid_bitmap;
192*5113495bSYour Name 	param.vdev_id = q_params->vdev_id;
193*5113495bSYour Name 	param.peer_macaddr = q_params->peer_mac;
194*5113495bSYour Name 	param.tid_num = q_params->tid_num;
195*5113495bSYour Name 
196*5113495bSYour Name 	for (tid = 0; tid < DP_MAX_TIDS; tid++) {
197*5113495bSYour Name 		if (!(BIT(tid) & q_params->tid_bitmap))
198*5113495bSYour Name 			continue;
199*5113495bSYour Name 		param.queue_params_list[tid].hw_qdesc_paddr =
200*5113495bSYour Name 			q_params->q_setup_list[tid].hw_qdesc_paddr;
201*5113495bSYour Name 		param.queue_params_list[tid].queue_no =
202*5113495bSYour Name 			q_params->q_setup_list[tid].queue_no;
203*5113495bSYour Name 		param.queue_params_list[tid].ba_window_size_valid =
204*5113495bSYour Name 			q_params->q_setup_list[tid].ba_window_size_valid;
205*5113495bSYour Name 		param.queue_params_list[tid].ba_window_size =
206*5113495bSYour Name 			q_params->q_setup_list[tid].ba_window_size;
207*5113495bSYour Name 	}
208*5113495bSYour Name 
209*5113495bSYour Name 	status = wmi_unified_peer_multi_rx_reorder_queue_setup_send(
210*5113495bSYour Name 		pdev_wmi_handle, &param);
211*5113495bSYour Name out:
212*5113495bSYour Name 	wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
213*5113495bSYour Name 	qdf_mem_free(q_params);
214*5113495bSYour Name 
215*5113495bSYour Name 	return status;
216*5113495bSYour Name }
217*5113495bSYour Name 
218*5113495bSYour Name QDF_STATUS
target_if_peer_rx_reorder_queue_setup(struct cdp_ctrl_objmgr_psoc * psoc,uint8_t pdev_id,uint8_t vdev_id,uint8_t * peer_macaddr,qdf_dma_addr_t hw_qdesc,int tid,uint16_t queue_no,uint8_t ba_window_size_valid,uint16_t ba_window_size)219*5113495bSYour Name target_if_peer_rx_reorder_queue_setup(struct cdp_ctrl_objmgr_psoc *psoc,
220*5113495bSYour Name 				      uint8_t pdev_id,
221*5113495bSYour Name 				      uint8_t vdev_id, uint8_t *peer_macaddr,
222*5113495bSYour Name 				      qdf_dma_addr_t hw_qdesc, int tid,
223*5113495bSYour Name 				      uint16_t queue_no,
224*5113495bSYour Name 				      uint8_t ba_window_size_valid,
225*5113495bSYour Name 				      uint16_t ba_window_size)
226*5113495bSYour Name {
227*5113495bSYour Name 	struct scheduler_msg msg = {0};
228*5113495bSYour Name 	struct reorder_q_setup *q_params;
229*5113495bSYour Name 	QDF_STATUS status;
230*5113495bSYour Name 
231*5113495bSYour Name 	q_params = qdf_mem_malloc(sizeof(*q_params));
232*5113495bSYour Name 	if (!q_params)
233*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
234*5113495bSYour Name 
235*5113495bSYour Name 	q_params->psoc = psoc;
236*5113495bSYour Name 	q_params->vdev_id = vdev_id;
237*5113495bSYour Name 	q_params->pdev_id = pdev_id;
238*5113495bSYour Name 	q_params->hw_qdesc_paddr = hw_qdesc;
239*5113495bSYour Name 	q_params->tid = tid;
240*5113495bSYour Name 	q_params->queue_no = queue_no;
241*5113495bSYour Name 	q_params->ba_window_size_valid = ba_window_size_valid;
242*5113495bSYour Name 	q_params->ba_window_size = ba_window_size;
243*5113495bSYour Name 	qdf_mem_copy(q_params->peer_mac, peer_macaddr, QDF_MAC_ADDR_SIZE);
244*5113495bSYour Name 
245*5113495bSYour Name 	msg.bodyptr = q_params;
246*5113495bSYour Name 	msg.callback = target_if_rx_reorder_queue_setup;
247*5113495bSYour Name 	status = scheduler_post_message(QDF_MODULE_ID_TARGET_IF,
248*5113495bSYour Name 					QDF_MODULE_ID_TARGET_IF,
249*5113495bSYour Name 					QDF_MODULE_ID_TARGET_IF, &msg);
250*5113495bSYour Name 
251*5113495bSYour Name 	if (status != QDF_STATUS_SUCCESS)
252*5113495bSYour Name 		qdf_mem_free(q_params);
253*5113495bSYour Name 
254*5113495bSYour Name 	return status;
255*5113495bSYour Name }
256*5113495bSYour Name 
257*5113495bSYour Name QDF_STATUS
target_if_peer_multi_rx_reorder_queue_setup(struct cdp_ctrl_objmgr_psoc * psoc,uint8_t pdev_id,struct multi_rx_reorder_queue_setup_params * tid_params)258*5113495bSYour Name target_if_peer_multi_rx_reorder_queue_setup(struct cdp_ctrl_objmgr_psoc *psoc,
259*5113495bSYour Name 		uint8_t pdev_id,
260*5113495bSYour Name 		struct multi_rx_reorder_queue_setup_params *tid_params)
261*5113495bSYour Name {
262*5113495bSYour Name 	struct scheduler_msg msg = {0};
263*5113495bSYour Name 	struct multi_reorder_q_setup *q_params;
264*5113495bSYour Name 	QDF_STATUS status;
265*5113495bSYour Name 	int tid;
266*5113495bSYour Name 
267*5113495bSYour Name 	q_params = qdf_mem_malloc(sizeof(*q_params));
268*5113495bSYour Name 	if (!q_params)
269*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
270*5113495bSYour Name 
271*5113495bSYour Name 	q_params->psoc = psoc;
272*5113495bSYour Name 	q_params->vdev_id = tid_params->vdev_id;
273*5113495bSYour Name 	q_params->pdev_id = pdev_id;
274*5113495bSYour Name 	q_params->tid_bitmap = tid_params->tid_bitmap;
275*5113495bSYour Name 	q_params->tid_num = tid_params->tid_num;
276*5113495bSYour Name 	qdf_mem_copy(q_params->peer_mac, tid_params->peer_macaddr,
277*5113495bSYour Name 		     QDF_MAC_ADDR_SIZE);
278*5113495bSYour Name 
279*5113495bSYour Name 	for (tid = 0; tid < DP_MAX_TIDS; tid++) {
280*5113495bSYour Name 		if (!(BIT(tid) & tid_params->tid_bitmap))
281*5113495bSYour Name 			continue;
282*5113495bSYour Name 		q_params->q_setup_list[tid].hw_qdesc_paddr =
283*5113495bSYour Name 			tid_params->queue_params_list[tid].hw_qdesc_paddr;
284*5113495bSYour Name 		q_params->q_setup_list[tid].queue_no =
285*5113495bSYour Name 			tid_params->queue_params_list[tid].queue_no;
286*5113495bSYour Name 		q_params->q_setup_list[tid].ba_window_size_valid =
287*5113495bSYour Name 			tid_params->queue_params_list[tid].ba_window_size_valid;
288*5113495bSYour Name 		q_params->q_setup_list[tid].ba_window_size =
289*5113495bSYour Name 			tid_params->queue_params_list[tid].ba_window_size;
290*5113495bSYour Name 	}
291*5113495bSYour Name 
292*5113495bSYour Name 	msg.bodyptr = q_params;
293*5113495bSYour Name 	msg.callback = target_if_multi_rx_reorder_queue_setup;
294*5113495bSYour Name 	status = scheduler_post_message(QDF_MODULE_ID_TARGET_IF,
295*5113495bSYour Name 					QDF_MODULE_ID_TARGET_IF,
296*5113495bSYour Name 					QDF_MODULE_ID_TARGET_IF, &msg);
297*5113495bSYour Name 
298*5113495bSYour Name 	if (status != QDF_STATUS_SUCCESS)
299*5113495bSYour Name 		qdf_mem_free(q_params);
300*5113495bSYour Name 
301*5113495bSYour Name 	return status;
302*5113495bSYour Name }
303*5113495bSYour Name #else
304*5113495bSYour Name QDF_STATUS
target_if_peer_rx_reorder_queue_setup(struct cdp_ctrl_objmgr_psoc * psoc,uint8_t pdev_id,uint8_t vdev_id,uint8_t * peer_macaddr,qdf_dma_addr_t hw_qdesc,int tid,uint16_t queue_no,uint8_t ba_window_size_valid,uint16_t ba_window_size)305*5113495bSYour Name target_if_peer_rx_reorder_queue_setup(struct cdp_ctrl_objmgr_psoc *psoc,
306*5113495bSYour Name 				      uint8_t pdev_id,
307*5113495bSYour Name 				      uint8_t vdev_id, uint8_t *peer_macaddr,
308*5113495bSYour Name 				      qdf_dma_addr_t hw_qdesc, int tid,
309*5113495bSYour Name 				      uint16_t queue_no,
310*5113495bSYour Name 				      uint8_t ba_window_size_valid,
311*5113495bSYour Name 				      uint16_t ba_window_size)
312*5113495bSYour Name {
313*5113495bSYour Name 	struct rx_reorder_queue_setup_params param;
314*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
315*5113495bSYour Name 	QDF_STATUS status;
316*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev =
317*5113495bSYour Name 		wlan_objmgr_get_pdev_by_id((struct wlan_objmgr_psoc *)psoc,
318*5113495bSYour Name 					   pdev_id, WLAN_PDEV_TARGET_IF_ID);
319*5113495bSYour Name 
320*5113495bSYour Name 	if (!pdev) {
321*5113495bSYour Name 		target_if_err("pdev with id %d is NULL", pdev_id);
322*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
323*5113495bSYour Name 	}
324*5113495bSYour Name 
325*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
326*5113495bSYour Name 	if (!pdev_wmi_handle) {
327*5113495bSYour Name 		wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
328*5113495bSYour Name 		target_if_err("pdev wmi handle NULL");
329*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
330*5113495bSYour Name 	}
331*5113495bSYour Name 	param.tid = tid;
332*5113495bSYour Name 	param.vdev_id = vdev_id;
333*5113495bSYour Name 	param.peer_macaddr = peer_macaddr;
334*5113495bSYour Name 	param.hw_qdesc_paddr_lo = hw_qdesc & 0xffffffff;
335*5113495bSYour Name 	param.hw_qdesc_paddr_hi = (uint64_t)hw_qdesc >> 32;
336*5113495bSYour Name 	param.queue_no = queue_no;
337*5113495bSYour Name 	param.ba_window_size_valid = ba_window_size_valid;
338*5113495bSYour Name 	param.ba_window_size = ba_window_size;
339*5113495bSYour Name 
340*5113495bSYour Name 	status = wmi_unified_peer_rx_reorder_queue_setup_send(pdev_wmi_handle,
341*5113495bSYour Name 							      &param);
342*5113495bSYour Name 	wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
343*5113495bSYour Name 
344*5113495bSYour Name 	return status;
345*5113495bSYour Name }
346*5113495bSYour Name 
347*5113495bSYour Name QDF_STATUS
target_if_peer_multi_rx_reorder_queue_setup(struct cdp_ctrl_objmgr_psoc * psoc,uint8_t pdev_id,struct multi_rx_reorder_queue_setup_params * tid_params)348*5113495bSYour Name target_if_peer_multi_rx_reorder_queue_setup(struct cdp_ctrl_objmgr_psoc *psoc,
349*5113495bSYour Name 		uint8_t pdev_id,
350*5113495bSYour Name 		struct multi_rx_reorder_queue_setup_params *tid_params)
351*5113495bSYour Name {
352*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
353*5113495bSYour Name 	QDF_STATUS status;
354*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev =
355*5113495bSYour Name 		wlan_objmgr_get_pdev_by_id((struct wlan_objmgr_psoc *)psoc,
356*5113495bSYour Name 					   pdev_id, WLAN_PDEV_TARGET_IF_ID);
357*5113495bSYour Name 	if (!pdev) {
358*5113495bSYour Name 		target_if_err("pdev with id %d is NULL", pdev_id);
359*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
360*5113495bSYour Name 	}
361*5113495bSYour Name 
362*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
363*5113495bSYour Name 	if (!pdev_wmi_handle) {
364*5113495bSYour Name 		wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
365*5113495bSYour Name 		target_if_err("pdev wmi handle NULL");
366*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
367*5113495bSYour Name 	}
368*5113495bSYour Name 
369*5113495bSYour Name 	status = wmi_unified_peer_multi_rx_reorder_queue_setup_send(
370*5113495bSYour Name 						pdev_wmi_handle, tid_params);
371*5113495bSYour Name 	wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
372*5113495bSYour Name 
373*5113495bSYour Name 	return status;
374*5113495bSYour Name }
375*5113495bSYour Name #endif
376*5113495bSYour Name 
377*5113495bSYour Name QDF_STATUS
target_if_peer_rx_reorder_queue_remove(struct cdp_ctrl_objmgr_psoc * psoc,uint8_t pdev_id,uint8_t vdev_id,uint8_t * peer_macaddr,uint32_t peer_tid_bitmap)378*5113495bSYour Name target_if_peer_rx_reorder_queue_remove(struct cdp_ctrl_objmgr_psoc *psoc,
379*5113495bSYour Name 				       uint8_t pdev_id,
380*5113495bSYour Name 				       uint8_t vdev_id, uint8_t *peer_macaddr,
381*5113495bSYour Name 				       uint32_t peer_tid_bitmap)
382*5113495bSYour Name {
383*5113495bSYour Name 	struct rx_reorder_queue_remove_params param;
384*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
385*5113495bSYour Name 	QDF_STATUS status;
386*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev =
387*5113495bSYour Name 		wlan_objmgr_get_pdev_by_id((struct wlan_objmgr_psoc *)psoc,
388*5113495bSYour Name 					   pdev_id, WLAN_PDEV_TARGET_IF_ID);
389*5113495bSYour Name 
390*5113495bSYour Name 	if (!pdev) {
391*5113495bSYour Name 		target_if_err("pdev with id %d is NULL", pdev_id);
392*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
393*5113495bSYour Name 	}
394*5113495bSYour Name 
395*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
396*5113495bSYour Name 	if (!pdev_wmi_handle) {
397*5113495bSYour Name 		wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
398*5113495bSYour Name 		target_if_err("pdev wmi handle NULL");
399*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
400*5113495bSYour Name 	}
401*5113495bSYour Name 	param.vdev_id = vdev_id;
402*5113495bSYour Name 	param.peer_macaddr = peer_macaddr;
403*5113495bSYour Name 	param.peer_tid_bitmap = peer_tid_bitmap;
404*5113495bSYour Name 	status = wmi_unified_peer_rx_reorder_queue_remove_send(pdev_wmi_handle,
405*5113495bSYour Name 							       &param);
406*5113495bSYour Name 	wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
407*5113495bSYour Name 
408*5113495bSYour Name 	return status;
409*5113495bSYour Name }
410*5113495bSYour Name 
411*5113495bSYour Name QDF_STATUS
target_if_lro_hash_config(struct cdp_ctrl_objmgr_psoc * psoc,uint8_t pdev_id,struct cdp_lro_hash_config * lro_hash_cfg)412*5113495bSYour Name target_if_lro_hash_config(struct cdp_ctrl_objmgr_psoc *psoc, uint8_t pdev_id,
413*5113495bSYour Name 			  struct cdp_lro_hash_config *lro_hash_cfg)
414*5113495bSYour Name {
415*5113495bSYour Name 	struct wmi_lro_config_cmd_t wmi_lro_cmd = {0};
416*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
417*5113495bSYour Name 	QDF_STATUS status;
418*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev =
419*5113495bSYour Name 		wlan_objmgr_get_pdev_by_id((struct wlan_objmgr_psoc *)psoc,
420*5113495bSYour Name 					   pdev_id, WLAN_PDEV_TARGET_IF_ID);
421*5113495bSYour Name 
422*5113495bSYour Name 	if (!pdev) {
423*5113495bSYour Name 		target_if_err("pdev with id %d is NULL", pdev_id);
424*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
425*5113495bSYour Name 	}
426*5113495bSYour Name 
427*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
428*5113495bSYour Name 	if (!lro_hash_cfg || !pdev_wmi_handle) {
429*5113495bSYour Name 		wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
430*5113495bSYour Name 		target_if_err("wmi_handle: 0x%pK, lro_hash_cfg: 0x%pK",
431*5113495bSYour Name 			      pdev_wmi_handle, lro_hash_cfg);
432*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
433*5113495bSYour Name 	}
434*5113495bSYour Name 
435*5113495bSYour Name 	wmi_lro_cmd.lro_enable = lro_hash_cfg->lro_enable;
436*5113495bSYour Name 	wmi_lro_cmd.tcp_flag = lro_hash_cfg->tcp_flag;
437*5113495bSYour Name 	wmi_lro_cmd.tcp_flag_mask = lro_hash_cfg->tcp_flag_mask;
438*5113495bSYour Name 	wmi_lro_cmd.pdev_id = pdev_id;
439*5113495bSYour Name 
440*5113495bSYour Name 	qdf_mem_copy(wmi_lro_cmd.toeplitz_hash_ipv4,
441*5113495bSYour Name 		     lro_hash_cfg->toeplitz_hash_ipv4,
442*5113495bSYour Name 		     LRO_IPV4_SEED_ARR_SZ * sizeof(uint32_t));
443*5113495bSYour Name 
444*5113495bSYour Name 	qdf_mem_copy(wmi_lro_cmd.toeplitz_hash_ipv6,
445*5113495bSYour Name 		     lro_hash_cfg->toeplitz_hash_ipv6,
446*5113495bSYour Name 		     LRO_IPV6_SEED_ARR_SZ * sizeof(uint32_t));
447*5113495bSYour Name 
448*5113495bSYour Name 	status = wmi_unified_lro_config_cmd(pdev_wmi_handle,
449*5113495bSYour Name 					    &wmi_lro_cmd);
450*5113495bSYour Name 	wlan_objmgr_pdev_release_ref(pdev, WLAN_PDEV_TARGET_IF_ID);
451*5113495bSYour Name 
452*5113495bSYour Name 	return status;
453*5113495bSYour Name }
454*5113495bSYour Name 
455*5113495bSYour Name #ifdef WLAN_SUPPORT_PPEDS
456*5113495bSYour Name QDF_STATUS
target_if_peer_set_ppeds_default_routing(struct cdp_ctrl_objmgr_psoc * soc,uint8_t * peer_macaddr,uint16_t service_code,uint8_t priority_valid,uint16_t src_info,uint8_t vdev_id,uint8_t use_ppe,uint8_t ppe_routing_enabled)457*5113495bSYour Name target_if_peer_set_ppeds_default_routing(struct cdp_ctrl_objmgr_psoc *soc,
458*5113495bSYour Name 					 uint8_t *peer_macaddr,
459*5113495bSYour Name 					 uint16_t service_code,
460*5113495bSYour Name 					 uint8_t priority_valid,
461*5113495bSYour Name 					 uint16_t src_info,
462*5113495bSYour Name 					 uint8_t vdev_id, uint8_t use_ppe,
463*5113495bSYour Name 					 uint8_t ppe_routing_enabled)
464*5113495bSYour Name {
465*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
466*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev;
467*5113495bSYour Name 	struct wlan_objmgr_vdev *vdev;
468*5113495bSYour Name 	struct peer_ppe_ds_param param;
469*5113495bSYour Name 	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
470*5113495bSYour Name 
471*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc = (struct wlan_objmgr_psoc *)soc;
472*5113495bSYour Name 	if (!psoc) {
473*5113495bSYour Name 		target_if_err("PSOC is NULL!");
474*5113495bSYour Name 		return QDF_STATUS_E_NULL_VALUE;
475*5113495bSYour Name 	}
476*5113495bSYour Name 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
477*5113495bSYour Name 						    WLAN_WDS_ID);
478*5113495bSYour Name 	if (!vdev) {
479*5113495bSYour Name 		target_if_err("vdev with id %d is NULL", vdev_id);
480*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
481*5113495bSYour Name 	}
482*5113495bSYour Name 
483*5113495bSYour Name 	pdev = wlan_vdev_get_pdev(vdev);
484*5113495bSYour Name 
485*5113495bSYour Name 	if (!pdev) {
486*5113495bSYour Name 		wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
487*5113495bSYour Name 		target_if_err("pdev is NULL");
488*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
489*5113495bSYour Name 	}
490*5113495bSYour Name 
491*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
492*5113495bSYour Name 	if (!pdev_wmi_handle) {
493*5113495bSYour Name 		wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
494*5113495bSYour Name 		target_if_err("pdev_wmi_handle is NULL");
495*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
496*5113495bSYour Name 	}
497*5113495bSYour Name 
498*5113495bSYour Name 	qdf_mem_zero(&param, sizeof(param));
499*5113495bSYour Name 
500*5113495bSYour Name 	qdf_mem_copy(&param.peer_macaddr[0], peer_macaddr, QDF_MAC_ADDR_SIZE);
501*5113495bSYour Name 	param.ppe_routing_enabled = ppe_routing_enabled;
502*5113495bSYour Name 	param.service_code = service_code;
503*5113495bSYour Name 	param.priority_valid = priority_valid;
504*5113495bSYour Name 	param.src_info = src_info;
505*5113495bSYour Name 	param.vdev_id = vdev_id;
506*5113495bSYour Name 	param.use_ppe = use_ppe;
507*5113495bSYour Name 
508*5113495bSYour Name 	qdf_status = wmi_unified_peer_ppe_ds_param_send(pdev_wmi_handle,
509*5113495bSYour Name 							&param);
510*5113495bSYour Name 	if (qdf_status != QDF_STATUS_SUCCESS) {
511*5113495bSYour Name 		target_if_err("Unable to set PPE default routing for peer "
512*5113495bSYour Name 				QDF_MAC_ADDR_FMT,
513*5113495bSYour Name 				QDF_MAC_ADDR_REF(peer_macaddr));
514*5113495bSYour Name 	}
515*5113495bSYour Name 
516*5113495bSYour Name 	wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
517*5113495bSYour Name 	return qdf_status;
518*5113495bSYour Name }
519*5113495bSYour Name #endif	/* WLAN_SUPPORT_PPEDS */
520*5113495bSYour Name 
521*5113495bSYour Name #ifdef WDS_CONV_TARGET_IF_OPS_ENABLE
522*5113495bSYour Name QDF_STATUS
target_if_add_wds_entry(struct cdp_ctrl_objmgr_psoc * soc,uint8_t vdev_id,uint8_t * peer_mac,const uint8_t * dest_mac,uint32_t flags,uint8_t type)523*5113495bSYour Name target_if_add_wds_entry(struct cdp_ctrl_objmgr_psoc *soc, uint8_t vdev_id,
524*5113495bSYour Name 			uint8_t *peer_mac, const uint8_t *dest_mac,
525*5113495bSYour Name 			uint32_t flags, uint8_t type)
526*5113495bSYour Name {
527*5113495bSYour Name 	struct peer_add_wds_entry_params wmi_wds_param = {0};
528*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
529*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev;
530*5113495bSYour Name 	struct wlan_objmgr_vdev *vdev;
531*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc = (struct wlan_objmgr_psoc *)soc;
532*5113495bSYour Name 	QDF_STATUS status;
533*5113495bSYour Name 
534*5113495bSYour Name 	if (type == CDP_TXRX_AST_TYPE_WDS_HM_SEC)
535*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
536*5113495bSYour Name 
537*5113495bSYour Name 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
538*5113495bSYour Name 						    WLAN_WDS_ID);
539*5113495bSYour Name 	if (!vdev) {
540*5113495bSYour Name 		target_if_err("vdev with id %d is NULL", vdev_id);
541*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
542*5113495bSYour Name 	}
543*5113495bSYour Name 
544*5113495bSYour Name 	pdev = wlan_vdev_get_pdev(vdev);
545*5113495bSYour Name 	if (!pdev) {
546*5113495bSYour Name 		wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
547*5113495bSYour Name 		target_if_err("pdev is NULL");
548*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
549*5113495bSYour Name 	}
550*5113495bSYour Name 
551*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
552*5113495bSYour Name 	if (!pdev_wmi_handle) {
553*5113495bSYour Name 		wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
554*5113495bSYour Name 		target_if_err("pdev_wmi_handle is NULL");
555*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
556*5113495bSYour Name 	}
557*5113495bSYour Name 
558*5113495bSYour Name 	qdf_mem_copy(&wmi_wds_param.dest_addr, dest_mac, QDF_MAC_ADDR_SIZE);
559*5113495bSYour Name 	qdf_mem_copy(&wmi_wds_param.peer_addr, peer_mac, QDF_MAC_ADDR_SIZE);
560*5113495bSYour Name 	wmi_wds_param.vdev_id = vdev_id;
561*5113495bSYour Name 	wmi_wds_param.flags = flags;
562*5113495bSYour Name 
563*5113495bSYour Name 	status = wmi_unified_peer_add_wds_entry_cmd(pdev_wmi_handle,
564*5113495bSYour Name 						    &wmi_wds_param);
565*5113495bSYour Name 	wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
566*5113495bSYour Name 
567*5113495bSYour Name 	return status;
568*5113495bSYour Name }
569*5113495bSYour Name 
570*5113495bSYour Name void
target_if_del_wds_entry(struct cdp_ctrl_objmgr_psoc * soc,uint8_t vdev_id,uint8_t * dest_mac,uint8_t type,uint8_t delete_in_fw)571*5113495bSYour Name target_if_del_wds_entry(struct cdp_ctrl_objmgr_psoc *soc, uint8_t vdev_id,
572*5113495bSYour Name 			uint8_t *dest_mac, uint8_t type, uint8_t delete_in_fw)
573*5113495bSYour Name {
574*5113495bSYour Name 	struct peer_del_wds_entry_params wmi_wds_param = {0};
575*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
576*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev;
577*5113495bSYour Name 	struct wlan_objmgr_vdev *vdev;
578*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc = (struct wlan_objmgr_psoc *)soc;
579*5113495bSYour Name 
580*5113495bSYour Name 	if (!delete_in_fw || type == CDP_TXRX_AST_TYPE_WDS_HM_SEC) {
581*5113495bSYour Name 		target_if_err("delete_in_fw: %d type: %d", delete_in_fw, type);
582*5113495bSYour Name 		return;
583*5113495bSYour Name 	}
584*5113495bSYour Name 
585*5113495bSYour Name 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
586*5113495bSYour Name 						    WLAN_WDS_ID);
587*5113495bSYour Name 	if (!vdev) {
588*5113495bSYour Name 		target_if_err("vdev with id %d is NULL", vdev_id);
589*5113495bSYour Name 		return;
590*5113495bSYour Name 	}
591*5113495bSYour Name 
592*5113495bSYour Name 	pdev = wlan_vdev_get_pdev(vdev);
593*5113495bSYour Name 	if (!pdev) {
594*5113495bSYour Name 		wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
595*5113495bSYour Name 		target_if_err("pdev is NULL");
596*5113495bSYour Name 		return;
597*5113495bSYour Name 	}
598*5113495bSYour Name 
599*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
600*5113495bSYour Name 	if (!pdev_wmi_handle) {
601*5113495bSYour Name 		wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
602*5113495bSYour Name 		target_if_err("pdev_wmi_handle is NULL");
603*5113495bSYour Name 		return;
604*5113495bSYour Name 	}
605*5113495bSYour Name 
606*5113495bSYour Name 	qdf_mem_copy(&wmi_wds_param.dest_addr, dest_mac, QDF_MAC_ADDR_SIZE);
607*5113495bSYour Name 	wmi_wds_param.vdev_id = vdev_id;
608*5113495bSYour Name 
609*5113495bSYour Name 	wmi_unified_peer_del_wds_entry_cmd(pdev_wmi_handle,
610*5113495bSYour Name 					   &wmi_wds_param);
611*5113495bSYour Name 	wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
612*5113495bSYour Name }
613*5113495bSYour Name 
614*5113495bSYour Name QDF_STATUS
target_if_update_wds_entry(struct cdp_ctrl_objmgr_psoc * soc,uint8_t vdev_id,uint8_t * dest_mac,uint8_t * peer_mac,uint32_t flags)615*5113495bSYour Name target_if_update_wds_entry(struct cdp_ctrl_objmgr_psoc *soc, uint8_t vdev_id,
616*5113495bSYour Name 			   uint8_t *dest_mac, uint8_t *peer_mac,
617*5113495bSYour Name 			   uint32_t flags)
618*5113495bSYour Name {
619*5113495bSYour Name 	struct peer_update_wds_entry_params wmi_wds_param = {0};
620*5113495bSYour Name 	struct wmi_unified *pdev_wmi_handle;
621*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev;
622*5113495bSYour Name 	struct wlan_objmgr_vdev *vdev;
623*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc = (struct wlan_objmgr_psoc *)soc;
624*5113495bSYour Name 	QDF_STATUS status;
625*5113495bSYour Name 
626*5113495bSYour Name 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id,
627*5113495bSYour Name 						    WLAN_WDS_ID);
628*5113495bSYour Name 	if (!vdev) {
629*5113495bSYour Name 		target_if_err("vdev with id %d is NULL", vdev_id);
630*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
631*5113495bSYour Name 	}
632*5113495bSYour Name 
633*5113495bSYour Name 	pdev = wlan_vdev_get_pdev(vdev);
634*5113495bSYour Name 	if (!pdev) {
635*5113495bSYour Name 		wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
636*5113495bSYour Name 		target_if_err("pdev is NULL");
637*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
638*5113495bSYour Name 	}
639*5113495bSYour Name 
640*5113495bSYour Name 	pdev_wmi_handle = lmac_get_pdev_wmi_handle(pdev);
641*5113495bSYour Name 	if (!pdev_wmi_handle) {
642*5113495bSYour Name 		wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
643*5113495bSYour Name 		target_if_err("pdev_wmi_handle is NULL");
644*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
645*5113495bSYour Name 	}
646*5113495bSYour Name 
647*5113495bSYour Name 	qdf_mem_copy(&wmi_wds_param.dest_addr, dest_mac, QDF_MAC_ADDR_SIZE);
648*5113495bSYour Name 	qdf_mem_copy(&wmi_wds_param.peer_addr, peer_mac, QDF_MAC_ADDR_SIZE);
649*5113495bSYour Name 	wmi_wds_param.vdev_id = vdev_id;
650*5113495bSYour Name 	wmi_wds_param.flags = flags;
651*5113495bSYour Name 
652*5113495bSYour Name 	status = wmi_unified_update_wds_entry_cmd(pdev_wmi_handle,
653*5113495bSYour Name 						  &wmi_wds_param);
654*5113495bSYour Name 	wlan_objmgr_vdev_release_ref(vdev, WLAN_WDS_ID);
655*5113495bSYour Name 
656*5113495bSYour Name 	return status;
657*5113495bSYour Name }
658*5113495bSYour Name #endif
659*5113495bSYour Name 
660*5113495bSYour Name #ifdef WLAN_FEATURE_PEER_TXQ_FLUSH_CONF
661*5113495bSYour Name /**
662*5113495bSYour Name  * map_flush_policy() - Map DP layer flush policy values to target i/f layer
663*5113495bSYour Name  * @policy: The DP layer flush policy value
664*5113495bSYour Name  *
665*5113495bSYour Name  * Return: Peer flush policy
666*5113495bSYour Name  */
667*5113495bSYour Name static enum peer_txq_flush_policy
map_flush_policy(enum cdp_peer_txq_flush_policy policy)668*5113495bSYour Name map_flush_policy(enum cdp_peer_txq_flush_policy policy)
669*5113495bSYour Name {
670*5113495bSYour Name 	switch (policy) {
671*5113495bSYour Name 	case  CDP_PEER_TXQ_FLUSH_POLICY_NONE:
672*5113495bSYour Name 		return PEER_TXQ_FLUSH_POLICY_NONE;
673*5113495bSYour Name 	case CDP_PEER_TXQ_FLUSH_POLICY_TWT_SP_END:
674*5113495bSYour Name 		return PEER_TXQ_FLUSH_POLICY_TWT_SP_END;
675*5113495bSYour Name 	default:
676*5113495bSYour Name 		return PEER_TXQ_FLUSH_POLICY_INVALID;
677*5113495bSYour Name 	}
678*5113495bSYour Name }
679*5113495bSYour Name 
680*5113495bSYour Name /**
681*5113495bSYour Name  * send_peer_txq_flush_conf() - Send flush config for peers TID queues
682*5113495bSYour Name  * @psoc: Opaque handle for posc object manager object
683*5113495bSYour Name  * @mac: MAC addr of peer for which the tx queue flush is intended
684*5113495bSYour Name  * @vdev_id: VDEV identifier
685*5113495bSYour Name  * @tid: TID mask for identifying the tx queues to be flushed
686*5113495bSYour Name  * @policy: The peer tid queue flush policy
687*5113495bSYour Name  *
688*5113495bSYour Name  * Return: 0 for success or error code
689*5113495bSYour Name  */
send_peer_txq_flush_conf(struct cdp_ctrl_objmgr_psoc * psoc,uint8_t * mac,uint8_t vdev_id,uint32_t tid,enum cdp_peer_txq_flush_policy policy)690*5113495bSYour Name static int send_peer_txq_flush_conf(struct cdp_ctrl_objmgr_psoc *psoc,
691*5113495bSYour Name 				    uint8_t *mac, uint8_t vdev_id,
692*5113495bSYour Name 				    uint32_t tid,
693*5113495bSYour Name 				    enum cdp_peer_txq_flush_policy policy)
694*5113495bSYour Name {
695*5113495bSYour Name 	struct wlan_objmgr_psoc *obj_soc;
696*5113495bSYour Name 	struct wmi_unified *wmi_handle;
697*5113495bSYour Name 	enum peer_txq_flush_policy flush_policy;
698*5113495bSYour Name 	struct peer_txq_flush_config_params param = {0};
699*5113495bSYour Name 	QDF_STATUS status;
700*5113495bSYour Name 
701*5113495bSYour Name 	obj_soc = (struct wlan_objmgr_psoc *)psoc;
702*5113495bSYour Name 	wmi_handle = GET_WMI_HDL_FROM_PSOC(obj_soc);
703*5113495bSYour Name 	if (!wmi_handle) {
704*5113495bSYour Name 		target_if_err("Invalid wmi handle");
705*5113495bSYour Name 		return -EINVAL;
706*5113495bSYour Name 	}
707*5113495bSYour Name 
708*5113495bSYour Name 	flush_policy = map_flush_policy(policy);
709*5113495bSYour Name 	if (flush_policy >= PEER_TXQ_FLUSH_POLICY_INVALID) {
710*5113495bSYour Name 		target_if_err("Invalid flush policy : %d", policy);
711*5113495bSYour Name 		return -EINVAL;
712*5113495bSYour Name 	}
713*5113495bSYour Name 
714*5113495bSYour Name 	param.vdev_id = vdev_id;
715*5113495bSYour Name 	param.tid_mask = tid;
716*5113495bSYour Name 	param.policy = flush_policy;
717*5113495bSYour Name 	qdf_mem_copy(param.peer, mac, QDF_MAC_ADDR_SIZE);
718*5113495bSYour Name 
719*5113495bSYour Name 	status = wmi_unified_peer_txq_flush_config_send(wmi_handle, &param);
720*5113495bSYour Name 	return qdf_status_to_os_return(status);
721*5113495bSYour Name }
722*5113495bSYour Name 
723*5113495bSYour Name /**
724*5113495bSYour Name  * send_peer_txq_flush_tids() - Send flush command peers TID queues
725*5113495bSYour Name  * @psoc: Opaque handle for psoc object manager object
726*5113495bSYour Name  * @mac: MAC addr of peer for which the tx queue flush is intended
727*5113495bSYour Name  * @vdev_id: VDEV identifier
728*5113495bSYour Name  * @tid: TID mask for identifying the tx queues to be flushed
729*5113495bSYour Name  *
730*5113495bSYour Name  * Return: 0 for success or error code
731*5113495bSYour Name  */
send_peer_txq_flush_tids(struct cdp_ctrl_objmgr_psoc * psoc,uint8_t * mac,uint8_t vdev_id,uint32_t tid)732*5113495bSYour Name static int send_peer_txq_flush_tids(struct cdp_ctrl_objmgr_psoc *psoc,
733*5113495bSYour Name 				    uint8_t *mac, uint8_t vdev_id,
734*5113495bSYour Name 				    uint32_t tid)
735*5113495bSYour Name {
736*5113495bSYour Name 	struct wlan_objmgr_psoc *obj_soc;
737*5113495bSYour Name 	struct wmi_unified *wmi_handle;
738*5113495bSYour Name 	struct peer_flush_params param;
739*5113495bSYour Name 	QDF_STATUS status;
740*5113495bSYour Name 
741*5113495bSYour Name 	if (!psoc || !mac) {
742*5113495bSYour Name 		target_if_err("Invalid params");
743*5113495bSYour Name 		return -EINVAL;
744*5113495bSYour Name 	}
745*5113495bSYour Name 
746*5113495bSYour Name 	obj_soc = (struct wlan_objmgr_psoc *)psoc;
747*5113495bSYour Name 	wmi_handle = GET_WMI_HDL_FROM_PSOC(obj_soc);
748*5113495bSYour Name 	if (!wmi_handle) {
749*5113495bSYour Name 		target_if_err("Invalid wmi handle");
750*5113495bSYour Name 		return -EINVAL;
751*5113495bSYour Name 	}
752*5113495bSYour Name 
753*5113495bSYour Name 	param.vdev_id = vdev_id;
754*5113495bSYour Name 	param.peer_tid_bitmap = tid;
755*5113495bSYour Name 	qdf_mem_copy(param.peer_mac, mac, QDF_MAC_ADDR_SIZE);
756*5113495bSYour Name 
757*5113495bSYour Name 	status = wmi_unified_peer_flush_tids_send(wmi_handle, mac, &param);
758*5113495bSYour Name 	return qdf_status_to_os_return(status);
759*5113495bSYour Name }
760*5113495bSYour Name 
target_if_peer_txq_flush_config(struct cdp_ctrl_objmgr_psoc * psoc,uint8_t vdev_id,uint8_t * addr,uint8_t ac,uint32_t tid,enum cdp_peer_txq_flush_policy policy)761*5113495bSYour Name int target_if_peer_txq_flush_config(struct cdp_ctrl_objmgr_psoc *psoc,
762*5113495bSYour Name 				    uint8_t vdev_id, uint8_t *addr,
763*5113495bSYour Name 				    uint8_t ac, uint32_t tid,
764*5113495bSYour Name 				    enum cdp_peer_txq_flush_policy policy)
765*5113495bSYour Name {
766*5113495bSYour Name 	static uint8_t ac_to_tid[4][2] = { {0, 3}, {1, 2}, {4, 5}, {6, 7} };
767*5113495bSYour Name 	struct wlan_objmgr_psoc *obj_soc;
768*5113495bSYour Name 	struct wlan_objmgr_peer *peer;
769*5113495bSYour Name 	int i, rc;
770*5113495bSYour Name 
771*5113495bSYour Name 	if (!psoc || !addr) {
772*5113495bSYour Name 		target_if_err("Invalid params");
773*5113495bSYour Name 		return -EINVAL;
774*5113495bSYour Name 	}
775*5113495bSYour Name 
776*5113495bSYour Name 	if (!tid && !ac) {
777*5113495bSYour Name 		target_if_err("no ac/tid mask setting");
778*5113495bSYour Name 		return -EINVAL;
779*5113495bSYour Name 	}
780*5113495bSYour Name 
781*5113495bSYour Name 	if (tid && policy == CDP_PEER_TXQ_FLUSH_POLICY_INVALID) {
782*5113495bSYour Name 		target_if_err("Invalid flush policy");
783*5113495bSYour Name 		return -EINVAL;
784*5113495bSYour Name 	}
785*5113495bSYour Name 	obj_soc = (struct wlan_objmgr_psoc *)psoc;
786*5113495bSYour Name 
787*5113495bSYour Name 	peer = wlan_objmgr_get_peer_by_mac(obj_soc, addr, WLAN_DP_ID);
788*5113495bSYour Name 	if (!peer) {
789*5113495bSYour Name 		target_if_err("Peer not found in the list");
790*5113495bSYour Name 		return -EINVAL;
791*5113495bSYour Name 	}
792*5113495bSYour Name 	/* If tid mask is provided and policy is immediate use legacy WMI.
793*5113495bSYour Name 	 * If tid mask is provided and policy is other than immediate use
794*5113495bSYour Name 	 * the new WMI command for flush config.
795*5113495bSYour Name 	 * If tid mask is not provided and ac mask is provided, convert to tid,
796*5113495bSYour Name 	 * use the legacy WMI cmd for flushing the queues immediately.
797*5113495bSYour Name 	 */
798*5113495bSYour Name 	if (tid) {
799*5113495bSYour Name 		if (policy == CDP_PEER_TXQ_FLUSH_POLICY_IMMEDIATE) {
800*5113495bSYour Name 			rc = send_peer_txq_flush_tids(psoc, addr, vdev_id, tid);
801*5113495bSYour Name 			wlan_objmgr_peer_release_ref(peer, WLAN_DP_ID);
802*5113495bSYour Name 			return rc;
803*5113495bSYour Name 		}
804*5113495bSYour Name 		rc = send_peer_txq_flush_conf(psoc, addr, vdev_id, tid, policy);
805*5113495bSYour Name 		wlan_objmgr_peer_release_ref(peer, WLAN_DP_ID);
806*5113495bSYour Name 		return rc;
807*5113495bSYour Name 	}
808*5113495bSYour Name 
809*5113495bSYour Name 	if (ac) {
810*5113495bSYour Name 		tid = 0;
811*5113495bSYour Name 		for (i = 0; i < 4; ++i) {
812*5113495bSYour Name 			if (((ac & 0x0f) >> i) & 0x01) {
813*5113495bSYour Name 				tid |= (1 << ac_to_tid[i][0]) |
814*5113495bSYour Name 				       (1 << ac_to_tid[i][1]);
815*5113495bSYour Name 			}
816*5113495bSYour Name 		}
817*5113495bSYour Name 		rc = send_peer_txq_flush_tids(psoc, addr, vdev_id, tid);
818*5113495bSYour Name 		wlan_objmgr_peer_release_ref(peer, WLAN_DP_ID);
819*5113495bSYour Name 		return rc;
820*5113495bSYour Name 	}
821*5113495bSYour Name 	 /* should not hit this line */
822*5113495bSYour Name 	return 0;
823*5113495bSYour Name }
824*5113495bSYour Name #endif
825