--- old/usr/src/uts/common/sys/scsi/adapters/mpt_sas3/mptsas3_var.h	2014-06-12 17:42:19.601364295 +0100
+++ new/usr/src/uts/common/sys/scsi/adapters/mpt_sas3/mptsas3_var.h	2014-06-12 17:42:19.607556677 +0100
@@ -21,8 +21,9 @@
 
 /*
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014, Tegile Systems Inc. All rights reserved.
  */
 
 /*
@@ -52,17 +53,18 @@
  * DAMAGE.
  */
 
-#ifndef _SYS_SCSI_ADAPTERS_MPTVAR_H
-#define	_SYS_SCSI_ADAPTERS_MPTVAR_H
+#ifndef _SYS_SCSI_ADAPTERS_MPTSAS3_VAR_H
+#define	_SYS_SCSI_ADAPTERS_MPTSAS3_VAR_H
 
 #include <sys/byteorder.h>
+#include <sys/queue.h>
 #include <sys/isa_defs.h>
 #include <sys/sunmdi.h>
 #include <sys/mdi_impldefs.h>
-#include <sys/scsi/adapters/mpt_sas/mptsas_hash.h>
-#include <sys/scsi/adapters/mpt_sas/mptsas_ioctl.h>
-#include <sys/scsi/adapters/mpt_sas/mpi/mpi2_tool.h>
-#include <sys/scsi/adapters/mpt_sas/mpi/mpi2_cnfg.h>
+#include <sys/scsi/adapters/mpt_sas3/mptsas3_hash.h>
+#include <sys/scsi/adapters/mpt_sas3/mptsas3_ioctl.h>
+#include <sys/scsi/adapters/mpt_sas3/mpi/mpi2_tool.h>
+#include <sys/scsi/adapters/mpt_sas3/mpi/mpi2_cnfg.h>
 
 #ifdef	__cplusplus
 extern "C" {
@@ -141,14 +143,17 @@
 	(((mpt->m_req_frame_size - (sizeof (MPI2_SCSI_IO_REQUEST))) / 8) + 1)
 
 /*
- * Caculating how many 64-bit DMA simple elements can be stored in the first
+ * Calculating how many 64-bit DMA simple elements can be stored in the first
  * frame. Note that msg_scsi_io_request contains 2 double-words (8 bytes) for
  * element storage.  And 64-bit dma element is 3 double-words (12 bytes) in
- * size.
+ * size. IEEE 64-bit dma element used for SAS3 controllers is 4 double-words
+ * (16 bytes).
  */
 #define	MPTSAS_MAX_FRAME_SGES64(mpt) \
 	((mpt->m_req_frame_size - \
-	(sizeof (MPI2_SCSI_IO_REQUEST)) + sizeof (MPI2_SGE_IO_UNION)) / 12)
+	sizeof (MPI2_SCSI_IO_REQUEST) + sizeof (MPI2_SGE_IO_UNION)) / \
+	(mpt->m_MPI25 ? sizeof (MPI2_IEEE_SGE_SIMPLE64) : \
+	sizeof (MPI2_SGE_SIMPLE64)))
 
 /*
  * Scatter-gather list structure defined by HBA hardware
@@ -200,30 +205,36 @@
 	mptsas_phymask_t mta_phymask;
 } mptsas_target_addr_t;
 
+TAILQ_HEAD(mptsas_active_cmdq, mptsas_cmd);
+typedef struct mptsas_active_cmdq mptsas_active_cmdq_t;
+
 typedef	struct mptsas_target {
+		kmutex_t		m_t_mutex;
 		mptsas_target_addr_t	m_addr;
 		refhash_link_t		m_link;
-		uint8_t			m_dr_flag;
 		uint16_t		m_devhdl;
 		uint32_t		m_deviceinfo;
-		uint8_t			m_phynum;
 		uint32_t		m_dups;
-		int32_t			m_timeout;
-		int32_t			m_timebase;
+		uint8_t			m_phynum;
+		mptsas_active_cmdq_t	m_active_cmdq;
 		int32_t			m_t_throttle;
 		int32_t			m_t_ncmds;
 		int32_t			m_reset_delay;
 		int32_t			m_t_nwait;
-
-		uint16_t		m_qfull_retry_interval;
-		uint8_t			m_qfull_retries;
+		uint16_t		m_io_flags;
 		uint16_t		m_enclosure;
 		uint16_t		m_slot_num;
-		uint32_t		m_tgt_unconfigured;
+		uint16_t		m_qfull_retry_interval;
+		uint8_t			m_qfull_retries;
+		uint8_t			m_tgt_unconfigured;
 		uint8_t			m_led_status;
-
+		uint8_t			m_dr_flag;
 } mptsas_target_t;
 
+/*
+ * If you change this structure, be sure that mptsas_smp_target_copy()
+ * does the right thing.
+ */
 typedef struct mptsas_smp {
 	mptsas_target_addr_t	m_addr;
 	refhash_link_t		m_link;
@@ -237,7 +248,7 @@
 	ddi_dma_handle_t m_dma_hdl;
 	ddi_acc_handle_t m_acc_hdl;
 	caddr_t m_frames_addr;
-	uint32_t m_phys_addr;
+	uint64_t m_phys_addr;
 } mptsas_cache_frames_t;
 
 typedef struct	mptsas_cmd {
@@ -251,24 +262,22 @@
 	off_t			cmd_dma_offset;
 	size_t			cmd_dma_len;
 	uint32_t		cmd_totaldmacount;
-
-	ddi_dma_handle_t	cmd_arqhandle;	/* dma arq handle */
-	ddi_dma_cookie_t	cmd_arqcookie;
-	struct buf		*cmd_arq_buf;
-	ddi_dma_handle_t	cmd_ext_arqhandle; /* dma extern arq handle */
-	ddi_dma_cookie_t	cmd_ext_arqcookie;
-	struct buf		*cmd_ext_arq_buf;
+	caddr_t			cmd_arq_buf;
 
 	int			cmd_pkt_flags;
 
-	/* timer for command in active slot */
-	int			cmd_active_timeout;
+	/* pending expiration time for command in active slot */
+	hrtime_t		cmd_active_expiration;
+	TAILQ_ENTRY(mptsas_cmd)	cmd_active_link;
 
 	struct scsi_pkt		*cmd_pkt;
 	struct scsi_arq_status	cmd_scb;
 	uchar_t			cmd_cdblen;	/* length of cdb */
 	uchar_t			cmd_rqslen;	/* len of requested rqsense */
 	uchar_t			cmd_privlen;
+	uint16_t		cmd_extrqslen;	/* len of extended rqsense */
+	uint16_t		cmd_extrqschunks; /* len in map chunks */
+	uint16_t		cmd_extrqsidx;	/* Index into map */
 	uint_t			cmd_scblen;
 	uint32_t		cmd_dmacount;
 	uint64_t		cmd_dma_addr;
@@ -281,6 +290,7 @@
 	uint64_t		cmd_pkt_private[PKT_PRIV_LEN];
 	uint32_t		cmd_slot;
 	uint32_t		ioc_cmd_slot;
+	uint8_t			cmd_rpqidx;
 
 	mptsas_cache_frames_t	*cmd_extra_frames;
 
@@ -316,7 +326,6 @@
 #define	CFLAG_PMM_RECEIVED	0x200000 /* use cmd_pmm* for saving pointers */
 #define	CFLAG_RETRY		0x400000 /* cmd has been retried */
 #define	CFLAG_CMDIOC		0x800000 /* cmd is just for for ioc, no io */
-#define	CFLAG_EXTARQBUFVALID	0x1000000 /* extern arq buf handle is valid */
 #define	CFLAG_PASSTHRU		0x2000000 /* cmd is a passthrough command */
 #define	CFLAG_XARQ		0x4000000 /* cmd requests for extra sense */
 #define	CFLAG_CMDACK		0x8000000 /* cmd for event ack */
@@ -325,6 +334,15 @@
 #define	CFLAG_CONFIG		0x40000000 /* cmd is for config header/page */
 #define	CFLAG_FW_DIAG		0x80000000 /* cmd is for FW diag buffers */
 
+#ifdef MPTSAS_DEBUG
+/* Could be used with cmn_err %b */
+#define	CFLAGS_DEBUG_BITS "\\020\\0CmdDisc\\1Watch\\2Finished\\3ChkSeg" \
+	"\\4Cmpltd\\5Prepd\\6InTran\\7RestPtrs\\8ARQIP\\9TM\\10CArq" \
+	"\\11DMAVal\\12DMASnd\\13CIopb\\14CDBExt\\15SCBExt\\16Free" \
+	"\\17PrivExt\\18DMAPrtl\\19QFull\\20Tout\\21PMMRcv\\22Retry" \
+	"\\23CIoc\\25PThru\\26XArq\\27CAck\\28TXq\\29FWCmd\\30Config\\31FWDiag"
+#endif
+
 #define	MPTSAS_SCSI_REPORTLUNS_ADDRESS_SIZE			8
 #define	MPTSAS_SCSI_REPORTLUNS_ADDRESS_MASK			0xC0
 #define	MPTSAS_SCSI_REPORTLUNS_ADDRESS_PERIPHERAL			0x00
@@ -362,7 +380,9 @@
 	uint32_t request_size;
 	uint32_t data_size;
 	uint32_t dataout_size;
-	uint32_t direction;
+	uint8_t direction;
+	uint8_t simple;
+	uint16_t sgl_offset;
 	ddi_dma_cookie_t data_cookie;
 	ddi_dma_cookie_t dataout_cookie;
 } mptsas_pt_request_t;
