xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_flow_ctrl_v2.h (revision 1397a33f48ea6455be40871470b286e535820eb8)
1 /*
2  * Copyright (c) 2016-2018 The Linux Foundation. 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  * @file cdp_txrx_flow_ctrl_v2.h
21  * @brief Define the host data path flow control version 2 API
22  * functions
23  */
24 #ifndef _CDP_TXRX_FC_V2_H_
25 #define _CDP_TXRX_FC_V2_H_
26 #include <cdp_txrx_ops.h>
27 
28 /**
29  * cdp_register_pause_cb() - Register flow control callback function pointer
30  * @soc - data path soc handle
31  * @pause_cb - Pause callback intend to register
32  *
33  * Register flow control callback function pointer and client context pointer
34  *
35  * return QDF_STATUS_SUCCESS success
36  */
37 static inline QDF_STATUS
38 cdp_register_pause_cb(ol_txrx_soc_handle soc,
39 		tx_pause_callback pause_cb)
40 {
41 	if (!soc || !soc->ops) {
42 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
43 			"%s invalid instance", __func__);
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
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 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
71 			"%s invalid instance", __func__);
72 		QDF_BUG(0);
73 		return;
74 	}
75 
76 	if (!soc->ops->flowctl_ops ||
77 	    !soc->ops->flowctl_ops->set_desc_global_pool_size)
78 		return;
79 
80 	soc->ops->flowctl_ops->set_desc_global_pool_size(
81 			num_msdu_desc);
82 }
83 
84 /**
85  * cdp_dump_flow_pool_info() - dump flow pool information
86  * @soc - data path soc handle
87  *
88  * dump flow pool information
89  *
90  * return none
91  */
92 static inline void
93 cdp_dump_flow_pool_info(struct cdp_soc_t *soc)
94 {
95 	void *dp_soc = (void *)soc;
96 
97 	if (!soc || !soc->ops) {
98 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
99 			"%s invalid instance", __func__);
100 		QDF_BUG(0);
101 		return;
102 	}
103 
104 	if (!soc->ops->flowctl_ops ||
105 	    !soc->ops->flowctl_ops->dump_flow_pool_info)
106 		return;
107 
108 	soc->ops->flowctl_ops->dump_flow_pool_info(dp_soc);
109 }
110 
111 /**
112  * cdp_tx_desc_thresh_reached() - Check if avail tx desc meet threshold
113  * @soc - data path soc handle
114  * @vdev - dp vdev handle
115  *
116  * Return: true if threshold is met, false if not
117  */
118 static inline bool
119 cdp_tx_desc_thresh_reached(struct cdp_soc_t *soc, struct cdp_vdev *vdev)
120 {
121 	if (!soc || !soc->ops) {
122 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
123 			  "%s invalid instance", __func__);
124 		QDF_BUG(0);
125 		return false;
126 	}
127 
128 	if (!soc->ops->flowctl_ops ||
129 	    !soc->ops->flowctl_ops->tx_desc_thresh_reached)
130 		return false;
131 
132 	return soc->ops->flowctl_ops->tx_desc_thresh_reached(vdev);
133 }
134 #endif /* _CDP_TXRX_FC_V2_H_ */
135