libata-trace.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. }