dp_rx_mon.h 33 KB

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