1*f61dddd7SZhenzhong Duan /* 2*f61dddd7SZhenzhong Duan * VFIO BASE CONTAINER 3*f61dddd7SZhenzhong Duan * 4*f61dddd7SZhenzhong Duan * Copyright (C) 2023 Intel Corporation. 5*f61dddd7SZhenzhong Duan * Copyright Red Hat, Inc. 2023 6*f61dddd7SZhenzhong Duan * 7*f61dddd7SZhenzhong Duan * Authors: Yi Liu <yi.l.liu@intel.com> 8*f61dddd7SZhenzhong Duan * Eric Auger <eric.auger@redhat.com> 9*f61dddd7SZhenzhong Duan * 10*f61dddd7SZhenzhong Duan * SPDX-License-Identifier: GPL-2.0-or-later 11*f61dddd7SZhenzhong Duan */ 12*f61dddd7SZhenzhong Duan 13*f61dddd7SZhenzhong Duan #ifndef HW_VFIO_VFIO_CONTAINER_BASE_H 14*f61dddd7SZhenzhong Duan #define HW_VFIO_VFIO_CONTAINER_BASE_H 15*f61dddd7SZhenzhong Duan 16*f61dddd7SZhenzhong Duan #include "exec/memory.h" 17*f61dddd7SZhenzhong Duan 18*f61dddd7SZhenzhong Duan typedef struct VFIODevice VFIODevice; 19*f61dddd7SZhenzhong Duan typedef struct VFIOIOMMUOps VFIOIOMMUOps; 20*f61dddd7SZhenzhong Duan 21*f61dddd7SZhenzhong Duan typedef struct { 22*f61dddd7SZhenzhong Duan unsigned long *bitmap; 23*f61dddd7SZhenzhong Duan hwaddr size; 24*f61dddd7SZhenzhong Duan hwaddr pages; 25*f61dddd7SZhenzhong Duan } VFIOBitmap; 26*f61dddd7SZhenzhong Duan 27*f61dddd7SZhenzhong Duan /* 28*f61dddd7SZhenzhong Duan * This is the base object for vfio container backends 29*f61dddd7SZhenzhong Duan */ 30*f61dddd7SZhenzhong Duan typedef struct VFIOContainerBase { 31*f61dddd7SZhenzhong Duan const VFIOIOMMUOps *ops; 32*f61dddd7SZhenzhong Duan } VFIOContainerBase; 33*f61dddd7SZhenzhong Duan 34*f61dddd7SZhenzhong Duan struct VFIOIOMMUOps { 35*f61dddd7SZhenzhong Duan /* basic feature */ 36*f61dddd7SZhenzhong Duan int (*dma_map)(VFIOContainerBase *bcontainer, 37*f61dddd7SZhenzhong Duan hwaddr iova, ram_addr_t size, 38*f61dddd7SZhenzhong Duan void *vaddr, bool readonly); 39*f61dddd7SZhenzhong Duan int (*dma_unmap)(VFIOContainerBase *bcontainer, 40*f61dddd7SZhenzhong Duan hwaddr iova, ram_addr_t size, 41*f61dddd7SZhenzhong Duan IOMMUTLBEntry *iotlb); 42*f61dddd7SZhenzhong Duan int (*attach_device)(const char *name, VFIODevice *vbasedev, 43*f61dddd7SZhenzhong Duan AddressSpace *as, Error **errp); 44*f61dddd7SZhenzhong Duan void (*detach_device)(VFIODevice *vbasedev); 45*f61dddd7SZhenzhong Duan /* migration feature */ 46*f61dddd7SZhenzhong Duan int (*set_dirty_page_tracking)(VFIOContainerBase *bcontainer, bool start); 47*f61dddd7SZhenzhong Duan int (*query_dirty_bitmap)(VFIOContainerBase *bcontainer, VFIOBitmap *vbmap, 48*f61dddd7SZhenzhong Duan hwaddr iova, hwaddr size); 49*f61dddd7SZhenzhong Duan }; 50*f61dddd7SZhenzhong Duan #endif /* HW_VFIO_VFIO_CONTAINER_BASE_H */ 51