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