/drivers/s390/cio/qdio.h
C++ Header | 473 lines | 341 code | 74 blank | 58 comment | 10 complexity | 73fece37eee876eeb75d0a978a3926ab MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
- /*
- * linux/drivers/s390/cio/qdio.h
- *
- * Copyright 2000,2009 IBM Corp.
- * Author(s): Utz Bacher <utz.bacher@de.ibm.com>
- * Jan Glauber <jang@linux.vnet.ibm.com>
- */
- #ifndef _CIO_QDIO_H
- #define _CIO_QDIO_H
- #include <asm/page.h>
- #include <asm/schid.h>
- #include <asm/debug.h>
- #include "chsc.h"
- #define QDIO_BUSY_BIT_PATIENCE (100 << 12) /* 100 microseconds */
- #define QDIO_INPUT_THRESHOLD (500 << 12) /* 500 microseconds */
- /*
- * if an asynchronous HiperSockets queue runs full, the 10 seconds timer wait
- * till next initiative to give transmitted skbs back to the stack is too long.
- * Therefore polling is started in case of multicast queue is filled more
- * than 50 percent.
- */
- #define QDIO_IQDIO_POLL_LVL 65 /* HS multicast queue */
- enum qdio_irq_states {
- QDIO_IRQ_STATE_INACTIVE,
- QDIO_IRQ_STATE_ESTABLISHED,
- QDIO_IRQ_STATE_ACTIVE,
- QDIO_IRQ_STATE_STOPPED,
- QDIO_IRQ_STATE_CLEANUP,
- QDIO_IRQ_STATE_ERR,
- NR_QDIO_IRQ_STATES,
- };
- /* used as intparm in do_IO */
- #define QDIO_DOING_ESTABLISH 1
- #define QDIO_DOING_ACTIVATE 2
- #define QDIO_DOING_CLEANUP 3
- #define SLSB_STATE_NOT_INIT 0x0
- #define SLSB_STATE_EMPTY 0x1
- #define SLSB_STATE_PRIMED 0x2
- #define SLSB_STATE_HALTED 0xe
- #define SLSB_STATE_ERROR 0xf
- #define SLSB_TYPE_INPUT 0x0
- #define SLSB_TYPE_OUTPUT 0x20
- #define SLSB_OWNER_PROG 0x80
- #define SLSB_OWNER_CU 0x40
- #define SLSB_P_INPUT_NOT_INIT \
- (SLSB_OWNER_PROG | SLSB_TYPE_INPUT | SLSB_STATE_NOT_INIT) /* 0x80 */
- #define SLSB_P_INPUT_ACK \
- (SLSB_OWNER_PROG | SLSB_TYPE_INPUT | SLSB_STATE_EMPTY) /* 0x81 */
- #define SLSB_CU_INPUT_EMPTY \
- (SLSB_OWNER_CU | SLSB_TYPE_INPUT | SLSB_STATE_EMPTY) /* 0x41 */
- #define SLSB_P_INPUT_PRIMED \
- (SLSB_OWNER_PROG | SLSB_TYPE_INPUT | SLSB_STATE_PRIMED) /* 0x82 */
- #define SLSB_P_INPUT_HALTED \
- (SLSB_OWNER_PROG | SLSB_TYPE_INPUT | SLSB_STATE_HALTED) /* 0x8e */
- #define SLSB_P_INPUT_ERROR \
- (SLSB_OWNER_PROG | SLSB_TYPE_INPUT | SLSB_STATE_ERROR) /* 0x8f */
- #define SLSB_P_OUTPUT_NOT_INIT \
- (SLSB_OWNER_PROG | SLSB_TYPE_OUTPUT | SLSB_STATE_NOT_INIT) /* 0xa0 */
- #define SLSB_P_OUTPUT_EMPTY \
- (SLSB_OWNER_PROG | SLSB_TYPE_OUTPUT | SLSB_STATE_EMPTY) /* 0xa1 */
- #define SLSB_CU_OUTPUT_PRIMED \
- (SLSB_OWNER_CU | SLSB_TYPE_OUTPUT | SLSB_STATE_PRIMED) /* 0x62 */
- #define SLSB_P_OUTPUT_HALTED \
- (SLSB_OWNER_PROG | SLSB_TYPE_OUTPUT | SLSB_STATE_HALTED) /* 0xae */
- #define SLSB_P_OUTPUT_ERROR \
- (SLSB_OWNER_PROG | SLSB_TYPE_OUTPUT | SLSB_STATE_ERROR) /* 0xaf */
- #define SLSB_ERROR_DURING_LOOKUP 0xff
- /* additional CIWs returned by extended Sense-ID */
- #define CIW_TYPE_EQUEUE 0x3 /* establish QDIO queues */
- #define CIW_TYPE_AQUEUE 0x4 /* activate QDIO queues */
- /* flags for st qdio sch data */
- #define CHSC_FLAG_QDIO_CAPABILITY 0x80
- #define CHSC_FLAG_VALIDITY 0x40
- /* qdio adapter-characteristics-1 flag */
- #define AC1_SIGA_INPUT_NEEDED 0x40 /* process input queues */
- #define AC1_SIGA_OUTPUT_NEEDED 0x20 /* process output queues */
- #define AC1_SIGA_SYNC_NEEDED 0x10 /* ask hypervisor to sync */
- #define AC1_AUTOMATIC_SYNC_ON_THININT 0x08 /* set by hypervisor */
- #define AC1_AUTOMATIC_SYNC_ON_OUT_PCI 0x04 /* set by hypervisor */
- #define AC1_SC_QEBSM_AVAILABLE 0x02 /* available for subchannel */
- #define AC1_SC_QEBSM_ENABLED 0x01 /* enabled for subchannel */
- /* SIGA flags */
- #define QDIO_SIGA_WRITE 0x00
- #define QDIO_SIGA_READ 0x01
- #define QDIO_SIGA_SYNC 0x02
- #define QDIO_SIGA_QEBSM_FLAG 0x80
- #ifdef CONFIG_64BIT
- static inline int do_sqbs(u64 token, unsigned char state, int queue,
- int *start, int *count)
- {
- register unsigned long _ccq asm ("0") = *count;
- register unsigned long _token asm ("1") = token;
- unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
- asm volatile(
- " .insn rsy,0xeb000000008A,%1,0,0(%2)"
- : "+d" (_ccq), "+d" (_queuestart)
- : "d" ((unsigned long)state), "d" (_token)
- : "memory", "cc");
- *count = _ccq & 0xff;
- *start = _queuestart & 0xff;
- return (_ccq >> 32) & 0xff;
- }
- static inline int do_eqbs(u64 token, unsigned char *state, int queue,
- int *start, int *count, int ack)
- {
- register unsigned long _ccq asm ("0") = *count;
- register unsigned long _token asm ("1") = token;
- unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
- unsigned long _state = (unsigned long)ack << 63;
- asm volatile(
- " .insn rrf,0xB99c0000,%1,%2,0,0"
- : "+d" (_ccq), "+d" (_queuestart), "+d" (_state)
- : "d" (_token)
- : "memory", "cc");
- *count = _ccq & 0xff;
- *start = _queuestart & 0xff;
- *state = _state & 0xff;
- return (_ccq >> 32) & 0xff;
- }
- #else
- static inline int do_sqbs(u64 token, unsigned char state, int queue,
- int *start, int *count) { return 0; }
- static inline int do_eqbs(u64 token, unsigned char *state, int queue,
- int *start, int *count, int ack) { return 0; }
- #endif /* CONFIG_64BIT */
- struct qdio_irq;
- struct siga_flag {
- u8 input:1;
- u8 output:1;
- u8 sync:1;
- u8 sync_after_ai:1;
- u8 sync_out_after_pci:1;
- u8:3;
- } __attribute__ ((packed));
- struct chsc_ssqd_area {
- struct chsc_header request;
- u16:10;
- u8 ssid:2;
- u8 fmt:4;
- u16 first_sch;
- u16:16;
- u16 last_sch;
- u32:32;
- struct chsc_header response;
- u32:32;
- struct qdio_ssqd_desc qdio_ssqd;
- } __attribute__ ((packed));
- struct scssc_area {
- struct chsc_header request;
- u16 operation_code;
- u16:16;
- u32:32;
- u32:32;
- u64 summary_indicator_addr;
- u64 subchannel_indicator_addr;
- u32 ks:4;
- u32 kc:4;
- u32:21;
- u32 isc:3;
- u32 word_with_d_bit;
- u32:32;
- struct subchannel_id schid;
- u32 reserved[1004];
- struct chsc_header response;
- u32:32;
- } __attribute__ ((packed));
- struct qdio_dev_perf_stat {
- unsigned int adapter_int;
- unsigned int qdio_int;
- unsigned int pci_request_int;
- unsigned int tasklet_inbound;
- unsigned int tasklet_inbound_resched;
- unsigned int tasklet_inbound_resched2;
- unsigned int tasklet_outbound;
- unsigned int siga_read;
- unsigned int siga_write;
- unsigned int siga_sync;
- unsigned int inbound_call;
- unsigned int inbound_handler;
- unsigned int stop_polling;
- unsigned int inbound_queue_full;
- unsigned int outbound_call;
- unsigned int outbound_handler;
- unsigned int outbound_queue_full;
- unsigned int fast_requeue;
- unsigned int target_full;
- unsigned int eqbs;
- unsigned int eqbs_partial;
- unsigned int sqbs;
- unsigned int sqbs_partial;
- unsigned int int_discarded;
- } ____cacheline_aligned;
- struct qdio_queue_perf_stat {
- /*
- * Sorted into order-2 buckets: 1, 2-3, 4-7, ... 64-127, 128.
- * Since max. 127 SBALs are scanned reuse entry for 128 as queue full
- * aka 127 SBALs found.
- */
- unsigned int nr_sbals[8];
- unsigned int nr_sbal_error;
- unsigned int nr_sbal_nop;
- unsigned int nr_sbal_total;
- };
- enum qdio_queue_irq_states {
- QDIO_QUEUE_IRQS_DISABLED,
- };
- struct qdio_input_q {
- /* input buffer acknowledgement flag */
- int polling;
- /* first ACK'ed buffer */
- int ack_start;
- /* how much sbals are acknowledged with qebsm */
- int ack_count;
- /* last time of noticing incoming data */
- u64 timestamp;
- /* upper-layer polling flag */
- unsigned long queue_irq_state;
- /* callback to start upper-layer polling */
-