xref: /linux/include/trace/events/net.h (revision 1a59d1b8e05ea6ab45f7e18897de1ef0e6bc3da6)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM net
4 
5 #if !defined(_TRACE_NET_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_NET_H
7 
8 #include <linux/skbuff.h>
9 #include <linux/netdevice.h>
10 #include <linux/if_vlan.h>
11 #include <linux/ip.h>
12 #include <linux/tracepoint.h>
13 
14 TRACE_EVENT(net_dev_start_xmit,
15 
16 	TP_PROTO(const struct sk_buff *skb, const struct net_device *dev),
17 
18 	TP_ARGS(skb, dev),
19 
20 	TP_STRUCT__entry(
21 		__string(	name,			dev->name	)
22 		__field(	u16,			queue_mapping	)
23 		__field(	const void *,		skbaddr		)
24 		__field(	bool,			vlan_tagged	)
25 		__field(	u16,			vlan_proto	)
26 		__field(	u16,			vlan_tci	)
27 		__field(	u16,			protocol	)
28 		__field(	u8,			ip_summed	)
29 		__field(	unsigned int,		len		)
30 		__field(	unsigned int,		data_len	)
31 		__field(	int,			network_offset	)
32 		__field(	bool,			transport_offset_valid)
33 		__field(	int,			transport_offset)
34 		__field(	u8,			tx_flags	)
35 		__field(	u16,			gso_size	)
36 		__field(	u16,			gso_segs	)
37 		__field(	u16,			gso_type	)
38 	),
39 
40 	TP_fast_assign(
41 		__assign_str(name, dev->name);
42 		__entry->queue_mapping = skb->queue_mapping;
43 		__entry->skbaddr = skb;
44 		__entry->vlan_tagged = skb_vlan_tag_present(skb);
45 		__entry->vlan_proto = ntohs(skb->vlan_proto);
46 		__entry->vlan_tci = skb_vlan_tag_get(skb);
47 		__entry->protocol = ntohs(skb->protocol);
48 		__entry->ip_summed = skb->ip_summed;
49 		__entry->len = skb->len;
50 		__entry->data_len = skb->data_len;
51 		__entry->network_offset = skb_network_offset(skb);
52 		__entry->transport_offset_valid =
53 			skb_transport_header_was_set(skb);
54 		__entry->transport_offset = skb_transport_offset(skb);
55 		__entry->tx_flags = skb_shinfo(skb)->tx_flags;
56 		__entry->gso_size = skb_shinfo(skb)->gso_size;
57 		__entry->gso_segs = skb_shinfo(skb)->gso_segs;
58 		__entry->gso_type = skb_shinfo(skb)->gso_type;
59 	),
60 
61 	TP_printk("dev=%s queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x protocol=0x%04x ip_summed=%d len=%u data_len=%u network_offset=%d transport_offset_valid=%d transport_offset=%d tx_flags=%d gso_size=%d gso_segs=%d gso_type=%#x",
62 		  __get_str(name), __entry->queue_mapping, __entry->skbaddr,
63 		  __entry->vlan_tagged, __entry->vlan_proto, __entry->vlan_tci,
64 		  __entry->protocol, __entry->ip_summed, __entry->len,
65 		  __entry->data_len,
66 		  __entry->network_offset, __entry->transport_offset_valid,
67 		  __entry->transport_offset, __entry->tx_flags,
68 		  __entry->gso_size, __entry->gso_segs, __entry->gso_type)
69 );
70 
71 TRACE_EVENT(net_dev_xmit,
72 
73 	TP_PROTO(struct sk_buff *skb,
74 		 int rc,
75 		 struct net_device *dev,
76 		 unsigned int skb_len),
77 
78 	TP_ARGS(skb, rc, dev, skb_len),
79 
80 	TP_STRUCT__entry(
81 		__field(	void *,		skbaddr		)
82 		__field(	unsigned int,	len		)
83 		__field(	int,		rc		)
84 		__string(	name,		dev->name	)
85 	),
86 
87 	TP_fast_assign(
88 		__entry->skbaddr = skb;
89 		__entry->len = skb_len;
90 		__entry->rc = rc;
91 		__assign_str(name, dev->name);
92 	),
93 
94 	TP_printk("dev=%s skbaddr=%p len=%u rc=%d",
95 		__get_str(name), __entry->skbaddr, __entry->len, __entry->rc)
96 );
97 
98 TRACE_EVENT(net_dev_xmit_timeout,
99 
100 	TP_PROTO(struct net_device *dev,
101 		 int queue_index),
102 
103 	TP_ARGS(dev, queue_index),
104 
105 	TP_STRUCT__entry(
106 		__string(	name,		dev->name	)
107 		__string(	driver,		netdev_drivername(dev))
108 		__field(	int,		queue_index	)
109 	),
110 
111 	TP_fast_assign(
112 		__assign_str(name, dev->name);
113 		__assign_str(driver, netdev_drivername(dev));
114 		__entry->queue_index = queue_index;
115 	),
116 
117 	TP_printk("dev=%s driver=%s queue=%d",
118 		__get_str(name), __get_str(driver), __entry->queue_index)
119 );
120 
121 DECLARE_EVENT_CLASS(net_dev_template,
122 
123 	TP_PROTO(struct sk_buff *skb),
124 
125 	TP_ARGS(skb),
126 
127 	TP_STRUCT__entry(
128 		__field(	void *,		skbaddr		)
129 		__field(	unsigned int,	len		)
130 		__string(	name,		skb->dev->name	)
131 	),
132 
133 	TP_fast_assign(
134 		__entry->skbaddr = skb;
135 		__entry->len = skb->len;
136 		__assign_str(name, skb->dev->name);
137 	),
138 
139 	TP_printk("dev=%s skbaddr=%p len=%u",
140 		__get_str(name), __entry->skbaddr, __entry->len)
141 )
142 
143 DEFINE_EVENT(net_dev_template, net_dev_queue,
144 
145 	TP_PROTO(struct sk_buff *skb),
146 
147 	TP_ARGS(skb)
148 );
149 
150 DEFINE_EVENT(net_dev_template, netif_receive_skb,
151 
152 	TP_PROTO(struct sk_buff *skb),
153 
154 	TP_ARGS(skb)
155 );
156 
157 DEFINE_EVENT(net_dev_template, netif_rx,
158 
159 	TP_PROTO(struct sk_buff *skb),
160 
161 	TP_ARGS(skb)
162 );
163 
164 DECLARE_EVENT_CLASS(net_dev_rx_verbose_template,
165 
166 	TP_PROTO(const struct sk_buff *skb),
167 
168 	TP_ARGS(skb),
169 
170 	TP_STRUCT__entry(
171 		__string(	name,			skb->dev->name	)
172 		__field(	unsigned int,		napi_id		)
173 		__field(	u16,			queue_mapping	)
174 		__field(	const void *,		skbaddr		)
175 		__field(	bool,			vlan_tagged	)
176 		__field(	u16,			vlan_proto	)
177 		__field(	u16,			vlan_tci	)
178 		__field(	u16,			protocol	)
179 		__field(	u8,			ip_summed	)
180 		__field(	u32,			hash		)
181 		__field(	bool,			l4_hash		)
182 		__field(	unsigned int,		len		)
183 		__field(	unsigned int,		data_len	)
184 		__field(	unsigned int,		truesize	)
185 		__field(	bool,			mac_header_valid)
186 		__field(	int,			mac_header	)
187 		__field(	unsigned char,		nr_frags	)
188 		__field(	u16,			gso_size	)
189 		__field(	u16,			gso_type	)
190 	),
191 
192 	TP_fast_assign(
193 		__assign_str(name, skb->dev->name);
194 #ifdef CONFIG_NET_RX_BUSY_POLL
195 		__entry->napi_id = skb->napi_id;
196 #else
197 		__entry->napi_id = 0;
198 #endif
199 		__entry->queue_mapping = skb->queue_mapping;
200 		__entry->skbaddr = skb;
201 		__entry->vlan_tagged = skb_vlan_tag_present(skb);
202 		__entry->vlan_proto = ntohs(skb->vlan_proto);
203 		__entry->vlan_tci = skb_vlan_tag_get(skb);
204 		__entry->protocol = ntohs(skb->protocol);
205 		__entry->ip_summed = skb->ip_summed;
206 		__entry->hash = skb->hash;
207 		__entry->l4_hash = skb->l4_hash;
208 		__entry->len = skb->len;
209 		__entry->data_len = skb->data_len;
210 		__entry->truesize = skb->truesize;
211 		__entry->mac_header_valid = skb_mac_header_was_set(skb);
212 		__entry->mac_header = skb_mac_header(skb) - skb->data;
213 		__entry->nr_frags = skb_shinfo(skb)->nr_frags;
214 		__entry->gso_size = skb_shinfo(skb)->gso_size;
215 		__entry->gso_type = skb_shinfo(skb)->gso_type;
216 	),
217 
218 	TP_printk("dev=%s napi_id=%#x queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u data_len=%u truesize=%u mac_header_valid=%d mac_header=%d nr_frags=%d gso_size=%d gso_type=%#x",
219 		  __get_str(name), __entry->napi_id, __entry->queue_mapping,
220 		  __entry->skbaddr, __entry->vlan_tagged, __entry->vlan_proto,
221 		  __entry->vlan_tci, __entry->protocol, __entry->ip_summed,
222 		  __entry->hash, __entry->l4_hash, __entry->len,
223 		  __entry->data_len, __entry->truesize,
224 		  __entry->mac_header_valid, __entry->mac_header,
225 		  __entry->nr_frags, __entry->gso_size, __entry->gso_type)
226 );
227 
228 DEFINE_EVENT(net_dev_rx_verbose_template, napi_gro_frags_entry,
229 
230 	TP_PROTO(const struct sk_buff *skb),
231 
232 	TP_ARGS(skb)
233 );
234 
235 DEFINE_EVENT(net_dev_rx_verbose_template, napi_gro_receive_entry,
236 
237 	TP_PROTO(const struct sk_buff *skb),
238 
239 	TP_ARGS(skb)
240 );
241 
242 DEFINE_EVENT(net_dev_rx_verbose_template, netif_receive_skb_entry,
243 
244 	TP_PROTO(const struct sk_buff *skb),
245 
246 	TP_ARGS(skb)
247 );
248 
249 DEFINE_EVENT(net_dev_rx_verbose_template, netif_receive_skb_list_entry,
250 
251 	TP_PROTO(const struct sk_buff *skb),
252 
253 	TP_ARGS(skb)
254 );
255 
256 DEFINE_EVENT(net_dev_rx_verbose_template, netif_rx_entry,
257 
258 	TP_PROTO(const struct sk_buff *skb),
259 
260 	TP_ARGS(skb)
261 );
262 
263 DEFINE_EVENT(net_dev_rx_verbose_template, netif_rx_ni_entry,
264 
265 	TP_PROTO(const struct sk_buff *skb),
266 
267 	TP_ARGS(skb)
268 );
269 
270 DECLARE_EVENT_CLASS(net_dev_rx_exit_template,
271 
272 	TP_PROTO(int ret),
273 
274 	TP_ARGS(ret),
275 
276 	TP_STRUCT__entry(
277 		__field(int,	ret)
278 	),
279 
280 	TP_fast_assign(
281 		__entry->ret = ret;
282 	),
283 
284 	TP_printk("ret=%d", __entry->ret)
285 );
286 
287 DEFINE_EVENT(net_dev_rx_exit_template, napi_gro_frags_exit,
288 
289 	TP_PROTO(int ret),
290 
291 	TP_ARGS(ret)
292 );
293 
294 DEFINE_EVENT(net_dev_rx_exit_template, napi_gro_receive_exit,
295 
296 	TP_PROTO(int ret),
297 
298 	TP_ARGS(ret)
299 );
300 
301 DEFINE_EVENT(net_dev_rx_exit_template, netif_receive_skb_exit,
302 
303 	TP_PROTO(int ret),
304 
305 	TP_ARGS(ret)
306 );
307 
308 DEFINE_EVENT(net_dev_rx_exit_template, netif_rx_exit,
309 
310 	TP_PROTO(int ret),
311 
312 	TP_ARGS(ret)
313 );
314 
315 DEFINE_EVENT(net_dev_rx_exit_template, netif_rx_ni_exit,
316 
317 	TP_PROTO(int ret),
318 
319 	TP_ARGS(ret)
320 );
321 
322 DEFINE_EVENT(net_dev_rx_exit_template, netif_receive_skb_list_exit,
323 
324 	TP_PROTO(int ret),
325 
326 	TP_ARGS(ret)
327 );
328 
329 #endif /* _TRACE_NET_H */
330 
331 /* This part must be outside protection */
332 #include <trace/define_trace.h>
333