Hardware/HDD/SSDSandforce.cs
changeset 339 07a6126a4796
parent 338 f580591971ce
child 340 600962f8a298
     1.1 --- a/Hardware/HDD/SSDSandforce.cs	Mon Feb 13 20:34:39 2012 +0000
     1.2 +++ b/Hardware/HDD/SSDSandforce.cs	Mon Feb 13 21:56:29 2012 +0000
     1.3 @@ -44,30 +44,58 @@
     1.4  
     1.5      private static readonly IEnumerable<SmartAttribute> smartAttributes =
     1.6        new List<SmartAttribute> {
     1.7 -      new SmartAttribute(0x05, SmartNames.RetiredBlockCount),
     1.8 +      new SmartAttribute(0x01, SmartNames.RawReadErrorRate),
     1.9 +      new SmartAttribute(0x05, SmartNames.RetiredBlockCount, RawToInt),
    1.10        new SmartAttribute(0x09, SmartNames.PowerOnHours, RawToInt),
    1.11        new SmartAttribute(0x0C, SmartNames.PowerCycleCount, RawToInt),
    1.12 -      new SmartAttribute(0xAB, SmartNames.ProgramFailCount),
    1.13 -      new SmartAttribute(0xAC, SmartNames.EraseFailCount),
    1.14 -      new SmartAttribute(0xAE, SmartNames.UnexpectedPowerLossCount),
    1.15 -      new SmartAttribute(0xB1, SmartNames.WearRangeDelta),
    1.16 -      new SmartAttribute(0xB5, SmartNames.AlternativeProgramFailCount),
    1.17 -      new SmartAttribute(0xB6, SmartNames.AlternativeEraseFailCount),
    1.18 +      new SmartAttribute(0xAB, SmartNames.ProgramFailCount, RawToInt),
    1.19 +      new SmartAttribute(0xAC, SmartNames.EraseFailCount, RawToInt),
    1.20 +      new SmartAttribute(0xAE, SmartNames.UnexpectedPowerLossCount, RawToInt),
    1.21 +      new SmartAttribute(0xB1, SmartNames.WearRangeDelta, RawToInt),
    1.22 +      new SmartAttribute(0xB5, SmartNames.AlternativeProgramFailCount, RawToInt),
    1.23 +      new SmartAttribute(0xB6, SmartNames.AlternativeEraseFailCount, RawToInt),
    1.24 +      new SmartAttribute(0xBB, SmartNames.UncorrectableErrorCount, RawToInt),
    1.25 +      new SmartAttribute(0xC2, SmartNames.Temperature, 
    1.26 +        (byte[] raw, byte value) => { return value; }), 
    1.27        new SmartAttribute(0xC3, SmartNames.UnrecoverableEcc), 
    1.28 -      new SmartAttribute(0xC4, SmartNames.ReallocationEventCount),
    1.29 -      new SmartAttribute(0xE7, SmartNames.RemainingLife, 
    1.30 -        null, SensorType.Level, 0),
    1.31 -      new SmartAttribute(0xF1, SmartNames.HostWrites, 
    1.32 -        (byte[] r, byte v) => { return RawToInt(r, v); }, 
    1.33 +      new SmartAttribute(0xC4, SmartNames.ReallocationEventCount, RawToInt),
    1.34 +      new SmartAttribute(0xE7, SmartNames.RemainingLife, null, 
    1.35 +        SensorType.Level, 0),
    1.36 +      new SmartAttribute(0xE9, SmartNames.ControllerWritesToNAND, RawToInt,
    1.37          SensorType.Data, 0),
    1.38 -      new SmartAttribute(0xF2, SmartNames.HostReads, 
    1.39 -        (byte[] r, byte v) => { return RawToInt(r, v); }, 
    1.40 -        SensorType.Data, 1)
    1.41 +      new SmartAttribute(0xEA, SmartNames.HostWritesToController, RawToInt, 
    1.42 +        SensorType.Data, 1),
    1.43 +      new SmartAttribute(0xF1, SmartNames.HostWrites, RawToInt, 
    1.44 +        SensorType.Data, 1),
    1.45 +      new SmartAttribute(0xF2, SmartNames.HostReads, RawToInt, 
    1.46 +        SensorType.Data, 2)
    1.47      };
    1.48  
    1.49 +    private Sensor writeAmplification;
    1.50 +
    1.51      public SSDSandforce(ISmart smart, string name, string firmwareRevision, 
    1.52        int index, ISettings settings) 
    1.53        : base(smart, name, firmwareRevision,  index, smartAttributes, settings) 
    1.54 -    { }
    1.55 +    {
    1.56 +      this.writeAmplification = new Sensor("Write Amplification", 1, 
    1.57 +        SensorType.Level, this, settings);    
    1.58 +    }
    1.59 +
    1.60 +    public override void UpdateAdditionalSensors(DriveAttributeValue[] values) {
    1.61 +      float? controllerWritesToNAND = null;
    1.62 +      float? hostWritesToController = null;
    1.63 +      foreach (DriveAttributeValue value in values) {
    1.64 +        if (value.Identifier == 0xE9)
    1.65 +          controllerWritesToNAND = RawToInt(value.RawValue, value.AttrValue);
    1.66 +
    1.67 +        if (value.Identifier == 0xEA)
    1.68 +          hostWritesToController = RawToInt(value.RawValue, value.AttrValue);
    1.69 +      }
    1.70 +      if (controllerWritesToNAND.HasValue && hostWritesToController.HasValue) {
    1.71 +        writeAmplification.Value = 100 *
    1.72 +          controllerWritesToNAND.Value / hostWritesToController.Value;
    1.73 +        ActivateSensor(writeAmplification);
    1.74 +      }
    1.75 +    }
    1.76    }
    1.77  }