Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add mpii(4), a driver for LSI Megaraid Fusion controllers.



details:   https://anonhg.NetBSD.org/src/rev/a3ff4530eaac
branches:  trunk
changeset: 446149:a3ff4530eaac
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Nov 24 18:23:29 2018 +0000

description:
Add mpii(4), a driver for LSI Megaraid Fusion controllers.
Ported from OpenBSD. This driver is MP-safe.
Note that the earlier fusion controllers (Megaraid 2208, codenamed Thunderbold)
are also supported by mfi(4). mpii will take precedence if both drivers
are enabled.
Tested on a
mfii0 at pci6 dev 0 function 0: "PERC H740P Adapter ", firmware 50.3.0-1512, 819
2MB cache
mfii0: interrupting at ioapic2 pin 2
scsibus0 at mfii0: 64 targets, 8 luns per target
scsibus0: waiting 2 seconds for devices to settle...
sd0 at scsibus0 target 0 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd0: fabricating a geometry
sd0: 99 GB, 102399 cyl, 64 head, 32 sec, 512 bytes/sect x 209714688 sectors
sd0: tagged queueing
sd1 at scsibus0 target 1 lun 0: <DELL, PERC H740P Adp, 5.03> disk fixed
sd1: fabricating a geometry
sd1: 22254 GB, 22788608 cyl, 64 head, 32 sec, 512 bytes/sect x 46671069696 sectors
sd1: fabricating a geometry

It supports bioctl(8) ioctls, as well as sensors for the BBU and logical
drives.

Sponsored by LIP6.

diffstat:

 sys/arch/amd64/conf/ALL         |     5 +-
 sys/arch/amd64/conf/GENERIC     |     5 +-
 sys/arch/amd64/conf/XEN3_DOM0   |     5 +-
 sys/arch/i386/conf/ALL          |     5 +-
 sys/arch/i386/conf/GENERIC      |     5 +-
 sys/arch/i386/conf/XEN3PAE_DOM0 |     3 +-
 sys/dev/pci/files.pci           |     7 +-
 sys/dev/pci/mfii.c              |  3871 +++++++++++++++++++++++++++++++++++++++
 8 files changed, 3894 insertions(+), 12 deletions(-)

diffs (truncated from 4043 to 300 lines):

diff -r eb9b52cb6f62 -r a3ff4530eaac sys/arch/amd64/conf/ALL
--- a/sys/arch/amd64/conf/ALL   Sat Nov 24 18:15:23 2018 +0000
+++ b/sys/arch/amd64/conf/ALL   Sat Nov 24 18:23:29 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.107 2018/09/23 09:21:01 maxv Exp $
+# $NetBSD: ALL,v 1.108 2018/11/24 18:23:29 bouyer Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "ALL-$Revision: 1.107 $"
+#ident         "ALL-$Revision: 1.108 $"
 
 maxusers       64              # estimated number of users
 
@@ -752,6 +752,7 @@
 iha*   at pci? dev ? function ?        # Initio INIC-940/950 SCSI
 isp*   at pci? dev ? function ?        # Qlogic ISP [12]0x0 SCSI/FibreChannel
 mfi*   at pci? dev ? function ?        # LSI MegaRAID SAS
+mfii*  at pci? dev ? function ?        # LSI MegaRAID SAS (Fusion and newer)
 mly*   at pci? dev ? function ?        # Mylex AcceleRAID and eXtremeRAID
 mpt*   at pci? dev ? function ?        # LSILogic 9x9 and 53c1030 (Fusion-MPT)
 mpii*  at pci? dev ? function ?        # LSI Logic Fusion-MPT II
diff -r eb9b52cb6f62 -r a3ff4530eaac sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC       Sat Nov 24 18:15:23 2018 +0000
+++ b/sys/arch/amd64/conf/GENERIC       Sat Nov 24 18:23:29 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.507 2018/11/17 20:29:49 uwe Exp $
+# $NetBSD: GENERIC,v 1.508 2018/11/24 18:23:29 bouyer Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "GENERIC-$Revision: 1.507 $"
+#ident         "GENERIC-$Revision: 1.508 $"
 
 maxusers       64              # estimated number of users
 
