Module Name:    src
Committed By:   riz
Date:           Wed Oct 24 03:23:46 UTC 2012

Modified Files:
        src/etc [netbsd-6]: MAKEDEV.tmpl
        src/etc/etc.amd64 [netbsd-6]: MAKEDEV.conf
        src/etc/etc.i386 [netbsd-6]: MAKEDEV.conf
        src/sys/compat/linux/common [netbsd-6]: linux_ioctl.c
        src/sys/conf [netbsd-6]: majors
        src/sys/dev/ic [netbsd-6]: mfi.c mfireg.h mfivar.h
Added Files:
        src/sys/dev/ic [netbsd-6]: mfiio.h

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #629):
        sys/compat/linux/common/linux_ioctl.c: revision 1.57
        sys/dev/ic/mfi.c: revision 1.47
        sys/conf/majors: revision 1.62
        etc/etc.i386/MAKEDEV.conf: revision 1.24
        sys/dev/ic/mfivar.h: revision 1.20
        etc/MAKEDEV.tmpl: revision 1.159
        sys/dev/ic/mfiio.h: revision 1.1
        etc/etc.amd64/MAKEDEV.conf: revision 1.19
        sys/dev/ic/mfireg.h: revision 1.8
Add a pass-through ioctl for mfi(4), allowing userland to send raw commands
to the controller. This is compatible with the linux and FreeBSD
implementations.
Add the needed conversion for mfi ioctls in COMPAT_LINUX
Allocate a character major number, and create /dev/mfi0 by default
on amd64 and i386.
This allows (along with a hand-created /emul/linux/proc/devices file)
to run the MegaCLI linux binary provided by LSI.


To generate a diff of this commit:
cvs rdiff -u -r1.151.2.6 -r1.151.2.7 src/etc/MAKEDEV.tmpl
cvs rdiff -u -r1.17 -r1.17.6.1 src/etc/etc.amd64/MAKEDEV.conf
cvs rdiff -u -r1.21 -r1.21.6.1 src/etc/etc.i386/MAKEDEV.conf
cvs rdiff -u -r1.56 -r1.56.8.1 src/sys/compat/linux/common/linux_ioctl.c
cvs rdiff -u -r1.61 -r1.61.2.1 src/sys/conf/majors
cvs rdiff -u -r1.36.8.3 -r1.36.8.4 src/sys/dev/ic/mfi.c
cvs rdiff -u -r0 -r1.1.2.2 src/sys/dev/ic/mfiio.h
cvs rdiff -u -r1.4.16.2 -r1.4.16.3 src/sys/dev/ic/mfireg.h
cvs rdiff -u -r1.14.16.2 -r1.14.16.3 src/sys/dev/ic/mfivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/MAKEDEV.tmpl
diff -u src/etc/MAKEDEV.tmpl:1.151.2.6 src/etc/MAKEDEV.tmpl:1.151.2.7
--- src/etc/MAKEDEV.tmpl:1.151.2.6	Thu Sep 13 22:20:58 2012
+++ src/etc/MAKEDEV.tmpl	Wed Oct 24 03:23:45 2012
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#	$NetBSD: MAKEDEV.tmpl,v 1.151.2.6 2012/09/13 22:20:58 riz Exp $
+#	$NetBSD: MAKEDEV.tmpl,v 1.151.2.7 2012/10/24 03:23:45 riz Exp $
 #
 # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -254,6 +254,7 @@
 #	lockstat kernel locking statistics
 #	magma*	Magma multiport serial/parallel cards
 #	midi*	MIDI
+#	mfi*	LSI MegaRAID/MegaSAS control interface
 #	mlx*	Mylex DAC960 control interface
 #	mly*	Mylex AcceleRAID/eXtremeRAID control interface
 #	np*	UNIBUS Ethernet co-processor interface, for downloading.
@@ -1558,6 +1559,11 @@ iop[0-9]*)
 	mkdev iop$unit c %iop_chr% $unit
 	;;
 
