tracepoint.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright (c) 2013 Broadcom Corporation
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  11. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  13. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #if !defined(BRCMF_TRACEPOINT_H_) || defined(TRACE_HEADER_MULTI_READ)
  17. #define BRCMF_TRACEPOINT_H_
  18. #include <linux/types.h>
  19. #include <linux/tracepoint.h>
  20. #ifndef CONFIG_BRCM_TRACING
  21. #undef TRACE_EVENT
  22. #define TRACE_EVENT(name, proto, ...) \
  23. static inline void trace_ ## name(proto) {}
  24. #undef DECLARE_EVENT_CLASS
  25. #define DECLARE_EVENT_CLASS(...)
  26. #undef DEFINE_EVENT
  27. #define DEFINE_EVENT(evt_class, name, proto, ...) \
  28. static inline void trace_ ## name(proto) {}
  29. #endif /* CONFIG_BRCM_TRACING */
  30. #undef TRACE_SYSTEM
  31. #define TRACE_SYSTEM brcmfmac
  32. #define MAX_MSG_LEN 100
  33. TRACE_EVENT(brcmf_err,
  34. TP_PROTO(const char *func, struct va_format *vaf),
  35. TP_ARGS(func, vaf),
  36. TP_STRUCT__entry(
  37. __string(func, func)
  38. __dynamic_array(char, msg, MAX_MSG_LEN)
  39. ),
  40. TP_fast_assign(
  41. __assign_str(func, func);
  42. WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
  43. MAX_MSG_LEN, vaf->fmt,
  44. *vaf->va) >= MAX_MSG_LEN);
  45. ),
  46. TP_printk("%s: %s", __get_str(func), __get_str(msg))
  47. );
  48. TRACE_EVENT(brcmf_dbg,
  49. TP_PROTO(u32 level, const char *func, struct va_format *vaf),
  50. TP_ARGS(level, func, vaf),
  51. TP_STRUCT__entry(
  52. __field(u32, level)
  53. __string(func, func)
  54. __dynamic_array(char, msg, MAX_MSG_LEN)
  55. ),
  56. TP_fast_assign(
  57. __entry->level = level;
  58. __assign_str(func, func);
  59. WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
  60. MAX_MSG_LEN, vaf->fmt,
  61. *vaf->va) >= MAX_MSG_LEN);
  62. ),
  63. TP_printk("%s: %s", __get_str(func), __get_str(msg))
  64. );
  65. TRACE_EVENT(brcmf_hexdump,
  66. TP_PROTO(void *data, size_t len),
  67. TP_ARGS(data, len),
  68. TP_STRUCT__entry(
  69. __field(unsigned long, len)
  70. __field(unsigned long, addr)
  71. __dynamic_array(u8, hdata, len)
  72. ),
  73. TP_fast_assign(
  74. __entry->len = len;
  75. __entry->addr = (unsigned long)data;
  76. memcpy(__get_dynamic_array(hdata), data, len);
  77. ),
  78. TP_printk("hexdump [addr=%lx, length=%lu]", __entry->addr, __entry->len)
  79. );
  80. TRACE_EVENT(brcmf_bcdchdr,
  81. TP_PROTO(void *data),
  82. TP_ARGS(data),
  83. TP_STRUCT__entry(
  84. __field(u8, flags)
  85. __field(u8, prio)
  86. __field(u8, flags2)
  87. __field(u32, siglen)
  88. __dynamic_array(u8, signal, *((u8 *)data + 3) * 4)
  89. ),
  90. TP_fast_assign(
  91. __entry->flags = *(u8 *)data;
  92. __entry->prio = *((u8 *)data + 1);
  93. __entry->flags2 = *((u8 *)data + 2);
  94. __entry->siglen = *((u8 *)data + 3) * 4;
  95. memcpy(__get_dynamic_array(signal),
  96. (u8 *)data + 4, __entry->siglen);
  97. ),
  98. TP_printk("bcdc: prio=%d siglen=%d", __entry->prio, __entry->siglen)
  99. );
  100. #ifndef SDPCM_RX
  101. #define SDPCM_RX 0
  102. #endif
  103. #ifndef SDPCM_TX
  104. #define SDPCM_TX 1
  105. #endif
  106. #ifndef SDPCM_GLOM
  107. #define SDPCM_GLOM 2
  108. #endif
  109. TRACE_EVENT(brcmf_sdpcm_hdr,
  110. TP_PROTO(u8 dir, void *data),
  111. TP_ARGS(dir, data),
  112. TP_STRUCT__entry(
  113. __field(u8, dir)
  114. __field(u16, len)
  115. __dynamic_array(u8, hdr, dir == SDPCM_GLOM ? 20 : 12)
  116. ),
  117. TP_fast_assign(
  118. memcpy(__get_dynamic_array(hdr), data, dir == SDPCM_GLOM ? 20 : 12);
  119. __entry->len = *(u8 *)data | (*((u8 *)data + 1) << 8);
  120. __entry->dir = dir;
  121. ),
  122. TP_printk("sdpcm: %s len %u, seq %d",
  123. __entry->dir == SDPCM_RX ? "RX" : "TX",
  124. __entry->len, ((u8 *)__get_dynamic_array(hdr))[4])
  125. );
  126. #ifdef CONFIG_BRCM_TRACING
  127. #undef TRACE_INCLUDE_PATH
  128. #define TRACE_INCLUDE_PATH .
  129. #undef TRACE_INCLUDE_FILE
  130. #define TRACE_INCLUDE_FILE tracepoint
  131. #include <trace/define_trace.h>
  132. #endif /* CONFIG_BRCM_TRACING */
  133. #endif /* BRCMF_TRACEPOINT_H_ */