hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/include/linux/vringh.h
....@@ -1,23 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Linux host-side vring helpers; for when the kernel needs to access
34 * someone else's vring.
45 *
56 * Copyright IBM Corporation, 2013.
67 * Parts taken from drivers/vhost/vhost.c Copyright 2009 Red Hat, Inc.
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, write to the Free Software
20
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
218 *
229 * Written by: Rusty Russell <rusty@rustcorp.com.au>
2310 */
....@@ -27,6 +14,10 @@
2714 #include <linux/virtio_byteorder.h>
2815 #include <linux/uio.h>
2916 #include <linux/slab.h>
17
+#if IS_REACHABLE(CONFIG_VHOST_IOTLB)
18
+#include <linux/dma-direction.h>
19
+#include <linux/vhost_iotlb.h>
20
+#endif
3021 #include <asm/barrier.h>
3122
3223 /* virtio_ring with information needed for host access. */
....@@ -51,6 +42,9 @@
5142
5243 /* The vring (note: it may contain user pointers!) */
5344 struct vring vring;
45
+
46
+ /* IOTLB for this vring */
47
+ struct vhost_iotlb *iotlb;
5448
5549 /* The function to call to notify the guest about added buffers */
5650 void (*notify)(struct vringh *);
....@@ -111,9 +105,9 @@
111105 /* Helpers for userspace vrings. */
112106 int vringh_init_user(struct vringh *vrh, u64 features,
113107 unsigned int num, bool weak_barriers,
114
- struct vring_desc __user *desc,
115
- struct vring_avail __user *avail,
116
- struct vring_used __user *used);
108
+ vring_desc_t __user *desc,
109
+ vring_avail_t __user *avail,
110
+ vring_used_t __user *used);
117111
118112 static inline void vringh_iov_init(struct vringh_iov *iov,
119113 struct iovec *iovec, unsigned num)
....@@ -261,4 +255,39 @@
261255 {
262256 return __cpu_to_virtio64(vringh_is_little_endian(vrh), val);
263257 }
258
+
259
+#if IS_REACHABLE(CONFIG_VHOST_IOTLB)
260
+
261
+void vringh_set_iotlb(struct vringh *vrh, struct vhost_iotlb *iotlb);
262
+
263
+int vringh_init_iotlb(struct vringh *vrh, u64 features,
264
+ unsigned int num, bool weak_barriers,
265
+ struct vring_desc *desc,
266
+ struct vring_avail *avail,
267
+ struct vring_used *used);
268
+
269
+int vringh_getdesc_iotlb(struct vringh *vrh,
270
+ struct vringh_kiov *riov,
271
+ struct vringh_kiov *wiov,
272
+ u16 *head,
273
+ gfp_t gfp);
274
+
275
+ssize_t vringh_iov_pull_iotlb(struct vringh *vrh,
276
+ struct vringh_kiov *riov,
277
+ void *dst, size_t len);
278
+ssize_t vringh_iov_push_iotlb(struct vringh *vrh,
279
+ struct vringh_kiov *wiov,
280
+ const void *src, size_t len);
281
+
282
+void vringh_abandon_iotlb(struct vringh *vrh, unsigned int num);
283
+
284
+int vringh_complete_iotlb(struct vringh *vrh, u16 head, u32 len);
285
+
286
+bool vringh_notify_enable_iotlb(struct vringh *vrh);
287
+void vringh_notify_disable_iotlb(struct vringh *vrh);
288
+
289
+int vringh_need_notify_iotlb(struct vringh *vrh);
290
+
291
+#endif /* CONFIG_VHOST_IOTLB */
292
+
264293 #endif /* _LINUX_VRINGH_H */