say N here. This enables compilation of support for
          outputting debugging information to the kernel log. The
          output is controlled via the module parameter debug.
+
+config BATMAN_ADV_TRACING
+       bool "B.A.T.M.A.N. tracing support"
+       depends on BATMAN_ADV
+       depends on EVENT_TRACING
+       help
+         This is an option for use by developers; most people should
+         say N here. Select this option to gather traces like the debug
+         messages using the generic tracing infrastructure of the kernel.
+         BATMAN_ADV_DEBUG must also be selected to get trace events for
+         batadv_dbg.
 
 batman-adv-y += send.o
 batman-adv-y += soft-interface.o
 batman-adv-y += sysfs.o
+batman-adv-$(CONFIG_BATMAN_ADV_TRACING) += trace.o
 batman-adv-y += tp_meter.o
 batman-adv-y += translation-table.o
 batman-adv-y += tvlv.o
+
+CFLAGS_trace.o := -I$(src)
 
 #include <stdarg.h>
 
 #include "debugfs.h"
+#include "trace.h"
 
 #define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1)
 
  */
 int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
 {
+       struct va_format vaf;
        va_list args;
-       char tmp_log_buf[256];
 
        va_start(args, fmt);
-       vscnprintf(tmp_log_buf, sizeof(tmp_log_buf), fmt, args);
-       batadv_fdebug_log(bat_priv->debug_log, "[%10u] %s",
-                         jiffies_to_msecs(jiffies), tmp_log_buf);
+
+       vaf.fmt = fmt;
+       vaf.va = &args;
+
+       batadv_fdebug_log(bat_priv->debug_log, "[%10u] %pV",
+                         jiffies_to_msecs(jiffies), &vaf);
+
+       trace_batadv_dbg(bat_priv, &vaf);
+
        va_end(args);
 
        return 0;
        if (!try_module_get(THIS_MODULE))
                return -EBUSY;
 
-       batadv_debugfs_deprecated(file, "");
+       batadv_debugfs_deprecated(file,
+                                 "Use tracepoint batadv:batadv_dbg instead\n");
 
        nonseekable_open(inode, file);
        file->private_data = inode->i_private;
 
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2010-2018  B.A.T.M.A.N. contributors:
+ *
+ * Sven Eckelmann
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/module.h>
+
+#define CREATE_TRACE_POINTS
+#include "trace.h"
 
--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2010-2018  B.A.T.M.A.N. contributors:
+ *
+ * Sven Eckelmann
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(_NET_BATMAN_ADV_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
+#define _NET_BATMAN_ADV_TRACE_H_
+
+#include "main.h"
+
+#include <linux/tracepoint.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM batadv
+
+/* provide dummy function when tracing is disabled */
+#if !defined(CONFIG_BATMAN_ADV_TRACING)
+
+#undef TRACE_EVENT
+#define TRACE_EVENT(name, proto, ...) \
+       static inline void trace_ ## name(proto) {}
+
+#endif /* CONFIG_BATMAN_ADV_TRACING */
+
+#define BATADV_MAX_MSG_LEN     256
+
+TRACE_EVENT(batadv_dbg,
+
+           TP_PROTO(struct batadv_priv *bat_priv,
+                    struct va_format *vaf),
+
+           TP_ARGS(bat_priv, vaf),
+
+           TP_STRUCT__entry(
+                   __string(device, bat_priv->soft_iface->name)
+                   __string(driver, KBUILD_MODNAME)
+                   __dynamic_array(char, msg, BATADV_MAX_MSG_LEN)
+           ),
+
+           TP_fast_assign(
+                   __assign_str(device, bat_priv->soft_iface->name);
+                   __assign_str(driver, KBUILD_MODNAME);
+                   WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
+                                          BATADV_MAX_MSG_LEN,
+                                          vaf->fmt,
+                                          *vaf->va) >= BATADV_MAX_MSG_LEN);
+           ),
+
+           TP_printk(
+                   "%s %s %s",
+                   __get_str(driver),
+                   __get_str(device),
+                   __get_str(msg)
+           )
+);
+
+#endif /* _NET_BATMAN_ADV_TRACE_H_ || TRACE_HEADER_MULTI_READ */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE trace
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>