--- old/usr/src/uts/common/sys/scsi/targets/sddef.h	Mon Aug  5 17:37:09 2019
+++ new/usr/src/uts/common/sys/scsi/targets/sddef.h	Mon Aug  5 17:37:09 2019
@@ -18,12 +18,14 @@
  *
  * CDDL HEADER END
  */
+
 /*
  * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
  */
+
 /*
  * Copyright 2011 cyril.galibern@opensvc.com
- * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2019 Nexenta Systems, Inc.
  */
 
 #ifndef	_SYS_SCSI_TARGETS_SDDEF_H
@@ -38,10 +40,8 @@
 extern "C" {
 #endif
 
-
 #if defined(_KERNEL) || defined(_KMEMUSER)
 
-
 #define	SD_SUCCESS		0
 #define	SD_FAILURE		(-1)
 
@@ -56,35 +56,18 @@
 #define	TRUE			1
 #define	FALSE			0
 
-#if defined(VERBOSE)
-#undef VERBOSE
-#endif
-
-#if defined(SILENT)
-#undef SILENT
-#endif
-
-
 /*
- *  Fault Injection Flag for Inclusion of Code
- *
- *  This should only be defined when SDDEBUG is defined
- * #if DEBUG || lint
- * #define	SD_FAULT_INJECTION
- * #endif
+ * Fault Injection Flag for Inclusion of Code
  */
-
 #if DEBUG || lint
 #define	SD_FAULT_INJECTION
 #endif
-#define	VERBOSE			1
-#define	SILENT			0
 
 /*
  * Structures for recording whether a device is fully open or closed.
  * Assumptions:
  *
- *	+ There are only 8 (sparc) or 16 (x86) disk slices possible.
+ *	+ There are only 16 disk slices possible.
  *	+ BLK, MNT, CHR, SWP don't change in some future release!
  */
 
@@ -112,6 +95,11 @@
 #error "No VTOC format defined."
 #endif
 
+#define	P0_RAW_DISK	(NDKMAP)
+#define	FDISK_P1	(NDKMAP+1)
+#define	FDISK_P2	(NDKMAP+2)
+#define	FDISK_P3	(NDKMAP+3)
+#define	FDISK_P4	(NDKMAP+4)
 
 #define	SDUNIT(dev)	(getminor((dev)) >> SDUNIT_SHIFT)
 #define	SDPART(dev)	(getminor((dev)) &  SDPART_MASK)
@@ -131,8 +119,6 @@
 #define	SD_GET_INSTANCE_FROM_BUF(bp)				\
 	(getminor((bp)->b_edev) >> SDUNIT_SHIFT)
 
-
-
 struct ocinfo {
 	/*
 	 * Types BLK, MNT, CHR, SWP,
@@ -152,7 +138,6 @@
 #define	lyropen rinfo.lyr_open
 #define	regopen rinfo.reg_open
 
-
 #define	SD_CDB_GROUP0		0
 #define	SD_CDB_GROUP1		1
 #define	SD_CDB_GROUP5		2
@@ -165,8 +150,6 @@
 	uint32_t sc_maxlen;	/* Maximum transfer length supported */
 };
 
-
-
 /*
  * The following declaration are for Non-512 byte block support for the
  * removable devices. (ex - DVD RAM, MO).
@@ -196,9 +179,6 @@
 	kcondvar_t	wm_avail;	/* Sleep on this, while not available */
 };
 
-_NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, sd_w_map::wm_flags))
-
-
 /*
  * This is the struct for the layer-private data area for the
  * mapblocksize layer.
@@ -212,10 +192,56 @@
 	int		mbs_layer_index;	/* chain index for RMW */
 };
 
-_NOTE(SCHEME_PROTECTS_DATA("unshared data", sd_mapblocksize_info))
+/*
+ * Latency is tracked in usec and is quantized by power of two starting at
+ * offset SD_LAT_MIN_USEC_SHIFT. Values below that offset will go in the first
+ * (0th) bucket. Similar, values above SD_LAT_MAX_USEC_SHIFT go in the
+ * (SD_LAT_MAX_USEC_SHIFT - 1) bucket.
+ *
+ * From observations, using SAS SSDs and rotational drives these values are
+ * sufficient for now.
+ */
 
