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> 12*680ee045SJakub Kicinski #include <net/xdp.h> 13a67edbf4SDaniel Borkmann 14a67edbf4SDaniel Borkmann #define __XDP_ACT_MAP(FN) \ 15a67edbf4SDaniel Borkmann FN(ABORTED) \ 16a67edbf4SDaniel Borkmann FN(DROP) \ 17a67edbf4SDaniel Borkmann FN(PASS) \ 185acaee0aSJohn Fastabend FN(TX) \ 195acaee0aSJohn Fastabend FN(REDIRECT) 20a67edbf4SDaniel Borkmann 21a67edbf4SDaniel Borkmann #define __XDP_ACT_TP_FN(x) \ 22a67edbf4SDaniel Borkmann TRACE_DEFINE_ENUM(XDP_##x); 23a67edbf4SDaniel Borkmann #define __XDP_ACT_SYM_FN(x) \ 24a67edbf4SDaniel Borkmann { XDP_##x, #x }, 25a67edbf4SDaniel Borkmann #define __XDP_ACT_SYM_TAB \ 265e5b03d1SBen Dooks (Codethink) __XDP_ACT_MAP(__XDP_ACT_SYM_FN) { -1, NULL } 27a67edbf4SDaniel Borkmann __XDP_ACT_MAP(__XDP_ACT_TP_FN) 28a67edbf4SDaniel Borkmann 29a67edbf4SDaniel Borkmann TRACE_EVENT(xdp_exception, 30a67edbf4SDaniel Borkmann 31a67edbf4SDaniel Borkmann TP_PROTO(const struct net_device *dev, 32a67edbf4SDaniel Borkmann const struct bpf_prog *xdp, u32 act), 33a67edbf4SDaniel Borkmann 34a67edbf4SDaniel Borkmann TP_ARGS(dev, xdp, act), 35a67edbf4SDaniel Borkmann 36a67edbf4SDaniel Borkmann TP_STRUCT__entry( 37b06337dfSJesper Dangaard Brouer __field(int, prog_id) 38a67edbf4SDaniel Borkmann __field(u32, act) 39315ec399SJesper Dangaard Brouer __field(int, ifindex) 40a67edbf4SDaniel Borkmann ), 41a67edbf4SDaniel Borkmann 42a67edbf4SDaniel Borkmann TP_fast_assign( 43b06337dfSJesper Dangaard Brouer __entry->prog_id = xdp->aux->id; 44a67edbf4SDaniel Borkmann __entry->act = act; 45315ec399SJesper Dangaard Brouer __entry->ifindex = dev->ifindex; 46a67edbf4SDaniel Borkmann ), 47a67edbf4SDaniel Borkmann 48b06337dfSJesper Dangaard Brouer TP_printk("prog_id=%d action=%s ifindex=%d", 49b06337dfSJesper Dangaard Brouer __entry->prog_id, 50315ec399SJesper Dangaard Brouer __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), 51315ec399SJesper Dangaard Brouer __entry->ifindex) 52a67edbf4SDaniel Borkmann ); 53a67edbf4SDaniel Borkmann 54e7d47989SToshiaki Makita TRACE_EVENT(xdp_bulk_tx, 55e7d47989SToshiaki Makita 56e7d47989SToshiaki Makita TP_PROTO(const struct net_device *dev, 57e7d47989SToshiaki Makita int sent, int drops, int err), 58e7d47989SToshiaki Makita 59e7d47989SToshiaki Makita TP_ARGS(dev, sent, drops, err), 60e7d47989SToshiaki Makita 61e7d47989SToshiaki Makita TP_STRUCT__entry( 62e7d47989SToshiaki Makita __field(int, ifindex) 63e7d47989SToshiaki Makita __field(u32, act) 64e7d47989SToshiaki Makita __field(int, drops) 65e7d47989SToshiaki Makita __field(int, sent) 66e7d47989SToshiaki Makita __field(int, err) 67e7d47989SToshiaki Makita ), 68e7d47989SToshiaki Makita 69e7d47989SToshiaki Makita TP_fast_assign( 70e7d47989SToshiaki Makita __entry->ifindex = dev->ifindex; 71e7d47989SToshiaki Makita __entry->act = XDP_TX; 72e7d47989SToshiaki Makita __entry->drops = drops; 73e7d47989SToshiaki Makita __entry->sent = sent; 74e7d47989SToshiaki Makita __entry->err = err; 75e7d47989SToshiaki Makita ), 76e7d47989SToshiaki Makita 77e7d47989SToshiaki Makita TP_printk("ifindex=%d action=%s sent=%d drops=%d err=%d", 78e7d47989SToshiaki Makita __entry->ifindex, 79e7d47989SToshiaki Makita __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), 80e7d47989SToshiaki Makita __entry->sent, __entry->drops, __entry->err) 81e7d47989SToshiaki Makita ); 82e7d47989SToshiaki Makita 831d233886SToke Høiland-Jørgensen #ifndef __DEVMAP_OBJ_TYPE 841d233886SToke Høiland-Jørgensen #define __DEVMAP_OBJ_TYPE 851d233886SToke Høiland-Jørgensen struct _bpf_dtab_netdev { 861d233886SToke Høiland-Jørgensen struct net_device *dev; 871d233886SToke Høiland-Jørgensen }; 881d233886SToke Høiland-Jørgensen #endif /* __DEVMAP_OBJ_TYPE */ 891d233886SToke Høiland-Jørgensen 908d3b778fSJesper Dangaard Brouer DECLARE_EVENT_CLASS(xdp_redirect_template, 915acaee0aSJohn Fastabend 92a8735855SJesper Dangaard Brouer TP_PROTO(const struct net_device *dev, 93c31e5a48SJesper Dangaard Brouer const struct bpf_prog *xdp, 941d233886SToke Høiland-Jørgensen const void *tgt, int err, 95ee75aef2SBjörn Töpel enum bpf_map_type map_type, 96ee75aef2SBjörn Töpel u32 map_id, u32 index), 975acaee0aSJohn Fastabend 98ee75aef2SBjörn Töpel TP_ARGS(dev, xdp, tgt, err, map_type, map_id, index), 995acaee0aSJohn Fastabend 1005acaee0aSJohn Fastabend TP_STRUCT__entry( 101b06337dfSJesper Dangaard Brouer __field(int, prog_id) 1025acaee0aSJohn Fastabend __field(u32, act) 103a8735855SJesper Dangaard Brouer __field(int, ifindex) 1044c03bdd7SJesper Dangaard Brouer __field(int, err) 1058d3b778fSJesper Dangaard Brouer __field(int, to_ifindex) 1068d3b778fSJesper Dangaard Brouer __field(u32, map_id) 1078d3b778fSJesper Dangaard Brouer __field(int, map_index) 1085acaee0aSJohn Fastabend ), 1095acaee0aSJohn Fastabend 1105acaee0aSJohn Fastabend TP_fast_assign( 111ee75aef2SBjörn Töpel u32 ifindex = 0, map_index = index; 112ee75aef2SBjörn Töpel 113ee75aef2SBjörn Töpel if (map_type == BPF_MAP_TYPE_DEVMAP || map_type == BPF_MAP_TYPE_DEVMAP_HASH) { 114e624d4edSHangbin Liu /* Just leave to_ifindex to 0 if do broadcast redirect, 115e624d4edSHangbin Liu * as tgt will be NULL. 116e624d4edSHangbin Liu */ 117e624d4edSHangbin Liu if (tgt) 118ee75aef2SBjörn Töpel ifindex = ((struct _bpf_dtab_netdev *)tgt)->dev->ifindex; 119ee75aef2SBjörn Töpel } else if (map_type == BPF_MAP_TYPE_UNSPEC && map_id == INT_MAX) { 120ee75aef2SBjörn Töpel ifindex = index; 121ee75aef2SBjörn Töpel map_index = 0; 122ee75aef2SBjörn Töpel } 123ee75aef2SBjörn Töpel 124b06337dfSJesper Dangaard Brouer __entry->prog_id = xdp->aux->id; 125c31e5a48SJesper Dangaard Brouer __entry->act = XDP_REDIRECT; 126a8735855SJesper Dangaard Brouer __entry->ifindex = dev->ifindex; 1274c03bdd7SJesper Dangaard Brouer __entry->err = err; 128ee75aef2SBjörn Töpel __entry->to_ifindex = ifindex; 129ee75aef2SBjörn Töpel __entry->map_id = map_id; 130ee75aef2SBjörn Töpel __entry->map_index = map_index; 1315acaee0aSJohn Fastabend ), 1325acaee0aSJohn Fastabend 1331d233886SToke Høiland-Jørgensen TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d" 1341d233886SToke Høiland-Jørgensen " map_id=%d map_index=%d", 135b06337dfSJesper Dangaard Brouer __entry->prog_id, 1364c03bdd7SJesper Dangaard Brouer __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), 1378d3b778fSJesper Dangaard Brouer __entry->ifindex, __entry->to_ifindex, 1381d233886SToke Høiland-Jørgensen __entry->err, __entry->map_id, __entry->map_index) 1395acaee0aSJohn Fastabend ); 1408d3b778fSJesper Dangaard Brouer 1418d3b778fSJesper Dangaard Brouer DEFINE_EVENT(xdp_redirect_template, xdp_redirect, 1428d3b778fSJesper Dangaard Brouer TP_PROTO(const struct net_device *dev, 1438d3b778fSJesper Dangaard Brouer const struct bpf_prog *xdp, 1441d233886SToke Høiland-Jørgensen const void *tgt, int err, 145ee75aef2SBjörn Töpel enum bpf_map_type map_type, 146ee75aef2SBjörn Töpel u32 map_id, u32 index), 147ee75aef2SBjörn Töpel TP_ARGS(dev, xdp, tgt, err, map_type, map_id, index) 1488d3b778fSJesper Dangaard Brouer ); 1498d3b778fSJesper Dangaard Brouer 150f5836ca5SJesper Dangaard Brouer DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err, 151f5836ca5SJesper Dangaard Brouer TP_PROTO(const struct net_device *dev, 152f5836ca5SJesper Dangaard Brouer const struct bpf_prog *xdp, 1531d233886SToke Høiland-Jørgensen const void *tgt, int err, 154ee75aef2SBjörn Töpel enum bpf_map_type map_type, 155ee75aef2SBjörn Töpel u32 map_id, u32 index), 156ee75aef2SBjörn Töpel TP_ARGS(dev, xdp, tgt, err, map_type, map_id, index) 157f5836ca5SJesper Dangaard Brouer ); 1588d3b778fSJesper Dangaard Brouer 159f5836ca5SJesper Dangaard Brouer #define _trace_xdp_redirect(dev, xdp, to) \ 160ee75aef2SBjörn Töpel trace_xdp_redirect(dev, xdp, NULL, 0, BPF_MAP_TYPE_UNSPEC, INT_MAX, to) 161f5836ca5SJesper Dangaard Brouer 162f5836ca5SJesper Dangaard Brouer #define _trace_xdp_redirect_err(dev, xdp, to, err) \ 163ee75aef2SBjörn Töpel trace_xdp_redirect_err(dev, xdp, NULL, err, BPF_MAP_TYPE_UNSPEC, INT_MAX, to) 164f5836ca5SJesper Dangaard Brouer 165ee75aef2SBjörn Töpel #define _trace_xdp_redirect_map(dev, xdp, to, map_type, map_id, index) \ 166ee75aef2SBjörn Töpel trace_xdp_redirect(dev, xdp, to, 0, map_type, map_id, index) 1671d233886SToke Høiland-Jørgensen 168ee75aef2SBjörn Töpel #define _trace_xdp_redirect_map_err(dev, xdp, to, map_type, map_id, index, err) \ 169ee75aef2SBjörn Töpel trace_xdp_redirect_err(dev, xdp, to, err, map_type, map_id, index) 1701d233886SToke Høiland-Jørgensen 1711d233886SToke Høiland-Jørgensen /* not used anymore, but kept around so as not to break old programs */ 1721d233886SToke Høiland-Jørgensen DEFINE_EVENT(xdp_redirect_template, xdp_redirect_map, 17359a30896SJesper Dangaard Brouer TP_PROTO(const struct net_device *dev, 17459a30896SJesper Dangaard Brouer const struct bpf_prog *xdp, 1751d233886SToke Høiland-Jørgensen const void *tgt, int err, 176ee75aef2SBjörn Töpel enum bpf_map_type map_type, 177ee75aef2SBjörn Töpel u32 map_id, u32 index), 178ee75aef2SBjörn Töpel TP_ARGS(dev, xdp, tgt, err, map_type, map_id, index) 17959a30896SJesper Dangaard Brouer ); 180f5836ca5SJesper Dangaard Brouer 1811d233886SToke Høiland-Jørgensen DEFINE_EVENT(xdp_redirect_template, xdp_redirect_map_err, 18259a30896SJesper Dangaard Brouer TP_PROTO(const struct net_device *dev, 18359a30896SJesper Dangaard Brouer const struct bpf_prog *xdp, 1841d233886SToke Høiland-Jørgensen const void *tgt, int err, 185ee75aef2SBjörn Töpel enum bpf_map_type map_type, 186ee75aef2SBjörn Töpel u32 map_id, u32 index), 187ee75aef2SBjörn Töpel TP_ARGS(dev, xdp, tgt, err, map_type, map_id, index) 18859a30896SJesper Dangaard Brouer ); 18959a30896SJesper Dangaard Brouer 190f9419f7bSJesper Dangaard Brouer TRACE_EVENT(xdp_cpumap_kthread, 191f9419f7bSJesper Dangaard Brouer 192f9419f7bSJesper Dangaard Brouer TP_PROTO(int map_id, unsigned int processed, unsigned int drops, 19392164774SLorenzo Bianconi int sched, struct xdp_cpumap_stats *xdp_stats), 194f9419f7bSJesper Dangaard Brouer 19592164774SLorenzo Bianconi TP_ARGS(map_id, processed, drops, sched, xdp_stats), 196f9419f7bSJesper Dangaard Brouer 197f9419f7bSJesper Dangaard Brouer TP_STRUCT__entry( 198f9419f7bSJesper Dangaard Brouer __field(int, map_id) 199f9419f7bSJesper Dangaard Brouer __field(u32, act) 200f9419f7bSJesper Dangaard Brouer __field(int, cpu) 201f9419f7bSJesper Dangaard Brouer __field(unsigned int, drops) 202f9419f7bSJesper Dangaard Brouer __field(unsigned int, processed) 203f9419f7bSJesper Dangaard Brouer __field(int, sched) 20492164774SLorenzo Bianconi __field(unsigned int, xdp_pass) 20592164774SLorenzo Bianconi __field(unsigned int, xdp_drop) 20628b1520eSLorenzo Bianconi __field(unsigned int, xdp_redirect) 207f9419f7bSJesper Dangaard Brouer ), 208f9419f7bSJesper Dangaard Brouer 209f9419f7bSJesper Dangaard Brouer TP_fast_assign( 210f9419f7bSJesper Dangaard Brouer __entry->map_id = map_id; 211f9419f7bSJesper Dangaard Brouer __entry->act = XDP_REDIRECT; 212f9419f7bSJesper Dangaard Brouer __entry->cpu = smp_processor_id(); 213f9419f7bSJesper Dangaard Brouer __entry->drops = drops; 214f9419f7bSJesper Dangaard Brouer __entry->processed = processed; 215f9419f7bSJesper Dangaard Brouer __entry->sched = sched; 21692164774SLorenzo Bianconi __entry->xdp_pass = xdp_stats->pass; 21792164774SLorenzo Bianconi __entry->xdp_drop = xdp_stats->drop; 21828b1520eSLorenzo Bianconi __entry->xdp_redirect = xdp_stats->redirect; 219f9419f7bSJesper Dangaard Brouer ), 220f9419f7bSJesper Dangaard Brouer 221f9419f7bSJesper Dangaard Brouer TP_printk("kthread" 222f9419f7bSJesper Dangaard Brouer " cpu=%d map_id=%d action=%s" 223f9419f7bSJesper Dangaard Brouer " processed=%u drops=%u" 22492164774SLorenzo Bianconi " sched=%d" 22528b1520eSLorenzo Bianconi " xdp_pass=%u xdp_drop=%u xdp_redirect=%u", 226f9419f7bSJesper Dangaard Brouer __entry->cpu, __entry->map_id, 227f9419f7bSJesper Dangaard Brouer __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), 228f9419f7bSJesper Dangaard Brouer __entry->processed, __entry->drops, 22992164774SLorenzo Bianconi __entry->sched, 23028b1520eSLorenzo Bianconi __entry->xdp_pass, __entry->xdp_drop, __entry->xdp_redirect) 231f9419f7bSJesper Dangaard Brouer ); 232f9419f7bSJesper Dangaard Brouer 233f9419f7bSJesper Dangaard Brouer TRACE_EVENT(xdp_cpumap_enqueue, 234f9419f7bSJesper Dangaard Brouer 235f9419f7bSJesper Dangaard Brouer TP_PROTO(int map_id, unsigned int processed, unsigned int drops, 236f9419f7bSJesper Dangaard Brouer int to_cpu), 237f9419f7bSJesper Dangaard Brouer 238f9419f7bSJesper Dangaard Brouer TP_ARGS(map_id, processed, drops, to_cpu), 239f9419f7bSJesper Dangaard Brouer 240f9419f7bSJesper Dangaard Brouer TP_STRUCT__entry( 241f9419f7bSJesper Dangaard Brouer __field(int, map_id) 242f9419f7bSJesper Dangaard Brouer __field(u32, act) 243f9419f7bSJesper Dangaard Brouer __field(int, cpu) 244f9419f7bSJesper Dangaard Brouer __field(unsigned int, drops) 245f9419f7bSJesper Dangaard Brouer __field(unsigned int, processed) 246f9419f7bSJesper Dangaard Brouer __field(int, to_cpu) 247f9419f7bSJesper Dangaard Brouer ), 248f9419f7bSJesper Dangaard Brouer 249f9419f7bSJesper Dangaard Brouer TP_fast_assign( 250f9419f7bSJesper Dangaard Brouer __entry->map_id = map_id; 251f9419f7bSJesper Dangaard Brouer __entry->act = XDP_REDIRECT; 252f9419f7bSJesper Dangaard Brouer __entry->cpu = smp_processor_id(); 253f9419f7bSJesper Dangaard Brouer __entry->drops = drops; 254f9419f7bSJesper Dangaard Brouer __entry->processed = processed; 255f9419f7bSJesper Dangaard Brouer __entry->to_cpu = to_cpu; 256f9419f7bSJesper Dangaard Brouer ), 257f9419f7bSJesper Dangaard Brouer 258f9419f7bSJesper Dangaard Brouer TP_printk("enqueue" 259f9419f7bSJesper Dangaard Brouer " cpu=%d map_id=%d action=%s" 260f9419f7bSJesper Dangaard Brouer " processed=%u drops=%u" 261f9419f7bSJesper Dangaard Brouer " to_cpu=%d", 262f9419f7bSJesper Dangaard Brouer __entry->cpu, __entry->map_id, 263f9419f7bSJesper Dangaard Brouer __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), 264f9419f7bSJesper Dangaard Brouer __entry->processed, __entry->drops, 265f9419f7bSJesper Dangaard Brouer __entry->to_cpu) 266f9419f7bSJesper Dangaard Brouer ); 267f9419f7bSJesper Dangaard Brouer 26838edddb8SJesper Dangaard Brouer TRACE_EVENT(xdp_devmap_xmit, 26938edddb8SJesper Dangaard Brouer 27058aa94f9SJesper Dangaard Brouer TP_PROTO(const struct net_device *from_dev, 27158aa94f9SJesper Dangaard Brouer const struct net_device *to_dev, 27258aa94f9SJesper Dangaard Brouer int sent, int drops, int err), 27338edddb8SJesper Dangaard Brouer 27458aa94f9SJesper Dangaard Brouer TP_ARGS(from_dev, to_dev, sent, drops, err), 27538edddb8SJesper Dangaard Brouer 27638edddb8SJesper Dangaard Brouer TP_STRUCT__entry( 27758aa94f9SJesper Dangaard Brouer __field(int, from_ifindex) 27838edddb8SJesper Dangaard Brouer __field(u32, act) 27958aa94f9SJesper Dangaard Brouer __field(int, to_ifindex) 28038edddb8SJesper Dangaard Brouer __field(int, drops) 28138edddb8SJesper Dangaard Brouer __field(int, sent) 282e74de52eSJesper Dangaard Brouer __field(int, err) 28338edddb8SJesper Dangaard Brouer ), 28438edddb8SJesper Dangaard Brouer 28538edddb8SJesper Dangaard Brouer TP_fast_assign( 28658aa94f9SJesper Dangaard Brouer __entry->from_ifindex = from_dev->ifindex; 28738edddb8SJesper Dangaard Brouer __entry->act = XDP_REDIRECT; 28858aa94f9SJesper Dangaard Brouer __entry->to_ifindex = to_dev->ifindex; 28938edddb8SJesper Dangaard Brouer __entry->drops = drops; 29038edddb8SJesper Dangaard Brouer __entry->sent = sent; 291e74de52eSJesper Dangaard Brouer __entry->err = err; 29238edddb8SJesper Dangaard Brouer ), 29338edddb8SJesper Dangaard Brouer 29438edddb8SJesper Dangaard Brouer TP_printk("ndo_xdp_xmit" 29558aa94f9SJesper Dangaard Brouer " from_ifindex=%d to_ifindex=%d action=%s" 29638edddb8SJesper Dangaard Brouer " sent=%d drops=%d" 29758aa94f9SJesper Dangaard Brouer " err=%d", 29858aa94f9SJesper Dangaard Brouer __entry->from_ifindex, __entry->to_ifindex, 29938edddb8SJesper Dangaard Brouer __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB), 30038edddb8SJesper Dangaard Brouer __entry->sent, __entry->drops, 30158aa94f9SJesper Dangaard Brouer __entry->err) 30238edddb8SJesper Dangaard Brouer ); 30338edddb8SJesper Dangaard Brouer 304f033b688SJesper Dangaard Brouer /* Expect users already include <net/xdp.h>, but not xdp_priv.h */ 305f033b688SJesper Dangaard Brouer #include <net/xdp_priv.h> 306f033b688SJesper Dangaard Brouer 307f033b688SJesper Dangaard Brouer #define __MEM_TYPE_MAP(FN) \ 308f033b688SJesper Dangaard Brouer FN(PAGE_SHARED) \ 309f033b688SJesper Dangaard Brouer FN(PAGE_ORDER0) \ 310f033b688SJesper Dangaard Brouer FN(PAGE_POOL) \ 3112b43470aSBjörn Töpel FN(XSK_BUFF_POOL) 312f033b688SJesper Dangaard Brouer 313f033b688SJesper Dangaard Brouer #define __MEM_TYPE_TP_FN(x) \ 314f033b688SJesper Dangaard Brouer TRACE_DEFINE_ENUM(MEM_TYPE_##x); 315f033b688SJesper Dangaard Brouer #define __MEM_TYPE_SYM_FN(x) \ 316f033b688SJesper Dangaard Brouer { MEM_TYPE_##x, #x }, 317f033b688SJesper Dangaard Brouer #define __MEM_TYPE_SYM_TAB \ 318f033b688SJesper Dangaard Brouer __MEM_TYPE_MAP(__MEM_TYPE_SYM_FN) { -1, 0 } 319f033b688SJesper Dangaard Brouer __MEM_TYPE_MAP(__MEM_TYPE_TP_FN) 320f033b688SJesper Dangaard Brouer 321f033b688SJesper Dangaard Brouer TRACE_EVENT(mem_disconnect, 322f033b688SJesper Dangaard Brouer 323c3f812ceSJonathan Lemon TP_PROTO(const struct xdp_mem_allocator *xa), 324f033b688SJesper Dangaard Brouer 325c3f812ceSJonathan Lemon TP_ARGS(xa), 326f033b688SJesper Dangaard Brouer 327f033b688SJesper Dangaard Brouer TP_STRUCT__entry( 328f033b688SJesper Dangaard Brouer __field(const struct xdp_mem_allocator *, xa) 329f033b688SJesper Dangaard Brouer __field(u32, mem_id) 330f033b688SJesper Dangaard Brouer __field(u32, mem_type) 331f033b688SJesper Dangaard Brouer __field(const void *, allocator) 332f033b688SJesper Dangaard Brouer ), 333f033b688SJesper Dangaard Brouer 334f033b688SJesper Dangaard Brouer TP_fast_assign( 335f033b688SJesper Dangaard Brouer __entry->xa = xa; 336f033b688SJesper Dangaard Brouer __entry->mem_id = xa->mem.id; 337f033b688SJesper Dangaard Brouer __entry->mem_type = xa->mem.type; 338f033b688SJesper Dangaard Brouer __entry->allocator = xa->allocator; 339f033b688SJesper Dangaard Brouer ), 340f033b688SJesper Dangaard Brouer 341c3f812ceSJonathan Lemon TP_printk("mem_id=%d mem_type=%s allocator=%p", 342f033b688SJesper Dangaard Brouer __entry->mem_id, 343f033b688SJesper Dangaard Brouer __print_symbolic(__entry->mem_type, __MEM_TYPE_SYM_TAB), 344c3f812ceSJonathan Lemon __entry->allocator 345f033b688SJesper Dangaard Brouer ) 346f033b688SJesper Dangaard Brouer ); 347f033b688SJesper Dangaard Brouer 348f033b688SJesper Dangaard Brouer TRACE_EVENT(mem_connect, 349f033b688SJesper Dangaard Brouer 350f033b688SJesper Dangaard Brouer TP_PROTO(const struct xdp_mem_allocator *xa, 351f033b688SJesper Dangaard Brouer const struct xdp_rxq_info *rxq), 352f033b688SJesper Dangaard Brouer 353f033b688SJesper Dangaard Brouer TP_ARGS(xa, rxq), 354f033b688SJesper Dangaard Brouer 355f033b688SJesper Dangaard Brouer TP_STRUCT__entry( 356f033b688SJesper Dangaard Brouer __field(const struct xdp_mem_allocator *, xa) 357f033b688SJesper Dangaard Brouer __field(u32, mem_id) 358f033b688SJesper Dangaard Brouer __field(u32, mem_type) 359f033b688SJesper Dangaard Brouer __field(const void *, allocator) 360f033b688SJesper Dangaard Brouer __field(const struct xdp_rxq_info *, rxq) 361f033b688SJesper Dangaard Brouer __field(int, ifindex) 362f033b688SJesper Dangaard Brouer ), 363f033b688SJesper Dangaard Brouer 364f033b688SJesper Dangaard Brouer TP_fast_assign( 365f033b688SJesper Dangaard Brouer __entry->xa = xa; 366f033b688SJesper Dangaard Brouer __entry->mem_id = xa->mem.id; 367f033b688SJesper Dangaard Brouer __entry->mem_type = xa->mem.type; 368f033b688SJesper Dangaard Brouer __entry->allocator = xa->allocator; 369f033b688SJesper Dangaard Brouer __entry->rxq = rxq; 370f033b688SJesper Dangaard Brouer __entry->ifindex = rxq->dev->ifindex; 371f033b688SJesper Dangaard Brouer ), 372f033b688SJesper Dangaard Brouer 373f033b688SJesper Dangaard Brouer TP_printk("mem_id=%d mem_type=%s allocator=%p" 374f033b688SJesper Dangaard Brouer " ifindex=%d", 375f033b688SJesper Dangaard Brouer __entry->mem_id, 376f033b688SJesper Dangaard Brouer __print_symbolic(__entry->mem_type, __MEM_TYPE_SYM_TAB), 377f033b688SJesper Dangaard Brouer __entry->allocator, 378f033b688SJesper Dangaard Brouer __entry->ifindex 379f033b688SJesper Dangaard Brouer ) 380f033b688SJesper Dangaard Brouer ); 381f033b688SJesper Dangaard Brouer 382f033b688SJesper Dangaard Brouer TRACE_EVENT(mem_return_failed, 383f033b688SJesper Dangaard Brouer 384f033b688SJesper Dangaard Brouer TP_PROTO(const struct xdp_mem_info *mem, 385f033b688SJesper Dangaard Brouer const struct page *page), 386f033b688SJesper Dangaard Brouer 387f033b688SJesper Dangaard Brouer TP_ARGS(mem, page), 388f033b688SJesper Dangaard Brouer 389f033b688SJesper Dangaard Brouer TP_STRUCT__entry( 390f033b688SJesper Dangaard Brouer __field(const struct page *, page) 391f033b688SJesper Dangaard Brouer __field(u32, mem_id) 392f033b688SJesper Dangaard Brouer __field(u32, mem_type) 393f033b688SJesper Dangaard Brouer ), 394f033b688SJesper Dangaard Brouer 395f033b688SJesper Dangaard Brouer TP_fast_assign( 396f033b688SJesper Dangaard Brouer __entry->page = page; 397f033b688SJesper Dangaard Brouer __entry->mem_id = mem->id; 398f033b688SJesper Dangaard Brouer __entry->mem_type = mem->type; 399f033b688SJesper Dangaard Brouer ), 400f033b688SJesper Dangaard Brouer 401f033b688SJesper Dangaard Brouer TP_printk("mem_id=%d mem_type=%s page=%p", 402f033b688SJesper Dangaard Brouer __entry->mem_id, 403f033b688SJesper Dangaard Brouer __print_symbolic(__entry->mem_type, __MEM_TYPE_SYM_TAB), 404f033b688SJesper Dangaard Brouer __entry->page 405f033b688SJesper Dangaard Brouer ) 406f033b688SJesper Dangaard Brouer ); 407f033b688SJesper Dangaard Brouer 408bf4ea1d0SLeon Hwang TRACE_EVENT(bpf_xdp_link_attach_failed, 409bf4ea1d0SLeon Hwang 410bf4ea1d0SLeon Hwang TP_PROTO(const char *msg), 411bf4ea1d0SLeon Hwang 412bf4ea1d0SLeon Hwang TP_ARGS(msg), 413bf4ea1d0SLeon Hwang 414bf4ea1d0SLeon Hwang TP_STRUCT__entry( 415bf4ea1d0SLeon Hwang __string(msg, msg) 416bf4ea1d0SLeon Hwang ), 417bf4ea1d0SLeon Hwang 418bf4ea1d0SLeon Hwang TP_fast_assign( 419bf4ea1d0SLeon Hwang __assign_str(msg, msg); 420bf4ea1d0SLeon Hwang ), 421bf4ea1d0SLeon Hwang 422bf4ea1d0SLeon Hwang TP_printk("errmsg=%s", __get_str(msg)) 423bf4ea1d0SLeon Hwang ); 424bf4ea1d0SLeon Hwang 425a67edbf4SDaniel Borkmann #endif /* _TRACE_XDP_H */ 426a67edbf4SDaniel Borkmann 427a67edbf4SDaniel Borkmann #include <trace/define_trace.h> 428