1 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
3 * Copyright(c) 2020 Cornelis Networks, Inc.
4 * Copyright(c) 2016 Intel Corporation.
17 struct mmu_rb_handler *handler;
18 struct list_head list;
22 * NOTE: filter, insert, invalidate, and evict must not sleep. Only remove is
26 bool (*filter)(struct mmu_rb_node *node, unsigned long addr,
28 int (*insert)(void *ops_arg, struct mmu_rb_node *mnode);
29 void (*remove)(void *ops_arg, struct mmu_rb_node *mnode);
30 int (*invalidate)(void *ops_arg, struct mmu_rb_node *node);
31 int (*evict)(void *ops_arg, struct mmu_rb_node *mnode,
32 void *evict_arg, bool *stop);
35 struct mmu_rb_handler {
36 struct mmu_notifier mn;
37 struct rb_root_cached root;
39 spinlock_t lock; /* protect the RB tree */
40 struct mmu_rb_ops *ops;
41 struct list_head lru_list;
42 struct work_struct del_work;
43 struct list_head del_list;
44 struct workqueue_struct *wq;
47 int hfi1_mmu_rb_register(void *ops_arg,
48 struct mmu_rb_ops *ops,
49 struct workqueue_struct *wq,
50 struct mmu_rb_handler **handler);
51 void hfi1_mmu_rb_unregister(struct mmu_rb_handler *handler);
52 int hfi1_mmu_rb_insert(struct mmu_rb_handler *handler,
53 struct mmu_rb_node *mnode);
54 void hfi1_mmu_rb_evict(struct mmu_rb_handler *handler, void *evict_arg);
55 void hfi1_mmu_rb_remove(struct mmu_rb_handler *handler,
56 struct mmu_rb_node *mnode);
57 bool hfi1_mmu_rb_remove_unless_exact(struct mmu_rb_handler *handler,
58 unsigned long addr, unsigned long len,
59 struct mmu_rb_node **rb_node);
61 #endif /* _HFI1_MMU_RB_H */