xref: /titanic_53/usr/src/uts/sun4v/sys/vdc.h (revision 342440ec94087b8c751c580ab9ed6c693d31d418)
11ae08745Sheppo /*
21ae08745Sheppo  * CDDL HEADER START
31ae08745Sheppo  *
41ae08745Sheppo  * The contents of this file are subject to the terms of the
51ae08745Sheppo  * Common Development and Distribution License (the "License").
61ae08745Sheppo  * You may not use this file except in compliance with the License.
71ae08745Sheppo  *
81ae08745Sheppo  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91ae08745Sheppo  * or http://www.opensolaris.org/os/licensing.
101ae08745Sheppo  * See the License for the specific language governing permissions
111ae08745Sheppo  * and limitations under the License.
121ae08745Sheppo  *
131ae08745Sheppo  * When distributing Covered Code, include this CDDL HEADER in each
141ae08745Sheppo  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151ae08745Sheppo  * If applicable, add the following below this CDDL HEADER, with the
161ae08745Sheppo  * fields enclosed by brackets "[]" replaced with your own identifying
171ae08745Sheppo  * information: Portions Copyright [yyyy] [name of copyright owner]
181ae08745Sheppo  *
191ae08745Sheppo  * CDDL HEADER END
201ae08745Sheppo  */
211ae08745Sheppo 
221ae08745Sheppo /*
23edcc0754Sachartre  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
241ae08745Sheppo  * Use is subject to license terms.
251ae08745Sheppo  */
261ae08745Sheppo 
271ae08745Sheppo #ifndef	_VDC_H
281ae08745Sheppo #define	_VDC_H
291ae08745Sheppo 
301ae08745Sheppo /*
311ae08745Sheppo  * Virtual disk client implementation definitions
321ae08745Sheppo  */
331ae08745Sheppo 
341ae08745Sheppo #include <sys/sysmacros.h>
351ae08745Sheppo #include <sys/note.h>
361ae08745Sheppo 
371ae08745Sheppo #include <sys/ldc.h>
381ae08745Sheppo #include <sys/vio_mailbox.h>
391ae08745Sheppo #include <sys/vdsk_mailbox.h>
401ae08745Sheppo #include <sys/vdsk_common.h>
411ae08745Sheppo 
421ae08745Sheppo #ifdef	__cplusplus
431ae08745Sheppo extern "C" {
441ae08745Sheppo #endif
451ae08745Sheppo 
461ae08745Sheppo #define	VDC_DRIVER_NAME		"vdc"
471ae08745Sheppo 
481ae08745Sheppo /*
491ae08745Sheppo  * Bit-field values to indicate if parts of the vdc driver are initialised.
501ae08745Sheppo  */
511ae08745Sheppo #define	VDC_SOFT_STATE	0x0001
521ae08745Sheppo #define	VDC_LOCKS	0x0002
531ae08745Sheppo #define	VDC_MINOR	0x0004
541ae08745Sheppo #define	VDC_THREAD	0x0008
558cd10891Snarayan #define	VDC_DRING_INIT	0x0010	/* The DRing was created */
568cd10891Snarayan #define	VDC_DRING_BOUND	0x0020	/* The DRing was bound to an LDC channel */
578cd10891Snarayan #define	VDC_DRING_LOCAL	0x0040	/* The local private DRing was allocated */
588cd10891Snarayan #define	VDC_DRING_ENTRY	0x0080	/* At least one DRing entry was initialised */
591ae08745Sheppo #define	VDC_DRING	(VDC_DRING_INIT | VDC_DRING_BOUND |	\
601ae08745Sheppo 				VDC_DRING_LOCAL | VDC_DRING_ENTRY)
618cd10891Snarayan #define	VDC_HANDSHAKE	0x0100	/* Indicates if a handshake is in progress */
628cd10891Snarayan #define	VDC_HANDSHAKE_STOP	0x0200	/* stop further handshakes */
631ae08745Sheppo 
641ae08745Sheppo /*
651ae08745Sheppo  * Definitions of MD nodes/properties.
661ae08745Sheppo  */
671ae08745Sheppo #define	VDC_MD_CHAN_NAME		"channel-endpoint"
681ae08745Sheppo #define	VDC_MD_VDEV_NAME		"virtual-device"
69655fd6a9Sachartre #define	VDC_MD_PORT_NAME		"virtual-device-port"
701ae08745Sheppo #define	VDC_MD_DISK_NAME		"disk"
711ae08745Sheppo #define	VDC_MD_CFG_HDL			"cfg-handle"
72655fd6a9Sachartre #define	VDC_MD_TIMEOUT			"vdc-timeout"
73655fd6a9Sachartre #define	VDC_MD_ID			"id"
741ae08745Sheppo 
751ae08745Sheppo /*
76e1ebb9ecSlm66018  * Definition of actions to be carried out when processing the sequence ID
77e1ebb9ecSlm66018  * of a message received from the vDisk server. The function verifying the
78e1ebb9ecSlm66018  * sequence number checks the 'seq_num_xxx' fields in the soft state and
79e1ebb9ecSlm66018  * returns whether the message should be processed (VDC_SEQ_NUM_TODO) or
80e1ebb9ecSlm66018  * whether it was it was previously processed (VDC_SEQ_NUM_SKIP).
81e1ebb9ecSlm66018  */
82e1ebb9ecSlm66018 #define	VDC_SEQ_NUM_INVALID		-1	/* Error */
83e1ebb9ecSlm66018 #define	VDC_SEQ_NUM_SKIP		0	/* Request already processed */
84e1ebb9ecSlm66018 #define	VDC_SEQ_NUM_TODO		1	/* Request needs processing */
85e1ebb9ecSlm66018 
86e1ebb9ecSlm66018 /*
870d0c8d4bSnarayan  * Macros to get UNIT and PART number
881ae08745Sheppo  */
890d0c8d4bSnarayan #define	VDCUNIT_SHIFT	3
900d0c8d4bSnarayan #define	VDCPART_MASK	7
910d0c8d4bSnarayan 
920d0c8d4bSnarayan #define	VDCUNIT(dev)	(getminor((dev)) >> VDCUNIT_SHIFT)
930d0c8d4bSnarayan #define	VDCPART(dev)	(getminor((dev)) &  VDCPART_MASK)
940d0c8d4bSnarayan 
950d0c8d4bSnarayan /*
960d0c8d4bSnarayan  * Scheme to store the instance number and the slice number in the minor number.
970d0c8d4bSnarayan  * (NOTE: Uses the same format and definitions as the sd(7D) driver)
980d0c8d4bSnarayan  */
990d0c8d4bSnarayan #define	VD_MAKE_DEV(instance, minor)	((instance << VDCUNIT_SHIFT) | minor)
1001ae08745Sheppo 
1011ae08745Sheppo /*
1021ae08745Sheppo  * variables controlling how long to wait before timing out and how many
1031ae08745Sheppo  * retries to attempt before giving up when communicating with vds.
104e1ebb9ecSlm66018  *
105e1ebb9ecSlm66018  * These values need to be sufficiently large so that a guest can survive
106e1ebb9ecSlm66018  * the reboot of the service domain.
1071ae08745Sheppo  */
108e1ebb9ecSlm66018 #define	VDC_RETRIES	10
1091ae08745Sheppo 
1101ae08745Sheppo #define	VDC_USEC_TIMEOUT_MIN	(30 * MICROSEC)		/* 30 sec */
1111ae08745Sheppo 
112e1ebb9ecSlm66018 /*
113e1ebb9ecSlm66018  * This macro returns the number of Hz that the vdc driver should wait before
114e1ebb9ecSlm66018  * a timeout is triggered. The 'timeout' parameter specifiecs the wait
115e1ebb9ecSlm66018  * time in Hz. The 'mul' parameter allows for a multiplier to be
116e1ebb9ecSlm66018  * specified allowing for a backoff to be implemented (e.g. using the
117e1ebb9ecSlm66018  * retry number as a multiplier) where the wait time will get longer if
118e1ebb9ecSlm66018  * there is no response on the previous retry.
119e1ebb9ecSlm66018  */
120e1ebb9ecSlm66018 #define	VD_GET_TIMEOUT_HZ(timeout, mul)	\
121e1ebb9ecSlm66018 	(ddi_get_lbolt() + ((timeout) * MAX(1, (mul))))
1221ae08745Sheppo 
1231ae08745Sheppo /*
1241ae08745Sheppo  * Macros to manipulate Descriptor Ring variables in the soft state
1251ae08745Sheppo  * structure.
1261ae08745Sheppo  */
127e1ebb9ecSlm66018 #define	VDC_GET_NEXT_REQ_ID(vdc)	((vdc)->req_id++)
1281ae08745Sheppo 
1291ae08745Sheppo #define	VDC_GET_DRING_ENTRY_PTR(vdc, idx)	\
13017cadca8Slm66018 		(vd_dring_entry_t *)(uintptr_t)((vdc)->dring_mem_info.vaddr + \
131e1ebb9ecSlm66018 			(idx * (vdc)->dring_entry_size))
1321ae08745Sheppo 
1331ae08745Sheppo #define	VDC_MARK_DRING_ENTRY_FREE(vdc, idx)			\
1341ae08745Sheppo 	{ \
1351ae08745Sheppo 		vd_dring_entry_t *dep = NULL;				\
1361ae08745Sheppo 		ASSERT(vdc != NULL);					\
13717cadca8Slm66018 		ASSERT(idx < vdc->dring_len);		\
1381ae08745Sheppo 		ASSERT(vdc->dring_mem_info.vaddr != NULL);		\
13917cadca8Slm66018 		dep = (vd_dring_entry_t *)(uintptr_t)			\
14017cadca8Slm66018 			(vdc->dring_mem_info.vaddr +	\
1411ae08745Sheppo 			(idx * vdc->dring_entry_size));			\
1421ae08745Sheppo 		ASSERT(dep != NULL);					\
1431ae08745Sheppo 		dep->hdr.dstate = VIO_DESC_FREE;			\
1441ae08745Sheppo 	}
1451ae08745Sheppo 
1461ae08745Sheppo /* Initialise the Session ID and Sequence Num in the DRing msg */
1471ae08745Sheppo #define	VDC_INIT_DRING_DATA_MSG_IDS(dmsg, vdc)		\
1481ae08745Sheppo 		ASSERT(vdc != NULL);			\
1491ae08745Sheppo 		dmsg.tag.vio_sid = vdc->session_id;	\
1500a55fbb7Slm66018 		dmsg.seq_num = vdc->seq_num;
1511ae08745Sheppo 
1521ae08745Sheppo /*
1533af08d82Slm66018  * The states that the read thread can be in.
1541ae08745Sheppo  */
1553af08d82Slm66018 typedef enum vdc_rd_state {
1563af08d82Slm66018 	VDC_READ_IDLE,			/* idling - conn is not up */
1573af08d82Slm66018 	VDC_READ_WAITING,		/* waiting for data */
1583af08d82Slm66018 	VDC_READ_PENDING,		/* pending data avail for read */
1593af08d82Slm66018 	VDC_READ_RESET			/* channel was reset - stop reads */
1603af08d82Slm66018 } vdc_rd_state_t;
1613af08d82Slm66018 
1623af08d82Slm66018 /*
1633af08d82Slm66018  * The states that the vdc-vds connection can be in.
1643af08d82Slm66018  */
1653af08d82Slm66018 typedef enum vdc_state {
1663af08d82Slm66018 	VDC_STATE_INIT,			/* device is initialized */
1673af08d82Slm66018 	VDC_STATE_INIT_WAITING,		/* waiting for ldc connection */
1683af08d82Slm66018 	VDC_STATE_NEGOTIATE,		/* doing handshake negotiation */
1693af08d82Slm66018 	VDC_STATE_HANDLE_PENDING,	/* handle requests in backup dring */
1703af08d82Slm66018 	VDC_STATE_RUNNING,		/* running and accepting requests */
1713af08d82Slm66018 	VDC_STATE_DETACH,		/* detaching */
1723af08d82Slm66018 	VDC_STATE_RESETTING		/* resetting connection with vds */
1733af08d82Slm66018 } vdc_state_t;
1743af08d82Slm66018 
1753af08d82Slm66018 /*
1763af08d82Slm66018  * The states that the vdc instance can be in.
1773af08d82Slm66018  */
1783af08d82Slm66018 typedef enum vdc_lc_state {
1793af08d82Slm66018 	VDC_LC_ATTACHING,	/* driver is attaching */
1803af08d82Slm66018 	VDC_LC_ONLINE,		/* driver is attached and online */
1813af08d82Slm66018 	VDC_LC_DETACHING	/* driver is detaching */
1823af08d82Slm66018 } vdc_lc_state_t;
1831ae08745Sheppo 
1841ae08745Sheppo /*
1851ae08745Sheppo  * Local Descriptor Ring entry
1861ae08745Sheppo  *
1871ae08745Sheppo  * vdc creates a Local (private) descriptor ring the same size as the
1881ae08745Sheppo  * public descriptor ring it exports to vds.
1891ae08745Sheppo  */
1903af08d82Slm66018 
1913af08d82Slm66018 typedef enum {
1923af08d82Slm66018 	VIO_read_dir,		/* read data from server */
1933af08d82Slm66018 	VIO_write_dir,		/* write data to server */
1943af08d82Slm66018 	VIO_both_dir		/* transfer both in and out in same buffer */
1953af08d82Slm66018 } vio_desc_direction_t;
1963af08d82Slm66018 
1973af08d82Slm66018 typedef enum {
1983af08d82Slm66018 	CB_STRATEGY,		/* non-blocking strategy call */
1993af08d82Slm66018 	CB_SYNC			/* synchronous operation */
2003af08d82Slm66018 } vio_cb_type_t;
2013af08d82Slm66018 
2021ae08745Sheppo typedef struct vdc_local_desc {
2033af08d82Slm66018 	boolean_t		is_free;	/* local state - inuse or not */
2043af08d82Slm66018 
2051ae08745Sheppo 	int			operation;	/* VD_OP_xxx to be performed */
2061ae08745Sheppo 	caddr_t			addr;		/* addr passed in by consumer */
2073af08d82Slm66018 	int			slice;
2083af08d82Slm66018 	diskaddr_t		offset;		/* disk offset */
2093af08d82Slm66018 	size_t			nbytes;
2103af08d82Slm66018 	vio_cb_type_t		cb_type;	/* operation type blk/nonblk */
2113af08d82Slm66018 	void			*cb_arg;	/* buf passed to strategy() */
2123af08d82Slm66018 	vio_desc_direction_t	dir;		/* direction of transfer */
2133af08d82Slm66018 
2141ae08745Sheppo 	caddr_t			align_addr;	/* used if addr non-aligned */
2151ae08745Sheppo 	ldc_mem_handle_t	desc_mhdl;	/* Mem handle of buf */
2161ae08745Sheppo 	vd_dring_entry_t	*dep;		/* public Dring Entry Pointer */
2173af08d82Slm66018 
2181ae08745Sheppo } vdc_local_desc_t;
2191ae08745Sheppo 
2201ae08745Sheppo /*
2212f5224aeSachartre  * I/O queue used by failfast
2222f5224aeSachartre  */
2232f5224aeSachartre typedef struct vdc_io {
2242f5224aeSachartre 	struct vdc_io	*vio_next;	/* next pending I/O in the queue */
2252f5224aeSachartre 	struct buf	*vio_buf;	/* buf for CB_STRATEGY I/O */
2262f5224aeSachartre 	clock_t		vio_qtime;	/* time the I/O was queued */
2272f5224aeSachartre } vdc_io_t;
2282f5224aeSachartre 
2292f5224aeSachartre /*
2308cd10891Snarayan  * Per vDisk server channel states
2318cd10891Snarayan  */
2328cd10891Snarayan #define	VDC_LDC_INIT	0x0001
2338cd10891Snarayan #define	VDC_LDC_CB	0x0002
2348cd10891Snarayan #define	VDC_LDC_OPEN	0x0004
2358cd10891Snarayan #define	VDC_LDC		(VDC_LDC_INIT | VDC_LDC_CB | VDC_LDC_OPEN)
2368cd10891Snarayan 
2378cd10891Snarayan /*
2388cd10891Snarayan  * vDisk server information
2398cd10891Snarayan  */
2408cd10891Snarayan typedef struct vdc_server {
2418cd10891Snarayan 	struct vdc_server	*next;			/* Next server */
2428cd10891Snarayan 	struct vdc		*vdcp;			/* Ptr to vdc struct */
2438cd10891Snarayan 	uint64_t		id;			/* Server port id */
2448cd10891Snarayan 	uint64_t		state;			/* Server state */
2458cd10891Snarayan 	uint64_t		ldc_id;			/* Server LDC id */
2468cd10891Snarayan 	ldc_handle_t		ldc_handle;		/* Server LDC handle */
2478cd10891Snarayan 	ldc_status_t		ldc_state;		/* Server LDC state */
2488cd10891Snarayan 	uint64_t		ctimeout;		/* conn tmout (secs) */
2498cd10891Snarayan } vdc_server_t;
2508cd10891Snarayan 
2518cd10891Snarayan /*
2521ae08745Sheppo  * vdc soft state structure
2531ae08745Sheppo  */
2541ae08745Sheppo typedef struct vdc {
2551ae08745Sheppo 
2561ae08745Sheppo 	kmutex_t	lock;		/* protects next 2 sections of vars */
2573af08d82Slm66018 	kcondvar_t	running_cv;	/* signal when upper layers can send */
2583af08d82Slm66018 	kcondvar_t	initwait_cv;	/* signal when ldc conn is up */
2593af08d82Slm66018 	kcondvar_t	dring_free_cv;	/* signal when desc is avail */
2603af08d82Slm66018 	kcondvar_t	membind_cv;	/* signal when mem can be bound */
2613af08d82Slm66018 	boolean_t	self_reset;
2621ae08745Sheppo 
2631ae08745Sheppo 	int		initialized;	/* keeps track of what's init'ed */
2643af08d82Slm66018 	vdc_lc_state_t	lifecycle;	/* Current state of the vdc instance */
2653af08d82Slm66018 
2660a55fbb7Slm66018 	int		hshake_cnt;	/* number of failed handshakes */
26778fcd0a1Sachartre 	uint8_t		open[OTYPCNT];	/* mask of opened slices */
26878fcd0a1Sachartre 	uint8_t		open_excl;	/* mask of exclusively opened slices */
26978fcd0a1Sachartre 	ulong_t		open_lyr[V_NUMPAR]; /* number of layered opens */
2701ae08745Sheppo 	int		dkio_flush_pending; /* # outstanding DKIO flushes */
27178fcd0a1Sachartre 	int		validate_pending; /* # outstanding validate request */
27278fcd0a1Sachartre 	vd_disk_label_t vdisk_label; 	/* label type of device/disk imported */
273*342440ecSPrasad Singamsetty 	struct extvtoc	*vtoc;		/* structure to store VTOC data */
27478fcd0a1Sachartre 	struct dk_geom	*geom;		/* structure to store geometry data */
275edcc0754Sachartre 	vd_slice_t	slice[V_NUMPAR]; /* logical partitions */
2761ae08745Sheppo 
2773af08d82Slm66018 	kthread_t	*msg_proc_thr;	/* main msg processing thread */
2783af08d82Slm66018 
2793af08d82Slm66018 	kmutex_t	read_lock;	/* lock to protect read */
2803af08d82Slm66018 	kcondvar_t	read_cv;	/* cv to wait for READ events */
2813af08d82Slm66018 	vdc_rd_state_t	read_state;	/* current read state */
2823af08d82Slm66018 
2833af08d82Slm66018 	uint32_t	sync_op_cnt;	/* num of active sync operations */
2843af08d82Slm66018 	boolean_t	sync_op_pending; /* sync operation is pending */
2853af08d82Slm66018 	boolean_t	sync_op_blocked; /* blocked waiting to do sync op */
2863af08d82Slm66018 	uint32_t	sync_op_status;	/* status of sync operation */
2873af08d82Slm66018 	kcondvar_t	sync_pending_cv; /* cv wait for sync op to finish */
2883af08d82Slm66018 	kcondvar_t	sync_blocked_cv; /* cv wait for other syncs to finish */
2893af08d82Slm66018 
2901ae08745Sheppo 	uint64_t	session_id;	/* common ID sent with all messages */
2911ae08745Sheppo 	uint64_t	seq_num;	/* most recent sequence num generated */
2921ae08745Sheppo 	uint64_t	seq_num_reply;	/* Last seq num ACK/NACK'ed by vds */
2931ae08745Sheppo 	uint64_t	req_id;		/* Most recent Request ID generated */
294e1ebb9ecSlm66018 	uint64_t	req_id_proc;	/* Last request ID processed by vdc */
2953af08d82Slm66018 	vdc_state_t	state;		/* Current disk client-server state */
296e1ebb9ecSlm66018 
297e1ebb9ecSlm66018 	dev_info_t	*dip;		/* device info pointer */
298e1ebb9ecSlm66018 	int		instance;	/* driver instance number */
2993af08d82Slm66018 
300e1ebb9ecSlm66018 	vio_ver_t	ver;		/* version number agreed with server */
3011ae08745Sheppo 	vd_disk_type_t	vdisk_type;	/* type of device/disk being imported */
30217cadca8Slm66018 	uint32_t	vdisk_media;	/* physical media type of vDisk */
3034bac2208Snarayan 	uint64_t	vdisk_size;	/* device size in blocks */
3041ae08745Sheppo 	uint64_t	max_xfer_sz;	/* maximum block size of a descriptor */
3051ae08745Sheppo 	uint64_t	block_size;	/* device block size used */
30617cadca8Slm66018 	uint64_t	operations;	/* bitmask of ops. server supports */
3071ae08745Sheppo 	struct dk_cinfo	*cinfo;		/* structure to store DKIOCINFO data */
3081ae08745Sheppo 	struct dk_minfo	*minfo;		/* structure for DKIOCGMEDIAINFO data */
3094bac2208Snarayan 	ddi_devid_t	devid;		/* device id */
310655fd6a9Sachartre 	boolean_t	ctimeout_reached; /* connection timeout has expired */
3111ae08745Sheppo 
3122f5224aeSachartre 	/*
3132f5224aeSachartre 	 * The ownership fields are protected by the lock mutex. The
3142f5224aeSachartre 	 * ownership_lock mutex is used to serialize ownership operations;
3152f5224aeSachartre 	 * it should be acquired before the lock mutex.
3162f5224aeSachartre 	 */
3172f5224aeSachartre 	kmutex_t	ownership_lock;		/* serialize ownership ops */
3182f5224aeSachartre 	int		ownership;		/* ownership status flags */
3192f5224aeSachartre 	kthread_t	*ownership_thread;	/* ownership thread */
3202f5224aeSachartre 	kcondvar_t	ownership_cv;		/* cv for ownership update */
3212f5224aeSachartre 
3222f5224aeSachartre 	/*
3232f5224aeSachartre 	 * The failfast fields are protected by the lock mutex.
3242f5224aeSachartre 	 */
3252f5224aeSachartre 	kthread_t	*failfast_thread;	/* failfast thread */
3262f5224aeSachartre 	clock_t		failfast_interval;	/* interval in microsecs */
3272f5224aeSachartre 	kcondvar_t	failfast_cv;		/* cv for failfast update */
3282f5224aeSachartre 	kcondvar_t	failfast_io_cv;		/* cv wait for I/O to finish */
3292f5224aeSachartre 	vdc_io_t	*failfast_io_queue;	/* failfast io queue */
3302f5224aeSachartre 
331366a92acSlm66018 	/*
332366a92acSlm66018 	 * kstats used to store I/O statistics consumed by iostat(1M).
333366a92acSlm66018 	 * These are protected by the lock mutex.
334366a92acSlm66018 	 */
335366a92acSlm66018 	kstat_t		*io_stats;
336366a92acSlm66018 	kstat_t		*err_stats;
337366a92acSlm66018 
3388cd10891Snarayan 	ldc_dring_handle_t	dring_hdl;		/* dring handle */
3393af08d82Slm66018 	ldc_mem_info_t		dring_mem_info;		/* dring information */
3403af08d82Slm66018 	uint_t			dring_curr_idx;		/* current index */
3413af08d82Slm66018 	uint32_t		dring_len;		/* dring length */
3423af08d82Slm66018 	uint32_t		dring_max_cookies;	/* dring max cookies */
3433af08d82Slm66018 	uint32_t		dring_cookie_count;	/* num cookies */
3443af08d82Slm66018 	uint32_t		dring_entry_size;	/* descriptor size */
3453af08d82Slm66018 	ldc_mem_cookie_t 	*dring_cookie;		/* dring cookies */
3463af08d82Slm66018 	uint64_t		dring_ident;		/* dring ident */
3471ae08745Sheppo 
3483af08d82Slm66018 	uint64_t		threads_pending; 	/* num of threads */
3491ae08745Sheppo 
3503af08d82Slm66018 	vdc_local_desc_t	*local_dring;		/* local dring */
3513af08d82Slm66018 	vdc_local_desc_t	*local_dring_backup;	/* local dring backup */
3523af08d82Slm66018 	int			local_dring_backup_tail; /* backup dring tail */
3533af08d82Slm66018 	int			local_dring_backup_len;	/* backup dring len */
3541ae08745Sheppo 
3558cd10891Snarayan 	int			num_servers;		/* no. of servers */
3568cd10891Snarayan 	vdc_server_t		*server_list;		/* vdisk server list */
3578cd10891Snarayan 	vdc_server_t		*curr_server;		/* curr vdisk server */
3581ae08745Sheppo } vdc_t;
3591ae08745Sheppo 
3601ae08745Sheppo /*
3612f5224aeSachartre  * Ownership status flags
3622f5224aeSachartre  */
3632f5224aeSachartre #define	VDC_OWNERSHIP_NONE	0x00 /* no ownership wanted */
3642f5224aeSachartre #define	VDC_OWNERSHIP_WANTED	0x01 /* ownership is wanted */
3652f5224aeSachartre #define	VDC_OWNERSHIP_GRANTED	0x02 /* ownership has been granted */
3662f5224aeSachartre #define	VDC_OWNERSHIP_RESET	0x04 /* ownership has been reset */
3672f5224aeSachartre 
3682f5224aeSachartre /*
3692f5224aeSachartre  * Reservation conflict panic message
3702f5224aeSachartre  */
3712f5224aeSachartre #define	VDC_RESV_CONFLICT_FMT_STR	"Reservation Conflict\nDisk: "
3722f5224aeSachartre #define	VDC_RESV_CONFLICT_FMT_LEN 	(sizeof (VDC_RESV_CONFLICT_FMT_STR))
3732f5224aeSachartre 
3742f5224aeSachartre /*
3751ae08745Sheppo  * Debugging macros
3761ae08745Sheppo  */
3771ae08745Sheppo #ifdef DEBUG
3781ae08745Sheppo extern int	vdc_msglevel;
3793af08d82Slm66018 extern uint64_t	vdc_matchinst;
3801ae08745Sheppo 
3813af08d82Slm66018 #define	DMSG(_vdc, err_level, format, ...)				\
3823af08d82Slm66018 	do {								\
3833af08d82Slm66018 		if (vdc_msglevel > err_level &&				\
3843af08d82Slm66018 		(vdc_matchinst & (1ull << (_vdc)->instance)))		\
3853af08d82Slm66018 			cmn_err(CE_CONT, "?[%d,t@%p] %s: "format,	\
3863af08d82Slm66018 			(_vdc)->instance, (void *)curthread,		\
3873af08d82Slm66018 			__func__, __VA_ARGS__);				\
3883af08d82Slm66018 		_NOTE(CONSTANTCONDITION)				\
3893af08d82Slm66018 	} while (0);
3903af08d82Slm66018 
3913af08d82Slm66018 #define	DMSGX(err_level, format, ...)					\
392e1ebb9ecSlm66018 	do {								\
393e1ebb9ecSlm66018 		if (vdc_msglevel > err_level)				\
3943af08d82Slm66018 			cmn_err(CE_CONT, "?%s: "format, __func__, __VA_ARGS__);\
395e1ebb9ecSlm66018 		_NOTE(CONSTANTCONDITION)				\
396e1ebb9ecSlm66018 	} while (0);
3971ae08745Sheppo 
3981ae08745Sheppo #define	VDC_DUMP_DRING_MSG(dmsgp)					\
3993af08d82Slm66018 		DMSGX(0, "sq:%lu start:%d end:%d ident:%lu\n",		\
4001ae08745Sheppo 			dmsgp->seq_num, dmsgp->start_idx,		\
4011ae08745Sheppo 			dmsgp->end_idx, dmsgp->dring_ident);
4021ae08745Sheppo 
4031ae08745Sheppo #else	/* !DEBUG */
404e1ebb9ecSlm66018 #define	DMSG(err_level, ...)
4053af08d82Slm66018 #define	DMSGX(err_level, format, ...)
4061ae08745Sheppo #define	VDC_DUMP_DRING_MSG(dmsgp)
4071ae08745Sheppo 
4081ae08745Sheppo #endif	/* !DEBUG */
4091ae08745Sheppo 
4101ae08745Sheppo #ifdef	__cplusplus
4111ae08745Sheppo }
4121ae08745Sheppo #endif
4131ae08745Sheppo 
4141ae08745Sheppo #endif	/* _VDC_H */
415