libata.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM libata
  3. #if !defined(_TRACE_LIBATA_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_LIBATA_H
  5. #include <linux/ata.h>
  6. #include <linux/libata.h>
  7. #include <linux/tracepoint.h>
  8. #include <linux/trace_seq.h>
  9. #define ata_opcode_name(opcode) { opcode, #opcode }
  10. #define show_opcode_name(val) \
  11. __print_symbolic(val, \
  12. ata_opcode_name(ATA_CMD_DEV_RESET), \
  13. ata_opcode_name(ATA_CMD_CHK_POWER), \
  14. ata_opcode_name(ATA_CMD_STANDBY), \
  15. ata_opcode_name(ATA_CMD_IDLE), \
  16. ata_opcode_name(ATA_CMD_EDD), \
  17. ata_opcode_name(ATA_CMD_DOWNLOAD_MICRO), \
  18. ata_opcode_name(ATA_CMD_DOWNLOAD_MICRO_DMA), \
  19. ata_opcode_name(ATA_CMD_NOP), \
  20. ata_opcode_name(ATA_CMD_FLUSH), \
  21. ata_opcode_name(ATA_CMD_FLUSH_EXT), \
  22. ata_opcode_name(ATA_CMD_ID_ATA), \
  23. ata_opcode_name(ATA_CMD_ID_ATAPI), \
  24. ata_opcode_name(ATA_CMD_SERVICE), \
  25. ata_opcode_name(ATA_CMD_READ), \
  26. ata_opcode_name(ATA_CMD_READ_EXT), \
  27. ata_opcode_name(ATA_CMD_READ_QUEUED), \
  28. ata_opcode_name(ATA_CMD_READ_STREAM_EXT), \
  29. ata_opcode_name(ATA_CMD_READ_STREAM_DMA_EXT), \
  30. ata_opcode_name(ATA_CMD_WRITE), \
  31. ata_opcode_name(ATA_CMD_WRITE_EXT), \
  32. ata_opcode_name(ATA_CMD_WRITE_QUEUED), \
  33. ata_opcode_name(ATA_CMD_WRITE_STREAM_EXT), \
  34. ata_opcode_name(ATA_CMD_WRITE_STREAM_DMA_EXT), \
  35. ata_opcode_name(ATA_CMD_WRITE_FUA_EXT), \
  36. ata_opcode_name(ATA_CMD_WRITE_QUEUED_FUA_EXT), \
  37. ata_opcode_name(ATA_CMD_FPDMA_READ), \
  38. ata_opcode_name(ATA_CMD_FPDMA_WRITE), \
  39. ata_opcode_name(ATA_CMD_NCQ_NON_DATA), \
  40. ata_opcode_name(ATA_CMD_FPDMA_SEND), \
  41. ata_opcode_name(ATA_CMD_FPDMA_RECV), \
  42. ata_opcode_name(ATA_CMD_PIO_READ), \
  43. ata_opcode_name(ATA_CMD_PIO_READ_EXT), \
  44. ata_opcode_name(ATA_CMD_PIO_WRITE), \
  45. ata_opcode_name(ATA_CMD_PIO_WRITE_EXT), \
  46. ata_opcode_name(ATA_CMD_READ_MULTI), \
  47. ata_opcode_name(ATA_CMD_READ_MULTI_EXT), \
  48. ata_opcode_name(ATA_CMD_WRITE_MULTI), \
  49. ata_opcode_name(ATA_CMD_WRITE_MULTI_EXT), \
  50. ata_opcode_name(ATA_CMD_WRITE_MULTI_FUA_EXT), \
  51. ata_opcode_name(ATA_CMD_SET_FEATURES), \
  52. ata_opcode_name(ATA_CMD_SET_MULTI), \
  53. ata_opcode_name(ATA_CMD_PACKET), \
  54. ata_opcode_name(ATA_CMD_VERIFY), \
  55. ata_opcode_name(ATA_CMD_VERIFY_EXT), \
  56. ata_opcode_name(ATA_CMD_WRITE_UNCORR_EXT), \
  57. ata_opcode_name(ATA_CMD_STANDBYNOW1), \
  58. ata_opcode_name(ATA_CMD_IDLEIMMEDIATE), \
  59. ata_opcode_name(ATA_CMD_SLEEP), \
  60. ata_opcode_name(ATA_CMD_INIT_DEV_PARAMS), \
  61. ata_opcode_name(ATA_CMD_READ_NATIVE_MAX), \
  62. ata_opcode_name(ATA_CMD_READ_NATIVE_MAX_EXT), \
  63. ata_opcode_name(ATA_CMD_SET_MAX), \
  64. ata_opcode_name(ATA_CMD_SET_MAX_EXT), \
  65. ata_opcode_name(ATA_CMD_READ_LOG_EXT), \
  66. ata_opcode_name(ATA_CMD_WRITE_LOG_EXT), \
  67. ata_opcode_name(ATA_CMD_READ_LOG_DMA_EXT), \
  68. ata_opcode_name(ATA_CMD_WRITE_LOG_DMA_EXT), \
  69. ata_opcode_name(ATA_CMD_TRUSTED_NONDATA), \
  70. ata_opcode_name(ATA_CMD_TRUSTED_RCV), \
  71. ata_opcode_name(ATA_CMD_TRUSTED_RCV_DMA), \
  72. ata_opcode_name(ATA_CMD_TRUSTED_SND), \
  73. ata_opcode_name(ATA_CMD_TRUSTED_SND_DMA), \
  74. ata_opcode_name(ATA_CMD_PMP_READ), \
  75. ata_opcode_name(ATA_CMD_PMP_READ_DMA), \
  76. ata_opcode_name(ATA_CMD_PMP_WRITE), \
  77. ata_opcode_name(ATA_CMD_PMP_WRITE_DMA), \
  78. ata_opcode_name(ATA_CMD_CONF_OVERLAY), \
  79. ata_opcode_name(ATA_CMD_SEC_SET_PASS), \
  80. ata_opcode_name(ATA_CMD_SEC_UNLOCK), \
  81. ata_opcode_name(ATA_CMD_SEC_ERASE_PREP), \
  82. ata_opcode_name(ATA_CMD_SEC_ERASE_UNIT), \
  83. ata_opcode_name(ATA_CMD_SEC_FREEZE_LOCK), \
  84. ata_opcode_name(ATA_CMD_SEC_DISABLE_PASS), \
  85. ata_opcode_name(ATA_CMD_CONFIG_STREAM), \
  86. ata_opcode_name(ATA_CMD_SMART), \
  87. ata_opcode_name(ATA_CMD_MEDIA_LOCK), \
  88. ata_opcode_name(ATA_CMD_MEDIA_UNLOCK), \
  89. ata_opcode_name(ATA_CMD_DSM), \
  90. ata_opcode_name(ATA_CMD_CHK_MED_CRD_TYP), \
  91. ata_opcode_name(ATA_CMD_CFA_REQ_EXT_ERR), \
  92. ata_opcode_name(ATA_CMD_CFA_WRITE_NE), \
  93. ata_opcode_name(ATA_CMD_CFA_TRANS_SECT), \
  94. ata_opcode_name(ATA_CMD_CFA_ERASE), \
  95. ata_opcode_name(ATA_CMD_CFA_WRITE_MULT_NE), \
  96. ata_opcode_name(ATA_CMD_REQ_SENSE_DATA), \
  97. ata_opcode_name(ATA_CMD_SANITIZE_DEVICE), \
  98. ata_opcode_name(ATA_CMD_ZAC_MGMT_IN), \
  99. ata_opcode_name(ATA_CMD_ZAC_MGMT_OUT), \
  100. ata_opcode_name(ATA_CMD_RESTORE), \
  101. ata_opcode_name(ATA_CMD_READ_LONG), \
  102. ata_opcode_name(ATA_CMD_READ_LONG_ONCE), \
  103. ata_opcode_name(ATA_CMD_WRITE_LONG), \
  104. ata_opcode_name(ATA_CMD_WRITE_LONG_ONCE))
  105. #define ata_error_name(result) { result, #result }
  106. #define show_error_name(val) \
  107. __print_symbolic(val, \
  108. ata_error_name(ATA_ICRC), \
  109. ata_error_name(ATA_UNC), \
  110. ata_error_name(ATA_MC), \
  111. ata_error_name(ATA_IDNF), \
  112. ata_error_name(ATA_MCR), \
  113. ata_error_name(ATA_ABORTED), \
  114. ata_error_name(ATA_TRK0NF), \
  115. ata_error_name(ATA_AMNF))
  116. #define ata_protocol_name(proto) { proto, #proto }
  117. #define show_protocol_name(val) \
  118. __print_symbolic(val, \
  119. ata_protocol_name(ATA_PROT_UNKNOWN), \
  120. ata_protocol_name(ATA_PROT_NODATA), \
  121. ata_protocol_name(ATA_PROT_PIO), \
  122. ata_protocol_name(ATA_PROT_DMA), \
  123. ata_protocol_name(ATA_PROT_NCQ), \
  124. ata_protocol_name(ATA_PROT_NCQ_NODATA), \
  125. ata_protocol_name(ATAPI_PROT_NODATA), \
  126. ata_protocol_name(ATAPI_PROT_PIO), \
  127. ata_protocol_name(ATAPI_PROT_DMA))
  128. const char *libata_trace_parse_status(struct trace_seq*, unsigned char);
  129. #define __parse_status(s) libata_trace_parse_status(p, s)
  130. const char *libata_trace_parse_eh_action(struct trace_seq *, unsigned int);
  131. #define __parse_eh_action(a) libata_trace_parse_eh_action(p, a)
  132. const char *libata_trace_parse_eh_err_mask(struct trace_seq *, unsigned int);
  133. #define __parse_eh_err_mask(m) libata_trace_parse_eh_err_mask(p, m)
  134. const char *libata_trace_parse_qc_flags(struct trace_seq *, unsigned int);
  135. #define __parse_qc_flags(f) libata_trace_parse_qc_flags(p, f)
  136. const char *libata_trace_parse_subcmd(struct trace_seq *, unsigned char,
  137. unsigned char, unsigned char);
  138. #define __parse_subcmd(c,f,h) libata_trace_parse_subcmd(p, c, f, h)
  139. TRACE_EVENT(ata_qc_issue,
  140. TP_PROTO(struct ata_queued_cmd *qc),
  141. TP_ARGS(qc),
  142. TP_STRUCT__entry(
  143. __field( unsigned int, ata_port )
  144. __field( unsigned int, ata_dev )
  145. __field( unsigned int, tag )
  146. __field( unsigned char, cmd )
  147. __field( unsigned char, dev )
  148. __field( unsigned char, lbal )
  149. __field( unsigned char, lbam )
  150. __field( unsigned char, lbah )
  151. __field( unsigned char, nsect )
  152. __field( unsigned char, feature )
  153. __field( unsigned char, hob_lbal )
  154. __field( unsigned char, hob_lbam )
  155. __field( unsigned char, hob_lbah )
  156. __field( unsigned char, hob_nsect )
  157. __field( unsigned char, hob_feature )
  158. __field( unsigned char, ctl )
  159. __field( unsigned char, proto )
  160. __field( unsigned long, flags )
  161. ),
  162. TP_fast_assign(
  163. __entry->ata_port = qc->ap->print_id;
  164. __entry->ata_dev = qc->dev->link->pmp + qc->dev->devno;
  165. __entry->tag = qc->tag;
  166. __entry->proto = qc->tf.protocol;
  167. __entry->cmd = qc->tf.command;
  168. __entry->dev = qc->tf.device;
  169. __entry->lbal = qc->tf.lbal;
  170. __entry->lbam = qc->tf.lbam;
  171. __entry->lbah = qc->tf.lbah;
  172. __entry->hob_lbal = qc->tf.hob_lbal;
  173. __entry->hob_lbam = qc->tf.hob_lbam;
  174. __entry->hob_lbah = qc->tf.hob_lbah;
  175. __entry->feature = qc->tf.feature;
  176. __entry->hob_feature = qc->tf.hob_feature;
  177. __entry->nsect = qc->tf.nsect;
  178. __entry->hob_nsect = qc->tf.hob_nsect;
  179. ),
  180. TP_printk("ata_port=%u ata_dev=%u tag=%d proto=%s cmd=%s%s " \
  181. " tf=(%02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x)",
  182. __entry->ata_port, __entry->ata_dev, __entry->tag,
  183. show_protocol_name(__entry->proto),
  184. show_opcode_name(__entry->cmd),
  185. __parse_subcmd(__entry->cmd, __entry->feature, __entry->hob_nsect),
  186. __entry->cmd, __entry->feature, __entry->nsect,
  187. __entry->lbal, __entry->lbam, __entry->lbah,
  188. __entry->hob_feature, __entry->hob_nsect,
  189. __entry->hob_lbal, __entry->hob_lbam, __entry->hob_lbah,
  190. __entry->dev)
  191. );
  192. DECLARE_EVENT_CLASS(ata_qc_complete_template,
  193. TP_PROTO(struct ata_queued_cmd *qc),
  194. TP_ARGS(qc),
  195. TP_STRUCT__entry(
  196. __field( unsigned int, ata_port )
  197. __field( unsigned int, ata_dev )
  198. __field( unsigned int, tag )
  199. __field( unsigned char, status )
  200. __field( unsigned char, dev )
  201. __field( unsigned char, lbal )
  202. __field( unsigned char, lbam )
  203. __field( unsigned char, lbah )
  204. __field( unsigned char, nsect )
  205. __field( unsigned char, error )
  206. __field( unsigned char, hob_lbal )
  207. __field( unsigned char, hob_lbam )
  208. __field( unsigned char, hob_lbah )
  209. __field( unsigned char, hob_nsect )
  210. __field( unsigned char, hob_feature )
  211. __field( unsigned char, ctl )
  212. __field( unsigned long, flags )
  213. ),
  214. TP_fast_assign(
  215. __entry->ata_port = qc->ap->print_id;
  216. __entry->ata_dev = qc->dev->link->pmp + qc->dev->devno;
  217. __entry->tag = qc->tag;
  218. __entry->status = qc->result_tf.command;
  219. __entry->dev = qc->result_tf.device;
  220. __entry->lbal = qc->result_tf.lbal;
  221. __entry->lbam = qc->result_tf.lbam;
  222. __entry->lbah = qc->result_tf.lbah;
  223. __entry->hob_lbal = qc->result_tf.hob_lbal;
  224. __entry->hob_lbam = qc->result_tf.hob_lbam;
  225. __entry->hob_lbah = qc->result_tf.hob_lbah;
  226. __entry->error = qc->result_tf.feature;
  227. __entry->hob_feature = qc->result_tf.hob_feature;
  228. __entry->nsect = qc->result_tf.nsect;
  229. __entry->hob_nsect = qc->result_tf.hob_nsect;
  230. ),
  231. TP_printk("ata_port=%u ata_dev=%u tag=%d flags=%s status=%s " \
  232. " res=(%02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x)",
  233. __entry->ata_port, __entry->ata_dev, __entry->tag,
  234. __parse_qc_flags(__entry->flags),
  235. __parse_status(__entry->status),
  236. __entry->status, __entry->error, __entry->nsect,
  237. __entry->lbal, __entry->lbam, __entry->lbah,
  238. __entry->hob_feature, __entry->hob_nsect,
  239. __entry->hob_lbal, __entry->hob_lbam, __entry->hob_lbah,
  240. __entry->dev)
  241. );
  242. DEFINE_EVENT(ata_qc_complete_template, ata_qc_complete_internal,
  243. TP_PROTO(struct ata_queued_cmd *qc),
  244. TP_ARGS(qc));
  245. DEFINE_EVENT(ata_qc_complete_template, ata_qc_complete_failed,
  246. TP_PROTO(struct ata_queued_cmd *qc),
  247. TP_ARGS(qc));
  248. DEFINE_EVENT(ata_qc_complete_template, ata_qc_complete_done,
  249. TP_PROTO(struct ata_queued_cmd *qc),
  250. TP_ARGS(qc));
  251. TRACE_EVENT(ata_eh_link_autopsy,
  252. TP_PROTO(struct ata_device *dev, unsigned int eh_action, unsigned int eh_err_mask),
  253. TP_ARGS(dev, eh_action, eh_err_mask),
  254. TP_STRUCT__entry(
  255. __field( unsigned int, ata_port )
  256. __field( unsigned int, ata_dev )
  257. __field( unsigned int, eh_action )
  258. __field( unsigned int, eh_err_mask)
  259. ),
  260. TP_fast_assign(
  261. __entry->ata_port = dev->link->ap->print_id;
  262. __entry->ata_dev = dev->link->pmp + dev->devno;
  263. __entry->eh_action = eh_action;
  264. __entry->eh_err_mask = eh_err_mask;
  265. ),
  266. TP_printk("ata_port=%u ata_dev=%u eh_action=%s err_mask=%s",
  267. __entry->ata_port, __entry->ata_dev,
  268. __parse_eh_action(__entry->eh_action),
  269. __parse_eh_err_mask(__entry->eh_err_mask))
  270. );
  271. TRACE_EVENT(ata_eh_link_autopsy_qc,
  272. TP_PROTO(struct ata_queued_cmd *qc),
  273. TP_ARGS(qc),
  274. TP_STRUCT__entry(
  275. __field( unsigned int, ata_port )
  276. __field( unsigned int, ata_dev )
  277. __field( unsigned int, tag )
  278. __field( unsigned int, qc_flags )
  279. __field( unsigned int, eh_err_mask)
  280. ),
  281. TP_fast_assign(
  282. __entry->ata_port = qc->ap->print_id;
  283. __entry->ata_dev = qc->dev->link->pmp + qc->dev->devno;
  284. __entry->tag = qc->tag;
  285. __entry->qc_flags = qc->flags;
  286. __entry->eh_err_mask = qc->err_mask;
  287. ),
  288. TP_printk("ata_port=%u ata_dev=%u tag=%d flags=%s err_mask=%s",
  289. __entry->ata_port, __entry->ata_dev, __entry->tag,
  290. __parse_qc_flags(__entry->qc_flags),
  291. __parse_eh_err_mask(__entry->eh_err_mask))
  292. );
  293. #endif /* _TRACE_LIBATA_H */
  294. /* This part must be outside protection */
  295. #include <trace/define_trace.h>