xref: /wlan-driver/qcacld-3.0/components/dp/core/inc/wlan_dp_main.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
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   * DOC: wlan_dp_main.h
20   *
21   *
22   */
23 #ifndef __WLAN_DP_MAIN_H__
24 #define __WLAN_DP_MAIN_H__
25 
26 #include "wlan_dp_public_struct.h"
27 #include "wlan_dp_priv.h"
28 #include "wlan_dp_objmgr.h"
29 
30 #define NUM_RX_QUEUES 5
31 
32 #define dp_enter() QDF_TRACE_ENTER(QDF_MODULE_ID_DP, "enter")
33 #define dp_exit() QDF_TRACE_EXIT(QDF_MODULE_ID_DP, "exit")
34 
35 /**
36  * dp_allocate_ctx() - Allocate DP context
37  *
38  */
39 QDF_STATUS dp_allocate_ctx(void);
40 
41 /**
42  * dp_free_ctx() - Free DP context
43  *
44  */
45 void dp_free_ctx(void);
46 
47 /**
48  * dp_get_front_intf_no_lock() - Get the first interface from the intf list
49  * This API does not use any lock in it's implementation. It is the caller's
50  * directive to ensure concurrency safety.
51  * @dp_ctx: pointer to the DP context
52  * @out_intf: double pointer to pass the next interface
53  *
54  * Return: QDF_STATUS
55  */
56 QDF_STATUS
57 dp_get_front_intf_no_lock(struct wlan_dp_psoc_context *dp_ctx,
58 			  struct wlan_dp_intf **out_intf);
59 
60 /**
61  * dp_get_next_intf_no_lock() - Get the next intf from the intf list
62  * This API does not use any lock in it's implementation. It is the caller's
63  * directive to ensure concurrency safety.
64  * @dp_ctx: pointer to the DP context
65  * @cur_intf: pointer to the current intf
66  * @out_intf: double pointer to pass the next intf
67  *
68  * Return: QDF_STATUS
69  */
70 QDF_STATUS
71 dp_get_next_intf_no_lock(struct wlan_dp_psoc_context *dp_ctx,
72 			 struct wlan_dp_intf *cur_intf,
73 			 struct wlan_dp_intf **out_intf);
74 
75 /**
76  * __dp_take_ref_and_fetch_front_intf_safe - Helper macro to lock, fetch
77  * front and next intf, take ref and unlock.
78  * @dp_ctx: the global DP context
79  * @dp_intf: an dp_intf pointer to use as a cursor
80  * @dp_intf_next: dp_intf pointer to next intf
81  *
82  */
83 #define __dp_take_ref_and_fetch_front_intf_safe(dp_ctx, dp_intf, \
84 						dp_intf_next) \
85 	qdf_spin_lock_bh(&dp_ctx->intf_list_lock), \
86 	dp_get_front_intf_no_lock(dp_ctx, &dp_intf), \
87 	dp_get_next_intf_no_lock(dp_ctx, dp_intf, &dp_intf_next), \
88 	qdf_spin_unlock_bh(&dp_ctx->intf_list_lock)
89 
90 /**
91  * __dp_take_ref_and_fetch_next_intf_safe - Helper macro to lock, fetch next
92  * interface, take ref and unlock.
93  * @dp_ctx: the global DP context
94  * @dp_intf: dp_intf pointer to use as a cursor
95  * @dp_intf_next: dp_intf pointer to next interface
96  *
97  */
98 #define __dp_take_ref_and_fetch_next_intf_safe(dp_ctx, dp_intf, \
99 					       dp_intf_next) \
100 	qdf_spin_lock_bh(&dp_ctx->intf_list_lock), \
101 	dp_intf = dp_intf_next, \
102 	dp_get_next_intf_no_lock(dp_ctx, dp_intf, &dp_intf_next), \
103 	qdf_spin_unlock_bh(&dp_ctx->intf_list_lock)
104 
105 /**
106  * __dp_is_intf_valid - Helper macro to return true/false for valid interface.
107  * @_dp_intf: an dp_intf pointer to use as a cursor
108  */
109 #define __dp_is_intf_valid(_dp_intf) !!(_dp_intf)
110 
111 /**
112  * dp_for_each_intf_held_safe - Interface iterator called
113  *                                      in a delete safe manner
114  * @dp_ctx: the global DP context
115  * @dp_intf: an dp_intf pointer to use as a cursor
116  * @dp_intf_next: dp_intf pointer to the next interface
117  *
118  */
119 #define dp_for_each_intf_held_safe(dp_ctx, dp_intf, dp_intf_next) \
120 	for (__dp_take_ref_and_fetch_front_intf_safe(dp_ctx, dp_intf, \
121 						     dp_intf_next); \
122 	     __dp_is_intf_valid(dp_intf); \
123 	     __dp_take_ref_and_fetch_next_intf_safe(dp_ctx, dp_intf, \
124 						    dp_intf_next))
125 
126 /**
127  * dp_get_intf_by_macaddr() - Api to Get interface from MAC address
128  * @dp_ctx: DP context
129  * @addr: MAC address
130  *
131  * Return: Pointer to DP interface.
132  */
133 struct wlan_dp_intf*
134 dp_get_intf_by_macaddr(struct wlan_dp_psoc_context *dp_ctx,
135 		       struct qdf_mac_addr *addr);
136 
137 /**
138  * dp_get_intf_by_netdev() - Api to Get interface from netdev
139  * @dp_ctx: DP context
140  * @dev: Pointer to network device
141  *
142  * Return: Pointer to DP interface.
143  */
144 struct wlan_dp_intf*
145 dp_get_intf_by_netdev(struct wlan_dp_psoc_context *dp_ctx, qdf_netdev_t dev);
146 
147 /**
148  * dp_get_front_link_no_lock() - Get the first link from the dp links list
149  * This API does not use any lock in it's implementation. It is the caller's
150  * directive to ensure concurrency safety.
151  * @dp_intf: DP interface handle
152  * @out_link: double pointer to pass the next link
153  *
154  * Return: QDF_STATUS
155  */
156 QDF_STATUS
157 dp_get_front_link_no_lock(struct wlan_dp_intf *dp_intf,
158 			  struct wlan_dp_link **out_link);
159 
160 /**
161  * dp_get_next_link_no_lock() - Get the next link from the link list
162  * This API does not use any lock in it's implementation. It is the caller's
163  * directive to ensure concurrency safety.
164  * @dp_intf: DP interface handle
165  * @cur_link: pointer to the currentlink
166  * @out_link: double pointer to pass the nextlink
167  *
168  * Return: QDF_STATUS
169  */
170 QDF_STATUS
171 dp_get_next_link_no_lock(struct wlan_dp_intf *dp_intf,
172 			 struct wlan_dp_link *cur_link,
173 			 struct wlan_dp_link **out_link);
174 
175 /**
176  * __dp_take_ref_and_fetch_front_link_safe - Helper macro to lock, fetch
177  * front and next link, take ref and unlock.
178  * @dp_intf: DP interface handle
179  * @dp_link: an dp_link pointer to use as a cursor
180  * @dp_link_next: dp_link pointer to nextlink
181  */
182 #define __dp_take_ref_and_fetch_front_link_safe(dp_intf, dp_link, \
183 						dp_link_next) \
184 	qdf_spin_lock_bh(&(dp_intf)->dp_link_list_lock), \
185 	dp_get_front_link_no_lock(dp_intf, &(dp_link)), \
186 	dp_get_next_link_no_lock(dp_intf, dp_link, &(dp_link_next)), \
187 	qdf_spin_unlock_bh(&(dp_intf)->dp_link_list_lock)
188 
189 /**
190  * __dp_take_ref_and_fetch_next_link_safe - Helper macro to lock, fetch next
191  * interface, take ref and unlock.
192  * @dp_intf: DP interface handle
193  * @dp_link: dp_link pointer to use as a cursor
194  * @dp_link_next: dp_link pointer to next link
195  */
196 #define __dp_take_ref_and_fetch_next_link_safe(dp_intf, dp_link, \
197 					       dp_link_next) \
198 	qdf_spin_lock_bh(&(dp_intf)->dp_link_list_lock), \
199 	dp_link = dp_link_next, \
200 	dp_get_next_link_no_lock(dp_intf, dp_link, &(dp_link_next)), \
201 	qdf_spin_unlock_bh(&(dp_intf)->dp_link_list_lock)
202 
203 /**
204  * __dp_is_link_valid - Helper macro to return true/false for valid interface.
205  * @_dp_link: an dp_link pointer to use as a cursor
206  */
207 #define __dp_is_link_valid(_dp_link) !!(_dp_link)
208 
209 /**
210  * dp_for_each_link_held_safe - Interface iterator called
211  *                                      in a delete safe manner
212  * @dp_intf: DP interface handle
213  * @dp_link: an dp_link pointer to use as a cursor
214  * @dp_link_next: dp_link pointer to the next interface
215  *
216  */
217 #define dp_for_each_link_held_safe(dp_intf, dp_link, dp_link_next) \
218 	for (__dp_take_ref_and_fetch_front_link_safe(dp_intf, dp_link, \
219 						     dp_link_next); \
220 	     __dp_is_link_valid(dp_link); \
221 	     __dp_take_ref_and_fetch_next_link_safe(dp_intf, dp_link, \
222 						    dp_link_next))
223 
224 /* MAX iteration count to wait for dp packet process to complete */
225 #define DP_TASK_MAX_WAIT_CNT  100
226 /* Milli seconds to wait when packet is getting processed */
227 #define DP_TASK_WAIT_TIME 200
228 
229 #define DP_TX_FN_CLR (1 << 0)
230 #define DP_TX_SAP_STOP (1 << 1)
231 #define DP_TX_DFS_CAC_BLOCK (1 << 2)
232 #define WLAN_DP_SUSPEND (1 << 3)
233 
234 /**
235  * dp_wait_complete_tasks: Wait for DP tasks to complete
236  * @dp_ctx: DP context pointer
237  *
238  * This function waits for dp tasks like TX to be completed
239  *
240  * Return: None
241  */
242 void dp_wait_complete_tasks(struct wlan_dp_psoc_context *dp_ctx);
243 
244 #define NUM_RX_QUEUES 5
245 
246 #define dp_enter() QDF_TRACE_ENTER(QDF_MODULE_ID_DP, "enter")
247 #define dp_exit() QDF_TRACE_EXIT(QDF_MODULE_ID_DP, "exit")
248 
249 /**
250  * __wlan_dp_runtime_suspend() - Runtime suspend DP handler
251  * @soc: CDP SoC handle
252  * @pdev_id: DP PDEV ID
253  *
254  * Return: QDF_STATUS
255  */
256 QDF_STATUS __wlan_dp_runtime_suspend(ol_txrx_soc_handle soc, uint8_t pdev_id);
257 
258 /**
259  * __wlan_dp_runtime_resume() - Runtime suspend DP handler
260  * @soc: CDP SoC handle
261  * @pdev_id: DP PDEV ID
262  *
263  * Return: QDF_STATUS
264  */
265 QDF_STATUS __wlan_dp_runtime_resume(ol_txrx_soc_handle soc, uint8_t pdev_id);
266 
267 /**
268  * __wlan_dp_bus_suspend() - BUS suspend DP handler
269  * @soc: CDP SoC handle
270  * @pdev_id: DP PDEV ID
271  *
272  * Return: QDF_STATUS
273  */
274 QDF_STATUS __wlan_dp_bus_suspend(ol_txrx_soc_handle soc, uint8_t pdev_id);
275 
276 /**
277  * __wlan_dp_bus_resume() - BUS resume DP handler
278  * @soc: CDP SoC handle
279  * @pdev_id: DP PDEV ID
280  *
281  * Return: QDF_STATUS
282  */
283 QDF_STATUS __wlan_dp_bus_resume(ol_txrx_soc_handle soc, uint8_t pdev_id);
284 
285 /**
286  * wlan_dp_txrx_soc_attach() - Datapath soc attach
287  * @params: SoC attach params
288  * @is_wifi3_0_target: [OUT] Pointer to update if the target is wifi3.0
289  *
290  * Return: SoC handle
291  */
292 void *wlan_dp_txrx_soc_attach(struct dp_txrx_soc_attach_params *params,
293 			      bool *is_wifi3_0_target);
294 
295 /**
296  * wlan_dp_txrx_soc_detach() - Datapath SoC detach
297  * @soc: DP SoC handle
298  *
299  * Return: None
300  */
301 void wlan_dp_txrx_soc_detach(ol_txrx_soc_handle soc);
302 
303 /**
304  * wlan_dp_txrx_attach_target() - DP target attach
305  * @soc: DP SoC handle
306  * @pdev_id: DP pdev id
307  *
308  * Return: QDF_STATUS
309  */
310 QDF_STATUS wlan_dp_txrx_attach_target(ol_txrx_soc_handle soc, uint8_t pdev_id);
311 
312 /**
313  * wlan_dp_txrx_pdev_attach() - DP pdev attach
314  * @soc: DP SoC handle
315  *
316  * Return: QDF_STATUS
317  */
318 QDF_STATUS wlan_dp_txrx_pdev_attach(ol_txrx_soc_handle soc);
319 
320 /**
321  * wlan_dp_txrx_pdev_detach() - DP pdev detach
322  * @soc: DP SoC handle
323  * @pdev_id: DP pdev id
324  * @force: indicates if force detach is to be done or not
325  *
326  * Return: QDF_STATUS
327  */
328 QDF_STATUS wlan_dp_txrx_pdev_detach(ol_txrx_soc_handle soc, uint8_t pdev_id,
329 				    int force);
330 
331 #ifdef WLAN_FEATURE_11BE_MLO
332 /**
333  * dp_link_switch_notification() - DP notifier for MLO link switch
334  * @vdev: Objmgr vdev handle
335  * @lswitch_req: Link switch request params
336  * @notify_reason: Reason of notification
337  *
338  * Return: QDF_STATUS
339  */
340 QDF_STATUS
341 dp_link_switch_notification(struct wlan_objmgr_vdev *vdev,
342 			    struct wlan_mlo_link_switch_req *lswitch_req,
343 			    enum wlan_mlo_link_switch_notify_reason notify_reason);
344 #endif
345 
346 /**
347  * dp_peer_obj_create_notification(): dp peer create handler
348  * @peer: peer which is going to created by objmgr
349  * @arg: argument for vdev create handler
350  *
351  * Register this api with objmgr to detect peer is created
352  *
353  * Return: QDF_STATUS status in case of success else return error
354  */
355 QDF_STATUS
356 dp_peer_obj_create_notification(struct wlan_objmgr_peer *peer, void *arg);
357 
358 /**
359  * dp_peer_obj_destroy_notification(): dp peer delete handler
360  * @peer: peer which is going to delete by objmgr
361  * @arg: argument for vdev delete handler
362  *
363  * Register this api with objmgr to detect peer is deleted
364  *
365  * Return: QDF_STATUS status in case of success else return error
366  */
367 QDF_STATUS
368 dp_peer_obj_destroy_notification(struct wlan_objmgr_peer *peer, void *arg);
369 
370 /**
371  * dp_vdev_obj_destroy_notification() - Free per DP vdev object
372  * @vdev: vdev context
373  * @arg: Pointer to arguments
374  *
375  * This function gets called from object manager when vdev is being
376  * deleted and delete DP vdev context.
377  *
378  * Return: QDF_STATUS_SUCCESS - in case of success
379  */
380 QDF_STATUS
381 dp_vdev_obj_destroy_notification(struct wlan_objmgr_vdev *vdev, void *arg);
382 
383 /**
384  * dp_vdev_obj_create_notification() - Allocate per DP vdev object
385  * @vdev: vdev context
386  * @arg: Pointer to arguments
387  *
388  * This function gets called from object manager when vdev is being
389  * created and creates DP vdev context.
390  *
391  * Return: QDF_STATUS_SUCCESS - in case of success
392  */
393 QDF_STATUS
394 dp_vdev_obj_create_notification(struct wlan_objmgr_vdev *vdev, void *arg);
395 
396 /**
397  * dp_pdev_obj_create_notification() - Allocate per DP pdev object
398  * @pdev: pdev context
399  * @arg: Pointer to arguments
400  *
401  * This function gets called from object manager when pdev is being
402  * created and creates DP pdev context.
403  *
404  * Return: QDF_STATUS_SUCCESS - in case of success
405  */
406 QDF_STATUS
407 dp_pdev_obj_create_notification(struct wlan_objmgr_pdev *pdev, void *arg);
408 
409 /**
410  * dp_pdev_obj_destroy_notification() - Free per DP pdev object
411  * @pdev: pdev context
412  * @arg: Pointer to arguments
413  *
414  * This function gets called from object manager when pdev is being
415  * deleted and delete DP pdev context.
416  *
417  * Return: QDF_STATUS_SUCCESS - in case of success
418  */
419 QDF_STATUS
420 dp_pdev_obj_destroy_notification(struct wlan_objmgr_pdev *pdev, void *arg);
421 
422 /**
423  * dp_psoc_obj_create_notification() - Function to allocate per DP
424  * psoc private object
425  * @psoc: psoc context
426  * @arg: Pointer to arguments
427  *
428  * This function gets called from object manager when psoc is being
429  * created and creates DP soc context.
430  *
431  * Return: QDF_STATUS_SUCCESS - in case of success
432  */
433 QDF_STATUS
434 dp_psoc_obj_create_notification(struct wlan_objmgr_psoc *psoc, void *arg);
435 
436 /**
437  * dp_psoc_obj_destroy_notification() - Free psoc private object
438  * @psoc: psoc context
439  * @arg: Pointer to arguments
440  *
441  * This function gets called from object manager when psoc is being
442  * deleted and delete DP soc context.
443  *
444  * Return: QDF_STATUS_SUCCESS - in case of success
445  */
446 QDF_STATUS
447 dp_psoc_obj_destroy_notification(struct wlan_objmgr_psoc *psoc, void *arg);
448 
449 /**
450  * dp_attach_ctx() - Api to attach dp ctx
451  * @dp_ctx : DP Context
452  *
453  * Helper function to attach dp ctx
454  *
455  * Return: None.
456  */
457 void dp_attach_ctx(struct wlan_dp_psoc_context *dp_ctx);
458 
459 /**
460  * dp_detach_ctx() - to detach dp context
461  *
462  * Helper function to detach dp context
463  *
464  * Return: None.
465  */
466 void dp_detach_ctx(void);
467 
468 /**
469  * dp_get_context() - to get dp context
470  *
471  * Helper function to get dp context
472  *
473  * Return: dp context.
474  */
475 struct wlan_dp_psoc_context *dp_get_context(void);
476 
477 /**
478  * dp_add_latency_critical_client() - Add latency critical client
479  * @vdev: pointer to vdev object (Should not be NULL)
480  * @phymode: the phymode of the connected adapter
481  *
482  * This function checks if the present connection is latency critical
483  * and adds to the latency critical clients count and informs the
484  * datapath about this connection being latency critical.
485  *
486  * Returns: None
487  */
488 static inline void
dp_add_latency_critical_client(struct wlan_objmgr_vdev * vdev,enum qca_wlan_802_11_mode phymode)489 dp_add_latency_critical_client(struct wlan_objmgr_vdev *vdev,
490 			       enum qca_wlan_802_11_mode phymode)
491 {
492 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
493 	struct wlan_dp_intf *dp_intf;
494 
495 	if (!dp_link) {
496 		dp_err("No dp_link for objmgr vdev %pK", vdev);
497 		return;
498 	}
499 
500 	dp_intf = dp_link->dp_intf;
501 	if (!dp_intf) {
502 		dp_err("Invalid dp_intf for dp_link %pK (" QDF_MAC_ADDR_FMT ")",
503 		       dp_link, QDF_MAC_ADDR_REF(dp_link->mac_addr.bytes));
504 		return;
505 	}
506 
507 	switch (phymode) {
508 	case QCA_WLAN_802_11_MODE_11A:
509 	case QCA_WLAN_802_11_MODE_11G:
510 		qdf_atomic_inc(&dp_intf->dp_ctx->num_latency_critical_clients);
511 
512 		dp_debug("Adding latency critical connection for vdev %d",
513 			 dp_link->link_id);
514 		cdp_vdev_inform_ll_conn(cds_get_context(QDF_MODULE_ID_SOC),
515 					dp_link->link_id,
516 					CDP_VDEV_LL_CONN_ADD);
517 		break;
518 	default:
519 		break;
520 	}
521 }
522 
523 /**
524  * dp_del_latency_critical_client() - Add tlatency critical client
525  * @vdev: pointer to vdev object (Should not be NULL)
526  * @phymode: the phymode of the connected adapter
527  *
528  * This function checks if the present connection was latency critical
529  * and removes from the latency critical clients count and informs the
530  * datapath about the removed connection being latency critical.
531  *
532  * Returns: None
533  */
534 static inline void
dp_del_latency_critical_client(struct wlan_objmgr_vdev * vdev,enum qca_wlan_802_11_mode phymode)535 dp_del_latency_critical_client(struct wlan_objmgr_vdev *vdev,
536 			       enum qca_wlan_802_11_mode phymode)
537 {
538 	struct wlan_dp_link *dp_link = dp_get_vdev_priv_obj(vdev);
539 	struct wlan_dp_intf *dp_intf;
540 
541 	if (!dp_link) {
542 		dp_err("No dp_link for objmgr vdev %pK", vdev);
543 		return;
544 	}
545 
546 	dp_intf = dp_link->dp_intf;
547 	if (!dp_intf) {
548 		dp_err("Invalid dp_intf for dp_link %pK (" QDF_MAC_ADDR_FMT ")",
549 		       dp_link, QDF_MAC_ADDR_REF(dp_link->mac_addr.bytes));
550 		return;
551 	}
552 
553 	switch (phymode) {
554 	case QCA_WLAN_802_11_MODE_11A:
555 	case QCA_WLAN_802_11_MODE_11G:
556 		qdf_atomic_dec(&dp_intf->dp_ctx->num_latency_critical_clients);
557 
558 		dp_info("Removing latency critical connection for vdev %d",
559 			dp_link->link_id);
560 		cdp_vdev_inform_ll_conn(cds_get_context(QDF_MODULE_ID_SOC),
561 					dp_link->link_id,
562 					CDP_VDEV_LL_CONN_DEL);
563 		break;
564 	default:
565 		break;
566 	}
567 }
568 
569 /**
570  * is_dp_intf_valid() - to check DP interface valid
571  * @dp_intf: DP interface pointer
572  *
573  * API to check whether DP interface is valid
574  *
575  * Return: non zero value on interface valid
576  */
577 int is_dp_intf_valid(struct wlan_dp_intf *dp_intf);
578 
579 /**
580  * is_dp_link_valid() - check if DP link is valid
581  * @dp_link: DP link handle
582  *
583  * API to check whether DP link is valid
584  *
585  * Return: true if dp_link is valid, else false.
586  */
587 bool is_dp_link_valid(struct wlan_dp_link *dp_link);
588 
589 /**
590  * dp_send_rps_ind() - send rps indication to daemon
591  * @dp_intf: DP interface
592  *
593  * If RPS feature enabled by INI, send RPS enable indication to daemon
594  * Indication contents is the name of interface to find correct sysfs node
595  * Should send all available interfaces
596  *
597  * Return: none
598  */
599 void dp_send_rps_ind(struct wlan_dp_intf *dp_intf);
600 
601 /**
602  * dp_try_send_rps_ind() - try to send rps indication to daemon.
603  * @vdev: vdev handle
604  *
605  * If RPS flag is set in DP context then send rsp indication.
606  *
607  * Return: none
608  */
609 void dp_try_send_rps_ind(struct wlan_objmgr_vdev *vdev);
610 
611 /**
612  * dp_send_rps_disable_ind() - send rps disable indication to daemon
613  * @dp_intf: DP interface
614  *
615  * Return: none
616  */
617 void dp_send_rps_disable_ind(struct wlan_dp_intf *dp_intf);
618 
619 #ifdef QCA_CONFIG_RPS
620 /**
621  * dp_set_rps() - Enable/disable RPS for mode specified
622  * @vdev_id: vdev id which RPS needs to be enabled
623  * @enable: Set true to enable RPS in SAP mode
624  *
625  * Callback function registered with ipa
626  *
627  * Return: none
628  */
629 void dp_set_rps(uint8_t vdev_id, bool enable);
630 #else
dp_set_rps(uint8_t vdev_id,bool enable)631 static inline void dp_set_rps(uint8_t vdev_id, bool enable)
632 {
633 }
634 #endif
635 
636 /**
637  * dp_set_rx_mode_rps() - Enable/disable RPS in SAP mode
638  * @enable: Set true to enable RPS in SAP mode
639  *
640  * Callback function registered with core datapath
641  *
642  * Return: none
643  */
644 void dp_set_rx_mode_rps(bool enable);
645 
646 /**
647  * dp_set_rps_cpu_mask - set RPS CPU mask for interfaces
648  * @dp_ctx: pointer to struct dp_context
649  *
650  * Return: none
651  */
652 void dp_set_rps_cpu_mask(struct wlan_dp_psoc_context *dp_ctx);
653 
654 /**
655  * dp_try_set_rps_cpu_mask() - try to set RPS CPU mask
656  * @psoc: psoc handle
657  *
658  * If RPS flag is set in DP context then set RPS CPU mask.
659  *
660  * Return: none
661  */
662 void dp_try_set_rps_cpu_mask(struct wlan_objmgr_psoc *psoc);
663 
664 /**
665  * dp_clear_rps_cpu_mask - clear RPS CPU mask for interfaces
666  * @dp_ctx: pointer to struct dp_context
667  *
668  * Return: none
669  */
670 void dp_clear_rps_cpu_mask(struct wlan_dp_psoc_context *dp_ctx);
671 
672 /**
673  * dp_mic_init_work() - init mic error work
674  * @dp_intf: Pointer to dp interface
675  *
676  * Return: None
677  */
678 void dp_mic_init_work(struct wlan_dp_intf *dp_intf);
679 
680 /**
681  * dp_mic_deinit_work() - deinitialize mic error work
682  * @dp_intf: Pointer to dp interface
683  *
684  * Return: None
685  */
686 void dp_mic_deinit_work(struct wlan_dp_intf *dp_intf);
687 
688 /**
689  * dp_rx_mic_error_ind() - MIC error indication handler
690  * @psoc: opaque handle for UMAC psoc object
691  * @pdev_id: physical device instance id
692  * @mic_failure_info: mic failure information
693  *
694  * This function indicates the Mic failure to the supplicant
695  *
696  * Return: None
697  */
698 void
699 dp_rx_mic_error_ind(struct cdp_ctrl_objmgr_psoc *psoc, uint8_t pdev_id,
700 		    struct cdp_rx_mic_err_info *mic_failure_info);
701 /**
702  * dp_intf_get_tx_ops: get TX ops from the DP interface
703  * @psoc: pointer to psoc object
704  *
705  * Return: pointer to TX op callback
706  */
707 static inline
dp_intf_get_tx_ops(struct wlan_objmgr_psoc * psoc)708 struct wlan_dp_psoc_sb_ops *dp_intf_get_tx_ops(struct wlan_objmgr_psoc *psoc)
709 {
710 	struct wlan_dp_psoc_context *dp_ctx;
711 
712 	if (!psoc) {
713 		dp_err("psoc is null");
714 		return NULL;
715 	}
716 
717 	dp_ctx = dp_psoc_get_priv(psoc);
718 	if (!dp_ctx) {
719 		dp_err("psoc private object is null");
720 		return NULL;
721 	}
722 
723 	return &dp_ctx->sb_ops;
724 }
725 
726 /**
727  * dp_intf_get_rx_ops: get RX ops from the DP interface
728  * @psoc: pointer to psoc object
729  *
730  * Return: pointer to RX op callback
731  */
732 static inline
dp_intf_get_rx_ops(struct wlan_objmgr_psoc * psoc)733 struct wlan_dp_psoc_nb_ops *dp_intf_get_rx_ops(struct wlan_objmgr_psoc *psoc)
734 {
735 	struct wlan_dp_psoc_context *dp_ctx;
736 
737 	if (!psoc) {
738 		dp_err("psoc is null");
739 		return NULL;
740 	}
741 
742 	dp_ctx = dp_psoc_get_priv(psoc);
743 	if (!dp_ctx) {
744 		dp_err("psoc private object is null");
745 		return NULL;
746 	}
747 
748 	return &dp_ctx->nb_ops;
749 }
750 
751 /**
752  * dp_get_arp_request_ctx: get ARP req context from the DP context
753  * @psoc: pointer to psoc object
754  *
755  * Return: pointer to ARP request ctx.
756  */
757 static inline
dp_get_arp_request_ctx(struct wlan_objmgr_psoc * psoc)758 void *dp_get_arp_request_ctx(struct wlan_objmgr_psoc *psoc)
759 {
760 	struct wlan_dp_psoc_context *dp_ctx;
761 
762 	dp_ctx = dp_psoc_get_priv(psoc);
763 	if (!dp_ctx) {
764 		dp_err("psoc private object is null");
765 		return NULL;
766 	}
767 	return dp_ctx->sb_ops.arp_request_ctx;
768 }
769 
770 /**
771  * dp_get_arp_stats_event_handler() - callback api to update the
772  * stats received from FW
773  * @psoc : psoc handle
774  * @rsp: pointer to data received from FW.
775  *
776  * This is called when wlan driver received response event for
777  * get arp stats to firmware.
778  *
779  * Return: None
780  */
781 QDF_STATUS dp_get_arp_stats_event_handler(struct wlan_objmgr_psoc *psoc,
782 					  struct dp_rsp_stats *rsp);
783 
784 /**
785  * dp_trace_init() - Initialize DP trace
786  * @psoc: psoc handle
787  *
788  * Return: None
789  */
790 
791 void dp_trace_init(struct wlan_objmgr_psoc *psoc);
792 
793 /**
794  * dp_set_dump_dp_trace() - set DP trace dump level
795  * @cmd_type : command type
796  * @count: count
797  *
798  * Return: None
799  */
800 void dp_set_dump_dp_trace(uint16_t cmd_type, uint16_t count);
801 
802 #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH
803 #define DP_BUS_BW_CFG(bus_bw_cfg)	bus_bw_cfg
804 #define DP_BUS_BW_GET_RX_LVL(dp_ctx)	(dp_ctx)->cur_rx_level
805 static inline bool
dp_is_low_tput_gro_enable(struct wlan_dp_psoc_context * dp_ctx)806 dp_is_low_tput_gro_enable(struct wlan_dp_psoc_context *dp_ctx)
807 {
808 	return (qdf_atomic_read(&dp_ctx->low_tput_gro_enable)) ? true : false;
809 }
810 #else
811 #define DP_BUS_BW_CFG(bus_bw_cfg)	0
812 #define DP_BUS_BW_GET_RX_LVL(dp_ctx)	0
813 static inline bool
dp_is_low_tput_gro_enable(struct wlan_dp_psoc_context * dp_ctx)814 dp_is_low_tput_gro_enable(struct wlan_dp_psoc_context *dp_ctx)
815 {
816 	return false;
817 }
818 #endif
819 
820 #define DP_DATA_STALL_ENABLE      BIT(0)
821 #define DP_HOST_STA_TX_TIMEOUT    BIT(16)
822 #define DP_HOST_SAP_TX_TIMEOUT    BIT(17)
823 #define DP_HOST_NUD_FAILURE       BIT(18)
824 #define DP_TIMEOUT_WLM_MODE       BIT(31)
825 #define FW_DATA_STALL_EVT_MASK     0x8000FFFF
826 
827 /**
828  * dp_is_data_stall_event_enabled() - Check if data stall detection is enabled
829  * @evt: Data stall event to be checked
830  *
831  * Return: True if the data stall event is enabled
832  */
833 bool dp_is_data_stall_event_enabled(uint32_t evt);
834 
835 /*
836  * dp_get_net_dev_stats(): Get netdev stats
837  * @dp_intf: DP interface handle
838  * @stats: To hold netdev stats
839  *
840  * Return: None
841  */
842 static inline void
dp_get_net_dev_stats(struct wlan_dp_intf * dp_intf,qdf_net_dev_stats * stats)843 dp_get_net_dev_stats(struct wlan_dp_intf *dp_intf, qdf_net_dev_stats *stats)
844 {
845 	qdf_mem_copy(stats, &dp_intf->stats, sizeof(dp_intf->stats));
846 }
847 
848 /*
849  * dp_clear_net_dev_stats(): Clear netdev stats
850  * @dp_intf: DP interface handle
851  *
852  * Return: None
853  */
854 static inline
dp_clear_net_dev_stats(struct wlan_dp_intf * dp_intf)855 void dp_clear_net_dev_stats(struct wlan_dp_intf *dp_intf)
856 {
857 	qdf_mem_set(&dp_intf->stats, sizeof(dp_intf->stats), 0);
858 }
859 
860 #ifdef FEATURE_DIRECT_LINK
861 /**
862  * dp_direct_link_init() - Initializes Direct Link datapath
863  * @dp_ctx: DP private context
864  *
865  * Return: QDF status
866  */
867 QDF_STATUS dp_direct_link_init(struct wlan_dp_psoc_context *dp_ctx);
868 
869 /**
870  * dp_direct_link_deinit() - De-initializes Direct Link datapath
871  * @dp_ctx: DP private context
872  * @is_ssr: true if SSR is in progress else false
873  *
874  * Return: None
875  */
876 void dp_direct_link_deinit(struct wlan_dp_psoc_context *dp_ctx, bool is_ssr);
877 
878 /**
879  * dp_config_direct_link: Set direct link config of vdev
880  * @dp_intf: DP interface handle
881  * @config_direct_link: Flag to enable direct link path
882  * @enable_low_latency: Flag to enable low link latency
883  *
884  * Return: QDF Status
885  */
886 QDF_STATUS dp_config_direct_link(struct wlan_dp_intf *dp_intf,
887 				 bool config_direct_link,
888 				 bool enable_low_latency);
889 #else
890 static inline
dp_direct_link_init(struct wlan_dp_psoc_context * dp_ctx)891 QDF_STATUS dp_direct_link_init(struct wlan_dp_psoc_context *dp_ctx)
892 {
893 	return QDF_STATUS_SUCCESS;
894 }
895 
896 static inline
dp_direct_link_deinit(struct wlan_dp_psoc_context * dp_ctx,bool is_ssr)897 void dp_direct_link_deinit(struct wlan_dp_psoc_context *dp_ctx, bool is_ssr)
898 {
899 }
900 
901 static inline
dp_config_direct_link(struct wlan_dp_intf * dp_intf,bool config_direct_link,bool enable_low_latency)902 QDF_STATUS dp_config_direct_link(struct wlan_dp_intf *dp_intf,
903 				 bool config_direct_link,
904 				 bool enable_low_latency)
905 {
906 	return QDF_STATUS_SUCCESS;
907 }
908 #endif
909 #ifdef WLAN_FEATURE_11BE
910 /**
911  * __wlan_dp_update_peer_map_unmap_version() - update peer map unmap version
912  * @version: Peer map unmap version pointer to be updated
913  *
914  * Return: None
915  */
916 static inline void
__wlan_dp_update_peer_map_unmap_version(uint8_t * version)917 __wlan_dp_update_peer_map_unmap_version(uint8_t *version)
918 {
919 	/* 0x32 -> host supports HTT peer map v3 format and peer unmap v2 format. */
920 	*version = 0x32;
921 }
922 #else
923 static inline void
__wlan_dp_update_peer_map_unmap_version(uint8_t * version)924 __wlan_dp_update_peer_map_unmap_version(uint8_t *version)
925 {
926 }
927 #endif
928 
929 #ifdef WLAN_DP_PROFILE_SUPPORT
930 /**
931  * wlan_dp_get_profile_info() - Get DP memory profile info
932  *
933  * Return: None
934  */
935 struct wlan_dp_memory_profile_info *wlan_dp_get_profile_info(void);
936 
937 /**
938  * wlan_dp_select_profile_cfg() - Select DP profile configuration
939  * @psoc: psoc context
940  *
941  * Return: QDF_STATUS
942  */
943 QDF_STATUS wlan_dp_select_profile_cfg(struct wlan_objmgr_psoc *psoc);
944 
945 /**
946  * wlan_dp_soc_cfg_sync_profile() - Sync DP soc cfg items with profile
947  * @cdp_soc: cdp soc context
948  *
949  * Return: None
950  */
951 void wlan_dp_soc_cfg_sync_profile(struct cdp_soc_t *cdp_soc);
952 
953 /**
954  * wlan_dp_pdev_cfg_sync_profile() - Sync DP pdev cfg items with profile
955  * @cdp_soc: cdp soc context
956  * @pdev_id: pdev id
957  *
958  * Return: QDF_STATUS
959  */
960 void wlan_dp_pdev_cfg_sync_profile(struct cdp_soc_t *cdp_soc, uint8_t pdev_id);
961 #else
962 
963 static inline
wlan_dp_select_profile_cfg(struct wlan_objmgr_psoc * psoc)964 QDF_STATUS wlan_dp_select_profile_cfg(struct wlan_objmgr_psoc *psoc)
965 {
966 	return QDF_STATUS_E_NOSUPPORT;
967 }
968 #endif
969 
970 /**
971  * wlan_dp_link_cdp_vdev_delete_notification() - CDP vdev delete notification
972  * @context: osif_vdev handle
973  *
974  * Return: None
975  */
976 void wlan_dp_link_cdp_vdev_delete_notification(void *context);
977 
978 /* DP CFG APIs - START */
979 
980 #ifdef WLAN_SUPPORT_RX_FISA
981 /**
982  * wlan_dp_cfg_is_rx_fisa_enabled() - Get Rx FISA enabled flag
983  * @dp_cfg: soc configuration context
984  *
985  * Return: true if enabled, false otherwise.
986  */
987 static inline
wlan_dp_cfg_is_rx_fisa_enabled(struct wlan_dp_psoc_cfg * dp_cfg)988 bool wlan_dp_cfg_is_rx_fisa_enabled(struct wlan_dp_psoc_cfg *dp_cfg)
989 {
990 	return dp_cfg->is_rx_fisa_enabled;
991 }
992 
993 /**
994  * wlan_dp_cfg_is_rx_fisa_lru_del_enabled() - Get Rx FISA LRU del enabled flag
995  * @dp_cfg: soc configuration context
996  *
997  * Return: true if enabled, false otherwise.
998  */
999 static inline
wlan_dp_cfg_is_rx_fisa_lru_del_enabled(struct wlan_dp_psoc_cfg * dp_cfg)1000 bool wlan_dp_cfg_is_rx_fisa_lru_del_enabled(struct wlan_dp_psoc_cfg *dp_cfg)
1001 {
1002 	return dp_cfg->is_rx_fisa_lru_del_enabled;
1003 }
1004 #else
1005 static inline
wlan_dp_cfg_is_rx_fisa_enabled(struct wlan_dp_psoc_cfg * dp_cfg)1006 bool wlan_dp_cfg_is_rx_fisa_enabled(struct wlan_dp_psoc_cfg *dp_cfg)
1007 {
1008 	return false;
1009 }
1010 
1011 static inline
wlan_dp_cfg_is_rx_fisa_lru_del_enabled(struct wlan_dp_psoc_cfg * dp_cfg)1012 bool wlan_dp_cfg_is_rx_fisa_lru_del_enabled(struct wlan_dp_psoc_cfg *dp_cfg)
1013 {
1014 	return false;
1015 }
1016 #endif
1017 
1018 
1019 /* DP CFG APIs - END */
1020 /**
1021  * __wlan_dp_update_def_link() - update DP interface default link
1022  * @psoc: psoc handle
1023  * @intf_mac: interface MAC address
1024  * @vdev: objmgr vdev handle to set the def_link in dp_intf
1025  *
1026  */
1027 void __wlan_dp_update_def_link(struct wlan_objmgr_psoc *psoc,
1028 			       struct qdf_mac_addr *intf_mac,
1029 			       struct wlan_objmgr_vdev *vdev);
1030 #endif
1031