dp_li_rx.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * Copyright (c) 2016-2021 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_LI_RX_H_
  19. #define _DP_LI_RX_H_
  20. #include <dp_types.h>
  21. #include <dp_rx.h>
  22. #include "dp_li.h"
  23. uint32_t dp_rx_process_li(struct dp_intr *int_ctx,
  24. hal_ring_handle_t hal_ring_hdl, uint8_t reo_ring_num,
  25. uint32_t quota);
  26. /**
  27. * dp_rx_desc_pool_init_li() - Initialize Rx Descriptor pool(s)
  28. * @soc: Handle to DP Soc structure
  29. * @rx_desc_pool: Rx descriptor pool handler
  30. * @pool_id: Rx descriptor pool ID
  31. *
  32. * Return: None
  33. */
  34. QDF_STATUS dp_rx_desc_pool_init_li(struct dp_soc *soc,
  35. struct rx_desc_pool *rx_desc_pool,
  36. uint32_t pool_id);
  37. /**
  38. * dp_rx_desc_pool_deinit_li() - De-initialize Rx Descriptor pool(s)
  39. * @soc: Handle to DP Soc structure
  40. * @rx_desc_pool: Rx descriptor pool handler
  41. * @pool_id: Rx descriptor pool ID
  42. *
  43. * Return: None
  44. */
  45. void dp_rx_desc_pool_deinit_li(struct dp_soc *soc,
  46. struct rx_desc_pool *rx_desc_pool,
  47. uint32_t pool_id);
  48. /**
  49. * dp_wbm_get_rx_desc_from_hal_desc_li() - Get corresponding Rx Desc
  50. * address from WBM ring Desc
  51. * @soc: Handle to DP Soc structure
  52. * @ring_desc: ring descriptor structure pointer
  53. * @r_rx_desc: pointer to a pointer of Rx Desc
  54. *
  55. * Return: QDF_STATUS_SUCCESS - succeeded, others - failed
  56. */
  57. QDF_STATUS dp_wbm_get_rx_desc_from_hal_desc_li(
  58. struct dp_soc *soc,
  59. void *ring_desc,
  60. struct dp_rx_desc **r_rx_desc);
  61. /**
  62. * dp_rx_desc_cookie_2_va_li() - Convert RX Desc cookie ID to VA
  63. * @soc:Handle to DP Soc structure
  64. * @cookie: cookie used to lookup virtual address
  65. *
  66. * Return: Rx descriptor virtual address
  67. */
  68. static inline
  69. struct dp_rx_desc *dp_rx_desc_cookie_2_va_li(struct dp_soc *soc,
  70. uint32_t cookie)
  71. {
  72. return dp_rx_cookie_2_va_rxdma_buf(soc, cookie);
  73. }
  74. #define DP_PEER_METADATA_VDEV_ID_MASK 0x003f0000
  75. #define DP_PEER_METADATA_VDEV_ID_SHIFT 16
  76. #define DP_PEER_METADATA_OFFLOAD_MASK 0x01000000
  77. #define DP_PEER_METADATA_OFFLOAD_SHIFT 24
  78. #define DP_PEER_METADATA_VDEV_ID_GET_LI(_peer_metadata) \
  79. (((_peer_metadata) & DP_PEER_METADATA_VDEV_ID_MASK) \
  80. >> DP_PEER_METADATA_VDEV_ID_SHIFT)
  81. #define DP_PEER_METADATA_OFFLOAD_GET_LI(_peer_metadata) \
  82. (((_peer_metadata) & DP_PEER_METADATA_OFFLOAD_MASK) \
  83. >> DP_PEER_METADATA_OFFLOAD_SHIFT)
  84. static inline uint16_t
  85. dp_rx_peer_metadata_peer_id_get_li(struct dp_soc *soc, uint32_t peer_metadata)
  86. {
  87. struct htt_rx_peer_metadata_v0 *metadata =
  88. (struct htt_rx_peer_metadata_v0 *)&peer_metadata;
  89. return metadata->peer_id;
  90. }
  91. #ifdef QCA_DP_RX_NBUF_AND_NBUF_DATA_PREFETCH
  92. static inline
  93. void dp_rx_prefetch_nbuf_data(qdf_nbuf_t nbuf, qdf_nbuf_t next)
  94. {
  95. struct rx_pkt_tlvs *pkt_tlvs;
  96. if (next) {
  97. /* prefetch skb->next and first few bytes of skb->cb */
  98. qdf_prefetch(next);
  99. /* skb->cb spread across 2 cache lines hence below prefetch */
  100. qdf_prefetch(&next->_skb_refdst);
  101. qdf_prefetch(&next->len);
  102. qdf_prefetch(&next->protocol);
  103. pkt_tlvs = (struct rx_pkt_tlvs *)next->data;
  104. /* sa_idx, da_idx, l3_pad in RX msdu_end TLV */
  105. qdf_prefetch(pkt_tlvs);
  106. /* msdu_done in RX attention TLV */
  107. qdf_prefetch(&pkt_tlvs->attn_tlv);
  108. /* fr_ds & to_ds in RX MPDU start TLV */
  109. if (qdf_nbuf_is_rx_chfrag_end(nbuf))
  110. qdf_prefetch(&pkt_tlvs->mpdu_start_tlv);
  111. }
  112. }
  113. #else
  114. static inline
  115. void dp_rx_prefetch_nbuf_data(qdf_nbuf_t nbuf, qdf_nbuf_t next)
  116. {
  117. }
  118. #endif
  119. #ifdef QCA_DP_RX_HW_SW_NBUF_DESC_PREFETCH
  120. /**
  121. * dp_rx_cookie_2_va_rxdma_buf_prefetch() - function to prefetch the SW desc
  122. * @soc: Handle to DP Soc structure
  123. * @cookie: cookie used to lookup virtual address
  124. *
  125. * Return: prefetched Rx descriptor virtual address
  126. */
  127. static inline
  128. void *dp_rx_cookie_2_va_rxdma_buf_prefetch(struct dp_soc *soc, uint32_t cookie)
  129. {
  130. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  131. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  132. struct rx_desc_pool *rx_desc_pool;
  133. void *prefetch_desc;
  134. if (qdf_unlikely(pool_id >= MAX_RXDESC_POOLS))
  135. return NULL;
  136. rx_desc_pool = &soc->rx_desc_buf[pool_id];
  137. if (qdf_unlikely(index >= rx_desc_pool->pool_size))
  138. return NULL;
  139. prefetch_desc = &soc->rx_desc_buf[pool_id].array[index].rx_desc;
  140. qdf_prefetch(prefetch_desc);
  141. return prefetch_desc;
  142. }
  143. /**
  144. * dp_rx_prefetch_hw_sw_nbuf_desc() - function to prefetch HW and SW desc
  145. * @soc: Handle to HAL Soc structure
  146. * @num_entries: valid number of HW descriptors
  147. * @hal_ring_hdl: Destination ring pointer
  148. * @last_prefetched_hw_desc: pointer to the last prefetched HW descriptor
  149. * @last_prefetched_sw_desc: input & output param of last prefetch SW desc
  150. *
  151. * Return: None
  152. */
  153. static inline
  154. void dp_rx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  155. hal_soc_handle_t hal_soc,
  156. uint32_t num_entries,
  157. hal_ring_handle_t hal_ring_hdl,
  158. hal_ring_desc_t *last_prefetched_hw_desc,
  159. struct dp_rx_desc **last_prefetched_sw_desc)
  160. {
  161. if (*last_prefetched_sw_desc) {
  162. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf);
  163. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf + 64);
  164. }
  165. if (num_entries) {
  166. *last_prefetched_sw_desc = dp_rx_cookie_2_va_rxdma_buf_prefetch(soc, HAL_RX_REO_BUF_COOKIE_GET(*last_prefetched_hw_desc));
  167. *last_prefetched_hw_desc = hal_srng_dst_prefetch_next_cached_desc(hal_soc,
  168. hal_ring_hdl,
  169. (uint8_t *)*last_prefetched_hw_desc);
  170. }
  171. }
  172. #else
  173. static inline
  174. void dp_rx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  175. hal_soc_handle_t hal_soc,
  176. uint32_t quota,
  177. hal_ring_handle_t hal_ring_hdl,
  178. hal_ring_desc_t *last_prefetched_hw_desc,
  179. struct dp_rx_desc **last_prefetched_sw_desc)
  180. {
  181. }
  182. #endif
  183. #endif