blob: 4e16c43fba10ab7ce958582b0b6771473dbe926a [file] [log] [blame]
Daniel Borkmanna67edbf2017-01-25 02:28:18 +01001#undef TRACE_SYSTEM
2#define TRACE_SYSTEM xdp
3
4#if !defined(_TRACE_XDP_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_XDP_H
6
7#include <linux/netdevice.h>
8#include <linux/filter.h>
9#include <linux/tracepoint.h>
10
11#define __XDP_ACT_MAP(FN) \
12 FN(ABORTED) \
13 FN(DROP) \
14 FN(PASS) \
John Fastabend5acaee02017-07-17 09:28:35 -070015 FN(TX) \
16 FN(REDIRECT)
Daniel Borkmanna67edbf2017-01-25 02:28:18 +010017
18#define __XDP_ACT_TP_FN(x) \
19 TRACE_DEFINE_ENUM(XDP_##x);
20#define __XDP_ACT_SYM_FN(x) \
21 { XDP_##x, #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)
25
26TRACE_EVENT(xdp_exception,
27
28 TP_PROTO(const struct net_device *dev,
29 const struct bpf_prog *xdp, u32 act),
30
31 TP_ARGS(dev, xdp, act),
32
33 TP_STRUCT__entry(
Jesper Dangaard Brouerb06337d2017-08-29 16:37:51 +020034 __field(int, prog_id)
Daniel Borkmanna67edbf2017-01-25 02:28:18 +010035 __field(u32, act)
Jesper Dangaard Brouer315ec392017-08-24 12:33:23 +020036 __field(int, ifindex)
Daniel Borkmanna67edbf2017-01-25 02:28:18 +010037 ),
38
39 TP_fast_assign(
Jesper Dangaard Brouerb06337d2017-08-29 16:37:51 +020040 __entry->prog_id = xdp->aux->id;
Jesper Dangaard Brouer315ec392017-08-24 12:33:23 +020041 __entry->act = act;
42 __entry->ifindex = dev->ifindex;
Daniel Borkmanna67edbf2017-01-25 02:28:18 +010043 ),
44
Jesper Dangaard Brouerb06337d2017-08-29 16:37:51 +020045 TP_printk("prog_id=%d action=%s ifindex=%d",
46 __entry->prog_id,
Jesper Dangaard Brouer315ec392017-08-24 12:33:23 +020047 __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
48 __entry->ifindex)
Daniel Borkmanna67edbf2017-01-25 02:28:18 +010049);
50
Jesper Dangaard Brouer8d3b7782017-08-29 16:37:45 +020051DECLARE_EVENT_CLASS(xdp_redirect_template,
John Fastabend5acaee02017-07-17 09:28:35 -070052
Jesper Dangaard Brouera8735852017-08-24 12:33:18 +020053 TP_PROTO(const struct net_device *dev,
Jesper Dangaard Brouerc31e5a42017-08-29 16:37:40 +020054 const struct bpf_prog *xdp,
Jesper Dangaard Brouer8d3b7782017-08-29 16:37:45 +020055 int to_ifindex, int err,
56 const struct bpf_map *map, u32 map_index),
John Fastabend5acaee02017-07-17 09:28:35 -070057
Jesper Dangaard Brouer8d3b7782017-08-29 16:37:45 +020058 TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
John Fastabend5acaee02017-07-17 09:28:35 -070059
60 TP_STRUCT__entry(
Jesper Dangaard Brouerb06337d2017-08-29 16:37:51 +020061 __field(int, prog_id)
John Fastabend5acaee02017-07-17 09:28:35 -070062 __field(u32, act)
Jesper Dangaard Brouera8735852017-08-24 12:33:18 +020063 __field(int, ifindex)
Jesper Dangaard Brouer4c03bdd2017-08-17 18:22:37 +020064 __field(int, err)
Jesper Dangaard Brouer8d3b7782017-08-29 16:37:45 +020065 __field(int, to_ifindex)
66 __field(u32, map_id)
67 __field(int, map_index)
John Fastabend5acaee02017-07-17 09:28:35 -070068 ),
69
70 TP_fast_assign(
Jesper Dangaard Brouerb06337d2017-08-29 16:37:51 +020071 __entry->prog_id = xdp->aux->id;
Jesper Dangaard Brouerc31e5a42017-08-29 16:37:40 +020072 __entry->act = XDP_REDIRECT;
Jesper Dangaard Brouera8735852017-08-24 12:33:18 +020073 __entry->ifindex = dev->ifindex;
Jesper Dangaard Brouera8735852017-08-24 12:33:18 +020074 __entry->err = err;
Jesper Dangaard Brouer8d3b7782017-08-29 16:37:45 +020075 __entry->to_ifindex = to_ifindex;
76 __entry->map_id = map ? map->id : 0;
77 __entry->map_index = map_index;
John Fastabend5acaee02017-07-17 09:28:35 -070078 ),
79
Jesper Dangaard Brouer59a30892017-08-29 16:38:01 +020080 TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d",
Jesper Dangaard Brouerb06337d2017-08-29 16:37:51 +020081 __entry->prog_id,
Jesper Dangaard Brouer4c03bdd2017-08-17 18:22:37 +020082 __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
Jesper Dangaard Brouer8d3b7782017-08-29 16:37:45 +020083 __entry->ifindex, __entry->to_ifindex,
Jesper Dangaard Brouer59a30892017-08-29 16:38:01 +020084 __entry->err)
John Fastabend5acaee02017-07-17 09:28:35 -070085);
Jesper Dangaard Brouer8d3b7782017-08-29 16:37:45 +020086
87DEFINE_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)
93);
94
Jesper Dangaard Brouerf5836ca2017-08-29 16:37:56 +020095DEFINE_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)
101);
Jesper Dangaard Brouer8d3b7782017-08-29 16:37:45 +0200102
Jesper Dangaard Brouerf5836ca2017-08-29 16:37:56 +0200103#define _trace_xdp_redirect(dev, xdp, to) \
104 trace_xdp_redirect(dev, xdp, to, 0, NULL, 0);
105
106#define _trace_xdp_redirect_err(dev, xdp, to, err) \
107 trace_xdp_redirect_err(dev, xdp, to, err, NULL, 0);
108
Jesper Dangaard Brouer59a30892017-08-29 16:38:01 +0200109DEFINE_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",
117 __entry->prog_id,
118 __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
119 __entry->ifindex, __entry->to_ifindex,
120 __entry->err,
121 __entry->map_id, __entry->map_index)
122);
Jesper Dangaard Brouerf5836ca2017-08-29 16:37:56 +0200123
Jesper Dangaard Brouer59a30892017-08-29 16:38:01 +0200124DEFINE_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",
132 __entry->prog_id,
133 __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
134 __entry->ifindex, __entry->to_ifindex,
135 __entry->err,
136 __entry->map_id, __entry->map_index)
137);
138
139#define _trace_xdp_redirect_map(dev, xdp, fwd, map, idx) \
140 trace_xdp_redirect_map(dev, xdp, fwd ? fwd->ifindex : 0, \
Jesper Dangaard Brouer96c55082017-09-10 09:47:02 +0200141 0, map, idx)
Jesper Dangaard Brouer59a30892017-08-29 16:38:01 +0200142
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, \
Jesper Dangaard Brouer96c55082017-09-10 09:47:02 +0200145 err, map, idx)
Jesper Dangaard Brouer8d3b7782017-08-29 16:37:45 +0200146
Daniel Borkmanna67edbf2017-01-25 02:28:18 +0100147#endif /* _TRACE_XDP_H */
148
149#include <trace/define_trace.h>