/* -*- linux-c -*- */
/*
 *
 *   Copyright (c) International Business Machines  Corp., 2000
 *
 *   This program is free software;  you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or 
 *   (at your option) any later version.
 * 
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 *   the GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program;  if not, write to the Free Software 
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
/*
 * linux/include/linux/evms_drvlink.h
 *
 * EVMS DriveLink Feature kernel header file
 *
 */

#ifndef __EVMS_DRIVELINK_INCLUDED__
#define __EVMS_DRIVELINK_INCLUDED__

#define EVMS_DRIVELINK_FEATURE_ID       1
#define EVMS_DRIVELINK_SIGNATURE        0x4C767244	//DrvL
#define EVMS_DRIVELINK_MAX_ENTRIES      60

/* 
 * feature data version defines
 */		       
#define DRIVELINK_METADATA_MAJOR	2
#define DRIVELINK_METADATA_MINOR        0
#define DRIVELINK_METADATA_PATCHLEVEL   0

static struct evms_version metadata_ver = {
	.major	= DRIVELINK_METADATA_MAJOR,
	.minor	= DRIVELINK_METADATA_MINOR,
	.patchlevel = DRIVELINK_METADATA_PATCHLEVEL
};

/**
 * struct evms_dl_ordering_table_entry - ordering table entry structure definition
 * @child_sn: child serial number
 * @child_size: in sectors
 * 
 * ordering table entry struction definition
 **/
struct evms_dl_ordering_table_entry {
	u64 child_serial_number;
	u64 child_vsize;
};

/**
 * struct evms_drivelink_metadata - on-disk metadata definition
 * @signature: drivelink metadata magic number
 * @crc: crc of entire structure
 * @version: drivelink metadata version
 * @flags:
 * @sequence_number: used to determine most recent redundant data
 * @child_sn: child object serial number
 * @parent_sn: parent object serial number
 * @child_count: count of child objects of parent
 * @pad: used for alignment of following table
 * @ordering_table: table of child ordering entries
 *
 * drivelink on-disk metadata definition
 **/
struct evms_drivelink_metadata {
	u32 signature;
	u32 crc;
	struct evms_version version;
	u32 flags;
	u64 sequence_number;
	u64 child_serial_number;
	u64 parent_serial_number;
	u64 child_count;
	u64 pad;
	struct evms_dl_ordering_table_entry
	    ordering_table[EVMS_DRIVELINK_MAX_ENTRIES];
};

#ifdef __KERNEL__
/**
 * struct runtime_entry - in-memory metadata entry description
 * @block_size: largest block size of all children
 * @voffset: relative offset of child object within parent object (in 512 byte units)
 * @vsize: child object size (in 512 byte units)
 * @child_node: child storage object
 * @child_metadata: child's on-disk metadata
 *
 * drivelink's in-memory metadata entry description
 **/
struct runtime_entry {
	u64 block_size;
	u64 voffset;
	u64 vsize;
	struct evms_logical_node *child_node;
	struct evms_drivelink_metadata *child_metadata;
};

/**
 * struct runtime_data - in-memory metadata description
 * @block_size: largest block size of all children
 * @voffset: relative offset of child object within parent object (in 512 byte units)
 * @vsize: child object size (in 512 byte units)
 * @child_node: child storage object
 * @child_metadata: child's on-disk metadata
 *
 * drivelink's in-memory metadata description
 **/
struct runtime_data {
	u64 block_size;
	u64 parent_sn;
	u64 child_count;
	struct runtime_entry *child_table;
};
#endif

#endif
