public static StorApiStatus Initialize() { byte b = 0; lock (MarvellUtil.mvApiLock) { if (!MarvellUtil.apiInitialized) { try { b = MvApi.MvApi.MV_API_Initialize(); } catch (Exception ex) { Logger.Warn("MV_API_Initialize exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } if (b == 0) { MarvellUtil.apiInitialized = true; } } } return(MarvellUtil.ToStorApiStatus(b)); }
public static StorApiStatus Initialize() { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; if (Storage.initialized) { return(storApiStatus); } storApiStatus = MarvellUtil.Initialize(); if (storApiStatus != StorApiStatusEnum.STOR_NO_ERROR) { Storage.Debug("Marvell initialization failed: {0}", new object[] { storApiStatus }); } storApiStatus = SpacesUtil.Initialize(); if (storApiStatus != StorApiStatusEnum.STOR_NO_ERROR) { Storage.Debug("Storage Spaces initialization failed: {0}", new object[] { storApiStatus }); } return(StorApiStatusEnum.STOR_NO_ERROR); }
public override StorApiStatus DeleteVolume(string id) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; byte mvstatus = 0; Volume volume = this.FindVolume(id); if (volume == null || !(volume is MarvellVolume)) { return(StorApiStatusEnum.STOR_INVALID_PARAM); } lock (MarvellUtil.mvApiLock) { try { mvstatus = MvApi.MvApi.MV_LD_Delete(this.AdapterId, ((MarvellVolume)volume).MvId, 1); } catch (Exception ex) { Logger.Warn("MV_LD_Delete exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } return(MarvellUtil.ToStorApiStatus(mvstatus)); }
public override StorApiStatus Verify(bool fixError) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; byte b = 0; byte type = 0; if (fixError) { type = 1; } lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_LD_StartConsistencyCheck(((MarvellController)this.controller).AdapterId, this.mvid, type); } catch (Exception ex) { Logger.Warn("MV_LD_StartConsistencyCheck exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } if (b != 0) { storApiStatus = MarvellUtil.ToStorApiStatus(b); storApiStatus.internalIntData = (int)b; } return(storApiStatus); }
public override StorApiStatus Rebuild(List <Drive> newDrives) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; byte b = 0; if (newDrives == null || newDrives.Count == 0) { return(StorApiStatusEnum.STOR_INVALID_PARAM); } if (!(newDrives[0] is MarvellDrive)) { return(StorApiStatusEnum.STOR_INVALID_PARAM); } lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_LD_StartRebuild(((MarvellController)this.controller).AdapterId, this.mvid, ((MarvellDrive)newDrives[0]).MvId); } catch (Exception ex) { Logger.Warn("MV_LD_StartRebuild exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } if (b != 0) { storApiStatus = MarvellUtil.ToStorApiStatus(b); storApiStatus.internalIntData = (int)b; } return(storApiStatus); }
public override StorApiStatus GetSmart(ref SmartInfo smart) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; byte b = 0; MvApi.MvApi.SMART_Info_Request smart_Info_Request = default(MvApi.MvApi.SMART_Info_Request); smart_Info_Request.header.Init(); smart_Info_Request.header.requestType = 1; smart_Info_Request.header.startingIndexOrId = 0; smart_Info_Request.header.numRequested = 30; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_PD_GET_SMART_INFO(((MarvellController)this.controller).AdapterId, this.mvid, ref smart_Info_Request); } catch (Exception ex) { Logger.Warn("MV_PD_GET_SMART_INFO exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } if (b == 0) { if (smart == null) { smart = new SmartInfo(); } smart.attributes = new SmartAttribute[(int)smart_Info_Request.header.numReturned]; smart.thresholds = new SmartThreshold[(int)smart_Info_Request.header.numReturned]; for (short num = 0; num < smart_Info_Request.header.numReturned; num += 1) { SmartAttribute smartAttribute = new SmartAttribute(); SmartThreshold smartThreshold = new SmartThreshold(); smartAttribute.id = smart_Info_Request.SmartInfo[(int)num].Id; smartAttribute.flags = (ushort)((int)smart_Info_Request.SmartInfo[(int)num].StatusFlags1 << 8 | (int)smart_Info_Request.SmartInfo[(int)num].StatusFlags2); smartAttribute.current = smart_Info_Request.SmartInfo[(int)num].CurrentValue; smartAttribute.worst = smart_Info_Request.SmartInfo[(int)num].WorstValue; Array.Copy(smart_Info_Request.SmartInfo[(int)num].RawValue, smartAttribute.raw, smartAttribute.raw.Length); smartThreshold.id = smart_Info_Request.SmartInfo[(int)num].Id; smartThreshold.value = smart_Info_Request.SmartInfo[(int)num].ThresholdValue; smart.attributes[(int)num] = smartAttribute; smart.thresholds[(int)num] = smartThreshold; } } return(MarvellUtil.ToStorApiStatus(b)); }
public override StorApiStatus CreateVolume(CreateVolumeData data) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; byte mvstatus = 0; MvApi.MvApi.Create_LD_Param create_LD_Param = default(MvApi.MvApi.Create_LD_Param); int num = 0; create_LD_Param.RaidMode = MarvellUtil.ToMarvellRaidLevel(data.level); create_LD_Param.RoundingScheme = 0; create_LD_Param.InitializationOption = 0; create_LD_Param.CachePolicy = (byte)(data.writeCache ? 0 : 1); create_LD_Param.StripeBlockSize = (short)data.stripeSize; create_LD_Param.HDIDs = new short[128]; foreach (Drive drive in data.drives) { if (num >= 128) { return(StorApiStatusEnum.STOR_INVALID_PARAM); } create_LD_Param.HDIDs[num] = ((MarvellDrive)drive).MvId; num++; } create_LD_Param.HDCount = (byte)num; create_LD_Param.Name = new byte[16]; byte[] bytes = Encoding.ASCII.GetBytes(data.name); if (bytes.Length >= 16) { return(StorApiStatusEnum.STOR_INVALID_PARAM); } bytes.CopyTo(create_LD_Param.Name, 0); lock (MarvellUtil.mvApiLock) { try { mvstatus = MvApi.MvApi.MV_LD_Create(this.AdapterId, ref create_LD_Param); } catch (Exception ex) { Logger.Warn("MV_LD_Create exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } return(MarvellUtil.ToStorApiStatus(mvstatus)); }
public override StorApiStatus Initialize(VolumeInitializeType type) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; byte b = 0; byte init_Type = 3; switch (type) { case VolumeInitializeType.INIT_QUICK: init_Type = 0; break; case VolumeInitializeType.INIT_FULLFG: init_Type = 1; break; case VolumeInitializeType.INIT_FULLBG: init_Type = 2; break; } lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_LD_StartINIT(((MarvellController)this.controller).AdapterId, this.mvid, init_Type); } catch (Exception ex) { Logger.Warn("MV_LD_StartINIT exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } if (b != 0) { storApiStatus = MarvellUtil.ToStorApiStatus(b); storApiStatus.internalIntData = (int)b; } return(storApiStatus); }
public static StorApiStatus Finalize() { StorApiStatus storApiStatus = MarvellUtil.Finalize(); if (storApiStatus != StorApiStatusEnum.STOR_NO_ERROR) { Storage.Debug("Marvell finalize failed: {0}", new object[] { storApiStatus }); } storApiStatus = SpacesUtil.Finalize(); if (storApiStatus != StorApiStatusEnum.STOR_NO_ERROR) { Storage.Debug("Storage Spaces finalize failed: {0}", new object[] { storApiStatus }); } return(StorApiStatusEnum.STOR_NO_ERROR); }
public static StorApiStatus Finalize() { StorApiStatus result; lock (MarvellUtil.mvApiLock) { try { result = MarvellUtil.ToStorApiStatus(MvApi.MvApi.MV_API_Finalize()); } catch (Exception ex) { Logger.Warn("MV_API_Finalize exception: {0}", new object[] { ex }); result = StorApiStatusEnum.STOR_API_ERROR; } } return(result); }
public override StorApiStatus IsWriteCacheOn(ref bool on) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; byte b = 0; MvApi.MvApi.HD_Config_Request hd_Config_Request = default(MvApi.MvApi.HD_Config_Request); hd_Config_Request.header.Init(); hd_Config_Request.header.requestType = 2; hd_Config_Request.header.startingIndexOrId = this.mvid; hd_Config_Request.header.numRequested = 1; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_PD_GetConfig(((MarvellController)this.controller).AdapterId, ref hd_Config_Request); } catch (Exception ex) { Logger.Warn("IsWriteCacheOn MV_PD_GetConfig exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } if (b == 0) { if (hd_Config_Request.header.numReturned != 1) { b = 55; } else { on = (hd_Config_Request.hdConfig[0].WriteCacheOn != 0); } } return(MarvellUtil.ToStorApiStatus(b)); }
public override StorApiStatus ATACmd(ref ATACmdInfo ata) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; byte b = 0; MvApi.MvApi.ATA_REGS ata_REGS = default(MvApi.MvApi.ATA_REGS); ata_REGS.Init(); Array.Copy(ata.registers, ata_REGS.drive_regs, ata_REGS.drive_regs.Length); if (ata.datalen > 0u) { if (ata.data == null || (long)ata.data.Length != (long)((ulong)ata.datalen)) { return(StorApiStatusEnum.STOR_INVALID_PARAM); } ata_REGS.buffer_size = (short)ata.datalen; } lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_PassThrough_ATA_Helper(((MarvellController)this.controller).AdapterId, this.mvid, ref ata_REGS, ref ata.data); } catch (Exception ex) { Logger.Warn("MV_PassThrough_ATA_Helper exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } if (b == 0) { Array.Copy(ata_REGS.drive_regs, ata.registers, ata.registers.Length); } return(MarvellUtil.ToStorApiStatus(b)); }
protected MarvellDrive MakeDrive(MvApi.MvApi.HD_Info hdInfo) { byte b = 0; StorApiStatus a = StorApiStatusEnum.STOR_NO_ERROR; MarvellDrive marvellDrive = new MarvellDrive(hdInfo.Link.Self.DevID, this); marvellDrive.Port = this.GetDrivePort(hdInfo); marvellDrive.Model = MarvellUtil.GetApiString(hdInfo.Model, 40); marvellDrive.Serial = MarvellUtil.GetApiString(hdInfo.SerialNo, 20); marvellDrive.Revision = MarvellUtil.GetApiString(hdInfo.FWVersion, 8); marvellDrive.SectorSize = (ulong)((hdInfo.BlockSize == 0u) ? 512u : hdInfo.BlockSize); marvellDrive.SectorCount = hdInfo.Size.ToUlong() * 1024UL / marvellDrive.SectorSize; marvellDrive.IsSmartEnabled = false; marvellDrive.IsSystem = false; marvellDrive.Status = DriveStatus.DRIVE_UNKNOWN; marvellDrive.Domain = DriveDomain.DRIVE_DOMAIN_UNKNOWN; short[] id = new short[] { hdInfo.Link.Self.DevID }; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_DiskHasOS(this.AdapterId, 1, 1, id); } catch (Exception ex) { Logger.Warn("MV_DiskHasOS exception: {0}", new object[] { ex }); throw ex; } } if (b == 159) { marvellDrive.IsSystem = true; } MvApi.MvApi.HD_Config_Request hd_Config_Request = default(MvApi.MvApi.HD_Config_Request); hd_Config_Request.header.Init(); hd_Config_Request.header.requestType = 2; hd_Config_Request.header.startingIndexOrId = hdInfo.Link.Self.DevID; hd_Config_Request.header.numRequested = 1; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_PD_GetConfig(this.AdapterId, ref hd_Config_Request); } catch (Exception ex2) { Logger.Warn("MV_PD_GetConfig exception: {0}", new object[] { ex2 }); throw ex2; } } marvellDrive.IsSmartEnabled = (hd_Config_Request.hdConfig[0].SMARTOn == 1); if (!marvellDrive.IsSmartEnabled) { a = marvellDrive.EnableSmart(); if (a == StorApiStatusEnum.STOR_NO_ERROR) { marvellDrive.IsSmartEnabled = true; } } return(marvellDrive); }
protected MarvellVolume MakeVolume(MvApi.MvApi.LD_Info ldInfo) { byte b = 0; MarvellVolume marvellVolume = new MarvellVolume(ldInfo.ID, this); marvellVolume.Name = MarvellUtil.GetApiString(ldInfo.Name, 16); marvellVolume.RaidLevel = MarvellUtil.ToStorApiRaidLevel(ldInfo.RaidMode); marvellVolume.StripeSize = (ulong)((long)(ldInfo.StripeBlockSize * 1024)); marvellVolume.Status = MarvellUtil.ToStorApiVolumeStatus(ldInfo.Status); marvellVolume.Capacity = ldInfo.Size.ToUlong() * 1024UL; for (byte b2 = 0; b2 < ldInfo.HDCount; b2 += 1) { marvellVolume.BlockIds.Add(ldInfo.BlockIDs[(int)b2]); } short[] id = new short[] { ldInfo.ID }; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_DiskHasOS(this.AdapterId, 0, 1, id); } catch (Exception ex) { Logger.Warn("MakeVolume MV_DiskHasOS exception: {0}", new object[] { ex }); throw ex; } } if (b == 158) { marvellVolume.IsSystem = true; } if (ldInfo.BGAStatus != 0) { MvApi.MvApi.LD_Status_Request ld_Status_Request = default(MvApi.MvApi.LD_Status_Request); ld_Status_Request.header.Init(); ld_Status_Request.header.requestType = 2; ld_Status_Request.header.startingIndexOrId = ldInfo.ID; ld_Status_Request.header.numRequested = 1; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_LD_GetStatus(this.AdapterId, ref ld_Status_Request); } catch (Exception ex2) { Logger.Warn("MV_LD_GetStatus exception: {0}", new object[] { ex2 }); throw ex2; } } if (b == 0) { marvellVolume.Progress = (float)ld_Status_Request.ldStatus[0].BgaPercentage; if (ld_Status_Request.ldStatus[0].Bga != 0 && marvellVolume.Status != VolumeStatus.VOLUME_FAILED) { VolumeStatus volumeStatus = MarvellUtil.ToStorApiVolumeStatusBGA(ld_Status_Request.ldStatus[0].Bga); if (volumeStatus != VolumeStatus.VOLUME_UNKNOWN) { marvellVolume.Status = volumeStatus; } } if (ld_Status_Request.ldStatus[0].Bga == 32) { MvApi.MvApi.LD_Info ld_Info = default(MvApi.MvApi.LD_Info); lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_LD_GetTargetLDInfo(this.AdapterId, ldInfo.ID, ref ld_Info); } catch (Exception ex3) { Logger.Warn("MV_LD_GetTargetLDInfo exception: {0}", new object[] { ex3 }); throw ex3; } } if (b == 0) { marvellVolume.RaidLevel = MarvellUtil.ToStorApiRaidLevel(ld_Info.RaidMode); marvellVolume.StripeSize = (ulong)ld_Info.StripeBlockSize; marvellVolume.BlockIds.Clear(); for (byte b3 = 0; b3 < ld_Info.HDCount; b3 += 1) { marvellVolume.BlockIds.Add(ld_Info.BlockIDs[(int)b3]); } } } } } return(marvellVolume); }
public override StorApiStatus Migrate(RaidLevel newLevel, List <Drive> newDrives) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; byte b = 0; MvApi.MvApi.Create_LD_Param create_LD_Param = default(MvApi.MvApi.Create_LD_Param); MvApi.MvApi.LD_Config_Request ld_Config_Request = default(MvApi.MvApi.LD_Config_Request); int num = 0; ld_Config_Request.header.Init(); ld_Config_Request.header.requestType = 2; ld_Config_Request.header.startingIndexOrId = this.mvid; ld_Config_Request.header.numRequested = 1; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_LD_GetConfig(((MarvellController)this.controller).AdapterId, ref ld_Config_Request); } catch (Exception ex) { Logger.Warn("MV_LD_GetConfig exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } if (b != 0) { storApiStatus = MarvellUtil.ToStorApiStatus(b); storApiStatus.internalIntData = (int)b; Logger.Warn("MV_LD_GetConfig failed: {0}", new object[] { b }); return(storApiStatus); } string @string = Encoding.ASCII.GetString(ld_Config_Request.ldConfig[0].Name); create_LD_Param.LDID = this.MvId; create_LD_Param.RaidMode = MarvellUtil.ToMarvellRaidLevel(newLevel); create_LD_Param.RoundingScheme = 0; create_LD_Param.InitializationOption = 0; create_LD_Param.HDIDs = new short[128]; foreach (Drive drive in this.drives) { if (num >= 128) { storApiStatus = StorApiStatusEnum.STOR_INVALID_PARAM; return(storApiStatus); } create_LD_Param.HDIDs[num] = ((MarvellDrive)drive).MvId; num++; } foreach (Drive drive2 in newDrives) { if (num >= 128) { storApiStatus = StorApiStatusEnum.STOR_INVALID_PARAM; return(storApiStatus); } create_LD_Param.HDIDs[num] = ((MarvellDrive)drive2).MvId; num++; } create_LD_Param.HDCount = (byte)num; create_LD_Param.Name = new byte[16]; ld_Config_Request.ldConfig[0].Name.CopyTo(create_LD_Param.Name, 0); Logger.Debug("Migrate parameter: LD={0}, RAID={1}, HDCount={2}, HD={3}, Name={4}", new object[] { create_LD_Param.LDID, create_LD_Param.RaidMode, create_LD_Param.HDCount, string.Join <short>(" ", create_LD_Param.HDIDs.ToList <short>().GetRange(0, (int)create_LD_Param.HDCount)), @string }); try { b = MvApi.MvApi.MV_LD_StartMigration(((MarvellController)this.controller).AdapterId, ref create_LD_Param); } catch (Exception ex2) { Logger.Warn("MV_LD_StartMigration exception: {0}", new object[] { ex2 }); return(StorApiStatusEnum.STOR_API_ERROR); } if (b != 0) { storApiStatus = MarvellUtil.ToStorApiStatus(b); storApiStatus.internalIntData = (int)b; Logger.Warn("MV_LD_StartMigration failed: {0}", new object[] { b }); } } return(storApiStatus); }
public new static StorApiStatus GetControllers(ref List <Controller> controllers) { StorApiStatus result = StorApiStatusEnum.STOR_NO_ERROR; byte b = 0; byte b2 = 0; lock (MarvellUtil.mvApiLock) { try { b2 = MvApi.MvApi.MV_Adapter_GetCount(); } catch (Exception ex) { Logger.Warn("MV_Adapter_GetCount exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } Storage.Debug("MV_Adapter_GetCount: {0}", new object[] { b2 }); for (byte b3 = 0; b3 < b2; b3 += 1) { byte b4 = 0; MvApi.MvApi.Adapter_Info adapter_Info = default(MvApi.MvApi.Adapter_Info); lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_Adapter_GetInfo(b3, ref b4, ref adapter_Info); } catch (Exception ex2) { Logger.Warn("MV_Adapter_GetInfo exception: {0}", new object[] { ex2 }); return(StorApiStatusEnum.STOR_API_ERROR); } } Storage.Debug("MV_Adapter_GetInfo: mvstatus={0}, count={1}", new object[] { b, b2 }); if (b != 0 || b4 != 1) { result = MarvellUtil.ToStorApiStatus(b); break; } if (controllers == null) { controllers = new List <Controller>(); } MarvellController marvellController = new MarvellController(b3); marvellController.vendorId = (int)adapter_Info.VenID; marvellController.maxHDSupported = (int)adapter_Info.MaxHD; Storage.Debug("AdvancedFeatures: {0:X}", new object[] { adapter_Info.AdvancedFeatures }); Storage.Debug("Supports ATA passthru: {0}", new object[] { ((adapter_Info.AdvancedFeatures & 134217728) != 0) ? "yes" : "no" }); controllers.Add(marvellController); } return(result); }
public override StorApiStatus SetWriteCache(bool on) { StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR; byte b = 0; MvApi.MvApi.HD_Config_Request hd_Config_Request = default(MvApi.MvApi.HD_Config_Request); hd_Config_Request.header.Init(); hd_Config_Request.header.requestType = 2; hd_Config_Request.header.startingIndexOrId = this.mvid; hd_Config_Request.header.numRequested = 1; lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_PD_GetConfig(((MarvellController)this.controller).AdapterId, ref hd_Config_Request); } catch (Exception ex) { Logger.Warn("SetWriteCache MV_PD_GetConfig exception: {0}", new object[] { ex }); return(StorApiStatusEnum.STOR_API_ERROR); } } if (b == 0) { if (hd_Config_Request.header.numReturned != 1) { b = 55; } else { bool writeCacheOn = hd_Config_Request.hdConfig[0].WriteCacheOn != 0; if (writeCacheOn != on) { hd_Config_Request.hdConfig[0].WriteCacheOn = (byte)((!on) ? 0 : 1); IntPtr intPtr = StorHelper.AllocateIntPtr <MvApi.MvApi.HD_Config>(hd_Config_Request.hdConfig[0]); if (intPtr != IntPtr.Zero) { lock (MarvellUtil.mvApiLock) { try { b = MvApi.MvApi.MV_PD_SetConfig(((MarvellController)this.controller).AdapterId, this.mvid, intPtr); } catch (Exception ex2) { StorHelper.FreeIntPtr(intPtr); Logger.Warn("MV_PD_SetConfig exception: {0}", new object[] { ex2 }); return(StorApiStatusEnum.STOR_API_ERROR); } } StorHelper.FreeIntPtr(intPtr); } } } } return(MarvellUtil.ToStorApiStatus(b)); }