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 12struct iova_bitmap; 13 14typedef 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) 19struct iova_bitmap *iova_bitmap_alloc(unsigned long iova, size_t length, 20 unsigned long page_size, 21 u64 __user *data); 22void iova_bitmap_free(struct iova_bitmap *bitmap); 23int iova_bitmap_for_each(struct iova_bitmap *bitmap, void *opaque, 24 iova_bitmap_fn_t fn); 25void iova_bitmap_set(struct iova_bitmap *bitmap, 26 unsigned long iova, size_t length); 27#else 28static 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 36static inline void iova_bitmap_free(struct iova_bitmap *bitmap) 37{ 38} 39 40static inline int iova_bitmap_for_each(struct iova_bitmap *bitmap, void *opaque, 41 iova_bitmap_fn_t fn) 42{ 43 return -EOPNOTSUPP; 44} 45 46static inline void iova_bitmap_set(struct iova_bitmap *bitmap, 47 unsigned long iova, size_t length) 48{ 49} 50#endif 51 52#endif 53