cdp_txrx_flow_ctrl_legacy.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. * @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. uint8_t vdev_id, uint8_t 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. uint8_t 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. uint8_t vdev_id, uint8_t chan)
  74. {
  75. return 0;
  76. }
  77. static inline int cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,
  78. uint8_t 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. * @pdev - datapath pdev instance
  152. * @peer_addr - peer mac address
  153. * @low_watermark - low resource threshold
  154. * @high_watermark_offset - high resource threshold
  155. *
  156. * get data path resource count
  157. *
  158. * return true enough data path resource available
  159. * false resource is not avaialbe
  160. */
  161. static inline bool
  162. cdp_fc_get_tx_resource(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
  163. struct qdf_mac_addr peer_addr,
  164. unsigned int low_watermark,
  165. unsigned int high_watermark_offset)
  166. {
  167. if (!soc || !soc->ops) {
  168. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  169. "%s invalid instance", __func__);
  170. QDF_BUG(0);
  171. return false;
  172. }
  173. if (!soc->ops->l_flowctl_ops ||
  174. !soc->ops->l_flowctl_ops->get_tx_resource)
  175. return false;
  176. return soc->ops->l_flowctl_ops->get_tx_resource(pdev, peer_addr,
  177. low_watermark, high_watermark_offset);
  178. }
  179. /**
  180. * cdp_fc_ll_set_tx_pause_q_depth() - set pause queue depth
  181. * @soc - data path soc handle
  182. * @vdev_id - virtual interface id to register flow control
  183. * @pause_q_depth - pending tx queue delth
  184. *
  185. * set pause queue depth
  186. *
  187. * return 0 success
  188. */
  189. static inline int
  190. cdp_fc_ll_set_tx_pause_q_depth(ol_txrx_soc_handle soc,
  191. uint8_t vdev_id, int pause_q_depth)
  192. {
  193. if (!soc || !soc->ops) {
  194. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  195. "%s invalid instance", __func__);
  196. QDF_BUG(0);
  197. return 0;
  198. }
  199. if (!soc->ops->l_flowctl_ops ||
  200. !soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth)
  201. return 0;
  202. return soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth(
  203. vdev_id, pause_q_depth);
  204. }
  205. /**
  206. * cdp_fc_vdev_flush() - flush tx queue
  207. * @soc - data path soc handle
  208. * @vdev - virtual interface context pointer
  209. *
  210. * flush tx queue
  211. *
  212. * return None
  213. */
  214. static inline void
  215. cdp_fc_vdev_flush(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
  216. {
  217. if (!soc || !soc->ops) {
  218. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  219. "%s invalid instance", __func__);
  220. QDF_BUG(0);
  221. return;
  222. }
  223. if (!soc->ops->l_flowctl_ops ||
  224. !soc->ops->l_flowctl_ops->vdev_flush)
  225. return;
  226. soc->ops->l_flowctl_ops->vdev_flush(vdev);
  227. }
  228. /**
  229. * cdp_fc_vdev_pause() - pause tx scheduler on vdev
  230. * @soc - data path soc handle
  231. * @vdev - virtual interface context pointer
  232. * @reason - pause reason
  233. *
  234. * pause tx scheduler on vdev
  235. *
  236. * return None
  237. */
  238. static inline void
  239. cdp_fc_vdev_pause(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  240. uint32_t reason)
  241. {
  242. if (!soc || !soc->ops) {
  243. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  244. "%s invalid instance", __func__);
  245. QDF_BUG(0);
  246. return;
  247. }
  248. if (!soc->ops->l_flowctl_ops ||
  249. !soc->ops->l_flowctl_ops->vdev_pause)
  250. return;
  251. soc->ops->l_flowctl_ops->vdev_pause(vdev, reason);
  252. }
  253. /**
  254. * cdp_fc_vdev_unpause() - resume tx scheduler on vdev
  255. * @soc - data path soc handle
  256. * @vdev - virtual interface context pointer
  257. * @reason - pause reason
  258. *
  259. * resume tx scheduler on vdev
  260. *
  261. * return None
  262. */
  263. static inline void
  264. cdp_fc_vdev_unpause(ol_txrx_soc_handle soc, struct cdp_vdev *vdev,
  265. uint32_t reason)
  266. {
  267. if (!soc || !soc->ops) {
  268. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  269. "%s invalid instance", __func__);
  270. return;
  271. }
  272. if (!soc->ops->l_flowctl_ops ||
  273. !soc->ops->l_flowctl_ops->vdev_unpause)
  274. return;
  275. soc->ops->l_flowctl_ops->vdev_unpause(vdev, reason);
  276. }
  277. #endif /* _CDP_TXRX_FC_LEG_H_ */