dp_rx_mon.h 12 KB

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