Merge tag 'pinctrl-v5.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[linux-2.6-microblaze.git] / drivers / infiniband / hw / hfi1 / trace_ibhdrs.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_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(TID_RDMA_WRITE_REQ),                \
83         ib_opcode_name(TID_RDMA_WRITE_RESP),               \
84         ib_opcode_name(TID_RDMA_WRITE_DATA),               \
85         ib_opcode_name(TID_RDMA_WRITE_DATA_LAST),          \
86         ib_opcode_name(TID_RDMA_READ_REQ),                 \
87         ib_opcode_name(TID_RDMA_READ_RESP),                \
88         ib_opcode_name(TID_RDMA_RESYNC),                   \
89         ib_opcode_name(TID_RDMA_ACK),                      \
90         ib_opcode_name(UC_SEND_FIRST),                     \
91         ib_opcode_name(UC_SEND_MIDDLE),                    \
92         ib_opcode_name(UC_SEND_LAST),                      \
93         ib_opcode_name(UC_SEND_LAST_WITH_IMMEDIATE),       \
94         ib_opcode_name(UC_SEND_ONLY),                      \
95         ib_opcode_name(UC_SEND_ONLY_WITH_IMMEDIATE),       \
96         ib_opcode_name(UC_RDMA_WRITE_FIRST),               \
97         ib_opcode_name(UC_RDMA_WRITE_MIDDLE),              \
98         ib_opcode_name(UC_RDMA_WRITE_LAST),                \
99         ib_opcode_name(UC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
100         ib_opcode_name(UC_RDMA_WRITE_ONLY),                \
101         ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
102         ib_opcode_name(UD_SEND_ONLY),                      \
103         ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE),       \
104         ib_opcode_name(CNP))
105
106 u8 ibhdr_exhdr_len(struct ib_header *hdr);
107 const char *parse_everbs_hdrs(struct trace_seq *p, u8 opcode,
108                               u8 l4, u32 dest_qpn, u32 src_qpn,
109                               void *ehdrs);
110 u8 hfi1_trace_opa_hdr_len(struct hfi1_opa_header *opah);
111 u8 hfi1_trace_packet_hdr_len(struct hfi1_packet *packet);
112 const char *hfi1_trace_get_packet_l4_str(u8 l4);
113 void hfi1_trace_parse_9b_bth(struct ib_other_headers *ohdr,
114                              u8 *ack, bool *becn, bool *fecn, u8 *mig,
115                              u8 *se, u8 *pad, u8 *opcode, u8 *tver,
116                              u16 *pkey, u32 *psn, u32 *qpn);
117 void hfi1_trace_parse_9b_hdr(struct ib_header *hdr, bool sc5,
118                              u8 *lnh, u8 *lver, u8 *sl, u8 *sc,
119                              u16 *len, u32 *dlid, u32 *slid);
120 void hfi1_trace_parse_16b_bth(struct ib_other_headers *ohdr,
121                               u8 *ack, u8 *mig, u8 *opcode,
122                               u8 *pad, u8 *se, u8 *tver,
123                               u32 *psn, u32 *qpn);
124 void hfi1_trace_parse_16b_hdr(struct hfi1_16b_header *hdr,
125                               u8 *age, bool *becn, bool *fecn,
126                               u8 *l4, u8 *rc, u8 *sc,
127                               u16 *entropy, u16 *len, u16 *pkey,
128                               u32 *dlid, u32 *slid);
129
130 const char *hfi1_trace_fmt_lrh(struct trace_seq *p, bool bypass,
131                                u8 age, bool becn, bool fecn, u8 l4,
132                                u8 lnh, const char *lnh_name, u8 lver,
133                                u8 rc, u8 sc, u8 sl, u16 entropy,
134                                u16 len, u16 pkey, u32 dlid, u32 slid);
135
136 const char *hfi1_trace_fmt_rest(struct trace_seq *p, bool bypass, u8 l4,
137                                 u8 ack, bool becn, bool fecn, u8 mig,
138                                 u8 se, u8 pad, u8 opcode, const char *opname,
139                                 u8 tver, u16 pkey, u32 psn, u32 qpn,
140                                 u32 dest_qpn, u32 src_qpn);
141
142 const char *hfi1_trace_get_packet_l2_str(u8 l2);
143
144 #define __parse_ib_ehdrs(op, l4, dest_qpn, src_qpn, ehdrs) \
145                          parse_everbs_hdrs(p, op, l4, dest_qpn, src_qpn, ehdrs)
146
147 #define lrh_name(lrh) { HFI1_##lrh, #lrh }
148 #define show_lnh(lrh)                    \
149 __print_symbolic(lrh,                    \
150         lrh_name(LRH_BTH),               \
151         lrh_name(LRH_GRH))
152
153 DECLARE_EVENT_CLASS(hfi1_input_ibhdr_template,
154                     TP_PROTO(struct hfi1_devdata *dd,
155                              struct hfi1_packet *packet,
156                              bool sc5),
157                     TP_ARGS(dd, packet, sc5),
158                     TP_STRUCT__entry(
159                         DD_DEV_ENTRY(dd)
160                         __field(u8, etype)
161                         __field(u8, ack)
162                         __field(u8, age)
163                         __field(bool, becn)
164                         __field(bool, fecn)
165                         __field(u8, l2)
166                         __field(u8, l4)
167                         __field(u8, lnh)
168                         __field(u8, lver)
169                         __field(u8, mig)
170                         __field(u8, opcode)
171                         __field(u8, pad)
172                         __field(u8, rc)
173                         __field(u8, sc)
174                         __field(u8, se)
175                         __field(u8, sl)
176                         __field(u8, tver)
177                         __field(u16, entropy)
178                         __field(u16, len)
179                         __field(u16, pkey)
180                         __field(u32, dlid)
181                         __field(u32, psn)
182                         __field(u32, qpn)
183                         __field(u32, slid)
184                         __field(u32, dest_qpn)
185                         __field(u32, src_qpn)
186                         /* extended headers */
187                         __dynamic_array(u8, ehdrs,
188                                         hfi1_trace_packet_hdr_len(packet))
189                         ),
190                     TP_fast_assign(
191                         DD_DEV_ASSIGN(dd);
192
193                         __entry->etype = packet->etype;
194                         __entry->l2 = hfi1_16B_get_l2(packet->hdr);
195                         __entry->dest_qpn = 0;
196                         __entry->src_qpn = 0;
197                         if (__entry->etype == RHF_RCV_TYPE_BYPASS) {
198                                 hfi1_trace_parse_16b_hdr(packet->hdr,
199                                                          &__entry->age,
200                                                          &__entry->becn,
201                                                          &__entry->fecn,
202                                                          &__entry->l4,
203                                                          &__entry->rc,
204                                                          &__entry->sc,
205                                                          &__entry->entropy,
206                                                          &__entry->len,
207                                                          &__entry->pkey,
208                                                          &__entry->dlid,
209                                                          &__entry->slid);
210
211                                 if (__entry->l4 == OPA_16B_L4_FM) {
212                                         __entry->opcode = IB_OPCODE_UD_SEND_ONLY;
213                                         __entry->dest_qpn = hfi1_16B_get_dest_qpn(packet->mgmt);
214                                         __entry->src_qpn = hfi1_16B_get_src_qpn(packet->mgmt);
215                                 }  else {
216                                         hfi1_trace_parse_16b_bth(packet->ohdr,
217                                                                  &__entry->ack,
218                                                                  &__entry->mig,
219                                                                  &__entry->opcode,
220                                                                  &__entry->pad,
221                                                                  &__entry->se,
222                                                                  &__entry->tver,
223                                                                  &__entry->psn,
224                                                                  &__entry->qpn);
225                                 }
226                         } else {
227                                 __entry->l4 = OPA_16B_L4_9B;
228                                 hfi1_trace_parse_9b_hdr(packet->hdr, sc5,
229                                                         &__entry->lnh,
230                                                         &__entry->lver,
231                                                         &__entry->sl,
232                                                         &__entry->sc,
233                                                         &__entry->len,
234                                                         &__entry->dlid,
235                                                         &__entry->slid);
236
237                                   hfi1_trace_parse_9b_bth(packet->ohdr,
238                                                           &__entry->ack,
239                                                           &__entry->becn,
240                                                           &__entry->fecn,
241                                                           &__entry->mig,
242                                                           &__entry->se,
243                                                           &__entry->pad,
244                                                           &__entry->opcode,
245                                                           &__entry->tver,
246                                                           &__entry->pkey,
247                                                           &__entry->psn,
248                                                           &__entry->qpn);
249                         }
250                         /* extended headers */
251                         if (__entry->l4 != OPA_16B_L4_FM)
252                                 memcpy(__get_dynamic_array(ehdrs),
253                                        &packet->ohdr->u,
254                                        __get_dynamic_array_len(ehdrs));
255                          ),
256                     TP_printk("[%s] (%s) %s %s hlen:%d %s",
257                               __get_str(dev),
258                               __entry->etype != RHF_RCV_TYPE_BYPASS ?
259                                         show_packettype(__entry->etype) :
260                                         hfi1_trace_get_packet_l2_str(
261                                                 __entry->l2),
262                               hfi1_trace_fmt_lrh(p,
263                                                  __entry->etype ==
264                                                         RHF_RCV_TYPE_BYPASS,
265                                                  __entry->age,
266                                                  __entry->becn,
267                                                  __entry->fecn,
268                                                  __entry->l4,
269                                                  __entry->lnh,
270                                                  show_lnh(__entry->lnh),
271                                                  __entry->lver,
272                                                  __entry->rc,
273                                                  __entry->sc,
274                                                  __entry->sl,
275                                                  __entry->entropy,
276                                                  __entry->len,
277                                                  __entry->pkey,
278                                                  __entry->dlid,
279                                                  __entry->slid),
280                               hfi1_trace_fmt_rest(p,
281                                                   __entry->etype ==
282                                                         RHF_RCV_TYPE_BYPASS,
283                                                   __entry->l4,
284                                                   __entry->ack,
285                                                   __entry->becn,
286                                                   __entry->fecn,
287                                                   __entry->mig,
288                                                   __entry->se,
289                                                   __entry->pad,
290                                                   __entry->opcode,
291                                                   show_ib_opcode(__entry->opcode),
292                                                   __entry->tver,
293                                                   __entry->pkey,
294                                                   __entry->psn,
295                                                   __entry->qpn,
296                                                   __entry->dest_qpn,
297                                                   __entry->src_qpn),
298                               /* extended headers */
299                               __get_dynamic_array_len(ehdrs),
300                               __parse_ib_ehdrs(
301                                         __entry->opcode,
302                                         __entry->l4,
303                                         __entry->dest_qpn,
304                                         __entry->src_qpn,
305                                         (void *)__get_dynamic_array(ehdrs))
306                              )
307 );
308
309 DEFINE_EVENT(hfi1_input_ibhdr_template, input_ibhdr,
310              TP_PROTO(struct hfi1_devdata *dd,
311                       struct hfi1_packet *packet, bool sc5),
312              TP_ARGS(dd, packet, sc5));
313
314 DECLARE_EVENT_CLASS(hfi1_output_ibhdr_template,
315                     TP_PROTO(struct hfi1_devdata *dd,
316                              struct hfi1_opa_header *opah, bool sc5),
317                     TP_ARGS(dd, opah, sc5),
318                     TP_STRUCT__entry(
319                         DD_DEV_ENTRY(dd)
320                         __field(u8, hdr_type)
321                         __field(u8, ack)
322                         __field(u8, age)
323                         __field(bool, becn)
324                         __field(bool, fecn)
325                         __field(u8, l4)
326                         __field(u8, lnh)
327                         __field(u8, lver)
328                         __field(u8, mig)
329                         __field(u8, opcode)
330                         __field(u8, pad)
331                         __field(u8, rc)
332                         __field(u8, sc)
333                         __field(u8, se)
334                         __field(u8, sl)
335                         __field(u8, tver)
336                         __field(u16, entropy)
337                         __field(u16, len)
338                         __field(u16, pkey)
339                         __field(u32, dlid)
340                         __field(u32, psn)
341                         __field(u32, qpn)
342                         __field(u32, slid)
343                         __field(u32, dest_qpn)
344                         __field(u32, src_qpn)
345                         /* extended headers */
346                         __dynamic_array(u8, ehdrs,
347                                         hfi1_trace_opa_hdr_len(opah))
348                         ),
349                     TP_fast_assign(
350                         struct ib_other_headers *ohdr;
351
352                         DD_DEV_ASSIGN(dd);
353
354                         __entry->hdr_type = opah->hdr_type;
355                         __entry->dest_qpn = 0;
356                         __entry->src_qpn = 0;
357                         if (__entry->hdr_type)  {
358                                 hfi1_trace_parse_16b_hdr(&opah->opah,
359                                                          &__entry->age,
360                                                          &__entry->becn,
361                                                          &__entry->fecn,
362                                                          &__entry->l4,
363                                                          &__entry->rc,
364                                                          &__entry->sc,
365                                                          &__entry->entropy,
366                                                          &__entry->len,
367                                                          &__entry->pkey,
368                                                          &__entry->dlid,
369                                                          &__entry->slid);
370
371                                 if (__entry->l4 == OPA_16B_L4_FM) {
372                                         ohdr = NULL;
373                                         __entry->opcode = IB_OPCODE_UD_SEND_ONLY;
374                                         __entry->dest_qpn = hfi1_16B_get_dest_qpn(&opah->opah.u.mgmt);
375                                         __entry->src_qpn = hfi1_16B_get_src_qpn(&opah->opah.u.mgmt);
376                                 } else {
377                                         if (__entry->l4 == OPA_16B_L4_IB_LOCAL)
378                                                 ohdr = &opah->opah.u.oth;
379                                         else
380                                                 ohdr = &opah->opah.u.l.oth;
381                                         hfi1_trace_parse_16b_bth(ohdr,
382                                                                  &__entry->ack,
383                                                                  &__entry->mig,
384                                                                  &__entry->opcode,
385                                                                  &__entry->pad,
386                                                                  &__entry->se,
387                                                                  &__entry->tver,
388                                                                  &__entry->psn,
389                                                                  &__entry->qpn);
390                                 }
391                         } else {
392                                 __entry->l4 = OPA_16B_L4_9B;
393                                 hfi1_trace_parse_9b_hdr(&opah->ibh, sc5,
394                                                         &__entry->lnh,
395                                                         &__entry->lver,
396                                                         &__entry->sl,
397                                                         &__entry->sc,
398                                                         &__entry->len,
399                                                         &__entry->dlid,
400                                                         &__entry->slid);
401                                 if (__entry->lnh == HFI1_LRH_BTH)
402                                         ohdr = &opah->ibh.u.oth;
403                                 else
404                                         ohdr = &opah->ibh.u.l.oth;
405                                 hfi1_trace_parse_9b_bth(ohdr,
406                                                         &__entry->ack,
407                                                         &__entry->becn,
408                                                         &__entry->fecn,
409                                                         &__entry->mig,
410                                                         &__entry->se,
411                                                         &__entry->pad,
412                                                         &__entry->opcode,
413                                                         &__entry->tver,
414                                                         &__entry->pkey,
415                                                         &__entry->psn,
416                                                         &__entry->qpn);
417                         }
418
419                         /* extended headers */
420                         if (__entry->l4 != OPA_16B_L4_FM)
421                                 memcpy(__get_dynamic_array(ehdrs),
422                                        &ohdr->u, __get_dynamic_array_len(ehdrs));
423                     ),
424                     TP_printk("[%s] (%s) %s %s hlen:%d %s",
425                               __get_str(dev),
426                               hfi1_trace_get_packet_l4_str(__entry->l4),
427                               hfi1_trace_fmt_lrh(p,
428                                                  !!__entry->hdr_type,
429                                                  __entry->age,
430                                                  __entry->becn,
431                                                  __entry->fecn,
432                                                  __entry->l4,
433                                                  __entry->lnh,
434                                                  show_lnh(__entry->lnh),
435                                                  __entry->lver,
436                                                  __entry->rc,
437                                                  __entry->sc,
438                                                  __entry->sl,
439                                                  __entry->entropy,
440                                                  __entry->len,
441                                                  __entry->pkey,
442                                                  __entry->dlid,
443                                                  __entry->slid),
444                               hfi1_trace_fmt_rest(p,
445                                                   !!__entry->hdr_type,
446                                                   __entry->l4,
447                                                   __entry->ack,
448                                                   __entry->becn,
449                                                   __entry->fecn,
450                                                   __entry->mig,
451                                                   __entry->se,
452                                                   __entry->pad,
453                                                   __entry->opcode,
454                                                   show_ib_opcode(__entry->opcode),
455                                                   __entry->tver,
456                                                   __entry->pkey,
457                                                   __entry->psn,
458                                                   __entry->qpn,
459                                                   __entry->dest_qpn,
460                                                   __entry->src_qpn),
461                               /* extended headers */
462                               __get_dynamic_array_len(ehdrs),
463                               __parse_ib_ehdrs(
464                                         __entry->opcode,
465                                         __entry->l4,
466                                         __entry->dest_qpn,
467                                         __entry->src_qpn,
468                                         (void *)__get_dynamic_array(ehdrs))
469                              )
470 );
471
472 DEFINE_EVENT(hfi1_output_ibhdr_template, pio_output_ibhdr,
473              TP_PROTO(struct hfi1_devdata *dd,
474                       struct hfi1_opa_header *opah, bool sc5),
475              TP_ARGS(dd, opah, sc5));
476
477 DEFINE_EVENT(hfi1_output_ibhdr_template, ack_output_ibhdr,
478              TP_PROTO(struct hfi1_devdata *dd,
479                       struct hfi1_opa_header *opah, bool sc5),
480              TP_ARGS(dd, opah, sc5));
481
482 DEFINE_EVENT(hfi1_output_ibhdr_template, sdma_output_ibhdr,
483              TP_PROTO(struct hfi1_devdata *dd,
484                       struct hfi1_opa_header *opah, bool sc5),
485              TP_ARGS(dd, opah, sc5));
486
487
488 #endif /* __HFI1_TRACE_IBHDRS_H */
489
490 #undef TRACE_INCLUDE_PATH
491 #undef TRACE_INCLUDE_FILE
492 #define TRACE_INCLUDE_PATH .
493 #define TRACE_INCLUDE_FILE trace_ibhdrs
494 #include <trace/define_trace.h>