Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
qdio.h
Go to the documentation of this file.
1 /*
2  * Copyright IBM Corp. 2000, 2008
3  * Author(s): Utz Bacher <[email protected]>
4  * Jan Glauber <[email protected]>
5  *
6  */
7 #ifndef __QDIO_H__
8 #define __QDIO_H__
9 
10 #include <linux/interrupt.h>
11 #include <asm/cio.h>
12 #include <asm/ccwdev.h>
13 
14 /* only use 4 queues to save some cachelines */
15 #define QDIO_MAX_QUEUES_PER_IRQ 4
16 #define QDIO_MAX_BUFFERS_PER_Q 128
17 #define QDIO_MAX_BUFFERS_MASK (QDIO_MAX_BUFFERS_PER_Q - 1)
18 #define QDIO_MAX_ELEMENTS_PER_BUFFER 16
19 #define QDIO_SBAL_SIZE 256
20 
21 #define QDIO_QETH_QFMT 0
22 #define QDIO_ZFCP_QFMT 1
23 #define QDIO_IQDIO_QFMT 2
24 
35 struct qdesfmt0 {
39  u32 : 32;
40  u32 akey : 4;
41  u32 bkey : 4;
42  u32 ckey : 4;
43  u32 dkey : 4;
44  u32 : 16;
45 } __attribute__ ((packed));
46 
47 #define QDR_AC_MULTI_BUFFER_ENABLE 0x01
48 
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: */
79  u32 : 32;
80  u32 qkey : 4;
81  u32 : 28;
82  struct qdesfmt0 qdf0[126];
83 } __attribute__ ((packed, aligned(4096)));
84 
85 #define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40
86 #define QIB_RFLAGS_ENABLE_QEBSM 0x80
87 #define QIB_RFLAGS_ENABLE_DATA_DIV 0x02
88 
100 struct qib {
101  u32 qfmt : 8;
102  u32 pfmt : 8;
103  u32 rflags : 8;
104  u32 ac : 8;
105  u32 : 32;
108  u32 : 32;
109  u32 : 32;
110  u8 ebcnam[8];
111  /* private: */
112  u8 res[88];
113  /* public: */
115 } __attribute__ ((packed, aligned(256)));
116 
121 struct slibe {
123 };
124 
142 struct qaob {
143  u64 res0[6];
154  u64 res4[2];
157 } __attribute__ ((packed, aligned(256)));
166 struct slib {
170  /* private: */
171  u8 res[1000];
172  /* public: */
174 } __attribute__ ((packed, aligned(2048)));
176 #define SBAL_EFLAGS_LAST_ENTRY 0x40
177 #define SBAL_EFLAGS_CONTIGUOUS 0x20
178 #define SBAL_EFLAGS_FIRST_FRAG 0x04
179 #define SBAL_EFLAGS_MIDDLE_FRAG 0x08
180 #define SBAL_EFLAGS_LAST_FRAG 0x0c
181 #define SBAL_EFLAGS_MASK 0x6f
182 
183 #define SBAL_SFLAGS0_PCI_REQ 0x40
184 #define SBAL_SFLAGS0_DATA_CONTINUATION 0x20
185 
186 /* Awesome OpenFCP extensions */
187 #define SBAL_SFLAGS0_TYPE_STATUS 0x00
188 #define SBAL_SFLAGS0_TYPE_WRITE 0x08
189 #define SBAL_SFLAGS0_TYPE_READ 0x10
190 #define SBAL_SFLAGS0_TYPE_WRITE_READ 0x18
191 #define SBAL_SFLAGS0_MORE_SBALS 0x04
192 #define SBAL_SFLAGS0_COMMAND 0x02
193 #define SBAL_SFLAGS0_LAST_SBAL 0x00
194 #define SBAL_SFLAGS0_ONLY_SBAL SBAL_SFLAGS0_COMMAND
195 #define SBAL_SFLAGS0_MIDDLE_SBAL SBAL_SFLAGS0_MORE_SBALS
196 #define SBAL_SFLAGS0_FIRST_SBAL (SBAL_SFLAGS0_MORE_SBALS | SBAL_SFLAGS0_COMMAND)
197 
208  /* private: */
210  /* public: */
214 #ifdef CONFIG_32BIT
215  /* private: */
216  void *res2;
217  /* public: */
218 #endif
219  void *addr;
220 } __attribute__ ((packed, aligned(16)));
226 struct qdio_buffer {
228 } __attribute__ ((packed, aligned(256)));
234 struct sl_element {
235 #ifdef CONFIG_32BIT
236  /* private: */
237  unsigned long reserved;
238  /* public: */
239 #endif
240  unsigned long sbal;
241 } __attribute__ ((packed));
242 
247 struct sl {
249 } __attribute__ ((packed, aligned(1024)));
250 
255 struct slsb {
257 } __attribute__ ((packed, aligned(256)));
270  struct qaob *aob;
271  void *user;
272 };
273 
274 #define QDIO_OUTBUF_STATE_FLAG_NONE 0x00
275 #define QDIO_OUTBUF_STATE_FLAG_PENDING 0x01
276 
277 #define CHSC_AC1_INITIATE_INPUTQ 0x80
278 
279 
280 /* qdio adapter-characteristics-1 flag */
281 #define AC1_SIGA_INPUT_NEEDED 0x40 /* process input queues */
282 #define AC1_SIGA_OUTPUT_NEEDED 0x20 /* process output queues */
283 #define AC1_SIGA_SYNC_NEEDED 0x10 /* ask hypervisor to sync */
284 #define AC1_AUTOMATIC_SYNC_ON_THININT 0x08 /* set by hypervisor */
285 #define AC1_AUTOMATIC_SYNC_ON_OUT_PCI 0x04 /* set by hypervisor */
286 #define AC1_SC_QEBSM_AVAILABLE 0x02 /* available for subchannel */
287 #define AC1_SC_QEBSM_ENABLED 0x01 /* enabled for subchannel */
288 
289 #define CHSC_AC2_MULTI_BUFFER_AVAILABLE 0x0080
290 #define CHSC_AC2_MULTI_BUFFER_ENABLED 0x0040
291 #define CHSC_AC2_DATA_DIV_AVAILABLE 0x0010
292 #define CHSC_AC2_DATA_DIV_ENABLED 0x0002
293 
294 #define CHSC_AC3_FORMAT2_CQ_AVAILABLE 0x8000
295 
298  u8:8;
306  u8:8;
308  u8:8;
315  u16:16;
316  u8:8;
318 } __attribute__ ((packed));
319 
320 /* params are: ccw_device, qdio_error, queue_number,
321  first element processed, number of elements processed, int_parm */
322 typedef void qdio_handler_t(struct ccw_device *, unsigned int, int,
323  int, int, unsigned long);
325 /* qdio errors reported to the upper-layer program */
326 #define QDIO_ERROR_ACTIVATE 0x0001
327 #define QDIO_ERROR_GET_BUF_STATE 0x0002
328 #define QDIO_ERROR_SET_BUF_STATE 0x0004
329 #define QDIO_ERROR_SLSB_STATE 0x0100
330 
331 #define QDIO_ERROR_FATAL 0x00ff
332 #define QDIO_ERROR_TEMPORARY 0xff00
334 /* for qdio_cleanup */
335 #define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01
336 #define QDIO_FLAG_CLEANUP_USING_HALT 0x02
337 
359  struct ccw_device *cdev;
360  unsigned char q_format;
361  unsigned char qdr_ac;
362  unsigned char adapter_name[8];
364  unsigned char *qib_param_field;
365  unsigned char qib_rflags;
366  unsigned long *input_slib_elements;
367  unsigned long *output_slib_elements;
368  unsigned int no_input_qs;
369  unsigned int no_output_qs;
373  unsigned long);
375  unsigned long int_parm;
379 };
380 
381 #define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */
382 #define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_establish */
383 #define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */
384 #define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */
385 
386 #define QDIO_FLAG_SYNC_INPUT 0x01
387 #define QDIO_FLAG_SYNC_OUTPUT 0x02
388 #define QDIO_FLAG_PCI_OUT 0x10
389 
390 extern int qdio_allocate(struct qdio_initialize *);
391 extern int qdio_establish(struct qdio_initialize *);
392 extern int qdio_activate(struct ccw_device *);
393 extern void qdio_release_aob(struct qaob *);
394 extern int do_QDIO(struct ccw_device *, unsigned int, int, unsigned int,
395  unsigned int);
396 extern int qdio_start_irq(struct ccw_device *, int);
397 extern int qdio_stop_irq(struct ccw_device *, int);
398 extern int qdio_get_next_buffers(struct ccw_device *, int, int *, int *);
399 extern int qdio_shutdown(struct ccw_device *, int);
400 extern int qdio_free(struct ccw_device *);
401 extern int qdio_get_ssqd_desc(struct ccw_device *, struct qdio_ssqd_desc *);
402 
403 #endif /* __QDIO_H__ */