+#define	SD_LAT_MIN_USEC_SHIFT 4
+#define	SD_LAT_MAX_USEC_SHIFT 24
+#define	SD_LAT_BUCKET_MAX (SD_LAT_MAX_USEC_SHIFT - SD_LAT_MIN_USEC_SHIFT)
 
+typedef struct un_lat_stat {
+	hrtime_t l_sum;					/* total latency  */
+	uint64_t l_nrequest;				/* number of requests */
+	uint64_t l_histogram[SD_LAT_BUCKET_MAX]; 	/* latency histogram */
+} un_lat_stat_t;
+
+/* Thin-provisioning (UNMAP) flags for un_thin_flags. */
+enum {
+	SD_THIN_PROV_ENABLED =		1 << 0,	/* UNMAP available */
+	SD_THIN_PROV_READ_ZEROS =	1 << 1	/* unmapped blk = zeros */
+};
+
 /*
+ * Device limits as read from the Block Limits VPD page (0xB0). If the page
+ * is unavailable, will be filled with some defaults.
+ */
+typedef struct sd_blk_limits_s {
+	uint16_t	lim_opt_xfer_len_gran;
+	uint32_t	lim_max_xfer_len;
+	uint32_t	lim_opt_xfer_len;
+	uint32_t	lim_max_pfetch_len;
+	uint32_t	lim_max_unmap_lba_cnt;
+	uint32_t	lim_max_unmap_descr_cnt;
+	uint32_t	lim_opt_unmap_gran;
+	uint32_t	lim_unmap_gran_align;
+	uint64_t	lim_max_write_same_len;
+} sd_blk_limits_t;
+
+typedef struct sd_unmapstats {
+	kstat_named_t	us_cmds;
+	kstat_named_t	us_errs;
+	kstat_named_t	us_extents;
+	kstat_named_t	us_bytes;
+} sd_unmapstats_t;
+
+/*
  * sd_lun: The main data structure for a scsi logical unit.
  * Stored as the softstate structure for each device.
  */
@@ -275,7 +301,7 @@
 	 * Various configuration data
 	 */
 	uchar_t	un_ctype;		/* Controller type */
-	char 	*un_node_type;		/* minor node type */
+	char	*un_node_type;		/* minor node type */
 	uchar_t	un_interconnect_type;	/* Interconnect for underlying HBA */
 
 	uint_t	un_notready_retry_count; /* Per disk notready retry count */
@@ -284,7 +310,6 @@
 	uint_t	un_retry_count;		/* Per disk retry count */
 	uint_t	un_victim_retry_count;	/* Per disk victim retry count */
 
-	/* (4356701, 4367306) */
 	uint_t	un_reset_retry_count; /* max io retries before issuing reset */
 	ushort_t un_reserve_release_time; /* reservation release timeout */
 
@@ -356,7 +381,11 @@
 	union	ocmap	un_ocmap;		/* open partition map */
 	struct	kstat	*un_pstats[NSDMAP];	/* partition statistics */
 	struct	kstat	*un_stats;		/* disk statistics */
+	sd_unmapstats_t	*un_unmapstats;		/* UNMAP stats structure */
+	struct	kstat	*un_unmapstats_ks;	/* UNMAP kstat */
 	kstat_t		*un_errstats;		/* for error statistics */
+	kstat_t 	*un_lat_ksp;		/* pointer to the raw kstat */
+	un_lat_stat_t	*un_lat_stats;		/* data from the above kstat */
 	uint64_t	un_exclopen;		/* exclusive open bitmask */
 	ddi_devid_t	un_devid;		/* device id */
 	uint_t		un_vpd_page_mask;	/* Supported VPD pages */
