cdp_txrx_flow_ctrl_legacy.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. /*
  2. * Copyright (c) 2016-2019,2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /**
  20. * @file cdp_txrx_flow_ctrl_legacy.h
  21. * @brief Define the host data path legacy flow control API
  22. * functions
  23. */
  24. #ifndef _CDP_TXRX_FC_LEG_H_
  25. #define _CDP_TXRX_FC_LEG_H_
  26. #include <cdp_txrx_mob_def.h>
  27. #include "cdp_txrx_handle.h"
  28. #include <cdp_txrx_cmn.h>
  29. #ifdef QCA_HL_NETDEV_FLOW_CONTROL
  30. /**
  31. * cdp_hl_fc_register() - Register HL flow control callback.
  32. * @soc: data path soc handle
  33. * @pdev_id: datapath pdev identifier
  34. * @flowcontrol: callback function pointer to stop/start OS netdev queues
  35. *
  36. * Register flow control callback.
  37. *
  38. * Returns: 0 for success
  39. */
  40. static inline int
  41. cdp_hl_fc_register(ol_txrx_soc_handle soc, uint8_t pdev_id,
  42. tx_pause_callback flowcontrol)
  43. {
  44. if (!soc || !soc->ops) {
  45. dp_cdp_debug("invalid instance");
  46. QDF_BUG(0);
  47. return -EINVAL;
  48. }
  49. if (!soc->ops->l_flowctl_ops ||
  50. !soc->ops->l_flowctl_ops->register_tx_flow_control)
  51. return -EINVAL;
  52. return soc->ops->l_flowctl_ops->register_tx_flow_control(soc, pdev_id,
  53. flowcontrol);
  54. }
  55. static inline int cdp_hl_fc_set_td_limit(ol_txrx_soc_handle soc,
  56. uint8_t vdev_id, uint32_t chan_freq)
  57. {
  58. if (!soc->ops->l_flowctl_ops->set_vdev_tx_desc_limit)
  59. return 0;
  60. return soc->ops->l_flowctl_ops->set_vdev_tx_desc_limit(soc, vdev_id,
  61. chan_freq);
  62. }
  63. static inline int cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,
  64. uint8_t vdev_id,
  65. enum netif_action_type action)
  66. {
  67. if (!soc->ops->l_flowctl_ops->set_vdev_os_queue_status)
  68. return -EINVAL;
  69. return soc->ops->l_flowctl_ops->set_vdev_os_queue_status(soc,
  70. vdev_id,
  71. action);
  72. }
  73. #else
  74. static inline int
  75. cdp_hl_fc_register(ol_txrx_soc_handle soc, uint8_t pdev_id,
  76. tx_pause_callback flowcontrol)
  77. {
  78. return 0;
  79. }
  80. static inline int cdp_hl_fc_set_td_limit(ol_txrx_soc_handle soc,
  81. uint8_t vdev_id, uint32_t chan_freq)
  82. {
  83. return 0;
  84. }
  85. static inline int cdp_hl_fc_set_os_queue_status(ol_txrx_soc_handle soc,
  86. uint8_t vdev_id,
  87. enum netif_action_type action)
  88. {
  89. return 0;
  90. }
  91. #endif /* QCA_HL_NETDEV_FLOW_CONTROL */
  92. #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
  93. /**
  94. * cdp_fc_register() - Register flow control callback function pointer
  95. * @soc - data path soc handle
  96. * @vdev_id - virtual interface id to register flow control
  97. * @flowControl - callback function pointer
  98. * @osif_fc_ctx - client context pointer
  99. * @flow_control_is_pause: is vdev paused by flow control
  100. *
  101. * Register flow control callback function pointer and client context pointer
  102. *
  103. * return 0 success
  104. */
  105. static inline int
  106. cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id,
  107. ol_txrx_tx_flow_control_fp flowcontrol, void *osif_fc_ctx,
  108. ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)
  109. {
  110. if (!soc || !soc->ops) {
  111. dp_cdp_debug("invalid instance");
  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. dp_cdp_debug("invalid instance");
  145. QDF_BUG(0);
  146. return 0;
  147. }
  148. if (!soc->ops->l_flowctl_ops ||
  149. !soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb)
  150. return 0;
  151. return soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb(
  152. soc, vdev_id);
  153. }
  154. /**
  155. * cdp_fc_get_tx_resource() - get data path resource count
  156. * @soc: data path soc handle
  157. * @pdev_id: datapath pdev ID
  158. * @peer_addr: peer mac address
  159. * @low_watermark: low resource threshold
  160. * @high_watermark_offset: high resource threshold
  161. *
  162. * get data path resource count
  163. *
  164. * return true enough data path resource available
  165. * false resource is not available
  166. */
  167. static inline bool
  168. cdp_fc_get_tx_resource(ol_txrx_soc_handle soc, uint8_t pdev_id,
  169. struct qdf_mac_addr peer_addr,
  170. unsigned int low_watermark,
  171. unsigned int high_watermark_offset)
  172. {
  173. if (!soc || !soc->ops) {
  174. dp_cdp_debug("invalid instance");
  175. QDF_BUG(0);
  176. return false;
  177. }
  178. if (!soc->ops->l_flowctl_ops ||
  179. !soc->ops->l_flowctl_ops->get_tx_resource)
  180. return false;
  181. return soc->ops->l_flowctl_ops->get_tx_resource(soc, pdev_id, peer_addr,
  182. low_watermark,
  183. high_watermark_offset);
  184. }
  185. /**
  186. * cdp_fc_ll_set_tx_pause_q_depth() - set pause queue depth
  187. * @soc - data path soc handle
  188. * @vdev_id - virtual interface id to register flow control
  189. * @pause_q_depth - pending tx queue delth
  190. *
  191. * set pause queue depth
  192. *
  193. * return 0 success
  194. */
  195. static inline int
  196. cdp_fc_ll_set_tx_pause_q_depth(ol_txrx_soc_handle soc,
  197. uint8_t vdev_id, int pause_q_depth)
  198. {
  199. if (!soc || !soc->ops) {
  200. dp_cdp_debug("invalid instance");
  201. QDF_BUG(0);
  202. return 0;
  203. }
  204. if (!soc->ops->l_flowctl_ops ||
  205. !soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth)
  206. return 0;
  207. return soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth(
  208. soc, vdev_id, pause_q_depth);
  209. }
  210. /**
  211. * cdp_fc_vdev_flush() - flush tx queue
  212. * @soc: data path soc handle
  213. * @vdev_id: id of vdev
  214. *
  215. * flush tx queue
  216. *
  217. * return None
  218. */
  219. static inline void
  220. cdp_fc_vdev_flush(ol_txrx_soc_handle soc, uint8_t vdev_id)
  221. {
  222. if (!soc || !soc->ops) {
  223. dp_cdp_debug("invalid instance");
  224. QDF_BUG(0);
  225. return;
  226. }
  227. if (!soc->ops->l_flowctl_ops ||
  228. !soc->ops->l_flowctl_ops->vdev_flush)
  229. return;
  230. soc->ops->l_flowctl_ops->vdev_flush(soc, vdev_id);
  231. }
  232. /**
  233. * cdp_fc_vdev_pause() - pause tx scheduler on vdev
  234. * @soc: data path soc handle
  235. * @vdev_id: id of vdev
  236. * @reason: pause reason
  237. * @pause_type: type of pause
  238. *
  239. * pause tx scheduler on vdev
  240. *
  241. * return None
  242. */
  243. static inline void
  244. cdp_fc_vdev_pause(ol_txrx_soc_handle soc, uint8_t vdev_id,
  245. uint32_t reason, uint32_t pause_type)
  246. {
  247. if (!soc || !soc->ops) {
  248. dp_cdp_debug("invalid instance");
  249. QDF_BUG(0);
  250. return;
  251. }
  252. if (!soc->ops->l_flowctl_ops ||
  253. !soc->ops->l_flowctl_ops->vdev_pause)
  254. return;
  255. soc->ops->l_flowctl_ops->vdev_pause(soc, vdev_id, reason, pause_type);
  256. }
  257. /**
  258. * cdp_fc_vdev_unpause() - resume tx scheduler on vdev
  259. * @soc: data path soc handle
  260. * @vdev_id: id of vdev
  261. * @reason: pause reason
  262. * @pause_type: type of pause
  263. *
  264. * resume tx scheduler on vdev
  265. *
  266. * return None
  267. */
  268. static inline void
  269. cdp_fc_vdev_unpause(ol_txrx_soc_handle soc, uint8_t vdev_id,
  270. uint32_t reason, uint32_t pause_type)
  271. {
  272. if (!soc || !soc->ops) {
  273. dp_cdp_debug("invalid instance");
  274. return;
  275. }
  276. if (!soc->ops->l_flowctl_ops ||
  277. !soc->ops->l_flowctl_ops->vdev_unpause)
  278. return;
  279. soc->ops->l_flowctl_ops->vdev_unpause(soc, vdev_id, reason,
  280. pause_type);
  281. }
  282. #endif /* _CDP_TXRX_FC_LEG_H_ */