aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_tpc.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2014-10-01 11:30:20 +0000
committerAlexander Motin <mav@FreeBSD.org>2014-10-01 11:30:20 +0000
commit0b060244ab02b88891291d127f44dad06ca99ec0 (patch)
treef9f7fe48f9c7d79d2a4308a46109d1b6b234c9dd /sys/cam/ctl/ctl_tpc.c
parentdee826cec0ebf83097150cb351e50cf1bc698dbf (diff)
downloadsrc-0b060244ab02b88891291d127f44dad06ca99ec0.tar.gz
src-0b060244ab02b88891291d127f44dad06ca99ec0.zip
Fix couple issues with ROD tokens content.
MFC after: 3 days
Notes
Notes: svn path=/head/; revision=272355
Diffstat (limited to 'sys/cam/ctl/ctl_tpc.c')
-rw-r--r--sys/cam/ctl/ctl_tpc.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/sys/cam/ctl/ctl_tpc.c b/sys/cam/ctl/ctl_tpc.c
index 7a973cbbaec1..60ae8a01347c 100644
--- a/sys/cam/ctl/ctl_tpc.c
+++ b/sys/cam/ctl/ctl_tpc.c
@@ -1812,6 +1812,7 @@ tpc_create_token(struct ctl_lun *lun, struct ctl_port *port, off_t len,
static int id = 0;
struct scsi_vpd_id_descriptor *idd = NULL;
struct scsi_ec_cscd_id *cscd;
+ struct scsi_read_capacity_data_long *dtsd;
int targid_len;
scsi_ulto4b(ROD_TYPE_AUR, token->type);
@@ -1830,9 +1831,19 @@ tpc_create_token(struct ctl_lun *lun, struct ctl_port *port, off_t len,
cscd->type_code = EC_CSCD_ID;
cscd->luidt_pdt = T_DIRECT;
memcpy(&cscd->codeset, idd, 4 + idd->length);
+ scsi_ulto3b(lun->be_lun->blocksize, cscd->dtsp.block_length);
}
- scsi_u64to8b(0, &token->body[40]);
+ scsi_u64to8b(0, &token->body[40]); /* XXX: Should be 128bit value. */
scsi_u64to8b(len, &token->body[48]);
+
+ /* ROD token device type specific data (RC16 without first field) */
+ dtsd = (struct scsi_read_capacity_data_long *)&token->body[88 - 8];
+ scsi_ulto4b(lun->be_lun->blocksize, dtsd->length);
+ dtsd->prot_lbppbe = lun->be_lun->pblockexp & SRC16_LBPPBE;
+ scsi_ulto2b(lun->be_lun->pblockoff & SRC16_LALBA_A, dtsd->lalba_lbp);
+ if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP)
+ dtsd->lalba_lbp[0] |= SRC16_LBPME | SRC16_LBPRZ;
+
if (port->target_devid) {
targid_len = port->target_devid->len;
memcpy(&token->body[120], port->target_devid->data, targid_len);
@@ -1938,6 +1949,8 @@ ctl_populate_token(struct ctl_scsiio *ctsio)
token->range = &data->desc[0];
token->nrange = scsi_2btoul(data->range_descriptor_length) /
sizeof(struct scsi_range_desc);
+ list->cursectors = tpc_ranges_length(token->range, token->nrange);
+ list->curbytes = (off_t)list->cursectors * lun->be_lun->blocksize;
tpc_create_token(lun, port, list->curbytes,
(struct scsi_token *)token->token);
token->active = 0;
@@ -1954,8 +1967,6 @@ ctl_populate_token(struct ctl_scsiio *ctsio)
}
memcpy(list->res_token, token->token, sizeof(list->res_token));
list->res_token_valid = 1;
- list->cursectors = tpc_ranges_length(token->range, token->nrange);
- list->curbytes = (off_t)list->cursectors * lun->be_lun->blocksize;
list->curseg = 0;
list->completed = 1;
list->last_active = time_uptime;