cdp_txrx_flow_ctrl_legacy.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. /*
  2. * Copyright (c) 2016-2019,2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022-2023 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. * DOC: cdp_txrx_flow_ctrl_legacy.h
  21. * Define the host data path legacy flow control API 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. #include <cdp_txrx_cmn.h>
  28. #ifdef QCA_HL_NETDEV_FLOW_CONTROL
  29. /**
  30. * cdp_hl_fc_register() - Register HL flow control callback.
  31. * @soc: data path soc handle
  32. * @pdev_id: datapath pdev identifier
  33. * @flowcontrol: callback function pointer to stop/start OS netdev queues
  34. *
  35. * Register flow control callback.
  36. *
  37. * Return: 0 for success
  38. */
  39. static inline int
  40. cdp_hl_fc_register(ol_txrx_soc_handle soc, uint8_t pdev_id,
  41. tx_pause_callback flowcontrol)
  42. {
  43. if (!soc || !soc->ops) {
  44. dp_cdp_debug("invalid instance");
  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, uint32_t chan_freq)
  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_freq);
  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, uint32_t chan_freq)
  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. dp_cdp_debug("invalid instance");
  111. QDF_BUG(0);
  112. return 0;
  113. }
  114. if (!soc->ops->l_flowctl_ops ||
  115. !soc->ops->l_flowctl_ops->register_tx_flow_control)
  116. return 0;
  117. return soc->ops->l_flowctl_ops->register_tx_flow_control(
  118. soc, vdev_id, flowcontrol, osif_fc_ctx,
  119. flow_control_is_pause);
  120. }
  121. #else
  122. static inline int
  123. cdp_fc_register(ol_txrx_soc_handle soc, uint8_t vdev_id,
  124. ol_txrx_tx_flow_control_fp flowcontrol, void *osif_fc_ctx,
  125. ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause)
  126. {
  127. return 0;
  128. }
  129. #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
  130. /**
  131. * cdp_fc_deregister() - remove flow control instance
  132. * @soc: data path soc handle
  133. * @vdev_id: virtual interface id to register flow control
  134. *
  135. * remove flow control instance
  136. *
  137. * Return: 0 success
  138. */
  139. static inline int
  140. cdp_fc_deregister(ol_txrx_soc_handle soc, uint8_t vdev_id)
  141. {
  142. if (!soc || !soc->ops) {
  143. dp_cdp_debug("invalid instance");
  144. QDF_BUG(0);
  145. return 0;
  146. }
  147. if (!soc->ops->l_flowctl_ops ||
  148. !soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb)
  149. return 0;
  150. return soc->ops->l_flowctl_ops->deregister_tx_flow_control_cb(
  151. soc, vdev_id);
  152. }
  153. /**
  154. * cdp_fc_get_tx_resource() - get data path resource count
  155. * @soc: data path soc handle
  156. * @pdev_id: datapath pdev ID
  157. * @peer_addr: peer mac address
  158. * @low_watermark: low resource threshold
  159. * @high_watermark_offset: high resource threshold
  160. *
  161. * get data path resource count
  162. *
  163. * Return: true enough data path resource available
  164. * false resource is not available
  165. */
  166. static inline bool
  167. cdp_fc_get_tx_resource(ol_txrx_soc_handle soc, uint8_t pdev_id,
  168. struct qdf_mac_addr peer_addr,
  169. unsigned int low_watermark,
  170. unsigned int high_watermark_offset)
  171. {
  172. if (!soc || !soc->ops) {
  173. dp_cdp_debug("invalid instance");
  174. QDF_BUG(0);
  175. return false;
  176. }
  177. if (!soc->ops->l_flowctl_ops ||
  178. !soc->ops->l_flowctl_ops->get_tx_resource)
  179. return false;
  180. return soc->ops->l_flowctl_ops->get_tx_resource(soc, pdev_id, peer_addr,
  181. low_watermark,
  182. high_watermark_offset);
  183. }
  184. /**
  185. * cdp_fc_ll_set_tx_pause_q_depth() - set pause queue depth
  186. * @soc: data path soc handle
  187. * @vdev_id: virtual interface id to register flow control
  188. * @pause_q_depth: pending tx queue delth
  189. *
  190. * set pause queue depth
  191. *
  192. * Return: 0 success
  193. */
  194. static inline int
  195. cdp_fc_ll_set_tx_pause_q_depth(ol_txrx_soc_handle soc,
  196. uint8_t vdev_id, int pause_q_depth)
  197. {
  198. if (!soc || !soc->ops) {
  199. dp_cdp_debug("invalid instance");
  200. QDF_BUG(0);
  201. return 0;
  202. }
  203. if (!soc->ops->l_flowctl_ops ||
  204. !soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth)
  205. return 0;
  206. return soc->ops->l_flowctl_ops->ll_set_tx_pause_q_depth(
  207. soc, vdev_id, pause_q_depth);
  208. }
  209. /**
  210. * cdp_fc_vdev_flush() - flush tx queue
  211. * @soc: data path soc handle
  212. * @vdev_id: id of vdev
  213. *
  214. * flush tx queue
  215. *
  216. * Return: None
  217. */
  218. static inline void
  219. cdp_fc_vdev_flush(ol_txrx_soc_handle soc, uint8_t vdev_id)
  220. {
  221. if (!soc || !soc->ops) {
  222. dp_cdp_debug("invalid instance");
  223. QDF_BUG(0);
  224. return;
  225. }
  226. if (!soc->ops->l_flowctl_ops ||
  227. !soc->ops->l_flowctl_ops->vdev_flush)
  228. return;
  229. soc->ops->l_flowctl_ops->vdev_flush(soc, vdev_id);
  230. }
  231. /**
  232. * cdp_fc_vdev_pause() - pause tx scheduler on vdev
  233. * @soc: data path soc handle
  234. * @vdev_id: id of vdev
  235. * @reason: pause reason
  236. * @pause_type: type of pause
  237. *
  238. * pause tx scheduler on vdev
  239. *
  240. * Return: None
  241. */
  242. static inline void
  243. cdp_fc_vdev_pause(ol_txrx_soc_handle soc, uint8_t vdev_id,
  244. uint32_t reason, uint32_t pause_type)
  245. {
  246. if (!soc || !soc->ops) {
  247. dp_cdp_debug("invalid instance");
  248. QDF_BUG(0);
  249. return;
  250. }
  251. if (!soc->ops->l_flowctl_ops ||
  252. !soc->ops->l_flowctl_ops->vdev_pause)
  253. return;
  254. soc->ops->l_flowctl_ops->vdev_pause(soc, vdev_id, reason, pause_type);
  255. }
  256. /**
  257. * cdp_fc_vdev_unpause() - resume tx scheduler on vdev
  258. * @soc: data path soc handle
  259. * @vdev_id: id of vdev
  260. * @reason: pause reason
  261. * @pause_type: type of pause
  262. *
  263. * resume tx scheduler on vdev
  264. *
  265. * Return: None
  266. */
  267. static inline void
  268. cdp_fc_vdev_unpause(ol_txrx_soc_handle soc, uint8_t vdev_id,
  269. uint32_t reason, uint32_t pause_type)
  270. {
  271. if (!soc || !soc->ops) {
  272. dp_cdp_debug("invalid instance");
  273. return;
  274. }
  275. if (!soc->ops->l_flowctl_ops ||
  276. !soc->ops->l_flowctl_ops->vdev_unpause)
  277. return;
  278. soc->ops->l_flowctl_ops->vdev_unpause(soc, vdev_id, reason,
  279. pause_type);
  280. }
  281. #endif /* _CDP_TXRX_FC_LEG_H_ */