Convert trailing spaces and periods in path components
[linux/fpc-iii.git] / drivers / edac / edac_device.h
blob1aaba74ae411161bf6b6ab01267f7fe2fd2fe79b
1 /*
2 * Defines, structures, APIs for edac_device
4 * (C) 2007 Linux Networx (http://lnxi.com)
5 * This file may be distributed under the terms of the
6 * GNU General Public License.
8 * Written by Thayne Harbaugh
9 * Based on work by Dan Hollis <goemon at anime dot net> and others.
10 * http://www.anime.net/~goemon/linux-ecc/
12 * NMI handling support added by
13 * Dave Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>
15 * Refactored for multi-source files:
16 * Doug Thompson <norsk5@xmission.com>
18 * Please look at Documentation/driver-api/edac.rst for more info about
19 * EDAC core structs and functions.
22 #ifndef _EDAC_DEVICE_H_
23 #define _EDAC_DEVICE_H_
25 #include <linux/completion.h>
26 #include <linux/device.h>
27 #include <linux/edac.h>
28 #include <linux/kobject.h>
29 #include <linux/list.h>
30 #include <linux/types.h>
31 #include <linux/sysfs.h>
32 #include <linux/workqueue.h>
36 * The following are the structures to provide for a generic
37 * or abstract 'edac_device'. This set of structures and the
38 * code that implements the APIs for the same, provide for
39 * registering EDAC type devices which are NOT standard memory.
41 * CPU caches (L1 and L2)
42 * DMA engines
43 * Core CPU switches
44 * Fabric switch units
45 * PCIe interface controllers
46 * other EDAC/ECC type devices that can be monitored for
47 * errors, etc.
49 * It allows for a 2 level set of hierarchy. For example:
51 * cache could be composed of L1, L2 and L3 levels of cache.
52 * Each CPU core would have its own L1 cache, while sharing
53 * L2 and maybe L3 caches.
55 * View them arranged, via the sysfs presentation:
56 * /sys/devices/system/edac/..
58 * mc/ <existing memory device directory>
59 * cpu/cpu0/.. <L1 and L2 block directory>
60 * /L1-cache/ce_count
61 * /ue_count
62 * /L2-cache/ce_count
63 * /ue_count
64 * cpu/cpu1/.. <L1 and L2 block directory>
65 * /L1-cache/ce_count
66 * /ue_count
67 * /L2-cache/ce_count
68 * /ue_count
69 * ...
71 * the L1 and L2 directories would be "edac_device_block's"
74 struct edac_device_counter {
75 u32 ue_count;
76 u32 ce_count;
79 /* forward reference */
80 struct edac_device_ctl_info;
81 struct edac_device_block;
83 /* edac_dev_sysfs_attribute structure
84 * used for driver sysfs attributes in mem_ctl_info
85 * for extra controls and attributes:
86 * like high level error Injection controls
88 struct edac_dev_sysfs_attribute {
89 struct attribute attr;
90 ssize_t (*show)(struct edac_device_ctl_info *, char *);
91 ssize_t (*store)(struct edac_device_ctl_info *, const char *, size_t);
94 /* edac_dev_sysfs_block_attribute structure
96 * used in leaf 'block' nodes for adding controls/attributes
98 * each block in each instance of the containing control structure
99 * can have an array of the following. The show and store functions
100 * will be filled in with the show/store function in the
101 * low level driver.
103 * The 'value' field will be the actual value field used for
104 * counting
106 struct edac_dev_sysfs_block_attribute {
107 struct attribute attr;
108 ssize_t (*show)(struct kobject *, struct attribute *, char *);
109 ssize_t (*store)(struct kobject *, struct attribute *,
110 const char *, size_t);
111 struct edac_device_block *block;
113 unsigned int value;
116 /* device block control structure */
117 struct edac_device_block {
118 struct edac_device_instance *instance; /* Up Pointer */
119 char name[EDAC_DEVICE_NAME_LEN + 1];
121 struct edac_device_counter counters; /* basic UE and CE counters */
123 int nr_attribs; /* how many attributes */
125 /* this block's attributes, could be NULL */
126 struct edac_dev_sysfs_block_attribute *block_attributes;
128 /* edac sysfs device control */
129 struct kobject kobj;
132 /* device instance control structure */
133 struct edac_device_instance {
134 struct edac_device_ctl_info *ctl; /* Up pointer */
135 char name[EDAC_DEVICE_NAME_LEN + 4];
137 struct edac_device_counter counters; /* instance counters */
139 u32 nr_blocks; /* how many blocks */
140 struct edac_device_block *blocks; /* block array */
142 /* edac sysfs device control */
143 struct kobject kobj;
148 * Abstract edac_device control info structure
151 struct edac_device_ctl_info {
152 /* for global list of edac_device_ctl_info structs */
153 struct list_head link;
155 struct module *owner; /* Module owner of this control struct */
157 int dev_idx;
159 /* Per instance controls for this edac_device */
160 int log_ue; /* boolean for logging UEs */
161 int log_ce; /* boolean for logging CEs */
162 int panic_on_ue; /* boolean for panic'ing on an UE */
163 unsigned poll_msec; /* number of milliseconds to poll interval */
164 unsigned long delay; /* number of jiffies for poll_msec */
166 /* Additional top controller level attributes, but specified
167 * by the low level driver.
169 * Set by the low level driver to provide attributes at the
170 * controller level, same level as 'ue_count' and 'ce_count' above.
171 * An array of structures, NULL terminated
173 * If attributes are desired, then set to array of attributes
174 * If no attributes are desired, leave NULL
176 struct edac_dev_sysfs_attribute *sysfs_attributes;
178 /* pointer to main 'edac' subsys in sysfs */
179 struct bus_type *edac_subsys;
181 /* the internal state of this controller instance */
182 int op_state;
183 /* work struct for this instance */
184 struct delayed_work work;
186 /* pointer to edac polling checking routine:
187 * If NOT NULL: points to polling check routine
188 * If NULL: Then assumes INTERRUPT operation, where
189 * MC driver will receive events
191 void (*edac_check) (struct edac_device_ctl_info * edac_dev);
193 struct device *dev; /* pointer to device structure */
195 const char *mod_name; /* module name */
196 const char *ctl_name; /* edac controller name */
197 const char *dev_name; /* pci/platform/etc... name */
199 void *pvt_info; /* pointer to 'private driver' info */
201 unsigned long start_time; /* edac_device load start time (jiffies) */
203 struct completion removal_complete;
205 /* sysfs top name under 'edac' directory
206 * and instance name:
207 * cpu/cpu0/...
208 * cpu/cpu1/...
209 * cpu/cpu2/...
210 * ...
212 char name[EDAC_DEVICE_NAME_LEN + 1];
214 /* Number of instances supported on this control structure
215 * and the array of those instances
217 u32 nr_instances;
218 struct edac_device_instance *instances;
220 /* Event counters for the this whole EDAC Device */
221 struct edac_device_counter counters;
223 /* edac sysfs device control for the 'name'
224 * device this structure controls
226 struct kobject kobj;
229 /* To get from the instance's wq to the beginning of the ctl structure */
230 #define to_edac_mem_ctl_work(w) \
231 container_of(w, struct mem_ctl_info, work)
233 #define to_edac_device_ctl_work(w) \
234 container_of(w,struct edac_device_ctl_info,work)
237 * The alloc() and free() functions for the 'edac_device' control info
238 * structure. A MC driver will allocate one of these for each edac_device
239 * it is going to control/register with the EDAC CORE.
241 extern struct edac_device_ctl_info *edac_device_alloc_ctl_info(
242 unsigned sizeof_private,
243 char *edac_device_name, unsigned nr_instances,
244 char *edac_block_name, unsigned nr_blocks,
245 unsigned offset_value,
246 struct edac_dev_sysfs_block_attribute *block_attributes,
247 unsigned nr_attribs,
248 int device_index);
250 /* The offset value can be:
251 * -1 indicating no offset value
252 * 0 for zero-based block numbers
253 * 1 for 1-based block number
254 * other for other-based block number
256 #define BLOCK_OFFSET_VALUE_OFF ((unsigned) -1)
258 extern void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info);
261 * edac_device_add_device: Insert the 'edac_dev' structure into the
262 * edac_device global list and create sysfs entries associated with
263 * edac_device structure.
265 * @edac_dev: pointer to edac_device structure to be added to the list
266 * 'edac_device' structure.
268 * Returns:
269 * 0 on Success, or an error code on failure
271 extern int edac_device_add_device(struct edac_device_ctl_info *edac_dev);
274 * edac_device_del_device:
275 * Remove sysfs entries for specified edac_device structure and
276 * then remove edac_device structure from global list
278 * @dev:
279 * Pointer to struct &device representing the edac device
280 * structure to remove.
282 * Returns:
283 * Pointer to removed edac_device structure,
284 * or %NULL if device not found.
286 extern struct edac_device_ctl_info *edac_device_del_device(struct device *dev);
289 * edac_device_handle_ue():
290 * perform a common output and handling of an 'edac_dev' UE event
292 * @edac_dev: pointer to struct &edac_device_ctl_info
293 * @inst_nr: number of the instance where the UE error happened
294 * @block_nr: number of the block where the UE error happened
295 * @msg: message to be printed
297 extern void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
298 int inst_nr, int block_nr, const char *msg);
300 * edac_device_handle_ce():
301 * perform a common output and handling of an 'edac_dev' CE event
303 * @edac_dev: pointer to struct &edac_device_ctl_info
304 * @inst_nr: number of the instance where the CE error happened
305 * @block_nr: number of the block where the CE error happened
306 * @msg: message to be printed
308 extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
309 int inst_nr, int block_nr, const char *msg);
312 * edac_device_alloc_index: Allocate a unique device index number
314 * Returns:
315 * allocated index number
317 extern int edac_device_alloc_index(void);
318 extern const char *edac_layer_name[];
320 #endif