Daniel Borkmann | a67edbf | 2017-01-25 02:28:18 +0100 | [diff] [blame] | 1 | #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 Fastabend | 5acaee0 | 2017-07-17 09:28:35 -0700 | [diff] [blame] | 15 | FN(TX) \ |
| 16 | FN(REDIRECT) |
Daniel Borkmann | a67edbf | 2017-01-25 02:28:18 +0100 | [diff] [blame] | 17 | |
| 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 | |
| 26 | TRACE_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 Brouer | b06337d | 2017-08-29 16:37:51 +0200 | [diff] [blame] | 34 | __field(int, prog_id) |
Daniel Borkmann | a67edbf | 2017-01-25 02:28:18 +0100 | [diff] [blame] | 35 | __field(u32, act) |
Jesper Dangaard Brouer | 315ec39 | 2017-08-24 12:33:23 +0200 | [diff] [blame] | 36 | __field(int, ifindex) |
Daniel Borkmann | a67edbf | 2017-01-25 02:28:18 +0100 | [diff] [blame] | 37 | ), |
| 38 | |
| 39 | TP_fast_assign( |
Jesper Dangaard Brouer | b06337d | 2017-08-29 16:37:51 +0200 | [diff] [blame] | 40 | __entry->prog_id = xdp->aux->id; |
Jesper Dangaard Brouer | 315ec39 | 2017-08-24 12:33:23 +0200 | [diff] [blame] | 41 | __entry->act = act; |
| 42 | __entry->ifindex = dev->ifindex; |
Daniel Borkmann | a67edbf | 2017-01-25 02:28:18 +0100 | [diff] [blame] | 43 | ), |
| 44 | |
Jesper Dangaard Brouer | b06337d | 2017-08-29 16:37:51 +0200 | [diff] [blame] | 45 | TP_printk("prog_id=%d action=%s ifindex=%d", |
| 46 | __entry->prog_id, |
Jesper Dangaard Brouer | 315ec39 | 2017-08-24 12:33:23 +0200 | [diff] [blame] | 47 | __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), |
| 48 | __entry->ifindex) |
Daniel Borkmann | a67edbf | 2017-01-25 02:28:18 +0100 | [diff] [blame] | 49 | ); |
| 50 | |
Jesper Dangaard Brouer | 8d3b778 | 2017-08-29 16:37:45 +0200 | [diff] [blame] | 51 | DECLARE_EVENT_CLASS(xdp_redirect_template, |
John Fastabend | 5acaee0 | 2017-07-17 09:28:35 -0700 | [diff] [blame] | 52 | |
Jesper Dangaard Brouer | a873585 | 2017-08-24 12:33:18 +0200 | [diff] [blame] | 53 | TP_PROTO(const struct net_device *dev, |
Jesper Dangaard Brouer | c31e5a4 | 2017-08-29 16:37:40 +0200 | [diff] [blame] | 54 | const struct bpf_prog *xdp, |
Jesper Dangaard Brouer | 8d3b778 | 2017-08-29 16:37:45 +0200 | [diff] [blame] | 55 | int to_ifindex, int err, |
| 56 | const struct bpf_map *map, u32 map_index), |
John Fastabend | 5acaee0 | 2017-07-17 09:28:35 -0700 | [diff] [blame] | 57 | |
Jesper Dangaard Brouer | 8d3b778 | 2017-08-29 16:37:45 +0200 | [diff] [blame] | 58 | TP_ARGS(dev, xdp, to_ifindex, err, map, map_index), |
John Fastabend | 5acaee0 | 2017-07-17 09:28:35 -0700 | [diff] [blame] | 59 | |
| 60 | TP_STRUCT__entry( |
Jesper Dangaard Brouer | b06337d | 2017-08-29 16:37:51 +0200 | [diff] [blame] | 61 | __field(int, prog_id) |
John Fastabend | 5acaee0 | 2017-07-17 09:28:35 -0700 | [diff] [blame] | 62 | __field(u32, act) |
Jesper Dangaard Brouer | a873585 | 2017-08-24 12:33:18 +0200 | [diff] [blame] | 63 | __field(int, ifindex) |
Jesper Dangaard Brouer | 4c03bdd | 2017-08-17 18:22:37 +0200 | [diff] [blame] | 64 | __field(int, err) |
Jesper Dangaard Brouer | 8d3b778 | 2017-08-29 16:37:45 +0200 | [diff] [blame] | 65 | __field(int, to_ifindex) |
| 66 | __field(u32, map_id) |
| 67 | __field(int, map_index) |
John Fastabend | 5acaee0 | 2017-07-17 09:28:35 -0700 | [diff] [blame] | 68 | ), |
| 69 | |
| 70 | TP_fast_assign( |
Jesper Dangaard Brouer | b06337d | 2017-08-29 16:37:51 +0200 | [diff] [blame] | 71 | __entry->prog_id = xdp->aux->id; |
Jesper Dangaard Brouer | c31e5a4 | 2017-08-29 16:37:40 +0200 | [diff] [blame] | 72 | __entry->act = XDP_REDIRECT; |
Jesper Dangaard Brouer | a873585 | 2017-08-24 12:33:18 +0200 | [diff] [blame] | 73 | __entry->ifindex = dev->ifindex; |
Jesper Dangaard Brouer | a873585 | 2017-08-24 12:33:18 +0200 | [diff] [blame] | 74 | __entry->err = err; |
Jesper Dangaard Brouer | 8d3b778 | 2017-08-29 16:37:45 +0200 | [diff] [blame] | 75 | __entry->to_ifindex = to_ifindex; |
| 76 | __entry->map_id = map ? map->id : 0; |
| 77 | __entry->map_index = map_index; |
John Fastabend | 5acaee0 | 2017-07-17 09:28:35 -0700 | [diff] [blame] | 78 | ), |
| 79 | |
Jesper Dangaard Brouer | 59a3089 | 2017-08-29 16:38:01 +0200 | [diff] [blame] | 80 | TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d", |
Jesper Dangaard Brouer | b06337d | 2017-08-29 16:37:51 +0200 | [diff] [blame] | 81 | __entry->prog_id, |
Jesper Dangaard Brouer | 4c03bdd | 2017-08-17 18:22:37 +0200 | [diff] [blame] | 82 | __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), |
Jesper Dangaard Brouer | 8d3b778 | 2017-08-29 16:37:45 +0200 | [diff] [blame] | 83 | __entry->ifindex, __entry->to_ifindex, |
Jesper Dangaard Brouer | 59a3089 | 2017-08-29 16:38:01 +0200 | [diff] [blame] | 84 | __entry->err) |
John Fastabend | 5acaee0 | 2017-07-17 09:28:35 -0700 | [diff] [blame] | 85 | ); |
Jesper Dangaard Brouer | 8d3b778 | 2017-08-29 16:37:45 +0200 | [diff] [blame] | 86 | |
| 87 | DEFINE_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 Brouer | f5836ca | 2017-08-29 16:37:56 +0200 | [diff] [blame] | 95 | DEFINE_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 Brouer | 8d3b778 | 2017-08-29 16:37:45 +0200 | [diff] [blame] | 102 | |
Jesper Dangaard Brouer | f5836ca | 2017-08-29 16:37:56 +0200 | [diff] [blame] | 103 | #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 Brouer | 59a3089 | 2017-08-29 16:38:01 +0200 | [diff] [blame] | 109 | DEFINE_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 Brouer | f5836ca | 2017-08-29 16:37:56 +0200 | [diff] [blame] | 123 | |
Jesper Dangaard Brouer | 59a3089 | 2017-08-29 16:38:01 +0200 | [diff] [blame] | 124 | DEFINE_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 Brouer | 96c5508 | 2017-09-10 09:47:02 +0200 | [diff] [blame] | 141 | 0, map, idx) |
Jesper Dangaard Brouer | 59a3089 | 2017-08-29 16:38:01 +0200 | [diff] [blame] | 142 | |
| 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 Brouer | 96c5508 | 2017-09-10 09:47:02 +0200 | [diff] [blame] | 145 | err, map, idx) |
Jesper Dangaard Brouer | 8d3b778 | 2017-08-29 16:37:45 +0200 | [diff] [blame] | 146 | |
Daniel Borkmann | a67edbf | 2017-01-25 02:28:18 +0100 | [diff] [blame] | 147 | #endif /* _TRACE_XDP_H */ |
| 148 | |
| 149 | #include <trace/define_trace.h> |