summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2014-10-06 13:21:13 +0000
committermav <mav@FreeBSD.org>2014-10-06 13:21:13 +0000
commit48c3bee1ace64a23f42dc65b9aec3fa8389a2b6c (patch)
treef4431b548d879e692a050a9bb3021abb3975326b
parent116bd3882f12a46da4ef95b23c4c9038e35effe3 (diff)
downloadFreeBSD-src-48c3bee1ace64a23f42dc65b9aec3fa8389a2b6c.zip
FreeBSD-src-48c3bee1ace64a23f42dc65b9aec3fa8389a2b6c.tar.gz
MFC r271839:
Add support for "no Data-Out Buffer" (NDOB) flag of WRITE SAME (16) command.
-rw-r--r--sys/cam/ctl/ctl.c11
-rw-r--r--sys/cam/ctl/ctl_backend_block.c2
-rw-r--r--sys/cam/ctl/ctl_cmd_table.c2
-rw-r--r--sys/cam/scsi/scsi_all.h1
4 files changed, 13 insertions, 3 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index 7690d05..8499532 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -5995,6 +5995,14 @@ ctl_write_same(struct ctl_scsiio *ctsio)
break; /* NOTREACHED */
}
+ /* NDOB flag can be used only together with UNMAP */
+ if ((byte2 & (SWS_NDOB | SWS_UNMAP)) == SWS_NDOB) {
+ ctl_set_invalid_field(ctsio, /*sks_valid*/ 1,
+ /*command*/ 1, /*field*/ 1, /*bit_valid*/ 1, /*bit*/ 0);
+ ctl_done((union ctl_io *)ctsio);
+ return (CTL_RETVAL_COMPLETE);
+ }
+
/*
* The first check is to make sure we're in bounds, the second
* check is to catch wrap-around problems. If the lba + num blocks
@@ -6029,7 +6037,8 @@ ctl_write_same(struct ctl_scsiio *ctsio)
* If we've got a kernel request that hasn't been malloced yet,
* malloc it and tell the caller the data buffer is here.
*/
- if ((ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) {
+ if ((byte2 & SWS_NDOB) == 0 &&
+ (ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) {
ctsio->kern_data_ptr = malloc(len, M_CTL, M_WAITOK);;
ctsio->kern_data_len = len;
ctsio->kern_total_len = len;
diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c
index 912f348..086458e 100644
--- a/sys/cam/ctl/ctl_backend_block.c
+++ b/sys/cam/ctl/ctl_backend_block.c
@@ -1045,7 +1045,7 @@ ctl_be_block_cw_dispatch_ws(struct ctl_be_block_lun *be_lun,
softc = be_lun->softc;
lbalen = ARGS(beio->io);
- if (lbalen->flags & ~(SWS_LBDATA | SWS_UNMAP | SWS_ANCHOR) ||
+ if (lbalen->flags & ~(SWS_LBDATA | SWS_UNMAP | SWS_ANCHOR | SWS_NDOB) ||
(lbalen->flags & (SWS_UNMAP | SWS_ANCHOR) && be_lun->unmap == NULL)) {
ctl_free_beio(beio);
ctl_set_invalid_field(&io->scsiio,
diff --git a/sys/cam/ctl/ctl_cmd_table.c b/sys/cam/ctl/ctl_cmd_table.c
index 6ad90dd..7d679a7 100644
--- a/sys/cam/ctl/ctl_cmd_table.c
+++ b/sys/cam/ctl/ctl_cmd_table.c
@@ -1085,7 +1085,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
{ctl_write_same, CTL_SERIDX_WRITE, CTL_CMD_FLAG_OK_ON_SLUN |
CTL_FLAG_DATA_OUT,
CTL_LUN_PAT_WRITE | CTL_LUN_PAT_RANGE,
- 16, {0x1a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 16, {0x1b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}},
/* 94 */
diff --git a/sys/cam/scsi/scsi_all.h b/sys/cam/scsi/scsi_all.h
index bd66ab3..db2ee80 100644
--- a/sys/cam/scsi/scsi_all.h
+++ b/sys/cam/scsi/scsi_all.h
@@ -1030,6 +1030,7 @@ struct scsi_write_same_16
{
uint8_t opcode;
uint8_t byte2;
+#define SWS_NDOB 0x01
uint8_t addr[8];
uint8_t length[4];
uint8_t group;
OpenPOWER on IntegriCloud