blob: 630b8b9060116a08e9ab8d449eef8cb933fd17eb [file] [log] [blame]
Dhanashri Atre9c222b12016-03-22 13:26:13 -07001/*
Rakesh Pillaidce01372019-06-28 19:11:23 +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 Park3e665982017-04-03 08:37:57 -070019/**
Dhanashri Atre9c222b12016-03-22 13:26:13 -070020 * @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_
Leo Changdb6358c2016-09-27 17:00:52 -070026#include <cdp_txrx_ops.h>
Dhanashri Atre9c222b12016-03-22 13:26:13 -070027
28/**
Leo Changdb6358c2016-09-27 17:00:52 -070029 * cdp_register_pause_cb() - Register flow control callback function pointer
30 * @soc - data path soc handle
Manjunathappa Prakashced7ea62017-07-02 03:02:15 -070031 * @pause_cb - Pause callback intend to register
Leo Changdb6358c2016-09-27 17:00:52 -070032 *
33 * Register flow control callback function pointer and client context pointer
34 *
35 * return QDF_STATUS_SUCCESS success
Dhanashri Atre9c222b12016-03-22 13:26:13 -070036 */
Leo Changdb6358c2016-09-27 17:00:52 -070037static inline QDF_STATUS
38cdp_register_pause_cb(ol_txrx_soc_handle soc,
Manjunathappa Prakashced7ea62017-07-02 03:02:15 -070039 tx_pause_callback pause_cb)
Dhanashri Atre9c222b12016-03-22 13:26:13 -070040{
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -070041 if (!soc || !soc->ops) {
42 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Leo Changdb6358c2016-09-27 17:00:52 -070043 "%s invalid instance", __func__);
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -070044 QDF_BUG(0);
Leo Changdb6358c2016-09-27 17:00:52 -070045 return QDF_STATUS_E_INVAL;
46 }
Dhanashri Atre9c222b12016-03-22 13:26:13 -070047
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -070048 if (!soc->ops->flowctl_ops ||
49 !soc->ops->flowctl_ops->register_pause_cb)
50 return QDF_STATUS_SUCCESS;
Leo Changdb6358c2016-09-27 17:00:52 -070051
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -070052 return soc->ops->flowctl_ops->register_pause_cb(soc, pause_cb);
53
Dhanashri Atre9c222b12016-03-22 13:26:13 -070054}
55
Leo Changdb6358c2016-09-27 17:00:52 -070056/**
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 */
65static inline void
66cdp_set_desc_global_pool_size(ol_txrx_soc_handle soc,
67 uint32_t num_msdu_desc)
Dhanashri Atre9c222b12016-03-22 13:26:13 -070068{
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -070069 if (!soc || !soc->ops) {
70 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Leo Changdb6358c2016-09-27 17:00:52 -070071 "%s invalid instance", __func__);
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -070072 QDF_BUG(0);
Leo Changdb6358c2016-09-27 17:00:52 -070073 return;
74 }
75
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -070076 if (!soc->ops->flowctl_ops ||
77 !soc->ops->flowctl_ops->set_desc_global_pool_size)
78 return;
Leo Changdb6358c2016-09-27 17:00:52 -070079
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -070080 soc->ops->flowctl_ops->set_desc_global_pool_size(
81 num_msdu_desc);
Dhanashri Atre9c222b12016-03-22 13:26:13 -070082}
Leo Changdb6358c2016-09-27 17:00:52 -070083
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 */
92static inline void
Manjunathappa Prakashced7ea62017-07-02 03:02:15 -070093cdp_dump_flow_pool_info(struct cdp_soc_t *soc)
Leo Changdb6358c2016-09-27 17:00:52 -070094{
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -070095 if (!soc || !soc->ops) {
96 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Leo Changdb6358c2016-09-27 17:00:52 -070097 "%s invalid instance", __func__);
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -070098 QDF_BUG(0);
Leo Changdb6358c2016-09-27 17:00:52 -070099 return;
100 }
101
Venkata Sharath Chandra Manchalaaa62ae72017-10-20 00:00:54 -0700102 if (!soc->ops->flowctl_ops ||
103 !soc->ops->flowctl_ops->dump_flow_pool_info)
104 return;
Manjunathappa Prakashced7ea62017-07-02 03:02:15 -0700105
Rakesh Pillaidce01372019-06-28 19:11:23 +0530106 soc->ops->flowctl_ops->dump_flow_pool_info(soc);
Leo Changdb6358c2016-09-27 17:00:52 -0700107}
Sravan Kumar Kairamb75565e2018-12-17 17:55:44 +0530108
109/**
110 * cdp_tx_desc_thresh_reached() - Check if avail tx desc meet threshold
Rakesh Pillaidce01372019-06-28 19:11:23 +0530111 * @soc: data path soc handle
112 * @vdev_id: vdev_id corresponding to vdev start
Sravan Kumar Kairamb75565e2018-12-17 17:55:44 +0530113 *
114 * Return: true if threshold is met, false if not
115 */
116static inline bool
Rakesh Pillaidce01372019-06-28 19:11:23 +0530117cdp_tx_desc_thresh_reached(struct cdp_soc_t *soc, uint8_t vdev_id)
Sravan Kumar Kairamb75565e2018-12-17 17:55:44 +0530118{
119 if (!soc || !soc->ops) {
120 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
121 "%s invalid instance", __func__);
122 QDF_BUG(0);
123 return false;
124 }
125
126 if (!soc->ops->flowctl_ops ||
127 !soc->ops->flowctl_ops->tx_desc_thresh_reached)
128 return false;
129
Rakesh Pillaidce01372019-06-28 19:11:23 +0530130 return soc->ops->flowctl_ops->tx_desc_thresh_reached(soc, vdev_id);
Sravan Kumar Kairamb75565e2018-12-17 17:55:44 +0530131}
Dhanashri Atre9c222b12016-03-22 13:26:13 -0700132#endif /* _CDP_TXRX_FC_V2_H_ */