/*	@(#)volmgmtpars.h	13.1 (RC International) 91/02/02	*/

/*
 *  volmgmtpars.h
 *
 *  	Volume Management related parameters.
 *	This file is included in all vol_*.c source files.
 */

#ifndef	_VOLMGMTPARS_
#define	_VOLMGMTPARS_

/** #ifdef DEBUG **/
/************************************************
 *  	Defines for XDBX debugging.		*
 ************************************************/
/** #define register **/
/** #endif DEBUG **/

#ifdef lint
/************************************************
 *	Kludges to make lint shut up!		*
/************************************************/
#undef disable
#undef enable
#define disable()
#define enable()
#endif lint

/*************************************
 *  Macros for semaphore operations. *
 *************************************/

#define vol_resrc_lock(l) { sem_lock((l), TRUE); }
#define vol_resrc_free(l) { sem_unlock((l)); }

/********************************
 *  Macros for list operations. *
 ********************************/
/*
 *  vol_link() call declaration.
 *
 *	Link the new list header (struct list_hdr) after the
 *	specified element such that the old element's forward
 *	link points to the new element.
 *
 *	ASSUMPTIONS:
 *
 *		1)  Doubly linked list of struct list_hdr elements.
 *		2)  List contains no NULL pointers.
 */

#define vol_link(lst_hdr, old_lst_hdr) { \
    struct list_hdr	*new; \
    struct list_hdr	*old; \
    new = lst_hdr; \
    old = old_lst_hdr; \
    new->lh_fw = old->lh_fw; \
    new->lh_bk = old; \
    old->lh_fw->lh_bk = new; \
    old->lh_fw = new; \
}

/*
 *  vol_unlink() call declaration.
 *
 *	Unlink the list header (struct list_hdr) from the
 *	list.
 *
 *	ASSUMPTIONS:
 *
 *		1)  Doubly linked list of struct list_hdr elements.
 *		2)  List contains no NULL pointers.
 */

#define vol_unlink(lst_hdr) { \
    struct list_hdr	*l; \
    l = lst_hdr; \
    l->lh_fw->lh_bk = l->lh_bk; \
    l->lh_bk->lh_fw = l->lh_fw; \
    l->lh_fw = 0; \
    l->lh_bk = 0; \
}

/******************************
 *  Macros for SDs and PDDs.  *
 ******************************/
/*
 *  vol_local_sd () call declaration.
 *
 *	Return TRUE if the given subdisk's current 
 *	disk path is local.
 */

#define vol_local_sd(sde) \
    ((sde)->sde_pdsk->pd_cur_dpath.sbb_id == host_sbb_id)

/*
 *  vol_remote_pdd () call declaration.
 *
 *	Return TRUE if the given PDD is a REMOTE PDD.
 */

#define vol_remote_pdd(pdd) \
    ((pdd)->pd_dpath[0].sbb_id != host_sbb_id)

/*
 *  Miscellaneous parameters.
 */

				/***************************************/
#define VOLMGMTREVNO	3	/* Volume management rev number        */
				/* NOTE: Bump this each time           */
				/* 	 subdisk label changes result  */
				/*	 in incompatible labels.       */
				/***************************************/

#define MMEM_HEAP	1	/* Main memory RTE heap */
#define MAX_LABEL	32 	/* Max label length in chars includes null */
                                /*  terminator. */
#define SD_MAGICNO	0x12275077
				/* Located in each subdisk label */

/*
 *  Hardware parameters.
 */

#define MAX_N_PORT	2	/* Maximum ports to a physical disk. */
#define SBB_CHANS	4	/* Maximum channels per SBB. */
#define MAX_CNTLS	8	/* Maximum # controllers per channel. */
#define DSKS_PER_CNTL	4	/* Maximum # disks per controller. */
#define DSKS_PER_SBB	128	/* Maximum # disks per SBB. */

/*
 *  Volume Management Configuration parameters.
 */

#define MAX_PLEX 	8 	/* Maximum allowable Subdisk plex which */
				/*  can be defined in a Subdisk group. */
				/*  NOTE: If a plex > 32. is selected  */
				/*        make the necessary changes   */
				/*	  to (plex_no_map) in "lventry.h" */
#define SD_LAB_SZ	1	/* Subdisk label size in disk sectors. */
#define CFG_LOG_SZ      1       /* Configuration Log size in disk sectors. */
#define WRT_LOG_SZ      4       /* Max write Log size in disk sectors. */
#define	MIN_SD_SZ	32	/* Min subdisk size */
#define MAX_SDG_RQ 	2	/* Max subdisk grps involved in a request */
#define SD_PER_PHY_DSK  8	/* Max Subdisks per physical disk. */
#define SD_PER_LOG_DSK  32	/* Max Subdisks per Logical disk. */
#define MAX_ROOT_LVS	8	/* Max ROOT LVs per SBB. */
#define DEF_RV_RATE	5	/* Default revive rate in 10 msec ticks. */
#define DEF_RV_BLK_SZ	32	/* Default block size used in the */
			        /*  revive process. */
#define SD_ADRSPCS	6	/* # address spaces associated with a subdisk */
				/*  (Cfg 1 + Cfg 2 + Wrt 1 + Wrt 2 + Pimg + */
				/*   Data area) */

/*
 *  Volume management system parameters.
 */

#define DSKSTAT_INT	2	/* Disk statistics sampling interval in */
				/*   10ms intervals (20ms). */
#define SYNC_WAIT       4000 	/* Sync I/O timeout in 10ms intervals */
				/*   (40 Sec = 4000*10ms) */
#define MAX_IOC_MSGS	50	/* Allocated free message descriptors for */
 				/*   (vol I/O completion => vol mgmt process) */
				/*   communication. */
#define MAX_IODS	20	/* Allocated I/O descriptors */
#define MAX_DCS		50	/* Allocated RTE disk command structures */
#define MAX_DC_BMPS	10	/* Allocated disk command buffer map structs */
#define MIN_REV_PRCS	1	/* Min concurrent revive process allowed. */
#define MAX_REV_PRCS	10	/* Max concurrent revive process allowed. */
#define MIN_RV_BLKSZ	10	/* Min revive I/O blocksize allowed. */
#define MAX_RV_BLKSZ	32      /* Max revive I/O blocksize allowed. */
				/* Must be equal to MAX_IOV */
#define MNT_DELAY	10000	/* (100 Sec = 10000*10ms) Delay period */
				/*   before a subset LV is mounted. */
#define REV_DELAY	1000	/* (10 Sec = 1000*10ms) Delay before another */
				/*   revive start sequence is initiated on */
				/*   SD. */
#define RMTIO_TIMEOUT	3000	/* (30 Sec = 3000*10ms) Remote disk i/o  */
				/*   timeout */
#define SBB_UPDATE	1000	/* (10 Sec = 1000*10ms) SBB sector update */
				/*   rate in seconds */
#define SBB_DSKLOAD	1500	/* (15 Sec = 1500*10ms) Dual port disk */
				/*   load balancing scan interval */
#define TIMER_INT	100	/* (1 Sec = 100*10ms) Smallest timer */
				/*   interval used by volmgmt subsystem */

#endif _VOLMGMTPARS_

/*
 *  End of volmgmtpars.h
 */