+mfi[0-9]*)
+	unit=${i#mfi}
+	mkdev mfi$unit c %mfi_chr% $unit
+	;;
+
 mlx[0-9]*)
 	unit=${i#mlx}
 	mkdev mlx$unit c %mlx_chr% $unit

Index: src/etc/etc.amd64/MAKEDEV.conf
diff -u src/etc/etc.amd64/MAKEDEV.conf:1.17 src/etc/etc.amd64/MAKEDEV.conf:1.17.6.1
--- src/etc/etc.amd64/MAKEDEV.conf:1.17	Sat Feb 26 18:07:16 2011
+++ src/etc/etc.amd64/MAKEDEV.conf	Wed Oct 24 03:23:45 2012
@@ -1,4 +1,4 @@
-# $NetBSD: MAKEDEV.conf,v 1.17 2011/02/26 18:07:16 ahoka Exp $
+# $NetBSD: MAKEDEV.conf,v 1.17.6.1 2012/10/24 03:23:45 riz Exp $
 
 # As of 2003-04-17, the "init" case must not create more than 890 entries.
 all_md)
@@ -11,7 +11,7 @@ all_md)
 	makedev bpf
 	makedev ccd0 md0 ch0 random
 	makedev cgd0 cgd1
-	makedev amr0 iop0 mlx0 mly0 dpti0 dpt0 twe0
+	makedev amr0 iop0 mfi0 mlx0 mly0 dpti0 dpt0 twe0
 	makedev raid0 raid1 raid2 raid3
 	makedev ld0 ld1 ld2 ld3
 	makedev xbd0 xbd1 xbd2 xbd3 xen

Index: src/etc/etc.i386/MAKEDEV.conf
diff -u src/etc/etc.i386/MAKEDEV.conf:1.21 src/etc/etc.i386/MAKEDEV.conf:1.21.6.1
--- src/etc/etc.i386/MAKEDEV.conf:1.21	Sat Feb 26 18:07:17 2011
+++ src/etc/etc.i386/MAKEDEV.conf	Wed Oct 24 03:23:45 2012
@@ -1,4 +1,4 @@
-# $NetBSD: MAKEDEV.conf,v 1.21 2011/02/26 18:07:17 ahoka Exp $
+# $NetBSD: MAKEDEV.conf,v 1.21.6.1 2012/10/24 03:23:45 riz Exp $
 
 # As of 2005-03-15, the "init" case must not create more than 1024 entries.
 all_md)
@@ -11,7 +11,7 @@ all_md)
 	makedev bpf
 	makedev ccd0 md0 ch0 random
 	makedev cgd0 cgd1
-	makedev amr0 iop0 mlx0 mly0 dpti0 dpt0 twe0 icp0
+	makedev amr0 iop0 mfi0 mlx0 mly0 dpti0 dpt0 twe0 icp0
 	makedev ed0 ed1
 	makedev raid0 raid1 raid2 raid3
 	makedev ld0 ld1 ld2 ld3

Index: src/sys/compat/linux/common/linux_ioctl.c
diff -u src/sys/compat/linux/common/linux_ioctl.c:1.56 src/sys/compat/linux/common/linux_ioctl.c:1.56.8.1
--- src/sys/compat/linux/common/linux_ioctl.c:1.56	Fri Oct 14 09:23:28 2011
+++ src/sys/compat/linux/common/linux_ioctl.c	Wed Oct 24 03:23:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_ioctl.c,v 1.56 2011/10/14 09:23:28 hannken Exp $	*/
+/*	$NetBSD: linux_ioctl.c,v 1.56.8.1 2012/10/24 03:23:44 riz Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.56 2011/10/14 09:23:28 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ioctl.c,v 1.56.8.1 2012/10/24 03:23:44 riz Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "sequencer.h"
@@ -63,6 +63,10 @@ __KERNEL_RCSID(0, "$NetBSD: linux_ioctl.
 #include <compat/ossaudio/ossaudio.h>
 #define LINUX_TO_OSS(v) ((const void *)(v))	/* do nothing, same ioctl() encoding */
 
