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 | * |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 4 | * Copyright 2000,2008 IBM Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Author(s): Utz Bacher <utz.bacher@de.ibm.com> |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 6 | * Jan Glauber <jang@linux.vnet.ibm.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * |
| 8 | */ |
| 9 | #ifndef __QDIO_H__ |
| 10 | #define __QDIO_H__ |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/interrupt.h> |
| 13 | #include <asm/cio.h> |
| 14 | #include <asm/ccwdev.h> |
| 15 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 16 | #define QDIO_MAX_QUEUES_PER_IRQ 32 |
| 17 | #define QDIO_MAX_BUFFERS_PER_Q 128 |
| 18 | #define QDIO_MAX_BUFFERS_MASK (QDIO_MAX_BUFFERS_PER_Q - 1) |
| 19 | #define QDIO_MAX_ELEMENTS_PER_BUFFER 16 |
| 20 | #define QDIO_SBAL_SIZE 256 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 22 | #define QDIO_QETH_QFMT 0 |
| 23 | #define QDIO_ZFCP_QFMT 1 |
| 24 | #define QDIO_IQDIO_QFMT 2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 26 | /** |
| 27 | * struct qdesfmt0 - queue descriptor, format 0 |
| 28 | * @sliba: storage list information block address |
| 29 | * @sla: storage list address |
| 30 | * @slsba: storage list state block address |
| 31 | * @akey: access key for DLIB |
| 32 | * @bkey: access key for SL |
| 33 | * @ckey: access key for SBALs |
| 34 | * @dkey: access key for SLSB |
| 35 | */ |
| 36 | struct qdesfmt0 { |
| 37 | u64 sliba; |
| 38 | u64 sla; |
| 39 | u64 slsba; |
| 40 | u32 : 32; |
| 41 | u32 akey : 4; |
| 42 | u32 bkey : 4; |
| 43 | u32 ckey : 4; |
| 44 | u32 dkey : 4; |
| 45 | u32 : 16; |
| 46 | } __attribute__ ((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 48 | /** |
| 49 | * struct qdr - queue description record (QDR) |
| 50 | * @qfmt: queue format |
| 51 | * @pfmt: implementation dependent parameter format |
| 52 | * @ac: adapter characteristics |
| 53 | * @iqdcnt: input queue descriptor count |
| 54 | * @oqdcnt: output queue descriptor count |
| 55 | * @iqdsz: inpout queue descriptor size |
| 56 | * @oqdsz: output queue descriptor size |
| 57 | * @qiba: queue information block address |
| 58 | * @qkey: queue information block key |
| 59 | * @qdf0: queue descriptions |
| 60 | */ |
| 61 | struct qdr { |
| 62 | u32 qfmt : 8; |
| 63 | u32 pfmt : 8; |
| 64 | u32 : 8; |
| 65 | u32 ac : 8; |
| 66 | u32 : 8; |
| 67 | u32 iqdcnt : 8; |
| 68 | u32 : 8; |
| 69 | u32 oqdcnt : 8; |
| 70 | u32 : 8; |
| 71 | u32 iqdsz : 8; |
| 72 | u32 : 8; |
| 73 | u32 oqdsz : 8; |
| 74 | /* private: */ |
| 75 | u32 res[9]; |
| 76 | /* public: */ |
| 77 | u64 qiba; |
| 78 | u32 : 32; |
| 79 | u32 qkey : 4; |
| 80 | u32 : 28; |
| 81 | struct qdesfmt0 qdf0[126]; |
| 82 | } __attribute__ ((packed, aligned(4096))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 84 | #define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40 |
| 85 | #define QIB_RFLAGS_ENABLE_QEBSM 0x80 |
| 86 | |
| 87 | /** |
| 88 | * struct qib - queue information block (QIB) |
| 89 | * @qfmt: queue format |
| 90 | * @pfmt: implementation dependent parameter format |
| 91 | * @rflags: QEBSM |
| 92 | * @ac: adapter characteristics |
| 93 | * @isliba: absolute address of first input SLIB |
| 94 | * @osliba: absolute address of first output SLIB |
| 95 | * @ebcnam: adapter identifier in EBCDIC |
| 96 | * @parm: implementation dependent parameters |
| 97 | */ |
| 98 | struct qib { |
| 99 | u32 qfmt : 8; |
| 100 | u32 pfmt : 8; |
| 101 | u32 rflags : 8; |
| 102 | u32 ac : 8; |
| 103 | u32 : 32; |
| 104 | u64 isliba; |
| 105 | u64 osliba; |
| 106 | u32 : 32; |
| 107 | u32 : 32; |
| 108 | u8 ebcnam[8]; |
| 109 | /* private: */ |
| 110 | u8 res[88]; |
| 111 | /* public: */ |
| 112 | u8 parm[QDIO_MAX_BUFFERS_PER_Q]; |
| 113 | } __attribute__ ((packed, aligned(256))); |
| 114 | |
| 115 | /** |
| 116 | * struct slibe - storage list information block element (SLIBE) |
| 117 | * @parms: implementation dependent parameters |
| 118 | */ |
| 119 | struct slibe { |
| 120 | u64 parms; |
| 121 | }; |
| 122 | |
| 123 | /** |
| 124 | * struct slib - storage list information block (SLIB) |
| 125 | * @nsliba: next SLIB address (if any) |
| 126 | * @sla: SL address |
| 127 | * @slsba: SLSB address |
| 128 | * @slibe: SLIB elements |
| 129 | */ |
| 130 | struct slib { |
| 131 | u64 nsliba; |
| 132 | u64 sla; |
| 133 | u64 slsba; |
| 134 | /* private: */ |
| 135 | u8 res[1000]; |
| 136 | /* public: */ |
| 137 | struct slibe slibe[QDIO_MAX_BUFFERS_PER_Q]; |
| 138 | } __attribute__ ((packed, aligned(2048))); |
| 139 | |
| 140 | /** |
| 141 | * struct sbal_flags - storage block address list flags |
| 142 | * @last: last entry |
| 143 | * @cont: contiguous storage |
| 144 | * @frag: fragmentation |
| 145 | */ |
| 146 | struct sbal_flags { |
| 147 | u8 : 1; |
| 148 | u8 last : 1; |
| 149 | u8 cont : 1; |
| 150 | u8 : 1; |
| 151 | u8 frag : 2; |
| 152 | u8 : 2; |
| 153 | } __attribute__ ((packed)); |
| 154 | |
| 155 | #define SBAL_FLAGS_FIRST_FRAG 0x04000000UL |
| 156 | #define SBAL_FLAGS_MIDDLE_FRAG 0x08000000UL |
| 157 | #define SBAL_FLAGS_LAST_FRAG 0x0c000000UL |
| 158 | #define SBAL_FLAGS_LAST_ENTRY 0x40000000UL |
| 159 | #define SBAL_FLAGS_CONTIGUOUS 0x20000000UL |
| 160 | |
| 161 | #define SBAL_FLAGS0_DATA_CONTINUATION 0x20UL |
| 162 | |
| 163 | /* Awesome OpenFCP extensions */ |
| 164 | #define SBAL_FLAGS0_TYPE_STATUS 0x00UL |
| 165 | #define SBAL_FLAGS0_TYPE_WRITE 0x08UL |
| 166 | #define SBAL_FLAGS0_TYPE_READ 0x10UL |
| 167 | #define SBAL_FLAGS0_TYPE_WRITE_READ 0x18UL |
| 168 | #define SBAL_FLAGS0_MORE_SBALS 0x04UL |
| 169 | #define SBAL_FLAGS0_COMMAND 0x02UL |
| 170 | #define SBAL_FLAGS0_LAST_SBAL 0x00UL |
| 171 | #define SBAL_FLAGS0_ONLY_SBAL SBAL_FLAGS0_COMMAND |
| 172 | #define SBAL_FLAGS0_MIDDLE_SBAL SBAL_FLAGS0_MORE_SBALS |
| 173 | #define SBAL_FLAGS0_FIRST_SBAL SBAL_FLAGS0_MORE_SBALS | SBAL_FLAGS0_COMMAND |
| 174 | #define SBAL_FLAGS0_PCI 0x40 |
| 175 | |
| 176 | /** |
| 177 | * struct sbal_sbalf_0 - sbal flags for sbale 0 |
| 178 | * @pci: PCI indicator |
| 179 | * @cont: data continuation |
| 180 | * @sbtype: storage-block type (FCP) |
| 181 | */ |
| 182 | struct sbal_sbalf_0 { |
| 183 | u8 : 1; |
| 184 | u8 pci : 1; |
| 185 | u8 cont : 1; |
| 186 | u8 sbtype : 2; |
| 187 | u8 : 3; |
| 188 | } __attribute__ ((packed)); |
| 189 | |
| 190 | /** |
| 191 | * struct sbal_sbalf_1 - sbal flags for sbale 1 |
| 192 | * @key: storage key |
| 193 | */ |
| 194 | struct sbal_sbalf_1 { |
| 195 | u8 : 4; |
| 196 | u8 key : 4; |
| 197 | } __attribute__ ((packed)); |
| 198 | |
| 199 | /** |
| 200 | * struct sbal_sbalf_14 - sbal flags for sbale 14 |
| 201 | * @erridx: error index |
| 202 | */ |
| 203 | struct sbal_sbalf_14 { |
| 204 | u8 : 4; |
| 205 | u8 erridx : 4; |
| 206 | } __attribute__ ((packed)); |
| 207 | |
| 208 | /** |
| 209 | * struct sbal_sbalf_15 - sbal flags for sbale 15 |
| 210 | * @reason: reason for error state |
| 211 | */ |
| 212 | struct sbal_sbalf_15 { |
| 213 | u8 reason; |
| 214 | } __attribute__ ((packed)); |
| 215 | |
| 216 | /** |
| 217 | * union sbal_sbalf - storage block address list flags |
| 218 | * @i0: sbalf0 |
| 219 | * @i1: sbalf1 |
| 220 | * @i14: sbalf14 |
| 221 | * @i15: sblaf15 |
| 222 | * @value: raw value |
| 223 | */ |
| 224 | union sbal_sbalf { |
| 225 | struct sbal_sbalf_0 i0; |
| 226 | struct sbal_sbalf_1 i1; |
| 227 | struct sbal_sbalf_14 i14; |
| 228 | struct sbal_sbalf_15 i15; |
| 229 | u8 value; |
| 230 | }; |
| 231 | |
| 232 | /** |
| 233 | * struct qdio_buffer_element - SBAL entry |
| 234 | * @flags: flags |
| 235 | * @length: length |
| 236 | * @addr: address |
| 237 | */ |
| 238 | struct qdio_buffer_element { |
| 239 | u32 flags; |
| 240 | u32 length; |
| 241 | #ifdef CONFIG_32BIT |
| 242 | /* private: */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | void *reserved; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 244 | /* public: */ |
| 245 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | void *addr; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 247 | } __attribute__ ((packed, aligned(16))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 249 | /** |
| 250 | * struct qdio_buffer - storage block address list (SBAL) |
| 251 | * @element: SBAL entries |
| 252 | */ |
| 253 | struct qdio_buffer { |
| 254 | struct qdio_buffer_element element[QDIO_MAX_ELEMENTS_PER_BUFFER]; |
| 255 | } __attribute__ ((packed, aligned(256))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 257 | /** |
| 258 | * struct sl_element - storage list entry |
| 259 | * @sbal: absolute SBAL address |
| 260 | */ |
| 261 | struct sl_element { |
| 262 | #ifdef CONFIG_32BIT |
| 263 | /* private: */ |
| 264 | unsigned long reserved; |
| 265 | /* public: */ |
| 266 | #endif |
| 267 | unsigned long sbal; |
| 268 | } __attribute__ ((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 270 | /** |
| 271 | * struct sl - storage list (SL) |
| 272 | * @element: SL entries |
| 273 | */ |
| 274 | struct sl { |
| 275 | struct sl_element element[QDIO_MAX_BUFFERS_PER_Q]; |
| 276 | } __attribute__ ((packed, aligned(1024))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 278 | /** |
| 279 | * struct slsb - storage list state block (SLSB) |
| 280 | * @val: state per buffer |
| 281 | */ |
| 282 | struct slsb { |
| 283 | u8 val[QDIO_MAX_BUFFERS_PER_Q]; |
| 284 | } __attribute__ ((packed, aligned(256))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 286 | struct qdio_ssqd_desc { |
| 287 | u8 flags; |
| 288 | u8:8; |
| 289 | u16 sch; |
| 290 | u8 qfmt; |
| 291 | u8 parm; |
| 292 | u8 qdioac1; |
| 293 | u8 sch_class; |
| 294 | u8 pcnt; |
| 295 | u8 icnt; |
| 296 | u8:8; |
| 297 | u8 ocnt; |
| 298 | u8:8; |
| 299 | u8 mbccnt; |
| 300 | u16 qdioac2; |
| 301 | u64 sch_token; |
Klaus-Dieter Wacker | 7a0f475 | 2008-10-10 21:33:18 +0200 | [diff] [blame] | 302 | u8 mro; |
| 303 | u8 mri; |
| 304 | u8:8; |
| 305 | u8 sbalic; |
| 306 | u16:16; |
| 307 | u8:8; |
| 308 | u8 mmwc; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 309 | } __attribute__ ((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 311 | /* params are: ccw_device, qdio_error, queue_number, |
| 312 | first element processed, number of elements processed, int_parm */ |
| 313 | typedef void qdio_handler_t(struct ccw_device *, unsigned int, int, |
| 314 | int, int, unsigned long); |
| 315 | |
| 316 | /* qdio errors reported to the upper-layer program */ |
Jan Glauber | d303b6f | 2009-03-26 15:24:31 +0100 | [diff] [blame] | 317 | #define QDIO_ERROR_SIGA_TARGET 0x02 |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 318 | #define QDIO_ERROR_SIGA_ACCESS_EXCEPTION 0x10 |
| 319 | #define QDIO_ERROR_SIGA_BUSY 0x20 |
| 320 | #define QDIO_ERROR_ACTIVATE_CHECK_CONDITION 0x40 |
| 321 | #define QDIO_ERROR_SLSB_STATE 0x80 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
| 323 | /* for qdio_initialize */ |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 324 | #define QDIO_INBOUND_0COPY_SBALS 0x01 |
| 325 | #define QDIO_OUTBOUND_0COPY_SBALS 0x02 |
| 326 | #define QDIO_USE_OUTBOUND_PCIS 0x04 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | |
| 328 | /* for qdio_cleanup */ |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 329 | #define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01 |
| 330 | #define QDIO_FLAG_CLEANUP_USING_HALT 0x02 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 332 | /** |
| 333 | * struct qdio_initialize - qdio initalization data |
| 334 | * @cdev: associated ccw device |
| 335 | * @q_format: queue format |
| 336 | * @adapter_name: name for the adapter |
| 337 | * @qib_param_field_format: format for qib_parm_field |
| 338 | * @qib_param_field: pointer to 128 bytes or NULL, if no param field |
| 339 | * @input_slib_elements: pointer to no_input_qs * 128 words of data or NULL |
| 340 | * @output_slib_elements: pointer to no_output_qs * 128 words of data or NULL |
| 341 | * @no_input_qs: number of input queues |
| 342 | * @no_output_qs: number of output queues |
| 343 | * @input_handler: handler to be called for input queues |
| 344 | * @output_handler: handler to be called for output queues |
| 345 | * @int_parm: interruption parameter |
| 346 | * @flags: initialization flags |
| 347 | * @input_sbal_addr_array: address of no_input_qs * 128 pointers |
| 348 | * @output_sbal_addr_array: address of no_output_qs * 128 pointers |
| 349 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | struct qdio_initialize { |
| 351 | struct ccw_device *cdev; |
| 352 | unsigned char q_format; |
| 353 | unsigned char adapter_name[8]; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 354 | unsigned int qib_param_field_format; |
| 355 | unsigned char *qib_param_field; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | unsigned long *input_slib_elements; |
| 357 | unsigned long *output_slib_elements; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | unsigned int no_input_qs; |
| 359 | unsigned int no_output_qs; |
| 360 | qdio_handler_t *input_handler; |
| 361 | qdio_handler_t *output_handler; |
| 362 | unsigned long int_parm; |
| 363 | unsigned long flags; |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 364 | void **input_sbal_addr_array; |
| 365 | void **output_sbal_addr_array; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | }; |
| 367 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 368 | #define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */ |
| 369 | #define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_establish */ |
| 370 | #define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */ |
| 371 | #define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */ |
| 372 | |
| 373 | #define QDIO_FLAG_SYNC_INPUT 0x01 |
| 374 | #define QDIO_FLAG_SYNC_OUTPUT 0x02 |
| 375 | #define QDIO_FLAG_PCI_OUT 0x10 |
| 376 | |
Jan Glauber | bbd50e1 | 2008-12-25 13:38:43 +0100 | [diff] [blame] | 377 | extern int qdio_initialize(struct qdio_initialize *); |
| 378 | extern int qdio_allocate(struct qdio_initialize *); |
| 379 | extern int qdio_establish(struct qdio_initialize *); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 380 | extern int qdio_activate(struct ccw_device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
Jan Glauber | bbd50e1 | 2008-12-25 13:38:43 +0100 | [diff] [blame] | 382 | extern int do_QDIO(struct ccw_device *cdev, unsigned int callflags, |
| 383 | int q_nr, int bufnr, int count); |
| 384 | extern int qdio_cleanup(struct ccw_device*, int); |
| 385 | extern int qdio_shutdown(struct ccw_device*, int); |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 386 | extern int qdio_free(struct ccw_device *); |
Jan Glauber | bbd50e1 | 2008-12-25 13:38:43 +0100 | [diff] [blame] | 387 | extern int qdio_get_ssqd_desc(struct ccw_device *dev, struct qdio_ssqd_desc*); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | |
| 389 | #endif /* __QDIO_H__ */ |