]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
a67edbf4 DB |
2 | #undef TRACE_SYSTEM |
3 | #define TRACE_SYSTEM xdp | |
4 | ||
5 | #if !defined(_TRACE_XDP_H) || defined(TRACE_HEADER_MULTI_READ) | |
6 | #define _TRACE_XDP_H | |
7 | ||
8 | #include <linux/netdevice.h> | |
9 | #include <linux/filter.h> | |
10 | #include <linux/tracepoint.h> | |
11 | ||
12 | #define __XDP_ACT_MAP(FN) \ | |
13 | FN(ABORTED) \ | |
14 | FN(DROP) \ | |
15 | FN(PASS) \ | |
5acaee0a JF |
16 | FN(TX) \ |
17 | FN(REDIRECT) | |
a67edbf4 DB |
18 | |
19 | #define __XDP_ACT_TP_FN(x) \ | |
20 | TRACE_DEFINE_ENUM(XDP_##x); | |
21 | #define __XDP_ACT_SYM_FN(x) \ | |
22 | { XDP_##x, #x }, | |
23 | #define __XDP_ACT_SYM_TAB \ | |
24 | __XDP_ACT_MAP(__XDP_ACT_SYM_FN) { -1, 0 } | |
25 | __XDP_ACT_MAP(__XDP_ACT_TP_FN) | |
26 | ||
27 | TRACE_EVENT(xdp_exception, | |
28 | ||
29 | TP_PROTO(const struct net_device *dev, | |
30 | const struct bpf_prog *xdp, u32 act), | |
31 | ||
32 | TP_ARGS(dev, xdp, act), | |
33 | ||
34 | TP_STRUCT__entry( | |
b06337df | 35 | __field(int, prog_id) |
a67edbf4 | 36 | __field(u32, act) |
315ec399 | 37 | __field(int, ifindex) |
a67edbf4 DB |
38 | ), |
39 | ||
40 | TP_fast_assign( | |
b06337df | 41 | __entry->prog_id = xdp->aux->id; |
315ec399 JDB |
42 | __entry->act = act; |
43 | __entry->ifindex = dev->ifindex; | |
a67edbf4 DB |
44 | ), |
45 | ||
b06337df JDB |
46 | TP_printk("prog_id=%d action=%s ifindex=%d", |
47 | __entry->prog_id, | |
315ec399 JDB |
48 | __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), |
49 | __entry->ifindex) | |
a67edbf4 DB |
50 | ); |
51 | ||
8d3b778f | 52 | DECLARE_EVENT_CLASS(xdp_redirect_template, |
5acaee0a | 53 | |
a8735855 | 54 | TP_PROTO(const struct net_device *dev, |
c31e5a48 | 55 | const struct bpf_prog *xdp, |
8d3b778f JDB |
56 | int to_ifindex, int err, |
57 | const struct bpf_map *map, u32 map_index), | |
5acaee0a | 58 | |
8d3b778f | 59 | TP_ARGS(dev, xdp, to_ifindex, err, map, map_index), |
5acaee0a JF |
60 | |
61 | TP_STRUCT__entry( | |
b06337df | 62 | __field(int, prog_id) |
5acaee0a | 63 | __field(u32, act) |
a8735855 | 64 | __field(int, ifindex) |
4c03bdd7 | 65 | __field(int, err) |
8d3b778f JDB |
66 | __field(int, to_ifindex) |
67 | __field(u32, map_id) | |
68 | __field(int, map_index) | |
5acaee0a JF |
69 | ), |
70 | ||
71 | TP_fast_assign( | |
b06337df | 72 | __entry->prog_id = xdp->aux->id; |
c31e5a48 | 73 | __entry->act = XDP_REDIRECT; |
a8735855 | 74 | __entry->ifindex = dev->ifindex; |
a8735855 | 75 | __entry->err = err; |
8d3b778f JDB |
76 | __entry->to_ifindex = to_ifindex; |
77 | __entry->map_id = map ? map->id : 0; | |
78 | __entry->map_index = map_index; | |
5acaee0a JF |
79 | ), |
80 | ||
59a30896 | 81 | TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d", |
b06337df | 82 | __entry->prog_id, |
4c03bdd7 | 83 | __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), |
8d3b778f | 84 | __entry->ifindex, __entry->to_ifindex, |
59a30896 | 85 | __entry->err) |
5acaee0a | 86 | ); |
8d3b778f JDB |
87 | |
88 | DEFINE_EVENT(xdp_redirect_template, xdp_redirect, | |
89 | TP_PROTO(const struct net_device *dev, | |
90 | const struct bpf_prog *xdp, | |
91 | int to_ifindex, int err, | |
92 | const struct bpf_map *map, u32 map_index), | |
93 | TP_ARGS(dev, xdp, to_ifindex, err, map, map_index) | |
94 | ); | |
95 | ||
f5836ca5 JDB |
96 | DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err, |
97 | TP_PROTO(const struct net_device *dev, | |
98 | const struct bpf_prog *xdp, | |
99 | int to_ifindex, int err, | |
100 | const struct bpf_map *map, u32 map_index), | |
101 | TP_ARGS(dev, xdp, to_ifindex, err, map, map_index) | |
102 | ); | |
103 | ||
104 | #define _trace_xdp_redirect(dev, xdp, to) \ | |
105 | trace_xdp_redirect(dev, xdp, to, 0, NULL, 0); | |
106 | ||
107 | #define _trace_xdp_redirect_err(dev, xdp, to, err) \ | |
108 | trace_xdp_redirect_err(dev, xdp, to, err, NULL, 0); | |
109 | ||
59a30896 JDB |
110 | DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map, |
111 | TP_PROTO(const struct net_device *dev, | |
112 | const struct bpf_prog *xdp, | |
113 | int to_ifindex, int err, | |
114 | const struct bpf_map *map, u32 map_index), | |
115 | TP_ARGS(dev, xdp, to_ifindex, err, map, map_index), | |
116 | TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d" | |
117 | " map_id=%d map_index=%d", | |
118 | __entry->prog_id, | |
119 | __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), | |
120 | __entry->ifindex, __entry->to_ifindex, | |
121 | __entry->err, | |
122 | __entry->map_id, __entry->map_index) | |
123 | ); | |
124 | ||
125 | DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map_err, | |
126 | TP_PROTO(const struct net_device *dev, | |
127 | const struct bpf_prog *xdp, | |
128 | int to_ifindex, int err, | |
129 | const struct bpf_map *map, u32 map_index), | |
130 | TP_ARGS(dev, xdp, to_ifindex, err, map, map_index), | |
131 | TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d" | |
132 | " map_id=%d map_index=%d", | |
133 | __entry->prog_id, | |
134 | __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), | |
135 | __entry->ifindex, __entry->to_ifindex, | |
136 | __entry->err, | |
137 | __entry->map_id, __entry->map_index) | |
138 | ); | |
139 | ||
140 | #define _trace_xdp_redirect_map(dev, xdp, fwd, map, idx) \ | |
141 | trace_xdp_redirect_map(dev, xdp, fwd ? fwd->ifindex : 0, \ | |
96c5508e | 142 | 0, map, idx) |
8d3b778f | 143 | |
59a30896 JDB |
144 | #define _trace_xdp_redirect_map_err(dev, xdp, fwd, map, idx, err) \ |
145 | trace_xdp_redirect_map_err(dev, xdp, fwd ? fwd->ifindex : 0, \ | |
96c5508e | 146 | err, map, idx) |
8d3b778f | 147 | |
a67edbf4 DB |
148 | #endif /* _TRACE_XDP_H */ |
149 | ||
150 | #include <trace/define_trace.h> |