io_sch.h 5.5 KB

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