summaryrefslogtreecommitdiff
path: root/drivers/infiniband/hw/hfi1/trace_ibhdrs.h
blob: 1dc2c28fc96e7dd088c29ea5ba4c2857cb826e41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
/*
 * Copyright(c) 2015 - 2017 Intel Corporation.
 *
 * This file is provided under a dual BSD/GPLv2 license.  When using or
 * redistributing this file, you may do so under either license.
 *
 * GPL LICENSE SUMMARY
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * BSD LICENSE
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  - Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  - Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  - Neither the name of Intel Corporation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
#if !defined(__HFI1_TRACE_IBHDRS_H) || defined(TRACE_HEADER_MULTI_READ)
#define __HFI1_TRACE_IBHDRS_H

#include <linux/tracepoint.h>
#include <linux/trace_seq.h>

#include "hfi.h"

#undef TRACE_SYSTEM
#define TRACE_SYSTEM hfi1_ibhdrs

#define ib_opcode_name(opcode) { IB_OPCODE_##opcode, #opcode  }
#define show_ib_opcode(opcode)                             \
__print_symbolic(opcode,                                   \
	ib_opcode_name(RC_SEND_FIRST),                     \
	ib_opcode_name(RC_SEND_MIDDLE),                    \
	ib_opcode_name(RC_SEND_LAST),                      \
	ib_opcode_name(RC_SEND_LAST_WITH_IMMEDIATE),       \
	ib_opcode_name(RC_SEND_ONLY),                      \
	ib_opcode_name(RC_SEND_ONLY_WITH_IMMEDIATE),       \
	ib_opcode_name(RC_RDMA_WRITE_FIRST),               \
	ib_opcode_name(RC_RDMA_WRITE_MIDDLE),              \
	ib_opcode_name(RC_RDMA_WRITE_LAST),                \
	ib_opcode_name(RC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
	ib_opcode_name(RC_RDMA_WRITE_ONLY),                \
	ib_opcode_name(RC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
	ib_opcode_name(RC_RDMA_READ_REQUEST),              \
	ib_opcode_name(RC_RDMA_READ_RESPONSE_FIRST),       \
	ib_opcode_name(RC_RDMA_READ_RESPONSE_MIDDLE),      \
	ib_opcode_name(RC_RDMA_READ_RESPONSE_LAST),        \
	ib_opcode_name(RC_RDMA_READ_RESPONSE_ONLY),        \
	ib_opcode_name(RC_ACKNOWLEDGE),                    \
	ib_opcode_name(RC_ATOMIC_ACKNOWLEDGE),             \
	ib_opcode_name(RC_COMPARE_SWAP),                   \
	ib_opcode_name(RC_FETCH_ADD),                      \
	ib_opcode_name(UC_SEND_FIRST),                     \
	ib_opcode_name(UC_SEND_MIDDLE),                    \
	ib_opcode_name(UC_SEND_LAST),                      \
	ib_opcode_name(UC_SEND_LAST_WITH_IMMEDIATE),       \
	ib_opcode_name(UC_SEND_ONLY),                      \
	ib_opcode_name(UC_SEND_ONLY_WITH_IMMEDIATE),       \
	ib_opcode_name(UC_RDMA_WRITE_FIRST),               \
	ib_opcode_name(UC_RDMA_WRITE_MIDDLE),              \
	ib_opcode_name(UC_RDMA_WRITE_LAST),                \
	ib_opcode_name(UC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
	ib_opcode_name(UC_RDMA_WRITE_ONLY),                \
	ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
	ib_opcode_name(UD_SEND_ONLY),                      \
	ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE),       \
	ib_opcode_name(CNP))

u8 ibhdr_exhdr_len(struct ib_header *hdr);
const char *parse_everbs_hdrs(struct trace_seq *p, u8 opcode,
			      u8 l4, u32 dest_qpn, u32 src_qpn,
			      void *ehdrs);
u8 hfi1_trace_opa_hdr_len(struct hfi1_opa_header *opah);
u8 hfi1_trace_packet_hdr_len(struct hfi1_packet *packet);
const char *hfi1_trace_get_packet_l4_str(u8 l4);
void hfi1_trace_parse_9b_bth(struct ib_other_headers *ohdr,
			     u8 *ack, bool *becn, bool *fecn, u8 *mig,
			     u8 *se, u8 *pad, u8 *opcode, u8 *tver,
			     u16 *pkey, u32 *psn, u32 *qpn);
void hfi1_trace_parse_9b_hdr(struct ib_header *hdr, bool sc5,
			     u8 *lnh, u8 *lver, u8 *sl, u8 *sc,
			     u16 *len, u32 *dlid, u32 *slid);
void hfi1_trace_parse_16b_bth(struct ib_other_headers *ohdr,
			      u8 *ack, u8 *mig, u8 *opcode,
			      u8 *pad, u8 *se, u8 *tver,
			      u32 *psn, u32 *qpn);
void hfi1_trace_parse_16b_hdr(struct hfi1_16b_header *hdr,
			      u8 *age, bool *becn, bool *fecn,
			      u8 *l4, u8 *rc, u8 *sc,
			      u16 *entropy, u16 *len, u16 *pkey,
			      u32 *dlid, u32 *slid);

const char *hfi1_trace_fmt_lrh(struct trace_seq *p, bool bypass,
			       u8 age, bool becn, bool fecn, u8 l4,
			       u8 lnh, const char *lnh_name, u8 lver,
			       u8 rc, u8 sc, u8 sl, u16 entropy,
			       u16 len, u16 pkey, u32 dlid, u32 slid);

const char *hfi1_trace_fmt_rest(struct trace_seq *p, bool bypass, u8 l4,
				u8 ack, bool becn, bool fecn, u8 mig,
				u8 se, u8 pad, u8 opcode, const char *opname,
				u8 tver, u16 pkey, u32 psn, u32 qpn,
				u32 dest_qpn, u32 src_qpn);

const char *hfi1_trace_get_packet_l2_str(u8 l2);

#define __parse_ib_ehdrs(op, l4, dest_qpn, src_qpn, ehdrs) \
			 parse_everbs_hdrs(p, op, l4, dest_qpn, src_qpn, ehdrs)

#define lrh_name(lrh) { HFI1_##lrh, #lrh }
#define show_lnh(lrh)                    \
__print_symbolic(lrh,                    \
	lrh_name(LRH_BTH),               \
	lrh_name(LRH_GRH))

DECLARE_EVENT_CLASS(hfi1_input_ibhdr_template,
		    TP_PROTO(struct hfi1_devdata *dd,
			     struct hfi1_packet *packet,
			     bool sc5),
		    TP_ARGS(dd, packet, sc5),
		    TP_STRUCT__entry(
			DD_DEV_ENTRY(dd)
			__field(u8, etype)
			__field(u8, ack)
			__field(u8, age)
			__field(bool, becn)
			__field(bool, fecn)
			__field(u8, l2)
			__field(u8, l4)
			__field(u8, lnh)
			__field(u8, lver)
			__field(u8, mig)
			__field(u8, opcode)
			__field(u8, pad)
			__field(u8, rc)
			__field(u8, sc)
			__field(u8, se)
			__field(u8, sl)
			__field(u8, tver)
			__field(u16, entropy)
			__field(u16, len)
			__field(u16, pkey)
			__field(u32, dlid)
			__field(u32, psn)
			__field(u32, qpn)
			__field(u32, slid)
			__field(u32, dest_qpn)
			__field(u32, src_qpn)
			/* extended headers */
			__dynamic_array(u8, ehdrs,
					hfi1_trace_packet_hdr_len(packet))
			),
		    TP_fast_assign(
			DD_DEV_ASSIGN(dd);

			__entry->etype = packet->etype;
			__entry->l2 = hfi1_16B_get_l2(packet->hdr);
			__entry->dest_qpn = 0;
			__entry->src_qpn = 0;
			if (__entry->etype == RHF_RCV_TYPE_BYPASS) {
				hfi1_trace_parse_16b_hdr(packet->hdr,
							 &__entry->age,
							 &__entry->becn,
							 &__entry->fecn,
							 &__entry->l4,
							 &__entry->rc,
							 &__entry->sc,
							 &__entry->entropy,
							 &__entry->len,
							 &__entry->pkey,
							 &__entry->dlid,
							 &__entry->slid);

				if (__entry->l4 == OPA_16B_L4_FM) {
					__entry->opcode = IB_OPCODE_UD_SEND_ONLY;
					__entry->dest_qpn = hfi1_16B_get_dest_qpn(packet->mgmt);
					__entry->src_qpn = hfi1_16B_get_src_qpn(packet->mgmt);
				}  else {
					hfi1_trace_parse_16b_bth(packet->ohdr,
								 &__entry->ack,
								 &__entry->mig,
								 &__entry->opcode,
								 &__entry->pad,
								 &__entry->se,
								 &__entry->tver,
								 &__entry->psn,
								 &__entry->qpn);
				}
			} else {
				__entry->l4 = OPA_16B_L4_9B;
				hfi1_trace_parse_9b_hdr(packet->hdr, sc5,
							&__entry->lnh,
							&__entry->lver,
							&__entry->sl,
							&__entry->sc,
							&__entry->len,
							&__entry->dlid,
							&__entry->slid);

				  hfi1_trace_parse_9b_bth(packet->ohdr,
							  &__entry->ack,
							  &__entry->becn,
							  &__entry->fecn,
							  &__entry->mig,
							  &__entry->se,
							  &__entry->pad,
							  &__entry->opcode,
							  &__entry->tver,
							  &__entry->pkey,
							  &__entry->psn,
							  &__entry->qpn);
			}
			/* extended headers */
			if (__entry->l4 != OPA_16B_L4_FM)
				memcpy(__get_dynamic_array(ehdrs),
				       &packet->ohdr->u,
				       __get_dynamic_array_len(ehdrs));
			 ),
		    TP_printk("[%s] (%s) %s %s hlen:%d %s",
			      __get_str(dev),
			      __entry->etype != RHF_RCV_TYPE_BYPASS ?
					show_packettype(__entry->etype) :
					hfi1_trace_get_packet_l2_str(
						__entry->l2),
			      hfi1_trace_fmt_lrh(p,
						 __entry->etype ==
							RHF_RCV_TYPE_BYPASS,
						 __entry->age,
						 __entry->becn,
						 __entry->fecn,
						 __entry->l4,
						 __entry->lnh,
						 show_lnh(__entry->lnh),
						 __entry->lver,
						 __entry->rc,
						 __entry->sc,
						 __entry->sl,
						 __entry->entropy,
						 __entry->len,
						 __entry->pkey,
						 __entry->dlid,
						 __entry->slid),
			      hfi1_trace_fmt_rest(p,
						  __entry->etype ==
							RHF_RCV_TYPE_BYPASS,
						  __entry->l4,
						  __entry->ack,
						  __entry->becn,
						  __entry->fecn,
						  __entry->mig,
						  __entry->se,
						  __entry->pad,
						  __entry->opcode,
						  show_ib_opcode(__entry->opcode),
						  __entry->tver,
						  __entry->pkey,
						  __entry->psn,
						  __entry->qpn,
						  __entry->dest_qpn,
						  __entry->src_qpn),
			      /* extended headers */
			      __get_dynamic_array_len(ehdrs),
			      __parse_ib_ehdrs(
					__entry->opcode,
					__entry->l4,
					__entry->dest_qpn,
					__entry->src_qpn,
					(void *)__get_dynamic_array(ehdrs))
			     )
);

