diff -Nur mpt-status-1.2.0-RC3/mpt-status.c mpt-status-1.2.0-RC4/mpt-status.c --- mpt-status-1.2.0-RC3/mpt-status.c 2006-04-23 20:27:12.000000000 +0200 +++ mpt-status-1.2.0-RC4/mpt-status.c 2006-04-23 21:49:17.000000000 +0200 @@ -515,10 +515,271 @@ return; } +void GetPhysDiskInfo(RaidVol0PhysDisk_t *pDisk, int count) { + Config_t *ConfigRequest; + ConfigReply_t *pReply = NULL; + uint numBytes; + int status; + int ii; + unsigned char tmp; + + printf("\tPhysical Disk Information:\n"); + + numBytes = (sizeof(Config_t) - sizeof(SGE_IO_UNION)) + sizeof (SGESimple64_t); + if ((mpiBlkPtr = allocIoctlBlk(numBytes)) == NULL) + return; + + ConfigRequest = (Config_t *) mpiBlkPtr->MF; + mpiBlkPtr->dataInSize = mpiBlkPtr->dataOutSize = 0; + mpiBlkPtr->dataInBufPtr = mpiBlkPtr->dataOutBufPtr = NULL; + mpiBlkPtr->dataSgeOffset = (sizeof (Config_t) - sizeof(SGE_IO_UNION))/4; + pReply = (ConfigReply_t *)mpiBlkPtr->replyFrameBufPtr; + + ConfigRequest->Action = MPI_CONFIG_ACTION_PAGE_HEADER; + ConfigRequest->Function = MPI_FUNCTION_CONFIG; + ConfigRequest->MsgContext = -1; + ConfigRequest->Header.PageType = MPI_CONFIG_PAGETYPE_RAID_PHYSDISK; + ConfigRequest->PageAddress = cpu_to_le32((uint)pDisk[0].PhysDiskNum); + + status = read_page2(MPT_FLAGS_KEEP_MEM); + if ((status == 0) && (pReply->Header.PageLength > 0)) { + mpiBlkPtr->dataInSize = pReply->Header.PageLength * 4; + if (allocDataFrame(DATA_DIR_IN)) { + printf ("Config: Unable to allocate data buffer."); + freeMem(); + return; + } + } + + ConfigRequest->Action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; + ConfigRequest->Header.PageVersion = pReply->Header.PageVersion; + ConfigRequest->Header.PageLength = pReply->Header.PageLength; + for (ii = 0; ii < count; ii++){ + ConfigRequest->PageAddress = cpu_to_le32((uint)pDisk[ii].PhysDiskNum); + + status = read_page2(MPT_FLAGS_KEEP_MEM); + if (status == 0) { + RaidPhysDiskPage0_t *pRPD0 = (RaidPhysDiskPage0_t *) + mpiBlkPtr->dataInBufPtr; + + printf("\t\tPhys Disk Num=%d at ID=%d", + pRPD0->PhysDiskNum, pRPD0->PhysDiskID); + tmp = pRPD0->PhysDiskStatus.Flags; + if (tmp & MPI_PHYSDISK0_STATUS_FLAG_OUT_OF_SYNC) + printf(", Out of Sync"); + if (tmp & MPI_PHYSDISK0_STATUS_FLAG_QUIESCED) + printf(", Quiesced"); + tmp = pRPD0->PhysDiskStatus.State; + if (tmp & MPI_PHYSDISK0_STATUS_ONLINE) + printf(", Online"); + if (tmp & MPI_PHYSDISK0_STATUS_MISSING) + printf(", Missing"); + if (tmp & MPI_PHYSDISK0_STATUS_NOT_COMPATIBLE) + printf(", Not Compatible"); + if (tmp & MPI_PHYSDISK0_STATUS_FAILED) + printf(", Failed"); + if (tmp & MPI_PHYSDISK0_STATUS_INITIALIZING) + printf(", Initializing"); + if (tmp & MPI_PHYSDISK0_STATUS_FAILED_REQUESTED) + printf(", Failed Requested"); + printf("\n"); + } else + printf("\t\tNot Available.\n"); + } + freeMem(); + return; +} + +void GetHotSpareInfo(void) { + Config_t *ConfigRequest; + ConfigReply_t *pReply = NULL; + IOCPage5_t *pPg5 = NULL; + uint numBytes; + int status; + uint num_spares = 0; + u8 tmp; + + numBytes = (sizeof(Config_t) - sizeof(SGE_IO_UNION)) + sizeof (SGESimple64_t); + if ((mpiBlkPtr = allocIoctlBlk(numBytes)) == NULL) + return; + + ConfigRequest = (Config_t *) mpiBlkPtr->MF; + mpiBlkPtr->dataInSize = mpiBlkPtr->dataOutSize = 0; + mpiBlkPtr->dataInBufPtr = mpiBlkPtr->dataOutBufPtr = NULL; + mpiBlkPtr->dataSgeOffset = (sizeof (Config_t) - sizeof(SGE_IO_UNION))/4; + + pReply = (ConfigReply_t *)mpiBlkPtr->replyFrameBufPtr; + + ConfigRequest->Action = MPI_CONFIG_ACTION_PAGE_HEADER; + ConfigRequest->Function = MPI_FUNCTION_CONFIG; + ConfigRequest->MsgContext = -1; + ConfigRequest->Header.PageNumber = 5; + ConfigRequest->Header.PageType = MPI_CONFIG_PAGETYPE_IOC; + ConfigRequest->PageAddress = cpu_to_le32(0); + + status = read_page2(MPT_FLAGS_KEEP_MEM); + printf("Hot Spare Information:\n"); + if (status != 0) { + printf("\tUnsupported.\n"); + freeMem(); + return; + } else if (pReply->Header.PageLength == 0 ) { + printf("\tNone.\n"); + freeMem(); + return; + } + + mpiBlkPtr->dataInSize = pReply->Header.PageLength * 4; + if (allocDataFrame(DATA_DIR_IN)) { + printf ("Config: Unable to allocate data buffer."); + freeMem(); + return; + } + + ConfigRequest->Action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; + ConfigRequest->Header.PageVersion = pReply->Header.PageVersion; + ConfigRequest->Header.PageLength = pReply->Header.PageLength; + status = read_page2(MPT_FLAGS_KEEP_MEM); + pPg5 = (IOCPage5_t *) mpiBlkPtr->dataInBufPtr; + + if ((status == 0) && (pPg5->NumHotSpares > 0)){ + num_spares = pPg5->NumHotSpares; + { + // Get Phys Disk Information + Ioc5HotSpare_t disk_num[num_spares]; + unsigned int ii; + + for (ii = 0; ii < num_spares; ii++) { + disk_num[ii].PhysDiskNum = pPg5->HotSpare[ii].PhysDiskNum; + disk_num[ii].HotSparePool = pPg5->HotSpare[ii].HotSparePool; + } + + freeMem(); /* Do not reference pPg5 any more */ + + numBytes = (sizeof(Config_t) - sizeof(SGE_IO_UNION)) + sizeof (SGESimple64_t); + if ((mpiBlkPtr = allocIoctlBlk(numBytes)) == NULL) + return; + + ConfigRequest = (Config_t *) mpiBlkPtr->MF; + mpiBlkPtr->dataInSize = mpiBlkPtr->dataOutSize = 0; + mpiBlkPtr->dataInBufPtr = mpiBlkPtr->dataOutBufPtr = NULL; + mpiBlkPtr->dataSgeOffset = (sizeof (Config_t) - sizeof(SGE_IO_UNION))/4; + + pReply = (ConfigReply_t *)mpiBlkPtr->replyFrameBufPtr; + + ConfigRequest->Action = MPI_CONFIG_ACTION_PAGE_HEADER; + ConfigRequest->Function = MPI_FUNCTION_CONFIG; + ConfigRequest->MsgContext = -1; + ConfigRequest->Header.PageType = MPI_CONFIG_PAGETYPE_RAID_PHYSDISK; + ConfigRequest->PageAddress = cpu_to_le32((uint)disk_num[0].PhysDiskNum); + + status = read_page2(MPT_FLAGS_KEEP_MEM); + if ((status == 0) && (pReply->Header.PageLength > 0)) { + mpiBlkPtr->dataInSize = pReply->Header.PageLength * 4; + if (allocDataFrame(DATA_DIR_IN)) { + printf ("Config: Unable to allocate data buffer."); + freeMem(); + return; + } + } + + ConfigRequest->Action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; + ConfigRequest->Header.PageVersion = pReply->Header.PageVersion; + ConfigRequest->Header.PageLength = pReply->Header.PageLength; + for (ii = 0; ii < num_spares; ii++){ + ConfigRequest->PageAddress = cpu_to_le32((uint)disk_num[ii].PhysDiskNum); + + status = read_page2(MPT_FLAGS_KEEP_MEM); + if (status == 0) { + RaidPhysDiskPage0_t *pRPD0 = (RaidPhysDiskPage0_t *) mpiBlkPtr->dataInBufPtr; + printf("\tNum=%d ID=%d", pRPD0->PhysDiskNum, pRPD0->PhysDiskID); + tmp=pRPD0->PhysDiskStatus.Flags; + if (tmp & MPI_PHYSDISK0_STATUS_FLAG_OUT_OF_SYNC) + printf(", Out of Sync"); + if (tmp & MPI_PHYSDISK0_STATUS_FLAG_QUIESCED) + printf(", Quiesced"); + tmp=pRPD0->PhysDiskStatus.State; + if (tmp & MPI_PHYSDISK0_STATUS_ONLINE) + printf(", Online"); + if (tmp & MPI_PHYSDISK0_STATUS_MISSING) + printf(", Missing"); + if (tmp & MPI_PHYSDISK0_STATUS_NOT_COMPATIBLE) + printf(", Not Compatible"); + if (tmp & MPI_PHYSDISK0_STATUS_FAILED) + printf(", Failed"); + if (tmp & MPI_PHYSDISK0_STATUS_INITIALIZING) + printf(", Initializing"); + if (tmp & MPI_PHYSDISK0_STATUS_FAILED_REQUESTED) + printf(", Failed Requested"); + printf("\n"); + } else + printf("\t\tNot Available.\n"); + } + } + } else if (status == 0) + printf("Not Available.\n"); + else + printf("No Hot Spare Disks.\n"); + + freeMem(); + return; +} + +void GetResyncPercentage(RaidVol0PhysDisk_t *pDisk, unsigned char *pVol, int count) { + MpiRaidActionRequest_t *pRequest; + uint blks_done; + uint numBytes; + int ii; + uint tot_blks, blks_left; + int status; + + numBytes = (sizeof(MpiRaidActionRequest_t) - sizeof(SGE_IO_UNION)) + + sizeof (SGESimple64_t); + + if ((mpiBlkPtr = allocIoctlBlk(numBytes)) == NULL) + return; + + pRequest = (MpiRaidActionRequest_t *) mpiBlkPtr->MF; + mpiBlkPtr->dataSgeOffset = (sizeof (MpiRaidActionRequest_t) - sizeof(SGE_IO_UNION))/4; + + /* Initialize data in/data out sizes: Change below if need to */ + mpiBlkPtr->dataInSize = mpiBlkPtr->dataOutSize = 0; + + pRequest->Action = MPI_RAID_ACTION_INDICATOR_STRUCT; + pRequest->Function = MPI_FUNCTION_RAID_ACTION; + pRequest->MsgContext = -1; + pRequest->ActionDataWord = cpu_to_le32(0); /* action data is 0 */ + + printf("Resync Information:\n"); + for (ii = 0; ii < count; ii++ ) { + pRequest->VolumeID = (u8) pVol[ii]; + pRequest->PhysDiskNum = pDisk[ii].PhysDiskNum; + + status = read_page2(MPT_FLAGS_KEEP_MEM); + if (status == 0) { + uint *pdata = (uint *) mpiBlkPtr->replyFrameBufPtr; + pdata += 6; + tot_blks = cpu_to_le32(*pdata); + pdata++; + pdata++; + blks_left = cpu_to_le32(*pdata); + pdata++; + blks_done = tot_blks - blks_left; + printf("\tPhys Disk %d on Volume %d:\n\t\t0x%x of 0x%x Remaining,", + pDisk[ii].PhysDiskNum, pVol[ii], + blks_left, tot_blks ); + + printf(" Done 0x%x, (%d%%) Complete \n", + blks_done, ((blks_done >> 6) * 100) / (tot_blks >> 6)); + } + } + freeMem(); + return; +} + static void print_information() { RaidVolumePage0_t *page; RaidPhysDiskPage0_t *phys; - //IOCPage5_t *ioc_hotspare; int i; page = read_page(MPI_CONFIG_PAGETYPE_RAID_VOLUME, @@ -680,29 +941,6 @@ free(productid); free(rev); } - - /* go through all hotspares - ioc_hotspare = read_page(MPI_CONFIG_PAGETYPE_RAID_VOLUME, - MPI_CONFIG_ACTION_PAGE_READ_CURRENT, - 0, - id_of_primary_device, - MPI_IOCPAGE5_PAGEVERSION); - - //mpt_printf("Number of hotspares: %d\n", ioc_hotspare->NumHotSpares); - for (i = 0; i < ioc_hotspare->NumHotSpares; ++i) { - Ioc5HotSpare_t *hotspare; - - hotspare = read_page(MPI_CONFIG_PAGETYPE_RAID_PHYSDISK, - MPI_CONFIG_ACTION_PAGE_READ_CURRENT, - 0, - ioc_hotspare->HotSpare[i].PhysDiskNum, - MPI_IOCPAGE5_PAGEVERSION); - mpt_printf("Hotspare: phys_id %d state: %s\n", - hotspare->PhysDiskNum, - hotspare->Flags == MPI_IOC_PAGE_5_HOT_SPARE_ACTIVE ? - "ACTIVE" : "INACTIVE"); - } - */ } static void do_init(void) { diff -Nur mpt-status-1.2.0-RC3/mpt-status.h mpt-status-1.2.0-RC4/mpt-status.h --- mpt-status-1.2.0-RC3/mpt-status.h 2006-04-23 19:36:48.000000000 +0200 +++ mpt-status-1.2.0-RC4/mpt-status.h 2006-04-23 21:42:05.000000000 +0200 @@ -21,7 +21,7 @@ #include "lsi/mpi_ioc.h" #include "lsi/mpi_cnfg.h" //#include "lsi/mpi_init.h" -//#include "lsi/mpi_raid.h" +#include "lsi/mpi_raid.h" //#include "lsi/mpi_tool.h" #include "mptctl.h" #endif // SANITIZED_KERNEL_HEADERS