cdp_txrx_flow_ctrl_legacy.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. * @flow_control_is_pause: is vdev paused by flow control
  42. *
  43. * Register flow control callback function pointer and client context pointer
  44. *
  45. * return 0 success
  46. */
  47. static inline int
  48. cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id,
  49. ol_txrx_tx_flow_control_fp flowControl, void *osif_fc_ctx,
  50. ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)
  51. {
  52. if (!soc || !soc->ops) {
  53. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  54. "%s invalid instance", __func__);
  55. QDF_BUG(0);
  56. return 0;
  57. }
  58. if (!soc->ops->l_flowctl_ops ||
  59. !soc->ops->l_flowctl_ops->register_tx_flow_control)
  60. return 0;
  61. return soc->ops->l_flowctl_ops->register_tx_flow_control(
  62. vdev_id, flowControl, osif_fc_ctx,
  63. flow_control_is_pause);
  64. }
  65. /**
  66. * cdp_fc_deregister() - remove flow control instance
  67. * @soc - data path soc handle
  68. * @vdev_id - virtual interface id to register flow control
  69. *
  70. * remove flow control instance
  71. *
  72. * return 0 success
  73. */
  74. static inline int
  75. cdp_fc_deregister(ol_txrx_soc_handle soc, uint8_t vdev_id)
  76. {
  77. if (!soc || !soc->ops) {
  78. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  79. "%s invalid instance", __func__);
  80. QDF_BUG(0);
  81. return 0;
  82. }
  83. if (!soc->ops->l_flowctl_ops ||
  84. !soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb)
  85. return 0;
  86. return soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb(
  87. vdev_id);
  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. if (!soc->ops->l_flowctl_ops ||
  112. !soc->ops->l_flowctl_ops->get_tx_resource)
  113. return false;
  114. return soc->ops->l_flowctl_ops->get_tx_resource(sta_id,
  115. low_watermark, high_watermark_offset);
  116. }
  117. /**
  118. * cdp_fc_ll_set_tx_pause_q_depth() - set pause queue depth
  119. * @soc - data path soc handle
  120. * @vdev_id - virtual interface id to register flow control
  121. * @pause_q_depth - pending tx queue delth
  122. *
  123. * set pause queue depth
  124. *
  125. * return 0 success
  126. */
  127. static inline int
  128. cdp_fc_ll_set_tx_pause_q_depth(ol_txrx_soc_handle soc,
  129. uint8_t vdev_id, int pause_q_depth)
  130. {
  131. if (!soc || !soc->ops) {
  132. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  133. "%s invalid instance", __func__);
  134. QDF_BUG(0);
  135. return 0;
  136. }
  137. if (!soc->ops->l_flowctl_ops ||
  138. !soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth)
  139. return 0;
  140. return soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth(
  141. vdev_id, pause_q_depth);
  142. }
  143. /**
  144. * cdp_fc_vdev_flush() - flush tx queue
  145. * @soc - data path soc handle
  146. * @vdev - virtual interface context pointer
  147. *
  148. * flush tx queue
  149. *
  150. * return None
  151. */
  152. static inline void
  153. cdp_fc_vdev_flush(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  154. {
  155. if (!soc || !soc->ops) {
  156. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  157. "%s invalid instance", __func__);
  158. QDF_BUG(0);
  159. return;
  160. }
  161. if (!soc->ops->l_flowctl_ops ||
  162. !soc->ops->l_flowctl_ops->vdev_flush)
  163. return;
  164. soc->ops->l_flowctl_ops->vdev_flush(vdev);
  165. }
  166. /**
  167. * cdp_fc_vdev_pause() - pause tx scheduler on vdev
  168. * @soc - data path soc handle
  169. * @vdev - virtual interface context pointer
  170. * @reason - pause reason
  171. *
  172. * pause tx scheduler on vdev
  173. *
  174. * return None
  175. */
  176. static inline void
  177. cdp_fc_vdev_pause(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  178. uint32_t reason)
  179. {
  180. if (!soc || !soc->ops) {
  181. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  182. "%s invalid instance", __func__);
  183. QDF_BUG(0);
  184. return;
  185. }
  186. if (!soc->ops->l_flowctl_ops ||
  187. !soc->ops->l_flowctl_ops->vdev_pause)
  188. return;
  189. soc->ops->l_flowctl_ops->vdev_pause(vdev, reason);
  190. }
  191. /**
  192. * cdp_fc_vdev_unpause() - resume tx scheduler on vdev
  193. * @soc - data path soc handle
  194. * @vdev - virtual interface context pointer
  195. * @reason - pause reason
  196. *
  197. * resume tx scheduler on vdev
  198. *
  199. * return None
  200. */
  201. static inline void
  202. cdp_fc_vdev_unpause(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  203. uint32_t reason)
  204. {
  205. if (!soc || !soc->ops) {
  206. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  207. "%s invalid instance", __func__);
  208. return;
  209. }
  210. if (!soc->ops->l_flowctl_ops ||
  211. !soc->ops->l_flowctl_ops->vdev_unpause)
  212. return;
  213. soc->ops->l_flowctl_ops->vdev_unpause(vdev, reason);
  214. }
  215. #endif /* _CDP_TXRX_FC_LEG_H_ */