xdp.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM xdp
  3. #if !defined(_TRACE_XDP_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_XDP_H
  5. #include <linux/netdevice.h>
  6. #include <linux/filter.h>
  7. #include <linux/tracepoint.h>
  8. #define __XDP_ACT_MAP(FN) \
  9. FN(ABORTED) \
  10. FN(DROP) \
  11. FN(PASS) \
  12. FN(TX) \
  13. FN(REDIRECT)
  14. #define __XDP_ACT_TP_FN(x) \
  15. TRACE_DEFINE_ENUM(XDP_##x);
  16. #define __XDP_ACT_SYM_FN(x) \
  17. { XDP_##x, #x },
  18. #define __XDP_ACT_SYM_TAB \
  19. __XDP_ACT_MAP(__XDP_ACT_SYM_FN) { -1, 0 }
  20. __XDP_ACT_MAP(__XDP_ACT_TP_FN)
  21. TRACE_EVENT(xdp_exception,
  22. TP_PROTO(const struct net_device *dev,
  23. const struct bpf_prog *xdp, u32 act),
  24. TP_ARGS(dev, xdp, act),
  25. TP_STRUCT__entry(
  26. __field(int, prog_id)
  27. __field(u32, act)
  28. __field(int, ifindex)
  29. ),
  30. TP_fast_assign(
  31. __entry->prog_id = xdp->aux->id;
  32. __entry->act = act;
  33. __entry->ifindex = dev->ifindex;
  34. ),
  35. TP_printk("prog_id=%d action=%s ifindex=%d",
  36. __entry->prog_id,
  37. __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
  38. __entry->ifindex)
  39. );
  40. DECLARE_EVENT_CLASS(xdp_redirect_template,
  41. TP_PROTO(const struct net_device *dev,
  42. const struct bpf_prog *xdp,
  43. int to_ifindex, int err,
  44. const struct bpf_map *map, u32 map_index),
  45. TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
  46. TP_STRUCT__entry(
  47. __field(int, prog_id)
  48. __field(u32, act)
  49. __field(int, ifindex)
  50. __field(int, err)
  51. __field(int, to_ifindex)
  52. __field(u32, map_id)
  53. __field(int, map_index)
  54. ),
  55. TP_fast_assign(
  56. __entry->prog_id = xdp->aux->id;
  57. __entry->act = XDP_REDIRECT;
  58. __entry->ifindex = dev->ifindex;
  59. __entry->err = err;
  60. __entry->to_ifindex = to_ifindex;
  61. __entry->map_id = map ? map->id : 0;
  62. __entry->map_index = map_index;
  63. ),
  64. TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d",
  65. __entry->prog_id,
  66. __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
  67. __entry->ifindex, __entry->to_ifindex,
  68. __entry->err)
  69. );
  70. DEFINE_EVENT(xdp_redirect_template, xdp_redirect,
  71. TP_PROTO(const struct net_device *dev,
  72. const struct bpf_prog *xdp,
  73. int to_ifindex, int err,
  74. const struct bpf_map *map, u32 map_index),
  75. TP_ARGS(dev, xdp, to_ifindex, err, map, map_index)
  76. );
  77. DEFINE_EVENT(xdp_redirect_template, xdp_redirect_err,
  78. TP_PROTO(const struct net_device *dev,
  79. const struct bpf_prog *xdp,
  80. int to_ifindex, int err,
  81. const struct bpf_map *map, u32 map_index),
  82. TP_ARGS(dev, xdp, to_ifindex, err, map, map_index)
  83. );
  84. #define _trace_xdp_redirect(dev, xdp, to) \
  85. trace_xdp_redirect(dev, xdp, to, 0, NULL, 0);
  86. #define _trace_xdp_redirect_err(dev, xdp, to, err) \
  87. trace_xdp_redirect_err(dev, xdp, to, err, NULL, 0);
  88. DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map,
  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),
  94. TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d"
  95. " map_id=%d map_index=%d",
  96. __entry->prog_id,
  97. __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
  98. __entry->ifindex, __entry->to_ifindex,
  99. __entry->err,
  100. __entry->map_id, __entry->map_index)
  101. );
  102. DEFINE_EVENT_PRINT(xdp_redirect_template, xdp_redirect_map_err,
  103. TP_PROTO(const struct net_device *dev,
  104. const struct bpf_prog *xdp,
  105. int to_ifindex, int err,
  106. const struct bpf_map *map, u32 map_index),
  107. TP_ARGS(dev, xdp, to_ifindex, err, map, map_index),
  108. TP_printk("prog_id=%d action=%s ifindex=%d to_ifindex=%d err=%d"
  109. " map_id=%d map_index=%d",
  110. __entry->prog_id,
  111. __print_symbolic(__entry->act, __XDP_ACT_SYM_TAB),
  112. __entry->ifindex, __entry->to_ifindex,
  113. __entry->err,
  114. __entry->map_id, __entry->map_index)
  115. );
  116. #define _trace_xdp_redirect_map(dev, xdp, fwd, map, idx) \
  117. trace_xdp_redirect_map(dev, xdp, fwd ? fwd->ifindex : 0, \
  118. 0, map, idx)
  119. #define _trace_xdp_redirect_map_err(dev, xdp, fwd, map, idx, err) \
  120. trace_xdp_redirect_map_err(dev, xdp, fwd ? fwd->ifindex : 0, \
  121. err, map, idx)
  122. #endif /* _TRACE_XDP_H */
  123. #include <trace/define_trace.h>