dp_rx_mon.h 12 KB

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