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