dp_li_rx.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-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. #ifndef _DP_LI_RX_H_
  20. #define _DP_LI_RX_H_
  21. #include <dp_types.h>
  22. #include <dp_rx.h>
  23. #include "dp_li.h"
  24. /**
  25. * dp_rx_process_li() - Brain of the Rx processing functionality
  26. * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
  27. * @int_ctx: per interrupt context
  28. * @hal_ring_hdl: opaque pointer to the HAL Rx Ring, which will be serviced
  29. * @reo_ring_num: ring number (0, 1, 2 or 3) of the reo ring.
  30. * @quota: No. of units (packets) that can be serviced in one shot.
  31. *
  32. * This function implements the core of Rx functionality. This is
  33. * expected to handle only non-error frames.
  34. *
  35. * Return: uint32_t: No. of elements processed
  36. */
  37. uint32_t dp_rx_process_li(struct dp_intr *int_ctx,
  38. hal_ring_handle_t hal_ring_hdl, uint8_t reo_ring_num,
  39. uint32_t quota);
  40. /**
  41. * dp_rx_chain_msdus_li() - Function to chain all msdus of a mpdu
  42. * to pdev invalid peer list
  43. *
  44. * @soc: core DP main context
  45. * @nbuf: Buffer pointer
  46. * @rx_tlv_hdr: start of rx tlv header
  47. * @mac_id: mac id
  48. *
  49. * Return: bool: true for last msdu of mpdu
  50. */
  51. bool dp_rx_chain_msdus_li(struct dp_soc *soc, qdf_nbuf_t nbuf,
  52. uint8_t *rx_tlv_hdr, uint8_t mac_id);
  53. /**
  54. * dp_rx_desc_pool_init_li() - Initialize Rx Descriptor pool(s)
  55. * @soc: Handle to DP Soc structure
  56. * @rx_desc_pool: Rx descriptor pool handler
  57. * @pool_id: Rx descriptor pool ID
  58. *
  59. * Return: None
  60. */
  61. QDF_STATUS dp_rx_desc_pool_init_li(struct dp_soc *soc,
  62. struct rx_desc_pool *rx_desc_pool,
  63. uint32_t pool_id);
  64. /**
  65. * dp_rx_desc_pool_deinit_li() - De-initialize Rx Descriptor pool(s)
  66. * @soc: Handle to DP Soc structure
  67. * @rx_desc_pool: Rx descriptor pool handler
  68. * @pool_id: Rx descriptor pool ID
  69. *
  70. * Return: None
  71. */
  72. void dp_rx_desc_pool_deinit_li(struct dp_soc *soc,
  73. struct rx_desc_pool *rx_desc_pool,
  74. uint32_t pool_id);
  75. /**
  76. * dp_wbm_get_rx_desc_from_hal_desc_li() - Get corresponding Rx Desc
  77. * address from WBM ring Desc
  78. * @soc: Handle to DP Soc structure
  79. * @ring_desc: ring descriptor structure pointer
  80. * @r_rx_desc: pointer to a pointer of Rx Desc
  81. *
  82. * Return: QDF_STATUS_SUCCESS - succeeded, others - failed
  83. */
  84. QDF_STATUS dp_wbm_get_rx_desc_from_hal_desc_li(
  85. struct dp_soc *soc,
  86. void *ring_desc,
  87. struct dp_rx_desc **r_rx_desc);
  88. /**
  89. * dp_rx_get_reo_qdesc_addr_li(): API to get qdesc address of reo
  90. * entrance ring desc
  91. *
  92. * @hal_soc: Handle to HAL Soc structure
  93. * @dst_ring_desc: reo dest ring descriptor (used for Lithium DP)
  94. * @buf: pointer to the start of RX PKT TLV headers
  95. * @txrx_peer: pointer to txrx_peer
  96. * @tid: tid value
  97. *
  98. * Return: qdesc address in reo destination ring buffer
  99. */
  100. static inline
  101. uint64_t dp_rx_get_reo_qdesc_addr_li(hal_soc_handle_t hal_soc,
  102. uint8_t *dst_ring_desc,
  103. uint8_t *buf,
  104. struct dp_txrx_peer *txrx_peer,
  105. unsigned int tid)
  106. {
  107. return hal_rx_get_qdesc_addr(hal_soc, dst_ring_desc, buf);
  108. }
  109. /**
  110. * dp_rx_desc_cookie_2_va_li() - Convert RX Desc cookie ID to VA
  111. * @soc:Handle to DP Soc structure
  112. * @cookie: cookie used to lookup virtual address
  113. *
  114. * Return: Rx descriptor virtual address
  115. */
  116. static inline
  117. struct dp_rx_desc *dp_rx_desc_cookie_2_va_li(struct dp_soc *soc,
  118. uint32_t cookie)
  119. {
  120. return dp_rx_cookie_2_va_rxdma_buf(soc, cookie);
  121. }
  122. #define DP_PEER_METADATA_VDEV_ID_MASK 0x003f0000
  123. #define DP_PEER_METADATA_VDEV_ID_SHIFT 16
  124. #define DP_PEER_METADATA_OFFLOAD_MASK 0x01000000
  125. #define DP_PEER_METADATA_OFFLOAD_SHIFT 24
  126. #define DP_PEER_METADATA_VDEV_ID_GET_LI(_peer_metadata) \
  127. (((_peer_metadata) & DP_PEER_METADATA_VDEV_ID_MASK) \
  128. >> DP_PEER_METADATA_VDEV_ID_SHIFT)
  129. #define DP_PEER_METADATA_OFFLOAD_GET_LI(_peer_metadata) \
  130. (((_peer_metadata) & DP_PEER_METADATA_OFFLOAD_MASK) \
  131. >> DP_PEER_METADATA_OFFLOAD_SHIFT)
  132. static inline uint16_t
  133. dp_rx_peer_metadata_peer_id_get_li(struct dp_soc *soc, uint32_t peer_metadata)
  134. {
  135. struct htt_rx_peer_metadata_v0 *metadata =
  136. (struct htt_rx_peer_metadata_v0 *)&peer_metadata;
  137. return metadata->peer_id;
  138. }
  139. bool
  140. dp_rx_intrabss_handle_nawds_li(struct dp_soc *soc, struct dp_txrx_peer *ta_peer,
  141. qdf_nbuf_t nbuf_copy,
  142. struct cdp_tid_rx_stats *tid_stats);
  143. #ifdef QCA_DP_RX_NBUF_AND_NBUF_DATA_PREFETCH
  144. static inline
  145. void dp_rx_prefetch_nbuf_data(qdf_nbuf_t nbuf, qdf_nbuf_t next)
  146. {
  147. struct rx_pkt_tlvs *pkt_tlvs;
  148. if (next) {
  149. /* prefetch skb->next and first few bytes of skb->cb */
  150. qdf_prefetch(next);
  151. /* skb->cb spread across 2 cache lines hence below prefetch */
  152. qdf_prefetch(&next->_skb_refdst);
  153. qdf_prefetch(&next->len);
  154. qdf_prefetch(&next->protocol);
  155. pkt_tlvs = (struct rx_pkt_tlvs *)next->data;
  156. /* sa_idx, da_idx, l3_pad in RX msdu_end TLV */
  157. qdf_prefetch(pkt_tlvs);
  158. /* msdu_done in RX attention TLV */
  159. qdf_prefetch(&pkt_tlvs->attn_tlv);
  160. /* fr_ds & to_ds in RX MPDU start TLV */
  161. if (qdf_nbuf_is_rx_chfrag_end(nbuf))
  162. qdf_prefetch(&pkt_tlvs->mpdu_start_tlv);
  163. }
  164. }
  165. #else
  166. static inline
  167. void dp_rx_prefetch_nbuf_data(qdf_nbuf_t nbuf, qdf_nbuf_t next)
  168. {
  169. }
  170. #endif
  171. #ifdef QCA_DP_RX_HW_SW_NBUF_DESC_PREFETCH
  172. /**
  173. * dp_rx_cookie_2_va_rxdma_buf_prefetch() - function to prefetch the SW desc
  174. * @soc: Handle to DP Soc structure
  175. * @cookie: cookie used to lookup virtual address
  176. *
  177. * Return: prefetched Rx descriptor virtual address
  178. */
  179. static inline
  180. void *dp_rx_cookie_2_va_rxdma_buf_prefetch(struct dp_soc *soc, uint32_t cookie)
  181. {
  182. uint8_t pool_id = DP_RX_DESC_COOKIE_POOL_ID_GET(cookie);
  183. uint16_t index = DP_RX_DESC_COOKIE_INDEX_GET(cookie);
  184. struct rx_desc_pool *rx_desc_pool;
  185. void *prefetch_desc;
  186. if (qdf_unlikely(pool_id >= MAX_RXDESC_POOLS))
  187. return NULL;
  188. rx_desc_pool = &soc->rx_desc_buf[pool_id];
  189. if (qdf_unlikely(index >= rx_desc_pool->pool_size))
  190. return NULL;
  191. prefetch_desc = &soc->rx_desc_buf[pool_id].array[index].rx_desc;
  192. qdf_prefetch(prefetch_desc);
  193. return prefetch_desc;
  194. }
  195. /**
  196. * dp_rx_prefetch_hw_sw_nbuf_desc() - function to prefetch HW and SW desc
  197. * @soc: Handle to DP Soc structure
  198. * @hal_soc: Handle to HAL Soc structure
  199. * @num_entries: valid number of HW descriptors
  200. * @hal_ring_hdl: Destination ring pointer
  201. * @last_prefetched_hw_desc: pointer to the last prefetched HW descriptor
  202. * @last_prefetched_sw_desc: input & output param of last prefetch SW desc
  203. *
  204. * Return: None
  205. */
  206. static inline
  207. void dp_rx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  208. hal_soc_handle_t hal_soc,
  209. uint32_t num_entries,
  210. hal_ring_handle_t hal_ring_hdl,
  211. hal_ring_desc_t *last_prefetched_hw_desc,
  212. struct dp_rx_desc **last_prefetched_sw_desc)
  213. {
  214. if (*last_prefetched_sw_desc) {
  215. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf);
  216. qdf_prefetch((uint8_t *)(*last_prefetched_sw_desc)->nbuf + 64);
  217. }
  218. if (num_entries) {
  219. *last_prefetched_sw_desc = dp_rx_cookie_2_va_rxdma_buf_prefetch(soc, HAL_RX_REO_BUF_COOKIE_GET(*last_prefetched_hw_desc));
  220. *last_prefetched_hw_desc = hal_srng_dst_prefetch_next_cached_desc(hal_soc,
  221. hal_ring_hdl,
  222. (uint8_t *)*last_prefetched_hw_desc);
  223. }
  224. }
  225. #else
  226. static inline
  227. void dp_rx_prefetch_hw_sw_nbuf_desc(struct dp_soc *soc,
  228. hal_soc_handle_t hal_soc,
  229. uint32_t quota,
  230. hal_ring_handle_t hal_ring_hdl,
  231. hal_ring_desc_t *last_prefetched_hw_desc,
  232. struct dp_rx_desc **last_prefetched_sw_desc)
  233. {
  234. }
  235. #endif
  236. static inline
  237. QDF_STATUS dp_peer_rx_reorder_queue_setup_li(struct dp_soc *soc,
  238. struct dp_peer *peer,
  239. int tid,
  240. uint32_t ba_window_size)
  241. {
  242. struct dp_rx_tid *rx_tid = &peer->rx_tid[tid];
  243. if (!rx_tid->hw_qdesc_paddr)
  244. return QDF_STATUS_E_INVAL;
  245. if (soc->cdp_soc.ol_ops->peer_rx_reorder_queue_setup) {
  246. if (soc->cdp_soc.ol_ops->peer_rx_reorder_queue_setup(
  247. soc->ctrl_psoc,
  248. peer->vdev->pdev->pdev_id,
  249. peer->vdev->vdev_id,
  250. peer->mac_addr.raw, rx_tid->hw_qdesc_paddr, tid, tid,
  251. 1, ba_window_size)) {
  252. dp_peer_err("%pK: Failed to send reo queue setup to FW - tid %d\n",
  253. soc, tid);
  254. return QDF_STATUS_E_FAILURE;
  255. }
  256. }
  257. return QDF_STATUS_SUCCESS;
  258. }
  259. #endif