kvm tools, setup: Create private directory
[linux-2.6/next.git] / arch / s390 / include / asm / qdio.h
blob15c97625df8d3f0411c17a44c999b117ef1ff49d
1 /*
2 * linux/include/asm-s390/qdio.h
4 * Copyright 2000,2008 IBM Corp.
5 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>
6 * Jan Glauber <jang@linux.vnet.ibm.com>
8 */
9 #ifndef __QDIO_H__
10 #define __QDIO_H__
12 #include <linux/interrupt.h>
13 #include <asm/cio.h>
14 #include <asm/ccwdev.h>
16 /* only use 4 queues to save some cachelines */
17 #define QDIO_MAX_QUEUES_PER_IRQ 4
18 #define QDIO_MAX_BUFFERS_PER_Q 128
19 #define QDIO_MAX_BUFFERS_MASK (QDIO_MAX_BUFFERS_PER_Q - 1)
20 #define QDIO_MAX_ELEMENTS_PER_BUFFER 16
21 #define QDIO_SBAL_SIZE 256
23 #define QDIO_QETH_QFMT 0
24 #define QDIO_ZFCP_QFMT 1
25 #define QDIO_IQDIO_QFMT 2
27 /**
28 * struct qdesfmt0 - queue descriptor, format 0
29 * @sliba: storage list information block address
30 * @sla: storage list address
31 * @slsba: storage list state block address
32 * @akey: access key for DLIB
33 * @bkey: access key for SL
34 * @ckey: access key for SBALs
35 * @dkey: access key for SLSB
37 struct qdesfmt0 {
38 u64 sliba;
39 u64 sla;
40 u64 slsba;
41 u32 : 32;
42 u32 akey : 4;
43 u32 bkey : 4;
44 u32 ckey : 4;
45 u32 dkey : 4;
46 u32 : 16;
47 } __attribute__ ((packed));
49 /**
50 * struct qdr - queue description record (QDR)
51 * @qfmt: queue format
52 * @pfmt: implementation dependent parameter format
53 * @ac: adapter characteristics
54 * @iqdcnt: input queue descriptor count
55 * @oqdcnt: output queue descriptor count
56 * @iqdsz: inpout queue descriptor size
57 * @oqdsz: output queue descriptor size
58 * @qiba: queue information block address
59 * @qkey: queue information block key
60 * @qdf0: queue descriptions
62 struct qdr {
63 u32 qfmt : 8;
64 u32 pfmt : 8;
65 u32 : 8;
66 u32 ac : 8;
67 u32 : 8;
68 u32 iqdcnt : 8;
69 u32 : 8;
70 u32 oqdcnt : 8;
71 u32 : 8;
72 u32 iqdsz : 8;
73 u32 : 8;
74 u32 oqdsz : 8;
75 /* private: */
76 u32 res[9];
77 /* public: */
78 u64 qiba;
79 u32 : 32;
80 u32 qkey : 4;
81 u32 : 28;
82 struct qdesfmt0 qdf0[126];
83 } __attribute__ ((packed, aligned(4096)));
85 #define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40
86 #define QIB_RFLAGS_ENABLE_QEBSM 0x80
87 #define QIB_RFLAGS_ENABLE_DATA_DIV 0x02
89 /**
90 * struct qib - queue information block (QIB)
91 * @qfmt: queue format
92 * @pfmt: implementation dependent parameter format
93 * @rflags: QEBSM
94 * @ac: adapter characteristics
95 * @isliba: absolute address of first input SLIB
96 * @osliba: absolute address of first output SLIB
97 * @ebcnam: adapter identifier in EBCDIC
98 * @parm: implementation dependent parameters
100 struct qib {
101 u32 qfmt : 8;
102 u32 pfmt : 8;
103 u32 rflags : 8;
104 u32 ac : 8;
105 u32 : 32;
106 u64 isliba;
107 u64 osliba;
108 u32 : 32;
109 u32 : 32;
110 u8 ebcnam[8];
111 /* private: */
112 u8 res[88];
113 /* public: */
114 u8 parm[QDIO_MAX_BUFFERS_PER_Q];
115 } __attribute__ ((packed, aligned(256)));
118 * struct slibe - storage list information block element (SLIBE)
119 * @parms: implementation dependent parameters
121 struct slibe {
122 u64 parms;
126 * struct slib - storage list information block (SLIB)
127 * @nsliba: next SLIB address (if any)
128 * @sla: SL address
129 * @slsba: SLSB address
130 * @slibe: SLIB elements
132 struct slib {
133 u64 nsliba;
134 u64 sla;
135 u64 slsba;
136 /* private: */
137 u8 res[1000];
138 /* public: */
139 struct slibe slibe[QDIO_MAX_BUFFERS_PER_Q];
140 } __attribute__ ((packed, aligned(2048)));
142 #define SBAL_EFLAGS_LAST_ENTRY 0x40
143 #define SBAL_EFLAGS_CONTIGUOUS 0x20
144 #define SBAL_EFLAGS_FIRST_FRAG 0x04
145 #define SBAL_EFLAGS_MIDDLE_FRAG 0x08
146 #define SBAL_EFLAGS_LAST_FRAG 0x0c
147 #define SBAL_EFLAGS_MASK 0x6f
149 #define SBAL_SFLAGS0_PCI_REQ 0x40
150 #define SBAL_SFLAGS0_DATA_CONTINUATION 0x20
152 /* Awesome OpenFCP extensions */
153 #define SBAL_SFLAGS0_TYPE_STATUS 0x00
154 #define SBAL_SFLAGS0_TYPE_WRITE 0x08
155 #define SBAL_SFLAGS0_TYPE_READ 0x10
156 #define SBAL_SFLAGS0_TYPE_WRITE_READ 0x18
157 #define SBAL_SFLAGS0_MORE_SBALS 0x04
158 #define SBAL_SFLAGS0_COMMAND 0x02
159 #define SBAL_SFLAGS0_LAST_SBAL 0x00
160 #define SBAL_SFLAGS0_ONLY_SBAL SBAL_SFLAGS0_COMMAND
161 #define SBAL_SFLAGS0_MIDDLE_SBAL SBAL_SFLAGS0_MORE_SBALS
162 #define SBAL_SFLAGS0_FIRST_SBAL (SBAL_SFLAGS0_MORE_SBALS | SBAL_SFLAGS0_COMMAND)
165 * struct qdio_buffer_element - SBAL entry
166 * @eflags: SBAL entry flags
167 * @scount: SBAL count
168 * @sflags: whole SBAL flags
169 * @length: length
170 * @addr: address
172 struct qdio_buffer_element {
173 u8 eflags;
174 /* private: */
175 u8 res1;
176 /* public: */
177 u8 scount;
178 u8 sflags;
179 u32 length;
180 #ifdef CONFIG_32BIT
181 /* private: */
182 void *res2;
183 /* public: */
184 #endif
185 void *addr;
186 } __attribute__ ((packed, aligned(16)));
189 * struct qdio_buffer - storage block address list (SBAL)
190 * @element: SBAL entries
192 struct qdio_buffer {
193 struct qdio_buffer_element element[QDIO_MAX_ELEMENTS_PER_BUFFER];
194 } __attribute__ ((packed, aligned(256)));
197 * struct sl_element - storage list entry
198 * @sbal: absolute SBAL address
200 struct sl_element {
201 #ifdef CONFIG_32BIT
202 /* private: */
203 unsigned long reserved;
204 /* public: */
205 #endif
206 unsigned long sbal;
207 } __attribute__ ((packed));
210 * struct sl - storage list (SL)
211 * @element: SL entries
213 struct sl {
214 struct sl_element element[QDIO_MAX_BUFFERS_PER_Q];
215 } __attribute__ ((packed, aligned(1024)));
218 * struct slsb - storage list state block (SLSB)
219 * @val: state per buffer
221 struct slsb {
222 u8 val[QDIO_MAX_BUFFERS_PER_Q];
223 } __attribute__ ((packed, aligned(256)));
225 #define CHSC_AC2_DATA_DIV_AVAILABLE 0x0010
226 #define CHSC_AC2_DATA_DIV_ENABLED 0x0002
228 struct qdio_ssqd_desc {
229 u8 flags;
230 u8:8;
231 u16 sch;
232 u8 qfmt;
233 u8 parm;
234 u8 qdioac1;
235 u8 sch_class;
236 u8 pcnt;
237 u8 icnt;
238 u8:8;
239 u8 ocnt;
240 u8:8;
241 u8 mbccnt;
242 u16 qdioac2;
243 u64 sch_token;
244 u8 mro;
245 u8 mri;
246 u8:8;
247 u8 sbalic;
248 u16:16;
249 u8:8;
250 u8 mmwc;
251 } __attribute__ ((packed));
253 /* params are: ccw_device, qdio_error, queue_number,
254 first element processed, number of elements processed, int_parm */
255 typedef void qdio_handler_t(struct ccw_device *, unsigned int, int,
256 int, int, unsigned long);
258 /* qdio errors reported to the upper-layer program */
259 #define QDIO_ERROR_SIGA_TARGET 0x02
260 #define QDIO_ERROR_SIGA_ACCESS_EXCEPTION 0x10
261 #define QDIO_ERROR_SIGA_BUSY 0x20
262 #define QDIO_ERROR_ACTIVATE_CHECK_CONDITION 0x40
263 #define QDIO_ERROR_SLSB_STATE 0x80
265 /* for qdio_cleanup */
266 #define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01
267 #define QDIO_FLAG_CLEANUP_USING_HALT 0x02
270 * struct qdio_initialize - qdio initalization data
271 * @cdev: associated ccw device
272 * @q_format: queue format
273 * @adapter_name: name for the adapter
274 * @qib_param_field_format: format for qib_parm_field
275 * @qib_param_field: pointer to 128 bytes or NULL, if no param field
276 * @qib_rflags: rflags to set
277 * @input_slib_elements: pointer to no_input_qs * 128 words of data or NULL
278 * @output_slib_elements: pointer to no_output_qs * 128 words of data or NULL
279 * @no_input_qs: number of input queues
280 * @no_output_qs: number of output queues
281 * @input_handler: handler to be called for input queues
282 * @output_handler: handler to be called for output queues
283 * @int_parm: interruption parameter
284 * @input_sbal_addr_array: address of no_input_qs * 128 pointers
285 * @output_sbal_addr_array: address of no_output_qs * 128 pointers
287 struct qdio_initialize {
288 struct ccw_device *cdev;
289 unsigned char q_format;
290 unsigned char adapter_name[8];
291 unsigned int qib_param_field_format;
292 unsigned char *qib_param_field;
293 unsigned char qib_rflags;
294 unsigned long *input_slib_elements;
295 unsigned long *output_slib_elements;
296 unsigned int no_input_qs;
297 unsigned int no_output_qs;
298 qdio_handler_t *input_handler;
299 qdio_handler_t *output_handler;
300 void (*queue_start_poll) (struct ccw_device *, int, unsigned long);
301 int scan_threshold;
302 unsigned long int_parm;
303 void **input_sbal_addr_array;
304 void **output_sbal_addr_array;
307 #define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */
308 #define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_establish */
309 #define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */
310 #define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */
312 #define QDIO_FLAG_SYNC_INPUT 0x01
313 #define QDIO_FLAG_SYNC_OUTPUT 0x02
314 #define QDIO_FLAG_PCI_OUT 0x10
316 extern int qdio_allocate(struct qdio_initialize *);
317 extern int qdio_establish(struct qdio_initialize *);
318 extern int qdio_activate(struct ccw_device *);
319 extern int do_QDIO(struct ccw_device *, unsigned int, int, unsigned int,
320 unsigned int);
321 extern int qdio_start_irq(struct ccw_device *, int);
322 extern int qdio_stop_irq(struct ccw_device *, int);
323 extern int qdio_get_next_buffers(struct ccw_device *, int, int *, int *);
324 extern int qdio_shutdown(struct ccw_device *, int);
325 extern int qdio_free(struct ccw_device *);
326 extern int qdio_get_ssqd_desc(struct ccw_device *, struct qdio_ssqd_desc *);
328 #endif /* __QDIO_H__ */