public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] scsi: trace: change the rtn log in string
@ 2025-05-20  1:04 Kassey Li
  2025-05-20 12:10 ` kernel test robot
  2025-05-20 13:35 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Kassey Li @ 2025-05-20  1:04 UTC (permalink / raw)
  To: rostedt, James.Bottomley, martin.petersen, mathieu.desnoyers,
	linux-kernel, linux-trace-kernel, linux-scsi
  Cc: quic_yingangl

By default it showed rtn in decimal:

kworker/3:1H-183 [003] ....  51.035474: scsi_dispatch_cmd_error: host_no=0 channel=0 id=0 lun=4 data_sgl=1  prot_sgl=0 prot_op=SCSI_PROT
_NORMAL cmnd=(READ_10 lba=3907214  txlen=1 protect=0 raw=28 00 00 3b 9e 8e 00 00 01 00) rtn=4181

In source code we define these possible values as hexadecimal:

include/scsi/scsi.h

SCSI_MLQUEUE_HOST_BUSY   0x1055
SCSI_MLQUEUE_DEVICE_BUSY 0x1056
SCSI_MLQUEUE_EH_RETRY    0x1057
SCSI_MLQUEUE_TARGET_BUSY 0x1058

This change shows the rtn in strings:

dd-1090    [007] .....    23.485300: scsi_dispatch_cmd_error: host_no=0 channel=0 id=0 lun=4 data_sgl=64 prot_sgl=0 prot_op=SCSI_PROT_NORMAL driver_tag=18 scheduler_tag=9 cmnd=(READ_10 lba=384 txlen=128 protect=0
raw=28 00 00 00 01 80 00 00 80 00) rtn=HOST_BUSY

Signed-off-by: Kassey Li <quic_yingangl@quicinc.com>
---
 include/trace/events/scsi.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h
index bf6cc98d9122..92a5b6a411b5 100644
--- a/include/trace/events/scsi.h
+++ b/include/trace/events/scsi.h
@@ -200,6 +200,12 @@ TRACE_EVENT(scsi_dispatch_cmd_start,
 		  __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len))
 );
 
+#define show_rtn_name(rtn)    \
+	__print_symbolic(rtn, { SCSI_MLQUEUE_HOST_BUSY, "HOST_BUSY" }, \
+	  { SCSI_MLQUEUE_DEVICE_BUSY, "DEVICE_BUSY" }, \
+	  { SCSI_MLQUEUE_EH_RETRY, "EH_RETRY" }, \
+	  { SCSI_MLQUEUE_TARGET_BUSY, "TARGET_BUSY" })
+
 TRACE_EVENT(scsi_dispatch_cmd_error,
 
 	TP_PROTO(struct scsi_cmnd *cmd, int rtn),
@@ -240,14 +246,15 @@ TRACE_EVENT(scsi_dispatch_cmd_error,
 
 	TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
 		  " prot_op=%s driver_tag=%d scheduler_tag=%d cmnd=(%s %s raw=%s)" \
-		  " rtn=%d",
+		  " rtn=%s",
 		  __entry->host_no, __entry->channel, __entry->id,
 		  __entry->lun, __entry->data_sglen, __entry->prot_sglen,
 		  show_prot_op_name(__entry->prot_op), __entry->driver_tag,
 		  __entry->scheduler_tag, show_opcode_name(__entry->opcode),
 		  __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
 		  __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
-		  __entry->rtn)
+		  show_rtn_type(__entry->rtn)
+	  )
 );
 
 DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-20 13:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-20  1:04 [PATCH v3] scsi: trace: change the rtn log in string Kassey Li
2025-05-20 12:10 ` kernel test robot
2025-05-20 13:35 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox