Merge tag 'mt76-for-kvalo-2020-06-07' of https://github.com/nbd168/wireless
[linux-2.6-block.git] / include / linux / vhost_iotlb.h
CommitLineData
0bbe3066
JW
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_VHOST_IOTLB_H
3#define _LINUX_VHOST_IOTLB_H
4
5#include <linux/interval_tree_generic.h>
6
7struct vhost_iotlb_map {
8 struct rb_node rb;
9 struct list_head link;
10 u64 start;
11 u64 last;
12 u64 size;
13 u64 addr;
14#define VHOST_MAP_RO 0x1
15#define VHOST_MAP_WO 0x2
16#define VHOST_MAP_RW 0x3
17 u32 perm;
18 u32 flags_padding;
19 u64 __subtree_last;
20};
21
22#define VHOST_IOTLB_FLAG_RETIRE 0x1
23
24struct vhost_iotlb {
25 struct rb_root_cached root;
26 struct list_head list;
27 unsigned int limit;
28 unsigned int nmaps;
29 unsigned int flags;
30};
31
32int vhost_iotlb_add_range(struct vhost_iotlb *iotlb, u64 start, u64 last,
33 u64 addr, unsigned int perm);
34void vhost_iotlb_del_range(struct vhost_iotlb *iotlb, u64 start, u64 last);
35
36struct vhost_iotlb *vhost_iotlb_alloc(unsigned int limit, unsigned int flags);
37void vhost_iotlb_free(struct vhost_iotlb *iotlb);
38void vhost_iotlb_reset(struct vhost_iotlb *iotlb);
39
40struct vhost_iotlb_map *
41vhost_iotlb_itree_first(struct vhost_iotlb *iotlb, u64 start, u64 last);
42struct vhost_iotlb_map *
43vhost_iotlb_itree_next(struct vhost_iotlb_map *map, u64 start, u64 last);
44
45void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
46 struct vhost_iotlb_map *map);
47#endif