svn commit: r251310 - stable/9/sys/cam/scsi
Steven Hartland
smh at FreeBSD.org
Mon Jun 3 16:54:57 UTC 2013
Author: smh
Date: Mon Jun 3 16:54:56 2013
New Revision: 251310
URL: http://svnweb.freebsd.org/changeset/base/251310
Log:
MFC r249933:
Added the ability to send ATA identify and TRIM commands via SCSI
Modified:
stable/9/sys/cam/scsi/scsi_all.c
stable/9/sys/cam/scsi/scsi_all.h
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/cam/scsi/scsi_all.c
==============================================================================
--- stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 16:50:16 2013 (r251309)
+++ stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 16:54:56 2013 (r251310)
@@ -5848,6 +5848,57 @@ scsi_write_same(struct ccb_scsiio *csio,
}
void
+scsi_ata_identify(struct ccb_scsiio *csio, u_int32_t retries,
+ void (*cbfcnp)(struct cam_periph *, union ccb *),
+ u_int8_t tag_action, u_int8_t *data_ptr,
+ u_int16_t dxfer_len, u_int8_t sense_len,
+ u_int32_t timeout)
+{
+ scsi_ata_pass_16(csio,
+ retries,
+ cbfcnp,
+ /*flags*/CAM_DIR_IN,
+ tag_action,
+ /*protocol*/AP_PROTO_PIO_IN,
+ /*ata_flags*/AP_FLAG_TDIR_FROM_DEV|
+ AP_FLAG_BYT_BLOK_BYTES|AP_FLAG_TLEN_SECT_CNT,
+ /*features*/0,
+ /*sector_count*/dxfer_len,
+ /*lba*/0,
+ /*command*/ATA_ATA_IDENTIFY,
+ /*control*/0,
+ data_ptr,
+ dxfer_len,
+ sense_len,
+ timeout);
+}
+
+void
+scsi_ata_trim(struct ccb_scsiio *csio, u_int32_t retries,
+ void (*cbfcnp)(struct cam_periph *, union ccb *),
+ u_int8_t tag_action, u_int16_t block_count,
+ u_int8_t *data_ptr, u_int16_t dxfer_len, u_int8_t sense_len,
+ u_int32_t timeout)
+{
+ scsi_ata_pass_16(csio,
+ retries,
+ cbfcnp,
+ /*flags*/CAM_DIR_OUT,
+ tag_action,
+ /*protocol*/AP_EXTEND|AP_PROTO_DMA,
+ /*ata_flags*/AP_FLAG_TLEN_SECT_CNT|AP_FLAG_BYT_BLOK_BLOCKS,
+ /*features*/ATA_DSM_TRIM,
+ /*sector_count*/block_count,
+ /*lba*/0,
+ /*command*/ATA_DATA_SET_MANAGEMENT,
+ /*control*/0,
+ data_ptr,
+ dxfer_len,
+ sense_len,
+ timeout);
+}
+
+void
scsi_ata_pass_16(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int32_t flags, u_int8_t tag_action,
Modified: stable/9/sys/cam/scsi/scsi_all.h
==============================================================================
--- stable/9/sys/cam/scsi/scsi_all.h Mon Jun 3 16:50:16 2013 (r251309)
+++ stable/9/sys/cam/scsi/scsi_all.h Mon Jun 3 16:54:56 2013 (r251310)
@@ -1429,6 +1429,61 @@ struct scsi_diag_page {
uint8_t params[0];
};
+/*
+ * Logical Block Provisioning VPD Page based on
+ * T10/1799-D Revision 31
+ */
+struct scsi_vpd_logical_block_prov
+{
+ u_int8_t device;
+ u_int8_t page_code;
+#define SVPD_LBP 0xB2
+ u_int8_t page_length[2];
+#define SVPD_LBP_PL_BASIC 0x04
+ u_int8_t threshold_exponent;
+ u_int8_t flags;
+#define SVPD_LBP_UNMAP 0x80
+#define SVPD_LBP_WS16 0x40
+#define SVPD_LBP_WS10 0x20
+#define SVPD_LBP_RZ 0x04
+#define SVPD_LBP_ANC_SUP 0x02
+#define SVPD_LBP_DP 0x01
+ u_int8_t prov_type;
+#define SVPD_LBP_RESOURCE 0x01
+#define SVPD_LBP_THIN 0x02
+ u_int8_t reserved;
+ /*
+ * Provisioning Group Descriptor can be here if SVPD_LBP_DP is set
+ * Its size can be determined from page_length - 4
+ */
+};
+
+/*
+ * Block Limits VDP Page based on
+ * T10/1799-D Revision 31
+ */
+struct scsi_vpd_block_limits
+{
+ u_int8_t device;
+ u_int8_t page_code;
+#define SVPD_BLOCK_LIMITS 0xB0
+ u_int8_t page_length[2];
+#define SVPD_BL_PL_BASIC 0x10
+#define SVPD_BL_PL_TP 0x3C
+ u_int8_t reserved1;
+ u_int8_t max_cmp_write_len;
+ u_int8_t opt_txfer_len_grain[2];
+ u_int8_t max_txfer_len[4];
+ u_int8_t opt_txfer_len[4];
+ u_int8_t max_prefetch[4];
+ u_int8_t max_unmap_lba_cnt[4];
+ u_int8_t max_unmap_blk_cnt[4];
+ u_int8_t opt_unmap_grain[4];
+ u_int8_t unmap_grain_align[4];
+ u_int8_t max_write_same_length[8];
+ u_int8_t reserved2[20];
+};
+
struct scsi_read_capacity
{
u_int8_t opcode;
@@ -2392,6 +2447,18 @@ void scsi_write_same(struct ccb_scsiio *
u_int32_t dxfer_len, u_int8_t sense_len,
u_int32_t timeout);
+void scsi_ata_identify(struct ccb_scsiio *csio, u_int32_t retries,
+ void (*cbfcnp)(struct cam_periph *, union ccb *),
+ u_int8_t tag_action, u_int8_t *data_ptr,
+ u_int16_t dxfer_len, u_int8_t sense_len,
+ u_int32_t timeout);
+
+void scsi_ata_trim(struct ccb_scsiio *csio, u_int32_t retries,
+ void (*cbfcnp)(struct cam_periph *, union ccb *),
+ u_int8_t tag_action, u_int16_t block_count,
+ u_int8_t *data_ptr, u_int16_t dxfer_len,
+ u_int8_t sense_len, u_int32_t timeout);
+
void scsi_ata_pass_16(struct ccb_scsiio *csio, u_int32_t retries,
void (*cbfcnp)(struct cam_periph *, union ccb *),
u_int32_t flags, u_int8_t tag_action,
More information about the svn-src-stable-9
mailing list