dp_rx_mon.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * Copyright (c) 2016-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_MON_H_
  19. #define _DP_RX_MON_H_
  20. /**
  21. * dp_rx_mon_dest_process() - Brain of the Rx processing functionality
  22. * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
  23. * @soc: core txrx main context 164
  24. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  25. * @quota: No. of units (packets) that can be serviced in one shot.
  26. *
  27. * This function implements the core of Rx functionality. This is
  28. * expected to handle only non-error frames.
  29. *
  30. * Return: uint32_t: No. of elements processed
  31. */
  32. void dp_rx_mon_dest_process(struct dp_soc *soc, uint32_t mac_id,
  33. uint32_t quota);
  34. QDF_STATUS dp_rx_pdev_mon_attach(struct dp_pdev *pdev);
  35. QDF_STATUS dp_rx_pdev_mon_detach(struct dp_pdev *pdev);
  36. QDF_STATUS dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev, int mac_id);
  37. QDF_STATUS dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev, int mac_id);
  38. /**
  39. * dp_reset_monitor_mode() - Disable monitor mode
  40. * @pdev_handle: Datapath PDEV handle
  41. *
  42. * Return: QDF_STATUS
  43. */
  44. QDF_STATUS dp_reset_monitor_mode(struct cdp_soc_t *soc_hdl,
  45. uint8_t pdev_id,
  46. uint8_t smart_monitor);
  47. /**
  48. * dp_mon_link_free() - free monitor link desc pool
  49. * @pdev: core txrx pdev context
  50. *
  51. * This function will release DP link desc pool for monitor mode from
  52. * main device context.
  53. *
  54. * Return: QDF_STATUS_SUCCESS: success
  55. * QDF_STATUS_E_RESOURCES: Error return
  56. */
  57. QDF_STATUS dp_mon_link_free(struct dp_pdev *pdev);
  58. uint32_t dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota);
  59. QDF_STATUS dp_rx_mon_deliver(struct dp_soc *soc, uint32_t mac_id,
  60. qdf_nbuf_t head_msdu, qdf_nbuf_t tail_msdu);
  61. /*
  62. * dp_rx_mon_deliver_non_std() - deliver frames for non standard path
  63. * @soc: core txrx main contex
  64. * @mac_id: MAC ID
  65. *
  66. * This function delivers the radio tap and dummy MSDU
  67. * into user layer application for preamble only PPDU.
  68. *
  69. * Return: Operation status
  70. */
  71. QDF_STATUS dp_rx_mon_deliver_non_std(struct dp_soc *soc, uint32_t mac_id);
  72. /**
  73. * dp_rxdma_err_process() - RxDMA error processing functionality
  74. * @soc: core txrx main contex
  75. * @mac_id: mac id which is one of 3 mac_ids
  76. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  77. * @quota: No. of units (packets) that can be serviced in one shot.
  78. *
  79. * Return: num of buffers processed
  80. */
  81. uint32_t dp_rxdma_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  82. uint32_t mac_id, uint32_t quota);
  83. /**
  84. * dp_mon_buf_delayed_replenish() - Helper routine to replenish monitor dest buf
  85. * @pdev: DP pdev object
  86. *
  87. * Return: None
  88. */
  89. void dp_mon_buf_delayed_replenish(struct dp_pdev *pdev);
  90. /**
  91. * dp_rx_mon_link_desc_return() - Return a MPDU link descriptor to HW
  92. * (WBM), following error handling
  93. *
  94. * @dp_pdev: core txrx pdev context
  95. * @buf_addr_info: void pointer to monitor link descriptor buf addr info
  96. * Return: QDF_STATUS
  97. */
  98. QDF_STATUS
  99. dp_rx_mon_link_desc_return(struct dp_pdev *dp_pdev,
  100. hal_buff_addrinfo_t buf_addr_info,
  101. int mac_id);
  102. /**
  103. * dp_mon_adjust_frag_len() - MPDU and MSDU may spread across
  104. * multiple nbufs. This function
  105. * is to return data length in
  106. * fragmented buffer
  107. *
  108. * @total_len: pointer to remaining data length.
  109. * @frag_len: pointer to data length in this fragment.
  110. */
  111. static inline void dp_mon_adjust_frag_len(uint32_t *total_len,
  112. uint32_t *frag_len)
  113. {
  114. if (*total_len >= (RX_MONITOR_BUFFER_SIZE - RX_PKT_TLVS_LEN)) {
  115. *frag_len = RX_MONITOR_BUFFER_SIZE - RX_PKT_TLVS_LEN;
  116. *total_len -= *frag_len;
  117. } else {
  118. *frag_len = *total_len;
  119. *total_len = 0;
  120. }
  121. }
  122. /**
  123. * dp_rx_cookie_2_mon_link_desc() - Retrieve Link descriptor based on target
  124. * @pdev: core physical device context
  125. * @hal_buf_info: structure holding the buffer info
  126. * mac_id: mac number
  127. *
  128. * Return: link descriptor address
  129. */
  130. static inline
  131. void *dp_rx_cookie_2_mon_link_desc(struct dp_pdev *pdev,
  132. struct hal_buf_info buf_info,
  133. uint8_t mac_id)
  134. {
  135. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
  136. return dp_rx_cookie_2_mon_link_desc_va(pdev, &buf_info,
  137. mac_id);
  138. return dp_rx_cookie_2_link_desc_va(pdev->soc, &buf_info);
  139. }
  140. /**
  141. * dp_rx_monitor_link_desc_return() - Return Link descriptor based on target
  142. * @pdev: core physical device context
  143. * @p_last_buf_addr_info: MPDU Link descriptor
  144. * mac_id: mac number
  145. *
  146. * Return: QDF_STATUS
  147. */
  148. static inline
  149. QDF_STATUS dp_rx_monitor_link_desc_return(struct dp_pdev *pdev,
  150. hal_buff_addrinfo_t
  151. p_last_buf_addr_info,
  152. uint8_t mac_id, uint8_t bm_action)
  153. {
  154. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
  155. return dp_rx_mon_link_desc_return(pdev, p_last_buf_addr_info,
  156. mac_id);
  157. return dp_rx_link_desc_return_by_addr(pdev->soc, p_last_buf_addr_info,
  158. bm_action);
  159. }
  160. /**
  161. * dp_rxdma_get_mon_dst_ring() - Return the pointer to rxdma_err_dst_ring
  162. * or mon_dst_ring based on the target
  163. * @pdev: core physical device context
  164. * @mac_for_pdev: mac_id number
  165. *
  166. * Return: ring address
  167. */
  168. static inline
  169. void *dp_rxdma_get_mon_dst_ring(struct dp_pdev *pdev,
  170. uint8_t mac_for_pdev)
  171. {
  172. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
  173. return pdev->soc->rxdma_mon_dst_ring[mac_for_pdev].hal_srng;
  174. return pdev->soc->rxdma_err_dst_ring[mac_for_pdev].hal_srng;
  175. }
  176. /**
  177. * dp_rxdma_get_mon_buf_ring() - Return monitor buf ring address
  178. * based on target
  179. * @pdev: core physical device context
  180. * @mac_for_pdev: mac id number
  181. *
  182. * Return: ring address
  183. */
  184. static inline
  185. struct dp_srng *dp_rxdma_get_mon_buf_ring(struct dp_pdev *pdev,
  186. uint8_t mac_for_pdev)
  187. {
  188. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
  189. return &pdev->soc->rxdma_mon_buf_ring[mac_for_pdev];
  190. return &pdev->soc->rx_refill_buf_ring[mac_for_pdev];
  191. }
  192. /**
  193. * dp_rx_get_mon_desc_pool() - Return monitor descriptor pool
  194. * based on target
  195. * @soc: soc handle
  196. * @mac_id: mac id number
  197. * @pdev_id: pdev id number
  198. *
  199. * Return: descriptor pool address
  200. */
  201. static inline
  202. struct rx_desc_pool *dp_rx_get_mon_desc_pool(struct dp_soc *soc,
  203. uint8_t mac_id,
  204. uint8_t pdev_id)
  205. {
  206. if (soc->wlan_cfg_ctx->rxdma1_enable)
  207. return &soc->rx_desc_mon[mac_id];
  208. return &soc->rx_desc_buf[pdev_id];
  209. }
  210. /**
  211. * dp_rx_get_mon_desc() - Return Rx descriptor based on target
  212. * @soc: soc handle
  213. * @cookie: cookie value
  214. *
  215. * Return: Rx descriptor
  216. */
  217. static inline
  218. struct dp_rx_desc *dp_rx_get_mon_desc(struct dp_soc *soc,
  219. uint32_t cookie)
  220. {
  221. if (soc->wlan_cfg_ctx->rxdma1_enable)
  222. return dp_rx_cookie_2_va_mon_buf(soc, cookie);
  223. return dp_rx_cookie_2_va_rxdma_buf(soc, cookie);
  224. }
  225. #ifndef REMOVE_MON_DBG_STATS
  226. /*
  227. * dp_rx_mon_update_dbg_ppdu_stats() - Update status ring TLV count
  228. * @ppdu_info: HAL RX PPDU info retrieved from status ring TLV
  229. * @rx_mon_stats: monitor mode status/destination ring PPDU and MPDU count
  230. *
  231. * Update status ring PPDU start and end count. Keep track TLV state on
  232. * PPDU start and end to find out if start and end is matching. Keep
  233. * track missing PPDU start and end count. Keep track matching PPDU
  234. * start and end count.
  235. *
  236. * Return: None
  237. */
  238. static inline void
  239. dp_rx_mon_update_dbg_ppdu_stats(struct hal_rx_ppdu_info *ppdu_info,
  240. struct cdp_pdev_mon_stats *rx_mon_stats)
  241. {
  242. if (ppdu_info->rx_state ==
  243. HAL_RX_MON_PPDU_START) {
  244. rx_mon_stats->status_ppdu_start++;
  245. if (rx_mon_stats->status_ppdu_state
  246. != CDP_MON_PPDU_END)
  247. rx_mon_stats->status_ppdu_end_mis++;
  248. rx_mon_stats->status_ppdu_state
  249. = CDP_MON_PPDU_START;
  250. } else if (ppdu_info->rx_state ==
  251. HAL_RX_MON_PPDU_END) {
  252. rx_mon_stats->status_ppdu_end++;
  253. if (rx_mon_stats->status_ppdu_state
  254. != CDP_MON_PPDU_START)
  255. rx_mon_stats->status_ppdu_start_mis++;
  256. else
  257. rx_mon_stats->status_ppdu_compl++;
  258. rx_mon_stats->status_ppdu_state
  259. = CDP_MON_PPDU_END;
  260. }
  261. }
  262. /*
  263. * dp_rx_mon_init_dbg_ppdu_stats() - initialization for monitor mode stats
  264. * @ppdu_info: HAL RX PPDU info retrieved from status ring TLV
  265. * @rx_mon_stats: monitor mode status/destination ring PPDU and MPDU count
  266. *
  267. * Return: None
  268. */
  269. static inline void
  270. dp_rx_mon_init_dbg_ppdu_stats(struct hal_rx_ppdu_info *ppdu_info,
  271. struct cdp_pdev_mon_stats *rx_mon_stats)
  272. {
  273. ppdu_info->rx_state = HAL_RX_MON_PPDU_END;
  274. rx_mon_stats->status_ppdu_state
  275. = CDP_MON_PPDU_END;
  276. }
  277. #else
  278. static inline void
  279. dp_rx_mon_update_dbg_ppdu_stats(struct hal_rx_ppdu_info *ppdu_info,
  280. struct cdp_pdev_mon_stats *rx_mon_stats)
  281. {
  282. }
  283. static inline void
  284. dp_rx_mon_init_dbg_ppdu_stats(struct hal_rx_ppdu_info *ppdu_info,
  285. struct cdp_pdev_mon_stats *rx_mon_stats)
  286. {
  287. }
  288. #endif
  289. #endif