History

vringh: IOTLB support

This patch implements the third memory accessor for vringh besides current kernel and userspace accessors. This idea is to allow vringh to do the address translation through an IOTLB which is implemented via vhost_map interval tree. Users should setup and IOVA to PA mapping in this IOTLB. This allows us to: - Use vringh to access virtqueues with vIOMMU - Use vringh to implement software virtqueues for vDPA devices

Jason Wang committed 6 years ago

Commit 9ad9c491 parent 0bbe3063 files · +435 −23Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/vringh.h+36−0
@@ -14,6 +14,8 @@ · 13 unmodified lines
1414 #include <linux/virtio_byteorder.h>
1515 #include <linux/uio.h>
1616 #include <linux/slab.h>
17+#include <linux/dma-direction.h>
18+#include <linux/vhost_iotlb.h>
1719 #include <asm/barrier.h>
1820
1921 /* virtio_ring with information needed for host access. */
@@ -39,6 +41,9 @@ struct vringh { · 19 unmodified lines
3941 /* The vring (note: it may contain user pointers!) */
4042 struct vring vring;
4143
44+ /* IOTLB for this vring */
45+ struct vhost_iotlb *iotlb;
46+
4247 /* The function to call to notify the guest about added buffers */
4348 void (*notify)(struct vringh *);
4449 };
@@ -248,4 +253,35 @@ static inline __virtio64 cpu_to_vringh64(const struct vringh *vrh, u64 val) · 203 unmodified lines
248253 {
249254 return __cpu_to_virtio64(vringh_is_little_endian(vrh), val);
250255 }
256+
257+void vringh_set_iotlb(struct vringh *vrh, struct vhost_iotlb *iotlb);
258+
259+int vringh_init_iotlb(struct vringh *vrh, u64 features,
260+ unsigned int num, bool weak_barriers,
261+ struct vring_desc *desc,
262+ struct vring_avail *avail,
263+ struct vring_used *used);
264+
265+int vringh_getdesc_iotlb(struct vringh *vrh,
266+ struct vringh_kiov *riov,
267+ struct vringh_kiov *wiov,
268+ u16 *head,
269+ gfp_t gfp);
270+
271+ssize_t vringh_iov_pull_iotlb(struct vringh *vrh,
272+ struct vringh_kiov *riov,
273+ void *dst, size_t len);
274+ssize_t vringh_iov_push_iotlb(struct vringh *vrh,
275+ struct vringh_kiov *wiov,
276+ const void *src, size_t len);
277+
278+void vringh_abandon_iotlb(struct vringh *vrh, unsigned int num);
279+
280+int vringh_complete_iotlb(struct vringh *vrh, u16 head, u32 len);
281+
282+bool vringh_notify_enable_iotlb(struct vringh *vrh);
283+void vringh_notify_disable_iotlb(struct vringh *vrh);
284+
285+int vringh_need_notify_iotlb(struct vringh *vrh);
286+
251287 #endif /* _LINUX_VRINGH_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t