Commit | Line | Data |
---|---|---|
138c014d | 1 | /* |
1da177e4 LT |
2 | * File...........: linux/drivers/s390/block/dasd_int.h |
3 | * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> | |
138c014d | 4 | * Horst Hummel <Horst.Hummel@de.ibm.com> |
1da177e4 LT |
5 | * Martin Schwidefsky <schwidefsky@de.ibm.com> |
6 | * Bugreports.to..: <Linux390@de.ibm.com> | |
7 | * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 | |
8 | * | |
1da177e4 LT |
9 | */ |
10 | ||
11 | #ifndef DASD_INT_H | |
12 | #define DASD_INT_H | |
13 | ||
14 | #ifdef __KERNEL__ | |
15 | ||
1da177e4 LT |
16 | /* we keep old device allocation scheme; IOW, minors are still in 0..255 */ |
17 | #define DASD_PER_MAJOR (1U << (MINORBITS - DASD_PARTN_BITS)) | |
18 | #define DASD_PARTN_MASK ((1 << DASD_PARTN_BITS) - 1) | |
19 | ||
20 | /* | |
21 | * States a dasd device can have: | |
22 | * new: the dasd_device structure is allocated. | |
23 | * known: the discipline for the device is identified. | |
24 | * basic: the device can do basic i/o. | |
90f0094d | 25 | * unfmt: the device could not be analyzed (format is unknown). |
1da177e4 LT |
26 | * ready: partition detection is done and the device is can do block io. |
27 | * online: the device accepts requests from the block device queue. | |
28 | * | |
29 | * Things to do for startup state transitions: | |
30 | * new -> known: find discipline for the device and create devfs entries. | |
31 | * known -> basic: request irq line for the device. | |
32 | * basic -> ready: do the initial analysis, e.g. format detection, | |
33 | * do block device setup and detect partitions. | |
34 | * ready -> online: schedule the device tasklet. | |
35 | * Things to do for shutdown state transitions: | |
36 | * online -> ready: just set the new device state. | |
37 | * ready -> basic: flush requests from the block device layer, clear | |
38 | * partition information and reset format information. | |
39 | * basic -> known: terminate all requests and free irq. | |
40 | * known -> new: remove devfs entries and forget discipline. | |
41 | */ | |
42 | ||
43 | #define DASD_STATE_NEW 0 | |
44 | #define DASD_STATE_KNOWN 1 | |
45 | #define DASD_STATE_BASIC 2 | |
90f0094d HH |
46 | #define DASD_STATE_UNFMT 3 |
47 | #define DASD_STATE_READY 4 | |
48 | #define DASD_STATE_ONLINE 5 | |
1da177e4 LT |
49 | |
50 | #include <linux/module.h> | |
51 | #include <linux/wait.h> | |
52 | #include <linux/blkdev.h> | |
1da177e4 LT |
53 | #include <linux/genhd.h> |
54 | #include <linux/hdreg.h> | |
55 | #include <linux/interrupt.h> | |
e108cebb | 56 | #include <linux/log2.h> |
1da177e4 LT |
57 | #include <asm/ccwdev.h> |
58 | #include <linux/workqueue.h> | |
59 | #include <asm/debug.h> | |
60 | #include <asm/dasd.h> | |
61 | #include <asm/idals.h> | |
62 | ||
63 | /* | |
64 | * SECTION: Type definitions | |
65 | */ | |
66 | struct dasd_device; | |
8e09f215 | 67 | struct dasd_block; |
1da177e4 LT |
68 | |
69 | /* BIT DEFINITIONS FOR SENSE DATA */ | |
70 | #define DASD_SENSE_BIT_0 0x80 | |
71 | #define DASD_SENSE_BIT_1 0x40 | |
72 | #define DASD_SENSE_BIT_2 0x20 | |
73 | #define DASD_SENSE_BIT_3 0x10 | |
74 | ||
f60c768c SH |
75 | /* BIT DEFINITIONS FOR SIM SENSE */ |
76 | #define DASD_SIM_SENSE 0x0F | |
77 | #define DASD_SIM_MSG_TO_OP 0x03 | |
78 | #define DASD_SIM_LOG 0x0C | |
79 | ||
1da177e4 LT |
80 | /* |
81 | * SECTION: MACROs for klogd and s390 debug feature (dbf) | |
82 | */ | |
83 | #define DBF_DEV_EVENT(d_level, d_device, d_str, d_data...) \ | |
84 | do { \ | |
85 | debug_sprintf_event(d_device->debug_area, \ | |
86 | d_level, \ | |
87 | d_str "\n", \ | |
88 | d_data); \ | |
89 | } while(0) | |
90 | ||
91 | #define DBF_DEV_EXC(d_level, d_device, d_str, d_data...) \ | |
92 | do { \ | |
93 | debug_sprintf_exception(d_device->debug_area, \ | |
94 | d_level, \ | |
95 | d_str "\n", \ | |
96 | d_data); \ | |
97 | } while(0) | |
98 | ||
99 | #define DBF_EVENT(d_level, d_str, d_data...)\ | |
100 | do { \ | |
101 | debug_sprintf_event(dasd_debug_area, \ | |
102 | d_level,\ | |
103 | d_str "\n", \ | |
104 | d_data); \ | |
105 | } while(0) | |
106 | ||
107 | #define DBF_EXC(d_level, d_str, d_data...)\ | |
108 | do { \ | |
109 | debug_sprintf_exception(dasd_debug_area, \ | |
110 | d_level,\ | |
111 | d_str "\n", \ | |
112 | d_data); \ | |
113 | } while(0) | |
114 | ||
fc19f381 SH |
115 | /* limit size for an errorstring */ |
116 | #define ERRORLENGTH 30 | |
117 | ||
1da177e4 LT |
118 | /* definition of dbf debug levels */ |
119 | #define DBF_EMERG 0 /* system is unusable */ | |
120 | #define DBF_ALERT 1 /* action must be taken immediately */ | |
121 | #define DBF_CRIT 2 /* critical conditions */ | |
122 | #define DBF_ERR 3 /* error conditions */ | |
123 | #define DBF_WARNING 4 /* warning conditions */ | |
124 | #define DBF_NOTICE 5 /* normal but significant condition */ | |
125 | #define DBF_INFO 6 /* informational */ | |
126 | #define DBF_DEBUG 6 /* debug-level messages */ | |
127 | ||
128 | /* messages to be written via klogd and dbf */ | |
129 | #define DEV_MESSAGE(d_loglevel,d_device,d_string,d_args...)\ | |
130 | do { \ | |
131 | printk(d_loglevel PRINTK_HEADER " %s: " d_string "\n", \ | |
2a0217d5 | 132 | dev_name(&d_device->cdev->dev), d_args); \ |
1da177e4 LT |
133 | DBF_DEV_EVENT(DBF_ALERT, d_device, d_string, d_args); \ |
134 | } while(0) | |
135 | ||
136 | #define MESSAGE(d_loglevel,d_string,d_args...)\ | |
137 | do { \ | |
138 | printk(d_loglevel PRINTK_HEADER " " d_string "\n", d_args); \ | |
139 | DBF_EVENT(DBF_ALERT, d_string, d_args); \ | |
140 | } while(0) | |
141 | ||
142 | /* messages to be written via klogd only */ | |
143 | #define DEV_MESSAGE_LOG(d_loglevel,d_device,d_string,d_args...)\ | |
144 | do { \ | |
145 | printk(d_loglevel PRINTK_HEADER " %s: " d_string "\n", \ | |
2a0217d5 | 146 | dev_name(&d_device->cdev->dev), d_args); \ |
1da177e4 LT |
147 | } while(0) |
148 | ||
149 | #define MESSAGE_LOG(d_loglevel,d_string,d_args...)\ | |
150 | do { \ | |
151 | printk(d_loglevel PRINTK_HEADER " " d_string "\n", d_args); \ | |
152 | } while(0) | |
153 | ||
154 | struct dasd_ccw_req { | |
155 | unsigned int magic; /* Eye catcher */ | |
8e09f215 SW |
156 | struct list_head devlist; /* for dasd_device request queue */ |
157 | struct list_head blocklist; /* for dasd_block request queue */ | |
1da177e4 LT |
158 | |
159 | /* Where to execute what... */ | |
8e09f215 SW |
160 | struct dasd_block *block; /* the originating block device */ |
161 | struct dasd_device *memdev; /* the device used to allocate this */ | |
162 | struct dasd_device *startdev; /* device the request is started on */ | |
f3eb5384 SW |
163 | void *cpaddr; /* address of ccw or tcw */ |
164 | unsigned char cpmode; /* 0 = cmd mode, 1 = itcw */ | |
8e09f215 | 165 | char status; /* status of this request */ |
1da177e4 LT |
166 | short retries; /* A retry counter */ |
167 | unsigned long flags; /* flags of this request */ | |
168 | ||
169 | /* ... and how */ | |
170 | unsigned long starttime; /* jiffies time of request start */ | |
171 | int expires; /* expiration period in jiffies */ | |
8e09f215 | 172 | char lpm; /* logical path mask */ |
1da177e4 LT |
173 | void *data; /* pointer to data area */ |
174 | ||
175 | /* these are important for recovering erroneous requests */ | |
6cc7f168 | 176 | int intrc; /* internal error, e.g. from start_IO */ |
1da177e4 LT |
177 | struct irb irb; /* device status in case of an error */ |
178 | struct dasd_ccw_req *refers; /* ERP-chain queueing. */ | |
179 | void *function; /* originating ERP action */ | |
180 | ||
181 | /* these are for statistics only */ | |
182 | unsigned long long buildclk; /* TOD-clock of request generation */ | |
183 | unsigned long long startclk; /* TOD-clock of request start */ | |
184 | unsigned long long stopclk; /* TOD-clock of request interrupt */ | |
185 | unsigned long long endclk; /* TOD-clock of request termination */ | |
186 | ||
187 | /* Callback that is called after reaching final status. */ | |
8e09f215 SW |
188 | void (*callback)(struct dasd_ccw_req *, void *data); |
189 | void *callback_data; | |
1da177e4 LT |
190 | }; |
191 | ||
138c014d | 192 | /* |
1da177e4 LT |
193 | * dasd_ccw_req -> status can be: |
194 | */ | |
8e09f215 SW |
195 | #define DASD_CQR_FILLED 0x00 /* request is ready to be processed */ |
196 | #define DASD_CQR_DONE 0x01 /* request is completed successfully */ | |
197 | #define DASD_CQR_NEED_ERP 0x02 /* request needs recovery action */ | |
198 | #define DASD_CQR_IN_ERP 0x03 /* request is in recovery */ | |
199 | #define DASD_CQR_FAILED 0x04 /* request is finally failed */ | |
200 | #define DASD_CQR_TERMINATED 0x05 /* request was stopped by driver */ | |
201 | ||
202 | #define DASD_CQR_QUEUED 0x80 /* request is queued to be processed */ | |
203 | #define DASD_CQR_IN_IO 0x81 /* request is currently in IO */ | |
204 | #define DASD_CQR_ERROR 0x82 /* request is completed with error */ | |
205 | #define DASD_CQR_CLEAR_PENDING 0x83 /* request is clear pending */ | |
206 | #define DASD_CQR_CLEARED 0x84 /* request was cleared */ | |
73ac36ea | 207 | #define DASD_CQR_SUCCESS 0x85 /* request was successful */ |
8e09f215 | 208 | |
1da177e4 LT |
209 | |
210 | /* per dasd_ccw_req flags */ | |
211 | #define DASD_CQR_FLAGS_USE_ERP 0 /* use ERP for this request */ | |
1c01b8a5 | 212 | #define DASD_CQR_FLAGS_FAILFAST 1 /* FAILFAST */ |
1da177e4 LT |
213 | |
214 | /* Signature for error recovery functions. */ | |
215 | typedef struct dasd_ccw_req *(*dasd_erp_fn_t) (struct dasd_ccw_req *); | |
216 | ||
217 | /* | |
218 | * the struct dasd_discipline is | |
219 | * sth like a table of virtual functions, if you think of dasd_eckd | |
220 | * inheriting dasd... | |
221 | * no, currently we are not planning to reimplement the driver in C++ | |
222 | */ | |
223 | struct dasd_discipline { | |
224 | struct module *owner; | |
225 | char ebcname[8]; /* a name used for tagging and printks */ | |
226 | char name[8]; /* a name used for tagging and printks */ | |
227 | int max_blocks; /* maximum number of blocks to be chained */ | |
228 | ||
229 | struct list_head list; /* used for list of disciplines */ | |
230 | ||
8e09f215 SW |
231 | /* |
232 | * Device recognition functions. check_device is used to verify | |
233 | * the sense data and the information returned by read device | |
234 | * characteristics. It returns 0 if the discipline can be used | |
235 | * for the device in question. uncheck_device is called during | |
236 | * device shutdown to deregister a device from its discipline. | |
237 | */ | |
238 | int (*check_device) (struct dasd_device *); | |
239 | void (*uncheck_device) (struct dasd_device *); | |
240 | ||
241 | /* | |
242 | * do_analysis is used in the step from device state "basic" to | |
243 | * state "accept". It returns 0 if the device can be made ready, | |
244 | * it returns -EMEDIUMTYPE if the device can't be made ready or | |
245 | * -EAGAIN if do_analysis started a ccw that needs to complete | |
246 | * before the analysis may be repeated. | |
247 | */ | |
248 | int (*do_analysis) (struct dasd_block *); | |
249 | ||
250 | /* | |
251 | * Last things to do when a device is set online, and first things | |
252 | * when it is set offline. | |
253 | */ | |
254 | int (*ready_to_online) (struct dasd_device *); | |
255 | int (*online_to_ready) (struct dasd_device *); | |
256 | ||
257 | /* | |
258 | * Device operation functions. build_cp creates a ccw chain for | |
259 | * a block device request, start_io starts the request and | |
260 | * term_IO cancels it (e.g. in case of a timeout). format_device | |
261 | * returns a ccw chain to be used to format the device. | |
262 | * handle_terminated_request allows to examine a cqr and prepare | |
263 | * it for retry. | |
264 | */ | |
1da177e4 | 265 | struct dasd_ccw_req *(*build_cp) (struct dasd_device *, |
8e09f215 | 266 | struct dasd_block *, |
1da177e4 LT |
267 | struct request *); |
268 | int (*start_IO) (struct dasd_ccw_req *); | |
269 | int (*term_IO) (struct dasd_ccw_req *); | |
8e09f215 | 270 | void (*handle_terminated_request) (struct dasd_ccw_req *); |
1da177e4 LT |
271 | struct dasd_ccw_req *(*format_device) (struct dasd_device *, |
272 | struct format_data_t *); | |
273 | int (*free_cp) (struct dasd_ccw_req *, struct request *); | |
8e09f215 SW |
274 | |
275 | /* | |
276 | * Error recovery functions. examine_error() returns a value that | |
277 | * indicates what to do for an error condition. If examine_error() | |
138c014d | 278 | * returns 'dasd_era_recover' erp_action() is called to create a |
8e09f215 SW |
279 | * special error recovery ccw. erp_postaction() is called after |
280 | * an error recovery ccw has finished its execution. dump_sense | |
281 | * is called for every error condition to print the sense data | |
282 | * to the console. | |
283 | */ | |
1da177e4 LT |
284 | dasd_erp_fn_t(*erp_action) (struct dasd_ccw_req *); |
285 | dasd_erp_fn_t(*erp_postaction) (struct dasd_ccw_req *); | |
286 | void (*dump_sense) (struct dasd_device *, struct dasd_ccw_req *, | |
287 | struct irb *); | |
fc19f381 SH |
288 | void (*dump_sense_dbf) (struct dasd_device *, struct dasd_ccw_req *, |
289 | struct irb *, char *); | |
1da177e4 | 290 | |
8e09f215 SW |
291 | void (*handle_unsolicited_interrupt) (struct dasd_device *, |
292 | struct irb *); | |
293 | ||
1da177e4 | 294 | /* i/o control functions. */ |
8e09f215 | 295 | int (*fill_geometry) (struct dasd_block *, struct hd_geometry *); |
1da177e4 | 296 | int (*fill_info) (struct dasd_device *, struct dasd_information2_t *); |
8e09f215 | 297 | int (*ioctl) (struct dasd_block *, unsigned int, void __user *); |
1da177e4 LT |
298 | }; |
299 | ||
300 | extern struct dasd_discipline *dasd_diag_discipline_pointer; | |
301 | ||
3d052595 HH |
302 | /* |
303 | * Unique identifier for dasd device. | |
304 | */ | |
8e09f215 SW |
305 | #define UA_NOT_CONFIGURED 0x00 |
306 | #define UA_BASE_DEVICE 0x01 | |
307 | #define UA_BASE_PAV_ALIAS 0x02 | |
308 | #define UA_HYPER_PAV_ALIAS 0x03 | |
309 | ||
3d052595 | 310 | struct dasd_uid { |
8e09f215 | 311 | __u8 type; |
3d052595 HH |
312 | char vendor[4]; |
313 | char serial[15]; | |
314 | __u16 ssid; | |
8e09f215 SW |
315 | __u8 real_unit_addr; |
316 | __u8 base_unit_addr; | |
4abb08c2 | 317 | char vduit[33]; |
3d052595 | 318 | }; |
20c64468 SW |
319 | |
320 | /* | |
321 | * Notification numbers for extended error reporting notifications: | |
322 | * The DASD_EER_DISABLE notification is sent before a dasd_device (and it's | |
323 | * eer pointer) is freed. The error reporting module needs to do all necessary | |
324 | * cleanup steps. | |
325 | * The DASD_EER_TRIGGER notification sends the actual error reports (triggers). | |
326 | */ | |
327 | #define DASD_EER_DISABLE 0 | |
328 | #define DASD_EER_TRIGGER 1 | |
329 | ||
330 | /* Trigger IDs for extended error reporting DASD_EER_TRIGGER notification */ | |
331 | #define DASD_EER_FATALERROR 1 | |
332 | #define DASD_EER_NOPATH 2 | |
333 | #define DASD_EER_STATECHANGE 3 | |
334 | #define DASD_EER_PPRCSUSPEND 4 | |
335 | ||
1da177e4 LT |
336 | struct dasd_device { |
337 | /* Block device stuff. */ | |
8e09f215 SW |
338 | struct dasd_block *block; |
339 | ||
1da177e4 | 340 | unsigned int devindex; |
138c014d HH |
341 | unsigned long flags; /* per device flags */ |
342 | unsigned short features; /* copy of devmap-features (read-only!) */ | |
1da177e4 | 343 | |
20c64468 SW |
344 | /* extended error reporting stuff (eer) */ |
345 | struct dasd_ccw_req *eer_cqr; | |
346 | ||
1da177e4 LT |
347 | /* Device discipline stuff. */ |
348 | struct dasd_discipline *discipline; | |
aa88861f | 349 | struct dasd_discipline *base_discipline; |
1da177e4 LT |
350 | char *private; |
351 | ||
352 | /* Device state and target state. */ | |
353 | int state, target; | |
354 | int stopped; /* device (ccw_device_start) was stopped */ | |
355 | ||
8e09f215 | 356 | /* reference count. */ |
1da177e4 | 357 | atomic_t ref_count; |
1da177e4 LT |
358 | |
359 | /* ccw queue and memory for static ccw/erp buffers. */ | |
360 | struct list_head ccw_queue; | |
361 | spinlock_t mem_lock; | |
362 | void *ccw_mem; | |
363 | void *erp_mem; | |
364 | struct list_head ccw_chunks; | |
365 | struct list_head erp_chunks; | |
366 | ||
367 | atomic_t tasklet_scheduled; | |
368 | struct tasklet_struct tasklet; | |
369 | struct work_struct kick_work; | |
370 | struct timer_list timer; | |
371 | ||
372 | debug_info_t *debug_area; | |
373 | ||
374 | struct ccw_device *cdev; | |
375 | ||
8e09f215 SW |
376 | /* hook for alias management */ |
377 | struct list_head alias_list; | |
378 | }; | |
379 | ||
380 | struct dasd_block { | |
381 | /* Block device stuff. */ | |
382 | struct gendisk *gdp; | |
383 | struct request_queue *request_queue; | |
384 | spinlock_t request_queue_lock; | |
385 | struct block_device *bdev; | |
386 | atomic_t open_count; | |
387 | ||
b44b0ab3 | 388 | unsigned long long blocks; /* size of volume in blocks */ |
8e09f215 SW |
389 | unsigned int bp_block; /* bytes per block */ |
390 | unsigned int s2b_shift; /* log2 (bp_block/512) */ | |
391 | ||
392 | struct dasd_device *base; | |
393 | struct list_head ccw_queue; | |
394 | spinlock_t queue_lock; | |
395 | ||
396 | atomic_t tasklet_scheduled; | |
397 | struct tasklet_struct tasklet; | |
398 | struct timer_list timer; | |
399 | ||
1da177e4 LT |
400 | #ifdef CONFIG_DASD_PROFILE |
401 | struct dasd_profile_info_t profile; | |
402 | #endif | |
403 | }; | |
404 | ||
8e09f215 SW |
405 | |
406 | ||
1da177e4 LT |
407 | /* reasons why device (ccw_device_start) was stopped */ |
408 | #define DASD_STOPPED_NOT_ACC 1 /* not accessible */ | |
409 | #define DASD_STOPPED_QUIESCE 2 /* Quiesced */ | |
410 | #define DASD_STOPPED_PENDING 4 /* long busy */ | |
411 | #define DASD_STOPPED_DC_WAIT 8 /* disconnected, wait */ | |
8e09f215 | 412 | #define DASD_STOPPED_SU 16 /* summary unit check handling */ |
1da177e4 LT |
413 | |
414 | /* per device flags */ | |
1da177e4 | 415 | #define DASD_FLAG_OFFLINE 3 /* device is in offline processing */ |
20c64468 SW |
416 | #define DASD_FLAG_EER_SNSS 4 /* A SNSS is required */ |
417 | #define DASD_FLAG_EER_IN_USE 5 /* A SNSS request is running */ | |
1da177e4 LT |
418 | |
419 | void dasd_put_device_wake(struct dasd_device *); | |
420 | ||
421 | /* | |
422 | * Reference count inliners | |
423 | */ | |
424 | static inline void | |
425 | dasd_get_device(struct dasd_device *device) | |
426 | { | |
427 | atomic_inc(&device->ref_count); | |
428 | } | |
429 | ||
430 | static inline void | |
431 | dasd_put_device(struct dasd_device *device) | |
432 | { | |
433 | if (atomic_dec_return(&device->ref_count) == 0) | |
434 | dasd_put_device_wake(device); | |
435 | } | |
436 | ||
437 | /* | |
438 | * The static memory in ccw_mem and erp_mem is managed by a sorted | |
439 | * list of free memory chunks. | |
440 | */ | |
441 | struct dasd_mchunk | |
442 | { | |
443 | struct list_head list; | |
444 | unsigned long size; | |
445 | } __attribute__ ((aligned(8))); | |
446 | ||
447 | static inline void | |
448 | dasd_init_chunklist(struct list_head *chunk_list, void *mem, | |
449 | unsigned long size) | |
450 | { | |
451 | struct dasd_mchunk *chunk; | |
452 | ||
453 | INIT_LIST_HEAD(chunk_list); | |
454 | chunk = (struct dasd_mchunk *) mem; | |
455 | chunk->size = size - sizeof(struct dasd_mchunk); | |
456 | list_add(&chunk->list, chunk_list); | |
457 | } | |
458 | ||
459 | static inline void * | |
460 | dasd_alloc_chunk(struct list_head *chunk_list, unsigned long size) | |
461 | { | |
462 | struct dasd_mchunk *chunk, *tmp; | |
463 | ||
464 | size = (size + 7L) & -8L; | |
465 | list_for_each_entry(chunk, chunk_list, list) { | |
466 | if (chunk->size < size) | |
467 | continue; | |
468 | if (chunk->size > size + sizeof(struct dasd_mchunk)) { | |
469 | char *endaddr = (char *) (chunk + 1) + chunk->size; | |
470 | tmp = (struct dasd_mchunk *) (endaddr - size) - 1; | |
471 | tmp->size = size; | |
472 | chunk->size -= size + sizeof(struct dasd_mchunk); | |
473 | chunk = tmp; | |
474 | } else | |
475 | list_del(&chunk->list); | |
476 | return (void *) (chunk + 1); | |
477 | } | |
478 | return NULL; | |
479 | } | |
480 | ||
481 | static inline void | |
482 | dasd_free_chunk(struct list_head *chunk_list, void *mem) | |
483 | { | |
484 | struct dasd_mchunk *chunk, *tmp; | |
485 | struct list_head *p, *left; | |
486 | ||
487 | chunk = (struct dasd_mchunk *) | |
488 | ((char *) mem - sizeof(struct dasd_mchunk)); | |
489 | /* Find out the left neighbour in chunk_list. */ | |
490 | left = chunk_list; | |
491 | list_for_each(p, chunk_list) { | |
492 | if (list_entry(p, struct dasd_mchunk, list) > chunk) | |
493 | break; | |
494 | left = p; | |
495 | } | |
496 | /* Try to merge with right neighbour = next element from left. */ | |
497 | if (left->next != chunk_list) { | |
498 | tmp = list_entry(left->next, struct dasd_mchunk, list); | |
499 | if ((char *) (chunk + 1) + chunk->size == (char *) tmp) { | |
500 | list_del(&tmp->list); | |
501 | chunk->size += tmp->size + sizeof(struct dasd_mchunk); | |
502 | } | |
503 | } | |
504 | /* Try to merge with left neighbour. */ | |
505 | if (left != chunk_list) { | |
506 | tmp = list_entry(left, struct dasd_mchunk, list); | |
507 | if ((char *) (tmp + 1) + tmp->size == (char *) chunk) { | |
508 | tmp->size += chunk->size + sizeof(struct dasd_mchunk); | |
509 | return; | |
510 | } | |
511 | } | |
512 | __list_add(&chunk->list, left, left->next); | |
513 | } | |
514 | ||
515 | /* | |
516 | * Check if bsize is in { 512, 1024, 2048, 4096 } | |
517 | */ | |
518 | static inline int | |
519 | dasd_check_blocksize(int bsize) | |
520 | { | |
e108cebb | 521 | if (bsize < 512 || bsize > 4096 || !is_power_of_2(bsize)) |
1da177e4 LT |
522 | return -EMEDIUMTYPE; |
523 | return 0; | |
524 | } | |
525 | ||
526 | /* externals in dasd.c */ | |
527 | #define DASD_PROFILE_ON 1 | |
528 | #define DASD_PROFILE_OFF 0 | |
529 | ||
530 | extern debug_info_t *dasd_debug_area; | |
531 | extern struct dasd_profile_info_t dasd_global_profile; | |
532 | extern unsigned int dasd_profile_level; | |
533 | extern struct block_device_operations dasd_device_operations; | |
534 | ||
e18b890b | 535 | extern struct kmem_cache *dasd_page_cache; |
1da177e4 LT |
536 | |
537 | struct dasd_ccw_req * | |
538 | dasd_kmalloc_request(char *, int, int, struct dasd_device *); | |
539 | struct dasd_ccw_req * | |
540 | dasd_smalloc_request(char *, int, int, struct dasd_device *); | |
541 | void dasd_kfree_request(struct dasd_ccw_req *, struct dasd_device *); | |
542 | void dasd_sfree_request(struct dasd_ccw_req *, struct dasd_device *); | |
543 | ||
544 | static inline int | |
545 | dasd_kmalloc_set_cda(struct ccw1 *ccw, void *cda, struct dasd_device *device) | |
546 | { | |
547 | return set_normalized_cda(ccw, cda); | |
548 | } | |
549 | ||
550 | struct dasd_device *dasd_alloc_device(void); | |
551 | void dasd_free_device(struct dasd_device *); | |
552 | ||
8e09f215 SW |
553 | struct dasd_block *dasd_alloc_block(void); |
554 | void dasd_free_block(struct dasd_block *); | |
555 | ||
1da177e4 LT |
556 | void dasd_enable_device(struct dasd_device *); |
557 | void dasd_set_target_state(struct dasd_device *, int); | |
558 | void dasd_kick_device(struct dasd_device *); | |
559 | ||
560 | void dasd_add_request_head(struct dasd_ccw_req *); | |
561 | void dasd_add_request_tail(struct dasd_ccw_req *); | |
562 | int dasd_start_IO(struct dasd_ccw_req *); | |
563 | int dasd_term_IO(struct dasd_ccw_req *); | |
8e09f215 SW |
564 | void dasd_schedule_device_bh(struct dasd_device *); |
565 | void dasd_schedule_block_bh(struct dasd_block *); | |
1da177e4 LT |
566 | int dasd_sleep_on(struct dasd_ccw_req *); |
567 | int dasd_sleep_on_immediatly(struct dasd_ccw_req *); | |
568 | int dasd_sleep_on_interruptible(struct dasd_ccw_req *); | |
8e09f215 SW |
569 | void dasd_device_set_timer(struct dasd_device *, int); |
570 | void dasd_device_clear_timer(struct dasd_device *); | |
571 | void dasd_block_set_timer(struct dasd_block *, int); | |
572 | void dasd_block_clear_timer(struct dasd_block *); | |
1da177e4 | 573 | int dasd_cancel_req(struct dasd_ccw_req *); |
8e09f215 | 574 | int dasd_flush_device_queue(struct dasd_device *); |
1da177e4 LT |
575 | int dasd_generic_probe (struct ccw_device *, struct dasd_discipline *); |
576 | void dasd_generic_remove (struct ccw_device *cdev); | |
577 | int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *); | |
578 | int dasd_generic_set_offline (struct ccw_device *cdev); | |
579 | int dasd_generic_notify(struct ccw_device *, int); | |
8e09f215 | 580 | void dasd_generic_handle_state_change(struct dasd_device *); |
1da177e4 | 581 | |
92636b15 | 582 | int dasd_generic_read_dev_chars(struct dasd_device *, char *, void *, int); |
f3eb5384 | 583 | char *dasd_get_sense(struct irb *); |
17283b56 | 584 | |
1da177e4 LT |
585 | /* externals in dasd_devmap.c */ |
586 | extern int dasd_max_devindex; | |
587 | extern int dasd_probeonly; | |
588 | extern int dasd_autodetect; | |
40545573 | 589 | extern int dasd_nopav; |
f3eb5384 | 590 | extern int dasd_nofcx; |
1da177e4 LT |
591 | |
592 | int dasd_devmap_init(void); | |
593 | void dasd_devmap_exit(void); | |
594 | ||
595 | struct dasd_device *dasd_create_device(struct ccw_device *); | |
596 | void dasd_delete_device(struct dasd_device *); | |
597 | ||
3d052595 HH |
598 | int dasd_get_uid(struct ccw_device *, struct dasd_uid *); |
599 | int dasd_set_uid(struct ccw_device *, struct dasd_uid *); | |
f24acd45 HH |
600 | int dasd_get_feature(struct ccw_device *, int); |
601 | int dasd_set_feature(struct ccw_device *, int, int); | |
602 | ||
1da177e4 LT |
603 | int dasd_add_sysfs_files(struct ccw_device *); |
604 | void dasd_remove_sysfs_files(struct ccw_device *); | |
605 | ||
606 | struct dasd_device *dasd_device_from_cdev(struct ccw_device *); | |
a00bfd71 | 607 | struct dasd_device *dasd_device_from_cdev_locked(struct ccw_device *); |
1da177e4 LT |
608 | struct dasd_device *dasd_device_from_devindex(int); |
609 | ||
610 | int dasd_parse(void); | |
69f90f6a | 611 | int dasd_busid_known(const char *); |
1da177e4 LT |
612 | |
613 | /* externals in dasd_gendisk.c */ | |
614 | int dasd_gendisk_init(void); | |
615 | void dasd_gendisk_exit(void); | |
8e09f215 SW |
616 | int dasd_gendisk_alloc(struct dasd_block *); |
617 | void dasd_gendisk_free(struct dasd_block *); | |
618 | int dasd_scan_partitions(struct dasd_block *); | |
619 | void dasd_destroy_partitions(struct dasd_block *); | |
1da177e4 LT |
620 | |
621 | /* externals in dasd_ioctl.c */ | |
57a7c0bc | 622 | int dasd_ioctl(struct block_device *, fmode_t, unsigned int, unsigned long); |
1da177e4 LT |
623 | |
624 | /* externals in dasd_proc.c */ | |
625 | int dasd_proc_init(void); | |
626 | void dasd_proc_exit(void); | |
627 | ||
628 | /* externals in dasd_erp.c */ | |
629 | struct dasd_ccw_req *dasd_default_erp_action(struct dasd_ccw_req *); | |
630 | struct dasd_ccw_req *dasd_default_erp_postaction(struct dasd_ccw_req *); | |
631 | struct dasd_ccw_req *dasd_alloc_erp_request(char *, int, int, | |
632 | struct dasd_device *); | |
633 | void dasd_free_erp_request(struct dasd_ccw_req *, struct dasd_device *); | |
634 | void dasd_log_sense(struct dasd_ccw_req *, struct irb *); | |
fc19f381 | 635 | void dasd_log_sense_dbf(struct dasd_ccw_req *cqr, struct irb *irb); |
1da177e4 | 636 | |
1da177e4 | 637 | /* externals in dasd_3990_erp.c */ |
1da177e4 | 638 | struct dasd_ccw_req *dasd_3990_erp_action(struct dasd_ccw_req *); |
f60c768c | 639 | void dasd_3990_erp_handle_sim(struct dasd_device *, char *); |
1da177e4 | 640 | |
20c64468 SW |
641 | /* externals in dasd_eer.c */ |
642 | #ifdef CONFIG_DASD_EER | |
643 | int dasd_eer_init(void); | |
644 | void dasd_eer_exit(void); | |
645 | int dasd_eer_enable(struct dasd_device *); | |
646 | void dasd_eer_disable(struct dasd_device *); | |
647 | void dasd_eer_write(struct dasd_device *, struct dasd_ccw_req *cqr, | |
648 | unsigned int id); | |
649 | void dasd_eer_snss(struct dasd_device *); | |
650 | ||
651 | static inline int dasd_eer_enabled(struct dasd_device *device) | |
652 | { | |
653 | return device->eer_cqr != NULL; | |
654 | } | |
655 | #else | |
656 | #define dasd_eer_init() (0) | |
657 | #define dasd_eer_exit() do { } while (0) | |
658 | #define dasd_eer_enable(d) (0) | |
659 | #define dasd_eer_disable(d) do { } while (0) | |
660 | #define dasd_eer_write(d,c,i) do { } while (0) | |
661 | #define dasd_eer_snss(d) do { } while (0) | |
662 | #define dasd_eer_enabled(d) (0) | |
663 | #endif /* CONFIG_DASD_ERR */ | |
664 | ||
1da177e4 LT |
665 | #endif /* __KERNEL__ */ |
666 | ||
667 | #endif /* DASD_H */ |