efe846eccee0b4b0bf0d46a310ecf5796f930934
[linux-flexiantxendom0-3.2.10.git] / include / asm-ia64 / sn / ioerror_handling.h
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
7  */
8 #ifndef _ASM_IA64_SN_IOERROR_HANDLING_H
9 #define _ASM_IA64_SN_IOERROR_HANDLING_H
10
11 #include <linux/types.h>
12 #include <asm/sn/sgi.h>
13
14 #if __KERNEL__
15
16 /*
17  * Basic types required for io error handling interfaces.
18  */
19
20 /*
21  * Return code from the io error handling interfaces.
22  */
23
24 enum error_return_code_e {
25         /* Success */
26         ERROR_RETURN_CODE_SUCCESS,
27
28         /* Unknown failure */
29         ERROR_RETURN_CODE_GENERAL_FAILURE,
30
31         /* Nth error noticed while handling the first error */
32         ERROR_RETURN_CODE_NESTED_CALL,
33
34         /* State of the vertex is invalid */
35         ERROR_RETURN_CODE_INVALID_STATE,
36
37         /* Invalid action */
38         ERROR_RETURN_CODE_INVALID_ACTION,
39
40         /* Valid action but not cannot set it */
41         ERROR_RETURN_CODE_CANNOT_SET_ACTION,
42
43         /* Valid action but not possible for the current state */
44         ERROR_RETURN_CODE_CANNOT_PERFORM_ACTION,
45
46         /* Valid state but cannot change the state of the vertex to it */
47         ERROR_RETURN_CODE_CANNOT_SET_STATE,
48
49         /* ??? */
50         ERROR_RETURN_CODE_DUPLICATE,
51
52         /* Reached the root of the system critical graph */
53         ERROR_RETURN_CODE_SYS_CRITICAL_GRAPH_BEGIN,
54
55         /* Reached the leaf of the system critical graph */
56         ERROR_RETURN_CODE_SYS_CRITICAL_GRAPH_ADD,
57
58         /* Cannot shutdown the device in hw/sw */
59         ERROR_RETURN_CODE_SHUTDOWN_FAILED,
60
61         /* Cannot restart the device in hw/sw */
62         ERROR_RETURN_CODE_RESET_FAILED,
63
64         /* Cannot failover the io subsystem */
65         ERROR_RETURN_CODE_FAILOVER_FAILED,
66
67         /* No Jump Buffer exists */
68         ERROR_RETURN_CODE_NO_JUMP_BUFFER
69 };
70
71 typedef uint64_t  error_return_code_t;
72
73 /*
74  * State of the vertex during error handling.
75  */
76 enum error_state_e {
77         /* Ignore state */
78         ERROR_STATE_IGNORE,
79
80         /* Invalid state */
81         ERROR_STATE_NONE,
82
83         /* Trying to decipher the error bits */
84         ERROR_STATE_LOOKUP,
85
86         /* Trying to carryout the action decided upon after
87          * looking at the error bits 
88          */
89         ERROR_STATE_ACTION,
90
91         /* Donot allow any other operations to this vertex from
92          * other parts of the kernel. This is also used to indicate
93          * that the device has been software shutdown.
94          */
95         ERROR_STATE_SHUTDOWN,
96
97         /* This is a transitory state when no new requests are accepted
98          * on behalf of the device. This is usually used when trying to
99          * quiesce all the outstanding operations and preparing the
100          * device for a failover / shutdown etc.
101          */
102         ERROR_STATE_SHUTDOWN_IN_PROGRESS,
103
104         /* This is the state when there is absolutely no activity going
105          * on wrt device.
106          */
107         ERROR_STATE_SHUTDOWN_COMPLETE,
108         
109         /* This is the state when the device has issued a retry. */
110         ERROR_STATE_RETRY,
111
112         /* This is the normal state. This can also be used to indicate
113          * that the device has been software-enabled after software-
114          * shutting down previously.
115          */
116         ERROR_STATE_NORMAL
117         
118 };
119
120 typedef uint64_t  error_state_t;
121
122 /*
123  * Generic error classes. This is used to classify errors after looking
124  * at the error bits and helpful in deciding on the action.
125  */
126 enum error_class_e {
127         /* Unclassified error */
128         ERROR_CLASS_UNKNOWN,
129
130         /* LLP transmit error */
131         ERROR_CLASS_LLP_XMIT,
132
133         /* LLP receive error */
134         ERROR_CLASS_LLP_RECV,
135
136         /* Credit error */
137         ERROR_CLASS_CREDIT,
138
139         /* Timeout error */
140         ERROR_CLASS_TIMEOUT,
141
142         /* Access error */
143         ERROR_CLASS_ACCESS,
144
145         /* System coherency error */
146         ERROR_CLASS_SYS_COHERENCY,
147
148         /* Bad data error (ecc / parity etc) */
149         ERROR_CLASS_BAD_DATA,
150
151         /* Illegal request packet */
152         ERROR_CLASS_BAD_REQ_PKT,
153         
154         /* Illegal response packet */
155         ERROR_CLASS_BAD_RESP_PKT
156 };
157
158 typedef uint64_t  error_class_t;
159
160
161 /* 
162  * Error context which the error action can use.
163  */
164 typedef void                    *error_context_t;
165 #define ERROR_CONTEXT_IGNORE    ((error_context_t)-1ll)
166
167
168 /* 
169  * Error action type.
170  */
171 typedef error_return_code_t     (*error_action_f)( error_context_t);
172 #define ERROR_ACTION_IGNORE     ((error_action_f)-1ll)
173
174 /* Typical set of error actions */
175 typedef struct error_action_set_s {
176         error_action_f          eas_panic;
177         error_action_f          eas_shutdown;
178         error_action_f          eas_abort;
179         error_action_f          eas_retry;
180         error_action_f          eas_failover;
181         error_action_f          eas_log_n_ignore;
182         error_action_f          eas_reset;
183 } error_action_set_t;
184
185
186 /* Set of priorites for in case mutliple error actions/states
187  * are trying to be prescribed for a device.
188  * NOTE : The ordering below encapsulates the priorities. Highest value
189  * corresponds to highest priority.
190  */
191 enum error_priority_e {
192         ERROR_PRIORITY_IGNORE,
193         ERROR_PRIORITY_NONE,
194         ERROR_PRIORITY_NORMAL,
195         ERROR_PRIORITY_LOG,
196         ERROR_PRIORITY_FAILOVER,
197         ERROR_PRIORITY_RETRY,
198         ERROR_PRIORITY_ABORT,
199         ERROR_PRIORITY_SHUTDOWN,
200         ERROR_PRIORITY_RESTART,
201         ERROR_PRIORITY_PANIC
202 };
203
204 typedef uint64_t  error_priority_t;
205
206 /* Error action interfaces */
207
208 extern error_return_code_t      error_action_set(vertex_hdl_t,
209                                                  error_action_f,
210                                                  error_context_t,
211                                                  error_priority_t);
212 extern error_return_code_t      error_action_perform(vertex_hdl_t);
213
214
215 #define INFO_LBL_ERROR_SKIP_ENV "error_skip_env"
216
217 #define v_error_skip_env_get(v, l)              \
218 hwgraph_info_get_LBL(v, INFO_LBL_ERROR_SKIP_ENV, (arbitrary_info_t *)&l)
219
220 #define v_error_skip_env_set(v, l, r)           \
221 (r ?                                            \
222  hwgraph_info_replace_LBL(v, INFO_LBL_ERROR_SKIP_ENV, (arbitrary_info_t)l,0) :\
223  hwgraph_info_add_LBL(v, INFO_LBL_ERROR_SKIP_ENV, (arbitrary_info_t)l))
224
225 #define v_error_skip_env_clear(v)               \
226 hwgraph_info_remove_LBL(v, INFO_LBL_ERROR_SKIP_ENV, 0)
227
228 typedef uint64_t                counter_t;
229
230 extern counter_t                error_retry_count_get(vertex_hdl_t);
231 extern error_return_code_t      error_retry_count_set(vertex_hdl_t,counter_t);
232 extern counter_t                error_retry_count_increment(vertex_hdl_t);
233 extern counter_t                error_retry_count_decrement(vertex_hdl_t);
234
235 /* Except for the PIO Read error typically the other errors are handled in
236  * the context of an asynchronous error interrupt.
237  */
238 #define IS_ERROR_INTR_CONTEXT(_ec)      ((_ec & IOECODE_DMA)            || \
239                                          (_ec == IOECODE_PIO_WRITE))
240
241 #endif /* __KERNEL__ */
242 #endif /* _ASM_IA64_SN_IOERROR_HANDLING_H */