summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2017-01-21 08:36:05 +0000
committermav <mav@FreeBSD.org>2017-01-21 08:36:05 +0000
commit12c326a2419e089c58a9ad8d2b801bd8675f4506 (patch)
tree3924653906c21bb07d10f8f4360cde712217596d /sys/cam
parent04f0cc0f092f5fbb496f739037c0ad0659d536cb (diff)
downloadFreeBSD-src-12c326a2419e089c58a9ad8d2b801bd8675f4506.zip
FreeBSD-src-12c326a2419e089c58a9ad8d2b801bd8675f4506.tar.gz
MFC r310640, r310643:
Add support for revert to defaults (RTD) bit in MODE SELECT.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ctl/ctl.c38
-rw-r--r--sys/cam/ctl/ctl.h6
-rw-r--r--sys/cam/ctl/ctl_cmd_table.c4
-rw-r--r--sys/cam/scsi/scsi_all.h1
4 files changed, 39 insertions, 10 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index d0276b7..4ecac77 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -6149,10 +6149,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;
@@ -6160,6 +6163,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);
@@ -6171,6 +6175,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);
@@ -6182,6 +6187,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
@@ -9554,6 +9583,11 @@ ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len)
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
diff --git a/sys/cam/ctl/ctl.h b/sys/cam/ctl/ctl.h
index 7b4d06c..7143012 100644
--- a/sys/cam/ctl/ctl.h
+++ b/sys/cam/ctl/ctl.h
@@ -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;
};
/*
diff --git a/sys/cam/ctl/ctl_cmd_table.c b/sys/cam/ctl/ctl_cmd_table.c
index eaedea6..e42df74 100644
--- a/sys/cam/ctl/ctl_cmd_table.c
+++ b/sys/cam/ctl/ctl_cmd_table.c
@@ -990,7 +990,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
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[256] =
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 |
diff --git a/sys/cam/scsi/scsi_all.h b/sys/cam/scsi/scsi_all.h
index cac0017..19ee882 100644
--- a/sys/cam/scsi/scsi_all.h
+++ b/sys/cam/scsi/scsi_all.h
@@ -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;
OpenPOWER on IntegriCloud