blob: b00b905d3a9f7d8f1a9258f76f65b79bc410b463 [file] [log] [blame]
Dhanashri Atre9c222b12016-03-22 13:26:13 -07001/*
Rakshith Suresh Patkar8a0b6e92019-07-26 16:23:37 +05302 * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
Dhanashri Atre9c222b12016-03-22 13:26:13 -07003 *
Dhanashri Atre9c222b12016-03-22 13:26:13 -07004 * 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
Yun Park81e7dd62017-04-03 08:39:18 -070019/**
Dhanashri Atre9c222b12016-03-22 13:26:13 -070020 * @file cdp_txrx_flow_ctrl_legacy.h
21 * @brief Define the host data path legacy flow control API
22 * functions
23 */
24#ifndef _CDP_TXRX_FC_LEG_H_
25#define _CDP_TXRX_FC_LEG_H_
Leo Changdb6358c2016-09-27 17:00:52 -070026#include <cdp_txrx_mob_def.h>
Venkata Sharath Chandra Manchalaf2a125a2016-11-28 18:10:11 -080027#include "cdp_txrx_handle.h"
Dhanashri Atre9c222b12016-03-22 13:26:13 -070028
Ajit Pal Singhd1543e02018-04-19 15:02:22 +053029#ifdef QCA_HL_NETDEV_FLOW_CONTROL
30
31/**
32 * cdp_hl_fc_register() - Register HL flow control callback.
Rakesh Pillaid295d1e2019-09-11 08:00:36 +053033 * @soc: data path soc handle
34 * @pdev_id: datapath pdev identifier
35 * @flowcontrol: callback function pointer to stop/start OS netdev queues
36 *
Ajit Pal Singhd1543e02018-04-19 15:02:22 +053037 * Register flow control callback.
Rakesh Pillaid295d1e2019-09-11 08:00:36 +053038 *
39 * Returns: 0 for success
Ajit Pal Singhd1543e02018-04-19 15:02:22 +053040 */
41static inline int
Rakesh Pillaid295d1e2019-09-11 08:00:36 +053042cdp_hl_fc_register(ol_txrx_soc_handle soc, uint8_t pdev_id,
43 tx_pause_callback flowcontrol)
Ajit Pal Singhd1543e02018-04-19 15:02:22 +053044{
45 if (!soc || !soc->ops) {
46 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
47 "%s invalid instance", __func__);
48 QDF_BUG(0);
49 return -EINVAL;
50 }
51
52 if (!soc->ops->l_flowctl_ops ||
53 !soc->ops->l_flowctl_ops->register_tx_flow_control)
54 return -EINVAL;
55
Rakesh Pillaid295d1e2019-09-11 08:00:36 +053056 return soc->ops->l_flowctl_ops->register_tx_flow_control(soc, pdev_id,
Ajit Pal Singhd1543e02018-04-19 15:02:22 +053057 flowcontrol);
58}
Ajit Pal Singh506c4d62018-04-25 16:59:19 +053059
60static inline int cdp_hl_fc_set_td_limit(ol_txrx_soc_handle soc,
Yue Ma9c43a472019-11-12 12:51:02 -080061 uint8_t vdev_id, uint32_t chan_freq)
Ajit Pal Singh506c4d62018-04-25 16:59:19 +053062{
63 if (!soc->ops->l_flowctl_ops->set_vdev_tx_desc_limit)
64 return 0;
65
Rakesh Pillai20325542019-11-07 19:26:36 +053066 return soc->ops->l_flowctl_ops->set_vdev_tx_desc_limit(soc, vdev_id,
Yue Ma9c43a472019-11-12 12:51:02 -080067 chan_freq);
Ajit Pal Singh506c4d62018-04-25 16:59:19 +053068}
69
70static inline int cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,
Krunal Sonibe43d552018-10-03 11:20:20 -070071 uint8_t vdev_id,
Ajit Pal Singh506c4d62018-04-25 16:59:19 +053072 enum netif_action_type action)
73{
74 if (!soc->ops->l_flowctl_ops->set_vdev_os_queue_status)
75 return -EINVAL;
76
Rakesh Pillai20325542019-11-07 19:26:36 +053077 return soc->ops->l_flowctl_ops->set_vdev_os_queue_status(soc,
78 vdev_id,
Ajit Pal Singh506c4d62018-04-25 16:59:19 +053079 action);
80}
Ajit Pal Singhd1543e02018-04-19 15:02:22 +053081#else
82static inline int
Rakesh Pillaid295d1e2019-09-11 08:00:36 +053083cdp_hl_fc_register(ol_txrx_soc_handle soc, uint8_t pdev_id,
84 tx_pause_callback flowcontrol)
Ajit Pal Singhd1543e02018-04-19 15:02:22 +053085{
86 return 0;
87}
Ajit Pal Singh506c4d62018-04-25 16:59:19 +053088
89static inline int cdp_hl_fc_set_td_limit(ol_txrx_soc_handle soc,
Yue Ma9c43a472019-11-12 12:51:02 -080090 uint8_t vdev_id, uint32_t chan_freq)
Ajit Pal Singh506c4d62018-04-25 16:59:19 +053091{
92 return 0;
93}
94
95static inline int cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,
Krunal Sonibe43d552018-10-03 11:20:20 -070096 uint8_t vdev_id,
Ajit Pal Singh506c4d62018-04-25 16:59:19 +053097 enum netif_action_type action)
98{
99 return 0;
100}
101
Ajit Pal Singhd1543e02018-04-19 15:02:22 +0530102#endif /* QCA_HL_NETDEV_FLOW_CONTROL */
103
104#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700105/**
Leo Changdb6358c2016-09-27 17:00:52 -0700106 * cdp_fc_register() - Register flow control callback function pointer
107 * @soc - data path soc handle
108 * @vdev_id - virtual interface id to register flow control
109 * @flowControl - callback function pointer
110 * @osif_fc_ctx - client context pointer
bings4dcaf8b2017-08-11 10:37:46 +0800111 * @flow_control_is_pause: is vdev paused by flow control
Leo Changdb6358c2016-09-27 17:00:52 -0700112 *
113 * Register flow control callback function pointer and client context pointer
114 *
115 * return 0 success
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700116 */
Leo Changdb6358c2016-09-27 17:00:52 -0700117static inline int
118cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id,
Rakesh Pillai20325542019-11-07 19:26:36 +0530119 ol_txrx_tx_flow_control_fp flowcontrol, void *osif_fc_ctx,
bings4dcaf8b2017-08-11 10:37:46 +0800120 ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)
Yuanyuan Liu4e3feeb2016-04-20 10:41:15 -0700121{
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700122 if (!soc || !soc->ops) {
123 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Leo Changdb6358c2016-09-27 17:00:52 -0700124 "%s invalid instance", __func__);
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700125 QDF_BUG(0);
Leo Changdb6358c2016-09-27 17:00:52 -0700126 return 0;
127 }
128
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700129 if (!soc->ops->l_flowctl_ops ||
130 !soc->ops->l_flowctl_ops->register_tx_flow_control)
131 return 0;
132
133 return soc->ops->l_flowctl_ops->register_tx_flow_control(
Rakesh Pillai20325542019-11-07 19:26:36 +0530134 soc, vdev_id, flowcontrol, osif_fc_ctx,
bings4dcaf8b2017-08-11 10:37:46 +0800135 flow_control_is_pause);
Leo Changdb6358c2016-09-27 17:00:52 -0700136}
Ajit Pal Singhd1543e02018-04-19 15:02:22 +0530137#else
138static inline int
139cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id,
140 ol_txrx_tx_flow_control_fp flowcontrol, void *osif_fc_ctx,
141 ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)
142{
143 return 0;
144}
145#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
Leo Changdb6358c2016-09-27 17:00:52 -0700146/**
147 * cdp_fc_deregister() - remove flow control instance
148 * @soc - data path soc handle
149 * @vdev_id - virtual interface id to register flow control
150 *
151 * remove flow control instance
152 *
153 * return 0 success
154 */
155static inline int
156cdp_fc_deregister(ol_txrx_soc_handle soc, uint8_t vdev_id)
157{
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700158 if (!soc || !soc->ops) {
159 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Leo Changdb6358c2016-09-27 17:00:52 -0700160 "%s invalid instance", __func__);
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700161 QDF_BUG(0);
Leo Changdb6358c2016-09-27 17:00:52 -0700162 return 0;
163 }
164
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700165 if (!soc->ops->l_flowctl_ops ||
166 !soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb)
167 return 0;
Leo Changdb6358c2016-09-27 17:00:52 -0700168
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700169 return soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb(
Rakesh Pillai20325542019-11-07 19:26:36 +0530170 soc, vdev_id);
Leo Changdb6358c2016-09-27 17:00:52 -0700171}
172
173/**
174 * cdp_fc_get_tx_resource() - get data path resource count
Rakesh Pillai20325542019-11-07 19:26:36 +0530175 * @soc: data path soc handle
176 * @pdev_id: datapath pdev ID
177 * @peer_addr: peer mac address
178 * @low_watermark: low resource threshold
179 * @high_watermark_offset: high resource threshold
Leo Changdb6358c2016-09-27 17:00:52 -0700180 *
181 * get data path resource count
182 *
183 * return true enough data path resource available
184 * false resource is not avaialbe
185 */
186static inline bool
Rakesh Pillai20325542019-11-07 19:26:36 +0530187cdp_fc_get_tx_resource(ol_txrx_soc_handle soc, uint8_t pdev_id,
Rakshith Suresh Patkar8a0b6e92019-07-26 16:23:37 +0530188 struct qdf_mac_addr peer_addr,
189 unsigned int low_watermark,
190 unsigned int high_watermark_offset)
Leo Changdb6358c2016-09-27 17:00:52 -0700191{
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700192 if (!soc || !soc->ops) {
193 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Leo Changdb6358c2016-09-27 17:00:52 -0700194 "%s invalid instance", __func__);
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700195 QDF_BUG(0);
Leo Changdb6358c2016-09-27 17:00:52 -0700196 return false;
197 }
198
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700199 if (!soc->ops->l_flowctl_ops ||
200 !soc->ops->l_flowctl_ops->get_tx_resource)
201 return false;
Leo Changdb6358c2016-09-27 17:00:52 -0700202
Rakesh Pillai20325542019-11-07 19:26:36 +0530203 return soc->ops->l_flowctl_ops->get_tx_resource(soc, pdev_id, peer_addr,
204 low_watermark,
205 high_watermark_offset);
Leo Changdb6358c2016-09-27 17:00:52 -0700206}
207
208/**
209 * cdp_fc_ll_set_tx_pause_q_depth() - set pause queue depth
210 * @soc - data path soc handle
211 * @vdev_id - virtual interface id to register flow control
212 * @pause_q_depth - pending tx queue delth
213 *
214 * set pause queue depth
215 *
216 * return 0 success
217 */
218static inline int
219cdp_fc_ll_set_tx_pause_q_depth(ol_txrx_soc_handle soc,
220 uint8_t vdev_id, int pause_q_depth)
221{
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700222 if (!soc || !soc->ops) {
223 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Leo Changdb6358c2016-09-27 17:00:52 -0700224 "%s invalid instance", __func__);
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700225 QDF_BUG(0);
Leo Changdb6358c2016-09-27 17:00:52 -0700226 return 0;
227 }
228
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700229 if (!soc->ops->l_flowctl_ops ||
230 !soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth)
231 return 0;
Leo Changdb6358c2016-09-27 17:00:52 -0700232
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700233 return soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth(
Rakesh Pillai20325542019-11-07 19:26:36 +0530234 soc, vdev_id, pause_q_depth);
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700235
Leo Changdb6358c2016-09-27 17:00:52 -0700236}
237
238/**
239 * cdp_fc_vdev_flush() - flush tx queue
Rakesh Pillai20325542019-11-07 19:26:36 +0530240 * @soc: data path soc handle
241 * @vdev_id: id of vdev
Leo Changdb6358c2016-09-27 17:00:52 -0700242 *
243 * flush tx queue
244 *
245 * return None
246 */
247static inline void
Rakesh Pillai20325542019-11-07 19:26:36 +0530248cdp_fc_vdev_flush(ol_txrx_soc_handle soc, uint8_t vdev_id)
Leo Changdb6358c2016-09-27 17:00:52 -0700249{
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700250 if (!soc || !soc->ops) {
251 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Leo Changdb6358c2016-09-27 17:00:52 -0700252 "%s invalid instance", __func__);
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700253 QDF_BUG(0);
Leo Changdb6358c2016-09-27 17:00:52 -0700254 return;
255 }
256
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700257 if (!soc->ops->l_flowctl_ops ||
258 !soc->ops->l_flowctl_ops->vdev_flush)
259 return;
Leo Changdb6358c2016-09-27 17:00:52 -0700260
Rakesh Pillai20325542019-11-07 19:26:36 +0530261 soc->ops->l_flowctl_ops->vdev_flush(soc, vdev_id);
Yuanyuan Liu4e3feeb2016-04-20 10:41:15 -0700262}
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700263
Leo Changdb6358c2016-09-27 17:00:52 -0700264/**
265 * cdp_fc_vdev_pause() - pause tx scheduler on vdev
Rakesh Pillai20325542019-11-07 19:26:36 +0530266 * @soc: data path soc handle
267 * @vdev_id: id of vdev
268 * @reason: pause reason
269 * @pause_type: type of pause
Leo Changdb6358c2016-09-27 17:00:52 -0700270 *
271 * pause tx scheduler on vdev
272 *
273 * return None
274 */
275static inline void
Rakesh Pillai20325542019-11-07 19:26:36 +0530276cdp_fc_vdev_pause(ol_txrx_soc_handle soc, uint8_t vdev_id,
277 uint32_t reason, uint32_t pause_type)
Yuanyuan Liu4e3feeb2016-04-20 10:41:15 -0700278{
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700279 if (!soc || !soc->ops) {
280 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Leo Changdb6358c2016-09-27 17:00:52 -0700281 "%s invalid instance", __func__);
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700282 QDF_BUG(0);
Leo Changdb6358c2016-09-27 17:00:52 -0700283 return;
284 }
285
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700286 if (!soc->ops->l_flowctl_ops ||
287 !soc->ops->l_flowctl_ops->vdev_pause)
288 return;
Leo Changdb6358c2016-09-27 17:00:52 -0700289
Rakesh Pillai20325542019-11-07 19:26:36 +0530290 soc->ops->l_flowctl_ops->vdev_pause(soc, vdev_id, reason, pause_type);
Yuanyuan Liu4e3feeb2016-04-20 10:41:15 -0700291}
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700292
Leo Changdb6358c2016-09-27 17:00:52 -0700293/**
294 * cdp_fc_vdev_unpause() - resume tx scheduler on vdev
Rakesh Pillai20325542019-11-07 19:26:36 +0530295 * @soc: data path soc handle
296 * @vdev_id: id of vdev
297 * @reason: pause reason
298 * @pause_type: type of pause
Leo Changdb6358c2016-09-27 17:00:52 -0700299 *
300 * resume tx scheduler on vdev
301 *
302 * return None
303 */
304static inline void
Rakesh Pillai20325542019-11-07 19:26:36 +0530305cdp_fc_vdev_unpause(ol_txrx_soc_handle soc, uint8_t vdev_id,
306 uint32_t reason, uint32_t pause_type)
Leo Changdb6358c2016-09-27 17:00:52 -0700307{
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700308 if (!soc || !soc->ops) {
309 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Leo Changdb6358c2016-09-27 17:00:52 -0700310 "%s invalid instance", __func__);
311 return;
312 }
313
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700314 if (!soc->ops->l_flowctl_ops ||
315 !soc->ops->l_flowctl_ops->vdev_unpause)
316 return;
Leo Changdb6358c2016-09-27 17:00:52 -0700317
Rakesh Pillai20325542019-11-07 19:26:36 +0530318 soc->ops->l_flowctl_ops->vdev_unpause(soc, vdev_id, reason,
319 pause_type);
Leo Changdb6358c2016-09-27 17:00:52 -0700320}
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700321#endif /* _CDP_TXRX_FC_LEG_H_ */