DEFINE_EVENT(hfi1_input_ibhdr_template, input_ibhdr,
	     TP_PROTO(struct hfi1_devdata *dd,
		      struct hfi1_packet *packet, bool sc5),
	     TP_ARGS(dd, packet, sc5));

DECLARE_EVENT_CLASS(hfi1_output_ibhdr_template,
		    TP_PROTO(struct hfi1_devdata *dd,
			     struct hfi1_opa_header *opah, bool sc5),
		    TP_ARGS(dd, opah, sc5),
		    TP_STRUCT__entry(
			DD_DEV_ENTRY(dd)
			__field(u8, hdr_type)
			__field(u8, ack)
			__field(u8, age)
			__field(bool, becn)
			__field(bool, fecn)
			__field(u8, l4)
			__field(u8, lnh)
			__field(u8, lver)
			__field(u8, mig)
			__field(u8, opcode)
			__field(u8, pad)
			__field(u8, rc)
			__field(u8, sc)
			__field(u8, se)
			__field(u8, sl)
			__field(u8, tver)
			__field(u16, entropy)
			__field(u16, len)
			__field(u16, pkey)
			__field(u32, dlid)
			__field(u32, psn)
			__field(u32, qpn)
			__field(u32, slid)
			__field(u32, dest_qpn)
			__field(u32, src_qpn)
			/* extended headers */
			__dynamic_array(u8, ehdrs,
					hfi1_trace_opa_hdr_len(opah))
			),
		    TP_fast_assign(
			struct ib_other_headers *ohdr;

			DD_DEV_ASSIGN(dd);

			__entry->hdr_type = opah->hdr_type;
			__entry->dest_qpn = 0;
			__entry->src_qpn = 0;
			if (__entry->hdr_type)  {
				hfi1_trace_parse_16b_hdr(&opah->opah,
							 &__entry->age,
							 &__entry->becn,
							 &__entry->fecn,
							 &__entry->l4,
							 &__entry->rc,
							 &__entry->sc,
							 &__entry->entropy,
							 &__entry->len,
							 &__entry->pkey,
							 &__entry->dlid,
							 &__entry->slid);

				if (__entry->l4 == OPA_16B_L4_FM) {
					ohdr = NULL;
					__entry->opcode = IB_OPCODE_UD_SEND_ONLY;
					__entry->dest_qpn = hfi1_16B_get_dest_qpn(&opah->opah.u.mgmt);
					__entry->src_qpn = hfi1_16B_get_src_qpn(&opah->opah.u.mgmt);
				} else {
					if (__entry->l4 == OPA_16B_L4_IB_LOCAL)
						ohdr = &opah->opah.u.oth;
					else
						ohdr = &opah->opah.u.l.oth;
					hfi1_trace_parse_16b_bth(ohdr,
								 &__entry->ack,
								 &__entry->mig,
								 &__entry->opcode,
								 &__entry->pad,
								 &__entry->se,
								 &__entry->tver,
								 &__entry->psn,
								 &__entry->qpn);
				}
			} else {
				__entry->l4 = OPA_16B_L4_9B;
				hfi1_trace_parse_9b_hdr(&opah->ibh, sc5,
							&__entry->lnh,
							&__entry->lver,
							&__entry->sl,
							&__entry->sc,
							&__entry->len,
							&__entry->dlid,
							&__entry->slid);
				if (__entry->lnh == HFI1_LRH_BTH)
					ohdr = &opah->ibh.u.oth;
				else
					ohdr = &opah->ibh.u.l.oth;
				hfi1_trace_parse_9b_bth(ohdr,
							&__entry->ack,
							&__entry->becn,
							&__entry->fecn,
							&__entry->mig,
							&__entry->se,
							&__entry->pad,
							&__entry->opcode,
							&__entry->tver,
							&__entry->pkey,
							&__entry->psn,
							&__entry->qpn);
			}

			/* extended headers */
			if (__entry->l4 != OPA_16B_L4_FM)
				memcpy(__get_dynamic_array(ehdrs),
				       &ohdr->u, __get_dynamic_array_len(ehdrs));
		    ),
		    TP_printk("[%s] (%s) %s %s hlen:%d %s",
			      __get_str(dev),
			      hfi1_trace_get_packet_l4_str(__entry->l4),
			      hfi1_trace_fmt_lrh(p,
						 !!__entry->hdr_type,
						 __entry->age,
						 __entry->becn,
						 __entry->fecn,
						 __entry->l4,
						 __entry->lnh,
						 show_lnh(__entry->lnh),
						 __entry->lver,
						 __entry->rc,
						 __entry->sc,
						 __entry->sl,
						 __entry->entropy,
						 __entry->len,
						 __entry->pkey,
						 __entry->dlid,
						 __entry->slid),
			      hfi1_trace_fmt_rest(p,
						  !!__entry->hdr_type,
						  __entry->l4,
						  __entry->ack,
						  __entry->becn,
						  __entry->fecn,
						  __entry->mig,
						  __entry->se,
						  __entry->pad,
						  __entry->opcode,
						  show_ib_opcode(__entry->opcode),
						  __entry->tver,
						  __entry->pkey,
						  __entry->psn,
						  __entry->qpn,
						  __entry->dest_qpn,
						  __entry->src_qpn),
			      /* extended headers */
			      __get_dynamic_array_len(ehdrs),
			      __parse_ib_ehdrs(
					__entry->opcode,
					__entry->l4,
					__entry->dest_qpn,
					__entry->src_qpn,
					(void *)__get_dynamic_array(ehdrs))
			     )
);

DEFINE_EVENT(hfi1_output_ibhdr_template, pio_output_ibhdr,
	     TP_PROTO(struct hfi1_devdata *dd,
		      struct hfi1_opa_header *opah, bool sc5),
	     TP_ARGS(dd, opah, sc5));

DEFINE_EVENT(hfi1_output_ibhdr_template, ack_output_ibhdr,
	     TP_PROTO(struct hfi1_devdata *dd,
		      struct hfi1_opa_header *opah, bool sc5),
	     TP_ARGS(dd, opah, sc5));

DEFINE_EVENT(hfi1_output_ibhdr_template, sdma_output_ibhdr,
	     TP_PROTO(struct hfi1_devdata *dd,
		      struct hfi1_opa_header *opah, bool sc5),
	     TP_ARGS(dd, opah, sc5));


#endif /* __HFI1_TRACE_IBHDRS_H */

#undef TRACE_INCLUDE_PATH
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE trace_ibhdrs
#include <trace/define_trace.h>