2 #define TRACE_SYSTEM xdp
4 #if !defined(_TRACE_XDP_H) || defined(TRACE_HEADER_MULTI_READ)
7 #include <linux/netdevice.h>
8 #include <linux/filter.h>
9 #include <linux/tracepoint.h>
11 #define __XDP_ACT_MAP(FN) \
18 #define __XDP_ACT_TP_FN(x) \
19 TRACE_DEFINE_ENUM(XDP_##x);
20 #define __XDP_ACT_SYM_FN(x) \
22 #define __XDP_ACT_SYM_TAB \
23 __XDP_ACT_MAP(__XDP_ACT_SYM_FN) { -1, 0 }
24 __XDP_ACT_MAP(__XDP_ACT_TP_FN)
26 TRACE_EVENT(xdp_exception,
28 TP_PROTO(const struct net_device *dev,
29 const struct bpf_prog *xdp, u32 act),
31 TP_ARGS(dev, xdp, act),
40 __entry->prog_id = xdp->aux->id;
42 __entry->ifindex = dev->ifindex;
45 TP_printk("prog_id=%d action=%s ifindex=%d",
47 __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
51 DECLARE_EVENT_CLASS(xdp_redirect_template,
53 TP_PROTO(const struct net_device *dev,
54 const struct bpf_prog *xdp,
55 int to_ifindex, int err,
56 const struct bpf_map *map, u32 map_index),
58 TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
65 __field(int, to_ifindex)
67 __field(int, map_index)
71 __entry->prog_id = xdp->aux->id;
72 __entry->act = XDP_REDIRECT;
73 __entry->ifindex = dev->ifindex;
75 __entry->to_ifindex = to_ifindex;
76 __entry->map_id = map ? map->id : 0;
77 __entry->map_index = map_index;
80 TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d",
82 __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
83 __entry->ifindex, __entry->to_ifindex,
87 DEFINE_EVENT(xdp_redirect_template, xdp_redirect,
88 TP_PROTO(const struct net_device *dev,
89 const struct bpf_prog *xdp,
90 int to_ifindex, int err,
91 const struct bpf_map *map, u32 map_index),
92 TP_ARGS(dev, xdp, to_ifindex, err, map, map_index)
95 DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err,
96 TP_PROTO(const struct net_device *dev,
97 const struct bpf_prog *xdp,
98 int to_ifindex, int err,
99 const struct bpf_map *map, u32 map_index),
100 TP_ARGS(dev, xdp, to_ifindex, err, map, map_index)
103 #define _trace_xdp_redirect(dev, xdp, to) \
104 trace_xdp_redirect(dev, xdp, to, 0, NULL, 0);
106 #define _trace_xdp_redirect_err(dev, xdp, to, err) \
107 trace_xdp_redirect_err(dev, xdp, to, err, NULL, 0);
109 DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map,
110 TP_PROTO(const struct net_device *dev,
111 const struct bpf_prog *xdp,
112 int to_ifindex, int err,
113 const struct bpf_map *map, u32 map_index),
114 TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
115 TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d"
116 " map_id=%d map_index=%d",
118 __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
119 __entry->ifindex, __entry->to_ifindex,
121 __entry->map_id, __entry->map_index)
124 DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map_err,
125 TP_PROTO(const struct net_device *dev,
126 const struct bpf_prog *xdp,
127 int to_ifindex, int err,
128 const struct bpf_map *map, u32 map_index),
129 TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
130 TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d"
131 " map_id=%d map_index=%d",
133 __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
134 __entry->ifindex, __entry->to_ifindex,
136 __entry->map_id, __entry->map_index)
139 #define _trace_xdp_redirect_map(dev, xdp, fwd, map, idx) \
140 trace_xdp_redirect_map(dev, xdp, fwd ? fwd->ifindex : 0, \
143 #define _trace_xdp_redirect_map_err(dev, xdp, fwd, map, idx, err) \
144 trace_xdp_redirect_map_err(dev, xdp, fwd ? fwd->ifindex : 0, \
147 #endif /* _TRACE_XDP_H */
149 #include <trace/define_trace.h>