xref: /wlan-driver/qca-wifi-host-cmn/qdf/linux/src/qdf_tracepoint_defs.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
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 /**
20  * DOC: qdf_tracepoint_defs.h
21  * This file provides OS abstraction for function tracing.
22  */
23 
24 #if  !defined(_QDF_TRACEPOINT_DEFS_H) || defined(TRACE_HEADER_MULTI_READ)
25 #define _QDF_TRACEPOINT_DEFS_H
26 
27 #include <linux/tracepoint.h>
28 #include <linux/skbuff.h>
29 
30 #undef TRACE_SYSTEM
31 #define TRACE_SYSTEM wlan
32 
33 #ifndef WLAN_TRACEPOINTS
34 #undef TRACE_EVENT
35 #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
36 	static inline void trace_##name(proto) {}              \
37 	static inline bool trace_##name##_enabled(void)        \
38 	{                                                      \
39 		return false;                                  \
40 	}
41 
42 #undef DECLARE_EVENT_CLASS
43 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
44 
45 #undef DEFINE_EVENT
46 #define DEFINE_EVENT(evt_class, name, proto, args)      \
47 	static inline void trace_##name(proto) {}       \
48 	static inline bool trace_##name##_enabled(void) \
49 	{                                               \
50 		return false;                           \
51 	}
52 #endif /* WLAN_TRACEPOINTS */
53 
54 DECLARE_EVENT_CLASS(dp_trace_tcp_pkt_class,
55 		    TP_PROTO(struct sk_buff *skb, uint32_t tcp_seq_num,
56 			     uint32_t tcp_ack_num, uint16_t srcport,
57 			     uint16_t dstport, uint64_t tdelta),
58 		    TP_ARGS(skb, tcp_seq_num, tcp_ack_num, srcport,
59 			    dstport, tdelta),
60 		    TP_STRUCT__entry(
61 			__field(void *, skb)
62 			__field(uint32_t, tcp_seq_num)
63 			__field(uint32_t, tcp_ack_num)
64 			__field(uint16_t, srcport)
65 			__field(uint16_t, dstport)
66 			__field(uint64_t, tdelta)
67 		    ),
68 		    TP_fast_assign(
69 			__entry->skb = skb;
70 			__entry->tcp_seq_num = tcp_seq_num;
71 			__entry->tcp_ack_num = tcp_ack_num;
72 			__entry->srcport = srcport;
73 			__entry->dstport = dstport;
74 			__entry->tdelta = tdelta;
75 		    ),
76 		    TP_printk("skb=%pK seqnum=%u acknum=%u srcport=%u dstport=%u latency(us)=%llu",
77 			      __entry->skb, __entry->tcp_seq_num,
78 			      __entry->tcp_ack_num, __entry->srcport,
79 			      __entry->dstport, __entry->tdelta)
80 );
81 
82 DEFINE_EVENT(dp_trace_tcp_pkt_class, dp_rx_tcp_pkt,
83 	     TP_PROTO(struct sk_buff *skb, uint32_t tcp_seq_num,
84 		      uint32_t tcp_ack_num, uint16_t srcport,
85 		      uint16_t dstport, uint64_t tdelta),
86 	     TP_ARGS(skb, tcp_seq_num, tcp_ack_num, srcport, dstport, tdelta)
87 );
88 
89 DEFINE_EVENT(dp_trace_tcp_pkt_class, dp_tx_comp_tcp_pkt,
90 	     TP_PROTO(struct sk_buff *skb, uint32_t tcp_seq_num,
91 		      uint32_t tcp_ack_num, uint16_t srcport,
92 		      uint16_t dstport, uint64_t tdelta),
93 	     TP_ARGS(skb, tcp_seq_num, tcp_ack_num, srcport, dstport, tdelta)
94 );
95 
96 DECLARE_EVENT_CLASS(dp_trace_udp_pkt_class,
97 		    TP_PROTO(struct sk_buff *skb, uint16_t ip_id,
98 			     uint16_t srcport, uint16_t dstport,
99 			     uint64_t tdelta),
100 		    TP_ARGS(skb, ip_id, srcport, dstport, tdelta),
101 		    TP_STRUCT__entry(
102 			__field(void *, skb)
103 			__field(uint16_t, ip_id)
104 			__field(uint16_t, srcport)
105 			__field(uint16_t, dstport)
106 			__field(uint64_t, tdelta)
107 		    ),
108 		    TP_fast_assign(
109 			__entry->skb = skb;
110 			__entry->ip_id = ip_id;
111 			__entry->srcport = srcport;
112 			__entry->dstport = dstport;
113 			__entry->tdelta = tdelta;
114 		    ),
115 		    TP_printk("skb=%pK ip_id=%u srcport=%u dstport=%d latency(us)=%llu",
116 			      __entry->skb, __entry->ip_id,
117 			      __entry->srcport, __entry->dstport,
118 			      __entry->tdelta)
119 );
120 
121 DEFINE_EVENT(dp_trace_udp_pkt_class, dp_rx_udp_pkt,
122 	     TP_PROTO(struct sk_buff *skb, uint16_t ip_id, uint16_t srcport,
123 		      uint16_t dstport, uint64_t tdelta),
124 	     TP_ARGS(skb, ip_id, srcport, dstport, tdelta)
125 );
126 
127 DEFINE_EVENT(dp_trace_udp_pkt_class, dp_tx_comp_udp_pkt,
128 	     TP_PROTO(struct sk_buff *skb, uint16_t ip_id, uint16_t srcport,
129 		      uint16_t dstport, uint64_t tdelta),
130 	     TP_ARGS(skb, ip_id, srcport, dstport, tdelta)
131 );
132 
133 DECLARE_EVENT_CLASS(dp_trace_generic_ip_pkt_class,
134 		    TP_PROTO(struct sk_buff *skb, uint8_t ip_proto,
135 			     uint16_t ip_id, uint32_t trans_hdr_4_bytes,
136 			     uint64_t tdelta),
137 		    TP_ARGS(skb, ip_proto, ip_id,
138 			    trans_hdr_4_bytes, tdelta),
139 		    TP_STRUCT__entry(
140 			__field(void *, skb)
141 			__field(uint8_t, ip_proto)
142 			__field(uint16_t, ip_id)
143 			__field(uint32_t, trans_hdr_4_bytes)
144 			__field(uint64_t, tdelta)
145 		    ),
146 		    TP_fast_assign(
147 			__entry->skb = skb;
148 			__entry->ip_proto = ip_proto;
149 			__entry->ip_id = ip_id;
150 			__entry->trans_hdr_4_bytes = trans_hdr_4_bytes;
151 			__entry->tdelta = tdelta;
152 		    ),
153 		    TP_printk("skb=%pK ip_proto=0x%x ip_id=0x%x, transport_hdr[4]:0x%08x, latency(us)=%llu",
154 			      __entry->skb, __entry->ip_proto,
155 			      __entry->ip_id,  __entry->trans_hdr_4_bytes,
156 			      __entry->tdelta)
157 );
158 
159 DEFINE_EVENT(dp_trace_generic_ip_pkt_class, dp_rx_generic_ip_pkt,
160 	     TP_PROTO(struct sk_buff *skb, uint8_t ip_proto,
161 		      uint16_t ip_id, uint32_t trans_hdr_4_bytes,
162 		      uint64_t tdelta),
163 	     TP_ARGS(skb, ip_proto, ip_id,
164 		     trans_hdr_4_bytes,
165 		     tdelta)
166 );
167 
168 DEFINE_EVENT(dp_trace_generic_ip_pkt_class, dp_tx_comp_generic_ip_pkt,
169 	     TP_PROTO(struct sk_buff *skb, uint8_t ip_proto,
170 		      uint16_t ip_id, uint32_t trans_hdr_4_bytes,
171 		      uint64_t tdelta),
172 	     TP_ARGS(skb, ip_proto, ip_id,
173 		     trans_hdr_4_bytes,
174 		     tdelta)
175 );
176 
177 DECLARE_EVENT_CLASS(dp_trace_pkt_class,
178 		    TP_PROTO(struct sk_buff *skb, uint16_t ether_type,
179 			     uint64_t tdelta),
180 		    TP_ARGS(skb, ether_type, tdelta),
181 		    TP_STRUCT__entry(
182 			__field(void *, skb)
183 			__field(uint16_t, ether_type)
184 			__field(uint64_t, tdelta)
185 		    ),
186 		    TP_fast_assign(
187 			__entry->skb = skb;
188 			__entry->ether_type = ether_type;
189 			__entry->tdelta = tdelta;
190 		    ),
191 		    TP_printk("skb=%pK ether_type=0x%x latency(us)=%llu",
192 			      __entry->skb, __entry->ether_type,
193 			      __entry->tdelta)
194 );
195 
196 DEFINE_EVENT(dp_trace_pkt_class, dp_rx_pkt,
197 	     TP_PROTO(struct sk_buff *skb, uint16_t ether_type,
198 		      uint64_t tdelta),
199 	     TP_ARGS(skb, ether_type, tdelta)
200 );
201 
202 DEFINE_EVENT(dp_trace_pkt_class, dp_tx_comp_pkt,
203 	     TP_PROTO(struct sk_buff *skb, uint16_t ether_type,
204 		      uint64_t tdelta),
205 	     TP_ARGS(skb, ether_type, tdelta)
206 );
207 
208 TRACE_EVENT(dp_del_reg_write,
209 	    TP_PROTO(uint8_t srng_id, uint32_t enq_val, uint32_t deq_val,
210 		     uint64_t enq_time, uint64_t deq_time),
211 	    TP_ARGS(srng_id, enq_val, deq_val, enq_time, deq_time),
212 	    TP_STRUCT__entry(
213 		__field(uint8_t, srng_id)
214 		__field(uint32_t, enq_val)
215 		__field(uint32_t, deq_val)
216 		__field(uint64_t, enq_time)
217 		__field(uint64_t, deq_time)
218 	    ),
219 	    TP_fast_assign(
220 		__entry->srng_id = srng_id;
221 		__entry->enq_val = enq_val;
222 		__entry->deq_val = deq_val;
223 		__entry->enq_time = enq_time;
224 		__entry->deq_time = deq_time;
225 	    ),
226 	    TP_printk("srng_id=%u enq_val=%u deq_val=%u enq_time=0x%llx deq_time=0x%llx",
227 		      __entry->srng_id, __entry->enq_val, __entry->deq_val,
228 		      __entry->enq_time, __entry->deq_time)
229 );
230 
231 TRACE_EVENT(dp_ce_tasklet_sched_latency,
232 	    TP_PROTO(uint8_t ce_id, uint64_t sched_latency),
233 	    TP_ARGS(ce_id, sched_latency),
234 	    TP_STRUCT__entry(
235 		__field(uint8_t, ce_id)
236 		__field(uint64_t, sched_latency)
237 	    ),
238 	    TP_fast_assign(
239 		__entry->ce_id = ce_id;
240 		__entry->sched_latency = sched_latency;
241 	    ),
242 	    TP_printk("ce_id=%u latency(ns)=%llu", __entry->ce_id,
243 		      __entry->sched_latency)
244 );
245 #endif /* _QDF_TRACEPOINT_DEFS_H */
246 
247 /* Below should be outside the protection */
248 #undef TRACE_INCLUDE_PATH
249 #define TRACE_INCLUDE_PATH .
250 #undef TRACE_INCLUDE_FILE
251 #define TRACE_INCLUDE_FILE qdf_tracepoint_defs
252 #include <trace/define_trace.h>
253