GNU Linux-libre 4.19.264-gnu1
[releases.git] / drivers / infiniband / hw / hfi1 / trace_rx.h
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_packet *packet),
67             TP_ARGS(packet),
68             TP_STRUCT__entry(DD_DEV_ENTRY(packet->rcd->dd)
69                              __field(u64, eflags)
70                              __field(u32, ctxt)
71                              __field(u32, etype)
72                              __field(u32, hlen)
73                              __field(u32, tlen)
74                              __field(u32, updegr)
75                              __field(u32, etail)
76                              ),
77              TP_fast_assign(DD_DEV_ASSIGN(packet->rcd->dd);
78                             __entry->eflags = rhf_err_flags(packet->rhf);
79                             __entry->ctxt = packet->rcd->ctxt;
80                             __entry->etype = packet->etype;
81                             __entry->hlen = packet->hlen;
82                             __entry->tlen = packet->tlen;
83                             __entry->updegr = packet->updegr;
84                             __entry->etail = rhf_egr_index(packet->rhf);
85                             ),
86              TP_printk(
87                 "[%s] ctxt %d eflags 0x%llx etype %d,%s hlen %d tlen %d updegr %d etail %d",
88                 __get_str(dev),
89                 __entry->ctxt,
90                 __entry->eflags,
91                 __entry->etype, show_packettype(__entry->etype),
92                 __entry->hlen,
93                 __entry->tlen,
94                 __entry->updegr,
95                 __entry->etail
96                 )
97 );
98
99 TRACE_EVENT(hfi1_receive_interrupt,
100             TP_PROTO(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd),
101             TP_ARGS(dd, rcd),
102             TP_STRUCT__entry(DD_DEV_ENTRY(dd)
103                              __field(u32, ctxt)
104                              __field(u8, slow_path)
105                              __field(u8, dma_rtail)
106                              ),
107             TP_fast_assign(DD_DEV_ASSIGN(dd);
108                         __entry->ctxt = rcd->ctxt;
109                         if (rcd->do_interrupt ==
110                             &handle_receive_interrupt) {
111                                 __entry->slow_path = 1;
112                                 __entry->dma_rtail = 0xFF;
113                         } else if (rcd->do_interrupt ==
114                                         &handle_receive_interrupt_dma_rtail){
115                                 __entry->dma_rtail = 1;
116                                 __entry->slow_path = 0;
117                         } else if (rcd->do_interrupt ==
118                                         &handle_receive_interrupt_nodma_rtail) {
119                                 __entry->dma_rtail = 0;
120                                 __entry->slow_path = 0;
121                         }
122                         ),
123             TP_printk("[%s] ctxt %d SlowPath: %d DmaRtail: %d",
124                       __get_str(dev),
125                       __entry->ctxt,
126                       __entry->slow_path,
127                       __entry->dma_rtail
128                       )
129 );
130
131 DECLARE_EVENT_CLASS(
132             hfi1_exp_tid_reg_unreg,
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 DEFINE_EVENT(
167         hfi1_exp_tid_reg_unreg, hfi1_exp_tid_unreg,
168         TP_PROTO(unsigned int ctxt, u16 subctxt, u32 rarr, u32 npages,
169                  unsigned long va, unsigned long pa, dma_addr_t dma),
170         TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma));
171
172 DEFINE_EVENT(
173         hfi1_exp_tid_reg_unreg, hfi1_exp_tid_reg,
174         TP_PROTO(unsigned int ctxt, u16 subctxt, u32 rarr, u32 npages,
175                  unsigned long va, unsigned long pa, dma_addr_t dma),
176         TP_ARGS(ctxt, subctxt, rarr, npages, va, pa, dma));
177
178 TRACE_EVENT(
179         hfi1_put_tid,
180         TP_PROTO(struct hfi1_devdata *dd,
181                  u32 index, u32 type, unsigned long pa, u16 order),
182         TP_ARGS(dd, index, type, pa, order),
183         TP_STRUCT__entry(
184                 DD_DEV_ENTRY(dd)
185                 __field(unsigned long, pa);
186                 __field(u32, index);
187                 __field(u32, type);
188                 __field(u16, order);
189         ),
190         TP_fast_assign(
191                 DD_DEV_ASSIGN(dd);
192                 __entry->pa = pa;
193                 __entry->index = index;
194                 __entry->type = type;
195                 __entry->order = order;
196         ),
197         TP_printk("[%s] type %s pa %lx index %u order %u",
198                   __get_str(dev),
199                   show_tidtype(__entry->type),
200                   __entry->pa,
201                   __entry->index,
202                   __entry->order
203         )
204 );
205
206 TRACE_EVENT(hfi1_exp_tid_inval,
207             TP_PROTO(unsigned int ctxt, u16 subctxt, unsigned long va, u32 rarr,
208                      u32 npages, dma_addr_t dma),
209             TP_ARGS(ctxt, subctxt, va, rarr, npages, dma),
210             TP_STRUCT__entry(
211                              __field(unsigned int, ctxt)
212                              __field(u16, subctxt)
213                              __field(unsigned long, va)
214                              __field(u32, rarr)
215                              __field(u32, npages)
216                              __field(dma_addr_t, dma)
217                              ),
218             TP_fast_assign(
219                            __entry->ctxt = ctxt;
220                            __entry->subctxt = subctxt;
221                            __entry->va = va;
222                            __entry->rarr = rarr;
223                            __entry->npages = npages;
224                            __entry->dma = dma;
225                           ),
226             TP_printk("[%u:%u] entry:%u, %u pages @ 0x%lx dma: 0x%llx",
227                       __entry->ctxt,
228                       __entry->subctxt,
229                       __entry->rarr,
230                       __entry->npages,
231                       __entry->va,
232                       __entry->dma
233                       )
234             );
235
236 TRACE_EVENT(hfi1_mmu_invalidate,
237             TP_PROTO(unsigned int ctxt, u16 subctxt, const char *type,
238                      unsigned long start, unsigned long end),
239             TP_ARGS(ctxt, subctxt, type, start, end),
240             TP_STRUCT__entry(
241                              __field(unsigned int, ctxt)
242                              __field(u16, subctxt)
243                              __string(type, type)
244                              __field(unsigned long, start)
245                              __field(unsigned long, end)
246                              ),
247             TP_fast_assign(
248                         __entry->ctxt = ctxt;
249                         __entry->subctxt = subctxt;
250                         __assign_str(type, type);
251                         __entry->start = start;
252                         __entry->end = end;
253             ),
254             TP_printk("[%3u:%02u] MMU Invalidate (%s) 0x%lx - 0x%lx",
255                       __entry->ctxt,
256                       __entry->subctxt,
257                       __get_str(type),
258                       __entry->start,
259                       __entry->end
260                       )
261             );
262
263 #endif /* __HFI1_TRACE_RX_H */
264
265 #undef TRACE_INCLUDE_PATH
266 #undef TRACE_INCLUDE_FILE
267 #define TRACE_INCLUDE_PATH .
268 #define TRACE_INCLUDE_FILE trace_rx
269 #include <trace/define_trace.h>