xref: /linux/arch/s390/include/asm/qdio.h (revision a53c8fab3f87c995c30ac226a03af95361243144)
1c6557e7fSMartin Schwidefsky /*
2*a53c8fabSHeiko Carstens  * Copyright IBM Corp. 2000, 2008
3c6557e7fSMartin Schwidefsky  * Author(s): Utz Bacher <utz.bacher@de.ibm.com>
4c6557e7fSMartin Schwidefsky  *	      Jan Glauber <jang@linux.vnet.ibm.com>
5c6557e7fSMartin Schwidefsky  *
6c6557e7fSMartin Schwidefsky  */
7c6557e7fSMartin Schwidefsky #ifndef __QDIO_H__
8c6557e7fSMartin Schwidefsky #define __QDIO_H__
9c6557e7fSMartin Schwidefsky 
10c6557e7fSMartin Schwidefsky #include <linux/interrupt.h>
11c6557e7fSMartin Schwidefsky #include <asm/cio.h>
12c6557e7fSMartin Schwidefsky #include <asm/ccwdev.h>
13c6557e7fSMartin Schwidefsky 
14432ac5e0SJan Glauber /* only use 4 queues to save some cachelines */
15432ac5e0SJan Glauber #define QDIO_MAX_QUEUES_PER_IRQ		4
16c6557e7fSMartin Schwidefsky #define QDIO_MAX_BUFFERS_PER_Q		128
17c6557e7fSMartin Schwidefsky #define QDIO_MAX_BUFFERS_MASK		(QDIO_MAX_BUFFERS_PER_Q - 1)
18c6557e7fSMartin Schwidefsky #define QDIO_MAX_ELEMENTS_PER_BUFFER	16
19c6557e7fSMartin Schwidefsky #define QDIO_SBAL_SIZE			256
20c6557e7fSMartin Schwidefsky 
21c6557e7fSMartin Schwidefsky #define QDIO_QETH_QFMT			0
22c6557e7fSMartin Schwidefsky #define QDIO_ZFCP_QFMT			1
23c6557e7fSMartin Schwidefsky #define QDIO_IQDIO_QFMT			2
24c6557e7fSMartin Schwidefsky 
25c6557e7fSMartin Schwidefsky /**
26c6557e7fSMartin Schwidefsky  * struct qdesfmt0 - queue descriptor, format 0
27c6557e7fSMartin Schwidefsky  * @sliba: storage list information block address
28c6557e7fSMartin Schwidefsky  * @sla: storage list address
29c6557e7fSMartin Schwidefsky  * @slsba: storage list state block address
30c6557e7fSMartin Schwidefsky  * @akey: access key for DLIB
31c6557e7fSMartin Schwidefsky  * @bkey: access key for SL
32c6557e7fSMartin Schwidefsky  * @ckey: access key for SBALs
33c6557e7fSMartin Schwidefsky  * @dkey: access key for SLSB
34c6557e7fSMartin Schwidefsky  */
35c6557e7fSMartin Schwidefsky struct qdesfmt0 {
36c6557e7fSMartin Schwidefsky 	u64 sliba;
37c6557e7fSMartin Schwidefsky 	u64 sla;
38c6557e7fSMartin Schwidefsky 	u64 slsba;
39c6557e7fSMartin Schwidefsky 	u32	 : 32;
40c6557e7fSMartin Schwidefsky 	u32 akey : 4;
41c6557e7fSMartin Schwidefsky 	u32 bkey : 4;
42c6557e7fSMartin Schwidefsky 	u32 ckey : 4;
43c6557e7fSMartin Schwidefsky 	u32 dkey : 4;
44c6557e7fSMartin Schwidefsky 	u32	 : 16;
45c6557e7fSMartin Schwidefsky } __attribute__ ((packed));
46c6557e7fSMartin Schwidefsky 
47dfe5bb50SSwen Schillig #define QDR_AC_MULTI_BUFFER_ENABLE 0x01
48dfe5bb50SSwen Schillig 
49c6557e7fSMartin Schwidefsky /**
50c6557e7fSMartin Schwidefsky  * struct qdr - queue description record (QDR)
51c6557e7fSMartin Schwidefsky  * @qfmt: queue format
52c6557e7fSMartin Schwidefsky  * @pfmt: implementation dependent parameter format
53c6557e7fSMartin Schwidefsky  * @ac: adapter characteristics
54c6557e7fSMartin Schwidefsky  * @iqdcnt: input queue descriptor count
55c6557e7fSMartin Schwidefsky  * @oqdcnt: output queue descriptor count
56c6557e7fSMartin Schwidefsky  * @iqdsz: inpout queue descriptor size
57c6557e7fSMartin Schwidefsky  * @oqdsz: output queue descriptor size
58c6557e7fSMartin Schwidefsky  * @qiba: queue information block address
59c6557e7fSMartin Schwidefsky  * @qkey: queue information block key
60c6557e7fSMartin Schwidefsky  * @qdf0: queue descriptions
61c6557e7fSMartin Schwidefsky  */
62c6557e7fSMartin Schwidefsky struct qdr {
63c6557e7fSMartin Schwidefsky 	u32 qfmt   : 8;
64c6557e7fSMartin Schwidefsky 	u32 pfmt   : 8;
65c6557e7fSMartin Schwidefsky 	u32	   : 8;
66c6557e7fSMartin Schwidefsky 	u32 ac	   : 8;
67c6557e7fSMartin Schwidefsky 	u32	   : 8;
68c6557e7fSMartin Schwidefsky 	u32 iqdcnt : 8;
69c6557e7fSMartin Schwidefsky 	u32	   : 8;
70c6557e7fSMartin Schwidefsky 	u32 oqdcnt : 8;
71c6557e7fSMartin Schwidefsky 	u32	   : 8;
72c6557e7fSMartin Schwidefsky 	u32 iqdsz  : 8;
73c6557e7fSMartin Schwidefsky 	u32	   : 8;
74c6557e7fSMartin Schwidefsky 	u32 oqdsz  : 8;
75c6557e7fSMartin Schwidefsky 	/* private: */
76c6557e7fSMartin Schwidefsky 	u32 res[9];
77c6557e7fSMartin Schwidefsky 	/* public: */
78c6557e7fSMartin Schwidefsky 	u64 qiba;
79c6557e7fSMartin Schwidefsky 	u32	   : 32;
80c6557e7fSMartin Schwidefsky 	u32 qkey   : 4;
81c6557e7fSMartin Schwidefsky 	u32	   : 28;
82c6557e7fSMartin Schwidefsky 	struct qdesfmt0 qdf0[126];
83c6557e7fSMartin Schwidefsky } __attribute__ ((packed, aligned(4096)));
84c6557e7fSMartin Schwidefsky 
85c6557e7fSMartin Schwidefsky #define QIB_AC_OUTBOUND_PCI_SUPPORTED	0x40
86c6557e7fSMartin Schwidefsky #define QIB_RFLAGS_ENABLE_QEBSM		0x80
87dcc18f48SChristof Schmitt #define QIB_RFLAGS_ENABLE_DATA_DIV	0x02
88c6557e7fSMartin Schwidefsky 
89c6557e7fSMartin Schwidefsky /**
90c6557e7fSMartin Schwidefsky  * struct qib - queue information block (QIB)
91c6557e7fSMartin Schwidefsky  * @qfmt: queue format
92c6557e7fSMartin Schwidefsky  * @pfmt: implementation dependent parameter format
93c6557e7fSMartin Schwidefsky  * @rflags: QEBSM
94c6557e7fSMartin Schwidefsky  * @ac: adapter characteristics
95c6557e7fSMartin Schwidefsky  * @isliba: absolute address of first input SLIB
96c6557e7fSMartin Schwidefsky  * @osliba: absolute address of first output SLIB
97c6557e7fSMartin Schwidefsky  * @ebcnam: adapter identifier in EBCDIC
98c6557e7fSMartin Schwidefsky  * @parm: implementation dependent parameters
99c6557e7fSMartin Schwidefsky  */
100c6557e7fSMartin Schwidefsky struct qib {
101c6557e7fSMartin Schwidefsky 	u32 qfmt   : 8;
102c6557e7fSMartin Schwidefsky 	u32 pfmt   : 8;
103c6557e7fSMartin Schwidefsky 	u32 rflags : 8;
104c6557e7fSMartin Schwidefsky 	u32 ac	   : 8;
105c6557e7fSMartin Schwidefsky 	u32	   : 32;
106c6557e7fSMartin Schwidefsky 	u64 isliba;
107c6557e7fSMartin Schwidefsky 	u64 osliba;
108c6557e7fSMartin Schwidefsky 	u32	   : 32;
109c6557e7fSMartin Schwidefsky 	u32	   : 32;
110c6557e7fSMartin Schwidefsky 	u8 ebcnam[8];
111c6557e7fSMartin Schwidefsky 	/* private: */
112c6557e7fSMartin Schwidefsky 	u8 res[88];
113c6557e7fSMartin Schwidefsky 	/* public: */
114c6557e7fSMartin Schwidefsky 	u8 parm[QDIO_MAX_BUFFERS_PER_Q];
115c6557e7fSMartin Schwidefsky } __attribute__ ((packed, aligned(256)));
116c6557e7fSMartin Schwidefsky 
117c6557e7fSMartin Schwidefsky /**
118c6557e7fSMartin Schwidefsky  * struct slibe - storage list information block element (SLIBE)
119c6557e7fSMartin Schwidefsky  * @parms: implementation dependent parameters
120c6557e7fSMartin Schwidefsky  */
121c6557e7fSMartin Schwidefsky struct slibe {
122c6557e7fSMartin Schwidefsky 	u64 parms;
123c6557e7fSMartin Schwidefsky };
124c6557e7fSMartin Schwidefsky 
125c6557e7fSMartin Schwidefsky /**
126104ea556Sfrank.blaschka@de.ibm.com  * struct qaob - queue asynchronous operation block
127104ea556Sfrank.blaschka@de.ibm.com  * @res0: reserved parameters
128104ea556Sfrank.blaschka@de.ibm.com  * @res1: reserved parameter
129104ea556Sfrank.blaschka@de.ibm.com  * @res2: reserved parameter
130104ea556Sfrank.blaschka@de.ibm.com  * @res3: reserved parameter
131104ea556Sfrank.blaschka@de.ibm.com  * @aorc: asynchronous operation return code
132104ea556Sfrank.blaschka@de.ibm.com  * @flags: internal flags
133104ea556Sfrank.blaschka@de.ibm.com  * @cbtbs: control block type
134104ea556Sfrank.blaschka@de.ibm.com  * @sb_count: number of storage blocks
135104ea556Sfrank.blaschka@de.ibm.com  * @sba: storage block element addresses
136104ea556Sfrank.blaschka@de.ibm.com  * @dcount: size of storage block elements
137104ea556Sfrank.blaschka@de.ibm.com  * @user0: user defineable value
138104ea556Sfrank.blaschka@de.ibm.com  * @res4: reserved paramater
139104ea556Sfrank.blaschka@de.ibm.com  * @user1: user defineable value
140104ea556Sfrank.blaschka@de.ibm.com  * @user2: user defineable value
141104ea556Sfrank.blaschka@de.ibm.com  */
142104ea556Sfrank.blaschka@de.ibm.com struct qaob {
143104ea556Sfrank.blaschka@de.ibm.com 	u64 res0[6];
144104ea556Sfrank.blaschka@de.ibm.com 	u8 res1;
145104ea556Sfrank.blaschka@de.ibm.com 	u8 res2;
146104ea556Sfrank.blaschka@de.ibm.com 	u8 res3;
147104ea556Sfrank.blaschka@de.ibm.com 	u8 aorc;
148104ea556Sfrank.blaschka@de.ibm.com 	u8 flags;
149104ea556Sfrank.blaschka@de.ibm.com 	u16 cbtbs;
150104ea556Sfrank.blaschka@de.ibm.com 	u8 sb_count;
151104ea556Sfrank.blaschka@de.ibm.com 	u64 sba[QDIO_MAX_ELEMENTS_PER_BUFFER];
152104ea556Sfrank.blaschka@de.ibm.com 	u16 dcount[QDIO_MAX_ELEMENTS_PER_BUFFER];
153104ea556Sfrank.blaschka@de.ibm.com 	u64 user0;
154104ea556Sfrank.blaschka@de.ibm.com 	u64 res4[2];
155104ea556Sfrank.blaschka@de.ibm.com 	u64 user1;
156104ea556Sfrank.blaschka@de.ibm.com 	u64 user2;
157104ea556Sfrank.blaschka@de.ibm.com } __attribute__ ((packed, aligned(256)));
158104ea556Sfrank.blaschka@de.ibm.com 
159104ea556Sfrank.blaschka@de.ibm.com /**
160c6557e7fSMartin Schwidefsky  * struct slib - storage list information block (SLIB)
161c6557e7fSMartin Schwidefsky  * @nsliba: next SLIB address (if any)
162c6557e7fSMartin Schwidefsky  * @sla: SL address
163c6557e7fSMartin Schwidefsky  * @slsba: SLSB address
164c6557e7fSMartin Schwidefsky  * @slibe: SLIB elements
165c6557e7fSMartin Schwidefsky  */
166c6557e7fSMartin Schwidefsky struct slib {
167c6557e7fSMartin Schwidefsky 	u64 nsliba;
168c6557e7fSMartin Schwidefsky 	u64 sla;
169c6557e7fSMartin Schwidefsky 	u64 slsba;
170c6557e7fSMartin Schwidefsky 	/* private: */
171c6557e7fSMartin Schwidefsky 	u8 res[1000];
172c6557e7fSMartin Schwidefsky 	/* public: */
173c6557e7fSMartin Schwidefsky 	struct slibe slibe[QDIO_MAX_BUFFERS_PER_Q];
174c6557e7fSMartin Schwidefsky } __attribute__ ((packed, aligned(2048)));
175c6557e7fSMartin Schwidefsky 
1763ec90878SJan Glauber #define SBAL_EFLAGS_LAST_ENTRY		0x40
1773ec90878SJan Glauber #define SBAL_EFLAGS_CONTIGUOUS		0x20
1783ec90878SJan Glauber #define SBAL_EFLAGS_FIRST_FRAG		0x04
1793ec90878SJan Glauber #define SBAL_EFLAGS_MIDDLE_FRAG		0x08
1803ec90878SJan Glauber #define SBAL_EFLAGS_LAST_FRAG		0x0c
1813ec90878SJan Glauber #define SBAL_EFLAGS_MASK		0x6f
182c6557e7fSMartin Schwidefsky 
1833ec90878SJan Glauber #define SBAL_SFLAGS0_PCI_REQ		0x40
1843ec90878SJan Glauber #define SBAL_SFLAGS0_DATA_CONTINUATION	0x20
185c6557e7fSMartin Schwidefsky 
186c6557e7fSMartin Schwidefsky /* Awesome OpenFCP extensions */
1873ec90878SJan Glauber #define SBAL_SFLAGS0_TYPE_STATUS	0x00
1883ec90878SJan Glauber #define SBAL_SFLAGS0_TYPE_WRITE		0x08
1893ec90878SJan Glauber #define SBAL_SFLAGS0_TYPE_READ		0x10
1903ec90878SJan Glauber #define SBAL_SFLAGS0_TYPE_WRITE_READ	0x18
1913ec90878SJan Glauber #define SBAL_SFLAGS0_MORE_SBALS		0x04
1923ec90878SJan Glauber #define SBAL_SFLAGS0_COMMAND		0x02
1933ec90878SJan Glauber #define SBAL_SFLAGS0_LAST_SBAL		0x00
1943ec90878SJan Glauber #define SBAL_SFLAGS0_ONLY_SBAL		SBAL_SFLAGS0_COMMAND
1953ec90878SJan Glauber #define SBAL_SFLAGS0_MIDDLE_SBAL	SBAL_SFLAGS0_MORE_SBALS
1963ec90878SJan Glauber #define SBAL_SFLAGS0_FIRST_SBAL (SBAL_SFLAGS0_MORE_SBALS | SBAL_SFLAGS0_COMMAND)
197c6557e7fSMartin Schwidefsky 
198c6557e7fSMartin Schwidefsky /**
199c6557e7fSMartin Schwidefsky  * struct qdio_buffer_element - SBAL entry
2003ec90878SJan Glauber  * @eflags: SBAL entry flags
2013ec90878SJan Glauber  * @scount: SBAL count
2023ec90878SJan Glauber  * @sflags: whole SBAL flags
203c6557e7fSMartin Schwidefsky  * @length: length
204c6557e7fSMartin Schwidefsky  * @addr: address
205c6557e7fSMartin Schwidefsky */
206c6557e7fSMartin Schwidefsky struct qdio_buffer_element {
2073ec90878SJan Glauber 	u8 eflags;
2083ec90878SJan Glauber 	/* private: */
2093ec90878SJan Glauber 	u8 res1;
2103ec90878SJan Glauber 	/* public: */
2113ec90878SJan Glauber 	u8 scount;
2123ec90878SJan Glauber 	u8 sflags;
213c6557e7fSMartin Schwidefsky 	u32 length;
214c6557e7fSMartin Schwidefsky #ifdef CONFIG_32BIT
215c6557e7fSMartin Schwidefsky 	/* private: */
2163ec90878SJan Glauber 	void *res2;
217c6557e7fSMartin Schwidefsky 	/* public: */
218c6557e7fSMartin Schwidefsky #endif
219c6557e7fSMartin Schwidefsky 	void *addr;
220c6557e7fSMartin Schwidefsky } __attribute__ ((packed, aligned(16)));
221c6557e7fSMartin Schwidefsky 
222c6557e7fSMartin Schwidefsky /**
223c6557e7fSMartin Schwidefsky  * struct qdio_buffer - storage block address list (SBAL)
224c6557e7fSMartin Schwidefsky  * @element: SBAL entries
225c6557e7fSMartin Schwidefsky  */
226c6557e7fSMartin Schwidefsky struct qdio_buffer {
227c6557e7fSMartin Schwidefsky 	struct qdio_buffer_element element[QDIO_MAX_ELEMENTS_PER_BUFFER];
228c6557e7fSMartin Schwidefsky } __attribute__ ((packed, aligned(256)));
229c6557e7fSMartin Schwidefsky 
230c6557e7fSMartin Schwidefsky /**
231c6557e7fSMartin Schwidefsky  * struct sl_element - storage list entry
232c6557e7fSMartin Schwidefsky  * @sbal: absolute SBAL address
233c6557e7fSMartin Schwidefsky  */
234c6557e7fSMartin Schwidefsky struct sl_element {
235c6557e7fSMartin Schwidefsky #ifdef CONFIG_32BIT
236c6557e7fSMartin Schwidefsky 	/* private: */
237c6557e7fSMartin Schwidefsky 	unsigned long reserved;
238c6557e7fSMartin Schwidefsky 	/* public: */
239c6557e7fSMartin Schwidefsky #endif
240c6557e7fSMartin Schwidefsky 	unsigned long sbal;
241c6557e7fSMartin Schwidefsky } __attribute__ ((packed));
242c6557e7fSMartin Schwidefsky 
243c6557e7fSMartin Schwidefsky /**
244c6557e7fSMartin Schwidefsky  * struct sl - storage list (SL)
245c6557e7fSMartin Schwidefsky  * @element: SL entries
246c6557e7fSMartin Schwidefsky  */
247c6557e7fSMartin Schwidefsky struct sl {
248c6557e7fSMartin Schwidefsky 	struct sl_element element[QDIO_MAX_BUFFERS_PER_Q];
249c6557e7fSMartin Schwidefsky } __attribute__ ((packed, aligned(1024)));
250c6557e7fSMartin Schwidefsky 
251c6557e7fSMartin Schwidefsky /**
252c6557e7fSMartin Schwidefsky  * struct slsb - storage list state block (SLSB)
253c6557e7fSMartin Schwidefsky  * @val: state per buffer
254c6557e7fSMartin Schwidefsky  */
255c6557e7fSMartin Schwidefsky struct slsb {
256c6557e7fSMartin Schwidefsky 	u8 val[QDIO_MAX_BUFFERS_PER_Q];
257c6557e7fSMartin Schwidefsky } __attribute__ ((packed, aligned(256)));
258c6557e7fSMartin Schwidefsky 
259104ea556Sfrank.blaschka@de.ibm.com /**
260104ea556Sfrank.blaschka@de.ibm.com  * struct qdio_outbuf_state - SBAL related asynchronous operation information
261104ea556Sfrank.blaschka@de.ibm.com  *   (for communication with upper layer programs)
262104ea556Sfrank.blaschka@de.ibm.com  *   (only required for use with completion queues)
263104ea556Sfrank.blaschka@de.ibm.com  * @flags: flags indicating state of buffer
264104ea556Sfrank.blaschka@de.ibm.com  * @aob: pointer to QAOB used for the particular SBAL
265104ea556Sfrank.blaschka@de.ibm.com  * @user: pointer to upper layer program's state information related to SBAL
266104ea556Sfrank.blaschka@de.ibm.com  *        (stored in user1 data of QAOB)
267104ea556Sfrank.blaschka@de.ibm.com  */
268104ea556Sfrank.blaschka@de.ibm.com struct qdio_outbuf_state {
269104ea556Sfrank.blaschka@de.ibm.com 	u8 flags;
270104ea556Sfrank.blaschka@de.ibm.com 	struct qaob *aob;
271104ea556Sfrank.blaschka@de.ibm.com 	void *user;
272104ea556Sfrank.blaschka@de.ibm.com };
273104ea556Sfrank.blaschka@de.ibm.com 
274104ea556Sfrank.blaschka@de.ibm.com #define QDIO_OUTBUF_STATE_FLAG_NONE	0x00
275104ea556Sfrank.blaschka@de.ibm.com #define QDIO_OUTBUF_STATE_FLAG_PENDING	0x01
276104ea556Sfrank.blaschka@de.ibm.com 
277104ea556Sfrank.blaschka@de.ibm.com #define CHSC_AC1_INITIATE_INPUTQ	0x80
278104ea556Sfrank.blaschka@de.ibm.com 
2799cb7284fSfrank.blaschka@de.ibm.com 
2809cb7284fSfrank.blaschka@de.ibm.com /* qdio adapter-characteristics-1 flag */
2819cb7284fSfrank.blaschka@de.ibm.com #define AC1_SIGA_INPUT_NEEDED		0x40	/* process input queues */
2829cb7284fSfrank.blaschka@de.ibm.com #define AC1_SIGA_OUTPUT_NEEDED		0x20	/* process output queues */
2839cb7284fSfrank.blaschka@de.ibm.com #define AC1_SIGA_SYNC_NEEDED		0x10	/* ask hypervisor to sync */
2849cb7284fSfrank.blaschka@de.ibm.com #define AC1_AUTOMATIC_SYNC_ON_THININT	0x08	/* set by hypervisor */
2859cb7284fSfrank.blaschka@de.ibm.com #define AC1_AUTOMATIC_SYNC_ON_OUT_PCI	0x04	/* set by hypervisor */
2869cb7284fSfrank.blaschka@de.ibm.com #define AC1_SC_QEBSM_AVAILABLE		0x02	/* available for subchannel */
2879cb7284fSfrank.blaschka@de.ibm.com #define AC1_SC_QEBSM_ENABLED		0x01	/* enabled for subchannel */
2889cb7284fSfrank.blaschka@de.ibm.com 
289050276abSSteffen Maier #define CHSC_AC2_MULTI_BUFFER_AVAILABLE	0x0080
290050276abSSteffen Maier #define CHSC_AC2_MULTI_BUFFER_ENABLED	0x0040
291104ea556Sfrank.blaschka@de.ibm.com #define CHSC_AC2_DATA_DIV_AVAILABLE	0x0010
292104ea556Sfrank.blaschka@de.ibm.com #define CHSC_AC2_DATA_DIV_ENABLED	0x0002
293104ea556Sfrank.blaschka@de.ibm.com 
294104ea556Sfrank.blaschka@de.ibm.com #define CHSC_AC3_FORMAT2_CQ_AVAILABLE	0x8000
295104ea556Sfrank.blaschka@de.ibm.com 
296c6557e7fSMartin Schwidefsky struct qdio_ssqd_desc {
297c6557e7fSMartin Schwidefsky 	u8 flags;
298c6557e7fSMartin Schwidefsky 	u8:8;
299c6557e7fSMartin Schwidefsky 	u16 sch;
300c6557e7fSMartin Schwidefsky 	u8 qfmt;
301c6557e7fSMartin Schwidefsky 	u8 parm;
302c6557e7fSMartin Schwidefsky 	u8 qdioac1;
303c6557e7fSMartin Schwidefsky 	u8 sch_class;
304c6557e7fSMartin Schwidefsky 	u8 pcnt;
305c6557e7fSMartin Schwidefsky 	u8 icnt;
306c6557e7fSMartin Schwidefsky 	u8:8;
307c6557e7fSMartin Schwidefsky 	u8 ocnt;
308c6557e7fSMartin Schwidefsky 	u8:8;
309c6557e7fSMartin Schwidefsky 	u8 mbccnt;
310c6557e7fSMartin Schwidefsky 	u16 qdioac2;
311c6557e7fSMartin Schwidefsky 	u64 sch_token;
3127a0f4755SKlaus-Dieter Wacker 	u8 mro;
3137a0f4755SKlaus-Dieter Wacker 	u8 mri;
314104ea556Sfrank.blaschka@de.ibm.com 	u16 qdioac3;
3157a0f4755SKlaus-Dieter Wacker 	u16:16;
3167a0f4755SKlaus-Dieter Wacker 	u8:8;
3177a0f4755SKlaus-Dieter Wacker 	u8 mmwc;
318c6557e7fSMartin Schwidefsky } __attribute__ ((packed));
319c6557e7fSMartin Schwidefsky 
320c6557e7fSMartin Schwidefsky /* params are: ccw_device, qdio_error, queue_number,
321c6557e7fSMartin Schwidefsky    first element processed, number of elements processed, int_parm */
322c6557e7fSMartin Schwidefsky typedef void qdio_handler_t(struct ccw_device *, unsigned int, int,
323c6557e7fSMartin Schwidefsky 			    int, int, unsigned long);
324c6557e7fSMartin Schwidefsky 
325c6557e7fSMartin Schwidefsky /* qdio errors reported to the upper-layer program */
3261549d13fSJan Glauber #define QDIO_ERROR_ACTIVATE			0x0001
3271549d13fSJan Glauber #define QDIO_ERROR_GET_BUF_STATE		0x0002
3281549d13fSJan Glauber #define QDIO_ERROR_SET_BUF_STATE		0x0004
3291549d13fSJan Glauber #define QDIO_ERROR_SLSB_STATE			0x0100
3301549d13fSJan Glauber 
3311549d13fSJan Glauber #define QDIO_ERROR_FATAL			0x00ff
3321549d13fSJan Glauber #define QDIO_ERROR_TEMPORARY			0xff00
333c6557e7fSMartin Schwidefsky 
334c6557e7fSMartin Schwidefsky /* for qdio_cleanup */
335c6557e7fSMartin Schwidefsky #define QDIO_FLAG_CLEANUP_USING_CLEAR		0x01
336c6557e7fSMartin Schwidefsky #define QDIO_FLAG_CLEANUP_USING_HALT		0x02
337c6557e7fSMartin Schwidefsky 
338c6557e7fSMartin Schwidefsky /**
339c6557e7fSMartin Schwidefsky  * struct qdio_initialize - qdio initalization data
340c6557e7fSMartin Schwidefsky  * @cdev: associated ccw device
341c6557e7fSMartin Schwidefsky  * @q_format: queue format
342c6557e7fSMartin Schwidefsky  * @adapter_name: name for the adapter
343c6557e7fSMartin Schwidefsky  * @qib_param_field_format: format for qib_parm_field
344c6557e7fSMartin Schwidefsky  * @qib_param_field: pointer to 128 bytes or NULL, if no param field
345dcc18f48SChristof Schmitt  * @qib_rflags: rflags to set
346c6557e7fSMartin Schwidefsky  * @input_slib_elements: pointer to no_input_qs * 128 words of data or NULL
347c6557e7fSMartin Schwidefsky  * @output_slib_elements: pointer to no_output_qs * 128 words of data or NULL
348c6557e7fSMartin Schwidefsky  * @no_input_qs: number of input queues
349c6557e7fSMartin Schwidefsky  * @no_output_qs: number of output queues
350c6557e7fSMartin Schwidefsky  * @input_handler: handler to be called for input queues
351c6557e7fSMartin Schwidefsky  * @output_handler: handler to be called for output queues
352e58b0d90SSteffen Maier  * @queue_start_poll_array: polling handlers (one per input queue or NULL)
353c6557e7fSMartin Schwidefsky  * @int_parm: interruption parameter
354c6557e7fSMartin Schwidefsky  * @input_sbal_addr_array:  address of no_input_qs * 128 pointers
355c6557e7fSMartin Schwidefsky  * @output_sbal_addr_array: address of no_output_qs * 128 pointers
356104ea556Sfrank.blaschka@de.ibm.com  * @output_sbal_state_array: no_output_qs * 128 state info (for CQ or NULL)
357c6557e7fSMartin Schwidefsky  */
358c6557e7fSMartin Schwidefsky struct qdio_initialize {
359c6557e7fSMartin Schwidefsky 	struct ccw_device *cdev;
360c6557e7fSMartin Schwidefsky 	unsigned char q_format;
361dfe5bb50SSwen Schillig 	unsigned char qdr_ac;
362c6557e7fSMartin Schwidefsky 	unsigned char adapter_name[8];
363c6557e7fSMartin Schwidefsky 	unsigned int qib_param_field_format;
364c6557e7fSMartin Schwidefsky 	unsigned char *qib_param_field;
365dcc18f48SChristof Schmitt 	unsigned char qib_rflags;
366c6557e7fSMartin Schwidefsky 	unsigned long *input_slib_elements;
367c6557e7fSMartin Schwidefsky 	unsigned long *output_slib_elements;
368c6557e7fSMartin Schwidefsky 	unsigned int no_input_qs;
369c6557e7fSMartin Schwidefsky 	unsigned int no_output_qs;
370c6557e7fSMartin Schwidefsky 	qdio_handler_t *input_handler;
371c6557e7fSMartin Schwidefsky 	qdio_handler_t *output_handler;
372e58b0d90SSteffen Maier 	void (**queue_start_poll_array) (struct ccw_device *, int,
373e58b0d90SSteffen Maier 					  unsigned long);
3743d6c76ffSJan Glauber 	int scan_threshold;
375c6557e7fSMartin Schwidefsky 	unsigned long int_parm;
376c6557e7fSMartin Schwidefsky 	void **input_sbal_addr_array;
377c6557e7fSMartin Schwidefsky 	void **output_sbal_addr_array;
378104ea556Sfrank.blaschka@de.ibm.com 	struct qdio_outbuf_state *output_sbal_state_array;
379c6557e7fSMartin Schwidefsky };
380c6557e7fSMartin Schwidefsky 
381c6557e7fSMartin Schwidefsky #define QDIO_STATE_INACTIVE		0x00000002 /* after qdio_cleanup */
382c6557e7fSMartin Schwidefsky #define QDIO_STATE_ESTABLISHED		0x00000004 /* after qdio_establish */
383c6557e7fSMartin Schwidefsky #define QDIO_STATE_ACTIVE		0x00000008 /* after qdio_activate */
384c6557e7fSMartin Schwidefsky #define QDIO_STATE_STOPPED		0x00000010 /* after queues went down */
385c6557e7fSMartin Schwidefsky 
386c6557e7fSMartin Schwidefsky #define QDIO_FLAG_SYNC_INPUT		0x01
387c6557e7fSMartin Schwidefsky #define QDIO_FLAG_SYNC_OUTPUT		0x02
388c6557e7fSMartin Schwidefsky #define QDIO_FLAG_PCI_OUT		0x10
389c6557e7fSMartin Schwidefsky 
390bbd50e17SJan Glauber extern int qdio_allocate(struct qdio_initialize *);
391bbd50e17SJan Glauber extern int qdio_establish(struct qdio_initialize *);
392c6557e7fSMartin Schwidefsky extern int qdio_activate(struct ccw_device *);
393104ea556Sfrank.blaschka@de.ibm.com extern void qdio_release_aob(struct qaob *);
394d36deae7SJan Glauber extern int do_QDIO(struct ccw_device *, unsigned int, int, unsigned int,
395d36deae7SJan Glauber 		   unsigned int);
396d36deae7SJan Glauber extern int qdio_start_irq(struct ccw_device *, int);
397d36deae7SJan Glauber extern int qdio_stop_irq(struct ccw_device *, int);
398d36deae7SJan Glauber extern int qdio_get_next_buffers(struct ccw_device *, int, int *, int *);
399bbd50e17SJan Glauber extern int qdio_shutdown(struct ccw_device *, int);
400c6557e7fSMartin Schwidefsky extern int qdio_free(struct ccw_device *);
401d36deae7SJan Glauber extern int qdio_get_ssqd_desc(struct ccw_device *, struct qdio_ssqd_desc *);
402c6557e7fSMartin Schwidefsky 
403c6557e7fSMartin Schwidefsky #endif /* __QDIO_H__ */
404