1/* $NetBSD: ata_raidvar.h,v 1.12 2010/07/06 18:03:21 bsh 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 * If this list is updated, ensure the array in
49 * ata_raid.c:ata_raid_type_name() is also updated.
50 */
51#define ATA_RAID_TYPE_PROMISE 0
52#define ATA_RAID_TYPE_ADAPTEC 1
53#define ATA_RAID_TYPE_VIA 2
54#define ATA_RAID_TYPE_NVIDIA 3
55#define ATA_RAID_TYPE_JMICRON 4
56#define ATA_RAID_TYPE_INTEL 5
57#define ATA_RAID_TYPE_MAX 5
58
59/*
60 * Max # of disks supported by a single array. This is limited by
61 * the number that the individual controller config blocks can support:
62 *
63 * Promise 8
64 */
65#define ATA_RAID_MAX_DISKS 8
66
67struct ataraid_disk_info {
68 device_t adi_dev; /* disk's device */
69 int adi_status; /* disk's status */
70 uint64_t adi_sectors;
71 uint64_t adi_compsize; /* in sectors */
72};
73
74/* adi_status */
75#define ADI_S_ONLINE 0x01
76#define ADI_S_ASSIGNED 0x02
77#define ADI_S_SPARE 0x04
78
79struct ataraid_array_info {
80 TAILQ_ENTRY(ataraid_array_info) aai_list;
81
82 device_t aai_ld; /* associated logical disk */
83
84 u_int aai_type; /* array type */
85 u_int aai_arrayno; /* array number */
86 int aai_level; /* RAID level */
87 int aai_generation; /* config generation # */
88 int aai_status; /* array status */
89
90 /* Geometry info. */
91 u_int aai_interleave; /* stripe size */
92 u_int aai_width; /* array width */
93 u_int aai_ndisks; /* number of disks */
94 u_int aai_heads; /* tracks/cyl */
95 u_int aai_sectors; /* secs/track */
96 u_int aai_cylinders; /* cyl/unit */
97 uint64_t aai_capacity; /* in sectors */
98 daddr_t aai_offset; /* component start offset */
99 uint64_t aai_reserved; /* component reserved sectors */
100
101 char aai_name[32]; /* array volume name */
102
103 uint aai_curdisk; /* to enumerate component disks */
104 struct ataraid_disk_info aai_disks[ATA_RAID_MAX_DISKS];
105};
106
107/* aai_level */
108#define AAI_L_SPAN 0x01
109#define AAI_L_RAID0 0x02
110#define AAI_L_RAID1 0x04
111#define AAI_L_RAID5 0x08
112
113/* aai_status */
114#define AAI_S_READY 0x01
115#define AAI_S_DEGRADED 0x02
116
117struct vnode;
118struct wd_softc;
119
120typedef TAILQ_HEAD(, ataraid_array_info) ataraid_array_info_list_t;
121extern ataraid_array_info_list_t ataraid_array_info_list;
122
123void ata_raid_check_component(device_t);
124const char *ata_raid_type_name(u_int);
125
126struct ataraid_array_info *ata_raid_get_array_info(u_int, u_int);
127int ata_raid_config_block_rw(struct vnode *, daddr_t, void *,
128 size_t, int);
129
130struct vnode *ata_raid_disk_vnode_find(struct ataraid_disk_info *);
131
132/* Promise RAID support */
133int ata_raid_read_config_promise(struct wd_softc *);
134
135/* Adaptec HostRAID support */
136int ata_raid_read_config_adaptec(struct wd_softc *);
137
138/* VIA V-RAID support */
139int ata_raid_read_config_via(struct wd_softc *);
140
141/* nVidia MediaShield support */
142int ata_raid_read_config_nvidia(struct wd_softc *);
143
144/* JMicron RAID support */
145int ata_raid_read_config_jmicron(struct wd_softc *);
146
147/* Intel MatrixRAID support */
148int ata_raid_read_config_intel(struct wd_softc *);
149
150#endif /* _DEV_ATA_ATA_RAIDVAR_H_ */
151