Add support for revert to defaults (RTD) bit in MODE SELECT.
MFC after: 2 weeks
This commit is contained in:
parent
a8a4d60efe
commit
0c4641a51d
@ -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
|
||||
@ -9562,6 +9591,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
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -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 |
|
||||
|
Loading…
x
Reference in New Issue
Block a user