Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _CIO_QDIO_H |
| 2 | #define _CIO_QDIO_H |
| 3 | |
Peter Oberparleiter | 0b642ed | 2005-05-01 08:58:58 -0700 | [diff] [blame] | 4 | #include <asm/page.h> |
| 5 | |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 6 | #include "schid.h" |
| 7 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #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 Oberparleiter | 0b642ed | 2005-05-01 08:58:58 -0700 | [diff] [blame] | 46 | #define QDIO_STORAGE_KEY PAGE_DEFAULT_KEY |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 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 | |
| 68 | enum 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 Holzheu | 66a464d | 2005-06-25 14:55:33 -0700 | [diff] [blame] | 134 | #define QDIO_DBF_SETUP_PAGES 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | #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 Holzheu | 66a464d | 2005-06-25 14:55:33 -0700 | [diff] [blame] | 144 | #define QDIO_DBF_SBAL_PAGES 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | #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 Holzheu | 66a464d | 2005-06-25 14:55:33 -0700 | [diff] [blame] | 156 | #define QDIO_DBF_TRACE_PAGES 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | #define QDIO_DBF_TRACE_LEVEL 4 /* -------- could be even more verbose here */ |
| 158 | #else /* CONFIG_QDIO_DEBUG */ |
Michael Holzheu | 66a464d | 2005-06-25 14:55:33 -0700 | [diff] [blame] | 159 | #define QDIO_DBF_TRACE_PAGES 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | #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 Holzheu | 66a464d | 2005-06-25 14:55:33 -0700 | [diff] [blame] | 165 | #define QDIO_DBF_SENSE_PAGES 2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | #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 Holzheu | 66a464d | 2005-06-25 14:55:33 -0700 | [diff] [blame] | 178 | #define QDIO_DBF_SLSB_OUT_PAGES 256 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | #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 Holzheu | 66a464d | 2005-06-25 14:55:33 -0700 | [diff] [blame] | 184 | #define QDIO_DBF_SLSB_IN_PAGES 256 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | #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 Carstens | 39b083f | 2006-09-20 15:58:51 +0200 | [diff] [blame] | 194 | #define QDIO_PRINT_STUPID(x...) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | #endif |
| 196 | |
| 197 | #if QDIO_VERBOSE_LEVEL>7 |
| 198 | #define QDIO_PRINT_ALL(x...) printk( QDIO_PRINTK_HEADER x) |
| 199 | #else |
Heiko Carstens | 39b083f | 2006-09-20 15:58:51 +0200 | [diff] [blame] | 200 | #define QDIO_PRINT_ALL(x...) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | #endif |
| 202 | |
| 203 | #if QDIO_VERBOSE_LEVEL>6 |
| 204 | #define QDIO_PRINT_INFO(x...) printk( QDIO_PRINTK_HEADER x) |
| 205 | #else |
Heiko Carstens | 39b083f | 2006-09-20 15:58:51 +0200 | [diff] [blame] | 206 | #define QDIO_PRINT_INFO(x...) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | #endif |
| 208 | |
| 209 | #if QDIO_VERBOSE_LEVEL>5 |
| 210 | #define QDIO_PRINT_WARN(x...) printk( QDIO_PRINTK_HEADER x) |
| 211 | #else |
Heiko Carstens | 39b083f | 2006-09-20 15:58:51 +0200 | [diff] [blame] | 212 | #define QDIO_PRINT_WARN(x...) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | #endif |
| 214 | |
| 215 | #if QDIO_VERBOSE_LEVEL>4 |
| 216 | #define QDIO_PRINT_ERR(x...) printk( QDIO_PRINTK_HEADER x) |
| 217 | #else |
Heiko Carstens | 39b083f | 2006-09-20 15:58:51 +0200 | [diff] [blame] | 218 | #define QDIO_PRINT_ERR(x...) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | #endif |
| 220 | |
| 221 | #if QDIO_VERBOSE_LEVEL>3 |
| 222 | #define QDIO_PRINT_CRIT(x...) printk( QDIO_PRINTK_HEADER x) |
| 223 | #else |
Heiko Carstens | 39b083f | 2006-09-20 15:58:51 +0200 | [diff] [blame] | 224 | #define QDIO_PRINT_CRIT(x...) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | #endif |
| 226 | |
| 227 | #if QDIO_VERBOSE_LEVEL>2 |
| 228 | #define QDIO_PRINT_ALERT(x...) printk( QDIO_PRINTK_HEADER x) |
| 229 | #else |
Heiko Carstens | 39b083f | 2006-09-20 15:58:51 +0200 | [diff] [blame] | 230 | #define QDIO_PRINT_ALERT(x...) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | #endif |
| 232 | |
| 233 | #if QDIO_VERBOSE_LEVEL>1 |
| 234 | #define QDIO_PRINT_EMERG(x...) printk( QDIO_PRINTK_HEADER x) |
| 235 | #else |
Heiko Carstens | 39b083f | 2006-09-20 15:58:51 +0200 | [diff] [blame] | 236 | #define QDIO_PRINT_EMERG(x...) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | #endif |
| 238 | |
| 239 | #define HEXDUMP16(importance,header,ptr) \ |
| 240 | QDIO_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)); \ |
| 251 | QDIO_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 Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 267 | |
| 268 | static inline int |
| 269 | do_sqbs(unsigned long sch, unsigned char state, int queue, |
| 270 | unsigned int *start, unsigned int *count) |
| 271 | { |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 272 | #ifdef CONFIG_64BIT |
Frank Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 273 | 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 Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 277 | 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 Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 282 | *count = _ccq & 0xff; |
| 283 | *start = _queuestart & 0xff; |
| 284 | |
| 285 | return (_ccq >> 32) & 0xff; |
| 286 | #else |
| 287 | return 0; |
| 288 | #endif |
| 289 | } |
| 290 | |
| 291 | static inline int |
| 292 | do_eqbs(unsigned long sch, unsigned char *state, int queue, |
| 293 | unsigned int *start, unsigned int *count) |
| 294 | { |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 295 | #ifdef CONFIG_64BIT |
Frank Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 296 | 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 Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 301 | asm volatile( |
| 302 | " .insn rrf,0xB99c0000,%1,%2,0,0" |
| 303 | : "+d" (_ccq), "+d" (_queuestart), "+d" (_state) |
| 304 | : "d" (_sch) |
| 305 | : "memory", "cc" ); |
Frank Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 306 | *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 Bunk | 4448aaf | 2005-11-08 21:34:42 -0800 | [diff] [blame] | 317 | static inline int |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 318 | do_siga_sync(struct subchannel_id schid, unsigned int mask1, unsigned int mask2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 320 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | int cc; |
| 325 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 326 | asm volatile( |
| 327 | " siga 0\n" |
| 328 | " ipm %0\n" |
| 329 | " srl %0,28\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | : "=d" (cc) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 331 | : "d" (reg0), "d" (reg1), "d" (reg2), "d" (reg3) : "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | return cc; |
| 333 | } |
| 334 | |
Adrian Bunk | 4448aaf | 2005-11-08 21:34:42 -0800 | [diff] [blame] | 335 | static inline int |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 336 | do_siga_input(struct subchannel_id schid, unsigned int mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 338 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | int cc; |
| 342 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 343 | asm volatile( |
| 344 | " siga 0\n" |
| 345 | " ipm %0\n" |
| 346 | " srl %0,28\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | : "=d" (cc) |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 348 | : "d" (reg0), "d" (reg1), "d" (reg2) : "cc", "memory"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | return cc; |
| 350 | } |
| 351 | |
Adrian Bunk | 4448aaf | 2005-11-08 21:34:42 -0800 | [diff] [blame] | 352 | static inline int |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 353 | do_siga_output(unsigned long schid, unsigned long mask, __u32 *bb, |
Frank Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 354 | unsigned int fc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 356 | register unsigned long __fc asm("0") = fc; |
| 357 | register unsigned long __schid asm("1") = schid; |
| 358 | register unsigned long __mask asm("2") = mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | int cc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 361 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | return cc; |
| 372 | } |
| 373 | |
Adrian Bunk | 4448aaf | 2005-11-08 21:34:42 -0800 | [diff] [blame] | 374 | static inline unsigned long |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | do_clear_global_summary(void) |
| 376 | { |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 377 | register unsigned long __fn asm("1") = 3; |
| 378 | register unsigned long __tmp asm("2"); |
| 379 | register unsigned long __time asm("3"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame^] | 381 | asm volatile( |
| 382 | " .insn rre,0xb2650000,2,0" |
| 383 | : "+d" (__fn), "=d" (__tmp), "=d" (__time)); |
| 384 | return __time; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | } |
| 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 |
| 413 | struct 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 Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 449 | #ifdef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | #define QDIO_GET_ADDR(x) ((__u32)(unsigned long)x) |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 451 | #else /* CONFIG_64BIT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | #define QDIO_GET_ADDR(x) ((__u32)(long)x) |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 453 | #endif /* CONFIG_64BIT */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | struct qdio_q { |
| 456 | volatile struct slsb slsb; |
| 457 | |
| 458 | char unused[QDIO_MAX_BUFFERS_PER_Q]; |
| 459 | |
Frank Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 460 | __u32 * dev_st_chg_ind; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | |
| 462 | int is_input_q; |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 463 | struct subchannel_id schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | 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 Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 508 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | 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 | |
| 554 | struct qdio_irq { |
| 555 | __u32 * volatile dev_st_chg_ind; |
| 556 | |
| 557 | unsigned long int_parm; |
Cornelia Huck | a8237fc | 2006-01-06 00:19:21 -0800 | [diff] [blame] | 558 | struct subchannel_id schid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | |
| 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 Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 565 | /* QEBSM facility */ |
| 566 | unsigned int is_qebsm; |
| 567 | unsigned long sch_token; |
| 568 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | 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 |