1 /* 2 * Copyright (c) 2016-2017 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_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_ 26 #include <cdp_txrx_mob_def.h> 27 #include "cdp_txrx_handle.h" 28 29 /** 30 * cdp_fc_register() - Register flow control callback function pointer 31 * @soc - data path soc handle 32 * @vdev_id - virtual interface id to register flow control 33 * @flowControl - callback function pointer 34 * @osif_fc_ctx - client context pointer 35 * @flow_control_is_pause: is vdev paused by flow control 36 * 37 * Register flow control callback function pointer and client context pointer 38 * 39 * return 0 success 40 */ 41 static inline int 42 cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id, 43 ol_txrx_tx_flow_control_fp flowControl, void *osif_fc_ctx, 44 ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause) 45 { 46 if (!soc || !soc->ops) { 47 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 48 "%s invalid instance", __func__); 49 QDF_BUG(0); 50 return 0; 51 } 52 53 if (!soc->ops->l_flowctl_ops || 54 !soc->ops->l_flowctl_ops->register_tx_flow_control) 55 return 0; 56 57 return soc->ops->l_flowctl_ops->register_tx_flow_control( 58 vdev_id, flowControl, osif_fc_ctx, 59 flow_control_is_pause); 60 } 61 62 /** 63 * cdp_fc_deregister() - remove flow control instance 64 * @soc - data path soc handle 65 * @vdev_id - virtual interface id to register flow control 66 * 67 * remove flow control instance 68 * 69 * return 0 success 70 */ 71 static inline int 72 cdp_fc_deregister(ol_txrx_soc_handle soc, uint8_t vdev_id) 73 { 74 if (!soc || !soc->ops) { 75 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 76 "%s invalid instance", __func__); 77 QDF_BUG(0); 78 return 0; 79 } 80 81 if (!soc->ops->l_flowctl_ops || 82 !soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb) 83 return 0; 84 85 return soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb( 86 vdev_id); 87 } 88 89 /** 90 * cdp_fc_get_tx_resource() - get data path resource count 91 * @soc - data path soc handle 92 * @sta_id - local peer id 93 * @low_watermark - low resource threshold 94 * @high_watermark_offset - high resource threshold 95 * 96 * get data path resource count 97 * 98 * return true enough data path resource available 99 * false resource is not avaialbe 100 */ 101 static inline bool 102 cdp_fc_get_tx_resource(ol_txrx_soc_handle soc, uint8_t sta_id, 103 unsigned int low_watermark, unsigned int high_watermark_offset) 104 { 105 if (!soc || !soc->ops) { 106 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 107 "%s invalid instance", __func__); 108 QDF_BUG(0); 109 return false; 110 } 111 112 if (!soc->ops->l_flowctl_ops || 113 !soc->ops->l_flowctl_ops->get_tx_resource) 114 return false; 115 116 return soc->ops->l_flowctl_ops->get_tx_resource(sta_id, 117 low_watermark, high_watermark_offset); 118 } 119 120 /** 121 * cdp_fc_ll_set_tx_pause_q_depth() - set pause queue depth 122 * @soc - data path soc handle 123 * @vdev_id - virtual interface id to register flow control 124 * @pause_q_depth - pending tx queue delth 125 * 126 * set pause queue depth 127 * 128 * return 0 success 129 */ 130 static inline int 131 cdp_fc_ll_set_tx_pause_q_depth(ol_txrx_soc_handle soc, 132 uint8_t vdev_id, int pause_q_depth) 133 { 134 if (!soc || !soc->ops) { 135 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 136 "%s invalid instance", __func__); 137 QDF_BUG(0); 138 return 0; 139 } 140 141 if (!soc->ops->l_flowctl_ops || 142 !soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth) 143 return 0; 144 145 return soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth( 146 vdev_id, pause_q_depth); 147 148 } 149 150 /** 151 * cdp_fc_vdev_flush() - flush tx queue 152 * @soc - data path soc handle 153 * @vdev - virtual interface context pointer 154 * 155 * flush tx queue 156 * 157 * return None 158 */ 159 static inline void 160 cdp_fc_vdev_flush(ol_txrx_soc_handle soc, struct cdp_vdev *vdev) 161 { 162 if (!soc || !soc->ops) { 163 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 164 "%s invalid instance", __func__); 165 QDF_BUG(0); 166 return; 167 } 168 169 if (!soc->ops->l_flowctl_ops || 170 !soc->ops->l_flowctl_ops->vdev_flush) 171 return; 172 173 soc->ops->l_flowctl_ops->vdev_flush(vdev); 174 } 175 176 /** 177 * cdp_fc_vdev_pause() - pause tx scheduler on vdev 178 * @soc - data path soc handle 179 * @vdev - virtual interface context pointer 180 * @reason - pause reason 181 * 182 * pause tx scheduler on vdev 183 * 184 * return None 185 */ 186 static inline void 187 cdp_fc_vdev_pause(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 188 uint32_t reason) 189 { 190 if (!soc || !soc->ops) { 191 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 192 "%s invalid instance", __func__); 193 QDF_BUG(0); 194 return; 195 } 196 197 if (!soc->ops->l_flowctl_ops || 198 !soc->ops->l_flowctl_ops->vdev_pause) 199 return; 200 201 soc->ops->l_flowctl_ops->vdev_pause(vdev, reason); 202 } 203 204 /** 205 * cdp_fc_vdev_unpause() - resume tx scheduler on vdev 206 * @soc - data path soc handle 207 * @vdev - virtual interface context pointer 208 * @reason - pause reason 209 * 210 * resume tx scheduler on vdev 211 * 212 * return None 213 */ 214 static inline void 215 cdp_fc_vdev_unpause(ol_txrx_soc_handle soc, struct cdp_vdev *vdev, 216 uint32_t reason) 217 { 218 if (!soc || !soc->ops) { 219 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 220 "%s invalid instance", __func__); 221 return; 222 } 223 224 if (!soc->ops->l_flowctl_ops || 225 !soc->ops->l_flowctl_ops->vdev_unpause) 226 return; 227 228 soc->ops->l_flowctl_ops->vdev_unpause(vdev, reason); 229 } 230 #endif /* _CDP_TXRX_FC_LEG_H_ */ 231