mlx_disk.c (78234) | mlx_disk.c (78752) |
---|---|
1/*- 2 * Copyright (c) 1999 Jonathan Lemon 3 * Copyright (c) 1999 Michael Smith 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * | 1/*- 2 * Copyright (c) 1999 Jonathan Lemon 3 * Copyright (c) 1999 Michael Smith 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * |
27 * $FreeBSD: head/sys/dev/mlx/mlx_disk.c 78234 2001-06-15 00:13:54Z peter $ | 27 * $FreeBSD: head/sys/dev/mlx/mlx_disk.c 78752 2001-06-25 04:32:31Z msmith $ |
28 */ 29 30/* 31 * Disk driver for Mylex DAC960 RAID adapters. 32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> 37 | 28 */ 29 30/* 31 * Disk driver for Mylex DAC960 RAID adapters. 32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> 37 |
38#include <sys/bio.h> | |
39#include <sys/bus.h> 40#include <sys/conf.h> 41#include <sys/devicestat.h> 42#include <sys/disk.h> 43 44#include <machine/bus.h> 45#include <sys/rman.h> 46 | 38#include <sys/bus.h> 39#include <sys/conf.h> 40#include <sys/devicestat.h> 41#include <sys/disk.h> 42 43#include <machine/bus.h> 44#include <sys/rman.h> 45 |
46#include <dev/mlx/mlx_compat.h> |
|
47#include <dev/mlx/mlxio.h> 48#include <dev/mlx/mlxvar.h> 49#include <dev/mlx/mlxreg.h> 50 51/* prototypes */ 52static int mlxd_probe(device_t dev); 53static int mlxd_attach(device_t dev); 54static int mlxd_detach(device_t dev); --- 101 unchanged lines hidden (view full) --- 156 157/* 158 * Read/write routine for a buffer. Finds the proper unit, range checks 159 * arguments, and schedules the transfer. Does not wait for the transfer 160 * to complete. Multi-page transfers are supported. All I/O requests must 161 * be a multiple of a sector in length. 162 */ 163static void | 47#include <dev/mlx/mlxio.h> 48#include <dev/mlx/mlxvar.h> 49#include <dev/mlx/mlxreg.h> 50 51/* prototypes */ 52static int mlxd_probe(device_t dev); 53static int mlxd_attach(device_t dev); 54static int mlxd_detach(device_t dev); --- 101 unchanged lines hidden (view full) --- 156 157/* 158 * Read/write routine for a buffer. Finds the proper unit, range checks 159 * arguments, and schedules the transfer. Does not wait for the transfer 160 * to complete. Multi-page transfers are supported. All I/O requests must 161 * be a multiple of a sector in length. 162 */ 163static void |
164mlxd_strategy(struct bio *bp) | 164mlxd_strategy(mlx_bio *bp) |
165{ | 165{ |
166 struct mlxd_softc *sc = (struct mlxd_softc *)bp->bio_dev->si_drv1; | 166 struct mlxd_softc *sc = (struct mlxd_softc *)MLX_BIO_SOFTC(bp); |
167 168 debug_called(1); 169 170 /* bogus disk? */ 171 if (sc == NULL) { | 167 168 debug_called(1); 169 170 /* bogus disk? */ 171 if (sc == NULL) { |
172 bp->bio_error = EINVAL; | 172 MLX_BIO_SET_ERROR(bp, EINVAL); |
173 goto bad; 174 } 175 176 /* XXX may only be temporarily offline - sleep? */ 177 if (sc->mlxd_drive->ms_state == MLX_SYSD_OFFLINE) { | 173 goto bad; 174 } 175 176 /* XXX may only be temporarily offline - sleep? */ 177 if (sc->mlxd_drive->ms_state == MLX_SYSD_OFFLINE) { |
178 bp->bio_error = ENXIO; | 178 MLX_BIO_SET_ERROR(bp, ENXIO); |
179 goto bad; 180 } 181 | 179 goto bad; 180 } 181 |
182 devstat_start_transaction(&sc->mlxd_stats); | 182 MLX_BIO_STATS_START(bp); |
183 mlx_submit_buf(sc->mlxd_controller, bp); 184 return; 185 186 bad: | 183 mlx_submit_buf(sc->mlxd_controller, bp); 184 return; 185 186 bad: |
187 bp->bio_flags |= BIO_ERROR; 188 | |
189 /* | 187 /* |
190 * Correctly set the buf to indicate a completed transfer | 188 * Correctly set the bio to indicate a failed tranfer. |
191 */ | 189 */ |
192 bp->bio_resid = bp->bio_bcount; 193 biodone(bp); | 190 MLX_BIO_RESID(bp) = MLX_BIO_LENGTH(bp); 191 MLX_BIO_DONE(bp); |
194 return; 195} 196 197void 198mlxd_intr(void *data) 199{ | 192 return; 193} 194 195void 196mlxd_intr(void *data) 197{ |
200 struct bio *bp = (struct bio *)data; 201 struct mlxd_softc *sc = (struct mlxd_softc *)bp->bio_dev->si_drv1; | 198 mlx_bio *bp = (mlx_bio *)data; |
202 203 debug_called(1); 204 | 199 200 debug_called(1); 201 |
205 if (bp->bio_flags & BIO_ERROR) 206 bp->bio_error = EIO; | 202 if (MLX_BIO_HAS_ERROR(bp)) 203 MLX_BIO_SET_ERROR(bp, EIO); |
207 else | 204 else |
208 bp->bio_resid = 0; | 205 MLX_BIO_RESID(bp) = 0; |
209 | 206 |
210 biofinish(bp, &sc->mlxd_stats, 0); | 207 MLX_BIO_STATS_END(bp); 208 MLX_BIO_DONE(bp); |
211} 212 213static int 214mlxd_probe(device_t dev) 215{ 216 217 debug_called(1); 218 --- 72 unchanged lines hidden --- | 209} 210 211static int 212mlxd_probe(device_t dev) 213{ 214 215 debug_called(1); 216 --- 72 unchanged lines hidden --- |