Mercurial > illumos > illumos-gate
changeset 9795:152ae1212035
6813803 Solaris needs SAS 2.0 MegaRAID mr_sas driver on Sparc
6807251 mr_sas driver should support PCI-E relaxed ordering
6840379 mr_sas driver should have an mdb module
author | Yu Wu - Sun Microsystems - Beijing China <Yu.Wu@Sun.COM> |
---|---|
date | Fri, 05 Jun 2009 09:34:31 +0800 |
parents | 1dcede0b3745 |
children | 0bf39e39ee05 |
files | usr/src/cmd/mdb/Makefile.common usr/src/cmd/mdb/common/modules/mr_sas/mr_sas.c usr/src/cmd/mdb/intel/amd64/mr_sas/Makefile usr/src/cmd/mdb/intel/ia32/mr_sas/Makefile usr/src/cmd/mdb/sparc/v9/mr_sas/Makefile usr/src/pkgdefs/SUNWmdb/prototype_i386 usr/src/pkgdefs/SUNWmdb/prototype_sparc usr/src/pkgdefs/SUNWmdbr/prototype_i386 usr/src/pkgdefs/SUNWmdbr/prototype_sparc usr/src/pkgdefs/SUNWmrsas/postinstall usr/src/pkgdefs/SUNWmrsas/prototype_com usr/src/pkgdefs/SUNWmrsas/prototype_i386 usr/src/pkgdefs/SUNWmrsas/prototype_sparc usr/src/uts/common/io/mr_sas/mr_sas.c usr/src/uts/common/io/mr_sas/mr_sas.h usr/src/uts/common/io/mr_sas/mr_sas_list.h usr/src/uts/sparc/Makefile.sparc.shared usr/src/uts/sparc/mr_sas/Makefile |
diffstat | 18 files changed, 560 insertions(+), 103 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/mdb/Makefile.common Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/cmd/mdb/Makefile.common Fri Jun 05 09:34:31 2009 +0800 @@ -72,6 +72,7 @@ logindmux \ mac \ md \ + mr_sas \ nca \ nsctl \ nsmb \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/cmd/mdb/common/modules/mr_sas/mr_sas.c Fri Jun 05 09:34:31 2009 +0800 @@ -0,0 +1,215 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include <limits.h> +#include <sys/mdb_modapi.h> +#include <sys/sysinfo.h> +#include <sys/sunmdi.h> +#include <sys/scsi/scsi.h> +#include "mr_sas.h" + +int +construct_path(uintptr_t addr, char *result) +{ + struct dev_info d; + char devi_node[PATH_MAX]; + char devi_addr[PATH_MAX]; + + if (mdb_vread(&d, sizeof (d), addr) == -1) { + mdb_warn("couldn't read dev_info"); + return (DCMD_ERR); + } + + if (d.devi_parent) { + construct_path((uintptr_t)d.devi_parent, result); + mdb_readstr(devi_node, sizeof (devi_node), + (uintptr_t)d.devi_node_name); + mdb_readstr(devi_addr, sizeof (devi_addr), + (uintptr_t)d.devi_addr); + mdb_snprintf(result+strlen(result), + PATH_MAX-strlen(result), + "/%s%s%s", devi_node, (*devi_addr ? "@" : ""), + devi_addr); + } + return (DCMD_OK); +} + +void +display_targets(struct mrsas_instance m, int verbose) +{ + int tgt; + struct mrsas_ld *mr_ldp; + char device_path[PATH_MAX]; + + if (verbose) { + *device_path = 0; + if (construct_path((uintptr_t)m.dip, device_path) != DCMD_OK) { + strcpy(device_path, "couldn't determine device path"); + } + } + + mdb_printf("\n"); + if (verbose) + mdb_printf("%s\n", device_path); + mdb_printf("dev_type target\n"); + mdb_printf("----------"); + mdb_printf("\n"); + for (tgt = 0; tgt < MRDRV_MAX_LD; tgt++) { + mr_ldp = (struct mrsas_ld *)&m.mr_ld_list[tgt]; + if ((mr_ldp != NULL) && (mr_ldp->dip != NULL) && + (mr_ldp->lun_type == MRSAS_LD_LUN)) { + mdb_printf("sd %d", tgt); + mdb_printf("\n"); + } + } + mdb_printf("\n"); +} + +void +display_deviceinfo(struct mrsas_instance m) +{ + uint16_t vid, did, svid, sid; + + vid = m.vendor_id; + did = m.device_id; + svid = m.subsysvid; + sid = m.subsysid; + + mdb_printf("\n"); + mdb_printf("vendor_id device_id subsysvid subsysid"); + mdb_printf("\n"); + mdb_printf("--------------------------------------"); + mdb_printf("\n"); + mdb_printf(" 0x%x 0x%x 0x%x 0x%x", + vid, did, svid, sid); + mdb_printf("\n"); +} + +static int +mr_sas_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) +{ + struct mrsas_instance m; + + int instance; + uint16_t ncmds; + uint_t verbose = FALSE; + uint_t device_info = FALSE; + uint_t target_info = FALSE; + int rv = DCMD_OK; + void *mrsas_state; + + if (!(flags & DCMD_ADDRSPEC)) { + mrsas_state = NULL; + if (mdb_readvar(&mrsas_state, "mrsas_state") == -1) { + mdb_warn("can't read mrsas_state"); + return (DCMD_ERR); + } + if (mdb_pwalk_dcmd("genunix`softstate", "mr_sas`mr_sas", + argc, argv, (uintptr_t)mrsas_state) == -1) { + mdb_warn("mdb_pwalk_dcmd failed"); + return (DCMD_ERR); + } + return (DCMD_OK); + } + + if (mdb_getopts(argc, argv, + 'd', MDB_OPT_SETBITS, TRUE, &device_info, + 't', MDB_OPT_SETBITS, TRUE, &target_info, + 'v', MDB_OPT_SETBITS, TRUE, &verbose, + NULL) != argc) + return (DCMD_USAGE); + + if (mdb_vread(&m, sizeof (m), addr) == -1) { + mdb_warn("couldn't read mrsas_instance struct at 0x%p", addr); + return (DCMD_ERR); + } + instance = m.instance; + + /* cmd slot info */ + ncmds = m.max_fw_cmds; + + /* processing completed */ + if (((flags & DCMD_ADDRSPEC) && !(flags & DCMD_LOOP)) || + (flags & DCMD_LOOPFIRST)) { + if ((flags & DCMD_LOOP) && !(flags & DCMD_LOOPFIRST)) + mdb_printf("\n"); + mdb_printf(" mrsas_t inst max_fw_cmds intr_type"); + mdb_printf("\n"); + mdb_printf("==========================================="); + mdb_printf("\n"); + } + + mdb_printf("%16p %4d %4d ", addr, instance, ncmds); + switch (m.intr_type) { + case DDI_INTR_TYPE_MSIX: + mdb_printf("MSI-X"); + break; + case DDI_INTR_TYPE_MSI: + mdb_printf("MSI"); + break; + case DDI_INTR_TYPE_FIXED: + mdb_printf("FIXED"); + break; + default: + mdb_printf("INVALD"); + } + mdb_printf("\n"); + + if (target_info) + display_targets(m, verbose); + + if (device_info) + display_deviceinfo(m); + + return (rv); +} + +void +mr_sas_help(void) +{ + mdb_printf("Prints summary information about each mr_sas instance, " + "Without the address of a \"struct mrsas_instance\", prints every " + "instance.\n\n" + "Switches:\n" + " -t includes information about targets\n" + " -d includes information about the hardware\n" + " -v displays extra information for some options\n"); +} + +static const mdb_dcmd_t dcmds[] = { + { "mr_sas", "?[-tdv]", "print mr_sas information", mr_sas_dcmd, + mr_sas_help }, + { NULL } +}; + +static const mdb_modinfo_t modinfo = { + MDB_API_VERSION, dcmds, NULL +}; + +const mdb_modinfo_t * +_mdb_init(void) +{ + return (&modinfo); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/cmd/mdb/intel/amd64/mr_sas/Makefile Fri Jun 05 09:34:31 2009 +0800 @@ -0,0 +1,42 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +MODULE = mr_sas.so +MDBTGT = kvm + +MODSRCS = mr_sas.c + +MRSASBASE = ../../../../../uts/common/io/mr_sas + +include ../../../../Makefile.cmd +include ../../../../Makefile.cmd.64 +include ../../Makefile.amd64 +include ../../../Makefile.module + +CPPFLAGS += -I$(SRC)/uts/common +CPPFLAGS += -I$(SRC)/uts/common/sys/scsi +CPPFLAGS += -I$(SRC)/uts/common/sys/scsi/adapters +CPPFLAGS += -I$(MRSASBASE) +CPPFLAGS += -D KMDB_MODULE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/cmd/mdb/intel/ia32/mr_sas/Makefile Fri Jun 05 09:34:31 2009 +0800 @@ -0,0 +1,41 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +MODULE = mr_sas.so +MDBTGT = kvm + +MODSRCS = mr_sas.c + +MRSASBASE = ../../../../../uts/common/io/mr_sas + +include ../../../../Makefile.cmd +include ../../Makefile.ia32 +include ../../../Makefile.module + +CPPFLAGS += -I$(SRC)/uts/common +CPPFLAGS += -I$(SRC)/uts/common/sys/scsi +CPPFLAGS += -I$(SRC)/uts/common/sys/scsi/adapter +CPPFLAGS += -I$(MRSASBASE) +CPPFLAGS += -D KMDB_MODULE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/cmd/mdb/sparc/v9/mr_sas/Makefile Fri Jun 05 09:34:31 2009 +0800 @@ -0,0 +1,42 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +MODULE = mr_sas.so +MDBTGT = kvm + +MODSRCS = mr_sas.c + +MRSASBASE = ../../../../../uts/common/io/mr_sas + +include ../../../../Makefile.cmd +include ../../../../Makefile.cmd.64 +include ../../Makefile.sparcv9 +include ../../../Makefile.module + +CPPFLAGS += -I$(SRC)/uts/common +CPPFLAGS += -I$(SRC)/uts/common/sys/scsi +CPPFLAGS += -I$(SRC)/uts/common/sys/scsi/adapters +CPPFLAGS += -I$(MRSASBASE) +CPPFLAGS += -D KMDB_MODULE
--- a/usr/src/pkgdefs/SUNWmdb/prototype_i386 Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/pkgdefs/SUNWmdb/prototype_i386 Fri Jun 05 09:34:31 2009 +0800 @@ -75,6 +75,7 @@ f none usr/lib/mdb/kvm/amd64/mdb_kb.so 555 root sys f none usr/lib/mdb/kvm/amd64/mdb_ks.so 555 root sys f none usr/lib/mdb/kvm/amd64/mpt.so 555 root sys +f none usr/lib/mdb/kvm/amd64/mr_sas.so 555 root sys f none usr/lib/mdb/kvm/amd64/nca.so 555 root sys f none usr/lib/mdb/kvm/amd64/nfs.so 555 root sys f none usr/lib/mdb/kvm/amd64/ptm.so 555 root sys @@ -108,6 +109,7 @@ f none usr/lib/mdb/kvm/mdb_kb.so 555 root sys f none usr/lib/mdb/kvm/mdb_ks.so 555 root sys f none usr/lib/mdb/kvm/mpt.so 555 root sys +f none usr/lib/mdb/kvm/mr_sas.so 555 root sys f none usr/lib/mdb/kvm/nca.so 555 root sys f none usr/lib/mdb/kvm/nfs.so 555 root sys f none usr/lib/mdb/kvm/ptm.so 555 root sys
--- a/usr/src/pkgdefs/SUNWmdb/prototype_sparc Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/pkgdefs/SUNWmdb/prototype_sparc Fri Jun 05 09:34:31 2009 +0800 @@ -55,6 +55,7 @@ f none usr/lib/mdb/kvm/sparcv9/md.so 555 root sys f none usr/lib/mdb/kvm/sparcv9/mdb_ks.so 555 root sys f none usr/lib/mdb/kvm/sparcv9/mpt.so 555 root sys +f none usr/lib/mdb/kvm/sparcv9/mr_sas.so 555 root sys f none usr/lib/mdb/kvm/sparcv9/nca.so 555 root sys f none usr/lib/mdb/kvm/sparcv9/nfs.so 555 root sys s none usr/lib/mdb/kvm/sparcv9/pcisch.so=intr.so
--- a/usr/src/pkgdefs/SUNWmdbr/prototype_i386 Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/pkgdefs/SUNWmdbr/prototype_i386 Fri Jun 05 09:34:31 2009 +0800 @@ -43,6 +43,7 @@ f none kernel/kmdb/amd64/md 555 root sys f none kernel/kmdb/amd64/mdb_ds 555 root sys f none kernel/kmdb/amd64/mpt 555 root sys +f none kernel/kmdb/amd64/mr_sas 555 root sys f none kernel/kmdb/amd64/nca 555 root sys f none kernel/kmdb/amd64/neti 555 root sys f none kernel/kmdb/amd64/nfs 555 root sys @@ -75,6 +76,7 @@ f none kernel/kmdb/md 555 root sys f none kernel/kmdb/mdb_ds 555 root sys f none kernel/kmdb/mpt 555 root sys +f none kernel/kmdb/mr_sas 555 root sys f none kernel/kmdb/nca 555 root sys f none kernel/kmdb/neti 555 root sys f none kernel/kmdb/nfs 555 root sys
--- a/usr/src/pkgdefs/SUNWmdbr/prototype_sparc Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/pkgdefs/SUNWmdbr/prototype_sparc Fri Jun 05 09:34:31 2009 +0800 @@ -43,6 +43,7 @@ f none kernel/kmdb/sparcv9/md 555 root sys f none kernel/kmdb/sparcv9/mdb_ds 555 root sys f none kernel/kmdb/sparcv9/mpt 555 root sys +f none kernel/kmdb/sparcv9/mr_sas 555 root sys f none kernel/kmdb/sparcv9/nca 555 root sys f none kernel/kmdb/sparcv9/neti 555 root sys f none kernel/kmdb/sparcv9/nfs 555 root sys
--- a/usr/src/pkgdefs/SUNWmrsas/postinstall Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/pkgdefs/SUNWmrsas/postinstall Fri Jun 05 09:34:31 2009 +0800 @@ -124,7 +124,13 @@ # We should all use main PCI ID entries. -check_add_drv -i \ - '"pciex1000,78" - "pciex1000,79"' \ - -c scsi-self-identifying mr_sas +ARCH=`uname -p` +if [ ${ARCH} = "i386" ]; then + DRVALIAS='"pciex1000,78" "pciex1000,79"' +fi + +if [ ${ARCH} = "sparc" ]; then + DRVALIAS='"pci1000,78" "pci1000,79" "pciex1000,78" "pciex1000,79"' +fi + +check_add_drv -i "$DRVALIAS" -c scsi-self-identifying mr_sas
--- a/usr/src/pkgdefs/SUNWmrsas/prototype_com Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/pkgdefs/SUNWmrsas/prototype_com Fri Jun 05 09:34:31 2009 +0800 @@ -18,7 +18,7 @@ # # CDDL HEADER END # -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # @@ -37,6 +37,8 @@ i copyright i depend i pkginfo +i postinstall +i postremove # # source locations relative to the prototype file @@ -45,3 +47,4 @@ # d none kernel 0755 root sys d none kernel/drv 0755 root sys +f none kernel/drv/mr_sas.conf 0644 root sys
--- a/usr/src/pkgdefs/SUNWmrsas/prototype_i386 Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/pkgdefs/SUNWmrsas/prototype_i386 Fri Jun 05 09:34:31 2009 +0800 @@ -39,16 +39,10 @@ !include prototype_com # -# List files which are i386 specific here -i postinstall -i postremove - -# # source locations relative to the prototype file # # SUNWmrsas # f none kernel/drv/mr_sas 0755 root sys -f none kernel/drv/mr_sas.conf 0644 root sys d none kernel/drv/amd64 0755 root sys f none kernel/drv/amd64/mr_sas 0755 root sys
--- a/usr/src/pkgdefs/SUNWmrsas/prototype_sparc Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/pkgdefs/SUNWmrsas/prototype_sparc Fri Jun 05 09:34:31 2009 +0800 @@ -46,3 +46,4 @@ # SUNWmrsas # d none kernel/drv/sparcv9 0755 root sys +f none kernel/drv/sparcv9/mr_sas 0755 root sys
--- a/usr/src/uts/common/io/mr_sas/mr_sas.c Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/uts/common/io/mr_sas/mr_sas.c Fri Jun 05 09:34:31 2009 +0800 @@ -64,6 +64,7 @@ #include <sys/sunddi.h> #include <sys/atomic.h> #include <sys/signal.h> +#include <sys/byteorder.h> #include <sys/fs/dv_node.h> /* devfs_clean */ #include "mr_sas.h" @@ -81,6 +82,7 @@ */ static void *mrsas_state = NULL; static int debug_level_g = CL_NONE; +boolean_t mrsas_relaxed_ordering = B_TRUE; #pragma weak scsi_hba_open #pragma weak scsi_hba_close @@ -583,6 +585,11 @@ tran->tran_sync_pkt = mrsas_tran_sync_pkt; tran->tran_bus_config = mrsas_tran_bus_config; + if (mrsas_relaxed_ordering) + mrsas_generic_dma_attr.dma_attr_flags |= + DDI_DMA_RELAXED_ORDERING; + + tran_dma_attr = mrsas_generic_dma_attr; tran_dma_attr.dma_attr_sgllen = instance->max_num_sge; @@ -937,7 +944,6 @@ struct mrsas_instance *instance; struct mrsas_ioctl *ioctl; struct mrsas_aen aen; - int i; con_log(CL_ANN1, (CE_NOTE, "chkpnt:%s:%d", __func__, __LINE__)); instance = ddi_get_soft_state(mrsas_state, MINOR2INST(getminor(dev))); @@ -954,56 +960,44 @@ switch ((uint_t)cmd) { case MRSAS_IOCTL_FIRMWARE: - for (i = 0; i < sizeof (struct mrsas_ioctl); i++) { - if (ddi_copyin((uint8_t *)arg+i, - (uint8_t *)ioctl+i, 1, mode)) { - con_log(CL_ANN, (CE_WARN, "mrsas_ioctl " - "ERROR IOCTL copyin")); - kmem_free(ioctl, - sizeof (struct mrsas_ioctl)); - return (EFAULT); - } + if (ddi_copyin((void *)arg, ioctl, + sizeof (struct mrsas_ioctl), mode)) { + con_log(CL_ANN, (CE_WARN, "mrsas_ioctl: " + "ERROR IOCTL copyin")); + kmem_free(ioctl, sizeof (struct mrsas_ioctl)); + return (EFAULT); } + if (ioctl->control_code == MRSAS_DRIVER_IOCTL_COMMON) { rval = handle_drv_ioctl(instance, ioctl, mode); } else { rval = handle_mfi_ioctl(instance, ioctl, mode); } - for (i = 0; i < sizeof (struct mrsas_ioctl) - 1; i++) { - if (ddi_copyout((uint8_t *)ioctl+i, - (uint8_t *)arg+i, 1, mode)) { - con_log(CL_ANN, (CE_WARN, - "mrsas_ioctl: ddi_copyout " - "failed")); - rval = 1; - break; - } + + if (ddi_copyout((void *)ioctl, (void *)arg, + (sizeof (struct mrsas_ioctl) - 1), mode)) { + con_log(CL_ANN, (CE_WARN, + "mrsas_ioctl: copy_to_user failed")); + rval = 1; } break; case MRSAS_IOCTL_AEN: - for (i = 0; i < sizeof (struct mrsas_aen); i++) { - if (ddi_copyin((uint8_t *)arg+i, - (uint8_t *)&aen+i, 1, mode)) { - con_log(CL_ANN, (CE_WARN, - "mrsas_ioctl: " - "ERROR AEN copyin")); - kmem_free(ioctl, - sizeof (struct mrsas_ioctl)); - return (EFAULT); - } + if (ddi_copyin((void *) arg, &aen, + sizeof (struct mrsas_aen), mode)) { + con_log(CL_ANN, (CE_WARN, + "mrsas_ioctl: ERROR AEN copyin")); + kmem_free(ioctl, sizeof (struct mrsas_ioctl)); + return (EFAULT); } rval = handle_mfi_aen(instance, &aen); - for (i = 0; i < sizeof (struct mrsas_aen); i++) { - if (ddi_copyout((uint8_t *)&aen + i, - (uint8_t *)arg + i, 1, mode)) { - con_log(CL_ANN, (CE_WARN, - "mrsas_ioctl: " - "ddi_copyout failed")); - rval = 1; - break; - } + + if (ddi_copyout((void *) &aen, (void *)arg, + sizeof (struct mrsas_aen), mode)) { + con_log(CL_ANN, (CE_WARN, + "mrsas_ioctl: copy_to_user failed")); + rval = 1; } break; @@ -1562,7 +1556,7 @@ != DDI_SUCCESS) { mrsas_fm_ereport(instance, DDI_FM_DEVICE_NO_RESPONSE); ddi_fm_service_impact(instance->dip, DDI_SERVICE_LOST); - return (DDI_INTR_UNCLAIMED); + return (DDI_INTR_CLAIMED); } producer = ddi_get32(instance->mfi_internal_dma_obj.acc_handle, @@ -1574,7 +1568,7 @@ producer, consumer)); if (producer == consumer) { con_log(CL_ANN1, (CE_WARN, "producer = consumer case")); - return (DDI_INTR_UNCLAIMED); + return (DDI_INTR_CLAIMED); } mutex_enter(&instance->completed_pool_mtx); @@ -1706,7 +1700,6 @@ uint16_t sge_sz; uint32_t sgl_sz; uint32_t tot_frame_size; - struct mrsas_cmd *cmd; max_cmd = instance->max_fw_cmds; @@ -2015,9 +2008,15 @@ if (!instance->func_ptr->issue_cmd_in_poll_mode(instance, cmd)) { ret = 0; + ctrl_info->max_request_size = ddi_get32( + cmd->frame_dma_obj.acc_handle, &ci->max_request_size); + ctrl_info->ld_present_count = ddi_get16( + cmd->frame_dma_obj.acc_handle, &ci->ld_present_count); ddi_rep_get8(cmd->frame_dma_obj.acc_handle, - (uint8_t *)ctrl_info, (uint8_t *)ci, - sizeof (struct mrsas_ctrl_info), DDI_DEV_AUTOINCR); + (uint8_t *)(ctrl_info->product_name), + (uint8_t *)(ci->product_name), 80 * sizeof (char), + DDI_DEV_AUTOINCR); + /* should get more members of ci with ddi_get when needed */ } else { con_log(CL_ANN, (CE_WARN, "get_ctrl_info: Ctrl info failed")); ret = -1; @@ -2382,7 +2381,7 @@ dma_obj_t dcmd_dma_obj; struct mrsas_cmd *cmd; struct mrsas_dcmd_frame *dcmd; - + struct mrsas_evt_log_info *eli_tmp; cmd = get_mfi_pkt(instance); if (!cmd) { @@ -2439,10 +2438,9 @@ "failed to issue MRSAS_DCMD_CTRL_EVENT_GET_INFO"); ret = DDI_FAILURE; } else { - /* copy the data back into callers buffer */ - ddi_rep_get8(cmd->frame_dma_obj.acc_handle, (uint8_t *)eli, - (uint8_t *)dcmd_dma_obj.buffer, - sizeof (struct mrsas_evt_log_info), DDI_DEV_AUTOINCR); + eli_tmp = (struct mrsas_evt_log_info *)dcmd_dma_obj.buffer; + eli->newest_seq_num = ddi_get32(cmd->frame_dma_obj.acc_handle, + &eli_tmp->newest_seq_num); ret = DDI_SUCCESS; } @@ -2477,8 +2475,9 @@ /* register AEN with FW for latest sequence number plus 1 */ class_locale.members.reserved = 0; - class_locale.members.locale = MR_EVT_LOCALE_ALL; + class_locale.members.locale = LE_16(MR_EVT_LOCALE_ALL); class_locale.members.class = MR_EVT_CLASS_INFO; + class_locale.word = LE_32(class_locale.word); ret = register_mfi_aen(instance, eli.newest_seq_num + 1, class_locale.word); @@ -2679,7 +2678,7 @@ if (mlist_empty(&instance->completed_pool_list)) { mutex_exit(&instance->completed_pool_mtx); - return (DDI_INTR_UNCLAIMED); + return (DDI_INTR_CLAIMED); } instance->softint_running = 1; @@ -2702,7 +2701,7 @@ DDI_SUCCESS) { mrsas_fm_ereport(instance, DDI_FM_DEVICE_NO_RESPONSE); ddi_fm_service_impact(instance->dip, DDI_SERVICE_LOST); - return (DDI_INTR_UNCLAIMED); + return (DDI_INTR_CLAIMED); } hdr = &cmd->frame->hdr; @@ -2822,7 +2821,7 @@ acmd->cmd_scblen - offsetof(struct scsi_arq_status, sts_sensedata), DDI_DEV_AUTOINCR); - } + } break; case MFI_STAT_LD_OFFLINE: case MFI_STAT_DEVICE_NOT_FOUND: @@ -3896,7 +3895,7 @@ model = ddi_model_convert_from(mode & FMODELS); if (model == DDI_MODEL_ILP32) { con_log(CL_ANN1, (CE_NOTE, - "handle_drv_ioctl: DDI_MODEL_ILP32")); + "issue_mfi_smp: DDI_MODEL_ILP32")); sge32 = &smp->sgl[0].sge32[0]; ddi_put32(acc_handle, &sge32[0].length, response_xferlen); @@ -3908,7 +3907,7 @@ } else { #ifdef _ILP32 con_log(CL_ANN1, (CE_NOTE, - "handle_drv_ioctl: DDI_MODEL_ILP32")); + "issue_mfi_smp: DDI_MODEL_ILP32")); sge32 = &smp->sgl[0].sge32[0]; ddi_put32(acc_handle, &sge32[0].length, response_xferlen); ddi_put32(acc_handle, &sge32[0].phys_addr, @@ -4252,19 +4251,16 @@ "MRSAS_DRIVER_IOCTL_DRIVER_VERSION")); fill_up_drv_ver(&dv); - for (i = 0; i < xferlen; i++) { - if (ddi_copyout((uint8_t *)&dv + i, (uint8_t *)ubuf + i, - 1, mode)) { - con_log(CL_ANN, (CE_WARN, "handle_drv_ioctl: " - "MRSAS_DRIVER_IOCTL_DRIVER_VERSION" - " : copy to user space failed")); - kdcmd->cmd_status = 1; - rval = DDI_FAILURE; - break; - } + + if (ddi_copyout(&dv, ubuf, xferlen, mode)) { + con_log(CL_ANN, (CE_WARN, "handle_drv_ioctl: " + "MRSAS_DRIVER_IOCTL_DRIVER_VERSION : " + "copy to user space failed")); + kdcmd->cmd_status = 1; + rval = 1; + } else { + kdcmd->cmd_status = 0; } - if (i == xferlen) - kdcmd->cmd_status = 0; break; case MRSAS_DRIVER_IOCTL_PCI_INFORMATION: con_log(CL_ANN1, (CE_NOTE, "handle_drv_ioctl: " @@ -4292,21 +4288,16 @@ pci_conf_buf[i] = pci_config_get8(instance->pci_handle, i); } - for (i = 0; i < xferlen; i++) { - if (ddi_copyout((uint8_t *)&pi + i, (uint8_t *)ubuf + i, - 1, mode)) { - con_log(CL_ANN, (CE_WARN, "handle_drv_ioctl: " - "MRSAS_DRIVER_IOCTL_PCI_INFORMATION" - " : copy to user space failed")); - kdcmd->cmd_status = 1; - rval = DDI_FAILURE; - break; - } + + if (ddi_copyout(&pi, ubuf, xferlen, mode)) { + con_log(CL_ANN, (CE_WARN, "handle_drv_ioctl: " + "MRSAS_DRIVER_IOCTL_PCI_INFORMATION : " + "copy to user space failed")); + kdcmd->cmd_status = 1; + rval = 1; + } else { + kdcmd->cmd_status = 0; } - - if (i == xferlen) - kdcmd->cmd_status = 0; - break; default: con_log(CL_ANN, (CE_WARN, "handle_drv_ioctl: " @@ -4347,7 +4338,7 @@ hdr = (struct mrsas_header *)&ioctl->frame[0]; - switch (hdr->cmd) { + switch (ddi_get8(cmd->frame_dma_obj.acc_handle, &hdr->cmd)) { case MFI_CMD_OP_DCMD: rval = issue_mfi_dcmd(instance, ioctl, cmd, mode); break; @@ -4415,12 +4406,14 @@ * old and current and re-issue to the FW */ - curr_aen.word = class_locale_word; + curr_aen.word = LE_32(class_locale_word); + curr_aen.members.locale = LE_16(curr_aen.members.locale); aen_cmd = instance->aen_cmd; if (aen_cmd) { prev_aen.word = ddi_get32(aen_cmd->frame_dma_obj.acc_handle, &aen_cmd->frame->dcmd.mbox.w[1]); - + prev_aen.word = LE_32(prev_aen.word); + prev_aen.members.locale = LE_16(prev_aen.members.locale); /* * A class whose enum value is smaller is inclusive of all * higher values. If a PROGRESS (= -1) was previously @@ -4488,6 +4481,8 @@ ddi_put32(cmd->frame_dma_obj.acc_handle, &dcmd->opcode, MR_DCMD_CTRL_EVENT_WAIT); ddi_put32(cmd->frame_dma_obj.acc_handle, &dcmd->mbox.w[0], seq_num); + curr_aen.members.locale = LE_16(curr_aen.members.locale); + curr_aen.word = LE_32(curr_aen.word); ddi_put32(cmd->frame_dma_obj.acc_handle, &dcmd->mbox.w[1], curr_aen.word); ddi_put32(cmd->frame_dma_obj.acc_handle, &dcmd->sgl.sge32[0].phys_addr, @@ -4723,6 +4718,7 @@ intr_ack_ppc(struct mrsas_instance *instance) { uint32_t status; + int ret = DDI_INTR_CLAIMED; con_log(CL_ANN1, (CE_NOTE, "intr_ack_ppc: called")); @@ -4732,9 +4728,17 @@ con_log(CL_ANN1, (CE_NOTE, "intr_ack_ppc: status = 0x%x", status)); if (!(status & MFI_REPLY_2108_MESSAGE_INTR)) { - return (DDI_INTR_UNCLAIMED); - } - + ret = DDI_INTR_UNCLAIMED; + } + + if (mrsas_check_acc_handle(instance->regmap_handle) != DDI_SUCCESS) { + ddi_fm_service_impact(instance->dip, DDI_SERVICE_UNAFFECTED); + ret = DDI_INTR_UNCLAIMED; + } + + if (ret == DDI_INTR_UNCLAIMED) { + return (ret); + } /* clear the interrupt by writing back the same value */ WR_OB_DOORBELL_CLEAR(status, instance); @@ -4743,7 +4747,7 @@ con_log(CL_ANN1, (CE_NOTE, "intr_ack_ppc: interrupt cleared")); - return (DDI_INTR_CLAIMED); + return (ret); } static int
--- a/usr/src/uts/common/io/mr_sas/mr_sas.h Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/uts/common/io/mr_sas/mr_sas.h Fri Jun 05 09:34:31 2009 +0800 @@ -37,7 +37,6 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - #ifndef _MR_SAS_H_ #define _MR_SAS_H_ @@ -51,8 +50,8 @@ /* * MegaRAID SAS2.0 Driver meta data */ -#define MRSAS_VERSION "LSIv2.0" -#define MRSAS_RELDATE "Jan 9, 2009" +#define MRSAS_VERSION "LSIv2.1" +#define MRSAS_RELDATE "May 11, 2009" #define MRSAS_TRUE 1 #define MRSAS_FALSE 0 @@ -1648,6 +1647,7 @@ #define DDI_VENDOR_LSI "LSI" #endif /* DDI_VENDOR_LSI */ +#ifndef KMDB_MODULE static int mrsas_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **); static int mrsas_attach(dev_info_t *, ddi_attach_cmd_t); static int mrsas_reset(dev_info_t *, ddi_reset_cmd_t); @@ -1758,6 +1758,7 @@ static int mrsas_service_evt(struct mrsas_instance *, int, int, int, uint64_t); static int mrsas_mode_sense_build(struct scsi_pkt *); +#endif /* KMDB_MODULE */ #ifdef __cplusplus }
--- a/usr/src/uts/common/io/mr_sas/mr_sas_list.h Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/uts/common/io/mr_sas/mr_sas_list.h Fri Jun 05 09:34:31 2009 +0800 @@ -70,7 +70,7 @@ (ptr)->next = (ptr); (ptr)->prev = (ptr); \ } - +#ifndef KMDB_MODULE /* * Insert a new entry between two known consecutive entries. * @@ -173,7 +173,7 @@ at->prev = last; } } - +#endif /* KMDB_MODULE */ /* * mlist_entry - get the struct for this entry
--- a/usr/src/uts/sparc/Makefile.sparc.shared Fri Jun 05 09:36:22 2009 +0800 +++ b/usr/src/uts/sparc/Makefile.sparc.shared Fri Jun 05 09:34:31 2009 +0800 @@ -257,6 +257,7 @@ DRV_KMODS += igb DRV_KMODS += ixgbe DRV_KMODS += vr +DRV_KMODS += mr_sas $(CLOSED_BUILD)CLOSED_DRV_KMODS += ixgb #
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/uts/sparc/mr_sas/Makefile Fri Jun 05 09:34:31 2009 +0800 @@ -0,0 +1,100 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# This makefile drives the production of the mr_sas driver kernel module. +# +# Sparc implementation architecture dependent +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Define the module and object file sets. +# +MODULE = mr_sas +OBJECTS = $(MR_SAS_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(MR_SAS_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) +CONF_SRCDIR = $(UTSBASE)/common/io/mr_sas + +# +# Include common rules. +# +include $(UTSBASE)/sparc/Makefile.sparc + +# +# Define targets +# +ALL_TARGET = $(BINARY) $(CONFMOD) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) + +# +# lint pass one enforcement +# +CFLAGS += $(CCVERBOSE) + +# +# Turn on doubleword alignment for 64 bit registers +# +CFLAGS += -dalign + +# +# Kernel Module Dependencies +# +LDFLAGS += -dy -Nmisc/scsi + +# +# Overrides +# + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/sparc/Makefile.targ