summaryrefslogtreecommitdiffstats
path: root/sys/cam/ctl/ctl_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cam/ctl/ctl_util.c')
-rw-r--r--sys/cam/ctl/ctl_util.c120
1 files changed, 81 insertions, 39 deletions
diff --git a/sys/cam/ctl/ctl_util.c b/sys/cam/ctl/ctl_util.c
index 61b0085..a991cfb 100644
--- a/sys/cam/ctl/ctl_util.c
+++ b/sys/cam/ctl/ctl_util.c
@@ -731,69 +731,64 @@ ctl_scsi_task_string(struct ctl_taskio *taskio)
}
void
-ctl_io_error_sbuf(union ctl_io *io, struct scsi_inquiry_data *inq_data,
- struct sbuf *sb)
+ctl_io_sbuf(union ctl_io *io, struct sbuf *sb)
{
- struct ctl_status_desc *status_desc;
+ const char *task_desc;
char path_str[64];
- unsigned int i;
-
- status_desc = NULL;
-
- for (i = 0; i < (sizeof(ctl_status_table)/sizeof(ctl_status_table[0]));
- i++) {
- if ((io->io_hdr.status & CTL_STATUS_MASK) ==
- ctl_status_table[i].status) {
- status_desc = &ctl_status_table[i];
- break;
- }
- }
ctl_scsi_path_string(io, path_str, sizeof(path_str));
switch (io->io_hdr.io_type) {
case CTL_IO_SCSI:
sbuf_cat(sb, path_str);
-
ctl_scsi_command_string(&io->scsiio, NULL, sb);
-
- sbuf_printf(sb, "\n");
-
- sbuf_printf(sb, "%sTag: 0x%04x, Type: %d\n", path_str,
+ sbuf_printf(sb, " Tag: %#x/%d\n",
io->scsiio.tag_num, io->scsiio.tag_type);
break;
- case CTL_IO_TASK: {
- const char *task_desc;
-
+ case CTL_IO_TASK:
sbuf_cat(sb, path_str);
-
task_desc = ctl_scsi_task_string(&io->taskio);
-
if (task_desc == NULL)
sbuf_printf(sb, "Unknown Task Action %d (%#x)",
- io->taskio.task_action,
- io->taskio.task_action);
+ io->taskio.task_action, io->taskio.task_action);
else
sbuf_printf(sb, "Task Action: %s", task_desc);
-
- sbuf_printf(sb, "\n");
-
switch (io->taskio.task_action) {
case CTL_TASK_ABORT_TASK:
- case CTL_TASK_ABORT_TASK_SET:
- case CTL_TASK_CLEAR_TASK_SET:
- sbuf_printf(sb, "%sTag: 0x%04x, Type: %d\n", path_str,
- io->taskio.tag_num,
- io->taskio.tag_type);
+ sbuf_printf(sb, " Tag: %#x/%d\n",
+ io->taskio.tag_num, io->taskio.tag_type);
break;
default:
+ sbuf_printf(sb, "\n");
break;
}
break;
- }
default:
break;
}
+}
+
+void
+ctl_io_error_sbuf(union ctl_io *io, struct scsi_inquiry_data *inq_data,
+ struct sbuf *sb)
+{
+ struct ctl_status_desc *status_desc;
+ char path_str[64];
+ unsigned int i;
+
+ ctl_io_sbuf(io, sb);
+
+ status_desc = NULL;
+ for (i = 0; i < (sizeof(ctl_status_table)/sizeof(ctl_status_table[0]));
+ i++) {
+ if ((io->io_hdr.status & CTL_STATUS_MASK) ==
+ ctl_status_table[i].status) {
+ status_desc = &ctl_status_table[i];
+ break;
+ }
+ }
+
+ ctl_scsi_path_string(io, path_str, sizeof(path_str));
sbuf_cat(sb, path_str);
if (status_desc == NULL)
@@ -815,23 +810,39 @@ ctl_io_error_sbuf(union ctl_io *io, struct scsi_inquiry_data *inq_data,
}
char *
+ctl_io_string(union ctl_io *io, char *str, int str_len)
+{
+ struct sbuf sb;
+
+ sbuf_new(&sb, str, str_len, SBUF_FIXEDLEN);
+ ctl_io_sbuf(io, &sb);
+ sbuf_finish(&sb);
+ return (sbuf_data(&sb));
+}
+
+char *
ctl_io_error_string(union ctl_io *io, struct scsi_inquiry_data *inq_data,
char *str, int str_len)
{
struct sbuf sb;
sbuf_new(&sb, str, str_len, SBUF_FIXEDLEN);
-
ctl_io_error_sbuf(io, inq_data, &sb);
-
sbuf_finish(&sb);
-
return (sbuf_data(&sb));
}
#ifdef _KERNEL
void
+ctl_io_print(union ctl_io *io)
+{
+ char str[512];
+
+ printf("%s", ctl_io_string(io, str, sizeof(str)));
+}
+
+void
ctl_io_error_print(union ctl_io *io, struct scsi_inquiry_data *inq_data)
{
char str[512];
@@ -856,6 +867,37 @@ ctl_io_error_print(union ctl_io *io, struct scsi_inquiry_data *inq_data)
}
+void
+ctl_data_print(union ctl_io *io)
+{
+ char str[128];
+ char path_str[64];
+ struct sbuf sb;
+ int i, j, len;
+
+ if (io->io_hdr.io_type != CTL_IO_SCSI)
+ return;
+ if (io->io_hdr.flags & CTL_FLAG_BUS_ADDR)
+ return;
+ if (io->io_hdr.flags & CTL_FLAG_EDPTR_SGLIST) /* XXX: Implement */
+ return;
+ ctl_scsi_path_string(io, path_str, sizeof(path_str));
+ len = min(io->scsiio.kern_data_len, 4096);
+ for (i = 0; i < len; ) {
+ sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN);
+ sbuf_cat(&sb, path_str);
+ sbuf_printf(&sb, " %#6x:%04x:", io->scsiio.tag_num, i);
+ for (j = 0; j < 16 && i < len; i++, j++) {
+ if (j == 8)
+ sbuf_cat(&sb, " ");
+ sbuf_printf(&sb, " %02x", io->scsiio.kern_data_ptr[i]);
+ }
+ sbuf_cat(&sb, "\n");
+ sbuf_finish(&sb);
+ printf("%s", sbuf_data(&sb));
+ }
+}
+
#else /* _KERNEL */
void
OpenPOWER on IntegriCloud