blob: cbbf7d831a331c31aba7ec615c2331c643265e20 [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
Swen Schilligdfe5bb52011-08-15 14:40:31 +020049#define QDR_AC_MULTI_BUFFER_ENABLE 0x01
50
Jan Glauber779e6e12008-07-17 17:16:48 +020051/**
52 * struct qdr - queue description record (QDR)
53 * @qfmt: queue format
54 * @pfmt: implementation dependent parameter format
55 * @ac: adapter characteristics
56 * @iqdcnt: input queue descriptor count
57 * @oqdcnt: output queue descriptor count
58 * @iqdsz: inpout queue descriptor size
59 * @oqdsz: output queue descriptor size
60 * @qiba: queue information block address
61 * @qkey: queue information block key
62 * @qdf0: queue descriptions
63 */
64struct qdr {
65 u32 qfmt : 8;
66 u32 pfmt : 8;
67 u32 : 8;
68 u32 ac : 8;
69 u32 : 8;
70 u32 iqdcnt : 8;
71 u32 : 8;
72 u32 oqdcnt : 8;
73 u32 : 8;
74 u32 iqdsz : 8;
75 u32 : 8;
76 u32 oqdsz : 8;
77 /* private: */
78 u32 res[9];
79 /* public: */
80 u64 qiba;
81 u32 : 32;
82 u32 qkey : 4;
83 u32 : 28;
84 struct qdesfmt0 qdf0[126];
85} __attribute__ ((packed, aligned(4096)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Jan Glauber779e6e12008-07-17 17:16:48 +020087#define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40
88#define QIB_RFLAGS_ENABLE_QEBSM 0x80
Christof Schmittdcc18f42010-07-16 15:37:41 +020089#define QIB_RFLAGS_ENABLE_DATA_DIV 0x02
Jan Glauber779e6e12008-07-17 17:16:48 +020090
91/**
92 * struct qib - queue information block (QIB)
93 * @qfmt: queue format
94 * @pfmt: implementation dependent parameter format
95 * @rflags: QEBSM
96 * @ac: adapter characteristics
97 * @isliba: absolute address of first input SLIB
98 * @osliba: absolute address of first output SLIB
99 * @ebcnam: adapter identifier in EBCDIC
100 * @parm: implementation dependent parameters
101 */
102struct qib {
103 u32 qfmt : 8;
104 u32 pfmt : 8;
105 u32 rflags : 8;
106 u32 ac : 8;
107 u32 : 32;
108 u64 isliba;
109 u64 osliba;
110 u32 : 32;
111 u32 : 32;
112 u8 ebcnam[8];
113 /* private: */
114 u8 res[88];
115 /* public: */
116 u8 parm[QDIO_MAX_BUFFERS_PER_Q];
117} __attribute__ ((packed, aligned(256)));
118
119/**
120 * struct slibe - storage list information block element (SLIBE)
121 * @parms: implementation dependent parameters
122 */
123struct slibe {
124 u64 parms;
125};
126
127/**
128 * struct slib - storage list information block (SLIB)
129 * @nsliba: next SLIB address (if any)
130 * @sla: SL address
131 * @slsba: SLSB address
132 * @slibe: SLIB elements
133 */
134struct slib {
135 u64 nsliba;
136 u64 sla;
137 u64 slsba;
138 /* private: */
139 u8 res[1000];
140 /* public: */
141 struct slibe slibe[QDIO_MAX_BUFFERS_PER_Q];
142} __attribute__ ((packed, aligned(2048)));
143
Jan Glauber3ec90872011-06-06 14:14:40 +0200144#define SBAL_EFLAGS_LAST_ENTRY 0x40
145#define SBAL_EFLAGS_CONTIGUOUS 0x20
146#define SBAL_EFLAGS_FIRST_FRAG 0x04
147#define SBAL_EFLAGS_MIDDLE_FRAG 0x08
148#define SBAL_EFLAGS_LAST_FRAG 0x0c
149#define SBAL_EFLAGS_MASK 0x6f
Jan Glauber779e6e12008-07-17 17:16:48 +0200150
Jan Glauber3ec90872011-06-06 14:14:40 +0200151#define SBAL_SFLAGS0_PCI_REQ 0x40
152#define SBAL_SFLAGS0_DATA_CONTINUATION 0x20
Jan Glauber779e6e12008-07-17 17:16:48 +0200153
154/* Awesome OpenFCP extensions */
Jan Glauber3ec90872011-06-06 14:14:40 +0200155#define SBAL_SFLAGS0_TYPE_STATUS 0x00
156#define SBAL_SFLAGS0_TYPE_WRITE 0x08
157#define SBAL_SFLAGS0_TYPE_READ 0x10
158#define SBAL_SFLAGS0_TYPE_WRITE_READ 0x18
159#define SBAL_SFLAGS0_MORE_SBALS 0x04
160#define SBAL_SFLAGS0_COMMAND 0x02
161#define SBAL_SFLAGS0_LAST_SBAL 0x00
162#define SBAL_SFLAGS0_ONLY_SBAL SBAL_SFLAGS0_COMMAND
163#define SBAL_SFLAGS0_MIDDLE_SBAL SBAL_SFLAGS0_MORE_SBALS
164#define SBAL_SFLAGS0_FIRST_SBAL (SBAL_SFLAGS0_MORE_SBALS | SBAL_SFLAGS0_COMMAND)
Jan Glauber779e6e12008-07-17 17:16:48 +0200165
166/**
167 * struct qdio_buffer_element - SBAL entry
Jan Glauber3ec90872011-06-06 14:14:40 +0200168 * @eflags: SBAL entry flags
169 * @scount: SBAL count
170 * @sflags: whole SBAL flags
Jan Glauber779e6e12008-07-17 17:16:48 +0200171 * @length: length
172 * @addr: address
173*/
174struct qdio_buffer_element {
Jan Glauber3ec90872011-06-06 14:14:40 +0200175 u8 eflags;
176 /* private: */
177 u8 res1;
178 /* public: */
179 u8 scount;
180 u8 sflags;
Jan Glauber779e6e12008-07-17 17:16:48 +0200181 u32 length;
182#ifdef CONFIG_32BIT
183 /* private: */
Jan Glauber3ec90872011-06-06 14:14:40 +0200184 void *res2;
Jan Glauber779e6e12008-07-17 17:16:48 +0200185 /* public: */
186#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 void *addr;
Jan Glauber779e6e12008-07-17 17:16:48 +0200188} __attribute__ ((packed, aligned(16)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
Jan Glauber779e6e12008-07-17 17:16:48 +0200190/**
191 * struct qdio_buffer - storage block address list (SBAL)
192 * @element: SBAL entries
193 */
194struct qdio_buffer {
195 struct qdio_buffer_element element[QDIO_MAX_ELEMENTS_PER_BUFFER];
196} __attribute__ ((packed, aligned(256)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Jan Glauber779e6e12008-07-17 17:16:48 +0200198/**
199 * struct sl_element - storage list entry
200 * @sbal: absolute SBAL address
201 */
202struct sl_element {
203#ifdef CONFIG_32BIT
204 /* private: */
205 unsigned long reserved;
206 /* public: */
207#endif
208 unsigned long sbal;
209} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210
Jan Glauber779e6e12008-07-17 17:16:48 +0200211/**
212 * struct sl - storage list (SL)
213 * @element: SL entries
214 */
215struct sl {
216 struct sl_element element[QDIO_MAX_BUFFERS_PER_Q];
217} __attribute__ ((packed, aligned(1024)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
Jan Glauber779e6e12008-07-17 17:16:48 +0200219/**
220 * struct slsb - storage list state block (SLSB)
221 * @val: state per buffer
222 */
223struct slsb {
224 u8 val[QDIO_MAX_BUFFERS_PER_Q];
225} __attribute__ ((packed, aligned(256)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
Swen Schilligdfe5bb52011-08-15 14:40:31 +0200227#define CHSC_AC2_MULTI_BUFFER_AVAILABLE 0x0080
228#define CHSC_AC2_MULTI_BUFFER_ENABLED 0x0040
Christof Schmittdcc18f42010-07-16 15:37:41 +0200229#define CHSC_AC2_DATA_DIV_AVAILABLE 0x0010
230#define CHSC_AC2_DATA_DIV_ENABLED 0x0002
231
Jan Glauber779e6e12008-07-17 17:16:48 +0200232struct qdio_ssqd_desc {
233 u8 flags;
234 u8:8;
235 u16 sch;
236 u8 qfmt;
237 u8 parm;
238 u8 qdioac1;
239 u8 sch_class;
240 u8 pcnt;
241 u8 icnt;
242 u8:8;
243 u8 ocnt;
244 u8:8;
245 u8 mbccnt;
246 u16 qdioac2;
247 u64 sch_token;
Klaus-Dieter Wacker7a0f4752008-10-10 21:33:18 +0200248 u8 mro;
249 u8 mri;
250 u8:8;
251 u8 sbalic;
252 u16:16;
253 u8:8;
254 u8 mmwc;
Jan Glauber779e6e12008-07-17 17:16:48 +0200255} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
Jan Glauber779e6e12008-07-17 17:16:48 +0200257/* params are: ccw_device, qdio_error, queue_number,
258 first element processed, number of elements processed, int_parm */
259typedef void qdio_handler_t(struct ccw_device *, unsigned int, int,
260 int, int, unsigned long);
261
262/* qdio errors reported to the upper-layer program */
Jan Glauberd303b6f2009-03-26 15:24:31 +0100263#define QDIO_ERROR_SIGA_TARGET 0x02
Jan Glauber779e6e12008-07-17 17:16:48 +0200264#define QDIO_ERROR_SIGA_ACCESS_EXCEPTION 0x10
265#define QDIO_ERROR_SIGA_BUSY 0x20
266#define QDIO_ERROR_ACTIVATE_CHECK_CONDITION 0x40
267#define QDIO_ERROR_SLSB_STATE 0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269/* for qdio_cleanup */
Jan Glauber779e6e12008-07-17 17:16:48 +0200270#define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01
271#define QDIO_FLAG_CLEANUP_USING_HALT 0x02
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Jan Glauber779e6e12008-07-17 17:16:48 +0200273/**
274 * struct qdio_initialize - qdio initalization data
275 * @cdev: associated ccw device
276 * @q_format: queue format
277 * @adapter_name: name for the adapter
278 * @qib_param_field_format: format for qib_parm_field
279 * @qib_param_field: pointer to 128 bytes or NULL, if no param field
Christof Schmittdcc18f42010-07-16 15:37:41 +0200280 * @qib_rflags: rflags to set
Jan Glauber779e6e12008-07-17 17:16:48 +0200281 * @input_slib_elements: pointer to no_input_qs * 128 words of data or NULL
282 * @output_slib_elements: pointer to no_output_qs * 128 words of data or NULL
283 * @no_input_qs: number of input queues
284 * @no_output_qs: number of output queues
285 * @input_handler: handler to be called for input queues
286 * @output_handler: handler to be called for output queues
287 * @int_parm: interruption parameter
Jan Glauber779e6e12008-07-17 17:16:48 +0200288 * @input_sbal_addr_array: address of no_input_qs * 128 pointers
289 * @output_sbal_addr_array: address of no_output_qs * 128 pointers
290 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291struct qdio_initialize {
292 struct ccw_device *cdev;
293 unsigned char q_format;
Swen Schilligdfe5bb52011-08-15 14:40:31 +0200294 unsigned char qdr_ac;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 unsigned char adapter_name[8];
Jan Glauber779e6e12008-07-17 17:16:48 +0200296 unsigned int qib_param_field_format;
297 unsigned char *qib_param_field;
Christof Schmittdcc18f42010-07-16 15:37:41 +0200298 unsigned char qib_rflags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 unsigned long *input_slib_elements;
300 unsigned long *output_slib_elements;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 unsigned int no_input_qs;
302 unsigned int no_output_qs;
303 qdio_handler_t *input_handler;
304 qdio_handler_t *output_handler;
Jan Glauberd36deae2010-09-07 21:14:39 +0000305 void (*queue_start_poll) (struct ccw_device *, int, unsigned long);
Jan Glauber3d6c76f2011-01-05 12:47:50 +0100306 int scan_threshold;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 unsigned long int_parm;
Jan Glauber779e6e12008-07-17 17:16:48 +0200308 void **input_sbal_addr_array;
309 void **output_sbal_addr_array;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310};
311
Jan Glauber779e6e12008-07-17 17:16:48 +0200312#define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */
313#define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_establish */
314#define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */
315#define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */
316
317#define QDIO_FLAG_SYNC_INPUT 0x01
318#define QDIO_FLAG_SYNC_OUTPUT 0x02
319#define QDIO_FLAG_PCI_OUT 0x10
320
Jan Glauberbbd50e12008-12-25 13:38:43 +0100321extern int qdio_allocate(struct qdio_initialize *);
322extern int qdio_establish(struct qdio_initialize *);
Jan Glauber779e6e12008-07-17 17:16:48 +0200323extern int qdio_activate(struct ccw_device *);
Jan Glauberd36deae2010-09-07 21:14:39 +0000324extern int do_QDIO(struct ccw_device *, unsigned int, int, unsigned int,
325 unsigned int);
326extern int qdio_start_irq(struct ccw_device *, int);
327extern int qdio_stop_irq(struct ccw_device *, int);
328extern int qdio_get_next_buffers(struct ccw_device *, int, int *, int *);
329extern int qdio_shutdown(struct ccw_device *, int);
Jan Glauber779e6e12008-07-17 17:16:48 +0200330extern int qdio_free(struct ccw_device *);
Jan Glauberd36deae2010-09-07 21:14:39 +0000331extern int qdio_get_ssqd_desc(struct ccw_device *, struct qdio_ssqd_desc *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
333#endif /* __QDIO_H__ */