cdp_txrx_flow_ctrl_v2.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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_v2.h
  20. * @brief Define the host data path flow control version 2 API
  21. * functions
  22. */
  23. #ifndef _CDP_TXRX_FC_V2_H_
  24. #define _CDP_TXRX_FC_V2_H_
  25. #include <cdp_txrx_ops.h>
  26. /**
  27. * cdp_register_pause_cb() - Register flow control callback function pointer
  28. * @soc - data path soc handle
  29. * @pause_cb - Pause callback intend to register
  30. *
  31. * Register flow control callback function pointer and client context pointer
  32. *
  33. * return QDF_STATUS_SUCCESS success
  34. */
  35. static inline QDF_STATUS
  36. cdp_register_pause_cb(ol_txrx_soc_handle soc,
  37. tx_pause_callback pause_cb)
  38. {
  39. if (!soc || !soc->ops) {
  40. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  41. "%s invalid instance", __func__);
  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. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  65. "%s invalid instance", __func__);
  66. QDF_BUG(0);
  67. return;
  68. }
  69. if (!soc->ops->flowctl_ops ||
  70. !soc->ops->flowctl_ops->set_desc_global_pool_size)
  71. return;
  72. soc->ops->flowctl_ops->set_desc_global_pool_size(
  73. num_msdu_desc);
  74. }
  75. /**
  76. * cdp_dump_flow_pool_info() - dump flow pool information
  77. * @soc - data path soc handle
  78. *
  79. * dump flow pool information
  80. *
  81. * return none
  82. */
  83. static inline void
  84. cdp_dump_flow_pool_info(struct cdp_soc_t *soc)
  85. {
  86. if (!soc || !soc->ops) {
  87. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  88. "%s invalid instance", __func__);
  89. QDF_BUG(0);
  90. return;
  91. }
  92. if (!soc->ops->flowctl_ops ||
  93. !soc->ops->flowctl_ops->dump_flow_pool_info)
  94. return;
  95. soc->ops->flowctl_ops->dump_flow_pool_info(soc);
  96. }
  97. /**
  98. * cdp_tx_desc_thresh_reached() - Check if avail tx desc meet threshold
  99. * @soc: data path soc handle
  100. * @vdev_id: vdev_id corresponding to vdev start
  101. *
  102. * Return: true if threshold is met, false if not
  103. */
  104. static inline bool
  105. cdp_tx_desc_thresh_reached(struct cdp_soc_t *soc, uint8_t vdev_id)
  106. {
  107. if (!soc || !soc->ops) {
  108. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  109. "%s invalid instance", __func__);
  110. QDF_BUG(0);
  111. return false;
  112. }
  113. if (!soc->ops->flowctl_ops ||
  114. !soc->ops->flowctl_ops->tx_desc_thresh_reached)
  115. return false;
  116. return soc->ops->flowctl_ops->tx_desc_thresh_reached(soc, vdev_id);
  117. }
  118. #endif /* _CDP_TXRX_FC_V2_H_ */