xref: /netbsd-src/sys/dev/ata/ata_raidvar.h (revision d710132b4b8ce7f7cccaaf660cb16aa16b4077a0)
1 /*	$NetBSD: ata_raidvar.h,v 1.1 2003/01/27 18:21:28 thorpej Exp $	*/
2 
3 /*
4  * Copyright (c) 2003 Wasabi Systems, Inc.
5  * All rights reserved.
6  *
7  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed for the NetBSD Project by
20  *	Wasabi Systems, Inc.
21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22  *    or promote products derived from this software without specific prior
23  *    written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef _DEV_ATA_ATA_RAIDVAR_H_
39 #define	_DEV_ATA_ATA_RAIDVAR_H_
40 
41 #include <sys/queue.h>
42 
43 /*
44  * Types of RAID configurations we support.  Do not change the order
45  * of this list, as it will change the order in which the arrays are
46  * sorted.
47  */
48 #define	ATA_RAID_TYPE_PROMISE	0
49 #define	ATA_RAID_TYPE_MAX	0
50 
51 /*
52  * Max # of disks supported by a single array.  This is limited by
53  * the number that the individual controller config blocks can support:
54  *
55  *	Promise		8
56  */
57 #define	ATA_RAID_MAX_DISKS	8
58 
59 struct ataraid_disk_info {
60 	struct device *adi_dev;		/* disk's device */
61 	int	adi_status;		/* disk's status */
62 	u_int	adi_sectors;
63 	u_int	adi_compsize;		/* in sectors */
64 };
65 
66 /* adi_status */
67 #define	ADI_S_ONLINE		0x01
68 #define	ADI_S_ASSIGNED		0x02
69 #define	ADI_S_SPARE		0x04
70 
71 struct ataraid_array_info {
72 	TAILQ_ENTRY(ataraid_array_info) aai_list;
73 
74 	struct device *aai_ld;		/* associated logical disk */
75 
76 	u_int	aai_type;		/* array type */
77 	u_int	aai_arrayno;		/* array number */
78 	int	aai_level;		/* RAID level */
79 	int	aai_generation;		/* config generaion # */
80 	int	aai_status;		/* array status */
81 
82 	/* Geometry info. */
83 	u_int	aai_interleave;		/* stripe size */
84 	u_int	aai_width;		/* array width */
85 	u_int	aai_ndisks;		/* number of disks */
86 	u_int	aai_heads;		/* tracks/cyl */
87 	u_int	aai_sectors;		/* secs/track */
88 	u_int	aai_cylinders;		/* cyl/unit */
89 	u_int	aai_capacity;		/* in sectors */
90 	u_int	aai_offset;		/* component start offset */
91 	u_int	aai_reserved;		/* component reserved sectors */
92 
93 	struct ataraid_disk_info aai_disks[ATA_RAID_MAX_DISKS];
94 };
95 
96 /* aai_level */
97 #define	AAI_L_SPAN		0x01
98 #define	AAI_L_RAID0		0x02
99 #define	AAI_L_RAID1		0x04
100 
101 /* aai_status */
102 #define	AAI_S_READY		0x01
103 #define	AAI_S_DEGRADED		0x02
104 
105 struct vnode;
106 struct wd_softc;
107 
108 typedef TAILQ_HEAD(, ataraid_array_info) ataraid_array_info_list_t;
109 extern ataraid_array_info_list_t ataraid_array_info_list;
110 
111 void	ata_raid_check_component(struct device *);
112 const char *ata_raid_type_name(u_int);
113 
114 struct ataraid_array_info *ata_raid_get_array_info(u_int, u_int);
115 int	ata_raid_config_block_rw(struct vnode *, daddr_t, void *,
116 	    size_t, int);
117 
118 /* Promise RAID support */
119 int	ata_raid_read_config_promise(struct wd_softc *);
120 
121 #endif /* _DEV_ATA_ATA_RAIDVAR_H_ */
122