xref: /openbmc/linux/include/trace/events/skb.h (revision 14e5f71e31ff3925cc970fa7907393ee7f4b748d)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2d0b6e04aSLi Zefan #undef TRACE_SYSTEM
3d0b6e04aSLi Zefan #define TRACE_SYSTEM skb
4d0b6e04aSLi Zefan 
5ad8d75ffSSteven Rostedt #if !defined(_TRACE_SKB_H) || defined(TRACE_HEADER_MULTI_READ)
6ad8d75ffSSteven Rostedt #define _TRACE_SKB_H
7ad8d75ffSSteven Rostedt 
8ad8d75ffSSteven Rostedt #include <linux/skbuff.h>
9e9b3cc1bSNeil Horman #include <linux/netdevice.h>
10ad8d75ffSSteven Rostedt #include <linux/tracepoint.h>
11ad8d75ffSSteven Rostedt 
129cb252c4SMenglong Dong #undef FN
139cb252c4SMenglong Dong #define FN(reason)	TRACE_DEFINE_ENUM(SKB_DROP_REASON_##reason);
149cb252c4SMenglong Dong DEFINE_DROP_REASON(FN, FN)
159cb252c4SMenglong Dong 
169cb252c4SMenglong Dong #undef FN
179cb252c4SMenglong Dong #undef FNe
189cb252c4SMenglong Dong #define FN(reason)	{ SKB_DROP_REASON_##reason, #reason },
199cb252c4SMenglong Dong #define FNe(reason)	{ SKB_DROP_REASON_##reason, #reason }
209cb252c4SMenglong Dong 
21ad8d75ffSSteven Rostedt /*
22ad8d75ffSSteven Rostedt  * Tracepoint for free an sk_buff:
23ad8d75ffSSteven Rostedt  */
24ad8d75ffSSteven Rostedt TRACE_EVENT(kfree_skb,
25ad8d75ffSSteven Rostedt 
26c504e5c2SMenglong Dong 	TP_PROTO(struct sk_buff *skb, void *location,
27c504e5c2SMenglong Dong 		 enum skb_drop_reason reason),
28ad8d75ffSSteven Rostedt 
29c504e5c2SMenglong Dong 	TP_ARGS(skb, location, reason),
30ad8d75ffSSteven Rostedt 
31ad8d75ffSSteven Rostedt 	TP_STRUCT__entry(
32ad8d75ffSSteven Rostedt 		__field(void *,		skbaddr)
33ad8d75ffSSteven Rostedt 		__field(void *,		location)
34ca9da2ddSDavid Sharp 		__field(unsigned short,	protocol)
35c504e5c2SMenglong Dong 		__field(enum skb_drop_reason,	reason)
36ad8d75ffSSteven Rostedt 	),
37ad8d75ffSSteven Rostedt 
38ad8d75ffSSteven Rostedt 	TP_fast_assign(
39ad8d75ffSSteven Rostedt 		__entry->skbaddr = skb;
40ad8d75ffSSteven Rostedt 		__entry->location = location;
41ca9da2ddSDavid Sharp 		__entry->protocol = ntohs(skb->protocol);
42c504e5c2SMenglong Dong 		__entry->reason = reason;
43ad8d75ffSSteven Rostedt 	),
44ad8d75ffSSteven Rostedt 
45*14e5f71eSStanislav Fomichev 	TP_printk("skbaddr=%p protocol=%u location=%pS reason: %s",
46c504e5c2SMenglong Dong 		  __entry->skbaddr, __entry->protocol, __entry->location,
479cb252c4SMenglong Dong 		  __print_symbolic(__entry->reason,
489cb252c4SMenglong Dong 				   DEFINE_DROP_REASON(FN, FNe)))
49ad8d75ffSSteven Rostedt );
50ad8d75ffSSteven Rostedt 
519cb252c4SMenglong Dong #undef FN
529cb252c4SMenglong Dong #undef FNe
539cb252c4SMenglong Dong 
5407dc22e7SKoki Sanagi TRACE_EVENT(consume_skb,
5507dc22e7SKoki Sanagi 
5607dc22e7SKoki Sanagi 	TP_PROTO(struct sk_buff *skb),
5707dc22e7SKoki Sanagi 
5807dc22e7SKoki Sanagi 	TP_ARGS(skb),
5907dc22e7SKoki Sanagi 
6007dc22e7SKoki Sanagi 	TP_STRUCT__entry(
6107dc22e7SKoki Sanagi 		__field(	void *,	skbaddr	)
6207dc22e7SKoki Sanagi 	),
6307dc22e7SKoki Sanagi 
6407dc22e7SKoki Sanagi 	TP_fast_assign(
6507dc22e7SKoki Sanagi 		__entry->skbaddr = skb;
6607dc22e7SKoki Sanagi 	),
6707dc22e7SKoki Sanagi 
6807dc22e7SKoki Sanagi 	TP_printk("skbaddr=%p", __entry->skbaddr)
6907dc22e7SKoki Sanagi );
7007dc22e7SKoki Sanagi 
71e9b3cc1bSNeil Horman TRACE_EVENT(skb_copy_datagram_iovec,
72e9b3cc1bSNeil Horman 
73e9b3cc1bSNeil Horman 	TP_PROTO(const struct sk_buff *skb, int len),
74e9b3cc1bSNeil Horman 
75e9b3cc1bSNeil Horman 	TP_ARGS(skb, len),
76e9b3cc1bSNeil Horman 
77e9b3cc1bSNeil Horman 	TP_STRUCT__entry(
78e9b3cc1bSNeil Horman 		__field(	const void *,		skbaddr		)
79e9b3cc1bSNeil Horman 		__field(	int,			len		)
80e9b3cc1bSNeil Horman 	),
81e9b3cc1bSNeil Horman 
82e9b3cc1bSNeil Horman 	TP_fast_assign(
83e9b3cc1bSNeil Horman 		__entry->skbaddr = skb;
84e9b3cc1bSNeil Horman 		__entry->len = len;
85e9b3cc1bSNeil Horman 	),
86e9b3cc1bSNeil Horman 
87e9b3cc1bSNeil Horman 	TP_printk("skbaddr=%p len=%d", __entry->skbaddr, __entry->len)
88e9b3cc1bSNeil Horman );
89e9b3cc1bSNeil Horman 
90ad8d75ffSSteven Rostedt #endif /* _TRACE_SKB_H */
91ad8d75ffSSteven Rostedt 
92ad8d75ffSSteven Rostedt /* This part must be outside protection */
93ad8d75ffSSteven Rostedt #include <trace/define_trace.h>
94