/* @(#)src/sol/kernel/base/vxio.h	3.3 07/16/98 14:10:34 -  */
/* #ident "@(#)vxfs:src/sol/kernel/base/vxio.h	3.3" */

/*
 * Copyright (c) 1998 VERITAS Software Corporation.  ALL RIGHTS RESERVED.
 * UNPUBLISHED -- RIGHTS RESERVED UNDER THE COPYRIGHT
 * LAWS OF THE UNITED STATES.  USE OF A COPYRIGHT NOTICE
 * IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
 * OR DISCLOSURE.
 *
 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND
 * TRADE SECRETS OF VERITAS SOFTWARE.  USE, DISCLOSURE,
 * OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
 * EXPRESS WRITTEN PERMISSION OF VERITAS SOFTWARE.
 *
 * 		RESTRICTED RIGHTS LEGEND
 * USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT IS
 * SUBJECT TO RESTRICTIONS AS SET FORTH IN SUBPARAGRAPH
 * (C) (1) (ii) OF THE RIGHTS IN TECHNICAL DATA AND
 * COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013.
 * 		VERITAS SOFTWARE
 * 1600 PLYMOUTH STREET, MOUNTAIN VIEW, CA 94043
 */

#ifndef _VXVM_VXIO_H
#define	_VXVM_VXIO_H

/*
 * vxio.h - definitions and structures for veritas enhanced I/O API.
 */

/*
 * The following ioctl value is shared between fs and vm. As such, both
 * subsystems need to have the same values for this ioctl.
 */
#define VXVIOC		(('V' << 24) | ('X' << 16) | ('I' << 8))

#define	VX_GET_IOPARAMETERS	(VXVIOC | 1)	/* get volume I/O paramters */

#define	VXVI_DEF_IO	(65536 / NBPSCTR)	/* default I/O size */
#define	VXVI_PREF_LOW		10	/* low level for vi_pref_strength */
#define	VXVI_PREF_MEDIUM	20	/* medium level for vi_pref_strength */
#define	VXVI_PREF_HIGH		30	/* high level for vi_pref_strength */

/*
 * I/O sizes desired by the volume manager or file system.  These sizes
 * represent hints to enable applications to issue more efficient I/O
 * requests.
 *
 * For reading, the ideal application will issue groups of vi_read_nstream
 * requests of vi_read_preferred_io bytes.  If the application can't issue
 * streaming I/O requests, then it should try for individual requests that
 * are the product of (vi_read_nstream * vi_read_preferred_io).  If the
 * desired amount of data is too large or too small for the application,
 * as a general rule the next best sizes are multiples or factors of the
 * product of (vi_read_nstream * vi_read_preferred_io).  If no reasonable
 * size can be used based on vi_read_preferred_io, then vi_read_unit_io
 * provides a slightly less desirable size for I/O requests.
 *
 * For writes, apply the same rules used for reads but using the vi_write_*
 * parameters.
 *
 * The vi_pref_strength provides an indication of how hard the application
 * should try to build preferred size I/O requests.  The higher the value
 * of vi_pref_strength the greater the benefit of issuing correct size I/O
 * requests.
 *
 * The vi_breakup_size indicates the size where I/O requests will get broken
 * up into multiple operations at the driver level.  In general, unless the
 * preferred I/O request indicates a value larger than vi_breakup_size then
 * issuing I/O requests larger than vi_breakup_size can hurt performance.
 *
 * In the future, if we support volumes that are build on top of other
 * volumes, the start of the top level volume might not correspond to the
 * geometry of the storage.  The value vi_align_offset should be subtracted
 * from sector offsets when trying to decide if a request is aligned to
 * a preferred boundary.
 *
 * If the VX_GET_IOPARAMETERS ioctl is issued against a character device,
 * then vi_block_device contains the device number of the corresponding
 * block device.  This functions as a sanity check when converting from
 * character devices to block devices.
 */

struct vx_ioparameters {
	size_t	vi_read_preferred_io;	/* preferred read size in bytes */
	size_t	vi_read_nstream;	/* num of preferred reads to stream */
	size_t	vi_read_unit_io;	/* less preferred read size in bytes */
	size_t	vi_write_preferred_io;	/* preferred write size in bytes */
	size_t	vi_write_nstream;	/* num of preferred writes to stream */
	size_t	vi_write_unit_io;	/* less preferred write size in bytes */
	size_t	vi_pref_strength;	/* srength of preferences */
	size_t	vi_breakup_size;	/* I/O breakup size in bytes */
	size_t	vi_align_offset;	/* adj for alignment calculations */
	dev_t	vi_block_device;	/* bdev number for this cdev */
	size_t	vi_padding[10];
};

#endif	/* _VXVM_VXIO_H */
