From 7ef2619b25c32ca28b6c37fd7f614c931a9dd4b3 Mon Sep 17 00:00:00 2001 From: Marco Peereboom Date: Sun, 21 Nov 2004 04:49:27 +0000 Subject: Fix theo's amd64 Fix vmware --- sys/dev/ic/mpt.c | 455 ++++++++++++++++++++++++++++++++++++++++++++++- sys/dev/ic/mpt_mpilib.h | 60 ++++--- sys/dev/ic/mpt_openbsd.c | 238 ++++++++++++++++--------- sys/dev/ic/mpt_openbsd.h | 54 +++++- 4 files changed, 694 insertions(+), 113 deletions(-) diff --git a/sys/dev/ic/mpt.c b/sys/dev/ic/mpt.c index c15e8968279..7ca95ec4805 100644 --- a/sys/dev/ic/mpt.c +++ b/sys/dev/ic/mpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt.c,v 1.13 2004/11/03 00:59:56 marco Exp $ */ +/* $OpenBSD: mpt.c,v 1.14 2004/11/21 04:49:25 marco Exp $ */ /* $NetBSD: mpt.c,v 1.4 2003/11/02 11:07:45 wiz Exp $ */ /* @@ -58,6 +58,11 @@ int mpt_wait_state(mpt_softc_t *, enum DB_STATE_BITS); int mpt_get_iocfacts(mpt_softc_t *, MSG_IOC_FACTS_REPLY *); int mpt_get_portfacts(mpt_softc_t *, MSG_PORT_FACTS_REPLY *); int mpt_send_ioc_init(mpt_softc_t *, u_int32_t); +void mpt_print_header(mpt_softc_t *, char *, fCONFIG_PAGE_HEADER *); +int mpt_read_config_info_mfg(mpt_softc_t *); +int mpt_read_config_info_iou(mpt_softc_t *); +int mpt_read_config_info_ioc(mpt_softc_t *); +int mpt_read_config_info_raid(mpt_softc_t *); int mpt_read_config_info_spi(mpt_softc_t *); int mpt_set_initial_config_spi(mpt_softc_t *); int mpt_send_port_enable(mpt_softc_t *, int); @@ -719,7 +724,20 @@ mpt_read_cfg_page(mpt_softc_t *mpt, int PageAddress, fCONFIG_PAGE_HEADER *hdr) } else if (cfgp->Header.PageType == MPI_CONFIG_PAGETYPE_SCSI_DEVICE && cfgp->Header.PageNumber == 1) { amt = sizeof (fCONFIG_PAGE_SCSI_DEVICE_1); + } else if (cfgp->Header.PageType == MPI_CONFIG_PAGETYPE_MANUFACTURING && + cfgp->Header.PageNumber == 0) { + amt = sizeof (fCONFIG_PAGE_MANUFACTURING_0); + } else if (cfgp->Header.PageType == MPI_CONFIG_PAGETYPE_IOC && + cfgp->Header.PageNumber == 2) { + amt = sizeof (fCONFIG_PAGE_IOC_2); + } else if (cfgp->Header.PageType == MPI_CONFIG_PAGETYPE_RAID_VOLUME && + cfgp->Header.PageNumber == 0) { + amt = sizeof (fCONFIG_PAGE_RAID_VOL_0); + } else if (cfgp->Header.PageType == MPI_CONFIG_PAGETYPE_RAID_PHYSDISK && + cfgp->Header.PageNumber == 0) { + amt = sizeof (fCONFIG_PAGE_RAID_PHYS_DISK_0); } + bcopy(((caddr_t)req->req_vbuf)+CFG_DATA_OFF, hdr, amt); mpt_free_request(mpt, req); return (0); @@ -810,6 +828,388 @@ mpt_write_cfg_page(mpt_softc_t *mpt, int PageAddress, fCONFIG_PAGE_HEADER *hdr) return (0); } +void +mpt_print_header(mpt_softc_t *mpt, char *s, fCONFIG_PAGE_HEADER *phdr) +{ + mpt_prt(mpt, "%s %x: %x %x %x %x", + s, + phdr->PageNumber, + phdr->PageType, + phdr->PageNumber, + phdr->PageLength, + phdr->PageVersion); +} + +/* + * Read manufacturing configuration information + */ +int +mpt_read_config_info_mfg(mpt_softc_t *mpt) +{ + int rv, i; + fCONFIG_PAGE_HEADER *phdr[5] = { + phdr[0] = &mpt->mpt_mfg_page0.Header, + phdr[1] = &mpt->mpt_mfg_page1.Header, + phdr[2] = &mpt->mpt_mfg_page2.Header, + phdr[3] = &mpt->mpt_mfg_page3.Header, + phdr[4] = &mpt->mpt_mfg_page4.Header + }; + + for (i = 0; i < 5 /* 5 pages total */; i++) { + /* retrieve MFG headers */ + rv = mpt_read_cfg_header(mpt, + MPI_CONFIG_PAGETYPE_MANUFACTURING, i, 0, phdr[i]); + if (rv) { + mpt_prt(mpt, "Could not retrieve Manufacturing Page " + "%i Header.", i); + return (-1); + } else if (mpt->verbose > 1) { + mpt_print_header(mpt, "Manufacturing Header Page", + phdr[i]); + } + + /* retrieve MFG config pages using retrieved headers */ + rv = mpt_read_cfg_page(mpt, i, phdr[i]); + if (rv) { + mpt_prt(mpt, "Could not retrieve manufacturing Page" + " %i", i); + return (-1); + } + } + + /* mpt->verbose = 2; */ + if (mpt->verbose > 1) { + mpt_prt(mpt, "Manufacturing Page 0 data: %s %s %s %s %s", + mpt->mpt_mfg_page0.ChipName, + mpt->mpt_mfg_page0.ChipRevision, + mpt->mpt_mfg_page0.BoardName, + mpt->mpt_mfg_page0.BoardAssembly, + mpt->mpt_mfg_page0.BoardTracerNumber); + + mpt_prt(mpt, "Manufacturing Page 1 data:"); + for (i = 0; + i < ((mpt->mpt_mfg_page1.Header.PageLength - 1)<< 2); i++) { + printf("%02x ", mpt->mpt_mfg_page1.VPD[i]); + } + printf("\n"); + + mpt_prt(mpt, "Manufacturing Page 2 data: %x %x", + mpt->mpt_mfg_page2.ChipId.PCIRevisionID, + mpt->mpt_mfg_page2.ChipId.DeviceID); + for (i = 0; + i < (mpt->mpt_mfg_page2.Header.PageLength - 2); i++) { + printf("%08x ", mpt->mpt_mfg_page2.HwSettings[i]); + } + printf("\n"); + + mpt_prt(mpt, "Manufacturing Page 3 data: %x %x", + mpt->mpt_mfg_page3.ChipId.PCIRevisionID, + mpt->mpt_mfg_page3.ChipId.DeviceID); + for (i = 0; + i < (mpt->mpt_mfg_page3.Header.PageLength - 2); i++) { + printf("%08x ", mpt->mpt_mfg_page3.Info[i]); + } + printf("\n"); + + mpt_prt(mpt, "Manufacturing Page 4 data: %x %x %x %x %x", + mpt->mpt_mfg_page4.InfoSize1, + mpt->mpt_mfg_page4.InfoOffset1, + mpt->mpt_mfg_page4.InfoSize0, + mpt->mpt_mfg_page4.InfoOffset0, + mpt->mpt_mfg_page4.InquirySize, + mpt->mpt_mfg_page4.ISVolumeSettings, + mpt->mpt_mfg_page4.IMEVolumeSettings, + mpt->mpt_mfg_page4.IMVolumeSettings); + for (i = 0; i < sizeof(mpt->mpt_mfg_page4.InquiryData); i++) { + printf("%02x ", mpt->mpt_mfg_page4.InquiryData[i]); + } + printf("\n"); + } + /* mpt->verbose = 1; */ + + return (0); +} + +/* + * Read IO Unit configuration information + */ +int +mpt_read_config_info_iou(mpt_softc_t *mpt) +{ + int rv, i; + + fCONFIG_PAGE_HEADER *phdr[4] = { + phdr[0] = &mpt->mpt_iou_page0.Header, + phdr[1] = &mpt->mpt_iou_page1.Header, + phdr[2] = &mpt->mpt_iou_page2.Header, + phdr[3] = &mpt->mpt_iou_page2.Header, + }; + + for (i = 0; i < 4 /* 4 pages total */; i++) { + /* retrieve IO Unit headers */ + rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_IO_UNIT, i, + 0, phdr[i]); + if (rv) { + mpt_prt(mpt, "Could not retrieve IO Unit Page %i " + "header.", i); + return (-1); + } else if (mpt->verbose > 1) { + mpt_print_header(mpt, "IO Unit Header Page", phdr[i]); + } + + /* retrieve IO Unit config pages using retrieved headers */ + rv = mpt_read_cfg_page(mpt, i, phdr[i]); + if (rv) { + mpt_prt(mpt, "Could not retrieve IO Unit Page %i", i); + return (-1); + } + + if (i == 0 && + mpt->mpt_iou_page0.UniqueValue.High == 0xdeadbeef && + mpt->mpt_iou_page0.UniqueValue.Low == 0xdeadbeef) + { + /* vmware returns a lot of dead beef in page 0 */ + mpt->vmware = 1; + } + } + + /* mpt->verbose = 2; */ + if (mpt->verbose > 1) { + mpt_prt(mpt, "IO Unit Page 0 data: %llx", + mpt->mpt_iou_page0.UniqueValue); + + mpt_prt(mpt, "IO Unit Page 1 data: %x", + mpt->mpt_iou_page1.Flags); + + mpt_prt(mpt, "IO Unit Page 2 data: %x %x %x %x %x %x", + mpt->mpt_iou_page2.Flags, + mpt->mpt_iou_page2.BiosVersion, + mpt->mpt_iou_page2.AdapterOrder[0], + mpt->mpt_iou_page2.AdapterOrder[1], + mpt->mpt_iou_page2.AdapterOrder[2], + mpt->mpt_iou_page2.AdapterOrder[3]); + } + /* mpt->verbose = 1; */ + + return (0); +} + +/* + * Read IOC configuration information + */ +int +mpt_read_config_info_ioc(mpt_softc_t *mpt) +{ + int rv, i; + fCONFIG_PAGE_HEADER *phdr[5] = { + phdr[0] = &mpt->mpt_ioc_page0.Header, + phdr[1] = &mpt->mpt_ioc_page1.Header, + phdr[2] = &mpt->mpt_ioc_page2.Header, + phdr[3] = &mpt->mpt_ioc_page3.Header, + phdr[4] = &mpt->mpt_ioc_page4.Header + }; + + for (i = 0; i < 5 /* 5 pages total */; i++) { + /* retrieve IOC headers */ + rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_IOC, i, + 0, phdr[i]); + if (rv) { + mpt_prt(mpt, "Could not retrieve IOC Page %i header.", + i); + return (-1); + } else if (mpt->verbose > 1) { + mpt_print_header(mpt, "IOC Header Page", phdr[i]); + } + + /* retrieve IOC config pages using retrieved headers */ + rv = mpt_read_cfg_page(mpt, i, phdr[i]); + if (rv) { + mpt_prt(mpt, "Could not retrieve IOC Page %i", i); + return (-1); + } + } + + /* mpt->verbose = 2; */ + if (mpt->verbose > 1) { + mpt_prt(mpt, "IOC Page 0 data: %x %x %x %x %x %x %x %x", + mpt->mpt_ioc_page0.TotalNVStore, + mpt->mpt_ioc_page0.FreeNVStore, + mpt->mpt_ioc_page0.DeviceID, + mpt->mpt_ioc_page0.VendorID, + mpt->mpt_ioc_page0.RevisionID, + mpt->mpt_ioc_page0.ClassCode, + mpt->mpt_ioc_page0.SubsystemID, + mpt->mpt_ioc_page0.SubsystemVendorID + ); + + mpt_prt(mpt, "IOC Page 1 data: %x %x %x", + mpt->mpt_ioc_page1.Flags, + mpt->mpt_ioc_page1.CoalescingTimeout, + mpt->mpt_ioc_page1.CoalescingDepth); + + mpt_prt(mpt, "IOC Page 2 data: %x %x %x %x %x", + mpt->mpt_ioc_page2.CapabilitiesFlags, + mpt->mpt_ioc_page2.MaxPhysDisks, + mpt->mpt_ioc_page2.NumActivePhysDisks, + mpt->mpt_ioc_page2.MaxVolumes, + mpt->mpt_ioc_page2.NumActiveVolumes); + + /* FIXME: move this to attach */ + if (mpt->mpt_ioc_page2.MaxVolumes > + MPI_IOC_PAGE_2_RAID_VOLUME_MAX) { + /* complain */ + } + for (i = 0; i < mpt->mpt_ioc_page2.MaxVolumes; i++) { + mpt_prt(mpt, "IOC Page 2 RAID Volume %x %x %x %x %x", + mpt->mpt_ioc_page2.RaidVolume[i].VolumeType, + mpt->mpt_ioc_page2.RaidVolume[i].VolumePageNumber, + mpt->mpt_ioc_page2.RaidVolume[i].VolumeIOC, + mpt->mpt_ioc_page2.RaidVolume[i].VolumeBus, + mpt->mpt_ioc_page2.RaidVolume[i].VolumeID); + } + + mpt_prt(mpt, "IOC Page 3 data: %x ", + mpt->mpt_ioc_page3.NumPhysDisks); + + for (i = 0; i < mpt->mpt_ioc_page3.NumPhysDisks; i++) { + mpt_prt(mpt, "IOC Page 3 Physical Disk: %x %x %x %x", + mpt->mpt_ioc_page3.PhysDisk[i].PhysDiskNum, + mpt->mpt_ioc_page3.PhysDisk[i].PhysDiskIOC, + mpt->mpt_ioc_page3.PhysDisk[i].PhysDiskBus, + mpt->mpt_ioc_page3.PhysDisk[i].PhysDiskID); + } + + mpt_prt(mpt, "IOC Page 4 data: %x %x", + mpt->mpt_ioc_page4.MaxSEP, + mpt->mpt_ioc_page4.ActiveSEP); + + for (i = 0; i < mpt->mpt_ioc_page4.MaxSEP; i++) { + mpt_prt(mpt, "IOC Page 4 SEP: %x %x", + mpt->mpt_ioc_page4.SEP[i].SEPTargetID, + mpt->mpt_ioc_page4.SEP[i].SEPBus); + } + } + /* mpt->verbose = 1; */ + + return (0); +} + +/* + * Read RAID Volume pages + */ +int +mpt_read_config_info_raid(mpt_softc_t *mpt) +{ + int rv, i; + + /* retrieve raid volume headers */ + rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_RAID_VOLUME, 0, + 0, &mpt->mpt_raidvol_page0.Header); + if (rv) { + mpt_prt(mpt, "Could not retrieve RAID Volume Page 0 Header"); + return (-1); + } else if (mpt->verbose > 1) { + mpt_print_header(mpt, "RAID Volume Header Page", + &mpt->mpt_raidvol_page0.Header); + } + + /* retrieve raid volume page using retrieved headers */ + rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_raidvol_page0.Header); + if (rv) { + mpt_prt(mpt, "Could not retrieve RAID Volume Page 0"); + return (-1); + } + + /* retrieve raid physical disk header */ + rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_RAID_PHYSDISK, 0, + 0, &mpt->mpt_raidphys_page0.Header); + if (rv) { + mpt_prt(mpt, "Could not retrieve RAID Phys Disk Page 0 Header"); + return (-1); + } else if (mpt->verbose > 1) { + mpt_print_header(mpt, "RAID Volume Physical Disk Page", + &mpt->mpt_raidphys_page0.Header); + } + + /* retrieve raid physical disk page using retrieved headers */ + rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_raidphys_page0.Header); + if (rv) { + mpt_prt(mpt, "Could not retrieve RAID Phys Disk Page 0"); + return (-1); + } + + /* mpt->verbose = 2; */ + if (mpt->verbose > 1) { + mpt_prt(mpt, "RAID Volume Page 0 data: %x %x %x %x %x" + "%x %x %x %x", + mpt->mpt_raidvol_page0.VolumeType, + mpt->mpt_raidvol_page0.VolumeIOC, + mpt->mpt_raidvol_page0.VolumeBus, + mpt->mpt_raidvol_page0.VolumeID, + mpt->mpt_raidvol_page0.VolumeStatus, + mpt->mpt_raidvol_page0.VolumeSettings, + mpt->mpt_raidvol_page0.MaxLBA, + mpt->mpt_raidvol_page0.StripeSize, + mpt->mpt_raidvol_page0.NumPhysDisks); + + for (i = 0; i < mpt->mpt_raidvol_page0.NumPhysDisks; i++) { + mpt_prt(mpt, "RAID Volume Page 0 Physical Disk: %x %x", + mpt->mpt_raidvol_page0.PhysDisk[i].PhysDiskNum, + mpt->mpt_raidvol_page0.PhysDisk[i].PhysDiskMap); + } + printf("\n"); + } + + if (mpt->verbose > 1) { + mpt_prt(mpt, "RAID Phyical Disk Page 0 data: %x %x %x %x %x" + "%x %x %x", + mpt->mpt_raidphys_page0.PhysDiskNum, + mpt->mpt_raidphys_page0.PhysDiskIOC, + mpt->mpt_raidphys_page0.PhysDiskBus, + mpt->mpt_raidphys_page0.PhysDiskID, + mpt->mpt_raidphys_page0.PhysDiskSettings.SepID, + mpt->mpt_raidphys_page0.PhysDiskSettings.SepBus, + mpt->mpt_raidphys_page0.PhysDiskSettings.HotSparePool, + mpt->mpt_raidphys_page0.PhysDiskSettings.PhysDiskSettings); + + for (i = 0; + i < sizeof(mpt->mpt_raidphys_page0.DiskIdentifier); i++) { + printf("%02x ", + mpt->mpt_raidphys_page0.DiskIdentifier[i]); + } + + /* does them all */ + printf("\n"); + mpt_prt(mpt, "RAID Phyical Disk Page 0 data: %s", + mpt->mpt_raidphys_page0.InquiryData.VendorID); + + for (i = 0; + i < sizeof(mpt->mpt_raidphys_page0.InquiryData.Info); i++) { + printf("%02x ", + mpt->mpt_raidphys_page0.InquiryData.Info[i]); + } + + printf("\n"); + mpt_prt(mpt, "RAID Phyical Disk Page 0 data: %x %x %x" + "%x %x %x %x %x %x %x %x", + mpt->mpt_raidphys_page0.PhysDiskStatus.Flags, + mpt->mpt_raidphys_page0.PhysDiskStatus.State, + mpt->mpt_raidphys_page0.MaxLBA, + mpt->mpt_raidphys_page0.ErrorData.ErrorSenseKey, + mpt->mpt_raidphys_page0.ErrorData.ErrorCdbByte, + mpt->mpt_raidphys_page0.ErrorData.ErrorASCQ, + mpt->mpt_raidphys_page0.ErrorData.ErrorASC, + mpt->mpt_raidphys_page0.ErrorData.ErrorCount, + mpt->mpt_raidphys_page0.ErrorData.SmartASCQ, + mpt->mpt_raidphys_page0.ErrorData.SmartASC, + mpt->mpt_raidphys_page0.ErrorData.SmartCount + ); + } + /* mpt->verbose = 1; */ + + return (0); +} + /* * Read SCSI configuration information */ @@ -1277,6 +1677,59 @@ mpt_init(mpt_softc_t *mpt, u_int32_t who) } } + /* + * Read IO Unit pages + */ + if (mpt_read_config_info_iou(mpt)) { + mpt_prt(mpt, "could not retrieve IO Unit pages"); + return (EIO); + } + + /* + * if the vmware flag is set skip page retrival since it does + * not support all of them. + */ + if (mpt->vmware) { + mpt->verbose = 2; + if (mpt->verbose > 1) + mpt_prt(mpt, "running in vmware, skipping page" + "retrieval"); + mpt->verbose = 1; + } + else { + /* + * Read manufacturing pages + */ + if (mpt_read_config_info_mfg(mpt)) { + mpt_prt(mpt, "could not retrieve manufacturing" + "pages"); + return (EIO); + } + + /* + * Read IOC pages + */ + if (mpt_read_config_info_ioc(mpt)) { + mpt_prt(mpt, "could not retrieve IOC pages"); + return (EIO); + } + mpt->im_support = mpt->mpt_ioc_page2.CapabilitiesFlags & + (MPI_IOCPAGE2_CAP_FLAGS_IS_SUPPORT | + MPI_IOCPAGE2_CAP_FLAGS_IME_SUPPORT | + MPI_IOCPAGE2_CAP_FLAGS_IM_SUPPORT); + + /* + * Read RAID pages if we have IM/IME/IS volumes + */ + if (mpt->mpt_ioc_page2.NumActiveVolumes) { + if (mpt_read_config_info_raid(mpt)) { + mpt_prt(mpt, "could not retrieve RAID" + "pages"); + return (EIO); + } + } + } + /* * Now enable the port */ diff --git a/sys/dev/ic/mpt_mpilib.h b/sys/dev/ic/mpt_mpilib.h index f9e632547db..2bf82de454b 100644 --- a/sys/dev/ic/mpt_mpilib.h +++ b/sys/dev/ic/mpt_mpilib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt_mpilib.h,v 1.4 2004/11/03 00:59:56 marco Exp $ */ +/* $OpenBSD: mpt_mpilib.h,v 1.5 2004/11/21 04:49:25 marco Exp $ */ /* $NetBSD: mpt_mpilib.h,v 1.2 2003/04/16 23:24:01 thorpej Exp $ */ /* @@ -1097,7 +1097,7 @@ typedef struct _MSG_CONFIG_REPLY typedef struct _CONFIG_PAGE_MANUFACTURING_0 { - fCONFIG_PAGE_HEADER Header; /* 00h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ U8 ChipName[16]; /* 04h */ U8 ChipRevision[8]; /* 14h */ U8 BoardName[16]; /* 1Ch */ @@ -1112,7 +1112,7 @@ typedef struct _CONFIG_PAGE_MANUFACTURING_0 typedef struct _CONFIG_PAGE_MANUFACTURING_1 { - fCONFIG_PAGE_HEADER Header; /* 00h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ U8 VPD[256]; /* 04h */ } fCONFIG_PAGE_MANUFACTURING_1, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_1, ManufacturingPage1_t, MPI_POINTER pManufacturingPage1_t; @@ -1134,12 +1134,14 @@ typedef struct _MPI_CHIP_REVISION_ID * one and check Header.PageLength at runtime. */ #ifndef MPI_MAN_PAGE_2_HW_SETTINGS_WORDS -#define MPI_MAN_PAGE_2_HW_SETTINGS_WORDS (1) +/*#define MPI_MAN_PAGE_2_HW_SETTINGS_WORDS (1)*/ +/* MP: is this right? */ +#define MPI_MAN_PAGE_2_HW_SETTINGS_WORDS (16) #endif typedef struct _CONFIG_PAGE_MANUFACTURING_2 { - fCONFIG_PAGE_HEADER Header; /* 00h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ MPI_CHIP_REVISION_ID ChipId; /* 04h */ U32 HwSettings[MPI_MAN_PAGE_2_HW_SETTINGS_WORDS];/* 08h */ } fCONFIG_PAGE_MANUFACTURING_2, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_2, @@ -1153,12 +1155,14 @@ typedef struct _CONFIG_PAGE_MANUFACTURING_2 * one and check Header.PageLength at runtime. */ #ifndef MPI_MAN_PAGE_3_INFO_WORDS -#define MPI_MAN_PAGE_3_INFO_WORDS (1) +/*#define MPI_MAN_PAGE_3_INFO_WORDS (1)*/ +/* MP: is this right? */ +#define MPI_MAN_PAGE_3_INFO_WORDS (16) #endif typedef struct _CONFIG_PAGE_MANUFACTURING_3 { - fCONFIG_PAGE_HEADER Header; /* 00h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ MPI_CHIP_REVISION_ID ChipId; /* 04h */ U32 Info[MPI_MAN_PAGE_3_INFO_WORDS];/* 08h */ } fCONFIG_PAGE_MANUFACTURING_3, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_3, @@ -1169,7 +1173,7 @@ typedef struct _CONFIG_PAGE_MANUFACTURING_3 typedef struct _CONFIG_PAGE_MANUFACTURING_4 { - fCONFIG_PAGE_HEADER Header; /* 00h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ U32 Reserved1; /* 04h */ U8 InfoOffset0; /* 08h */ U8 InfoSize0; /* 09h */ @@ -1194,7 +1198,7 @@ typedef struct _CONFIG_PAGE_MANUFACTURING_4 typedef struct _CONFIG_PAGE_IO_UNIT_0 { - fCONFIG_PAGE_HEADER Header; /* 00h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ U64 UniqueValue; /* 04h */ } fCONFIG_PAGE_IO_UNIT_0, MPI_POINTER PTR_CONFIG_PAGE_IO_UNIT_0, IOUnitPage0_t, MPI_POINTER pIOUnitPage0_t; @@ -1204,7 +1208,7 @@ typedef struct _CONFIG_PAGE_IO_UNIT_0 typedef struct _CONFIG_PAGE_IO_UNIT_1 { - fCONFIG_PAGE_HEADER Header; /* 00h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ U32 Flags; /* 04h */ } fCONFIG_PAGE_IO_UNIT_1, MPI_POINTER PTR_CONFIG_PAGE_IO_UNIT_1, IOUnitPage1_t, MPI_POINTER pIOUnitPage1_t; @@ -1234,7 +1238,7 @@ typedef struct _MPI_ADAPTER_INFO typedef struct _CONFIG_PAGE_IO_UNIT_2 { - fCONFIG_PAGE_HEADER Header; /* 00h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ U32 Flags; /* 04h */ U32 BiosVersion; /* 08h */ MPI_ADAPTER_INFO AdapterOrder[4]; /* 0Ch */ @@ -1329,12 +1333,14 @@ typedef struct _CONFIG_PAGE_IOC_2_RAID_VOL * one and check Header.PageLength at runtime. */ #ifndef MPI_IOC_PAGE_2_RAID_VOLUME_MAX -#define MPI_IOC_PAGE_2_RAID_VOLUME_MAX (1) +/* #define MPI_IOC_PAGE_2_RAID_VOLUME_MAX (1) */ +/* MP: is this the right way of doing this? */ +#define MPI_IOC_PAGE_2_RAID_VOLUME_MAX (16) #endif typedef struct _CONFIG_PAGE_IOC_2 { - fCONFIG_PAGE_HEADER Header; /* 00h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ U32 CapabilitiesFlags; /* 04h */ U8 NumActiveVolumes; /* 08h */ U8 MaxVolumes; /* 09h */ @@ -1376,7 +1382,9 @@ typedef struct _IOC_3_PHYS_DISK * one and check Header.PageLength at runtime. */ #ifndef MPI_IOC_PAGE_3_PHYSDISK_MAX -#define MPI_IOC_PAGE_3_PHYSDISK_MAX (1) +/* #define MPI_IOC_PAGE_3_PHYSDISK_MAX (1) */ +/* MP: is this the right way of doing this? */ +#define MPI_IOC_PAGE_3_PHYSDISK_MAX (16) #endif typedef struct _CONFIG_PAGE_IOC_3 @@ -1404,13 +1412,15 @@ typedef struct _IOC_4_SEP * Host code (drivers, BIOS, utilities, etc.) should leave this define set to * one and check Header.PageLength at runtime. */ -#ifndef MPI_IOC_PAGE_4_SEP_MAX -#define MPI_IOC_PAGE_4_SEP_MAX (1) +#ifndef MPI_IOC_PAGE_4_SEP_MAX +/* #define MPI_IOC_PAGE_4_SEP_MAX (1) */ +/* MP: is this the right way of doing this? */ +#define MPI_IOC_PAGE_4_SEP_MAX (16) #endif typedef struct _CONFIG_PAGE_IOC_4 { - fCONFIG_PAGE_HEADER Header; /* 00h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ U8 ActiveSEP; /* 04h */ U8 MaxSEP; /* 05h */ U16 Reserved1; /* 06h */ @@ -1427,9 +1437,9 @@ typedef struct _CONFIG_PAGE_IOC_4 typedef struct _CONFIG_PAGE_SCSI_PORT_0 { - fCONFIG_PAGE_HEADER Header; /* 00h */ - U32 Capabilities; /* 04h */ - U32 PhysicalInterface; /* 08h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ + U32 Capabilities; /* 04h */ + U32 PhysicalInterface; /* 08h */ } fCONFIG_PAGE_SCSI_PORT_0, MPI_POINTER PTR_CONFIG_PAGE_SCSI_PORT_0, SCSIPortPage0_t, MPI_POINTER pSCSIPortPage0_t; @@ -1451,9 +1461,9 @@ typedef struct _CONFIG_PAGE_SCSI_PORT_0 typedef struct _CONFIG_PAGE_SCSI_PORT_1 { - fCONFIG_PAGE_HEADER Header; /* 00h */ - U32 Configuration; /* 04h */ - U32 OnBusTimerValue; /* 08h */ + fCONFIG_PAGE_HEADER Header; /* 00h */ + U32 Configuration; /* 04h */ + U32 OnBusTimerValue; /* 08h */ } fCONFIG_PAGE_SCSI_PORT_1, MPI_POINTER PTR_CONFIG_PAGE_SCSI_PORT_1, SCSIPortPage1_t, MPI_POINTER pSCSIPortPage1_t; @@ -2014,7 +2024,9 @@ typedef struct _RAID_VOL0_SETTINGS * one and check Header.PageLength at runtime. */ #ifndef MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX -#define MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX (1) +/* #define MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX (1) */ +/* MP: is this the right way of doing this? */ +#define MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX (16) #endif typedef struct _CONFIG_PAGE_RAID_VOL_0 diff --git a/sys/dev/ic/mpt_openbsd.c b/sys/dev/ic/mpt_openbsd.c index 7b61077f0b4..9111689d25a 100644 --- a/sys/dev/ic/mpt_openbsd.c +++ b/sys/dev/ic/mpt_openbsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt_openbsd.c,v 1.18 2004/11/03 00:59:56 marco Exp $ */ +/* $OpenBSD: mpt_openbsd.c,v 1.19 2004/11/21 04:49:26 marco Exp $ */ /* $NetBSD: mpt_netbsd.c,v 1.7 2003/07/14 15:47:11 lukem Exp $ */ /* @@ -119,6 +119,9 @@ void mpt_event_notify_reply(mpt_softc_t *, MSG_EVENT_NOTIFY_REPLY *); int mpt_action(struct scsi_xfer *); void mpt_minphys(struct buf *); +#if NBIO > 0 +int mpt_ioctl(struct device *, u_long, caddr_t); +#endif struct cfdriver mpt_cd = { NULL, "mpt", DV_DULL }; @@ -188,10 +191,12 @@ mpt_ppr(mpt_softc_t *mpt, struct scsi_link *sc_link, int speed, int flags) /* * Set the synchronous parameters for the target. */ - page1.RequestedParameters &= ~(MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK | + page1.RequestedParameters &= + ~(MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK | MPI_SCSIDEVPAGE1_RP_MAX_SYNC_OFFSET_MASK | MPI_SCSIDEVPAGE1_RP_DT | MPI_SCSIDEVPAGE1_RP_QAS | MPI_SCSIDEVPAGE1_RP_IU); + if (!(sc_link->quirks & SDEV_NOSYNC)) { int factor, offset, np; @@ -204,18 +209,18 @@ mpt_ppr(mpt_softc_t *mpt, struct scsi_link *sc_link, int speed, int flags) factor = (mpt->mpt_port_page0.Capabilities >> 8) & 0xff; offset = (mpt->mpt_port_page0.Capabilities >> 16) & 0xff; np = 0; - + switch (speed) { - case U320: - /* do nothing */ - break; + case U320: + /* do nothing */ + break; - case U160: - factor = 0x09; /* force U160 */ - break; - - case U80: - factor = 0x0a; /* force U80 */ + case U160: + factor = 0x09; /* force U160 */ + break; + + case U80: + factor = 0x0a; /* force U80 */ } if (factor < 0x9) { @@ -271,20 +276,24 @@ mpt_ppr(mpt_softc_t *mpt, struct scsi_link *sc_link, int speed, int flags) if (mpt->verbose > 1) { mpt_prt(mpt, - "SPI Tgt %d Page 0: NParms %x Information %x", - sc_link->target, - page0.NegotiatedParameters, page0.Information); + "SPI Tgt %d Page 0: NParms %x Information %x", + sc_link->target, + page0.NegotiatedParameters, page0.Information); } if (!(page0.NegotiatedParameters & 0x07) && (speed == U320)) { - /* if lowest 3 aren't set the PPR probably failed, retry with other parameters */ + /* + * if lowest 3 aren't set the PPR probably failed, + * retry with other parameters + */ if (mpt->verbose > 1) { mpt_prt(mpt, "U320 PPR failed"); } return 0; } - if ((((page0.NegotiatedParameters >> 8) & 0xff) > 0x09) && (speed == U160)) { + if ((((page0.NegotiatedParameters >> 8) & 0xff) > 0x09) && + (speed == U160)) { /* if transfer period > 0x09 then U160 PPR failed, retry */ if (mpt->verbose > 1) { mpt_prt(mpt, "U160 PPR failed"); @@ -293,55 +302,56 @@ mpt_ppr(mpt_softc_t *mpt, struct scsi_link *sc_link, int speed, int flags) } /* - * Bit 3 - PPR rejected: The IOC sets this bit if the device rejects a PPR message. - * Bit 2 - WDTR Rejected: The IOC sets this bit if the device rejects a WDTR message. - * Bit 1 - SDTR Rejected: The IOC sets this bit if the device rejects a SDTR message. - * Bit 0 - 1 A SCSI SDTR, WDTR, or PPR negotiation has occurred with this device. + * Bit 3 - PPR rejected: IOC sets this if the device rejects PPR. + * Bit 2 - WDTR rejected: IOC sets this if the device rejects WDTR. + * Bit 1 - SDTR Rejected: IOC sets this if the device rejects SDTR. + * Bit 0 - 1 A SCSI SDTR, WDTR, or PPR negotiation has occurred. */ if (page0.Information & 0x0e) { /* target rejected PPR message */ mpt_prt(mpt, "Target %d rejected PPR message with %02x", - sc_link->target, - (uint8_t)page0.Information); + sc_link->target, + (uint8_t)page0.Information); + return 0; } /* print PPR results */ switch ((page0.NegotiatedParameters >> 8) & 0xff) { - case 0x08: - tp = 160; - break; - - case 0x09: - tp = 80; - break; - - case 0x0a: - tp = 40; - break; - - case 0x0b: - tp = 20; - break; - - case 0x0c: - tp = 10; - break; + case 0x08: + tp = 160; + break; - default: - tp = 0; + case 0x09: + tp = 80; + break; + + case 0x0a: + tp = 40; + break; + + case 0x0b: + tp = 20; + break; + + case 0x0c: + tp = 10; + break; + + default: + tp = 0; } mpt_prt(mpt, - "target %d %s at %dMHz width %dbit offset %d QAS %d DT %d IU %d", - sc_link->target, - tp ? "Synchronous" : "Asynchronous", - tp, - (page0.NegotiatedParameters & 0x20000000) ? 16 : 8, - (page0.NegotiatedParameters >> 16) & 0xff, - (page0.NegotiatedParameters & 0x04) ? 1 : 0, - (page0.NegotiatedParameters & 0x02) ? 1 : 0, - (page0.NegotiatedParameters & 0x01) ? 1 : 0); + "target %d %s at %dMHz width %dbit offset %d QAS %d DT %d IU %d", + sc_link->target, + tp ? "Synchronous" : "Asynchronous", + tp, + (page0.NegotiatedParameters & 0x20000000) ? 16 : 8, + (page0.NegotiatedParameters >> 16) & 0xff, + (page0.NegotiatedParameters & 0x04) ? 1 : 0, + (page0.NegotiatedParameters & 0x02) ? 1 : 0, + (page0.NegotiatedParameters & 0x01) ? 1 : 0); return 1; /* success */ } @@ -362,12 +372,14 @@ mpt_run_ppr(mpt_softc_t *mpt, int flags) dev = TAILQ_NEXT(dev, dv_list)) { if (dev->dv_parent == (struct device *)mpt) { /* found scsibus softc */ - buswidth = ((struct scsi_link *)&mpt->sc_link)->adapter_buswidth; + buswidth = ((struct scsi_link *)&mpt->sc_link)-> + adapter_buswidth; /* printf("mpt_softc: %x scsibus: %x buswidth: %d\n", - mpt, dev, buswidth); */ + * mpt, dev, buswidth); */ /* walk target list */ for (target = 0; target < buswidth; target++) { - sc_link = ((struct scsibus_softc *)dev)->sc_link[target][0]; + sc_link = ((struct scsibus_softc *)dev)-> + sc_link[target][0]; if ((sc_link != NULL)) { /* got a device! run PPR */ /* FIXME: skip CPU devices since they @@ -375,21 +387,23 @@ mpt_run_ppr(mpt_softc_t *mpt, int flags) /*if (device == cpu) { continue; }*/ - if (mpt_ppr(mpt, sc_link, U320, flags)) { - mpt->mpt_negotiated_speed[target] = U320; + if (mpt_ppr(mpt, sc_link, U320, flags)){ + mpt->mpt_negotiated_speed + [target] = U320; continue; } - if (mpt_ppr(mpt, sc_link, U160, flags)) { - mpt->mpt_negotiated_speed[target] = U160; + if (mpt_ppr(mpt, sc_link, U160, flags)){ + mpt->mpt_negotiated_speed + [target] = U160; continue; } if (mpt_ppr(mpt, sc_link, U80, flags)) { - mpt->mpt_negotiated_speed[target] = U80; + mpt->mpt_negotiated_speed + [target] = U80; continue; } - } /* sc_link */ } /* for target */ } /* if dev */ @@ -403,8 +417,6 @@ void mpt_attach(mpt_softc_t *mpt) { struct scsi_link *lptr = &mpt->sc_link; - struct _CONFIG_PAGE_IOC_2 iocp2; - int rv; mpt->bus = 0; /* XXX ?? */ @@ -432,29 +444,15 @@ mpt_attach(mpt_softc_t *mpt) mpt->verbose = 2; #endif - /* Read IOC page 2 to figure out if we have IM */ - rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_IOC, 2, - 0, &iocp2.Header); - if (rv) { - mpt_prt(mpt, "Could not retrieve IOC PAGE 2 to determine" - "RAID capabilities."); - } - else { - mpt->im_support = iocp2.CapabilitiesFlags & - (MPI_IOCPAGE2_CAP_FLAGS_IS_SUPPORT | - MPI_IOCPAGE2_CAP_FLAGS_IME_SUPPORT | - MPI_IOCPAGE2_CAP_FLAGS_IM_SUPPORT); +#if NBIO > 0 + if (bio_register(&mpt->mpt_dev, mpt_ioctl) != 0) + panic("%s: controller registration failed", + mpt->mpt_dev.dv_xname); +#endif - if (mpt->verbose > 1) { - mpt_prt(mpt, "IOC Page 2: %x %x %x %x %x", - iocp2.CapabilitiesFlags, - iocp2.NumActiveVolumes, - iocp2.MaxVolumes, - iocp2.NumActivePhysDisks, - iocp2.MaxPhysDisks); - mpt_prt(mpt, "IM support: %x", mpt->im_support); - } - } + mpt_prt(mpt, "IM support: %x", mpt->im_support); + /*mpt_prt(mpt, "IM support: %x %x", mpt->im_support, + mpt->mpt_ioc_page2.CapabilitiesFlags);*/ (void) config_found(&mpt->mpt_dev, lptr, scsiprint); @@ -1625,3 +1623,71 @@ mpt_free_fw_mem(mpt_softc_t *mpt) bus_dmamem_unmap(mpt->sc_dmat, (caddr_t)mpt->fw, mpt->fw_image_size); bus_dmamem_free(mpt->sc_dmat, &mpt->fw_seg, mpt->fw_rseg); } + +#if NBIO > 0 +int +mpt_ioctl(dev, cmd, addr) + struct device *dev; + u_long cmd; + caddr_t addr; +{ + int error = 0; + int rv; + struct mpt_dummy *dummy; + struct mpt_mfg0 *pmfg0; + fCONFIG_PAGE_MANUFACTURING_0 mfgp0; + mpt_softc_t *mpt = (mpt_softc_t *)dev; + + switch (cmd) { + case MPT_IOCTL_DUMMY: + dummy = (struct mpt_dummy *)addr; + if (mpt->verbose > 2) { + printf("%s: MPT_IOCTL_DUMMY %d\n", + dev->dv_xname, dummy->x++); + } + break; + case MPT_IOCTL_MFG0: + /* Retrieve Manufacturing Page 0 */ + mfgp0.Header.PageNumber = 0; + mfgp0.Header.PageType = MPI_CONFIG_PAGETYPE_MANUFACTURING; + rv = mpt_read_cfg_page(mpt, 0, &mfgp0.Header); + if (rv) { + mpt_prt(mpt, "Could not retrieve MFG PAGE 0."); + error = EINVAL; + } + else { + if (mpt->verbose > 2) { + printf("Chip name: %s\n", + mfgp0.ChipName); + printf("Chip Revision: %s\n", + mfgp0.ChipRevision); + printf("Board name: %s\n", + mfgp0.BoardName); + printf("Board assembly: %s\n", + mfgp0.BoardAssembly); + printf("Board tracer number: %s\n", + mfgp0.BoardTracerNumber); + } + pmfg0 = (struct mpt_mfg0 *)addr; + memcpy(&pmfg0->cpm0, &mfgp0, + sizeof(fCONFIG_PAGE_MANUFACTURING_0)); + } + break; + /* Retrieve Manufacturing Page 1 */ + case MPT_IOCTL_MFG1: + break; + /* Retrieve Manufacturing Page 2 */ + case MPT_IOCTL_MFG2: + break; + /* Retrieve Manufacturing Page 3 */ + case MPT_IOCTL_MFG3: + break; + /* Retrieve Manufacturing Page 4 */ + case MPT_IOCTL_MFG4: + break; + default: + error = EINVAL; + } + return (error); +} +#endif diff --git a/sys/dev/ic/mpt_openbsd.h b/sys/dev/ic/mpt_openbsd.h index e26af696bde..effe8034daf 100644 --- a/sys/dev/ic/mpt_openbsd.h +++ b/sys/dev/ic/mpt_openbsd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt_openbsd.h,v 1.13 2004/11/03 00:59:56 marco Exp $ */ +/* $OpenBSD: mpt_openbsd.h,v 1.14 2004/11/21 04:49:26 marco Exp $ */ /* $NetBSD: mpt_netbsd.h,v 1.2 2003/04/16 23:02:14 thorpej Exp $ */ /* @@ -106,6 +106,7 @@ #include #include #include +#include #include #include #include @@ -120,8 +121,12 @@ #include #include +#include +#include #include +#include "bio.h" + /* * macro to convert from milliseconds to hz without integer overflow * Default version using only 32bits arithmetics. @@ -216,7 +221,7 @@ typedef struct mpt_softc { uint16_t mpt_ini_id; /* Device configuration information */ - union { + struct { struct mpt_spi_cfg { fCONFIG_PAGE_SCSI_PORT_0 _port_page0; fCONFIG_PAGE_SCSI_PORT_1 _port_page1; @@ -245,6 +250,50 @@ typedef struct mpt_softc { struct mpt_fc_cfg { uint8_t nada; } fc; + + struct mpt_mfg_cfg { + fCONFIG_PAGE_MANUFACTURING_0 _mfg_page0; + fCONFIG_PAGE_MANUFACTURING_1 _mfg_page1; + fCONFIG_PAGE_MANUFACTURING_2 _mfg_page2; + fCONFIG_PAGE_MANUFACTURING_3 _mfg_page3; + fCONFIG_PAGE_MANUFACTURING_4 _mfg_page4; + } mfg; +#define mpt_mfg_page0 cfg.mfg._mfg_page0 +#define mpt_mfg_page1 cfg.mfg._mfg_page1 +#define mpt_mfg_page2 cfg.mfg._mfg_page2 +#define mpt_mfg_page3 cfg.mfg._mfg_page3 +#define mpt_mfg_page4 cfg.mfg._mfg_page4 + + struct mpt_iou_cfg { + fCONFIG_PAGE_IO_UNIT_0 _iou_page0; + fCONFIG_PAGE_IO_UNIT_1 _iou_page1; + fCONFIG_PAGE_IO_UNIT_2 _iou_page2; + fCONFIG_PAGE_IO_UNIT_3 _iou_page3; + } iou; +#define mpt_iou_page0 cfg.iou._iou_page0 +#define mpt_iou_page1 cfg.iou._iou_page1 +#define mpt_iou_page2 cfg.iou._iou_page2 +#define mpt_iou_page3 cfg.iou._iou_page3 + + struct mpt_ioc_cfg { + fCONFIG_PAGE_IOC_0 _ioc_page0; + fCONFIG_PAGE_IOC_1 _ioc_page1; + fCONFIG_PAGE_IOC_2 _ioc_page2; + fCONFIG_PAGE_IOC_3 _ioc_page3; + fCONFIG_PAGE_IOC_4 _ioc_page4; + } ioc; +#define mpt_ioc_page0 cfg.ioc._ioc_page0 +#define mpt_ioc_page1 cfg.ioc._ioc_page1 +#define mpt_ioc_page2 cfg.ioc._ioc_page2 +#define mpt_ioc_page3 cfg.ioc._ioc_page3 +#define mpt_ioc_page4 cfg.ioc._ioc_page4 + + struct mpt_raid_cfg { + fCONFIG_PAGE_RAID_VOL_0 _raidvol_page0; + fCONFIG_PAGE_RAID_PHYS_DISK_0 _raidphys_page0; + } raid; +#define mpt_raidvol_page0 cfg.raid._raidvol_page0 +#define mpt_raidphys_page0 cfg.raid._raidphys_page0 } cfg; bus_space_tag_t sc_st; @@ -272,6 +321,7 @@ typedef struct mpt_softc { uint32_t timeouts; /* timeout count */ uint32_t success; /* success after timeout */ + uint8_t vmware; /* If set, running in vmware */ uint8_t upload_fw; /* If set, do a fw upload */ /* Firmware memory */ bus_dmamap_t fw_dmap; -- cgit v1.2.3