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