@@ -548,7 +568,7 @@
  */
 #define	MPTSAS_DR_EVENT_RECONFIG_TARGET	0x01
 #define	MPTSAS_DR_EVENT_OFFLINE_TARGET	0x02
-#define	MPTSAS_TOPO_FLAG_REMOVE_HANDLE	0x04
+#define	MPTSAS_DR_EVENT_REMOVE_HANDLE	0x04
 
 /*
  * SMP target hotplug events
@@ -642,25 +662,58 @@
 } mptsas_phy_info_t;
 
 
-typedef struct mptsas_doneq_thread_arg {
+typedef struct mptsas_thread_arg {
 	void		*mpt;
-	uint64_t	t;
-} mptsas_doneq_thread_arg_t;
+	uint32_t	t;
+} mptsas_thread_arg_t;
+
+typedef struct mptsas_done_list {
+	mptsas_cmd_t		*dl_q;
+	mptsas_cmd_t		**dl_tail;
+	uint32_t		dl_len;
+} mptsas_done_list_t;
 
 #define	MPTSAS_DONEQ_THREAD_ACTIVE	0x1
 typedef struct mptsas_doneq_thread_list {
-	mptsas_cmd_t		*doneq;
-	mptsas_cmd_t		**donetail;
+	mptsas_done_list_t	dlist;
 	kthread_t		*threadp;
 	kcondvar_t		cv;
 	ushort_t		reserv1;
 	uint32_t		reserv2;
 	kmutex_t		mutex;
 	uint32_t		flag;
-	uint32_t		len;
-	mptsas_doneq_thread_arg_t	arg;
+	mptsas_thread_arg_t	arg;
 } mptsas_doneq_thread_list_t;
 
+typedef struct mptsas_reply_pqueue {
+	kmutex_t		rpq_mutex;
+	uint8_t			rpq_num;
+	caddr_t			rpq_queue; /* Pointer to this queue base */
+	uint32_t		rpq_index; /* Index of next replyq entry */
+	uint32_t		rpq_ncmds; /* Number of outstanding commands */
+	mptsas_done_list_t	rpq_dlist;
+	uint32_t		rpq_intr_count;
+	uint32_t		rpq_intr_unclaimed;
+	uint32_t		rpq_intr_mutexbusy;
+} mptsas_reply_pqueue_t;
+
+
+typedef struct mptsas_tx_waitqueue {
+	kmutex_t	txwq_mutex;
+	kcondvar_t	txwq_cv;
+	kcondvar_t	txwq_drain_cv;
+	kthread_t	*txwq_threadp;
+	mptsas_cmd_t	*txwq_cmdq;	/* TX cmd queue for active request */
+	mptsas_cmd_t	**txwq_qtail;	/* tx_wait queue tail ptr */
+	uint32_t	txwq_len;	/* TX queue length */
+	mptsas_thread_arg_t	arg;
+	uint8_t		txwq_active;	/* Thread active flag */
+	uint8_t		txwq_draining;	/* TX queue draining flag */
+	uint8_t		txwq_wdrain;
+} mptsas_tx_waitqueue_t;
+
+#define	NUM_TX_WAITQ	2
+
 typedef struct mptsas {
 	int		m_instance;
 
@@ -687,32 +740,33 @@
 
 	m_raidconfig_t	m_raidconfig[MPTSAS_MAX_RAIDCONFIGS];
 	uint8_t		m_num_raid_configs;
+	uint8_t		m_pref_tx_waitq;
 
 	struct mptsas_slots *m_active;	/* outstanding cmds */
 
 	mptsas_cmd_t	*m_waitq;	/* cmd queue for active request */
 	mptsas_cmd_t	**m_waitqtail;	/* wait queue tail ptr */
-
-	kmutex_t	m_tx_waitq_mutex;
-	mptsas_cmd_t	*m_tx_waitq;	/* TX cmd queue for active request */
-	mptsas_cmd_t	**m_tx_waitqtail;	/* tx_wait queue tail ptr */
-	int		m_tx_draining;	/* TX queue draining flag */
-
-	mptsas_cmd_t	*m_doneq;	/* queue of completed commands */
-	mptsas_cmd_t	**m_donetail;	/* queue tail ptr */
+	mptsas_tx_waitqueue_t	m_tx_waitq[NUM_TX_WAITQ];
+	uint16_t		m_txwq_thread_threshold;
+	uint16_t		m_txwq_thread_n;
+	uint8_t			m_txwq_enabled;
+	uint8_t			m_txwq_allow_q_jumping;
+	mptsas_done_list_t	m_dlist; /* List of completed commands */
 
 	/*
 	 * variables for helper threads (fan-out interrupts)
 	 */
 	mptsas_doneq_thread_list_t	*m_doneq_thread_id;
-	uint32_t		m_doneq_thread_n;
+	uint16_t		m_doneq_thread_n;
+	uint16_t		m_doneq_next_thread;
 	uint32_t		m_doneq_thread_threshold;
 	uint32_t		m_doneq_length_threshold;
-	uint32_t		m_doneq_len;
-	kcondvar_t		m_doneq_thread_cv;
-	kmutex_t		m_doneq_mutex;
+	kcondvar_t		m_qthread_cv;
+	kmutex_t		m_qthread_mutex;
 
-	int		m_ncmds;	/* number of outstanding commands */
+	uint32_t		m_ncmds; /* number of outstanding commands */
+	uint32_t		m_ncstarted; /* ncmds started per interval */
+	uint32_t		m_lncstarted; /* record of last value */
 	m_event_struct_t *m_ioc_event_cmdq;	/* cmd queue for ioc event */
 	m_event_struct_t **m_ioc_event_cmdtail;	/* ioc cmd queue tail */
 
@@ -731,12 +785,15 @@
 
 	ddi_dma_handle_t m_dma_req_frame_hdl;
 	ddi_acc_handle_t m_acc_req_frame_hdl;
+	ddi_dma_handle_t m_dma_req_sense_hdl;
+	ddi_acc_handle_t m_acc_req_sense_hdl;
 	ddi_dma_handle_t m_dma_reply_frame_hdl;
 	ddi_acc_handle_t m_acc_reply_frame_hdl;
 	ddi_dma_handle_t m_dma_free_queue_hdl;
 	ddi_acc_handle_t m_acc_free_queue_hdl;
 	ddi_dma_handle_t m_dma_post_queue_hdl;
 	ddi_acc_handle_t m_acc_post_queue_hdl;
+	uint8_t		m_dma_flags;
 
 	/*
 	 * list of reset notification requests
@@ -766,8 +823,6 @@
 	 */
 	uint_t		m_options;
 
-	int		m_in_callback;
-
 	int		m_power_level;	/* current power level */
 
 	int		m_busy;		/* power management busy state */
@@ -786,20 +841,26 @@
 	 */
 	caddr_t		m_req_frame;
 	uint64_t	m_req_frame_dma_addr;
+	caddr_t		m_req_sense;
+	caddr_t		m_extreq_sense;
+	uint64_t	m_req_sense_dma_addr;
 	caddr_t		m_reply_frame;
 	uint64_t	m_reply_frame_dma_addr;
 	caddr_t		m_free_queue;
 	uint64_t	m_free_queue_dma_addr;
 	caddr_t		m_post_queue;
 	uint64_t	m_post_queue_dma_addr;
+	struct map	*m_erqsense_map;
+	mptsas_reply_pqueue_t	*m_rep_post_queues;
 
 	m_replyh_arg_t *m_replyh_args;
 
 	uint16_t	m_max_requests;
 	uint16_t	m_req_frame_size;
+	uint16_t	m_req_sense_size;
 
 	/*
-	 * Max frames per request reprted in IOC Facts
+	 * Max frames per request reported in IOC Facts
 	 */
 	uint8_t		m_max_chain_depth;
 	/*
@@ -808,16 +869,26 @@
 	 * m_max_chain_depth.
 	 */
 	uint8_t		m_max_request_frames;
+	uint8_t		m_max_msix_vectors;
+	uint8_t		m_reply_frame_size;
+	uint8_t		m_post_reply_qcount;
 
 	uint16_t	m_free_queue_depth;
 	uint16_t	m_post_queue_depth;
 	uint16_t	m_max_replies;
 	uint32_t	m_free_index;
-	uint32_t	m_post_index;
-	uint8_t		m_reply_frame_size;
 	uint32_t	m_ioc_capabilities;
 
 	/*
+	 * Housekeeping.
+	 */
+	uint64_t	m_interrupt_count;
+	uint32_t	m_unclaimed_pm_interrupt_count;
+	uint32_t	m_unclaimed_polled_interrupt_count;
+	uint32_t	m_unclaimed_no_interrupt_count;
+	uint32_t	m_unclaimed_nocmd_interrupt_count;
+
+	/*
 	 * indicates if the firmware was upload by the driver
 	 * at boot time
 	 */
@@ -891,6 +962,9 @@
 	mptsas_fw_diagnostic_buffer_t
 		m_fw_diag_buffer_list[MPI2_DIAG_BUF_TYPE_COUNT];
 
+	/* GEN3 support */
+	uint8_t			m_MPI25;
+
 	/*
 	 * Event Replay flag (MUR support)
 	 */
@@ -935,9 +1009,7 @@
 _NOTE(DATA_READABLE_WITHOUT_LOCK(mptsas::m_io_dma_attr.dma_attr_sgllen))
 _NOTE(DATA_READABLE_WITHOUT_LOCK(mptsas::m_devid))
 _NOTE(DATA_READABLE_WITHOUT_LOCK(mptsas::m_productid))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(mptsas::m_port_type))
 _NOTE(DATA_READABLE_WITHOUT_LOCK(mptsas::m_mpxio_enable))
