]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/trace/events/xdp.h
Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64...
[mirror_ubuntu-bionic-kernel.git] / include / trace / events / xdp.h
1 /* SPDX-License-Identifier: GPL-2.0 */
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) \
16 FN(TX) \
17 FN(REDIRECT)
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(
35 __field(int, prog_id)
36 __field(u32, act)
37 __field(int, ifindex)
38 ),
39
40 TP_fast_assign(
41 __entry->prog_id = xdp->aux->id;
42 __entry->act = act;
43 __entry->ifindex = dev->ifindex;
44 ),
45
46 TP_printk("prog_id=%d action=%s ifindex=%d",
47 __entry->prog_id,
48 __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
49 __entry->ifindex)
50 );
51
52 DECLARE_EVENT_CLASS(xdp_redirect_template,
53
54 TP_PROTO(const struct net_device *dev,
55 const struct bpf_prog *xdp,
56 int to_ifindex, int err,
57 const struct bpf_map *map, u32 map_index),
58
59 TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
60
61 TP_STRUCT__entry(
62 __field(int, prog_id)
63 __field(u32, act)
64 __field(int, ifindex)
65 __field(int, err)
66 __field(int, to_ifindex)
67 __field(u32, map_id)
68 __field(int, map_index)
69 ),
70
71 TP_fast_assign(
72 __entry->prog_id = xdp->aux->id;
73 __entry->act = XDP_REDIRECT;
74 __entry->ifindex = dev->ifindex;
75 __entry->err = err;
76 __entry->to_ifindex = to_ifindex;
77 __entry->map_id = map ? map->id : 0;
78 __entry->map_index = map_index;
79 ),
80
81 TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d",
82 __entry->prog_id,
83 __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
84 __entry->ifindex, __entry->to_ifindex,
85 __entry->err)
86 );
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
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
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, \
142 0, map, idx)
143
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, \
146 err, map, idx)
147
148 #endif /* _TRACE_XDP_H */
149
150 #include <trace/define_trace.h>