@@ -402,7 +431,6 @@
 	    un_f_dvdram_writable_device	:1,	/* DVDRAM device is writable */
 	    un_f_cfg_cdda		:1,	/* READ CDDA supported */
 	    un_f_cfg_tur_check		:1,	/* verify un_ncmds before tur */
-
 	    un_f_use_adaptive_throttle	:1,	/* enable/disable adaptive */
 						/* throttling */
 	    un_f_pm_is_enabled		:1,	/* PM is enabled on this */
@@ -416,7 +444,7 @@
 						/* SCSI Logical Unit Reset */
 	    un_f_doorlock_supported	:1,	/* Device supports Doorlock */
 	    un_f_start_stop_supported	:1,	/* device has motor */
-	    un_f_reserved1		:1;
+	    un_f_sdconf_phy_blocksize	:1;	/* take pbs from sd.conf */
 
 	uint32_t
 	    un_f_mboot_supported	:1,	/* mboot supported */
@@ -438,7 +466,7 @@
 	    un_f_attach_spinup		:1,	/* spin up once the */
 						/* device is attached */
 	    un_f_log_sense_supported	:1,	/* support log sense */
-	    un_f_pm_supported		:1, 	/* support power-management */
+	    un_f_pm_supported		:1,	/* support power-management */
 	    un_f_cfg_is_lsi		:1,	/* Is LSI device, */
 						/* default to NO */
 	    un_f_wcc_inprog		:1,	/* write cache change in */
@@ -466,11 +494,12 @@
 	    un_f_enable_rmw		:1,	/* Force RMW in sd driver */
 	    un_f_expnevent		:1,
 	    un_f_cache_mode_changeable	:1,	/* can change cache mode */
-	    un_f_reserved		:1;
+	    un_f_detach_waiting		:1;
 
 	/* Ptr to table of strings for ASC/ASCQ error message printing */
 	struct scsi_asq_key_strings	*un_additional_codes;
 
+	kcondvar_t	un_detach_cv;
 	/*
 	 * Power Management support.
 	 *
@@ -508,6 +537,12 @@
 	uint64_t	un_rmw_incre_count;	/* count I/O */
 	timeout_id_t	un_rmw_msg_timeid;	/* for RMW message control */
 
+	/* Thin provisioning support (see SD_THIN_PROV_*) */
+	uint64_t	un_thin_flags;
+
+	/* Block limits (0xB0 VPD page) */
+	sd_blk_limits_t	un_blk_lim;
+
 	/* For timeout callback to issue a START STOP UNIT command */
 	timeout_id_t	un_startstop_timeid;
 
@@ -529,6 +564,9 @@
 	 */
 	uint_t		un_sonoma_failure_count;
 
+	int		un_io_time;
+	hrtime_t 	un_slow_io_threshold;
+
 	/*
 	 * Support for failfast operation.
 	 */
@@ -543,7 +581,6 @@
 					/* un_f_write_cache_enabled */
 
 #ifdef SD_FAULT_INJECTION
-	/* SD Fault Injection */
 #define	SD_FI_MAX_BUF 65536
 #define	SD_FI_MAX_ERROR 1024
 	kmutex_t			un_fi_mutex;
@@ -553,10 +590,10 @@
 	struct sd_fi_xb		*sd_fi_fifo_xb[SD_FI_MAX_ERROR];
 	struct sd_fi_un		*sd_fi_fifo_un[SD_FI_MAX_ERROR];
 	struct sd_fi_arq	*sd_fi_fifo_arq[SD_FI_MAX_ERROR];
+	struct sd_fi_tran	*sd_fi_fifo_tran[SD_FI_MAX_ERROR];
 	uint_t				sd_fi_fifo_start;
 	uint_t				sd_fi_fifo_end;
 	uint_t				sd_injection_mask;
-
 #endif
 
 	cmlb_handle_t	un_cmlbhandle;
