xref: /wlan-driver/qca-wifi-host-cmn/utils/pktlog/include/pktlog_ac_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012-2014, 2016-2018, 2020 The Linux Foundation.
3  * All rights reserved.
4  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
5  *
6  * Permission to use, copy, modify, and/or distribute this software for
7  * any purpose with or without fee is hereby granted, provided that the
8  * above copyright notice and this permission notice appear in all
9  * copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18  * PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 /*
22  *  The file is used to define structures that are shared between
23  *  kernel space and user space pktlog application.
24  */
25 
26 #ifndef _PKTLOG_AC_API_
27 #define _PKTLOG_AC_API_
28 #if defined(CONNECTIVITY_PKTLOG) || !defined(REMOVE_PKT_LOG)
29 
30 struct hif_opaque_softc;
31 /**
32  * typedef hif_opaque_softc_handle - opaque handle for hif_opaque_softc
33  */
34 typedef struct hif_opaque_softc * hif_opaque_softc_handle;
35 
36 enum pktlog_callback_regtype {
37 	PKTLOG_DEFAULT_CALLBACK_REGISTRATION,
38 	PKTLOG_LITE_CALLBACK_REGISTRATION
39 };
40 
41 struct net_device;
42 /**
43  * typedef net_device_handle - opaque handle to linux net device object
44  */
45 typedef struct net_device * net_device_handle;
46 
47 struct pktlog_dev_t;
48 
49 void pktlog_sethandle(struct pktlog_dev_t **pl_handle,
50 		     hif_opaque_softc_handle scn);
51 void pktlog_set_pdev_id(struct pktlog_dev_t *pl_dev, uint8_t pdev_id);
52 
53 void *get_txrx_context(void);
54 
55 struct pktlog_dev_t *get_pktlog_handle(void);
56 void pktlog_set_callback_regtype(enum pktlog_callback_regtype callback_type);
57 
58 /* Packet log state information */
59 #ifndef _PKTLOG_INFO
60 #define _PKTLOG_INFO
61 
62 /**
63  * enum ath_pktlog_state - pktlog status
64  * @PKTLOG_OPR_IN_PROGRESS : pktlog command in progress
65  * @PKTLOG_OPR_IN_PROGRESS_READ_START: pktlog read is issued
66  * @PKTLOG_OPR_IN_PROGRESS_READ_START_PKTLOG_DISABLED:
67  *			as part of pktlog read, pktlog is disabled
68  * @PKTLOG_OPR_IN_PROGRESS_READ_COMPLETE:
69  *		as part of read, till pktlog read is complete
70  * @PKTLOG_OPR_IN_PROGRESS_CLEARBUFF_COMPLETE:
71  *		as part of read, pktlog clear buffer is done
72  * @PKTLOG_OPR_NOT_IN_PROGRESS: no pktlog command in progress
73  */
74 enum ath_pktlog_state {
75 	PKTLOG_OPR_IN_PROGRESS = 0,
76 	PKTLOG_OPR_IN_PROGRESS_READ_START,
77 	PKTLOG_OPR_IN_PROGRESS_READ_START_PKTLOG_DISABLED,
78 	PKTLOG_OPR_IN_PROGRESS_READ_COMPLETE,
79 	PKTLOG_OPR_IN_PROGRESS_CLEARBUFF_COMPLETE,
80 	PKTLOG_OPR_NOT_IN_PROGRESS
81 };
82 
83 struct ath_pktlog_info {
84 	struct ath_pktlog_buf *buf;
85 	uint32_t log_state;
86 	uint32_t saved_state;
87 	uint32_t options;
88 	/* Initial saved state: It will save the log state in pktlog
89 	 * open and used in pktlog release after
90 	 * pktlog read is complete.
91 	 */
92 	uint32_t init_saved_state;
93 	enum ath_pktlog_state curr_pkt_state;
94 
95 	/* Size of buffer in bytes */
96 	int32_t buf_size;
97 	qdf_spinlock_t log_lock;
98 	struct mutex pktlog_mutex;
99 
100 	/* Threshold of TCP SACK packets for triggered stop */
101 	int sack_thr;
102 
103 	/* # of tail packets to log after triggered stop */
104 	int tail_length;
105 
106 	/* throuput threshold in bytes for triggered stop */
107 	uint32_t thruput_thresh;
108 
109 	/* (aggregated or single) packet size in bytes */
110 	uint32_t pktlen;
111 
112 	/* a temporary variable for counting TX throughput only */
113 	/* PER threshold for triggered stop, 10 for 10%, range [1, 99] */
114 	uint32_t per_thresh;
115 
116 	/* Phyerr threshold for triggered stop */
117 	uint32_t phyerr_thresh;
118 
119 	/* time period for counting trigger parameters, in millisecond */
120 	uint32_t trigger_interval;
121 	uint32_t start_time_thruput;
122 	uint32_t start_time_per;
123 };
124 #endif /* _PKTLOG_INFO */
125 #else                           /* REMOVE_PKT_LOG */
126 typedef void *pktlog_dev_handle;
127 #define pktlog_set_pdev_id(pl_dev, pdev_id)	\
128 	do {					\
129 		(void)pl_dev;			\
130 		(void)pdev_id;			\
131 	} while (0)
132 
133 #define pktlog_sethandle(pl_handle, scn)	\
134 	do {				\
135 		(void)pl_handle;	\
136 		(void)scn;		\
137 	} while (0)
138 
139 #define ol_pl_set_name(dev)	\
140 	do {				\
141 		(void)scn;		\
142 		(void)dev;		\
143 	} while (0)
144 
145 #endif /* REMOVE_PKT_LOG */
146 #endif /* _PKTLOG_AC_API_ */
147