blob: c666bfe5e9847dc055ad7bcc5f7c863afa89f4cb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * linux/include/asm-s390/qdio.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Jan Glauber779e6e12008-07-17 17:16:48 +02004 * Copyright 2000,2008 IBM Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>
Jan Glauber779e6e12008-07-17 17:16:48 +02006 * Jan Glauber <jang@linux.vnet.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
8 */
9#ifndef __QDIO_H__
10#define __QDIO_H__
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/interrupt.h>
13#include <asm/cio.h>
14#include <asm/ccwdev.h>
15
Jan Glauber432ac5e2010-02-26 22:37:37 +010016/* only use 4 queues to save some cachelines */
17#define QDIO_MAX_QUEUES_PER_IRQ 4
Jan Glauber779e6e12008-07-17 17:16:48 +020018#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
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Jan Glauber779e6e12008-07-17 17:16:48 +020023#define QDIO_QETH_QFMT 0
24#define QDIO_ZFCP_QFMT 1
25#define QDIO_IQDIO_QFMT 2
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Jan Glauber779e6e12008-07-17 17:16:48 +020027/**
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
36 */
37struct 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));
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Jan Glauber779e6e12008-07-17 17:16:48 +020049/**
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
61 */
62struct 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)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Jan Glauber779e6e12008-07-17 17:16:48 +020085#define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40
86#define QIB_RFLAGS_ENABLE_QEBSM 0x80
87
88/**
89 * struct qib - queue information block (QIB)
90 * @qfmt: queue format
91 * @pfmt: implementation dependent parameter format
92 * @rflags: QEBSM
93 * @ac: adapter characteristics
94 * @isliba: absolute address of first input SLIB
95 * @osliba: absolute address of first output SLIB
96 * @ebcnam: adapter identifier in EBCDIC
97 * @parm: implementation dependent parameters
98 */
99struct qib {
100 u32 qfmt : 8;
101 u32 pfmt : 8;
102 u32 rflags : 8;
103 u32 ac : 8;
104 u32 : 32;
105 u64 isliba;
106 u64 osliba;
107 u32 : 32;
108 u32 : 32;
109 u8 ebcnam[8];
110 /* private: */
111 u8 res[88];
112 /* public: */
113 u8 parm[QDIO_MAX_BUFFERS_PER_Q];
114} __attribute__ ((packed, aligned(256)));
115
116/**
117 * struct slibe - storage list information block element (SLIBE)
118 * @parms: implementation dependent parameters
119 */
120struct slibe {
121 u64 parms;
122};
123
124/**
125 * struct slib - storage list information block (SLIB)
126 * @nsliba: next SLIB address (if any)
127 * @sla: SL address
128 * @slsba: SLSB address
129 * @slibe: SLIB elements
130 */
131struct slib {
132 u64 nsliba;
133 u64 sla;
134 u64 slsba;
135 /* private: */
136 u8 res[1000];
137 /* public: */
138 struct slibe slibe[QDIO_MAX_BUFFERS_PER_Q];
139} __attribute__ ((packed, aligned(2048)));
140
141/**
142 * struct sbal_flags - storage block address list flags
143 * @last: last entry
144 * @cont: contiguous storage
145 * @frag: fragmentation
146 */
147struct sbal_flags {
148 u8 : 1;
149 u8 last : 1;
150 u8 cont : 1;
151 u8 : 1;
152 u8 frag : 2;
153 u8 : 2;
154} __attribute__ ((packed));
155
156#define SBAL_FLAGS_FIRST_FRAG 0x04000000UL
157#define SBAL_FLAGS_MIDDLE_FRAG 0x08000000UL
158#define SBAL_FLAGS_LAST_FRAG 0x0c000000UL
159#define SBAL_FLAGS_LAST_ENTRY 0x40000000UL
160#define SBAL_FLAGS_CONTIGUOUS 0x20000000UL
161
162#define SBAL_FLAGS0_DATA_CONTINUATION 0x20UL
163
164/* Awesome OpenFCP extensions */
165#define SBAL_FLAGS0_TYPE_STATUS 0x00UL
166#define SBAL_FLAGS0_TYPE_WRITE 0x08UL
167#define SBAL_FLAGS0_TYPE_READ 0x10UL
168#define SBAL_FLAGS0_TYPE_WRITE_READ 0x18UL
169#define SBAL_FLAGS0_MORE_SBALS 0x04UL
170#define SBAL_FLAGS0_COMMAND 0x02UL
171#define SBAL_FLAGS0_LAST_SBAL 0x00UL
172#define SBAL_FLAGS0_ONLY_SBAL SBAL_FLAGS0_COMMAND
173#define SBAL_FLAGS0_MIDDLE_SBAL SBAL_FLAGS0_MORE_SBALS
174#define SBAL_FLAGS0_FIRST_SBAL SBAL_FLAGS0_MORE_SBALS | SBAL_FLAGS0_COMMAND
175#define SBAL_FLAGS0_PCI 0x40
176
177/**
178 * struct sbal_sbalf_0 - sbal flags for sbale 0
179 * @pci: PCI indicator
180 * @cont: data continuation
181 * @sbtype: storage-block type (FCP)
182 */
183struct sbal_sbalf_0 {
184 u8 : 1;
185 u8 pci : 1;
186 u8 cont : 1;
187 u8 sbtype : 2;
188 u8 : 3;
189} __attribute__ ((packed));
190
191/**
192 * struct sbal_sbalf_1 - sbal flags for sbale 1
193 * @key: storage key
194 */
195struct sbal_sbalf_1 {
196 u8 : 4;
197 u8 key : 4;
198} __attribute__ ((packed));
199
200/**
201 * struct sbal_sbalf_14 - sbal flags for sbale 14
202 * @erridx: error index
203 */
204struct sbal_sbalf_14 {
205 u8 : 4;
206 u8 erridx : 4;
207} __attribute__ ((packed));
208
209/**
210 * struct sbal_sbalf_15 - sbal flags for sbale 15
211 * @reason: reason for error state
212 */
213struct sbal_sbalf_15 {
214 u8 reason;
215} __attribute__ ((packed));
216
217/**
218 * union sbal_sbalf - storage block address list flags
219 * @i0: sbalf0
220 * @i1: sbalf1
221 * @i14: sbalf14
222 * @i15: sblaf15
223 * @value: raw value
224 */
225union sbal_sbalf {
226 struct sbal_sbalf_0 i0;
227 struct sbal_sbalf_1 i1;
228 struct sbal_sbalf_14 i14;
229 struct sbal_sbalf_15 i15;
230 u8 value;
231};
232
233/**
234 * struct qdio_buffer_element - SBAL entry
235 * @flags: flags
236 * @length: length
237 * @addr: address
238*/
239struct qdio_buffer_element {
240 u32 flags;
241 u32 length;
242#ifdef CONFIG_32BIT
243 /* private: */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 void *reserved;
Jan Glauber779e6e12008-07-17 17:16:48 +0200245 /* public: */
246#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 void *addr;
Jan Glauber779e6e12008-07-17 17:16:48 +0200248} __attribute__ ((packed, aligned(16)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Jan Glauber779e6e12008-07-17 17:16:48 +0200250/**
251 * struct qdio_buffer - storage block address list (SBAL)
252 * @element: SBAL entries
253 */
254struct qdio_buffer {
255 struct qdio_buffer_element element[QDIO_MAX_ELEMENTS_PER_BUFFER];
256} __attribute__ ((packed, aligned(256)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
Jan Glauber779e6e12008-07-17 17:16:48 +0200258/**
259 * struct sl_element - storage list entry
260 * @sbal: absolute SBAL address
261 */
262struct sl_element {
263#ifdef CONFIG_32BIT
264 /* private: */
265 unsigned long reserved;
266 /* public: */
267#endif
268 unsigned long sbal;
269} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Jan Glauber779e6e12008-07-17 17:16:48 +0200271/**
272 * struct sl - storage list (SL)
273 * @element: SL entries
274 */
275struct sl {
276 struct sl_element element[QDIO_MAX_BUFFERS_PER_Q];
277} __attribute__ ((packed, aligned(1024)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Jan Glauber779e6e12008-07-17 17:16:48 +0200279/**
280 * struct slsb - storage list state block (SLSB)
281 * @val: state per buffer
282 */
283struct slsb {
284 u8 val[QDIO_MAX_BUFFERS_PER_Q];
285} __attribute__ ((packed, aligned(256)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Jan Glauber779e6e12008-07-17 17:16:48 +0200287struct qdio_ssqd_desc {
288 u8 flags;
289 u8:8;
290 u16 sch;
291 u8 qfmt;
292 u8 parm;
293 u8 qdioac1;
294 u8 sch_class;
295 u8 pcnt;
296 u8 icnt;
297 u8:8;
298 u8 ocnt;
299 u8:8;
300 u8 mbccnt;
301 u16 qdioac2;
302 u64 sch_token;
Klaus-Dieter Wacker7a0f4752008-10-10 21:33:18 +0200303 u8 mro;
304 u8 mri;
305 u8:8;
306 u8 sbalic;
307 u16:16;
308 u8:8;
309 u8 mmwc;
Jan Glauber779e6e12008-07-17 17:16:48 +0200310} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
Jan Glauber779e6e12008-07-17 17:16:48 +0200312/* params are: ccw_device, qdio_error, queue_number,
313 first element processed, number of elements processed, int_parm */
314typedef void qdio_handler_t(struct ccw_device *, unsigned int, int,
315 int, int, unsigned long);
316
317/* qdio errors reported to the upper-layer program */
Jan Glauberd303b6f2009-03-26 15:24:31 +0100318#define QDIO_ERROR_SIGA_TARGET 0x02
Jan Glauber779e6e12008-07-17 17:16:48 +0200319#define QDIO_ERROR_SIGA_ACCESS_EXCEPTION 0x10
320#define QDIO_ERROR_SIGA_BUSY 0x20
321#define QDIO_ERROR_ACTIVATE_CHECK_CONDITION 0x40
322#define QDIO_ERROR_SLSB_STATE 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
324/* for qdio_initialize */
Jan Glauber779e6e12008-07-17 17:16:48 +0200325#define QDIO_INBOUND_0COPY_SBALS 0x01
326#define QDIO_OUTBOUND_0COPY_SBALS 0x02
327#define QDIO_USE_OUTBOUND_PCIS 0x04
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
329/* for qdio_cleanup */
Jan Glauber779e6e12008-07-17 17:16:48 +0200330#define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01
331#define QDIO_FLAG_CLEANUP_USING_HALT 0x02
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
Jan Glauber779e6e12008-07-17 17:16:48 +0200333/**
334 * struct qdio_initialize - qdio initalization data
335 * @cdev: associated ccw device
336 * @q_format: queue format
337 * @adapter_name: name for the adapter
338 * @qib_param_field_format: format for qib_parm_field
339 * @qib_param_field: pointer to 128 bytes or NULL, if no param field
340 * @input_slib_elements: pointer to no_input_qs * 128 words of data or NULL
341 * @output_slib_elements: pointer to no_output_qs * 128 words of data or NULL
342 * @no_input_qs: number of input queues
343 * @no_output_qs: number of output queues
344 * @input_handler: handler to be called for input queues
345 * @output_handler: handler to be called for output queues
346 * @int_parm: interruption parameter
347 * @flags: initialization flags
348 * @input_sbal_addr_array: address of no_input_qs * 128 pointers
349 * @output_sbal_addr_array: address of no_output_qs * 128 pointers
350 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351struct qdio_initialize {
352 struct ccw_device *cdev;
353 unsigned char q_format;
354 unsigned char adapter_name[8];
Jan Glauber779e6e12008-07-17 17:16:48 +0200355 unsigned int qib_param_field_format;
356 unsigned char *qib_param_field;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 unsigned long *input_slib_elements;
358 unsigned long *output_slib_elements;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 unsigned int no_input_qs;
360 unsigned int no_output_qs;
361 qdio_handler_t *input_handler;
362 qdio_handler_t *output_handler;
363 unsigned long int_parm;
364 unsigned long flags;
Jan Glauber779e6e12008-07-17 17:16:48 +0200365 void **input_sbal_addr_array;
366 void **output_sbal_addr_array;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367};
368
Jan Glauber779e6e12008-07-17 17:16:48 +0200369#define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */
370#define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_establish */
371#define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */
372#define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */
373
374#define QDIO_FLAG_SYNC_INPUT 0x01
375#define QDIO_FLAG_SYNC_OUTPUT 0x02
376#define QDIO_FLAG_PCI_OUT 0x10
377
Jan Glauberbbd50e12008-12-25 13:38:43 +0100378extern int qdio_initialize(struct qdio_initialize *);
379extern int qdio_allocate(struct qdio_initialize *);
380extern int qdio_establish(struct qdio_initialize *);
Jan Glauber779e6e12008-07-17 17:16:48 +0200381extern int qdio_activate(struct ccw_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382
Jan Glauberbbd50e12008-12-25 13:38:43 +0100383extern int do_QDIO(struct ccw_device *cdev, unsigned int callflags,
Jan Glauber66182412009-06-22 12:08:15 +0200384 int q_nr, unsigned int bufnr, unsigned int count);
Jan Glauberbbd50e12008-12-25 13:38:43 +0100385extern int qdio_cleanup(struct ccw_device*, int);
386extern int qdio_shutdown(struct ccw_device*, int);
Jan Glauber779e6e12008-07-17 17:16:48 +0200387extern int qdio_free(struct ccw_device *);
Jan Glauberbbd50e12008-12-25 13:38:43 +0100388extern int qdio_get_ssqd_desc(struct ccw_device *dev, struct qdio_ssqd_desc*);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
390#endif /* __QDIO_H__ */