@@ -632,100 +669,10 @@
  * for physio, for devices without tagged queuing enabled.
  * The default for devices with tagged queuing enabled is SD_MAX_XFER_SIZE
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_DEFAULT_MAX_XFER_SIZE	(256 * 1024)
-#endif
 #define	SD_MAX_XFER_SIZE		(1024 * 1024)
 
 /*
- * Warlock annotations
- */
-_NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, sd_lun))
-_NOTE(READ_ONLY_DATA(sd_lun::un_sd))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_reservation_type))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_mincdb))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_maxcdb))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_max_hba_cdb))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_status_len))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_f_arq_enabled))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_ctype))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_cmlbhandle))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_fm_private))
-
-
-_NOTE(SCHEME_PROTECTS_DATA("safe sharing",
-	sd_lun::un_mhd_token
-	sd_lun::un_state
-	sd_lun::un_tagflags
-	sd_lun::un_f_format_in_progress
-	sd_lun::un_resvd_timeid
-	sd_lun::un_reset_throttle_timeid
-	sd_lun::un_startstop_timeid
-	sd_lun::un_dcvb_timeid
-	sd_lun::un_f_allow_bus_device_reset
-	sd_lun::un_sys_blocksize
-	sd_lun::un_tgt_blocksize
-	sd_lun::un_phy_blocksize
-	sd_lun::un_additional_codes))
-
-_NOTE(SCHEME_PROTECTS_DATA("stable data",
-	sd_lun::un_reserve_release_time
-	sd_lun::un_max_xfer_size
-	sd_lun::un_partial_dma_supported
-	sd_lun::un_buf_breakup_supported
-	sd_lun::un_f_is_fibre
-	sd_lun::un_node_type
-	sd_lun::un_buf_chain_type
-	sd_lun::un_uscsi_chain_type
-	sd_lun::un_direct_chain_type
-	sd_lun::un_priority_chain_type
-	sd_lun::un_xbuf_attr
-	sd_lun::un_cmd_timeout
-	sd_lun::un_pkt_flags))
-
-_NOTE(SCHEME_PROTECTS_DATA("Unshared data",
-	block_descriptor
-	buf
-	cdrom_subchnl
-	cdrom_tocentry
-	cdrom_tochdr
-	cdrom_read
-	dk_cinfo
-	dk_devid
-	dk_label
-	dk_map
-	dk_temperature
-	mhioc_inkeys
-	mhioc_inresvs
-	mode_caching
-	mode_header
-	mode_speed
-	scsi_cdb
-	scsi_arq_status
-	scsi_extended_sense
-	scsi_inquiry
-	scsi_pkt
-	uio
-	uscsi_cmd))
-
-
-_NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_device dk_cinfo))
-_NOTE(SCHEME_PROTECTS_DATA("unique per pkt", scsi_status scsi_cdb))
-
-_NOTE(MUTEX_PROTECTS_DATA(sd_lun::un_pm_mutex, sd_lun::un_pm_count
-	sd_lun::un_pm_timeid sd_lun::un_pm_busy sd_lun::un_pm_busy_cv
-	sd_lun::un_pm_idle_timeid))
-
-#ifdef SD_FAULT_INJECTION
-_NOTE(MUTEX_PROTECTS_DATA(sd_lun::un_fi_mutex,
-	sd_lun::sd_fi_buf_len sd_lun::sd_fi_log))
-#endif
-
-/* _NOTE(LOCK_ORDER(sd_lun::un_sd.sd_mutex sd_lun::un_pm_mutex)) */
-
-
-
-/*
  * Referenced for frequently-accessed members of the unit structure
  */
 #define	SD_SCSI_DEVP(un)	((un)->un_sd)
@@ -737,7 +684,6 @@
 #define	SD_FM_LOG(un)		(((struct sd_fm_internal *)\
 				((un)->un_fm_private))->fm_log_level)
 
-
 /*
  * Values for un_ctype
  */
@@ -807,7 +753,7 @@
  */
 #define	SD_WTYPE_SIMPLE	0x001	/* Write aligned at blksize boundary */
 #define	SD_WTYPE_RMW	0x002	/* Write requires read-modify-write */
