summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/hisilicon/hns3/hns3_trace.h
blob: 5153e5d41bbd62b0dc513c5ae4720b632404a817 (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
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright (c) 2018-2019 Hisilicon Limited. */

/* This must be outside ifdef _HNS3_TRACE_H */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM hns3

#if !defined(_HNS3_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
#define _HNS3_TRACE_H_

#include <linux/tracepoint.h>

#define DESC_NR		(sizeof(struct hns3_desc) / sizeof(u32))

DECLARE_EVENT_CLASS(hns3_skb_template,
	TP_PROTO(struct sk_buff *skb),
	TP_ARGS(skb),

	TP_STRUCT__entry(
		__field(unsigned int, headlen)
		__field(unsigned int, len)
		__field(__u8, nr_frags)
		__field(__u8, ip_summed)
		__field(unsigned int, hdr_len)
		__field(unsigned short, gso_size)
		__field(unsigned short, gso_segs)
		__field(unsigned int, gso_type)
		__field(bool, fraglist)
		__array(__u32, size, MAX_SKB_FRAGS)
	),

	TP_fast_assign(
		__entry->headlen = skb_headlen(skb);
		__entry->len = skb->len;
		__entry->nr_frags = skb_shinfo(skb)->nr_frags;
		__entry->gso_size = skb_shinfo(skb)->gso_size;
		__entry->gso_segs = skb_shinfo(skb)->gso_segs;
		__entry->gso_type = skb_shinfo(skb)->gso_type;
		__entry->hdr_len = skb->encapsulation ?
		skb_inner_transport_offset(skb) + inner_tcp_hdrlen(skb) :
		skb_transport_offset(skb) + tcp_hdrlen(skb);
		__entry->ip_summed = skb->ip_summed;
		__entry->fraglist = skb_has_frag_list(skb);
		hns3_shinfo_pack(skb_shinfo(skb), __entry->size);
	),

	TP_printk(
		"len: %u, %u, %u, cs: %u, gso: %u, %u, %x, frag(%d %u): %s",
		__entry->headlen, __entry->len, __entry->hdr_len,
		__entry->ip_summed, __entry->gso_size, __entry->gso_segs,
		__entry->gso_type, __entry->fraglist, __entry->nr_frags,
		__print_array(__entry->size, MAX_SKB_FRAGS, sizeof(__u32))
	)
);

DEFINE_EVENT(hns3_skb_template, hns3_over_max_bd,
	TP_PROTO(struct sk_buff *skb),
	TP_ARGS(skb));

DEFINE_EVENT(hns3_skb_template, hns3_gro,
	TP_PROTO(struct sk_buff *skb),
	TP_ARGS(skb));

DEFINE_EVENT(hns3_skb_template, hns3_tso,
	TP_PROTO(struct sk_buff *skb),
	TP_ARGS(skb));

TRACE_EVENT(hns3_tx_desc,
	TP_PROTO(struct hns3_enet_ring *ring, int cur_ntu),
	TP_ARGS(ring, cur_ntu),

	TP_STRUCT__entry(
		__field(int, index)
		__field(int, ntu)
		__field(int, ntc)
		__field(dma_addr_t, desc_dma)
		__array(u32, desc, DESC_NR)
		__string(devname, ring->tqp->handle->kinfo.netdev->name)
	),

	TP_fast_assign(
		__entry->index = ring->tqp->tqp_index;
		__entry->ntu = ring->next_to_use;
		__entry->ntc = ring->next_to_clean;
		__entry->desc_dma = ring->desc_dma_addr,
		memcpy(__entry->desc, &ring->desc[cur_ntu],
		       sizeof(struct hns3_desc));
		__assign_str(devname, ring->tqp->handle->kinfo.netdev->name);
	),

	TP_printk(
		"%s-%d-%d/%d desc(%pad): %s",
		__get_str(devname), __entry->index, __entry->ntu,
		__entry->ntc, &__entry->desc_dma,
		__print_array(__entry->desc, DESC_NR, sizeof(u32))
	)
);

TRACE_EVENT(hns3_rx_desc,
	TP_PROTO(struct hns3_enet_ring *ring),
	TP_ARGS(ring),

	TP_STRUCT__entry(
		__field(int, index)
		__field(int, ntu)
		__field(int, ntc)
		__field(dma_addr_t, desc_dma)
		__field(dma_addr_t, buf_dma)
		__array(u32, desc, DESC_NR)
		__string(devname, ring->tqp->handle->kinfo.netdev->name)
	),

	TP_fast_assign(
		__entry->index = ring->tqp->tqp_index;
		__entry->ntu = ring->next_to_use;
		__entry->ntc = ring->next_to_clean;
		__entry->desc_dma = ring->desc_dma_addr;
		__entry->buf_dma = ring->desc_cb[ring->next_to_clean].dma;
		memcpy(__entry->desc, &ring->desc[ring->next_to_clean],
		       sizeof(struct hns3_desc));
		__assign_str(devname, ring->tqp->handle->kinfo.netdev->name);
	),

	TP_printk(
		"%s-%d-%d/%d desc(%pad) buf(%pad): %s",
		__get_str(devname), __entry->index, __entry->ntu,
		__entry->ntc, &__entry->desc_dma, &__entry->buf_dma,
		__print_array(__entry->desc, DESC_NR, sizeof(u32))
	)
);

#endif /* _HNS3_TRACE_H_ */

/* This must be outside ifdef _HNS3_TRACE_H */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE hns3_trace
#include <trace/define_trace.h>