-_NOTE(DATA_READABLE_WITHOUT_LOCK(mptsas::m_ntargets))
 _NOTE(DATA_READABLE_WITHOUT_LOCK(mptsas::m_instance))
 
 /*
@@ -985,6 +1057,8 @@
  * m_options flags
  */
 #define	MPTSAS_OPT_PM		0x01	/* Power Management */
+#define	MPTSAS_OPT_MSI		0x02	/* PCI MSI Interrupts */
+#define	MPTSAS_OPT_MSI_X	0x04	/* PCI MSI-X Interrupts */
 
 /*
  * m_softstate flags
@@ -995,6 +1069,15 @@
 #define	MPTSAS_DID_MSG_UNIT_RESET	0x10
 
 /*
+ * m_dma_flags (allocated).
+ */
+#define	MPTSAS_REQ_FRAME	0x01
+#define	MPTSAS_REQ_SENSE	0x02
+#define	MPTSAS_REPLY_FRAME	0x04
+#define	MPTSAS_FREE_QUEUE	0x08
+#define	MPTSAS_POST_QUEUE	0x10
+
+/*
  * regspec defines.
  */
 #define	CONFIG_SPACE	0	/* regset[0] - configuration space */
@@ -1007,6 +1090,7 @@
  */
 #define	FALSE		0
 #define	TRUE		1
