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