trace.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. /*
  2. * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
  3. * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #if !defined(__MT7601U_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
  15. #define __MT7601U_TRACE_H
  16. #include <linux/tracepoint.h>
  17. #include "mt7601u.h"
  18. #include "mac.h"
  19. #undef TRACE_SYSTEM
  20. #define TRACE_SYSTEM mt7601u
  21. #define MAXNAME 32
  22. #define DEV_ENTRY __array(char, wiphy_name, 32)
  23. #define DEV_ASSIGN strlcpy(__entry->wiphy_name, \
  24. wiphy_name(dev->hw->wiphy), MAXNAME)
  25. #define DEV_PR_FMT "%s "
  26. #define DEV_PR_ARG __entry->wiphy_name
  27. #define REG_ENTRY __field(u32, reg) __field(u32, val)
  28. #define REG_ASSIGN __entry->reg = reg; __entry->val = val
  29. #define REG_PR_FMT "%04x=%08x"
  30. #define REG_PR_ARG __entry->reg, __entry->val
  31. DECLARE_EVENT_CLASS(dev_reg_evt,
  32. TP_PROTO(struct mt7601u_dev *dev, u32 reg, u32 val),
  33. TP_ARGS(dev, reg, val),
  34. TP_STRUCT__entry(
  35. DEV_ENTRY
  36. REG_ENTRY
  37. ),
  38. TP_fast_assign(
  39. DEV_ASSIGN;
  40. REG_ASSIGN;
  41. ),
  42. TP_printk(
  43. DEV_PR_FMT REG_PR_FMT,
  44. DEV_PR_ARG, REG_PR_ARG
  45. )
  46. );
  47. DEFINE_EVENT(dev_reg_evt, reg_read,
  48. TP_PROTO(struct mt7601u_dev *dev, u32 reg, u32 val),
  49. TP_ARGS(dev, reg, val)
  50. );
  51. DEFINE_EVENT(dev_reg_evt, reg_write,
  52. TP_PROTO(struct mt7601u_dev *dev, u32 reg, u32 val),
  53. TP_ARGS(dev, reg, val)
  54. );
  55. TRACE_EVENT(mt_submit_urb,
  56. TP_PROTO(struct mt7601u_dev *dev, struct urb *u),
  57. TP_ARGS(dev, u),
  58. TP_STRUCT__entry(
  59. DEV_ENTRY __field(unsigned, pipe) __field(u32, len)
  60. ),
  61. TP_fast_assign(
  62. DEV_ASSIGN;
  63. __entry->pipe = u->pipe;
  64. __entry->len = u->transfer_buffer_length;
  65. ),
  66. TP_printk(DEV_PR_FMT "p:%08x len:%u",
  67. DEV_PR_ARG, __entry->pipe, __entry->len)
  68. );
  69. #define trace_mt_submit_urb_sync(__dev, __pipe, __len) ({ \
  70. struct urb u; \
  71. u.pipe = __pipe; \
  72. u.transfer_buffer_length = __len; \
  73. trace_mt_submit_urb(__dev, &u); \
  74. })
  75. TRACE_EVENT(mt_mcu_msg_send,
  76. TP_PROTO(struct mt7601u_dev *dev,
  77. struct sk_buff *skb, u32 csum, bool resp),
  78. TP_ARGS(dev, skb, csum, resp),
  79. TP_STRUCT__entry(
  80. DEV_ENTRY
  81. __field(u32, info)
  82. __field(u32, csum)
  83. __field(bool, resp)
  84. ),
  85. TP_fast_assign(
  86. DEV_ASSIGN;
  87. __entry->info = *(u32 *)skb->data;
  88. __entry->csum = csum;
  89. __entry->resp = resp;
  90. ),
  91. TP_printk(DEV_PR_FMT "i:%08x c:%08x r:%d",
  92. DEV_PR_ARG, __entry->info, __entry->csum, __entry->resp)
  93. );
  94. TRACE_EVENT(mt_vend_req,
  95. TP_PROTO(struct mt7601u_dev *dev, unsigned pipe, u8 req, u8 req_type,
  96. u16 val, u16 offset, void *buf, size_t buflen, int ret),
  97. TP_ARGS(dev, pipe, req, req_type, val, offset, buf, buflen, ret),
  98. TP_STRUCT__entry(
  99. DEV_ENTRY
  100. __field(unsigned, pipe) __field(u8, req) __field(u8, req_type)
  101. __field(u16, val) __field(u16, offset) __field(void*, buf)
  102. __field(int, buflen) __field(int, ret)
  103. ),
  104. TP_fast_assign(
  105. DEV_ASSIGN;
  106. __entry->pipe = pipe;
  107. __entry->req = req;
  108. __entry->req_type = req_type;
  109. __entry->val = val;
  110. __entry->offset = offset;
  111. __entry->buf = buf;
  112. __entry->buflen = buflen;
  113. __entry->ret = ret;
  114. ),
  115. TP_printk(DEV_PR_FMT
  116. "%d p:%08x req:%02hhx %02hhx val:%04hx %04hx buf:%d %d",
  117. DEV_PR_ARG, __entry->ret, __entry->pipe, __entry->req,
  118. __entry->req_type, __entry->val, __entry->offset,
  119. !!__entry->buf, __entry->buflen)
  120. );
  121. TRACE_EVENT(ee_read,
  122. TP_PROTO(struct mt7601u_dev *dev, int offset, u16 val),
  123. TP_ARGS(dev, offset, val),
  124. TP_STRUCT__entry(
  125. DEV_ENTRY
  126. __field(int, o) __field(u16, v)
  127. ),
  128. TP_fast_assign(
  129. DEV_ASSIGN;
  130. __entry->o = offset;
  131. __entry->v = val;
  132. ),
  133. TP_printk(DEV_PR_FMT "%04x=%04x", DEV_PR_ARG, __entry->o, __entry->v)
  134. );
  135. DECLARE_EVENT_CLASS(dev_rf_reg_evt,
  136. TP_PROTO(struct mt7601u_dev *dev, u8 bank, u8 reg, u8 val),
  137. TP_ARGS(dev, bank, reg, val),
  138. TP_STRUCT__entry(
  139. DEV_ENTRY
  140. __field(u8, bank)
  141. __field(u8, reg)
  142. __field(u8, val)
  143. ),
  144. TP_fast_assign(
  145. DEV_ASSIGN;
  146. REG_ASSIGN;
  147. __entry->bank = bank;
  148. ),
  149. TP_printk(
  150. DEV_PR_FMT "%02hhx:%02hhx=%02hhx",
  151. DEV_PR_ARG, __entry->bank, __entry->reg, __entry->val
  152. )
  153. );
  154. DEFINE_EVENT(dev_rf_reg_evt, rf_read,
  155. TP_PROTO(struct mt7601u_dev *dev, u8 bank, u8 reg, u8 val),
  156. TP_ARGS(dev, bank, reg, val)
  157. );
  158. DEFINE_EVENT(dev_rf_reg_evt, rf_write,
  159. TP_PROTO(struct mt7601u_dev *dev, u8 bank, u8 reg, u8 val),
  160. TP_ARGS(dev, bank, reg, val)
  161. );
  162. DECLARE_EVENT_CLASS(dev_bbp_reg_evt,
  163. TP_PROTO(struct mt7601u_dev *dev, u8 reg, u8 val),
  164. TP_ARGS(dev, reg, val),
  165. TP_STRUCT__entry(
  166. DEV_ENTRY
  167. __field(u8, reg)
  168. __field(u8, val)
  169. ),
  170. TP_fast_assign(
  171. DEV_ASSIGN;
  172. REG_ASSIGN;
  173. ),
  174. TP_printk(
  175. DEV_PR_FMT "%02hhx=%02hhx",
  176. DEV_PR_ARG, __entry->reg, __entry->val
  177. )
  178. );
  179. DEFINE_EVENT(dev_bbp_reg_evt, bbp_read,
  180. TP_PROTO(struct mt7601u_dev *dev, u8 reg, u8 val),
  181. TP_ARGS(dev, reg, val)
  182. );
  183. DEFINE_EVENT(dev_bbp_reg_evt, bbp_write,
  184. TP_PROTO(struct mt7601u_dev *dev, u8 reg, u8 val),
  185. TP_ARGS(dev, reg, val)
  186. );
  187. DECLARE_EVENT_CLASS(dev_simple_evt,
  188. TP_PROTO(struct mt7601u_dev *dev, u8 val),
  189. TP_ARGS(dev, val),
  190. TP_STRUCT__entry(
  191. DEV_ENTRY
  192. __field(u8, val)
  193. ),
  194. TP_fast_assign(
  195. DEV_ASSIGN;
  196. __entry->val = val;
  197. ),
  198. TP_printk(
  199. DEV_PR_FMT "%02hhx", DEV_PR_ARG, __entry->val
  200. )
  201. );
  202. DEFINE_EVENT(dev_simple_evt, temp_mode,
  203. TP_PROTO(struct mt7601u_dev *dev, u8 val),
  204. TP_ARGS(dev, val)
  205. );
  206. DEFINE_EVENT(dev_simple_evt, read_temp,
  207. TP_PROTO(struct mt7601u_dev *dev, u8 val),
  208. TP_ARGS(dev, val)
  209. );
  210. DEFINE_EVENT(dev_simple_evt, freq_cal_adjust,
  211. TP_PROTO(struct mt7601u_dev *dev, u8 val),
  212. TP_ARGS(dev, val)
  213. );
  214. TRACE_EVENT(freq_cal_offset,
  215. TP_PROTO(struct mt7601u_dev *dev, u8 phy_mode, s8 freq_off),
  216. TP_ARGS(dev, phy_mode, freq_off),
  217. TP_STRUCT__entry(
  218. DEV_ENTRY
  219. __field(u8, phy_mode)
  220. __field(s8, freq_off)
  221. ),
  222. TP_fast_assign(
  223. DEV_ASSIGN;
  224. __entry->phy_mode = phy_mode;
  225. __entry->freq_off = freq_off;
  226. ),
  227. TP_printk(DEV_PR_FMT "phy:%02hhx off:%02hhx",
  228. DEV_PR_ARG, __entry->phy_mode, __entry->freq_off)
  229. );
  230. TRACE_EVENT(mt_rx,
  231. TP_PROTO(struct mt7601u_dev *dev, struct mt7601u_rxwi *rxwi, u32 f),
  232. TP_ARGS(dev, rxwi, f),
  233. TP_STRUCT__entry(
  234. DEV_ENTRY
  235. __field_struct(struct mt7601u_rxwi, rxwi)
  236. __field(u32, fce_info)
  237. ),
  238. TP_fast_assign(
  239. DEV_ASSIGN;
  240. __entry->rxwi = *rxwi;
  241. __entry->fce_info = f;
  242. ),
  243. TP_printk(DEV_PR_FMT "rxi:%08x ctl:%08x frag_sn:%04hx rate:%04hx "
  244. "uknw:%02hhx z:%02hhx%02hhx%02hhx snr:%02hhx "
  245. "ant:%02hhx gain:%02hhx freq_o:%02hhx "
  246. "r:%08x ea:%08x fce:%08x", DEV_PR_ARG,
  247. le32_to_cpu(__entry->rxwi.rxinfo),
  248. le32_to_cpu(__entry->rxwi.ctl),
  249. le16_to_cpu(__entry->rxwi.frag_sn),
  250. le16_to_cpu(__entry->rxwi.rate),
  251. __entry->rxwi.unknown,
  252. __entry->rxwi.zero[0], __entry->rxwi.zero[1],
  253. __entry->rxwi.zero[2],
  254. __entry->rxwi.snr, __entry->rxwi.ant,
  255. __entry->rxwi.gain, __entry->rxwi.freq_off,
  256. __entry->rxwi.resv2, __entry->rxwi.expert_ant,
  257. __entry->fce_info)
  258. );
  259. TRACE_EVENT(mt_tx,
  260. TP_PROTO(struct mt7601u_dev *dev, struct sk_buff *skb,
  261. struct mt76_sta *sta, struct mt76_txwi *h),
  262. TP_ARGS(dev, skb, sta, h),
  263. TP_STRUCT__entry(
  264. DEV_ENTRY
  265. __field_struct(struct mt76_txwi, h)
  266. __field(struct sk_buff *, skb)
  267. __field(struct mt76_sta *, sta)
  268. ),
  269. TP_fast_assign(
  270. DEV_ASSIGN;
  271. __entry->h = *h;
  272. __entry->skb = skb;
  273. __entry->sta = sta;
  274. ),
  275. TP_printk(DEV_PR_FMT "skb:%p sta:%p flg:%04hx rate_ctl:%04hx "
  276. "ack:%02hhx wcid:%02hhx len_ctl:%05hx", DEV_PR_ARG,
  277. __entry->skb, __entry->sta,
  278. le16_to_cpu(__entry->h.flags),
  279. le16_to_cpu(__entry->h.rate_ctl),
  280. __entry->h.ack_ctl, __entry->h.wcid,
  281. le16_to_cpu(__entry->h.len_ctl))
  282. );
  283. TRACE_EVENT(mt_tx_dma_done,
  284. TP_PROTO(struct mt7601u_dev *dev, struct sk_buff *skb),
  285. TP_ARGS(dev, skb),
  286. TP_STRUCT__entry(
  287. DEV_ENTRY
  288. __field(struct sk_buff *, skb)
  289. ),
  290. TP_fast_assign(
  291. DEV_ASSIGN;
  292. __entry->skb = skb;
  293. ),
  294. TP_printk(DEV_PR_FMT "%p", DEV_PR_ARG, __entry->skb)
  295. );
  296. TRACE_EVENT(mt_tx_status_cleaned,
  297. TP_PROTO(struct mt7601u_dev *dev, int cleaned),
  298. TP_ARGS(dev, cleaned),
  299. TP_STRUCT__entry(
  300. DEV_ENTRY
  301. __field(int, cleaned)
  302. ),
  303. TP_fast_assign(
  304. DEV_ASSIGN;
  305. __entry->cleaned = cleaned;
  306. ),
  307. TP_printk(DEV_PR_FMT "%d", DEV_PR_ARG, __entry->cleaned)
  308. );
  309. TRACE_EVENT(mt_tx_status,
  310. TP_PROTO(struct mt7601u_dev *dev, u32 stat1, u32 stat2),
  311. TP_ARGS(dev, stat1, stat2),
  312. TP_STRUCT__entry(
  313. DEV_ENTRY
  314. __field(u32, stat1) __field(u32, stat2)
  315. ),
  316. TP_fast_assign(
  317. DEV_ASSIGN;
  318. __entry->stat1 = stat1;
  319. __entry->stat2 = stat2;
  320. ),
  321. TP_printk(DEV_PR_FMT "%08x %08x",
  322. DEV_PR_ARG, __entry->stat1, __entry->stat2)
  323. );
  324. TRACE_EVENT(mt_rx_dma_aggr,
  325. TP_PROTO(struct mt7601u_dev *dev, int cnt, bool paged),
  326. TP_ARGS(dev, cnt, paged),
  327. TP_STRUCT__entry(
  328. DEV_ENTRY
  329. __field(u8, cnt)
  330. __field(bool, paged)
  331. ),
  332. TP_fast_assign(
  333. DEV_ASSIGN;
  334. __entry->cnt = cnt;
  335. __entry->paged = paged;
  336. ),
  337. TP_printk(DEV_PR_FMT "cnt:%d paged:%d",
  338. DEV_PR_ARG, __entry->cnt, __entry->paged)
  339. );
  340. DEFINE_EVENT(dev_simple_evt, set_key,
  341. TP_PROTO(struct mt7601u_dev *dev, u8 val),
  342. TP_ARGS(dev, val)
  343. );
  344. TRACE_EVENT(set_shared_key,
  345. TP_PROTO(struct mt7601u_dev *dev, u8 vid, u8 key),
  346. TP_ARGS(dev, vid, key),
  347. TP_STRUCT__entry(
  348. DEV_ENTRY
  349. __field(u8, vid)
  350. __field(u8, key)
  351. ),
  352. TP_fast_assign(
  353. DEV_ASSIGN;
  354. __entry->vid = vid;
  355. __entry->key = key;
  356. ),
  357. TP_printk(DEV_PR_FMT "phy:%02hhx off:%02hhx",
  358. DEV_PR_ARG, __entry->vid, __entry->key)
  359. );
  360. #endif
  361. #undef TRACE_INCLUDE_PATH
  362. #define TRACE_INCLUDE_PATH .
  363. #undef TRACE_INCLUDE_FILE
  364. #define TRACE_INCLUDE_FILE trace
  365. #include <trace/define_trace.h>