xref: /openbmc/linux/drivers/infiniband/hw/hfi1/trace.h (revision 7587eb18)
1 /*
2  * Copyright(c) 2015, 2016 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 #undef TRACE_SYSTEM_VAR
48 #define TRACE_SYSTEM_VAR hfi1
49 
50 #if !defined(__HFI1_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
51 #define __HFI1_TRACE_H
52 
53 #include <linux/tracepoint.h>
54 #include <linux/trace_seq.h>
55 
56 #include "hfi.h"
57 #include "mad.h"
58 #include "sdma.h"
59 
60 #define DD_DEV_ENTRY(dd)       __string(dev, dev_name(&(dd)->pcidev->dev))
61 #define DD_DEV_ASSIGN(dd)      __assign_str(dev, dev_name(&(dd)->pcidev->dev))
62 
63 #define packettype_name(etype) { RHF_RCV_TYPE_##etype, #etype }
64 #define show_packettype(etype)                  \
65 __print_symbolic(etype,                         \
66 	packettype_name(EXPECTED),              \
67 	packettype_name(EAGER),                 \
68 	packettype_name(IB),                    \
69 	packettype_name(ERROR),                 \
70 	packettype_name(BYPASS))
71 
72 #undef TRACE_SYSTEM
73 #define TRACE_SYSTEM hfi1_rx
74 
75 TRACE_EVENT(hfi1_rcvhdr,
76 	    TP_PROTO(struct hfi1_devdata *dd,
77 		     u32 ctxt,
78 		     u64 eflags,
79 		     u32 etype,
80 		     u32 hlen,
81 		     u32 tlen,
82 		     u32 updegr,
83 		     u32 etail
84 		     ),
85 	    TP_ARGS(dd, ctxt, eflags, etype, hlen, tlen, updegr, etail),
86 	    TP_STRUCT__entry(DD_DEV_ENTRY(dd)
87 			     __field(u64, eflags)
88 			     __field(u32, ctxt)
89 			     __field(u32, etype)
90 			     __field(u32, hlen)
91 			     __field(u32, tlen)
92 			     __field(u32, updegr)
93 			     __field(u32, etail)
94 			     ),
95 	    TP_fast_assign(DD_DEV_ASSIGN(dd);
96 			   __entry->eflags = eflags;
97 			   __entry->ctxt = ctxt;
98 			   __entry->etype = etype;
99 			   __entry->hlen = hlen;
100 			   __entry->tlen = tlen;
101 			   __entry->updegr = updegr;
102 			   __entry->etail = etail;
103 			   ),
104 	    TP_printk(
105 		      "[%s] ctxt %d eflags 0x%llx etype %d,%s hlen %d tlen %d updegr %d etail %d",
106 		      __get_str(dev),
107 		      __entry->ctxt,
108 		      __entry->eflags,
109 		      __entry->etype, show_packettype(__entry->etype),
110 		      __entry->hlen,
111 		      __entry->tlen,
112 		      __entry->updegr,
113 		      __entry->etail
114 		      )
115 );
116 
117 TRACE_EVENT(hfi1_receive_interrupt,
118 	    TP_PROTO(struct hfi1_devdata *dd, u32 ctxt),
119 	    TP_ARGS(dd, ctxt),
120 	    TP_STRUCT__entry(DD_DEV_ENTRY(dd)
121 			     __field(u32, ctxt)
122 			     __field(u8, slow_path)
123 			     __field(u8, dma_rtail)
124 			     ),
125 	    TP_fast_assign(DD_DEV_ASSIGN(dd);
126 			   __entry->ctxt = ctxt;
127 			   if (dd->rcd[ctxt]->do_interrupt ==
128 			       &handle_receive_interrupt) {
129 				__entry->slow_path = 1;
130 				__entry->dma_rtail = 0xFF;
131 			   } else if (dd->rcd[ctxt]->do_interrupt ==
132 				      &handle_receive_interrupt_dma_rtail){
133 				__entry->dma_rtail = 1;
134 				__entry->slow_path = 0;
135 			   } else if (dd->rcd[ctxt]->do_interrupt ==
136 				      &handle_receive_interrupt_nodma_rtail) {
137 				__entry->dma_rtail = 0;
138 				__entry->slow_path = 0;
139 			   }
140 			   ),
141 	    TP_printk("[%s] ctxt %d SlowPath: %d DmaRtail: %d",
142 		      __get_str(dev),
143 		      __entry->ctxt,
144 		      __entry->slow_path,
145 		      __entry->dma_rtail
146 		      )
147 );
148 
149 TRACE_EVENT(hfi1_exp_tid_reg,
150 	    TP_PROTO(unsigned ctxt, u16 subctxt, u32 rarr,
151 		     u32 npages, unsigned long va, unsigned long pa,
152 		     dma_addr_t dma),
153 	    TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma),
154 	    TP_STRUCT__entry(
155 		    __field(unsigned, ctxt)
156 		    __field(u16, subctxt)
157 		    __field(u32, rarr)
158 		    __field(u32, npages)
159 		    __field(unsigned long, va)
160 		    __field(unsigned long, pa)
161 		    __field(dma_addr_t, dma)
162 		    ),
163 	    TP_fast_assign(
164 		    __entry->ctxt = ctxt;
165 		    __entry->subctxt = subctxt;
166 		    __entry->rarr = rarr;
167 		    __entry->npages = npages;
168 		    __entry->va = va;
169 		    __entry->pa = pa;
170 		    __entry->dma = dma;
171 		    ),
172 	    TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx, va:0x%lx dma:0x%llx",
173 		      __entry->ctxt,
174 		      __entry->subctxt,
175 		      __entry->rarr,
176 		      __entry->npages,
177 		      __entry->pa,
178 		      __entry->va,
179 		      __entry->dma
180 		    )
181 	);
182 
183 TRACE_EVENT(hfi1_exp_tid_unreg,
184 	    TP_PROTO(unsigned ctxt, u16 subctxt, u32 rarr, u32 npages,
185 		     unsigned long va, unsigned long pa, dma_addr_t dma),
186 	    TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma),
187 	    TP_STRUCT__entry(
188 		    __field(unsigned, ctxt)
189 		    __field(u16, subctxt)
190 		    __field(u32, rarr)
191 		    __field(u32, npages)
192 		    __field(unsigned long, va)
193 		    __field(unsigned long, pa)
194 		    __field(dma_addr_t, dma)
195 		    ),
196 	    TP_fast_assign(
197 		    __entry->ctxt = ctxt;
198 		    __entry->subctxt = subctxt;
199 		    __entry->rarr = rarr;
200 		    __entry->npages = npages;
201 		    __entry->va = va;
202 		    __entry->pa = pa;
203 		    __entry->dma = dma;
204 		    ),
205 	    TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx, va:0x%lx dma:0x%llx",
206 		      __entry->ctxt,
207 		      __entry->subctxt,
208 		      __entry->rarr,
209 		      __entry->npages,
210 		      __entry->pa,
211 		      __entry->va,
212 		      __entry->dma
213 		    )
214 	);
215 
216 TRACE_EVENT(hfi1_exp_tid_inval,
217 	    TP_PROTO(unsigned ctxt, u16 subctxt, unsigned long va, u32 rarr,
218 		     u32 npages, dma_addr_t dma),
219 	    TP_ARGS(ctxt, subctxt, va, rarr, npages, dma),
220 	    TP_STRUCT__entry(
221 		    __field(unsigned, ctxt)
222 		    __field(u16, subctxt)
223 		    __field(unsigned long, va)
224 		    __field(u32, rarr)
225 		    __field(u32, npages)
226 		    __field(dma_addr_t, dma)
227 		    ),
228 	    TP_fast_assign(
229 		    __entry->ctxt = ctxt;
230 		    __entry->subctxt = subctxt;
231 		    __entry->va = va;
232 		    __entry->rarr = rarr;
233 		    __entry->npages = npages;
234 		    __entry->dma = dma;
235 		    ),
236 	    TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx dma: 0x%llx",
237 		      __entry->ctxt,
238 		      __entry->subctxt,
239 		      __entry->rarr,
240 		      __entry->npages,
241 		      __entry->va,
242 		      __entry->dma
243 		    )
244 	);
245 
246 TRACE_EVENT(hfi1_mmu_invalidate,
247 	    TP_PROTO(unsigned ctxt, u16 subctxt, const char *type,
248 		     unsigned long start, unsigned long end),
249 	    TP_ARGS(ctxt, subctxt, type, start, end),
250 	    TP_STRUCT__entry(
251 		    __field(unsigned, ctxt)
252 		    __field(u16, subctxt)
253 		    __string(type, type)
254 		    __field(unsigned long, start)
255 		    __field(unsigned long, end)
256 		    ),
257 	    TP_fast_assign(
258 		    __entry->ctxt = ctxt;
259 		    __entry->subctxt = subctxt;
260 		    __assign_str(type, type);
261 		    __entry->start = start;
262 		    __entry->end = end;
263 		    ),
264 	    TP_printk("[%3u:%02u] MMU Invalidate (%s) 0x%lx - 0x%lx",
265 		      __entry->ctxt,
266 		      __entry->subctxt,
267 		      __get_str(type),
268 		      __entry->start,
269 		      __entry->end
270 		    )
271 	);
272 
273 #undef TRACE_SYSTEM
274 #define TRACE_SYSTEM hfi1_tx
275 
276 TRACE_EVENT(hfi1_piofree,
277 	    TP_PROTO(struct send_context *sc, int extra),
278 	    TP_ARGS(sc, extra),
279 	    TP_STRUCT__entry(DD_DEV_ENTRY(sc->dd)
280 			     __field(u32, sw_index)
281 			     __field(u32, hw_context)
282 			     __field(int, extra)
283 			     ),
284 	    TP_fast_assign(DD_DEV_ASSIGN(sc->dd);
285 			   __entry->sw_index = sc->sw_index;
286 			   __entry->hw_context = sc->hw_context;
287 			   __entry->extra = extra;
288 			   ),
289 	    TP_printk("[%s] ctxt %u(%u) extra %d",
290 		      __get_str(dev),
291 		      __entry->sw_index,
292 		      __entry->hw_context,
293 		      __entry->extra
294 		      )
295 );
296 
297 TRACE_EVENT(hfi1_wantpiointr,
298 	    TP_PROTO(struct send_context *sc, u32 needint, u64 credit_ctrl),
299 	    TP_ARGS(sc, needint, credit_ctrl),
300 	    TP_STRUCT__entry(DD_DEV_ENTRY(sc->dd)
301 			     __field(u32, sw_index)
302 			     __field(u32, hw_context)
303 			     __field(u32, needint)
304 			     __field(u64, credit_ctrl)
305 			     ),
306 	    TP_fast_assign(DD_DEV_ASSIGN(sc->dd);
307 			   __entry->sw_index = sc->sw_index;
308 			   __entry->hw_context = sc->hw_context;
309 			   __entry->needint = needint;
310 			   __entry->credit_ctrl = credit_ctrl;
311 			   ),
312 	    TP_printk("[%s] ctxt %u(%u) on %d credit_ctrl 0x%llx",
313 		      __get_str(dev),
314 		      __entry->sw_index,
315 		      __entry->hw_context,
316 		      __entry->needint,
317 		      (unsigned long long)__entry->credit_ctrl
318 		       )
319 );
320 
321 DECLARE_EVENT_CLASS(hfi1_qpsleepwakeup_template,
322 		    TP_PROTO(struct rvt_qp *qp, u32 flags),
323 		    TP_ARGS(qp, flags),
324 		    TP_STRUCT__entry(
325 			    DD_DEV_ENTRY(dd_from_ibdev(qp->ibqp.device))
326 			    __field(u32, qpn)
327 			    __field(u32, flags)
328 			    __field(u32, s_flags)
329 			    ),
330 		    TP_fast_assign(
331 			    DD_DEV_ASSIGN(dd_from_ibdev(qp->ibqp.device))
332 			    __entry->flags = flags;
333 			    __entry->qpn = qp->ibqp.qp_num;
334 			    __entry->s_flags = qp->s_flags;
335 			    ),
336 		    TP_printk(
337 			    "[%s] qpn 0x%x flags 0x%x s_flags 0x%x",
338 			    __get_str(dev),
339 			    __entry->qpn,
340 			    __entry->flags,
341 			    __entry->s_flags
342 			    )
343 );
344 
345 DEFINE_EVENT(hfi1_qpsleepwakeup_template, hfi1_qpwakeup,
346 	     TP_PROTO(struct rvt_qp *qp, u32 flags),
347 	     TP_ARGS(qp, flags));
348 
349 DEFINE_EVENT(hfi1_qpsleepwakeup_template, hfi1_qpsleep,
350 	     TP_PROTO(struct rvt_qp *qp, u32 flags),
351 	     TP_ARGS(qp, flags));
352 
353 #undef TRACE_SYSTEM
354 #define TRACE_SYSTEM hfi1_ibhdrs
355 
356 u8 ibhdr_exhdr_len(struct hfi1_ib_header *hdr);
357 const char *parse_everbs_hdrs(struct trace_seq *p, u8 opcode, void *ehdrs);
358 
359 #define __parse_ib_ehdrs(op, ehdrs) parse_everbs_hdrs(p, op, ehdrs)
360 
361 const char *parse_sdma_flags(struct trace_seq *p, u64 desc0, u64 desc1);
362 
363 #define __parse_sdma_flags(desc0, desc1) parse_sdma_flags(p, desc0, desc1)
364 
365 #define lrh_name(lrh) { HFI1_##lrh, #lrh }
366 #define show_lnh(lrh)                    \
367 __print_symbolic(lrh,                    \
368 	lrh_name(LRH_BTH),               \
369 	lrh_name(LRH_GRH))
370 
371 #define ib_opcode_name(opcode) { IB_OPCODE_##opcode, #opcode  }
372 #define show_ib_opcode(opcode)                             \
373 __print_symbolic(opcode,                                   \
374 	ib_opcode_name(RC_SEND_FIRST),                     \
375 	ib_opcode_name(RC_SEND_MIDDLE),                    \
376 	ib_opcode_name(RC_SEND_LAST),                      \
377 	ib_opcode_name(RC_SEND_LAST_WITH_IMMEDIATE),       \
378 	ib_opcode_name(RC_SEND_ONLY),                      \
379 	ib_opcode_name(RC_SEND_ONLY_WITH_IMMEDIATE),       \
380 	ib_opcode_name(RC_RDMA_WRITE_FIRST),               \
381 	ib_opcode_name(RC_RDMA_WRITE_MIDDLE),              \
382 	ib_opcode_name(RC_RDMA_WRITE_LAST),                \
383 	ib_opcode_name(RC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
384 	ib_opcode_name(RC_RDMA_WRITE_ONLY),                \
385 	ib_opcode_name(RC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
386 	ib_opcode_name(RC_RDMA_READ_REQUEST),              \
387 	ib_opcode_name(RC_RDMA_READ_RESPONSE_FIRST),       \
388 	ib_opcode_name(RC_RDMA_READ_RESPONSE_MIDDLE),      \
389 	ib_opcode_name(RC_RDMA_READ_RESPONSE_LAST),        \
390 	ib_opcode_name(RC_RDMA_READ_RESPONSE_ONLY),        \
391 	ib_opcode_name(RC_ACKNOWLEDGE),                    \
392 	ib_opcode_name(RC_ATOMIC_ACKNOWLEDGE),             \
393 	ib_opcode_name(RC_COMPARE_SWAP),                   \
394 	ib_opcode_name(RC_FETCH_ADD),                      \
395 	ib_opcode_name(RC_SEND_LAST_WITH_INVALIDATE),      \
396 	ib_opcode_name(RC_SEND_ONLY_WITH_INVALIDATE),      \
397 	ib_opcode_name(UC_SEND_FIRST),                     \
398 	ib_opcode_name(UC_SEND_MIDDLE),                    \
399 	ib_opcode_name(UC_SEND_LAST),                      \
400 	ib_opcode_name(UC_SEND_LAST_WITH_IMMEDIATE),       \
401 	ib_opcode_name(UC_SEND_ONLY),                      \
402 	ib_opcode_name(UC_SEND_ONLY_WITH_IMMEDIATE),       \
403 	ib_opcode_name(UC_RDMA_WRITE_FIRST),               \
404 	ib_opcode_name(UC_RDMA_WRITE_MIDDLE),              \
405 	ib_opcode_name(UC_RDMA_WRITE_LAST),                \
406 	ib_opcode_name(UC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
407 	ib_opcode_name(UC_RDMA_WRITE_ONLY),                \
408 	ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
409 	ib_opcode_name(UD_SEND_ONLY),                      \
410 	ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE),       \
411 	ib_opcode_name(CNP))
412 
413 #define LRH_PRN "vl %d lver %d sl %d lnh %d,%s dlid %.4x len %d slid %.4x"
414 #define BTH_PRN \
415 	"op 0x%.2x,%s se %d m %d pad %d tver %d pkey 0x%.4x " \
416 	"f %d b %d qpn 0x%.6x a %d psn 0x%.8x"
417 #define EHDR_PRN "%s"
418 
419 DECLARE_EVENT_CLASS(hfi1_ibhdr_template,
420 		    TP_PROTO(struct hfi1_devdata *dd,
421 			     struct hfi1_ib_header *hdr),
422 		    TP_ARGS(dd, hdr),
423 		    TP_STRUCT__entry(
424 			    DD_DEV_ENTRY(dd)
425 			    /* LRH */
426 			    __field(u8, vl)
427 			    __field(u8, lver)
428 			    __field(u8, sl)
429 			    __field(u8, lnh)
430 			    __field(u16, dlid)
431 			    __field(u16, len)
432 			    __field(u16, slid)
433 			    /* BTH */
434 			    __field(u8, opcode)
435 			    __field(u8, se)
436 			    __field(u8, m)
437 			    __field(u8, pad)
438 			    __field(u8, tver)
439 			    __field(u16, pkey)
440 			    __field(u8, f)
441 			    __field(u8, b)
442 			    __field(u32, qpn)
443 			    __field(u8, a)
444 			    __field(u32, psn)
445 			    /* extended headers */
446 			    __dynamic_array(u8, ehdrs, ibhdr_exhdr_len(hdr))
447 			    ),
448 		    TP_fast_assign(
449 			   struct hfi1_other_headers *ohdr;
450 
451 			   DD_DEV_ASSIGN(dd);
452 			   /* LRH */
453 			   __entry->vl =
454 			   (u8)(be16_to_cpu(hdr->lrh[0]) >> 12);
455 			   __entry->lver =
456 			   (u8)(be16_to_cpu(hdr->lrh[0]) >> 8) & 0xf;
457 			   __entry->sl =
458 			   (u8)(be16_to_cpu(hdr->lrh[0]) >> 4) & 0xf;
459 			   __entry->lnh =
460 			   (u8)(be16_to_cpu(hdr->lrh[0]) & 3);
461 			   __entry->dlid =
462 			   be16_to_cpu(hdr->lrh[1]);
463 			   /* allow for larger len */
464 			   __entry->len =
465 			   be16_to_cpu(hdr->lrh[2]);
466 			   __entry->slid =
467 			   be16_to_cpu(hdr->lrh[3]);
468 			   /* BTH */
469 			   if (__entry->lnh == HFI1_LRH_BTH)
470 				ohdr = &hdr->u.oth;
471 			   else
472 				ohdr = &hdr->u.l.oth;
473 			  __entry->opcode =
474 			  (be32_to_cpu(ohdr->bth[0]) >> 24) & 0xff;
475 			  __entry->se =
476 			  (be32_to_cpu(ohdr->bth[0]) >> 23) & 1;
477 			  __entry->m =
478 			  (be32_to_cpu(ohdr->bth[0]) >> 22) & 1;
479 			  __entry->pad =
480 			  (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
481 			  __entry->tver =
482 			  (be32_to_cpu(ohdr->bth[0]) >> 16) & 0xf;
483 			  __entry->pkey =
484 			  be32_to_cpu(ohdr->bth[0]) & 0xffff;
485 			  __entry->f =
486 			  (be32_to_cpu(ohdr->bth[1]) >> HFI1_FECN_SHIFT) &
487 			  HFI1_FECN_MASK;
488 			  __entry->b =
489 			  (be32_to_cpu(ohdr->bth[1]) >> HFI1_BECN_SHIFT) &
490 			  HFI1_BECN_MASK;
491 			  __entry->qpn =
492 			  be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;
493 			  __entry->a =
494 			  (be32_to_cpu(ohdr->bth[2]) >> 31) & 1;
495 			  /* allow for larger PSN */
496 			  __entry->psn =
497 			  be32_to_cpu(ohdr->bth[2]) & 0x7fffffff;
498 			  /* extended headers */
499 			  memcpy(__get_dynamic_array(ehdrs), &ohdr->u,
500 				 ibhdr_exhdr_len(hdr));
501 			 ),
502 		    TP_printk("[%s] " LRH_PRN " " BTH_PRN " " EHDR_PRN,
503 			      __get_str(dev),
504 			      /* LRH */
505 			      __entry->vl,
506 			      __entry->lver,
507 			      __entry->sl,
508 			      __entry->lnh, show_lnh(__entry->lnh),
509 			      __entry->dlid,
510 			      __entry->len,
511 			      __entry->slid,
512 			      /* BTH */
513 			      __entry->opcode, show_ib_opcode(__entry->opcode),
514 			      __entry->se,
515 			      __entry->m,
516 			      __entry->pad,
517 			      __entry->tver,
518 			      __entry->pkey,
519 			      __entry->f,
520 			      __entry->b,
521 			      __entry->qpn,
522 			      __entry->a,
523 			      __entry->psn,
524 			      /* extended headers */
525 			      __parse_ib_ehdrs(
526 					__entry->opcode,
527 					(void *)__get_dynamic_array(ehdrs))
528 			     )
529 );
530 
531 DEFINE_EVENT(hfi1_ibhdr_template, input_ibhdr,
532 	     TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ib_header *hdr),
533 	     TP_ARGS(dd, hdr));
534 
535 DEFINE_EVENT(hfi1_ibhdr_template, pio_output_ibhdr,
536 	     TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ib_header *hdr),
537 	     TP_ARGS(dd, hdr));
538 
539 DEFINE_EVENT(hfi1_ibhdr_template, ack_output_ibhdr,
540 	     TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ib_header *hdr),
541 	     TP_ARGS(dd, hdr));
542 
543 DEFINE_EVENT(hfi1_ibhdr_template, sdma_output_ibhdr,
544 	     TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ib_header *hdr),
545 	     TP_ARGS(dd, hdr));
546 
547 #define SNOOP_PRN \
548 	"slid %.4x dlid %.4x qpn 0x%.6x opcode 0x%.2x,%s " \
549 	"svc lvl %d pkey 0x%.4x [header = %d bytes] [data = %d bytes]"
550 
551 #undef TRACE_SYSTEM
552 #define TRACE_SYSTEM hfi1_snoop
553 
554 TRACE_EVENT(snoop_capture,
555 	    TP_PROTO(struct hfi1_devdata *dd,
556 		     int hdr_len,
557 		     struct hfi1_ib_header *hdr,
558 		     int data_len,
559 		     void *data),
560 	    TP_ARGS(dd, hdr_len, hdr, data_len, data),
561 	    TP_STRUCT__entry(
562 		DD_DEV_ENTRY(dd)
563 		__field(u16, slid)
564 		__field(u16, dlid)
565 		__field(u32, qpn)
566 		__field(u8, opcode)
567 		__field(u8, sl)
568 		__field(u16, pkey)
569 		__field(u32, hdr_len)
570 		__field(u32, data_len)
571 		__field(u8, lnh)
572 		__dynamic_array(u8, raw_hdr, hdr_len)
573 		__dynamic_array(u8, raw_pkt, data_len)
574 		),
575 	    TP_fast_assign(
576 		struct hfi1_other_headers *ohdr;
577 
578 		__entry->lnh = (u8)(be16_to_cpu(hdr->lrh[0]) & 3);
579 		if (__entry->lnh == HFI1_LRH_BTH)
580 			ohdr = &hdr->u.oth;
581 		else
582 			ohdr = &hdr->u.l.oth;
583 		DD_DEV_ASSIGN(dd);
584 		__entry->slid = be16_to_cpu(hdr->lrh[3]);
585 		__entry->dlid = be16_to_cpu(hdr->lrh[1]);
586 		__entry->qpn = be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;
587 		__entry->opcode = (be32_to_cpu(ohdr->bth[0]) >> 24) & 0xff;
588 		__entry->sl = (u8)(be16_to_cpu(hdr->lrh[0]) >> 4) & 0xf;
589 		__entry->pkey =	be32_to_cpu(ohdr->bth[0]) & 0xffff;
590 		__entry->hdr_len = hdr_len;
591 		__entry->data_len = data_len;
592 		memcpy(__get_dynamic_array(raw_hdr), hdr, hdr_len);
593 		memcpy(__get_dynamic_array(raw_pkt), data, data_len);
594 		),
595 	    TP_printk(
596 		"[%s] " SNOOP_PRN,
597 		__get_str(dev),
598 		__entry->slid,
599 		__entry->dlid,
600 		__entry->qpn,
601 		__entry->opcode,
602 		show_ib_opcode(__entry->opcode),
603 		__entry->sl,
604 		__entry->pkey,
605 		__entry->hdr_len,
606 		__entry->data_len
607 		)
608 );
609 
610 #undef TRACE_SYSTEM
611 #define TRACE_SYSTEM hfi1_ctxts
612 
613 #define UCTXT_FMT \
614 	"cred:%u, credaddr:0x%llx, piobase:0x%llx, rcvhdr_cnt:%u, "	\
615 	"rcvbase:0x%llx, rcvegrc:%u, rcvegrb:0x%llx"
616 TRACE_EVENT(hfi1_uctxtdata,
617 	    TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ctxtdata *uctxt),
618 	    TP_ARGS(dd, uctxt),
619 	    TP_STRUCT__entry(DD_DEV_ENTRY(dd)
620 			     __field(unsigned, ctxt)
621 			     __field(u32, credits)
622 			     __field(u64, hw_free)
623 			     __field(u64, piobase)
624 			     __field(u16, rcvhdrq_cnt)
625 			     __field(u64, rcvhdrq_phys)
626 			     __field(u32, eager_cnt)
627 			     __field(u64, rcvegr_phys)
628 			     ),
629 	    TP_fast_assign(DD_DEV_ASSIGN(dd);
630 			   __entry->ctxt = uctxt->ctxt;
631 			   __entry->credits = uctxt->sc->credits;
632 			   __entry->hw_free = (u64)uctxt->sc->hw_free;
633 			   __entry->piobase = (u64)uctxt->sc->base_addr;
634 			   __entry->rcvhdrq_cnt = uctxt->rcvhdrq_cnt;
635 			   __entry->rcvhdrq_phys = uctxt->rcvhdrq_phys;
636 			   __entry->eager_cnt = uctxt->egrbufs.alloced;
637 			   __entry->rcvegr_phys =
638 			   uctxt->egrbufs.rcvtids[0].phys;
639 			   ),
640 	    TP_printk("[%s] ctxt %u " UCTXT_FMT,
641 		      __get_str(dev),
642 		      __entry->ctxt,
643 		      __entry->credits,
644 		      __entry->hw_free,
645 		      __entry->piobase,
646 		      __entry->rcvhdrq_cnt,
647 		      __entry->rcvhdrq_phys,
648 		      __entry->eager_cnt,
649 		      __entry->rcvegr_phys
650 		      )
651 );
652 
653 #define CINFO_FMT \
654 	"egrtids:%u, egr_size:%u, hdrq_cnt:%u, hdrq_size:%u, sdma_ring_size:%u"
655 TRACE_EVENT(hfi1_ctxt_info,
656 	    TP_PROTO(struct hfi1_devdata *dd, unsigned ctxt, unsigned subctxt,
657 		     struct hfi1_ctxt_info cinfo),
658 	    TP_ARGS(dd, ctxt, subctxt, cinfo),
659 	    TP_STRUCT__entry(DD_DEV_ENTRY(dd)
660 			     __field(unsigned, ctxt)
661 			     __field(unsigned, subctxt)
662 			     __field(u16, egrtids)
663 			     __field(u16, rcvhdrq_cnt)
664 			     __field(u16, rcvhdrq_size)
665 			     __field(u16, sdma_ring_size)
666 			     __field(u32, rcvegr_size)
667 			     ),
668 	    TP_fast_assign(DD_DEV_ASSIGN(dd);
669 			    __entry->ctxt = ctxt;
670 			    __entry->subctxt = subctxt;
671 			    __entry->egrtids = cinfo.egrtids;
672 			    __entry->rcvhdrq_cnt = cinfo.rcvhdrq_cnt;
673 			    __entry->rcvhdrq_size = cinfo.rcvhdrq_entsize;
674 			    __entry->sdma_ring_size = cinfo.sdma_ring_size;
675 			    __entry->rcvegr_size = cinfo.rcvegr_size;
676 			    ),
677 	    TP_printk("[%s] ctxt %u:%u " CINFO_FMT,
678 		      __get_str(dev),
679 		      __entry->ctxt,
680 		      __entry->subctxt,
681 		      __entry->egrtids,
682 		      __entry->rcvegr_size,
683 		      __entry->rcvhdrq_cnt,
684 		      __entry->rcvhdrq_size,
685 		      __entry->sdma_ring_size
686 		      )
687 );
688 
689 #undef TRACE_SYSTEM
690 #define TRACE_SYSTEM hfi1_sma
691 
692 #define BCT_FORMAT \
693 	"shared_limit %x vls 0-7 [%x,%x][%x,%x][%x,%x][%x,%x][%x,%x][%x,%x][%x,%x][%x,%x] 15 [%x,%x]"
694 
695 #define BCT(field) \
696 	be16_to_cpu( \
697 		((struct buffer_control *)__get_dynamic_array(bct))->field \
698 	)
699 
700 DECLARE_EVENT_CLASS(hfi1_bct_template,
701 		    TP_PROTO(struct hfi1_devdata *dd,
702 			     struct buffer_control *bc),
703 		    TP_ARGS(dd, bc),
704 		    TP_STRUCT__entry(DD_DEV_ENTRY(dd)
705 				     __dynamic_array(u8, bct, sizeof(*bc))
706 				     ),
707 		    TP_fast_assign(DD_DEV_ASSIGN(dd);
708 				   memcpy(__get_dynamic_array(bct), bc,
709 					  sizeof(*bc));
710 				   ),
711 		    TP_printk(BCT_FORMAT,
712 			      BCT(overall_shared_limit),
713 
714 			      BCT(vl[0].dedicated),
715 			      BCT(vl[0].shared),
716 
717 			      BCT(vl[1].dedicated),
718 			      BCT(vl[1].shared),
719 
720 			      BCT(vl[2].dedicated),
721 			      BCT(vl[2].shared),
722 
723 			      BCT(vl[3].dedicated),
724 			      BCT(vl[3].shared),
725 
726 			      BCT(vl[4].dedicated),
727 			      BCT(vl[4].shared),
728 
729 			      BCT(vl[5].dedicated),
730 			      BCT(vl[5].shared),
731 
732 			      BCT(vl[6].dedicated),
733 			      BCT(vl[6].shared),
734 
735 			      BCT(vl[7].dedicated),
736 			      BCT(vl[7].shared),
737 
738 			      BCT(vl[15].dedicated),
739 			      BCT(vl[15].shared)
740 			      )
741 );
742 
743 DEFINE_EVENT(hfi1_bct_template, bct_set,
744 	     TP_PROTO(struct hfi1_devdata *dd, struct buffer_control *bc),
745 	     TP_ARGS(dd, bc));
746 
747 DEFINE_EVENT(hfi1_bct_template, bct_get,
748 	     TP_PROTO(struct hfi1_devdata *dd, struct buffer_control *bc),
749 	     TP_ARGS(dd, bc));
750 
751 #undef TRACE_SYSTEM
752 #define TRACE_SYSTEM hfi1_sdma
753 
754 TRACE_EVENT(hfi1_sdma_descriptor,
755 	    TP_PROTO(struct sdma_engine *sde,
756 		     u64 desc0,
757 		     u64 desc1,
758 		     u16 e,
759 		     void *descp),
760 	TP_ARGS(sde, desc0, desc1, e, descp),
761 	TP_STRUCT__entry(DD_DEV_ENTRY(sde->dd)
762 			 __field(void *, descp)
763 			 __field(u64, desc0)
764 			 __field(u64, desc1)
765 			 __field(u16, e)
766 			 __field(u8, idx)
767 			 ),
768 	TP_fast_assign(DD_DEV_ASSIGN(sde->dd);
769 		       __entry->desc0 = desc0;
770 		       __entry->desc1 = desc1;
771 		       __entry->idx = sde->this_idx;
772 		       __entry->descp = descp;
773 		       __entry->e = e;
774 		       ),
775 	TP_printk(
776 		  "[%s] SDE(%u) flags:%s addr:0x%016llx gen:%u len:%u d0:%016llx d1:%016llx to %p,%u",
777 		  __get_str(dev),
778 		  __entry->idx,
779 		  __parse_sdma_flags(__entry->desc0, __entry->desc1),
780 		  (__entry->desc0 >> SDMA_DESC0_PHY_ADDR_SHIFT) &
781 		  SDMA_DESC0_PHY_ADDR_MASK,
782 		  (u8)((__entry->desc1 >> SDMA_DESC1_GENERATION_SHIFT) &
783 		       SDMA_DESC1_GENERATION_MASK),
784 		  (u16)((__entry->desc0 >> SDMA_DESC0_BYTE_COUNT_SHIFT) &
785 			SDMA_DESC0_BYTE_COUNT_MASK),
786 		  __entry->desc0,
787 		  __entry->desc1,
788 		  __entry->descp,
789 		  __entry->e
790 		  )
791 );
792 
793 TRACE_EVENT(hfi1_sdma_engine_select,
794 	    TP_PROTO(struct hfi1_devdata *dd, u32 sel, u8 vl, u8 idx),
795 	    TP_ARGS(dd, sel, vl, idx),
796 	    TP_STRUCT__entry(DD_DEV_ENTRY(dd)
797 			     __field(u32, sel)
798 			     __field(u8, vl)
799 			     __field(u8, idx)
800 			     ),
801 	    TP_fast_assign(DD_DEV_ASSIGN(dd);
802 			   __entry->sel = sel;
803 			   __entry->vl = vl;
804 			   __entry->idx = idx;
805 			   ),
806 	    TP_printk("[%s] selecting SDE %u sel 0x%x vl %u",
807 		      __get_str(dev),
808 		      __entry->idx,
809 		      __entry->sel,
810 		      __entry->vl
811 		      )
812 );
813 
814 DECLARE_EVENT_CLASS(hfi1_sdma_engine_class,
815 		    TP_PROTO(struct sdma_engine *sde, u64 status),
816 		    TP_ARGS(sde, status),
817 		    TP_STRUCT__entry(DD_DEV_ENTRY(sde->dd)
818 				     __field(u64, status)
819 				     __field(u8, idx)
820 				     ),
821 		    TP_fast_assign(DD_DEV_ASSIGN(sde->dd);
822 				   __entry->status = status;
823 				   __entry->idx = sde->this_idx;
824 				   ),
825 		    TP_printk("[%s] SDE(%u) status %llx",
826 			      __get_str(dev),
827 			      __entry->idx,
828 			      (unsigned long long)__entry->status
829 			      )
830 );
831 
832 DEFINE_EVENT(hfi1_sdma_engine_class, hfi1_sdma_engine_interrupt,
833 	     TP_PROTO(struct sdma_engine *sde, u64 status),
834 	     TP_ARGS(sde, status)
835 );
836 
837 DEFINE_EVENT(hfi1_sdma_engine_class, hfi1_sdma_engine_progress,
838 	     TP_PROTO(struct sdma_engine *sde, u64 status),
839 	     TP_ARGS(sde, status)
840 );
841 
842 DECLARE_EVENT_CLASS(hfi1_sdma_ahg_ad,
843 		    TP_PROTO(struct sdma_engine *sde, int aidx),
844 		    TP_ARGS(sde, aidx),
845 		    TP_STRUCT__entry(DD_DEV_ENTRY(sde->dd)
846 				     __field(int, aidx)
847 				     __field(u8, idx)
848 				     ),
849 		    TP_fast_assign(DD_DEV_ASSIGN(sde->dd);
850 				   __entry->idx = sde->this_idx;
851 				   __entry->aidx = aidx;
852 				   ),
853 		    TP_printk("[%s] SDE(%u) aidx %d",
854 			      __get_str(dev),
855 			      __entry->idx,
856 			      __entry->aidx
857 			      )
858 );
859 
860 DEFINE_EVENT(hfi1_sdma_ahg_ad, hfi1_ahg_allocate,
861 	     TP_PROTO(struct sdma_engine *sde, int aidx),
862 	     TP_ARGS(sde, aidx));
863 
864 DEFINE_EVENT(hfi1_sdma_ahg_ad, hfi1_ahg_deallocate,
865 	     TP_PROTO(struct sdma_engine *sde, int aidx),
866 	     TP_ARGS(sde, aidx));
867 
868 #ifdef CONFIG_HFI1_DEBUG_SDMA_ORDER
869 TRACE_EVENT(hfi1_sdma_progress,
870 	    TP_PROTO(struct sdma_engine *sde,
871 		     u16 hwhead,
872 		     u16 swhead,
873 		     struct sdma_txreq *txp
874 		     ),
875 	    TP_ARGS(sde, hwhead, swhead, txp),
876 	    TP_STRUCT__entry(DD_DEV_ENTRY(sde->dd)
877 			     __field(u64, sn)
878 			     __field(u16, hwhead)
879 			     __field(u16, swhead)
880 			     __field(u16, txnext)
881 			     __field(u16, tx_tail)
882 			     __field(u16, tx_head)
883 			     __field(u8, idx)
884 			     ),
885 	    TP_fast_assign(DD_DEV_ASSIGN(sde->dd);
886 			   __entry->hwhead = hwhead;
887 			   __entry->swhead = swhead;
888 			   __entry->tx_tail = sde->tx_tail;
889 			   __entry->tx_head = sde->tx_head;
890 			   __entry->txnext = txp ? txp->next_descq_idx : ~0;
891 			   __entry->idx = sde->this_idx;
892 			   __entry->sn = txp ? txp->sn : ~0;
893 			   ),
894 	    TP_printk(
895 		      "[%s] SDE(%u) sn %llu hwhead %u swhead %u next_descq_idx %u tx_head %u tx_tail %u",
896 		      __get_str(dev),
897 		      __entry->idx,
898 		      __entry->sn,
899 		      __entry->hwhead,
900 		      __entry->swhead,
901 		      __entry->txnext,
902 		      __entry->tx_head,
903 		      __entry->tx_tail
904 		      )
905 );
906 #else
907 TRACE_EVENT(hfi1_sdma_progress,
908 	    TP_PROTO(struct sdma_engine *sde,
909 		     u16 hwhead, u16 swhead,
910 		     struct sdma_txreq *txp
911 	    ),
912 	TP_ARGS(sde, hwhead, swhead, txp),
913 	TP_STRUCT__entry(DD_DEV_ENTRY(sde->dd)
914 			 __field(u16, hwhead)
915 			 __field(u16, swhead)
916 			 __field(u16, txnext)
917 			 __field(u16, tx_tail)
918 			 __field(u16, tx_head)
919 			 __field(u8, idx)
920 			 ),
921 	TP_fast_assign(DD_DEV_ASSIGN(sde->dd);
922 		       __entry->hwhead = hwhead;
923 		       __entry->swhead = swhead;
924 		       __entry->tx_tail = sde->tx_tail;
925 		       __entry->tx_head = sde->tx_head;
926 		       __entry->txnext = txp ? txp->next_descq_idx : ~0;
927 		       __entry->idx = sde->this_idx;
928 		       ),
929 	TP_printk(
930 		  "[%s] SDE(%u) hwhead %u swhead %u next_descq_idx %u tx_head %u tx_tail %u",
931 		  __get_str(dev),
932 		  __entry->idx,
933 		  __entry->hwhead,
934 		  __entry->swhead,
935 		  __entry->txnext,
936 		  __entry->tx_head,
937 		  __entry->tx_tail
938 		  )
939 );
940 #endif
941 
942 DECLARE_EVENT_CLASS(hfi1_sdma_sn,
943 		    TP_PROTO(struct sdma_engine *sde, u64 sn),
944 		    TP_ARGS(sde, sn),
945 		    TP_STRUCT__entry(DD_DEV_ENTRY(sde->dd)
946 				     __field(u64, sn)
947 				     __field(u8, idx)
948 				     ),
949 		    TP_fast_assign(DD_DEV_ASSIGN(sde->dd);
950 				   __entry->sn = sn;
951 				   __entry->idx = sde->this_idx;
952 				   ),
953 		    TP_printk("[%s] SDE(%u) sn %llu",
954 			      __get_str(dev),
955 			      __entry->idx,
956 			      __entry->sn
957 			      )
958 );
959 
960 DEFINE_EVENT(hfi1_sdma_sn, hfi1_sdma_out_sn,
961 	     TP_PROTO(
962 		struct sdma_engine *sde,
963 		u64 sn
964 	     ),
965 	     TP_ARGS(sde, sn)
966 );
967 
968 DEFINE_EVENT(hfi1_sdma_sn, hfi1_sdma_in_sn,
969 	     TP_PROTO(struct sdma_engine *sde, u64 sn),
970 	     TP_ARGS(sde, sn)
971 );
972 
973 #define USDMA_HDR_FORMAT \
974 	"[%s:%u:%u:%u] PBC=(0x%x 0x%x) LRH=(0x%x 0x%x) BTH=(0x%x 0x%x 0x%x) KDETH=(0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x) TIDVal=0x%x"
975 
976 TRACE_EVENT(hfi1_sdma_user_header,
977 	    TP_PROTO(struct hfi1_devdata *dd, u16 ctxt, u8 subctxt, u16 req,
978 		     struct hfi1_pkt_header *hdr, u32 tidval),
979 	    TP_ARGS(dd, ctxt, subctxt, req, hdr, tidval),
980 	    TP_STRUCT__entry(
981 		    DD_DEV_ENTRY(dd)
982 		    __field(u16, ctxt)
983 		    __field(u8, subctxt)
984 		    __field(u16, req)
985 		    __field(__le32, pbc0)
986 		    __field(__le32, pbc1)
987 		    __field(__be32, lrh0)
988 		    __field(__be32, lrh1)
989 		    __field(__be32, bth0)
990 		    __field(__be32, bth1)
991 		    __field(__be32, bth2)
992 		    __field(__le32, kdeth0)
993 		    __field(__le32, kdeth1)
994 		    __field(__le32, kdeth2)
995 		    __field(__le32, kdeth3)
996 		    __field(__le32, kdeth4)
997 		    __field(__le32, kdeth5)
998 		    __field(__le32, kdeth6)
999 		    __field(__le32, kdeth7)
1000 		    __field(__le32, kdeth8)
1001 		    __field(u32, tidval)
1002 		    ),
1003 	    TP_fast_assign(
1004 		    __le32 *pbc = (__le32 *)hdr->pbc;
1005 		    __be32 *lrh = (__be32 *)hdr->lrh;
1006 		    __be32 *bth = (__be32 *)hdr->bth;
1007 		    __le32 *kdeth = (__le32 *)&hdr->kdeth;
1008 
1009 		    DD_DEV_ASSIGN(dd);
1010 		    __entry->ctxt = ctxt;
1011 		    __entry->subctxt = subctxt;
1012 		    __entry->req = req;
1013 		    __entry->pbc0 = pbc[0];
1014 		    __entry->pbc1 = pbc[1];
1015 		    __entry->lrh0 = be32_to_cpu(lrh[0]);
1016 		    __entry->lrh1 = be32_to_cpu(lrh[1]);
1017 		    __entry->bth0 = be32_to_cpu(bth[0]);
1018 		    __entry->bth1 = be32_to_cpu(bth[1]);
1019 		    __entry->bth2 = be32_to_cpu(bth[2]);
1020 		    __entry->kdeth0 = kdeth[0];
1021 		    __entry->kdeth1 = kdeth[1];
1022 		    __entry->kdeth2 = kdeth[2];
1023 		    __entry->kdeth3 = kdeth[3];
1024 		    __entry->kdeth4 = kdeth[4];
1025 		    __entry->kdeth5 = kdeth[5];
1026 		    __entry->kdeth6 = kdeth[6];
1027 		    __entry->kdeth7 = kdeth[7];
1028 		    __entry->kdeth8 = kdeth[8];
1029 		    __entry->tidval = tidval;
1030 		    ),
1031 	    TP_printk(USDMA_HDR_FORMAT,
1032 		      __get_str(dev),
1033 		      __entry->ctxt,
1034 		      __entry->subctxt,
1035 		      __entry->req,
1036 		      __entry->pbc1,
1037 		      __entry->pbc0,
1038 		      __entry->lrh0,
1039 		      __entry->lrh1,
1040 		      __entry->bth0,
1041 		      __entry->bth1,
1042 		      __entry->bth2,
1043 		      __entry->kdeth0,
1044 		      __entry->kdeth1,
1045 		      __entry->kdeth2,
1046 		      __entry->kdeth3,
1047 		      __entry->kdeth4,
1048 		      __entry->kdeth5,
1049 		      __entry->kdeth6,
1050 		      __entry->kdeth7,
1051 		      __entry->kdeth8,
1052 		      __entry->tidval
1053 		    )
1054 	);
1055 
1056 #define SDMA_UREQ_FMT \
1057 	"[%s:%u:%u] ver/op=0x%x, iovcnt=%u, npkts=%u, frag=%u, idx=%u"
1058 TRACE_EVENT(hfi1_sdma_user_reqinfo,
1059 	    TP_PROTO(struct hfi1_devdata *dd, u16 ctxt, u8 subctxt, u16 *i),
1060 	    TP_ARGS(dd, ctxt, subctxt, i),
1061 	    TP_STRUCT__entry(
1062 		    DD_DEV_ENTRY(dd);
1063 		    __field(u16, ctxt)
1064 		    __field(u8, subctxt)
1065 		    __field(u8, ver_opcode)
1066 		    __field(u8, iovcnt)
1067 		    __field(u16, npkts)
1068 		    __field(u16, fragsize)
1069 		    __field(u16, comp_idx)
1070 		    ),
1071 	    TP_fast_assign(
1072 		    DD_DEV_ASSIGN(dd);
1073 		    __entry->ctxt = ctxt;
1074 		    __entry->subctxt = subctxt;
1075 		    __entry->ver_opcode = i[0] & 0xff;
1076 		    __entry->iovcnt = (i[0] >> 8) & 0xff;
1077 		    __entry->npkts = i[1];
1078 		    __entry->fragsize = i[2];
1079 		    __entry->comp_idx = i[3];
1080 		    ),
1081 	    TP_printk(SDMA_UREQ_FMT,
1082 		      __get_str(dev),
1083 		      __entry->ctxt,
1084 		      __entry->subctxt,
1085 		      __entry->ver_opcode,
1086 		      __entry->iovcnt,
1087 		      __entry->npkts,
1088 		      __entry->fragsize,
1089 		      __entry->comp_idx
1090 		    )
1091 	);
1092 
1093 #define usdma_complete_name(st) { st, #st }
1094 #define show_usdma_complete_state(st)			\
1095 	__print_symbolic(st,				\
1096 			 usdma_complete_name(FREE),	\
1097 			 usdma_complete_name(QUEUED),	\
1098 			 usdma_complete_name(COMPLETE), \
1099 			 usdma_complete_name(ERROR))
1100 
1101 TRACE_EVENT(hfi1_sdma_user_completion,
1102 	    TP_PROTO(struct hfi1_devdata *dd, u16 ctxt, u8 subctxt, u16 idx,
1103 		     u8 state, int code),
1104 	    TP_ARGS(dd, ctxt, subctxt, idx, state, code),
1105 	    TP_STRUCT__entry(
1106 		    DD_DEV_ENTRY(dd)
1107 		    __field(u16, ctxt)
1108 		    __field(u8, subctxt)
1109 		    __field(u16, idx)
1110 		    __field(u8, state)
1111 		    __field(int, code)
1112 		    ),
1113 	    TP_fast_assign(
1114 		    DD_DEV_ASSIGN(dd);
1115 		    __entry->ctxt = ctxt;
1116 		    __entry->subctxt = subctxt;
1117 		    __entry->idx = idx;
1118 		    __entry->state = state;
1119 		    __entry->code = code;
1120 		    ),
1121 	    TP_printk("[%s:%u:%u:%u] SDMA completion state %s (%d)",
1122 		      __get_str(dev), __entry->ctxt, __entry->subctxt,
1123 		      __entry->idx, show_usdma_complete_state(__entry->state),
1124 		      __entry->code)
1125 	);
1126 
1127 const char *print_u32_array(struct trace_seq *, u32 *, int);
1128 #define __print_u32_hex(arr, len) print_u32_array(p, arr, len)
1129 
1130 TRACE_EVENT(hfi1_sdma_user_header_ahg,
1131 	    TP_PROTO(struct hfi1_devdata *dd, u16 ctxt, u8 subctxt, u16 req,
1132 		     u8 sde, u8 ahgidx, u32 *ahg, int len, u32 tidval),
1133 	    TP_ARGS(dd, ctxt, subctxt, req, sde, ahgidx, ahg, len, tidval),
1134 	    TP_STRUCT__entry(
1135 		    DD_DEV_ENTRY(dd)
1136 		    __field(u16, ctxt)
1137 		    __field(u8, subctxt)
1138 		    __field(u16, req)
1139 		    __field(u8, sde)
1140 		    __field(u8, idx)
1141 		    __field(int, len)
1142 		    __field(u32, tidval)
1143 		    __array(u32, ahg, 10)
1144 		    ),
1145 	    TP_fast_assign(
1146 		    DD_DEV_ASSIGN(dd);
1147 		    __entry->ctxt = ctxt;
1148 		    __entry->subctxt = subctxt;
1149 		    __entry->req = req;
1150 		    __entry->sde = sde;
1151 		    __entry->idx = ahgidx;
1152 		    __entry->len = len;
1153 		    __entry->tidval = tidval;
1154 		    memcpy(__entry->ahg, ahg, len * sizeof(u32));
1155 		    ),
1156 	    TP_printk("[%s:%u:%u:%u] (SDE%u/AHG%u) ahg[0-%d]=(%s) TIDVal=0x%x",
1157 		      __get_str(dev),
1158 		      __entry->ctxt,
1159 		      __entry->subctxt,
1160 		      __entry->req,
1161 		      __entry->sde,
1162 		      __entry->idx,
1163 		      __entry->len - 1,
1164 		      __print_u32_hex(__entry->ahg, __entry->len),
1165 		      __entry->tidval
1166 		    )
1167 	);
1168 
1169 TRACE_EVENT(hfi1_sdma_state,
1170 	    TP_PROTO(struct sdma_engine *sde,
1171 		     const char *cstate,
1172 		     const char *nstate
1173 		     ),
1174 	    TP_ARGS(sde, cstate, nstate),
1175 	    TP_STRUCT__entry(DD_DEV_ENTRY(sde->dd)
1176 			     __string(curstate, cstate)
1177 			     __string(newstate, nstate)
1178 			     ),
1179 	TP_fast_assign(DD_DEV_ASSIGN(sde->dd);
1180 		       __assign_str(curstate, cstate);
1181 		       __assign_str(newstate, nstate);
1182 		       ),
1183 	TP_printk("[%s] current state %s new state %s",
1184 		  __get_str(dev),
1185 		  __get_str(curstate),
1186 		  __get_str(newstate)
1187 		  )
1188 );
1189 
1190 #undef TRACE_SYSTEM
1191 #define TRACE_SYSTEM hfi1_rc
1192 
1193 DECLARE_EVENT_CLASS(hfi1_rc_template,
1194 		    TP_PROTO(struct rvt_qp *qp, u32 psn),
1195 		    TP_ARGS(qp, psn),
1196 		    TP_STRUCT__entry(
1197 			DD_DEV_ENTRY(dd_from_ibdev(qp->ibqp.device))
1198 			__field(u32, qpn)
1199 			__field(u32, s_flags)
1200 			__field(u32, psn)
1201 			__field(u32, s_psn)
1202 			__field(u32, s_next_psn)
1203 			__field(u32, s_sending_psn)
1204 			__field(u32, s_sending_hpsn)
1205 			__field(u32, r_psn)
1206 			),
1207 		    TP_fast_assign(
1208 			DD_DEV_ASSIGN(dd_from_ibdev(qp->ibqp.device))
1209 			__entry->qpn = qp->ibqp.qp_num;
1210 			__entry->s_flags = qp->s_flags;
1211 			__entry->psn = psn;
1212 			__entry->s_psn = qp->s_psn;
1213 			__entry->s_next_psn = qp->s_next_psn;
1214 			__entry->s_sending_psn = qp->s_sending_psn;
1215 			__entry->s_sending_hpsn = qp->s_sending_hpsn;
1216 			__entry->r_psn = qp->r_psn;
1217 			),
1218 		    TP_printk(
1219 			"[%s] qpn 0x%x s_flags 0x%x psn 0x%x s_psn 0x%x s_next_psn 0x%x s_sending_psn 0x%x sending_hpsn 0x%x r_psn 0x%x",
1220 			__get_str(dev),
1221 			__entry->qpn,
1222 			__entry->s_flags,
1223 			__entry->psn,
1224 			__entry->s_psn,
1225 			__entry->s_next_psn,
1226 			__entry->s_sending_psn,
1227 			__entry->s_sending_hpsn,
1228 			__entry->r_psn
1229 			)
1230 );
1231 
1232 DEFINE_EVENT(hfi1_rc_template, hfi1_rc_sendcomplete,
1233 	     TP_PROTO(struct rvt_qp *qp, u32 psn),
1234 	     TP_ARGS(qp, psn)
1235 );
1236 
1237 DEFINE_EVENT(hfi1_rc_template, hfi1_rc_ack,
1238 	     TP_PROTO(struct rvt_qp *qp, u32 psn),
1239 	     TP_ARGS(qp, psn)
1240 );
1241 
1242 DEFINE_EVENT(hfi1_rc_template, hfi1_rc_timeout,
1243 	     TP_PROTO(struct rvt_qp *qp, u32 psn),
1244 	     TP_ARGS(qp, psn)
1245 );
1246 
1247 DEFINE_EVENT(hfi1_rc_template, hfi1_rc_rcv_error,
1248 	     TP_PROTO(struct rvt_qp *qp, u32 psn),
1249 	     TP_ARGS(qp, psn)
1250 );
1251 
1252 #undef TRACE_SYSTEM
1253 #define TRACE_SYSTEM hfi1_misc
1254 
1255 TRACE_EVENT(hfi1_interrupt,
1256 	    TP_PROTO(struct hfi1_devdata *dd, const struct is_table *is_entry,
1257 		     int src),
1258 	    TP_ARGS(dd, is_entry, src),
1259 	    TP_STRUCT__entry(DD_DEV_ENTRY(dd)
1260 			     __array(char, buf, 64)
1261 			     __field(int, src)
1262 			     ),
1263 	    TP_fast_assign(DD_DEV_ASSIGN(dd)
1264 			   is_entry->is_name(__entry->buf, 64,
1265 					     src - is_entry->start);
1266 			   __entry->src = src;
1267 			   ),
1268 	    TP_printk("[%s] source: %s [%d]", __get_str(dev), __entry->buf,
1269 		      __entry->src)
1270 );
1271 
1272 /*
1273  * Note:
1274  * This produces a REALLY ugly trace in the console output when the string is
1275  * too long.
1276  */
1277 
1278 #undef TRACE_SYSTEM
1279 #define TRACE_SYSTEM hfi1_trace
1280 
1281 #define MAX_MSG_LEN 512
1282 
1283 DECLARE_EVENT_CLASS(hfi1_trace_template,
1284 		    TP_PROTO(const char *function, struct va_format *vaf),
1285 		    TP_ARGS(function, vaf),
1286 		    TP_STRUCT__entry(__string(function, function)
1287 				     __dynamic_array(char, msg, MAX_MSG_LEN)
1288 				     ),
1289 		    TP_fast_assign(__assign_str(function, function);
1290 				   WARN_ON_ONCE(vsnprintf
1291 						(__get_dynamic_array(msg),
1292 						 MAX_MSG_LEN, vaf->fmt,
1293 						 *vaf->va) >=
1294 						MAX_MSG_LEN);
1295 				   ),
1296 		    TP_printk("(%s) %s",
1297 			      __get_str(function),
1298 			      __get_str(msg))
1299 );
1300 
1301 /*
1302  * It may be nice to macroize the __hfi1_trace but the va_* stuff requires an
1303  * actual function to work and can not be in a macro.
1304  */
1305 #define __hfi1_trace_def(lvl) \
1306 void __hfi1_trace_##lvl(const char *funct, char *fmt, ...);		\
1307 									\
1308 DEFINE_EVENT(hfi1_trace_template, hfi1_ ##lvl,				\
1309 	TP_PROTO(const char *function, struct va_format *vaf),		\
1310 	TP_ARGS(function, vaf))
1311 
1312 #define __hfi1_trace_fn(lvl) \
1313 void __hfi1_trace_##lvl(const char *func, char *fmt, ...)		\
1314 {									\
1315 	struct va_format vaf = {					\
1316 		.fmt = fmt,						\
1317 	};								\
1318 	va_list args;							\
1319 									\
1320 	va_start(args, fmt);						\
1321 	vaf.va = &args;							\
1322 	trace_hfi1_ ##lvl(func, &vaf);					\
1323 	va_end(args);							\
1324 	return;								\
1325 }
1326 
1327 /*
1328  * To create a new trace level simply define it below and as a __hfi1_trace_fn
1329  * in trace.c. This will create all the hooks for calling
1330  * hfi1_cdbg(LVL, fmt, ...); as well as take care of all
1331  * the debugfs stuff.
1332  */
1333 __hfi1_trace_def(PKT);
1334 __hfi1_trace_def(PROC);
1335 __hfi1_trace_def(SDMA);
1336 __hfi1_trace_def(LINKVERB);
1337 __hfi1_trace_def(DEBUG);
1338 __hfi1_trace_def(SNOOP);
1339 __hfi1_trace_def(CNTR);
1340 __hfi1_trace_def(PIO);
1341 __hfi1_trace_def(DC8051);
1342 __hfi1_trace_def(FIRMWARE);
1343 __hfi1_trace_def(RCVCTRL);
1344 __hfi1_trace_def(TID);
1345 __hfi1_trace_def(MMU);
1346 __hfi1_trace_def(IOCTL);
1347 
1348 #define hfi1_cdbg(which, fmt, ...) \
1349 	__hfi1_trace_##which(__func__, fmt, ##__VA_ARGS__)
1350 
1351 #define hfi1_dbg(fmt, ...) \
1352 	hfi1_cdbg(DEBUG, fmt, ##__VA_ARGS__)
1353 
1354 /*
1355  * Define HFI1_EARLY_DBG at compile time or here to enable early trace
1356  * messages. Do not check in an enablement for this.
1357  */
1358 
1359 #ifdef HFI1_EARLY_DBG
1360 #define hfi1_dbg_early(fmt, ...) \
1361 	trace_printk(fmt, ##__VA_ARGS__)
1362 #else
1363 #define hfi1_dbg_early(fmt, ...)
1364 #endif
1365 
1366 #endif /* __HFI1_TRACE_H */
1367 
1368 #undef TRACE_INCLUDE_PATH
1369 #undef TRACE_INCLUDE_FILE
1370 #define TRACE_INCLUDE_PATH .
1371 #define TRACE_INCLUDE_FILE trace
1372 #include <trace/define_trace.h>
1373