cdp_txrx_flow_ctrl_legacy.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * @file cdp_txrx_flow_ctrl_legacy.h
  28. * @brief Define the host data path legacy flow control API
  29. * functions
  30. */
  31. #ifndef _CDP_TXRX_FC_LEG_H_
  32. #define _CDP_TXRX_FC_LEG_H_
  33. #include <cdp_txrx_mob_def.h>
  34. #include "cdp_txrx_handle.h"
  35. /**
  36. * cdp_fc_register() - Register flow control callback function pointer
  37. * @soc - data path soc handle
  38. * @vdev_id - virtual interface id to register flow control
  39. * @flowControl - callback function pointer
  40. * @osif_fc_ctx - client context pointer
  41. *
  42. * Register flow control callback function pointer and client context pointer
  43. *
  44. * return 0 success
  45. */
  46. static inline int
  47. cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id,
  48. ol_txrx_tx_flow_control_fp flowControl, void *osif_fc_ctx)
  49. {
  50. if (!soc || !soc->ops || !soc->ops->l_flowctl_ops) {
  51. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  52. "%s invalid instance", __func__);
  53. return 0;
  54. }
  55. if (soc->ops->l_flowctl_ops->register_tx_flow_control)
  56. return soc->ops->l_flowctl_ops->register_tx_flow_control(
  57. vdev_id, flowControl, osif_fc_ctx);
  58. return 0;
  59. }
  60. /**
  61. * cdp_fc_deregister() - remove flow control instance
  62. * @soc - data path soc handle
  63. * @vdev_id - virtual interface id to register flow control
  64. *
  65. * remove flow control instance
  66. *
  67. * return 0 success
  68. */
  69. static inline int
  70. cdp_fc_deregister(ol_txrx_soc_handle soc, uint8_t vdev_id)
  71. {
  72. if (!soc || !soc->ops || !soc->ops->l_flowctl_ops) {
  73. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  74. "%s invalid instance", __func__);
  75. return 0;
  76. }
  77. if (soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb)
  78. return soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb(
  79. vdev_id);
  80. return 0;
  81. }
  82. /**
  83. * cdp_fc_get_tx_resource() - get data path resource count
  84. * @soc - data path soc handle
  85. * @sta_id - local peer id
  86. * @low_watermark - low resource threshold
  87. * @high_watermark_offset - high resource threshold
  88. *
  89. * get data path resource count
  90. *
  91. * return true enough data path resource available
  92. * false resource is not avaialbe
  93. */
  94. static inline bool
  95. cdp_fc_get_tx_resource(ol_txrx_soc_handle soc, uint8_t sta_id,
  96. unsigned int low_watermark, unsigned int high_watermark_offset)
  97. {
  98. if (!soc || !soc->ops || !soc->ops->l_flowctl_ops) {
  99. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  100. "%s invalid instance", __func__);
  101. return false;
  102. }
  103. if (soc->ops->l_flowctl_ops->get_tx_resource)
  104. return soc->ops->l_flowctl_ops->get_tx_resource(sta_id,
  105. low_watermark, high_watermark_offset);
  106. return false;
  107. }
  108. /**
  109. * cdp_fc_ll_set_tx_pause_q_depth() - set pause queue depth
  110. * @soc - data path soc handle
  111. * @vdev_id - virtual interface id to register flow control
  112. * @pause_q_depth - pending tx queue delth
  113. *
  114. * set pause queue depth
  115. *
  116. * return 0 success
  117. */
  118. static inline int
  119. cdp_fc_ll_set_tx_pause_q_depth(ol_txrx_soc_handle soc,
  120. uint8_t vdev_id, int pause_q_depth)
  121. {
  122. if (!soc || !soc->ops || !soc->ops->l_flowctl_ops) {
  123. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  124. "%s invalid instance", __func__);
  125. return 0;
  126. }
  127. if (soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth)
  128. return soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth(vdev_id,
  129. pause_q_depth);
  130. return 0;
  131. }
  132. /**
  133. * cdp_fc_vdev_flush() - flush tx queue
  134. * @soc - data path soc handle
  135. * @vdev - virtual interface context pointer
  136. *
  137. * flush tx queue
  138. *
  139. * return None
  140. */
  141. static inline void
  142. cdp_fc_vdev_flush(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  143. {
  144. if (!soc || !soc->ops || !soc->ops->l_flowctl_ops) {
  145. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  146. "%s invalid instance", __func__);
  147. return;
  148. }
  149. if (soc->ops->l_flowctl_ops->vdev_flush)
  150. return soc->ops->l_flowctl_ops->vdev_flush(vdev);
  151. return;
  152. }
  153. /**
  154. * cdp_fc_vdev_pause() - pause tx scheduler on vdev
  155. * @soc - data path soc handle
  156. * @vdev - virtual interface context pointer
  157. * @reason - pause reason
  158. *
  159. * pause tx scheduler on vdev
  160. *
  161. * return None
  162. */
  163. static inline void
  164. cdp_fc_vdev_pause(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  165. uint32_t reason)
  166. {
  167. if (!soc || !soc->ops || !soc->ops->l_flowctl_ops) {
  168. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  169. "%s invalid instance", __func__);
  170. return;
  171. }
  172. if (soc->ops->l_flowctl_ops->vdev_pause)
  173. return soc->ops->l_flowctl_ops->vdev_pause(vdev, reason);
  174. return;
  175. }
  176. /**
  177. * cdp_fc_vdev_unpause() - resume tx scheduler on vdev
  178. * @soc - data path soc handle
  179. * @vdev - virtual interface context pointer
  180. * @reason - pause reason
  181. *
  182. * resume tx scheduler on vdev
  183. *
  184. * return None
  185. */
  186. static inline void
  187. cdp_fc_vdev_unpause(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  188. uint32_t reason)
  189. {
  190. if (!soc || !soc->ops || !soc->ops->l_flowctl_ops) {
  191. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
  192. "%s invalid instance", __func__);
  193. return;
  194. }
  195. if (soc->ops->l_flowctl_ops->vdev_unpause)
  196. return soc->ops->l_flowctl_ops->vdev_unpause(vdev, reason);
  197. return;
  198. }
  199. #endif /* _CDP_TXRX_FC_LEG_H_ */