+#define	BLOCKED		2
 #define	UNDEFINED	-1
 #define	FAILED		-2
 
@@ -1105,11 +1189,12 @@
 			(uint32_t *)(mpt->m_devaddr + NREG_DSPS)))
 
 
-#define	MPTSAS_START_CMD(mpt, req_desc_lo, req_desc_hi) \
-	ddi_put32(mpt->m_datap, &mpt->m_reg->RequestDescriptorPostLow,\
-	    req_desc_lo);\
-	ddi_put32(mpt->m_datap, &mpt->m_reg->RequestDescriptorPostHigh,\
-	    req_desc_hi);
+#define	MPTSAS_START_CMD(mpt, req_desc) \
+	ddi_put64(mpt->m_datap, \
+	    (uint64_t *)(void *)&mpt->m_reg->RequestDescriptorPostLow, \
+	    req_desc);						       \
+	atomic_inc_32(&mpt->m_ncstarted)
+
 
 #define	INTPENDING(mpt) \
 	(MPTSAS_GET_ISTAT(mpt) & MPI2_HIS_REPLY_DESCRIPTOR_INTERRUPT)
@@ -1128,8 +1213,8 @@
 	ddi_put32(mpt->m_datap, &mpt->m_reg->HostInterruptMask, \
 	(MPI2_HIM_DIM | MPI2_HIM_RESET_IRQ_MASK))
 
