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