1 /*
2  * Copyright (c) 2021, 2023 Qualcomm Innovation Center, Inc. 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 /**
19  * DOC: qdf_tracepoint.h
20  * This file defines HLOS agnostic functions providing external interface
21  * for triggering tracepoints.
22  */
23 #if  !defined(_QDF_TRACEPOINT_H)
24 #define _QDF_TRACEPOINT_H
25 
26 #include <i_qdf_tracepoint.h>
27 #include <qdf_nbuf.h>
28 #include <qdf_trace.h>
29 
30 #ifdef WLAN_TRACEPOINTS
31 /**
32  * qdf_trace_dp_packet() - Trace packet in tx or rx path
33  * @nbuf: network buffer pointer
34  * @dir: tx or rx direction
35  * @tso_desc: TSO descriptor
36  * @enq_time: tx hw enqueue wall clock time in milliseconds
37  *
38  * Return: None
39  */
40 void qdf_trace_dp_packet(qdf_nbuf_t nbuf, enum qdf_proto_dir dir,
41 			 struct qdf_tso_seg_elem_t *tso_desc,
42 			 uint64_t enq_time);
43 #else
44 static inline
qdf_trace_dp_packet(qdf_nbuf_t nbuf,enum qdf_proto_dir dir,struct qdf_tso_seg_elem_t * tso_desc,uint64_t enq_time)45 void qdf_trace_dp_packet(qdf_nbuf_t nbuf, enum qdf_proto_dir dir,
46 			 struct qdf_tso_seg_elem_t *tso_desc,
47 			 uint64_t enq_time)
48 {
49 }
50 #endif
51 
52 /**
53  * qdf_trace_dp_rx_tcp_pkt_enabled() - Get the dp_rx_tcp_pkt tracepoint
54  *  enabled or disabled state
55  *
56  * Return: True if the tracepoint is enabled else false
57  */
58 static inline
qdf_trace_dp_rx_tcp_pkt_enabled(void)59 bool qdf_trace_dp_rx_tcp_pkt_enabled(void)
60 {
61 	return __qdf_trace_dp_rx_tcp_pkt_enabled();
62 }
63 
64 /**
65  * qdf_trace_dp_rx_tcp_pkt() - Trace tcp packet in rx direction
66  * @nbuf: pointer to network buffer
67  * @tcp_seq_num: TCP sequence number
68  * @tcp_ack_num: TCP acknowlegment number
69  * @srcport: TCP source port
70  * @dstport: TCP destination port
71  * @latency: latency in milliseconds
72  *
73  * Return: None
74  */
75 static inline
qdf_trace_dp_rx_tcp_pkt(qdf_nbuf_t nbuf,uint32_t tcp_seq_num,uint32_t tcp_ack_num,uint16_t srcport,uint16_t dstport,uint64_t latency)76 void qdf_trace_dp_rx_tcp_pkt(qdf_nbuf_t nbuf, uint32_t tcp_seq_num,
77 			     uint32_t tcp_ack_num, uint16_t srcport,
78 			     uint16_t dstport, uint64_t latency)
79 {
80 	__qdf_trace_dp_rx_tcp_pkt(nbuf, tcp_seq_num, tcp_ack_num,
81 				  srcport, dstport, latency);
82 }
83 
84 /**
85  * qdf_trace_dp_tx_comp_tcp_pkt_enabled() - Get the dp_tx_comp_tcp_pkt
86  *  tracepoint enabled or disabled state
87  *
88  * Return: True if the tracepoint is enabled else false
89  */
90 static inline
qdf_trace_dp_tx_comp_tcp_pkt_enabled(void)91 bool qdf_trace_dp_tx_comp_tcp_pkt_enabled(void)
92 {
93 	return __qdf_trace_dp_tx_comp_tcp_pkt_enabled();
94 }
95 
96 /**
97  * qdf_trace_dp_tx_comp_tcp_pkt() - Trace tcp packet in tx completion
98  * @nbuf: pointer to network buffer
99  * @tcp_seq_num: TCP sequence number
100  * @tcp_ack_num: TCP acknowlegment number
101  * @srcport: TCP source port
102  * @dstport: TCP destination port
103  * @latency: latency in milliseconds
104  *
105  * Return: None
106  */
107 static inline
qdf_trace_dp_tx_comp_tcp_pkt(qdf_nbuf_t nbuf,uint32_t tcp_seq_num,uint32_t tcp_ack_num,uint16_t srcport,uint16_t dstport,uint64_t latency)108 void qdf_trace_dp_tx_comp_tcp_pkt(qdf_nbuf_t nbuf, uint32_t tcp_seq_num,
109 				  uint32_t tcp_ack_num, uint16_t srcport,
110 				  uint16_t dstport, uint64_t latency)
111 {
112 	__qdf_trace_dp_tx_comp_tcp_pkt(nbuf, tcp_seq_num, tcp_ack_num, srcport,
113 				       dstport, latency);
114 }
115 
116 /**
117  * qdf_trace_dp_rx_udp_pkt_enabled() - Get the dp_rx_udp_pkt tracepoint
118  *  enabled or disabled state
119  *
120  * Return: True if the tracepoint is enabled else false
121  */
122 static inline
qdf_trace_dp_rx_udp_pkt_enabled(void)123 bool qdf_trace_dp_rx_udp_pkt_enabled(void)
124 {
125 	return __qdf_trace_dp_rx_udp_pkt_enabled();
126 }
127 
128 /**
129  * qdf_trace_dp_rx_udp_pkt() - Trace udp packet in rx direction
130  * @nbuf: pointer to network buffer
131  * @ip_id: ip identification field
132  * @srcport: UDP source port
133  * @dstport: UDP destination port
134  * @latency: latency in milliseconds
135  *
136  * Return: None
137  */
138 static inline
qdf_trace_dp_rx_udp_pkt(qdf_nbuf_t nbuf,uint16_t ip_id,uint16_t srcport,uint16_t dstport,uint64_t latency)139 void qdf_trace_dp_rx_udp_pkt(qdf_nbuf_t nbuf, uint16_t ip_id,
140 			     uint16_t srcport, uint16_t dstport,
141 			     uint64_t latency)
142 {
143 	__qdf_trace_dp_rx_udp_pkt(nbuf, ip_id, srcport, dstport, latency);
144 }
145 
146 /**
147  * qdf_trace_dp_tx_comp_udp_pkt_enabled() - Get the dp_tx_comp_udp_pkt
148  *  tracepoint enabled or disabled state
149  *
150  * Return: True if the tracepoint is enabled else false
151  */
152 static inline
qdf_trace_dp_tx_comp_udp_pkt_enabled(void)153 bool qdf_trace_dp_tx_comp_udp_pkt_enabled(void)
154 {
155 	return __qdf_trace_dp_tx_comp_udp_pkt_enabled();
156 }
157 
158 /**
159  * qdf_trace_dp_tx_comp_udp_pkt() - Trace udp packet in tx completion
160  * @nbuf: pointer to network buffer
161  * @ip_id: ip identification field
162  * @srcport: UDP source port
163  * @dstport: UDP destination port
164  * @latency: latency in milliseconds
165  *
166  * Return: None
167  */
168 static inline
qdf_trace_dp_tx_comp_udp_pkt(qdf_nbuf_t nbuf,uint16_t ip_id,uint16_t srcport,uint16_t dstport,uint64_t latency)169 void qdf_trace_dp_tx_comp_udp_pkt(qdf_nbuf_t nbuf, uint16_t ip_id,
170 				  uint16_t srcport, uint16_t dstport,
171 				  uint64_t latency)
172 {
173 	__qdf_trace_dp_tx_comp_udp_pkt(nbuf, ip_id, srcport, dstport, latency);
174 }
175 
176 /**
177  * qdf_trace_dp_rx_pkt_enabled() - Get the dp_rx_pkt tracepoint
178  *  enabled or disabled state
179  *
180  * Return: True if the tracepoint is enabled else false
181  */
182 static inline
qdf_trace_dp_rx_pkt_enabled(void)183 bool qdf_trace_dp_rx_pkt_enabled(void)
184 {
185 	return __qdf_trace_dp_rx_pkt_enabled();
186 }
187 
188 /**
189  * qdf_trace_dp_rx_pkt() - Trace non-tcp/udp packet in rx direction
190  * @nbuf: pointer to network buffer
191  * @ether_type: type in ethernet header
192  * @latency: latency in milliseconds
193  *
194  * Return: None
195  */
196 static inline
qdf_trace_dp_rx_pkt(qdf_nbuf_t nbuf,uint16_t ether_type,uint64_t latency)197 void qdf_trace_dp_rx_pkt(qdf_nbuf_t nbuf, uint16_t ether_type,
198 			 uint64_t latency)
199 {
200 	__qdf_trace_dp_rx_pkt(nbuf, ether_type, latency);
201 }
202 
203 /**
204  * qdf_trace_dp_tx_comp_pkt_enabled() - Get the dp_tx_comp_pkt tracepoint
205  *  enabled or disabled state
206  *
207  * Return: True if the tracepoint is enabled else false
208  */
209 static inline
qdf_trace_dp_tx_comp_pkt_enabled(void)210 bool qdf_trace_dp_tx_comp_pkt_enabled(void)
211 {
212 	return __qdf_trace_dp_tx_comp_pkt_enabled();
213 }
214 
215 /**
216  * qdf_trace_dp_tx_comp_pkt() - Trace non-tcp/udp packet in rx direction
217  * @nbuf: pointer to network buffer
218  * @ether_type: type in ethernet header
219  * @latency: latency in milliseconds
220  *
221  * Return: None
222  */
223 static inline
qdf_trace_dp_tx_comp_pkt(qdf_nbuf_t nbuf,uint16_t ether_type,uint64_t latency)224 void qdf_trace_dp_tx_comp_pkt(qdf_nbuf_t nbuf, uint16_t ether_type,
225 			      uint64_t latency)
226 {
227 	__qdf_trace_dp_tx_comp_pkt(nbuf, ether_type, latency);
228 }
229 
230 /**
231  * qdf_trace_dp_del_reg_write_enabled() - Get the dp_del_reg_write tracepoint
232  *  enabled or disabled state
233  *
234  * Return: True if the tracepoint is enabled else false
235  */
236 static inline
qdf_trace_dp_del_reg_write_enabled(void)237 bool qdf_trace_dp_del_reg_write_enabled(void)
238 {
239 	return __qdf_trace_dp_del_reg_write_enabled();
240 }
241 
242 /**
243  * qdf_trace_dp_del_reg_write() - Trace delayed register writes
244  * @srng_id: srng id
245  * @enq_val: enqueue value
246  * @deq_val: dequeue value
247  * @enq_time: enqueue time in qtimer ticks
248  * @deq_time: dequeue time in qtimer ticks
249  *
250  * Return: None
251  */
252 static inline
qdf_trace_dp_del_reg_write(uint8_t srng_id,uint32_t enq_val,uint32_t deq_val,uint64_t enq_time,uint64_t deq_time)253 void qdf_trace_dp_del_reg_write(uint8_t srng_id, uint32_t enq_val,
254 				uint32_t deq_val, uint64_t enq_time,
255 				uint64_t deq_time)
256 {
257 	__qdf_trace_dp_del_reg_write(srng_id, enq_val, deq_val, enq_time,
258 				     deq_time);
259 }
260 
261 /**
262  * qdf_trace_dp_ce_tasklet_sched_latency_enabled() - Get the
263  *   dp_ce_tasklet_sched_latency tracepoint enabled or disabled state
264  *
265  * Return: True if the tracepoint is enabled else false
266  */
267 static inline
qdf_trace_dp_ce_tasklet_sched_latency_enabled(void)268 bool qdf_trace_dp_ce_tasklet_sched_latency_enabled(void)
269 {
270 	return __qdf_trace_dp_ce_tasklet_sched_latency_enabled();
271 }
272 
273 /**
274  * qdf_trace_dp_ce_tasklet_sched_latency() - Trace ce tasklet scheduling
275  *  latency
276  * @ce_id: ce id
277  * @sched_latency: ce tasklet sched latency in nanoseconds
278  *
279  * Return: None
280  */
281 static inline void
qdf_trace_dp_ce_tasklet_sched_latency(uint8_t ce_id,uint64_t sched_latency)282 qdf_trace_dp_ce_tasklet_sched_latency(uint8_t ce_id, uint64_t sched_latency)
283 {
284 	__qdf_trace_dp_ce_tasklet_sched_latency(ce_id, sched_latency);
285 }
286 #endif /* _QDF_TRACEPOINT_H */
287