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