Linux-libre 4.14.2-gnu
[librecmc/linux-libre.git] / drivers / infiniband / hw / hfi1 / trace_ibhdrs.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_IBHDRS_H) || defined(TRACE_HEADER_MULTI_READ)
48 #define __HFI1_TRACE_IBHDRS_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_ibhdrs
57
58 #define ib_opcode_name(opcode) { IB_OPCODE_##opcode, #opcode  }
59 #define show_ib_opcode(opcode)                             \
60 __print_symbolic(opcode,                                   \
61         ib_opcode_name(RC_SEND_FIRST),                     \
62         ib_opcode_name(RC_SEND_MIDDLE),                    \
63         ib_opcode_name(RC_SEND_LAST),                      \
64         ib_opcode_name(RC_SEND_LAST_WITH_IMMEDIATE),       \
65         ib_opcode_name(RC_SEND_ONLY),                      \
66         ib_opcode_name(RC_SEND_ONLY_WITH_IMMEDIATE),       \
67         ib_opcode_name(RC_RDMA_WRITE_FIRST),               \
68         ib_opcode_name(RC_RDMA_WRITE_MIDDLE),              \
69         ib_opcode_name(RC_RDMA_WRITE_LAST),                \
70         ib_opcode_name(RC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
71         ib_opcode_name(RC_RDMA_WRITE_ONLY),                \
72         ib_opcode_name(RC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
73         ib_opcode_name(RC_RDMA_READ_REQUEST),              \
74         ib_opcode_name(RC_RDMA_READ_RESPONSE_FIRST),       \
75         ib_opcode_name(RC_RDMA_READ_RESPONSE_MIDDLE),      \
76         ib_opcode_name(RC_RDMA_READ_RESPONSE_LAST),        \
77         ib_opcode_name(RC_RDMA_READ_RESPONSE_ONLY),        \
78         ib_opcode_name(RC_ACKNOWLEDGE),                    \
79         ib_opcode_name(RC_ATOMIC_ACKNOWLEDGE),             \
80         ib_opcode_name(RC_COMPARE_SWAP),                   \
81         ib_opcode_name(RC_FETCH_ADD),                      \
82         ib_opcode_name(UC_SEND_FIRST),                     \
83         ib_opcode_name(UC_SEND_MIDDLE),                    \
84         ib_opcode_name(UC_SEND_LAST),                      \
85         ib_opcode_name(UC_SEND_LAST_WITH_IMMEDIATE),       \
86         ib_opcode_name(UC_SEND_ONLY),                      \
87         ib_opcode_name(UC_SEND_ONLY_WITH_IMMEDIATE),       \
88         ib_opcode_name(UC_RDMA_WRITE_FIRST),               \
89         ib_opcode_name(UC_RDMA_WRITE_MIDDLE),              \
90         ib_opcode_name(UC_RDMA_WRITE_LAST),                \
91         ib_opcode_name(UC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
92         ib_opcode_name(UC_RDMA_WRITE_ONLY),                \
93         ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
94         ib_opcode_name(UD_SEND_ONLY),                      \
95         ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE),       \
96         ib_opcode_name(CNP))
97
98 u8 ibhdr_exhdr_len(struct ib_header *hdr);
99 const char *parse_everbs_hdrs(struct trace_seq *p, u8 opcode, void *ehdrs);
100 u8 hfi1_trace_opa_hdr_len(struct hfi1_opa_header *opah);
101 u8 hfi1_trace_packet_hdr_len(struct hfi1_packet *packet);
102 const char *hfi1_trace_get_packet_type_str(u8 l4);
103 const char *hfi1_trace_get_packet_str(struct hfi1_packet *packet);
104 void hfi1_trace_parse_9b_bth(struct ib_other_headers *ohdr,
105                              u8 *ack, u8 *becn, u8 *fecn, u8 *mig,
106                              u8 *se, u8 *pad, u8 *opcode, u8 *tver,
107                              u16 *pkey, u32 *psn, u32 *qpn);
108 void hfi1_trace_parse_9b_hdr(struct ib_header *hdr, bool sc5,
109                              u8 *lnh, u8 *lver, u8 *sl, u8 *sc,
110                              u16 *len, u32 *dlid, u32 *slid);
111 void hfi1_trace_parse_16b_bth(struct ib_other_headers *ohdr,
112                               u8 *ack, u8 *mig, u8 *opcode,
113                               u8 *pad, u8 *se, u8 *tver,
114                               u32 *psn, u32 *qpn);
115 void hfi1_trace_parse_16b_hdr(struct hfi1_16b_header *hdr,
116                               u8 *age, u8 *becn, u8 *fecn,
117                               u8 *l4, u8 *rc, u8 *sc,
118                               u16 *entropy, u16 *len, u16 *pkey,
119                               u32 *dlid, u32 *slid);
120
121 const char *hfi1_trace_fmt_lrh(struct trace_seq *p, bool bypass,
122                                u8 age, u8 becn, u8 fecn, u8 l4,
123                                u8 lnh, const char *lnh_name, u8 lver,
124                                u8 rc, u8 sc, u8 sl, u16 entropy,
125                                u16 len, u16 pkey, u32 dlid, u32 slid);
126
127 const char *hfi1_trace_fmt_bth(struct trace_seq *p, bool bypass,
128                                u8 ack, u8 becn, u8 fecn, u8 mig,
129                                u8 se, u8 pad, u8 opcode, const char *opname,
130                                u8 tver, u16 pkey, u32 psn, u32 qpn);
131
132 #define __parse_ib_ehdrs(op, ehdrs) parse_everbs_hdrs(p, op, ehdrs)
133
134 #define lrh_name(lrh) { HFI1_##lrh, #lrh }
135 #define show_lnh(lrh)                    \
136 __print_symbolic(lrh,                    \
137         lrh_name(LRH_BTH),               \
138         lrh_name(LRH_GRH))
139 #define PKT_ENTRY(pkt)  __string(ptype,  hfi1_trace_get_packet_str(packet))
140 #define PKT_ASSIGN(pkt) __assign_str(ptype, hfi1_trace_get_packet_str(packet))
141
142 DECLARE_EVENT_CLASS(hfi1_input_ibhdr_template,
143                     TP_PROTO(struct hfi1_devdata *dd,
144                              struct hfi1_packet *packet,
145                              bool sc5),
146                     TP_ARGS(dd, packet, sc5),
147                     TP_STRUCT__entry(
148                         DD_DEV_ENTRY(dd)
149                         PKT_ENTRY(packet)
150                         __field(bool, bypass)
151                         __field(u8, ack)
152                         __field(u8, age)
153                         __field(u8, becn)
154                         __field(u8, fecn)
155                         __field(u8, l4)
156                         __field(u8, lnh)
157                         __field(u8, lver)
158                         __field(u8, mig)
159                         __field(u8, opcode)
160                         __field(u8, pad)
161                         __field(u8, rc)
162                         __field(u8, sc)
163                         __field(u8, se)
164                         __field(u8, sl)
165                         __field(u8, tver)
166                         __field(u16, entropy)
167                         __field(u16, len)
168                         __field(u16, pkey)
169                         __field(u32, dlid)
170                         __field(u32, psn)
171                         __field(u32, qpn)
172                         __field(u32, slid)
173                         /* extended headers */
174                         __dynamic_array(u8, ehdrs,
175                                         hfi1_trace_packet_hdr_len(packet))
176                         ),
177                     TP_fast_assign(
178                         DD_DEV_ASSIGN(dd);
179                         PKT_ASSIGN(packet);
180
181                         if (packet->etype == RHF_RCV_TYPE_BYPASS) {
182                                 __entry->bypass = true;
183                                 hfi1_trace_parse_16b_hdr(packet->hdr,
184                                                          &__entry->age,
185                                                          &__entry->becn,
186                                                          &__entry->fecn,
187                                                          &__entry->l4,
188                                                          &__entry->rc,
189                                                          &__entry->sc,
190                                                          &__entry->entropy,
191                                                          &__entry->len,
192                                                          &__entry->pkey,
193                                                          &__entry->dlid,
194                                                          &__entry->slid);
195
196                                   hfi1_trace_parse_16b_bth(packet->ohdr,
197                                                            &__entry->ack,
198                                                            &__entry->mig,
199                                                            &__entry->opcode,
200                                                            &__entry->pad,
201                                                            &__entry->se,
202                                                            &__entry->tver,
203                                                            &__entry->psn,
204                                                            &__entry->qpn);
205                         } else {
206                                 __entry->bypass = false;
207                                 hfi1_trace_parse_9b_hdr(packet->hdr, sc5,
208                                                         &__entry->lnh,
209                                                         &__entry->lver,
210                                                         &__entry->sl,
211                                                         &__entry->sc,
212                                                         &__entry->len,
213                                                         &__entry->dlid,
214                                                         &__entry->slid);
215
216                                   hfi1_trace_parse_9b_bth(packet->ohdr,
217                                                           &__entry->ack,
218                                                           &__entry->becn,
219                                                           &__entry->fecn,
220                                                           &__entry->mig,
221                                                           &__entry->se,
222                                                           &__entry->pad,
223                                                           &__entry->opcode,
224                                                           &__entry->tver,
225                                                           &__entry->pkey,
226                                                           &__entry->psn,
227                                                           &__entry->qpn);
228                                 }
229                                 /* extended headers */
230                                 memcpy(__get_dynamic_array(ehdrs),
231                                        &packet->ohdr->u,
232                                        __get_dynamic_array_len(ehdrs));
233                          ),
234                     TP_printk("[%s] (%s) %s %s hlen:%d %s",
235                               __get_str(dev),
236                               __get_str(ptype),
237                               hfi1_trace_fmt_lrh(p,
238                                                  __entry->bypass,
239                                                  __entry->age,
240                                                  __entry->becn,
241                                                  __entry->fecn,
242                                                  __entry->l4,
243                                                  __entry->lnh,
244                                                  show_lnh(__entry->lnh),
245                                                  __entry->lver,
246                                                  __entry->rc,
247                                                  __entry->sc,
248                                                  __entry->sl,
249                                                  __entry->entropy,
250                                                  __entry->len,
251                                                  __entry->pkey,
252                                                  __entry->dlid,
253                                                  __entry->slid),
254                               hfi1_trace_fmt_bth(p,
255                                                  __entry->bypass,
256                                                  __entry->ack,
257                                                  __entry->becn,
258                                                  __entry->fecn,
259                                                  __entry->mig,
260                                                  __entry->se,
261                                                  __entry->pad,
262                                                  __entry->opcode,
263                                                  show_ib_opcode(__entry->opcode),
264                                                  __entry->tver,
265                                                  __entry->pkey,
266                                                  __entry->psn,
267                                                  __entry->qpn),
268                               /* extended headers */
269                               __get_dynamic_array_len(ehdrs),
270                               __parse_ib_ehdrs(
271                                         __entry->opcode,
272                                         (void *)__get_dynamic_array(ehdrs))
273                              )
274 );
275
276 DEFINE_EVENT(hfi1_input_ibhdr_template, input_ibhdr,
277              TP_PROTO(struct hfi1_devdata *dd,
278                       struct hfi1_packet *packet, bool sc5),
279              TP_ARGS(dd, packet, sc5));
280
281 DECLARE_EVENT_CLASS(hfi1_output_ibhdr_template,
282                     TP_PROTO(struct hfi1_devdata *dd,
283                              struct hfi1_opa_header *opah, bool sc5),
284                     TP_ARGS(dd, opah, sc5),
285                     TP_STRUCT__entry(
286                         DD_DEV_ENTRY(dd)
287                         __field(bool, bypass)
288                         __field(u8, ack)
289                         __field(u8, age)
290                         __field(u8, becn)
291                         __field(u8, fecn)
292                         __field(u8, l4)
293                         __field(u8, lnh)
294                         __field(u8, lver)
295                         __field(u8, mig)
296                         __field(u8, opcode)
297                         __field(u8, pad)
298                         __field(u8, rc)
299                         __field(u8, sc)
300                         __field(u8, se)
301                         __field(u8, sl)
302                         __field(u8, tver)
303                         __field(u16, entropy)
304                         __field(u16, len)
305                         __field(u16, pkey)
306                         __field(u32, dlid)
307                         __field(u32, psn)
308                         __field(u32, qpn)
309                         __field(u32, slid)
310                         /* extended headers */
311                         __dynamic_array(u8, ehdrs,
312                                         hfi1_trace_opa_hdr_len(opah))
313                         ),
314                     TP_fast_assign(
315                         struct ib_other_headers *ohdr;
316
317                         DD_DEV_ASSIGN(dd);
318
319                         if (opah->hdr_type)  {
320                                 __entry->bypass = true;
321                                 hfi1_trace_parse_16b_hdr(&opah->opah,
322                                                          &__entry->age,
323                                                          &__entry->becn,
324                                                          &__entry->fecn,
325                                                          &__entry->l4,
326                                                          &__entry->rc,
327                                                          &__entry->sc,
328                                                          &__entry->entropy,
329                                                          &__entry->len,
330                                                          &__entry->pkey,
331                                                          &__entry->dlid,
332                                                          &__entry->slid);
333
334                                 if (entry->l4 == OPA_16B_L4_IB_LOCAL)
335                                         ohdr = &opah->opah.u.oth;
336                                 else
337                                         ohdr = &opah->opah.u.l.oth;
338                                 hfi1_trace_parse_16b_bth(ohdr,
339                                                          &__entry->ack,
340                                                          &__entry->mig,
341                                                          &__entry->opcode,
342                                                          &__entry->pad,
343                                                          &__entry->se,
344                                                          &__entry->tver,
345                                                          &__entry->psn,
346                                                          &__entry->qpn);
347                         } else {
348                                 __entry->bypass = false;
349                                 hfi1_trace_parse_9b_hdr(&opah->ibh, sc5,
350                                                         &__entry->lnh,
351                                                         &__entry->lver,
352                                                         &__entry->sl,
353                                                         &__entry->sc,
354                                                         &__entry->len,
355                                                         &__entry->dlid,
356                                                         &__entry->slid);
357                                 if (entry->lnh == HFI1_LRH_BTH)
358                                         ohdr = &opah->ibh.u.oth;
359                                 else
360                                         ohdr = &opah->ibh.u.l.oth;
361                                 hfi1_trace_parse_9b_bth(ohdr,
362                                                         &__entry->ack,
363                                                         &__entry->becn,
364                                                         &__entry->fecn,
365                                                         &__entry->mig,
366                                                         &__entry->se,
367                                                         &__entry->pad,
368                                                         &__entry->opcode,
369                                                         &__entry->tver,
370                                                         &__entry->pkey,
371                                                         &__entry->psn,
372                                                         &__entry->qpn);
373                         }
374
375                         /* extended headers */
376                         memcpy(__get_dynamic_array(ehdrs),
377                                &ohdr->u, __get_dynamic_array_len(ehdrs));
378                     ),
379                     TP_printk("[%s] (%s) %s %s hlen:%d %s",
380                               __get_str(dev),
381                               hfi1_trace_get_packet_type_str(__entry->l4),
382                               hfi1_trace_fmt_lrh(p,
383                                                  __entry->bypass,
384                                                  __entry->age,
385                                                  __entry->becn,
386                                                  __entry->fecn,
387                                                  __entry->l4,
388                                                  __entry->lnh,
389                                                  show_lnh(__entry->lnh),
390                                                  __entry->lver,
391                                                  __entry->rc,
392                                                  __entry->sc,
393                                                  __entry->sl,
394                                                  __entry->entropy,
395                                                  __entry->len,
396                                                  __entry->pkey,
397                                                  __entry->dlid,
398                                                  __entry->slid),
399                               hfi1_trace_fmt_bth(p,
400                                                  __entry->bypass,
401                                                  __entry->ack,
402                                                  __entry->becn,
403                                                  __entry->fecn,
404                                                  __entry->mig,
405                                                  __entry->se,
406                                                  __entry->pad,
407                                                  __entry->opcode,
408                                                  show_ib_opcode(__entry->opcode),
409                                                  __entry->tver,
410                                                  __entry->pkey,
411                                                  __entry->psn,
412                                                  __entry->qpn),
413                               /* extended headers */
414                               __get_dynamic_array_len(ehdrs),
415                               __parse_ib_ehdrs(
416                                         __entry->opcode,
417                                         (void *)__get_dynamic_array(ehdrs))
418                              )
419 );
420
421 DEFINE_EVENT(hfi1_output_ibhdr_template, pio_output_ibhdr,
422              TP_PROTO(struct hfi1_devdata *dd,
423                       struct hfi1_opa_header *opah, bool sc5),
424              TP_ARGS(dd, opah, sc5));
425
426 DEFINE_EVENT(hfi1_output_ibhdr_template, ack_output_ibhdr,
427              TP_PROTO(struct hfi1_devdata *dd,
428                       struct hfi1_opa_header *opah, bool sc5),
429              TP_ARGS(dd, opah, sc5));
430
431 DEFINE_EVENT(hfi1_output_ibhdr_template, sdma_output_ibhdr,
432              TP_PROTO(struct hfi1_devdata *dd,
433                       struct hfi1_opa_header *opah, bool sc5),
434              TP_ARGS(dd, opah, sc5));
435
436
437 #endif /* __HFI1_TRACE_IBHDRS_H */
438
439 #undef TRACE_INCLUDE_PATH
440 #undef TRACE_INCLUDE_FILE
441 #define TRACE_INCLUDE_PATH .
442 #define TRACE_INCLUDE_FILE trace_ibhdrs
443 #include <trace/define_trace.h>