From owner-svn-src-stable@FreeBSD.ORG Thu Jun 6 11:41:23 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id F009EA5D; Thu, 6 Jun 2013 11:41:22 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D226B1B15; Thu, 6 Jun 2013 11:41:22 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r56BfMUC022596; Thu, 6 Jun 2013 11:41:22 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r56BfMAO022593; Thu, 6 Jun 2013 11:41:22 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306061141.r56BfMAO022593@svn.freebsd.org> From: Steven Hartland Date: Thu, 6 Jun 2013 11:41:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r251466 - stable/8/sys/cam/scsi X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2013 11:41:23 -0000 Author: smh Date: Thu Jun 6 11:41:22 2013 New Revision: 251466 URL: http://svnweb.freebsd.org/changeset/base/251466 Log: MFC r249933: Added the ability to send ATA identify and TRIM commands via SCSI Modified: stable/8/sys/cam/scsi/scsi_all.c stable/8/sys/cam/scsi/scsi_all.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/cam/ (props changed) Modified: stable/8/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/8/sys/cam/scsi/scsi_all.c Thu Jun 6 10:27:34 2013 (r251465) +++ stable/8/sys/cam/scsi/scsi_all.c Thu Jun 6 11:41:22 2013 (r251466) @@ -4391,6 +4391,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/8/sys/cam/scsi/scsi_all.h ============================================================================== --- stable/8/sys/cam/scsi/scsi_all.h Thu Jun 6 10:27:34 2013 (r251465) +++ stable/8/sys/cam/scsi/scsi_all.h Thu Jun 6 11:41:22 2013 (r251466) @@ -875,6 +875,61 @@ struct scsi_vpd_unit_serial_number u_int8_t serial_num[SVPD_SERIAL_NUM_SIZE]; }; +/* + * 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; @@ -1355,6 +1410,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,