This source file includes following definitions.
- vfio_ccw_fsm_event
- VFIO_CCW_HEX_EVENT
1
2
3
4
5
6
7
8
9
10
11
12
13 #ifndef _VFIO_CCW_PRIVATE_H_
14 #define _VFIO_CCW_PRIVATE_H_
15
16 #include <linux/completion.h>
17 #include <linux/eventfd.h>
18 #include <linux/workqueue.h>
19 #include <linux/vfio_ccw.h>
20 #include <asm/debug.h>
21
22 #include "css.h"
23 #include "vfio_ccw_cp.h"
24
25 #define VFIO_CCW_OFFSET_SHIFT 10
26 #define VFIO_CCW_OFFSET_TO_INDEX(off) (off >> VFIO_CCW_OFFSET_SHIFT)
27 #define VFIO_CCW_INDEX_TO_OFFSET(index) ((u64)(index) << VFIO_CCW_OFFSET_SHIFT)
28 #define VFIO_CCW_OFFSET_MASK (((u64)(1) << VFIO_CCW_OFFSET_SHIFT) - 1)
29
30
31 struct vfio_ccw_private;
32 struct vfio_ccw_region;
33
34 struct vfio_ccw_regops {
35 ssize_t (*read)(struct vfio_ccw_private *private, char __user *buf,
36 size_t count, loff_t *ppos);
37 ssize_t (*write)(struct vfio_ccw_private *private,
38 const char __user *buf, size_t count, loff_t *ppos);
39 void (*release)(struct vfio_ccw_private *private,
40 struct vfio_ccw_region *region);
41 };
42
43 struct vfio_ccw_region {
44 u32 type;
45 u32 subtype;
46 const struct vfio_ccw_regops *ops;
47 void *data;
48 size_t size;
49 u32 flags;
50 };
51
52 int vfio_ccw_register_dev_region(struct vfio_ccw_private *private,
53 unsigned int subtype,
54 const struct vfio_ccw_regops *ops,
55 size_t size, u32 flags, void *data);
56
57 int vfio_ccw_register_async_dev_regions(struct vfio_ccw_private *private);
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 struct vfio_ccw_private {
79 struct subchannel *sch;
80 int state;
81 struct completion *completion;
82 atomic_t avail;
83 struct mdev_device *mdev;
84 struct notifier_block nb;
85 struct ccw_io_region *io_region;
86 struct mutex io_mutex;
87 struct vfio_ccw_region *region;
88 struct ccw_cmd_region *cmd_region;
89 int num_regions;
90
91 struct channel_program cp;
92 struct irb irb;
93 union scsw scsw;
94
95 struct eventfd_ctx *io_trigger;
96 struct work_struct io_work;
97 } __aligned(8);
98
99 extern int vfio_ccw_mdev_reg(struct subchannel *sch);
100 extern void vfio_ccw_mdev_unreg(struct subchannel *sch);
101
102 extern int vfio_ccw_sch_quiesce(struct subchannel *sch);
103
104
105
106
107 enum vfio_ccw_state {
108 VFIO_CCW_STATE_NOT_OPER,
109 VFIO_CCW_STATE_STANDBY,
110 VFIO_CCW_STATE_IDLE,
111 VFIO_CCW_STATE_CP_PROCESSING,
112 VFIO_CCW_STATE_CP_PENDING,
113
114 NR_VFIO_CCW_STATES
115 };
116
117
118
119
120 enum vfio_ccw_event {
121 VFIO_CCW_EVENT_NOT_OPER,
122 VFIO_CCW_EVENT_IO_REQ,
123 VFIO_CCW_EVENT_INTERRUPT,
124 VFIO_CCW_EVENT_ASYNC_REQ,
125
126 NR_VFIO_CCW_EVENTS
127 };
128
129
130
131
132 typedef void (fsm_func_t)(struct vfio_ccw_private *, enum vfio_ccw_event);
133 extern fsm_func_t *vfio_ccw_jumptable[NR_VFIO_CCW_STATES][NR_VFIO_CCW_EVENTS];
134
135 static inline void vfio_ccw_fsm_event(struct vfio_ccw_private *private,
136 int event)
137 {
138 vfio_ccw_jumptable[private->state][event](private, event);
139 }
140
141 extern struct workqueue_struct *vfio_ccw_work_q;
142
143
144
145 extern debug_info_t *vfio_ccw_debug_msg_id;
146 extern debug_info_t *vfio_ccw_debug_trace_id;
147
148 #define VFIO_CCW_TRACE_EVENT(imp, txt) \
149 debug_text_event(vfio_ccw_debug_trace_id, imp, txt)
150
151 #define VFIO_CCW_MSG_EVENT(imp, args...) \
152 debug_sprintf_event(vfio_ccw_debug_msg_id, imp, ##args)
153
154 static inline void VFIO_CCW_HEX_EVENT(int level, void *data, int length)
155 {
156 debug_event(vfio_ccw_debug_trace_id, level, data, length);
157 }
158
159 #endif