1 /*
2  * Copyright(c) 2015 - 2017 Intel Corporation.
3  *
4  * This file is provided under a dual BSD/GPLv2 license.  When using or
5  * redistributing this file, you may do so under either license.
6  *
7  * GPL LICENSE SUMMARY
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of version 2 of the GNU General Public License as
11  * published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * BSD LICENSE
19  *
20  * Redistribution and use in source and binary forms, with or without
21  * modification, are permitted provided that the following conditions
22  * are met:
23  *
24  *  - Redistributions of source code must retain the above copyright
25  *    notice, this list of conditions and the following disclaimer.
26  *  - Redistributions in binary form must reproduce the above copyright
27  *    notice, this list of conditions and the following disclaimer in
28  *    the documentation and/or other materials provided with the
29  *    distribution.
30  *  - Neither the name of Intel Corporation nor the names of its
31  *    contributors may be used to endorse or promote products derived
32  *    from this software without specific prior written permission.
33  *
34  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45  *
46  */
47 #if !defined(__HFI1_TRACE_RX_H) || defined(TRACE_HEADER_MULTI_READ)
48 #define __HFI1_TRACE_RX_H
49 
50 #include <linux/tracepoint.h>
51 #include <linux/trace_seq.h>
52 
53 #include "hfi.h"
54 
55 #define tidtype_name(type) { PT_##type, #type }
56 #define show_tidtype(type)                   \
57 __print_symbolic(type,                       \
58 	tidtype_name(EXPECTED),              \
59 	tidtype_name(EAGER),                 \
60 	tidtype_name(INVALID))               \
61 
62 #undef TRACE_SYSTEM
63 #define TRACE_SYSTEM hfi1_rx
64 
65 TRACE_EVENT(hfi1_rcvhdr,
66 	    TP_PROTO(struct hfi1_devdata *dd,
67 		     u32 ctxt,
68 		     u64 eflags,
69 		     u32 etype,
70 		     u32 hlen,
71 		     u32 tlen,
72 		     u32 updegr,
73 		     u32 etail
74 		    ),
75 	    TP_ARGS(dd, ctxt, eflags, etype, hlen, tlen, updegr, etail),
76 	    TP_STRUCT__entry(DD_DEV_ENTRY(dd)
77 			     __field(u64, eflags)
78 			     __field(u32, ctxt)
79 			     __field(u32, etype)
80 			     __field(u32, hlen)
81 			     __field(u32, tlen)
82 			     __field(u32, updegr)
83 			     __field(u32, etail)
84 			     ),
85 	     TP_fast_assign(DD_DEV_ASSIGN(dd);
86 			    __entry->eflags = eflags;
87 			    __entry->ctxt = ctxt;
88 			    __entry->etype = etype;
89 			    __entry->hlen = hlen;
90 			    __entry->tlen = tlen;
91 			    __entry->updegr = updegr;
92 			    __entry->etail = etail;
93 			    ),
94 	     TP_printk(
95 		"[%s] ctxt %d eflags 0x%llx etype %d,%s hlen %d tlen %d updegr %d etail %d",
96 		__get_str(dev),
97 		__entry->ctxt,
98 		__entry->eflags,
99 		__entry->etype, show_packettype(__entry->etype),
100 		__entry->hlen,
101 		__entry->tlen,
102 		__entry->updegr,
103 		__entry->etail
104 		)
105 );
106 
107 TRACE_EVENT(hfi1_receive_interrupt,
108 	    TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd),
109 	    TP_ARGS(dd, rcd),
110 	    TP_STRUCT__entry(DD_DEV_ENTRY(dd)
111 			     __field(u32, ctxt)
112 			     __field(u8, slow_path)
113 			     __field(u8, dma_rtail)
114 			     ),
115 	    TP_fast_assign(DD_DEV_ASSIGN(dd);
116 			__entry->ctxt = rcd->ctxt;
117 			if (rcd->do_interrupt ==
118 			    &handle_receive_interrupt) {
119 				__entry->slow_path = 1;
120 				__entry->dma_rtail = 0xFF;
121 			} else if (rcd->do_interrupt ==
122 					&handle_receive_interrupt_dma_rtail){
123 				__entry->dma_rtail = 1;
124 				__entry->slow_path = 0;
125 			} else if (rcd->do_interrupt ==
126 					&handle_receive_interrupt_nodma_rtail) {
127 				__entry->dma_rtail = 0;
128 				__entry->slow_path = 0;
129 			}
130 			),
131 	    TP_printk("[%s] ctxt %d SlowPath: %d DmaRtail: %d",
132 		      __get_str(dev),
133 		      __entry->ctxt,
134 		      __entry->slow_path,
135 		      __entry->dma_rtail
136 		      )
137 );
138 
139 DECLARE_EVENT_CLASS(
140 	    hfi1_exp_tid_reg_unreg,
141 	    TP_PROTO(unsigned int ctxt, u16 subctxt, u32 rarr,
142 		     u32 npages, unsigned long va, unsigned long pa,
143 		     dma_addr_t dma),
144 	    TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma),
145 	    TP_STRUCT__entry(
146 			     __field(unsigned int, ctxt)
147 			     __field(u16, subctxt)
148 			     __field(u32, rarr)
149 			     __field(u32, npages)
150 			     __field(unsigned long, va)
151 			     __field(unsigned long, pa)
152 			     __field(dma_addr_t, dma)
153 			     ),
154 	    TP_fast_assign(
155 			   __entry->ctxt = ctxt;
156 			   __entry->subctxt = subctxt;
157 			   __entry->rarr = rarr;
158 			   __entry->npages = npages;
159 			   __entry->va = va;
160 			   __entry->pa = pa;
161 			   __entry->dma = dma;
162 			   ),
163 	    TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx, va:0x%lx dma:0x%llx",
164 		      __entry->ctxt,
165 		      __entry->subctxt,
166 		      __entry->rarr,
167 		      __entry->npages,
168 		      __entry->pa,
169 		      __entry->va,
170 		      __entry->dma
171 		      )
172 	);
173 
174 DEFINE_EVENT(
175 	hfi1_exp_tid_reg_unreg, hfi1_exp_tid_unreg,
176 	TP_PROTO(unsigned int ctxt, u16 subctxt, u32 rarr, u32 npages,
177 		 unsigned long va, unsigned long pa, dma_addr_t dma),
178 	TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma));
179 
180 DEFINE_EVENT(
181 	hfi1_exp_tid_reg_unreg, hfi1_exp_tid_reg,
182 	TP_PROTO(unsigned int ctxt, u16 subctxt, u32 rarr, u32 npages,
183 		 unsigned long va, unsigned long pa, dma_addr_t dma),
184 	TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma));
185 
186 TRACE_EVENT(
187 	hfi1_put_tid,
188 	TP_PROTO(struct hfi1_devdata *dd,
189 		 u32 index, u32 type, unsigned long pa, u16 order),
190 	TP_ARGS(dd, index, type, pa, order),
191 	TP_STRUCT__entry(
192 		DD_DEV_ENTRY(dd)
193 		__field(unsigned long, pa);
194 		__field(u32, index);
195 		__field(u32, type);
196 		__field(u16, order);
197 	),
198 	TP_fast_assign(
199 		DD_DEV_ASSIGN(dd);
200 		__entry->pa = pa;
201 		__entry->index = index;
202 		__entry->type = type;
203 		__entry->order = order;
204 	),
205 	TP_printk("[%s] type %s pa %lx index %u order %u",
206 		  __get_str(dev),
207 		  show_tidtype(__entry->type),
208 		  __entry->pa,
209 		  __entry->index,
210 		  __entry->order
211 	)
212 );
213 
214 TRACE_EVENT(hfi1_exp_tid_inval,
215 	    TP_PROTO(unsigned int ctxt, u16 subctxt, unsigned long va, u32 rarr,
216 		     u32 npages, dma_addr_t dma),
217 	    TP_ARGS(ctxt, subctxt, va, rarr, npages, dma),
218 	    TP_STRUCT__entry(
219 			     __field(unsigned int, ctxt)
220 			     __field(u16, subctxt)
221 			     __field(unsigned long, va)
222 			     __field(u32, rarr)
223 			     __field(u32, npages)
224 			     __field(dma_addr_t, dma)
225 			     ),
226 	    TP_fast_assign(
227 			   __entry->ctxt = ctxt;
228 			   __entry->subctxt = subctxt;
229 			   __entry->va = va;
230 			   __entry->rarr = rarr;
231 			   __entry->npages = npages;
232 			   __entry->dma = dma;
233 			  ),
234 	    TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx dma: 0x%llx",
235 		      __entry->ctxt,
236 		      __entry->subctxt,
237 		      __entry->rarr,
238 		      __entry->npages,
239 		      __entry->va,
240 		      __entry->dma
241 		      )
242 	    );
243 
244 TRACE_EVENT(hfi1_mmu_invalidate,
245 	    TP_PROTO(unsigned int ctxt, u16 subctxt, const char *type,
246 		     unsigned long start, unsigned long end),
247 	    TP_ARGS(ctxt, subctxt, type, start, end),
248 	    TP_STRUCT__entry(
249 			     __field(unsigned int, ctxt)
250 			     __field(u16, subctxt)
251 			     __string(type, type)
252 			     __field(unsigned long, start)
253 			     __field(unsigned long, end)
254 			     ),
255 	    TP_fast_assign(
256 			__entry->ctxt = ctxt;
257 			__entry->subctxt = subctxt;
258 			__assign_str(type, type);
259 			__entry->start = start;
260 			__entry->end = end;
261 	    ),
262 	    TP_printk("[%3u:%02u] MMU Invalidate (%s) 0x%lx - 0x%lx",
263 		      __entry->ctxt,
264 		      __entry->subctxt,
265 		      __get_str(type),
266 		      __entry->start,
267 		      __entry->end
268 		      )
269 	    );
270 
271 #endif /* __HFI1_TRACE_RX_H */
272 
273 #undef TRACE_INCLUDE_PATH
274 #undef TRACE_INCLUDE_FILE
275 #define TRACE_INCLUDE_PATH .
276 #define TRACE_INCLUDE_FILE trace_rx
277 #include <trace/define_trace.h>
278