@@ -613,6 +613,7 @@
 iha*   at pci? dev ? function ?        # Initio INIC-940/950 SCSI
 isp*   at pci? dev ? function ?        # Qlogic ISP [12]0x0 SCSI/FibreChannel
 mfi*   at pci? dev ? function ?        # LSI MegaRAID SAS
+mfii*  at pci? dev ? function ?        # LSI MegaRAID SAS (Fusion and newer)
 mly*   at pci? dev ? function ?        # Mylex AcceleRAID and eXtremeRAID
 mpt*   at pci? dev ? function ?        # LSILogic 9x9 and 53c1030 (Fusion-MPT)
 mpii*  at pci? dev ? function ?        # LSI Logic Fusion-MPT II
diff -r eb9b52cb6f62 -r a3ff4530eaac sys/arch/amd64/conf/XEN3_DOM0
--- a/sys/arch/amd64/conf/XEN3_DOM0     Sat Nov 24 18:15:23 2018 +0000
+++ b/sys/arch/amd64/conf/XEN3_DOM0     Sat Nov 24 18:23:29 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.158 2018/10/23 19:58:52 jdolecek Exp $
+# $NetBSD: XEN3_DOM0,v 1.159 2018/11/24 18:23:29 bouyer Exp $
 
 include        "arch/amd64/conf/std.xen"
 
@@ -10,7 +10,7 @@
 #options       UVMHIST_PRINT
 #options       SYSCALL_DEBUG
 
-#ident         "XEN3_DOM0-$Revision: 1.158 $"
+#ident         "XEN3_DOM0-$Revision: 1.159 $"
 
 maxusers       32              # estimated number of users
 
@@ -519,6 +519,7 @@
 iha*   at pci? dev ? function ?        # Initio INIC-940/950 SCSI
 isp*   at pci? dev ? function ?        # Qlogic ISP [12]0x0 SCSI/FibreChannel
 mfi*   at pci? dev ? function ?        # LSI MegaRAID SAS
+mfii*  at pci? dev ? function ?        # LSI MegaRAID SAS (Fusion and newer)
 mly*   at pci? dev ? function ?        # Mylex AcceleRAID and eXtremeRAID
 mpt*   at pci? dev ? function ?        # LSILogic 9x9 and 53c1030 (Fusion-MPT)
 mpii*  at pci? dev ? function ?        # LSI Logic Fusion-MPT II
diff -r eb9b52cb6f62 -r a3ff4530eaac sys/arch/i386/conf/ALL
--- a/sys/arch/i386/conf/ALL    Sat Nov 24 18:15:23 2018 +0000
+++ b/sys/arch/i386/conf/ALL    Sat Nov 24 18:23:29 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.457 2018/09/23 09:21:02 maxv Exp $
+# $NetBSD: ALL,v 1.458 2018/11/24 18:23:29 bouyer Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "ALL-$Revision: 1.457 $"
+#ident         "ALL-$Revision: 1.458 $"
 
 maxusers       64              # estimated number of users
 
@@ -825,6 +825,7 @@
 iha*   at pci? dev ? function ?        # Initio INIC-940/950 SCSI
 isp*   at pci? dev ? function ?        # Qlogic ISP [12]0x0 SCSI/FibreChannel
 mfi*   at pci? dev ? function ?        # LSI MegaRAID SAS
+mfii*  at pci? dev ? function ?        # LSI MegaRAID SAS (Fusion and newer)
 mly*   at pci? dev ? function ?        # Mylex AcceleRAID and eXtremeRAID
 mpt*   at pci? dev ? function ?        # LSILogic 9x9 and 53c1030 (Fusion-MPT)
 mpii*  at pci? dev ? function ?        # LSI Logic Fusion-MPT II
