dasd_int.h 38 KB

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