libata-trace.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. * libata-trace.c - trace functions for libata
  3. *
  4. * Copyright 2015 Hannes Reinecke
  5. * Copyright 2015 SUSE Linux GmbH
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2, or (at your option)
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; see the file COPYING. If not, write to
  19. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/trace_seq.h>
  23. #include <trace/events/libata.h>
  24. const char *
  25. libata_trace_parse_status(struct trace_seq *p, unsigned char status)
  26. {
  27. const char *ret = trace_seq_buffer_ptr(p);
  28. trace_seq_printf(p, "{ ");
  29. if (status & ATA_BUSY)
  30. trace_seq_printf(p, "BUSY ");
  31. if (status & ATA_DRDY)
  32. trace_seq_printf(p, "DRDY ");
  33. if (status & ATA_DF)
  34. trace_seq_printf(p, "DF ");
  35. if (status & ATA_DSC)
  36. trace_seq_printf(p, "DSC ");
  37. if (status & ATA_DRQ)
  38. trace_seq_printf(p, "DRQ ");
  39. if (status & ATA_CORR)
  40. trace_seq_printf(p, "CORR ");
  41. if (status & ATA_SENSE)
  42. trace_seq_printf(p, "SENSE ");
  43. if (status & ATA_ERR)
  44. trace_seq_printf(p, "ERR ");
  45. trace_seq_putc(p, '}');
  46. trace_seq_putc(p, 0);
  47. return ret;
  48. }
  49. const char *
  50. libata_trace_parse_eh_action(struct trace_seq *p, unsigned int eh_action)
  51. {
  52. const char *ret = trace_seq_buffer_ptr(p);
  53. trace_seq_printf(p, "%x", eh_action);
  54. if (eh_action) {
  55. trace_seq_printf(p, "{ ");
  56. if (eh_action & ATA_EH_REVALIDATE)
  57. trace_seq_printf(p, "REVALIDATE ");
  58. if (eh_action & (ATA_EH_SOFTRESET | ATA_EH_HARDRESET))
  59. trace_seq_printf(p, "RESET ");
  60. else if (eh_action & ATA_EH_SOFTRESET)
  61. trace_seq_printf(p, "SOFTRESET ");
  62. else if (eh_action & ATA_EH_HARDRESET)
  63. trace_seq_printf(p, "HARDRESET ");
  64. if (eh_action & ATA_EH_ENABLE_LINK)
  65. trace_seq_printf(p, "ENABLE_LINK ");
  66. if (eh_action & ATA_EH_PARK)
  67. trace_seq_printf(p, "PARK ");
  68. trace_seq_putc(p, '}');
  69. }
  70. trace_seq_putc(p, 0);
  71. return ret;
  72. }
  73. const char *
  74. libata_trace_parse_eh_err_mask(struct trace_seq *p, unsigned int eh_err_mask)
  75. {
  76. const char *ret = trace_seq_buffer_ptr(p);
  77. trace_seq_printf(p, "%x", eh_err_mask);
  78. if (eh_err_mask) {
  79. trace_seq_printf(p, "{ ");
  80. if (eh_err_mask & AC_ERR_DEV)
  81. trace_seq_printf(p, "DEV ");
  82. if (eh_err_mask & AC_ERR_HSM)
  83. trace_seq_printf(p, "HSM ");
  84. if (eh_err_mask & AC_ERR_TIMEOUT)
  85. trace_seq_printf(p, "TIMEOUT ");
  86. if (eh_err_mask & AC_ERR_MEDIA)
  87. trace_seq_printf(p, "MEDIA ");
  88. if (eh_err_mask & AC_ERR_ATA_BUS)
  89. trace_seq_printf(p, "ATA_BUS ");
  90. if (eh_err_mask & AC_ERR_HOST_BUS)
  91. trace_seq_printf(p, "HOST_BUS ");
  92. if (eh_err_mask & AC_ERR_SYSTEM)
  93. trace_seq_printf(p, "SYSTEM ");
  94. if (eh_err_mask & AC_ERR_INVALID)
  95. trace_seq_printf(p, "INVALID ");
  96. if (eh_err_mask & AC_ERR_OTHER)
  97. trace_seq_printf(p, "OTHER ");
  98. if (eh_err_mask & AC_ERR_NODEV_HINT)
  99. trace_seq_printf(p, "NODEV_HINT ");
  100. if (eh_err_mask & AC_ERR_NCQ)
  101. trace_seq_printf(p, "NCQ ");
  102. trace_seq_putc(p, '}');
  103. }
  104. trace_seq_putc(p, 0);
  105. return ret;
  106. }
  107. const char *
  108. libata_trace_parse_qc_flags(struct trace_seq *p, unsigned int qc_flags)
  109. {
  110. const char *ret = trace_seq_buffer_ptr(p);
  111. trace_seq_printf(p, "%x", qc_flags);
  112. if (qc_flags) {
  113. trace_seq_printf(p, "{ ");
  114. if (qc_flags & ATA_QCFLAG_ACTIVE)
  115. trace_seq_printf(p, "ACTIVE ");
  116. if (qc_flags & ATA_QCFLAG_DMAMAP)
  117. trace_seq_printf(p, "DMAMAP ");
  118. if (qc_flags & ATA_QCFLAG_IO)
  119. trace_seq_printf(p, "IO ");
  120. if (qc_flags & ATA_QCFLAG_RESULT_TF)
  121. trace_seq_printf(p, "RESULT_TF ");
  122. if (qc_flags & ATA_QCFLAG_CLEAR_EXCL)
  123. trace_seq_printf(p, "CLEAR_EXCL ");
  124. if (qc_flags & ATA_QCFLAG_QUIET)
  125. trace_seq_printf(p, "QUIET ");
  126. if (qc_flags & ATA_QCFLAG_RETRY)
  127. trace_seq_printf(p, "RETRY ");
  128. if (qc_flags & ATA_QCFLAG_FAILED)
  129. trace_seq_printf(p, "FAILED ");
  130. if (qc_flags & ATA_QCFLAG_SENSE_VALID)
  131. trace_seq_printf(p, "SENSE_VALID ");
  132. if (qc_flags & ATA_QCFLAG_EH_SCHEDULED)
  133. trace_seq_printf(p, "EH_SCHEDULED ");
  134. trace_seq_putc(p, '}');
  135. }
  136. trace_seq_putc(p, 0);
  137. return ret;
  138. }
  139. const char *
  140. libata_trace_parse_subcmd(struct trace_seq *p, unsigned char cmd,
  141. unsigned char feature, unsigned char hob_nsect)
  142. {
  143. const char *ret = trace_seq_buffer_ptr(p);
  144. switch (cmd) {
  145. case ATA_CMD_FPDMA_RECV:
  146. switch (hob_nsect & 0x5f) {
  147. case ATA_SUBCMD_FPDMA_RECV_RD_LOG_DMA_EXT:
  148. trace_seq_printf(p, " READ_LOG_DMA_EXT");
  149. break;
  150. case ATA_SUBCMD_FPDMA_RECV_ZAC_MGMT_IN:
  151. trace_seq_printf(p, " ZAC_MGMT_IN");
  152. break;
  153. }
  154. break;
  155. case ATA_CMD_FPDMA_SEND:
  156. switch (hob_nsect & 0x5f) {
  157. case ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT:
  158. trace_seq_printf(p, " WRITE_LOG_DMA_EXT");
  159. break;
  160. case ATA_SUBCMD_FPDMA_SEND_DSM:
  161. trace_seq_printf(p, " DATASET_MANAGEMENT");
  162. break;
  163. }
  164. break;
  165. case ATA_CMD_NCQ_NON_DATA:
  166. switch (feature) {
  167. case ATA_SUBCMD_NCQ_NON_DATA_ABORT_QUEUE:
  168. trace_seq_printf(p, " ABORT_QUEUE");
  169. break;
  170. case ATA_SUBCMD_NCQ_NON_DATA_SET_FEATURES:
  171. trace_seq_printf(p, " SET_FEATURES");
  172. break;
  173. case ATA_SUBCMD_NCQ_NON_DATA_ZERO_EXT:
  174. trace_seq_printf(p, " ZERO_EXT");
  175. break;
  176. case ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT:
  177. trace_seq_printf(p, " ZAC_MGMT_OUT");
  178. break;
  179. }
  180. break;
  181. case ATA_CMD_ZAC_MGMT_IN:
  182. switch (feature) {
  183. case ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES:
  184. trace_seq_printf(p, " REPORT_ZONES");
  185. break;
  186. }
  187. break;
  188. case ATA_CMD_ZAC_MGMT_OUT:
  189. switch (feature) {
  190. case ATA_SUBCMD_ZAC_MGMT_OUT_CLOSE_ZONE:
  191. trace_seq_printf(p, " CLOSE_ZONE");
  192. break;
  193. case ATA_SUBCMD_ZAC_MGMT_OUT_FINISH_ZONE:
  194. trace_seq_printf(p, " FINISH_ZONE");
  195. break;
  196. case ATA_SUBCMD_ZAC_MGMT_OUT_OPEN_ZONE:
  197. trace_seq_printf(p, " OPEN_ZONE");
  198. break;
  199. case ATA_SUBCMD_ZAC_MGMT_OUT_RESET_WRITE_POINTER:
  200. trace_seq_printf(p, " RESET_WRITE_POINTER");
  201. break;
  202. }
  203. break;
  204. }
  205. trace_seq_putc(p, 0);
  206. return ret;
  207. }