xref: /openbmc/linux/include/trace/events/xdp.h (revision bf4ea1d0b2cb2251f9e5619c81daa98591087c33)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2a67edbf4SDaniel Borkmann #undef TRACE_SYSTEM
3a67edbf4SDaniel Borkmann #define TRACE_SYSTEM xdp
4a67edbf4SDaniel Borkmann 
5a67edbf4SDaniel Borkmann #if !defined(_TRACE_XDP_H) || defined(TRACE_HEADER_MULTI_READ)
6a67edbf4SDaniel Borkmann #define _TRACE_XDP_H
7a67edbf4SDaniel Borkmann 
8a67edbf4SDaniel Borkmann #include <linux/netdevice.h>
9a67edbf4SDaniel Borkmann #include <linux/filter.h>
10a67edbf4SDaniel Borkmann #include <linux/tracepoint.h>
1123721a75SXie XiuQi #include <linux/bpf.h>
12a67edbf4SDaniel Borkmann 
13a67edbf4SDaniel Borkmann #define __XDP_ACT_MAP(FN)	\
14a67edbf4SDaniel Borkmann 	FN(ABORTED)		\
15a67edbf4SDaniel Borkmann 	FN(DROP)		\
16a67edbf4SDaniel Borkmann 	FN(PASS)		\
175acaee0aSJohn Fastabend 	FN(TX)			\
185acaee0aSJohn Fastabend 	FN(REDIRECT)
19a67edbf4SDaniel Borkmann 
20a67edbf4SDaniel Borkmann #define __XDP_ACT_TP_FN(x)	\
21a67edbf4SDaniel Borkmann 	TRACE_DEFINE_ENUM(XDP_##x);
22a67edbf4SDaniel Borkmann #define __XDP_ACT_SYM_FN(x)	\
23a67edbf4SDaniel Borkmann 	{ XDP_##x, #x },
24a67edbf4SDaniel Borkmann #define __XDP_ACT_SYM_TAB	\
255e5b03d1SBen Dooks (Codethink) 	__XDP_ACT_MAP(__XDP_ACT_SYM_FN) { -1, NULL }
26a67edbf4SDaniel Borkmann __XDP_ACT_MAP(__XDP_ACT_TP_FN)
27a67edbf4SDaniel Borkmann 
28a67edbf4SDaniel Borkmann TRACE_EVENT(xdp_exception,
29a67edbf4SDaniel Borkmann 
30a67edbf4SDaniel Borkmann 	TP_PROTO(const struct net_device *dev,
31a67edbf4SDaniel Borkmann 		 const struct bpf_prog *xdp, u32 act),
32a67edbf4SDaniel Borkmann 
33a67edbf4SDaniel Borkmann 	TP_ARGS(dev, xdp, act),
34a67edbf4SDaniel Borkmann 
35a67edbf4SDaniel Borkmann 	TP_STRUCT__entry(
36b06337dfSJesper Dangaard Brouer 		__field(int, prog_id)
37a67edbf4SDaniel Borkmann 		__field(u32, act)
38315ec399SJesper Dangaard Brouer 		__field(int, ifindex)
39a67edbf4SDaniel Borkmann 	),
40a67edbf4SDaniel Borkmann 
41a67edbf4SDaniel Borkmann 	TP_fast_assign(
42b06337dfSJesper Dangaard Brouer 		__entry->prog_id	= xdp->aux->id;
43a67edbf4SDaniel Borkmann 		__entry->act		= act;
44315ec399SJesper Dangaard Brouer 		__entry->ifindex	= dev->ifindex;
45a67edbf4SDaniel Borkmann 	),
46a67edbf4SDaniel Borkmann 
47b06337dfSJesper Dangaard Brouer 	TP_printk("prog_id=%d action=%s ifindex=%d",
48b06337dfSJesper Dangaard Brouer 		  __entry->prog_id,
49315ec399SJesper Dangaard Brouer 		  __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
50315ec399SJesper Dangaard Brouer 		  __entry->ifindex)
51a67edbf4SDaniel Borkmann );
52a67edbf4SDaniel Borkmann 
53e7d47989SToshiaki Makita TRACE_EVENT(xdp_bulk_tx,
54e7d47989SToshiaki Makita 
55e7d47989SToshiaki Makita 	TP_PROTO(const struct net_device *dev,
56e7d47989SToshiaki Makita 		 int sent, int drops, int err),
57e7d47989SToshiaki Makita 
58e7d47989SToshiaki Makita 	TP_ARGS(dev, sent, drops, err),
59e7d47989SToshiaki Makita 
60e7d47989SToshiaki Makita 	TP_STRUCT__entry(
61e7d47989SToshiaki Makita 		__field(int, ifindex)
62e7d47989SToshiaki Makita 		__field(u32, act)
63e7d47989SToshiaki Makita 		__field(int, drops)
64e7d47989SToshiaki Makita 		__field(int, sent)
65e7d47989SToshiaki Makita 		__field(int, err)
66e7d47989SToshiaki Makita 	),
67e7d47989SToshiaki Makita 
68e7d47989SToshiaki Makita 	TP_fast_assign(
69e7d47989SToshiaki Makita 		__entry->ifindex	= dev->ifindex;
70e7d47989SToshiaki Makita 		__entry->act		= XDP_TX;
71e7d47989SToshiaki Makita 		__entry->drops		= drops;
72e7d47989SToshiaki Makita 		__entry->sent		= sent;
73e7d47989SToshiaki Makita 		__entry->err		= err;
74e7d47989SToshiaki Makita 	),
75e7d47989SToshiaki Makita 
76e7d47989SToshiaki Makita 	TP_printk("ifindex=%d action=%s sent=%d drops=%d err=%d",
77e7d47989SToshiaki Makita 		  __entry->ifindex,
78e7d47989SToshiaki Makita 		  __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
79e7d47989SToshiaki Makita 		  __entry->sent, __entry->drops, __entry->err)
80e7d47989SToshiaki Makita );
81e7d47989SToshiaki Makita 
821d233886SToke Høiland-Jørgensen #ifndef __DEVMAP_OBJ_TYPE
831d233886SToke Høiland-Jørgensen #define __DEVMAP_OBJ_TYPE
841d233886SToke Høiland-Jørgensen struct _bpf_dtab_netdev {
851d233886SToke Høiland-Jørgensen 	struct net_device *dev;
861d233886SToke Høiland-Jørgensen };
871d233886SToke Høiland-Jørgensen #endif /* __DEVMAP_OBJ_TYPE */
881d233886SToke Høiland-Jørgensen 
898d3b778fSJesper Dangaard Brouer DECLARE_EVENT_CLASS(xdp_redirect_template,
905acaee0aSJohn Fastabend 
91a8735855SJesper Dangaard Brouer 	TP_PROTO(const struct net_device *dev,
92c31e5a48SJesper Dangaard Brouer 		 const struct bpf_prog *xdp,
931d233886SToke Høiland-Jørgensen 		 const void *tgt, int err,
94ee75aef2SBjörn Töpel 		 enum bpf_map_type map_type,
95ee75aef2SBjörn Töpel 		 u32 map_id, u32 index),
965acaee0aSJohn Fastabend 
97ee75aef2SBjörn Töpel 	TP_ARGS(dev, xdp, tgt, err, map_type, map_id, index),
985acaee0aSJohn Fastabend 
995acaee0aSJohn Fastabend 	TP_STRUCT__entry(
100b06337dfSJesper Dangaard Brouer 		__field(int, prog_id)
1015acaee0aSJohn Fastabend 		__field(u32, act)
102a8735855SJesper Dangaard Brouer 		__field(int, ifindex)
1034c03bdd7SJesper Dangaard Brouer 		__field(int, err)
1048d3b778fSJesper Dangaard Brouer 		__field(int, to_ifindex)
1058d3b778fSJesper Dangaard Brouer 		__field(u32, map_id)
1068d3b778fSJesper Dangaard Brouer 		__field(int, map_index)
1075acaee0aSJohn Fastabend 	),
1085acaee0aSJohn Fastabend 
1095acaee0aSJohn Fastabend 	TP_fast_assign(
110ee75aef2SBjörn Töpel 		u32 ifindex = 0, map_index = index;
111ee75aef2SBjörn Töpel 
112ee75aef2SBjörn Töpel 		if (map_type == BPF_MAP_TYPE_DEVMAP || map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
113e624d4edSHangbin Liu 			/* Just leave to_ifindex to 0 if do broadcast redirect,
114e624d4edSHangbin Liu 			 * as tgt will be NULL.
115e624d4edSHangbin Liu 			 */
116e624d4edSHangbin Liu 			if (tgt)
117ee75aef2SBjörn Töpel 				ifindex = ((struct _bpf_dtab_netdev *)tgt)->dev->ifindex;
118ee75aef2SBjörn Töpel 		} else if (map_type == BPF_MAP_TYPE_UNSPEC && map_id == INT_MAX) {
119ee75aef2SBjörn Töpel 			ifindex = index;
120ee75aef2SBjörn Töpel 			map_index = 0;
121ee75aef2SBjörn Töpel 		}
122ee75aef2SBjörn Töpel 
123b06337dfSJesper Dangaard Brouer 		__entry->prog_id	= xdp->aux->id;
124c31e5a48SJesper Dangaard Brouer 		__entry->act		= XDP_REDIRECT;
125a8735855SJesper Dangaard Brouer 		__entry->ifindex	= dev->ifindex;
1264c03bdd7SJesper Dangaard Brouer 		__entry->err		= err;
127ee75aef2SBjörn Töpel 		__entry->to_ifindex	= ifindex;
128ee75aef2SBjörn Töpel 		__entry->map_id		= map_id;
129ee75aef2SBjörn Töpel 		__entry->map_index	= map_index;
1305acaee0aSJohn Fastabend 	),
1315acaee0aSJohn Fastabend 
1321d233886SToke Høiland-Jørgensen 	TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d"
1331d233886SToke Høiland-Jørgensen 		  " map_id=%d map_index=%d",
134b06337dfSJesper Dangaard Brouer 		  __entry->prog_id,
1354c03bdd7SJesper Dangaard Brouer 		  __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
1368d3b778fSJesper Dangaard Brouer 		  __entry->ifindex, __entry->to_ifindex,
1371d233886SToke Høiland-Jørgensen 		  __entry->err, __entry->map_id, __entry->map_index)
1385acaee0aSJohn Fastabend );
1398d3b778fSJesper Dangaard Brouer 
1408d3b778fSJesper Dangaard Brouer DEFINE_EVENT(xdp_redirect_template, xdp_redirect,
1418d3b778fSJesper Dangaard Brouer 	TP_PROTO(const struct net_device *dev,
1428d3b778fSJesper Dangaard Brouer 		 const struct bpf_prog *xdp,
1431d233886SToke Høiland-Jørgensen 		 const void *tgt, int err,
144ee75aef2SBjörn Töpel 		 enum bpf_map_type map_type,
145ee75aef2SBjörn Töpel 		 u32 map_id, u32 index),
146ee75aef2SBjörn Töpel 	TP_ARGS(dev, xdp, tgt, err, map_type, map_id, index)
1478d3b778fSJesper Dangaard Brouer );
1488d3b778fSJesper Dangaard Brouer 
149f5836ca5SJesper Dangaard Brouer DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err,
150f5836ca5SJesper Dangaard Brouer 	TP_PROTO(const struct net_device *dev,
151f5836ca5SJesper Dangaard Brouer 		 const struct bpf_prog *xdp,
1521d233886SToke Høiland-Jørgensen 		 const void *tgt, int err,
153ee75aef2SBjörn Töpel 		 enum bpf_map_type map_type,
154ee75aef2SBjörn Töpel 		 u32 map_id, u32 index),
155ee75aef2SBjörn Töpel 	TP_ARGS(dev, xdp, tgt, err, map_type, map_id, index)
156f5836ca5SJesper Dangaard Brouer );
1578d3b778fSJesper Dangaard Brouer 
158f5836ca5SJesper Dangaard Brouer #define _trace_xdp_redirect(dev, xdp, to)						\
159ee75aef2SBjörn Töpel 	 trace_xdp_redirect(dev, xdp, NULL, 0, BPF_MAP_TYPE_UNSPEC, INT_MAX, to)
160f5836ca5SJesper Dangaard Brouer 
161f5836ca5SJesper Dangaard Brouer #define _trace_xdp_redirect_err(dev, xdp, to, err)					\
162ee75aef2SBjörn Töpel 	 trace_xdp_redirect_err(dev, xdp, NULL, err, BPF_MAP_TYPE_UNSPEC, INT_MAX, to)
163f5836ca5SJesper Dangaard Brouer 
164ee75aef2SBjörn Töpel #define _trace_xdp_redirect_map(dev, xdp, to, map_type, map_id, index) \
165ee75aef2SBjörn Töpel 	 trace_xdp_redirect(dev, xdp, to, 0, map_type, map_id, index)
1661d233886SToke Høiland-Jørgensen 
167ee75aef2SBjörn Töpel #define _trace_xdp_redirect_map_err(dev, xdp, to, map_type, map_id, index, err) \
168ee75aef2SBjörn Töpel 	 trace_xdp_redirect_err(dev, xdp, to, err, map_type, map_id, index)
1691d233886SToke Høiland-Jørgensen 
1701d233886SToke Høiland-Jørgensen /* not used anymore, but kept around so as not to break old programs */
1711d233886SToke Høiland-Jørgensen DEFINE_EVENT(xdp_redirect_template, xdp_redirect_map,
17259a30896SJesper Dangaard Brouer 	TP_PROTO(const struct net_device *dev,
17359a30896SJesper Dangaard Brouer 		 const struct bpf_prog *xdp,
1741d233886SToke Høiland-Jørgensen 		 const void *tgt, int err,
175ee75aef2SBjörn Töpel 		 enum bpf_map_type map_type,
176ee75aef2SBjörn Töpel 		 u32 map_id, u32 index),
177ee75aef2SBjörn Töpel 	TP_ARGS(dev, xdp, tgt, err, map_type, map_id, index)
17859a30896SJesper Dangaard Brouer );
179f5836ca5SJesper Dangaard Brouer 
1801d233886SToke Høiland-Jørgensen DEFINE_EVENT(xdp_redirect_template, xdp_redirect_map_err,
18159a30896SJesper Dangaard Brouer 	TP_PROTO(const struct net_device *dev,
18259a30896SJesper Dangaard Brouer 		 const struct bpf_prog *xdp,
1831d233886SToke Høiland-Jørgensen 		 const void *tgt, int err,
184ee75aef2SBjörn Töpel 		 enum bpf_map_type map_type,
185ee75aef2SBjörn Töpel 		 u32 map_id, u32 index),
186ee75aef2SBjörn Töpel 	TP_ARGS(dev, xdp, tgt, err, map_type, map_id, index)
18759a30896SJesper Dangaard Brouer );
18859a30896SJesper Dangaard Brouer 
189f9419f7bSJesper Dangaard Brouer TRACE_EVENT(xdp_cpumap_kthread,
190f9419f7bSJesper Dangaard Brouer 
191f9419f7bSJesper Dangaard Brouer 	TP_PROTO(int map_id, unsigned int processed,  unsigned int drops,
19292164774SLorenzo Bianconi 		 int sched, struct xdp_cpumap_stats *xdp_stats),
193f9419f7bSJesper Dangaard Brouer 
19492164774SLorenzo Bianconi 	TP_ARGS(map_id, processed, drops, sched, xdp_stats),
195f9419f7bSJesper Dangaard Brouer 
196f9419f7bSJesper Dangaard Brouer 	TP_STRUCT__entry(
197f9419f7bSJesper Dangaard Brouer 		__field(int, map_id)
198f9419f7bSJesper Dangaard Brouer 		__field(u32, act)
199f9419f7bSJesper Dangaard Brouer 		__field(int, cpu)
200f9419f7bSJesper Dangaard Brouer 		__field(unsigned int, drops)
201f9419f7bSJesper Dangaard Brouer 		__field(unsigned int, processed)
202f9419f7bSJesper Dangaard Brouer 		__field(int, sched)
20392164774SLorenzo Bianconi 		__field(unsigned int, xdp_pass)
20492164774SLorenzo Bianconi 		__field(unsigned int, xdp_drop)
20528b1520eSLorenzo Bianconi 		__field(unsigned int, xdp_redirect)
206f9419f7bSJesper Dangaard Brouer 	),
207f9419f7bSJesper Dangaard Brouer 
208f9419f7bSJesper Dangaard Brouer 	TP_fast_assign(
209f9419f7bSJesper Dangaard Brouer 		__entry->map_id		= map_id;
210f9419f7bSJesper Dangaard Brouer 		__entry->act		= XDP_REDIRECT;
211f9419f7bSJesper Dangaard Brouer 		__entry->cpu		= smp_processor_id();
212f9419f7bSJesper Dangaard Brouer 		__entry->drops		= drops;
213f9419f7bSJesper Dangaard Brouer 		__entry->processed	= processed;
214f9419f7bSJesper Dangaard Brouer 		__entry->sched	= sched;
21592164774SLorenzo Bianconi 		__entry->xdp_pass	= xdp_stats->pass;
21692164774SLorenzo Bianconi 		__entry->xdp_drop	= xdp_stats->drop;
21728b1520eSLorenzo Bianconi 		__entry->xdp_redirect	= xdp_stats->redirect;
218f9419f7bSJesper Dangaard Brouer 	),
219f9419f7bSJesper Dangaard Brouer 
220f9419f7bSJesper Dangaard Brouer 	TP_printk("kthread"
221f9419f7bSJesper Dangaard Brouer 		  " cpu=%d map_id=%d action=%s"
222f9419f7bSJesper Dangaard Brouer 		  " processed=%u drops=%u"
22392164774SLorenzo Bianconi 		  " sched=%d"
22428b1520eSLorenzo Bianconi 		  " xdp_pass=%u xdp_drop=%u xdp_redirect=%u",
225f9419f7bSJesper Dangaard Brouer 		  __entry->cpu, __entry->map_id,
226f9419f7bSJesper Dangaard Brouer 		  __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
227f9419f7bSJesper Dangaard Brouer 		  __entry->processed, __entry->drops,
22892164774SLorenzo Bianconi 		  __entry->sched,
22928b1520eSLorenzo Bianconi 		  __entry->xdp_pass, __entry->xdp_drop, __entry->xdp_redirect)
230f9419f7bSJesper Dangaard Brouer );
231f9419f7bSJesper Dangaard Brouer 
232f9419f7bSJesper Dangaard Brouer TRACE_EVENT(xdp_cpumap_enqueue,
233f9419f7bSJesper Dangaard Brouer 
234f9419f7bSJesper Dangaard Brouer 	TP_PROTO(int map_id, unsigned int processed,  unsigned int drops,
235f9419f7bSJesper Dangaard Brouer 		 int to_cpu),
236f9419f7bSJesper Dangaard Brouer 
237f9419f7bSJesper Dangaard Brouer 	TP_ARGS(map_id, processed, drops, to_cpu),
238f9419f7bSJesper Dangaard Brouer 
239f9419f7bSJesper Dangaard Brouer 	TP_STRUCT__entry(
240f9419f7bSJesper Dangaard Brouer 		__field(int, map_id)
241f9419f7bSJesper Dangaard Brouer 		__field(u32, act)
242f9419f7bSJesper Dangaard Brouer 		__field(int, cpu)
243f9419f7bSJesper Dangaard Brouer 		__field(unsigned int, drops)
244f9419f7bSJesper Dangaard Brouer 		__field(unsigned int, processed)
245f9419f7bSJesper Dangaard Brouer 		__field(int, to_cpu)
246f9419f7bSJesper Dangaard Brouer 	),
247f9419f7bSJesper Dangaard Brouer 
248f9419f7bSJesper Dangaard Brouer 	TP_fast_assign(
249f9419f7bSJesper Dangaard Brouer 		__entry->map_id		= map_id;
250f9419f7bSJesper Dangaard Brouer 		__entry->act		= XDP_REDIRECT;
251f9419f7bSJesper Dangaard Brouer 		__entry->cpu		= smp_processor_id();
252f9419f7bSJesper Dangaard Brouer 		__entry->drops		= drops;
253f9419f7bSJesper Dangaard Brouer 		__entry->processed	= processed;
254f9419f7bSJesper Dangaard Brouer 		__entry->to_cpu		= to_cpu;
255f9419f7bSJesper Dangaard Brouer 	),
256f9419f7bSJesper Dangaard Brouer 
257f9419f7bSJesper Dangaard Brouer 	TP_printk("enqueue"
258f9419f7bSJesper Dangaard Brouer 		  " cpu=%d map_id=%d action=%s"
259f9419f7bSJesper Dangaard Brouer 		  " processed=%u drops=%u"
260f9419f7bSJesper Dangaard Brouer 		  " to_cpu=%d",
261f9419f7bSJesper Dangaard Brouer 		  __entry->cpu, __entry->map_id,
262f9419f7bSJesper Dangaard Brouer 		  __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
263f9419f7bSJesper Dangaard Brouer 		  __entry->processed, __entry->drops,
264f9419f7bSJesper Dangaard Brouer 		  __entry->to_cpu)
265f9419f7bSJesper Dangaard Brouer );
266f9419f7bSJesper Dangaard Brouer 
26738edddb8SJesper Dangaard Brouer TRACE_EVENT(xdp_devmap_xmit,
26838edddb8SJesper Dangaard Brouer 
26958aa94f9SJesper Dangaard Brouer 	TP_PROTO(const struct net_device *from_dev,
27058aa94f9SJesper Dangaard Brouer 		 const struct net_device *to_dev,
27158aa94f9SJesper Dangaard Brouer 		 int sent, int drops, int err),
27238edddb8SJesper Dangaard Brouer 
27358aa94f9SJesper Dangaard Brouer 	TP_ARGS(from_dev, to_dev, sent, drops, err),
27438edddb8SJesper Dangaard Brouer 
27538edddb8SJesper Dangaard Brouer 	TP_STRUCT__entry(
27658aa94f9SJesper Dangaard Brouer 		__field(int, from_ifindex)
27738edddb8SJesper Dangaard Brouer 		__field(u32, act)
27858aa94f9SJesper Dangaard Brouer 		__field(int, to_ifindex)
27938edddb8SJesper Dangaard Brouer 		__field(int, drops)
28038edddb8SJesper Dangaard Brouer 		__field(int, sent)
281e74de52eSJesper Dangaard Brouer 		__field(int, err)
28238edddb8SJesper Dangaard Brouer 	),
28338edddb8SJesper Dangaard Brouer 
28438edddb8SJesper Dangaard Brouer 	TP_fast_assign(
28558aa94f9SJesper Dangaard Brouer 		__entry->from_ifindex	= from_dev->ifindex;
28638edddb8SJesper Dangaard Brouer 		__entry->act		= XDP_REDIRECT;
28758aa94f9SJesper Dangaard Brouer 		__entry->to_ifindex	= to_dev->ifindex;
28838edddb8SJesper Dangaard Brouer 		__entry->drops		= drops;
28938edddb8SJesper Dangaard Brouer 		__entry->sent		= sent;
290e74de52eSJesper Dangaard Brouer 		__entry->err		= err;
29138edddb8SJesper Dangaard Brouer 	),
29238edddb8SJesper Dangaard Brouer 
29338edddb8SJesper Dangaard Brouer 	TP_printk("ndo_xdp_xmit"
29458aa94f9SJesper Dangaard Brouer 		  " from_ifindex=%d to_ifindex=%d action=%s"
29538edddb8SJesper Dangaard Brouer 		  " sent=%d drops=%d"
29658aa94f9SJesper Dangaard Brouer 		  " err=%d",
29758aa94f9SJesper Dangaard Brouer 		  __entry->from_ifindex, __entry->to_ifindex,
29838edddb8SJesper Dangaard Brouer 		  __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
29938edddb8SJesper Dangaard Brouer 		  __entry->sent, __entry->drops,
30058aa94f9SJesper Dangaard Brouer 		  __entry->err)
30138edddb8SJesper Dangaard Brouer );
30238edddb8SJesper Dangaard Brouer 
303f033b688SJesper Dangaard Brouer /* Expect users already include <net/xdp.h>, but not xdp_priv.h */
304f033b688SJesper Dangaard Brouer #include <net/xdp_priv.h>
305f033b688SJesper Dangaard Brouer 
306f033b688SJesper Dangaard Brouer #define __MEM_TYPE_MAP(FN)	\
307f033b688SJesper Dangaard Brouer 	FN(PAGE_SHARED)		\
308f033b688SJesper Dangaard Brouer 	FN(PAGE_ORDER0)		\
309f033b688SJesper Dangaard Brouer 	FN(PAGE_POOL)		\
3102b43470aSBjörn Töpel 	FN(XSK_BUFF_POOL)
311f033b688SJesper Dangaard Brouer 
312f033b688SJesper Dangaard Brouer #define __MEM_TYPE_TP_FN(x)	\
313f033b688SJesper Dangaard Brouer 	TRACE_DEFINE_ENUM(MEM_TYPE_##x);
314f033b688SJesper Dangaard Brouer #define __MEM_TYPE_SYM_FN(x)	\
315f033b688SJesper Dangaard Brouer 	{ MEM_TYPE_##x, #x },
316f033b688SJesper Dangaard Brouer #define __MEM_TYPE_SYM_TAB	\
317f033b688SJesper Dangaard Brouer 	__MEM_TYPE_MAP(__MEM_TYPE_SYM_FN) { -1, 0 }
318f033b688SJesper Dangaard Brouer __MEM_TYPE_MAP(__MEM_TYPE_TP_FN)
319f033b688SJesper Dangaard Brouer 
320f033b688SJesper Dangaard Brouer TRACE_EVENT(mem_disconnect,
321f033b688SJesper Dangaard Brouer 
322c3f812ceSJonathan Lemon 	TP_PROTO(const struct xdp_mem_allocator *xa),
323f033b688SJesper Dangaard Brouer 
324c3f812ceSJonathan Lemon 	TP_ARGS(xa),
325f033b688SJesper Dangaard Brouer 
326f033b688SJesper Dangaard Brouer 	TP_STRUCT__entry(
327f033b688SJesper Dangaard Brouer 		__field(const struct xdp_mem_allocator *,	xa)
328f033b688SJesper Dangaard Brouer 		__field(u32,		mem_id)
329f033b688SJesper Dangaard Brouer 		__field(u32,		mem_type)
330f033b688SJesper Dangaard Brouer 		__field(const void *,	allocator)
331f033b688SJesper Dangaard Brouer 	),
332f033b688SJesper Dangaard Brouer 
333f033b688SJesper Dangaard Brouer 	TP_fast_assign(
334f033b688SJesper Dangaard Brouer 		__entry->xa		= xa;
335f033b688SJesper Dangaard Brouer 		__entry->mem_id		= xa->mem.id;
336f033b688SJesper Dangaard Brouer 		__entry->mem_type	= xa->mem.type;
337f033b688SJesper Dangaard Brouer 		__entry->allocator	= xa->allocator;
338f033b688SJesper Dangaard Brouer 	),
339f033b688SJesper Dangaard Brouer 
340c3f812ceSJonathan Lemon 	TP_printk("mem_id=%d mem_type=%s allocator=%p",
341f033b688SJesper Dangaard Brouer 		  __entry->mem_id,
342f033b688SJesper Dangaard Brouer 		  __print_symbolic(__entry->mem_type, __MEM_TYPE_SYM_TAB),
343c3f812ceSJonathan Lemon 		  __entry->allocator
344f033b688SJesper Dangaard Brouer 	)
345f033b688SJesper Dangaard Brouer );
346f033b688SJesper Dangaard Brouer 
347f033b688SJesper Dangaard Brouer TRACE_EVENT(mem_connect,
348f033b688SJesper Dangaard Brouer 
349f033b688SJesper Dangaard Brouer 	TP_PROTO(const struct xdp_mem_allocator *xa,
350f033b688SJesper Dangaard Brouer 		 const struct xdp_rxq_info *rxq),
351f033b688SJesper Dangaard Brouer 
352f033b688SJesper Dangaard Brouer 	TP_ARGS(xa, rxq),
353f033b688SJesper Dangaard Brouer 
354f033b688SJesper Dangaard Brouer 	TP_STRUCT__entry(
355f033b688SJesper Dangaard Brouer 		__field(const struct xdp_mem_allocator *,	xa)
356f033b688SJesper Dangaard Brouer 		__field(u32,		mem_id)
357f033b688SJesper Dangaard Brouer 		__field(u32,		mem_type)
358f033b688SJesper Dangaard Brouer 		__field(const void *,	allocator)
359f033b688SJesper Dangaard Brouer 		__field(const struct xdp_rxq_info *,		rxq)
360f033b688SJesper Dangaard Brouer 		__field(int,		ifindex)
361f033b688SJesper Dangaard Brouer 	),
362f033b688SJesper Dangaard Brouer 
363f033b688SJesper Dangaard Brouer 	TP_fast_assign(
364f033b688SJesper Dangaard Brouer 		__entry->xa		= xa;
365f033b688SJesper Dangaard Brouer 		__entry->mem_id		= xa->mem.id;
366f033b688SJesper Dangaard Brouer 		__entry->mem_type	= xa->mem.type;
367f033b688SJesper Dangaard Brouer 		__entry->allocator	= xa->allocator;
368f033b688SJesper Dangaard Brouer 		__entry->rxq		= rxq;
369f033b688SJesper Dangaard Brouer 		__entry->ifindex	= rxq->dev->ifindex;
370f033b688SJesper Dangaard Brouer 	),
371f033b688SJesper Dangaard Brouer 
372f033b688SJesper Dangaard Brouer 	TP_printk("mem_id=%d mem_type=%s allocator=%p"
373f033b688SJesper Dangaard Brouer 		  " ifindex=%d",
374f033b688SJesper Dangaard Brouer 		  __entry->mem_id,
375f033b688SJesper Dangaard Brouer 		  __print_symbolic(__entry->mem_type, __MEM_TYPE_SYM_TAB),
376f033b688SJesper Dangaard Brouer 		  __entry->allocator,
377f033b688SJesper Dangaard Brouer 		  __entry->ifindex
378f033b688SJesper Dangaard Brouer 	)
379f033b688SJesper Dangaard Brouer );
380f033b688SJesper Dangaard Brouer 
381f033b688SJesper Dangaard Brouer TRACE_EVENT(mem_return_failed,
382f033b688SJesper Dangaard Brouer 
383f033b688SJesper Dangaard Brouer 	TP_PROTO(const struct xdp_mem_info *mem,
384f033b688SJesper Dangaard Brouer 		 const struct page *page),
385f033b688SJesper Dangaard Brouer 
386f033b688SJesper Dangaard Brouer 	TP_ARGS(mem, page),
387f033b688SJesper Dangaard Brouer 
388f033b688SJesper Dangaard Brouer 	TP_STRUCT__entry(
389f033b688SJesper Dangaard Brouer 		__field(const struct page *,	page)
390f033b688SJesper Dangaard Brouer 		__field(u32,		mem_id)
391f033b688SJesper Dangaard Brouer 		__field(u32,		mem_type)
392f033b688SJesper Dangaard Brouer 	),
393f033b688SJesper Dangaard Brouer 
394f033b688SJesper Dangaard Brouer 	TP_fast_assign(
395f033b688SJesper Dangaard Brouer 		__entry->page		= page;
396f033b688SJesper Dangaard Brouer 		__entry->mem_id		= mem->id;
397f033b688SJesper Dangaard Brouer 		__entry->mem_type	= mem->type;
398f033b688SJesper Dangaard Brouer 	),
399f033b688SJesper Dangaard Brouer 
400f033b688SJesper Dangaard Brouer 	TP_printk("mem_id=%d mem_type=%s page=%p",
401f033b688SJesper Dangaard Brouer 		  __entry->mem_id,
402f033b688SJesper Dangaard Brouer 		  __print_symbolic(__entry->mem_type, __MEM_TYPE_SYM_TAB),
403f033b688SJesper Dangaard Brouer 		  __entry->page
404f033b688SJesper Dangaard Brouer 	)
405f033b688SJesper Dangaard Brouer );
406f033b688SJesper Dangaard Brouer 
407*bf4ea1d0SLeon Hwang TRACE_EVENT(bpf_xdp_link_attach_failed,
408*bf4ea1d0SLeon Hwang 
409*bf4ea1d0SLeon Hwang 	TP_PROTO(const char *msg),
410*bf4ea1d0SLeon Hwang 
411*bf4ea1d0SLeon Hwang 	TP_ARGS(msg),
412*bf4ea1d0SLeon Hwang 
413*bf4ea1d0SLeon Hwang 	TP_STRUCT__entry(
414*bf4ea1d0SLeon Hwang 		__string(msg, msg)
415*bf4ea1d0SLeon Hwang 	),
416*bf4ea1d0SLeon Hwang 
417*bf4ea1d0SLeon Hwang 	TP_fast_assign(
418*bf4ea1d0SLeon Hwang 		__assign_str(msg, msg);
419*bf4ea1d0SLeon Hwang 	),
420*bf4ea1d0SLeon Hwang 
421*bf4ea1d0SLeon Hwang 	TP_printk("errmsg=%s", __get_str(msg))
422*bf4ea1d0SLeon Hwang );
423*bf4ea1d0SLeon Hwang 
424a67edbf4SDaniel Borkmann #endif /* _TRACE_XDP_H */
425a67edbf4SDaniel Borkmann 
426a67edbf4SDaniel Borkmann #include <trace/define_trace.h>
427