ioerror_handling.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:8k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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