cdp_txrx_flow_ctrl_legacy.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /*
  2. * Copyright (c) 2016-2018 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. #ifdef QCA_HL_NETDEV_FLOW_CONTROL
  28. /**
  29. * cdp_hl_fc_register() - Register HL flow control callback.
  30. * @soc - data path soc handle
  31. * @flowcontrol - callback function pointer to stop/start OS netdev queues
  32. * Register flow control callback.
  33. * return 0 success
  34. */
  35. static inline int
  36. cdp_hl_fc_register(ol_txrx_soc_handle soc, tx_pause_callback flowcontrol)
  37. {
  38. if (!soc || !soc->ops) {
  39. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  40. "%s invalid instance", __func__);
  41. QDF_BUG(0);
  42. return -EINVAL;
  43. }
  44. if (!soc->ops->l_flowctl_ops ||
  45. !soc->ops->l_flowctl_ops->register_tx_flow_control)
  46. return -EINVAL;
  47. return soc->ops->l_flowctl_ops->register_tx_flow_control(soc,
  48. flowcontrol);
  49. }
  50. static inline int cdp_hl_fc_set_td_limit(ol_txrx_soc_handle soc,
  51. u8 vdev_id, u8 chan)
  52. {
  53. if (!soc->ops->l_flowctl_ops->set_vdev_tx_desc_limit)
  54. return 0;
  55. return soc->ops->l_flowctl_ops->set_vdev_tx_desc_limit(vdev_id, chan);
  56. }
  57. static inline int cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,
  58. u8 vdev_id,
  59. enum netif_action_type action)
  60. {
  61. if (!soc->ops->l_flowctl_ops->set_vdev_os_queue_status)
  62. return -EINVAL;
  63. return soc->ops->l_flowctl_ops->set_vdev_os_queue_status(vdev_id,
  64. action);
  65. }
  66. #else
  67. static inline int
  68. cdp_hl_fc_register(ol_txrx_soc_handle soc, tx_pause_callback flowcontrol)
  69. {
  70. return 0;
  71. }
  72. static inline int cdp_hl_fc_set_td_limit(ol_txrx_soc_handle soc,
  73. u8 vdev_id, u8 chan)
  74. {
  75. return 0;
  76. }
  77. static inline int cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,
  78. u8 vdev_id,
  79. enum netif_action_type action)
  80. {
  81. return 0;
  82. }
  83. #endif /* QCA_HL_NETDEV_FLOW_CONTROL */
  84. #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
  85. /**
  86. * cdp_fc_register() - Register flow control callback function pointer
  87. * @soc - data path soc handle
  88. * @vdev_id - virtual interface id to register flow control
  89. * @flowControl - callback function pointer
  90. * @osif_fc_ctx - client context pointer
  91. * @flow_control_is_pause: is vdev paused by flow control
  92. *
  93. * Register flow control callback function pointer and client context pointer
  94. *
  95. * return 0 success
  96. */
  97. static inline int
  98. cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id,
  99. ol_txrx_tx_flow_control_fp flowControl, void *osif_fc_ctx,
  100. ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)
  101. {
  102. if (!soc || !soc->ops) {
  103. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  104. "%s invalid instance", __func__);
  105. QDF_BUG(0);
  106. return 0;
  107. }
  108. if (!soc->ops->l_flowctl_ops ||
  109. !soc->ops->l_flowctl_ops->register_tx_flow_control)
  110. return 0;
  111. return soc->ops->l_flowctl_ops->register_tx_flow_control(
  112. vdev_id, flowControl, osif_fc_ctx,
  113. flow_control_is_pause);
  114. }
  115. #else
  116. static inline int
  117. cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id,
  118. ol_txrx_tx_flow_control_fp flowcontrol, void *osif_fc_ctx,
  119. ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)
  120. {
  121. return 0;
  122. }
  123. #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
  124. /**
  125. * cdp_fc_deregister() - remove flow control instance
  126. * @soc - data path soc handle
  127. * @vdev_id - virtual interface id to register flow control
  128. *
  129. * remove flow control instance
  130. *
  131. * return 0 success
  132. */
  133. static inline int
  134. cdp_fc_deregister(ol_txrx_soc_handle soc, uint8_t vdev_id)
  135. {
  136. if (!soc || !soc->ops) {
  137. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  138. "%s invalid instance", __func__);
  139. QDF_BUG(0);
  140. return 0;
  141. }
  142. if (!soc->ops->l_flowctl_ops ||
  143. !soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb)
  144. return 0;
  145. return soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb(
  146. vdev_id);
  147. }
  148. /**
  149. * cdp_fc_get_tx_resource() - get data path resource count
  150. * @soc - data path soc handle
  151. * @sta_id - local peer id
  152. * @low_watermark - low resource threshold
  153. * @high_watermark_offset - high resource threshold
  154. *
  155. * get data path resource count
  156. *
  157. * return true enough data path resource available
  158. * false resource is not avaialbe
  159. */
  160. static inline bool
  161. cdp_fc_get_tx_resource(ol_txrx_soc_handle soc, uint8_t sta_id,
  162. unsigned int low_watermark, unsigned int high_watermark_offset)
  163. {
  164. if (!soc || !soc->ops) {
  165. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  166. "%s invalid instance", __func__);
  167. QDF_BUG(0);
  168. return false;
  169. }
  170. if (!soc->ops->l_flowctl_ops ||
  171. !soc->ops->l_flowctl_ops->get_tx_resource)
  172. return false;
  173. return soc->ops->l_flowctl_ops->get_tx_resource(sta_id,
  174. low_watermark, high_watermark_offset);
  175. }
  176. /**
  177. * cdp_fc_ll_set_tx_pause_q_depth() - set pause queue depth
  178. * @soc - data path soc handle
  179. * @vdev_id - virtual interface id to register flow control
  180. * @pause_q_depth - pending tx queue delth
  181. *
  182. * set pause queue depth
  183. *
  184. * return 0 success
  185. */
  186. static inline int
  187. cdp_fc_ll_set_tx_pause_q_depth(ol_txrx_soc_handle soc,
  188. uint8_t vdev_id, int pause_q_depth)
  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 0;
  195. }
  196. if (!soc->ops->l_flowctl_ops ||
  197. !soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth)
  198. return 0;
  199. return soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth(
  200. vdev_id, pause_q_depth);
  201. }
  202. /**
  203. * cdp_fc_vdev_flush() - flush tx queue
  204. * @soc - data path soc handle
  205. * @vdev - virtual interface context pointer
  206. *
  207. * flush tx queue
  208. *
  209. * return None
  210. */
  211. static inline void
  212. cdp_fc_vdev_flush(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  213. {
  214. if (!soc || !soc->ops) {
  215. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  216. "%s invalid instance", __func__);
  217. QDF_BUG(0);
  218. return;
  219. }
  220. if (!soc->ops->l_flowctl_ops ||
  221. !soc->ops->l_flowctl_ops->vdev_flush)
  222. return;
  223. soc->ops->l_flowctl_ops->vdev_flush(vdev);
  224. }
  225. /**
  226. * cdp_fc_vdev_pause() - pause tx scheduler on vdev
  227. * @soc - data path soc handle
  228. * @vdev - virtual interface context pointer
  229. * @reason - pause reason
  230. *
  231. * pause tx scheduler on vdev
  232. *
  233. * return None
  234. */
  235. static inline void
  236. cdp_fc_vdev_pause(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  237. uint32_t reason)
  238. {
  239. if (!soc || !soc->ops) {
  240. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  241. "%s invalid instance", __func__);
  242. QDF_BUG(0);
  243. return;
  244. }
  245. if (!soc->ops->l_flowctl_ops ||
  246. !soc->ops->l_flowctl_ops->vdev_pause)
  247. return;
  248. soc->ops->l_flowctl_ops->vdev_pause(vdev, reason);
  249. }
  250. /**
  251. * cdp_fc_vdev_unpause() - resume tx scheduler on vdev
  252. * @soc - data path soc handle
  253. * @vdev - virtual interface context pointer
  254. * @reason - pause reason
  255. *
  256. * resume tx scheduler on vdev
  257. *
  258. * return None
  259. */
  260. static inline void
  261. cdp_fc_vdev_unpause(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  262. uint32_t reason)
  263. {
  264. if (!soc || !soc->ops) {
  265. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  266. "%s invalid instance", __func__);
  267. return;
  268. }
  269. if (!soc->ops->l_flowctl_ops ||
  270. !soc->ops->l_flowctl_ops->vdev_unpause)
  271. return;
  272. soc->ops->l_flowctl_ops->vdev_unpause(vdev, reason);
  273. }
  274. #endif /* _CDP_TXRX_FC_LEG_H_ */