2 * Copyright(c) 2015, 2016 Intel Corporation.
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.
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.
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.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
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
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.
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.
47 #if !defined(__HFI1_TRACE_IBHDRS_H) || defined(TRACE_HEADER_MULTI_READ)
48 #define __HFI1_TRACE_IBHDRS_H
50 #include <linux/tracepoint.h>
51 #include <linux/trace_seq.h>
56 #define TRACE_SYSTEM hfi1_ibhdrs
58 u8 ibhdr_exhdr_len(struct ib_header *hdr);
59 const char *parse_everbs_hdrs(struct trace_seq *p, u8 opcode, void *ehdrs);
61 #define __parse_ib_ehdrs(op, ehdrs) parse_everbs_hdrs(p, op, ehdrs)
63 #define lrh_name(lrh) { HFI1_##lrh, #lrh }
64 #define show_lnh(lrh) \
65 __print_symbolic(lrh, \
69 #define LRH_PRN "vl %d lver %d sl %d lnh %d,%s dlid %.4x len %d slid %.4x"
71 "op 0x%.2x,%s se %d m %d pad %d tver %d pkey 0x%.4x " \
72 "f %d b %d qpn 0x%.6x a %d psn 0x%.8x"
75 DECLARE_EVENT_CLASS(hfi1_ibhdr_template,
76 TP_PROTO(struct hfi1_devdata *dd,
77 struct ib_header *hdr),
101 /* extended headers */
102 __dynamic_array(u8, ehdrs, ibhdr_exhdr_len(hdr))
105 struct ib_other_headers *ohdr;
110 (u8)(be16_to_cpu(hdr->lrh[0]) >> 12);
112 (u8)(be16_to_cpu(hdr->lrh[0]) >> 8) & 0xf;
114 (u8)(be16_to_cpu(hdr->lrh[0]) >> 4) & 0xf;
116 (u8)(be16_to_cpu(hdr->lrh[0]) & 3);
118 be16_to_cpu(hdr->lrh[1]);
119 /* allow for larger len */
121 be16_to_cpu(hdr->lrh[2]);
123 be16_to_cpu(hdr->lrh[3]);
125 if (__entry->lnh == HFI1_LRH_BTH)
128 ohdr = &hdr->u.l.oth;
130 (be32_to_cpu(ohdr->bth[0]) >> 24) & 0xff;
132 (be32_to_cpu(ohdr->bth[0]) >> 23) & 1;
134 (be32_to_cpu(ohdr->bth[0]) >> 22) & 1;
136 (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
138 (be32_to_cpu(ohdr->bth[0]) >> 16) & 0xf;
140 be32_to_cpu(ohdr->bth[0]) & 0xffff;
142 (be32_to_cpu(ohdr->bth[1]) >> HFI1_FECN_SHIFT) &
145 (be32_to_cpu(ohdr->bth[1]) >> HFI1_BECN_SHIFT) &
148 be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;
150 (be32_to_cpu(ohdr->bth[2]) >> 31) & 1;
151 /* allow for larger PSN */
153 be32_to_cpu(ohdr->bth[2]) & 0x7fffffff;
154 /* extended headers */
155 memcpy(__get_dynamic_array(ehdrs), &ohdr->u,
156 ibhdr_exhdr_len(hdr));
158 TP_printk("[%s] " LRH_PRN " " BTH_PRN " " EHDR_PRN,
164 __entry->lnh, show_lnh(__entry->lnh),
169 __entry->opcode, show_ib_opcode(__entry->opcode),
180 /* extended headers */
183 (void *)__get_dynamic_array(ehdrs))
187 DEFINE_EVENT(hfi1_ibhdr_template, input_ibhdr,
188 TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
191 DEFINE_EVENT(hfi1_ibhdr_template, pio_output_ibhdr,
192 TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
195 DEFINE_EVENT(hfi1_ibhdr_template, ack_output_ibhdr,
196 TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
199 DEFINE_EVENT(hfi1_ibhdr_template, sdma_output_ibhdr,
200 TP_PROTO(struct hfi1_devdata *dd, struct ib_header *hdr),
203 #endif /* __HFI1_TRACE_IBHDRS_H */
205 #undef TRACE_INCLUDE_PATH
206 #undef TRACE_INCLUDE_FILE
207 #define TRACE_INCLUDE_PATH .
208 #define TRACE_INCLUDE_FILE trace_ibhdrs
209 #include <trace/define_trace.h>