+#include <dev/ic/mfiio.h>
+#define LINUX_MEGARAID_CMD	_LINUX_IOWR('M', 1, struct mfi_ioc_packet)
+#define LINUX_MEGARAID_GET_AEN	_LINUX_IOW('M', 3, struct mfi_ioc_aen)
+
 /*
  * Most ioctl command are just converted to their NetBSD values,
  * and passed on. The ones that take structure pointers and (flag)
@@ -80,7 +84,28 @@ linux_sys_ioctl(struct lwp *l, const str
 
 	switch (LINUX_IOCGROUP(SCARG(uap, com))) {
 	case 'M':
-		error = oss_ioctl_mixer(l, LINUX_TO_OSS(uap), retval);
+		switch(SCARG(uap, com)) {
+		case LINUX_MEGARAID_CMD:
+		case LINUX_MEGARAID_GET_AEN:
+		{
+			struct sys_ioctl_args ua;
+			u_long com = 0;
+			if (SCARG(uap, com) & IOC_IN)
+				com |= IOC_OUT;
+			if (SCARG(uap, com) & IOC_OUT)
+				com |= IOC_IN;
+			SCARG(&ua, fd) = SCARG(uap, fd);
+			SCARG(&ua, com) = SCARG(uap, com);
+			SCARG(&ua, com) &= ~IOC_DIRMASK;
+			SCARG(&ua, com) |= com;
+			SCARG(&ua, data) = SCARG(uap, data);
+			error = sys_ioctl(l, (const void *)&ua, retval);
+			break;
+		}
+		default:
+			error = oss_ioctl_mixer(l, LINUX_TO_OSS(uap), retval);
+			break;
+		}
 		break;
 	case 'Q':
 		error = oss_ioctl_sequencer(l, LINUX_TO_OSS(uap), retval);

Index: src/sys/conf/majors
diff -u src/sys/conf/majors:1.61 src/sys/conf/majors:1.61.2.1
--- src/sys/conf/majors:1.61	Sun Jan 22 06:44:30 2012
+++ src/sys/conf/majors	Wed Oct 24 03:23:45 2012
@@ -1,4 +1,4 @@
-# $NetBSD: majors,v 1.61 2012/01/22 06:44:30 christos Exp $
+# $NetBSD: majors,v 1.61.2.1 2012/10/24 03:23:45 riz Exp $
 #
 # Device majors for Machine-Independent drivers.
 #
@@ -50,3 +50,4 @@ device-major iic       char 201         
 device-major filemon   char 202            filemon
 device-major iscsi     char 203            iscsi
 device-major tpm       char 204		   tpm
+device-major mfi       char 205		   mfi

Index: src/sys/dev/ic/mfi.c
diff -u src/sys/dev/ic/mfi.c:1.36.8.3 src/sys/dev/ic/mfi.c:1.36.8.4
--- src/sys/dev/ic/mfi.c:1.36.8.3	Wed Oct 24 03:19:19 2012
+++ src/sys/dev/ic/mfi.c	Wed Oct 24 03:23:44 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: mfi.c,v 1.36.8.3 2012/10/24 03:19:19 riz Exp $ */
+/* $NetBSD: mfi.c,v 1.36.8.4 2012/10/24 03:23:44 riz Exp $ */
 /* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
 
 /*
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.36.8.3 2012/10/24 03:19:19 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.36.8.4 2012/10/24 03:23:44 riz Exp $");
 
 #include "bio.h"
 
@@ -86,6 +86,8 @@ __KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.36
 #include <sys/malloc.h>
 #include <sys/proc.h>
 #include <sys/cpu.h>
+#include <sys/conf.h>
+#include <sys/kauth.h>
 
 #include <uvm/uvm_param.h>
 
@@ -100,6 +102,7 @@ __KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.36
 
 #include <dev/ic/mfireg.h>
 #include <dev/ic/mfivar.h>
+#include <dev/ic/mfiio.h>
 
 #if NBIO > 0
 #include <dev/biovar.h>
@@ -177,6 +180,16 @@ static bool		mfi_shutdown(device_t, int)
 static bool		mfi_suspend(device_t, const pmf_qual_t *);
 static bool		mfi_resume(device_t, const pmf_qual_t *);
 
+static dev_type_open(mfifopen);
+static dev_type_close(mfifclose);
+static dev_type_ioctl(mfifioctl);
+const struct cdevsw mfi_cdevsw = {
+	mfifopen, mfifclose, noread, nowrite, mfifioctl,
+	nostop, notty, nopoll, nommap, nokqfilter, D_OTHER
+};
+
+extern struct cfdriver mfi_cd;
+
 static uint32_t 	mfi_xscale_fw_state(struct mfi_softc *sc);
 static void 		mfi_xscale_intr_ena(struct mfi_softc *sc);
 static void 		mfi_xscale_intr_dis(struct mfi_softc *sc);
@@ -3472,3 +3485,151 @@ mfi_sync_map_complete(struct mfi_ccb *cc
 		workqueue_enqueue(sc->sc_ldsync_wq, &sc->sc_ldsync_wk, NULL);
 	}
 }
+
+static int
+mfifopen(dev_t dev, int flag, int mode, struct lwp *l)
+{
+	struct mfi_softc *sc;
+
+	if ((sc = device_lookup_private(&mfi_cd, minor(dev))) == NULL)
+		return (ENXIO);
+	return (0);
+}
+
+static int
+mfifclose(dev_t dev, int flag, int mode, struct lwp *l)
+{
+	struct mfi_softc *sc;
+
+	sc = device_lookup_private(&mfi_cd, minor(dev));
+	return (0);
+}
+
+static int
+mfifioctl(dev_t dev, u_long cmd, void *data, int flag,
+    struct lwp *l)
+{
+	struct mfi_softc *sc;
+	struct mfi_ioc_packet *ioc = data;
+	uint8_t *udata;
+	struct mfi_ccb *ccb = NULL;
+	int ctx, i, s, error;
+	union mfi_sense_ptr sense_ptr;
+
+	switch(cmd) {
+	case MFI_CMD:
+		sc = device_lookup_private(&mfi_cd, ioc->mfi_adapter_no);
+		break;
+	default:
+		return ENOTTY;
+	}
+	if (sc == NULL)
+		return (ENXIO);
+	if (sc->sc_opened)
+		return (EBUSY);
+
+	switch(cmd) {
+	case MFI_CMD:
+		error = kauth_authorize_device_passthru(l->l_cred, dev,
+		    KAUTH_REQ_DEVICE_RAWIO_PASSTHRU_ALL, data);
+		if (error)
+			return error;
+		if (ioc->mfi_sge_count > MAX_IOCTL_SGE)
+			return EINVAL;
+		s = splbio();
+		if ((ccb = mfi_get_ccb(sc)) == NULL)
+			return ENOMEM;
+		ccb->ccb_data = NULL;
+		ctx = ccb->ccb_frame->mfr_header.mfh_context;
+		memcpy(ccb->ccb_frame, ioc->mfi_frame.raw,
+		   sizeof(*ccb->ccb_frame));
+		ccb->ccb_frame->mfr_header.mfh_context = ctx;
+		ccb->ccb_frame->mfr_header.mfh_scsi_status = 0;
+		ccb->ccb_frame->mfr_header.mfh_pad0 = 0;
+		ccb->ccb_frame_size =
+		    (sizeof(union mfi_sgl) * ioc->mfi_sge_count) +
+		    ioc->mfi_sgl_off;
+		if (ioc->mfi_sge_count > 0) {
+			ccb->ccb_sgl = (union mfi_sgl *)
+			    &ccb->ccb_frame->mfr_bytes[ioc->mfi_sgl_off];
+		}
+		if (ccb->ccb_frame->mfr_header.mfh_flags & MFI_FRAME_DIR_READ)
+			ccb->ccb_direction = MFI_DATA_IN;
+		if (ccb->ccb_frame->mfr_header.mfh_flags & MFI_FRAME_DIR_WRITE)
+			ccb->ccb_direction = MFI_DATA_OUT;
+		ccb->ccb_len = ccb->ccb_frame->mfr_header.mfh_data_len;
+		if (ccb->ccb_len > MAXPHYS) {
+			error = ENOMEM;
+			goto out;
+		}
+		if (ccb->ccb_len &&
+		    (ccb->ccb_direction & (MFI_DATA_IN | MFI_DATA_OUT)) != 0) {
+			udata = malloc(ccb->ccb_len, M_DEVBUF, M_WAITOK|M_ZERO);
+			if (udata == NULL) {
+				error = ENOMEM;
+				goto out;
+			}
+			ccb->ccb_data = udata;
+			if (ccb->ccb_direction & MFI_DATA_OUT) {
+				for (i = 0; i < ioc->mfi_sge_count; i++) {
+					error = copyin(ioc->mfi_sgl[i].iov_base,
+					    udata, ioc->mfi_sgl[i].iov_len);
+					if (error)
+						goto out;
+					udata = &udata[
+					    ioc->mfi_sgl[i].iov_len];
+				}
+			}
+			if (mfi_create_sgl(ccb, BUS_DMA_WAITOK)) {
+				error = EIO;
+				goto out;
+			}
+		}
+		if (ccb->ccb_frame->mfr_header.mfh_cmd == MFI_CMD_PD_SCSI_IO) {
+			ccb->ccb_frame->mfr_io.mif_sense_addr_lo =
+			    htole32(ccb->ccb_psense);
+			ccb->ccb_frame->mfr_io.mif_sense_addr_hi = 0;
+		}
+		ccb->ccb_done = mfi_mgmt_done;
+		mfi_post(sc, ccb);
+		while (ccb->ccb_state != MFI_CCB_DONE)
+			tsleep(ccb, PRIBIO, "mfi_fioc", 0);
+
+		if (ccb->ccb_direction & MFI_DATA_IN) {
+			udata = ccb->ccb_data;
+			for (i = 0; i < ioc->mfi_sge_count; i++) {
+				error = copyout(udata,
+				    ioc->mfi_sgl[i].iov_base,
+				    ioc->mfi_sgl[i].iov_len);
+				if (error)
+					goto out;
+				udata = &udata[
+				    ioc->mfi_sgl[i].iov_len];
+			}
+		}
+		if (ioc->mfi_sense_len) {
+			memcpy(&sense_ptr.sense_ptr_data[0],
+			&ioc->mfi_frame.raw[ioc->mfi_sense_off],
+			sizeof(sense_ptr.sense_ptr_data));
+			error = copyout(ccb->ccb_sense,
+			    sense_ptr.user_space,
+			    sizeof(sense_ptr.sense_ptr_data));
+			if (error)
+				goto out;
+		}
+		memcpy(ioc->mfi_frame.raw, ccb->ccb_frame,
+		   sizeof(*ccb->ccb_frame));
+		break;
+	default:
+		printf("mfifioctl unhandled cmd 0x%lx\n", cmd);
+		return ENOTTY;
+	}
+
+out:
+	if (ccb->ccb_data)
+		free(ccb->ccb_data, M_DEVBUF);
+	if (ccb)
+		mfi_put_ccb(ccb);
+	splx(s);
+	return error;
+}

Index: src/sys/dev/ic/mfireg.h
diff -u src/sys/dev/ic/mfireg.h:1.4.16.2 src/sys/dev/ic/mfireg.h:1.4.16.3
--- src/sys/dev/ic/mfireg.h:1.4.16.2	Wed Oct 24 03:19:19 2012
+++ src/sys/dev/ic/mfireg.h	Wed Oct 24 03:23:44 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: mfireg.h,v 1.4.16.2 2012/10/24 03:19:19 riz Exp $ */
+/* $NetBSD: mfireg.h,v 1.4.16.3 2012/10/24 03:23:44 riz Exp $ */
 /* $OpenBSD: mfireg.h,v 1.24 2006/06/19 19:05:45 marco Exp $ */
 /*
  * Copyright (c) 2006 Marco Peereboom <ma...@peereboom.us>
@@ -43,6 +43,9 @@
  * SUCH DAMAGE.
  */
 
