cdp_txrx_flow_ctrl_legacy.h 8.1 KB

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