dp_rx_mon.h 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  1. /*
  2. * Copyright (c) 2016-2021 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. * The below macro defines the maximum number of ring entries that would
  28. * be processed in a single instance when processing each of the non-monitoring
  29. * RXDMA2SW ring.
  30. */
  31. #define MON_DROP_REAP_LIMIT 64
  32. /*
  33. * The maximum headroom reserved for monitor destination buffer to
  34. * accomodate radiotap header and protocol flow tag
  35. */
  36. #ifdef DP_RX_MON_MEM_FRAG
  37. /*
  38. * -------------------------------------------------
  39. * | Protocol & Flow TAG | Radiotap header|
  40. * | | Length(128 B) |
  41. * | ((4* QDF_NBUF_MAX_FRAGS) * 2) | |
  42. * -------------------------------------------------
  43. */
  44. #define DP_RX_MON_MAX_RADIO_TAP_HDR (128)
  45. #define DP_RX_MON_PF_TAG_LEN_PER_FRAG (4)
  46. #define DP_RX_MON_TOT_PF_TAG_LEN \
  47. ((DP_RX_MON_PF_TAG_LEN_PER_FRAG) * (QDF_NBUF_MAX_FRAGS))
  48. #define DP_RX_MON_MAX_MONITOR_HEADER \
  49. ((DP_RX_MON_TOT_PF_TAG_LEN * 2) + (DP_RX_MON_MAX_RADIO_TAP_HDR))
  50. #endif
  51. /* The maximum buffer length allocated for radiotap for monitor status buffer */
  52. #define MAX_MONITOR_HEADER (512)
  53. /* l2 header pad byte in case of Raw frame is Zero and 2 in non raw */
  54. #define DP_RX_MON_RAW_L2_HDR_PAD_BYTE (0)
  55. #define DP_RX_MON_NONRAW_L2_HDR_PAD_BYTE (2)
  56. #define dp_rx_mon_dest_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_RX_MON_DEST, params)
  57. #define dp_rx_mon_dest_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_RX_MON_DEST, params)
  58. #define dp_rx_mon_dest_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_RX_MON_DEST, params)
  59. #define dp_rx_mon_dest_info(params...) \
  60. __QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_RX_MON_DEST, ## params)
  61. #define dp_rx_mon_dest_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_RX_MON_DEST, params)
  62. /**
  63. * enum dp_mon_reap_status - monitor status ring ppdu status
  64. *
  65. * @DP_MON_STATUS_NO_DMA - DMA not done for status ring entry
  66. * @DP_MON_STATUS_MATCH - status and dest ppdu id mathes
  67. * @DP_MON_STATUS_LAG - status ppdu id is lagging
  68. * @DP_MON_STATUS_LEAD - status ppdu id is leading
  69. * @DP_MON_STATUS_REPLENISH - status ring entry is NULL
  70. */
  71. enum dp_mon_reap_status {
  72. DP_MON_STATUS_NO_DMA,
  73. DP_MON_STATUS_MATCH,
  74. DP_MON_STATUS_LAG,
  75. DP_MON_STATUS_LEAD,
  76. DP_MON_STATUS_REPLENISH
  77. };
  78. /*
  79. * dp_rx_mon_status_process() - Process monitor status ring and
  80. * TLV in status ring.
  81. *
  82. * @soc: core txrx main context
  83. * @int_ctx: interrupt context
  84. * @mac_id: mac_id which is one of 3 mac_ids
  85. * @quota: No. of ring entry that can be serviced in one shot.
  86. * Return: uint32_t: No. of ring entry that is processed.
  87. */
  88. uint32_t
  89. dp_rx_mon_status_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  90. uint32_t mac_id, uint32_t quota);
  91. /**
  92. * dp_rx_mon_dest_process() - Brain of the Rx processing functionality
  93. * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
  94. * @soc: core txrx main contex
  95. * @int_ctx: interrupt context
  96. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  97. * @quota: No. of units (packets) that can be serviced in one shot.
  98. *
  99. * This function implements the core of Rx functionality. This is
  100. * expected to handle only non-error frames.
  101. *
  102. * Return: none
  103. */
  104. void dp_rx_mon_dest_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  105. uint32_t mac_id, uint32_t quota);
  106. QDF_STATUS dp_rx_pdev_mon_desc_pool_alloc(struct dp_pdev *pdev);
  107. QDF_STATUS dp_rx_pdev_mon_buffers_alloc(struct dp_pdev *pdev);
  108. void dp_rx_pdev_mon_buffers_free(struct dp_pdev *pdev);
  109. void dp_rx_pdev_mon_desc_pool_init(struct dp_pdev *pdev);
  110. void dp_rx_pdev_mon_desc_pool_deinit(struct dp_pdev *pdev);
  111. void dp_rx_pdev_mon_desc_pool_free(struct dp_pdev *pdev);
  112. void dp_rx_pdev_mon_buf_buffers_free(struct dp_pdev *pdev, uint32_t mac_id);
  113. QDF_STATUS dp_rx_pdev_mon_status_buffers_alloc(struct dp_pdev *pdev,
  114. uint32_t mac_id);
  115. QDF_STATUS dp_rx_pdev_mon_status_desc_pool_alloc(struct dp_pdev *pdev,
  116. uint32_t mac_id);
  117. void dp_rx_pdev_mon_status_desc_pool_init(struct dp_pdev *pdev,
  118. uint32_t mac_id);
  119. void dp_rx_pdev_mon_status_desc_pool_deinit(struct dp_pdev *pdev,
  120. uint32_t mac_id);
  121. void dp_rx_pdev_mon_status_desc_pool_free(struct dp_pdev *pdev,
  122. uint32_t mac_id);
  123. void dp_rx_pdev_mon_status_buffers_free(struct dp_pdev *pdev, uint32_t mac_id);
  124. QDF_STATUS
  125. dp_rx_pdev_mon_buf_buffers_alloc(struct dp_pdev *pdev, uint32_t mac_id,
  126. bool delayed_replenish);
  127. QDF_STATUS
  128. dp_rx_pdev_mon_buf_desc_pool_alloc(struct dp_pdev *pdev, uint32_t mac_id);
  129. void
  130. dp_rx_pdev_mon_buf_desc_pool_init(struct dp_pdev *pdev, uint32_t mac_id);
  131. /*
  132. * dp_rx_populate_cbf_hdr - Send CBF frame with htt header
  133. * @soc: Datapath soc handle
  134. * @mac_id: Datapath mac id
  135. * @event: WDI event
  136. * @mpdu: mpdu buffer
  137. * @msdu_timesstamp: time stamp
  138. *
  139. * Return: QDF_STATUS
  140. */
  141. QDF_STATUS dp_rx_populate_cbf_hdr(struct dp_soc *soc,
  142. uint32_t mac_id, uint32_t event,
  143. qdf_nbuf_t data, uint32_t msdu_timestamp);
  144. /**
  145. * dp_rx_mon_handle_status_buf_done () - Handle DMA not done case for
  146. * monitor status ring
  147. *
  148. * @pdev: DP pdev handle
  149. * @mon_status_srng: Monitor status SRNG
  150. *
  151. * Return: enum dp_mon_reap_status
  152. */
  153. enum dp_mon_reap_status
  154. dp_rx_mon_handle_status_buf_done(struct dp_pdev *pdev,
  155. void *mon_status_srng);
  156. #ifdef QCA_SUPPORT_FULL_MON
  157. /**
  158. * dp_full_mon_attach() - Full monitor mode attach
  159. * This API initilises full monitor mode resources
  160. *
  161. * @pdev: dp pdev object
  162. *
  163. * Return: void
  164. *
  165. */
  166. void dp_full_mon_attach(struct dp_pdev *pdev);
  167. /**
  168. * dp_full_mon_detach() - Full monitor mode attach
  169. * This API deinitilises full monitor mode resources
  170. *
  171. * @pdev: dp pdev object
  172. *
  173. * Return: void
  174. *
  175. */
  176. void dp_full_mon_detach(struct dp_pdev *pdev);
  177. /**
  178. * dp_rx_mon_process ()- API to process monitor destination ring for
  179. * full monitor mode
  180. *
  181. * @soc: dp soc handle
  182. * @int_ctx: interrupt context
  183. * @mac_id: lmac id
  184. * @quota: No. of ring entry that can be serviced in one shot.
  185. */
  186. uint32_t dp_rx_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  187. uint32_t mac_id, uint32_t quota);
  188. #else
  189. /**
  190. * dp_full_mon_attach() - attach full monitor mode resources
  191. * @pdev: Datapath PDEV handle
  192. *
  193. * Return: void
  194. */
  195. static inline void dp_full_mon_attach(struct dp_pdev *pdev)
  196. {
  197. }
  198. /**
  199. * dp_full_mon_detach() - detach full monitor mode resources
  200. * @pdev: Datapath PDEV handle
  201. *
  202. * Return: void
  203. *
  204. */
  205. static inline void dp_full_mon_detach(struct dp_pdev *pdev)
  206. {
  207. }
  208. #endif
  209. /**
  210. * dp_reset_monitor_mode() - Disable monitor mode
  211. * @pdev_handle: Datapath PDEV handle
  212. *
  213. * Return: QDF_STATUS
  214. */
  215. QDF_STATUS dp_reset_monitor_mode(struct cdp_soc_t *soc_hdl,
  216. uint8_t pdev_id,
  217. uint8_t smart_monitor);
  218. /**
  219. * dp_mon_link_free() - free monitor link desc pool
  220. * @pdev: core txrx pdev context
  221. *
  222. * This function will release DP link desc pool for monitor mode from
  223. * main device context.
  224. *
  225. * Return: QDF_STATUS_SUCCESS: success
  226. * QDF_STATUS_E_RESOURCES: Error return
  227. */
  228. QDF_STATUS dp_mon_link_free(struct dp_pdev *pdev);
  229. /**
  230. * dp_mon_process() - Main monitor mode processing roution.
  231. * @soc: core txrx main context
  232. * @int_ctx: interrupt context
  233. * @mac_id: mac_id which is one of 3 mac_ids
  234. * @quota: No. of status ring entry that can be serviced in one shot.
  235. *
  236. * This call monitor status ring process then monitor
  237. * destination ring process.
  238. * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
  239. *
  240. * Return: uint32_t: No. of ring entry that is processed.
  241. */
  242. uint32_t dp_mon_process(struct dp_soc *soc, struct dp_intr *int_ctx,
  243. uint32_t mac_id, uint32_t quota);
  244. /**
  245. * dp_mon_drop_packets_for_mac() - Drop the mon status ring and
  246. * dest ring packets for a given mac. Packets in status ring and
  247. * dest ring are dropped independently.
  248. * @pdev: DP pdev
  249. * @mac_id: mac id
  250. * @quota: max number of status ring entries that can be processed
  251. *
  252. * Return: work done
  253. */
  254. uint32_t dp_mon_drop_packets_for_mac(struct dp_pdev *pdev, uint32_t mac_id,
  255. uint32_t quota);
  256. QDF_STATUS dp_rx_mon_deliver(struct dp_soc *soc, uint32_t mac_id,
  257. qdf_nbuf_t head_msdu, qdf_nbuf_t tail_msdu);
  258. /*
  259. * dp_rx_mon_deliver_non_std() - deliver frames for non standard path
  260. * @soc: core txrx main contex
  261. * @mac_id: MAC ID
  262. *
  263. * This function delivers the radio tap and dummy MSDU
  264. * into user layer application for preamble only PPDU.
  265. *
  266. * Return: Operation status
  267. */
  268. QDF_STATUS dp_rx_mon_deliver_non_std(struct dp_soc *soc, uint32_t mac_id);
  269. /**
  270. * dp_rxdma_err_process() - RxDMA error processing functionality
  271. * @soc: core txrx main contex
  272. * @mac_id: mac id which is one of 3 mac_ids
  273. * @hal_ring: opaque pointer to the HAL Rx Ring, which will be serviced
  274. * @quota: No. of units (packets) that can be serviced in one shot.
  275. *
  276. * Return: num of buffers processed
  277. */
  278. uint32_t dp_rxdma_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
  279. uint32_t mac_id, uint32_t quota);
  280. /**
  281. * dp_mon_buf_delayed_replenish() - Helper routine to replenish monitor dest buf
  282. * @pdev: DP pdev object
  283. *
  284. * Return: None
  285. */
  286. void dp_mon_buf_delayed_replenish(struct dp_pdev *pdev);
  287. /**
  288. * dp_rx_mon_link_desc_return() - Return a MPDU link descriptor to HW
  289. * (WBM), following error handling
  290. *
  291. * @dp_pdev: core txrx pdev context
  292. * @buf_addr_info: void pointer to monitor link descriptor buf addr info
  293. * Return: QDF_STATUS
  294. */
  295. QDF_STATUS
  296. dp_rx_mon_link_desc_return(struct dp_pdev *dp_pdev,
  297. hal_buff_addrinfo_t buf_addr_info,
  298. int mac_id);
  299. /**
  300. * dp_mon_adjust_frag_len() - MPDU and MSDU may spread across
  301. * multiple nbufs. This function
  302. * is to return data length in
  303. * fragmented buffer
  304. * @soc: Datapath soc handle
  305. * @total_len: pointer to remaining data length.
  306. * @frag_len: pointer to data length in this fragment.
  307. * @l2_hdr_pad: l2 header padding
  308. */
  309. static inline void dp_mon_adjust_frag_len(struct dp_soc *soc,
  310. uint32_t *total_len,
  311. uint32_t *frag_len,
  312. uint16_t l2_hdr_pad)
  313. {
  314. uint32_t rx_pkt_tlv_len = soc->rx_pkt_tlv_size;
  315. if (*total_len >= (RX_MONITOR_BUFFER_SIZE - rx_pkt_tlv_len)) {
  316. *frag_len = RX_MONITOR_BUFFER_SIZE - rx_pkt_tlv_len -
  317. l2_hdr_pad;
  318. *total_len -= *frag_len;
  319. } else {
  320. *frag_len = *total_len;
  321. *total_len = 0;
  322. }
  323. }
  324. /**
  325. * dp_rx_mon_frag_adjust_frag_len() - MPDU and MSDU may spread across
  326. * multiple nbufs. This function is to return data length in
  327. * fragmented buffer.
  328. * It takes input as max_limit for any buffer(as it changes based
  329. * on decap type and buffer sequence in MSDU.
  330. *
  331. * If MSDU is divided into multiple buffer then below format will
  332. * be max limit.
  333. * Decap type Non-Raw
  334. *--------------------------------
  335. *| 1st | 2nd | ... | Last |
  336. *| 1662 | 1664 | 1664 | <=1664 |
  337. *--------------------------------
  338. * Decap type Raw
  339. *--------------------------------
  340. *| 1st | 2nd | ... | Last |
  341. *| 1664 | 1664 | 1664 | <=1664 |
  342. *--------------------------------
  343. *
  344. * It also calculate if current buffer has placeholder to keep padding byte.
  345. * --------------------------------
  346. * | MAX LIMIT(1662/1664) |
  347. * --------------------------------
  348. * | Actual Data | Pad byte Pholder |
  349. * --------------------------------
  350. *
  351. * @total_len: Remaining data length.
  352. * @frag_len: Data length in this fragment.
  353. * @max_limit: Max limit of current buffer/MSDU.
  354. */
  355. #ifdef DP_RX_MON_MEM_FRAG
  356. static inline
  357. void dp_rx_mon_frag_adjust_frag_len(uint32_t *total_len, uint32_t *frag_len,
  358. uint32_t max_limit)
  359. {
  360. if (*total_len >= max_limit) {
  361. *frag_len = max_limit;
  362. *total_len -= *frag_len;
  363. } else {
  364. *frag_len = *total_len;
  365. *total_len = 0;
  366. }
  367. }
  368. /**
  369. * DP_RX_MON_GET_NBUF_FROM_DESC() - Get nbuf from desc
  370. */
  371. #define DP_RX_MON_GET_NBUF_FROM_DESC(rx_desc) \
  372. NULL
  373. /**
  374. * dp_rx_mon_add_msdu_to_list_failure_handler() - Handler for nbuf buffer
  375. * attach failure
  376. *
  377. * @rx_tlv_hdr: rx_tlv_hdr
  378. * @pdev: struct dp_pdev *
  379. * @last: skb pointing to last skb in chained list at any moment
  380. * @head_msdu: parent skb in the chained list
  381. * @tail_msdu: Last skb in the chained list
  382. * @func_name: caller function name
  383. *
  384. * Return: void
  385. */
  386. static inline void
  387. dp_rx_mon_add_msdu_to_list_failure_handler(void *rx_tlv_hdr,
  388. struct dp_pdev *pdev,
  389. qdf_nbuf_t *last,
  390. qdf_nbuf_t *head_msdu,
  391. qdf_nbuf_t *tail_msdu,
  392. const char *func_name)
  393. {
  394. DP_STATS_INC(pdev, replenish.nbuf_alloc_fail, 1);
  395. qdf_frag_free(rx_tlv_hdr);
  396. if (head_msdu)
  397. qdf_nbuf_list_free(*head_msdu);
  398. dp_err("[%s] failed to allocate subsequent parent buffer to hold all frag\n",
  399. func_name);
  400. if (head_msdu)
  401. *head_msdu = NULL;
  402. if (last)
  403. *last = NULL;
  404. if (tail_msdu)
  405. *tail_msdu = NULL;
  406. }
  407. /**
  408. * dp_rx_mon_get_paddr_from_desc() - Get paddr from desc
  409. */
  410. static inline
  411. qdf_dma_addr_t dp_rx_mon_get_paddr_from_desc(struct dp_rx_desc *rx_desc)
  412. {
  413. return rx_desc->paddr_buf_start;
  414. }
  415. /**
  416. * DP_RX_MON_IS_BUFFER_ADDR_NULL() - Is Buffer received from hw is NULL
  417. */
  418. #define DP_RX_MON_IS_BUFFER_ADDR_NULL(rx_desc) \
  419. (!(rx_desc->rx_buf_start))
  420. #define DP_RX_MON_IS_MSDU_NOT_NULL(msdu) \
  421. true
  422. /**
  423. * dp_rx_mon_buffer_free() - Free nbuf or frag memory
  424. * Free nbuf if feature is disabled, else free frag.
  425. *
  426. * @rx_desc: Rx desc
  427. */
  428. static inline void
  429. dp_rx_mon_buffer_free(struct dp_rx_desc *rx_desc)
  430. {
  431. qdf_frag_free(rx_desc->rx_buf_start);
  432. }
  433. /**
  434. * dp_rx_mon_buffer_unmap() - Unmap nbuf or frag memory
  435. * Unmap nbuf if feature is disabled, else unmap frag.
  436. *
  437. * @soc: struct dp_soc *
  438. * @rx_desc: struct dp_rx_desc *
  439. * @size: Size to be unmapped
  440. */
  441. static inline void
  442. dp_rx_mon_buffer_unmap(struct dp_soc *soc, struct dp_rx_desc *rx_desc,
  443. uint16_t size)
  444. {
  445. qdf_mem_unmap_page(soc->osdev, rx_desc->paddr_buf_start,
  446. size, QDF_DMA_FROM_DEVICE);
  447. }
  448. /**
  449. * dp_rx_mon_alloc_parent_buffer() - Allocate parent buffer to hold
  450. * radiotap header and accommodate all frag memory in nr_frag.
  451. *
  452. * @head_msdu: Ptr to hold allocated Msdu
  453. *
  454. * Return: QDF_STATUS
  455. */
  456. static inline
  457. QDF_STATUS dp_rx_mon_alloc_parent_buffer(qdf_nbuf_t *head_msdu)
  458. {
  459. /*
  460. * Headroom should accommodate radiotap header
  461. * and protocol and flow tag for all frag
  462. * Length reserved to accommodate Radiotap header
  463. * is 128 bytes and length reserved for Protocol
  464. * flow tag will vary based on QDF_NBUF_MAX_FRAGS.
  465. */
  466. /* -------------------------------------------------
  467. * | Protocol & Flow TAG | Radiotap header|
  468. * | | Length(128 B) |
  469. * | ((4* QDF_NBUF_MAX_FRAGS) * 2) | |
  470. * -------------------------------------------------
  471. */
  472. *head_msdu = qdf_nbuf_alloc_no_recycler(DP_RX_MON_MAX_MONITOR_HEADER,
  473. DP_RX_MON_MAX_MONITOR_HEADER, 4);
  474. if (!(*head_msdu))
  475. return QDF_STATUS_E_FAILURE;
  476. qdf_mem_zero(qdf_nbuf_head(*head_msdu), qdf_nbuf_headroom(*head_msdu));
  477. /* Set *head_msdu->next as NULL as all msdus are
  478. * mapped via nr frags
  479. */
  480. qdf_nbuf_set_next(*head_msdu, NULL);
  481. return QDF_STATUS_SUCCESS;
  482. }
  483. /**
  484. * dp_rx_mon_parse_desc_buffer() - Parse desc buffer based.
  485. *
  486. * Below code will parse desc buffer, handle continuation frame,
  487. * adjust frag length and update l2_hdr_padding
  488. *
  489. * @soc : struct dp_soc*
  490. * @msdu_info : struct hal_rx_msdu_desc_info*
  491. * @is_frag_p : is_frag *
  492. * @total_frag_len_p : Remaining frag len to be updated
  493. * @frag_len_p : frag len
  494. * @l2_hdr_offset_p : l2 hdr offset
  495. * @rx_desc_tlv : rx_desc_tlv
  496. * @is_frag_non_raw_p : Non raw frag
  497. * @data : NBUF Data
  498. */
  499. static inline void
  500. dp_rx_mon_parse_desc_buffer(struct dp_soc *dp_soc,
  501. struct hal_rx_msdu_desc_info *msdu_info,
  502. bool *is_frag_p, uint32_t *total_frag_len_p,
  503. uint32_t *frag_len_p, uint16_t *l2_hdr_offset_p,
  504. qdf_frag_t rx_desc_tlv,
  505. bool *is_frag_non_raw_p, void *data)
  506. {
  507. struct hal_rx_mon_dest_buf_info frame_info;
  508. uint16_t tot_payload_len =
  509. RX_MONITOR_BUFFER_SIZE - dp_soc->rx_pkt_tlv_size;
  510. if (msdu_info->msdu_flags & HAL_MSDU_F_MSDU_CONTINUATION) {
  511. /* First buffer of MSDU */
  512. if (!(*is_frag_p)) {
  513. /* Set total frag_len from msdu_len */
  514. *total_frag_len_p = msdu_info->msdu_len;
  515. *is_frag_p = true;
  516. if (HAL_HW_RX_DECAP_FORMAT_RAW ==
  517. hal_rx_tlv_decap_format_get(dp_soc->hal_soc,
  518. rx_desc_tlv)) {
  519. *l2_hdr_offset_p =
  520. DP_RX_MON_RAW_L2_HDR_PAD_BYTE;
  521. frame_info.is_decap_raw = 1;
  522. } else {
  523. *l2_hdr_offset_p =
  524. DP_RX_MON_NONRAW_L2_HDR_PAD_BYTE;
  525. frame_info.is_decap_raw = 0;
  526. *is_frag_non_raw_p = true;
  527. }
  528. dp_rx_mon_frag_adjust_frag_len(total_frag_len_p,
  529. frag_len_p,
  530. tot_payload_len -
  531. *l2_hdr_offset_p);
  532. frame_info.first_buffer = 1;
  533. frame_info.last_buffer = 0;
  534. hal_rx_priv_info_set_in_tlv(dp_soc->hal_soc,
  535. rx_desc_tlv,
  536. (uint8_t *)&frame_info,
  537. sizeof(frame_info));
  538. } else {
  539. /*
  540. * Continuation Middle frame
  541. * Here max limit will be same for Raw and Non raw case.
  542. */
  543. *l2_hdr_offset_p = DP_RX_MON_RAW_L2_HDR_PAD_BYTE;
  544. dp_rx_mon_frag_adjust_frag_len(total_frag_len_p,
  545. frag_len_p,
  546. tot_payload_len);
  547. /* Update frame info if is non raw frame */
  548. if (*is_frag_non_raw_p)
  549. frame_info.is_decap_raw = 0;
  550. else
  551. frame_info.is_decap_raw = 1;
  552. frame_info.first_buffer = 0;
  553. frame_info.last_buffer = 0;
  554. hal_rx_priv_info_set_in_tlv(dp_soc->hal_soc,
  555. rx_desc_tlv,
  556. (uint8_t *)&frame_info,
  557. sizeof(frame_info));
  558. }
  559. } else {
  560. /**
  561. * Last buffer of MSDU spread among multiple buffer
  562. * Here max limit will be same for Raw and Non raw case.
  563. */
  564. if (*is_frag_p) {
  565. *l2_hdr_offset_p = DP_RX_MON_RAW_L2_HDR_PAD_BYTE;
  566. dp_rx_mon_frag_adjust_frag_len(total_frag_len_p,
  567. frag_len_p,
  568. tot_payload_len);
  569. /* Update frame info if is non raw frame */
  570. if (*is_frag_non_raw_p)
  571. frame_info.is_decap_raw = 0;
  572. else
  573. frame_info.is_decap_raw = 1;
  574. frame_info.first_buffer = 0;
  575. frame_info.last_buffer = 1;
  576. hal_rx_priv_info_set_in_tlv(dp_soc->hal_soc,
  577. rx_desc_tlv,
  578. (uint8_t *)&frame_info,
  579. sizeof(frame_info));
  580. } else {
  581. /* MSDU with single buffer */
  582. *frag_len_p = msdu_info->msdu_len;
  583. if (HAL_HW_RX_DECAP_FORMAT_RAW ==
  584. hal_rx_tlv_decap_format_get(dp_soc->hal_soc,
  585. rx_desc_tlv)) {
  586. *l2_hdr_offset_p =
  587. DP_RX_MON_RAW_L2_HDR_PAD_BYTE;
  588. frame_info.is_decap_raw = 1;
  589. } else {
  590. *l2_hdr_offset_p =
  591. DP_RX_MON_NONRAW_L2_HDR_PAD_BYTE;
  592. frame_info.is_decap_raw = 0;
  593. }
  594. frame_info.first_buffer = 1;
  595. frame_info.last_buffer = 1;
  596. hal_rx_priv_info_set_in_tlv(dp_soc->hal_soc,
  597. rx_desc_tlv,
  598. (uint8_t *)&frame_info,
  599. sizeof(frame_info));
  600. }
  601. /* Reset bool after complete processing of MSDU */
  602. *is_frag_p = false;
  603. *is_frag_non_raw_p = false;
  604. }
  605. }
  606. /**
  607. * dp_rx_mon_buffer_set_pktlen() - set pktlen for buffer
  608. */
  609. static inline void dp_rx_mon_buffer_set_pktlen(qdf_nbuf_t msdu, uint32_t size)
  610. {
  611. }
  612. /**
  613. * dp_rx_mon_add_msdu_to_list()- Add msdu to list and update head_msdu
  614. * It will add reaped buffer frag to nr frag of parent msdu.
  615. * @soc: DP soc handle
  616. * @head_msdu: NULL if first time called else &msdu
  617. * @msdu: Msdu where frag address needs to be added via nr_frag
  618. * @last: Used to traverse in list if this feature is disabled.
  619. * @rx_desc_tlv: Frag address
  620. * @frag_len: Frag len
  621. * @l2_hdr_offset: l2 hdr padding
  622. */
  623. static inline
  624. QDF_STATUS dp_rx_mon_add_msdu_to_list(struct dp_soc *soc, qdf_nbuf_t *head_msdu,
  625. qdf_nbuf_t msdu, qdf_nbuf_t *last,
  626. qdf_frag_t rx_desc_tlv, uint32_t frag_len,
  627. uint32_t l2_hdr_offset)
  628. {
  629. uint32_t num_frags;
  630. qdf_nbuf_t msdu_curr;
  631. /* Here head_msdu and *head_msdu must not be NULL */
  632. /* Dont add frag to skb if frag length is zero. Drop frame */
  633. if (qdf_unlikely(!frag_len || !head_msdu || !(*head_msdu))) {
  634. dp_err("[%s] frag_len[%d] || head_msdu[%pK] || *head_msdu is Null while adding frag to skb\n",
  635. __func__, frag_len, head_msdu);
  636. return QDF_STATUS_E_FAILURE;
  637. }
  638. /* In case of first desc of MPDU, assign curr msdu to *head_msdu */
  639. if (!qdf_nbuf_get_nr_frags(*head_msdu))
  640. msdu_curr = *head_msdu;
  641. else
  642. msdu_curr = *last;
  643. /* Current msdu must not be NULL */
  644. if (qdf_unlikely(!msdu_curr)) {
  645. dp_err("[%s] Current msdu can't be Null while adding frag to skb\n",
  646. __func__);
  647. return QDF_STATUS_E_FAILURE;
  648. }
  649. num_frags = qdf_nbuf_get_nr_frags(msdu_curr);
  650. if (num_frags < QDF_NBUF_MAX_FRAGS) {
  651. qdf_nbuf_add_rx_frag(rx_desc_tlv, msdu_curr,
  652. soc->rx_mon_pkt_tlv_size,
  653. frag_len + l2_hdr_offset,
  654. RX_MONITOR_BUFFER_SIZE,
  655. false);
  656. if (*last != msdu_curr)
  657. *last = msdu_curr;
  658. return QDF_STATUS_SUCCESS;
  659. }
  660. /* Execution will reach here only if num_frags == QDF_NBUF_MAX_FRAGS */
  661. msdu_curr = NULL;
  662. if ((dp_rx_mon_alloc_parent_buffer(&msdu_curr))
  663. != QDF_STATUS_SUCCESS)
  664. return QDF_STATUS_E_FAILURE;
  665. qdf_nbuf_add_rx_frag(rx_desc_tlv, msdu_curr, soc->rx_mon_pkt_tlv_size,
  666. frag_len + l2_hdr_offset, RX_MONITOR_BUFFER_SIZE,
  667. false);
  668. /* Add allocated nbuf in the chain */
  669. qdf_nbuf_set_next(*last, msdu_curr);
  670. /* Assign current msdu to last to avoid traversal */
  671. *last = msdu_curr;
  672. return QDF_STATUS_SUCCESS;
  673. }
  674. /**
  675. * dp_rx_mon_init_tail_msdu() - Initialize tail msdu
  676. *
  677. * @head_msdu: Parent buffer to hold MPDU data
  678. * @msdu: Msdu to be updated in tail_msdu
  679. * @last: last msdu
  680. * @tail_msdu: Last msdu
  681. */
  682. static inline
  683. void dp_rx_mon_init_tail_msdu(qdf_nbuf_t *head_msdu, qdf_nbuf_t msdu,
  684. qdf_nbuf_t last, qdf_nbuf_t *tail_msdu)
  685. {
  686. if (!head_msdu || !(*head_msdu)) {
  687. *tail_msdu = NULL;
  688. return;
  689. }
  690. if (last)
  691. qdf_nbuf_set_next(last, NULL);
  692. *tail_msdu = last;
  693. }
  694. /**
  695. * dp_rx_mon_remove_raw_frame_fcs_len() - Remove FCS length for Raw Frame
  696. *
  697. * If feature is disabled, then removal happens in restitch logic.
  698. *
  699. * @soc: Datapath soc handle
  700. * @head_msdu: Head msdu
  701. * @tail_msdu: Tail msdu
  702. */
  703. static inline
  704. void dp_rx_mon_remove_raw_frame_fcs_len(struct dp_soc *soc,
  705. qdf_nbuf_t *head_msdu,
  706. qdf_nbuf_t *tail_msdu)
  707. {
  708. qdf_frag_t addr;
  709. if (qdf_unlikely(!head_msdu || !tail_msdu || !(*head_msdu)))
  710. return;
  711. /* If *head_msdu is valid, then *tail_msdu must be valid */
  712. /* If head_msdu is valid, then it must have nr_frags */
  713. /* If tail_msdu is valid, then it must have nr_frags */
  714. /* Strip FCS_LEN for Raw frame */
  715. addr = qdf_nbuf_get_frag_addr(*head_msdu, 0);
  716. addr -= soc->rx_mon_pkt_tlv_size;
  717. if (hal_rx_tlv_decap_format_get(soc->hal_soc, addr) ==
  718. HAL_HW_RX_DECAP_FORMAT_RAW) {
  719. qdf_nbuf_trim_add_frag_size(*tail_msdu,
  720. qdf_nbuf_get_nr_frags(*tail_msdu) - 1,
  721. -HAL_RX_FCS_LEN, 0);
  722. }
  723. }
  724. /**
  725. * dp_rx_mon_get_buffer_data()- Get data from desc buffer
  726. * @rx_desc: desc
  727. *
  728. * Return address containing actual tlv content
  729. */
  730. static inline
  731. uint8_t *dp_rx_mon_get_buffer_data(struct dp_rx_desc *rx_desc)
  732. {
  733. return rx_desc->rx_buf_start;
  734. }
  735. /**
  736. * dp_rx_mon_get_nbuf_80211_hdr() - Get 80211 hdr from nbuf
  737. * @nbuf: qdf_nbuf_t
  738. *
  739. * This function must be called after moving radiotap header.
  740. *
  741. * Return: Ptr pointing to 80211 header or NULL.
  742. */
  743. static inline
  744. qdf_frag_t dp_rx_mon_get_nbuf_80211_hdr(qdf_nbuf_t nbuf)
  745. {
  746. /* Return NULL if nr_frag is Zero */
  747. if (!qdf_nbuf_get_nr_frags(nbuf))
  748. return NULL;
  749. return qdf_nbuf_get_frag_addr(nbuf, 0);
  750. }
  751. #else
  752. #define DP_RX_MON_GET_NBUF_FROM_DESC(rx_desc) \
  753. (rx_desc->nbuf)
  754. static inline void
  755. dp_rx_mon_add_msdu_to_list_failure_handler(void *rx_tlv_hdr,
  756. struct dp_pdev *pdev,
  757. qdf_nbuf_t *last,
  758. qdf_nbuf_t *head_msdu,
  759. qdf_nbuf_t *tail_msdu,
  760. const char *func_name)
  761. {
  762. }
  763. static inline
  764. qdf_dma_addr_t dp_rx_mon_get_paddr_from_desc(struct dp_rx_desc *rx_desc)
  765. {
  766. qdf_dma_addr_t paddr = 0;
  767. qdf_nbuf_t msdu = NULL;
  768. msdu = rx_desc->nbuf;
  769. if (msdu)
  770. paddr = qdf_nbuf_get_frag_paddr(msdu, 0);
  771. return paddr;
  772. }
  773. #define DP_RX_MON_IS_BUFFER_ADDR_NULL(rx_desc) \
  774. (!(rx_desc->nbuf))
  775. #define DP_RX_MON_IS_MSDU_NOT_NULL(msdu) \
  776. (msdu)
  777. static inline void
  778. dp_rx_mon_buffer_free(struct dp_rx_desc *rx_desc)
  779. {
  780. qdf_nbuf_free(rx_desc->nbuf);
  781. }
  782. static inline void
  783. dp_rx_mon_buffer_unmap(struct dp_soc *soc, struct dp_rx_desc *rx_desc,
  784. uint16_t size)
  785. {
  786. qdf_nbuf_unmap_nbytes_single(soc->osdev, rx_desc->nbuf,
  787. QDF_DMA_FROM_DEVICE, size);
  788. }
  789. static inline
  790. QDF_STATUS dp_rx_mon_alloc_parent_buffer(qdf_nbuf_t *head_msdu)
  791. {
  792. return QDF_STATUS_SUCCESS;
  793. }
  794. static inline void
  795. dp_rx_mon_parse_desc_buffer(struct dp_soc *dp_soc,
  796. struct hal_rx_msdu_desc_info *msdu_info,
  797. bool *is_frag_p, uint32_t *total_frag_len_p,
  798. uint32_t *frag_len_p, uint16_t *l2_hdr_offset_p,
  799. qdf_frag_t rx_desc_tlv,
  800. bool *is_frag_non_raw_p, void *data)
  801. {
  802. /*
  803. * HW structures call this L3 header padding
  804. * -- even though this is actually the offset
  805. * from the buffer beginning where the L2
  806. * header begins.
  807. */
  808. *l2_hdr_offset_p =
  809. hal_rx_msdu_end_l3_hdr_padding_get(dp_soc->hal_soc, data);
  810. if (msdu_info->msdu_flags & HAL_MSDU_F_MSDU_CONTINUATION) {
  811. if (!*(is_frag_p)) {
  812. *total_frag_len_p = msdu_info->msdu_len;
  813. *is_frag_p = true;
  814. }
  815. dp_mon_adjust_frag_len(dp_soc, total_frag_len_p, frag_len_p,
  816. *l2_hdr_offset_p);
  817. } else {
  818. if (*is_frag_p) {
  819. dp_mon_adjust_frag_len(dp_soc, total_frag_len_p,
  820. frag_len_p,
  821. *l2_hdr_offset_p);
  822. } else {
  823. *frag_len_p = msdu_info->msdu_len;
  824. }
  825. *is_frag_p = false;
  826. }
  827. }
  828. static inline void dp_rx_mon_buffer_set_pktlen(qdf_nbuf_t msdu, uint32_t size)
  829. {
  830. qdf_nbuf_set_pktlen(msdu, size);
  831. }
  832. static inline
  833. QDF_STATUS dp_rx_mon_add_msdu_to_list(struct dp_soc *soc, qdf_nbuf_t *head_msdu,
  834. qdf_nbuf_t msdu, qdf_nbuf_t *last,
  835. qdf_frag_t rx_desc_tlv, uint32_t frag_len,
  836. uint32_t l2_hdr_offset)
  837. {
  838. if (head_msdu && !*head_msdu) {
  839. *head_msdu = msdu;
  840. } else {
  841. if (*last)
  842. qdf_nbuf_set_next(*last, msdu);
  843. }
  844. *last = msdu;
  845. return QDF_STATUS_SUCCESS;
  846. }
  847. static inline
  848. void dp_rx_mon_init_tail_msdu(qdf_nbuf_t *head_msdu, qdf_nbuf_t msdu,
  849. qdf_nbuf_t last, qdf_nbuf_t *tail_msdu)
  850. {
  851. if (last)
  852. qdf_nbuf_set_next(last, NULL);
  853. *tail_msdu = msdu;
  854. }
  855. static inline
  856. void dp_rx_mon_remove_raw_frame_fcs_len(struct dp_soc *soc,
  857. qdf_nbuf_t *head_msdu,
  858. qdf_nbuf_t *tail_msdu)
  859. {
  860. }
  861. static inline
  862. uint8_t *dp_rx_mon_get_buffer_data(struct dp_rx_desc *rx_desc)
  863. {
  864. qdf_nbuf_t msdu = NULL;
  865. uint8_t *data = NULL;
  866. msdu = rx_desc->nbuf;
  867. if (qdf_likely(msdu))
  868. data = qdf_nbuf_data(msdu);
  869. return data;
  870. }
  871. static inline
  872. qdf_frag_t dp_rx_mon_get_nbuf_80211_hdr(qdf_nbuf_t nbuf)
  873. {
  874. return qdf_nbuf_data(nbuf);
  875. }
  876. #endif
  877. /**
  878. * dp_rx_cookie_2_mon_link_desc() - Retrieve Link descriptor based on target
  879. * @pdev: core physical device context
  880. * @hal_buf_info: structure holding the buffer info
  881. * mac_id: mac number
  882. *
  883. * Return: link descriptor address
  884. */
  885. static inline
  886. void *dp_rx_cookie_2_mon_link_desc(struct dp_pdev *pdev,
  887. struct hal_buf_info buf_info,
  888. uint8_t mac_id)
  889. {
  890. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
  891. return dp_rx_cookie_2_mon_link_desc_va(pdev, &buf_info,
  892. mac_id);
  893. return dp_rx_cookie_2_link_desc_va(pdev->soc, &buf_info);
  894. }
  895. /**
  896. * dp_rx_monitor_link_desc_return() - Return Link descriptor based on target
  897. * @pdev: core physical device context
  898. * @p_last_buf_addr_info: MPDU Link descriptor
  899. * mac_id: mac number
  900. *
  901. * Return: QDF_STATUS
  902. */
  903. static inline
  904. QDF_STATUS dp_rx_monitor_link_desc_return(struct dp_pdev *pdev,
  905. hal_buff_addrinfo_t
  906. p_last_buf_addr_info,
  907. uint8_t mac_id, uint8_t bm_action)
  908. {
  909. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
  910. return dp_rx_mon_link_desc_return(pdev, p_last_buf_addr_info,
  911. mac_id);
  912. return dp_rx_link_desc_return_by_addr(pdev->soc, p_last_buf_addr_info,
  913. bm_action);
  914. }
  915. /**
  916. * dp_rxdma_get_mon_dst_ring() - Return the pointer to rxdma_err_dst_ring
  917. * or mon_dst_ring based on the target
  918. * @pdev: core physical device context
  919. * @mac_for_pdev: mac_id number
  920. *
  921. * Return: ring address
  922. */
  923. static inline
  924. void *dp_rxdma_get_mon_dst_ring(struct dp_pdev *pdev,
  925. uint8_t mac_for_pdev)
  926. {
  927. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
  928. return pdev->soc->rxdma_mon_dst_ring[mac_for_pdev].hal_srng;
  929. return pdev->soc->rxdma_err_dst_ring[mac_for_pdev].hal_srng;
  930. }
  931. /**
  932. * dp_rxdma_get_mon_buf_ring() - Return monitor buf ring address
  933. * based on target
  934. * @pdev: core physical device context
  935. * @mac_for_pdev: mac id number
  936. *
  937. * Return: ring address
  938. */
  939. static inline
  940. struct dp_srng *dp_rxdma_get_mon_buf_ring(struct dp_pdev *pdev,
  941. uint8_t mac_for_pdev)
  942. {
  943. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
  944. return &pdev->soc->rxdma_mon_buf_ring[mac_for_pdev];
  945. /* For MCL there is only 1 rx refill ring */
  946. return &pdev->soc->rx_refill_buf_ring[0];
  947. }
  948. /**
  949. * dp_rx_get_mon_desc_pool() - Return monitor descriptor pool
  950. * based on target
  951. * @soc: soc handle
  952. * @mac_id: mac id number
  953. * @pdev_id: pdev id number
  954. *
  955. * Return: descriptor pool address
  956. */
  957. static inline
  958. struct rx_desc_pool *dp_rx_get_mon_desc_pool(struct dp_soc *soc,
  959. uint8_t mac_id,
  960. uint8_t pdev_id)
  961. {
  962. if (soc->wlan_cfg_ctx->rxdma1_enable)
  963. return &soc->rx_desc_mon[mac_id];
  964. return &soc->rx_desc_buf[pdev_id];
  965. }
  966. /**
  967. * dp_rx_get_mon_desc() - Return Rx descriptor based on target
  968. * @soc: soc handle
  969. * @cookie: cookie value
  970. *
  971. * Return: Rx descriptor
  972. */
  973. static inline
  974. struct dp_rx_desc *dp_rx_get_mon_desc(struct dp_soc *soc,
  975. uint32_t cookie)
  976. {
  977. if (soc->wlan_cfg_ctx->rxdma1_enable)
  978. return dp_rx_cookie_2_va_mon_buf(soc, cookie);
  979. return dp_rx_cookie_2_va_rxdma_buf(soc, cookie);
  980. }
  981. #ifndef REMOVE_MON_DBG_STATS
  982. /*
  983. * dp_rx_mon_update_dbg_ppdu_stats() - Update status ring TLV count
  984. * @ppdu_info: HAL RX PPDU info retrieved from status ring TLV
  985. * @rx_mon_stats: monitor mode status/destination ring PPDU and MPDU count
  986. *
  987. * Update status ring PPDU start and end count. Keep track TLV state on
  988. * PPDU start and end to find out if start and end is matching. Keep
  989. * track missing PPDU start and end count. Keep track matching PPDU
  990. * start and end count.
  991. *
  992. * Return: None
  993. */
  994. static inline void
  995. dp_rx_mon_update_dbg_ppdu_stats(struct hal_rx_ppdu_info *ppdu_info,
  996. struct cdp_pdev_mon_stats *rx_mon_stats)
  997. {
  998. if (ppdu_info->rx_state ==
  999. HAL_RX_MON_PPDU_START) {
  1000. rx_mon_stats->status_ppdu_start++;
  1001. if (rx_mon_stats->status_ppdu_state
  1002. != CDP_MON_PPDU_END)
  1003. rx_mon_stats->status_ppdu_end_mis++;
  1004. rx_mon_stats->status_ppdu_state
  1005. = CDP_MON_PPDU_START;
  1006. ppdu_info->rx_state = HAL_RX_MON_PPDU_RESET;
  1007. } else if (ppdu_info->rx_state ==
  1008. HAL_RX_MON_PPDU_END) {
  1009. rx_mon_stats->status_ppdu_end++;
  1010. if (rx_mon_stats->status_ppdu_state
  1011. != CDP_MON_PPDU_START)
  1012. rx_mon_stats->status_ppdu_start_mis++;
  1013. else
  1014. rx_mon_stats->status_ppdu_compl++;
  1015. rx_mon_stats->status_ppdu_state
  1016. = CDP_MON_PPDU_END;
  1017. ppdu_info->rx_state = HAL_RX_MON_PPDU_RESET;
  1018. }
  1019. }
  1020. /*
  1021. * dp_rx_mon_init_dbg_ppdu_stats() - initialization for monitor mode stats
  1022. * @ppdu_info: HAL RX PPDU info retrieved from status ring TLV
  1023. * @rx_mon_stats: monitor mode status/destination ring PPDU and MPDU count
  1024. *
  1025. * Return: None
  1026. */
  1027. static inline void
  1028. dp_rx_mon_init_dbg_ppdu_stats(struct hal_rx_ppdu_info *ppdu_info,
  1029. struct cdp_pdev_mon_stats *rx_mon_stats)
  1030. {
  1031. ppdu_info->rx_state = HAL_RX_MON_PPDU_END;
  1032. rx_mon_stats->status_ppdu_state
  1033. = CDP_MON_PPDU_END;
  1034. }
  1035. #else
  1036. static inline void
  1037. dp_rx_mon_update_dbg_ppdu_stats(struct hal_rx_ppdu_info *ppdu_info,
  1038. struct cdp_pdev_mon_stats *rx_mon_stats)
  1039. {
  1040. }
  1041. static inline void
  1042. dp_rx_mon_init_dbg_ppdu_stats(struct hal_rx_ppdu_info *ppdu_info,
  1043. struct cdp_pdev_mon_stats *rx_mon_stats)
  1044. {
  1045. }
  1046. #endif
  1047. #if !defined(DISABLE_MON_CONFIG) && defined(MON_ENABLE_DROP_FOR_MAC)
  1048. /**
  1049. * dp_mon_dest_srng_drop_for_mac() - Drop the mon dest ring packets for
  1050. * a given mac
  1051. * @pdev: DP pdev
  1052. * @mac_id: mac id
  1053. *
  1054. * Return: None
  1055. */
  1056. uint32_t
  1057. dp_mon_dest_srng_drop_for_mac(struct dp_pdev *pdev, uint32_t mac_id);
  1058. #endif
  1059. #endif