xref: /wlan-driver/qca-wifi-host-cmn/dp/inc/cdp_txrx_flow_ctrl_legacy.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2016-2019,2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name /**
21*5113495bSYour Name  * DOC: cdp_txrx_flow_ctrl_legacy.h
22*5113495bSYour Name  * Define the host data path legacy flow control API functions
23*5113495bSYour Name  */
24*5113495bSYour Name #ifndef _CDP_TXRX_FC_LEG_H_
25*5113495bSYour Name #define _CDP_TXRX_FC_LEG_H_
26*5113495bSYour Name #include <cdp_txrx_mob_def.h>
27*5113495bSYour Name #include "cdp_txrx_handle.h"
28*5113495bSYour Name #include <cdp_txrx_cmn.h>
29*5113495bSYour Name #ifdef QCA_HL_NETDEV_FLOW_CONTROL
30*5113495bSYour Name 
31*5113495bSYour Name /**
32*5113495bSYour Name  * cdp_hl_fc_register() - Register HL flow control callback.
33*5113495bSYour Name  * @soc: data path soc handle
34*5113495bSYour Name  * @pdev_id: datapath pdev identifier
35*5113495bSYour Name  * @flowcontrol: callback function pointer to stop/start OS netdev queues
36*5113495bSYour Name  *
37*5113495bSYour Name  * Register flow control callback.
38*5113495bSYour Name  *
39*5113495bSYour Name  * Return: 0 for success
40*5113495bSYour Name  */
41*5113495bSYour Name static inline int
cdp_hl_fc_register(ol_txrx_soc_handle soc,uint8_t pdev_id,tx_pause_callback flowcontrol)42*5113495bSYour Name cdp_hl_fc_register(ol_txrx_soc_handle soc, uint8_t pdev_id,
43*5113495bSYour Name 		   tx_pause_callback flowcontrol)
44*5113495bSYour Name {
45*5113495bSYour Name 	if (!soc || !soc->ops) {
46*5113495bSYour Name 		dp_cdp_debug("invalid instance");
47*5113495bSYour Name 		QDF_BUG(0);
48*5113495bSYour Name 		return -EINVAL;
49*5113495bSYour Name 	}
50*5113495bSYour Name 
51*5113495bSYour Name 	if (!soc->ops->l_flowctl_ops ||
52*5113495bSYour Name 	    !soc->ops->l_flowctl_ops->register_tx_flow_control)
53*5113495bSYour Name 		return -EINVAL;
54*5113495bSYour Name 
55*5113495bSYour Name 	return soc->ops->l_flowctl_ops->register_tx_flow_control(soc, pdev_id,
56*5113495bSYour Name 								 flowcontrol);
57*5113495bSYour Name }
58*5113495bSYour Name 
cdp_hl_fc_set_td_limit(ol_txrx_soc_handle soc,uint8_t vdev_id,uint32_t chan_freq)59*5113495bSYour Name static inline int cdp_hl_fc_set_td_limit(ol_txrx_soc_handle soc,
60*5113495bSYour Name 					 uint8_t vdev_id, uint32_t chan_freq)
61*5113495bSYour Name {
62*5113495bSYour Name 	if (!soc->ops->l_flowctl_ops->set_vdev_tx_desc_limit)
63*5113495bSYour Name 		return 0;
64*5113495bSYour Name 
65*5113495bSYour Name 	return soc->ops->l_flowctl_ops->set_vdev_tx_desc_limit(soc, vdev_id,
66*5113495bSYour Name 							       chan_freq);
67*5113495bSYour Name }
68*5113495bSYour Name 
cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,uint8_t vdev_id,enum netif_action_type action)69*5113495bSYour Name static inline int cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,
70*5113495bSYour Name 						uint8_t vdev_id,
71*5113495bSYour Name 					    enum netif_action_type action)
72*5113495bSYour Name {
73*5113495bSYour Name 	if (!soc->ops->l_flowctl_ops->set_vdev_os_queue_status)
74*5113495bSYour Name 		return -EINVAL;
75*5113495bSYour Name 
76*5113495bSYour Name 	return soc->ops->l_flowctl_ops->set_vdev_os_queue_status(soc,
77*5113495bSYour Name 								 vdev_id,
78*5113495bSYour Name 								 action);
79*5113495bSYour Name }
80*5113495bSYour Name #else
81*5113495bSYour Name static inline int
cdp_hl_fc_register(ol_txrx_soc_handle soc,uint8_t pdev_id,tx_pause_callback flowcontrol)82*5113495bSYour Name cdp_hl_fc_register(ol_txrx_soc_handle soc, uint8_t pdev_id,
83*5113495bSYour Name 		   tx_pause_callback flowcontrol)
84*5113495bSYour Name {
85*5113495bSYour Name 	return 0;
86*5113495bSYour Name }
87*5113495bSYour Name 
cdp_hl_fc_set_td_limit(ol_txrx_soc_handle soc,uint8_t vdev_id,uint32_t chan_freq)88*5113495bSYour Name static inline int cdp_hl_fc_set_td_limit(ol_txrx_soc_handle soc,
89*5113495bSYour Name 					 uint8_t vdev_id, uint32_t chan_freq)
90*5113495bSYour Name {
91*5113495bSYour Name 	return 0;
92*5113495bSYour Name }
93*5113495bSYour Name 
cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,uint8_t vdev_id,enum netif_action_type action)94*5113495bSYour Name static inline int cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,
95*5113495bSYour Name 						uint8_t vdev_id,
96*5113495bSYour Name 						enum netif_action_type action)
97*5113495bSYour Name {
98*5113495bSYour Name 	return 0;
99*5113495bSYour Name }
100*5113495bSYour Name 
101*5113495bSYour Name #endif /* QCA_HL_NETDEV_FLOW_CONTROL */
102*5113495bSYour Name 
103*5113495bSYour Name #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
104*5113495bSYour Name /**
105*5113495bSYour Name  * cdp_fc_register() - Register flow control callback function pointer
106*5113495bSYour Name  * @soc: data path soc handle
107*5113495bSYour Name  * @vdev_id: virtual interface id to register flow control
108*5113495bSYour Name  * @flowcontrol: callback function pointer
109*5113495bSYour Name  * @osif_fc_ctx: client context pointer
110*5113495bSYour Name  * @flow_control_is_pause: is vdev paused by flow control
111*5113495bSYour Name  *
112*5113495bSYour Name  * Register flow control callback function pointer and client context pointer
113*5113495bSYour Name  *
114*5113495bSYour Name  * Return: 0 success
115*5113495bSYour Name  */
116*5113495bSYour Name static inline int
cdp_fc_register(ol_txrx_soc_handle soc,uint8_t vdev_id,ol_txrx_tx_flow_control_fp flowcontrol,void * osif_fc_ctx,ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)117*5113495bSYour Name cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id,
118*5113495bSYour Name 		ol_txrx_tx_flow_control_fp flowcontrol, void *osif_fc_ctx,
119*5113495bSYour Name 		ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)
120*5113495bSYour Name {
121*5113495bSYour Name 	if (!soc || !soc->ops) {
122*5113495bSYour Name 		dp_cdp_debug("invalid instance");
123*5113495bSYour Name 		QDF_BUG(0);
124*5113495bSYour Name 		return 0;
125*5113495bSYour Name 	}
126*5113495bSYour Name 
127*5113495bSYour Name 	if (!soc->ops->l_flowctl_ops ||
128*5113495bSYour Name 	    !soc->ops->l_flowctl_ops->register_tx_flow_control)
129*5113495bSYour Name 		return 0;
130*5113495bSYour Name 
131*5113495bSYour Name 	return soc->ops->l_flowctl_ops->register_tx_flow_control(
132*5113495bSYour Name 			soc, vdev_id, flowcontrol, osif_fc_ctx,
133*5113495bSYour Name 			flow_control_is_pause);
134*5113495bSYour Name }
135*5113495bSYour Name #else
136*5113495bSYour Name static inline int
cdp_fc_register(ol_txrx_soc_handle soc,uint8_t vdev_id,ol_txrx_tx_flow_control_fp flowcontrol,void * osif_fc_ctx,ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)137*5113495bSYour Name cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id,
138*5113495bSYour Name 		ol_txrx_tx_flow_control_fp flowcontrol, void *osif_fc_ctx,
139*5113495bSYour Name 		ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)
140*5113495bSYour Name {
141*5113495bSYour Name 	return 0;
142*5113495bSYour Name }
143*5113495bSYour Name #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
144*5113495bSYour Name /**
145*5113495bSYour Name  * cdp_fc_deregister() - remove flow control instance
146*5113495bSYour Name  * @soc: data path soc handle
147*5113495bSYour Name  * @vdev_id: virtual interface id to register flow control
148*5113495bSYour Name  *
149*5113495bSYour Name  * remove flow control instance
150*5113495bSYour Name  *
151*5113495bSYour Name  * Return: 0 success
152*5113495bSYour Name  */
153*5113495bSYour Name static inline int
cdp_fc_deregister(ol_txrx_soc_handle soc,uint8_t vdev_id)154*5113495bSYour Name cdp_fc_deregister(ol_txrx_soc_handle soc, uint8_t vdev_id)
155*5113495bSYour Name {
156*5113495bSYour Name 	if (!soc || !soc->ops) {
157*5113495bSYour Name 		dp_cdp_debug("invalid instance");
158*5113495bSYour Name 		QDF_BUG(0);
159*5113495bSYour Name 		return 0;
160*5113495bSYour Name 	}
161*5113495bSYour Name 
162*5113495bSYour Name 	if (!soc->ops->l_flowctl_ops ||
163*5113495bSYour Name 	    !soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb)
164*5113495bSYour Name 		return 0;
165*5113495bSYour Name 
166*5113495bSYour Name 	return soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb(
167*5113495bSYour Name 			soc, vdev_id);
168*5113495bSYour Name }
169*5113495bSYour Name 
170*5113495bSYour Name /**
171*5113495bSYour Name  * cdp_fc_get_tx_resource() - get data path resource count
172*5113495bSYour Name  * @soc: data path soc handle
173*5113495bSYour Name  * @pdev_id: datapath pdev ID
174*5113495bSYour Name  * @peer_addr: peer mac address
175*5113495bSYour Name  * @low_watermark: low resource threshold
176*5113495bSYour Name  * @high_watermark_offset: high resource threshold
177*5113495bSYour Name  *
178*5113495bSYour Name  * get data path resource count
179*5113495bSYour Name  *
180*5113495bSYour Name  * Return: true enough data path resource available
181*5113495bSYour Name  *        false resource is not available
182*5113495bSYour Name  */
183*5113495bSYour Name static inline bool
cdp_fc_get_tx_resource(ol_txrx_soc_handle soc,uint8_t pdev_id,struct qdf_mac_addr peer_addr,unsigned int low_watermark,unsigned int high_watermark_offset)184*5113495bSYour Name cdp_fc_get_tx_resource(ol_txrx_soc_handle soc, uint8_t pdev_id,
185*5113495bSYour Name 		       struct qdf_mac_addr peer_addr,
186*5113495bSYour Name 		       unsigned int low_watermark,
187*5113495bSYour Name 		       unsigned int high_watermark_offset)
188*5113495bSYour Name {
189*5113495bSYour Name 	if (!soc || !soc->ops) {
190*5113495bSYour Name 		dp_cdp_debug("invalid instance");
191*5113495bSYour Name 		QDF_BUG(0);
192*5113495bSYour Name 		return false;
193*5113495bSYour Name 	}
194*5113495bSYour Name 
195*5113495bSYour Name 	if (!soc->ops->l_flowctl_ops ||
196*5113495bSYour Name 	    !soc->ops->l_flowctl_ops->get_tx_resource)
197*5113495bSYour Name 		return false;
198*5113495bSYour Name 
199*5113495bSYour Name 	return soc->ops->l_flowctl_ops->get_tx_resource(soc, pdev_id, peer_addr,
200*5113495bSYour Name 							low_watermark,
201*5113495bSYour Name 							high_watermark_offset);
202*5113495bSYour Name }
203*5113495bSYour Name 
204*5113495bSYour Name /**
205*5113495bSYour Name  * cdp_fc_ll_set_tx_pause_q_depth() - set pause queue depth
206*5113495bSYour Name  * @soc: data path soc handle
207*5113495bSYour Name  * @vdev_id: virtual interface id to register flow control
208*5113495bSYour Name  * @pause_q_depth: pending tx queue delth
209*5113495bSYour Name  *
210*5113495bSYour Name  * set pause queue depth
211*5113495bSYour Name  *
212*5113495bSYour Name  * Return: 0 success
213*5113495bSYour Name  */
214*5113495bSYour Name static inline int
cdp_fc_ll_set_tx_pause_q_depth(ol_txrx_soc_handle soc,uint8_t vdev_id,int pause_q_depth)215*5113495bSYour Name cdp_fc_ll_set_tx_pause_q_depth(ol_txrx_soc_handle soc,
216*5113495bSYour Name 		uint8_t vdev_id, int pause_q_depth)
217*5113495bSYour Name {
218*5113495bSYour Name 	if (!soc || !soc->ops) {
219*5113495bSYour Name 		dp_cdp_debug("invalid instance");
220*5113495bSYour Name 		QDF_BUG(0);
221*5113495bSYour Name 		return 0;
222*5113495bSYour Name 	}
223*5113495bSYour Name 
224*5113495bSYour Name 	if (!soc->ops->l_flowctl_ops ||
225*5113495bSYour Name 	    !soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth)
226*5113495bSYour Name 		return 0;
227*5113495bSYour Name 
228*5113495bSYour Name 	return soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth(
229*5113495bSYour Name 			soc, vdev_id, pause_q_depth);
230*5113495bSYour Name 
231*5113495bSYour Name }
232*5113495bSYour Name 
233*5113495bSYour Name /**
234*5113495bSYour Name  * cdp_fc_vdev_flush() - flush tx queue
235*5113495bSYour Name  * @soc: data path soc handle
236*5113495bSYour Name  * @vdev_id: id of vdev
237*5113495bSYour Name  *
238*5113495bSYour Name  * flush tx queue
239*5113495bSYour Name  *
240*5113495bSYour Name  * Return: None
241*5113495bSYour Name  */
242*5113495bSYour Name static inline void
cdp_fc_vdev_flush(ol_txrx_soc_handle soc,uint8_t vdev_id)243*5113495bSYour Name cdp_fc_vdev_flush(ol_txrx_soc_handle soc, uint8_t vdev_id)
244*5113495bSYour Name {
245*5113495bSYour Name 	if (!soc || !soc->ops) {
246*5113495bSYour Name 		dp_cdp_debug("invalid instance");
247*5113495bSYour Name 		QDF_BUG(0);
248*5113495bSYour Name 		return;
249*5113495bSYour Name 	}
250*5113495bSYour Name 
251*5113495bSYour Name 	if (!soc->ops->l_flowctl_ops ||
252*5113495bSYour Name 	    !soc->ops->l_flowctl_ops->vdev_flush)
253*5113495bSYour Name 		return;
254*5113495bSYour Name 
255*5113495bSYour Name 	soc->ops->l_flowctl_ops->vdev_flush(soc, vdev_id);
256*5113495bSYour Name }
257*5113495bSYour Name 
258*5113495bSYour Name /**
259*5113495bSYour Name  * cdp_fc_vdev_pause() - pause tx scheduler on vdev
260*5113495bSYour Name  * @soc: data path soc handle
261*5113495bSYour Name  * @vdev_id: id of vdev
262*5113495bSYour Name  * @reason: pause reason
263*5113495bSYour Name  * @pause_type: type of pause
264*5113495bSYour Name  *
265*5113495bSYour Name  * pause tx scheduler on vdev
266*5113495bSYour Name  *
267*5113495bSYour Name  * Return: None
268*5113495bSYour Name  */
269*5113495bSYour Name static inline void
cdp_fc_vdev_pause(ol_txrx_soc_handle soc,uint8_t vdev_id,uint32_t reason,uint32_t pause_type)270*5113495bSYour Name cdp_fc_vdev_pause(ol_txrx_soc_handle soc, uint8_t vdev_id,
271*5113495bSYour Name 		  uint32_t reason, uint32_t pause_type)
272*5113495bSYour Name {
273*5113495bSYour Name 	if (!soc || !soc->ops) {
274*5113495bSYour Name 		dp_cdp_debug("invalid instance");
275*5113495bSYour Name 		QDF_BUG(0);
276*5113495bSYour Name 		return;
277*5113495bSYour Name 	}
278*5113495bSYour Name 
279*5113495bSYour Name 	if (!soc->ops->l_flowctl_ops ||
280*5113495bSYour Name 	    !soc->ops->l_flowctl_ops->vdev_pause)
281*5113495bSYour Name 		return;
282*5113495bSYour Name 
283*5113495bSYour Name 	soc->ops->l_flowctl_ops->vdev_pause(soc, vdev_id, reason, pause_type);
284*5113495bSYour Name }
285*5113495bSYour Name 
286*5113495bSYour Name /**
287*5113495bSYour Name  * cdp_fc_vdev_unpause() - resume tx scheduler on vdev
288*5113495bSYour Name  * @soc: data path soc handle
289*5113495bSYour Name  * @vdev_id: id of vdev
290*5113495bSYour Name  * @reason: pause reason
291*5113495bSYour Name  * @pause_type: type of pause
292*5113495bSYour Name  *
293*5113495bSYour Name  * resume tx scheduler on vdev
294*5113495bSYour Name  *
295*5113495bSYour Name  * Return: None
296*5113495bSYour Name  */
297*5113495bSYour Name static inline void
cdp_fc_vdev_unpause(ol_txrx_soc_handle soc,uint8_t vdev_id,uint32_t reason,uint32_t pause_type)298*5113495bSYour Name cdp_fc_vdev_unpause(ol_txrx_soc_handle soc, uint8_t vdev_id,
299*5113495bSYour Name 		    uint32_t reason, uint32_t pause_type)
300*5113495bSYour Name {
301*5113495bSYour Name 	if (!soc || !soc->ops) {
302*5113495bSYour Name 		dp_cdp_debug("invalid instance");
303*5113495bSYour Name 		return;
304*5113495bSYour Name 	}
305*5113495bSYour Name 
306*5113495bSYour Name 	if (!soc->ops->l_flowctl_ops ||
307*5113495bSYour Name 	    !soc->ops->l_flowctl_ops->vdev_unpause)
308*5113495bSYour Name 		return;
309*5113495bSYour Name 
310*5113495bSYour Name 	soc->ops->l_flowctl_ops->vdev_unpause(soc, vdev_id, reason,
311*5113495bSYour Name 					      pause_type);
312*5113495bSYour Name }
313*5113495bSYour Name #endif /* _CDP_TXRX_FC_LEG_H_ */
314