cdp_txrx_flow_ctrl_v2.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright (c) 2016-2019,2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 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_v2.h
  21. * Define the host data path flow control version 2 API functions
  22. */
  23. #ifndef _CDP_TXRX_FC_V2_H_
  24. #define _CDP_TXRX_FC_V2_H_
  25. #include <cdp_txrx_ops.h>
  26. #include <cdp_txrx_cmn.h>
  27. /**
  28. * cdp_register_pause_cb() - Register flow control callback function pointer
  29. * @soc: data path soc handle
  30. * @pause_cb: Pause callback intend to register
  31. *
  32. * Register flow control callback function pointer and client context pointer
  33. *
  34. * return QDF_STATUS_SUCCESS success
  35. */
  36. static inline QDF_STATUS
  37. cdp_register_pause_cb(ol_txrx_soc_handle soc,
  38. tx_pause_callback pause_cb)
  39. {
  40. if (!soc || !soc->ops) {
  41. dp_cdp_debug("invalid instance");
  42. QDF_BUG(0);
  43. return QDF_STATUS_E_INVAL;
  44. }
  45. if (!soc->ops->flowctl_ops ||
  46. !soc->ops->flowctl_ops->register_pause_cb)
  47. return QDF_STATUS_SUCCESS;
  48. return soc->ops->flowctl_ops->register_pause_cb(soc, pause_cb);
  49. }
  50. /**
  51. * cdp_set_desc_global_pool_size() - set global device pool size
  52. * @soc: data path soc handle
  53. * @num_msdu_desc: descriptor pool size
  54. *
  55. * set global device pool size
  56. *
  57. * return none
  58. */
  59. static inline void
  60. cdp_set_desc_global_pool_size(ol_txrx_soc_handle soc,
  61. uint32_t num_msdu_desc)
  62. {
  63. if (!soc || !soc->ops) {
  64. dp_cdp_debug("invalid instance");
  65. QDF_BUG(0);
  66. return;
  67. }
  68. if (!soc->ops->flowctl_ops ||
  69. !soc->ops->flowctl_ops->set_desc_global_pool_size)
  70. return;
  71. soc->ops->flowctl_ops->set_desc_global_pool_size(
  72. num_msdu_desc);
  73. }
  74. /**
  75. * cdp_dump_flow_pool_info() - dump flow pool information
  76. * @soc: data path soc handle
  77. *
  78. * dump flow pool information
  79. *
  80. * return none
  81. */
  82. static inline void
  83. cdp_dump_flow_pool_info(struct cdp_soc_t *soc)
  84. {
  85. if (!soc || !soc->ops) {
  86. dp_cdp_debug("invalid instance");
  87. QDF_BUG(0);
  88. return;
  89. }
  90. if (!soc->ops->flowctl_ops ||
  91. !soc->ops->flowctl_ops->dump_flow_pool_info)
  92. return;
  93. soc->ops->flowctl_ops->dump_flow_pool_info(soc);
  94. }
  95. /**
  96. * cdp_tx_desc_thresh_reached() - Check if avail tx desc meet threshold
  97. * @soc: data path soc handle
  98. * @vdev_id: vdev_id corresponding to vdev start
  99. *
  100. * Return: true if threshold is met, false if not
  101. */
  102. static inline bool
  103. cdp_tx_desc_thresh_reached(struct cdp_soc_t *soc, uint8_t vdev_id)
  104. {
  105. if (!soc || !soc->ops) {
  106. dp_cdp_debug("invalid instance");
  107. QDF_BUG(0);
  108. return false;
  109. }
  110. if (!soc->ops->flowctl_ops ||
  111. !soc->ops->flowctl_ops->tx_desc_thresh_reached)
  112. return false;
  113. return soc->ops->flowctl_ops->tx_desc_thresh_reached(soc, vdev_id);
  114. }
  115. #endif /* _CDP_TXRX_FC_V2_H_ */