diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2004-10-26 04:44:00 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2004-10-26 04:44:00 +0000 |
commit | eedff6b5104c3fd1bbb356be2522883026513743 (patch) | |
tree | 1e2fd32173a8fdf2f149de6b8b0f06b45b5b7f85 | |
parent | 5c827e48d6804f9eb34b5b13b1e611ed56a90b18 (diff) |
Add RAID volume page
Add more IOC pages
Some cleanup
-rw-r--r-- | sys/dev/ic/mpt.c | 107 | ||||
-rw-r--r-- | sys/dev/ic/mpt_mpilib.h | 36 | ||||
-rw-r--r-- | sys/dev/ic/mpt_openbsd.c | 144 | ||||
-rw-r--r-- | sys/dev/ic/mpt_openbsd.h | 12 |
4 files changed, 214 insertions, 85 deletions
diff --git a/sys/dev/ic/mpt.c b/sys/dev/ic/mpt.c index 186c2d41513..4a883d9e828 100644 --- a/sys/dev/ic/mpt.c +++ b/sys/dev/ic/mpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpt.c,v 1.9 2004/10/22 04:54:26 marco Exp $ */ +/* $OpenBSD: mpt.c,v 1.10 2004/10/26 04:43:59 marco Exp $ */ /* $NetBSD: mpt.c,v 1.4 2003/11/02 11:07:45 wiz Exp $ */ /* @@ -61,6 +61,7 @@ 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_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); @@ -728,7 +729,11 @@ mpt_read_cfg_page(mpt_softc_t *mpt, int PageAddress, fCONFIG_PAGE_HEADER *hdr) } 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); } + bcopy(((caddr_t)req->req_vbuf)+CFG_DATA_OFF, hdr, amt); mpt_free_request(mpt, req); return (0); @@ -914,6 +919,92 @@ mpt_read_config_info_ioc(mpt_softc_t *mpt) 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 headers */ + rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_RAID_VOLUME, 0, + 0, &mpt->mpt_raid_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_raid_page0.Header); + } + + /* retrieve raid volume page using retrieved headers */ + rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_raid_page0.Header); + if (rv) { + mpt_prt(mpt, "Could not retrieve RAID Volume 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_raid_page0.VolumeType, + mpt->mpt_raid_page0.VolumeIOC, + mpt->mpt_raid_page0.VolumeBus, + mpt->mpt_raid_page0.VolumeID, + mpt->mpt_raid_page0.VolumeStatus, + mpt->mpt_raid_page0.VolumeSettings, + mpt->mpt_raid_page0.MaxLBA, + mpt->mpt_raid_page0.StripeSize, + mpt->mpt_raid_page0.NumPhysDisks); + + for (i = 0; i < mpt->mpt_raid_page0.NumPhysDisks; i++) { + mpt_prt(mpt, "RAID Volume Page 0 Physical Disk: %x %x", + mpt->mpt_raid_page0.PhysDisk[i].PhysDiskNum, + mpt->mpt_raid_page0.PhysDisk[i].PhysDiskMap); + } } /* mpt->verbose = 1; */ @@ -1402,6 +1493,20 @@ mpt_init(mpt_softc_t *mpt, u_int32_t who) 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.MaxVolumes) { + 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 d34e3f996f5..1b799d765cf 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.1 2004/03/06 03:03:07 krw Exp $ */ +/* $OpenBSD: mpt_mpilib.h,v 1.2 2004/10/26 04:43:59 marco Exp $ */ /* $NetBSD: mpt_mpilib.h,v 1.2 2003/04/16 23:24:01 thorpej Exp $ */ /* @@ -1329,12 +1329,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 +1378,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 +1408,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 +1433,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 +1457,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 +2020,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 efd2103f4e0..b93e33df29b 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.16 2004/10/22 04:54:26 marco Exp $ */ +/* $OpenBSD: mpt_openbsd.c,v 1.17 2004/10/26 04:43:59 marco Exp $ */ /* $NetBSD: mpt_netbsd.c,v 1.7 2003/07/14 15:47:11 lukem Exp $ */ /* @@ -191,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; @@ -207,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) { @@ -274,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"); @@ -296,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 */ } @@ -365,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 @@ -378,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 */ @@ -439,12 +450,9 @@ mpt_attach(mpt_softc_t *mpt) mpt->mpt_dev.dv_xname); #endif - 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); - 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); @@ -1638,8 +1646,8 @@ mpt_ioctl(dev, cmd, addr) dev->dv_xname, dummy->x++); } break; - /* Retrieve Manufacturing Page 0 */ 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); diff --git a/sys/dev/ic/mpt_openbsd.h b/sys/dev/ic/mpt_openbsd.h index a27537c768d..41ca4a3ccb8 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.10 2004/10/22 04:54:26 marco Exp $ */ +/* $OpenBSD: mpt_openbsd.h,v 1.11 2004/10/26 04:43:59 marco Exp $ */ /* $NetBSD: mpt_netbsd.h,v 1.2 2003/04/16 23:02:14 thorpej Exp $ */ /* @@ -221,7 +221,8 @@ typedef struct mpt_softc { uint16_t mpt_ini_id; /* Device configuration information */ - union { + /* union { is this right? */ + struct { struct mpt_spi_cfg { fCONFIG_PAGE_SCSI_PORT_0 _port_page0; fCONFIG_PAGE_SCSI_PORT_1 _port_page1; @@ -268,6 +269,13 @@ typedef struct mpt_softc { #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 _raid_page0; + } raid; +#define mpt_raid_page0 cfg.raid._raid_page0 + + } cfg; bus_space_tag_t sc_st; |