Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 1 | #ifndef S390_IO_SCH_H |
| 2 | #define S390_IO_SCH_H |
| 3 | |
Peter Oberparleiter | e1f0fbd | 2009-12-07 12:51:25 +0100 | [diff] [blame] | 4 | #include <linux/types.h> |
Cornelia Huck | 9d92a7e | 2008-07-14 09:59:05 +0200 | [diff] [blame] | 5 | #include <asm/schid.h> |
Peter Oberparleiter | e1f0fbd | 2009-12-07 12:51:25 +0100 | [diff] [blame] | 6 | #include <asm/ccwdev.h> |
Peter Oberparleiter | de400d6 | 2011-10-30 15:16:04 +0100 | [diff] [blame] | 7 | #include <asm/irq.h> |
Peter Oberparleiter | e1f0fbd | 2009-12-07 12:51:25 +0100 | [diff] [blame] | 8 | #include "css.h" |
Sebastian Ott | 9e6f9f8 | 2011-03-15 17:08:23 +0100 | [diff] [blame] | 9 | #include "orb.h" |
Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 10 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 11 | struct io_subchannel_private { |
Peter Oberparleiter | 83262d6 | 2008-07-14 09:58:51 +0200 | [diff] [blame] | 12 | union orb orb; /* operation request block */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 13 | struct ccw1 sense_ccw; /* static ccw for sense command */ |
Sebastian Ott | 97eb6bfc | 2011-03-15 17:08:26 +0100 | [diff] [blame] | 14 | struct ccw_device *cdev;/* pointer to the child ccw device */ |
Sebastian Ott | c513d07 | 2011-03-15 17:08:25 +0100 | [diff] [blame] | 15 | struct { |
| 16 | unsigned int suspend:1; /* allow suspend */ |
| 17 | unsigned int prefetch:1;/* deny prefetch */ |
| 18 | unsigned int inter:1; /* suppress intermediate interrupts */ |
| 19 | } __packed options; |
| 20 | } __aligned(8); |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 21 | |
Sebastian Ott | f92519e | 2011-03-15 17:08:27 +0100 | [diff] [blame] | 22 | #define to_io_private(n) ((struct io_subchannel_private *) \ |
| 23 | dev_get_drvdata(&(n)->dev)) |
| 24 | #define set_io_private(n, p) (dev_set_drvdata(&(n)->dev, p)) |
Sebastian Ott | 97eb6bfc | 2011-03-15 17:08:26 +0100 | [diff] [blame] | 25 | |
| 26 | static inline struct ccw_device *sch_get_cdev(struct subchannel *sch) |
| 27 | { |
| 28 | struct io_subchannel_private *priv = to_io_private(sch); |
| 29 | return priv ? priv->cdev : NULL; |
| 30 | } |
| 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 | } |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 39 | |
| 40 | #define MAX_CIWS 8 |
| 41 | |
| 42 | /* |
Peter Oberparleiter | e1f0fbd | 2009-12-07 12:51:25 +0100 | [diff] [blame] | 43 | * Possible status values for a CCW request's I/O. |
| 44 | */ |
| 45 | enum io_status { |
| 46 | IO_DONE, |
| 47 | IO_RUNNING, |
| 48 | IO_STATUS_ERROR, |
| 49 | IO_PATH_ERROR, |
| 50 | IO_REJECTED, |
| 51 | IO_KILLED |
| 52 | }; |
| 53 | |
| 54 | /** |
| 55 | * ccw_request - Internal CCW request. |
| 56 | * @cp: channel program to start |
| 57 | * @timeout: maximum allowable time in jiffies between start I/O and interrupt |
| 58 | * @maxretries: number of retries per I/O operation and path |
| 59 | * @lpm: mask of paths to use |
| 60 | * @check: optional callback that determines if results are final |
| 61 | * @filter: optional callback to adjust request status based on IRB data |
| 62 | * @callback: final callback |
| 63 | * @data: user-defined pointer passed to all callbacks |
Sebastian Ott | 982bdf8 | 2010-08-09 18:12:53 +0200 | [diff] [blame] | 64 | * @singlepath: if set, use only one path from @lpm per start I/O |
| 65 | * @cancel: non-zero if request was cancelled |
| 66 | * @done: non-zero if request was finished |
Peter Oberparleiter | e1f0fbd | 2009-12-07 12:51:25 +0100 | [diff] [blame] | 67 | * @mask: current path mask |
| 68 | * @retries: current number of retries |
| 69 | * @drc: delayed return code |
Peter Oberparleiter | e1f0fbd | 2009-12-07 12:51:25 +0100 | [diff] [blame] | 70 | */ |
| 71 | struct ccw_request { |
| 72 | struct ccw1 *cp; |
| 73 | unsigned long timeout; |
| 74 | u16 maxretries; |
| 75 | u8 lpm; |
| 76 | int (*check)(struct ccw_device *, void *); |
| 77 | enum io_status (*filter)(struct ccw_device *, void *, struct irb *, |
| 78 | enum io_status); |
| 79 | void (*callback)(struct ccw_device *, void *, int); |
| 80 | void *data; |
Sebastian Ott | 982bdf8 | 2010-08-09 18:12:53 +0200 | [diff] [blame] | 81 | unsigned int singlepath:1; |
Peter Oberparleiter | e1f0fbd | 2009-12-07 12:51:25 +0100 | [diff] [blame] | 82 | /* These fields are used internally. */ |
Sebastian Ott | 982bdf8 | 2010-08-09 18:12:53 +0200 | [diff] [blame] | 83 | unsigned int cancel:1; |
| 84 | unsigned int done:1; |
Peter Oberparleiter | de1b043 | 2009-12-07 12:51:40 +0100 | [diff] [blame] | 85 | u16 mask; |
Peter Oberparleiter | e1f0fbd | 2009-12-07 12:51:25 +0100 | [diff] [blame] | 86 | u16 retries; |
| 87 | int drc; |
Peter Oberparleiter | e1f0fbd | 2009-12-07 12:51:25 +0100 | [diff] [blame] | 88 | } __attribute__((packed)); |
| 89 | |
| 90 | /* |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 91 | * sense-id response buffer layout |
| 92 | */ |
| 93 | struct senseid { |
| 94 | /* common part */ |
| 95 | u8 reserved; /* always 0x'FF' */ |
| 96 | u16 cu_type; /* control unit type */ |
| 97 | u8 cu_model; /* control unit model */ |
| 98 | u16 dev_type; /* device type */ |
| 99 | u8 dev_model; /* device model */ |
| 100 | u8 unused; /* padding byte */ |
| 101 | /* extended part */ |
| 102 | struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */ |
| 103 | } __attribute__ ((packed, aligned(4))); |
| 104 | |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 105 | enum cdev_todo { |
| 106 | CDEV_TODO_NOTHING, |
| 107 | CDEV_TODO_ENABLE_CMF, |
| 108 | CDEV_TODO_REBIND, |
| 109 | CDEV_TODO_REGISTER, |
| 110 | CDEV_TODO_UNREG, |
| 111 | CDEV_TODO_UNREG_EVAL, |
| 112 | }; |
| 113 | |
Sebastian Ott | 50c8e31 | 2011-12-01 13:32:21 +0100 | [diff] [blame] | 114 | #define FAKE_CMD_IRB 1 |
| 115 | #define FAKE_TM_IRB 2 |
| 116 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 117 | struct ccw_device_private { |
| 118 | struct ccw_device *cdev; |
| 119 | struct subchannel *sch; |
| 120 | int state; /* device state */ |
| 121 | atomic_t onoff; |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 122 | struct ccw_dev_id dev_id; /* device id */ |
| 123 | struct subchannel_id schid; /* subchannel number */ |
Peter Oberparleiter | e1f0fbd | 2009-12-07 12:51:25 +0100 | [diff] [blame] | 124 | struct ccw_request req; /* internal I/O request */ |
Peter Oberparleiter | 9679baa | 2009-12-07 12:51:27 +0100 | [diff] [blame] | 125 | int iretry; |
Sebastian Ott | 585b954 | 2010-10-25 16:10:34 +0200 | [diff] [blame] | 126 | u8 pgid_valid_mask; /* mask of valid PGIDs */ |
| 127 | u8 pgid_todo_mask; /* mask of PGIDs to be adjusted */ |
| 128 | u8 pgid_reset_mask; /* mask of PGIDs which were reset */ |
Sebastian Ott | 69f5576 | 2013-01-28 19:29:43 +0100 | [diff] [blame] | 129 | u8 path_noirq_mask; /* mask of paths for which no irq was |
| 130 | received */ |
| 131 | u8 path_notoper_mask; /* mask of paths which were found |
| 132 | not operable */ |
Sebastian Ott | 585b954 | 2010-10-25 16:10:34 +0200 | [diff] [blame] | 133 | u8 path_gone_mask; /* mask of paths, that became unavailable */ |
| 134 | u8 path_new_mask; /* mask of paths, that became available */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 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 */ |
Peter Oberparleiter | 454e1fa | 2009-12-07 12:51:30 +0100 | [diff] [blame] | 140 | unsigned int mpath:1; /* do multipathing */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 141 | } __attribute__ ((packed)) options; |
| 142 | struct { |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 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 */ |
Sebastian Ott | 50c8e31 | 2011-12-01 13:32:21 +0100 | [diff] [blame] | 148 | unsigned int fake_irb:2; /* deliver faked irb */ |
Sebastian Ott | 823d494 | 2009-06-16 10:30:20 +0200 | [diff] [blame] | 149 | unsigned int resuming:1; /* recognition while resume */ |
Peter Oberparleiter | 454e1fa | 2009-12-07 12:51:30 +0100 | [diff] [blame] | 150 | unsigned int pgroup:1; /* pathgroup is set up */ |
| 151 | unsigned int mpath:1; /* multipathing is set up */ |
Sebastian Ott | 69f5576 | 2013-01-28 19:29:43 +0100 | [diff] [blame] | 152 | unsigned int pgid_unknown:1;/* unknown pgid state */ |
Sebastian Ott | 24a1872 | 2009-12-07 12:51:34 +0100 | [diff] [blame] | 153 | unsigned int initialized:1; /* set if initial reference held */ |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 154 | } __attribute__((packed)) flags; |
| 155 | unsigned long intparm; /* user interruption parameter */ |
| 156 | struct qdio_irq *qdio_data; |
| 157 | struct irb irb; /* device status */ |
| 158 | struct senseid senseid; /* SenseID info */ |
| 159 | struct pgid pgid[8]; /* path group IDs per chpid*/ |
| 160 | struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */ |
Peter Oberparleiter | 37de53b | 2009-12-07 12:51:19 +0100 | [diff] [blame] | 161 | struct work_struct todo_work; |
| 162 | enum cdev_todo todo; |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 163 | wait_queue_head_t wait_q; |
| 164 | struct timer_list timer; |
| 165 | void *cmb; /* measurement information */ |
| 166 | struct list_head cmb_list; /* list of measured devices */ |
| 167 | u64 cmb_start_time; /* clock value of cmb reset */ |
| 168 | void *cmb_wait; /* deferred cmb enable/disable */ |
Peter Oberparleiter | de400d6 | 2011-10-30 15:16:04 +0100 | [diff] [blame] | 169 | enum interruption_class int_class; |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 170 | }; |
| 171 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 172 | static inline int rsch(struct subchannel_id schid) |
| 173 | { |
| 174 | register struct subchannel_id reg1 asm("1") = schid; |
| 175 | int ccode; |
| 176 | |
| 177 | asm volatile( |
| 178 | " rsch\n" |
| 179 | " ipm %0\n" |
| 180 | " srl %0,28" |
Peter Oberparleiter | f9c9fe3 | 2008-10-10 21:33:15 +0200 | [diff] [blame] | 181 | : "=d" (ccode) |
| 182 | : "d" (reg1) |
| 183 | : "cc", "memory"); |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 184 | return ccode; |
| 185 | } |
| 186 | |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 187 | static inline int hsch(struct subchannel_id schid) |
| 188 | { |
| 189 | register struct subchannel_id reg1 asm("1") = schid; |
| 190 | int ccode; |
| 191 | |
| 192 | asm volatile( |
| 193 | " hsch\n" |
| 194 | " ipm %0\n" |
| 195 | " srl %0,28" |
Peter Oberparleiter | f9c9fe3 | 2008-10-10 21:33:15 +0200 | [diff] [blame] | 196 | : "=d" (ccode) |
| 197 | : "d" (reg1) |
| 198 | : "cc"); |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 199 | return ccode; |
| 200 | } |
| 201 | |
| 202 | static inline int xsch(struct subchannel_id schid) |
| 203 | { |
| 204 | register struct subchannel_id reg1 asm("1") = schid; |
| 205 | int ccode; |
| 206 | |
| 207 | asm volatile( |
| 208 | " .insn rre,0xb2760000,%1,0\n" |
| 209 | " ipm %0\n" |
| 210 | " srl %0,28" |
Peter Oberparleiter | f9c9fe3 | 2008-10-10 21:33:15 +0200 | [diff] [blame] | 211 | : "=d" (ccode) |
| 212 | : "d" (reg1) |
| 213 | : "cc"); |
Cornelia Huck | cd6b4f2 | 2008-01-26 14:10:43 +0100 | [diff] [blame] | 214 | return ccode; |
| 215 | } |
| 216 | |
| 217 | #endif |