+#ifndef _DEV_IC_MFIREG_H_
+#define _DEV_IC_MFIREG_H_
+
 /* management interface constants */
 #define MFI_MGMT_VD			0x01
 #define MFI_MGMT_SD			0x02
@@ -1703,3 +1706,5 @@ typedef union _mfi_address {
 
 #define MEGASAS_MAX_NAME        32
 #define MEGASAS_VERSION         "4.23"
+
+#endif /* _DEV_IC_MFIREG_H_ */

Index: src/sys/dev/ic/mfivar.h
diff -u src/sys/dev/ic/mfivar.h:1.14.16.2 src/sys/dev/ic/mfivar.h:1.14.16.3
--- src/sys/dev/ic/mfivar.h:1.14.16.2	Wed Oct 24 03:19:19 2012
+++ src/sys/dev/ic/mfivar.h	Wed Oct 24 03:23:44 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: mfivar.h,v 1.14.16.2 2012/10/24 03:19:19 riz Exp $ */
+/* $NetBSD: mfivar.h,v 1.14.16.3 2012/10/24 03:23:44 riz Exp $ */
 /* $OpenBSD: mfivar.h,v 1.28 2006/08/31 18:18:46 marco Exp $ */
 /*
  * Copyright (c) 2006 Marco Peereboom <ma...@peereboom.us>
@@ -210,6 +210,9 @@ struct mfi_softc {
 	bool			sc_running;
 
 	device_t		sc_child;
+
+	/* for ioctl interface */
+	bool			sc_opened;
 };
 
 int	mfi_rescan(device_t, const char *, const int *);

