]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - drivers/s390/cio/vfio_ccw_private.h
Merge tag 'xtensa-20170612' of git://github.com/jcmvbkbc/linux-xtensa
[mirror_ubuntu-focal-kernel.git] / drivers / s390 / cio / vfio_ccw_private.h
1 /*
2 * Private stuff for vfio_ccw driver
3 *
4 * Copyright IBM Corp. 2017
5 *
6 * Author(s): Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
7 * Xiao Feng Ren <renxiaof@linux.vnet.ibm.com>
8 */
9
10 #ifndef _VFIO_CCW_PRIVATE_H_
11 #define _VFIO_CCW_PRIVATE_H_
12
13 #include <linux/completion.h>
14 #include <linux/eventfd.h>
15 #include <linux/workqueue.h>
16 #include <linux/vfio_ccw.h>
17
18 #include "css.h"
19 #include "vfio_ccw_cp.h"
20
21 /**
22 * struct vfio_ccw_private
23 * @sch: pointer to the subchannel
24 * @state: internal state of the device
25 * @completion: synchronization helper of the I/O completion
26 * @avail: available for creating a mediated device
27 * @mdev: pointer to the mediated device
28 * @nb: notifier for vfio events
29 * @io_region: MMIO region to input/output I/O arguments/results
30 * @cp: channel program for the current I/O operation
31 * @irb: irb info received from interrupt
32 * @scsw: scsw info
33 * @io_trigger: eventfd ctx for signaling userspace I/O results
34 * @io_work: work for deferral process of I/O handling
35 */
36 struct vfio_ccw_private {
37 struct subchannel *sch;
38 int state;
39 struct completion *completion;
40 atomic_t avail;
41 struct mdev_device *mdev;
42 struct notifier_block nb;
43 struct ccw_io_region io_region;
44
45 struct channel_program cp;
46 struct irb irb;
47 union scsw scsw;
48
49 struct eventfd_ctx *io_trigger;
50 struct work_struct io_work;
51 } __aligned(8);
52
53 extern int vfio_ccw_mdev_reg(struct subchannel *sch);
54 extern void vfio_ccw_mdev_unreg(struct subchannel *sch);
55
56 extern int vfio_ccw_sch_quiesce(struct subchannel *sch);
57
58 /*
59 * States of the device statemachine.
60 */
61 enum vfio_ccw_state {
62 VFIO_CCW_STATE_NOT_OPER,
63 VFIO_CCW_STATE_STANDBY,
64 VFIO_CCW_STATE_IDLE,
65 VFIO_CCW_STATE_BOXED,
66 VFIO_CCW_STATE_BUSY,
67 /* last element! */
68 NR_VFIO_CCW_STATES
69 };
70
71 /*
72 * Asynchronous events of the device statemachine.
73 */
74 enum vfio_ccw_event {
75 VFIO_CCW_EVENT_NOT_OPER,
76 VFIO_CCW_EVENT_IO_REQ,
77 VFIO_CCW_EVENT_INTERRUPT,
78 /* last element! */
79 NR_VFIO_CCW_EVENTS
80 };
81
82 /*
83 * Action called through jumptable.
84 */
85 typedef void (fsm_func_t)(struct vfio_ccw_private *, enum vfio_ccw_event);
86 extern fsm_func_t *vfio_ccw_jumptable[NR_VFIO_CCW_STATES][NR_VFIO_CCW_EVENTS];
87
88 static inline void vfio_ccw_fsm_event(struct vfio_ccw_private *private,
89 int event)
90 {
91 vfio_ccw_jumptable[private->state][event](private, event);
92 }
93
94 extern struct workqueue_struct *vfio_ccw_work_q;
95
96 #endif