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:
--- 13 unchanged lines hidden (view full) ---
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 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/mlx/mlx_disk.c 125975 2004-02-18 21:36:53Z phk $");
31
32/*
33 * Disk driver for Mylex DAC960 RAID adapters.
34 */
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/kernel.h>
--- 175 unchanged lines hidden (view full) ---
214 default:
215 state = "unknown state";
216 }
217
218 device_printf(dev, "%uMB (%u sectors) RAID %d (%s)\n",
219 sc->mlxd_drive->ms_size / ((1024 * 1024) / MLX_BLKSIZE),
220 sc->mlxd_drive->ms_size, sc->mlxd_drive->ms_raidlevel, state);
221
222 sc->mlxd_disk = disk_alloc();
223 sc->mlxd_disk->d_open = mlxd_open;
224 sc->mlxd_disk->d_close = mlxd_close;
225 sc->mlxd_disk->d_ioctl = mlxd_ioctl;
226 sc->mlxd_disk->d_strategy = mlxd_strategy;
227 sc->mlxd_disk->d_name = "mlxd";
228 sc->mlxd_disk->d_unit = sc->mlxd_unit;
229 sc->mlxd_disk->d_drv1 = sc;
230 sc->mlxd_disk->d_sectorsize = MLX_BLKSIZE;
231 sc->mlxd_disk->d_mediasize = MLX_BLKSIZE * (off_t)sc->mlxd_drive->ms_size;
232 sc->mlxd_disk->d_fwsectors = sc->mlxd_drive->ms_sectors;
233 sc->mlxd_disk->d_fwheads = sc->mlxd_drive->ms_heads;
234 sc->mlxd_disk->d_flags = DISKFLAG_NEEDSGIANT;
235
236 /*
237 * Set maximum I/O size to the lesser of the recommended maximum and the practical
238 * maximum except on v2 cards where the maximum is set to 8 pages.
239 */
240 if (sc->mlxd_controller->mlx_iftype == MLX_IFTYPE_2)
241 sc->mlxd_disk->d_maxsize = 8 * PAGE_SIZE;
242 else {
243 s1 = sc->mlxd_controller->mlx_enq2->me_maxblk * MLX_BLKSIZE;
244 s2 = (sc->mlxd_controller->mlx_enq2->me_max_sg - 1) * PAGE_SIZE;
245 sc->mlxd_disk->d_maxsize = imin(s1, s2);
246 }
247
248 disk_create(sc->mlxd_disk, DISK_VERSION);
249
250 return (0);
251}
252
253static int
254mlxd_detach(device_t dev)
255{
256 struct mlxd_softc *sc = (struct mlxd_softc *)device_get_softc(dev);
257
258 debug_called(1);
259
260 disk_destroy(sc->mlxd_disk);
261
262 return(0);
263}
264
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:
--- 13 unchanged lines hidden (view full) ---
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 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/mlx/mlx_disk.c 125975 2004-02-18 21:36:53Z phk $");
31
32/*
33 * Disk driver for Mylex DAC960 RAID adapters.
34 */
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/kernel.h>
--- 175 unchanged lines hidden (view full) ---
214 default:
215 state = "unknown state";
216 }
217
218 device_printf(dev, "%uMB (%u sectors) RAID %d (%s)\n",
219 sc->mlxd_drive->ms_size / ((1024 * 1024) / MLX_BLKSIZE),
220 sc->mlxd_drive->ms_size, sc->mlxd_drive->ms_raidlevel, state);
221
222 sc->mlxd_disk = disk_alloc();
223 sc->mlxd_disk->d_open = mlxd_open;
224 sc->mlxd_disk->d_close = mlxd_close;
225 sc->mlxd_disk->d_ioctl = mlxd_ioctl;
226 sc->mlxd_disk->d_strategy = mlxd_strategy;
227 sc->mlxd_disk->d_name = "mlxd";
228 sc->mlxd_disk->d_unit = sc->mlxd_unit;
229 sc->mlxd_disk->d_drv1 = sc;
230 sc->mlxd_disk->d_sectorsize = MLX_BLKSIZE;
231 sc->mlxd_disk->d_mediasize = MLX_BLKSIZE * (off_t)sc->mlxd_drive->ms_size;
232 sc->mlxd_disk->d_fwsectors = sc->mlxd_drive->ms_sectors;
233 sc->mlxd_disk->d_fwheads = sc->mlxd_drive->ms_heads;
234 sc->mlxd_disk->d_flags = DISKFLAG_NEEDSGIANT;
235
236 /*
237 * Set maximum I/O size to the lesser of the recommended maximum and the practical
238 * maximum except on v2 cards where the maximum is set to 8 pages.
239 */
240 if (sc->mlxd_controller->mlx_iftype == MLX_IFTYPE_2)
241 sc->mlxd_disk->d_maxsize = 8 * PAGE_SIZE;
242 else {
243 s1 = sc->mlxd_controller->mlx_enq2->me_maxblk * MLX_BLKSIZE;
244 s2 = (sc->mlxd_controller->mlx_enq2->me_max_sg - 1) * PAGE_SIZE;
245 sc->mlxd_disk->d_maxsize = imin(s1, s2);
246 }
247
248 disk_create(sc->mlxd_disk, DISK_VERSION);
249
250 return (0);
251}
252
253static int
254mlxd_detach(device_t dev)
255{
256 struct mlxd_softc *sc = (struct mlxd_softc *)device_get_softc(dev);
257
258 debug_called(1);
259
260 disk_destroy(sc->mlxd_disk);
261
262 return(0);
263}
264