svn commit: r312578 - in stable/11/sys/cam: ctl scsi
Alexander Motin
mav at FreeBSD.org
Sat Jan 21 08:35:30 UTC 2017
Author: mav
Date: Sat Jan 21 08:35:28 2017
New Revision: 312578
URL: https://svnweb.freebsd.org/changeset/base/312578
Log:
MFC r310640, r310643:
Add support for revert to defaults (RTD) bit in MODE SELECT.
Modified:
stable/11/sys/cam/ctl/ctl.c
stable/11/sys/cam/ctl/ctl.h
stable/11/sys/cam/ctl/ctl_cmd_table.c
stable/11/sys/cam/scsi/scsi_all.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/cam/ctl/ctl.c
==============================================================================
--- stable/11/sys/cam/ctl/ctl.c Sat Jan 21 08:34:27 2017 (r312577)
+++ stable/11/sys/cam/ctl/ctl.c Sat Jan 21 08:35:28 2017 (r312578)
@@ -6158,10 +6158,13 @@ bailout_no_done:
int
ctl_mode_select(struct ctl_scsiio *ctsio)
{
- int param_len, pf, sp;
- int header_size, bd_len;
+ struct ctl_lun *lun;
union ctl_modepage_info *modepage_info;
+ int bd_len, i, header_size, param_len, pf, rtd, sp;
+ uint32_t initidx;
+ lun = ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
+ initidx = ctl_get_initindex(&ctsio->io_hdr.nexus);
switch (ctsio->cdb[0]) {
case MODE_SELECT_6: {
struct scsi_mode_select_6 *cdb;
@@ -6169,6 +6172,7 @@ ctl_mode_select(struct ctl_scsiio *ctsio
cdb = (struct scsi_mode_select_6 *)ctsio->cdb;
pf = (cdb->byte2 & SMS_PF) ? 1 : 0;
+ rtd = (cdb->byte2 & SMS_RTD) ? 1 : 0;
sp = (cdb->byte2 & SMS_SP) ? 1 : 0;
param_len = cdb->length;
header_size = sizeof(struct scsi_mode_header_6);
@@ -6180,6 +6184,7 @@ ctl_mode_select(struct ctl_scsiio *ctsio
cdb = (struct scsi_mode_select_10 *)ctsio->cdb;
pf = (cdb->byte2 & SMS_PF) ? 1 : 0;
+ rtd = (cdb->byte2 & SMS_RTD) ? 1 : 0;
sp = (cdb->byte2 & SMS_SP) ? 1 : 0;
param_len = scsi_2btoul(cdb->length);
header_size = sizeof(struct scsi_mode_header_10);
@@ -6191,6 +6196,30 @@ ctl_mode_select(struct ctl_scsiio *ctsio
return (CTL_RETVAL_COMPLETE);
}
+ if (rtd) {
+ if (param_len != 0) {
+ ctl_set_invalid_field(ctsio, /*sks_valid*/ 0,
+ /*command*/ 1, /*field*/ 0,
+ /*bit_valid*/ 0, /*bit*/ 0);
+ ctl_done((union ctl_io *)ctsio);
+ return (CTL_RETVAL_COMPLETE);
+ }
+
+ /* Revert to defaults. */
+ ctl_init_page_index(lun);
+ mtx_lock(&lun->lun_lock);
+ ctl_est_ua_all(lun, initidx, CTL_UA_MODE_CHANGE);
+ mtx_unlock(&lun->lun_lock);
+ for (i = 0; i < CTL_NUM_MODE_PAGES; i++) {
+ ctl_isc_announce_mode(lun, -1,
+ lun->mode_pages.index[i].page_code & SMPH_PC_MASK,
+ lun->mode_pages.index[i].subpage);
+ }
+ ctl_set_success(ctsio);
+ ctl_done((union ctl_io *)ctsio);
+ return (CTL_RETVAL_COMPLETE);
+ }
+
/*
* From SPC-3:
* "A parameter list length of zero indicates that the Data-Out Buffer
@@ -9563,6 +9592,11 @@ ctl_inquiry_evpd_eid(struct ctl_scsiio *
eid_ptr->flags4 = SVPD_EID_LUICLR;
/*
+ * We support revert to defaults (RTD) bit in MODE SELECT.
+ */
+ eid_ptr->flags5 = SVPD_EID_RTD_SUP;
+
+ /*
* XXX KDM in order to correctly answer this, we would need
* information from the SIM to determine how much sense data it
* can send. So this would really be a path inquiry field, most
Modified: stable/11/sys/cam/ctl/ctl.h
==============================================================================
--- stable/11/sys/cam/ctl/ctl.h Sat Jan 21 08:34:27 2017 (r312577)
+++ stable/11/sys/cam/ctl/ctl.h Sat Jan 21 08:35:28 2017 (r312578)
@@ -78,14 +78,8 @@ struct ctl_modepage_header {
int32_t len_left;
};
-struct ctl_modepage_aps {
- struct ctl_modepage_header header;
- uint8_t lock_active;
-};
-
union ctl_modepage_info {
struct ctl_modepage_header header;
- struct ctl_modepage_aps aps;
};
/*
Modified: stable/11/sys/cam/ctl/ctl_cmd_table.c
==============================================================================
--- stable/11/sys/cam/ctl/ctl_cmd_table.c Sat Jan 21 08:34:27 2017 (r312577)
+++ stable/11/sys/cam/ctl/ctl_cmd_table.c Sat Jan 21 08:35:28 2017 (r312578)
@@ -990,7 +990,7 @@ const struct ctl_cmd_entry ctl_cmd_table
CTL_CMD_FLAG_OK_ON_NO_MEDIA |
CTL_CMD_FLAG_OK_ON_STANDBY |
CTL_FLAG_DATA_OUT,
- CTL_LUN_PAT_NONE, 6, {0x11, 0, 0, 0xff, 0x07}},
+ CTL_LUN_PAT_NONE, 6, {0x13, 0, 0, 0xff, 0x07}},
/* 16 RESERVE(6) */
{ctl_scsi_reserve, CTL_SERIDX_RES, CTL_CMD_FLAG_ALLOW_ON_RESV |
@@ -1260,7 +1260,7 @@ const struct ctl_cmd_entry ctl_cmd_table
CTL_CMD_FLAG_OK_ON_NO_MEDIA |
CTL_CMD_FLAG_OK_ON_STANDBY |
CTL_FLAG_DATA_OUT,
- CTL_LUN_PAT_NONE, 10, {0x11, 0, 0, 0, 0, 0, 0xff, 0xff, 0x07} },
+ CTL_LUN_PAT_NONE, 10, {0x13, 0, 0, 0, 0, 0, 0xff, 0xff, 0x07} },
/* 56 RESERVE(10) */
{ctl_scsi_reserve, CTL_SERIDX_RES, CTL_CMD_FLAG_ALLOW_ON_RESV |
Modified: stable/11/sys/cam/scsi/scsi_all.h
==============================================================================
--- stable/11/sys/cam/scsi/scsi_all.h Sat Jan 21 08:34:27 2017 (r312577)
+++ stable/11/sys/cam/scsi/scsi_all.h Sat Jan 21 08:35:28 2017 (r312578)
@@ -228,6 +228,7 @@ struct scsi_mode_select_6
u_int8_t opcode;
u_int8_t byte2;
#define SMS_SP 0x01
+#define SMS_RTD 0x02
#define SMS_PF 0x10
u_int8_t unused[2];
u_int8_t length;
More information about the svn-src-stable
mailing list