]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/trace/events/xdp.h
1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM xdp
5 #if !defined(_TRACE_XDP_H) || defined(TRACE_HEADER_MULTI_READ)
8 #include <linux/netdevice.h>
9 #include <linux/filter.h>
10 #include <linux/tracepoint.h>
12 #define __XDP_ACT_MAP(FN) \
19 #define __XDP_ACT_TP_FN(x) \
20 TRACE_DEFINE_ENUM(XDP_##x);
21 #define __XDP_ACT_SYM_FN(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
)
27 TRACE_EVENT(xdp_exception
,
29 TP_PROTO(const struct net_device
*dev
,
30 const struct bpf_prog
*xdp
, u32 act
),
32 TP_ARGS(dev
, xdp
, act
),
41 __entry
->prog_id
= xdp
->aux
->id
;
43 __entry
->ifindex
= dev
->ifindex
;
46 TP_printk("prog_id=%d action=%s ifindex=%d",
48 __print_symbolic(__entry
->act
, __XDP_ACT_SYM_TAB
),
52 DECLARE_EVENT_CLASS(xdp_redirect_template
,
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
),
59 TP_ARGS(dev
, xdp
, to_ifindex
, err
, map
, map_index
),
66 __field(int, to_ifindex
)
68 __field(int, map_index
)
72 __entry
->prog_id
= xdp
->aux
->id
;
73 __entry
->act
= XDP_REDIRECT
;
74 __entry
->ifindex
= dev
->ifindex
;
76 __entry
->to_ifindex
= to_ifindex
;
77 __entry
->map_id
= map
? map
->id
: 0;
78 __entry
->map_index
= map_index
;
81 TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d",
83 __print_symbolic(__entry
->act
, __XDP_ACT_SYM_TAB
),
84 __entry
->ifindex
, __entry
->to_ifindex
,
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
)
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
)
104 #define _trace_xdp_redirect(dev, xdp, to) \
105 trace_xdp_redirect(dev, xdp, to, 0, NULL, 0);
107 #define _trace_xdp_redirect_err(dev, xdp, to, err) \
108 trace_xdp_redirect_err(dev, xdp, to, err, NULL, 0);
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",
119 __print_symbolic(__entry
->act
, __XDP_ACT_SYM_TAB
),
120 __entry
->ifindex
, __entry
->to_ifindex
,
122 __entry
->map_id
, __entry
->map_index
)
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",
134 __print_symbolic(__entry
->act
, __XDP_ACT_SYM_TAB
),
135 __entry
->ifindex
, __entry
->to_ifindex
,
137 __entry
->map_id
, __entry
->map_index
)
140 #define devmap_ifindex(fwd, map) \
143 ((map->map_type == BPF_MAP_TYPE_DEVMAP) ? \
144 ((struct net_device *)fwd)->ifindex : 0)))
146 #define _trace_xdp_redirect_map(dev, xdp, fwd, map, idx) \
147 trace_xdp_redirect_map(dev, xdp, devmap_ifindex(fwd, map), \
150 #define _trace_xdp_redirect_map_err(dev, xdp, fwd, map, idx, err) \
151 trace_xdp_redirect_map_err(dev, xdp, devmap_ifindex(fwd, map), \
154 TRACE_EVENT(xdp_cpumap_kthread
,
156 TP_PROTO(int map_id
, unsigned int processed
, unsigned int drops
,
159 TP_ARGS(map_id
, processed
, drops
, sched
),
165 __field(unsigned int, drops
)
166 __field(unsigned int, processed
)
171 __entry
->map_id
= map_id
;
172 __entry
->act
= XDP_REDIRECT
;
173 __entry
->cpu
= smp_processor_id();
174 __entry
->drops
= drops
;
175 __entry
->processed
= processed
;
176 __entry
->sched
= sched
;
180 " cpu=%d map_id=%d action=%s"
181 " processed=%u drops=%u"
183 __entry
->cpu
, __entry
->map_id
,
184 __print_symbolic(__entry
->act
, __XDP_ACT_SYM_TAB
),
185 __entry
->processed
, __entry
->drops
,
189 TRACE_EVENT(xdp_cpumap_enqueue
,
191 TP_PROTO(int map_id
, unsigned int processed
, unsigned int drops
,
194 TP_ARGS(map_id
, processed
, drops
, to_cpu
),
200 __field(unsigned int, drops
)
201 __field(unsigned int, processed
)
206 __entry
->map_id
= map_id
;
207 __entry
->act
= XDP_REDIRECT
;
208 __entry
->cpu
= smp_processor_id();
209 __entry
->drops
= drops
;
210 __entry
->processed
= processed
;
211 __entry
->to_cpu
= to_cpu
;
215 " cpu=%d map_id=%d action=%s"
216 " processed=%u drops=%u"
218 __entry
->cpu
, __entry
->map_id
,
219 __print_symbolic(__entry
->act
, __XDP_ACT_SYM_TAB
),
220 __entry
->processed
, __entry
->drops
,
224 #endif /* _TRACE_XDP_H */
226 #include <trace/define_trace.h>