-#define	SD_WM_BUSY		0x100	/* write-map is busy */
+#define	SD_WM_BUSY	0x100	/* write-map is busy */
 
 /*
  * RMW type
@@ -814,7 +760,7 @@
  */
 #define	SD_RMW_TYPE_DEFAULT	0	/* do rmw with warning message */
 #define	SD_RMW_TYPE_NO_WARNING	1	/* do rmw without warning message */
-#define	SD_RMW_TYPE_RETURN_ERROR	2	/* rmw disabled */
+#define	SD_RMW_TYPE_RETURN_ERROR 2	/* rmw disabled */
 
 /* Device error kstats */
 struct sd_errstats {
@@ -958,13 +904,6 @@
 	kcondvar_t		srq_resv_reclaim_cv;
 };
 
-_NOTE(MUTEX_PROTECTS_DATA(sd_resv_reclaim_request::srq_resv_reclaim_mutex,
-    sd_resv_reclaim_request))
-_NOTE(SCHEME_PROTECTS_DATA("unshared data", sd_thr_request))
-_NOTE(SCHEME_PROTECTS_DATA("Unshared data", sd_prout))
-
-
-
 /*
  * Driver Logging Components
  *
@@ -1049,6 +988,8 @@
  * sd_fi_arq replicates the variables that are
  *           exposed for Auto-Reqeust-Sense
  *
+ * sd_fi_tran HBA-level fault injection.
+ *
  */
 struct sd_fi_pkt {
 	uint_t  pkt_flags;			/* flags */
@@ -1099,6 +1040,15 @@
 	struct scsi_extended_sense	sts_sensedata;
 };
 
+enum sd_fi_tran_cmd {
+	SD_FLTINJ_CMD_BUSY, /* Reject command instead of sending it to HW */
+	SD_FLTINJ_CMD_TIMEOUT /* Time-out command. */
+};
+
+struct sd_fi_tran {
+	enum sd_fi_tran_cmd tran_cmd;
+};
+
 /*
  * Conditional set def
  */
@@ -1112,16 +1062,17 @@
 	}
 
 /* SD FaultInjection ioctls */
-#define	SDIOC			('T'<<8)
-#define	SDIOCSTART		(SDIOC|1)
-#define	SDIOCSTOP		(SDIOC|2)
+#define	SDIOC		('T'<<8)
+#define	SDIOCSTART	(SDIOC|1)
+#define	SDIOCSTOP	(SDIOC|2)
 #define	SDIOCINSERTPKT	(SDIOC|3)
 #define	SDIOCINSERTXB	(SDIOC|4)
 #define	SDIOCINSERTUN	(SDIOC|5)
 #define	SDIOCINSERTARQ	(SDIOC|6)
-#define	SDIOCPUSH		(SDIOC|7)
+#define	SDIOCPUSH	(SDIOC|7)
 #define	SDIOCRETRIEVE	(SDIOC|8)
-#define	SDIOCRUN		(SDIOC|9)
+#define	SDIOCRUN	(SDIOC|9)
+#define	SDIOCINSERTTRAN	(SDIOC|0xA)
 #endif
 
 #else
@@ -1174,6 +1125,8 @@
 #define	SD_STATE_DUMPING	3
 #define	SD_STATE_SUSPENDED	4
 #define	SD_STATE_PM_CHANGING	5
+#define	SD_STATE_ATTACHING	6
+#define	SD_STATE_ATTACH_FAILED	7
 
 /*
  * The table is to be interpreted as follows: The rows lists all the states
@@ -1228,8 +1181,6 @@
  */
 #define	SD_LOWEST_VALID_THROTTLE	2
 
-
-
 /* Return codes for sd_send_polled_cmd() and sd_scsi_poll() */
 #define	SD_CMD_SUCCESS			0
 #define	SD_CMD_FAILURE			1
@@ -1420,8 +1371,6 @@
 	 */
 };
 
