diff -Nur mpt-status-1.2.0-RC2/incl/sles.h mpt-status-1.2.0-RC3/incl/sles.h --- mpt-status-1.2.0-RC2/incl/sles.h 2006-02-12 18:42:35.000000000 +0100 +++ mpt-status-1.2.0-RC3/incl/sles.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,198 +0,0 @@ -#define MPI_FUNCTION_CONFIG (0x04) -#define MPI_CONFIG_ACTION_PAGE_HEADER (0x00) -#define MPI_CONFIG_PAGETYPE_RAID_VOLUME (0x08) -#define MPI_CONFIG_ACTION_PAGE_READ_CURRENT (0x01) -#define MPI_RAIDVOLPAGE0_PAGEVERSION (0x01) -#define MPI_RAIDVOL0_STATUS_FLAG_ENABLED (0x01) -#define MPI_RAIDVOL0_STATUS_FLAG_QUIESCED (0x02) -#define MPI_RAIDVOL0_STATUS_FLAG_RESYNC_IN_PROGRESS (0x04) -#define MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE (0x08) -#define MPI_RAIDVOL0_STATUS_STATE_OPTIMAL (0x00) -#define MPI_RAIDVOL0_STATUS_STATE_DEGRADED (0x01) -#define MPI_RAIDVOL0_STATUS_STATE_FAILED (0x02) -#define MPI_CONFIG_PAGETYPE_RAID_PHYSDISK (0x0A) -#define MPI_RAIDPHYSDISKPAGE0_PAGEVERSION (0x00) -#define MPI_PHYSDISK0_STATUS_FLAG_OUT_OF_SYNC (0x01) -#define MPI_PHYSDISK0_STATUS_FLAG_QUIESCED (0x02) -#define MPI_PHYSDISK0_STATUS_ONLINE (0x00) -#define MPI_PHYSDISK0_STATUS_MISSING (0x01) -#define MPI_PHYSDISK0_STATUS_NOT_COMPATIBLE (0x02) -#define MPI_PHYSDISK0_STATUS_FAILED (0x03) -#define MPI_PHYSDISK0_STATUS_FAILED_REQUESTED (0x06) -#define MPI_PHYSDISK0_STATUS_INITIALIZING (0x04) -#define MPI_PHYSDISK0_STATUS_OFFLINE_REQUESTED (0x05) -#define MPI_PHYSDISK0_STATUS_FAILED_REQUESTED (0x06) -#define MPI_PHYSDISK0_STATUS_OTHER_OFFLINE (0xFF) -#define MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX (1) - -#define MPT_MAGIC_NUMBER 'm' -#define MPTCOMMAND _IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command) - -typedef struct ConfigPageHeader_t { - uint8_t PageVersion; /* 00h */ - uint8_t PageLength; /* 01h */ - uint8_t PageNumber; /* 02h */ - uint8_t PageType; /* 03h */ -} ConfigPageHeader_t; - -typedef struct SGESimpleUnion_t { - uint32_t FlagsLength; - union { - uint32_t Address32; - uint64_t Address64; - } u; -} SGESimpleUnion_t; - -typedef struct SGEChainUnion_t { - uint16_t Length; - uint8_t NextChainOffset; - uint8_t Flags; - union { - uint32_t Address32; - uint64_t Address64; - } u; -} SGEChainUnion_t; - -typedef struct SGEIOUnion_t { - union { - SGESimpleUnion_t Simple; - SGEChainUnion_t Chain; - } u; -} SGEIOUnion_t; - -typedef struct Config_t { - uint8_t Action; /* 00h */ - uint8_t Reserved; /* 01h */ - uint8_t ChainOffset; /* 02h */ - uint8_t Function; /* 03h */ - uint16_t ExtPageLength; /* 04h */ - uint8_t ExtPageType; /* 06h */ - uint8_t MsgFlags; /* 07h */ - uint32_t MsgContext; /* 08h */ - uint8_t Reserved2[8]; /* 0Ch */ - ConfigPageHeader_t Header; /* 14h */ - uint32_t PageAddress; /* 18h */ - SGEIOUnion_t PageBufferSGE; /* 1Ch */ -} Config_t; - -typedef struct ConfigReply_t { - uint8_t Action; /* 00h */ - uint8_t Reserved; /* 01h */ - uint8_t MsgLength; /* 02h */ - uint8_t Function; /* 03h */ - uint16_t ExtPageLength; /* 04h */ - uint8_t ExtPageType; /* 06h */ - uint8_t MsgFlags; /* 07h */ - uint32_t MsgContext; /* 08h */ - uint8_t Reserved2[2]; /* 0Ch */ - uint16_t IOCStatus; /* 0Eh */ - uint32_t IOCLogInfo; /* 10h */ - ConfigPageHeader_t Header; /* 14h */ -} ConfigReply_t; - -typedef struct RaidVol0Status_t { - uint8_t Flags; /* 00h */ - uint8_t State; /* 01h */ - uint16_t Reserved; /* 02h */ -} RaidVol0Status_t; - -typedef struct RaidVol0Settings { - uint16_t Settings; /* 00h */ - uint8_t HotSparePool; /* 01h *//* MPI_RAID_HOT_SPARE_POOL_ */ - uint8_t Reserved; /* 02h */ -} RaidVol0Settings; - -typedef struct RaidVol0PhysDisk_t { - uint16_t Reserved; /* 00h */ - uint8_t PhysDiskMap; /* 02h */ - uint8_t PhysDiskNum; /* 03h */ -} RaidVol0PhysDisk_t; - -typedef struct RaidVolumePage0_t { - ConfigPageHeader_t Header; /* 00h */ - uint8_t VolumeID; /* 04h */ - uint8_t VolumeBus; /* 05h */ - uint8_t VolumeIOC; /* 06h */ - uint8_t VolumeType; /* 07h *//* MPI_RAID_VOL_TYPE_ */ - RaidVol0Status_t VolumeStatus; /* 08h */ - RaidVol0Settings VolumeSettings; /* 0Ch */ - uint32_t MaxLBA; /* 10h */ - uint32_t Reserved1; /* 14h */ - uint32_t StripeSize; /* 18h */ - uint32_t Reserved2; /* 1Ch */ - uint32_t Reserved3; /* 20h */ - uint8_t NumPhysDisks; /* 24h */ - uint8_t Reserved4; /* 25h */ - uint16_t Reserved5; /* 26h */ - RaidVol0PhysDisk_t PhysDisk[MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX]; /* 28h */ -} RaidVolumePage0_t; - -typedef struct RaidPhysDiskSettings_t { - uint8_t SepID; /* 00h */ - uint8_t SepBus; /* 01h */ - uint8_t HotSparePool; /* 02h *//* MPI_RAID_HOT_SPARE_POOL_ */ - uint8_t PhysDiskSettings; /* 03h */ -} RaidPhysDiskSettings_t; - -typedef struct RaidPhysDisk0InquiryData { - uint8_t VendorID[8]; /* 00h */ - uint8_t ProductID[16]; /* 08h */ - uint8_t ProductRevLevel[4]; /* 18h */ - uint8_t Info[32]; /* 1Ch */ -} RaidPhysDisk0InquiryData; - -typedef struct RaidPhysDiskStatus_t { - uint8_t Flags; /* 00h */ - uint8_t State; /* 01h */ - uint16_t Reserved; /* 02h */ -} RaidPhysDiskStatus_t; - -typedef struct RaidPhysDisk0ErrorData_t { - uint8_t ErrorCdbByte; /* 00h */ - uint8_t ErrorSenseKey; /* 01h */ - uint16_t Reserved; /* 02h */ - uint16_t ErrorCount; /* 04h */ - uint8_t ErrorASC; /* 06h */ - uint8_t ErrorASCQ; /* 07h */ - uint16_t SmartCount; /* 08h */ - uint8_t SmartASC; /* 0Ah */ - uint8_t SmartASCQ; /* 0Bh */ -} RaidPhysDisk0ErrorData_t; - -typedef struct RaidPhysDiskPage0_t { - ConfigPageHeader_t Header; /* 00h */ - uint8_t PhysDiskID; /* 04h */ - uint8_t PhysDiskBus; /* 05h */ - uint8_t PhysDiskIOC; /* 06h */ - uint8_t PhysDiskNum; /* 07h */ - RaidPhysDiskSettings_t PhysDiskSettings; /* 08h */ - uint32_t Reserved1; /* 0Ch */ - uint32_t Reserved2; /* 10h */ - uint32_t Reserved3; /* 14h */ - uint8_t DiskIdentifier[16]; /* 18h */ - RaidPhysDisk0InquiryData InquiryData; /* 28h */ - RaidPhysDiskStatus_t PhysDiskStatus; /* 64h */ - uint32_t MaxLBA; /* 68h */ - RaidPhysDisk0ErrorData_t ErrorData; /* 6Ch */ -} RaidPhysDiskPage0_t; - -typedef struct mpt_ioctl_header { - unsigned int iocnum; /* IOC unit number */ - unsigned int port; /* IOC port number */ - int maxDataSize; /* Maximum Num. bytes to transfer on read */ -} mpt_ioctl_header; - -struct mpt_ioctl_command { - mpt_ioctl_header hdr; - int timeout; /* optional (seconds) */ - char *replyFrameBufPtr; - char *dataInBufPtr; - char *dataOutBufPtr; - char *senseDataPtr; - int maxReplyBytes; - int dataInSize; - int dataOutSize; - int maxSenseBytes; - int dataSgeOffset; - char MF[1]; -}; diff -Nur mpt-status-1.2.0-RC2/Makefile mpt-status-1.2.0-RC3/Makefile --- mpt-status-1.2.0-RC2/Makefile 2006-04-20 23:27:56.000000000 +0200 +++ mpt-status-1.2.0-RC3/Makefile 2006-04-23 20:26:46.000000000 +0200 @@ -1,27 +1,21 @@ PROG := mpt-status -KERNEL_PATH := /usr/src/linux PREFIX := /usr -CFLAGS := -I${KERNEL_PATH}/drivers/message/fusion -Iincl -Wall -W -O2 -DFLAGS := -DSANITIZED_KERNEL_HEADERS #-DVAR_DIV +KERNEL_PATH := /usr/src/linux +CFLAGS := -Iincl -Wall -W -O2 -I${KERNEL_PATH}/drivers/message/fusion +DFLAGS := -DNEWSTYLE #-DSANITIZED_KERNEL_HEADERS #-DVAR_DIV LDFLAGS := DESTDIR := CC := gcc INSTALL := install ARCH := $(shell uname -m) -REDHAT := $(shell if [ -e /etc/redhat-release ]; \ - then echo "true"; else echo "false"; fi) -ifeq "${REDHAT}" "true" - DFLAGS := -DREDHAT -endif ifeq "${ARCH}" "sparc64" - CFLAGS := -I${KERNEL_PATH}/drivers/message/fusion -Iincl -Wall -W -O2 \ - -m64 -pipe -mcpu=ultrasparc -mcmodel=medlow + CFLAGS := -Iincl -Wall -W -O2 -m64 -pipe \ + -mcpu=ultrasparc -mcmodel=medlow endif # This part is for the 1.2.0 version of mpt-status #ifeq "${ARCH}" "x86_64" -# CFLAGS := -I${KERNEL_PATH}/drivers/message/fusion -Iincl -Wall -W -O2 \ -# -m64 +# CFLAGS := -Iincl -Wall -W -O2 -m64 -I${KERNEL_PATH}/drivers/message/fusion #endif ${PROG}: ${PROG}.c ${PROG}.h diff -Nur mpt-status-1.2.0-RC2/mpt-status.c mpt-status-1.2.0-RC3/mpt-status.c --- mpt-status-1.2.0-RC2/mpt-status.c 2006-04-20 23:26:25.000000000 +0200 +++ mpt-status-1.2.0-RC3/mpt-status.c 2006-04-23 20:27:12.000000000 +0200 @@ -33,24 +33,10 @@ #include #include #include - -#include -#ifdef __linux__ -#include -#endif #include "mpt-status.h" #define ARG_M_A 0x0001 -#define MPT_EXIT_OKAY (0) -#define MPT_EXIT_VOL_OPTIMAL (0) -#define MPT_EXIT_VOL_FAILED (1 << 1) -#define MPT_EXIT_VOL_DEGRADED (1 << 2) -#define MPT_EXIT_VOL_RESYNC (1 << 3) -#define MPT_EXIT_PHYSDISK_ERROR (1 << 4) -#define MPT_EXIT_PHYSDISK_WARN (1 << 5) -#define MPT_EXIT_UNKNOWN (1 << 0) - static int m = 0; static int quiet_mode = 0; static int verbose_mode = 0; @@ -59,6 +45,10 @@ static int auto_load = 0; static int probe_id = 0; static int mpt_exit_mask = MPT_EXIT_OKAY; +static int print_status_only = PRINT_STATUS_ONLY; +static int id_of_primary_device = 0; +static int ioc_unit = 0; +//static int library_mode = 0; static int sel; static const struct option long_options[] = { @@ -108,12 +98,92 @@ " Bit 5: At least one physical disk is in warning condition.\n" "\n"; -static int print_status_only = PRINT_STATUS_ONLY; -static int id_of_primary_device = 0; -static int ioc_unit = 0; -static int library_mode = 0; + +static char *VolumeTypes[] = { "IS", "IME", "IM" }; +static char *VolumeTypesHuman[] = { "0", "1E", "1" }; //Raid levels +mpiIoctlBlk_t *mpiBlkPtr = NULL; +unsigned char g_command[1024]; +char g_data[4*1024]; +char g_reply[1024]; +char g_sense[256]; +int g_bigEndian = 0; + +static unsigned int cpu_to_le32 (unsigned int x) { + if (g_bigEndian) { + unsigned int y; + y = (x & 0xFF00) << 8; + y |= (x & 0xFF) << 24; + y |= (x & 0xFF0000) >> 8; + y |= (x & 0xFF000000) >> 24; + return y; + } + return x; +} + +static unsigned short le16_to_cpu(unsigned short x) { + if (g_bigEndian) { + unsigned short y = (((x & 0xFF00) >> 8) | ((x & 0xFF) << 8)); + return y; + } + return x; +} + +static void freeMem(void) { + if (mpiBlkPtr->replyFrameBufPtr) + mpiBlkPtr->replyFrameBufPtr = NULL; + if (mpiBlkPtr->dataOutBufPtr) + mpiBlkPtr->dataOutBufPtr = NULL; + if (mpiBlkPtr->dataInBufPtr) + mpiBlkPtr->dataInBufPtr = NULL; + mpiBlkPtr = NULL; +} + +static int allocDataFrame(int dir) { + if (dir == DATA_DIR_OUT) { + if (mpiBlkPtr->dataOutSize > (4*1024)) + return 1; + mpiBlkPtr->dataOutBufPtr = (char *)&g_data; + memset(mpiBlkPtr->dataOutBufPtr, 0, mpiBlkPtr->dataOutSize); + + } else if (dir == DATA_DIR_IN) { + if (mpiBlkPtr->dataInSize > (4*1024)) + return 1; + mpiBlkPtr->dataInBufPtr = (char *)&g_data; + memset(mpiBlkPtr->dataInBufPtr, 0, mpiBlkPtr->dataInSize); + } + return 0; +} + +static int allocReplyFrame(void) { + mpiBlkPtr->replyFrameBufPtr = (char *) &g_reply; + memset (mpiBlkPtr->replyFrameBufPtr, 0, REPLY_SIZE); + mpiBlkPtr->maxReplyBytes = REPLY_SIZE; + return 0; +} + +mpiIoctlBlk_t *allocIoctlBlk(uint numBytes) { + int blksize = sizeof(mpiIoctlBlk_t) + numBytes; + + if (blksize >= 1024) { + return NULL; + } + mpiBlkPtr = (mpiIoctlBlk_t *) &g_command; + memset(mpiBlkPtr, 0, blksize); + if (allocReplyFrame()) { + printf("allocReplyFrame call failed\n"); + freeMem(); + return NULL; + } + return mpiBlkPtr; +} static void mpt_exit(int status) { + if (status & MPT_EXIT_FREEMEM) { + freeMem(); + } + if (status & MPT_EXIT_NOCLOSE) { + close(m); + } exit(mpt_exit_mask |= status); } @@ -150,40 +220,31 @@ mpt_printf("Version: %s\n", VERSION); } +/* static void checkForLibraryMode(void) { char *env; - /* Library usage detection */ + // Library usage detection env = getenv("__MPT_STATUS_LIB"); if (env != NULL) { printf("Setting library mode: env = %s\n", env); library_mode = 1; } } - -/* -// 32bit version -static void *read_page(U8 pagetype, U8 pagewhich, U8 pagenumber, - U32 address, U8 version) { */ -// original + static void *read_page(unsigned int pagetype, unsigned int pagewhich, unsigned int pagenumber, unsigned int address, unsigned int version) { -/* -// 64bit version -static void *read_page(uint8_t pagetype, uint8_t pagewhich, - uint8_t pagenumber, uint32_t address, - uint8_t version) { -*/ char command[REALLYBIG]; char reply[REALLYBIG]; char sense[REALLYBIG]; char *in; unsigned int warnings; - struct mpt_ioctl_command *cmd; + struct mpt_ioctl_command *cmd = NULL; Config_t *config_request; ConfigReply_t *config_reply; + //MPIDefaultReply_t *config_reply; #ifdef VAR_DIV unsigned short div = sizeof(char *); /* this is fishy */ #else @@ -226,7 +287,7 @@ config_request->Header.PageVersion = 0; config_request->PageAddress = address; - if (-1 == ioctl(m, MPTCOMMAND, cmd)) { + if (-1 == ioctl(m, MPTCOMMAND, (char *) cmd)) { perror("MPI_FUNCTION_CONFIG (get page header)"); mpt_exit(MPT_EXIT_UNKNOWN); } @@ -269,7 +330,6 @@ return in; } - static int __probe_scsi_id() { int scsi_id; RaidVolumePage0_t *page; @@ -289,12 +349,176 @@ return -1; } +static int read_page2(uint flags) { + // this is the IssueMptCommand + MPIDefaultReply_t *pReply = NULL; + int CmdBlkSize; + int status = -1; + + CmdBlkSize = sizeof(mpiIoctlBlk_t) + ((mpiBlkPtr->dataSgeOffset)*4) + 8; + mpiBlkPtr->hdr.iocnum = ioc_unit; + mpiBlkPtr->hdr.port = 0; + + if (ioctl(m, (unsigned long) MPTCOMMAND, (char *) mpiBlkPtr) != 0) { + perror("IOCTL failed"); + mpt_exit(MPT_EXIT_UNKNOWN); + } else { + pReply = (MPIDefaultReply_t *) mpiBlkPtr->replyFrameBufPtr; + if ((pReply) && (pReply->MsgLength > 0)) { + pReply->IOCStatus = le16_to_cpu(pReply->IOCStatus); + status = pReply->IOCStatus & MPI_IOCSTATUS_MASK; + } else { + status = 0; + } + } + + if ((flags & MPT_FLAGS_KEEP_MEM) == 0) { + freeMem(); + } + + return status; +} + +static void GetVolumeInfo(void) { + Config_t *ConfigRequest; + ConfigReply_t *pReply = NULL; + RaidVolumePage0_t *pRVP0 = NULL; + RaidVol0PhysDisk_t disk_num[16]; + unsigned char pdisk_vol[16]; + uint numBytes; + int status; + int ii, id; + uint vol_count = 0; + int pdisk_cnt = 0; + int resync_on = 0; + unsigned bus = 0; + unsigned char 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; + + /* Populate the Config Request + */ + ConfigRequest->Action = MPI_CONFIG_ACTION_PAGE_HEADER; + ConfigRequest->Function = MPI_FUNCTION_CONFIG; + ConfigRequest->MsgContext = -1; + ConfigRequest->Header.PageType = MPI_CONFIG_PAGETYPE_RAID_VOLUME; + ConfigRequest->PageAddress = cpu_to_le32((bus << 8) | 0); + + status = read_page2(MPT_FLAGS_KEEP_MEM); + printf("Logical Volume 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; + + id = 0; // volume id: only one volume for now (vol_ids) + ConfigRequest->PageAddress = cpu_to_le32((bus << 8) | id); + status = read_page2(MPT_FLAGS_KEEP_MEM); + + /* Kludge - IO FW 1.1.60 returns IOCSTATUS of GOOD to + * this call resulting in bad information. + * IM FW returns a status of 0x0022 - INVALID PAGE + */ + pRVP0 = (RaidVolumePage0_t *) mpiBlkPtr->dataInBufPtr; + if ((status == 0) && (pRVP0->NumPhysDisks > 0)){ + vol_count++; + printf("\tID=0x%x, Bus=0x%x, IOC=0x%x, %s(0x%x)", + pRVP0->VolumeID,pRVP0->VolumeBus, pRVP0->VolumeIOC, + VolumeTypes[pRVP0->VolumeType], pRVP0->VolumeType); + if (pRVP0->VolumeType == MPI_RAID_VOL_TYPE_IS) + printf(", Stripe Size=0x%x", pRVP0->StripeSize); + printf(", %d Physical Disks", pRVP0->NumPhysDisks); + printf("\n"); + + printf("\tStatus: "); + tmp = pRVP0->VolumeStatus.Flags; + printf("%s", tmp & MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE ? "Not Active" : "Active"); + + printf(", %s", tmp & MPI_RAIDVOL0_STATUS_FLAG_ENABLED ? "Enabled" : "Disabled"); + if (tmp & MPI_RAIDVOL0_STATUS_FLAG_QUIESCED) + printf(", Quiesced Phys Disk IOs"); + + if (tmp & MPI_RAIDVOL0_STATUS_FLAG_RESYNC_IN_PROGRESS) { + printf(", Resync In Progress"); + resync_on = 1; + } + printf("\n"); + + /* + tmp = (pRVP0->VolumeStatus.State) & 0x03; + printf("\tState: %s\n", raid_status[tmp]); + */ + if (pRVP0->VolumeStatus.State == MPI_RAIDVOL0_STATUS_STATE_OPTIMAL) { + mpt_exit_mask |= MPT_EXIT_VOL_OPTIMAL; + mpt_printf(" OPTIMAL"); + } else if (pRVP0->VolumeStatus.State == + MPI_RAIDVOL0_STATUS_STATE_DEGRADED) { + mpt_exit_mask |= MPT_EXIT_VOL_DEGRADED; + mpt_printf(" DEGRADED"); + } else if (pRVP0->VolumeStatus.State == + MPI_RAIDVOL0_STATUS_STATE_FAILED) { + mpt_exit_mask |= MPT_EXIT_VOL_FAILED; + mpt_printf(" FAILED"); + } else { + mpt_exit_mask |= MPT_EXIT_UNKNOWN; + mpt_printf(" UNKNOWN"); + } + + for (ii = pdisk_cnt; ii < pdisk_cnt + pRVP0->NumPhysDisks; ii++) { + disk_num[ii].PhysDiskNum = pRVP0->PhysDisk[ii].PhysDiskNum; + disk_num[ii].PhysDiskMap = pRVP0->PhysDisk[ii].PhysDiskMap; + pdisk_vol[ii] = pRVP0->VolumeID; + } + pdisk_cnt += pRVP0->NumPhysDisks; + } + freeMem(); + + /* needs to be done later + if (pdisk_cnt > 0) { + GetPhysDiskInfo((RaidVol0PhysDisk_t *) &disk_num, pdisk_cnt); + } + GetResyncPercentage((RaidVol0PhysDisk_t *) &disk_num, + (unsigned char *) &pdisk_vol, pdisk_cnt); + */ + + if (vol_count == 0) { + printf("\tNo Logical Volumes Found.\n"); + } + + return; +} + static void print_information() { RaidVolumePage0_t *page; RaidPhysDiskPage0_t *phys; //IOCPage5_t *ioc_hotspare; - static char *VolumeTypes[] = { "IS", "IME", "IM" }; - static char *VolumeTypesHuman[] = { "0", "1E", "1" }; //Raid levels int i; page = read_page(MPI_CONFIG_PAGETYPE_RAID_VOLUME, @@ -383,8 +607,11 @@ page->PhysDisk[i].PhysDiskNum, MPI_RAIDPHYSDISKPAGE0_PAGEVERSION); ret = asprintf(&vendor, (void *)phys->InquiryData.VendorID); + if (ret > 0) vendor[ret-1] = '\0'; ret = asprintf(&productid, (void *)phys->InquiryData.ProductID); + if (ret > 0) productid[ret-1] = '\0'; ret = asprintf(&rev, (void *)phys->InquiryData.ProductRevLevel); + if (ret > 0) rev[ret-1] = '\0'; if (1 == print_status_only) { printf("phys_id:%d", phys->PhysDiskNum); } else { @@ -395,7 +622,8 @@ phys->PhysDiskID, vendor, productid, - rev, phys->MaxLBA / (2 * 1024 * 1024)); + rev, + phys->MaxLBA / (2 * 1024 * 1024)); printf(" state:"); } if (phys->PhysDiskStatus.State == @@ -500,8 +728,8 @@ " is supported by mptlinux?\n"); } mpt_fprintf(stderr, - "Also make sure mptctl is loaded into the kernel\n"); - mpt_exit(MPT_EXIT_UNKNOWN); + "Make sure mptctl is loaded into the kernel\n"); + mpt_exit(MPT_EXIT_UNKNOWN|MPT_EXIT_NOCLOSE); } } @@ -560,7 +788,11 @@ } while (next_option != -1); do_init(); - checkForLibraryMode(); + //checkForLibraryMode(); +#ifdef NEWSTYLE + GetVolumeInfo(); +#else print_information(); +#endif return mpt_exit_mask; } diff -Nur mpt-status-1.2.0-RC2/mpt-status.h mpt-status-1.2.0-RC3/mpt-status.h --- mpt-status-1.2.0-RC2/mpt-status.h 2006-04-20 23:14:49.000000000 +0200 +++ mpt-status-1.2.0-RC3/mpt-status.h 2006-04-23 19:36:48.000000000 +0200 @@ -1,48 +1,73 @@ #ifndef _MPT_STATUS_H #define _MPT_STATUS_H -#ifdef REDHAT -# define __user -# define __kernel +#include +#ifdef __linux__ +#include #endif -/* This is for version 1.2.0 of mpt-status -#ifndef __x86_64__ -#include "pci.h" // config.h and header.h from pciutils package -#include "lsi/mpi_type.h" -#include "lsi/mpi.h" -#include "lsi/mpi_ioc.h" -#include "lsi/mpi_cnfg.h" -#include "mptctl.h" -#else -#include -#include "pci.h" // config.h and header.h from pciutils package -#include "sles.h" -#endif // __x86_64__ -*/ - -#include "pci.h" // config.h and header.h from pciutils package #ifdef SANITIZED_KERNEL_HEADERS #include "mpt-sanitized.h" -/* #else +#ifndef __user +#define __user +#endif +#ifndef __kernel +#define __kernel +#endif +#include "pci.h" // config.h and header.h from pciutils package #include "lsi/mpi_type.h" #include "lsi/mpi.h" #include "lsi/mpi_ioc.h" #include "lsi/mpi_cnfg.h" +//#include "lsi/mpi_init.h" +//#include "lsi/mpi_raid.h" +//#include "lsi/mpi_tool.h" #include "mptctl.h" -*/ #endif // SANITIZED_KERNEL_HEADERS -#define VERSION "1.2.0-RC2" +#define VERSION "1.2.0-RC3" #define BIG 1024 #define REALLYBIG 10240 #define PRINT_STATUS_ONLY 0 +#define REPLY_SIZE 128 +#define MPT_EXIT_OKAY (0) +#define MPT_EXIT_VOL_OPTIMAL (0) +#define MPT_EXIT_VOL_FAILED (1 << 1) +#define MPT_EXIT_VOL_DEGRADED (1 << 2) +#define MPT_EXIT_VOL_RESYNC (1 << 3) +#define MPT_EXIT_PHYSDISK_ERROR (1 << 4) +#define MPT_EXIT_PHYSDISK_WARN (1 << 5) +#define MPT_EXIT_UNKNOWN (1 << 0) + +#define MPT_EXIT_NOCLOSE (1 << 10) +#define MPT_EXIT_FREEMEM (1 << 11) + +#define DATA_DIR_NONE 0 +#define DATA_DIR_IN 1 +#define DATA_DIR_OUT 2 + +#define MPT_FLAGS_FREE_MEM 0x00 +#define MPT_FLAGS_KEEP_MEM 0x01 +#define MPT_FLAGS_DUMP_REPLY 0x02 +#define MPT_FLAGS_DUMP_DATA 0x04 + + + static char *wrong_scsi_id = "\nYou seem to have no SCSI disks attached to your HBA or you have\n" "them on a different scsi_id. To get your SCSI id, run:\n\n" " mpt-status -p\n"; +typedef struct _test_endianness { + union { + u32 foo; + u8 bar[4]; + } u; +} test_endianess_t; + +typedef struct mpt_ioctl_command mpiIoctlBlk_t; + #endif /* End of mpt-status.h */