-#define	MPTSAS_GET_NEXT_REPLY(mpt, index)  \
-	&((uint64_t *)(void *)mpt->m_post_queue)[index]
+#define	MPTSAS_GET_NEXT_REPLY(rpqp, index)  \
+	&((uint64_t *)(void *)rpqp->rpq_queue)[index]
 
 #define	MPTSAS_GET_NEXT_FRAME(mpt, SMID) \
 	(mpt->m_req_frame + (mpt->m_req_frame_size * SMID))
@@ -1165,7 +1250,7 @@
  */
 #define	DEFAULT_SCSI_OPTIONS	SCSI_OPTIONS_DR
 #define	DEFAULT_TAG_AGE_LIMIT	2
-#define	DEFAULT_WD_TICK		10
+#define	DEFAULT_WD_TICK		1
 
 /*
  * invalid hostid.
@@ -1252,14 +1337,6 @@
 void mptsas_log(struct mptsas *mpt, int level, char *fmt, ...);
 int mptsas_poll(mptsas_t *mpt, mptsas_cmd_t *poll_cmd, int polltime);
 int mptsas_do_dma(mptsas_t *mpt, uint32_t size, int var, int (*callback)());
-int mptsas_send_config_request_msg(mptsas_t *mpt, uint8_t action,
-	uint8_t pagetype, uint32_t pageaddress, uint8_t pagenumber,
-	uint8_t pageversion, uint8_t pagelength, uint32_t
-	SGEflagslength, uint32_t SGEaddress32);
-int mptsas_send_extended_config_request_msg(mptsas_t *mpt, uint8_t action,
-	uint8_t extpagetype, uint32_t pageaddress, uint8_t pagenumber,
-	uint8_t pageversion, uint16_t extpagelength,
-	uint32_t SGEflagslength, uint32_t SGEaddress32);
 int mptsas_update_flash(mptsas_t *mpt, caddr_t ptrbuffer, uint32_t size,
 	uint8_t type, int mode);
 int mptsas_check_flash(mptsas_t *mpt, caddr_t origfile, uint32_t size,
@@ -1291,11 +1368,11 @@
 int mptsas_send_config_request_msg(mptsas_t *mpt, uint8_t action,
     uint8_t pagetype, uint32_t pageaddress, uint8_t pagenumber,
     uint8_t pageversion, uint8_t pagelength, uint32_t SGEflagslength,
-    uint32_t SGEaddress32);
+    uint64_t SGEaddress);
 int mptsas_send_extended_config_request_msg(mptsas_t *mpt, uint8_t action,
     uint8_t extpagetype, uint32_t pageaddress, uint8_t pagenumber,
     uint8_t pageversion, uint16_t extpagelength,
-    uint32_t SGEflagslength, uint32_t SGEaddress32);
+    uint32_t SGEflagslength, uint64_t SGEaddress);
 
 int mptsas_request_from_pool(mptsas_t *mpt, mptsas_cmd_t **cmd,
     struct scsi_pkt **pkt);
@@ -1311,7 +1388,6 @@
     int mode);
 int mptsas_send_event_ack(mptsas_t *mpt, uint32_t event, uint32_t eventcntx);
 void mptsas_send_pending_event_ack(mptsas_t *mpt);
-void mptsas_set_throttle(struct mptsas *mpt, mptsas_target_t *ptgt, int what);
 int mptsas_restart_ioc(mptsas_t *mpt);
 void mptsas_update_driver_data(struct mptsas *mpt);
 uint64_t mptsas_get_sata_guid(mptsas_t *mpt, mptsas_target_t *ptgt, int lun);
@@ -1331,7 +1407,7 @@
 int mptsas_get_sas_device_page0(mptsas_t *mpt, uint32_t page_address,
     uint16_t *dev_handle, uint64_t *sas_wwn, uint32_t *dev_info,
     uint8_t *physport, uint8_t *phynum, uint16_t *pdevhandle,
-    uint16_t *slot_num, uint16_t *enclosure);
+    uint16_t *slot_num, uint16_t *enclosure, uint16_t *io_flags);
 int mptsas_get_sas_io_unit_page(mptsas_t *mpt);
 int mptsas_get_sas_io_unit_page_hndshk(mptsas_t *mpt);
 int mptsas_get_sas_expander_page0(mptsas_t *mpt, uint32_t page_address,
@@ -1370,10 +1446,13 @@
 #if defined(MPTSAS_DEBUG)
 
 void mptsas_printf(char *fmt, ...);
+void mptsas_debug_log(char *fmt, ...);
 
 #define	MPTSAS_DBGPR(m, args)	\
 	if (mptsas_debug_flags & (m)) \
-		mptsas_printf args
+		mptsas_printf args;   \
+	if (~mptsas_dbglog_imask & (m)) \
+		mptsas_debug_log args
 #else	/* ! defined(MPTSAS_DEBUG) */
 #define	MPTSAS_DBGPR(m, args)
 #endif	/* defined(MPTSAS_DEBUG) */
