io_sch.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef S390_IO_SCH_H
  3. #define S390_IO_SCH_H
  4. #include <linux/types.h>
  5. #include <asm/schid.h>
  6. #include <asm/ccwdev.h>
  7. #include <asm/irq.h>
  8. #include "css.h"
  9. #include "orb.h"
  10. struct io_subchannel_private {
  11. union orb orb; /* operation request block */
  12. struct ccw1 sense_ccw; /* static ccw for sense command */
  13. struct ccw_device *cdev;/* pointer to the child ccw device */
  14. struct {
  15. unsigned int suspend:1; /* allow suspend */
  16. unsigned int prefetch:1;/* deny prefetch */
  17. unsigned int inter:1; /* suppress intermediate interrupts */
  18. } __packed options;
  19. } __aligned(8);
  20. #define to_io_private(n) ((struct io_subchannel_private *) \
  21. dev_get_drvdata(&(n)->dev))
  22. #define set_io_private(n, p) (dev_set_drvdata(&(n)->dev, p))
  23. static inline struct ccw_device *sch_get_cdev(struct subchannel *sch)
  24. {
  25. struct io_subchannel_private *priv = to_io_private(sch);
  26. return priv ? priv->cdev : NULL;
  27. }
  28. static inline void sch_set_cdev(struct subchannel *sch,
  29. struct ccw_device *cdev)
  30. {
  31. struct io_subchannel_private *priv = to_io_private(sch);
  32. if (priv)
  33. priv->cdev = cdev;
  34. }
  35. #define MAX_CIWS 8
  36. /*
  37. * Possible status values for a CCW request's I/O.
  38. */
  39. enum io_status {
  40. IO_DONE,
  41. IO_RUNNING,
  42. IO_STATUS_ERROR,
  43. IO_PATH_ERROR,
  44. IO_REJECTED,
  45. IO_KILLED
  46. };
  47. /**
  48. * ccw_request - Internal CCW request.
  49. * @cp: channel program to start
  50. * @timeout: maximum allowable time in jiffies between start I/O and interrupt
  51. * @maxretries: number of retries per I/O operation and path
  52. * @lpm: mask of paths to use
  53. * @check: optional callback that determines if results are final
  54. * @filter: optional callback to adjust request status based on IRB data
  55. * @callback: final callback
  56. * @data: user-defined pointer passed to all callbacks
  57. * @singlepath: if set, use only one path from @lpm per start I/O
  58. * @cancel: non-zero if request was cancelled
  59. * @done: non-zero if request was finished
  60. * @mask: current path mask
  61. * @retries: current number of retries
  62. * @drc: delayed return code
  63. */
  64. struct ccw_request {
  65. struct ccw1 *cp;
  66. unsigned long timeout;
  67. u16 maxretries;
  68. u8 lpm;
  69. int (*check)(struct ccw_device *, void *);
  70. enum io_status (*filter)(struct ccw_device *, void *, struct irb *,
  71. enum io_status);
  72. void (*callback)(struct ccw_device *, void *, int);
  73. void *data;
  74. unsigned int singlepath:1;
  75. /* These fields are used internally. */
  76. unsigned int cancel:1;
  77. unsigned int done:1;
  78. u16 mask;
  79. u16 retries;
  80. int drc;
  81. } __attribute__((packed));
  82. /*
  83. * sense-id response buffer layout
  84. */
  85. struct senseid {
  86. /* common part */
  87. u8 reserved; /* always 0x'FF' */
  88. u16 cu_type; /* control unit type */
  89. u8 cu_model; /* control unit model */
  90. u16 dev_type; /* device type */
  91. u8 dev_model; /* device model */
  92. u8 unused; /* padding byte */
  93. /* extended part */
  94. struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
  95. } __attribute__ ((packed, aligned(4)));
  96. enum cdev_todo {
  97. CDEV_TODO_NOTHING,
  98. CDEV_TODO_ENABLE_CMF,
  99. CDEV_TODO_REBIND,
  100. CDEV_TODO_REGISTER,
  101. CDEV_TODO_UNREG,
  102. CDEV_TODO_UNREG_EVAL,
  103. };
  104. #define FAKE_CMD_IRB 1
  105. #define FAKE_TM_IRB 2
  106. struct ccw_device_private {
  107. struct ccw_device *cdev;
  108. struct subchannel *sch;
  109. int state; /* device state */
  110. atomic_t onoff;
  111. struct ccw_dev_id dev_id; /* device id */
  112. struct ccw_request req; /* internal I/O request */
  113. int iretry;
  114. u8 pgid_valid_mask; /* mask of valid PGIDs */
  115. u8 pgid_todo_mask; /* mask of PGIDs to be adjusted */
  116. u8 pgid_reset_mask; /* mask of PGIDs which were reset */
  117. u8 path_noirq_mask; /* mask of paths for which no irq was
  118. received */
  119. u8 path_notoper_mask; /* mask of paths which were found
  120. not operable */
  121. u8 path_gone_mask; /* mask of paths, that became unavailable */
  122. u8 path_new_mask; /* mask of paths, that became available */
  123. u8 path_broken_mask; /* mask of paths, which were found to be
  124. unusable */
  125. struct {
  126. unsigned int fast:1; /* post with "channel end" */
  127. unsigned int repall:1; /* report every interrupt status */
  128. unsigned int pgroup:1; /* do path grouping */
  129. unsigned int force:1; /* allow forced online */
  130. unsigned int mpath:1; /* do multipathing */
  131. } __attribute__ ((packed)) options;
  132. struct {
  133. unsigned int esid:1; /* Ext. SenseID supported by HW */
  134. unsigned int dosense:1; /* delayed SENSE required */
  135. unsigned int doverify:1; /* delayed path verification */
  136. unsigned int donotify:1; /* call notify function */
  137. unsigned int recog_done:1; /* dev. recog. complete */
  138. unsigned int fake_irb:2; /* deliver faked irb */
  139. unsigned int resuming:1; /* recognition while resume */
  140. unsigned int pgroup:1; /* pathgroup is set up */
  141. unsigned int mpath:1; /* multipathing is set up */
  142. unsigned int pgid_unknown:1;/* unknown pgid state */
  143. unsigned int initialized:1; /* set if initial reference held */
  144. } __attribute__((packed)) flags;
  145. unsigned long intparm; /* user interruption parameter */
  146. struct qdio_irq *qdio_data;
  147. struct irb irb; /* device status */
  148. int async_kill_io_rc;
  149. struct senseid senseid; /* SenseID info */
  150. struct pgid pgid[8]; /* path group IDs per chpid*/
  151. struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
  152. struct work_struct todo_work;
  153. enum cdev_todo todo;
  154. wait_queue_head_t wait_q;
  155. struct timer_list timer;
  156. void *cmb; /* measurement information */
  157. struct list_head cmb_list; /* list of measured devices */
  158. u64 cmb_start_time; /* clock value of cmb reset */
  159. void *cmb_wait; /* deferred cmb enable/disable */
  160. enum interruption_class int_class;
  161. };
  162. #endif