xref: /linux/drivers/net/ethernet/hisilicon/hns3/hns3_trace.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2018-2019 Hisilicon Limited. */
3 
4 /* This must be outside ifdef _HNS3_TRACE_H */
5 #undef TRACE_SYSTEM
6 #define TRACE_SYSTEM hns3
7 
8 #if !defined(_HNS3_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
9 #define _HNS3_TRACE_H_
10 
11 #include <linux/tracepoint.h>
12 
13 #define DESC_NR		(sizeof(struct hns3_desc) / sizeof(u32))
14 
15 DECLARE_EVENT_CLASS(hns3_skb_template,
16 	TP_PROTO(struct sk_buff *skb),
17 	TP_ARGS(skb),
18 
19 	TP_STRUCT__entry(
20 		__field(unsigned int, headlen)
21 		__field(unsigned int, len)
22 		__field(__u8, nr_frags)
23 		__field(__u8, ip_summed)
24 		__field(unsigned int, hdr_len)
25 		__field(unsigned short, gso_size)
26 		__field(unsigned short, gso_segs)
27 		__field(unsigned int, gso_type)
28 		__field(bool, fraglist)
29 		__array(__u32, size, MAX_SKB_FRAGS)
30 	),
31 
32 	TP_fast_assign(
33 		__entry->headlen = skb_headlen(skb);
34 		__entry->len = skb->len;
35 		__entry->nr_frags = skb_shinfo(skb)->nr_frags;
36 		__entry->gso_size = skb_shinfo(skb)->gso_size;
37 		__entry->gso_segs = skb_shinfo(skb)->gso_segs;
38 		__entry->gso_type = skb_shinfo(skb)->gso_type;
39 		__entry->hdr_len = skb->encapsulation ?
40 		skb_inner_tcp_all_headers(skb) : skb_tcp_all_headers(skb);
41 		__entry->ip_summed = skb->ip_summed;
42 		__entry->fraglist = skb_has_frag_list(skb);
43 		hns3_shinfo_pack(skb_shinfo(skb), __entry->size);
44 	),
45 
46 	TP_printk(
47 		"len: %u, %u, %u, cs: %u, gso: %u, %u, %x, frag(%d %u): %s",
48 		__entry->headlen, __entry->len, __entry->hdr_len,
49 		__entry->ip_summed, __entry->gso_size, __entry->gso_segs,
50 		__entry->gso_type, __entry->fraglist, __entry->nr_frags,
51 		__print_array(__entry->size, MAX_SKB_FRAGS, sizeof(__u32))
52 	)
53 );
54 
55 DEFINE_EVENT(hns3_skb_template, hns3_over_max_bd,
56 	TP_PROTO(struct sk_buff *skb),
57 	TP_ARGS(skb));
58 
59 DEFINE_EVENT(hns3_skb_template, hns3_gro,
60 	TP_PROTO(struct sk_buff *skb),
61 	TP_ARGS(skb));
62 
63 DEFINE_EVENT(hns3_skb_template, hns3_tso,
64 	TP_PROTO(struct sk_buff *skb),
65 	TP_ARGS(skb));
66 
67 TRACE_EVENT(hns3_tx_desc,
68 	TP_PROTO(struct hns3_enet_ring *ring, int cur_ntu),
69 	TP_ARGS(ring, cur_ntu),
70 
71 	TP_STRUCT__entry(
72 		__field(int, index)
73 		__field(int, ntu)
74 		__field(int, ntc)
75 		__field(dma_addr_t, desc_dma)
76 		__array(u32, desc, DESC_NR)
77 		__string(devname, ring->tqp->handle->kinfo.netdev->name)
78 	),
79 
80 	TP_fast_assign(
81 		__entry->index = ring->tqp->tqp_index;
82 		__entry->ntu = ring->next_to_use;
83 		__entry->ntc = ring->next_to_clean;
84 		__entry->desc_dma = ring->desc_dma_addr,
85 		memcpy(__entry->desc, &ring->desc[cur_ntu],
86 		       sizeof(struct hns3_desc));
87 		__assign_str(devname);
88 	),
89 
90 	TP_printk(
91 		"%s-%d-%d/%d desc(%pad): %s",
92 		__get_str(devname), __entry->index, __entry->ntu,
93 		__entry->ntc, &__entry->desc_dma,
94 		__print_array(__entry->desc, DESC_NR, sizeof(u32))
95 	)
96 );
97 
98 TRACE_EVENT(hns3_rx_desc,
99 	TP_PROTO(struct hns3_enet_ring *ring),
100 	TP_ARGS(ring),
101 
102 	TP_STRUCT__entry(
103 		__field(int, index)
104 		__field(int, ntu)
105 		__field(int, ntc)
106 		__field(dma_addr_t, desc_dma)
107 		__field(dma_addr_t, buf_dma)
108 		__array(u32, desc, DESC_NR)
109 		__string(devname, ring->tqp->handle->kinfo.netdev->name)
110 	),
111 
112 	TP_fast_assign(
113 		__entry->index = ring->tqp->tqp_index;
114 		__entry->ntu = ring->next_to_use;
115 		__entry->ntc = ring->next_to_clean;
116 		__entry->desc_dma = ring->desc_dma_addr;
117 		__entry->buf_dma = ring->desc_cb[ring->next_to_clean].dma;
118 		memcpy(__entry->desc, &ring->desc[ring->next_to_clean],
119 		       sizeof(struct hns3_desc));
120 		__assign_str(devname);
121 	),
122 
123 	TP_printk(
124 		"%s-%d-%d/%d desc(%pad) buf(%pad): %s",
125 		__get_str(devname), __entry->index, __entry->ntu,
126 		__entry->ntc, &__entry->desc_dma, &__entry->buf_dma,
127 		__print_array(__entry->desc, DESC_NR, sizeof(u32))
128 	)
129 );
130 
131 #endif /* _HNS3_TRACE_H_ */
132 
133 /* This must be outside ifdef _HNS3_TRACE_H */
134 #undef TRACE_INCLUDE_PATH
135 #define TRACE_INCLUDE_PATH .
136 #undef TRACE_INCLUDE_FILE
137 #define TRACE_INCLUDE_FILE hns3_trace
138 #include <trace/define_trace.h>
139