svn commit: r268103 - in head/sys/cam: ctl scsi
Alexander Motin
mav at FreeBSD.org
Tue Jul 1 16:52:42 UTC 2014
Author: mav
Date: Tue Jul 1 16:52:41 2014
New Revision: 268103
URL: http://svnweb.freebsd.org/changeset/base/268103
Log:
Add support for REPORT TIMESTAMP command.
MFC after: 2 weeks
Modified:
head/sys/cam/ctl/ctl.c
head/sys/cam/ctl/ctl_cmd_table.c
head/sys/cam/ctl/ctl_private.h
head/sys/cam/scsi/scsi_all.h
Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c Tue Jul 1 16:01:48 2014 (r268102)
+++ head/sys/cam/ctl/ctl.c Tue Jul 1 16:52:41 2014 (r268103)
@@ -7288,6 +7288,58 @@ ctl_report_supported_tmf(struct ctl_scsi
}
int
+ctl_report_timestamp(struct ctl_scsiio *ctsio)
+{
+ struct ctl_lun *lun;
+ struct scsi_report_timestamp *cdb;
+ struct scsi_report_timestamp_data *data;
+ struct timeval tv;
+ int64_t timestamp;
+ int retval;
+ int alloc_len, total_len;
+
+ CTL_DEBUG_PRINT(("ctl_report_timestamp\n"));
+
+ cdb = (struct scsi_report_timestamp *)ctsio->cdb;
+ lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
+
+ retval = CTL_RETVAL_COMPLETE;
+
+ total_len = sizeof(struct scsi_report_timestamp_data);
+ alloc_len = scsi_4btoul(cdb->length);
+
+ ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO);
+
+ ctsio->kern_sg_entries = 0;
+
+ if (total_len < alloc_len) {
+ ctsio->residual = alloc_len - total_len;
+ ctsio->kern_data_len = total_len;
+ ctsio->kern_total_len = total_len;
+ } else {
+ ctsio->residual = 0;
+ ctsio->kern_data_len = alloc_len;
+ ctsio->kern_total_len = alloc_len;
+ }
+ ctsio->kern_data_resid = 0;
+ ctsio->kern_rel_offset = 0;
+
+ data = (struct scsi_report_timestamp_data *)ctsio->kern_data_ptr;
+ scsi_ulto2b(sizeof(*data) - 2, data->length);
+ data->origin = RTS_ORIG_OUTSIDE;
+ getmicrotime(&tv);
+ timestamp = (int64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ scsi_ulto4b(timestamp >> 16, data->timestamp);
+ scsi_ulto2b(timestamp & 0xffff, &data->timestamp[4]);
+
+ ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED;
+ ctsio->be_move_done = ctl_config_move_done;
+
+ ctl_datamove((union ctl_io *)ctsio);
+ return (retval);
+}
+
+int
ctl_persistent_reserve_in(struct ctl_scsiio *ctsio)
{
struct scsi_per_res_in *cdb;
Modified: head/sys/cam/ctl/ctl_cmd_table.c
==============================================================================
--- head/sys/cam/ctl/ctl_cmd_table.c Tue Jul 1 16:01:48 2014 (r268102)
+++ head/sys/cam/ctl/ctl_cmd_table.c Tue Jul 1 16:52:41 2014 (r268103)
@@ -309,7 +309,19 @@ const struct ctl_cmd_entry ctl_cmd_table
CTL_LUN_PAT_NONE,
12, {0x0d, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0x07}},
-/* 0e-1f */
+/* 0E */
+{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},
+
+/* 0F REPORT TIMESTAMP */
+{ctl_report_timestamp, CTL_SERIDX_MAIN_IN, CTL_CMD_FLAG_OK_ON_BOTH |
+ CTL_CMD_FLAG_OK_ON_STOPPED |
+ CTL_CMD_FLAG_OK_ON_INOPERABLE |
+ CTL_CMD_FLAG_OK_ON_SECONDARY |
+ CTL_FLAG_DATA_IN,
+ CTL_LUN_PAT_NONE,
+ 12, {0x0f, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0, 0x07}},
+
+/* 10-1f */
};
const struct ctl_cmd_entry ctl_cmd_table[256] =
Modified: head/sys/cam/ctl/ctl_private.h
==============================================================================
--- head/sys/cam/ctl/ctl_private.h Tue Jul 1 16:01:48 2014 (r268102)
+++ head/sys/cam/ctl/ctl_private.h Tue Jul 1 16:52:41 2014 (r268103)
@@ -501,6 +501,7 @@ int ctl_persistent_reserve_out(struct ct
int ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio);
int ctl_report_supported_opcodes(struct ctl_scsiio *ctsio);
int ctl_report_supported_tmf(struct ctl_scsiio *ctsio);
+int ctl_report_timestamp(struct ctl_scsiio *ctsio);
int ctl_isc(struct ctl_scsiio *ctsio);
#endif /* _KERNEL */
Modified: head/sys/cam/scsi/scsi_all.h
==============================================================================
--- head/sys/cam/scsi/scsi_all.h Tue Jul 1 16:01:48 2014 (r268102)
+++ head/sys/cam/scsi/scsi_all.h Tue Jul 1 16:52:41 2014 (r268103)
@@ -1059,6 +1059,29 @@ struct scsi_report_supported_tmf_data
uint8_t reserved[2];
};
+struct scsi_report_timestamp
+{
+ uint8_t opcode;
+ uint8_t service_action;
+ uint8_t reserved[4];
+ uint8_t length[4];
+ uint8_t reserved1;
+ uint8_t control;
+};
+
+struct scsi_report_timestamp_data
+{
+ uint8_t length[2];
+ uint8_t origin;
+#define RTS_ORIG_MASK 0x00
+#define RTS_ORIG_ZERO 0x00
+#define RTS_ORIG_SET 0x02
+#define RTS_ORIG_OUTSIDE 0x03
+ uint8_t reserved;
+ uint8_t timestamp[6];
+ uint8_t reserve2[2];
+};
+
struct ata_pass_16 {
u_int8_t opcode;
u_int8_t protocol;
More information about the svn-src-head
mailing list