Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Uwe Zeisberger | f30c226 | 2006-10-03 23:01:26 +0200 | [diff] [blame] | 2 | * linux/include/asm-s390/qdio.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Linux for S/390 QDIO base support, Hipersocket base support |
| 5 | * version 2 |
| 6 | * |
| 7 | * Copyright 2000,2002 IBM Corporation |
| 8 | * Author(s): Utz Bacher <utz.bacher@de.ibm.com> |
| 9 | * |
| 10 | */ |
| 11 | #ifndef __QDIO_H__ |
| 12 | #define __QDIO_H__ |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | /* note, that most of the typedef's are from ingo. */ |
| 15 | |
| 16 | #include <linux/interrupt.h> |
| 17 | #include <asm/cio.h> |
| 18 | #include <asm/ccwdev.h> |
| 19 | |
| 20 | #define QDIO_NAME "qdio " |
| 21 | |
| 22 | #ifndef __s390x__ |
| 23 | #define QDIO_32_BIT |
| 24 | #endif /* __s390x__ */ |
| 25 | |
| 26 | /**** CONSTANTS, that are relied on without using these symbols *****/ |
| 27 | #define QDIO_MAX_QUEUES_PER_IRQ 32 /* used in width of unsigned int */ |
| 28 | /************************ END of CONSTANTS **************************/ |
| 29 | #define QDIO_MAX_BUFFERS_PER_Q 128 /* must be a power of 2 (%x=&(x-1)*/ |
| 30 | #define QDIO_BUF_ORDER 7 /* 2**this == number of pages used for sbals in 1 q */ |
| 31 | #define QDIO_MAX_ELEMENTS_PER_BUFFER 16 |
| 32 | #define SBAL_SIZE 256 |
| 33 | |
| 34 | #define QDIO_QETH_QFMT 0 |
| 35 | #define QDIO_ZFCP_QFMT 1 |
| 36 | #define QDIO_IQDIO_QFMT 2 |
Ursula Braun | 028cf91 | 2006-12-15 17:18:14 +0100 | [diff] [blame] | 37 | #define QDIO_IQDIO_QFMT_ASYNCH 3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | struct qdio_buffer_element{ |
| 40 | unsigned int flags; |
| 41 | unsigned int length; |
| 42 | #ifdef QDIO_32_BIT |
| 43 | void *reserved; |
| 44 | #endif /* QDIO_32_BIT */ |
| 45 | void *addr; |
| 46 | } __attribute__ ((packed,aligned(16))); |
| 47 | |
| 48 | struct qdio_buffer{ |
| 49 | volatile struct qdio_buffer_element element[16]; |
| 50 | } __attribute__ ((packed,aligned(256))); |
| 51 | |
| 52 | |
| 53 | /* params are: ccw_device, status, qdio_error, siga_error, |
| 54 | queue_number, first element processed, number of elements processed, |
| 55 | int_parm */ |
| 56 | typedef void qdio_handler_t(struct ccw_device *,unsigned int,unsigned int, |
| 57 | unsigned int,unsigned int,int,int,unsigned long); |
| 58 | |
| 59 | |
| 60 | #define QDIO_STATUS_INBOUND_INT 0x01 |
| 61 | #define QDIO_STATUS_OUTBOUND_INT 0x02 |
| 62 | #define QDIO_STATUS_LOOK_FOR_ERROR 0x04 |
| 63 | #define QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR 0x08 |
| 64 | #define QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR 0x10 |
| 65 | #define QDIO_STATUS_ACTIVATE_CHECK_CONDITION 0x20 |
| 66 | |
| 67 | #define QDIO_SIGA_ERROR_ACCESS_EXCEPTION 0x10 |
| 68 | #define QDIO_SIGA_ERROR_B_BIT_SET 0x20 |
| 69 | |
| 70 | /* for qdio_initialize */ |
| 71 | #define QDIO_INBOUND_0COPY_SBALS 0x01 |
| 72 | #define QDIO_OUTBOUND_0COPY_SBALS 0x02 |
| 73 | #define QDIO_USE_OUTBOUND_PCIS 0x04 |
| 74 | |
| 75 | /* for qdio_cleanup */ |
| 76 | #define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01 |
| 77 | #define QDIO_FLAG_CLEANUP_USING_HALT 0x02 |
| 78 | |
| 79 | struct qdio_initialize { |
| 80 | struct ccw_device *cdev; |
| 81 | unsigned char q_format; |
| 82 | unsigned char adapter_name[8]; |
| 83 | unsigned int qib_param_field_format; /*adapter dependent*/ |
| 84 | /* pointer to 128 bytes or NULL, if no param field */ |
| 85 | unsigned char *qib_param_field; /* adapter dependent */ |
| 86 | /* pointer to no_queues*128 words of data or NULL */ |
| 87 | unsigned long *input_slib_elements; |
| 88 | unsigned long *output_slib_elements; |
| 89 | unsigned int min_input_threshold; |
| 90 | unsigned int max_input_threshold; |
| 91 | unsigned int min_output_threshold; |
| 92 | unsigned int max_output_threshold; |
| 93 | unsigned int no_input_qs; |
| 94 | unsigned int no_output_qs; |
| 95 | qdio_handler_t *input_handler; |
| 96 | qdio_handler_t *output_handler; |
| 97 | unsigned long int_parm; |
| 98 | unsigned long flags; |
| 99 | void **input_sbal_addr_array; /* addr of n*128 void ptrs */ |
| 100 | void **output_sbal_addr_array; /* addr of n*128 void ptrs */ |
| 101 | }; |
| 102 | |
| 103 | extern int qdio_initialize(struct qdio_initialize *init_data); |
| 104 | extern int qdio_allocate(struct qdio_initialize *init_data); |
| 105 | extern int qdio_establish(struct qdio_initialize *init_data); |
| 106 | |
| 107 | extern int qdio_activate(struct ccw_device *,int flags); |
| 108 | |
| 109 | #define QDIO_STATE_MUST_USE_OUTB_PCI 0x00000001 |
| 110 | #define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */ |
| 111 | #define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_initialize */ |
| 112 | #define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */ |
| 113 | #define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */ |
| 114 | extern unsigned long qdio_get_status(int irq); |
| 115 | |
| 116 | |
| 117 | #define QDIO_FLAG_SYNC_INPUT 0x01 |
| 118 | #define QDIO_FLAG_SYNC_OUTPUT 0x02 |
| 119 | #define QDIO_FLAG_UNDER_INTERRUPT 0x04 |
| 120 | #define QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT 0x08 /* no effect on |
| 121 | adapter interrupts */ |
| 122 | #define QDIO_FLAG_DONT_SIGA 0x10 |
| 123 | |
| 124 | extern int do_QDIO(struct ccw_device*, unsigned int flags, |
| 125 | unsigned int queue_number, |
| 126 | unsigned int qidx,unsigned int count, |
| 127 | struct qdio_buffer *buffers); |
| 128 | |
| 129 | extern int qdio_synchronize(struct ccw_device*, unsigned int flags, |
| 130 | unsigned int queue_number); |
| 131 | |
| 132 | extern int qdio_cleanup(struct ccw_device*, int how); |
| 133 | extern int qdio_shutdown(struct ccw_device*, int how); |
| 134 | extern int qdio_free(struct ccw_device*); |
| 135 | |
| 136 | unsigned char qdio_get_slsb_state(struct ccw_device*, unsigned int flag, |
| 137 | unsigned int queue_number, |
| 138 | unsigned int qidx); |
| 139 | |
| 140 | extern void qdio_init_scrubber(void); |
| 141 | |
| 142 | struct qdesfmt0 { |
| 143 | #ifdef QDIO_32_BIT |
| 144 | unsigned long res1; /* reserved */ |
| 145 | #endif /* QDIO_32_BIT */ |
| 146 | unsigned long sliba; /* storage-list-information-block |
| 147 | address */ |
| 148 | #ifdef QDIO_32_BIT |
| 149 | unsigned long res2; /* reserved */ |
| 150 | #endif /* QDIO_32_BIT */ |
| 151 | unsigned long sla; /* storage-list address */ |
| 152 | #ifdef QDIO_32_BIT |
| 153 | unsigned long res3; /* reserved */ |
| 154 | #endif /* QDIO_32_BIT */ |
| 155 | unsigned long slsba; /* storage-list-state-block address */ |
| 156 | unsigned int res4; /* reserved */ |
| 157 | unsigned int akey : 4; /* access key for DLIB */ |
| 158 | unsigned int bkey : 4; /* access key for SL */ |
| 159 | unsigned int ckey : 4; /* access key for SBALs */ |
| 160 | unsigned int dkey : 4; /* access key for SLSB */ |
| 161 | unsigned int res5 : 16; /* reserved */ |
| 162 | } __attribute__ ((packed)); |
| 163 | |
| 164 | /* |
| 165 | * Queue-Description record (QDR) |
| 166 | */ |
| 167 | struct qdr { |
| 168 | unsigned int qfmt : 8; /* queue format */ |
| 169 | unsigned int pfmt : 8; /* impl. dep. parameter format */ |
| 170 | unsigned int res1 : 8; /* reserved */ |
| 171 | unsigned int ac : 8; /* adapter characteristics */ |
| 172 | unsigned int res2 : 8; /* reserved */ |
| 173 | unsigned int iqdcnt : 8; /* input-queue-descriptor count */ |
| 174 | unsigned int res3 : 8; /* reserved */ |
| 175 | unsigned int oqdcnt : 8; /* output-queue-descriptor count */ |
| 176 | unsigned int res4 : 8; /* reserved */ |
| 177 | unsigned int iqdsz : 8; /* input-queue-descriptor size */ |
| 178 | unsigned int res5 : 8; /* reserved */ |
| 179 | unsigned int oqdsz : 8; /* output-queue-descriptor size */ |
| 180 | unsigned int res6[9]; /* reserved */ |
| 181 | #ifdef QDIO_32_BIT |
| 182 | unsigned long res7; /* reserved */ |
| 183 | #endif /* QDIO_32_BIT */ |
| 184 | unsigned long qiba; /* queue-information-block address */ |
| 185 | unsigned int res8; /* reserved */ |
| 186 | unsigned int qkey : 4; /* queue-informatio-block key */ |
| 187 | unsigned int res9 : 28; /* reserved */ |
| 188 | /* union _qd {*/ /* why this? */ |
| 189 | struct qdesfmt0 qdf0[126]; |
| 190 | /* } qd;*/ |
| 191 | } __attribute__ ((packed,aligned(4096))); |
| 192 | |
| 193 | |
| 194 | /* |
| 195 | * queue information block (QIB) |
| 196 | */ |
Frank Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 197 | #define QIB_AC_INBOUND_PCI_SUPPORTED 0x80 |
| 198 | #define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40 |
| 199 | #define QIB_RFLAGS_ENABLE_QEBSM 0x80 |
| 200 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | struct qib { |
| 202 | unsigned int qfmt : 8; /* queue format */ |
| 203 | unsigned int pfmt : 8; /* impl. dep. parameter format */ |
Frank Pavlic | 8129ee1 | 2006-01-06 00:19:20 -0800 | [diff] [blame] | 204 | unsigned int rflags : 8; /* QEBSM */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | unsigned int ac : 8; /* adapter characteristics */ |
| 206 | unsigned int res2; /* reserved */ |
| 207 | #ifdef QDIO_32_BIT |
| 208 | unsigned long res3; /* reserved */ |
| 209 | #endif /* QDIO_32_BIT */ |
| 210 | unsigned long isliba; /* absolute address of 1st |
| 211 | input SLIB */ |
| 212 | #ifdef QDIO_32_BIT |
| 213 | unsigned long res4; /* reserved */ |
| 214 | #endif /* QDIO_32_BIT */ |
| 215 | unsigned long osliba; /* absolute address of 1st |
| 216 | output SLIB */ |
| 217 | unsigned int res5; /* reserved */ |
| 218 | unsigned int res6; /* reserved */ |
| 219 | unsigned char ebcnam[8]; /* adapter identifier in EBCDIC */ |
| 220 | unsigned char res7[88]; /* reserved */ |
| 221 | unsigned char parm[QDIO_MAX_BUFFERS_PER_Q]; |
| 222 | /* implementation dependent |
| 223 | parameters */ |
| 224 | } __attribute__ ((packed,aligned(256))); |
| 225 | |
| 226 | |
| 227 | /* |
| 228 | * storage-list-information block element (SLIBE) |
| 229 | */ |
| 230 | struct slibe { |
| 231 | #ifdef QDIO_32_BIT |
| 232 | unsigned long res; /* reserved */ |
| 233 | #endif /* QDIO_32_BIT */ |
| 234 | unsigned long parms; /* implementation dependent |
| 235 | parameters */ |
| 236 | }; |
| 237 | |
| 238 | /* |
| 239 | * storage-list-information block (SLIB) |
| 240 | */ |
| 241 | struct slib { |
| 242 | #ifdef QDIO_32_BIT |
| 243 | unsigned long res1; /* reserved */ |
| 244 | #endif /* QDIO_32_BIT */ |
| 245 | unsigned long nsliba; /* next SLIB address (if any) */ |
| 246 | #ifdef QDIO_32_BIT |
| 247 | unsigned long res2; /* reserved */ |
| 248 | #endif /* QDIO_32_BIT */ |
| 249 | unsigned long sla; /* SL address */ |
| 250 | #ifdef QDIO_32_BIT |
| 251 | unsigned long res3; /* reserved */ |
| 252 | #endif /* QDIO_32_BIT */ |
| 253 | unsigned long slsba; /* SLSB address */ |
| 254 | unsigned char res4[1000]; /* reserved */ |
| 255 | struct slibe slibe[QDIO_MAX_BUFFERS_PER_Q]; /* SLIB elements */ |
| 256 | } __attribute__ ((packed,aligned(2048))); |
| 257 | |
| 258 | struct sbal_flags { |
| 259 | unsigned char res1 : 1; /* reserved */ |
| 260 | unsigned char last : 1; /* last entry */ |
| 261 | unsigned char cont : 1; /* contiguous storage */ |
| 262 | unsigned char res2 : 1; /* reserved */ |
| 263 | unsigned char frag : 2; /* fragmentation (s.below) */ |
| 264 | unsigned char res3 : 2; /* reserved */ |
| 265 | } __attribute__ ((packed)); |
| 266 | |
| 267 | #define SBAL_FLAGS_FIRST_FRAG 0x04000000UL |
| 268 | #define SBAL_FLAGS_MIDDLE_FRAG 0x08000000UL |
| 269 | #define SBAL_FLAGS_LAST_FRAG 0x0c000000UL |
| 270 | #define SBAL_FLAGS_LAST_ENTRY 0x40000000UL |
| 271 | #define SBAL_FLAGS_CONTIGUOUS 0x20000000UL |
| 272 | |
| 273 | #define SBAL_FLAGS0_DATA_CONTINUATION 0x20UL |
| 274 | |
| 275 | /* Awesome OpenFCP extensions */ |
| 276 | #define SBAL_FLAGS0_TYPE_STATUS 0x00UL |
| 277 | #define SBAL_FLAGS0_TYPE_WRITE 0x08UL |
| 278 | #define SBAL_FLAGS0_TYPE_READ 0x10UL |
| 279 | #define SBAL_FLAGS0_TYPE_WRITE_READ 0x18UL |
| 280 | #define SBAL_FLAGS0_MORE_SBALS 0x04UL |
| 281 | #define SBAL_FLAGS0_COMMAND 0x02UL |
| 282 | #define SBAL_FLAGS0_LAST_SBAL 0x00UL |
| 283 | #define SBAL_FLAGS0_ONLY_SBAL SBAL_FLAGS0_COMMAND |
| 284 | #define SBAL_FLAGS0_MIDDLE_SBAL SBAL_FLAGS0_MORE_SBALS |
| 285 | #define SBAL_FLAGS0_FIRST_SBAL SBAL_FLAGS0_MORE_SBALS | SBAL_FLAGS0_COMMAND |
| 286 | /* Naught of interest beyond this point */ |
| 287 | |
| 288 | #define SBAL_FLAGS0_PCI 0x40 |
| 289 | struct sbal_sbalf_0 { |
| 290 | unsigned char res1 : 1; /* reserved */ |
| 291 | unsigned char pci : 1; /* PCI indicator */ |
| 292 | unsigned char cont : 1; /* data continuation */ |
| 293 | unsigned char sbtype: 2; /* storage-block type (OpenFCP) */ |
| 294 | unsigned char res2 : 3; /* reserved */ |
| 295 | } __attribute__ ((packed)); |
| 296 | |
| 297 | struct sbal_sbalf_1 { |
| 298 | unsigned char res1 : 4; /* reserved */ |
| 299 | unsigned char key : 4; /* storage key */ |
| 300 | } __attribute__ ((packed)); |
| 301 | |
| 302 | struct sbal_sbalf_14 { |
| 303 | unsigned char res1 : 4; /* reserved */ |
| 304 | unsigned char erridx : 4; /* error index */ |
| 305 | } __attribute__ ((packed)); |
| 306 | |
| 307 | struct sbal_sbalf_15 { |
| 308 | unsigned char reason; /* reserved */ |
| 309 | } __attribute__ ((packed)); |
| 310 | |
| 311 | union sbal_sbalf { |
| 312 | struct sbal_sbalf_0 i0; |
| 313 | struct sbal_sbalf_1 i1; |
| 314 | struct sbal_sbalf_14 i14; |
| 315 | struct sbal_sbalf_15 i15; |
| 316 | unsigned char value; |
| 317 | }; |
| 318 | |
| 319 | struct sbal_element { |
| 320 | union { |
| 321 | struct sbal_flags bits; /* flags */ |
| 322 | unsigned char value; |
| 323 | } flags; |
| 324 | unsigned int res1 : 16; /* reserved */ |
| 325 | union sbal_sbalf sbalf; /* SBAL flags */ |
| 326 | unsigned int res2 : 16; /* reserved */ |
| 327 | unsigned int count : 16; /* data count */ |
| 328 | #ifdef QDIO_32_BIT |
| 329 | unsigned long res3; /* reserved */ |
| 330 | #endif /* QDIO_32_BIT */ |
| 331 | unsigned long addr; /* absolute data address */ |
| 332 | } __attribute__ ((packed,aligned(16))); |
| 333 | |
| 334 | /* |
| 335 | * strorage-block access-list (SBAL) |
| 336 | */ |
| 337 | struct sbal { |
| 338 | struct sbal_element element[QDIO_MAX_ELEMENTS_PER_BUFFER]; |
| 339 | } __attribute__ ((packed,aligned(256))); |
| 340 | |
| 341 | /* |
| 342 | * storage-list (SL) |
| 343 | */ |
| 344 | struct sl_element { |
| 345 | #ifdef QDIO_32_BIT |
| 346 | unsigned long res; /* reserved */ |
| 347 | #endif /* QDIO_32_BIT */ |
| 348 | unsigned long sbal; /* absolute SBAL address */ |
| 349 | } __attribute__ ((packed)); |
| 350 | |
| 351 | struct sl { |
| 352 | struct sl_element element[QDIO_MAX_BUFFERS_PER_Q]; |
| 353 | } __attribute__ ((packed,aligned(1024))); |
| 354 | |
| 355 | /* |
| 356 | * storage-list-state block (SLSB) |
| 357 | */ |
| 358 | struct slsb_flags { |
| 359 | unsigned char owner : 2; /* SBAL owner */ |
| 360 | unsigned char type : 1; /* buffer type */ |
| 361 | unsigned char state : 5; /* processing state */ |
| 362 | } __attribute__ ((packed)); |
| 363 | |
| 364 | |
| 365 | struct slsb { |
| 366 | union { |
| 367 | unsigned char val[QDIO_MAX_BUFFERS_PER_Q]; |
| 368 | struct slsb_flags flags[QDIO_MAX_BUFFERS_PER_Q]; |
| 369 | } acc; |
| 370 | } __attribute__ ((packed,aligned(256))); |
| 371 | |
| 372 | /* |
| 373 | * SLSB values |
| 374 | */ |
| 375 | #define SLSB_OWNER_PROG 1 |
| 376 | #define SLSB_OWNER_CU 2 |
| 377 | |
| 378 | #define SLSB_TYPE_INPUT 0 |
| 379 | #define SLSB_TYPE_OUTPUT 1 |
| 380 | |
| 381 | #define SLSB_STATE_NOT_INIT 0 |
| 382 | #define SLSB_STATE_EMPTY 1 |
| 383 | #define SLSB_STATE_PRIMED 2 |
| 384 | #define SLSB_STATE_HALTED 0xe |
| 385 | #define SLSB_STATE_ERROR 0xf |
| 386 | |
| 387 | #define SLSB_P_INPUT_NOT_INIT 0x80 |
| 388 | #define SLSB_P_INPUT_PROCESSING 0x81 |
| 389 | #define SLSB_CU_INPUT_EMPTY 0x41 |
| 390 | #define SLSB_P_INPUT_PRIMED 0x82 |
| 391 | #define SLSB_P_INPUT_HALTED 0x8E |
| 392 | #define SLSB_P_INPUT_ERROR 0x8F |
| 393 | |
| 394 | #define SLSB_P_OUTPUT_NOT_INIT 0xA0 |
| 395 | #define SLSB_P_OUTPUT_EMPTY 0xA1 |
| 396 | #define SLSB_CU_OUTPUT_PRIMED 0x62 |
| 397 | #define SLSB_P_OUTPUT_HALTED 0xAE |
| 398 | #define SLSB_P_OUTPUT_ERROR 0xAF |
| 399 | |
| 400 | #define SLSB_ERROR_DURING_LOOKUP 0xFF |
| 401 | |
| 402 | #endif /* __QDIO_H__ */ |