@@ -1385,7 +1464,7 @@
 
 #define	NDBG4(args)	MPTSAS_DBGPR(0x10, args)	/* kmem alloc/free */
 #define	NDBG5(args)	MPTSAS_DBGPR(0x20, args)	/* polled cmds */
-#define	NDBG6(args)	MPTSAS_DBGPR(0x40, args)	/* interrupts */
+#define	NDBG6(args)	MPTSAS_DBGPR(0x40, args)	/* interrupt setup */
 #define	NDBG7(args)	MPTSAS_DBGPR(0x80, args)	/* queue handling */
 
 #define	NDBG8(args)	MPTSAS_DBGPR(0x0100, args)	/* arq */
@@ -1396,11 +1475,11 @@
 #define	NDBG12(args)	MPTSAS_DBGPR(0x1000, args)	/* enumeration */
 #define	NDBG13(args)	MPTSAS_DBGPR(0x2000, args)	/* configuration page */
 #define	NDBG14(args)	MPTSAS_DBGPR(0x4000, args)	/* LED control */
-#define	NDBG15(args)	MPTSAS_DBGPR(0x8000, args)
+#define	NDBG15(args)	MPTSAS_DBGPR(0x8000, args)	/* Passthrough */
 
-#define	NDBG16(args)	MPTSAS_DBGPR(0x010000, args)
+#define	NDBG16(args)	MPTSAS_DBGPR(0x010000, args)	/* SAS Broadcasts */
 #define	NDBG17(args)	MPTSAS_DBGPR(0x020000, args)	/* scatter/gather */
-#define	NDBG18(args)	MPTSAS_DBGPR(0x040000, args)
+#define	NDBG18(args)	MPTSAS_DBGPR(0x040000, args)	/* Interrupts */
 #define	NDBG19(args)	MPTSAS_DBGPR(0x080000, args)	/* handshaking */
 
 #define	NDBG20(args)	MPTSAS_DBGPR(0x100000, args)	/* events */
@@ -1437,4 +1516,4 @@
 }
 #endif
 
-#endif	/* _SYS_SCSI_ADAPTERS_MPTVAR_H */
+#endif	/* _SYS_SCSI_ADAPTERS_MPTSAS3_VAR_H */
