dasd_int.h 37 KB

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