trace.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2010-2018 B.A.T.M.A.N. contributors:
  3. *
  4. * Sven Eckelmann
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of version 2 of the GNU General Public
  8. * License as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #if !defined(_NET_BATMAN_ADV_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
  19. #define _NET_BATMAN_ADV_TRACE_H_
  20. #include "main.h"
  21. #include <linux/tracepoint.h>
  22. #undef TRACE_SYSTEM
  23. #define TRACE_SYSTEM batadv
  24. /* provide dummy function when tracing is disabled */
  25. #if !defined(CONFIG_BATMAN_ADV_TRACING)
  26. #undef TRACE_EVENT
  27. #define TRACE_EVENT(name, proto, ...) \
  28. static inline void trace_ ## name(proto) {}
  29. #endif /* CONFIG_BATMAN_ADV_TRACING */
  30. #define BATADV_MAX_MSG_LEN 256
  31. TRACE_EVENT(batadv_dbg,
  32. TP_PROTO(struct batadv_priv *bat_priv,
  33. struct va_format *vaf),
  34. TP_ARGS(bat_priv, vaf),
  35. TP_STRUCT__entry(
  36. __string(device, bat_priv->soft_iface->name)
  37. __string(driver, KBUILD_MODNAME)
  38. __dynamic_array(char, msg, BATADV_MAX_MSG_LEN)
  39. ),
  40. TP_fast_assign(
  41. __assign_str(device, bat_priv->soft_iface->name);
  42. __assign_str(driver, KBUILD_MODNAME);
  43. WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
  44. BATADV_MAX_MSG_LEN,
  45. vaf->fmt,
  46. *vaf->va) >= BATADV_MAX_MSG_LEN);
  47. ),
  48. TP_printk(
  49. "%s %s %s",
  50. __get_str(driver),
  51. __get_str(device),
  52. __get_str(msg)
  53. )
  54. );
  55. #endif /* _NET_BATMAN_ADV_TRACE_H_ || TRACE_HEADER_MULTI_READ */
  56. #undef TRACE_INCLUDE_PATH
  57. #define TRACE_INCLUDE_PATH .
  58. #undef TRACE_INCLUDE_FILE
  59. #define TRACE_INCLUDE_FILE trace
  60. /* This part must be outside protection */
  61. #include <trace/define_trace.h>