blob: 49bb9e371c327e50266ebd4caf42662fd3b54d03 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _CIO_QDIO_H
2#define _CIO_QDIO_H
3
Peter Oberparleiter0b642ed2005-05-01 08:58:58 -07004#include <asm/page.h>
5
Cornelia Hucka8237fc2006-01-06 00:19:21 -08006#include "schid.h"
7
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#ifdef CONFIG_QDIO_DEBUG
9#define QDIO_VERBOSE_LEVEL 9
10#else /* CONFIG_QDIO_DEBUG */
11#define QDIO_VERBOSE_LEVEL 5
12#endif /* CONFIG_QDIO_DEBUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#define QDIO_USE_PROCESSING_STATE
14
15#ifdef CONFIG_QDIO_PERF_STATS
16#define QDIO_PERFORMANCE_STATS
17#endif /* CONFIG_QDIO_PERF_STATS */
18
19#define QDIO_MINIMAL_BH_RELIEF_TIME 16
20#define QDIO_TIMER_POLL_VALUE 1
21#define IQDIO_TIMER_POLL_VALUE 1
22
23/*
24 * unfortunately this can't be (QDIO_MAX_BUFFERS_PER_Q*4/3) or so -- as
25 * we never know, whether we'll get initiative again, e.g. to give the
26 * transmit skb's back to the stack, however the stack may be waiting for
27 * them... therefore we define 4 as threshold to start polling (which
28 * will stop as soon as the asynchronous queue catches up)
29 * btw, this only applies to the asynchronous HiperSockets queue
30 */
31#define IQDIO_FILL_LEVEL_TO_POLL 4
32
33#define TIQDIO_THININT_ISC 3
34#define TIQDIO_DELAY_TARGET 0
35#define QDIO_BUSY_BIT_PATIENCE 100 /* in microsecs */
36#define QDIO_BUSY_BIT_GIVE_UP 10000000 /* 10 seconds */
37#define IQDIO_GLOBAL_LAPS 2 /* GLOBAL_LAPS are not used as we */
38#define IQDIO_GLOBAL_LAPS_INT 1 /* don't global summary */
39#define IQDIO_LOCAL_LAPS 4
40#define IQDIO_LOCAL_LAPS_INT 1
41#define IQDIO_GLOBAL_SUMMARY_CC_MASK 2
42/*#define IQDIO_IQDC_INT_PARM 0x1234*/
43
44#define QDIO_Q_LAPS 5
45
Peter Oberparleiter0b642ed2005-05-01 08:58:58 -070046#define QDIO_STORAGE_KEY PAGE_DEFAULT_KEY
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48#define L2_CACHELINE_SIZE 256
49#define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32))
50
51#define QDIO_PERF "qdio_perf"
52
53/* must be a power of 2 */
54/*#define QDIO_STATS_NUMBER 4
55
56#define QDIO_STATS_CLASSES 2
57#define QDIO_STATS_COUNT_NEEDED 2*/
58
59#define QDIO_NO_USE_COUNT_TIMEOUT (1*HZ) /* wait for 1 sec on each q before
60 exiting without having use_count
61 of the queue to 0 */
62
63#define QDIO_ESTABLISH_TIMEOUT (1*HZ)
64#define QDIO_ACTIVATE_TIMEOUT ((5*HZ)>>10)
65#define QDIO_CLEANUP_CLEAR_TIMEOUT (20*HZ)
66#define QDIO_CLEANUP_HALT_TIMEOUT (10*HZ)
67
68enum qdio_irq_states {
69 QDIO_IRQ_STATE_INACTIVE,
70 QDIO_IRQ_STATE_ESTABLISHED,
71 QDIO_IRQ_STATE_ACTIVE,
72 QDIO_IRQ_STATE_STOPPED,
73 QDIO_IRQ_STATE_CLEANUP,
74 QDIO_IRQ_STATE_ERR,
75 NR_QDIO_IRQ_STATES,
76};
77
78/* used as intparm in do_IO: */
79#define QDIO_DOING_SENSEID 0
80#define QDIO_DOING_ESTABLISH 1
81#define QDIO_DOING_ACTIVATE 2
82#define QDIO_DOING_CLEANUP 3
83
84/************************* DEBUG FACILITY STUFF *********************/
85
86#define QDIO_DBF_HEX(ex,name,level,addr,len) \
87 do { \
88 if (ex) \
89 debug_exception(qdio_dbf_##name,level,(void*)(addr),len); \
90 else \
91 debug_event(qdio_dbf_##name,level,(void*)(addr),len); \
92 } while (0)
93#define QDIO_DBF_TEXT(ex,name,level,text) \
94 do { \
95 if (ex) \
96 debug_text_exception(qdio_dbf_##name,level,text); \
97 else \
98 debug_text_event(qdio_dbf_##name,level,text); \
99 } while (0)
100
101
102#define QDIO_DBF_HEX0(ex,name,addr,len) QDIO_DBF_HEX(ex,name,0,addr,len)
103#define QDIO_DBF_HEX1(ex,name,addr,len) QDIO_DBF_HEX(ex,name,1,addr,len)
104#define QDIO_DBF_HEX2(ex,name,addr,len) QDIO_DBF_HEX(ex,name,2,addr,len)
105#ifdef CONFIG_QDIO_DEBUG
106#define QDIO_DBF_HEX3(ex,name,addr,len) QDIO_DBF_HEX(ex,name,3,addr,len)
107#define QDIO_DBF_HEX4(ex,name,addr,len) QDIO_DBF_HEX(ex,name,4,addr,len)
108#define QDIO_DBF_HEX5(ex,name,addr,len) QDIO_DBF_HEX(ex,name,5,addr,len)
109#define QDIO_DBF_HEX6(ex,name,addr,len) QDIO_DBF_HEX(ex,name,6,addr,len)
110#else /* CONFIG_QDIO_DEBUG */
111#define QDIO_DBF_HEX3(ex,name,addr,len) do {} while (0)
112#define QDIO_DBF_HEX4(ex,name,addr,len) do {} while (0)
113#define QDIO_DBF_HEX5(ex,name,addr,len) do {} while (0)
114#define QDIO_DBF_HEX6(ex,name,addr,len) do {} while (0)
115#endif /* CONFIG_QDIO_DEBUG */
116
117#define QDIO_DBF_TEXT0(ex,name,text) QDIO_DBF_TEXT(ex,name,0,text)
118#define QDIO_DBF_TEXT1(ex,name,text) QDIO_DBF_TEXT(ex,name,1,text)
119#define QDIO_DBF_TEXT2(ex,name,text) QDIO_DBF_TEXT(ex,name,2,text)
120#ifdef CONFIG_QDIO_DEBUG
121#define QDIO_DBF_TEXT3(ex,name,text) QDIO_DBF_TEXT(ex,name,3,text)
122#define QDIO_DBF_TEXT4(ex,name,text) QDIO_DBF_TEXT(ex,name,4,text)
123#define QDIO_DBF_TEXT5(ex,name,text) QDIO_DBF_TEXT(ex,name,5,text)
124#define QDIO_DBF_TEXT6(ex,name,text) QDIO_DBF_TEXT(ex,name,6,text)
125#else /* CONFIG_QDIO_DEBUG */
126#define QDIO_DBF_TEXT3(ex,name,text) do {} while (0)
127#define QDIO_DBF_TEXT4(ex,name,text) do {} while (0)
128#define QDIO_DBF_TEXT5(ex,name,text) do {} while (0)
129#define QDIO_DBF_TEXT6(ex,name,text) do {} while (0)
130#endif /* CONFIG_QDIO_DEBUG */
131
132#define QDIO_DBF_SETUP_NAME "qdio_setup"
133#define QDIO_DBF_SETUP_LEN 8
Michael Holzheu66a464d2005-06-25 14:55:33 -0700134#define QDIO_DBF_SETUP_PAGES 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#define QDIO_DBF_SETUP_NR_AREAS 1
136#ifdef CONFIG_QDIO_DEBUG
137#define QDIO_DBF_SETUP_LEVEL 6
138#else /* CONFIG_QDIO_DEBUG */
139#define QDIO_DBF_SETUP_LEVEL 2
140#endif /* CONFIG_QDIO_DEBUG */
141
142#define QDIO_DBF_SBAL_NAME "qdio_labs" /* sbal */
143#define QDIO_DBF_SBAL_LEN 256
Michael Holzheu66a464d2005-06-25 14:55:33 -0700144#define QDIO_DBF_SBAL_PAGES 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145#define QDIO_DBF_SBAL_NR_AREAS 2
146#ifdef CONFIG_QDIO_DEBUG
147#define QDIO_DBF_SBAL_LEVEL 6
148#else /* CONFIG_QDIO_DEBUG */
149#define QDIO_DBF_SBAL_LEVEL 2
150#endif /* CONFIG_QDIO_DEBUG */
151
152#define QDIO_DBF_TRACE_NAME "qdio_trace"
153#define QDIO_DBF_TRACE_LEN 8
154#define QDIO_DBF_TRACE_NR_AREAS 2
155#ifdef CONFIG_QDIO_DEBUG
Michael Holzheu66a464d2005-06-25 14:55:33 -0700156#define QDIO_DBF_TRACE_PAGES 16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#define QDIO_DBF_TRACE_LEVEL 4 /* -------- could be even more verbose here */
158#else /* CONFIG_QDIO_DEBUG */
Michael Holzheu66a464d2005-06-25 14:55:33 -0700159#define QDIO_DBF_TRACE_PAGES 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160#define QDIO_DBF_TRACE_LEVEL 2
161#endif /* CONFIG_QDIO_DEBUG */
162
163#define QDIO_DBF_SENSE_NAME "qdio_sense"
164#define QDIO_DBF_SENSE_LEN 64
Michael Holzheu66a464d2005-06-25 14:55:33 -0700165#define QDIO_DBF_SENSE_PAGES 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166#define QDIO_DBF_SENSE_NR_AREAS 1
167#ifdef CONFIG_QDIO_DEBUG
168#define QDIO_DBF_SENSE_LEVEL 6
169#else /* CONFIG_QDIO_DEBUG */
170#define QDIO_DBF_SENSE_LEVEL 2
171#endif /* CONFIG_QDIO_DEBUG */
172
173#ifdef CONFIG_QDIO_DEBUG
174#define QDIO_TRACE_QTYPE QDIO_ZFCP_QFMT
175
176#define QDIO_DBF_SLSB_OUT_NAME "qdio_slsb_out"
177#define QDIO_DBF_SLSB_OUT_LEN QDIO_MAX_BUFFERS_PER_Q
Michael Holzheu66a464d2005-06-25 14:55:33 -0700178#define QDIO_DBF_SLSB_OUT_PAGES 256
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179#define QDIO_DBF_SLSB_OUT_NR_AREAS 1
180#define QDIO_DBF_SLSB_OUT_LEVEL 6
181
182#define QDIO_DBF_SLSB_IN_NAME "qdio_slsb_in"
183#define QDIO_DBF_SLSB_IN_LEN QDIO_MAX_BUFFERS_PER_Q
Michael Holzheu66a464d2005-06-25 14:55:33 -0700184#define QDIO_DBF_SLSB_IN_PAGES 256
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185#define QDIO_DBF_SLSB_IN_NR_AREAS 1
186#define QDIO_DBF_SLSB_IN_LEVEL 6
187#endif /* CONFIG_QDIO_DEBUG */
188
189#define QDIO_PRINTK_HEADER QDIO_NAME ": "
190
191#if QDIO_VERBOSE_LEVEL>8
192#define QDIO_PRINT_STUPID(x...) printk( KERN_DEBUG QDIO_PRINTK_HEADER x)
193#else
Heiko Carstens39b083f2006-09-20 15:58:51 +0200194#define QDIO_PRINT_STUPID(x...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195#endif
196
197#if QDIO_VERBOSE_LEVEL>7
198#define QDIO_PRINT_ALL(x...) printk( QDIO_PRINTK_HEADER x)
199#else
Heiko Carstens39b083f2006-09-20 15:58:51 +0200200#define QDIO_PRINT_ALL(x...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201#endif
202
203#if QDIO_VERBOSE_LEVEL>6
204#define QDIO_PRINT_INFO(x...) printk( QDIO_PRINTK_HEADER x)
205#else
Heiko Carstens39b083f2006-09-20 15:58:51 +0200206#define QDIO_PRINT_INFO(x...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207#endif
208
209#if QDIO_VERBOSE_LEVEL>5
210#define QDIO_PRINT_WARN(x...) printk( QDIO_PRINTK_HEADER x)
211#else
Heiko Carstens39b083f2006-09-20 15:58:51 +0200212#define QDIO_PRINT_WARN(x...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213#endif
214
215#if QDIO_VERBOSE_LEVEL>4
216#define QDIO_PRINT_ERR(x...) printk( QDIO_PRINTK_HEADER x)
217#else
Heiko Carstens39b083f2006-09-20 15:58:51 +0200218#define QDIO_PRINT_ERR(x...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219#endif
220
221#if QDIO_VERBOSE_LEVEL>3
222#define QDIO_PRINT_CRIT(x...) printk( QDIO_PRINTK_HEADER x)
223#else
Heiko Carstens39b083f2006-09-20 15:58:51 +0200224#define QDIO_PRINT_CRIT(x...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225#endif
226
227#if QDIO_VERBOSE_LEVEL>2
228#define QDIO_PRINT_ALERT(x...) printk( QDIO_PRINTK_HEADER x)
229#else
Heiko Carstens39b083f2006-09-20 15:58:51 +0200230#define QDIO_PRINT_ALERT(x...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231#endif
232
233#if QDIO_VERBOSE_LEVEL>1
234#define QDIO_PRINT_EMERG(x...) printk( QDIO_PRINTK_HEADER x)
235#else
Heiko Carstens39b083f2006-09-20 15:58:51 +0200236#define QDIO_PRINT_EMERG(x...) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237#endif
238
239#define HEXDUMP16(importance,header,ptr) \
240QDIO_PRINT_##importance(header "%02x %02x %02x %02x " \
241 "%02x %02x %02x %02x %02x %02x %02x %02x " \
242 "%02x %02x %02x %02x\n",*(((char*)ptr)), \
243 *(((char*)ptr)+1),*(((char*)ptr)+2), \
244 *(((char*)ptr)+3),*(((char*)ptr)+4), \
245 *(((char*)ptr)+5),*(((char*)ptr)+6), \
246 *(((char*)ptr)+7),*(((char*)ptr)+8), \
247 *(((char*)ptr)+9),*(((char*)ptr)+10), \
248 *(((char*)ptr)+11),*(((char*)ptr)+12), \
249 *(((char*)ptr)+13),*(((char*)ptr)+14), \
250 *(((char*)ptr)+15)); \
251QDIO_PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
252 "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
253 *(((char*)ptr)+16),*(((char*)ptr)+17), \
254 *(((char*)ptr)+18),*(((char*)ptr)+19), \
255 *(((char*)ptr)+20),*(((char*)ptr)+21), \
256 *(((char*)ptr)+22),*(((char*)ptr)+23), \
257 *(((char*)ptr)+24),*(((char*)ptr)+25), \
258 *(((char*)ptr)+26),*(((char*)ptr)+27), \
259 *(((char*)ptr)+28),*(((char*)ptr)+29), \
260 *(((char*)ptr)+30),*(((char*)ptr)+31));
261
262/****************** END OF DEBUG FACILITY STUFF *********************/
263
264/*
265 * Some instructions as assembly
266 */
Frank Pavlic8129ee12006-01-06 00:19:20 -0800267
268static inline int
269do_sqbs(unsigned long sch, unsigned char state, int queue,
270 unsigned int *start, unsigned int *count)
271{
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800272#ifdef CONFIG_64BIT
Frank Pavlic8129ee12006-01-06 00:19:20 -0800273 register unsigned long _ccq asm ("0") = *count;
274 register unsigned long _sch asm ("1") = sch;
275 unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
276
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200277 asm volatile(
278 " .insn rsy,0xeb000000008A,%1,0,0(%2)"
279 : "+d" (_ccq), "+d" (_queuestart)
280 : "d" ((unsigned long)state), "d" (_sch)
281 : "memory", "cc");
Frank Pavlic8129ee12006-01-06 00:19:20 -0800282 *count = _ccq & 0xff;
283 *start = _queuestart & 0xff;
284
285 return (_ccq >> 32) & 0xff;
286#else
287 return 0;
288#endif
289}
290
291static inline int
292do_eqbs(unsigned long sch, unsigned char *state, int queue,
293 unsigned int *start, unsigned int *count)
294{
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800295#ifdef CONFIG_64BIT
Frank Pavlic8129ee12006-01-06 00:19:20 -0800296 register unsigned long _ccq asm ("0") = *count;
297 register unsigned long _sch asm ("1") = sch;
298 unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
299 unsigned long _state = 0;
300
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200301 asm volatile(
302 " .insn rrf,0xB99c0000,%1,%2,0,0"
303 : "+d" (_ccq), "+d" (_queuestart), "+d" (_state)
304 : "d" (_sch)
305 : "memory", "cc" );
Frank Pavlic8129ee12006-01-06 00:19:20 -0800306 *count = _ccq & 0xff;
307 *start = _queuestart & 0xff;
308 *state = _state & 0xff;
309
310 return (_ccq >> 32) & 0xff;
311#else
312 return 0;
313#endif
314}
315
316
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800317static inline int
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800318do_siga_sync(struct subchannel_id schid, unsigned int mask1, unsigned int mask2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200320 register unsigned long reg0 asm ("0") = 2;
321 register struct subchannel_id reg1 asm ("1") = schid;
322 register unsigned long reg2 asm ("2") = mask1;
323 register unsigned long reg3 asm ("3") = mask2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 int cc;
325
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200326 asm volatile(
327 " siga 0\n"
328 " ipm %0\n"
329 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 : "=d" (cc)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200331 : "d" (reg0), "d" (reg1), "d" (reg2), "d" (reg3) : "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 return cc;
333}
334
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800335static inline int
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800336do_siga_input(struct subchannel_id schid, unsigned int mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200338 register unsigned long reg0 asm ("0") = 1;
339 register struct subchannel_id reg1 asm ("1") = schid;
340 register unsigned long reg2 asm ("2") = mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 int cc;
342
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200343 asm volatile(
344 " siga 0\n"
345 " ipm %0\n"
346 " srl %0,28\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 : "=d" (cc)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200348 : "d" (reg0), "d" (reg1), "d" (reg2) : "cc", "memory");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 return cc;
350}
351
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800352static inline int
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800353do_siga_output(unsigned long schid, unsigned long mask, __u32 *bb,
Frank Pavlic8129ee12006-01-06 00:19:20 -0800354 unsigned int fc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200356 register unsigned long __fc asm("0") = fc;
357 register unsigned long __schid asm("1") = schid;
358 register unsigned long __mask asm("2") = mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 int cc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200361 asm volatile(
362 " siga 0\n"
363 "0: ipm %0\n"
364 " srl %0,28\n"
365 "1:\n"
366 EX_TABLE(0b,1b)
367 : "=d" (cc), "+d" (__fc), "+d" (__schid), "+d" (__mask)
368 : "0" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION)
369 : "cc", "memory");
370 (*bb) = ((unsigned int) __fc) >> 31;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 return cc;
372}
373
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800374static inline unsigned long
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375do_clear_global_summary(void)
376{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200377 register unsigned long __fn asm("1") = 3;
378 register unsigned long __tmp asm("2");
379 register unsigned long __time asm("3");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200381 asm volatile(
382 " .insn rre,0xb2650000,2,0"
383 : "+d" (__fn), "=d" (__tmp), "=d" (__time));
384 return __time;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385}
386
387/*
388 * QDIO device commands returned by extended Sense-ID
389 */
390#define DEFAULT_ESTABLISH_QS_CMD 0x1b
391#define DEFAULT_ESTABLISH_QS_COUNT 0x1000
392#define DEFAULT_ACTIVATE_QS_CMD 0x1f
393#define DEFAULT_ACTIVATE_QS_COUNT 0
394
395/*
396 * additional CIWs returned by extended Sense-ID
397 */
398#define CIW_TYPE_EQUEUE 0x3 /* establish QDIO queues */
399#define CIW_TYPE_AQUEUE 0x4 /* activate QDIO queues */
400
401#define QDIO_CHSC_RESPONSE_CODE_OK 1
402/* flags for st qdio sch data */
403#define CHSC_FLAG_QDIO_CAPABILITY 0x80
404#define CHSC_FLAG_VALIDITY 0x40
405
406#define CHSC_FLAG_SIGA_INPUT_NECESSARY 0x40
407#define CHSC_FLAG_SIGA_OUTPUT_NECESSARY 0x20
408#define CHSC_FLAG_SIGA_SYNC_NECESSARY 0x10
409#define CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS 0x08
410#define CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS 0x04
411
412#ifdef QDIO_PERFORMANCE_STATS
413struct qdio_perf_stats {
414 unsigned int tl_runs;
415
416 unsigned int siga_outs;
417 unsigned int siga_ins;
418 unsigned int siga_syncs;
419 unsigned int pcis;
420 unsigned int thinints;
421 unsigned int fast_reqs;
422
423 __u64 start_time_outbound;
424 unsigned int outbound_cnt;
425 unsigned int outbound_time;
426 __u64 start_time_inbound;
427 unsigned int inbound_cnt;
428 unsigned int inbound_time;
429};
430#endif /* QDIO_PERFORMANCE_STATS */
431
432#define atomic_swap(a,b) xchg((int*)a.counter,b)
433
434/* unlikely as the later the better */
435#define SYNC_MEMORY if (unlikely(q->siga_sync)) qdio_siga_sync_q(q)
436#define SYNC_MEMORY_ALL if (unlikely(q->siga_sync)) \
437 qdio_siga_sync(q,~0U,~0U)
438#define SYNC_MEMORY_ALL_OUTB if (unlikely(q->siga_sync)) \
439 qdio_siga_sync(q,~0U,0)
440
441#define NOW qdio_get_micros()
442#define SAVE_TIMESTAMP(q) q->timing.last_transfer_time=NOW
443#define GET_SAVED_TIMESTAMP(q) (q->timing.last_transfer_time)
444#define SAVE_FRONTIER(q,val) q->last_move_ftc=val
445#define GET_SAVED_FRONTIER(q) (q->last_move_ftc)
446
447#define MY_MODULE_STRING(x) #x
448
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800449#ifdef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450#define QDIO_GET_ADDR(x) ((__u32)(unsigned long)x)
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800451#else /* CONFIG_64BIT */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452#define QDIO_GET_ADDR(x) ((__u32)(long)x)
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800453#endif /* CONFIG_64BIT */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455struct qdio_q {
456 volatile struct slsb slsb;
457
458 char unused[QDIO_MAX_BUFFERS_PER_Q];
459
Frank Pavlic8129ee12006-01-06 00:19:20 -0800460 __u32 * dev_st_chg_ind;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461
462 int is_input_q;
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800463 struct subchannel_id schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 struct ccw_device *cdev;
465
466 unsigned int is_iqdio_q;
467 unsigned int is_thinint_q;
468
469 /* bit 0 means queue 0, bit 1 means queue 1, ... */
470 unsigned int mask;
471 unsigned int q_no;
472
473 qdio_handler_t (*handler);
474
475 /* points to the next buffer to be checked for having
476 * been processed by the card (outbound)
477 * or to the next buffer the program should check for (inbound) */
478 volatile int first_to_check;
479 /* and the last time it was: */
480 volatile int last_move_ftc;
481
482 atomic_t number_of_buffers_used;
483 atomic_t polling;
484
485 unsigned int siga_in;
486 unsigned int siga_out;
487 unsigned int siga_sync;
488 unsigned int siga_sync_done_on_thinints;
489 unsigned int siga_sync_done_on_outb_tis;
490 unsigned int hydra_gives_outbound_pcis;
491
492 /* used to save beginning position when calling dd_handlers */
493 int first_element_to_kick;
494
495 atomic_t use_count;
496 atomic_t is_in_shutdown;
497
498 void *irq_ptr;
499
500#ifdef QDIO_USE_TIMERS_FOR_POLLING
501 struct timer_list timer;
502 atomic_t timer_already_set;
503 spinlock_t timer_lock;
504#else /* QDIO_USE_TIMERS_FOR_POLLING */
505 struct tasklet_struct tasklet;
506#endif /* QDIO_USE_TIMERS_FOR_POLLING */
507
Frank Pavlic8129ee12006-01-06 00:19:20 -0800508
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 enum qdio_irq_states state;
510
511 /* used to store the error condition during a data transfer */
512 unsigned int qdio_error;
513 unsigned int siga_error;
514 unsigned int error_status_flags;
515
516 /* list of interesting queues */
517 volatile struct qdio_q *list_next;
518 volatile struct qdio_q *list_prev;
519
520 struct sl *sl;
521 volatile struct sbal *sbal[QDIO_MAX_BUFFERS_PER_Q];
522
523 struct qdio_buffer *qdio_buffers[QDIO_MAX_BUFFERS_PER_Q];
524
525 unsigned long int_parm;
526
527 /*struct {
528 int in_bh_check_limit;
529 int threshold;
530 } threshold_classes[QDIO_STATS_CLASSES];*/
531
532 struct {
533 /* inbound: the time to stop polling
534 outbound: the time to kick peer */
535 int threshold; /* the real value */
536
537 /* outbound: last time of do_QDIO
538 inbound: last time of noticing incoming data */
539 /*__u64 last_transfer_times[QDIO_STATS_NUMBER];
540 int last_transfer_index; */
541
542 __u64 last_transfer_time;
543 __u64 busy_start;
544 } timing;
545 atomic_t busy_siga_counter;
546 unsigned int queue_type;
547
548 /* leave this member at the end. won't be cleared in qdio_fill_qs */
549 struct slib *slib; /* a page is allocated under this pointer,
550 sl points into this page, offset PAGE_SIZE/2
551 (after slib) */
552} __attribute__ ((aligned(256)));
553
554struct qdio_irq {
555 __u32 * volatile dev_st_chg_ind;
556
557 unsigned long int_parm;
Cornelia Hucka8237fc2006-01-06 00:19:21 -0800558 struct subchannel_id schid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559
560 unsigned int is_iqdio_irq;
561 unsigned int is_thinint_irq;
562 unsigned int hydra_gives_outbound_pcis;
563 unsigned int sync_done_on_outb_pcis;
564
Frank Pavlic8129ee12006-01-06 00:19:20 -0800565 /* QEBSM facility */
566 unsigned int is_qebsm;
567 unsigned long sch_token;
568
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 enum qdio_irq_states state;
570
571 unsigned int no_input_qs;
572 unsigned int no_output_qs;
573
574 unsigned char qdioac;
575
576 struct ccw1 ccw;
577
578 struct ciw equeue;
579 struct ciw aqueue;
580
581 struct qib qib;
582
583 void (*original_int_handler) (struct ccw_device *,
584 unsigned long, struct irb *);
585
586 /* leave these four members together at the end. won't be cleared in qdio_fill_irq */
587 struct qdr *qdr;
588 struct qdio_q *input_qs[QDIO_MAX_QUEUES_PER_IRQ];
589 struct qdio_q *output_qs[QDIO_MAX_QUEUES_PER_IRQ];
590 struct semaphore setting_up_sema;
591};
592#endif