cdp_txrx_flow_ctrl_legacy.h 5.8 KB

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