-_NOTE(SCHEME_PROTECTS_DATA("unique per pkt", sd_xbuf))
-
 #define	SD_PKT_ALLOC_SUCCESS			0
 #define	SD_PKT_ALLOC_FAILURE			1
 #define	SD_PKT_ALLOC_FAILURE_NO_DMA		2
@@ -1455,8 +1404,6 @@
 	uint64_t		ui_ena;
 };
 
-_NOTE(SCHEME_PROTECTS_DATA("Unshared data", sd_uscsi_info))
-
 /*
  * This structure is used to issue 'internal' command sequences from the
  * driver's attach(9E)/open(9E)/etc entry points. It provides a common context
@@ -1497,8 +1444,6 @@
 	char			ssc_info[1024]; /* Buffer holding for info */
 } sd_ssc_t;
 
-_NOTE(SCHEME_PROTECTS_DATA("Unshared data", sd_ssc_t))
-
 /*
  * This struct switch different 'type-of-assessment'
  * as an input argument for sd_ssc_assessment
@@ -1705,10 +1650,10 @@
 
 
 /*
- * 60 seconds is a *very* reasonable amount of time for most slow CD
- * operations.
+ * 15 seconds is a *very* reasonable amount of time for any device with retries.
+ * Doubled for slow CD operations.
  */
-#define	SD_IO_TIME			60
+#define	SD_IO_TIME			15
 
 /*
  * 2 hours is an excessively reasonable amount of time for format operations.
@@ -1739,11 +1684,7 @@
  * 100 msec. is what we'll wait for certain retries for fibre channel
  * targets, 0 msec for parallel SCSI.
  */
-#if defined(__fibre)
-#define	SD_RETRY_DELAY			(drv_usectohz(100000))
-#else
 #define	SD_RETRY_DELAY			((clock_t)0)
-#endif
 
 /*
  * Number of times we'll retry a normal operation.
@@ -1752,16 +1693,12 @@
  * (need to distinguish between Target and Transport failure)
  *
  */
-#if defined(__fibre)
-#define	SD_RETRY_COUNT			3
-#else
 #define	SD_RETRY_COUNT			5
-#endif
 
 /*
  * Number of times we will retry for unit attention.
  */
-#define	SD_UA_RETRY_COUNT		600
+#define	SD_UA_RETRY_COUNT		25
 
 #define	SD_VICTIM_RETRY_COUNT(un)	(un->un_victim_retry_count)
 #define	CD_NOT_READY_RETRY_COUNT(un)	(un->un_retry_count * 2)
