dp_rx_mon.h 10 KB

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