dp_rx_mon.h 11 KB

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