1e9447430SMauro Carvalho Chehab.. SPDX-License-Identifier: GPL-2.0
2e9447430SMauro Carvalho Chehab
3e9447430SMauro Carvalho Chehab====================================
4e9447430SMauro Carvalho ChehabFLIC (floating interrupt controller)
5e9447430SMauro Carvalho Chehab====================================
6e9447430SMauro Carvalho Chehab
7e9447430SMauro Carvalho ChehabFLIC handles floating (non per-cpu) interrupts, i.e. I/O, service and some
8e9447430SMauro Carvalho Chehabmachine check interruptions. All interrupts are stored in a per-vm list of
9e9447430SMauro Carvalho Chehabpending interrupts. FLIC performs operations on this list.
10e9447430SMauro Carvalho Chehab
11e9447430SMauro Carvalho ChehabOnly one FLIC instance may be instantiated.
12e9447430SMauro Carvalho Chehab
13e9447430SMauro Carvalho ChehabFLIC provides support to
14e9447430SMauro Carvalho Chehab- add interrupts (KVM_DEV_FLIC_ENQUEUE)
15e9447430SMauro Carvalho Chehab- inspect currently pending interrupts (KVM_FLIC_GET_ALL_IRQS)
16e9447430SMauro Carvalho Chehab- purge all pending floating interrupts (KVM_DEV_FLIC_CLEAR_IRQS)
17e9447430SMauro Carvalho Chehab- purge one pending floating I/O interrupt (KVM_DEV_FLIC_CLEAR_IO_IRQ)
18e9447430SMauro Carvalho Chehab- enable/disable for the guest transparent async page faults
19e9447430SMauro Carvalho Chehab- register and modify adapter interrupt sources (KVM_DEV_FLIC_ADAPTER_*)
20e9447430SMauro Carvalho Chehab- modify AIS (adapter-interruption-suppression) mode state (KVM_DEV_FLIC_AISM)
21e9447430SMauro Carvalho Chehab- inject adapter interrupts on a specified adapter (KVM_DEV_FLIC_AIRQ_INJECT)
22e9447430SMauro Carvalho Chehab- get/set all AIS mode states (KVM_DEV_FLIC_AISM_ALL)
23e9447430SMauro Carvalho Chehab
24e9447430SMauro Carvalho ChehabGroups:
25e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_ENQUEUE
26e9447430SMauro Carvalho Chehab    Passes a buffer and length into the kernel which are then injected into
27e9447430SMauro Carvalho Chehab    the list of pending interrupts.
28e9447430SMauro Carvalho Chehab    attr->addr contains the pointer to the buffer and attr->attr contains
29e9447430SMauro Carvalho Chehab    the length of the buffer.
30e9447430SMauro Carvalho Chehab    The format of the data structure kvm_s390_irq as it is copied from userspace
31e9447430SMauro Carvalho Chehab    is defined in usr/include/linux/kvm.h.
32e9447430SMauro Carvalho Chehab
33e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_GET_ALL_IRQS
34e9447430SMauro Carvalho Chehab    Copies all floating interrupts into a buffer provided by userspace.
35e9447430SMauro Carvalho Chehab    When the buffer is too small it returns -ENOMEM, which is the indication
36e9447430SMauro Carvalho Chehab    for userspace to try again with a bigger buffer.
37e9447430SMauro Carvalho Chehab
38e9447430SMauro Carvalho Chehab    -ENOBUFS is returned when the allocation of a kernelspace buffer has
39e9447430SMauro Carvalho Chehab    failed.
40e9447430SMauro Carvalho Chehab
41e9447430SMauro Carvalho Chehab    -EFAULT is returned when copying data to userspace failed.
42e9447430SMauro Carvalho Chehab    All interrupts remain pending, i.e. are not deleted from the list of
43e9447430SMauro Carvalho Chehab    currently pending interrupts.
44e9447430SMauro Carvalho Chehab    attr->addr contains the userspace address of the buffer into which all
45e9447430SMauro Carvalho Chehab    interrupt data will be copied.
46e9447430SMauro Carvalho Chehab    attr->attr contains the size of the buffer in bytes.
47e9447430SMauro Carvalho Chehab
48e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_CLEAR_IRQS
49e9447430SMauro Carvalho Chehab    Simply deletes all elements from the list of currently pending floating
50e9447430SMauro Carvalho Chehab    interrupts.  No interrupts are injected into the guest.
51e9447430SMauro Carvalho Chehab
52e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_CLEAR_IO_IRQ
53e9447430SMauro Carvalho Chehab    Deletes one (if any) I/O interrupt for a subchannel identified by the
54e9447430SMauro Carvalho Chehab    subsystem identification word passed via the buffer specified by
55e9447430SMauro Carvalho Chehab    attr->addr (address) and attr->attr (length).
56e9447430SMauro Carvalho Chehab
57e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_APF_ENABLE
58e9447430SMauro Carvalho Chehab    Enables async page faults for the guest. So in case of a major page fault
59e9447430SMauro Carvalho Chehab    the host is allowed to handle this async and continues the guest.
60e9447430SMauro Carvalho Chehab
61e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_APF_DISABLE_WAIT
62e9447430SMauro Carvalho Chehab    Disables async page faults for the guest and waits until already pending
63e9447430SMauro Carvalho Chehab    async page faults are done. This is necessary to trigger a completion interrupt
64e9447430SMauro Carvalho Chehab    for every init interrupt before migrating the interrupt list.
65e9447430SMauro Carvalho Chehab
66e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_ADAPTER_REGISTER
67e9447430SMauro Carvalho Chehab    Register an I/O adapter interrupt source. Takes a kvm_s390_io_adapter
68e9447430SMauro Carvalho Chehab    describing the adapter to register::
69e9447430SMauro Carvalho Chehab
70e9447430SMauro Carvalho Chehab	struct kvm_s390_io_adapter {
71e9447430SMauro Carvalho Chehab		__u32 id;
72e9447430SMauro Carvalho Chehab		__u8 isc;
73e9447430SMauro Carvalho Chehab		__u8 maskable;
74e9447430SMauro Carvalho Chehab		__u8 swap;
75e9447430SMauro Carvalho Chehab		__u8 flags;
76e9447430SMauro Carvalho Chehab	};
77e9447430SMauro Carvalho Chehab
78e9447430SMauro Carvalho Chehab   id contains the unique id for the adapter, isc the I/O interruption subclass
79e9447430SMauro Carvalho Chehab   to use, maskable whether this adapter may be masked (interrupts turned off),
80e9447430SMauro Carvalho Chehab   swap whether the indicators need to be byte swapped, and flags contains
81e9447430SMauro Carvalho Chehab   further characteristics of the adapter.
82e9447430SMauro Carvalho Chehab
83e9447430SMauro Carvalho Chehab   Currently defined values for 'flags' are:
84e9447430SMauro Carvalho Chehab
85e9447430SMauro Carvalho Chehab   - KVM_S390_ADAPTER_SUPPRESSIBLE: adapter is subject to AIS
86e9447430SMauro Carvalho Chehab     (adapter-interrupt-suppression) facility. This flag only has an effect if
87e9447430SMauro Carvalho Chehab     the AIS capability is enabled.
88e9447430SMauro Carvalho Chehab
89e9447430SMauro Carvalho Chehab   Unknown flag values are ignored.
90e9447430SMauro Carvalho Chehab
91e9447430SMauro Carvalho Chehab
92e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_ADAPTER_MODIFY
93e9447430SMauro Carvalho Chehab    Modifies attributes of an existing I/O adapter interrupt source. Takes
94e9447430SMauro Carvalho Chehab    a kvm_s390_io_adapter_req specifying the adapter and the operation::
95e9447430SMauro Carvalho Chehab
96e9447430SMauro Carvalho Chehab	struct kvm_s390_io_adapter_req {
97e9447430SMauro Carvalho Chehab		__u32 id;
98e9447430SMauro Carvalho Chehab		__u8 type;
99e9447430SMauro Carvalho Chehab		__u8 mask;
100e9447430SMauro Carvalho Chehab		__u16 pad0;
101e9447430SMauro Carvalho Chehab		__u64 addr;
102e9447430SMauro Carvalho Chehab	};
103e9447430SMauro Carvalho Chehab
104e9447430SMauro Carvalho Chehab    id specifies the adapter and type the operation. The supported operations
105e9447430SMauro Carvalho Chehab    are:
106e9447430SMauro Carvalho Chehab
107e9447430SMauro Carvalho Chehab    KVM_S390_IO_ADAPTER_MASK
108e9447430SMauro Carvalho Chehab      mask or unmask the adapter, as specified in mask
109e9447430SMauro Carvalho Chehab
110e9447430SMauro Carvalho Chehab    KVM_S390_IO_ADAPTER_MAP
111f6547066SUlrich Weigand      This is now a no-op. The mapping is purely done by the irq route.
112e9447430SMauro Carvalho Chehab    KVM_S390_IO_ADAPTER_UNMAP
113f6547066SUlrich Weigand      This is now a no-op. The mapping is purely done by the irq route.
114e9447430SMauro Carvalho Chehab
115e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_AISM
116e9447430SMauro Carvalho Chehab    modify the adapter-interruption-suppression mode for a given isc if the
117e9447430SMauro Carvalho Chehab    AIS capability is enabled. Takes a kvm_s390_ais_req describing::
118e9447430SMauro Carvalho Chehab
119e9447430SMauro Carvalho Chehab	struct kvm_s390_ais_req {
120e9447430SMauro Carvalho Chehab		__u8 isc;
121e9447430SMauro Carvalho Chehab		__u16 mode;
122e9447430SMauro Carvalho Chehab	};
123e9447430SMauro Carvalho Chehab
124e9447430SMauro Carvalho Chehab    isc contains the target I/O interruption subclass, mode the target
125e9447430SMauro Carvalho Chehab    adapter-interruption-suppression mode. The following modes are
126e9447430SMauro Carvalho Chehab    currently supported:
127e9447430SMauro Carvalho Chehab
128e9447430SMauro Carvalho Chehab    - KVM_S390_AIS_MODE_ALL: ALL-Interruptions Mode, i.e. airq injection
129e9447430SMauro Carvalho Chehab      is always allowed;
130e9447430SMauro Carvalho Chehab    - KVM_S390_AIS_MODE_SINGLE: SINGLE-Interruption Mode, i.e. airq
131e9447430SMauro Carvalho Chehab      injection is only allowed once and the following adapter interrupts
132e9447430SMauro Carvalho Chehab      will be suppressed until the mode is set again to ALL-Interruptions
133e9447430SMauro Carvalho Chehab      or SINGLE-Interruption mode.
134e9447430SMauro Carvalho Chehab
135e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_AIRQ_INJECT
136e9447430SMauro Carvalho Chehab    Inject adapter interrupts on a specified adapter.
137e9447430SMauro Carvalho Chehab    attr->attr contains the unique id for the adapter, which allows for
138e9447430SMauro Carvalho Chehab    adapter-specific checks and actions.
139e9447430SMauro Carvalho Chehab    For adapters subject to AIS, handle the airq injection suppression for
140e9447430SMauro Carvalho Chehab    an isc according to the adapter-interruption-suppression mode on condition
141e9447430SMauro Carvalho Chehab    that the AIS capability is enabled.
142e9447430SMauro Carvalho Chehab
143e9447430SMauro Carvalho Chehab  KVM_DEV_FLIC_AISM_ALL
144e9447430SMauro Carvalho Chehab    Gets or sets the adapter-interruption-suppression mode for all ISCs. Takes
145e9447430SMauro Carvalho Chehab    a kvm_s390_ais_all describing::
146e9447430SMauro Carvalho Chehab
147e9447430SMauro Carvalho Chehab	struct kvm_s390_ais_all {
148e9447430SMauro Carvalho Chehab	       __u8 simm; /* Single-Interruption-Mode mask */
149e9447430SMauro Carvalho Chehab	       __u8 nimm; /* No-Interruption-Mode mask *
150e9447430SMauro Carvalho Chehab	};
151e9447430SMauro Carvalho Chehab
152e9447430SMauro Carvalho Chehab    simm contains Single-Interruption-Mode mask for all ISCs, nimm contains
153e9447430SMauro Carvalho Chehab    No-Interruption-Mode mask for all ISCs. Each bit in simm and nimm corresponds
154e9447430SMauro Carvalho Chehab    to an ISC (MSB0 bit 0 to ISC 0 and so on). The combination of simm bit and
155e9447430SMauro Carvalho Chehab    nimm bit presents AIS mode for a ISC.
156e9447430SMauro Carvalho Chehab
157e9447430SMauro Carvalho Chehab    KVM_DEV_FLIC_AISM_ALL is indicated by KVM_CAP_S390_AIS_MIGRATION.
158e9447430SMauro Carvalho Chehab
159e9447430SMauro Carvalho ChehabNote: The KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR device ioctls executed on
160e9447430SMauro Carvalho ChehabFLIC with an unknown group or attribute gives the error code EINVAL (instead of
161e9447430SMauro Carvalho ChehabENXIO, as specified in the API documentation). It is not possible to conclude
162e9447430SMauro Carvalho Chehabthat a FLIC operation is unavailable based on the error code resulting from a
163e9447430SMauro Carvalho Chehabusage attempt.
164e9447430SMauro Carvalho Chehab
165e9447430SMauro Carvalho Chehab.. note:: The KVM_DEV_FLIC_CLEAR_IO_IRQ ioctl will return EINVAL in case a
166e9447430SMauro Carvalho Chehab	  zero schid is specified.
167