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 4514e5f71eSStanislav 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 56*dd1b5278SEric Dumazet TP_PROTO(struct sk_buff *skb, void *location), 5707dc22e7SKoki Sanagi 58*dd1b5278SEric Dumazet TP_ARGS(skb, location), 5907dc22e7SKoki Sanagi 6007dc22e7SKoki Sanagi TP_STRUCT__entry( 6107dc22e7SKoki Sanagi __field( void *, skbaddr) 62*dd1b5278SEric Dumazet __field( void *, location) 6307dc22e7SKoki Sanagi ), 6407dc22e7SKoki Sanagi 6507dc22e7SKoki Sanagi TP_fast_assign( 6607dc22e7SKoki Sanagi __entry->skbaddr = skb; 67*dd1b5278SEric Dumazet __entry->location = location; 6807dc22e7SKoki Sanagi ), 6907dc22e7SKoki Sanagi 70*dd1b5278SEric Dumazet TP_printk("skbaddr=%p location=%pS", __entry->skbaddr, __entry->location) 7107dc22e7SKoki Sanagi ); 7207dc22e7SKoki Sanagi 73e9b3cc1bSNeil Horman TRACE_EVENT(skb_copy_datagram_iovec, 74e9b3cc1bSNeil Horman 75e9b3cc1bSNeil Horman TP_PROTO(const struct sk_buff *skb, int len), 76e9b3cc1bSNeil Horman 77e9b3cc1bSNeil Horman TP_ARGS(skb, len), 78e9b3cc1bSNeil Horman 79e9b3cc1bSNeil Horman TP_STRUCT__entry( 80e9b3cc1bSNeil Horman __field( const void *, skbaddr ) 81e9b3cc1bSNeil Horman __field( int, len ) 82e9b3cc1bSNeil Horman ), 83e9b3cc1bSNeil Horman 84e9b3cc1bSNeil Horman TP_fast_assign( 85e9b3cc1bSNeil Horman __entry->skbaddr = skb; 86e9b3cc1bSNeil Horman __entry->len = len; 87e9b3cc1bSNeil Horman ), 88e9b3cc1bSNeil Horman 89e9b3cc1bSNeil Horman TP_printk("skbaddr=%p len=%d", __entry->skbaddr, __entry->len) 90e9b3cc1bSNeil Horman ); 91e9b3cc1bSNeil Horman 92ad8d75ffSSteven Rostedt #endif /* _TRACE_SKB_H */ 93ad8d75ffSSteven Rostedt 94ad8d75ffSSteven Rostedt /* This part must be outside protection */ 95ad8d75ffSSteven Rostedt #include <trace/define_trace.h> 96