Merge tag 'powerpc-4.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[cascardo/linux.git] / drivers / infiniband / hw / hfi1 / trace_rx.h
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 #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 #undef TRACE_SYSTEM
56 #define TRACE_SYSTEM hfi1_rx
57
58 TRACE_EVENT(hfi1_rcvhdr,
59             TP_PROTO(struct hfi1_devdata *dd,
60                      u32 ctxt,
61                      u64 eflags,
62                      u32 etype,
63                      u32 hlen,
64                      u32 tlen,
65                      u32 updegr,
66                      u32 etail
67                     ),
68             TP_ARGS(dd, ctxt, eflags, etype, hlen, tlen, updegr, etail),
69             TP_STRUCT__entry(DD_DEV_ENTRY(dd)
70                              __field(u64, eflags)
71                              __field(u32, ctxt)
72                              __field(u32, etype)
73                              __field(u32, hlen)
74                              __field(u32, tlen)
75                              __field(u32, updegr)
76                              __field(u32, etail)
77                              ),
78              TP_fast_assign(DD_DEV_ASSIGN(dd);
79                             __entry->eflags = eflags;
80                             __entry->ctxt = ctxt;
81                             __entry->etype = etype;
82                             __entry->hlen = hlen;
83                             __entry->tlen = tlen;
84                             __entry->updegr = updegr;
85                             __entry->etail = etail;
86                             ),
87              TP_printk(
88                 "[%s] ctxt %d eflags 0x%llx etype %d,%s hlen %d tlen %d updegr %d etail %d",
89                 __get_str(dev),
90                 __entry->ctxt,
91                 __entry->eflags,
92                 __entry->etype, show_packettype(__entry->etype),
93                 __entry->hlen,
94                 __entry->tlen,
95                 __entry->updegr,
96                 __entry->etail
97                 )
98 );
99
100 TRACE_EVENT(hfi1_receive_interrupt,
101             TP_PROTO(struct hfi1_devdata *dd, u32 ctxt),
102             TP_ARGS(dd, ctxt),
103             TP_STRUCT__entry(DD_DEV_ENTRY(dd)
104                              __field(u32, ctxt)
105                              __field(u8, slow_path)
106                              __field(u8, dma_rtail)
107                              ),
108             TP_fast_assign(DD_DEV_ASSIGN(dd);
109                         __entry->ctxt = ctxt;
110                         if (dd->rcd[ctxt]->do_interrupt ==
111                             &handle_receive_interrupt) {
112                                 __entry->slow_path = 1;
113                                 __entry->dma_rtail = 0xFF;
114                         } else if (dd->rcd[ctxt]->do_interrupt ==
115                                         &handle_receive_interrupt_dma_rtail){
116                                 __entry->dma_rtail = 1;
117                                 __entry->slow_path = 0;
118                         } else if (dd->rcd[ctxt]->do_interrupt ==
119                                         &handle_receive_interrupt_nodma_rtail) {
120                                 __entry->dma_rtail = 0;
121                                 __entry->slow_path = 0;
122                         }
123                         ),
124             TP_printk("[%s] ctxt %d SlowPath: %d DmaRtail: %d",
125                       __get_str(dev),
126                       __entry->ctxt,
127                       __entry->slow_path,
128                       __entry->dma_rtail
129                       )
130 );
131
132 TRACE_EVENT(hfi1_exp_tid_reg,
133             TP_PROTO(unsigned int ctxt, u16 subctxt, u32 rarr,
134                      u32 npages, unsigned long va, unsigned long pa,
135                      dma_addr_t dma),
136             TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma),
137             TP_STRUCT__entry(
138                              __field(unsigned int, ctxt)
139                              __field(u16, subctxt)
140                              __field(u32, rarr)
141                              __field(u32, npages)
142                              __field(unsigned long, va)
143                              __field(unsigned long, pa)
144                              __field(dma_addr_t, dma)
145                              ),
146             TP_fast_assign(
147                            __entry->ctxt = ctxt;
148                            __entry->subctxt = subctxt;
149                            __entry->rarr = rarr;
150                            __entry->npages = npages;
151                            __entry->va = va;
152                            __entry->pa = pa;
153                            __entry->dma = dma;
154                            ),
155             TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx, va:0x%lx dma:0x%llx",
156                       __entry->ctxt,
157                       __entry->subctxt,
158                       __entry->rarr,
159                       __entry->npages,
160                       __entry->pa,
161                       __entry->va,
162                       __entry->dma
163                       )
164         );
165
166 TRACE_EVENT(hfi1_exp_tid_unreg,
167             TP_PROTO(unsigned int ctxt, u16 subctxt, u32 rarr, u32 npages,
168                      unsigned long va, unsigned long pa, dma_addr_t dma),
169             TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma),
170             TP_STRUCT__entry(
171                              __field(unsigned int, ctxt)
172                              __field(u16, subctxt)
173                              __field(u32, rarr)
174                              __field(u32, npages)
175                              __field(unsigned long, va)
176                              __field(unsigned long, pa)
177                              __field(dma_addr_t, dma)
178                              ),
179             TP_fast_assign(
180                            __entry->ctxt = ctxt;
181                            __entry->subctxt = subctxt;
182                            __entry->rarr = rarr;
183                            __entry->npages = npages;
184                            __entry->va = va;
185                            __entry->pa = pa;
186                            __entry->dma = dma;
187                            ),
188             TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx, va:0x%lx dma:0x%llx",
189                       __entry->ctxt,
190                       __entry->subctxt,
191                       __entry->rarr,
192                       __entry->npages,
193                       __entry->pa,
194                       __entry->va,
195                       __entry->dma
196                       )
197         );
198
199 TRACE_EVENT(hfi1_exp_tid_inval,
200             TP_PROTO(unsigned int ctxt, u16 subctxt, unsigned long va, u32 rarr,
201                      u32 npages, dma_addr_t dma),
202             TP_ARGS(ctxt, subctxt, va, rarr, npages, dma),
203             TP_STRUCT__entry(
204                              __field(unsigned int, ctxt)
205                              __field(u16, subctxt)
206                              __field(unsigned long, va)
207                              __field(u32, rarr)
208                              __field(u32, npages)
209                              __field(dma_addr_t, dma)
210                              ),
211             TP_fast_assign(
212                            __entry->ctxt = ctxt;
213                            __entry->subctxt = subctxt;
214                            __entry->va = va;
215                            __entry->rarr = rarr;
216                            __entry->npages = npages;
217                            __entry->dma = dma;
218                           ),
219             TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx dma: 0x%llx",
220                       __entry->ctxt,
221                       __entry->subctxt,
222                       __entry->rarr,
223                       __entry->npages,
224                       __entry->va,
225                       __entry->dma
226                       )
227             );
228
229 TRACE_EVENT(hfi1_mmu_invalidate,
230             TP_PROTO(unsigned int ctxt, u16 subctxt, const char *type,
231                      unsigned long start, unsigned long end),
232             TP_ARGS(ctxt, subctxt, type, start, end),
233             TP_STRUCT__entry(
234                              __field(unsigned int, ctxt)
235                              __field(u16, subctxt)
236                              __string(type, type)
237                              __field(unsigned long, start)
238                              __field(unsigned long, end)
239                              ),
240             TP_fast_assign(
241                         __entry->ctxt = ctxt;
242                         __entry->subctxt = subctxt;
243                         __assign_str(type, type);
244                         __entry->start = start;
245                         __entry->end = end;
246             ),
247             TP_printk("[%3u:%02u] MMU Invalidate (%s) 0x%lx - 0x%lx",
248                       __entry->ctxt,
249                       __entry->subctxt,
250                       __get_str(type),
251                       __entry->start,
252                       __entry->end
253                       )
254             );
255
256 #define SNOOP_PRN \
257         "slid %.4x dlid %.4x qpn 0x%.6x opcode 0x%.2x,%s " \
258         "svc lvl %d pkey 0x%.4x [header = %d bytes] [data = %d bytes]"
259
260 TRACE_EVENT(snoop_capture,
261             TP_PROTO(struct hfi1_devdata *dd,
262                      int hdr_len,
263                      struct hfi1_ib_header *hdr,
264                      int data_len,
265                      void *data),
266             TP_ARGS(dd, hdr_len, hdr, data_len, data),
267             TP_STRUCT__entry(
268                              DD_DEV_ENTRY(dd)
269                              __field(u16, slid)
270                              __field(u16, dlid)
271                              __field(u32, qpn)
272                              __field(u8, opcode)
273                              __field(u8, sl)
274                              __field(u16, pkey)
275                              __field(u32, hdr_len)
276                              __field(u32, data_len)
277                              __field(u8, lnh)
278                              __dynamic_array(u8, raw_hdr, hdr_len)
279                              __dynamic_array(u8, raw_pkt, data_len)
280                              ),
281             TP_fast_assign(
282                 struct hfi1_other_headers *ohdr;
283
284                 __entry->lnh = (u8)(be16_to_cpu(hdr->lrh[0]) & 3);
285                 if (__entry->lnh == HFI1_LRH_BTH)
286                 ohdr = &hdr->u.oth;
287                 else
288                 ohdr = &hdr->u.l.oth;
289                 DD_DEV_ASSIGN(dd);
290                 __entry->slid = be16_to_cpu(hdr->lrh[3]);
291                 __entry->dlid = be16_to_cpu(hdr->lrh[1]);
292                 __entry->qpn = be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;
293                 __entry->opcode = (be32_to_cpu(ohdr->bth[0]) >> 24) & 0xff;
294                 __entry->sl = (u8)(be16_to_cpu(hdr->lrh[0]) >> 4) & 0xf;
295                 __entry->pkey = be32_to_cpu(ohdr->bth[0]) & 0xffff;
296                 __entry->hdr_len = hdr_len;
297                 __entry->data_len = data_len;
298                 memcpy(__get_dynamic_array(raw_hdr), hdr, hdr_len);
299                 memcpy(__get_dynamic_array(raw_pkt), data, data_len);
300                 ),
301             TP_printk(
302                 "[%s] " SNOOP_PRN,
303                 __get_str(dev),
304                 __entry->slid,
305                 __entry->dlid,
306                 __entry->qpn,
307                 __entry->opcode,
308                 show_ib_opcode(__entry->opcode),
309                 __entry->sl,
310                 __entry->pkey,
311                 __entry->hdr_len,
312                 __entry->data_len
313                 )
314 );
315
316 #endif /* __HFI1_TRACE_RX_H */
317
318 #undef TRACE_INCLUDE_PATH
319 #undef TRACE_INCLUDE_FILE
320 #define TRACE_INCLUDE_PATH .
321 #define TRACE_INCLUDE_FILE trace_rx
322 #include <trace/define_trace.h>