1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright(c) 2015 - 2017 Intel Corporation.
6 #if !defined(__HFI1_TRACE_IBHDRS_H) || defined(TRACE_HEADER_MULTI_READ)
7 #define __HFI1_TRACE_IBHDRS_H
9 #include <linux/tracepoint.h>
10 #include <linux/trace_seq.h>
15 #define TRACE_SYSTEM hfi1_ibhdrs
17 #define ib_opcode_name(opcode) { IB_OPCODE_##opcode, #opcode }
18 #define show_ib_opcode(opcode) \
19 __print_symbolic(opcode, \
20 ib_opcode_name(RC_SEND_FIRST), \
21 ib_opcode_name(RC_SEND_MIDDLE), \
22 ib_opcode_name(RC_SEND_LAST), \
23 ib_opcode_name(RC_SEND_LAST_WITH_IMMEDIATE), \
24 ib_opcode_name(RC_SEND_ONLY), \
25 ib_opcode_name(RC_SEND_ONLY_WITH_IMMEDIATE), \
26 ib_opcode_name(RC_RDMA_WRITE_FIRST), \
27 ib_opcode_name(RC_RDMA_WRITE_MIDDLE), \
28 ib_opcode_name(RC_RDMA_WRITE_LAST), \
29 ib_opcode_name(RC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
30 ib_opcode_name(RC_RDMA_WRITE_ONLY), \
31 ib_opcode_name(RC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
32 ib_opcode_name(RC_RDMA_READ_REQUEST), \
33 ib_opcode_name(RC_RDMA_READ_RESPONSE_FIRST), \
34 ib_opcode_name(RC_RDMA_READ_RESPONSE_MIDDLE), \
35 ib_opcode_name(RC_RDMA_READ_RESPONSE_LAST), \
36 ib_opcode_name(RC_RDMA_READ_RESPONSE_ONLY), \
37 ib_opcode_name(RC_ACKNOWLEDGE), \
38 ib_opcode_name(RC_ATOMIC_ACKNOWLEDGE), \
39 ib_opcode_name(RC_COMPARE_SWAP), \
40 ib_opcode_name(RC_FETCH_ADD), \
41 ib_opcode_name(RC_SEND_LAST_WITH_INVALIDATE), \
42 ib_opcode_name(RC_SEND_ONLY_WITH_INVALIDATE), \
43 ib_opcode_name(TID_RDMA_WRITE_REQ), \
44 ib_opcode_name(TID_RDMA_WRITE_RESP), \
45 ib_opcode_name(TID_RDMA_WRITE_DATA), \
46 ib_opcode_name(TID_RDMA_WRITE_DATA_LAST), \
47 ib_opcode_name(TID_RDMA_READ_REQ), \
48 ib_opcode_name(TID_RDMA_READ_RESP), \
49 ib_opcode_name(TID_RDMA_RESYNC), \
50 ib_opcode_name(TID_RDMA_ACK), \
51 ib_opcode_name(UC_SEND_FIRST), \
52 ib_opcode_name(UC_SEND_MIDDLE), \
53 ib_opcode_name(UC_SEND_LAST), \
54 ib_opcode_name(UC_SEND_LAST_WITH_IMMEDIATE), \
55 ib_opcode_name(UC_SEND_ONLY), \
56 ib_opcode_name(UC_SEND_ONLY_WITH_IMMEDIATE), \
57 ib_opcode_name(UC_RDMA_WRITE_FIRST), \
58 ib_opcode_name(UC_RDMA_WRITE_MIDDLE), \
59 ib_opcode_name(UC_RDMA_WRITE_LAST), \
60 ib_opcode_name(UC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
61 ib_opcode_name(UC_RDMA_WRITE_ONLY), \
62 ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
63 ib_opcode_name(UD_SEND_ONLY), \
64 ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE), \
67 u8
ibhdr_exhdr_len(struct ib_header
*hdr
);
68 const char *parse_everbs_hdrs(struct trace_seq
*p
, u8 opcode
,
69 u8 l4
, u32 dest_qpn
, u32 src_qpn
,
71 u8
hfi1_trace_opa_hdr_len(struct hfi1_opa_header
*opah
);
72 u8
hfi1_trace_packet_hdr_len(struct hfi1_packet
*packet
);
73 const char *hfi1_trace_get_packet_l4_str(u8 l4
);
74 void hfi1_trace_parse_9b_bth(struct ib_other_headers
*ohdr
,
75 u8
*ack
, bool *becn
, bool *fecn
, u8
*mig
,
76 u8
*se
, u8
*pad
, u8
*opcode
, u8
*tver
,
77 u16
*pkey
, u32
*psn
, u32
*qpn
);
78 void hfi1_trace_parse_9b_hdr(struct ib_header
*hdr
, bool sc5
,
79 u8
*lnh
, u8
*lver
, u8
*sl
, u8
*sc
,
80 u16
*len
, u32
*dlid
, u32
*slid
);
81 void hfi1_trace_parse_16b_bth(struct ib_other_headers
*ohdr
,
82 u8
*ack
, u8
*mig
, u8
*opcode
,
83 u8
*pad
, u8
*se
, u8
*tver
,
85 void hfi1_trace_parse_16b_hdr(struct hfi1_16b_header
*hdr
,
86 u8
*age
, bool *becn
, bool *fecn
,
87 u8
*l4
, u8
*rc
, u8
*sc
,
88 u16
*entropy
, u16
*len
, u16
*pkey
,
89 u32
*dlid
, u32
*slid
);
91 const char *hfi1_trace_fmt_lrh(struct trace_seq
*p
, bool bypass
,
92 u8 age
, bool becn
, bool fecn
, u8 l4
,
93 u8 lnh
, const char *lnh_name
, u8 lver
,
94 u8 rc
, u8 sc
, u8 sl
, u16 entropy
,
95 u16 len
, u16 pkey
, u32 dlid
, u32 slid
);
97 const char *hfi1_trace_fmt_rest(struct trace_seq
*p
, bool bypass
, u8 l4
,
98 u8 ack
, bool becn
, bool fecn
, u8 mig
,
99 u8 se
, u8 pad
, u8 opcode
, const char *opname
,
100 u8 tver
, u16 pkey
, u32 psn
, u32 qpn
,
101 u32 dest_qpn
, u32 src_qpn
);
103 const char *hfi1_trace_get_packet_l2_str(u8 l2
);
105 #define __parse_ib_ehdrs(op, l4, dest_qpn, src_qpn, ehdrs) \
106 parse_everbs_hdrs(p, op, l4, dest_qpn, src_qpn, ehdrs)
108 #define lrh_name(lrh) { HFI1_##lrh, #lrh }
109 #define show_lnh(lrh) \
110 __print_symbolic(lrh, \
114 DECLARE_EVENT_CLASS(hfi1_input_ibhdr_template
,
115 TP_PROTO(struct hfi1_devdata
*dd
,
116 struct hfi1_packet
*packet
,
118 TP_ARGS(dd
, packet
, sc5
),
138 __field(u16
, entropy
)
145 __field(u32
, dest_qpn
)
146 __field(u32
, src_qpn
)
147 /* extended headers */
148 __dynamic_array(u8
, ehdrs
,
149 hfi1_trace_packet_hdr_len(packet
))
154 __entry
->etype
= packet
->etype
;
155 __entry
->l2
= hfi1_16B_get_l2(packet
->hdr
);
156 __entry
->dest_qpn
= 0;
157 __entry
->src_qpn
= 0;
158 if (__entry
->etype
== RHF_RCV_TYPE_BYPASS
) {
159 hfi1_trace_parse_16b_hdr(packet
->hdr
,
172 if (__entry
->l4
== OPA_16B_L4_FM
) {
173 __entry
->opcode
= IB_OPCODE_UD_SEND_ONLY
;
174 __entry
->dest_qpn
= hfi1_16B_get_dest_qpn(packet
->mgmt
);
175 __entry
->src_qpn
= hfi1_16B_get_src_qpn(packet
->mgmt
);
177 hfi1_trace_parse_16b_bth(packet
->ohdr
,
188 __entry
->l4
= OPA_16B_L4_9B
;
189 hfi1_trace_parse_9b_hdr(packet
->hdr
, sc5
,
198 hfi1_trace_parse_9b_bth(packet
->ohdr
,
211 /* extended headers */
212 if (__entry
->l4
!= OPA_16B_L4_FM
)
213 memcpy(__get_dynamic_array(ehdrs
),
215 __get_dynamic_array_len(ehdrs
));
217 TP_printk("[%s] (%s) %s %s hlen:%d %s",
219 __entry
->etype
!= RHF_RCV_TYPE_BYPASS
?
220 show_packettype(__entry
->etype
) :
221 hfi1_trace_get_packet_l2_str(
223 hfi1_trace_fmt_lrh(p
,
231 show_lnh(__entry
->lnh
),
241 hfi1_trace_fmt_rest(p
,
252 show_ib_opcode(__entry
->opcode
),
259 /* extended headers */
260 __get_dynamic_array_len(ehdrs
),
266 (void *)__get_dynamic_array(ehdrs
))
270 DEFINE_EVENT(hfi1_input_ibhdr_template
, input_ibhdr
,
271 TP_PROTO(struct hfi1_devdata
*dd
,
272 struct hfi1_packet
*packet
, bool sc5
),
273 TP_ARGS(dd
, packet
, sc5
));
275 DECLARE_EVENT_CLASS(hfi1_output_ibhdr_template
,
276 TP_PROTO(struct hfi1_devdata
*dd
,
277 struct hfi1_opa_header
*opah
, bool sc5
),
278 TP_ARGS(dd
, opah
, sc5
),
281 __field(u8
, hdr_type
)
297 __field(u16
, entropy
)
304 __field(u32
, dest_qpn
)
305 __field(u32
, src_qpn
)
306 /* extended headers */
307 __dynamic_array(u8
, ehdrs
,
308 hfi1_trace_opa_hdr_len(opah
))
311 struct ib_other_headers
*ohdr
;
315 __entry
->hdr_type
= opah
->hdr_type
;
316 __entry
->dest_qpn
= 0;
317 __entry
->src_qpn
= 0;
318 if (__entry
->hdr_type
) {
319 hfi1_trace_parse_16b_hdr(&opah
->opah
,
332 if (__entry
->l4
== OPA_16B_L4_FM
) {
334 __entry
->opcode
= IB_OPCODE_UD_SEND_ONLY
;
335 __entry
->dest_qpn
= hfi1_16B_get_dest_qpn(&opah
->opah
.u
.mgmt
);
336 __entry
->src_qpn
= hfi1_16B_get_src_qpn(&opah
->opah
.u
.mgmt
);
338 if (__entry
->l4
== OPA_16B_L4_IB_LOCAL
)
339 ohdr
= &opah
->opah
.u
.oth
;
341 ohdr
= &opah
->opah
.u
.l
.oth
;
342 hfi1_trace_parse_16b_bth(ohdr
,
353 __entry
->l4
= OPA_16B_L4_9B
;
354 hfi1_trace_parse_9b_hdr(&opah
->ibh
, sc5
,
362 if (__entry
->lnh
== HFI1_LRH_BTH
)
363 ohdr
= &opah
->ibh
.u
.oth
;
365 ohdr
= &opah
->ibh
.u
.l
.oth
;
366 hfi1_trace_parse_9b_bth(ohdr
,
380 /* extended headers */
381 if (__entry
->l4
!= OPA_16B_L4_FM
)
382 memcpy(__get_dynamic_array(ehdrs
),
383 &ohdr
->u
, __get_dynamic_array_len(ehdrs
));
385 TP_printk("[%s] (%s) %s %s hlen:%d %s",
387 hfi1_trace_get_packet_l4_str(__entry
->l4
),
388 hfi1_trace_fmt_lrh(p
,
395 show_lnh(__entry
->lnh
),
405 hfi1_trace_fmt_rest(p
,
415 show_ib_opcode(__entry
->opcode
),
422 /* extended headers */
423 __get_dynamic_array_len(ehdrs
),
429 (void *)__get_dynamic_array(ehdrs
))
433 DEFINE_EVENT(hfi1_output_ibhdr_template
, pio_output_ibhdr
,
434 TP_PROTO(struct hfi1_devdata
*dd
,
435 struct hfi1_opa_header
*opah
, bool sc5
),
436 TP_ARGS(dd
, opah
, sc5
));
438 DEFINE_EVENT(hfi1_output_ibhdr_template
, ack_output_ibhdr
,
439 TP_PROTO(struct hfi1_devdata
*dd
,
440 struct hfi1_opa_header
*opah
, bool sc5
),
441 TP_ARGS(dd
, opah
, sc5
));
443 DEFINE_EVENT(hfi1_output_ibhdr_template
, sdma_output_ibhdr
,
444 TP_PROTO(struct hfi1_devdata
*dd
,
445 struct hfi1_opa_header
*opah
, bool sc5
),
446 TP_ARGS(dd
, opah
, sc5
));
449 #endif /* __HFI1_TRACE_IBHDRS_H */
451 #undef TRACE_INCLUDE_PATH
452 #undef TRACE_INCLUDE_FILE
453 #define TRACE_INCLUDE_PATH .
454 #define TRACE_INCLUDE_FILE trace_ibhdrs
455 #include <trace/define_trace.h>