dasd_int.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  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. unsigned int proc_bytes; /* bytes for partial completion */
  168. };
  169. /*
  170. * dasd_ccw_req -> status can be:
  171. */
  172. #define DASD_CQR_FILLED 0x00 /* request is ready to be processed */
  173. #define DASD_CQR_DONE 0x01 /* request is completed successfully */
  174. #define DASD_CQR_NEED_ERP 0x02 /* request needs recovery action */
  175. #define DASD_CQR_IN_ERP 0x03 /* request is in recovery */
  176. #define DASD_CQR_FAILED 0x04 /* request is finally failed */
  177. #define DASD_CQR_TERMINATED 0x05 /* request was stopped by driver */
  178. #define DASD_CQR_QUEUED 0x80 /* request is queued to be processed */
  179. #define DASD_CQR_IN_IO 0x81 /* request is currently in IO */
  180. #define DASD_CQR_ERROR 0x82 /* request is completed with error */
  181. #define DASD_CQR_CLEAR_PENDING 0x83 /* request is clear pending */
  182. #define DASD_CQR_CLEARED 0x84 /* request was cleared */
  183. #define DASD_CQR_SUCCESS 0x85 /* request was successful */
  184. /* default expiration time*/
  185. #define DASD_EXPIRES 300
  186. #define DASD_EXPIRES_MAX 40000000
  187. #define DASD_RETRIES 256
  188. #define DASD_RETRIES_MAX 32768
  189. /* per dasd_ccw_req flags */
  190. #define DASD_CQR_FLAGS_USE_ERP 0 /* use ERP for this request */
  191. #define DASD_CQR_FLAGS_FAILFAST 1 /* FAILFAST */
  192. #define DASD_CQR_VERIFY_PATH 2 /* path verification request */
  193. #define DASD_CQR_ALLOW_SLOCK 3 /* Try this request even when lock was
  194. * stolen. Should not be combined with
  195. * DASD_CQR_FLAGS_USE_ERP
  196. */
  197. /*
  198. * The following flags are used to suppress output of certain errors.
  199. */
  200. #define DASD_CQR_SUPPRESS_NRF 4 /* Suppress 'No Record Found' error */
  201. #define DASD_CQR_SUPPRESS_FP 5 /* Suppress 'File Protected' error*/
  202. #define DASD_CQR_SUPPRESS_IL 6 /* Suppress 'Incorrect Length' error */
  203. #define DASD_CQR_SUPPRESS_CR 7 /* Suppress 'Command Reject' error */
  204. #define DASD_REQ_PER_DEV 4
  205. /* Signature for error recovery functions. */
  206. typedef struct dasd_ccw_req *(*dasd_erp_fn_t) (struct dasd_ccw_req *);
  207. /*
  208. * A single CQR can only contain a maximum of 255 CCWs. It is limited by
  209. * the locate record and locate record extended count value which can only hold
  210. * 1 Byte max.
  211. */
  212. #define DASD_CQR_MAX_CCW 255
  213. /*
  214. * Unique identifier for dasd device.
  215. */
  216. #define UA_NOT_CONFIGURED 0x00
  217. #define UA_BASE_DEVICE 0x01
  218. #define UA_BASE_PAV_ALIAS 0x02
  219. #define UA_HYPER_PAV_ALIAS 0x03
  220. struct dasd_uid {
  221. __u8 type;
  222. char vendor[4];
  223. char serial[15];
  224. __u16 ssid;
  225. __u8 real_unit_addr;
  226. __u8 base_unit_addr;
  227. char vduit[33];
  228. };
  229. /*
  230. * the struct dasd_discipline is
  231. * sth like a table of virtual functions, if you think of dasd_eckd
  232. * inheriting dasd...
  233. * no, currently we are not planning to reimplement the driver in C++
  234. */
  235. struct dasd_discipline {
  236. struct module *owner;
  237. char ebcname[8]; /* a name used for tagging and printks */
  238. char name[8]; /* a name used for tagging and printks */
  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. /*
  272. * Initialize block layer request queue.
  273. */
  274. void (*setup_blk_queue)(struct dasd_block *);
  275. /* (struct dasd_device *);
  276. * Device operation functions. build_cp creates a ccw chain for
  277. * a block device request, start_io starts the request and
  278. * term_IO cancels it (e.g. in case of a timeout). format_device
  279. * formats the device and check_device_format compares the format of
  280. * a device with the expected format_data.
  281. * handle_terminated_request allows to examine a cqr and prepare
  282. * it for retry.
  283. */
  284. struct dasd_ccw_req *(*build_cp) (struct dasd_device *,
  285. struct dasd_block *,
  286. struct request *);
  287. int (*start_IO) (struct dasd_ccw_req *);
  288. int (*term_IO) (struct dasd_ccw_req *);
  289. void (*handle_terminated_request) (struct dasd_ccw_req *);
  290. int (*format_device) (struct dasd_device *,
  291. struct format_data_t *, int);
  292. int (*check_device_format)(struct dasd_device *,
  293. struct format_check_t *, int);
  294. int (*free_cp) (struct dasd_ccw_req *, struct request *);
  295. /*
  296. * Error recovery functions. examine_error() returns a value that
  297. * indicates what to do for an error condition. If examine_error()
  298. * returns 'dasd_era_recover' erp_action() is called to create a
  299. * special error recovery ccw. erp_postaction() is called after
  300. * an error recovery ccw has finished its execution. dump_sense
  301. * is called for every error condition to print the sense data
  302. * to the console.
  303. */
  304. dasd_erp_fn_t(*erp_action) (struct dasd_ccw_req *);
  305. dasd_erp_fn_t(*erp_postaction) (struct dasd_ccw_req *);
  306. void (*dump_sense) (struct dasd_device *, struct dasd_ccw_req *,
  307. struct irb *);
  308. void (*dump_sense_dbf) (struct dasd_device *, struct irb *, char *);
  309. void (*check_for_device_change) (struct dasd_device *,
  310. struct dasd_ccw_req *,
  311. struct irb *);
  312. /* i/o control functions. */
  313. int (*fill_geometry) (struct dasd_block *, struct hd_geometry *);
  314. int (*fill_info) (struct dasd_device *, struct dasd_information2_t *);
  315. int (*ioctl) (struct dasd_block *, unsigned int, void __user *);
  316. /* suspend/resume functions */
  317. int (*freeze) (struct dasd_device *);
  318. int (*restore) (struct dasd_device *);
  319. /* reload device after state change */
  320. int (*reload) (struct dasd_device *);
  321. int (*get_uid) (struct dasd_device *, struct dasd_uid *);
  322. void (*kick_validate) (struct dasd_device *);
  323. int (*check_attention)(struct dasd_device *, __u8);
  324. int (*host_access_count)(struct dasd_device *);
  325. int (*hosts_print)(struct dasd_device *, struct seq_file *);
  326. void (*handle_hpf_error)(struct dasd_device *, struct irb *);
  327. void (*disable_hpf)(struct dasd_device *);
  328. int (*hpf_enabled)(struct dasd_device *);
  329. void (*reset_path)(struct dasd_device *, __u8);
  330. /*
  331. * Extent Space Efficient (ESE) relevant functions
  332. */
  333. int (*is_ese)(struct dasd_device *);
  334. /* Capacity */
  335. int (*space_allocated)(struct dasd_device *);
  336. int (*space_configured)(struct dasd_device *);
  337. int (*logical_capacity)(struct dasd_device *);
  338. int (*release_space)(struct dasd_device *, struct format_data_t *);
  339. /* Extent Pool */
  340. int (*ext_pool_id)(struct dasd_device *);
  341. int (*ext_size)(struct dasd_device *);
  342. int (*ext_pool_cap_at_warnlevel)(struct dasd_device *);
  343. int (*ext_pool_warn_thrshld)(struct dasd_device *);
  344. int (*ext_pool_oos)(struct dasd_device *);
  345. int (*ext_pool_exhaust)(struct dasd_device *, struct dasd_ccw_req *);
  346. struct dasd_ccw_req *(*ese_format)(struct dasd_device *,
  347. struct dasd_ccw_req *, struct irb *);
  348. int (*ese_read)(struct dasd_ccw_req *, struct irb *);
  349. };
  350. extern struct dasd_discipline *dasd_diag_discipline_pointer;
  351. /*
  352. * Notification numbers for extended error reporting notifications:
  353. * The DASD_EER_DISABLE notification is sent before a dasd_device (and it's
  354. * eer pointer) is freed. The error reporting module needs to do all necessary
  355. * cleanup steps.
  356. * The DASD_EER_TRIGGER notification sends the actual error reports (triggers).
  357. */
  358. #define DASD_EER_DISABLE 0
  359. #define DASD_EER_TRIGGER 1
  360. /* Trigger IDs for extended error reporting DASD_EER_TRIGGER notification */
  361. #define DASD_EER_FATALERROR 1
  362. #define DASD_EER_NOPATH 2
  363. #define DASD_EER_STATECHANGE 3
  364. #define DASD_EER_PPRCSUSPEND 4
  365. #define DASD_EER_NOSPC 5
  366. /* DASD path handling */
  367. #define DASD_PATH_OPERATIONAL 1
  368. #define DASD_PATH_TBV 2
  369. #define DASD_PATH_PP 3
  370. #define DASD_PATH_NPP 4
  371. #define DASD_PATH_MISCABLED 5
  372. #define DASD_PATH_NOHPF 6
  373. #define DASD_PATH_CUIR 7
  374. #define DASD_PATH_IFCC 8
  375. #define DASD_THRHLD_MAX 4294967295U
  376. #define DASD_INTERVAL_MAX 4294967295U
  377. struct dasd_path {
  378. unsigned long flags;
  379. u8 cssid;
  380. u8 ssid;
  381. u8 chpid;
  382. struct dasd_conf_data *conf_data;
  383. atomic_t error_count;
  384. unsigned long errorclk;
  385. };
  386. struct dasd_profile_info {
  387. /* legacy part of profile data, as in dasd_profile_info_t */
  388. unsigned int dasd_io_reqs; /* number of requests processed */
  389. unsigned int dasd_io_sects; /* number of sectors processed */
  390. unsigned int dasd_io_secs[32]; /* histogram of request's sizes */
  391. unsigned int dasd_io_times[32]; /* histogram of requests's times */
  392. unsigned int dasd_io_timps[32]; /* h. of requests's times per sector */
  393. unsigned int dasd_io_time1[32]; /* hist. of time from build to start */
  394. unsigned int dasd_io_time2[32]; /* hist. of time from start to irq */
  395. unsigned int dasd_io_time2ps[32]; /* hist. of time from start to irq */
  396. unsigned int dasd_io_time3[32]; /* hist. of time from irq to end */
  397. unsigned int dasd_io_nr_req[32]; /* hist. of # of requests in chanq */
  398. /* new data */
  399. struct timespec64 starttod; /* time of start or last reset */
  400. unsigned int dasd_io_alias; /* requests using an alias */
  401. unsigned int dasd_io_tpm; /* requests using transport mode */
  402. unsigned int dasd_read_reqs; /* total number of read requests */
  403. unsigned int dasd_read_sects; /* total number read sectors */
  404. unsigned int dasd_read_alias; /* read request using an alias */
  405. unsigned int dasd_read_tpm; /* read requests in transport mode */
  406. unsigned int dasd_read_secs[32]; /* histogram of request's sizes */
  407. unsigned int dasd_read_times[32]; /* histogram of requests's times */
  408. unsigned int dasd_read_time1[32]; /* hist. time from build to start */
  409. unsigned int dasd_read_time2[32]; /* hist. of time from start to irq */
  410. unsigned int dasd_read_time3[32]; /* hist. of time from irq to end */
  411. unsigned int dasd_read_nr_req[32]; /* hist. of # of requests in chanq */
  412. unsigned long dasd_sum_times; /* sum of request times */
  413. unsigned long dasd_sum_time_str; /* sum of time from build to start */
  414. unsigned long dasd_sum_time_irq; /* sum of time from start to irq */
  415. unsigned long dasd_sum_time_end; /* sum of time from irq to end */
  416. };
  417. struct dasd_profile {
  418. struct dentry *dentry;
  419. struct dasd_profile_info *data;
  420. spinlock_t lock;
  421. };
  422. struct dasd_format_entry {
  423. struct list_head list;
  424. sector_t track;
  425. };
  426. struct dasd_device {
  427. /* Block device stuff. */
  428. struct dasd_block *block;
  429. unsigned int devindex;
  430. unsigned long flags; /* per device flags */
  431. unsigned short features; /* copy of devmap-features (read-only!) */
  432. /* extended error reporting stuff (eer) */
  433. struct dasd_ccw_req *eer_cqr;
  434. /* Device discipline stuff. */
  435. struct dasd_discipline *discipline;
  436. struct dasd_discipline *base_discipline;
  437. void *private;
  438. struct dasd_path path[8];
  439. __u8 opm;
  440. /* Device state and target state. */
  441. int state, target;
  442. struct mutex state_mutex;
  443. int stopped; /* device (ccw_device_start) was stopped */
  444. /* reference count. */
  445. atomic_t ref_count;
  446. /* ccw queue and memory for static ccw/erp buffers. */
  447. struct list_head ccw_queue;
  448. spinlock_t mem_lock;
  449. void *ccw_mem;
  450. void *erp_mem;
  451. void *ese_mem;
  452. struct list_head ccw_chunks;
  453. struct list_head erp_chunks;
  454. struct list_head ese_chunks;
  455. atomic_t tasklet_scheduled;
  456. struct tasklet_struct tasklet;
  457. struct work_struct kick_work;
  458. struct work_struct restore_device;
  459. struct work_struct reload_device;
  460. struct work_struct kick_validate;
  461. struct work_struct suc_work;
  462. struct work_struct requeue_requests;
  463. struct timer_list timer;
  464. debug_info_t *debug_area;
  465. struct ccw_device *cdev;
  466. /* hook for alias management */
  467. struct list_head alias_list;
  468. /* default expiration time in s */
  469. unsigned long default_expires;
  470. unsigned long default_retries;
  471. unsigned long blk_timeout;
  472. unsigned long path_thrhld;
  473. unsigned long path_interval;
  474. struct dentry *debugfs_dentry;
  475. struct dentry *hosts_dentry;
  476. struct dasd_profile profile;
  477. struct dasd_format_entry format_entry;
  478. };
  479. struct dasd_block {
  480. /* Block device stuff. */
  481. struct gendisk *gdp;
  482. struct request_queue *request_queue;
  483. spinlock_t request_queue_lock;
  484. struct blk_mq_tag_set tag_set;
  485. struct block_device *bdev;
  486. atomic_t open_count;
  487. unsigned long blocks; /* size of volume in blocks */
  488. unsigned int bp_block; /* bytes per block */
  489. unsigned int s2b_shift; /* log2 (bp_block/512) */
  490. struct dasd_device *base;
  491. struct list_head ccw_queue;
  492. spinlock_t queue_lock;
  493. atomic_t tasklet_scheduled;
  494. struct tasklet_struct tasklet;
  495. struct timer_list timer;
  496. struct dentry *debugfs_dentry;
  497. struct dasd_profile profile;
  498. struct list_head format_list;
  499. spinlock_t format_lock;
  500. };
  501. struct dasd_attention_data {
  502. struct dasd_device *device;
  503. __u8 lpum;
  504. };
  505. struct dasd_queue {
  506. spinlock_t lock;
  507. };
  508. /* reasons why device (ccw_device_start) was stopped */
  509. #define DASD_STOPPED_NOT_ACC 1 /* not accessible */
  510. #define DASD_STOPPED_QUIESCE 2 /* Quiesced */
  511. #define DASD_STOPPED_PENDING 4 /* long busy */
  512. #define DASD_STOPPED_DC_WAIT 8 /* disconnected, wait */
  513. #define DASD_STOPPED_SU 16 /* summary unit check handling */
  514. #define DASD_STOPPED_PM 32 /* pm state transition */
  515. #define DASD_UNRESUMED_PM 64 /* pm resume failed state */
  516. #define DASD_STOPPED_NOSPC 128 /* no space left */
  517. /* per device flags */
  518. #define DASD_FLAG_OFFLINE 3 /* device is in offline processing */
  519. #define DASD_FLAG_EER_SNSS 4 /* A SNSS is required */
  520. #define DASD_FLAG_EER_IN_USE 5 /* A SNSS request is running */
  521. #define DASD_FLAG_DEVICE_RO 6 /* The device itself is read-only. Don't
  522. * confuse this with the user specified
  523. * read-only feature.
  524. */
  525. #define DASD_FLAG_IS_RESERVED 7 /* The device is reserved */
  526. #define DASD_FLAG_LOCK_STOLEN 8 /* The device lock was stolen */
  527. #define DASD_FLAG_SUSPENDED 9 /* The device was suspended */
  528. #define DASD_FLAG_SAFE_OFFLINE 10 /* safe offline processing requested*/
  529. #define DASD_FLAG_SAFE_OFFLINE_RUNNING 11 /* safe offline running */
  530. #define DASD_FLAG_ABORTALL 12 /* Abort all noretry requests */
  531. #define DASD_FLAG_PATH_VERIFY 13 /* Path verification worker running */
  532. #define DASD_FLAG_SUC 14 /* unhandled summary unit check */
  533. #define DASD_SLEEPON_START_TAG ((void *) 1)
  534. #define DASD_SLEEPON_END_TAG ((void *) 2)
  535. void dasd_put_device_wake(struct dasd_device *);
  536. /*
  537. * Reference count inliners
  538. */
  539. static inline void
  540. dasd_get_device(struct dasd_device *device)
  541. {
  542. atomic_inc(&device->ref_count);
  543. }
  544. static inline void
  545. dasd_put_device(struct dasd_device *device)
  546. {
  547. if (atomic_dec_return(&device->ref_count) == 0)
  548. dasd_put_device_wake(device);
  549. }
  550. /*
  551. * The static memory in ccw_mem and erp_mem is managed by a sorted
  552. * list of free memory chunks.
  553. */
  554. struct dasd_mchunk
  555. {
  556. struct list_head list;
  557. unsigned long size;
  558. } __attribute__ ((aligned(8)));
  559. static inline void
  560. dasd_init_chunklist(struct list_head *chunk_list, void *mem,
  561. unsigned long size)
  562. {
  563. struct dasd_mchunk *chunk;
  564. INIT_LIST_HEAD(chunk_list);
  565. chunk = (struct dasd_mchunk *) mem;
  566. chunk->size = size - sizeof(struct dasd_mchunk);
  567. list_add(&chunk->list, chunk_list);
  568. }
  569. static inline void *
  570. dasd_alloc_chunk(struct list_head *chunk_list, unsigned long size)
  571. {
  572. struct dasd_mchunk *chunk, *tmp;
  573. size = (size + 7L) & -8L;
  574. list_for_each_entry(chunk, chunk_list, list) {
  575. if (chunk->size < size)
  576. continue;
  577. if (chunk->size > size + sizeof(struct dasd_mchunk)) {
  578. char *endaddr = (char *) (chunk + 1) + chunk->size;
  579. tmp = (struct dasd_mchunk *) (endaddr - size) - 1;
  580. tmp->size = size;
  581. chunk->size -= size + sizeof(struct dasd_mchunk);
  582. chunk = tmp;
  583. } else
  584. list_del(&chunk->list);
  585. return (void *) (chunk + 1);
  586. }
  587. return NULL;
  588. }
  589. static inline void
  590. dasd_free_chunk(struct list_head *chunk_list, void *mem)
  591. {
  592. struct dasd_mchunk *chunk, *tmp;
  593. struct list_head *p, *left;
  594. chunk = (struct dasd_mchunk *)
  595. ((char *) mem - sizeof(struct dasd_mchunk));
  596. /* Find out the left neighbour in chunk_list. */
  597. left = chunk_list;
  598. list_for_each(p, chunk_list) {
  599. if (list_entry(p, struct dasd_mchunk, list) > chunk)
  600. break;
  601. left = p;
  602. }
  603. /* Try to merge with right neighbour = next element from left. */
  604. if (left->next != chunk_list) {
  605. tmp = list_entry(left->next, struct dasd_mchunk, list);
  606. if ((char *) (chunk + 1) + chunk->size == (char *) tmp) {
  607. list_del(&tmp->list);
  608. chunk->size += tmp->size + sizeof(struct dasd_mchunk);
  609. }
  610. }
  611. /* Try to merge with left neighbour. */
  612. if (left != chunk_list) {
  613. tmp = list_entry(left, struct dasd_mchunk, list);
  614. if ((char *) (tmp + 1) + tmp->size == (char *) chunk) {
  615. tmp->size += chunk->size + sizeof(struct dasd_mchunk);
  616. return;
  617. }
  618. }
  619. __list_add(&chunk->list, left, left->next);
  620. }
  621. /*
  622. * Check if bsize is in { 512, 1024, 2048, 4096 }
  623. */
  624. static inline int
  625. dasd_check_blocksize(int bsize)
  626. {
  627. if (bsize < 512 || bsize > 4096 || !is_power_of_2(bsize))
  628. return -EMEDIUMTYPE;
  629. return 0;
  630. }
  631. /* externals in dasd.c */
  632. #define DASD_PROFILE_OFF 0
  633. #define DASD_PROFILE_ON 1
  634. #define DASD_PROFILE_GLOBAL_ONLY 2
  635. extern debug_info_t *dasd_debug_area;
  636. extern struct dasd_profile dasd_global_profile;
  637. extern unsigned int dasd_global_profile_level;
  638. extern const struct block_device_operations dasd_device_operations;
  639. extern struct kmem_cache *dasd_page_cache;
  640. struct dasd_ccw_req *
  641. dasd_smalloc_request(int, int, int, struct dasd_device *, struct dasd_ccw_req *);
  642. struct dasd_ccw_req *dasd_fmalloc_request(int, int, int, struct dasd_device *);
  643. void dasd_sfree_request(struct dasd_ccw_req *, struct dasd_device *);
  644. void dasd_ffree_request(struct dasd_ccw_req *, struct dasd_device *);
  645. void dasd_wakeup_cb(struct dasd_ccw_req *, void *);
  646. struct dasd_device *dasd_alloc_device(void);
  647. void dasd_free_device(struct dasd_device *);
  648. struct dasd_block *dasd_alloc_block(void);
  649. void dasd_free_block(struct dasd_block *);
  650. enum blk_eh_timer_return dasd_times_out(struct request *req, bool reserved);
  651. void dasd_enable_device(struct dasd_device *);
  652. void dasd_set_target_state(struct dasd_device *, int);
  653. void dasd_kick_device(struct dasd_device *);
  654. void dasd_restore_device(struct dasd_device *);
  655. void dasd_reload_device(struct dasd_device *);
  656. void dasd_schedule_requeue(struct dasd_device *);
  657. void dasd_add_request_head(struct dasd_ccw_req *);
  658. void dasd_add_request_tail(struct dasd_ccw_req *);
  659. int dasd_start_IO(struct dasd_ccw_req *);
  660. int dasd_term_IO(struct dasd_ccw_req *);
  661. void dasd_schedule_device_bh(struct dasd_device *);
  662. void dasd_schedule_block_bh(struct dasd_block *);
  663. int dasd_sleep_on(struct dasd_ccw_req *);
  664. int dasd_sleep_on_queue(struct list_head *);
  665. int dasd_sleep_on_immediatly(struct dasd_ccw_req *);
  666. int dasd_sleep_on_queue_interruptible(struct list_head *);
  667. int dasd_sleep_on_interruptible(struct dasd_ccw_req *);
  668. void dasd_device_set_timer(struct dasd_device *, int);
  669. void dasd_device_clear_timer(struct dasd_device *);
  670. void dasd_block_set_timer(struct dasd_block *, int);
  671. void dasd_block_clear_timer(struct dasd_block *);
  672. int dasd_cancel_req(struct dasd_ccw_req *);
  673. int dasd_flush_device_queue(struct dasd_device *);
  674. int dasd_generic_probe (struct ccw_device *, struct dasd_discipline *);
  675. void dasd_generic_free_discipline(struct dasd_device *);
  676. void dasd_generic_remove (struct ccw_device *cdev);
  677. int dasd_generic_set_online(struct ccw_device *, struct dasd_discipline *);
  678. int dasd_generic_set_offline (struct ccw_device *cdev);
  679. int dasd_generic_notify(struct ccw_device *, int);
  680. int dasd_generic_last_path_gone(struct dasd_device *);
  681. int dasd_generic_path_operational(struct dasd_device *);
  682. void dasd_generic_shutdown(struct ccw_device *);
  683. void dasd_generic_handle_state_change(struct dasd_device *);
  684. int dasd_generic_pm_freeze(struct ccw_device *);
  685. int dasd_generic_restore_device(struct ccw_device *);
  686. enum uc_todo dasd_generic_uc_handler(struct ccw_device *, struct irb *);
  687. void dasd_generic_path_event(struct ccw_device *, int *);
  688. int dasd_generic_verify_path(struct dasd_device *, __u8);
  689. void dasd_generic_space_exhaust(struct dasd_device *, struct dasd_ccw_req *);
  690. void dasd_generic_space_avail(struct dasd_device *);
  691. int dasd_generic_read_dev_chars(struct dasd_device *, int, void *, int);
  692. char *dasd_get_sense(struct irb *);
  693. void dasd_device_set_stop_bits(struct dasd_device *, int);
  694. void dasd_device_remove_stop_bits(struct dasd_device *, int);
  695. int dasd_device_is_ro(struct dasd_device *);
  696. void dasd_profile_reset(struct dasd_profile *);
  697. int dasd_profile_on(struct dasd_profile *);
  698. void dasd_profile_off(struct dasd_profile *);
  699. char *dasd_get_user_string(const char __user *, size_t);
  700. /* externals in dasd_devmap.c */
  701. extern int dasd_max_devindex;
  702. extern int dasd_probeonly;
  703. extern int dasd_autodetect;
  704. extern int dasd_nopav;
  705. extern int dasd_nofcx;
  706. int dasd_devmap_init(void);
  707. void dasd_devmap_exit(void);
  708. struct dasd_device *dasd_create_device(struct ccw_device *);
  709. void dasd_delete_device(struct dasd_device *);
  710. int dasd_get_feature(struct ccw_device *, int);
  711. int dasd_set_feature(struct ccw_device *, int, int);
  712. int dasd_add_sysfs_files(struct ccw_device *);
  713. void dasd_remove_sysfs_files(struct ccw_device *);
  714. struct dasd_device *dasd_device_from_cdev(struct ccw_device *);
  715. struct dasd_device *dasd_device_from_cdev_locked(struct ccw_device *);
  716. struct dasd_device *dasd_device_from_devindex(int);
  717. void dasd_add_link_to_gendisk(struct gendisk *, struct dasd_device *);
  718. struct dasd_device *dasd_device_from_gendisk(struct gendisk *);
  719. int dasd_parse(void) __init;
  720. int dasd_busid_known(const char *);
  721. /* externals in dasd_gendisk.c */
  722. int dasd_gendisk_init(void);
  723. void dasd_gendisk_exit(void);
  724. int dasd_gendisk_alloc(struct dasd_block *);
  725. void dasd_gendisk_free(struct dasd_block *);
  726. int dasd_scan_partitions(struct dasd_block *);
  727. void dasd_destroy_partitions(struct dasd_block *);
  728. /* externals in dasd_ioctl.c */
  729. int dasd_ioctl(struct block_device *, fmode_t, unsigned int, unsigned long);
  730. /* externals in dasd_proc.c */
  731. int dasd_proc_init(void);
  732. void dasd_proc_exit(void);
  733. /* externals in dasd_erp.c */
  734. struct dasd_ccw_req *dasd_default_erp_action(struct dasd_ccw_req *);
  735. struct dasd_ccw_req *dasd_default_erp_postaction(struct dasd_ccw_req *);
  736. struct dasd_ccw_req *dasd_alloc_erp_request(char *, int, int,
  737. struct dasd_device *);
  738. void dasd_free_erp_request(struct dasd_ccw_req *, struct dasd_device *);
  739. void dasd_log_sense(struct dasd_ccw_req *, struct irb *);
  740. void dasd_log_sense_dbf(struct dasd_ccw_req *cqr, struct irb *irb);
  741. /* externals in dasd_3990_erp.c */
  742. struct dasd_ccw_req *dasd_3990_erp_action(struct dasd_ccw_req *);
  743. void dasd_3990_erp_handle_sim(struct dasd_device *, char *);
  744. /* externals in dasd_eer.c */
  745. #ifdef CONFIG_DASD_EER
  746. int dasd_eer_init(void);
  747. void dasd_eer_exit(void);
  748. int dasd_eer_enable(struct dasd_device *);
  749. void dasd_eer_disable(struct dasd_device *);
  750. void dasd_eer_write(struct dasd_device *, struct dasd_ccw_req *cqr,
  751. unsigned int id);
  752. void dasd_eer_snss(struct dasd_device *);
  753. static inline int dasd_eer_enabled(struct dasd_device *device)
  754. {
  755. return device->eer_cqr != NULL;
  756. }
  757. #else
  758. #define dasd_eer_init() (0)
  759. #define dasd_eer_exit() do { } while (0)
  760. #define dasd_eer_enable(d) (0)
  761. #define dasd_eer_disable(d) do { } while (0)
  762. #define dasd_eer_write(d,c,i) do { } while (0)
  763. #define dasd_eer_snss(d) do { } while (0)
  764. #define dasd_eer_enabled(d) (0)
  765. #endif /* CONFIG_DASD_ERR */
  766. /* DASD path handling functions */
  767. /*
  768. * helper functions to modify bit masks for a given channel path for a device
  769. */
  770. static inline int dasd_path_is_operational(struct dasd_device *device, int chp)
  771. {
  772. return test_bit(DASD_PATH_OPERATIONAL, &device->path[chp].flags);
  773. }
  774. static inline int dasd_path_need_verify(struct dasd_device *device, int chp)
  775. {
  776. return test_bit(DASD_PATH_TBV, &device->path[chp].flags);
  777. }
  778. static inline void dasd_path_verify(struct dasd_device *device, int chp)
  779. {
  780. __set_bit(DASD_PATH_TBV, &device->path[chp].flags);
  781. }
  782. static inline void dasd_path_clear_verify(struct dasd_device *device, int chp)
  783. {
  784. __clear_bit(DASD_PATH_TBV, &device->path[chp].flags);
  785. }
  786. static inline void dasd_path_clear_all_verify(struct dasd_device *device)
  787. {
  788. int chp;
  789. for (chp = 0; chp < 8; chp++)
  790. dasd_path_clear_verify(device, chp);
  791. }
  792. static inline void dasd_path_operational(struct dasd_device *device, int chp)
  793. {
  794. __set_bit(DASD_PATH_OPERATIONAL, &device->path[chp].flags);
  795. device->opm |= (0x80 >> chp);
  796. }
  797. static inline void dasd_path_nonpreferred(struct dasd_device *device, int chp)
  798. {
  799. __set_bit(DASD_PATH_NPP, &device->path[chp].flags);
  800. }
  801. static inline int dasd_path_is_nonpreferred(struct dasd_device *device, int chp)
  802. {
  803. return test_bit(DASD_PATH_NPP, &device->path[chp].flags);
  804. }
  805. static inline void dasd_path_clear_nonpreferred(struct dasd_device *device,
  806. int chp)
  807. {
  808. __clear_bit(DASD_PATH_NPP, &device->path[chp].flags);
  809. }
  810. static inline void dasd_path_preferred(struct dasd_device *device, int chp)
  811. {
  812. __set_bit(DASD_PATH_PP, &device->path[chp].flags);
  813. }
  814. static inline int dasd_path_is_preferred(struct dasd_device *device, int chp)
  815. {
  816. return test_bit(DASD_PATH_PP, &device->path[chp].flags);
  817. }
  818. static inline void dasd_path_clear_preferred(struct dasd_device *device,
  819. int chp)
  820. {
  821. __clear_bit(DASD_PATH_PP, &device->path[chp].flags);
  822. }
  823. static inline void dasd_path_clear_oper(struct dasd_device *device, int chp)
  824. {
  825. __clear_bit(DASD_PATH_OPERATIONAL, &device->path[chp].flags);
  826. device->opm &= ~(0x80 >> chp);
  827. }
  828. static inline void dasd_path_clear_cable(struct dasd_device *device, int chp)
  829. {
  830. __clear_bit(DASD_PATH_MISCABLED, &device->path[chp].flags);
  831. }
  832. static inline void dasd_path_cuir(struct dasd_device *device, int chp)
  833. {
  834. __set_bit(DASD_PATH_CUIR, &device->path[chp].flags);
  835. }
  836. static inline int dasd_path_is_cuir(struct dasd_device *device, int chp)
  837. {
  838. return test_bit(DASD_PATH_CUIR, &device->path[chp].flags);
  839. }
  840. static inline void dasd_path_clear_cuir(struct dasd_device *device, int chp)
  841. {
  842. __clear_bit(DASD_PATH_CUIR, &device->path[chp].flags);
  843. }
  844. static inline void dasd_path_ifcc(struct dasd_device *device, int chp)
  845. {
  846. set_bit(DASD_PATH_IFCC, &device->path[chp].flags);
  847. }
  848. static inline int dasd_path_is_ifcc(struct dasd_device *device, int chp)
  849. {
  850. return test_bit(DASD_PATH_IFCC, &device->path[chp].flags);
  851. }
  852. static inline void dasd_path_clear_ifcc(struct dasd_device *device, int chp)
  853. {
  854. clear_bit(DASD_PATH_IFCC, &device->path[chp].flags);
  855. }
  856. static inline void dasd_path_clear_nohpf(struct dasd_device *device, int chp)
  857. {
  858. __clear_bit(DASD_PATH_NOHPF, &device->path[chp].flags);
  859. }
  860. static inline void dasd_path_miscabled(struct dasd_device *device, int chp)
  861. {
  862. __set_bit(DASD_PATH_MISCABLED, &device->path[chp].flags);
  863. }
  864. static inline int dasd_path_is_miscabled(struct dasd_device *device, int chp)
  865. {
  866. return test_bit(DASD_PATH_MISCABLED, &device->path[chp].flags);
  867. }
  868. static inline void dasd_path_nohpf(struct dasd_device *device, int chp)
  869. {
  870. __set_bit(DASD_PATH_NOHPF, &device->path[chp].flags);
  871. }
  872. static inline int dasd_path_is_nohpf(struct dasd_device *device, int chp)
  873. {
  874. return test_bit(DASD_PATH_NOHPF, &device->path[chp].flags);
  875. }
  876. /*
  877. * get functions for path masks
  878. * will return a path masks for the given device
  879. */
  880. static inline __u8 dasd_path_get_opm(struct dasd_device *device)
  881. {
  882. return device->opm;
  883. }
  884. static inline __u8 dasd_path_get_tbvpm(struct dasd_device *device)
  885. {
  886. int chp;
  887. __u8 tbvpm = 0x00;
  888. for (chp = 0; chp < 8; chp++)
  889. if (dasd_path_need_verify(device, chp))
  890. tbvpm |= 0x80 >> chp;
  891. return tbvpm;
  892. }
  893. static inline __u8 dasd_path_get_nppm(struct dasd_device *device)
  894. {
  895. int chp;
  896. __u8 npm = 0x00;
  897. for (chp = 0; chp < 8; chp++) {
  898. if (dasd_path_is_nonpreferred(device, chp))
  899. npm |= 0x80 >> chp;
  900. }
  901. return npm;
  902. }
  903. static inline __u8 dasd_path_get_ppm(struct dasd_device *device)
  904. {
  905. int chp;
  906. __u8 ppm = 0x00;
  907. for (chp = 0; chp < 8; chp++)
  908. if (dasd_path_is_preferred(device, chp))
  909. ppm |= 0x80 >> chp;
  910. return ppm;
  911. }
  912. static inline __u8 dasd_path_get_cablepm(struct dasd_device *device)
  913. {
  914. int chp;
  915. __u8 cablepm = 0x00;
  916. for (chp = 0; chp < 8; chp++)
  917. if (dasd_path_is_miscabled(device, chp))
  918. cablepm |= 0x80 >> chp;
  919. return cablepm;
  920. }
  921. static inline __u8 dasd_path_get_cuirpm(struct dasd_device *device)
  922. {
  923. int chp;
  924. __u8 cuirpm = 0x00;
  925. for (chp = 0; chp < 8; chp++)
  926. if (dasd_path_is_cuir(device, chp))
  927. cuirpm |= 0x80 >> chp;
  928. return cuirpm;
  929. }
  930. static inline __u8 dasd_path_get_ifccpm(struct dasd_device *device)
  931. {
  932. int chp;
  933. __u8 ifccpm = 0x00;
  934. for (chp = 0; chp < 8; chp++)
  935. if (dasd_path_is_ifcc(device, chp))
  936. ifccpm |= 0x80 >> chp;
  937. return ifccpm;
  938. }
  939. static inline __u8 dasd_path_get_hpfpm(struct dasd_device *device)
  940. {
  941. int chp;
  942. __u8 hpfpm = 0x00;
  943. for (chp = 0; chp < 8; chp++)
  944. if (dasd_path_is_nohpf(device, chp))
  945. hpfpm |= 0x80 >> chp;
  946. return hpfpm;
  947. }
  948. /*
  949. * add functions for path masks
  950. * the existing path mask will be extended by the given path mask
  951. */
  952. static inline void dasd_path_add_tbvpm(struct dasd_device *device, __u8 pm)
  953. {
  954. int chp;
  955. for (chp = 0; chp < 8; chp++)
  956. if (pm & (0x80 >> chp))
  957. dasd_path_verify(device, chp);
  958. }
  959. static inline __u8 dasd_path_get_notoperpm(struct dasd_device *device)
  960. {
  961. int chp;
  962. __u8 nopm = 0x00;
  963. for (chp = 0; chp < 8; chp++)
  964. if (dasd_path_is_nohpf(device, chp) ||
  965. dasd_path_is_ifcc(device, chp) ||
  966. dasd_path_is_cuir(device, chp) ||
  967. dasd_path_is_miscabled(device, chp))
  968. nopm |= 0x80 >> chp;
  969. return nopm;
  970. }
  971. static inline void dasd_path_add_opm(struct dasd_device *device, __u8 pm)
  972. {
  973. int chp;
  974. for (chp = 0; chp < 8; chp++)
  975. if (pm & (0x80 >> chp)) {
  976. dasd_path_operational(device, chp);
  977. /*
  978. * if the path is used
  979. * it should not be in one of the negative lists
  980. */
  981. dasd_path_clear_nohpf(device, chp);
  982. dasd_path_clear_cuir(device, chp);
  983. dasd_path_clear_cable(device, chp);
  984. dasd_path_clear_ifcc(device, chp);
  985. }
  986. }
  987. static inline void dasd_path_add_cablepm(struct dasd_device *device, __u8 pm)
  988. {
  989. int chp;
  990. for (chp = 0; chp < 8; chp++)
  991. if (pm & (0x80 >> chp))
  992. dasd_path_miscabled(device, chp);
  993. }
  994. static inline void dasd_path_add_cuirpm(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_cuir(device, chp);
  1000. }
  1001. static inline void dasd_path_add_ifccpm(struct dasd_device *device, __u8 pm)
  1002. {
  1003. int chp;
  1004. for (chp = 0; chp < 8; chp++)
  1005. if (pm & (0x80 >> chp))
  1006. dasd_path_ifcc(device, chp);
  1007. }
  1008. static inline void dasd_path_add_nppm(struct dasd_device *device, __u8 pm)
  1009. {
  1010. int chp;
  1011. for (chp = 0; chp < 8; chp++)
  1012. if (pm & (0x80 >> chp))
  1013. dasd_path_nonpreferred(device, chp);
  1014. }
  1015. static inline void dasd_path_add_nohpfpm(struct dasd_device *device, __u8 pm)
  1016. {
  1017. int chp;
  1018. for (chp = 0; chp < 8; chp++)
  1019. if (pm & (0x80 >> chp))
  1020. dasd_path_nohpf(device, chp);
  1021. }
  1022. static inline void dasd_path_add_ppm(struct dasd_device *device, __u8 pm)
  1023. {
  1024. int chp;
  1025. for (chp = 0; chp < 8; chp++)
  1026. if (pm & (0x80 >> chp))
  1027. dasd_path_preferred(device, chp);
  1028. }
  1029. /*
  1030. * set functions for path masks
  1031. * the existing path mask will be replaced by the given path mask
  1032. */
  1033. static inline void dasd_path_set_tbvpm(struct dasd_device *device, __u8 pm)
  1034. {
  1035. int chp;
  1036. for (chp = 0; chp < 8; chp++)
  1037. if (pm & (0x80 >> chp))
  1038. dasd_path_verify(device, chp);
  1039. else
  1040. dasd_path_clear_verify(device, chp);
  1041. }
  1042. static inline void dasd_path_set_opm(struct dasd_device *device, __u8 pm)
  1043. {
  1044. int chp;
  1045. for (chp = 0; chp < 8; chp++) {
  1046. dasd_path_clear_oper(device, chp);
  1047. if (pm & (0x80 >> chp)) {
  1048. dasd_path_operational(device, chp);
  1049. /*
  1050. * if the path is used
  1051. * it should not be in one of the negative lists
  1052. */
  1053. dasd_path_clear_nohpf(device, chp);
  1054. dasd_path_clear_cuir(device, chp);
  1055. dasd_path_clear_cable(device, chp);
  1056. dasd_path_clear_ifcc(device, chp);
  1057. }
  1058. }
  1059. }
  1060. /*
  1061. * remove functions for path masks
  1062. * the existing path mask will be cleared with the given path mask
  1063. */
  1064. static inline void dasd_path_remove_opm(struct dasd_device *device, __u8 pm)
  1065. {
  1066. int chp;
  1067. for (chp = 0; chp < 8; chp++) {
  1068. if (pm & (0x80 >> chp))
  1069. dasd_path_clear_oper(device, chp);
  1070. }
  1071. }
  1072. /*
  1073. * add the newly available path to the to be verified pm and remove it from
  1074. * normal operation until it is verified
  1075. */
  1076. static inline void dasd_path_available(struct dasd_device *device, int chp)
  1077. {
  1078. dasd_path_clear_oper(device, chp);
  1079. dasd_path_verify(device, chp);
  1080. }
  1081. static inline void dasd_path_notoper(struct dasd_device *device, int chp)
  1082. {
  1083. dasd_path_clear_oper(device, chp);
  1084. dasd_path_clear_preferred(device, chp);
  1085. dasd_path_clear_nonpreferred(device, chp);
  1086. }
  1087. /*
  1088. * remove all paths from normal operation
  1089. */
  1090. static inline void dasd_path_no_path(struct dasd_device *device)
  1091. {
  1092. int chp;
  1093. for (chp = 0; chp < 8; chp++)
  1094. dasd_path_notoper(device, chp);
  1095. dasd_path_clear_all_verify(device);
  1096. }
  1097. /* end - path handling */
  1098. #endif /* DASD_H */