ccdvar.h revision 1.36 1 1.36 chs /* $NetBSD: ccdvar.h,v 1.36 2017/06/08 22:23:56 chs Exp $ */
2 1.5 thorpej
3 1.11 thorpej /*-
4 1.31 ad * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
5 1.5 thorpej * All rights reserved.
6 1.5 thorpej *
7 1.11 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.11 thorpej * by Jason R. Thorpe.
9 1.11 thorpej *
10 1.5 thorpej * Redistribution and use in source and binary forms, with or without
11 1.5 thorpej * modification, are permitted provided that the following conditions
12 1.5 thorpej * are met:
13 1.5 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.5 thorpej * notice, this list of conditions and the following disclaimer.
15 1.5 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.5 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.5 thorpej * documentation and/or other materials provided with the distribution.
18 1.5 thorpej *
19 1.11 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.11 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.11 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.13 jtc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.13 jtc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.11 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.11 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.11 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.11 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.11 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.11 thorpej * POSSIBILITY OF SUCH DAMAGE.
30 1.5 thorpej */
31 1.2 cgd
32 1.1 hpeyerl /*
33 1.32 rmind * Copyright (c) 1988 University of Utah.
34 1.3 hpeyerl * Copyright (c) 1990, 1993
35 1.3 hpeyerl * The Regents of the University of California. All rights reserved.
36 1.23 agc *
37 1.23 agc * This code is derived from software contributed to Berkeley by
38 1.23 agc * the Systems Programming Group of the University of Utah Computer
39 1.23 agc * Science Department.
40 1.23 agc *
41 1.23 agc * Redistribution and use in source and binary forms, with or without
42 1.23 agc * modification, are permitted provided that the following conditions
43 1.23 agc * are met:
44 1.23 agc * 1. Redistributions of source code must retain the above copyright
45 1.23 agc * notice, this list of conditions and the following disclaimer.
46 1.23 agc * 2. Redistributions in binary form must reproduce the above copyright
47 1.23 agc * notice, this list of conditions and the following disclaimer in the
48 1.23 agc * documentation and/or other materials provided with the distribution.
49 1.23 agc * 3. Neither the name of the University nor the names of its contributors
50 1.23 agc * may be used to endorse or promote products derived from this software
51 1.23 agc * without specific prior written permission.
52 1.23 agc *
53 1.23 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 1.23 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 1.23 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 1.23 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 1.23 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 1.23 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 1.23 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 1.23 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 1.23 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 1.23 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 1.23 agc * SUCH DAMAGE.
64 1.23 agc *
65 1.23 agc * from: Utah $Hdr: cdvar.h 1.1 90/07/09$
66 1.23 agc *
67 1.23 agc * @(#)cdvar.h 8.1 (Berkeley) 6/10/93
68 1.23 agc */
69 1.23 agc
70 1.25 thorpej #ifndef _DEV_CCDVAR_H_
71 1.25 thorpej #define _DEV_CCDVAR_H_
72 1.25 thorpej
73 1.36 chs #include <sys/ioccom.h>
74 1.36 chs #ifdef _KERNEL
75 1.22 thorpej #include <sys/buf.h>
76 1.29 ad #include <sys/mutex.h>
77 1.12 thorpej #include <sys/queue.h>
78 1.31 ad #include <sys/condvar.h>
79 1.36 chs #endif
80 1.12 thorpej
81 1.5 thorpej /*
82 1.5 thorpej * Dynamic configuration and disklabel support by:
83 1.5 thorpej * Jason R. Thorpe <thorpej (at) nas.nasa.gov>
84 1.5 thorpej * Numerical Aerodynamic Simulation Facility
85 1.5 thorpej * Mail Stop 258-6
86 1.5 thorpej * NASA Ames Research Center
87 1.5 thorpej * Moffett Field, CA 94035
88 1.5 thorpej */
89 1.1 hpeyerl
90 1.1 hpeyerl /*
91 1.5 thorpej * This structure is used to configure a ccd via ioctl(2).
92 1.5 thorpej */
93 1.5 thorpej struct ccd_ioctl {
94 1.5 thorpej char **ccio_disks; /* pointer to component paths */
95 1.20 jdolecek u_int ccio_ndisks; /* number of disks to concatenate */
96 1.5 thorpej int ccio_ileave; /* interleave (DEV_BSIZE blocks) */
97 1.16 thorpej int ccio_flags; /* see sc_flags below */
98 1.5 thorpej int ccio_unit; /* unit number: use varies */
99 1.34 sborrill uint64_t ccio_size; /* (returned) size of ccd */
100 1.1 hpeyerl };
101 1.1 hpeyerl
102 1.36 chs #ifdef _KERNEL
103 1.34 sborrill
104 1.1 hpeyerl /*
105 1.1 hpeyerl * Component info table.
106 1.1 hpeyerl * Describes a single component of a concatenated disk.
107 1.1 hpeyerl */
108 1.1 hpeyerl struct ccdcinfo {
109 1.5 thorpej struct vnode *ci_vp; /* device's vnode */
110 1.5 thorpej dev_t ci_dev; /* XXX: device's dev_t */
111 1.34 sborrill uint64_t ci_size; /* size */
112 1.5 thorpej char *ci_path; /* path to component */
113 1.5 thorpej size_t ci_pathlen; /* length of component path */
114 1.1 hpeyerl };
115 1.1 hpeyerl
116 1.1 hpeyerl /*
117 1.1 hpeyerl * Interleave description table.
118 1.1 hpeyerl * Computed at boot time to speed irregular-interleave lookups.
119 1.1 hpeyerl * The idea is that we interleave in "groups". First we interleave
120 1.1 hpeyerl * evenly over all component disks up to the size of the smallest
121 1.1 hpeyerl * component (the first group), then we interleave evenly over all
122 1.1 hpeyerl * remaining disks up to the size of the next-smallest (second group),
123 1.1 hpeyerl * and so on.
124 1.1 hpeyerl *
125 1.1 hpeyerl * Each table entry describes the interleave characteristics of one
126 1.1 hpeyerl * of these groups. For example if a concatenated disk consisted of
127 1.1 hpeyerl * three components of 5, 3, and 7 DEV_BSIZE blocks interleaved at
128 1.1 hpeyerl * DEV_BSIZE (1), the table would have three entries:
129 1.1 hpeyerl *
130 1.1 hpeyerl * ndisk startblk startoff dev
131 1.1 hpeyerl * 3 0 0 0, 1, 2
132 1.1 hpeyerl * 2 9 3 0, 2
133 1.1 hpeyerl * 1 13 5 2
134 1.1 hpeyerl * 0 - - -
135 1.1 hpeyerl *
136 1.1 hpeyerl * which says that the first nine blocks (0-8) are interleaved over
137 1.1 hpeyerl * 3 disks (0, 1, 2) starting at block offset 0 on any component disk,
138 1.1 hpeyerl * the next 4 blocks (9-12) are interleaved over 2 disks (0, 2) starting
139 1.1 hpeyerl * at component block 3, and the remaining blocks (13-14) are on disk
140 1.1 hpeyerl * 2 starting at offset 5.
141 1.1 hpeyerl */
142 1.1 hpeyerl struct ccdiinfo {
143 1.1 hpeyerl int ii_ndisk; /* # of disks range is interleaved over */
144 1.1 hpeyerl daddr_t ii_startblk; /* starting scaled block # for range */
145 1.1 hpeyerl daddr_t ii_startoff; /* starting component offset (block #) */
146 1.8 thorpej int *ii_index; /* ordered list of components in range */
147 1.31 ad size_t ii_indexsz; /* size of memory area */
148 1.1 hpeyerl };
149 1.1 hpeyerl
150 1.5 thorpej /*
151 1.5 thorpej * Concatenated disk pseudo-geometry information.
152 1.5 thorpej */
153 1.5 thorpej struct ccdgeom {
154 1.5 thorpej u_int32_t ccg_secsize; /* # bytes per sector */
155 1.5 thorpej u_int32_t ccg_nsectors; /* # data sectors per track */
156 1.5 thorpej u_int32_t ccg_ntracks; /* # tracks per cylinder */
157 1.5 thorpej u_int32_t ccg_ncylinders; /* # cylinders per unit */
158 1.5 thorpej };
159 1.5 thorpej
160 1.12 thorpej struct ccdbuf;
161 1.12 thorpej
162 1.5 thorpej /*
163 1.5 thorpej * A concatenated disk is described after initialization by this structure.
164 1.5 thorpej */
165 1.5 thorpej struct ccd_softc {
166 1.33 christos int sc_unit;
167 1.5 thorpej int sc_flags; /* flags */
168 1.34 sborrill uint64_t sc_size; /* size of ccd */
169 1.5 thorpej int sc_ileave; /* interleave */
170 1.20 jdolecek u_int sc_nccdisks; /* number of components */
171 1.20 jdolecek #define CCD_MAXNDISKS 65536
172 1.5 thorpej struct ccdcinfo *sc_cinfo; /* component info */
173 1.5 thorpej struct ccdiinfo *sc_itable; /* interleave table */
174 1.5 thorpej struct ccdgeom sc_geom; /* pseudo geometry info */
175 1.9 thorpej char sc_xname[8]; /* XXX external name */
176 1.9 thorpej struct disk sc_dkdev; /* generic disk device info */
177 1.31 ad kmutex_t sc_dvlock; /* lock on device node */
178 1.27 yamt struct bufq_state *sc_bufq; /* buffer queue */
179 1.31 ad kmutex_t *sc_iolock; /* lock on I/O start/stop */
180 1.31 ad kcondvar_t sc_stop; /* when inflight goes zero */
181 1.31 ad struct lwp *sc_thread; /* for deferred I/O */
182 1.31 ad kcondvar_t sc_push; /* for deferred I/O */
183 1.31 ad bool sc_zap; /* for deferred I/O */
184 1.33 christos LIST_ENTRY(ccd_softc) sc_link;
185 1.5 thorpej };
186 1.5 thorpej
187 1.36 chs #endif /* _KERNEL */
188 1.36 chs
189 1.5 thorpej /* sc_flags */
190 1.21 thorpej #define CCDF_UNIFORM 0x002 /* use LCCD of sizes for uniform interleave */
191 1.24 lukem #define CCDF_NOLABEL 0x004 /* ignore on-disk (raw) disklabel */
192 1.24 lukem
193 1.21 thorpej #define CCDF_INITED 0x010 /* unit has been initialized */
194 1.21 thorpej #define CCDF_WLABEL 0x020 /* label area is writable */
195 1.21 thorpej #define CCDF_LABELLING 0x040 /* unit is currently being labelled */
196 1.21 thorpej #define CCDF_KLABEL 0x080 /* keep label on close */
197 1.21 thorpej #define CCDF_VLABEL 0x100 /* label is valid */
198 1.31 ad #define CCDF_RLABEL 0x200 /* currently reading label */
199 1.16 thorpej
200 1.16 thorpej /* Mask of user-settable ccd flags. */
201 1.24 lukem #define CCDF_USERMASK (CCDF_UNIFORM|CCDF_NOLABEL)
202 1.5 thorpej
203 1.5 thorpej /*
204 1.5 thorpej * Before you can use a unit, it must be configured with CCDIOCSET.
205 1.5 thorpej * The configuration persists across opens and closes of the device;
206 1.6 thorpej * a CCDIOCCLR must be used to reset a configuration. An attempt to
207 1.5 thorpej * CCDIOCSET an already active unit will return EBUSY. Attempts to
208 1.5 thorpej * CCDIOCCLR an inactive unit will return ENXIO.
209 1.5 thorpej */
210 1.5 thorpej #define CCDIOCSET _IOWR('F', 16, struct ccd_ioctl) /* enable ccd */
211 1.5 thorpej #define CCDIOCCLR _IOW('F', 17, struct ccd_ioctl) /* disable ccd */
212 1.25 thorpej
213 1.34 sborrill #if defined(COMPAT_60) && !defined(_LP64)
214 1.34 sborrill /*
215 1.34 sborrill * Old version with incorrect ccio_size
216 1.34 sborrill */
217 1.34 sborrill struct ccd_ioctl_60 {
218 1.34 sborrill char **ccio_disks; /* pointer to component paths */
219 1.34 sborrill u_int ccio_ndisks; /* number of disks to concatenate */
220 1.34 sborrill int ccio_ileave; /* interleave (DEV_BSIZE blocks) */
221 1.34 sborrill int ccio_flags; /* see sc_flags below */
222 1.34 sborrill int ccio_unit; /* unit number: use varies */
223 1.34 sborrill size_t ccio_size; /* (returned) size of ccd */
224 1.34 sborrill };
225 1.34 sborrill
226 1.34 sborrill #define CCDIOCSET_60 _IOWR('F', 16, struct ccd_ioctl_60) /* enable ccd */
227 1.34 sborrill #define CCDIOCCLR_60 _IOW('F', 17, struct ccd_ioctl_60) /* disable ccd */
228 1.34 sborrill #endif /* COMPAT_60 && !LP64*/
229 1.36 chs
230 1.33 christos /*
231 1.33 christos * Sysctl information
232 1.33 christos */
233 1.33 christos struct ccddiskinfo {
234 1.33 christos int ccd_ileave;
235 1.33 christos u_int ccd_ndisks;
236 1.34 sborrill uint64_t ccd_size;
237 1.33 christos int ccd_flags;
238 1.33 christos };
239 1.33 christos
240 1.25 thorpej #endif /* _DEV_CCDVAR_H_ */
241