dp_rx_mon.h 12 KB

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