@@ -1869,9 +1806,6 @@
 
 /*
  * Driver Property Bit Flag definitions
- *
- * Unfortunately, for historical reasons, the bit-flag definitions are
- * different on SPARC, INTEL, & FIBRE platforms.
  */
 
 /*
@@ -1890,13 +1824,7 @@
  * Bit flag telling driver to set the controller type from sd.conf
  * sd-config-list and driver table.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_CTYPE		1
-#elif defined(__fibre)
-#define	SD_CONF_SET_CTYPE		5
-#else
-#define	SD_CONF_SET_CTYPE		1
-#endif
 #define	SD_CONF_BSET_CTYPE		(1 << SD_CONF_SET_CTYPE)
 
 /*
@@ -1903,13 +1831,7 @@
  * Bit flag telling driver to set the not ready retry count for a device from
  * sd.conf sd-config-list and driver table.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_NOTREADY_RETRIES	10
-#elif defined(__fibre)
-#define	SD_CONF_SET_NOTREADY_RETRIES	1
-#else
-#define	SD_CONF_SET_NOTREADY_RETRIES	2
-#endif
 #define	SD_CONF_BSET_NRR_COUNT		(1 << SD_CONF_SET_NOTREADY_RETRIES)
 
 /*
@@ -1916,13 +1838,7 @@
  * Bit flag telling driver to set SCSI status BUSY Retries from sd.conf
  * sd-config-list and driver table.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_BUSY_RETRIES 	11
-#elif defined(__fibre)
-#define	SD_CONF_SET_BUSY_RETRIES 	2
-#else
-#define	SD_CONF_SET_BUSY_RETRIES 	5
-#endif
 #define	SD_CONF_BSET_BSY_RETRY_COUNT	(1 << SD_CONF_SET_BUSY_RETRIES)
 
 /*
@@ -1929,21 +1845,13 @@
  * Bit flag telling driver that device does not have a valid/unique serial
  * number.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_FAB_DEVID		2
-#else
-#define	SD_CONF_SET_FAB_DEVID		3
-#endif
 #define	SD_CONF_BSET_FAB_DEVID   	(1 << SD_CONF_SET_FAB_DEVID)
 
 /*
  * Bit flag telling driver to disable all caching for disk device.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_NOCACHE		3
-#else
-#define	SD_CONF_SET_NOCACHE		4
-#endif
 #define	SD_CONF_BSET_NOCACHE		(1 << SD_CONF_SET_NOCACHE)
 
 /*
@@ -1950,11 +1858,7 @@
  * Bit flag telling driver that the PLAY AUDIO command requires parms in BCD
  * format rather than binary.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_PLAYMSF_BCD		4
-#else
-#define	SD_CONF_SET_PLAYMSF_BCD		6
-#endif
 #define	SD_CONF_BSET_PLAYMSF_BCD    	(1 << SD_CONF_SET_PLAYMSF_BCD)
 
 /*
@@ -1961,11 +1865,7 @@
  * Bit flag telling driver that the response from the READ SUBCHANNEL command
  * has BCD fields rather than binary.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_READSUB_BCD		5
-#else
-#define	SD_CONF_SET_READSUB_BCD		7
-#endif
 #define	SD_CONF_BSET_READSUB_BCD	(1 << SD_CONF_SET_READSUB_BCD)
 
 /*
@@ -1972,11 +1872,7 @@
  * Bit in flags telling driver that the track number fields in the READ TOC
  * request and respone are in BCD rather than binary.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_READ_TOC_TRK_BCD	6
-#else
-#define	SD_CONF_SET_READ_TOC_TRK_BCD	8
-#endif
 #define	SD_CONF_BSET_READ_TOC_TRK_BCD	(1 << SD_CONF_SET_READ_TOC_TRK_BCD)
 
 /*
@@ -1983,11 +1879,7 @@
  * Bit flag telling driver that the address fields in the READ TOC request and
  * respone are in BCD rather than binary.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_READ_TOC_ADDR_BCD	7
-#else
-#define	SD_CONF_SET_READ_TOC_ADDR_BCD	9
-#endif
 #define	SD_CONF_BSET_READ_TOC_ADDR_BCD	(1 << SD_CONF_SET_READ_TOC_ADDR_BCD)
 
 /*
@@ -1994,11 +1886,7 @@
  * Bit flag telling the driver that the device doesn't support the READ HEADER
  * command.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_NO_READ_HEADER	8
-#else
-#define	SD_CONF_SET_NO_READ_HEADER	10
-#endif
 #define	SD_CONF_BSET_NO_READ_HEADER 	(1 << SD_CONF_SET_NO_READ_HEADER)
 
 /*
@@ -2005,11 +1893,7 @@
  * Bit flag telling the driver that for the READ CD command the device uses
  * opcode 0xd4 rather than 0xbe.
  */
-#if defined(__i386) || defined(__amd64)
 #define	SD_CONF_SET_READ_CD_XD4		9
