trace.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. /*
  2. * Copyright (c) 2005-2011 Atheros Communications Inc.
  3. * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #if !defined(_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
  18. #include <linux/tracepoint.h>
  19. #include "core.h"
  20. #if !defined(_TRACE_H_)
  21. static inline u32 ath10k_frm_hdr_len(const void *buf, size_t len)
  22. {
  23. const struct ieee80211_hdr *hdr = buf;
  24. /* In some rare cases (e.g. fcs error) device reports frame buffer
  25. * shorter than what frame header implies (e.g. len = 0). The buffer
  26. * can still be accessed so do a simple min() to guarantee caller
  27. * doesn't get value greater than len.
  28. */
  29. return min_t(u32, len, ieee80211_hdrlen(hdr->frame_control));
  30. }
  31. #endif
  32. #define _TRACE_H_
  33. /* create empty functions when tracing is disabled */
  34. #if !defined(CONFIG_ATH10K_TRACING)
  35. #undef TRACE_EVENT
  36. #define TRACE_EVENT(name, proto, ...) \
  37. static inline void trace_ ## name(proto) {}
  38. #undef DECLARE_EVENT_CLASS
  39. #define DECLARE_EVENT_CLASS(...)
  40. #undef DEFINE_EVENT
  41. #define DEFINE_EVENT(evt_class, name, proto, ...) \
  42. static inline void trace_ ## name(proto) {}
  43. #endif /* !CONFIG_ATH10K_TRACING || __CHECKER__ */
  44. #undef TRACE_SYSTEM
  45. #define TRACE_SYSTEM ath10k
  46. #define ATH10K_MSG_MAX 400
  47. DECLARE_EVENT_CLASS(ath10k_log_event,
  48. TP_PROTO(struct ath10k *ar, struct va_format *vaf),
  49. TP_ARGS(ar, vaf),
  50. TP_STRUCT__entry(
  51. __string(device, dev_name(ar->dev))
  52. __string(driver, dev_driver_string(ar->dev))
  53. __dynamic_array(char, msg, ATH10K_MSG_MAX)
  54. ),
  55. TP_fast_assign(
  56. __assign_str(device, dev_name(ar->dev));
  57. __assign_str(driver, dev_driver_string(ar->dev));
  58. WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
  59. ATH10K_MSG_MAX,
  60. vaf->fmt,
  61. *vaf->va) >= ATH10K_MSG_MAX);
  62. ),
  63. TP_printk(
  64. "%s %s %s",
  65. __get_str(driver),
  66. __get_str(device),
  67. __get_str(msg)
  68. )
  69. );
  70. DEFINE_EVENT(ath10k_log_event, ath10k_log_err,
  71. TP_PROTO(struct ath10k *ar, struct va_format *vaf),
  72. TP_ARGS(ar, vaf)
  73. );
  74. DEFINE_EVENT(ath10k_log_event, ath10k_log_warn,
  75. TP_PROTO(struct ath10k *ar, struct va_format *vaf),
  76. TP_ARGS(ar, vaf)
  77. );
  78. DEFINE_EVENT(ath10k_log_event, ath10k_log_info,
  79. TP_PROTO(struct ath10k *ar, struct va_format *vaf),
  80. TP_ARGS(ar, vaf)
  81. );
  82. TRACE_EVENT(ath10k_log_dbg,
  83. TP_PROTO(struct ath10k *ar, unsigned int level, struct va_format *vaf),
  84. TP_ARGS(ar, level, vaf),
  85. TP_STRUCT__entry(
  86. __string(device, dev_name(ar->dev))
  87. __string(driver, dev_driver_string(ar->dev))
  88. __field(unsigned int, level)
  89. __dynamic_array(char, msg, ATH10K_MSG_MAX)
  90. ),
  91. TP_fast_assign(
  92. __assign_str(device, dev_name(ar->dev));
  93. __assign_str(driver, dev_driver_string(ar->dev));
  94. __entry->level = level;
  95. WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
  96. ATH10K_MSG_MAX,
  97. vaf->fmt,
  98. *vaf->va) >= ATH10K_MSG_MAX);
  99. ),
  100. TP_printk(
  101. "%s %s %s",
  102. __get_str(driver),
  103. __get_str(device),
  104. __get_str(msg)
  105. )
  106. );
  107. TRACE_EVENT(ath10k_log_dbg_dump,
  108. TP_PROTO(struct ath10k *ar, const char *msg, const char *prefix,
  109. const void *buf, size_t buf_len),
  110. TP_ARGS(ar, msg, prefix, buf, buf_len),
  111. TP_STRUCT__entry(
  112. __string(device, dev_name(ar->dev))
  113. __string(driver, dev_driver_string(ar->dev))
  114. __string(msg, msg)
  115. __string(prefix, prefix)
  116. __field(size_t, buf_len)
  117. __dynamic_array(u8, buf, buf_len)
  118. ),
  119. TP_fast_assign(
  120. __assign_str(device, dev_name(ar->dev));
  121. __assign_str(driver, dev_driver_string(ar->dev));
  122. __assign_str(msg, msg);
  123. __assign_str(prefix, prefix);
  124. __entry->buf_len = buf_len;
  125. memcpy(__get_dynamic_array(buf), buf, buf_len);
  126. ),
  127. TP_printk(
  128. "%s %s %s/%s\n",
  129. __get_str(driver),
  130. __get_str(device),
  131. __get_str(prefix),
  132. __get_str(msg)
  133. )
  134. );
  135. TRACE_EVENT(ath10k_wmi_cmd,
  136. TP_PROTO(struct ath10k *ar, int id, const void *buf, size_t buf_len),
  137. TP_ARGS(ar, id, buf, buf_len),
  138. TP_STRUCT__entry(
  139. __string(device, dev_name(ar->dev))
  140. __string(driver, dev_driver_string(ar->dev))
  141. __field(unsigned int, id)
  142. __field(size_t, buf_len)
  143. __dynamic_array(u8, buf, buf_len)
  144. ),
  145. TP_fast_assign(
  146. __assign_str(device, dev_name(ar->dev));
  147. __assign_str(driver, dev_driver_string(ar->dev));
  148. __entry->id = id;
  149. __entry->buf_len = buf_len;
  150. memcpy(__get_dynamic_array(buf), buf, buf_len);
  151. ),
  152. TP_printk(
  153. "%s %s id %d len %zu",
  154. __get_str(driver),
  155. __get_str(device),
  156. __entry->id,
  157. __entry->buf_len
  158. )
  159. );
  160. TRACE_EVENT(ath10k_wmi_event,
  161. TP_PROTO(struct ath10k *ar, int id, const void *buf, size_t buf_len),
  162. TP_ARGS(ar, id, buf, buf_len),
  163. TP_STRUCT__entry(
  164. __string(device, dev_name(ar->dev))
  165. __string(driver, dev_driver_string(ar->dev))
  166. __field(unsigned int, id)
  167. __field(size_t, buf_len)
  168. __dynamic_array(u8, buf, buf_len)
  169. ),
  170. TP_fast_assign(
  171. __assign_str(device, dev_name(ar->dev));
  172. __assign_str(driver, dev_driver_string(ar->dev));
  173. __entry->id = id;
  174. __entry->buf_len = buf_len;
  175. memcpy(__get_dynamic_array(buf), buf, buf_len);
  176. ),
  177. TP_printk(
  178. "%s %s id %d len %zu",
  179. __get_str(driver),
  180. __get_str(device),
  181. __entry->id,
  182. __entry->buf_len
  183. )
  184. );
  185. TRACE_EVENT(ath10k_htt_stats,
  186. TP_PROTO(struct ath10k *ar, const void *buf, size_t buf_len),
  187. TP_ARGS(ar, buf, buf_len),
  188. TP_STRUCT__entry(
  189. __string(device, dev_name(ar->dev))
  190. __string(driver, dev_driver_string(ar->dev))
  191. __field(size_t, buf_len)
  192. __dynamic_array(u8, buf, buf_len)
  193. ),
  194. TP_fast_assign(
  195. __assign_str(device, dev_name(ar->dev));
  196. __assign_str(driver, dev_driver_string(ar->dev));
  197. __entry->buf_len = buf_len;
  198. memcpy(__get_dynamic_array(buf), buf, buf_len);
  199. ),
  200. TP_printk(
  201. "%s %s len %zu",
  202. __get_str(driver),
  203. __get_str(device),
  204. __entry->buf_len
  205. )
  206. );
  207. TRACE_EVENT(ath10k_wmi_dbglog,
  208. TP_PROTO(struct ath10k *ar, const void *buf, size_t buf_len),
  209. TP_ARGS(ar, buf, buf_len),
  210. TP_STRUCT__entry(
  211. __string(device, dev_name(ar->dev))
  212. __string(driver, dev_driver_string(ar->dev))
  213. __field(size_t, buf_len)
  214. __dynamic_array(u8, buf, buf_len)
  215. ),
  216. TP_fast_assign(
  217. __assign_str(device, dev_name(ar->dev));
  218. __assign_str(driver, dev_driver_string(ar->dev));
  219. __entry->buf_len = buf_len;
  220. memcpy(__get_dynamic_array(buf), buf, buf_len);
  221. ),
  222. TP_printk(
  223. "%s %s len %zu",
  224. __get_str(driver),
  225. __get_str(device),
  226. __entry->buf_len
  227. )
  228. );
  229. TRACE_EVENT(ath10k_htt_pktlog,
  230. TP_PROTO(struct ath10k *ar, const void *buf, u16 buf_len),
  231. TP_ARGS(ar, buf, buf_len),
  232. TP_STRUCT__entry(
  233. __string(device, dev_name(ar->dev))
  234. __string(driver, dev_driver_string(ar->dev))
  235. __field(u16, buf_len)
  236. __dynamic_array(u8, pktlog, buf_len)
  237. ),
  238. TP_fast_assign(
  239. __assign_str(device, dev_name(ar->dev));
  240. __assign_str(driver, dev_driver_string(ar->dev));
  241. __entry->buf_len = buf_len;
  242. memcpy(__get_dynamic_array(pktlog), buf, buf_len);
  243. ),
  244. TP_printk(
  245. "%s %s size %hu",
  246. __get_str(driver),
  247. __get_str(device),
  248. __entry->buf_len
  249. )
  250. );
  251. TRACE_EVENT(ath10k_htt_tx,
  252. TP_PROTO(struct ath10k *ar, u16 msdu_id, u16 msdu_len,
  253. u8 vdev_id, u8 tid),
  254. TP_ARGS(ar, msdu_id, msdu_len, vdev_id, tid),
  255. TP_STRUCT__entry(
  256. __string(device, dev_name(ar->dev))
  257. __string(driver, dev_driver_string(ar->dev))
  258. __field(u16, msdu_id)
  259. __field(u16, msdu_len)
  260. __field(u8, vdev_id)
  261. __field(u8, tid)
  262. ),
  263. TP_fast_assign(
  264. __assign_str(device, dev_name(ar->dev));
  265. __assign_str(driver, dev_driver_string(ar->dev));
  266. __entry->msdu_id = msdu_id;
  267. __entry->msdu_len = msdu_len;
  268. __entry->vdev_id = vdev_id;
  269. __entry->tid = tid;
  270. ),
  271. TP_printk(
  272. "%s %s msdu_id %d msdu_len %d vdev_id %d tid %d",
  273. __get_str(driver),
  274. __get_str(device),
  275. __entry->msdu_id,
  276. __entry->msdu_len,
  277. __entry->vdev_id,
  278. __entry->tid
  279. )
  280. );
  281. TRACE_EVENT(ath10k_txrx_tx_unref,
  282. TP_PROTO(struct ath10k *ar, u16 msdu_id),
  283. TP_ARGS(ar, msdu_id),
  284. TP_STRUCT__entry(
  285. __string(device, dev_name(ar->dev))
  286. __string(driver, dev_driver_string(ar->dev))
  287. __field(u16, msdu_id)
  288. ),
  289. TP_fast_assign(
  290. __assign_str(device, dev_name(ar->dev));
  291. __assign_str(driver, dev_driver_string(ar->dev));
  292. __entry->msdu_id = msdu_id;
  293. ),
  294. TP_printk(
  295. "%s %s msdu_id %d",
  296. __get_str(driver),
  297. __get_str(device),
  298. __entry->msdu_id
  299. )
  300. );
  301. DECLARE_EVENT_CLASS(ath10k_hdr_event,
  302. TP_PROTO(struct ath10k *ar, const void *data, size_t len),
  303. TP_ARGS(ar, data, len),
  304. TP_STRUCT__entry(
  305. __string(device, dev_name(ar->dev))
  306. __string(driver, dev_driver_string(ar->dev))
  307. __field(size_t, len)
  308. __dynamic_array(u8, data, ath10k_frm_hdr_len(data, len))
  309. ),
  310. TP_fast_assign(
  311. __assign_str(device, dev_name(ar->dev));
  312. __assign_str(driver, dev_driver_string(ar->dev));
  313. __entry->len = ath10k_frm_hdr_len(data, len);
  314. memcpy(__get_dynamic_array(data), data, __entry->len);
  315. ),
  316. TP_printk(
  317. "%s %s len %zu\n",
  318. __get_str(driver),
  319. __get_str(device),
  320. __entry->len
  321. )
  322. );
  323. DECLARE_EVENT_CLASS(ath10k_payload_event,
  324. TP_PROTO(struct ath10k *ar, const void *data, size_t len),
  325. TP_ARGS(ar, data, len),
  326. TP_STRUCT__entry(
  327. __string(device, dev_name(ar->dev))
  328. __string(driver, dev_driver_string(ar->dev))
  329. __field(size_t, len)
  330. __dynamic_array(u8, payload, (len -
  331. ath10k_frm_hdr_len(data, len)))
  332. ),
  333. TP_fast_assign(
  334. __assign_str(device, dev_name(ar->dev));
  335. __assign_str(driver, dev_driver_string(ar->dev));
  336. __entry->len = len - ath10k_frm_hdr_len(data, len);
  337. memcpy(__get_dynamic_array(payload),
  338. data + ath10k_frm_hdr_len(data, len), __entry->len);
  339. ),
  340. TP_printk(
  341. "%s %s len %zu\n",
  342. __get_str(driver),
  343. __get_str(device),
  344. __entry->len
  345. )
  346. );
  347. DEFINE_EVENT(ath10k_hdr_event, ath10k_tx_hdr,
  348. TP_PROTO(struct ath10k *ar, const void *data, size_t len),
  349. TP_ARGS(ar, data, len)
  350. );
  351. DEFINE_EVENT(ath10k_payload_event, ath10k_tx_payload,
  352. TP_PROTO(struct ath10k *ar, const void *data, size_t len),
  353. TP_ARGS(ar, data, len)
  354. );
  355. DEFINE_EVENT(ath10k_hdr_event, ath10k_rx_hdr,
  356. TP_PROTO(struct ath10k *ar, const void *data, size_t len),
  357. TP_ARGS(ar, data, len)
  358. );
  359. DEFINE_EVENT(ath10k_payload_event, ath10k_rx_payload,
  360. TP_PROTO(struct ath10k *ar, const void *data, size_t len),
  361. TP_ARGS(ar, data, len)
  362. );
  363. TRACE_EVENT(ath10k_htt_rx_desc,
  364. TP_PROTO(struct ath10k *ar, const void *data, size_t len),
  365. TP_ARGS(ar, data, len),
  366. TP_STRUCT__entry(
  367. __string(device, dev_name(ar->dev))
  368. __string(driver, dev_driver_string(ar->dev))
  369. __field(u16, len)
  370. __dynamic_array(u8, rxdesc, len)
  371. ),
  372. TP_fast_assign(
  373. __assign_str(device, dev_name(ar->dev));
  374. __assign_str(driver, dev_driver_string(ar->dev));
  375. __entry->len = len;
  376. memcpy(__get_dynamic_array(rxdesc), data, len);
  377. ),
  378. TP_printk(
  379. "%s %s rxdesc len %d",
  380. __get_str(driver),
  381. __get_str(device),
  382. __entry->len
  383. )
  384. );
  385. TRACE_EVENT(ath10k_wmi_diag_container,
  386. TP_PROTO(struct ath10k *ar,
  387. u8 type,
  388. u32 timestamp,
  389. u32 code,
  390. u16 len,
  391. const void *data),
  392. TP_ARGS(ar, type, timestamp, code, len, data),
  393. TP_STRUCT__entry(
  394. __string(device, dev_name(ar->dev))
  395. __string(driver, dev_driver_string(ar->dev))
  396. __field(u8, type)
  397. __field(u32, timestamp)
  398. __field(u32, code)
  399. __field(u16, len)
  400. __dynamic_array(u8, data, len)
  401. ),
  402. TP_fast_assign(
  403. __assign_str(device, dev_name(ar->dev));
  404. __assign_str(driver, dev_driver_string(ar->dev));
  405. __entry->type = type;
  406. __entry->timestamp = timestamp;
  407. __entry->code = code;
  408. __entry->len = len;
  409. memcpy(__get_dynamic_array(data), data, len);
  410. ),
  411. TP_printk(
  412. "%s %s diag container type %hhu timestamp %u code %u len %d",
  413. __get_str(driver),
  414. __get_str(device),
  415. __entry->type,
  416. __entry->timestamp,
  417. __entry->code,
  418. __entry->len
  419. )
  420. );
  421. TRACE_EVENT(ath10k_wmi_diag,
  422. TP_PROTO(struct ath10k *ar, const void *data, size_t len),
  423. TP_ARGS(ar, data, len),
  424. TP_STRUCT__entry(
  425. __string(device, dev_name(ar->dev))
  426. __string(driver, dev_driver_string(ar->dev))
  427. __field(u16, len)
  428. __dynamic_array(u8, data, len)
  429. ),
  430. TP_fast_assign(
  431. __assign_str(device, dev_name(ar->dev));
  432. __assign_str(driver, dev_driver_string(ar->dev));
  433. __entry->len = len;
  434. memcpy(__get_dynamic_array(data), data, len);
  435. ),
  436. TP_printk(
  437. "%s %s tlv diag len %d",
  438. __get_str(driver),
  439. __get_str(device),
  440. __entry->len
  441. )
  442. );
  443. #endif /* _TRACE_H_ || TRACE_HEADER_MULTI_READ*/
  444. /* we don't want to use include/trace/events */
  445. #undef TRACE_INCLUDE_PATH
  446. #define TRACE_INCLUDE_PATH .
  447. #undef TRACE_INCLUDE_FILE
  448. #define TRACE_INCLUDE_FILE trace
  449. /* This part must be outside protection */
  450. #include <trace/define_trace.h>