Added files:

Index: src/sys/dev/ic/mfiio.h
diff -u /dev/null src/sys/dev/ic/mfiio.h:1.1.2.2
--- /dev/null	Wed Oct 24 03:23:46 2012
+++ src/sys/dev/ic/mfiio.h	Wed Oct 24 03:23:44 2012
@@ -0,0 +1,93 @@
+/*-
+ * Copyright (c) 2006 IronPort Systems
+ * 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.
+ */
+#include <dev/ic/mfireg.h>
+#include <sys/ioctl.h>
+
+/*
+ * these structures are used for LSI's MegaCli on both FreeBSD and Linux
+ * We will also use them in the NetBSD driver.
+ */
+
+#define MAX_SPACE_FOR_SENSE_PTR         32
+union mfi_sense_ptr {
+	uint8_t         sense_ptr_data[MAX_SPACE_FOR_SENSE_PTR];
+	void            *user_space;
+	struct {
+		uint32_t        low;
+		uint32_t        high; 
+	} addr;
+} __packed;
+
+
+#define MAX_IOCTL_SGE	16
+
+struct mfi_ioc_packet {
+	uint16_t	mfi_adapter_no;
+	uint16_t	mfi_pad1;	
+	uint32_t	mfi_sgl_off;	
+	uint32_t	mfi_sge_count;
+	uint32_t	mfi_sense_off;
+	uint32_t	mfi_sense_len;
+	union {
+		uint8_t raw[128];	
+		struct mfi_frame_header hdr;
+	} mfi_frame;
+
+	struct iovec mfi_sgl[MAX_IOCTL_SGE];
+} __packed;
+
+struct mfi_ioc_aen {
+	uint16_t	aen_adapter_no;
+	uint16_t	aen_pad1;
+	uint32_t	aen_seq_num;
+	uint32_t	aen_class_locale;
+} __packed;
+
+#define MFI_CMD	 	_IOWR('M', 1, struct mfi_ioc_packet)
+#define MFI_SET_AEN	_IOW('M', 3, struct mfi_ioc_aen)
+
+#ifdef _LP64
+struct iovec32 {
+	u_int32_t	iov_base;
+	int		iov_len;
+};
+
+struct mfi_ioc_packet32 {
+	uint16_t	mfi_adapter_no;
+	uint16_t	mfi_pad1;	
+	uint32_t	mfi_sgl_off;	
+	uint32_t	mfi_sge_count;
+	uint32_t	mfi_sense_off;
+	uint32_t	mfi_sense_len;
+	union {
+		uint8_t raw[128];	
+		struct mfi_frame_header hdr;
+	} mfi_frame;
+
+	struct iovec32 mfi_sgl[MAX_IOCTL_SGE];
+} __packed;
+#define MFI_CMD32	_IOWR('M', 1, struct mfi_ioc_packet32)
+#endif

Reply via email to