ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-ia64 / sn / ioerror.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_H
9 #define _ASM_IA64_SN_IOERROR_H
10
11 #ifndef __ASSEMBLY__
12
13 #include <linux/types.h>
14 #include <asm/sn/types.h>
15
16 /*
17  * Macros defining the various Errors to be handled as part of
18  * IO Error handling.
19  */
20
21 /*
22  * List of errors to be handled by each subsystem.
23  * "error_code" field will take one of these values.
24  * The error code is built up of single bits expressing
25  * our confidence that the error was that type; note
26  * that it is possible to have a PIO or DMA error where
27  * we don't know whether it was a READ or a WRITE, or
28  * even a READ or WRITE error that we're not sure whether
29  * to call a PIO or DMA.
30  *
31  * It is also possible to set both PIO and DMA, and possible
32  * to set both READ and WRITE; the first may be nonsensical
33  * but the second *could* be used to designate an access
34  * that is known to be a read-modify-write cycle. It is
35  * quite possible that nobody will ever use PIO|DMA or
36  * READ|WRITE ... but being flexible is good.
37  */
38 #define IOECODE_UNSPEC          0
39 #define IOECODE_READ            1
40 #define IOECODE_WRITE           2
41 #define IOECODE_PIO             4
42 #define IOECODE_DMA             8
43
44 #define IOECODE_PIO_READ        (IOECODE_PIO|IOECODE_READ)
45 #define IOECODE_PIO_WRITE       (IOECODE_PIO|IOECODE_WRITE)
46 #define IOECODE_DMA_READ        (IOECODE_DMA|IOECODE_READ)
47 #define IOECODE_DMA_WRITE       (IOECODE_DMA|IOECODE_WRITE)
48
49 /* support older names, but try to move everything
50  * to using new names that identify which package
51  * controls their values ...
52  */
53 #define PIO_READ_ERROR          IOECODE_PIO_READ
54 #define PIO_WRITE_ERROR         IOECODE_PIO_WRITE
55 #define DMA_READ_ERROR          IOECODE_DMA_READ
56 #define DMA_WRITE_ERROR         IOECODE_DMA_WRITE
57
58 /*
59  * List of error numbers returned by error handling sub-system.
60  */
61
62 #define IOERROR_HANDLED         0       /* Error Properly handled.        */
63 #define IOERROR_NODEV           0x1     /* No such device attached        */
64 #define IOERROR_BADHANDLE       0x2     /* Received bad handle            */
65 #define IOERROR_BADWIDGETNUM    0x3     /* Bad widget number              */
66 #define IOERROR_BADERRORCODE    0x4     /* Bad error code passed in       */
67 #define IOERROR_INVALIDADDR     0x5     /* Invalid address specified      */
68
69 #define IOERROR_WIDGETLEVEL     0x6     /* Some failure at widget level    */
70 #define IOERROR_XTALKLEVEL      0x7
71
72 #define IOERROR_HWGRAPH_LOOKUP  0x8     /* hwgraph lookup failed for path  */
73 #define IOERROR_UNHANDLED       0x9     /* handler rejected error          */
74
75 #define IOERROR_PANIC           0xA     /* subsidiary handler has already
76                                          * started decode: continue error
77                                          * data dump, and panic from top
78                                          * caller in error chain.
79                                          */
80
81 /*
82  * IO errors at the bus/device driver level
83  */
84
85 #define IOERROR_DEV_NOTFOUND    0x10    /* Device matching bus addr not found */
86 #define IOERROR_DEV_SHUTDOWN    0x11    /* Device has been shutdown        */
87
88 /*
89  * Type of address.
90  * Indicates the direction of transfer that caused the error.
91  */
92 #define IOERROR_ADDR_PIO        1       /* Error Address generated due to PIO */
93 #define IOERROR_ADDR_DMA        2       /* Error address generated due to DMA */
94
95 /*
96  * IO error structure.
97  *
98  * This structure would expand to hold the information retrieved from
99  * all IO related error registers.
100  *
101  * This structure is defined to hold all system specific
102  * information related to a single error.
103  *
104  * This serves a couple of purpose.
105  *      - Error handling often involves translating one form of address to other
106  *        form. So, instead of having different data structures at each level,
107  *        we have a single structure, and the appropriate fields get filled in
108  *        at each layer.
109  *      - This provides a way to dump all error related information in any layer
110  *        of erorr handling (debugging aid).
111  *
112  * A second possibility is to allow each layer to define its own error
113  * data structure, and fill in the proper fields. This has the advantage
114  * of isolating the layers.
115  * A big concern is the potential stack usage (and overflow), if each layer
116  * defines these structures on stack (assuming we don't want to do kmalloc.
117  *
118  * Any layer wishing to pass extra information to a layer next to it in
119  * error handling hierarchy, can do so as a separate parameter.
120  */
121
122 typedef struct io_error_s {
123     /* Bit fields indicating which structure fields are valid */
124     union {
125         struct {
126             unsigned                ievb_errortype:1;
127             unsigned                ievb_widgetnum:1;
128             unsigned                ievb_widgetdev:1;
129             unsigned                ievb_srccpu:1;
130             unsigned                ievb_srcnode:1;
131             unsigned                ievb_errnode:1;
132             unsigned                ievb_sysioaddr:1;
133             unsigned                ievb_xtalkaddr:1;
134             unsigned                ievb_busspace:1;
135             unsigned                ievb_busaddr:1;
136             unsigned                ievb_vaddr:1;
137             unsigned                ievb_memaddr:1;
138             unsigned                ievb_epc:1;
139             unsigned                ievb_ef:1;
140             unsigned                ievb_tnum:1;
141         } iev_b;
142         unsigned                iev_a;
143     } ie_v;
144
145     short                   ie_errortype;       /* error type: extra info about error */
146     short                   ie_widgetnum;       /* Widget number that's in error */
147     short                   ie_widgetdev;       /* Device within widget in error */
148     cpuid_t                 ie_srccpu;  /* CPU on srcnode generating error */
149     cnodeid_t               ie_srcnode;         /* Node which caused the error   */
150     cnodeid_t               ie_errnode;         /* Node where error was noticed  */
151     iopaddr_t               ie_sysioaddr;       /* Sys specific IO address       */
152     iopaddr_t               ie_xtalkaddr;       /* Xtalk (48bit) addr of Error   */
153     iopaddr_t               ie_busspace;        /* Bus specific address space    */
154     iopaddr_t               ie_busaddr;         /* Bus specific address          */
155     caddr_t                 ie_vaddr;   /* Virtual address of error      */
156     paddr_t                 ie_memaddr;         /* Physical memory address       */
157     caddr_t                 ie_epc;             /* pc when error reported        */
158     caddr_t                 ie_ef;              /* eframe when error reported    */
159     short                   ie_tnum;            /* Xtalk TNUM field */
160 } ioerror_t;
161
162 #define IOERROR_INIT(e)         do { (e)->ie_v.iev_a = 0; } while (0)
163 #define IOERROR_SETVALUE(e,f,v) do { (e)->ie_ ## f = (v); (e)->ie_v.iev_b.ievb_ ## f = 1; } while (0)
164 #define IOERROR_FIELDVALID(e,f) ((unsigned long long)((e)->ie_v.iev_b.ievb_ ## f) != (unsigned long long) 0)
165 #define IOERROR_NOGETVALUE(e,f) (ASSERT(IOERROR_FIELDVALID(e,f)), ((e)->ie_ ## f))
166 #define IOERROR_GETVALUE(p,e,f) ASSERT(IOERROR_FIELDVALID(e,f)); p=((e)->ie_ ## f)
167
168 /* hub code likes to call the SysAD address "hubaddr" ... */
169 #define ie_hubaddr      ie_sysioaddr
170 #define ievb_hubaddr    ievb_sysioaddr
171 #endif
172
173 /*
174  * Error handling Modes.
175  */
176 typedef enum {
177     MODE_DEVPROBE,              /* Probing mode. Errors not fatal */
178     MODE_DEVERROR,              /* Error while system is running */
179     MODE_DEVUSERERROR,          /* Device Error created due to user mode access */
180     MODE_DEVREENABLE            /* Reenable pass                */
181 } ioerror_mode_t;
182
183
184 typedef int             error_handler_f(void *, int, ioerror_mode_t, ioerror_t *);
185 typedef void           *error_handler_arg_t;
186
187 #ifdef  ERROR_DEBUG
188 #define IOERR_PRINTF(x) (x)
189 #else
190 #define IOERR_PRINTF(x)
191 #endif                          /* ERROR_DEBUG */
192
193 #endif /* _ASM_IA64_SN_IOERROR_H */