diff -r eb9b52cb6f62 -r a3ff4530eaac sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Sat Nov 24 18:15:23 2018 +0000
+++ b/sys/arch/i386/conf/GENERIC        Sat Nov 24 18:23:29 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1193 2018/11/01 13:11:11 martin Exp $
+# $NetBSD: GENERIC,v 1.1194 2018/11/24 18:23:29 bouyer Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "GENERIC-$Revision: 1.1193 $"
+#ident         "GENERIC-$Revision: 1.1194 $"
 
 maxusers       64              # estimated number of users
 
@@ -762,6 +762,7 @@
 iha*   at pci? dev ? function ?        # Initio INIC-940/950 SCSI
 isp*   at pci? dev ? function ?        # Qlogic ISP [12]0x0 SCSI/FibreChannel
 mfi*   at pci? dev ? function ?        # LSI MegaRAID SAS
+mfii*  at pci? dev ? function ?        # LSI MegaRAID SAS (Fusion and newer)
 mly*   at pci? dev ? function ?        # Mylex AcceleRAID and eXtremeRAID
 mpt*   at pci? dev ? function ?        # LSILogic 9x9 and 53c1030 (Fusion-MPT)
 mpii*  at pci? dev ? function ?        # LSI Logic Fusion-MPT II
diff -r eb9b52cb6f62 -r a3ff4530eaac sys/arch/i386/conf/XEN3PAE_DOM0
--- a/sys/arch/i386/conf/XEN3PAE_DOM0   Sat Nov 24 18:15:23 2018 +0000
+++ b/sys/arch/i386/conf/XEN3PAE_DOM0   Sat Nov 24 18:23:29 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: XEN3PAE_DOM0,v 1.7 2018/10/23 19:58:52 jdolecek Exp $
+#      $NetBSD: XEN3PAE_DOM0,v 1.8 2018/11/24 18:23:29 bouyer Exp $
 #
 #      XEN3_0: Xen 3.0 domain0 kernel
 
@@ -482,6 +482,7 @@
 iha*   at pci? dev ? function ?        # Initio INIC-940/950 SCSI
 isp*   at pci? dev ? function ?        # Qlogic ISP [12]0x0 SCSI/FibreChannel
 mfi*   at pci? dev ? function ?        # LSI MegaRAID SAS
+mfii*  at pci? dev ? function ?        # LSI MegaRAID SAS (Fusion and newer)
 mly*   at pci? dev ? function ?        # Mylex AcceleRAID and eXtremeRAID
 mpt*   at pci? dev ? function ?        # LSILogic 9x9 and 53c1030 (Fusion-MPT)
 mpii*  at pci? dev ? function ?        # LSI Logic Fusion-MPT II
diff -r eb9b52cb6f62 -r a3ff4530eaac sys/dev/pci/files.pci
--- a/sys/dev/pci/files.pci     Sat Nov 24 18:15:23 2018 +0000
+++ b/sys/dev/pci/files.pci     Sat Nov 24 18:23:29 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.pci,v 1.409 2018/11/20 12:23:01 skrll Exp $
+#      $NetBSD: files.pci,v 1.410 2018/11/24 18:23:29 bouyer Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -152,6 +152,11 @@
 attach mfi at pci with mfi_pci
 file   dev/pci/mfi_pci.c               mfi_pci
 
+# LSI MegaRAID SAS Fusion RAID controllers 
+device mfii: scsi
+attach mfii at pci
+file   dev/pci/mfii.c                  mfii
+
 # LSILogic Fusion-MPT I/O Processor family
 # device declaration in sys/conf/files
 attach mpt at pci with mpt_pci
