vdsk_common.h revision ca6d128098b8e877673c13a3db1a0d3417ce5879
/*
* 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
*/
/*
*/
#ifndef _VDSK_COMMON_H
#define _VDSK_COMMON_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* This header file contains the private LDoms Virtual Disk (vDisk) definitions
* common to both the server (vds) and the client (vdc)
*/
#include <sys/efi_partition.h>
#include <sys/machparam.h>
#include <sys/vio_common.h>
#include <sys/vio_mailbox.h>
/*
* vDisk definitions
*/
/*
* The number of Descriptor Ring entries
*
* Constraints:
* - overall DRing size must be greater than 8K (MMU_PAGESIZE)
* - overall DRing size should be 8K aligned (desirable but not enforced)
* - DRing entry must be 8 byte aligned
*/
#define VD_DRING_LEN 512
/*
*
*/
#define VD_DRING_ENTRY_SZ (sizeof (vd_dring_entry_t) + \
/*
* The maximum block size we can transmit using one Descriptor Ring entry
*
* Currently no FS uses more than 128K and it doesn't look like they
* will either as there is no perf gain to be had by larger values.
* ( see ZFS comment at definition of SPA_MAXBLOCKSIZE ).
*
* We choose 256K to give us some headroom.
*/
#define VD_USEC_TIMEOUT 20000
#define VD_LDC_IDS_PROP "ldc-ids"
#define VD_LDC_MTU 256
/*
*/
#define VD_COPYOUT 0x1
#define VD_COPYIN 0x2
/*
* vDisk operations on physical devices
*/
/*
* Status for the VD_OP_GET_ACCESS operation
*/
/*
* Flags for the VD_OP_SET_ACCESS operation
*/
/*
* This is a mask of all the basic operations supported by all
* disk types (v1.0).
*/
#define VD_OP_MASK_READ \
((1 << VD_OP_BREAD) | \
(1 << VD_OP_GET_WCE) | \
(1 << VD_OP_GET_VTOC) | \
(1 << VD_OP_GET_DISKGEOM) | \
(1 << VD_OP_GET_DEVID) | \
(1 << VD_OP_GET_EFI))
#define VD_OP_MASK_WRITE \
((1 << VD_OP_BWRITE) | \
(1 << VD_OP_FLUSH) | \
(1 << VD_OP_SET_WCE) | \
(1 << VD_OP_SET_VTOC) | \
(1 << VD_OP_SET_DISKGEOM) | \
(1 << VD_OP_SET_EFI))
/*
* Mask for additional operations provided for SCSI disks (v1.1)
*/
#define VD_OP_MASK_SCSI \
((1 << VD_OP_SCSICMD) | \
(1 << VD_OP_RESET) | \
(1 << VD_OP_GET_ACCESS) | \
(1 << VD_OP_SET_ACCESS))
/*
* macro to check if the operation 'op' is supported by checking the list
* of operations supported which is exported by the vDisk server.
*/
/*
* Slice for absolute disk transaction.
*/
#define VD_SLICE_NONE 0xFF
/*
* EFI disks do not have a slice 7. Actually that slice is used to represent
* the whole disk.
*/
#define VD_EFI_WD_SLICE 7
/*
* Definitions of the various ways vds can export disk support to vdc.
*/
typedef enum vd_disk_type {
VD_DISK_TYPE_UNK = 0, /* Unknown device type */
VD_DISK_TYPE_SLICE, /* slice in block device */
VD_DISK_TYPE_DISK /* entire disk (slice 2) */
/*
* Definitions of the various disk label that vDisk supports.
*/
typedef enum vd_disk_label {
VD_DISK_LABEL_UNK = 0, /* Unknown disk label */
VD_DISK_LABEL_VTOC, /* VTOC disk label */
VD_DISK_LABEL_EFI /* EFI disk label */
/*
* vDisk Descriptor payload
*/
typedef struct vd_dring_payload {
/*
* vDisk Descriptor entry
*/
typedef struct vd_dring_entry {
/*
* vDisk logical partition
*/
typedef struct vd_slice {
} vd_slice_t;
/*
* vDisk control operation structures
*/
/*
* vDisk geometry definition (VD_OP_GET_DISKGEOM and VD_OP_SET_DISKGEOM)
*/
typedef struct vd_geom {
} vd_geom_t;
/*
* vDisk partition definition
*/
typedef struct vd_partition {
/*
* vDisk VTOC definition (VD_OP_GET_VTOC and VD_OP_SET_VTOC)
*/
typedef struct vd_vtoc {
} vd_vtoc_t;
/*
* vDisk EFI definition (VD_OP_GET_EFI and VD_OP_SET_EFI)
*/
typedef struct vd_efi {
} vd_efi_t;
/*
* vDisk DEVID definition (VD_OP_GET_DEVID)
*/
#define VD_DEVID_DEFAULT_LEN 128
typedef struct vd_devid {
} vd_devid_t;
/*
* vDisk CAPACITY definition (VD_OP_GET_CAPACITY)
*/
typedef struct vd_capacity {
/* Identifier for unknown disk size */
#define VD_SIZE_UNKNOWN -1
/*
* vDisk SCSI definition (VD_OP_SCSICMD)
*/
typedef struct vd_scsi {
} vd_scsi_t;
/* Minimum size of the vd_scsi structure */
/*
* Macros to access data buffers in a vd_scsi structure. When using these
* macros, the vd_scsi structure needs to be populated with the sizes of
* data buffers allocated in the structure.
*/
#define VD_SCSI_DATA_CDB(vscsi) \
#define VD_SCSI_DATA_SENSE(vscsi) \
#define VD_SCSI_DATA_IN(vscsi) \
#define VD_SCSI_DATA_OUT(vscsi) \
/* vDisk SCSI task attribute */
/* vDisk SCSI options */
/*
* Copy the contents of a vd_geom_t to the contents of a dk_geom struct
*/
{ \
}
/*
* Copy the contents of a vd_vtoc_t to the contents of a vtoc struct
*/
{ \
sizeof ((vtoc)->v_asciilabel))); \
for (int i = 0; i < (vd_vtoc)->num_partitions; i++) { \
} \
}
/*
* Copy the contents of a dk_geom struct to the contents of a vd_geom_t
*/
{ \
}
/*
* Copy the contents of a vtoc struct to the contents of a vd_vtoc_t
*/
{ \
sizeof ((vd_vtoc)->volume_name))); \
sizeof ((vd_vtoc)->ascii_label))); \
} \
}
/*
* Copy the contents of a vd_efi_t to the contents of a dk_efi_t.
* Note that (dk_efi)->dki_data and (vd_efi)->data should be correctly
* initialized prior to using this macro.
*/
{ \
}
/*
* Copy the contents of dk_efi_t to the contents of vd_efi_t.
* Note that (dk_efi)->dki_data and (vd_efi)->data should be correctly
* initialized prior to using this macro.
*/
{ \
}
#define VD_MEDIATYPE2DK_MEDIATYPE(mt) \
/*
* If the media type returned by the DKIOCGMEDIAINFO ioctl is greater than
* 0xFFFF then this is not an optical media and we consider that this is
* a fixed media.
*
* Otherwise, we have an optical media. If this is a SCSI media then the media
* type is actually the profile number returned by the SCSI GET CONFIGURATION
* command. In that case, the possible values we can have are described in the
* SCSI Multi-Media Commands (MMC) documentation.
*
* Not all SCSI optical media profile numbers are defined in Solaris. However
* undefined profiles are essentially different variants of DVD (like Blu-Ray
* or HD-DVD). So we consider that any optical media that we can not explicitly
* identify is a DVD.
*/
#define DK_MEDIA_OPTICAL_MAX 0xFFFF
#define DK_MEDIATYPE2VD_MEDIATYPE(mt) \
/*
* Hooks for EFI support
*/
/*
* The EFI alloc_and_read() function will use some ioctls to get EFI data
* but the device reference we will use is different depending if the command
* is issued from the vDisk server side (vds) or from the vDisk client side
* function to call back and to provide information about the virtual disk.
*/
typedef int (*vd_efi_ioctl_func)(void *, int, uintptr_t);
typedef struct vd_efi_dev {
void *vdisk; /* opaque pointer to the vdisk */
} vd_efi_dev_t;
/*
* Macros to update the I/O statistics kstat consumed by iostat(1m).
*/
/*
* Given a pointer to the instance private data of a vDisk driver (vd),
* updates the I/O statistics in the kstat.
*/
{ \
if ((op) == VD_OP_BREAD) { \
} else { \
} \
} \
}
/*
* These wrapper macros take a pointer to the I/O statistics kstat and
* update the queue length statistics. These are 'safe' wrappers which
* check to see if the kstat was created when the vDisk instance was
* added (i.e. is not NULL).
*/
#define VD_KSTAT_WAITQ_ENTER(vd) \
}
#define VD_KSTAT_WAITQ_EXIT(vd) \
}
#define VD_KSTAT_WAITQ_TO_RUNQ(vd) \
}
#define VD_KSTAT_RUNQ_BACK_TO_WAITQ(vd) \
}
#define VD_KSTAT_RUNQ_ENTER(vd) \
}
#define VD_KSTAT_RUNQ_EXIT(vd) \
}
/*
* Given a pointer to the instance private data of a vDisk driver (vd) and
* the name of the error stats entry we wish to update, increment that value
*/
{ \
vd_err_stats_t *stp; \
} \
}
/* Structure to record vDisk error statistics */
typedef struct vd_err_stats {
#ifdef __cplusplus
}
#endif
#endif /* _VDSK_COMMON_H */