1 /* 2 * Copyright (c) 2016-2019 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 if (!soc || !soc->ops) { 96 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, 97 "%s invalid instance", __func__); 98 QDF_BUG(0); 99 return; 100 } 101 102 if (!soc->ops->flowctl_ops || 103 !soc->ops->flowctl_ops->dump_flow_pool_info) 104 return; 105 106 soc->ops->flowctl_ops->dump_flow_pool_info(soc); 107 } 108 109 /** 110 * cdp_tx_desc_thresh_reached() - Check if avail tx desc meet threshold 111 * @soc: data path soc handle 112 * @vdev_id: vdev_id corresponding to vdev start 113 * 114 * Return: true if threshold is met, false if not 115 */ 116 static inline bool 117 cdp_tx_desc_thresh_reached(struct cdp_soc_t *soc, uint8_t vdev_id) 118 { 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 130 return soc->ops->flowctl_ops->tx_desc_thresh_reached(soc, vdev_id); 131 } 132 #endif /* _CDP_TXRX_FC_V2_H_ */ 133