-#else
-#define	SD_CONF_SET_READ_CD_XD4 	11
-#endif
 #define	SD_CONF_BSET_READ_CD_XD4	(1 << SD_CONF_SET_READ_CD_XD4)
 
 /*
@@ -2035,22 +1919,22 @@
 #define	SD_CONF_BSET_TUR_CHECK		(1 << SD_CONF_SET_TUR_CHECK)
 
 /*
- * Bit in flags telling driver to set min. throttle from ssd.conf
- * ssd-config-list and driver table.
+ * Bit in flags telling driver to set min. throttle from sd.conf
+ * sd-config-list and driver table.
  */
 #define	SD_CONF_SET_MIN_THROTTLE	15
 #define	SD_CONF_BSET_MIN_THROTTLE	(1 << SD_CONF_SET_MIN_THROTTLE)
 
 /*
- * Bit in flags telling driver to set disksort disable flag from ssd.conf
- * ssd-config-list and driver table.
+ * Bit in flags telling driver to set disksort disable flag from sd.conf
+ * sd-config-list and driver table.
  */
 #define	SD_CONF_SET_DISKSORT_DISABLED	16
 #define	SD_CONF_BSET_DISKSORT_DISABLED	(1 << SD_CONF_SET_DISKSORT_DISABLED)
 
 /*
- * Bit in flags telling driver to set LUN Reset enable flag from [s]sd.conf
- * [s]sd-config-list and driver table.
+ * Bit in flags telling driver to set LUN Reset enable flag from sd.conf
+ * sd-config-list and driver table.
  */
 #define	SD_CONF_SET_LUN_RESET_ENABLED	17
 #define	SD_CONF_BSET_LUN_RESET_ENABLED	(1 << SD_CONF_SET_LUN_RESET_ENABLED)
@@ -2059,14 +1943,14 @@
  * Bit in flags telling driver that the write cache on the device is
  * non-volatile.
  */
-#define	SD_CONF_SET_CACHE_IS_NV	18
+#define	SD_CONF_SET_CACHE_IS_NV		18
 #define	SD_CONF_BSET_CACHE_IS_NV	(1 << SD_CONF_SET_CACHE_IS_NV)
 
 /*
- * Bit in flags telling driver that the power condition flag from [s]sd.conf
- * [s]sd-config-list and driver table.
+ * Bit in flags telling driver that the power condition flag from sd.conf
+ * sd-config-list and driver table.
  */
-#define	SD_CONF_SET_PC_DISABLED	19
+#define	SD_CONF_SET_PC_DISABLED		19
 #define	SD_CONF_BSET_PC_DISABLED	(1 << SD_CONF_SET_PC_DISABLED)
 
 /*
@@ -2170,8 +2054,6 @@
 	uchar_t bdesc_length_lo;
 };
 
-_NOTE(SCHEME_PROTECTS_DATA("Unshared data", mode_header_grp2))
-
 /*
  * Length of the Mode Parameter Header for the Group 2 Mode Select command
  */
@@ -2375,7 +2257,8 @@
 #define	SD_VPD_ASCII_OP_PG	0x08	/* 0x82 - ASCII Op Defs */
 #define	SD_VPD_DEVID_WWN_PG	0x10	/* 0x83 - Device Identification */
 #define	SD_VPD_EXTENDED_DATA_PG	0x80	/* 0x86 - Extended data about the lun */
-#define	SD_VPD_DEV_CHARACTER_PG	0x400	/* 0xB1 - Device Characteristics */
+#define	SD_VPD_BLK_LIMITS_PG	0x400	/* 0xB0 - Block Limits */
+#define	SD_VPD_DEV_CHARACTER_PG	0x800	/* 0xB1 - Device Characteristics */
 
 /*
  * Non-volatile cache support
@@ -2394,19 +2277,6 @@
 #define	SD_VPD_NV_SUP	0x02
 #define	SD_SYNC_NV_BIT 0x04
 
-/*
- * Addition from sddef.intel.h
- */
-#if defined(__i386) || defined(__amd64)
-
-#define	P0_RAW_DISK	(NDKMAP)
-#define	FDISK_P1	(NDKMAP+1)
-#define	FDISK_P2	(NDKMAP+2)
-#define	FDISK_P3	(NDKMAP+3)
-#define	FDISK_P4	(NDKMAP+4)
-
-#endif	/* __i386 || __amd64 */
-
 #ifdef	__cplusplus
 }
 #endif
