blob: f9ff7683e2424c2f05d94e9926bbb4698762da76 [file] [log] [blame]
Cornelia Huckcd6b4f22008-01-26 14:10:43 +01001#ifndef S390_IO_SCH_H
2#define S390_IO_SCH_H
3
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +01004#include <linux/types.h>
Cornelia Huck9d92a7e2008-07-14 09:59:05 +02005#include <asm/schid.h>
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +01006#include <asm/ccwdev.h>
7#include "css.h"
Cornelia Huckcd6b4f22008-01-26 14:10:43 +01008
9/*
Peter Oberparleiter83262d62008-07-14 09:58:51 +020010 * command-mode operation request block
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010011 */
Peter Oberparleiter83262d62008-07-14 09:58:51 +020012struct cmd_orb {
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010013 u32 intparm; /* interruption parameter */
14 u32 key : 4; /* flags, like key, suspend control, etc. */
15 u32 spnd : 1; /* suspend control */
16 u32 res1 : 1; /* reserved */
17 u32 mod : 1; /* modification control */
18 u32 sync : 1; /* synchronize control */
19 u32 fmt : 1; /* format control */
20 u32 pfch : 1; /* prefetch control */
21 u32 isic : 1; /* initial-status-interruption control */
22 u32 alcc : 1; /* address-limit-checking control */
23 u32 ssic : 1; /* suppress-suspended-interr. control */
24 u32 res2 : 1; /* reserved */
25 u32 c64 : 1; /* IDAW/QDIO 64 bit control */
26 u32 i2k : 1; /* IDAW 2/4kB block size control */
27 u32 lpm : 8; /* logical path mask */
28 u32 ils : 1; /* incorrect length */
29 u32 zero : 6; /* reserved zeros */
30 u32 orbx : 1; /* ORB extension control */
31 u32 cpa; /* channel program address */
32} __attribute__ ((packed, aligned(4)));
33
Peter Oberparleiter83262d62008-07-14 09:58:51 +020034/*
35 * transport-mode operation request block
36 */
37struct tm_orb {
38 u32 intparm;
39 u32 key:4;
40 u32 :9;
41 u32 b:1;
42 u32 :2;
43 u32 lpm:8;
44 u32 :7;
45 u32 x:1;
46 u32 tcw;
47 u32 prio:8;
48 u32 :8;
49 u32 rsvpgm:8;
50 u32 :8;
51 u32 :32;
52 u32 :32;
53 u32 :32;
54 u32 :32;
55} __attribute__ ((packed, aligned(4)));
56
57union orb {
58 struct cmd_orb cmd;
59 struct tm_orb tm;
60} __attribute__ ((packed, aligned(4)));
61
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010062struct io_subchannel_private {
Peter Oberparleiter83262d62008-07-14 09:58:51 +020063 union orb orb; /* operation request block */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010064 struct ccw1 sense_ccw; /* static ccw for sense command */
65} __attribute__ ((aligned(8)));
66
67#define to_io_private(n) ((struct io_subchannel_private *)n->private)
Cornelia Huckdb6a6422008-01-26 14:10:46 +010068#define sch_get_cdev(n) (dev_get_drvdata(&n->dev))
69#define sch_set_cdev(n, c) (dev_set_drvdata(&n->dev, c))
Cornelia Huckcd6b4f22008-01-26 14:10:43 +010070
71#define MAX_CIWS 8
72
73/*
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +010074 * Possible status values for a CCW request's I/O.
75 */
76enum io_status {
77 IO_DONE,
78 IO_RUNNING,
79 IO_STATUS_ERROR,
80 IO_PATH_ERROR,
81 IO_REJECTED,
82 IO_KILLED
83};
84
85/**
86 * ccw_request - Internal CCW request.
87 * @cp: channel program to start
88 * @timeout: maximum allowable time in jiffies between start I/O and interrupt
89 * @maxretries: number of retries per I/O operation and path
90 * @lpm: mask of paths to use
91 * @check: optional callback that determines if results are final
92 * @filter: optional callback to adjust request status based on IRB data
93 * @callback: final callback
94 * @data: user-defined pointer passed to all callbacks
95 * @mask: current path mask
96 * @retries: current number of retries
97 * @drc: delayed return code
98 * @cancel: non-zero if request was cancelled
99 * @done: non-zero if request was finished
100 */
101struct ccw_request {
102 struct ccw1 *cp;
103 unsigned long timeout;
104 u16 maxretries;
105 u8 lpm;
106 int (*check)(struct ccw_device *, void *);
107 enum io_status (*filter)(struct ccw_device *, void *, struct irb *,
108 enum io_status);
109 void (*callback)(struct ccw_device *, void *, int);
110 void *data;
111 /* These fields are used internally. */
112 u8 mask;
113 u16 retries;
114 int drc;
115 int cancel:1;
116 int done:1;
117} __attribute__((packed));
118
119/*
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100120 * sense-id response buffer layout
121 */
122struct senseid {
123 /* common part */
124 u8 reserved; /* always 0x'FF' */
125 u16 cu_type; /* control unit type */
126 u8 cu_model; /* control unit model */
127 u16 dev_type; /* device type */
128 u8 dev_model; /* device model */
129 u8 unused; /* padding byte */
130 /* extended part */
131 struct ciw ciw[MAX_CIWS]; /* variable # of CIWs */
132} __attribute__ ((packed, aligned(4)));
133
Peter Oberparleiter37de53b2009-12-07 12:51:19 +0100134enum cdev_todo {
135 CDEV_TODO_NOTHING,
136 CDEV_TODO_ENABLE_CMF,
137 CDEV_TODO_REBIND,
138 CDEV_TODO_REGISTER,
139 CDEV_TODO_UNREG,
140 CDEV_TODO_UNREG_EVAL,
141};
142
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100143struct ccw_device_private {
144 struct ccw_device *cdev;
145 struct subchannel *sch;
146 int state; /* device state */
147 atomic_t onoff;
148 unsigned long registered;
149 struct ccw_dev_id dev_id; /* device id */
150 struct subchannel_id schid; /* subchannel number */
Peter Oberparleitere1f0fbd2009-12-07 12:51:25 +0100151 struct ccw_request req; /* internal I/O request */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100152 u8 imask; /* lpm mask for SNID/SID/SPGID */
153 int iretry; /* retry counter SNID/SID/SPGID */
154 struct {
155 unsigned int fast:1; /* post with "channel end" */
156 unsigned int repall:1; /* report every interrupt status */
157 unsigned int pgroup:1; /* do path grouping */
158 unsigned int force:1; /* allow forced online */
159 } __attribute__ ((packed)) options;
160 struct {
161 unsigned int pgid_single:1; /* use single path for Set PGID */
162 unsigned int esid:1; /* Ext. SenseID supported by HW */
163 unsigned int dosense:1; /* delayed SENSE required */
164 unsigned int doverify:1; /* delayed path verification */
165 unsigned int donotify:1; /* call notify function */
166 unsigned int recog_done:1; /* dev. recog. complete */
167 unsigned int fake_irb:1; /* deliver faked irb */
168 unsigned int intretry:1; /* retry internal operation */
Sebastian Ott823d4942009-06-16 10:30:20 +0200169 unsigned int resuming:1; /* recognition while resume */
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100170 } __attribute__((packed)) flags;
171 unsigned long intparm; /* user interruption parameter */
172 struct qdio_irq *qdio_data;
173 struct irb irb; /* device status */
174 struct senseid senseid; /* SenseID info */
175 struct pgid pgid[8]; /* path group IDs per chpid*/
176 struct ccw1 iccws[2]; /* ccws for SNID/SID/SPGID commands */
Peter Oberparleiter37de53b2009-12-07 12:51:19 +0100177 struct work_struct todo_work;
178 enum cdev_todo todo;
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100179 wait_queue_head_t wait_q;
180 struct timer_list timer;
181 void *cmb; /* measurement information */
182 struct list_head cmb_list; /* list of measured devices */
183 u64 cmb_start_time; /* clock value of cmb reset */
184 void *cmb_wait; /* deferred cmb enable/disable */
185};
186
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200187static inline int ssch(struct subchannel_id schid, union orb *addr)
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100188{
189 register struct subchannel_id reg1 asm("1") = schid;
Peter Oberparleiter83262d62008-07-14 09:58:51 +0200190 int ccode = -EIO;
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100191
192 asm volatile(
193 " ssch 0(%2)\n"
Peter Oberparleiter83262d62008-07-14 09:58:51 +0200194 "0: ipm %0\n"
195 " srl %0,28\n"
196 "1:\n"
197 EX_TABLE(0b, 1b)
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200198 : "+d" (ccode)
199 : "d" (reg1), "a" (addr), "m" (*addr)
200 : "cc", "memory");
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100201 return ccode;
202}
203
204static inline int rsch(struct subchannel_id schid)
205{
206 register struct subchannel_id reg1 asm("1") = schid;
207 int ccode;
208
209 asm volatile(
210 " rsch\n"
211 " ipm %0\n"
212 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200213 : "=d" (ccode)
214 : "d" (reg1)
215 : "cc", "memory");
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100216 return ccode;
217}
218
219static inline int csch(struct subchannel_id schid)
220{
221 register struct subchannel_id reg1 asm("1") = schid;
222 int ccode;
223
224 asm volatile(
225 " csch\n"
226 " ipm %0\n"
227 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200228 : "=d" (ccode)
229 : "d" (reg1)
230 : "cc");
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100231 return ccode;
232}
233
234static inline int hsch(struct subchannel_id schid)
235{
236 register struct subchannel_id reg1 asm("1") = schid;
237 int ccode;
238
239 asm volatile(
240 " hsch\n"
241 " ipm %0\n"
242 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200243 : "=d" (ccode)
244 : "d" (reg1)
245 : "cc");
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100246 return ccode;
247}
248
249static inline int xsch(struct subchannel_id schid)
250{
251 register struct subchannel_id reg1 asm("1") = schid;
252 int ccode;
253
254 asm volatile(
255 " .insn rre,0xb2760000,%1,0\n"
256 " ipm %0\n"
257 " srl %0,28"
Peter Oberparleiterf9c9fe32008-10-10 21:33:15 +0200258 : "=d" (ccode)
259 : "d" (reg1)
260 : "cc");
Cornelia Huckcd6b4f22008-01-26 14:10:43 +0100261 return ccode;
262}
263
264#endif