1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Private stuff for vfio_ccw driver
5 * Copyright IBM Corp. 2017
11 #ifndef _VFIO_CCW_PRIVATE_H_
12 #define _VFIO_CCW_PRIVATE_H_
14 #include <linux/completion.h>
15 #include <linux/eventfd.h>
16 #include <linux/workqueue.h>
17 #include <linux/vfio_ccw.h>
20 #include "vfio_ccw_cp.h"
23 * struct vfio_ccw_private
24 * @sch: pointer to the subchannel
25 * @state: internal state of the device
26 * @completion: synchronization helper of the I/O completion
27 * @avail: available for creating a mediated device
28 * @mdev: pointer to the mediated device
29 * @nb: notifier for vfio events
30 * @io_region: MMIO region to input/output I/O arguments/results
31 * @cp: channel program for the current I/O operation
32 * @irb: irb info received from interrupt
34 * @io_trigger: eventfd ctx for signaling userspace I/O results
35 * @io_work: work for deferral process of I/O handling
37 struct vfio_ccw_private {
38 struct subchannel *sch;
40 struct completion *completion;
42 struct mdev_device *mdev;
43 struct notifier_block nb;
44 struct ccw_io_region *io_region;
46 struct channel_program cp;
50 struct eventfd_ctx *io_trigger;
51 struct work_struct io_work;
54 extern int vfio_ccw_mdev_reg(struct subchannel *sch);
55 extern void vfio_ccw_mdev_unreg(struct subchannel *sch);
57 extern int vfio_ccw_sch_quiesce(struct subchannel *sch);
60 * States of the device statemachine.
63 VFIO_CCW_STATE_NOT_OPER,
64 VFIO_CCW_STATE_STANDBY,
73 * Asynchronous events of the device statemachine.
76 VFIO_CCW_EVENT_NOT_OPER,
77 VFIO_CCW_EVENT_IO_REQ,
78 VFIO_CCW_EVENT_INTERRUPT,
84 * Action called through jumptable.
86 typedef void (fsm_func_t)(struct vfio_ccw_private *, enum vfio_ccw_event);
87 extern fsm_func_t *vfio_ccw_jumptable[NR_VFIO_CCW_STATES][NR_VFIO_CCW_EVENTS];
89 static inline void vfio_ccw_fsm_event(struct vfio_ccw_private *private,
92 vfio_ccw_jumptable[private->state][event](private, event);
95 extern struct workqueue_struct *vfio_ccw_work_q;