vdc.h revision e1ebb9ec908bc2d0a8810f137ebd6566cc8a8061
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _VDC_H
#define _VDC_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Virtual disk client implementation definitions
*/
#include <sys/sysmacros.h>
#include <sys/vio_mailbox.h>
#include <sys/vdsk_mailbox.h>
#include <sys/vdsk_common.h>
#ifdef __cplusplus
extern "C" {
#endif
#define VDC_DRIVER_NAME "vdc"
/*
* Bit-field values to indicate if parts of the vdc driver are initialised.
*/
#define VDC_SOFT_STATE 0x0001
#define VDC_LOCKS 0x0002
#define VDC_MINOR 0x0004
#define VDC_THREAD 0x0008
#define VDC_LDC 0x0010
#define VDC_LDC_INIT 0x0020
#define VDC_LDC_CB 0x0040
#define VDC_LDC_OPEN 0x0080
/*
* Definitions of strings to be used to create device node properties.
* (vdc uses the capitalised versions of these properties as they are 64-bit)
*/
#define VDC_NBLOCKS_PROP_NAME "Nblocks"
#define VDC_SIZE_PROP_NAME "Size"
/*
* Definitions of MD nodes/properties.
*/
#define VDC_MD_CHAN_NAME "channel-endpoint"
#define VDC_MD_VDEV_NAME "virtual-device"
#define VDC_MD_DISK_NAME "disk"
#define VDC_MD_CFG_HDL "cfg-handle"
#define VDC_ID_PROP "id"
/*
* Definition of actions to be carried out when processing the sequence ID
* of a message received from the vDisk server. The function verifying the
* sequence number checks the 'seq_num_xxx' fields in the soft state and
* returns whether the message should be processed (VDC_SEQ_NUM_TODO) or
* whether it was it was previously processed (VDC_SEQ_NUM_SKIP).
*/
#define VDC_SEQ_NUM_SKIP 0 /* Request already processed */
/*
* Scheme to store the instance number and the slice number in the minor number.
* (Uses the same format and definitions as the sd(7D) driver)
*/
/*
* variables controlling how long to wait before timing out and how many
* retries to attempt before giving up when communicating with vds.
*
* These values need to be sufficiently large so that a guest can survive
* the reboot of the service domain.
*/
#define VDC_RETRIES 10
/*
* This macro returns the number of Hz that the vdc driver should wait before
* a timeout is triggered. The 'timeout' parameter specifiecs the wait
* time in Hz. The 'mul' parameter allows for a multiplier to be
* specified allowing for a backoff to be implemented (e.g. using the
* retry number as a multiplier) where the wait time will get longer if
* there is no response on the previous retry.
*/
/*
* Macros to manipulate Descriptor Ring variables in the soft state
* structure.
*/
{ \
}
/* Initialise the Session ID and Sequence Num in the DRing msg */
/*
* The states the message processing thread can be in.
*/
typedef enum vdc_thr_state {
VDC_THR_RUNNING, /* thread is running & ready to process */
VDC_THR_STOP, /* The detach func signals the thread to stop */
VDC_THR_DONE /* Thread has exited */
/*
* Local Descriptor Ring entry
*
* vdc creates a Local (private) descriptor ring the same size as the
* public descriptor ring it exports to vds.
*/
typedef struct vdc_local_desc {
int flags; /* Dring entry state, etc */
int operation; /* VD_OP_xxx to be performed */
/*
* vdc soft state structure
*/
typedef struct vdc {
int initialized; /* keeps track of what's init'ed */
int hshake_cnt; /* number of failed handshakes */
int open; /* count of outstanding opens */
int dkio_flush_pending; /* # outstanding DKIO flushes */
int instance; /* driver instance number */
/*
* The mutex 'msg_proc_lock' protects the following group of fields.
*
* The callback function checks to see if LDC triggered it due to
* there being data available and the callback will signal to
* the message processing thread waiting on 'msg_proc_cv'.
*/
/*
* The mutex 'dring_lock' protects the following group of fields.
*/
} vdc_t;
/*
* Debugging macros
*/
#ifdef DEBUG
extern int vdc_msglevel;
do { \
if (vdc_msglevel > err_level) \
} while (0);
#define VDC_DUMP_DRING_MSG(dmsgp) \
DMSG(0, "sq:%lu start:%d end:%d ident:%lu\n", \
#else /* !DEBUG */
#define VDC_DUMP_DRING_MSG(dmsgp)
#endif /* !DEBUG */
#ifdef __cplusplus
}
#endif
#endif /* _VDC_H */