1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | /* |
3 | * Copyright (c) 2022, Oracle and/or its affiliates. |
4 | * Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved |
5 | */ |
6 | #ifndef _IOVA_BITMAP_H_ |
7 | #define _IOVA_BITMAP_H_ |
8 | |
9 | #include <linux/types.h> |
10 | #include <linux/errno.h> |
11 | |
12 | struct iova_bitmap; |
13 | |
14 | typedef int (*iova_bitmap_fn_t)(struct iova_bitmap *bitmap, |
15 | unsigned long iova, size_t length, |
16 | void *opaque); |
17 | |
18 | #if IS_ENABLED(CONFIG_IOMMUFD_DRIVER) |
19 | struct iova_bitmap *iova_bitmap_alloc(unsigned long iova, size_t length, |
20 | unsigned long page_size, |
21 | u64 __user *data); |
22 | void iova_bitmap_free(struct iova_bitmap *bitmap); |
23 | int iova_bitmap_for_each(struct iova_bitmap *bitmap, void *opaque, |
24 | iova_bitmap_fn_t fn); |
25 | void iova_bitmap_set(struct iova_bitmap *bitmap, |
26 | unsigned long iova, size_t length); |
27 | #else |
28 | static inline struct iova_bitmap *iova_bitmap_alloc(unsigned long iova, |
29 | size_t length, |
30 | unsigned long page_size, |
31 | u64 __user *data) |
32 | { |
33 | return NULL; |
34 | } |
35 | |
36 | static inline void iova_bitmap_free(struct iova_bitmap *bitmap) |
37 | { |
38 | } |
39 | |
40 | static inline int iova_bitmap_for_each(struct iova_bitmap *bitmap, void *opaque, |
41 | iova_bitmap_fn_t fn) |
42 | { |
43 | return -EOPNOTSUPP; |
44 | } |
45 | |
46 | static inline void iova_bitmap_set(struct iova_bitmap *bitmap, |
47 | unsigned long iova, size_t length) |
48 | { |
49 | } |
50 | #endif |
51 | |
52 | #endif |
53 | |