2017-03-17 04:17:31 +01:00
|
|
|
/*
|
|
|
|
* Private stuff for vfio_ccw driver
|
|
|
|
*
|
|
|
|
* Copyright IBM Corp. 2017
|
|
|
|
*
|
|
|
|
* Author(s): Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
|
|
|
|
* Xiao Feng Ren <renxiaof@linux.vnet.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _VFIO_CCW_PRIVATE_H_
|
|
|
|
#define _VFIO_CCW_PRIVATE_H_
|
|
|
|
|
2017-03-17 04:17:35 +01:00
|
|
|
#include <linux/completion.h>
|
2017-03-17 04:17:38 +01:00
|
|
|
#include <linux/eventfd.h>
|
2017-03-17 04:17:39 +01:00
|
|
|
#include <linux/workqueue.h>
|
2017-03-17 04:17:34 +01:00
|
|
|
#include <linux/vfio_ccw.h>
|
|
|
|
|
2017-03-17 04:17:31 +01:00
|
|
|
#include "css.h"
|
2017-03-17 04:17:35 +01:00
|
|
|
#include "vfio_ccw_cp.h"
|
2017-03-17 04:17:31 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct vfio_ccw_private
|
|
|
|
* @sch: pointer to the subchannel
|
2017-03-17 04:17:40 +01:00
|
|
|
* @state: internal state of the device
|
2017-03-17 04:17:31 +01:00
|
|
|
* @completion: synchronization helper of the I/O completion
|
2017-03-17 04:17:33 +01:00
|
|
|
* @avail: available for creating a mediated device
|
|
|
|
* @mdev: pointer to the mediated device
|
|
|
|
* @nb: notifier for vfio events
|
2017-03-17 04:17:34 +01:00
|
|
|
* @io_region: MMIO region to input/output I/O arguments/results
|
2017-03-17 04:17:35 +01:00
|
|
|
* @cp: channel program for the current I/O operation
|
|
|
|
* @irb: irb info received from interrupt
|
|
|
|
* @scsw: scsw info
|
2017-03-17 04:17:38 +01:00
|
|
|
* @io_trigger: eventfd ctx for signaling userspace I/O results
|
2017-03-17 04:17:39 +01:00
|
|
|
* @io_work: work for deferral process of I/O handling
|
2017-03-17 04:17:31 +01:00
|
|
|
*/
|
|
|
|
struct vfio_ccw_private {
|
|
|
|
struct subchannel *sch;
|
2017-03-17 04:17:40 +01:00
|
|
|
int state;
|
2017-03-17 04:17:31 +01:00
|
|
|
struct completion *completion;
|
2017-03-17 04:17:33 +01:00
|
|
|
atomic_t avail;
|
|
|
|
struct mdev_device *mdev;
|
|
|
|
struct notifier_block nb;
|
2017-03-17 04:17:34 +01:00
|
|
|
struct ccw_io_region io_region;
|
2017-03-17 04:17:35 +01:00
|
|
|
|
|
|
|
struct channel_program cp;
|
|
|
|
struct irb irb;
|
|
|
|
union scsw scsw;
|
2017-03-17 04:17:38 +01:00
|
|
|
|
|
|
|
struct eventfd_ctx *io_trigger;
|
2017-03-17 04:17:39 +01:00
|
|
|
struct work_struct io_work;
|
2017-03-17 04:17:31 +01:00
|
|
|
} __aligned(8);
|
|
|
|
|
2017-03-17 04:17:33 +01:00
|
|
|
extern int vfio_ccw_mdev_reg(struct subchannel *sch);
|
|
|
|
extern void vfio_ccw_mdev_unreg(struct subchannel *sch);
|
|
|
|
|
|
|
|
extern int vfio_ccw_sch_quiesce(struct subchannel *sch);
|
2017-03-17 04:17:40 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* States of the device statemachine.
|
|
|
|
*/
|
|
|
|
enum vfio_ccw_state {
|
|
|
|
VFIO_CCW_STATE_NOT_OPER,
|
|
|
|
VFIO_CCW_STATE_STANDBY,
|
|
|
|
VFIO_CCW_STATE_IDLE,
|
|
|
|
VFIO_CCW_STATE_BOXED,
|
|
|
|
VFIO_CCW_STATE_BUSY,
|
|
|
|
/* last element! */
|
|
|
|
NR_VFIO_CCW_STATES
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Asynchronous events of the device statemachine.
|
|
|
|
*/
|
|
|
|
enum vfio_ccw_event {
|
|
|
|
VFIO_CCW_EVENT_NOT_OPER,
|
|
|
|
VFIO_CCW_EVENT_IO_REQ,
|
|
|
|
VFIO_CCW_EVENT_INTERRUPT,
|
|
|
|
/* last element! */
|
|
|
|
NR_VFIO_CCW_EVENTS
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Action called through jumptable.
|
|
|
|
*/
|
|
|
|
typedef void (fsm_func_t)(struct vfio_ccw_private *, enum vfio_ccw_event);
|
|
|
|
extern fsm_func_t *vfio_ccw_jumptable[NR_VFIO_CCW_STATES][NR_VFIO_CCW_EVENTS];
|
|
|
|
|
|
|
|
static inline void vfio_ccw_fsm_event(struct vfio_ccw_private *private,
|
|
|
|
int event)
|
|
|
|
{
|
|
|
|
vfio_ccw_jumptable[private->state][event](private, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern struct workqueue_struct *vfio_ccw_work_q;
|
2017-03-17 04:17:33 +01:00
|
|
|
|
2017-03-17 04:17:31 +01:00
|
|
|
#endif
|