This source file includes following definitions.
- vmci_deny_interaction
- vmci_ctx_get_id
1
2
3
4
5
6
7
8 #ifndef _VMCI_CONTEXT_H_
9 #define _VMCI_CONTEXT_H_
10
11 #include <linux/vmw_vmci_defs.h>
12 #include <linux/atomic.h>
13 #include <linux/kref.h>
14 #include <linux/types.h>
15 #include <linux/wait.h>
16
17 #include "vmci_handle_array.h"
18 #include "vmci_datagram.h"
19
20
21 enum {
22 VMCI_NOTIFICATION_CPT_STATE = 1,
23 VMCI_WELLKNOWN_CPT_STATE = 2,
24 VMCI_DG_OUT_STATE = 3,
25 VMCI_DG_IN_STATE = 4,
26 VMCI_DG_IN_SIZE_STATE = 5,
27 VMCI_DOORBELL_CPT_STATE = 6,
28 };
29
30
31 struct vmci_host {
32 wait_queue_head_t wait_queue;
33 };
34
35 struct vmci_handle_list {
36 struct list_head node;
37 struct vmci_handle handle;
38 };
39
40 struct vmci_ctx {
41 struct list_head list_item;
42 u32 cid;
43 struct kref kref;
44 struct list_head datagram_queue;
45 u32 pending_datagrams;
46 size_t datagram_queue_size;
47
48
49
50
51
52 int user_version;
53 spinlock_t lock;
54
55
56
57
58
59
60
61
62
63
64
65 struct vmci_handle_arr *queue_pair_array;
66
67
68 struct vmci_handle_arr *doorbell_array;
69
70
71 struct vmci_handle_arr *pending_doorbell_array;
72
73
74 struct list_head notifier_list;
75 unsigned int n_notifiers;
76
77 struct vmci_host host_context;
78 u32 priv_flags;
79
80 const struct cred *cred;
81 bool *notify;
82 struct page *notify_page;
83 };
84
85
86 struct vmci_ctx_info {
87 u32 remote_cid;
88 int result;
89 };
90
91
92 struct vmci_ctx_chkpt_buf_info {
93 u64 cpt_buf;
94 u32 cpt_type;
95 u32 buf_size;
96 s32 result;
97 u32 _pad;
98 };
99
100
101
102
103
104 struct vmci_ctx_notify_recv_info {
105 u64 db_handle_buf_uva;
106 u64 db_handle_buf_size;
107 u64 qp_handle_buf_uva;
108 u64 qp_handle_buf_size;
109 s32 result;
110 u32 _pad;
111 };
112
113
114
115
116
117
118 static inline bool vmci_deny_interaction(u32 part_one, u32 part_two)
119 {
120 return ((part_one & VMCI_PRIVILEGE_FLAG_RESTRICTED) &&
121 !(part_two & VMCI_PRIVILEGE_FLAG_TRUSTED)) ||
122 ((part_two & VMCI_PRIVILEGE_FLAG_RESTRICTED) &&
123 !(part_one & VMCI_PRIVILEGE_FLAG_TRUSTED));
124 }
125
126 struct vmci_ctx *vmci_ctx_create(u32 cid, u32 flags,
127 uintptr_t event_hnd, int version,
128 const struct cred *cred);
129 void vmci_ctx_destroy(struct vmci_ctx *context);
130
131 bool vmci_ctx_supports_host_qp(struct vmci_ctx *context);
132 int vmci_ctx_enqueue_datagram(u32 cid, struct vmci_datagram *dg);
133 int vmci_ctx_dequeue_datagram(struct vmci_ctx *context,
134 size_t *max_size, struct vmci_datagram **dg);
135 int vmci_ctx_pending_datagrams(u32 cid, u32 *pending);
136 struct vmci_ctx *vmci_ctx_get(u32 cid);
137 void vmci_ctx_put(struct vmci_ctx *context);
138 bool vmci_ctx_exists(u32 cid);
139
140 int vmci_ctx_add_notification(u32 context_id, u32 remote_cid);
141 int vmci_ctx_remove_notification(u32 context_id, u32 remote_cid);
142 int vmci_ctx_get_chkpt_state(u32 context_id, u32 cpt_type,
143 u32 *num_cids, void **cpt_buf_ptr);
144 int vmci_ctx_set_chkpt_state(u32 context_id, u32 cpt_type,
145 u32 num_cids, void *cpt_buf);
146
147 int vmci_ctx_qp_create(struct vmci_ctx *context, struct vmci_handle handle);
148 int vmci_ctx_qp_destroy(struct vmci_ctx *context, struct vmci_handle handle);
149 bool vmci_ctx_qp_exists(struct vmci_ctx *context, struct vmci_handle handle);
150
151 void vmci_ctx_check_signal_notify(struct vmci_ctx *context);
152 void vmci_ctx_unset_notify(struct vmci_ctx *context);
153
154 int vmci_ctx_dbell_create(u32 context_id, struct vmci_handle handle);
155 int vmci_ctx_dbell_destroy(u32 context_id, struct vmci_handle handle);
156 int vmci_ctx_dbell_destroy_all(u32 context_id);
157 int vmci_ctx_notify_dbell(u32 cid, struct vmci_handle handle,
158 u32 src_priv_flags);
159
160 int vmci_ctx_rcv_notifications_get(u32 context_id, struct vmci_handle_arr
161 **db_handle_array, struct vmci_handle_arr
162 **qp_handle_array);
163 void vmci_ctx_rcv_notifications_release(u32 context_id, struct vmci_handle_arr
164 *db_handle_array, struct vmci_handle_arr
165 *qp_handle_array, bool success);
166
167 static inline u32 vmci_ctx_get_id(struct vmci_ctx *context)
168 {
169 if (!context)
170 return VMCI_INVALID_ID;
171 return context->cid;
172 }
173
174 #endif