xref: /wlan-driver/qca-wifi-host-cmn/dp/wifi3.0/monitor/2.0/dp_rx_mon_status_2.0.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 #include "dp_types.h"
18 #include "qdf_nbuf.h"
19 #include "dp_internal.h"
20 #include "qdf_mem.h"   /* qdf_mem_malloc,free */
21 #include <qdf_nbuf_frag.h>
22 #include <hal_be_api_mon.h>
23 #include <dp_mon.h>
24 #include <dp_mon_2.0.h>
25 #include <dp_rx_mon_2.0.h>
26 #include <dp_rx.h>
27 #include <dp_rx_mon.h>
28 
29 #ifdef BE_PKTLOG_SUPPORT
30 #define BUFFER_RESIDUE 1
31 #define RX_MON_MIN_HEAD_ROOM   64
32 
33 QDF_STATUS
dp_rx_process_pktlog_be(struct dp_soc * soc,struct dp_pdev * pdev,struct hal_rx_ppdu_info * ppdu_info,void * status_frag,uint32_t end_offset)34 dp_rx_process_pktlog_be(struct dp_soc *soc, struct dp_pdev *pdev,
35 			struct hal_rx_ppdu_info *ppdu_info,
36 			void *status_frag, uint32_t end_offset)
37 {
38 	struct dp_mon_pdev *mon_pdev = pdev->monitor_pdev;
39 	qdf_nbuf_t nbuf = NULL;
40 	enum WDI_EVENT pktlog_mode = WDI_NO_VAL;
41 
42 	if (!mon_pdev->dp_peer_based_pktlog &&
43 	    (mon_pdev->rx_pktlog_mode == DP_RX_PKTLOG_DISABLED)) {
44 		return QDF_STATUS_E_INVAL;
45 	}
46 
47 	nbuf = qdf_nbuf_alloc(soc->osdev, RX_MON_MIN_HEAD_ROOM,
48 			      RX_BUFFER_RESERVATION, 0, FALSE);
49 	if (!nbuf)
50 		return QDF_STATUS_E_NOMEM;
51 
52 	qdf_nbuf_add_rx_frag(status_frag, nbuf, 0,
53 			     (end_offset + BUFFER_RESIDUE),
54 			     RX_MON_MIN_HEAD_ROOM, true);
55 
56 	if (mon_pdev->dp_peer_based_pktlog && ppdu_info) {
57 		dp_rx_process_peer_based_pktlog(soc, ppdu_info,
58 						nbuf, pdev->pdev_id);
59 	} else {
60 		if (mon_pdev->rx_pktlog_mode == DP_RX_PKTLOG_FULL)
61 			pktlog_mode = WDI_EVENT_RX_DESC;
62 		else if (mon_pdev->rx_pktlog_mode == DP_RX_PKTLOG_LITE)
63 			pktlog_mode = WDI_EVENT_LITE_RX;
64 
65 		if (pktlog_mode != WDI_NO_VAL)
66 			dp_wdi_event_handler(pktlog_mode, soc,
67 					     nbuf, HTT_INVALID_PEER,
68 					     WDI_NO_VAL, pdev->pdev_id);
69 	}
70 	qdf_nbuf_free(nbuf);
71 
72 	return QDF_STATUS_SUCCESS;
73 }
74 #endif
75 
76