1 /*
2  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: public API related to the DP called by north bound HDD/OSIF
21  */
22 
23 #include "wlan_dp_ucfg_api.h"
24 #include "wlan_ipa_ucfg_api.h"
25 #include "wlan_dp_main.h"
26 #include "wlan_dp_objmgr.h"
27 #include "wlan_pmo_obj_mgmt_api.h"
28 #include "cdp_txrx_cmn.h"
29 #include "cfg_ucfg_api.h"
30 #include "wlan_pmo_obj_mgmt_api.h"
31 #include "wlan_dp_objmgr.h"
32 #include "wlan_dp_bus_bandwidth.h"
33 #include "wlan_dp_periodic_sta_stats.h"
34 #include "wlan_dp_nud_tracking.h"
35 #include "wlan_dp_txrx.h"
36 #include "wlan_nlink_common.h"
37 #include "wlan_pkt_capture_api.h"
38 #include <cdp_txrx_ctrl.h>
39 #include <qdf_net_stats.h>
40 #include "wlan_dp_prealloc.h"
41 #include "wlan_dp_rx_thread.h"
42 #include <cdp_txrx_host_stats.h>
43 #ifdef WLAN_FEATURE_11BE_MLO
44 #include "wlan_mlo_mgr_public_api.h"
45 #endif
46 #include "cdp_txrx_ctrl.h"
47 
48 #ifdef FEATURE_DIRECT_LINK
49 /**
50  * wlan_dp_set_vdev_direct_link_cfg() - Set direct link config in DP vdev
51  * @psoc: objmgr psoc handle
52  * @dp_intf: pointer to DP component interface handle
53  *
54  * Return: direct link configuration
55  */
56 static inline
wlan_dp_set_vdev_direct_link_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_dp_intf * dp_intf)57 QDF_STATUS wlan_dp_set_vdev_direct_link_cfg(struct wlan_objmgr_psoc *psoc,
58 					    struct wlan_dp_intf *dp_intf)
59 {
60 	struct wlan_dp_link *dp_link, *dp_link_next;
61 	cdp_config_param_type vdev_param = {0};
62 	QDF_STATUS status;
63 
64 	if (dp_intf->device_mode != QDF_SAP_MODE ||
65 	    !dp_intf->dp_ctx->dp_direct_link_ctx)
66 		return QDF_STATUS_SUCCESS;
67 
68 	dp_for_each_link_held_safe(dp_intf, dp_link, dp_link_next) {
69 		vdev_param.cdp_vdev_tx_to_fw =
70 					dp_intf->direct_link_config.config_set;
71 		status = cdp_txrx_set_vdev_param(wlan_psoc_get_dp_handle(psoc),
72 						 dp_link->link_id,
73 						 CDP_VDEV_TX_TO_FW, vdev_param);
74 		if (QDF_IS_STATUS_ERROR(status))
75 			break;
76 	}
77 
78 	return status;
79 }
80 #else
81 static inline
wlan_dp_set_vdev_direct_link_cfg(struct wlan_objmgr_psoc * psoc,struct wlan_dp_intf * dp_intf)82 QDF_STATUS wlan_dp_set_vdev_direct_link_cfg(struct wlan_objmgr_psoc *psoc,
83 					    struct wlan_dp_intf *dp_intf)
84 {
85 	return QDF_STATUS_SUCCESS;
86 }
87 #endif
88 
89 #ifdef WLAN_FEATURE_11BE_MLO
90 static inline
wlan_dp_update_vdev_mac_addr(struct wlan_dp_psoc_context * dp_ctx,struct wlan_dp_link * dp_link,struct qdf_mac_addr * new_mac_addr)91 QDF_STATUS wlan_dp_update_vdev_mac_addr(struct wlan_dp_psoc_context *dp_ctx,
92 					struct wlan_dp_link *dp_link,
93 					struct qdf_mac_addr *new_mac_addr)
94 {
95 	cdp_config_param_type vdev_param = {0};
96 
97 	qdf_mem_copy(&vdev_param.mac_addr, new_mac_addr, QDF_MAC_ADDR_SIZE);
98 
99 	/* CDP API to change the mac address */
100 	return cdp_txrx_set_vdev_param(dp_ctx->cdp_soc, dp_link->link_id,
101 				       CDP_VDEV_SET_MAC_ADDR, vdev_param);
102 }
103 
wlan_dp_register_link_switch_notifier(void)104 static QDF_STATUS wlan_dp_register_link_switch_notifier(void)
105 {
106 	return wlan_mlo_mgr_register_link_switch_notifier(
107 					WLAN_COMP_DP,
108 					dp_link_switch_notification);
109 }
110 
wlan_dp_unregister_link_switch_notifier(void)111 static QDF_STATUS wlan_dp_unregister_link_switch_notifier(void)
112 {
113 	return wlan_mlo_mgr_unregister_link_switch_notifier(WLAN_COMP_DP);
114 }
115 #else
116 static inline
wlan_dp_update_vdev_mac_addr(struct wlan_dp_psoc_context * dp_ctx,struct wlan_dp_link * dp_link,struct qdf_mac_addr * new_mac_addr)117 QDF_STATUS wlan_dp_update_vdev_mac_addr(struct wlan_dp_psoc_context *dp_ctx,
118 					struct wlan_dp_link *dp_link,
119 					struct qdf_mac_addr *new_mac_addr)
120 {
121 	/* Link switch should be done only for 802.11BE */
122 	qdf_assert(0);
123 	return QDF_STATUS_E_NOSUPPORT;
124 }
125 
wlan_dp_register_link_switch_notifier(void)126 static inline QDF_STATUS wlan_dp_register_link_switch_notifier(void)
127 {
128 	return QDF_STATUS_SUCCESS;
129 }
130 
wlan_dp_unregister_link_switch_notifier(void)131 static inline QDF_STATUS wlan_dp_unregister_link_switch_notifier(void)
132 {
133 	return QDF_STATUS_SUCCESS;
134 }
135 #endif
136 
137 /** Add sanity for multiple link switches in parallel */
ucfg_dp_update_link_mac_addr(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * new_mac_addr,bool is_link_switch)138 QDF_STATUS ucfg_dp_update_link_mac_addr(struct wlan_objmgr_vdev *vdev,
139 					struct qdf_mac_addr *new_mac_addr,
140 					bool is_link_switch)
141 {
142 	struct wlan_dp_psoc_context *dp_ctx;
143 	struct wlan_dp_link *dp_link;
144 	QDF_STATUS status = QDF_STATUS_SUCCESS;
145 
146 	dp_ctx = dp_get_context();
147 
148 	dp_link = dp_get_vdev_priv_obj(vdev);
149 	if (!is_dp_link_valid(dp_link)) {
150 		dp_err("dp_link from vdev %pK is invalid", vdev);
151 		return QDF_STATUS_E_INVAL;
152 	}
153 
154 	qdf_copy_macaddr(&dp_link->mac_addr, new_mac_addr);
155 
156 	if (is_link_switch)
157 		status = wlan_dp_update_vdev_mac_addr(dp_ctx, dp_link,
158 						      new_mac_addr);
159 
160 	return status;
161 }
162 
ucfg_dp_update_def_link(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * intf_mac,struct wlan_objmgr_vdev * vdev)163 void ucfg_dp_update_def_link(struct wlan_objmgr_psoc *psoc,
164 			     struct qdf_mac_addr *intf_mac,
165 			     struct wlan_objmgr_vdev *vdev)
166 
167 {
168 	__wlan_dp_update_def_link(psoc, intf_mac, vdev);
169 }
170 
ucfg_dp_update_intf_mac(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * cur_mac,struct qdf_mac_addr * new_mac,struct wlan_objmgr_vdev * vdev)171 void ucfg_dp_update_intf_mac(struct wlan_objmgr_psoc *psoc,
172 			     struct qdf_mac_addr *cur_mac,
173 			     struct qdf_mac_addr *new_mac,
174 			     struct wlan_objmgr_vdev *vdev)
175 {
176 	struct wlan_dp_intf *dp_intf;
177 	struct wlan_dp_link *dp_link;
178 	struct wlan_dp_psoc_context *dp_ctx;
179 
180 	dp_ctx =  dp_psoc_get_priv(psoc);
181 
182 	dp_intf = dp_get_intf_by_macaddr(dp_ctx, cur_mac);
183 	if (!dp_intf) {
184 		dp_err("DP interface not found addr:" QDF_MAC_ADDR_FMT,
185 		       QDF_MAC_ADDR_REF(cur_mac->bytes));
186 		QDF_BUG(0);
187 		return;
188 	}
189 
190 	dp_info("MAC update from " QDF_MAC_ADDR_FMT " to " QDF_MAC_ADDR_FMT "",
191 		QDF_MAC_ADDR_REF(cur_mac->bytes),
192 		QDF_MAC_ADDR_REF(new_mac->bytes));
193 
194 	qdf_copy_macaddr(&dp_intf->mac_addr, new_mac);
195 
196 	/*
197 	 * update of dp_intf mac address happens only during dynamic mac
198 	 * address update. This is a special case, where the connection
199 	 * can change without vdevs getting deleted.
200 	 * Hence its expected to reset the def_link in dp_intf to the
201 	 * def_link used by UMAC, for the next connection.
202 	 */
203 	dp_link = dp_get_vdev_priv_obj(vdev);
204 	dp_info("Try def_link update for dp_intf %pK from %pK to %pK (intf %pK id %d)",
205 		dp_intf, dp_intf->def_link, dp_link,
206 		dp_link ? dp_link->dp_intf : NULL,
207 		dp_link ? dp_link->link_id : 255);
208 	if (dp_link && dp_link->dp_intf == dp_intf)
209 		dp_intf->def_link = dp_link;
210 
211 	wlan_dp_set_vdev_direct_link_cfg(psoc, dp_intf);
212 }
213 
214 QDF_STATUS
ucfg_dp_create_intf(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * intf_addr,qdf_netdev_t ndev)215 ucfg_dp_create_intf(struct wlan_objmgr_psoc *psoc,
216 		    struct qdf_mac_addr *intf_addr,
217 		    qdf_netdev_t ndev)
218 {
219 	struct wlan_dp_intf *dp_intf;
220 	struct wlan_dp_psoc_context *dp_ctx;
221 
222 	dp_ctx =  dp_get_context();
223 
224 	dp_info("DP interface create addr:" QDF_MAC_ADDR_FMT,
225 		QDF_MAC_ADDR_REF(intf_addr->bytes));
226 
227 	dp_intf = __qdf_mem_malloc(sizeof(*dp_intf), __func__, __LINE__);
228 	if (!dp_intf) {
229 		dp_err("DP intf memory alloc failed addr:" QDF_MAC_ADDR_FMT,
230 		       QDF_MAC_ADDR_REF(intf_addr->bytes));
231 		return QDF_STATUS_E_FAILURE;
232 	}
233 
234 	dp_intf->def_link = NULL;
235 	dp_intf->dp_ctx = dp_ctx;
236 	dp_intf->dev = ndev;
237 	qdf_copy_macaddr(&dp_intf->mac_addr, intf_addr);
238 
239 	qdf_spin_lock_bh(&dp_ctx->intf_list_lock);
240 	qdf_list_insert_front(&dp_ctx->intf_list, &dp_intf->node);
241 	qdf_spin_unlock_bh(&dp_ctx->intf_list_lock);
242 
243 	qdf_spinlock_create(&dp_intf->dp_link_list_lock);
244 	qdf_list_create(&dp_intf->dp_link_list, 0);
245 
246 	dp_periodic_sta_stats_init(dp_intf);
247 	dp_periodic_sta_stats_mutex_create(dp_intf);
248 	dp_nud_init_tracking(dp_intf);
249 	dp_mic_init_work(dp_intf);
250 	qdf_atomic_init(&dp_ctx->num_latency_critical_clients);
251 	qdf_atomic_init(&dp_intf->gro_disallowed);
252 
253 	return QDF_STATUS_SUCCESS;
254 }
255 
256 QDF_STATUS
ucfg_dp_destroy_intf(struct wlan_objmgr_psoc * psoc,struct qdf_mac_addr * intf_addr)257 ucfg_dp_destroy_intf(struct wlan_objmgr_psoc *psoc,
258 		     struct qdf_mac_addr *intf_addr)
259 {
260 	struct wlan_dp_intf *dp_intf;
261 	struct wlan_dp_psoc_context *dp_ctx;
262 
263 	dp_ctx =  dp_get_context();
264 
265 	dp_info("DP interface destroy addr:" QDF_MAC_ADDR_FMT,
266 		QDF_MAC_ADDR_REF(intf_addr->bytes));
267 
268 	dp_intf = dp_get_intf_by_macaddr(dp_ctx, intf_addr);
269 	if (!dp_intf) {
270 		dp_err("DP interface not found addr:" QDF_MAC_ADDR_FMT,
271 		       QDF_MAC_ADDR_REF(intf_addr->bytes));
272 		return QDF_STATUS_E_FAILURE;
273 	}
274 
275 	if (dp_intf->device_mode == QDF_SAP_MODE)
276 		dp_config_direct_link(dp_intf, false, false);
277 
278 	dp_periodic_sta_stats_mutex_destroy(dp_intf);
279 	dp_nud_deinit_tracking(dp_intf);
280 	dp_mic_deinit_work(dp_intf);
281 
282 	qdf_spinlock_destroy(&dp_intf->dp_link_list_lock);
283 	qdf_list_destroy(&dp_intf->dp_link_list);
284 
285 	qdf_spin_lock_bh(&dp_ctx->intf_list_lock);
286 	qdf_list_remove_node(&dp_ctx->intf_list, &dp_intf->node);
287 	qdf_spin_unlock_bh(&dp_ctx->intf_list_lock);
288 
289 	__qdf_mem_free(dp_intf);
290 
291 	return QDF_STATUS_SUCCESS;
292 }
293 
ucfg_dp_set_cmn_dp_handle(struct wlan_objmgr_psoc * psoc,ol_txrx_soc_handle soc)294 void ucfg_dp_set_cmn_dp_handle(struct wlan_objmgr_psoc *psoc,
295 			       ol_txrx_soc_handle soc)
296 {
297 	struct wlan_dp_psoc_context *dp_ctx;
298 	cdp_config_param_type soc_param;
299 	QDF_STATUS status;
300 
301 	dp_ctx = dp_psoc_get_priv(psoc);
302 
303 	if (!dp_ctx) {
304 		dp_err("Unable to get DP context");
305 		return;
306 	}
307 
308 	dp_ctx->cdp_soc = soc;
309 
310 	soc_param.hal_soc_hdl = NULL;
311 	status = cdp_txrx_get_psoc_param(dp_ctx->cdp_soc, CDP_TXRX_HAL_SOC_HDL,
312 					 &soc_param);
313 	if (QDF_IS_STATUS_ERROR(status)) {
314 		dp_err("Unable to fetch hal soc handle");
315 		return;
316 	}
317 
318 	dp_ctx->hal_soc = soc_param.hal_soc_hdl;
319 }
320 
ucfg_dp_set_hif_handle(struct wlan_objmgr_psoc * psoc,struct hif_opaque_softc * hif_handle)321 void ucfg_dp_set_hif_handle(struct wlan_objmgr_psoc *psoc,
322 			    struct hif_opaque_softc *hif_handle)
323 {
324 	struct wlan_dp_psoc_context *dp_ctx;
325 
326 	dp_ctx = dp_psoc_get_priv(psoc);
327 	if (!dp_ctx) {
328 		dp_err("Unable to get DP context");
329 		return;
330 	}
331 
332 	dp_ctx->hif_handle = hif_handle;
333 }
334 
ucfg_dp_init(void)335 QDF_STATUS ucfg_dp_init(void)
336 {
337 	QDF_STATUS status;
338 
339 	dp_info("DP module dispatcher init");
340 
341 	if (dp_allocate_ctx() != QDF_STATUS_SUCCESS) {
342 		dp_err("DP ctx allocation failed");
343 		return QDF_STATUS_E_FAULT;
344 	}
345 
346 	status = wlan_objmgr_register_psoc_create_handler(
347 			WLAN_COMP_DP,
348 			dp_psoc_obj_create_notification, NULL);
349 	if (QDF_IS_STATUS_ERROR(status)) {
350 		dp_err("Failed to register psoc create handler for DP");
351 		return status;
352 	}
353 
354 	status = wlan_objmgr_register_psoc_destroy_handler(
355 			WLAN_COMP_DP,
356 			dp_psoc_obj_destroy_notification, NULL);
357 	if (QDF_IS_STATUS_ERROR(status)) {
358 		dp_err("Failed to register psoc destroy handler for DP");
359 		goto fail_destroy_psoc;
360 	}
361 
362 	status = wlan_objmgr_register_pdev_create_handler(
363 			WLAN_COMP_DP,
364 			dp_pdev_obj_create_notification, NULL);
365 	if (QDF_IS_STATUS_ERROR(status)) {
366 		dp_err("Failed to register pdev create handler for DP");
367 		goto fail_create_pdev;
368 	}
369 
370 	status = wlan_objmgr_register_pdev_destroy_handler(
371 			WLAN_COMP_DP,
372 			dp_pdev_obj_destroy_notification, NULL);
373 	if (QDF_IS_STATUS_ERROR(status)) {
374 		dp_err("Failed to register pdev destroy handler for DP");
375 		goto fail_destroy_pdev;
376 	}
377 
378 	status = wlan_objmgr_register_vdev_create_handler(
379 			WLAN_COMP_DP,
380 			dp_vdev_obj_create_notification, NULL);
381 	if (QDF_IS_STATUS_ERROR(status)) {
382 		dp_err("Failed to register vdev create handler");
383 		goto fail_create_vdev;
384 	}
385 
386 	status = wlan_objmgr_register_vdev_destroy_handler(
387 			WLAN_COMP_DP,
388 			dp_vdev_obj_destroy_notification, NULL);
389 	if (QDF_IS_STATUS_ERROR(status)) {
390 		dp_err("Failed to register vdev destroy handler");
391 		goto fail_destroy_vdev;
392 	}
393 
394 	status = wlan_objmgr_register_peer_create_handler(
395 		WLAN_COMP_DP,
396 		dp_peer_obj_create_notification,
397 		NULL);
398 	if (QDF_IS_STATUS_ERROR(status)) {
399 		dp_err("wlan_objmgr_register_peer_create_handler failed");
400 		goto fail_create_peer;
401 	}
402 
403 	status = wlan_objmgr_register_peer_destroy_handler(
404 		WLAN_COMP_DP,
405 		dp_peer_obj_destroy_notification,
406 		NULL);
407 	if (QDF_IS_STATUS_ERROR(status)) {
408 		dp_err("wlan_objmgr_register_peer_destroy_handler failed");
409 		goto fail_destroy_peer;
410 	}
411 
412 	status = wlan_dp_register_link_switch_notifier();
413 	if (QDF_IS_STATUS_ERROR(status)) {
414 		dp_err("wlan_mlomgr_register_link_switch_handler failed");
415 		goto fail_link_switch;
416 	}
417 
418 	return QDF_STATUS_SUCCESS;
419 
420 fail_link_switch:
421 	wlan_objmgr_unregister_peer_destroy_handler(
422 			WLAN_COMP_DP, dp_peer_obj_destroy_notification,
423 			NULL);
424 
425 fail_destroy_peer:
426 	wlan_objmgr_unregister_peer_create_handler(WLAN_COMP_DP,
427 					dp_peer_obj_create_notification,
428 					NULL);
429 
430 fail_create_peer:
431 	wlan_objmgr_unregister_vdev_destroy_handler(WLAN_COMP_DP,
432 					dp_vdev_obj_destroy_notification,
433 					NULL);
434 
435 fail_destroy_vdev:
436 	wlan_objmgr_unregister_vdev_create_handler(
437 				WLAN_COMP_DP,
438 				dp_vdev_obj_create_notification, NULL);
439 
440 fail_create_vdev:
441 	wlan_objmgr_unregister_pdev_destroy_handler(
442 				WLAN_COMP_DP,
443 				dp_pdev_obj_destroy_notification, NULL);
444 
445 fail_destroy_pdev:
446 	wlan_objmgr_unregister_pdev_create_handler(
447 				WLAN_COMP_DP,
448 				dp_pdev_obj_create_notification, NULL);
449 
450 fail_create_pdev:
451 	wlan_objmgr_unregister_psoc_destroy_handler(
452 				WLAN_COMP_DP,
453 				dp_psoc_obj_destroy_notification, NULL);
454 fail_destroy_psoc:
455 	wlan_objmgr_unregister_psoc_create_handler(
456 				WLAN_COMP_DP,
457 				dp_psoc_obj_create_notification, NULL);
458 
459 	dp_free_ctx();
460 	return status;
461 }
462 
ucfg_dp_deinit(void)463 QDF_STATUS ucfg_dp_deinit(void)
464 {
465 	QDF_STATUS status;
466 
467 	dp_info("DP module dispatcher deinit");
468 
469 	/* de-register link switch handler */
470 	wlan_dp_unregister_link_switch_notifier();
471 
472 	/* de-register peer delete handler functions. */
473 	status = wlan_objmgr_unregister_peer_destroy_handler(
474 				WLAN_COMP_DP,
475 				dp_peer_obj_destroy_notification, NULL);
476 	if (QDF_IS_STATUS_ERROR(status))
477 		dp_err("Failed to unregister DP peer destroy handler: %d", status);
478 
479 	/* de-register peer create handler functions. */
480 	status = wlan_objmgr_unregister_peer_create_handler(
481 				WLAN_COMP_DP,
482 				dp_peer_obj_create_notification, NULL);
483 	if (QDF_IS_STATUS_ERROR(status))
484 		dp_err("Failed to unregister DP peer create handler: %d", status);
485 
486 	status = wlan_objmgr_unregister_vdev_destroy_handler(
487 				WLAN_COMP_DP,
488 				dp_vdev_obj_destroy_notification,
489 				NULL);
490 	if (QDF_IS_STATUS_ERROR(status))
491 		dp_err("Failed to unregister vdev delete handler:%d", status);
492 
493 	status = wlan_objmgr_unregister_vdev_create_handler(
494 				WLAN_COMP_DP,
495 				dp_vdev_obj_create_notification, NULL);
496 	if (QDF_IS_STATUS_ERROR(status))
497 		dp_err("Failed to unregister vdev create handler:%d", status);
498 
499 	status = wlan_objmgr_unregister_pdev_destroy_handler(
500 				WLAN_COMP_DP,
501 				dp_pdev_obj_destroy_notification, NULL);
502 	if (QDF_IS_STATUS_ERROR(status))
503 		dp_err("Failed to unregister pdev destroy handler:%d", status);
504 
505 	status = wlan_objmgr_unregister_pdev_create_handler(
506 				WLAN_COMP_DP,
507 				dp_pdev_obj_create_notification, NULL);
508 	if (QDF_IS_STATUS_ERROR(status))
509 		dp_err("Failed to unregister pdev create handler:%d", status);
510 
511 	status = wlan_objmgr_unregister_psoc_destroy_handler(
512 				WLAN_COMP_DP,
513 				dp_psoc_obj_destroy_notification, NULL);
514 	if (QDF_IS_STATUS_ERROR(status))
515 		dp_err("Failed to unregister DP psoc delete handle:%d", status);
516 
517 	status = wlan_objmgr_unregister_psoc_create_handler(
518 				WLAN_COMP_DP,
519 				dp_psoc_obj_create_notification, NULL);
520 	if (QDF_IS_STATUS_ERROR(status))
521 		dp_err("Failed to unregister DP psoc create handle:%d", status);
522 
523 	dp_free_ctx();
524 
525 	return status;
526 }
527 
528 /**
529  * ucfg_dp_suspend_handler() - suspend handler registered with PMO component
530  * @psoc: psoc handle
531  * @arg: Arguments passed by the suspend handler.
532  *
533  * This handler is used to update the wiphy suspend state in DP context
534  *
535  * Return: QDF_STATUS status -in case of success else return error
536  */
537 static QDF_STATUS
ucfg_dp_suspend_handler(struct wlan_objmgr_psoc * psoc,void * arg)538 ucfg_dp_suspend_handler(struct wlan_objmgr_psoc *psoc, void *arg)
539 {
540 	struct wlan_dp_psoc_context *dp_ctx;
541 	struct wlan_dp_intf *dp_intf, *dp_intf_next = NULL;
542 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
543 	QDF_STATUS status;
544 
545 	dp_ctx = dp_psoc_get_priv(psoc);
546 	if (!dp_ctx) {
547 		dp_err("DP context not found");
548 		return QDF_STATUS_E_FAILURE;
549 	}
550 	if (dp_ctx->enable_dp_rx_threads) {
551 		status = dp_txrx_suspend(cds_get_context(QDF_MODULE_ID_SOC));
552 
553 		if (status != QDF_STATUS_SUCCESS) {
554 			dp_txrx_resume(cds_get_context(QDF_MODULE_ID_SOC));
555 			return status;
556 			}
557 	}
558 	dp_ctx->is_suspend = true;
559 	cdp_set_tx_pause(soc, true);
560 	dp_for_each_intf_held_safe(dp_ctx, dp_intf, dp_intf_next) {
561 		dp_intf->sap_tx_block_mask |= WLAN_DP_SUSPEND;
562 	}
563 	return QDF_STATUS_SUCCESS;
564 }
565 
566 /**
567  * ucfg_dp_resume_handler() - resume handler registered with PMO component
568  * @psoc: psoc handle
569  * @arg: Arguments passed by the resume handler.
570  *
571  * This handler is used to update the wiphy resume state in DP context
572  *
573  * Return: QDF_STATUS status -in case of success else return error
574  */
575 static QDF_STATUS
ucfg_dp_resume_handler(struct wlan_objmgr_psoc * psoc,void * arg)576 ucfg_dp_resume_handler(struct wlan_objmgr_psoc *psoc, void *arg)
577 {
578 	struct wlan_dp_psoc_context *dp_ctx;
579 	struct wlan_dp_intf *dp_intf, *dp_intf_next = NULL;
580 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
581 
582 	dp_ctx = dp_psoc_get_priv(psoc);
583 	if (!dp_ctx) {
584 		dp_err("DP context not found");
585 		return QDF_STATUS_E_FAILURE;
586 	}
587 
588 	dp_ctx->is_suspend = false;
589 	cdp_set_tx_pause(soc, false);
590 	dp_for_each_intf_held_safe(dp_ctx, dp_intf, dp_intf_next) {
591 		dp_intf->sap_tx_block_mask &= ~WLAN_DP_SUSPEND;
592 	}
593 	if (dp_ctx->enable_dp_rx_threads)
594 		dp_txrx_resume(cds_get_context(QDF_MODULE_ID_SOC));
595 	return QDF_STATUS_SUCCESS;
596 }
597 
598 /**
599  * dp_register_pmo_handler() - register suspend and resume handler
600  * with PMO component
601  *
602  * Return: None
603  */
dp_register_pmo_handler(void)604 static inline void dp_register_pmo_handler(void)
605 {
606 	pmo_register_suspend_handler(WLAN_COMP_DP,
607 				     ucfg_dp_suspend_handler, NULL);
608 
609 	pmo_register_resume_handler(WLAN_COMP_DP,
610 				    ucfg_dp_resume_handler, NULL);
611 }
612 
613 /**
614  * dp_unregister_pmo_handler() - unregister suspend and resume handler
615  * with PMO component
616  *
617  * Return: None
618  */
dp_unregister_pmo_handler(void)619 static inline void dp_unregister_pmo_handler(void)
620 {
621 	pmo_unregister_suspend_handler(WLAN_COMP_DP, ucfg_dp_suspend_handler);
622 
623 	pmo_unregister_resume_handler(WLAN_COMP_DP, ucfg_dp_resume_handler);
624 }
625 
626 /**
627  * ucfg_dp_store_qdf_dev() - Store qdf device instance in DP component
628  * @psoc: psoc handle
629  *
630  * Return: QDF_STATUS status -in case of success else return error
631  */
632 static inline QDF_STATUS
ucfg_dp_store_qdf_dev(struct wlan_objmgr_psoc * psoc)633 ucfg_dp_store_qdf_dev(struct wlan_objmgr_psoc *psoc)
634 {
635 	struct wlan_dp_psoc_context *dp_ctx;
636 
637 	dp_ctx = dp_psoc_get_priv(psoc);
638 	if (!dp_ctx) {
639 		dp_err("DP context not found");
640 		return QDF_STATUS_E_FAILURE;
641 	}
642 
643 	dp_ctx->qdf_dev = wlan_psoc_get_qdf_dev(psoc);
644 	if (!dp_ctx->qdf_dev) {
645 		dp_err("QDF_DEV is NULL");
646 		QDF_BUG(0);
647 		return QDF_STATUS_E_FAILURE;
648 	}
649 	return QDF_STATUS_SUCCESS;
650 }
651 
ucfg_dp_psoc_open(struct wlan_objmgr_psoc * psoc)652 QDF_STATUS ucfg_dp_psoc_open(struct wlan_objmgr_psoc *psoc)
653 {
654 	struct wlan_dp_psoc_context *dp_ctx;
655 
656 	dp_ctx = dp_psoc_get_priv(psoc);
657 	if (!dp_ctx) {
658 		dp_err("DP context not found");
659 		return QDF_STATUS_E_FAILURE;
660 	}
661 
662 	ucfg_dp_store_qdf_dev(psoc);
663 	dp_rtpm_tput_policy_init(psoc);
664 	dp_register_pmo_handler();
665 	dp_trace_init(psoc);
666 	dp_bus_bandwidth_init(psoc);
667 	qdf_wake_lock_create(&dp_ctx->rx_wake_lock, "qcom_rx_wakelock");
668 
669 	return QDF_STATUS_SUCCESS;
670 }
671 
ucfg_dp_psoc_close(struct wlan_objmgr_psoc * psoc)672 QDF_STATUS ucfg_dp_psoc_close(struct wlan_objmgr_psoc *psoc)
673 {
674 	struct wlan_dp_psoc_context *dp_ctx;
675 
676 	dp_ctx = dp_psoc_get_priv(psoc);
677 	if (!dp_ctx) {
678 		dp_err("DP context not found");
679 		return QDF_STATUS_E_FAILURE;
680 	}
681 
682 	dp_rtpm_tput_policy_deinit(psoc);
683 	dp_unregister_pmo_handler();
684 	dp_bus_bandwidth_deinit(psoc);
685 	qdf_wake_lock_destroy(&dp_ctx->rx_wake_lock);
686 
687 	return QDF_STATUS_SUCCESS;
688 }
689 
ucfg_dp_suspend_wlan(struct wlan_objmgr_psoc * psoc)690 void ucfg_dp_suspend_wlan(struct wlan_objmgr_psoc *psoc)
691 {
692 	struct wlan_dp_psoc_context *dp_ctx;
693 
694 	dp_ctx = dp_psoc_get_priv(psoc);
695 	if (!dp_ctx) {
696 		dp_err("DP context not found");
697 		return;
698 	}
699 
700 	dp_ctx->is_wiphy_suspended = true;
701 }
702 
ucfg_dp_resume_wlan(struct wlan_objmgr_psoc * psoc)703 void ucfg_dp_resume_wlan(struct wlan_objmgr_psoc *psoc)
704 {
705 	struct wlan_dp_psoc_context *dp_ctx;
706 
707 	dp_ctx = dp_psoc_get_priv(psoc);
708 	if (!dp_ctx) {
709 		dp_err("DP context not found");
710 		return;
711 	}
712 
713 	dp_ctx->is_wiphy_suspended = false;
714 }
715 
ucfg_dp_wait_complete_tasks(void)716 void ucfg_dp_wait_complete_tasks(void)
717 {
718 	struct wlan_dp_psoc_context *dp_ctx;
719 
720 	dp_ctx =  dp_get_context();
721 	dp_wait_complete_tasks(dp_ctx);
722 }
723 
724 /*
725  * During connect/disconnect this needs to be updated
726  */
727 
ucfg_dp_remove_conn_info(struct wlan_objmgr_vdev * vdev)728 void ucfg_dp_remove_conn_info(struct wlan_objmgr_vdev *vdev)
729 {
730 	struct wlan_dp_link *dp_link;
731 
732 	dp_link = dp_get_vdev_priv_obj(vdev);
733 	if (unlikely(!dp_link)) {
734 		dp_err("DP link not found");
735 		return;
736 	}
737 
738 	qdf_mem_zero(&dp_link->conn_info,
739 		     sizeof(struct wlan_dp_conn_info));
740 }
741 
ucfg_dp_conn_info_set_bssid(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * bssid)742 void ucfg_dp_conn_info_set_bssid(struct wlan_objmgr_vdev *vdev,
743 				 struct qdf_mac_addr *bssid)
744 {
745 	struct wlan_dp_link *dp_link;
746 
747 	dp_link = dp_get_vdev_priv_obj(vdev);
748 	if (unlikely(!dp_link)) {
749 		dp_err("DP link not found");
750 		return;
751 	}
752 
753 	qdf_copy_macaddr(&dp_link->conn_info.bssid, bssid);
754 }
755 
ucfg_dp_conn_info_set_arp_service(struct wlan_objmgr_vdev * vdev,uint8_t proxy_arp_service)756 void ucfg_dp_conn_info_set_arp_service(struct wlan_objmgr_vdev *vdev,
757 				       uint8_t proxy_arp_service)
758 {
759 	struct wlan_dp_link *dp_link;
760 
761 	dp_link = dp_get_vdev_priv_obj(vdev);
762 	if (unlikely(!dp_link)) {
763 		dp_err("DP link not found");
764 		return;
765 	}
766 
767 	dp_link->conn_info.proxy_arp_service = proxy_arp_service;
768 }
769 
ucfg_dp_conn_info_set_peer_authenticate(struct wlan_objmgr_vdev * vdev,uint8_t is_authenticated)770 void ucfg_dp_conn_info_set_peer_authenticate(struct wlan_objmgr_vdev *vdev,
771 					     uint8_t is_authenticated)
772 {
773 	struct wlan_dp_link *dp_link;
774 
775 	dp_link = dp_get_vdev_priv_obj(vdev);
776 	if (unlikely(!dp_link)) {
777 		dp_err("DP link not found");
778 		return;
779 	}
780 
781 	dp_link->conn_info.is_authenticated = is_authenticated;
782 }
783 
ucfg_dp_conn_info_set_peer_mac(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * peer_mac)784 void ucfg_dp_conn_info_set_peer_mac(struct wlan_objmgr_vdev *vdev,
785 				    struct qdf_mac_addr *peer_mac)
786 {
787 	struct wlan_dp_link *dp_link;
788 
789 	dp_link = dp_get_vdev_priv_obj(vdev);
790 	if (unlikely(!dp_link)) {
791 		dp_err("DP link not found");
792 		return;
793 	}
794 
795 	qdf_copy_macaddr(&dp_link->conn_info.peer_macaddr, peer_mac);
796 }
797 
ucfg_dp_softap_check_wait_for_tx_eap_pkt(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * mac_addr)798 void ucfg_dp_softap_check_wait_for_tx_eap_pkt(struct wlan_objmgr_vdev *vdev,
799 					      struct qdf_mac_addr *mac_addr)
800 {
801 	struct wlan_dp_intf *dp_intf;
802 	struct wlan_dp_link *dp_link;
803 
804 	dp_link = dp_get_vdev_priv_obj(vdev);
805 	if (unlikely(!dp_link)) {
806 		dp_err("DP link not found");
807 		return;
808 	}
809 
810 	dp_intf = dp_link->dp_intf;
811 	dp_softap_check_wait_for_tx_eap_pkt(dp_intf, mac_addr);
812 }
813 
ucfg_dp_update_dhcp_state_on_disassoc(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr * mac_addr)814 void ucfg_dp_update_dhcp_state_on_disassoc(struct wlan_objmgr_vdev *vdev,
815 					   struct qdf_mac_addr *mac_addr)
816 {
817 	struct wlan_dp_intf *dp_intf;
818 	struct wlan_dp_link *dp_link;
819 	struct wlan_objmgr_peer *peer;
820 	struct wlan_dp_sta_info *stainfo;
821 
822 	dp_link = dp_get_vdev_priv_obj(vdev);
823 	if (unlikely(!dp_link)) {
824 		dp_err("DP link not found");
825 		return;
826 	}
827 
828 	dp_intf = dp_link->dp_intf;
829 	peer = wlan_objmgr_get_peer_by_mac(dp_intf->dp_ctx->psoc,
830 					   mac_addr->bytes,
831 					   WLAN_DP_ID);
832 	if (!peer) {
833 		dp_err("Peer object not found mac:" QDF_MAC_ADDR_FMT,
834 		       QDF_MAC_ADDR_REF(mac_addr->bytes));
835 		return;
836 	}
837 
838 	stainfo = dp_get_peer_priv_obj(peer);
839 	if (!stainfo) {
840 		wlan_objmgr_peer_release_ref(peer, WLAN_DP_ID);
841 		return;
842 	}
843 
844 	/* Send DHCP STOP indication to FW */
845 	stainfo->dhcp_phase = DHCP_PHASE_ACK;
846 	if (stainfo->dhcp_nego_status == DHCP_NEGO_IN_PROGRESS)
847 		dp_post_dhcp_ind(dp_link,
848 				 stainfo->sta_mac.bytes,
849 				 0);
850 	stainfo->dhcp_nego_status = DHCP_NEGO_STOP;
851 	wlan_objmgr_peer_release_ref(peer, WLAN_DP_ID);
852 }
853 
ucfg_dp_set_dfs_cac_tx(struct wlan_objmgr_vdev * vdev,bool tx_block)854 void ucfg_dp_set_dfs_cac_tx(struct wlan_objmgr_vdev *vdev, bool tx_block)
855 {
856 	struct wlan_dp_intf *dp_intf;
857 	struct wlan_dp_link *dp_link;
858 
859 	dp_link = dp_get_vdev_priv_obj(vdev);
860 	if (unlikely(!dp_link)) {
861 		dp_err("DP link not found");
862 		return;
863 	}
864 
865 	dp_intf = dp_link->dp_intf;
866 	if (tx_block)
867 		dp_intf->sap_tx_block_mask |= DP_TX_DFS_CAC_BLOCK;
868 	else
869 		dp_intf->sap_tx_block_mask &= ~DP_TX_DFS_CAC_BLOCK;
870 }
871 
ucfg_dp_set_bss_state_start(struct wlan_objmgr_vdev * vdev,bool start)872 void ucfg_dp_set_bss_state_start(struct wlan_objmgr_vdev *vdev, bool start)
873 {
874 	struct wlan_dp_intf *dp_intf;
875 	struct wlan_dp_link *dp_link;
876 
877 	dp_link = dp_get_vdev_priv_obj(vdev);
878 	if (unlikely(!dp_link)) {
879 		dp_err("DP link not found");
880 		return;
881 	}
882 
883 	dp_intf = dp_link->dp_intf;
884 	if (start) {
885 		dp_intf->sap_tx_block_mask &= ~DP_TX_SAP_STOP;
886 		dp_intf->bss_state = BSS_INTF_START;
887 	} else {
888 		dp_intf->sap_tx_block_mask |= DP_TX_SAP_STOP;
889 		dp_intf->bss_state = BSS_INTF_STOP;
890 	}
891 }
892 
ucfg_dp_lro_set_reset(struct wlan_objmgr_vdev * vdev,uint8_t enable_flag)893 QDF_STATUS ucfg_dp_lro_set_reset(struct wlan_objmgr_vdev *vdev,
894 				 uint8_t enable_flag)
895 {
896 	struct wlan_dp_intf *dp_intf;
897 	struct wlan_dp_link *dp_link;
898 
899 	dp_link = dp_get_vdev_priv_obj(vdev);
900 	if (unlikely(!dp_link)) {
901 		dp_err("DP link not found");
902 		return QDF_STATUS_E_INVAL;
903 	}
904 
905 	dp_intf = dp_link->dp_intf;
906 	return dp_lro_set_reset(dp_intf, enable_flag);
907 }
908 
ucfg_dp_is_ol_enabled(struct wlan_objmgr_psoc * psoc)909 bool ucfg_dp_is_ol_enabled(struct wlan_objmgr_psoc *psoc)
910 {
911 	struct wlan_dp_psoc_context *dp_ctx;
912 
913 	dp_ctx = dp_psoc_get_priv(psoc);
914 	if (!dp_ctx) {
915 		dp_err("DP context not found");
916 		return 0;
917 	}
918 
919 	return dp_ctx->ol_enable;
920 }
921 
922 #ifdef RECEIVE_OFFLOAD
ucfg_dp_rx_handle_concurrency(struct wlan_objmgr_psoc * psoc,bool disable)923 void ucfg_dp_rx_handle_concurrency(struct wlan_objmgr_psoc *psoc,
924 				   bool disable)
925 {
926 	struct wlan_dp_psoc_context *dp_ctx;
927 
928 	dp_ctx = dp_psoc_get_priv(psoc);
929 	if (!dp_ctx) {
930 		dp_err("DP context not found");
931 		return;
932 	}
933 
934 	if (disable) {
935 		if (DP_BUS_BW_CFG(dp_ctx->dp_cfg.enable_tcp_delack)) {
936 			struct wlan_rx_tp_data rx_tp_data;
937 
938 			dp_info("Enable TCP delack as LRO disabled in concurrency");
939 			rx_tp_data.rx_tp_flags = TCP_DEL_ACK_IND;
940 			rx_tp_data.level =
941 				DP_BUS_BW_GET_RX_LVL(dp_ctx);
942 			wlan_dp_update_tcp_rx_param(dp_ctx, &rx_tp_data);
943 			dp_ctx->en_tcp_delack_no_lro = 1;
944 		}
945 		qdf_atomic_set(&dp_ctx->disable_rx_ol_in_concurrency, 1);
946 	} else {
947 		if (DP_BUS_BW_CFG(dp_ctx->dp_cfg.enable_tcp_delack)) {
948 			dp_info("Disable TCP delack as LRO is enabled");
949 			dp_ctx->en_tcp_delack_no_lro = 0;
950 			dp_reset_tcp_delack(psoc);
951 		}
952 		qdf_atomic_set(&dp_ctx->disable_rx_ol_in_concurrency, 0);
953 	}
954 }
955 
ucfg_dp_rx_ol_init(struct wlan_objmgr_psoc * psoc,bool is_wifi3_0_target)956 QDF_STATUS ucfg_dp_rx_ol_init(struct wlan_objmgr_psoc *psoc,
957 			      bool is_wifi3_0_target)
958 {
959 	struct wlan_dp_psoc_context *dp_ctx;
960 
961 	dp_ctx = dp_psoc_get_priv(psoc);
962 	if (!dp_ctx) {
963 		dp_err("DP context not found");
964 		return QDF_STATUS_E_INVAL;
965 	}
966 
967 	return dp_rx_ol_init(dp_ctx, is_wifi3_0_target);
968 }
969 #else /* RECEIVE_OFFLOAD */
970 
ucfg_dp_rx_ol_init(struct wlan_objmgr_psoc * psoc,bool is_wifi3_0_target)971 QDF_STATUS ucfg_dp_rx_ol_init(struct wlan_objmgr_psoc *psoc,
972 			      bool is_wifi3_0_target)
973 {
974 	dp_err("Rx_OL, LRO/GRO not supported");
975 	return QDF_STATUS_E_NOSUPPORT;
976 }
977 #endif
978 
ucfg_dp_is_rx_common_thread_enabled(struct wlan_objmgr_psoc * psoc)979 bool ucfg_dp_is_rx_common_thread_enabled(struct wlan_objmgr_psoc *psoc)
980 {
981 	struct wlan_dp_psoc_context *dp_ctx;
982 
983 	dp_ctx = dp_psoc_get_priv(psoc);
984 	if (!dp_ctx) {
985 		dp_err("DP context not found");
986 		return QDF_STATUS_E_INVAL;
987 	}
988 
989 	return dp_ctx->enable_rxthread;
990 }
991 
ucfg_dp_is_rx_threads_enabled(struct wlan_objmgr_psoc * psoc)992 bool ucfg_dp_is_rx_threads_enabled(struct wlan_objmgr_psoc *psoc)
993 {
994 	struct wlan_dp_psoc_context *dp_ctx;
995 
996 	dp_ctx = dp_psoc_get_priv(psoc);
997 	if (!dp_ctx) {
998 		dp_err("DP context not found");
999 		return QDF_STATUS_E_INVAL;
1000 	}
1001 
1002 	return dp_ctx->enable_dp_rx_threads;
1003 }
1004 
1005 #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
1006 /**
1007  * dp_get_config_rx_softirq_limits() - Update DP rx softirq limit config
1008  *                          datapath
1009  * @psoc: psoc handle
1010  * @params: DP Configuration parameters
1011  *
1012  * Return: None
1013  */
1014 static
dp_get_config_rx_softirq_limits(struct wlan_objmgr_psoc * psoc,struct cdp_config_params * params)1015 void dp_get_config_rx_softirq_limits(struct wlan_objmgr_psoc *psoc,
1016 				     struct cdp_config_params *params)
1017 {
1018 	params->tx_comp_loop_pkt_limit = cfg_get(psoc,
1019 						 CFG_DP_TX_COMP_LOOP_PKT_LIMIT);
1020 	params->rx_reap_loop_pkt_limit = cfg_get(psoc,
1021 						 CFG_DP_RX_REAP_LOOP_PKT_LIMIT);
1022 	params->rx_hp_oos_update_limit = cfg_get(psoc,
1023 						 CFG_DP_RX_HP_OOS_UPDATE_LIMIT);
1024 }
1025 #else
1026 static
dp_get_config_rx_softirq_limits(struct wlan_objmgr_psoc * psoc,struct cdp_config_params * params)1027 void dp_get_config_rx_softirq_limits(struct wlan_objmgr_psoc *psoc,
1028 				     struct cdp_config_params *params)
1029 {
1030 }
1031 #endif /* WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT */
1032 
1033 #if defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(QCA_LL_PDEV_TX_FLOW_CONTROL)
1034 /**
1035  * dp_get_config_queue_threshold() - Update DP tx flow limit config
1036  *                          datapath
1037  * @psoc: psoc handle
1038  * @params: DP Configuration parameters
1039  *
1040  * Return: None
1041  */
1042 static void
dp_get_config_queue_threshold(struct wlan_objmgr_psoc * psoc,struct cdp_config_params * params)1043 dp_get_config_queue_threshold(struct wlan_objmgr_psoc *psoc,
1044 			      struct cdp_config_params *params)
1045 {
1046 	params->tx_flow_stop_queue_threshold =
1047 			cfg_get(psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH);
1048 	params->tx_flow_start_queue_offset =
1049 			cfg_get(psoc, CFG_DP_TX_FLOW_START_QUEUE_OFFSET);
1050 }
1051 #else
1052 static inline void
dp_get_config_queue_threshold(struct wlan_objmgr_psoc * psoc,struct cdp_config_params * params)1053 dp_get_config_queue_threshold(struct wlan_objmgr_psoc *psoc,
1054 			      struct cdp_config_params *params)
1055 {
1056 }
1057 #endif
1058 
1059 QDF_STATUS
ucfg_dp_update_config(struct wlan_objmgr_psoc * psoc,struct wlan_dp_user_config * req)1060 ucfg_dp_update_config(struct wlan_objmgr_psoc *psoc,
1061 		      struct wlan_dp_user_config *req)
1062 {
1063 	struct cdp_config_params params = {0};
1064 	struct wlan_dp_psoc_context *dp_ctx;
1065 	QDF_STATUS status;
1066 	void *soc;
1067 
1068 	dp_ctx =  dp_psoc_get_priv(psoc);
1069 	if (!dp_ctx) {
1070 		dp_err("Unable to get DP context");
1071 		return QDF_STATUS_E_INVAL;
1072 	}
1073 
1074 	dp_ctx->arp_connectivity_map = req->arp_connectivity_map;
1075 	soc = cds_get_context(QDF_MODULE_ID_SOC);
1076 	params.tso_enable = cfg_get(psoc, CFG_DP_TSO);
1077 	dp_ctx->dp_cfg.lro_enable = cfg_get(psoc, CFG_DP_LRO);
1078 	params.lro_enable = dp_ctx->dp_cfg.lro_enable;
1079 
1080 	dp_get_config_queue_threshold(psoc, &params);
1081 	params.flow_steering_enable =
1082 		cfg_get(psoc, CFG_DP_FLOW_STEERING_ENABLED);
1083 	params.napi_enable = dp_ctx->napi_enable;
1084 	params.p2p_tcp_udp_checksumoffload =
1085 		cfg_get(psoc, CFG_DP_P2P_TCP_UDP_CKSUM_OFFLOAD);
1086 	params.nan_tcp_udp_checksumoffload =
1087 		cfg_get(psoc, CFG_DP_NAN_TCP_UDP_CKSUM_OFFLOAD);
1088 	params.tcp_udp_checksumoffload =
1089 		cfg_get(psoc, CFG_DP_TCP_UDP_CKSUM_OFFLOAD);
1090 	params.ipa_enable = req->ipa_enable;
1091 	dp_ctx->dp_cfg.gro_enable = cfg_get(psoc, CFG_DP_GRO);
1092 	params.gro_enable = dp_ctx->dp_cfg.gro_enable;
1093 	params.tx_comp_loop_pkt_limit = cfg_get(psoc,
1094 						CFG_DP_TX_COMP_LOOP_PKT_LIMIT);
1095 	params.rx_reap_loop_pkt_limit = cfg_get(psoc,
1096 						CFG_DP_RX_REAP_LOOP_PKT_LIMIT);
1097 	params.rx_hp_oos_update_limit = cfg_get(psoc,
1098 						CFG_DP_RX_HP_OOS_UPDATE_LIMIT);
1099 	dp_get_config_rx_softirq_limits(psoc, &params);
1100 
1101 	status = cdp_update_config_parameters(soc, &params);
1102 	if (status) {
1103 		dp_err("Failed to attach config parameters");
1104 		return status;
1105 	}
1106 
1107 	return QDF_STATUS_SUCCESS;
1108 }
1109 
1110 uint64_t
ucfg_dp_get_rx_softirq_yield_duration(struct wlan_objmgr_psoc * psoc)1111 ucfg_dp_get_rx_softirq_yield_duration(struct wlan_objmgr_psoc *psoc)
1112 {
1113 	struct wlan_dp_psoc_context *dp_ctx;
1114 
1115 	dp_ctx = dp_psoc_get_priv(psoc);
1116 	if (!dp_ctx) {
1117 		dp_err("Unable to get DP context");
1118 		return 0;
1119 	}
1120 
1121 	return dp_ctx->dp_cfg.rx_softirq_max_yield_duration_ns;
1122 }
1123 
1124 #if defined(WLAN_SUPPORT_RX_FISA)
1125 /**
1126  * dp_rx_register_fisa_ops() - FISA callback functions
1127  * @txrx_ops: operations handle holding callback functions
1128  *
1129  * Return: None
1130  */
1131 static inline void
dp_rx_register_fisa_ops(struct ol_txrx_ops * txrx_ops)1132 dp_rx_register_fisa_ops(struct ol_txrx_ops *txrx_ops)
1133 {
1134 	txrx_ops->rx.osif_fisa_rx = wlan_dp_rx_fisa_cbk;
1135 	txrx_ops->rx.osif_fisa_flush = wlan_dp_rx_fisa_flush_by_ctx_id;
1136 }
1137 #else
1138 static inline void
dp_rx_register_fisa_ops(struct ol_txrx_ops * txrx_ops)1139 dp_rx_register_fisa_ops(struct ol_txrx_ops *txrx_ops)
1140 {
1141 }
1142 #endif
1143 
1144 #ifdef CONFIG_DP_PKT_ADD_TIMESTAMP
wlan_dp_get_tsf_time(void * dp_link_ctx,uint64_t input_time,uint64_t * tsf_time)1145 static QDF_STATUS wlan_dp_get_tsf_time(void *dp_link_ctx,
1146 				       uint64_t input_time,
1147 				       uint64_t *tsf_time)
1148 {
1149 	struct wlan_dp_link *dp_link = (struct wlan_dp_link *)dp_link_ctx;
1150 	struct wlan_dp_intf *dp_intf = dp_link->dp_intf;
1151 	struct wlan_dp_psoc_callbacks *dp_ops = &dp_intf->dp_ctx->dp_ops;
1152 
1153 	dp_ops->dp_get_tsf_time(dp_intf->dev,
1154 				input_time,
1155 				tsf_time);
1156 	return QDF_STATUS_SUCCESS;
1157 }
1158 #else
wlan_dp_get_tsf_time(void * dp_link_ctx,uint64_t input_time,uint64_t * tsf_time)1159 static QDF_STATUS wlan_dp_get_tsf_time(void *dp_link_ctx,
1160 				       uint64_t input_time,
1161 				       uint64_t *tsf_time)
1162 {
1163 	*tsf_time = 0;
1164 	return QDF_STATUS_E_NOSUPPORT;
1165 }
1166 #endif
1167 
ucfg_dp_sta_register_txrx_ops(struct wlan_objmgr_vdev * vdev)1168 QDF_STATUS ucfg_dp_sta_register_txrx_ops(struct wlan_objmgr_vdev *vdev)
1169 {
1170 	struct ol_txrx_ops txrx_ops;
1171 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1172 	struct wlan_dp_intf *dp_intf;
1173 	struct wlan_dp_link *dp_link;
1174 
1175 	dp_link = dp_get_vdev_priv_obj(vdev);
1176 	if (unlikely(!dp_link)) {
1177 		dp_err("DP link not found");
1178 		return QDF_STATUS_E_INVAL;
1179 	}
1180 
1181 	dp_intf = dp_link->dp_intf;
1182 	/* Register the vdev transmit and receive functions */
1183 	qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1184 
1185 	if (dp_intf->dp_ctx->enable_dp_rx_threads) {
1186 		txrx_ops.rx.rx = dp_rx_pkt_thread_enqueue_cbk;
1187 		txrx_ops.rx.rx_stack = dp_rx_packet_cbk;
1188 		txrx_ops.rx.rx_flush = dp_rx_flush_packet_cbk;
1189 		txrx_ops.rx.rx_gro_flush = dp_rx_thread_gro_flush_ind_cbk;
1190 	} else {
1191 		txrx_ops.rx.rx = dp_rx_packet_cbk;
1192 		txrx_ops.rx.rx_stack = NULL;
1193 		txrx_ops.rx.rx_flush = NULL;
1194 	}
1195 
1196 	if (wlan_dp_cfg_is_rx_fisa_enabled(&dp_intf->dp_ctx->dp_cfg) &&
1197 	    dp_intf->device_mode != QDF_MONITOR_MODE) {
1198 		dp_debug("FISA feature enabled");
1199 		dp_rx_register_fisa_ops(&txrx_ops);
1200 	}
1201 
1202 	txrx_ops.rx.stats_rx = dp_tx_rx_collect_connectivity_stats_info;
1203 
1204 	txrx_ops.tx.tx_comp = dp_sta_notify_tx_comp_cb;
1205 	txrx_ops.tx.tx = NULL;
1206 	txrx_ops.get_tsf_time = wlan_dp_get_tsf_time;
1207 	txrx_ops.vdev_del_notify = wlan_dp_link_cdp_vdev_delete_notification;
1208 	cdp_vdev_register(soc, dp_link->link_id, (ol_osif_vdev_handle)dp_link,
1209 			  &txrx_ops);
1210 	if (!txrx_ops.tx.tx) {
1211 		dp_err("vdev register fail");
1212 		return QDF_STATUS_E_FAILURE;
1213 	}
1214 
1215 	dp_link->cdp_vdev_registered = 1;
1216 	dp_link->cdp_vdev_deleted = 0;
1217 	dp_link->destroyed = 0;
1218 
1219 	dp_intf->txrx_ops = txrx_ops;
1220 
1221 	return QDF_STATUS_SUCCESS;
1222 }
1223 
1224 #ifdef FEATURE_WLAN_TDLS
ucfg_dp_tdlsta_register_txrx_ops(struct wlan_objmgr_vdev * vdev)1225 QDF_STATUS ucfg_dp_tdlsta_register_txrx_ops(struct wlan_objmgr_vdev *vdev)
1226 {
1227 	struct ol_txrx_ops txrx_ops;
1228 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1229 	struct wlan_dp_intf *dp_intf;
1230 	struct wlan_dp_link *dp_link;
1231 
1232 	dp_link = dp_get_vdev_priv_obj(vdev);
1233 	if (unlikely(!dp_link)) {
1234 		dp_err("DP link not found");
1235 		return QDF_STATUS_E_INVAL;
1236 	}
1237 
1238 	dp_intf = dp_link->dp_intf;
1239 	/* Register the vdev transmit and receive functions */
1240 	qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1241 	if (dp_intf->dp_ctx->enable_dp_rx_threads) {
1242 		txrx_ops.rx.rx = dp_rx_pkt_thread_enqueue_cbk;
1243 		txrx_ops.rx.rx_stack = dp_rx_packet_cbk;
1244 		txrx_ops.rx.rx_flush = dp_rx_flush_packet_cbk;
1245 		txrx_ops.rx.rx_gro_flush = dp_rx_thread_gro_flush_ind_cbk;
1246 	} else {
1247 		txrx_ops.rx.rx = dp_rx_packet_cbk;
1248 		txrx_ops.rx.rx_stack = NULL;
1249 		txrx_ops.rx.rx_flush = NULL;
1250 	}
1251 
1252 	if (wlan_dp_cfg_is_rx_fisa_enabled(&dp_intf->dp_ctx->dp_cfg) &&
1253 	    dp_intf->device_mode != QDF_MONITOR_MODE) {
1254 		dp_debug("FISA feature enabled");
1255 		dp_rx_register_fisa_ops(&txrx_ops);
1256 	}
1257 
1258 	txrx_ops.rx.stats_rx = dp_tx_rx_collect_connectivity_stats_info;
1259 
1260 	txrx_ops.tx.tx_comp = dp_sta_notify_tx_comp_cb;
1261 	txrx_ops.tx.tx = NULL;
1262 
1263 	txrx_ops.vdev_del_notify = wlan_dp_link_cdp_vdev_delete_notification;
1264 	cdp_vdev_register(soc, dp_link->link_id, (ol_osif_vdev_handle)dp_link,
1265 			  &txrx_ops);
1266 
1267 	if (!txrx_ops.tx.tx) {
1268 		dp_err("vdev register fail");
1269 		return QDF_STATUS_E_FAILURE;
1270 	}
1271 
1272 	dp_link->cdp_vdev_registered = 1;
1273 	dp_link->cdp_vdev_deleted = 0;
1274 	dp_link->destroyed = 0;
1275 	dp_intf->txrx_ops = txrx_ops;
1276 
1277 	return QDF_STATUS_SUCCESS;
1278 }
1279 #endif
1280 
ucfg_dp_ocb_register_txrx_ops(struct wlan_objmgr_vdev * vdev)1281 QDF_STATUS ucfg_dp_ocb_register_txrx_ops(struct wlan_objmgr_vdev *vdev)
1282 {
1283 	struct ol_txrx_ops txrx_ops;
1284 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1285 	struct wlan_dp_intf *dp_intf;
1286 	struct wlan_dp_link *dp_link;
1287 
1288 	dp_link = dp_get_vdev_priv_obj(vdev);
1289 	if (unlikely(!dp_link)) {
1290 		dp_err("DP link not found");
1291 		return QDF_STATUS_E_INVAL;
1292 	}
1293 
1294 	dp_intf = dp_link->dp_intf;
1295 	/* Register the vdev transmit and receive functions */
1296 	qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1297 	txrx_ops.rx.rx = dp_rx_packet_cbk;
1298 	txrx_ops.rx.stats_rx = dp_tx_rx_collect_connectivity_stats_info;
1299 	txrx_ops.vdev_del_notify = wlan_dp_link_cdp_vdev_delete_notification;
1300 
1301 	cdp_vdev_register(soc, dp_link->link_id, (ol_osif_vdev_handle)dp_link,
1302 			  &txrx_ops);
1303 	if (!txrx_ops.tx.tx) {
1304 		dp_err("vdev register fail");
1305 		return QDF_STATUS_E_FAILURE;
1306 	}
1307 
1308 	dp_link->cdp_vdev_registered = 1;
1309 	dp_link->cdp_vdev_deleted = 0;
1310 	dp_link->destroyed = 0;
1311 	dp_intf->txrx_ops = txrx_ops;
1312 
1313 	qdf_copy_macaddr(&dp_link->conn_info.peer_macaddr,
1314 			 &dp_link->mac_addr);
1315 
1316 	return QDF_STATUS_SUCCESS;
1317 }
1318 
1319 #ifdef FEATURE_MONITOR_MODE_SUPPORT
ucfg_dp_mon_register_txrx_ops(struct wlan_objmgr_vdev * vdev)1320 QDF_STATUS ucfg_dp_mon_register_txrx_ops(struct wlan_objmgr_vdev *vdev)
1321 {
1322 	struct ol_txrx_ops txrx_ops;
1323 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1324 	struct wlan_dp_intf *dp_intf;
1325 	struct wlan_dp_link *dp_link;
1326 
1327 	dp_link = dp_get_vdev_priv_obj(vdev);
1328 	if (unlikely(!dp_link)) {
1329 		dp_err("DP link not found");
1330 		return QDF_STATUS_E_INVAL;
1331 	}
1332 
1333 	dp_intf = dp_link->dp_intf;
1334 	qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1335 	txrx_ops.rx.rx = dp_mon_rx_packet_cbk;
1336 	dp_monitor_set_rx_monitor_cb(&txrx_ops, dp_rx_monitor_callback);
1337 	txrx_ops.vdev_del_notify = wlan_dp_link_cdp_vdev_delete_notification;
1338 	cdp_vdev_register(soc, dp_link->link_id,
1339 			  (ol_osif_vdev_handle)dp_link,
1340 			  &txrx_ops);
1341 
1342 	dp_link->cdp_vdev_registered = 1;
1343 	dp_link->cdp_vdev_deleted = 0;
1344 	dp_link->destroyed = 0;
1345 	dp_intf->txrx_ops = txrx_ops;
1346 
1347 	return QDF_STATUS_SUCCESS;
1348 }
1349 #endif
1350 
ucfg_dp_softap_register_txrx_ops(struct wlan_objmgr_vdev * vdev,struct ol_txrx_ops * txrx_ops)1351 QDF_STATUS ucfg_dp_softap_register_txrx_ops(struct wlan_objmgr_vdev *vdev,
1352 					    struct ol_txrx_ops *txrx_ops)
1353 {
1354 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1355 	struct wlan_dp_intf *dp_intf;
1356 	struct wlan_dp_link *dp_link;
1357 
1358 	dp_link = dp_get_vdev_priv_obj(vdev);
1359 	if (unlikely(!dp_link)) {
1360 		dp_err("DP link not found");
1361 		return QDF_STATUS_E_INVAL;
1362 	}
1363 
1364 	dp_intf = dp_link->dp_intf;
1365 
1366 	/* Register the vdev transmit and receive functions */
1367 	txrx_ops->tx.tx_comp = dp_softap_notify_tx_compl_cbk;
1368 
1369 	if (dp_intf->dp_ctx->enable_dp_rx_threads) {
1370 		txrx_ops->rx.rx = dp_rx_pkt_thread_enqueue_cbk;
1371 		txrx_ops->rx.rx_stack = dp_softap_rx_packet_cbk;
1372 		txrx_ops->rx.rx_flush = dp_rx_flush_packet_cbk;
1373 		txrx_ops->rx.rx_gro_flush = dp_rx_thread_gro_flush_ind_cbk;
1374 	} else {
1375 		txrx_ops->rx.rx = dp_softap_rx_packet_cbk;
1376 		txrx_ops->rx.rx_stack = NULL;
1377 		txrx_ops->rx.rx_flush = NULL;
1378 	}
1379 
1380 	txrx_ops->get_tsf_time = wlan_dp_get_tsf_time;
1381 	txrx_ops->vdev_del_notify = wlan_dp_link_cdp_vdev_delete_notification;
1382 	cdp_vdev_register(soc,
1383 			  dp_link->link_id,
1384 			  (ol_osif_vdev_handle)dp_link,
1385 			  txrx_ops);
1386 	if (!txrx_ops->tx.tx) {
1387 		dp_err("vdev register fail");
1388 		return QDF_STATUS_E_FAILURE;
1389 	}
1390 
1391 	dp_link->cdp_vdev_registered = 1;
1392 	dp_link->cdp_vdev_deleted = 0;
1393 	dp_link->destroyed = 0;
1394 	dp_intf->txrx_ops = *txrx_ops;
1395 	dp_intf->sap_tx_block_mask &= ~DP_TX_FN_CLR;
1396 
1397 	return QDF_STATUS_SUCCESS;
1398 }
1399 
ucfg_dp_register_pkt_capture_callbacks(struct wlan_objmgr_vdev * vdev)1400 QDF_STATUS ucfg_dp_register_pkt_capture_callbacks(struct wlan_objmgr_vdev *vdev)
1401 {
1402 	struct wlan_dp_intf *dp_intf;
1403 	struct wlan_dp_link *dp_link;
1404 
1405 	dp_link = dp_get_vdev_priv_obj(vdev);
1406 	if (unlikely(!dp_link)) {
1407 		dp_err("DP link not found");
1408 		return QDF_STATUS_E_INVAL;
1409 	}
1410 
1411 	dp_intf = dp_link->dp_intf;
1412 	return wlan_pkt_capture_register_callbacks(vdev,
1413 						   dp_mon_rx_packet_cbk,
1414 						   dp_intf);
1415 }
1416 
ucfg_dp_start_xmit(qdf_nbuf_t nbuf,struct wlan_objmgr_vdev * vdev)1417 QDF_STATUS ucfg_dp_start_xmit(qdf_nbuf_t nbuf, struct wlan_objmgr_vdev *vdev)
1418 {
1419 	struct wlan_dp_intf *dp_intf;
1420 	struct wlan_dp_link *dp_link, *tx_dp_link;
1421 	QDF_STATUS status;
1422 
1423 	dp_link = dp_get_vdev_priv_obj(vdev);
1424 	if (unlikely(!dp_link)) {
1425 		dp_err_rl("DP link not found");
1426 		return QDF_STATUS_E_INVAL;
1427 	}
1428 
1429 	dp_intf = dp_link->dp_intf;
1430 
1431 	/*
1432 	 * UMAC may queue TX on any vdev of the interface, but it may not be
1433 	 * in sync with the def_link for DP, hence ignore the vdev from
1434 	 * UMAC and select the tx_dp_link in DP.
1435 	 *
1436 	 * Since one link is already present in the dp_intf and validated above,
1437 	 * the def_link is not expected to be NULL. Hence there is no need
1438 	 * to validate tx_dp_link again.
1439 	 */
1440 	tx_dp_link = dp_intf->def_link;
1441 	qdf_atomic_inc(&dp_intf->num_active_task);
1442 	status = dp_start_xmit(tx_dp_link, nbuf);
1443 	qdf_atomic_dec(&dp_intf->num_active_task);
1444 
1445 	return status;
1446 }
1447 
ucfg_dp_rx_packet_cbk(struct wlan_objmgr_vdev * vdev,qdf_nbuf_t nbuf)1448 QDF_STATUS ucfg_dp_rx_packet_cbk(struct wlan_objmgr_vdev *vdev, qdf_nbuf_t nbuf)
1449 {
1450 	struct wlan_dp_intf *dp_intf;
1451 	struct wlan_dp_link *dp_link;
1452 
1453 	dp_link = dp_get_vdev_priv_obj(vdev);
1454 	if (unlikely(!dp_link)) {
1455 		dp_err_rl("DP link not found");
1456 		return QDF_STATUS_E_INVAL;
1457 	}
1458 
1459 	dp_intf = dp_link->dp_intf;
1460 	return dp_rx_packet_cbk(dp_link, nbuf);
1461 }
1462 
ucfg_dp_tx_timeout(struct wlan_objmgr_vdev * vdev)1463 void ucfg_dp_tx_timeout(struct wlan_objmgr_vdev *vdev)
1464 {
1465 	struct wlan_dp_intf *dp_intf;
1466 	struct wlan_dp_link *dp_link;
1467 
1468 	dp_link = dp_get_vdev_priv_obj(vdev);
1469 	if (unlikely(!dp_link)) {
1470 		dp_err_rl("DP link not found");
1471 		return;
1472 	}
1473 
1474 	dp_intf = dp_link->dp_intf;
1475 	dp_tx_timeout(dp_intf);
1476 }
1477 
1478 QDF_STATUS
ucfg_dp_softap_start_xmit(qdf_nbuf_t nbuf,struct wlan_objmgr_vdev * vdev)1479 ucfg_dp_softap_start_xmit(qdf_nbuf_t nbuf, struct wlan_objmgr_vdev *vdev)
1480 {
1481 	struct wlan_dp_intf *dp_intf;
1482 	struct wlan_dp_link *dp_link;
1483 	QDF_STATUS status;
1484 
1485 	dp_link = dp_get_vdev_priv_obj(vdev);
1486 	if (unlikely(!dp_link)) {
1487 		dp_err_rl("DP link not found");
1488 		return QDF_STATUS_E_INVAL;
1489 	}
1490 
1491 	dp_intf = dp_link->dp_intf;
1492 	qdf_atomic_inc(&dp_intf->num_active_task);
1493 	status = dp_softap_start_xmit(nbuf, dp_link);
1494 	qdf_atomic_dec(&dp_intf->num_active_task);
1495 
1496 	return status;
1497 }
1498 
ucfg_dp_softap_tx_timeout(struct wlan_objmgr_vdev * vdev)1499 void ucfg_dp_softap_tx_timeout(struct wlan_objmgr_vdev *vdev)
1500 {
1501 	struct wlan_dp_intf *dp_intf;
1502 	struct wlan_dp_link *dp_link;
1503 
1504 	dp_link = dp_get_vdev_priv_obj(vdev);
1505 	if (unlikely(!dp_link)) {
1506 		dp_err_rl("DP link not found");
1507 		return;
1508 	}
1509 
1510 	dp_intf = dp_link->dp_intf;
1511 	dp_softap_tx_timeout(dp_intf);
1512 }
1513 
ucfg_dp_get_dev_stats(qdf_netdev_t dev)1514 qdf_net_dev_stats *ucfg_dp_get_dev_stats(qdf_netdev_t dev)
1515 {
1516 	struct wlan_dp_intf *dp_intf;
1517 	struct wlan_dp_psoc_context *dp_ctx;
1518 
1519 	dp_ctx =  dp_get_context();
1520 
1521 	dp_intf = dp_get_intf_by_netdev(dp_ctx, dev);
1522 	if (!dp_intf) {
1523 		dp_err("DP interface not found dev: %s",
1524 		       qdf_netdev_get_devname(dev));
1525 		QDF_BUG(0);
1526 		return NULL;
1527 	}
1528 
1529 	return &dp_intf->stats;
1530 }
1531 
ucfg_dp_inc_rx_pkt_stats(struct wlan_objmgr_vdev * vdev,uint32_t pkt_len,bool delivered)1532 void ucfg_dp_inc_rx_pkt_stats(struct wlan_objmgr_vdev *vdev,
1533 			      uint32_t pkt_len,
1534 			      bool delivered)
1535 {
1536 	struct wlan_dp_intf *dp_intf;
1537 	struct wlan_dp_link *dp_link;
1538 	struct dp_tx_rx_stats *stats;
1539 	unsigned int cpu_index;
1540 
1541 	dp_link = dp_get_vdev_priv_obj(vdev);
1542 	if (unlikely(!dp_link)) {
1543 		dp_err_rl("DP link not found");
1544 		return;
1545 	}
1546 
1547 	dp_intf = dp_link->dp_intf;
1548 	cpu_index = qdf_get_cpu();
1549 	stats = &dp_intf->dp_stats.tx_rx_stats;
1550 
1551 	++stats->per_cpu[cpu_index].rx_packets;
1552 	qdf_net_stats_add_rx_pkts(&dp_intf->stats, 1);
1553 	qdf_net_stats_add_rx_bytes(&dp_intf->stats, pkt_len);
1554 
1555 	if (delivered)
1556 		++stats->per_cpu[cpu_index].rx_delivered;
1557 	else
1558 		++stats->per_cpu[cpu_index].rx_refused;
1559 }
1560 
ucfg_dp_register_rx_mic_error_ind_handler(void * soc)1561 void ucfg_dp_register_rx_mic_error_ind_handler(void *soc)
1562 {
1563 	cdp_register_rx_mic_error_ind_handler(soc, dp_rx_mic_error_ind);
1564 }
1565 
1566 #ifdef WLAN_NUD_TRACKING
1567 bool
ucfg_dp_is_roam_after_nud_enabled(struct wlan_objmgr_psoc * psoc)1568 ucfg_dp_is_roam_after_nud_enabled(struct wlan_objmgr_psoc *psoc)
1569 {
1570 	struct wlan_dp_psoc_context *dp_ctx;
1571 	struct wlan_dp_psoc_cfg *dp_cfg;
1572 
1573 	dp_ctx = dp_psoc_get_priv(psoc);
1574 	if (!dp_ctx) {
1575 		dp_err("Unable to get DP context");
1576 		return false;
1577 	}
1578 
1579 	dp_cfg = &dp_ctx->dp_cfg;
1580 	if (!dp_cfg) {
1581 		dp_err("Unable to get DP config");
1582 		return false;
1583 	}
1584 
1585 	if (dp_cfg->enable_nud_tracking == DP_ROAM_AFTER_NUD_FAIL ||
1586 	    dp_cfg->enable_nud_tracking == DP_DISCONNECT_AFTER_ROAM_FAIL)
1587 		return true;
1588 
1589 	return false;
1590 }
1591 
1592 bool
ucfg_dp_is_disconect_after_roam_fail(struct wlan_objmgr_psoc * psoc)1593 ucfg_dp_is_disconect_after_roam_fail(struct wlan_objmgr_psoc *psoc)
1594 {
1595 	struct wlan_dp_psoc_context *dp_ctx;
1596 	struct wlan_dp_psoc_cfg *dp_cfg;
1597 
1598 	dp_ctx = dp_psoc_get_priv(psoc);
1599 	if (!dp_ctx) {
1600 		dp_err("Unable to get DP context");
1601 		return false;
1602 	}
1603 
1604 	dp_cfg = &dp_ctx->dp_cfg;
1605 	if (!dp_cfg) {
1606 		dp_err("Unable to get DP config");
1607 		return false;
1608 	}
1609 
1610 	if (dp_cfg->enable_nud_tracking == DP_DISCONNECT_AFTER_ROAM_FAIL)
1611 		return true;
1612 
1613 	return false;
1614 }
1615 #endif
1616 
ucfg_dp_bbm_context_init(struct wlan_objmgr_psoc * psoc)1617 int ucfg_dp_bbm_context_init(struct wlan_objmgr_psoc *psoc)
1618 {
1619 	return dp_bbm_context_init(psoc);
1620 }
1621 
ucfg_dp_bbm_context_deinit(struct wlan_objmgr_psoc * psoc)1622 void ucfg_dp_bbm_context_deinit(struct wlan_objmgr_psoc *psoc)
1623 {
1624 	dp_bbm_context_deinit(psoc);
1625 }
1626 
ucfg_dp_bbm_apply_independent_policy(struct wlan_objmgr_psoc * psoc,struct bbm_params * params)1627 void ucfg_dp_bbm_apply_independent_policy(struct wlan_objmgr_psoc *psoc,
1628 					  struct bbm_params *params)
1629 {
1630 	dp_bbm_apply_independent_policy(psoc, params);
1631 }
1632 
ucfg_dp_set_rx_mode_rps(bool enable)1633 void ucfg_dp_set_rx_mode_rps(bool enable)
1634 {
1635 	dp_set_rx_mode_rps(enable);
1636 }
1637 
ucfg_dp_periodic_sta_stats_start(struct wlan_objmgr_vdev * vdev)1638 void ucfg_dp_periodic_sta_stats_start(struct wlan_objmgr_vdev *vdev)
1639 {
1640 	dp_periodic_sta_stats_start(vdev);
1641 }
1642 
ucfg_dp_periodic_sta_stats_stop(struct wlan_objmgr_vdev * vdev)1643 void ucfg_dp_periodic_sta_stats_stop(struct wlan_objmgr_vdev *vdev)
1644 {
1645 	dp_periodic_sta_stats_stop(vdev);
1646 }
1647 
ucfg_dp_try_send_rps_ind(struct wlan_objmgr_vdev * vdev)1648 void ucfg_dp_try_send_rps_ind(struct wlan_objmgr_vdev *vdev)
1649 {
1650 	dp_try_send_rps_ind(vdev);
1651 }
1652 
ucfg_dp_reg_ipa_rsp_ind(struct wlan_objmgr_pdev * pdev)1653 void ucfg_dp_reg_ipa_rsp_ind(struct wlan_objmgr_pdev *pdev)
1654 {
1655 	ucfg_ipa_reg_rps_enable_cb(pdev, dp_set_rps);
1656 }
1657 
ucfg_dp_try_set_rps_cpu_mask(struct wlan_objmgr_psoc * psoc)1658 void ucfg_dp_try_set_rps_cpu_mask(struct wlan_objmgr_psoc *psoc)
1659 {
1660 	dp_try_set_rps_cpu_mask(psoc);
1661 }
1662 
ucfg_dp_add_latency_critical_client(struct wlan_objmgr_vdev * vdev,enum qca_wlan_802_11_mode phymode)1663 void ucfg_dp_add_latency_critical_client(struct wlan_objmgr_vdev *vdev,
1664 					 enum qca_wlan_802_11_mode phymode)
1665 {
1666 	dp_add_latency_critical_client(vdev, phymode);
1667 }
1668 
ucfg_dp_del_latency_critical_client(struct wlan_objmgr_vdev * vdev,enum qca_wlan_802_11_mode phymode)1669 void ucfg_dp_del_latency_critical_client(struct wlan_objmgr_vdev *vdev,
1670 					 enum qca_wlan_802_11_mode phymode)
1671 {
1672 	dp_del_latency_critical_client(vdev, phymode);
1673 }
1674 
ucfg_dp_reset_tcp_delack(struct wlan_objmgr_psoc * psoc)1675 void ucfg_dp_reset_tcp_delack(struct wlan_objmgr_psoc *psoc)
1676 {
1677 	dp_reset_tcp_delack(psoc);
1678 }
1679 
1680 void
ucfg_dp_set_current_throughput_level(struct wlan_objmgr_psoc * psoc,enum pld_bus_width_type next_vote_level)1681 ucfg_dp_set_current_throughput_level(struct wlan_objmgr_psoc *psoc,
1682 				     enum pld_bus_width_type next_vote_level)
1683 {
1684 	dp_set_current_throughput_level(psoc, next_vote_level);
1685 }
1686 
1687 void
ucfg_dp_set_high_bus_bw_request(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,bool high_bus_bw)1688 ucfg_dp_set_high_bus_bw_request(struct wlan_objmgr_psoc *psoc,
1689 				uint8_t vdev_id,
1690 				bool high_bus_bw)
1691 {
1692 	dp_set_high_bus_bw_request(psoc, vdev_id, high_bus_bw);
1693 }
1694 
ucfg_wlan_dp_display_tx_rx_histogram(struct wlan_objmgr_psoc * psoc)1695 void ucfg_wlan_dp_display_tx_rx_histogram(struct wlan_objmgr_psoc *psoc)
1696 {
1697 	wlan_dp_display_tx_rx_histogram(psoc);
1698 }
1699 
ucfg_wlan_dp_clear_tx_rx_histogram(struct wlan_objmgr_psoc * psoc)1700 void ucfg_wlan_dp_clear_tx_rx_histogram(struct wlan_objmgr_psoc *psoc)
1701 {
1702 	wlan_dp_clear_tx_rx_histogram(psoc);
1703 }
1704 
ucfg_dp_bus_bw_compute_timer_start(struct wlan_objmgr_psoc * psoc)1705 void ucfg_dp_bus_bw_compute_timer_start(struct wlan_objmgr_psoc *psoc)
1706 {
1707 	dp_bus_bw_compute_timer_start(psoc);
1708 }
1709 
ucfg_dp_bus_bw_compute_timer_try_start(struct wlan_objmgr_psoc * psoc)1710 void ucfg_dp_bus_bw_compute_timer_try_start(struct wlan_objmgr_psoc *psoc)
1711 {
1712 	dp_bus_bw_compute_timer_try_start(psoc);
1713 }
1714 
ucfg_dp_bus_bw_compute_timer_stop(struct wlan_objmgr_psoc * psoc)1715 void ucfg_dp_bus_bw_compute_timer_stop(struct wlan_objmgr_psoc *psoc)
1716 {
1717 	dp_bus_bw_compute_timer_stop(psoc);
1718 }
1719 
ucfg_dp_bus_bw_compute_timer_try_stop(struct wlan_objmgr_psoc * psoc)1720 void ucfg_dp_bus_bw_compute_timer_try_stop(struct wlan_objmgr_psoc *psoc)
1721 {
1722 	dp_bus_bw_compute_timer_try_stop(psoc);
1723 }
1724 
ucfg_dp_bus_bw_compute_prev_txrx_stats(struct wlan_objmgr_vdev * vdev)1725 void ucfg_dp_bus_bw_compute_prev_txrx_stats(struct wlan_objmgr_vdev *vdev)
1726 {
1727 	dp_bus_bw_compute_prev_txrx_stats(vdev);
1728 }
1729 
1730 void
ucfg_dp_bus_bw_compute_reset_prev_txrx_stats(struct wlan_objmgr_vdev * vdev)1731 ucfg_dp_bus_bw_compute_reset_prev_txrx_stats(struct wlan_objmgr_vdev *vdev)
1732 {
1733 	dp_bus_bw_compute_reset_prev_txrx_stats(vdev);
1734 }
1735 
ucfg_dp_nud_set_gateway_addr(struct wlan_objmgr_vdev * vdev,struct qdf_mac_addr gw_mac_addr)1736 void ucfg_dp_nud_set_gateway_addr(struct wlan_objmgr_vdev *vdev,
1737 				  struct qdf_mac_addr gw_mac_addr)
1738 {
1739 	dp_nud_set_gateway_addr(vdev, gw_mac_addr);
1740 }
1741 
ucfg_dp_nud_event(struct qdf_mac_addr * netdev_mac_addr,struct qdf_mac_addr * gw_mac_addr,uint8_t nud_state)1742 void ucfg_dp_nud_event(struct qdf_mac_addr *netdev_mac_addr,
1743 		       struct qdf_mac_addr *gw_mac_addr,
1744 		       uint8_t nud_state)
1745 {
1746 	dp_nud_netevent_cb(netdev_mac_addr, gw_mac_addr, nud_state);
1747 }
1748 
ucfg_dp_get_arp_stats_event_handler(struct wlan_objmgr_psoc * psoc,struct dp_rsp_stats * rsp)1749 QDF_STATUS ucfg_dp_get_arp_stats_event_handler(struct wlan_objmgr_psoc *psoc,
1750 					       struct dp_rsp_stats *rsp)
1751 {
1752 	return dp_get_arp_stats_event_handler(psoc, rsp);
1753 }
1754 
ucfg_dp_get_arp_request_ctx(struct wlan_objmgr_psoc * psoc)1755 void *ucfg_dp_get_arp_request_ctx(struct wlan_objmgr_psoc *psoc)
1756 {
1757 	return dp_get_arp_request_ctx(psoc);
1758 }
1759 
ucfg_dp_nud_reset_tracking(struct wlan_objmgr_vdev * vdev)1760 void ucfg_dp_nud_reset_tracking(struct wlan_objmgr_vdev *vdev)
1761 {
1762 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1763 	struct wlan_dp_intf *dp_intf;
1764 
1765 	if (!dp_link) {
1766 		dp_err("Unable to get DP link");
1767 		return;
1768 	}
1769 
1770 	dp_intf = dp_link->dp_intf;
1771 	dp_nud_reset_tracking(dp_intf);
1772 }
1773 
ucfg_dp_nud_tracking_enabled(struct wlan_objmgr_psoc * psoc)1774 uint8_t ucfg_dp_nud_tracking_enabled(struct wlan_objmgr_psoc *psoc)
1775 {
1776 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
1777 
1778 	if (!dp_ctx) {
1779 		dp_err("DP Context is NULL");
1780 		return 0;
1781 	}
1782 	return dp_ctx->dp_cfg.enable_nud_tracking;
1783 }
1784 
ucfg_dp_nud_indicate_roam(struct wlan_objmgr_vdev * vdev)1785 void ucfg_dp_nud_indicate_roam(struct wlan_objmgr_vdev *vdev)
1786 {
1787 	dp_nud_indicate_roam(vdev);
1788 }
1789 
ucfg_dp_clear_arp_stats(struct wlan_objmgr_vdev * vdev)1790 void ucfg_dp_clear_arp_stats(struct wlan_objmgr_vdev *vdev)
1791 {
1792 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1793 	struct wlan_dp_intf *dp_intf;
1794 
1795 	if (!dp_link) {
1796 		dp_err("Unable to get DP link");
1797 		return;
1798 	}
1799 
1800 	dp_intf = dp_link->dp_intf;
1801 	qdf_mem_zero(&dp_intf->dp_stats.arp_stats,
1802 		     sizeof(dp_intf->dp_stats.arp_stats));
1803 }
1804 
ucfg_dp_clear_dns_stats(struct wlan_objmgr_vdev * vdev)1805 void ucfg_dp_clear_dns_stats(struct wlan_objmgr_vdev *vdev)
1806 {
1807 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1808 	struct wlan_dp_intf *dp_intf;
1809 
1810 	if (!dp_link) {
1811 		dp_err("Unable to get DP link");
1812 		return;
1813 	}
1814 
1815 	dp_intf = dp_link->dp_intf;
1816 	qdf_mem_zero(&dp_intf->dp_stats.dns_stats,
1817 		     sizeof(dp_intf->dp_stats.dns_stats));
1818 }
1819 
ucfg_dp_clear_tcp_stats(struct wlan_objmgr_vdev * vdev)1820 void ucfg_dp_clear_tcp_stats(struct wlan_objmgr_vdev *vdev)
1821 {
1822 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1823 	struct wlan_dp_intf *dp_intf;
1824 
1825 	if (!dp_link) {
1826 		dp_err("Unable to get DP link");
1827 		return;
1828 	}
1829 
1830 	dp_intf = dp_link->dp_intf;
1831 	qdf_mem_zero(&dp_intf->dp_stats.tcp_stats,
1832 		     sizeof(dp_intf->dp_stats.tcp_stats));
1833 }
1834 
ucfg_dp_clear_icmpv4_stats(struct wlan_objmgr_vdev * vdev)1835 void ucfg_dp_clear_icmpv4_stats(struct wlan_objmgr_vdev *vdev)
1836 {
1837 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1838 	struct wlan_dp_intf *dp_intf;
1839 
1840 	if (!dp_link) {
1841 		dp_err("Unable to get DP link");
1842 		return;
1843 	}
1844 
1845 	dp_intf = dp_link->dp_intf;
1846 	qdf_mem_zero(&dp_intf->dp_stats.icmpv4_stats,
1847 		     sizeof(dp_intf->dp_stats.icmpv4_stats));
1848 }
1849 
ucfg_dp_clear_dns_payload_value(struct wlan_objmgr_vdev * vdev)1850 void ucfg_dp_clear_dns_payload_value(struct wlan_objmgr_vdev *vdev)
1851 {
1852 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1853 	struct wlan_dp_intf *dp_intf;
1854 
1855 	if (!dp_link) {
1856 		dp_err("Unable to get DP link");
1857 		return;
1858 	}
1859 
1860 	dp_intf = dp_link->dp_intf;
1861 	qdf_mem_zero(dp_intf->dns_payload, dp_intf->track_dns_domain_len);
1862 }
1863 
ucfg_dp_set_pkt_type_bitmap_value(struct wlan_objmgr_vdev * vdev,uint32_t value)1864 void ucfg_dp_set_pkt_type_bitmap_value(struct wlan_objmgr_vdev *vdev,
1865 				       uint32_t value)
1866 {
1867 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1868 	struct wlan_dp_intf *dp_intf;
1869 
1870 	if (!dp_link) {
1871 		dp_err("Unable to get DP link");
1872 		return;
1873 	}
1874 
1875 	dp_intf = dp_link->dp_intf;
1876 	dp_intf->pkt_type_bitmap = value;
1877 }
1878 
ucfg_dp_intf_get_pkt_type_bitmap_value(void * intf_ctx)1879 uint32_t ucfg_dp_intf_get_pkt_type_bitmap_value(void *intf_ctx)
1880 {
1881 	struct wlan_dp_intf *dp_intf = (struct wlan_dp_intf *)intf_ctx;
1882 
1883 	if (!dp_intf) {
1884 		dp_err("Unable to get DP link");
1885 		return 0;
1886 	}
1887 
1888 	return dp_intf->pkt_type_bitmap;
1889 }
1890 
ucfg_dp_set_track_dest_ipv4_value(struct wlan_objmgr_vdev * vdev,uint32_t value)1891 void ucfg_dp_set_track_dest_ipv4_value(struct wlan_objmgr_vdev *vdev,
1892 				       uint32_t value)
1893 {
1894 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1895 	struct wlan_dp_intf *dp_intf;
1896 
1897 	if (!dp_link) {
1898 		dp_err("Unable to get DP link");
1899 		return;
1900 	}
1901 
1902 	dp_intf = dp_link->dp_intf;
1903 	dp_intf->track_dest_ipv4 = value;
1904 }
1905 
ucfg_dp_set_track_dest_port_value(struct wlan_objmgr_vdev * vdev,uint32_t value)1906 void ucfg_dp_set_track_dest_port_value(struct wlan_objmgr_vdev *vdev,
1907 				       uint32_t value)
1908 {
1909 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1910 	struct wlan_dp_intf *dp_intf;
1911 
1912 	if (!dp_link) {
1913 		dp_err("Unable to get DP link");
1914 		return;
1915 	}
1916 
1917 	dp_intf = dp_link->dp_intf;
1918 	dp_intf->track_dest_port = value;
1919 }
1920 
ucfg_dp_set_track_src_port_value(struct wlan_objmgr_vdev * vdev,uint32_t value)1921 void ucfg_dp_set_track_src_port_value(struct wlan_objmgr_vdev *vdev,
1922 				      uint32_t value)
1923 {
1924 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1925 	struct wlan_dp_intf *dp_intf;
1926 
1927 	if (!dp_link) {
1928 		dp_err("Unable to get DP link");
1929 		return;
1930 	}
1931 
1932 	dp_intf = dp_link->dp_intf;
1933 	dp_intf->track_src_port = value;
1934 }
1935 
ucfg_dp_set_track_dns_domain_len_value(struct wlan_objmgr_vdev * vdev,uint32_t value)1936 void ucfg_dp_set_track_dns_domain_len_value(struct wlan_objmgr_vdev *vdev,
1937 					    uint32_t value)
1938 {
1939 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1940 	struct wlan_dp_intf *dp_intf;
1941 
1942 	if (!dp_link) {
1943 		dp_err("Unable to get DP link");
1944 		return;
1945 	}
1946 
1947 	dp_intf = dp_link->dp_intf;
1948 	dp_intf->track_dns_domain_len = value;
1949 }
1950 
ucfg_dp_set_track_arp_ip_value(struct wlan_objmgr_vdev * vdev,uint32_t value)1951 void ucfg_dp_set_track_arp_ip_value(struct wlan_objmgr_vdev *vdev,
1952 				    uint32_t value)
1953 {
1954 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1955 	struct wlan_dp_intf *dp_intf;
1956 
1957 	if (!dp_link) {
1958 		dp_err("Unable to get DP link");
1959 		return;
1960 	}
1961 
1962 	dp_intf = dp_link->dp_intf;
1963 	dp_intf->track_arp_ip = value;
1964 }
1965 
ucfg_dp_get_pkt_type_bitmap_value(struct wlan_objmgr_vdev * vdev)1966 uint32_t ucfg_dp_get_pkt_type_bitmap_value(struct wlan_objmgr_vdev *vdev)
1967 {
1968 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1969 	struct wlan_dp_intf *dp_intf;
1970 
1971 	if (!dp_link) {
1972 		dp_err("Unable to get DP link");
1973 		return 0;
1974 	}
1975 
1976 	dp_intf = dp_link->dp_intf;
1977 	return dp_intf->pkt_type_bitmap;
1978 }
1979 
ucfg_dp_get_dns_payload_value(struct wlan_objmgr_vdev * vdev,uint8_t * dns_query)1980 void ucfg_dp_get_dns_payload_value(struct wlan_objmgr_vdev *vdev,
1981 				   uint8_t *dns_query)
1982 {
1983 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1984 	struct wlan_dp_intf *dp_intf;
1985 
1986 	if (!dp_link) {
1987 		dp_err("Unable to get DP link");
1988 		return;
1989 	}
1990 
1991 	dp_intf = dp_link->dp_intf;
1992 	qdf_mem_copy(dns_query, dp_intf->dns_payload,
1993 		     dp_intf->track_dns_domain_len);
1994 }
1995 
ucfg_dp_get_track_dns_domain_len_value(struct wlan_objmgr_vdev * vdev)1996 uint32_t ucfg_dp_get_track_dns_domain_len_value(struct wlan_objmgr_vdev *vdev)
1997 {
1998 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
1999 	struct wlan_dp_intf *dp_intf;
2000 
2001 	if (!dp_link) {
2002 		dp_err("Unable to get DP link");
2003 		return 0;
2004 	}
2005 
2006 	dp_intf = dp_link->dp_intf;
2007 	return dp_intf->track_dns_domain_len;
2008 }
2009 
ucfg_dp_get_track_dest_port_value(struct wlan_objmgr_vdev * vdev)2010 uint32_t ucfg_dp_get_track_dest_port_value(struct wlan_objmgr_vdev *vdev)
2011 {
2012 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2013 	struct wlan_dp_intf *dp_intf;
2014 
2015 	if (!dp_link) {
2016 		dp_err("Unable to get DP link");
2017 		return 0;
2018 	}
2019 
2020 	dp_intf = dp_link->dp_intf;
2021 	return dp_intf->track_dest_port;
2022 }
2023 
ucfg_dp_get_track_src_port_value(struct wlan_objmgr_vdev * vdev)2024 uint32_t ucfg_dp_get_track_src_port_value(struct wlan_objmgr_vdev *vdev)
2025 {
2026 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2027 	struct wlan_dp_intf *dp_intf;
2028 
2029 	if (!dp_link) {
2030 		dp_err("Unable to get DP link");
2031 		return 0;
2032 	}
2033 
2034 	dp_intf = dp_link->dp_intf;
2035 	return dp_intf->track_src_port;
2036 }
2037 
ucfg_dp_get_track_dest_ipv4_value(struct wlan_objmgr_vdev * vdev)2038 uint32_t ucfg_dp_get_track_dest_ipv4_value(struct wlan_objmgr_vdev *vdev)
2039 {
2040 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2041 	struct wlan_dp_intf *dp_intf;
2042 
2043 	if (!dp_link) {
2044 		dp_err("Unable to get DP link");
2045 		return 0;
2046 	}
2047 
2048 	dp_intf = dp_link->dp_intf;
2049 	return dp_intf->track_dest_ipv4;
2050 }
2051 
ucfg_dp_get_dad_value(struct wlan_objmgr_vdev * vdev)2052 bool ucfg_dp_get_dad_value(struct wlan_objmgr_vdev *vdev)
2053 {
2054 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2055 	struct wlan_dp_intf *dp_intf;
2056 
2057 	if (!dp_link) {
2058 		dp_err("Unable to get DP link");
2059 		return 0;
2060 	}
2061 
2062 	dp_intf = dp_link->dp_intf;
2063 	return dp_intf->dad;
2064 }
2065 
ucfg_dp_get_con_status_value(struct wlan_objmgr_vdev * vdev)2066 bool ucfg_dp_get_con_status_value(struct wlan_objmgr_vdev *vdev)
2067 {
2068 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2069 	struct wlan_dp_intf *dp_intf;
2070 
2071 	if (!dp_link) {
2072 		dp_err("Unable to get DP link");
2073 		return 0;
2074 	}
2075 
2076 	dp_intf = dp_link->dp_intf;
2077 	return dp_intf->con_status;
2078 }
2079 
ucfg_dp_get_link_id(struct wlan_objmgr_vdev * vdev)2080 uint8_t ucfg_dp_get_link_id(struct wlan_objmgr_vdev *vdev)
2081 {
2082 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2083 
2084 	if (!dp_link) {
2085 		dp_err("Unable to get DP link");
2086 		return 0;
2087 	}
2088 
2089 	return dp_link->link_id;
2090 }
2091 
ucfg_dp_get_arp_stats(struct wlan_objmgr_vdev * vdev)2092 struct dp_arp_stats *ucfg_dp_get_arp_stats(struct wlan_objmgr_vdev *vdev)
2093 {
2094 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2095 	struct wlan_dp_intf *dp_intf;
2096 
2097 	if (!dp_link) {
2098 		dp_err("Unable to get DP link");
2099 		return NULL;
2100 	}
2101 
2102 	dp_intf = dp_link->dp_intf;
2103 	return &dp_intf->dp_stats.arp_stats;
2104 }
2105 
ucfg_dp_get_icmpv4_stats(struct wlan_objmgr_vdev * vdev)2106 struct dp_icmpv4_stats *ucfg_dp_get_icmpv4_stats(struct wlan_objmgr_vdev *vdev)
2107 {
2108 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2109 	struct wlan_dp_intf *dp_intf;
2110 
2111 	if (!dp_link) {
2112 		dp_err("Unable to get DP link");
2113 		return NULL;
2114 	}
2115 
2116 	dp_intf = dp_link->dp_intf;
2117 	return &dp_intf->dp_stats.icmpv4_stats;
2118 }
2119 
ucfg_dp_get_tcp_stats(struct wlan_objmgr_vdev * vdev)2120 struct dp_tcp_stats *ucfg_dp_get_tcp_stats(struct wlan_objmgr_vdev *vdev)
2121 {
2122 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2123 	struct wlan_dp_intf *dp_intf;
2124 
2125 	if (!dp_link) {
2126 		dp_err("Unable to get DP link");
2127 		return NULL;
2128 	}
2129 
2130 	dp_intf = dp_link->dp_intf;
2131 	return &dp_intf->dp_stats.tcp_stats;
2132 }
2133 
ucfg_dp_get_dns_stats(struct wlan_objmgr_vdev * vdev)2134 struct dp_dns_stats *ucfg_dp_get_dns_stats(struct wlan_objmgr_vdev *vdev)
2135 {
2136 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2137 	struct wlan_dp_intf *dp_intf;
2138 
2139 	if (!dp_link) {
2140 		dp_err("Unable to get DP link");
2141 		return NULL;
2142 	}
2143 
2144 	dp_intf = dp_link->dp_intf;
2145 	return &dp_intf->dp_stats.dns_stats;
2146 }
2147 
ucfg_dp_set_nud_stats_cb(struct wlan_objmgr_psoc * psoc,void * cookie)2148 void ucfg_dp_set_nud_stats_cb(struct wlan_objmgr_psoc *psoc, void *cookie)
2149 {
2150 	struct wlan_dp_psoc_sb_ops *sb_ops = dp_intf_get_tx_ops(psoc);
2151 
2152 	if (!sb_ops) {
2153 		dp_err("Unable to get ops");
2154 		return;
2155 	}
2156 
2157 	sb_ops->dp_arp_stats_register_event_handler(psoc);
2158 	sb_ops->arp_request_ctx = cookie;
2159 }
2160 
ucfg_dp_clear_nud_stats_cb(struct wlan_objmgr_psoc * psoc)2161 void ucfg_dp_clear_nud_stats_cb(struct wlan_objmgr_psoc *psoc)
2162 {
2163 	struct wlan_dp_psoc_sb_ops *sb_ops = dp_intf_get_tx_ops(psoc);
2164 
2165 	if (!sb_ops) {
2166 		dp_err("Unable to get ops");
2167 		return;
2168 	}
2169 
2170 	sb_ops->dp_arp_stats_unregister_event_handler(psoc);
2171 }
2172 
ucfg_dp_set_dump_dp_trace(uint16_t cmd_type,uint16_t count)2173 void ucfg_dp_set_dump_dp_trace(uint16_t cmd_type, uint16_t count)
2174 {
2175 	dp_set_dump_dp_trace(cmd_type, count);
2176 }
2177 
ucfg_dp_get_current_throughput_level(struct wlan_objmgr_psoc * psoc)2178 int ucfg_dp_get_current_throughput_level(struct wlan_objmgr_psoc *psoc)
2179 {
2180 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2181 
2182 	if (!dp_ctx)
2183 		return 0;
2184 
2185 	return dp_get_current_throughput_level(dp_ctx);
2186 }
2187 
ucfg_dp_get_bus_bw_high_threshold(struct wlan_objmgr_psoc * psoc)2188 uint32_t ucfg_dp_get_bus_bw_high_threshold(struct wlan_objmgr_psoc *psoc)
2189 {
2190 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2191 
2192 	if (!dp_ctx)
2193 		return 0;
2194 
2195 	return dp_get_bus_bw_high_threshold(dp_ctx);
2196 }
2197 
2198 QDF_STATUS
ucfg_dp_req_get_arp_stats(struct wlan_objmgr_psoc * psoc,struct dp_get_arp_stats_params * params)2199 ucfg_dp_req_get_arp_stats(struct wlan_objmgr_psoc *psoc,
2200 			  struct dp_get_arp_stats_params *params)
2201 {
2202 	struct wlan_dp_psoc_sb_ops *sb_ops = dp_intf_get_tx_ops(psoc);
2203 
2204 	if (!sb_ops) {
2205 		dp_err("Unable to get ops");
2206 		return QDF_STATUS_E_INVAL;
2207 	}
2208 
2209 	return sb_ops->dp_get_arp_req_stats(psoc, params);
2210 }
2211 
2212 QDF_STATUS
ucfg_dp_req_set_arp_stats(struct wlan_objmgr_psoc * psoc,struct dp_set_arp_stats_params * params)2213 ucfg_dp_req_set_arp_stats(struct wlan_objmgr_psoc *psoc,
2214 			  struct dp_set_arp_stats_params *params)
2215 {
2216 	struct wlan_dp_psoc_sb_ops *sb_ops = dp_intf_get_tx_ops(psoc);
2217 
2218 	if (!sb_ops) {
2219 		dp_err("Unable to get ops");
2220 		return QDF_STATUS_E_INVAL;
2221 	}
2222 
2223 	return sb_ops->dp_set_arp_req_stats(psoc, params);
2224 }
2225 
ucfg_dp_register_hdd_callbacks(struct wlan_objmgr_psoc * psoc,struct wlan_dp_psoc_callbacks * cb_obj)2226 void ucfg_dp_register_hdd_callbacks(struct wlan_objmgr_psoc *psoc,
2227 				    struct wlan_dp_psoc_callbacks *cb_obj)
2228 {
2229 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2230 
2231 	if (!dp_ctx) {
2232 		dp_err("DP ctx is NULL");
2233 		return;
2234 	}
2235 	dp_ctx->dp_ops.callback_ctx = cb_obj->callback_ctx;
2236 	dp_ctx->dp_ops.wlan_dp_sta_get_dot11mode =
2237 		cb_obj->wlan_dp_sta_get_dot11mode;
2238 	dp_ctx->dp_ops.wlan_dp_get_ap_client_count =
2239 		cb_obj->wlan_dp_get_ap_client_count;
2240 	dp_ctx->dp_ops.wlan_dp_sta_ndi_connected =
2241 		cb_obj->wlan_dp_sta_ndi_connected;
2242 	dp_ctx->dp_ops.dp_any_adapter_connected =
2243 		cb_obj->dp_any_adapter_connected;
2244 	dp_ctx->dp_ops.dp_send_svc_nlink_msg = cb_obj->dp_send_svc_nlink_msg;
2245 	dp_ctx->dp_ops.dp_pm_qos_update_request =
2246 		cb_obj->dp_pm_qos_update_request;
2247 	dp_ctx->dp_ops.dp_pld_remove_pm_qos = cb_obj->dp_pld_remove_pm_qos;
2248 	dp_ctx->dp_ops.dp_pld_request_pm_qos = cb_obj->dp_pld_request_pm_qos;
2249 	dp_ctx->dp_ops.dp_pm_qos_add_request = cb_obj->dp_pm_qos_add_request;
2250 	dp_ctx->dp_ops.dp_pm_qos_remove_request =
2251 		cb_obj->dp_pm_qos_remove_request;
2252 	dp_ctx->dp_ops.wlan_dp_display_tx_multiq_stats =
2253 		cb_obj->wlan_dp_display_tx_multiq_stats;
2254 	dp_ctx->dp_ops.wlan_dp_display_netif_queue_history =
2255 		cb_obj->wlan_dp_display_netif_queue_history;
2256 	dp_ctx->dp_ops.dp_send_mscs_action_frame =
2257 		cb_obj->dp_send_mscs_action_frame;
2258 	dp_ctx->dp_ops.dp_pktlog_enable_disable =
2259 		cb_obj->dp_pktlog_enable_disable;
2260 	dp_ctx->dp_ops.dp_is_roaming_in_progress =
2261 		cb_obj->dp_is_roaming_in_progress;
2262 	dp_ctx->dp_ops.dp_is_ap_active = cb_obj->dp_is_ap_active;
2263 	dp_ctx->dp_ops.dp_disable_rx_ol_for_low_tput =
2264 		cb_obj->dp_disable_rx_ol_for_low_tput;
2265 	dp_ctx->dp_ops.dp_napi_apply_throughput_policy =
2266 		cb_obj->dp_napi_apply_throughput_policy;
2267 	dp_ctx->dp_ops.dp_is_link_adapter = cb_obj->dp_is_link_adapter;
2268 	dp_ctx->dp_ops.dp_get_pause_map = cb_obj->dp_get_pause_map;
2269 	dp_ctx->dp_ops.dp_nud_failure_work = cb_obj->dp_nud_failure_work;
2270 
2271 	dp_ctx->dp_ops.dp_get_tx_resource = cb_obj->dp_get_tx_resource;
2272 	dp_ctx->dp_ops.dp_get_tx_flow_low_watermark =
2273 		cb_obj->dp_get_tx_flow_low_watermark;
2274 	dp_ctx->dp_ops.dp_get_tsf_time = cb_obj->dp_get_tsf_time;
2275 	dp_ctx->dp_ops.dp_tsf_timestamp_rx = cb_obj->dp_tsf_timestamp_rx;
2276 	dp_ctx->dp_ops.dp_gro_rx_legacy_get_napi =
2277 		cb_obj->dp_gro_rx_legacy_get_napi;
2278 	dp_ctx->dp_ops.dp_get_netdev_by_vdev_mac =
2279 		cb_obj->dp_get_netdev_by_vdev_mac;
2280 
2281 	dp_ctx->dp_ops.dp_nbuf_push_pkt = cb_obj->dp_nbuf_push_pkt;
2282 	dp_ctx->dp_ops.dp_rx_napi_gro_flush = cb_obj->dp_rx_napi_gro_flush;
2283 	dp_ctx->dp_ops.dp_rx_thread_napi_gro_flush =
2284 	    cb_obj->dp_rx_thread_napi_gro_flush;
2285 	dp_ctx->dp_ops.dp_rx_napi_gro_receive = cb_obj->dp_rx_napi_gro_receive;
2286 	dp_ctx->dp_ops.dp_lro_rx_cb = cb_obj->dp_lro_rx_cb;
2287 	dp_ctx->dp_ops.dp_register_rx_offld_flush_cb =
2288 		cb_obj->dp_register_rx_offld_flush_cb;
2289 	dp_ctx->dp_ops.dp_rx_check_qdisc_configured =
2290 		cb_obj->dp_rx_check_qdisc_configured;
2291 	dp_ctx->dp_ops.dp_is_gratuitous_arp_unsolicited_na =
2292 		cb_obj->dp_is_gratuitous_arp_unsolicited_na;
2293 	dp_ctx->dp_ops.dp_send_rx_pkt_over_nl = cb_obj->dp_send_rx_pkt_over_nl;
2294 	dp_ctx->dp_ops.osif_dp_send_tcp_param_update_event =
2295 		cb_obj->osif_dp_send_tcp_param_update_event;
2296 	dp_ctx->dp_ops.os_if_dp_nud_stats_info =
2297 		cb_obj->os_if_dp_nud_stats_info;
2298 	dp_ctx->dp_ops.osif_dp_process_mic_error =
2299 		cb_obj->osif_dp_process_mic_error;
2300 	dp_ctx->dp_ops.link_monitoring_cb = cb_obj->link_monitoring_cb;
2301 	}
2302 
ucfg_dp_register_event_handler(struct wlan_objmgr_psoc * psoc,struct wlan_dp_psoc_nb_ops * cb_obj)2303 void ucfg_dp_register_event_handler(struct wlan_objmgr_psoc *psoc,
2304 				    struct wlan_dp_psoc_nb_ops *cb_obj)
2305 {
2306 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2307 
2308 	if (!dp_ctx) {
2309 		dp_err("DP ctx is NULL");
2310 		return;
2311 	}
2312 
2313 	dp_ctx->nb_ops.osif_dp_get_arp_stats_evt =
2314 		cb_obj->osif_dp_get_arp_stats_evt;
2315 }
2316 
ucfg_dp_get_bus_bw_compute_interval(struct wlan_objmgr_psoc * psoc)2317 uint32_t ucfg_dp_get_bus_bw_compute_interval(struct wlan_objmgr_psoc *psoc)
2318 {
2319 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2320 
2321 	if (!dp_ctx) {
2322 		dp_err("DP ctx is NULL");
2323 		return 0;
2324 	}
2325 	return DP_BUS_BW_CFG(dp_ctx->dp_cfg.bus_bw_compute_interval);
2326 }
2327 
ucfg_dp_get_txrx_stats(struct wlan_objmgr_vdev * vdev,struct dp_tx_rx_stats * dp_stats)2328 QDF_STATUS ucfg_dp_get_txrx_stats(struct wlan_objmgr_vdev *vdev,
2329 				  struct dp_tx_rx_stats *dp_stats)
2330 {
2331 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2332 	struct wlan_dp_intf *dp_intf;
2333 	struct dp_tx_rx_stats *txrx_stats;
2334 	int i = 0, rx_mcast_drp = 0;
2335 
2336 	if (!dp_link) {
2337 		dp_err("Unable to get DP link");
2338 		return QDF_STATUS_E_INVAL;
2339 	}
2340 
2341 	dp_intf = dp_link->dp_intf;
2342 	txrx_stats = &dp_intf->dp_stats.tx_rx_stats;
2343 	for (i = 0; i < NUM_CPUS; i++) {
2344 		dp_stats->per_cpu[i].rx_packets = txrx_stats->per_cpu[i].rx_packets;
2345 		dp_stats->per_cpu[i].rx_dropped = txrx_stats->per_cpu[i].rx_dropped;
2346 		dp_stats->per_cpu[i].rx_delivered = txrx_stats->per_cpu[i].rx_delivered;
2347 		dp_stats->per_cpu[i].rx_refused = txrx_stats->per_cpu[i].rx_refused;
2348 		dp_stats->per_cpu[i].tx_called = txrx_stats->per_cpu[i].tx_called;
2349 		dp_stats->per_cpu[i].tx_dropped = txrx_stats->per_cpu[i].tx_dropped;
2350 		dp_stats->per_cpu[i].tx_orphaned = txrx_stats->per_cpu[i].tx_orphaned;
2351 	}
2352 	rx_mcast_drp = qdf_atomic_read(&txrx_stats->rx_usolict_arp_n_mcast_drp);
2353 	qdf_atomic_set(&dp_stats->rx_usolict_arp_n_mcast_drp, rx_mcast_drp);
2354 
2355 	dp_stats->rx_aggregated = txrx_stats->rx_aggregated;
2356 	dp_stats->rx_gro_dropped = txrx_stats->rx_gro_dropped;
2357 	dp_stats->rx_non_aggregated = txrx_stats->rx_non_aggregated;
2358 	dp_stats->rx_gro_flush_skip = txrx_stats->rx_gro_flush_skip;
2359 	dp_stats->rx_gro_low_tput_flush = txrx_stats->rx_gro_low_tput_flush;
2360 	dp_stats->tx_timeout_cnt = txrx_stats->tx_timeout_cnt;
2361 	dp_stats->cont_txtimeout_cnt = txrx_stats->cont_txtimeout_cnt;
2362 	dp_stats->last_txtimeout = txrx_stats->last_txtimeout;
2363 
2364 	return QDF_STATUS_SUCCESS;
2365 }
2366 
ucfg_dp_get_net_dev_stats(struct wlan_objmgr_vdev * vdev,qdf_net_dev_stats * stats)2367 void ucfg_dp_get_net_dev_stats(struct wlan_objmgr_vdev *vdev,
2368 			       qdf_net_dev_stats *stats)
2369 {
2370 	struct wlan_dp_link *dp_link;
2371 	struct wlan_dp_intf *dp_intf;
2372 
2373 	dp_link = dp_get_vdev_priv_obj(vdev);
2374 	if (unlikely(!dp_link)) {
2375 		dp_err_rl("DP link not found");
2376 		return;
2377 	}
2378 
2379 	dp_intf = dp_link->dp_intf;
2380 	dp_get_net_dev_stats(dp_intf, stats);
2381 }
2382 
ucfg_dp_clear_net_dev_stats(qdf_netdev_t dev)2383 void ucfg_dp_clear_net_dev_stats(qdf_netdev_t dev)
2384 {
2385 	struct wlan_dp_intf *dp_intf;
2386 	struct wlan_dp_psoc_context *dp_ctx;
2387 
2388 	dp_ctx =  dp_get_context();
2389 	if (qdf_unlikely(!dp_ctx)) {
2390 		dp_err_rl("DP context not found");
2391 		return;
2392 	}
2393 
2394 	dp_intf = dp_get_intf_by_netdev(dp_ctx, dev);
2395 	if (qdf_unlikely(!dp_intf)) {
2396 		dp_err_rl("DP interface not found");
2397 		return;
2398 	}
2399 
2400 	dp_clear_net_dev_stats(dp_intf);
2401 }
2402 
ucfg_dp_reset_cont_txtimeout_cnt(struct wlan_objmgr_vdev * vdev)2403 void ucfg_dp_reset_cont_txtimeout_cnt(struct wlan_objmgr_vdev *vdev)
2404 {
2405 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2406 	struct wlan_dp_intf *dp_intf;
2407 
2408 	if (!dp_link) {
2409 		dp_err("Unable to get DP link");
2410 		return;
2411 	}
2412 
2413 	dp_intf = dp_link->dp_intf;
2414 	dp_intf->dp_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
2415 }
2416 
ucfg_dp_set_rx_thread_affinity(struct wlan_objmgr_psoc * psoc)2417 void ucfg_dp_set_rx_thread_affinity(struct wlan_objmgr_psoc *psoc)
2418 {
2419 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2420 	struct wlan_dp_psoc_cfg *cfg;
2421 
2422 	if (!dp_ctx) {
2423 		dp_err("DP ctx is NULL");
2424 		return;
2425 	}
2426 	cfg = &dp_ctx->dp_cfg;
2427 
2428 	if (cfg->rx_thread_affinity_mask)
2429 		cds_set_rx_thread_cpu_mask(cfg->rx_thread_affinity_mask);
2430 
2431 	if (cfg->rx_thread_ul_affinity_mask)
2432 		cds_set_rx_thread_ul_cpu_mask(cfg->rx_thread_ul_affinity_mask);
2433 }
2434 
ucfg_dp_get_disable_rx_ol_val(struct wlan_objmgr_psoc * psoc,uint8_t * disable_conc,uint8_t * disable_low_tput)2435 void ucfg_dp_get_disable_rx_ol_val(struct wlan_objmgr_psoc *psoc,
2436 				   uint8_t *disable_conc,
2437 				   uint8_t *disable_low_tput)
2438 {
2439 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2440 
2441 	if (!dp_ctx) {
2442 		dp_err("Unable to get DP context");
2443 		return;
2444 	}
2445 	*disable_conc = qdf_atomic_read(&dp_ctx->disable_rx_ol_in_concurrency);
2446 	*disable_low_tput = qdf_atomic_read(&dp_ctx->disable_rx_ol_in_low_tput);
2447 }
2448 
ucfg_dp_get_rx_aggregation_val(struct wlan_objmgr_psoc * psoc)2449 uint32_t ucfg_dp_get_rx_aggregation_val(struct wlan_objmgr_psoc *psoc)
2450 {
2451 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2452 
2453 	if (!dp_ctx) {
2454 		dp_err("Unable to get DP context");
2455 		return 0;
2456 	}
2457 	return qdf_atomic_read(&dp_ctx->dp_agg_param.rx_aggregation);
2458 }
2459 
ucfg_dp_set_rx_aggregation_val(struct wlan_objmgr_psoc * psoc,uint32_t value)2460 void ucfg_dp_set_rx_aggregation_val(struct wlan_objmgr_psoc *psoc,
2461 				    uint32_t value)
2462 {
2463 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2464 
2465 	if (!dp_ctx) {
2466 		dp_err("Unable to get DP context");
2467 		return;
2468 	}
2469 	qdf_atomic_set(&dp_ctx->dp_agg_param.rx_aggregation, !!value);
2470 }
2471 
ucfg_dp_set_tc_based_dyn_gro(struct wlan_objmgr_psoc * psoc,bool value)2472 void ucfg_dp_set_tc_based_dyn_gro(struct wlan_objmgr_psoc *psoc, bool value)
2473 {
2474 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2475 
2476 	if (!dp_ctx) {
2477 		dp_err("DP ctx is NULL");
2478 		return;
2479 	}
2480 	dp_ctx->dp_agg_param.tc_based_dyn_gro = value;
2481 }
2482 
ucfg_dp_runtime_disable_rx_thread(struct wlan_objmgr_vdev * vdev,bool value)2483 void ucfg_dp_runtime_disable_rx_thread(struct wlan_objmgr_vdev *vdev,
2484 				       bool value)
2485 {
2486 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2487 	struct wlan_dp_intf *dp_intf;
2488 
2489 	if (!dp_link) {
2490 		dp_err("Unable to get DP link");
2491 		return;
2492 	}
2493 
2494 	dp_intf = dp_link->dp_intf;
2495 	dp_intf->runtime_disable_rx_thread = value;
2496 }
2497 
ucfg_dp_get_napi_enabled(struct wlan_objmgr_psoc * psoc)2498 bool ucfg_dp_get_napi_enabled(struct wlan_objmgr_psoc *psoc)
2499 {
2500 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2501 
2502 	if (!dp_ctx) {
2503 		dp_err("Unable to get DP context");
2504 		return 0;
2505 	}
2506 	return dp_ctx->napi_enable;
2507 }
2508 
ucfg_dp_set_tc_ingress_prio(struct wlan_objmgr_psoc * psoc,uint32_t value)2509 void ucfg_dp_set_tc_ingress_prio(struct wlan_objmgr_psoc *psoc, uint32_t value)
2510 {
2511 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2512 
2513 	if (!dp_ctx) {
2514 		dp_err("DP ctx is NULL");
2515 		return;
2516 	}
2517 	dp_ctx->dp_agg_param.tc_ingress_prio = value;
2518 }
2519 
ucfg_dp_nud_fail_data_stall_evt_enabled(void)2520 bool ucfg_dp_nud_fail_data_stall_evt_enabled(void)
2521 {
2522 	return dp_is_data_stall_event_enabled(DP_HOST_NUD_FAILURE);
2523 }
2524 
ucfg_dp_fw_data_stall_evt_enabled(void)2525 uint32_t ucfg_dp_fw_data_stall_evt_enabled(void)
2526 {
2527 	return cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC),
2528 			   cfg_dp_enable_data_stall) & FW_DATA_STALL_EVT_MASK;
2529 }
2530 
ucfg_dp_event_eapol_log(qdf_nbuf_t nbuf,enum qdf_proto_dir dir)2531 void ucfg_dp_event_eapol_log(qdf_nbuf_t nbuf, enum qdf_proto_dir dir)
2532 {
2533 	dp_event_eapol_log(nbuf, dir);
2534 }
2535 
2536 QDF_STATUS
ucfg_dp_softap_inspect_dhcp_packet(struct wlan_objmgr_vdev * vdev,qdf_nbuf_t nbuf,enum qdf_proto_dir dir)2537 ucfg_dp_softap_inspect_dhcp_packet(struct wlan_objmgr_vdev *vdev,
2538 				   qdf_nbuf_t nbuf, enum qdf_proto_dir dir)
2539 {
2540 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2541 
2542 	if (!dp_link) {
2543 		dp_err("Unable to get DP link");
2544 		return QDF_STATUS_E_INVAL;
2545 	}
2546 
2547 	return dp_softap_inspect_dhcp_packet(dp_link, nbuf, dir);
2548 }
2549 
2550 void
dp_ucfg_enable_link_monitoring(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_vdev * vdev,uint32_t threshold)2551 dp_ucfg_enable_link_monitoring(struct wlan_objmgr_psoc *psoc,
2552 			       struct wlan_objmgr_vdev *vdev,
2553 			       uint32_t threshold)
2554 {
2555 	struct wlan_dp_link *dp_link;
2556 	struct wlan_dp_intf *dp_intf;
2557 
2558 	dp_link = dp_get_vdev_priv_obj(vdev);
2559 	if (unlikely(!dp_link)) {
2560 		dp_err("DP link not found");
2561 		return;
2562 	}
2563 
2564 	dp_intf = dp_link->dp_intf;
2565 	dp_intf->link_monitoring.rx_linkspeed_threshold = threshold;
2566 	dp_intf->link_monitoring.enabled = true;
2567 }
2568 
2569 void
dp_ucfg_disable_link_monitoring(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_vdev * vdev)2570 dp_ucfg_disable_link_monitoring(struct wlan_objmgr_psoc *psoc,
2571 				struct wlan_objmgr_vdev *vdev)
2572 {
2573 	struct wlan_dp_intf *dp_intf;
2574 	struct wlan_dp_link *dp_link;
2575 
2576 	dp_link = dp_get_vdev_priv_obj(vdev);
2577 	if (unlikely(!dp_link)) {
2578 		dp_err("DP link not found");
2579 		return;
2580 	}
2581 
2582 	dp_intf = dp_link->dp_intf;
2583 	dp_intf->link_monitoring.enabled = false;
2584 	dp_intf->link_monitoring.rx_linkspeed_threshold = 0;
2585 }
2586 
2587 #ifdef DP_TRAFFIC_END_INDICATION
2588 QDF_STATUS
ucfg_dp_traffic_end_indication_get(struct wlan_objmgr_vdev * vdev,struct dp_traffic_end_indication * info)2589 ucfg_dp_traffic_end_indication_get(struct wlan_objmgr_vdev *vdev,
2590 				   struct dp_traffic_end_indication *info)
2591 {
2592 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2593 	struct wlan_dp_intf *dp_intf;
2594 
2595 	if (!dp_link) {
2596 		dp_err("Unable to get DP link");
2597 		return QDF_STATUS_E_INVAL;
2598 	}
2599 
2600 	dp_intf = dp_link->dp_intf;
2601 
2602 	info->enabled = dp_intf->traffic_end_ind.enabled;
2603 	info->def_dscp = dp_intf->traffic_end_ind.def_dscp;
2604 	info->spl_dscp = dp_intf->traffic_end_ind.spl_dscp;
2605 
2606 	return QDF_STATUS_SUCCESS;
2607 }
2608 
2609 QDF_STATUS
ucfg_dp_traffic_end_indication_set(struct wlan_objmgr_vdev * vdev,struct dp_traffic_end_indication info)2610 ucfg_dp_traffic_end_indication_set(struct wlan_objmgr_vdev *vdev,
2611 				   struct dp_traffic_end_indication info)
2612 {
2613 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
2614 	struct wlan_dp_intf *dp_intf;
2615 	cdp_config_param_type vdev_param;
2616 
2617 	if (!dp_link) {
2618 		dp_err("Unable to get DP link");
2619 		return QDF_STATUS_E_INVAL;
2620 	}
2621 
2622 	dp_intf = dp_link->dp_intf;
2623 	dp_intf->traffic_end_ind = info;
2624 
2625 	dp_debug("enabled:%u default dscp:%u special dscp:%u",
2626 		 dp_intf->traffic_end_ind.enabled,
2627 		 dp_intf->traffic_end_ind.def_dscp,
2628 		 dp_intf->traffic_end_ind.spl_dscp);
2629 
2630 	vdev_param.cdp_vdev_param_traffic_end_ind = info.enabled;
2631 	if (cdp_txrx_set_vdev_param(cds_get_context(QDF_MODULE_ID_SOC),
2632 				    dp_link->link_id,
2633 				    CDP_ENABLE_TRAFFIC_END_INDICATION,
2634 				    vdev_param))
2635 		dp_err("Failed to set traffic end indication param on DP vdev");
2636 
2637 	return QDF_STATUS_SUCCESS;
2638 }
2639 
ucfg_dp_traffic_end_indication_update_dscp(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,unsigned char * dscp)2640 void ucfg_dp_traffic_end_indication_update_dscp(struct wlan_objmgr_psoc *psoc,
2641 						uint8_t vdev_id,
2642 						unsigned char *dscp)
2643 {
2644 	struct wlan_objmgr_vdev *vdev;
2645 	struct wlan_dp_intf *dp_intf;
2646 	struct wlan_dp_link *dp_link;
2647 
2648 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id, WLAN_DP_ID);
2649 	if (vdev) {
2650 		dp_link = dp_get_vdev_priv_obj(vdev);
2651 
2652 		if (!dp_link) {
2653 			dp_err("Unable to get DP link");
2654 			goto end;
2655 		}
2656 
2657 		dp_intf = dp_link->dp_intf;
2658 		if (!dp_intf->traffic_end_ind.enabled)
2659 			goto end;
2660 
2661 		if (*dscp == dp_intf->traffic_end_ind.spl_dscp)
2662 			*dscp = dp_intf->traffic_end_ind.def_dscp;
2663 end:
2664 		wlan_objmgr_vdev_release_ref(vdev, WLAN_DP_ID);
2665 	}
2666 }
2667 #endif
2668 
ucfg_dp_prealloc_init(struct cdp_ctrl_objmgr_psoc * ctrl_psoc)2669 QDF_STATUS ucfg_dp_prealloc_init(struct cdp_ctrl_objmgr_psoc *ctrl_psoc)
2670 {
2671 	wlan_dp_select_profile_cfg((struct wlan_objmgr_psoc *)ctrl_psoc);
2672 	return dp_prealloc_init(ctrl_psoc);
2673 }
2674 
ucfg_dp_prealloc_deinit(void)2675 void ucfg_dp_prealloc_deinit(void)
2676 {
2677 	dp_prealloc_deinit();
2678 }
2679 
2680 #ifdef DP_MEM_PRE_ALLOC
ucfg_dp_prealloc_get_consistent_mem_unaligned(qdf_size_t size,qdf_dma_addr_t * base_addr,uint32_t ring_type)2681 void *ucfg_dp_prealloc_get_consistent_mem_unaligned(qdf_size_t size,
2682 						    qdf_dma_addr_t *base_addr,
2683 						    uint32_t ring_type)
2684 {
2685 	return dp_prealloc_get_consistent_mem_unaligned(size, base_addr,
2686 							ring_type);
2687 }
2688 
ucfg_dp_prealloc_put_consistent_mem_unaligned(void * va_unaligned)2689 void ucfg_dp_prealloc_put_consistent_mem_unaligned(void *va_unaligned)
2690 {
2691 	dp_prealloc_put_consistent_mem_unaligned(va_unaligned);
2692 }
2693 
ucfg_dp_prealloc_get_multi_pages(uint32_t desc_type,qdf_size_t elem_size,uint16_t elem_num,struct qdf_mem_multi_page_t * pages,bool cacheable)2694 void ucfg_dp_prealloc_get_multi_pages(uint32_t desc_type, qdf_size_t elem_size,
2695 				      uint16_t elem_num,
2696 				      struct qdf_mem_multi_page_t *pages,
2697 				      bool cacheable)
2698 {
2699 	dp_prealloc_get_multi_pages(desc_type, elem_size, elem_num, pages,
2700 				    cacheable);
2701 }
2702 
ucfg_dp_prealloc_put_multi_pages(uint32_t desc_type,struct qdf_mem_multi_page_t * pages)2703 void ucfg_dp_prealloc_put_multi_pages(uint32_t desc_type,
2704 				      struct qdf_mem_multi_page_t *pages)
2705 {
2706 	dp_prealloc_put_multi_pages(desc_type, pages);
2707 }
2708 #endif
2709 
2710 #if defined(WLAN_SUPPORT_RX_FISA)
ucfg_dp_rx_skip_fisa(uint32_t value)2711 void ucfg_dp_rx_skip_fisa(uint32_t value)
2712 {
2713 	struct wlan_dp_psoc_context *dp_ctx;
2714 
2715 	dp_ctx = dp_get_context();
2716 
2717 	if (dp_ctx)
2718 		dp_rx_skip_fisa(dp_ctx, value);
2719 }
2720 #endif
2721 
2722 #ifdef FEATURE_DIRECT_LINK
ucfg_dp_direct_link_init(struct wlan_objmgr_psoc * psoc)2723 QDF_STATUS ucfg_dp_direct_link_init(struct wlan_objmgr_psoc *psoc)
2724 {
2725 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2726 
2727 	if (!dp_ctx) {
2728 		dp_err("DP context not found");
2729 		return QDF_STATUS_E_FAILURE;
2730 	}
2731 
2732 	return dp_direct_link_init(dp_ctx);
2733 }
2734 
ucfg_dp_direct_link_deinit(struct wlan_objmgr_psoc * psoc,bool is_ssr)2735 void ucfg_dp_direct_link_deinit(struct wlan_objmgr_psoc *psoc, bool is_ssr)
2736 {
2737 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
2738 
2739 	if (!dp_ctx) {
2740 		dp_err("DP context not found");
2741 		return;
2742 	}
2743 
2744 	dp_direct_link_deinit(dp_ctx, is_ssr);
2745 }
2746 
2747 void
ucfg_dp_wfds_handle_request_mem_ind(struct wlan_qmi_wfds_mem_ind_msg * mem_msg)2748 ucfg_dp_wfds_handle_request_mem_ind(struct wlan_qmi_wfds_mem_ind_msg *mem_msg)
2749 {
2750 	dp_wfds_handle_request_mem_ind(mem_msg);
2751 }
2752 
2753 void
ucfg_dp_wfds_handle_ipcc_map_n_cfg_ind(struct wlan_qmi_wfds_ipcc_map_n_cfg_ind_msg * ipcc_msg)2754 ucfg_dp_wfds_handle_ipcc_map_n_cfg_ind(struct wlan_qmi_wfds_ipcc_map_n_cfg_ind_msg *ipcc_msg)
2755 {
2756 	dp_wfds_handle_ipcc_map_n_cfg_ind(ipcc_msg);
2757 }
2758 
ucfg_dp_wfds_new_server(void)2759 QDF_STATUS ucfg_dp_wfds_new_server(void)
2760 {
2761 	return dp_wfds_new_server();
2762 }
2763 
ucfg_dp_wfds_del_server(void)2764 void ucfg_dp_wfds_del_server(void)
2765 {
2766 	dp_wfds_del_server();
2767 }
2768 
ucfg_dp_config_direct_link(qdf_netdev_t dev,bool config_direct_link,bool enable_low_latency)2769 QDF_STATUS ucfg_dp_config_direct_link(qdf_netdev_t dev,
2770 				      bool config_direct_link,
2771 				      bool enable_low_latency)
2772 {
2773 	struct wlan_dp_psoc_context *dp_ctx;
2774 	struct wlan_dp_intf *dp_intf;
2775 
2776 	dp_ctx = dp_get_context();
2777 	if (!dp_ctx)
2778 		return QDF_STATUS_E_FAILURE;
2779 
2780 	dp_intf = dp_get_intf_by_netdev(dp_ctx, dev);
2781 	if (!dp_intf) {
2782 		dp_err("Unable to get DP interface");
2783 		return QDF_STATUS_E_INVAL;
2784 	}
2785 
2786 	return dp_config_direct_link(dp_intf, config_direct_link,
2787 				     enable_low_latency);
2788 }
2789 #endif
2790 
ucfg_dp_bus_suspend(ol_txrx_soc_handle soc,uint8_t pdev_id)2791 QDF_STATUS ucfg_dp_bus_suspend(ol_txrx_soc_handle soc, uint8_t pdev_id)
2792 {
2793 	return __wlan_dp_bus_suspend(soc, pdev_id);
2794 }
2795 
ucfg_dp_bus_resume(ol_txrx_soc_handle soc,uint8_t pdev_id)2796 QDF_STATUS ucfg_dp_bus_resume(ol_txrx_soc_handle soc, uint8_t pdev_id)
2797 {
2798 	return __wlan_dp_bus_resume(soc, pdev_id);
2799 }
2800 
ucfg_dp_txrx_soc_attach(struct dp_txrx_soc_attach_params * params,bool * is_wifi3_0_target)2801 void *ucfg_dp_txrx_soc_attach(struct dp_txrx_soc_attach_params *params,
2802 			      bool *is_wifi3_0_target)
2803 {
2804 	return wlan_dp_txrx_soc_attach(params, is_wifi3_0_target);
2805 }
2806 
ucfg_dp_txrx_soc_detach(ol_txrx_soc_handle soc)2807 void ucfg_dp_txrx_soc_detach(ol_txrx_soc_handle soc)
2808 {
2809 	return wlan_dp_txrx_soc_detach(soc);
2810 }
2811 
ucfg_dp_txrx_attach_target(ol_txrx_soc_handle soc,uint8_t pdev_id)2812 QDF_STATUS ucfg_dp_txrx_attach_target(ol_txrx_soc_handle soc, uint8_t pdev_id)
2813 {
2814 	return wlan_dp_txrx_attach_target(soc, pdev_id);
2815 }
2816 
ucfg_dp_txrx_pdev_attach(ol_txrx_soc_handle soc)2817 QDF_STATUS ucfg_dp_txrx_pdev_attach(ol_txrx_soc_handle soc)
2818 {
2819 	return wlan_dp_txrx_pdev_attach(soc);
2820 }
2821 
ucfg_dp_txrx_pdev_detach(ol_txrx_soc_handle soc,uint8_t pdev_id,int force)2822 QDF_STATUS ucfg_dp_txrx_pdev_detach(ol_txrx_soc_handle soc, uint8_t pdev_id,
2823 				    int force)
2824 {
2825 	return wlan_dp_txrx_pdev_detach(soc, pdev_id, force);
2826 }
2827 
ucfg_dp_txrx_init(ol_txrx_soc_handle soc,uint8_t pdev_id,struct dp_txrx_config * config)2828 QDF_STATUS ucfg_dp_txrx_init(ol_txrx_soc_handle soc, uint8_t pdev_id,
2829 			     struct dp_txrx_config *config)
2830 {
2831 	return dp_txrx_init(soc, pdev_id, config);
2832 }
2833 
ucfg_dp_txrx_deinit(ol_txrx_soc_handle soc)2834 QDF_STATUS ucfg_dp_txrx_deinit(ol_txrx_soc_handle soc)
2835 {
2836 	return dp_txrx_deinit(soc);
2837 }
2838 
ucfg_dp_txrx_ext_dump_stats(ol_txrx_soc_handle soc,uint8_t stats_id)2839 QDF_STATUS ucfg_dp_txrx_ext_dump_stats(ol_txrx_soc_handle soc,
2840 				       uint8_t stats_id)
2841 {
2842 	return dp_txrx_ext_dump_stats(soc, stats_id);
2843 }
2844 
ucfg_dp_txrx_set_cpu_mask(ol_txrx_soc_handle soc,qdf_cpu_mask * new_mask)2845 QDF_STATUS ucfg_dp_txrx_set_cpu_mask(ol_txrx_soc_handle soc,
2846 				     qdf_cpu_mask *new_mask)
2847 {
2848 	return dp_txrx_set_cpu_mask(soc, new_mask);
2849 }
2850 
2851 QDF_STATUS
ucfg_dp_get_per_link_peer_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_stats * peer_stats,enum cdp_peer_type peer_type,uint8_t num_link)2852 ucfg_dp_get_per_link_peer_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
2853 				uint8_t *peer_mac,
2854 				struct cdp_peer_stats *peer_stats,
2855 				enum cdp_peer_type peer_type,
2856 				uint8_t num_link)
2857 {
2858 	return cdp_host_get_per_link_peer_stats(soc, vdev_id, peer_mac,
2859 						peer_stats, peer_type,
2860 						num_link);
2861 }
2862 
2863 #ifdef WLAN_FEATURE_LOCAL_PKT_CAPTURE
ucfg_dp_is_local_pkt_capture_enabled(struct wlan_objmgr_psoc * psoc)2864 bool ucfg_dp_is_local_pkt_capture_enabled(struct wlan_objmgr_psoc *psoc)
2865 {
2866 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2867 
2868 	return cdp_cfg_get(soc, cfg_dp_local_pkt_capture);
2869 }
2870 #endif
2871 
ucfg_dp_get_vdev_stats(ol_txrx_soc_handle soc,uint8_t vdev_id,struct cdp_vdev_stats * buf)2872 QDF_STATUS ucfg_dp_get_vdev_stats(ol_txrx_soc_handle soc, uint8_t vdev_id,
2873 				  struct cdp_vdev_stats *buf)
2874 {
2875 	return cdp_host_get_vdev_stats(soc, vdev_id, buf, true);
2876 }
2877 
ucfg_dp_set_mon_conf_flags(struct wlan_objmgr_psoc * psoc,uint32_t flags)2878 void ucfg_dp_set_mon_conf_flags(struct wlan_objmgr_psoc *psoc, uint32_t flags)
2879 {
2880 	cdp_config_param_type val;
2881 	QDF_STATUS status;
2882 	struct wlan_dp_psoc_context *dp_ctx = dp_get_context();
2883 
2884 	if (!dp_ctx) {
2885 		dp_err("Failed to set flag %d, dp_ctx NULL", flags);
2886 		return;
2887 	}
2888 
2889 	val.cdp_monitor_flag = flags;
2890 	status = cdp_txrx_set_psoc_param(dp_ctx->cdp_soc,
2891 					 CDP_MONITOR_FLAG, val);
2892 	if (QDF_IS_STATUS_ERROR(status))
2893 		dp_err("Failed to set flag %d status %d", flags, status);
2894 }
2895