summaryrefslogtreecommitdiff
path: root/usr/src/uts/common
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common')
-rw-r--r--usr/src/uts/common/io/scsi/targets/sd.c27
-rw-r--r--usr/src/uts/common/sys/scsi/impl/spc3_types.h25
-rw-r--r--usr/src/uts/common/sys/scsi/impl/uscsi.h10
3 files changed, 60 insertions, 2 deletions
diff --git a/usr/src/uts/common/io/scsi/targets/sd.c b/usr/src/uts/common/io/scsi/targets/sd.c
index dc5dc22e37..0e97d9125b 100644
--- a/usr/src/uts/common/io/scsi/targets/sd.c
+++ b/usr/src/uts/common/io/scsi/targets/sd.c
@@ -27,6 +27,7 @@
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
*/
/*
* Copyright 2011 cyril.galibern@opensvc.com
@@ -14175,15 +14176,21 @@ sd_initpkt_for_uscsi(struct buf *bp, struct scsi_pkt **pktpp)
/*
* Allocate the scsi_pkt for the command.
+ *
* Note: If PKT_DMA_PARTIAL flag is set, scsi_vhci binds a path
* during scsi_init_pkt time and will continue to use the
* same path as long as the same scsi_pkt is used without
- * intervening scsi_dma_free(). Since uscsi command does
+ * intervening scsi_dmafree(). Since uscsi command does
* not call scsi_dmafree() before retry failed command, it
* is necessary to make sure PKT_DMA_PARTIAL flag is NOT
* set such that scsi_vhci can use other available path for
* retry. Besides, ucsci command does not allow DMA breakup,
* so there is no need to set PKT_DMA_PARTIAL flag.
+ *
+ * More fundamentally, we can't support breaking up this DMA into
+ * multiple windows on x86. There is, in general, no guarantee
+ * that arbitrary SCSI commands are idempotent, which is required
+ * if we want to use multiple windows for a given command.
*/
if (uscmd->uscsi_rqlen > SENSE_LENGTH) {
pktp = scsi_init_pkt(SD_ADDRESS(un), NULL,
@@ -22408,6 +22415,7 @@ sdioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cred_p, int *rval_p)
case MHIOCGRP_REGISTERANDIGNOREKEY:
case CDROMCLOSETRAY:
case USCSICMD:
+ case USCSIMAXXFER:
goto skip_ready_valid;
default:
break;
@@ -22844,6 +22852,23 @@ skip_ready_valid:
}
break;
+ case USCSIMAXXFER:
+ SD_TRACE(SD_LOG_IOCTL, un, "USCSIMAXXFER\n");
+ cr = ddi_get_cred();
+ if ((drv_priv(cred_p) != 0) && (drv_priv(cr) != 0)) {
+ err = EPERM;
+ } else {
+ const uscsi_xfer_t xfer = un->un_max_xfer_size;
+
+ if (ddi_copyout(&xfer, (void *)arg, sizeof (xfer),
+ flag) != 0) {
+ err = EFAULT;
+ } else {
+ err = 0;
+ }
+ }
+ break;
+
case CDROMPAUSE:
case CDROMRESUME:
SD_TRACE(SD_LOG_IOCTL, un, "PAUSE-RESUME\n");
diff --git a/usr/src/uts/common/sys/scsi/impl/spc3_types.h b/usr/src/uts/common/sys/scsi/impl/spc3_types.h
index 456a0e336b..4b687eb9c6 100644
--- a/usr/src/uts/common/sys/scsi/impl/spc3_types.h
+++ b/usr/src/uts/common/sys/scsi/impl/spc3_types.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
*/
#ifndef _SPC3_TYPES_H
@@ -812,6 +813,30 @@ typedef struct spc3_persistent_reserve_in_cdb {
} spc3_persistent_reserve_in_cdb_t;
/*
+ * SPC-3 6.15 READ BUFFER
+ */
+typedef struct spc3_read_buffer_cdb {
+ uint8_t rbc_opcode;
+ DECL_BITFIELD2(
+ rbc_mode :5,
+ _reserved :3);
+ uint8_t rbc_bufferid;
+ uint8_t rbc_buffer_offset[3];
+ uint8_t rbc_allocation_len[3];
+ spc3_control_t rbc_control;
+} spc3_read_buffer_cdb_t;
+
+typedef enum spc3_read_buffer_mode {
+ SPC3_RB_MODE_COMB_HDR_DATA = 0x00,
+ SPC3_RB_MODE_VENDOR_SPECIFIC = 0x01,
+ SPC3_RB_MODE_DATA = 0x02,
+ SPC3_RB_MODE_DESCRIPTOR = 0x03,
+ SPC3_RB_MODE_ECHO_BUF = 0x0a,
+ SPC3_RB_MODE_ECHO_BUF_DESC = 0x0b,
+ SPC3_RB_MODE_ENABLE_EXPANDER_ECHO_BUF = 0x1a
+} spc3_read_buffer_mode_t;
+
+/*
* SPC-3 6.16 READ MEDIA SERIAL NUMBER
*/
typedef struct spc3_read_media_serial_number_cdb {
diff --git a/usr/src/uts/common/sys/scsi/impl/uscsi.h b/usr/src/uts/common/sys/scsi/impl/uscsi.h
index afce8ec081..f416b1bb5a 100644
--- a/usr/src/uts/common/sys/scsi/impl/uscsi.h
+++ b/usr/src/uts/common/sys/scsi/impl/uscsi.h
@@ -21,10 +21,12 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2016 Joyent, Inc.
*/
/*
- * Defines for user SCSI commands *
+ * Defines for user SCSI commands
*/
#ifndef _SYS_SCSI_IMPL_USCSI_H
@@ -186,10 +188,16 @@ struct uscsi_rqs32 {
#define RQS_VALID 0x02 /* RQS data is valid */
/*
+ * Structure for USCSIMAXXFER ioctls
+ */
+typedef uint64_t uscsi_xfer_t;
+
+/*
* User SCSI io control command
*/
#define USCSIIOC (0x04 << 8)
#define USCSICMD (USCSIIOC|201) /* user scsi command */
+#define USCSIMAXXFER (USCSIIOC|202) /* get max transfer size */
#ifdef _KERNEL