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