xref: /wlan-driver/qca-wifi-host-cmn/dp/inc/cdp_txrx_flow_ctrl_v2.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2016-2019,2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: cdp_txrx_flow_ctrl_v2.h
22  * Define the host data path flow control version 2 API functions
23  */
24 #ifndef _CDP_TXRX_FC_V2_H_
25 #define _CDP_TXRX_FC_V2_H_
26 #include <cdp_txrx_ops.h>
27 #include <cdp_txrx_cmn.h>
28 
29 /**
30  * cdp_register_pause_cb() - Register flow control callback function pointer
31  * @soc: data path soc handle
32  * @pause_cb: Pause callback intend to register
33  *
34  * Register flow control callback function pointer and client context pointer
35  *
36  * return QDF_STATUS_SUCCESS success
37  */
38 static inline QDF_STATUS
cdp_register_pause_cb(ol_txrx_soc_handle soc,tx_pause_callback pause_cb)39 cdp_register_pause_cb(ol_txrx_soc_handle soc,
40 		tx_pause_callback pause_cb)
41 {
42 	if (!soc || !soc->ops) {
43 		dp_cdp_debug("invalid instance");
44 		QDF_BUG(0);
45 		return QDF_STATUS_E_INVAL;
46 	}
47 
48 	if (!soc->ops->flowctl_ops ||
49 	    !soc->ops->flowctl_ops->register_pause_cb)
50 		return QDF_STATUS_SUCCESS;
51 
52 	return soc->ops->flowctl_ops->register_pause_cb(soc, pause_cb);
53 
54 }
55 
56 /**
57  * cdp_set_desc_global_pool_size() - set global device pool size
58  * @soc: data path soc handle
59  * @num_msdu_desc: descriptor pool size
60  *
61  * set global device pool size
62  *
63  * return none
64  */
65 static inline void
cdp_set_desc_global_pool_size(ol_txrx_soc_handle soc,uint32_t num_msdu_desc)66 cdp_set_desc_global_pool_size(ol_txrx_soc_handle soc,
67 		uint32_t num_msdu_desc)
68 {
69 	if (!soc || !soc->ops) {
70 		dp_cdp_debug("invalid instance");
71 		QDF_BUG(0);
72 		return;
73 	}
74 
75 	if (!soc->ops->flowctl_ops ||
76 	    !soc->ops->flowctl_ops->set_desc_global_pool_size)
77 		return;
78 
79 	soc->ops->flowctl_ops->set_desc_global_pool_size(
80 			num_msdu_desc);
81 }
82 
83 /**
84  * cdp_dump_flow_pool_info() - dump flow pool information
85  * @soc: data path soc handle
86  *
87  * dump flow pool information
88  *
89  * return none
90  */
91 static inline void
cdp_dump_flow_pool_info(struct cdp_soc_t * soc)92 cdp_dump_flow_pool_info(struct cdp_soc_t *soc)
93 {
94 	if (!soc || !soc->ops) {
95 		dp_cdp_debug("invalid instance");
96 		QDF_BUG(0);
97 		return;
98 	}
99 
100 	if (!soc->ops->flowctl_ops ||
101 	    !soc->ops->flowctl_ops->dump_flow_pool_info)
102 		return;
103 
104 	soc->ops->flowctl_ops->dump_flow_pool_info(soc);
105 }
106 
107 /**
108  * cdp_tx_desc_thresh_reached() - Check if avail tx desc meet threshold
109  * @soc: data path soc handle
110  * @vdev_id: vdev_id corresponding to vdev start
111  *
112  * Return: true if threshold is met, false if not
113  */
114 static inline bool
cdp_tx_desc_thresh_reached(struct cdp_soc_t * soc,uint8_t vdev_id)115 cdp_tx_desc_thresh_reached(struct cdp_soc_t *soc, uint8_t vdev_id)
116 {
117 	if (!soc || !soc->ops) {
118 		dp_cdp_debug("invalid instance");
119 		QDF_BUG(0);
120 		return false;
121 	}
122 
123 	if (!soc->ops->flowctl_ops ||
124 	    !soc->ops->flowctl_ops->tx_desc_thresh_reached)
125 		return false;
126 
127 	return soc->ops->flowctl_ops->tx_desc_thresh_reached(soc, vdev_id);
128 }
129 #endif /* _CDP_TXRX_FC_V2_H_ */
130