License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6-block.git] / drivers / s390 / block / dasd_int.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
138c014d 2/*
1da177e4 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>
d41dd122 7 * Copyright IBM Corp. 1999, 2009
1da177e4
LT
8 */
9
10#ifndef DASD_INT_H
11#define DASD_INT_H
12
1da177e4
LT
13/* we keep old device allocation scheme; IOW, minors are still in 0..255 */
14#define DASD_PER_MAJOR (1U << (MINORBITS - DASD_PARTN_BITS))
15#define DASD_PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
16
17/*
18 * States a dasd device can have:
19 * new: the dasd_device structure is allocated.
20 * known: the discipline for the device is identified.
21 * basic: the device can do basic i/o.
90f0094d 22 * unfmt: the device could not be analyzed (format is unknown).
1da177e4
LT
23 * ready: partition detection is done and the device is can do block io.
24 * online: the device accepts requests from the block device queue.
25 *
26 * Things to do for startup state transitions:
27 * new -> known: find discipline for the device and create devfs entries.
28 * known -> basic: request irq line for the device.
29 * basic -> ready: do the initial analysis, e.g. format detection,
30 * do block device setup and detect partitions.
31 * ready -> online: schedule the device tasklet.
32 * Things to do for shutdown state transitions:
33 * online -> ready: just set the new device state.
34 * ready -> basic: flush requests from the block device layer, clear
35 * partition information and reset format information.
36 * basic -> known: terminate all requests and free irq.
37 * known -> new: remove devfs entries and forget discipline.
38 */
39
40#define DASD_STATE_NEW 0
41#define DASD_STATE_KNOWN 1
42#define DASD_STATE_BASIC 2
90f0094d
HH
43#define DASD_STATE_UNFMT 3
44#define DASD_STATE_READY 4
45#define DASD_STATE_ONLINE 5
1da177e4
LT
46
47#include <linux/module.h>
48#include <linux/wait.h>
49#include <linux/blkdev.h>
1da177e4
LT
50#include <linux/genhd.h>
51#include <linux/hdreg.h>
52#include <linux/interrupt.h>
e108cebb 53#include <linux/log2.h>
1da177e4
LT
54#include <asm/ccwdev.h>
55#include <linux/workqueue.h>
56#include <asm/debug.h>
57#include <asm/dasd.h>
58#include <asm/idals.h>
c9346151 59#include <linux/bitops.h>
e443343e 60#include <linux/blk-mq.h>
1da177e4 61
68b781fe
SH
62/* DASD discipline magic */
63#define DASD_ECKD_MAGIC 0xC5C3D2C4
64#define DASD_DIAG_MAGIC 0xC4C9C1C7
65#define DASD_FBA_MAGIC 0xC6C2C140
66
1da177e4
LT
67/*
68 * SECTION: Type definitions
69 */
70struct dasd_device;
8e09f215 71struct dasd_block;
1da177e4
LT
72
73/* BIT DEFINITIONS FOR SENSE DATA */
74#define DASD_SENSE_BIT_0 0x80
75#define DASD_SENSE_BIT_1 0x40
76#define DASD_SENSE_BIT_2 0x20
77#define DASD_SENSE_BIT_3 0x10
78
f60c768c
SH
79/* BIT DEFINITIONS FOR SIM SENSE */
80#define DASD_SIM_SENSE 0x0F
81#define DASD_SIM_MSG_TO_OP 0x03
82#define DASD_SIM_LOG 0x0C
83
2dedf0d9
SH
84/* lock class for nested cdev lock */
85#define CDEV_NESTED_FIRST 1
86#define CDEV_NESTED_SECOND 2
87
1da177e4
LT
88/*
89 * SECTION: MACROs for klogd and s390 debug feature (dbf)
90 */
91#define DBF_DEV_EVENT(d_level, d_device, d_str, d_data...) \
92do { \
93 debug_sprintf_event(d_device->debug_area, \
94 d_level, \
95 d_str "\n", \
96 d_data); \
97} while(0)
98
99#define DBF_DEV_EXC(d_level, d_device, d_str, d_data...) \
100do { \
101 debug_sprintf_exception(d_device->debug_area, \
102 d_level, \
103 d_str "\n", \
104 d_data); \
105} while(0)
106
107#define DBF_EVENT(d_level, d_str, d_data...)\
108do { \
109 debug_sprintf_event(dasd_debug_area, \
110 d_level,\
111 d_str "\n", \
112 d_data); \
113} while(0)
114
b8ed5dd5
SH
115#define DBF_EVENT_DEVID(d_level, d_cdev, d_str, d_data...) \
116do { \
117 struct ccw_dev_id __dev_id; \
118 ccw_device_get_id(d_cdev, &__dev_id); \
119 debug_sprintf_event(dasd_debug_area, \
120 d_level, \
121 "0.%x.%04x " d_str "\n", \
122 __dev_id.ssid, __dev_id.devno, d_data); \
123} while (0)
124
1da177e4
LT
125#define DBF_EXC(d_level, d_str, d_data...)\
126do { \
127 debug_sprintf_exception(dasd_debug_area, \
128 d_level,\
129 d_str "\n", \
130 d_data); \
131} while(0)
132
fc19f381
SH
133/* limit size for an errorstring */
134#define ERRORLENGTH 30
135
1da177e4
LT
136/* definition of dbf debug levels */
137#define DBF_EMERG 0 /* system is unusable */
138#define DBF_ALERT 1 /* action must be taken immediately */
139#define DBF_CRIT 2 /* critical conditions */
140#define DBF_ERR 3 /* error conditions */
141#define DBF_WARNING 4 /* warning conditions */
142#define DBF_NOTICE 5 /* normal but significant condition */
143#define DBF_INFO 6 /* informational */
144#define DBF_DEBUG 6 /* debug-level messages */
145
146/* messages to be written via klogd and dbf */
147#define DEV_MESSAGE(d_loglevel,d_device,d_string,d_args...)\
148do { \
149 printk(d_loglevel PRINTK_HEADER " %s: " d_string "\n", \
2a0217d5 150 dev_name(&d_device->cdev->dev), d_args); \
1da177e4
LT
151 DBF_DEV_EVENT(DBF_ALERT, d_device, d_string, d_args); \
152} while(0)
153
154#define MESSAGE(d_loglevel,d_string,d_args...)\
155do { \
156 printk(d_loglevel PRINTK_HEADER " " d_string "\n", d_args); \
157 DBF_EVENT(DBF_ALERT, d_string, d_args); \
158} while(0)
159
160/* messages to be written via klogd only */
161#define DEV_MESSAGE_LOG(d_loglevel,d_device,d_string,d_args...)\
162do { \
163 printk(d_loglevel PRINTK_HEADER " %s: " d_string "\n", \
2a0217d5 164 dev_name(&d_device->cdev->dev), d_args); \
1da177e4
LT
165} while(0)
166
167#define MESSAGE_LOG(d_loglevel,d_string,d_args...)\
168do { \
169 printk(d_loglevel PRINTK_HEADER " " d_string "\n", d_args); \
170} while(0)
171
28b841b3
JH
172/* Macro to calculate number of blocks per page */
173#define BLOCKS_PER_PAGE(blksize) (PAGE_SIZE / blksize)
174
1da177e4
LT
175struct dasd_ccw_req {
176 unsigned int magic; /* Eye catcher */
8e09f215
SW
177 struct list_head devlist; /* for dasd_device request queue */
178 struct list_head blocklist; /* for dasd_block request queue */
1da177e4
LT
179
180 /* Where to execute what... */
8e09f215
SW
181 struct dasd_block *block; /* the originating block device */
182 struct dasd_device *memdev; /* the device used to allocate this */
183 struct dasd_device *startdev; /* device the request is started on */
29b8dd9d 184 struct dasd_device *basedev; /* base device if no block->base */
f3eb5384
SW
185 void *cpaddr; /* address of ccw or tcw */
186 unsigned char cpmode; /* 0 = cmd mode, 1 = itcw */
8e09f215 187 char status; /* status of this request */
1da177e4
LT
188 short retries; /* A retry counter */
189 unsigned long flags; /* flags of this request */
e443343e 190 struct dasd_queue *dq;
1da177e4
LT
191
192 /* ... and how */
193 unsigned long starttime; /* jiffies time of request start */
7c8faa86 194 unsigned long expires; /* expiration period in jiffies */
8e09f215 195 char lpm; /* logical path mask */
1da177e4
LT
196 void *data; /* pointer to data area */
197
198 /* these are important for recovering erroneous requests */
6cc7f168 199 int intrc; /* internal error, e.g. from start_IO */
1da177e4
LT
200 struct irb irb; /* device status in case of an error */
201 struct dasd_ccw_req *refers; /* ERP-chain queueing. */
202 void *function; /* originating ERP action */
203
204 /* these are for statistics only */
7bf76f01
JH
205 unsigned long buildclk; /* TOD-clock of request generation */
206 unsigned long startclk; /* TOD-clock of request start */
207 unsigned long stopclk; /* TOD-clock of request interrupt */
208 unsigned long endclk; /* TOD-clock of request termination */
1da177e4
LT
209
210 /* Callback that is called after reaching final status. */
8e09f215
SW
211 void (*callback)(struct dasd_ccw_req *, void *data);
212 void *callback_data;
1da177e4
LT
213};
214
138c014d 215/*
1da177e4
LT
216 * dasd_ccw_req -> status can be:
217 */
8e09f215
SW
218#define DASD_CQR_FILLED 0x00 /* request is ready to be processed */
219#define DASD_CQR_DONE 0x01 /* request is completed successfully */
220#define DASD_CQR_NEED_ERP 0x02 /* request needs recovery action */
221#define DASD_CQR_IN_ERP 0x03 /* request is in recovery */
222#define DASD_CQR_FAILED 0x04 /* request is finally failed */
223#define DASD_CQR_TERMINATED 0x05 /* request was stopped by driver */
224
225#define DASD_CQR_QUEUED 0x80 /* request is queued to be processed */
226#define DASD_CQR_IN_IO 0x81 /* request is currently in IO */
227#define DASD_CQR_ERROR 0x82 /* request is completed with error */
228#define DASD_CQR_CLEAR_PENDING 0x83 /* request is clear pending */
229#define DASD_CQR_CLEARED 0x84 /* request was cleared */
73ac36ea 230#define DASD_CQR_SUCCESS 0x85 /* request was successful */
8e09f215 231
7c8faa86
SH
232/* default expiration time*/
233#define DASD_EXPIRES 300
234#define DASD_EXPIRES_MAX 40000000
1f1ee9ad
HR
235#define DASD_RETRIES 256
236#define DASD_RETRIES_MAX 32768
1da177e4
LT
237
238/* per dasd_ccw_req flags */
239#define DASD_CQR_FLAGS_USE_ERP 0 /* use ERP for this request */
1c01b8a5 240#define DASD_CQR_FLAGS_FAILFAST 1 /* FAILFAST */
a4d26c6a 241#define DASD_CQR_VERIFY_PATH 2 /* path verification request */
5a27e60d
SW
242#define DASD_CQR_ALLOW_SLOCK 3 /* Try this request even when lock was
243 * stolen. Should not be combined with
244 * DASD_CQR_FLAGS_USE_ERP
245 */
8fd57520
JH
246/*
247 * The following flags are used to suppress output of certain errors.
8fd57520
JH
248 */
249#define DASD_CQR_SUPPRESS_NRF 4 /* Suppress 'No Record Found' error */
250#define DASD_CQR_SUPPRESS_FP 5 /* Suppress 'File Protected' error*/
251#define DASD_CQR_SUPPRESS_IL 6 /* Suppress 'Incorrect Length' error */
ab24fbd3 252#define DASD_CQR_SUPPRESS_CR 7 /* Suppress 'Command Reject' error */
1da177e4 253
e443343e
SH
254/*
255 * There is no reliable way to determine the number of available CPUs on
256 * LPAR but there is no big performance difference between 1 and the
257 * maximum CPU number.
258 * 64 is a good trade off performance wise.
259 */
260#define DASD_NR_HW_QUEUES 64
261#define DASD_MAX_LCU_DEV 256
262#define DASD_REQ_PER_DEV 4
263
1da177e4
LT
264/* Signature for error recovery functions. */
265typedef struct dasd_ccw_req *(*dasd_erp_fn_t) (struct dasd_ccw_req *);
266
46d1c03c
JH
267/*
268 * A single CQR can only contain a maximum of 255 CCWs. It is limited by
269 * the locate record and locate record extended count value which can only hold
270 * 1 Byte max.
271 */
272#define DASD_CQR_MAX_CCW 255
273
2dedf0d9
SH
274/*
275 * Unique identifier for dasd device.
276 */
277#define UA_NOT_CONFIGURED 0x00
278#define UA_BASE_DEVICE 0x01
279#define UA_BASE_PAV_ALIAS 0x02
280#define UA_HYPER_PAV_ALIAS 0x03
281
282struct dasd_uid {
283 __u8 type;
284 char vendor[4];
285 char serial[15];
286 __u16 ssid;
287 __u8 real_unit_addr;
288 __u8 base_unit_addr;
289 char vduit[33];
290};
291
1da177e4
LT
292/*
293 * the struct dasd_discipline is
294 * sth like a table of virtual functions, if you think of dasd_eckd
295 * inheriting dasd...
296 * no, currently we are not planning to reimplement the driver in C++
297 */
298struct dasd_discipline {
299 struct module *owner;
300 char ebcname[8]; /* a name used for tagging and printks */
301 char name[8]; /* a name used for tagging and printks */
302 int max_blocks; /* maximum number of blocks to be chained */
303
304 struct list_head list; /* used for list of disciplines */
305
8e09f215
SW
306 /*
307 * Device recognition functions. check_device is used to verify
308 * the sense data and the information returned by read device
309 * characteristics. It returns 0 if the discipline can be used
310 * for the device in question. uncheck_device is called during
311 * device shutdown to deregister a device from its discipline.
312 */
313 int (*check_device) (struct dasd_device *);
314 void (*uncheck_device) (struct dasd_device *);
315
316 /*
317 * do_analysis is used in the step from device state "basic" to
318 * state "accept". It returns 0 if the device can be made ready,
319 * it returns -EMEDIUMTYPE if the device can't be made ready or
320 * -EAGAIN if do_analysis started a ccw that needs to complete
321 * before the analysis may be repeated.
322 */
323 int (*do_analysis) (struct dasd_block *);
324
a4d26c6a
SW
325 /*
326 * This function is called, when new paths become available.
327 * Disciplins may use this callback to do necessary setup work,
328 * e.g. verify that new path is compatible with the current
329 * configuration.
330 */
331 int (*verify_path)(struct dasd_device *, __u8);
332
8e09f215
SW
333 /*
334 * Last things to do when a device is set online, and first things
335 * when it is set offline.
336 */
d42e1712 337 int (*basic_to_ready) (struct dasd_device *);
8e09f215 338 int (*online_to_ready) (struct dasd_device *);
daa991bf 339 int (*basic_to_known)(struct dasd_device *);
8e09f215 340
d42e1712 341 /* (struct dasd_device *);
8e09f215
SW
342 * Device operation functions. build_cp creates a ccw chain for
343 * a block device request, start_io starts the request and
344 * term_IO cancels it (e.g. in case of a timeout). format_device
8fd57520
JH
345 * formats the device and check_device_format compares the format of
346 * a device with the expected format_data.
8e09f215
SW
347 * handle_terminated_request allows to examine a cqr and prepare
348 * it for retry.
349 */
1da177e4 350 struct dasd_ccw_req *(*build_cp) (struct dasd_device *,
8e09f215 351 struct dasd_block *,
1da177e4
LT
352 struct request *);
353 int (*start_IO) (struct dasd_ccw_req *);
354 int (*term_IO) (struct dasd_ccw_req *);
8e09f215 355 void (*handle_terminated_request) (struct dasd_ccw_req *);
d42e1712 356 int (*format_device) (struct dasd_device *,
8fd57520
JH
357 struct format_data_t *, int);
358 int (*check_device_format)(struct dasd_device *,
359 struct format_check_t *, int);
1da177e4 360 int (*free_cp) (struct dasd_ccw_req *, struct request *);
8e09f215
SW
361
362 /*
363 * Error recovery functions. examine_error() returns a value that
364 * indicates what to do for an error condition. If examine_error()
138c014d 365 * returns 'dasd_era_recover' erp_action() is called to create a
8e09f215
SW
366 * special error recovery ccw. erp_postaction() is called after
367 * an error recovery ccw has finished its execution. dump_sense
368 * is called for every error condition to print the sense data
369 * to the console.
370 */
1da177e4
LT
371 dasd_erp_fn_t(*erp_action) (struct dasd_ccw_req *);
372 dasd_erp_fn_t(*erp_postaction) (struct dasd_ccw_req *);
373 void (*dump_sense) (struct dasd_device *, struct dasd_ccw_req *,
374 struct irb *);
aeec92ca 375 void (*dump_sense_dbf) (struct dasd_device *, struct irb *, char *);
5a27e60d
SW
376 void (*check_for_device_change) (struct dasd_device *,
377 struct dasd_ccw_req *,
378 struct irb *);
8e09f215 379
1da177e4 380 /* i/o control functions. */
8e09f215 381 int (*fill_geometry) (struct dasd_block *, struct hd_geometry *);
1da177e4 382 int (*fill_info) (struct dasd_device *, struct dasd_information2_t *);
8e09f215 383 int (*ioctl) (struct dasd_block *, unsigned int, void __user *);
d41dd122
SH
384
385 /* suspend/resume functions */
386 int (*freeze) (struct dasd_device *);
387 int (*restore) (struct dasd_device *);
501183f2
SH
388
389 /* reload device after state change */
390 int (*reload) (struct dasd_device *);
2dedf0d9
SH
391
392 int (*get_uid) (struct dasd_device *, struct dasd_uid *);
f1633031 393 void (*kick_validate) (struct dasd_device *);
5db8440c 394 int (*check_attention)(struct dasd_device *, __u8);
5a3b7b11
SH
395 int (*host_access_count)(struct dasd_device *);
396 int (*hosts_print)(struct dasd_device *, struct seq_file *);
a521b048
SH
397 void (*handle_hpf_error)(struct dasd_device *, struct irb *);
398 void (*disable_hpf)(struct dasd_device *);
399 int (*hpf_enabled)(struct dasd_device *);
400 void (*reset_path)(struct dasd_device *, __u8);
1da177e4
LT
401};
402
403extern struct dasd_discipline *dasd_diag_discipline_pointer;
404
20c64468
SW
405/*
406 * Notification numbers for extended error reporting notifications:
407 * The DASD_EER_DISABLE notification is sent before a dasd_device (and it's
408 * eer pointer) is freed. The error reporting module needs to do all necessary
409 * cleanup steps.
410 * The DASD_EER_TRIGGER notification sends the actual error reports (triggers).
411 */
412#define DASD_EER_DISABLE 0
413#define DASD_EER_TRIGGER 1
414
415/* Trigger IDs for extended error reporting DASD_EER_TRIGGER notification */
416#define DASD_EER_FATALERROR 1
417#define DASD_EER_NOPATH 2
418#define DASD_EER_STATECHANGE 3
419#define DASD_EER_PPRCSUSPEND 4
420
c9346151
SH
421/* DASD path handling */
422
423#define DASD_PATH_OPERATIONAL 1
424#define DASD_PATH_TBV 2
425#define DASD_PATH_PP 3
426#define DASD_PATH_NPP 4
427#define DASD_PATH_MISCABLED 5
428#define DASD_PATH_NOHPF 6
429#define DASD_PATH_CUIR 7
a521b048 430#define DASD_PATH_IFCC 8
c9346151 431
a521b048
SH
432#define DASD_THRHLD_MAX 4294967295U
433#define DASD_INTERVAL_MAX 4294967295U
c9346151 434
a4d26c6a 435struct dasd_path {
c9346151 436 unsigned long flags;
a521b048
SH
437 u8 cssid;
438 u8 ssid;
439 u8 chpid;
c9346151 440 struct dasd_conf_data *conf_data;
a521b048 441 atomic_t error_count;
7bf76f01 442 unsigned long errorclk;
a4d26c6a
SW
443};
444
c9346151 445
4fa52aa7
SW
446struct dasd_profile_info {
447 /* legacy part of profile data, as in dasd_profile_info_t */
448 unsigned int dasd_io_reqs; /* number of requests processed */
449 unsigned int dasd_io_sects; /* number of sectors processed */
450 unsigned int dasd_io_secs[32]; /* histogram of request's sizes */
451 unsigned int dasd_io_times[32]; /* histogram of requests's times */
452 unsigned int dasd_io_timps[32]; /* h. of requests's times per sector */
453 unsigned int dasd_io_time1[32]; /* hist. of time from build to start */
454 unsigned int dasd_io_time2[32]; /* hist. of time from start to irq */
455 unsigned int dasd_io_time2ps[32]; /* hist. of time from start to irq */
456 unsigned int dasd_io_time3[32]; /* hist. of time from irq to end */
457 unsigned int dasd_io_nr_req[32]; /* hist. of # of requests in chanq */
458
459 /* new data */
460 struct timespec starttod; /* time of start or last reset */
461 unsigned int dasd_io_alias; /* requests using an alias */
462 unsigned int dasd_io_tpm; /* requests using transport mode */
463 unsigned int dasd_read_reqs; /* total number of read requests */
464 unsigned int dasd_read_sects; /* total number read sectors */
465 unsigned int dasd_read_alias; /* read request using an alias */
466 unsigned int dasd_read_tpm; /* read requests in transport mode */
467 unsigned int dasd_read_secs[32]; /* histogram of request's sizes */
468 unsigned int dasd_read_times[32]; /* histogram of requests's times */
469 unsigned int dasd_read_time1[32]; /* hist. time from build to start */
470 unsigned int dasd_read_time2[32]; /* hist. of time from start to irq */
471 unsigned int dasd_read_time3[32]; /* hist. of time from irq to end */
472 unsigned int dasd_read_nr_req[32]; /* hist. of # of requests in chanq */
d2907225
SH
473 unsigned long dasd_sum_times; /* sum of request times */
474 unsigned long dasd_sum_time_str; /* sum of time from build to start */
475 unsigned long dasd_sum_time_irq; /* sum of time from start to irq */
476 unsigned long dasd_sum_time_end; /* sum of time from irq to end */
4fa52aa7
SW
477};
478
479struct dasd_profile {
480 struct dentry *dentry;
481 struct dasd_profile_info *data;
482 spinlock_t lock;
483};
484
1da177e4
LT
485struct dasd_device {
486 /* Block device stuff. */
8e09f215
SW
487 struct dasd_block *block;
488
1da177e4 489 unsigned int devindex;
138c014d
HH
490 unsigned long flags; /* per device flags */
491 unsigned short features; /* copy of devmap-features (read-only!) */
1da177e4 492
20c64468
SW
493 /* extended error reporting stuff (eer) */
494 struct dasd_ccw_req *eer_cqr;
495
1da177e4
LT
496 /* Device discipline stuff. */
497 struct dasd_discipline *discipline;
aa88861f 498 struct dasd_discipline *base_discipline;
543691a4 499 void *private;
c9346151
SH
500 struct dasd_path path[8];
501 __u8 opm;
1da177e4
LT
502
503 /* Device state and target state. */
504 int state, target;
9eb25122 505 struct mutex state_mutex;
1da177e4
LT
506 int stopped; /* device (ccw_device_start) was stopped */
507
8e09f215 508 /* reference count. */
1da177e4 509 atomic_t ref_count;
1da177e4
LT
510
511 /* ccw queue and memory for static ccw/erp buffers. */
512 struct list_head ccw_queue;
513 spinlock_t mem_lock;
514 void *ccw_mem;
515 void *erp_mem;
516 struct list_head ccw_chunks;
517 struct list_head erp_chunks;
518
519 atomic_t tasklet_scheduled;
520 struct tasklet_struct tasklet;
521 struct work_struct kick_work;
d41dd122 522 struct work_struct restore_device;
501183f2 523 struct work_struct reload_device;
f1633031 524 struct work_struct kick_validate;
59a9ed5f 525 struct work_struct suc_work;
a521b048 526 struct work_struct requeue_requests;
1da177e4
LT
527 struct timer_list timer;
528
529 debug_info_t *debug_area;
530
531 struct ccw_device *cdev;
532
8e09f215
SW
533 /* hook for alias management */
534 struct list_head alias_list;
7c8faa86
SH
535
536 /* default expiration time in s */
537 unsigned long default_expires;
1f1ee9ad 538 unsigned long default_retries;
4fa52aa7 539
3d71ad32
HR
540 unsigned long blk_timeout;
541
a521b048
SH
542 unsigned long path_thrhld;
543 unsigned long path_interval;
544
4fa52aa7 545 struct dentry *debugfs_dentry;
5a3b7b11 546 struct dentry *hosts_dentry;
4fa52aa7 547 struct dasd_profile profile;
8e09f215
SW
548};
549
550struct dasd_block {
551 /* Block device stuff. */
552 struct gendisk *gdp;
553 struct request_queue *request_queue;
554 spinlock_t request_queue_lock;
e443343e 555 struct blk_mq_tag_set tag_set;
8e09f215
SW
556 struct block_device *bdev;
557 atomic_t open_count;
558
7bf76f01 559 unsigned long blocks; /* size of volume in blocks */
8e09f215
SW
560 unsigned int bp_block; /* bytes per block */
561 unsigned int s2b_shift; /* log2 (bp_block/512) */
562
563 struct dasd_device *base;
564 struct list_head ccw_queue;
565 spinlock_t queue_lock;
566
567 atomic_t tasklet_scheduled;
568 struct tasklet_struct tasklet;
569 struct timer_list timer;
570
4fa52aa7
SW
571 struct dentry *debugfs_dentry;
572 struct dasd_profile profile;
1da177e4
LT
573};
574
5db8440c
SH
575struct dasd_attention_data {
576 struct dasd_device *device;
577 __u8 lpum;
578};
8e09f215 579
e443343e
SH
580struct dasd_queue {
581 spinlock_t lock;
582};
583
1da177e4
LT
584/* reasons why device (ccw_device_start) was stopped */
585#define DASD_STOPPED_NOT_ACC 1 /* not accessible */
586#define DASD_STOPPED_QUIESCE 2 /* Quiesced */
587#define DASD_STOPPED_PENDING 4 /* long busy */
588#define DASD_STOPPED_DC_WAIT 8 /* disconnected, wait */
8e09f215 589#define DASD_STOPPED_SU 16 /* summary unit check handling */
d41dd122
SH
590#define DASD_STOPPED_PM 32 /* pm state transition */
591#define DASD_UNRESUMED_PM 64 /* pm resume failed state */
1da177e4
LT
592
593/* per device flags */
1da177e4 594#define DASD_FLAG_OFFLINE 3 /* device is in offline processing */
20c64468
SW
595#define DASD_FLAG_EER_SNSS 4 /* A SNSS is required */
596#define DASD_FLAG_EER_IN_USE 5 /* A SNSS request is running */
33b62a30
SW
597#define DASD_FLAG_DEVICE_RO 6 /* The device itself is read-only. Don't
598 * confuse this with the user specified
599 * read-only feature.
600 */
5a27e60d
SW
601#define DASD_FLAG_IS_RESERVED 7 /* The device is reserved */
602#define DASD_FLAG_LOCK_STOLEN 8 /* The device lock was stolen */
c8d1c0ff 603#define DASD_FLAG_SUSPENDED 9 /* The device was suspended */
d07dc5d8
SH
604#define DASD_FLAG_SAFE_OFFLINE 10 /* safe offline processing requested*/
605#define DASD_FLAG_SAFE_OFFLINE_RUNNING 11 /* safe offline running */
5ea34a01 606#define DASD_FLAG_ABORTALL 12 /* Abort all noretry requests */
1eb38023 607#define DASD_FLAG_PATH_VERIFY 13 /* Path verification worker running */
59a9ed5f 608#define DASD_FLAG_SUC 14 /* unhandled summary unit check */
5a27e60d 609
5ea34a01
HR
610#define DASD_SLEEPON_START_TAG ((void *) 1)
611#define DASD_SLEEPON_END_TAG ((void *) 2)
1da177e4
LT
612
613void dasd_put_device_wake(struct dasd_device *);
614
615/*
616 * Reference count inliners
617 */
618static inline void
619dasd_get_device(struct dasd_device *device)
620{
621 atomic_inc(&device->ref_count);
622}
623
624static inline void
625dasd_put_device(struct dasd_device *device)
626{
627 if (atomic_dec_return(&device->ref_count) == 0)
628 dasd_put_device_wake(device);
629}
630
631/*
632 * The static memory in ccw_mem and erp_mem is managed by a sorted
633 * list of free memory chunks.
634 */
635struct dasd_mchunk
636{
637 struct list_head list;
638 unsigned long size;
639} __attribute__ ((aligned(8)));
640
641static inline void
642dasd_init_chunklist(struct list_head *chunk_list, void *mem,
643 unsigned long size)
644{
645 struct dasd_mchunk *chunk;
646
647 INIT_LIST_HEAD(chunk_list);
648 chunk = (struct dasd_mchunk *) mem;
649 chunk->size = size - sizeof(struct dasd_mchunk);
650 list_add(&chunk->list, chunk_list);
651}
652
653static inline void *
654dasd_alloc_chunk(struct list_head *chunk_list, unsigned long size)
655{
656 struct dasd_mchunk *chunk, *tmp;
657
658 size = (size + 7L) & -8L;
659 list_for_each_entry(chunk, chunk_list, list) {
660 if (chunk->size < size)
661 continue;
662 if (chunk->size > size + sizeof(struct dasd_mchunk)) {
663 char *endaddr = (char *) (chunk + 1) + chunk->size;
664 tmp = (struct dasd_mchunk *) (endaddr - size) - 1;
665 tmp->size = size;
666 chunk->size -= size + sizeof(struct dasd_mchunk);
667 chunk = tmp;
668 } else
669 list_del(&chunk->list);
670 return (void *) (chunk + 1);
671 }
672 return NULL;
673}
674
675static inline void
676dasd_free_chunk(struct list_head *chunk_list, void *mem)
677{
678 struct dasd_mchunk *chunk, *tmp;
679 struct list_head *p, *left;
680
681 chunk = (struct dasd_mchunk *)
682 ((char *) mem - sizeof(struct dasd_mchunk));
683 /* Find out the left neighbour in chunk_list. */
684 left = chunk_list;
685 list_for_each(p, chunk_list) {
686 if (list_entry(p, struct dasd_mchunk, list) > chunk)
687 break;
688 left = p;
689 }
690 /* Try to merge with right neighbour = next element from left. */
691 if (left->next != chunk_list) {
692 tmp = list_entry(left->next, struct dasd_mchunk, list);
693 if ((char *) (chunk + 1) + chunk->size == (char *) tmp) {
694 list_del(&tmp->list);
695 chunk->size += tmp->size + sizeof(struct dasd_mchunk);
696 }
697 }
698 /* Try to merge with left neighbour. */
699 if (left != chunk_list) {
700 tmp = list_entry(left, struct dasd_mchunk, list);
701 if ((char *) (tmp + 1) + tmp->size == (char *) chunk) {
702 tmp->size += chunk->size + sizeof(struct dasd_mchunk);
703 return;
704 }
705 }
706 __list_add(&chunk->list, left, left->next);
707}
708
709/*
710 * Check if bsize is in { 512, 1024, 2048, 4096 }
711 */
712static inline int
713dasd_check_blocksize(int bsize)
714{
e108cebb 715 if (bsize < 512 || bsize > 4096 || !is_power_of_2(bsize))
1da177e4
LT
716 return -EMEDIUMTYPE;
717 return 0;
718}
719
720/* externals in dasd.c */
4fa52aa7
SW
721#define DASD_PROFILE_OFF 0
722#define DASD_PROFILE_ON 1
723#define DASD_PROFILE_GLOBAL_ONLY 2
1da177e4
LT
724
725extern debug_info_t *dasd_debug_area;
8ea55c95 726extern struct dasd_profile dasd_global_profile;
4fa52aa7 727extern unsigned int dasd_global_profile_level;
83d5cde4 728extern const struct block_device_operations dasd_device_operations;
1da177e4 729
e18b890b 730extern struct kmem_cache *dasd_page_cache;
1da177e4
LT
731
732struct dasd_ccw_req *
68b781fe 733dasd_kmalloc_request(int , int, int, struct dasd_device *);
1da177e4 734struct dasd_ccw_req *
68b781fe 735dasd_smalloc_request(int , int, int, struct dasd_device *);
1da177e4
LT
736void dasd_kfree_request(struct dasd_ccw_req *, struct dasd_device *);
737void dasd_sfree_request(struct dasd_ccw_req *, struct dasd_device *);
5915a873 738void dasd_wakeup_cb(struct dasd_ccw_req *, void *);
1da177e4
LT
739
740static inline int
741dasd_kmalloc_set_cda(struct ccw1 *ccw, void *cda, struct dasd_device *device)
742{
743 return set_normalized_cda(ccw, cda);
744}
745
746struct dasd_device *dasd_alloc_device(void);
747void dasd_free_device(struct dasd_device *);
748
8e09f215
SW
749struct dasd_block *dasd_alloc_block(void);
750void dasd_free_block(struct dasd_block *);
751
e443343e 752enum blk_eh_timer_return dasd_times_out(struct request *req, bool reserved);
3d71ad32 753
1da177e4
LT
754void dasd_enable_device(struct dasd_device *);
755void dasd_set_target_state(struct dasd_device *, int);
756void dasd_kick_device(struct dasd_device *);
d41dd122 757void dasd_restore_device(struct dasd_device *);
501183f2 758void dasd_reload_device(struct dasd_device *);
a521b048 759void dasd_schedule_requeue(struct dasd_device *);
1da177e4
LT
760
761void dasd_add_request_head(struct dasd_ccw_req *);
762void dasd_add_request_tail(struct dasd_ccw_req *);
763int dasd_start_IO(struct dasd_ccw_req *);
764int dasd_term_IO(struct dasd_ccw_req *);
8e09f215
SW
765void dasd_schedule_device_bh(struct dasd_device *);
766void dasd_schedule_block_bh(struct dasd_block *);
1da177e4 767int dasd_sleep_on(struct dasd_ccw_req *);
d42e1712 768int dasd_sleep_on_queue(struct list_head *);
1da177e4
LT
769int dasd_sleep_on_immediatly(struct dasd_ccw_req *);
770int dasd_sleep_on_interruptible(struct dasd_ccw_req *);
8e09f215
SW
771void dasd_device_set_timer(struct dasd_device *, int);
772void dasd_device_clear_timer(struct dasd_device *);
773void dasd_block_set_timer(struct dasd_block *, int);
774void dasd_block_clear_timer(struct dasd_block *);
1da177e4 775int dasd_cancel_req(struct dasd_ccw_req *);
8e09f215 776int dasd_flush_device_queue(struct dasd_device *);
1da177e4 777int dasd_generic_probe (struct ccw_device *, struct dasd_discipline *);
c020d722 778void dasd_generic_free_discipline(struct dasd_device *);
1da177e4
LT
779void dasd_generic_remove (struct ccw_device *cdev);
780int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *);
781int dasd_generic_set_offline (struct ccw_device *cdev);
782int dasd_generic_notify(struct ccw_device *, int);
a4d26c6a
SW
783int dasd_generic_last_path_gone(struct dasd_device *);
784int dasd_generic_path_operational(struct dasd_device *);
4679e893 785void dasd_generic_shutdown(struct ccw_device *);
a4d26c6a 786
8e09f215 787void dasd_generic_handle_state_change(struct dasd_device *);
d41dd122
SH
788int dasd_generic_pm_freeze(struct ccw_device *);
789int dasd_generic_restore_device(struct ccw_device *);
a23ed009 790enum uc_todo dasd_generic_uc_handler(struct ccw_device *, struct irb *);
a4d26c6a
SW
791void dasd_generic_path_event(struct ccw_device *, int *);
792int dasd_generic_verify_path(struct dasd_device *, __u8);
1da177e4 793
68b781fe 794int dasd_generic_read_dev_chars(struct dasd_device *, int, void *, int);
f3eb5384 795char *dasd_get_sense(struct irb *);
17283b56 796
eb6e199b
SW
797void dasd_device_set_stop_bits(struct dasd_device *, int);
798void dasd_device_remove_stop_bits(struct dasd_device *, int);
799
33b62a30
SW
800int dasd_device_is_ro(struct dasd_device *);
801
4fa52aa7
SW
802void dasd_profile_reset(struct dasd_profile *);
803int dasd_profile_on(struct dasd_profile *);
804void dasd_profile_off(struct dasd_profile *);
4fa52aa7 805char *dasd_get_user_string(const char __user *, size_t);
33b62a30 806
1da177e4
LT
807/* externals in dasd_devmap.c */
808extern int dasd_max_devindex;
809extern int dasd_probeonly;
810extern int dasd_autodetect;
40545573 811extern int dasd_nopav;
f3eb5384 812extern int dasd_nofcx;
1da177e4
LT
813
814int dasd_devmap_init(void);
815void dasd_devmap_exit(void);
816
817struct dasd_device *dasd_create_device(struct ccw_device *);
818void dasd_delete_device(struct dasd_device *);
819
f24acd45
HH
820int dasd_get_feature(struct ccw_device *, int);
821int dasd_set_feature(struct ccw_device *, int, int);
822
1da177e4
LT
823int dasd_add_sysfs_files(struct ccw_device *);
824void dasd_remove_sysfs_files(struct ccw_device *);
825
826struct dasd_device *dasd_device_from_cdev(struct ccw_device *);
a00bfd71 827struct dasd_device *dasd_device_from_cdev_locked(struct ccw_device *);
1da177e4
LT
828struct dasd_device *dasd_device_from_devindex(int);
829
65f8da47
SW
830void dasd_add_link_to_gendisk(struct gendisk *, struct dasd_device *);
831struct dasd_device *dasd_device_from_gendisk(struct gendisk *);
832
3b1bea01 833int dasd_parse(void) __init;
69f90f6a 834int dasd_busid_known(const char *);
1da177e4
LT
835
836/* externals in dasd_gendisk.c */
837int dasd_gendisk_init(void);
838void dasd_gendisk_exit(void);
8e09f215
SW
839int dasd_gendisk_alloc(struct dasd_block *);
840void dasd_gendisk_free(struct dasd_block *);
841int dasd_scan_partitions(struct dasd_block *);
842void dasd_destroy_partitions(struct dasd_block *);
1da177e4
LT
843
844/* externals in dasd_ioctl.c */
57a7c0bc 845int dasd_ioctl(struct block_device *, fmode_t, unsigned int, unsigned long);
1da177e4
LT
846
847/* externals in dasd_proc.c */
848int dasd_proc_init(void);
849void dasd_proc_exit(void);
850
851/* externals in dasd_erp.c */
852struct dasd_ccw_req *dasd_default_erp_action(struct dasd_ccw_req *);
853struct dasd_ccw_req *dasd_default_erp_postaction(struct dasd_ccw_req *);
854struct dasd_ccw_req *dasd_alloc_erp_request(char *, int, int,
855 struct dasd_device *);
856void dasd_free_erp_request(struct dasd_ccw_req *, struct dasd_device *);
857void dasd_log_sense(struct dasd_ccw_req *, struct irb *);
fc19f381 858void dasd_log_sense_dbf(struct dasd_ccw_req *cqr, struct irb *irb);
1da177e4 859
1da177e4 860/* externals in dasd_3990_erp.c */
1da177e4 861struct dasd_ccw_req *dasd_3990_erp_action(struct dasd_ccw_req *);
f60c768c 862void dasd_3990_erp_handle_sim(struct dasd_device *, char *);
1da177e4 863
20c64468
SW
864/* externals in dasd_eer.c */
865#ifdef CONFIG_DASD_EER
866int dasd_eer_init(void);
867void dasd_eer_exit(void);
868int dasd_eer_enable(struct dasd_device *);
869void dasd_eer_disable(struct dasd_device *);
870void dasd_eer_write(struct dasd_device *, struct dasd_ccw_req *cqr,
871 unsigned int id);
872void dasd_eer_snss(struct dasd_device *);
873
874static inline int dasd_eer_enabled(struct dasd_device *device)
875{
876 return device->eer_cqr != NULL;
877}
878#else
879#define dasd_eer_init() (0)
880#define dasd_eer_exit() do { } while (0)
881#define dasd_eer_enable(d) (0)
882#define dasd_eer_disable(d) do { } while (0)
883#define dasd_eer_write(d,c,i) do { } while (0)
884#define dasd_eer_snss(d) do { } while (0)
885#define dasd_eer_enabled(d) (0)
886#endif /* CONFIG_DASD_ERR */
887
c9346151
SH
888
889/* DASD path handling functions */
890
891/*
892 * helper functions to modify bit masks for a given channel path for a device
893 */
894static inline int dasd_path_is_operational(struct dasd_device *device, int chp)
895{
896 return test_bit(DASD_PATH_OPERATIONAL, &device->path[chp].flags);
897}
898
899static inline int dasd_path_need_verify(struct dasd_device *device, int chp)
900{
901 return test_bit(DASD_PATH_TBV, &device->path[chp].flags);
902}
903
904static inline void dasd_path_verify(struct dasd_device *device, int chp)
905{
906 __set_bit(DASD_PATH_TBV, &device->path[chp].flags);
907}
908
909static inline void dasd_path_clear_verify(struct dasd_device *device, int chp)
910{
911 __clear_bit(DASD_PATH_TBV, &device->path[chp].flags);
912}
913
914static inline void dasd_path_clear_all_verify(struct dasd_device *device)
915{
916 int chp;
917
918 for (chp = 0; chp < 8; chp++)
919 dasd_path_clear_verify(device, chp);
920}
921
922static inline void dasd_path_operational(struct dasd_device *device, int chp)
923{
924 __set_bit(DASD_PATH_OPERATIONAL, &device->path[chp].flags);
925 device->opm |= (0x80 >> chp);
926}
927
928static inline void dasd_path_nonpreferred(struct dasd_device *device, int chp)
929{
930 __set_bit(DASD_PATH_NPP, &device->path[chp].flags);
931}
932
933static inline int dasd_path_is_nonpreferred(struct dasd_device *device, int chp)
934{
935 return test_bit(DASD_PATH_NPP, &device->path[chp].flags);
936}
937
938static inline void dasd_path_clear_nonpreferred(struct dasd_device *device,
939 int chp)
940{
941 __clear_bit(DASD_PATH_NPP, &device->path[chp].flags);
942}
943
944static inline void dasd_path_preferred(struct dasd_device *device, int chp)
945{
946 __set_bit(DASD_PATH_PP, &device->path[chp].flags);
947}
948
949static inline int dasd_path_is_preferred(struct dasd_device *device, int chp)
950{
951 return test_bit(DASD_PATH_PP, &device->path[chp].flags);
952}
953
954static inline void dasd_path_clear_preferred(struct dasd_device *device,
955 int chp)
956{
957 __clear_bit(DASD_PATH_PP, &device->path[chp].flags);
958}
959
960static inline void dasd_path_clear_oper(struct dasd_device *device, int chp)
961{
962 __clear_bit(DASD_PATH_OPERATIONAL, &device->path[chp].flags);
963 device->opm &= ~(0x80 >> chp);
964}
965
966static inline void dasd_path_clear_cable(struct dasd_device *device, int chp)
967{
968 __clear_bit(DASD_PATH_MISCABLED, &device->path[chp].flags);
969}
970
971static inline void dasd_path_cuir(struct dasd_device *device, int chp)
972{
973 __set_bit(DASD_PATH_CUIR, &device->path[chp].flags);
974}
975
976static inline int dasd_path_is_cuir(struct dasd_device *device, int chp)
977{
978 return test_bit(DASD_PATH_CUIR, &device->path[chp].flags);
979}
980
981static inline void dasd_path_clear_cuir(struct dasd_device *device, int chp)
982{
983 __clear_bit(DASD_PATH_CUIR, &device->path[chp].flags);
984}
985
a521b048
SH
986static inline void dasd_path_ifcc(struct dasd_device *device, int chp)
987{
988 set_bit(DASD_PATH_IFCC, &device->path[chp].flags);
989}
990
991static inline int dasd_path_is_ifcc(struct dasd_device *device, int chp)
992{
993 return test_bit(DASD_PATH_IFCC, &device->path[chp].flags);
994}
995
996static inline void dasd_path_clear_ifcc(struct dasd_device *device, int chp)
997{
998 clear_bit(DASD_PATH_IFCC, &device->path[chp].flags);
999}
1000
c9346151
SH
1001static inline void dasd_path_clear_nohpf(struct dasd_device *device, int chp)
1002{
1003 __clear_bit(DASD_PATH_NOHPF, &device->path[chp].flags);
1004}
1005
1006static inline void dasd_path_miscabled(struct dasd_device *device, int chp)
1007{
1008 __set_bit(DASD_PATH_MISCABLED, &device->path[chp].flags);
1009}
1010
1011static inline int dasd_path_is_miscabled(struct dasd_device *device, int chp)
1012{
1013 return test_bit(DASD_PATH_MISCABLED, &device->path[chp].flags);
1014}
1015
1016static inline void dasd_path_nohpf(struct dasd_device *device, int chp)
1017{
1018 __set_bit(DASD_PATH_NOHPF, &device->path[chp].flags);
1019}
1020
1021static inline int dasd_path_is_nohpf(struct dasd_device *device, int chp)
1022{
1023 return test_bit(DASD_PATH_NOHPF, &device->path[chp].flags);
1024}
1025
1026/*
1027 * get functions for path masks
1028 * will return a path masks for the given device
1029 */
1030
1031static inline __u8 dasd_path_get_opm(struct dasd_device *device)
1032{
1033 return device->opm;
1034}
1035
1036static inline __u8 dasd_path_get_tbvpm(struct dasd_device *device)
1037{
1038 int chp;
1039 __u8 tbvpm = 0x00;
1040
1041 for (chp = 0; chp < 8; chp++)
1042 if (dasd_path_need_verify(device, chp))
1043 tbvpm |= 0x80 >> chp;
1044 return tbvpm;
1045}
1046
1047static inline __u8 dasd_path_get_nppm(struct dasd_device *device)
1048{
1049 int chp;
1050 __u8 npm = 0x00;
1051
1052 for (chp = 0; chp < 8; chp++) {
1053 if (dasd_path_is_nonpreferred(device, chp))
1054 npm |= 0x80 >> chp;
1055 }
1056 return npm;
1057}
1058
1059static inline __u8 dasd_path_get_ppm(struct dasd_device *device)
1060{
1061 int chp;
1062 __u8 ppm = 0x00;
1063
1064 for (chp = 0; chp < 8; chp++)
1065 if (dasd_path_is_preferred(device, chp))
1066 ppm |= 0x80 >> chp;
1067 return ppm;
1068}
1069
1070static inline __u8 dasd_path_get_cablepm(struct dasd_device *device)
1071{
1072 int chp;
1073 __u8 cablepm = 0x00;
1074
1075 for (chp = 0; chp < 8; chp++)
1076 if (dasd_path_is_miscabled(device, chp))
1077 cablepm |= 0x80 >> chp;
1078 return cablepm;
1079}
1080
1081static inline __u8 dasd_path_get_cuirpm(struct dasd_device *device)
1082{
1083 int chp;
1084 __u8 cuirpm = 0x00;
1085
1086 for (chp = 0; chp < 8; chp++)
1087 if (dasd_path_is_cuir(device, chp))
1088 cuirpm |= 0x80 >> chp;
1089 return cuirpm;
1090}
1091
a521b048
SH
1092static inline __u8 dasd_path_get_ifccpm(struct dasd_device *device)
1093{
1094 int chp;
1095 __u8 ifccpm = 0x00;
1096
1097 for (chp = 0; chp < 8; chp++)
1098 if (dasd_path_is_ifcc(device, chp))
1099 ifccpm |= 0x80 >> chp;
1100 return ifccpm;
1101}
1102
c9346151
SH
1103static inline __u8 dasd_path_get_hpfpm(struct dasd_device *device)
1104{
1105 int chp;
1106 __u8 hpfpm = 0x00;
1107
1108 for (chp = 0; chp < 8; chp++)
1109 if (dasd_path_is_nohpf(device, chp))
1110 hpfpm |= 0x80 >> chp;
1111 return hpfpm;
1112}
1113
1114/*
1115 * add functions for path masks
1116 * the existing path mask will be extended by the given path mask
1117 */
1118static inline void dasd_path_add_tbvpm(struct dasd_device *device, __u8 pm)
1119{
1120 int chp;
1121
1122 for (chp = 0; chp < 8; chp++)
1123 if (pm & (0x80 >> chp))
1124 dasd_path_verify(device, chp);
1125}
1126
a521b048
SH
1127static inline __u8 dasd_path_get_notoperpm(struct dasd_device *device)
1128{
1129 int chp;
1130 __u8 nopm = 0x00;
1131
1132 for (chp = 0; chp < 8; chp++)
1133 if (dasd_path_is_nohpf(device, chp) ||
1134 dasd_path_is_ifcc(device, chp) ||
1135 dasd_path_is_cuir(device, chp) ||
1136 dasd_path_is_miscabled(device, chp))
1137 nopm |= 0x80 >> chp;
1138 return nopm;
1139}
1140
c9346151
SH
1141static inline void dasd_path_add_opm(struct dasd_device *device, __u8 pm)
1142{
1143 int chp;
1144
1145 for (chp = 0; chp < 8; chp++)
1146 if (pm & (0x80 >> chp)) {
1147 dasd_path_operational(device, chp);
1148 /*
1149 * if the path is used
1150 * it should not be in one of the negative lists
1151 */
1152 dasd_path_clear_nohpf(device, chp);
1153 dasd_path_clear_cuir(device, chp);
1154 dasd_path_clear_cable(device, chp);
a521b048 1155 dasd_path_clear_ifcc(device, chp);
c9346151
SH
1156 }
1157}
1158
1159static inline void dasd_path_add_cablepm(struct dasd_device *device, __u8 pm)
1160{
1161 int chp;
1162
1163 for (chp = 0; chp < 8; chp++)
1164 if (pm & (0x80 >> chp))
1165 dasd_path_miscabled(device, chp);
1166}
1167
1168static inline void dasd_path_add_cuirpm(struct dasd_device *device, __u8 pm)
1169{
1170 int chp;
1171
1172 for (chp = 0; chp < 8; chp++)
1173 if (pm & (0x80 >> chp))
1174 dasd_path_cuir(device, chp);
1175}
1176
a521b048
SH
1177static inline void dasd_path_add_ifccpm(struct dasd_device *device, __u8 pm)
1178{
1179 int chp;
1180
1181 for (chp = 0; chp < 8; chp++)
1182 if (pm & (0x80 >> chp))
1183 dasd_path_ifcc(device, chp);
1184}
1185
c9346151
SH
1186static inline void dasd_path_add_nppm(struct dasd_device *device, __u8 pm)
1187{
1188 int chp;
1189
1190 for (chp = 0; chp < 8; chp++)
1191 if (pm & (0x80 >> chp))
1192 dasd_path_nonpreferred(device, chp);
1193}
1194
1195static inline void dasd_path_add_nohpfpm(struct dasd_device *device, __u8 pm)
1196{
1197 int chp;
1198
1199 for (chp = 0; chp < 8; chp++)
1200 if (pm & (0x80 >> chp))
1201 dasd_path_nohpf(device, chp);
1202}
1203
1204static inline void dasd_path_add_ppm(struct dasd_device *device, __u8 pm)
1205{
1206 int chp;
1207
1208 for (chp = 0; chp < 8; chp++)
1209 if (pm & (0x80 >> chp))
1210 dasd_path_preferred(device, chp);
1211}
1212
1213/*
1214 * set functions for path masks
1215 * the existing path mask will be replaced by the given path mask
1216 */
1217static inline void dasd_path_set_tbvpm(struct dasd_device *device, __u8 pm)
1218{
1219 int chp;
1220
1221 for (chp = 0; chp < 8; chp++)
1222 if (pm & (0x80 >> chp))
1223 dasd_path_verify(device, chp);
1224 else
1225 dasd_path_clear_verify(device, chp);
1226}
1227
1228static inline void dasd_path_set_opm(struct dasd_device *device, __u8 pm)
1229{
1230 int chp;
1231
1232 for (chp = 0; chp < 8; chp++) {
1233 dasd_path_clear_oper(device, chp);
1234 if (pm & (0x80 >> chp)) {
1235 dasd_path_operational(device, chp);
1236 /*
1237 * if the path is used
1238 * it should not be in one of the negative lists
1239 */
1240 dasd_path_clear_nohpf(device, chp);
1241 dasd_path_clear_cuir(device, chp);
1242 dasd_path_clear_cable(device, chp);
a521b048 1243 dasd_path_clear_ifcc(device, chp);
c9346151
SH
1244 }
1245 }
1246}
1247
1248/*
1249 * remove functions for path masks
1250 * the existing path mask will be cleared with the given path mask
1251 */
1252static inline void dasd_path_remove_opm(struct dasd_device *device, __u8 pm)
1253{
1254 int chp;
1255
1256 for (chp = 0; chp < 8; chp++) {
1257 if (pm & (0x80 >> chp))
1258 dasd_path_clear_oper(device, chp);
1259 }
1260}
1261
1262/*
1263 * add the newly available path to the to be verified pm and remove it from
1264 * normal operation until it is verified
1265 */
1266static inline void dasd_path_available(struct dasd_device *device, int chp)
1267{
1268 dasd_path_clear_oper(device, chp);
1269 dasd_path_verify(device, chp);
1270}
1271
1272static inline void dasd_path_notoper(struct dasd_device *device, int chp)
1273{
1274 dasd_path_clear_oper(device, chp);
1275 dasd_path_clear_preferred(device, chp);
1276 dasd_path_clear_nonpreferred(device, chp);
1277}
1278
1279/*
1280 * remove all paths from normal operation
1281 */
1282static inline void dasd_path_no_path(struct dasd_device *device)
1283{
1284 int chp;
1285
1286 for (chp = 0; chp < 8; chp++)
1287 dasd_path_notoper(device, chp);
1288
1289 dasd_path_clear_all_verify(device);
1290}
1291
1292/* end - path handling */
1293
1da177e4 1294#endif /* DASD_H */