summaryrefslogtreecommitdiffstats
path: root/sys/dev/mlx
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>2001-06-25 04:32:31 +0000
committermsmith <msmith@FreeBSD.org>2001-06-25 04:32:31 +0000
commiteb1ff0cc22d9a440d73dd6f14c49440b0f8fa972 (patch)
treeca600fd401a31faa563da2676c1e9bddd7d08294 /sys/dev/mlx
parent9c03640f8131fa266b0dbeb2a532794b18cee818 (diff)
downloadFreeBSD-src-eb1ff0cc22d9a440d73dd6f14c49440b0f8fa972.zip
FreeBSD-src-eb1ff0cc22d9a440d73dd6f14c49440b0f8fa972.tar.gz
Driver modifications consistent with my other drivers to facilitate
the use of a single set of sources across 4.x and 5.x branches. No significant code changes.
Diffstat (limited to 'sys/dev/mlx')
-rw-r--r--sys/dev/mlx/mlx.c41
-rw-r--r--sys/dev/mlx/mlx_compat.h77
-rw-r--r--sys/dev/mlx/mlx_disk.c32
-rw-r--r--sys/dev/mlx/mlx_pci.c2
-rw-r--r--sys/dev/mlx/mlxvar.h4
5 files changed, 115 insertions, 41 deletions
diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c
index fe2dc31..189b787 100644
--- a/sys/dev/mlx/mlx.c
+++ b/sys/dev/mlx/mlx.c
@@ -35,7 +35,6 @@
#include <sys/malloc.h>
#include <sys/kernel.h>
-#include <sys/bio.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/devicestat.h>
@@ -49,6 +48,7 @@
#include <machine/clock.h>
#include <sys/rman.h>
+#include <dev/mlx/mlx_compat.h>
#include <dev/mlx/mlxio.h>
#include <dev/mlx/mlxvar.h>
#include <dev/mlx/mlxreg.h>
@@ -296,7 +296,7 @@ mlx_attach(struct mlx_softc *sc)
*/
TAILQ_INIT(&sc->mlx_work);
TAILQ_INIT(&sc->mlx_freecmds);
- bioq_init(&sc->mlx_bioq);
+ MLX_BIO_QINIT(sc->mlx_bioq);
/*
* Select accessor methods based on controller interface type.
@@ -696,14 +696,14 @@ mlx_intr(void *arg)
* disk resource, then poke the disk resource to start as much work as it can.
*/
int
-mlx_submit_buf(struct mlx_softc *sc, struct bio *bp)
+mlx_submit_buf(struct mlx_softc *sc, mlx_bio *bp)
{
int s;
debug_called(1);
s = splbio();
- bioq_insert_tail(&sc->mlx_bioq, bp);
+ MLX_BIO_QINSERT(sc->mlx_bioq, bp);
sc->mlx_waitbufs++;
splx(s);
mlx_startio(sc);
@@ -1725,7 +1725,7 @@ mlx_startio(struct mlx_softc *sc)
{
struct mlx_command *mc;
struct mlxd_softc *mlxd;
- struct bio *bp;
+ mlx_bio *bp;
int blkcount;
int driveno;
int cmd;
@@ -1740,7 +1740,7 @@ mlx_startio(struct mlx_softc *sc)
for (;;) {
/* see if there's work to be done */
- if ((bp = bioq_first(&sc->mlx_bioq)) == NULL)
+ if ((bp = MLX_BIO_QFIRST(sc->mlx_bioq)) == NULL)
break;
/* get a command */
if ((mc = mlx_alloccmd(sc)) == NULL)
@@ -1751,16 +1751,16 @@ mlx_startio(struct mlx_softc *sc)
break;
}
/* get the buf containing our work */
- bioq_remove(&sc->mlx_bioq, bp);
+ MLX_BIO_QREMOVE(sc->mlx_bioq, bp);
sc->mlx_waitbufs--;
splx(s);
/* connect the buf to the command */
mc->mc_complete = mlx_completeio;
mc->mc_private = bp;
- mc->mc_data = bp->bio_data;
- mc->mc_length = bp->bio_bcount;
- if (bp->bio_cmd == BIO_READ) {
+ mc->mc_data = MLX_BIO_DATA(bp);
+ mc->mc_length = MLX_BIO_LENGTH(bp);
+ if (MLX_BIO_IS_READ(bp)) {
mc->mc_flags |= MLX_CMD_DATAIN;
cmd = MLX_CMD_READSG;
} else {
@@ -1772,13 +1772,13 @@ mlx_startio(struct mlx_softc *sc)
mlx_mapcmd(mc);
/* build a suitable I/O command (assumes 512-byte rounded transfers) */
- mlxd = (struct mlxd_softc *)bp->bio_dev->si_drv1;
+ mlxd = (struct mlxd_softc *)MLX_BIO_SOFTC(bp);
driveno = mlxd->mlxd_drive - sc->mlx_sysdrive;
- blkcount = (bp->bio_bcount + MLX_BLKSIZE - 1) / MLX_BLKSIZE;
+ blkcount = (MLX_BIO_LENGTH(bp) + MLX_BLKSIZE - 1) / MLX_BLKSIZE;
- if ((bp->bio_pblkno + blkcount) > sc->mlx_sysdrive[driveno].ms_size)
+ if ((MLX_BIO_LBA(bp) + blkcount) > sc->mlx_sysdrive[driveno].ms_size)
device_printf(sc->mlx_dev, "I/O beyond end of unit (%u,%d > %u)\n",
- bp->bio_pblkno, blkcount, sc->mlx_sysdrive[driveno].ms_size);
+ MLX_BIO_LBA(bp), blkcount, sc->mlx_sysdrive[driveno].ms_size);
/*
* Build the I/O command. Note that the SG list type bits are set to zero,
@@ -1787,7 +1787,7 @@ mlx_startio(struct mlx_softc *sc)
if (sc->mlx_iftype == MLX_IFTYPE_2) {
mlx_make_type1(mc, (cmd == MLX_CMD_WRITESG) ? MLX_CMD_WRITESG_OLD : MLX_CMD_READSG_OLD,
blkcount & 0xff, /* xfer length low byte */
- bp->bio_pblkno, /* physical block number */
+ MLX_BIO_LBA(bp), /* physical block number */
driveno, /* target drive number */
mc->mc_sgphys, /* location of SG list */
mc->mc_nsgent & 0x3f); /* size of SG list (top 3 bits clear) */
@@ -1795,7 +1795,7 @@ mlx_startio(struct mlx_softc *sc)
mlx_make_type5(mc, cmd,
blkcount & 0xff, /* xfer length low byte */
(driveno << 3) | ((blkcount >> 8) & 0x07), /* target and length high 3 bits */
- bp->bio_pblkno, /* physical block number */
+ MLX_BIO_LBA(bp), /* physical block number */
mc->mc_sgphys, /* location of SG list */
mc->mc_nsgent & 0x3f); /* size of SG list (top 3 bits clear) */
}
@@ -1819,12 +1819,11 @@ static void
mlx_completeio(struct mlx_command *mc)
{
struct mlx_softc *sc = mc->mc_sc;
- struct bio *bp = (struct bio *)mc->mc_private;
- struct mlxd_softc *mlxd = (struct mlxd_softc *)bp->bio_dev->si_drv1;
+ mlx_bio *bp = (mlx_bio *)mc->mc_private;
+ struct mlxd_softc *mlxd = (struct mlxd_softc *)MLX_BIO_SOFTC(bp);
if (mc->mc_status != MLX_STATUS_OK) { /* could be more verbose here? */
- bp->bio_error = EIO;
- bp->bio_flags |= BIO_ERROR;
+ MLX_BIO_SET_ERROR(bp, EIO);
switch(mc->mc_status) {
case MLX_STATUS_RDWROFFLINE: /* system drive has gone offline */
@@ -1837,7 +1836,7 @@ mlx_completeio(struct mlx_command *mc)
device_printf(sc->mlx_dev, "I/O error - %s\n", mlx_diagnose_command(mc));
#if 0
device_printf(sc->mlx_dev, " b_bcount %ld blkcount %ld b_pblkno %d\n",
- bp->bio_bcount, bp->bio_bcount / MLX_BLKSIZE, bp->bio_pblkno);
+ MLX_BIO_LENGTH(bp), MLX_BIO_LENGTH(bp) / MLX_BLKSIZE, MLX_BIO_LBA(bp));
device_printf(sc->mlx_dev, " %13D\n", mc->mc_mailbox, " ");
#endif
break;
diff --git a/sys/dev/mlx/mlx_compat.h b/sys/dev/mlx/mlx_compat.h
new file mode 100644
index 0000000..0c4fd17
--- /dev/null
+++ b/sys/dev/mlx/mlx_compat.h
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 2000, 2001 Michael Smith
+ * Copyright (c) 2000 BSDi
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+/*
+ * Portability and compatibility interfaces.
+ */
+
+#if __FreeBSD_version < 500003
+# include <machine/clock.h>
+# define INTR_ENTROPY 0
+
+# include <sys/buf.h> /* old buf style */
+typedef struct buf mlx_bio;
+typedef struct buf_queue_head mlx_bioq;
+# define MLX_BIO_QINIT(bq) bufq_init(&bq);
+# define MLX_BIO_QINSERT(bq, bp) bufq_insert_tail(&bq, bp)
+# define MLX_BIO_QFIRST(bq) bufq_first(&bq)
+# define MLX_BIO_QREMOVE(bq, bp) bufq_remove(&bq, bp)
+# define MLX_BIO_IS_READ(bp) ((bp)->b_flags & B_READ)
+# define MLX_BIO_DATA(bp) (bp)->b_data
+# define MLX_BIO_LENGTH(bp) (bp)->b_bcount
+# define MLX_BIO_LBA(bp) (bp)->b_pblkno
+# define MLX_BIO_SOFTC(bp) (bp)->b_dev->si_drv1
+# define MLX_BIO_UNIT(bp) *(int *)((bp)->b_dev->si_drv2)
+# define MLX_BIO_SET_ERROR(bp, err) do { (bp)->b_error = err; (bp)->b_flags |= B_ERROR;} while(0)
+# define MLX_BIO_HAS_ERROR(bp) ((bp)->b_flags & B_ERROR)
+# define MLX_BIO_RESID(bp) (bp)->b_resid
+# define MLX_BIO_DONE(bp) biodone(bp)
+# define MLX_BIO_STATS_START(bp) devstat_start_transaction(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats)
+# define MLX_BIO_STATS_END(bp) devstat_end_transaction_buf(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats, bp)
+#else
+# include <sys/bio.h>
+typedef struct bio mlx_bio;
+typedef struct bio_queue_head mlx_bioq;
+# define MLX_BIO_QINIT(bq) bioq_init(&bq);
+# define MLX_BIO_QINSERT(bq, bp) bioq_insert_tail(&bq, bp)
+# define MLX_BIO_QFIRST(bq) bioq_first(&bq)
+# define MLX_BIO_QREMOVE(bq, bp) bioq_remove(&bq, bp)
+# define MLX_BIO_IS_READ(bp) ((bp)->bio_cmd == BIO_READ)
+# define MLX_BIO_DATA(bp) (bp)->bio_data
+# define MLX_BIO_LENGTH(bp) (bp)->bio_bcount
+# define MLX_BIO_LBA(bp) (bp)->bio_pblkno
+# define MLX_BIO_SOFTC(bp) (bp)->bio_dev->si_drv1
+# define MLX_BIO_UNIT(bp) *(int *)((bp)->bio_dev->si_drv2)
+# define MLX_BIO_SET_ERROR(bp, err) do { (bp)->bio_error = err; (bp)->bio_flags |= BIO_ERROR;} while(0)
+# define MLX_BIO_HAS_ERROR(bp) ((bp)->bio_flags & BIO_ERROR)
+# define MLX_BIO_RESID(bp) (bp)->bio_resid
+# define MLX_BIO_DONE(bp) biodone(bp) /* XXX nice to integrate bio_finish here */
+# define MLX_BIO_STATS_START(bp) devstat_start_transaction(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats)
+# define MLX_BIO_STATS_END(bp) devstat_end_transaction_bio(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats, bp)
+#endif
+
diff --git a/sys/dev/mlx/mlx_disk.c b/sys/dev/mlx/mlx_disk.c
index 7caa522..40c7263 100644
--- a/sys/dev/mlx/mlx_disk.c
+++ b/sys/dev/mlx/mlx_disk.c
@@ -35,7 +35,6 @@
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <sys/bio.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/devicestat.h>
@@ -44,6 +43,7 @@
#include <machine/bus.h>
#include <sys/rman.h>
+#include <dev/mlx/mlx_compat.h>
#include <dev/mlx/mlxio.h>
#include <dev/mlx/mlxvar.h>
#include <dev/mlx/mlxreg.h>
@@ -161,53 +161,51 @@ mlxd_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p)
* be a multiple of a sector in length.
*/
static void
-mlxd_strategy(struct bio *bp)
+mlxd_strategy(mlx_bio *bp)
{
- struct mlxd_softc *sc = (struct mlxd_softc *)bp->bio_dev->si_drv1;
+ struct mlxd_softc *sc = (struct mlxd_softc *)MLX_BIO_SOFTC(bp);
debug_called(1);
/* bogus disk? */
if (sc == NULL) {
- bp->bio_error = EINVAL;
+ MLX_BIO_SET_ERROR(bp, EINVAL);
goto bad;
}
/* XXX may only be temporarily offline - sleep? */
if (sc->mlxd_drive->ms_state == MLX_SYSD_OFFLINE) {
- bp->bio_error = ENXIO;
+ MLX_BIO_SET_ERROR(bp, ENXIO);
goto bad;
}
- devstat_start_transaction(&sc->mlxd_stats);
+ MLX_BIO_STATS_START(bp);
mlx_submit_buf(sc->mlxd_controller, bp);
return;
bad:
- bp->bio_flags |= BIO_ERROR;
-
/*
- * Correctly set the buf to indicate a completed transfer
+ * Correctly set the bio to indicate a failed tranfer.
*/
- bp->bio_resid = bp->bio_bcount;
- biodone(bp);
+ MLX_BIO_RESID(bp) = MLX_BIO_LENGTH(bp);
+ MLX_BIO_DONE(bp);
return;
}
void
mlxd_intr(void *data)
{
- struct bio *bp = (struct bio *)data;
- struct mlxd_softc *sc = (struct mlxd_softc *)bp->bio_dev->si_drv1;
+ mlx_bio *bp = (mlx_bio *)data;
debug_called(1);
- if (bp->bio_flags & BIO_ERROR)
- bp->bio_error = EIO;
+ if (MLX_BIO_HAS_ERROR(bp))
+ MLX_BIO_SET_ERROR(bp, EIO);
else
- bp->bio_resid = 0;
+ MLX_BIO_RESID(bp) = 0;
- biofinish(bp, &sc->mlxd_stats, 0);
+ MLX_BIO_STATS_END(bp);
+ MLX_BIO_DONE(bp);
}
static int
diff --git a/sys/dev/mlx/mlx_pci.c b/sys/dev/mlx/mlx_pci.c
index 84b07e7..741c682 100644
--- a/sys/dev/mlx/mlx_pci.c
+++ b/sys/dev/mlx/mlx_pci.c
@@ -31,7 +31,6 @@
#include <sys/kernel.h>
#include <sys/bus.h>
-#include <sys/bio.h>
#include <sys/conf.h>
#include <sys/devicestat.h>
#include <sys/disk.h>
@@ -45,6 +44,7 @@
#include <pci/pcireg.h>
#include <pci/pcivar.h>
+#include <dev/mlx/mlx_compat.h>
#include <dev/mlx/mlxio.h>
#include <dev/mlx/mlxvar.h>
#include <dev/mlx/mlxreg.h>
diff --git a/sys/dev/mlx/mlxvar.h b/sys/dev/mlx/mlxvar.h
index 06b0ffa..a4de085 100644
--- a/sys/dev/mlx/mlxvar.h
+++ b/sys/dev/mlx/mlxvar.h
@@ -135,7 +135,7 @@ struct mlx_softc
struct mlx_command *mlx_busycmd[MLX_NSLOTS]; /* busy commands */
int mlx_busycmds; /* count of busy commands */
struct mlx_sysdrive mlx_sysdrive[MLX_MAXDRIVES]; /* system drives */
- struct bio_queue_head mlx_bioq; /* outstanding I/O operations */
+ mlx_bioq mlx_bioq; /* outstanding I/O operations */
int mlx_waitbufs; /* number of bufs awaiting commands */
/* controller status */
@@ -239,7 +239,7 @@ struct mlxd_softc
/*
* Interface between driver core and disk driver (should be using a bus?)
*/
-extern int mlx_submit_buf(struct mlx_softc *sc, struct bio *bp);
+extern int mlx_submit_buf(struct mlx_softc *sc, mlx_bio *bp);
extern int mlx_submit_ioctl(struct mlx_softc *sc, struct mlx_sysdrive *drive, u_long cmd,
caddr_t addr, int32_t flag, struct proc *p);
extern void mlxd_intr(void *data);
OpenPOWER on IntegriCloud