diff -r eb9b52cb6f62 -r a3ff4530eaac sys/dev/pci/mfii.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/mfii.c        Sat Nov 24 18:23:29 2018 +0000
@@ -0,0 +1,3871 @@
+/* $NetBSD: mfii.c,v 1.1 2018/11/24 18:23:29 bouyer Exp $ */
+/* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
+
+/*
+ * Copyright (c) 2012 David Gwynne <dlg%openbsd.org@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.1 2018/11/24 18:23:29 bouyer Exp $");
+
+#include "bio.h"
+
+#include <sys/atomic.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/buf.h>
+#include <sys/ioctl.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/cpu.h>
+#include <sys/conf.h>
+#include <sys/kauth.h>
+#include <sys/workqueue.h>
+#include <sys/malloc.h>
+
+#include <uvm/uvm_param.h>
+
+#include <dev/pci/pcidevs.h>
+#include <dev/pci/pcivar.h>
+
+#include <sys/bus.h>
+
+#include <dev/sysmon/sysmonvar.h>
+#include <sys/envsys.h>
+
+#include <dev/scsipi/scsipi_all.h>
+#include <dev/scsipi/scsi_all.h>
+#include <dev/scsipi/scsi_spc.h>
+#include <dev/scsipi/scsipi_disk.h>
+#include <dev/scsipi/scsi_disk.h>
+#include <dev/scsipi/scsiconf.h>
+
+#if NBIO > 0
+#include <dev/biovar.h>
+#endif /* NBIO > 0 */
+
+#include <dev/ic/mfireg.h>
+#include <dev/pci/mpiireg.h>
+
+#define        MFII_BAR                0x14
+#define MFII_BAR_35            0x10
+#define        MFII_PCI_MEMSIZE        0x2000 /* 8k */
+
+#define MFII_OSTS_INTR_VALID   0x00000009
+#define MFII_RPI               0x6c /* reply post host index */
+#define MFII_OSP2              0xb4 /* outbound scratch pad 2 */
+#define MFII_OSP3              0xb8 /* outbound scratch pad 3 */
+
+#define MFII_REQ_TYPE_SCSI     MPII_REQ_DESCR_SCSI_IO
+#define MFII_REQ_TYPE_LDIO     (0x7 << 1)
+#define MFII_REQ_TYPE_MFA      (0x1 << 1)
+#define MFII_REQ_TYPE_NO_LOCK  (0x2 << 1)
+#define MFII_REQ_TYPE_HI_PRI   (0x6 << 1)
+
+#define MFII_REQ_MFA(_a)       htole64((_a) | MFII_REQ_TYPE_MFA)
+
+#define MFII_FUNCTION_PASSTHRU_IO                      (0xf0)
+#define MFII_FUNCTION_LDIO_REQUEST                     (0xf1)
+
+#define MFII_MAX_CHAIN_UNIT    0x00400000
+#define MFII_MAX_CHAIN_MASK    0x000003E0
+#define MFII_MAX_CHAIN_SHIFT   5
+
+#define MFII_256K_IO           128
+#define MFII_1MB_IO            (MFII_256K_IO * 4)
+
+#define MFII_CHAIN_FRAME_MIN   1024
+
+struct mfii_request_descr {
+       u_int8_t        flags;
+       u_int8_t        msix_index;
+       u_int16_t       smid;
+
+       u_int16_t       lmid;
+       u_int16_t       dev_handle;
+} __packed;
+
+#define MFII_RAID_CTX_IO_TYPE_SYSPD    (0x1 << 4)
+#define MFII_RAID_CTX_TYPE_CUDA                (0x2 << 4)
+
+struct mfii_raid_context {
+       u_int8_t        type_nseg;
+       u_int8_t        _reserved1;
+       u_int16_t       timeout_value;
+
+       u_int16_t       reg_lock_flags;
+#define MFII_RAID_CTX_RL_FLAGS_SEQNO_EN        (0x08)
+#define MFII_RAID_CTX_RL_FLAGS_CPU0    (0x00)
+#define MFII_RAID_CTX_RL_FLAGS_CPU1    (0x10)
+#define MFII_RAID_CTX_RL_FLAGS_CUDA    (0x80)
+
+#define MFII_RAID_CTX_ROUTING_FLAGS_SQN        (1 << 4)
+#define MFII_RAID_CTX_ROUTING_FLAGS_CPU0 0
+       u_int16_t       virtual_disk_target_id;
+
+       u_int64_t       reg_lock_row_lba;
+
+       u_int32_t       reg_lock_length;
+
+       u_int16_t       next_lm_id;
+       u_int8_t        ex_status;
+       u_int8_t        status;
+
+       u_int8_t        raid_flags;
+       u_int8_t        num_sge;



Home | Main Index | Thread Index | Old Index