dp_rx_buffer_pool.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (c) 2020 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. #ifndef _DP_RX_BUFFER_POOL_H_
  19. #define _DP_RX_BUFFER_POOL_H_
  20. #include "dp_types.h"
  21. #include "qdf_nbuf.h"
  22. #include "qdf_module.h"
  23. #include "athdefs.h"
  24. #include "wlan_cfg.h"
  25. #include "dp_internal.h"
  26. #include "dp_rx.h"
  27. #include "dp_rx_mon.h"
  28. #ifdef WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL
  29. /**
  30. * dp_rx_buffer_pool_init() - Initialize emergency buffer pool
  31. * @soc: SoC handle
  32. * @mac_id: MAC ID
  33. *
  34. * Return: None
  35. */
  36. void dp_rx_buffer_pool_init(struct dp_soc *soc, u8 mac_id);
  37. /**
  38. * dp_rx_buffer_pool_deinit() - De-Initialize emergency buffer pool
  39. * @soc: SoC handle
  40. * @mac_id: MAC ID
  41. *
  42. * Return: None
  43. */
  44. void dp_rx_buffer_pool_deinit(struct dp_soc *soc, u8 mac_id);
  45. /**
  46. * dp_rx_buffer_pool_refill() - Process the rx nbuf list and
  47. * refill the emergency buffer pool
  48. * @soc: SoC handle
  49. * @nbuf: RX buffer
  50. * @mac_id: MAC ID
  51. *
  52. * Return: Whether the rx nbuf is consumed into the pool or not.
  53. */
  54. bool dp_rx_buffer_pool_refill(struct dp_soc *soc, qdf_nbuf_t nbuf, u8 mac_id);
  55. /**
  56. * dp_rx_buffer_pool_nbuf_free() - Free the nbuf or queue it
  57. * back into the pool
  58. * @soc: SoC handle
  59. * @nbuf: RX buffer
  60. * @mac_id: MAC ID
  61. *
  62. * Return: None
  63. */
  64. void dp_rx_buffer_pool_nbuf_free(struct dp_soc *soc, qdf_nbuf_t nbuf,
  65. u8 mac_id);
  66. /**
  67. * dp_rx_buffer_pool_nbuf_alloc() - Allocate nbuf for buffer replenish,
  68. * give nbuf from the pool if allocation fails
  69. * @soc: SoC handle
  70. * @mac_id: MAC ID
  71. * @rx_desc_pool: RX descriptor pool
  72. * @num_available_buffers: number of available buffers in the ring.
  73. *
  74. * Return: nbuf
  75. */
  76. qdf_nbuf_t dp_rx_buffer_pool_nbuf_alloc(struct dp_soc *soc, uint32_t mac_id,
  77. struct rx_desc_pool *rx_desc_pool,
  78. uint32_t num_available_buffers);
  79. #else
  80. /**
  81. * dp_rx_buffer_pool_init() - Initialize emergency buffer pool
  82. * @soc: SoC handle
  83. * @mac_id: MAC ID
  84. *
  85. * Return: None
  86. */
  87. static inline
  88. void dp_rx_buffer_pool_init(struct dp_soc *soc, u8 mac_id)
  89. {
  90. soc->rx_buff_pool[mac_id].is_initialized = false;
  91. }
  92. /**
  93. * dp_rx_buffer_pool_deinit() - De-Initialize emergency buffer pool
  94. * @soc: SoC handle
  95. * @mac_id: MAC ID
  96. *
  97. * Return: None
  98. */
  99. static inline
  100. void dp_rx_buffer_pool_deinit(struct dp_soc *soc, u8 mac_id)
  101. {
  102. }
  103. /**
  104. * dp_rx_buffer_pool_refill() - Process the rx nbuf list and
  105. * refill the emergency buffer pool
  106. * @soc: SoC handle
  107. * @nbuf: RX buffer
  108. * @mac_id: MAC ID
  109. *
  110. * Return: Whether the rx nbuf is consumed into the pool or not.
  111. */
  112. static inline
  113. bool dp_rx_buffer_pool_refill(struct dp_soc *soc, qdf_nbuf_t nbuf, u8 mac_id)
  114. {
  115. return false;
  116. }
  117. /**
  118. * dp_rx_buffer_pool_nbuf_free() - Free the nbuf or queue it
  119. * back into the pool
  120. * @soc: SoC handle
  121. * @nbuf: RX buffer
  122. * @mac_id: MAC ID
  123. *
  124. * Return: None
  125. */
  126. static inline
  127. void dp_rx_buffer_pool_nbuf_free(struct dp_soc *soc, qdf_nbuf_t nbuf,
  128. u8 mac_id)
  129. {
  130. qdf_nbuf_free(nbuf);
  131. }
  132. /**
  133. * dp_rx_buffer_pool_nbuf_alloc() - Allocate nbuf for buffer replenish,
  134. * give nbuf from the pool if allocation fails
  135. * @soc: SoC handle
  136. * @mac_id: MAC ID
  137. * @rx_desc_pool: RX descriptor pool
  138. * @num_available_buffers: number of available buffers in the ring.
  139. *
  140. * Return: nbuf
  141. */
  142. static inline qdf_nbuf_t
  143. dp_rx_buffer_pool_nbuf_alloc(struct dp_soc *soc, uint32_t mac_id,
  144. struct rx_desc_pool *rx_desc_pool,
  145. uint32_t num_available_buffers)
  146. {
  147. return qdf_nbuf_alloc(soc->osdev, rx_desc_pool->buf_size,
  148. RX_BUFFER_RESERVATION,
  149. rx_desc_pool->buf_alignment, FALSE);
  150. }
  151. #endif /* WLAN_FEATURE_RX_PREALLOC_BUFFER_POOL */
  152. #endif /* _DP_RX_BUFFER_POOL_H_ */