View Javadoc

1   package org.jscsi.target.scsi.modeSense;
2   
3   
4   import java.nio.ByteBuffer;
5   
6   import org.jscsi.target.util.BitManip;
7   import org.jscsi.target.util.ReadWrite;
8   
9   
10  /**
11   * INFORMATION EXCEPTIONS CONTROL MODE PAGEs carry information about recent INFORMATION EXCEPTION SCSI errors.
12   * 
13   * @author Andreas Ergenzinger
14   */
15  public class InformationExceptionsControlModePage extends Page_0FormatModePage {
16  
17      /**
18       * If the performance (PERF) bit is set to zero, informational exception operations that are the cause of delays are
19       * acceptable. If the PERF bit is set to one, the device server shall not cause delays while doing informational
20       * exception operations. A PERF bit set to one may cause the device server to disable some or all of the
21       * informational exceptions operations, thereby limiting the reporting of informational exception conditions.
22       */
23      private final boolean performance;
24  
25      /**
26       * If background functions are supported and the Enable Background Function (EBF) bit is set to one, then the device
27       * server shall enable background functions. If the EBF bit is set to zero, the device server shall disable the
28       * functions.
29       * <p>
30       * For the purposes of the EBF bit, background functions are defined as idle time functions that may impact
31       * performance that are performed by a device server operating without errors but do not impact the reliability of
32       * the logical unit (e.g., read scan).
33       */
34      private final boolean enableBackgroundFunction;
35  
36      /**
37       * If the enable warning (EWASC) bit is set to zero, the device server shall disable reporting of the warning. The
38       * MRIE field is ignored when DEXCPT is set to one and EWASC is set to zero. If the EWASC bit is set to one, warning
39       * reporting shall be enabled. The method for reporting the warning when the EWASC bit is set to one is determined
40       * from the MRIE field.
41       */
42      private final boolean enableWarning;
43  
44      /**
45       * A disable exception control (DEXCPT) bit set to zero indicates the failure prediction threshold exceeded
46       * reporting shall be enabled. The method for reporting the failure prediction threshold exceeded when the DEXCPT
47       * bit is set to zero is determined from the MRIE field. A DEXCPT bit set to one indicates the device server shall
48       * disable reporting of the failure prediction threshold exceeded. The MRIE field is ignored when DEXCPT is set to
49       * one and EWASC is set to zero.
50       */
51      private final boolean disableExceptionControl;
52  
53      /**
54       * A TEST bit set to one shall create a test device failure at the next interval time, as specified by the INTERVAL
55       * TIMER field, if the DEXCPT bit is set to zero. When the TEST bit is set to one, the MRIE and REPORT COUNT fields
56       * shall apply as if the TEST bit were zero. The test device failure shall be reported with the additional sense
57       * code set to FAILURE PREDICTION THRESHOLD EXCEEDED (FALSE). If both the TEST bit and the DEXCPT bit are one, the
58       * MODE SELECT command shall be terminated with CHECK CONDITION status, with the sense key set to ILLEGAL REQUEST,
59       * and the additional sense code set to INVALID FIELD IN PARAMETER LIST. A TEST bit set to zero shall instruct the
60       * device server not to generate any test device failure notifications.
61       */
62      private final boolean test;
63  
64      /**
65       * If the log errors (LOGERR) bit is set to zero, the logging of informational exception conditions by a device
66       * server is vendor specific. If the LOGERR bit is set to one, the device server shall log informational exception
67       * conditions.
68       */
69      private final boolean logErrors;
70  
71      /**
72       * The value in the method of reporting informational exceptions (MRIE) field defines the method that shall be used
73       * by the device server to report informational exception conditions (see SPC3R23 table 257, p.294f). The priority
74       * of reporting multiple information exceptions is vendor specific.
75       */
76      private final int methodOfReportingInformationalExceptionConditions;
77  
78      /**
79       * The value in the INTERVAL TIMER field is the period in 100 millisecond increments for reporting that an
80       * informational exception condition has occurred. The device server shall not report informational exception
81       * conditions more frequently than the time specified by the INTERVAL TIMER field and shall report them after the
82       * time specified by INTERVAL TIMER field has elapsed. After the informational exception condition has been reported
83       * the interval timer shall be restarted.
84       * <p>
85       * A value of zero or FFFF FFFFh in the INTERVAL TIMER field indicates that the period for reporting an
86       * informational exception condition is vendor specific.
87       */
88      private final int intervalTimer;
89  
90      /**
91       * The value in the REPORT COUNT field is the number of times to report an informational exception condition to the
92       * application client. A value of zero in the REPORT COUNT field indicates there is no limit on the number of times
93       * the device server reports an informational exception condition.
94       */
95      private final int reportCount;
96  
97      public InformationExceptionsControlModePage (boolean parametersSaveable, final boolean performance, final boolean enableBackgroundFunction, final boolean enableWarning, final boolean disableExceptionControl, final boolean test, final boolean logErrors, final int methodOfReportingInformationalExceptionConditions, final int intervalTimer, final int reportCount) {
98          super(parametersSaveable,// PS
99          0x1c,// page code
100         0x0a);// page length
101         this.performance = performance;
102         this.enableBackgroundFunction = enableBackgroundFunction;
103         this.enableWarning = enableWarning;
104         this.disableExceptionControl = disableExceptionControl;
105         this.test = test;
106         this.logErrors = logErrors;
107         this.methodOfReportingInformationalExceptionConditions = methodOfReportingInformationalExceptionConditions;
108         this.intervalTimer = intervalTimer;
109         this.reportCount = reportCount;
110 
111     }
112 
113     @Override
114     protected void serializeModeParameters (ByteBuffer buffer, int index) {
115 
116         // byte 2 flags
117         buffer.position(index + 2);
118         byte b = 0;
119         b = BitManip.getByteWithBitSet(b, 7, performance);// PERF
120         b = BitManip.getByteWithBitSet(b, 5, enableBackgroundFunction);// PERF
121         b = BitManip.getByteWithBitSet(b, 4, enableWarning);// EWASC
122         b = BitManip.getByteWithBitSet(b, 3, disableExceptionControl);// DEXCPT
123         b = BitManip.getByteWithBitSet(b, 2, test);// TEST
124         b = BitManip.getByteWithBitSet(b, 0, logErrors);// LOGERR
125         buffer.put(b);
126 
127         // byte 3
128         b = (byte) (methodOfReportingInformationalExceptionConditions & 31);// MRIE
129         buffer.put(b);
130 
131         // INTERVAL TIMER and REPORT COUNT
132         ReadWrite.writeInt(intervalTimer,// value
133                 buffer,// buffer
134                 index + 4);// start index
135         ReadWrite.writeInt(reportCount,// value
136                 buffer,// buffer
137                 index + 8);// start index
138     }
139 
140 }