| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef VFIO_CDX_PRIVATE_H |
| 7 |
#define VFIO_CDX_PRIVATE_H |
| 8 |
|
| 9 |
#include <linux/mutex.h> |
| 10 |
|
| 11 |
#define VFIO_CDX_OFFSET_SHIFT 40 |
| 12 |
|
| 13 |
static inline u64 vfio_cdx_index_to_offset(u32 index) |
| 14 |
{ |
| 15 |
return ((u64)(index) << VFIO_CDX_OFFSET_SHIFT); |
| 16 |
} |
| 17 |
|
| 18 |
struct vfio_cdx_irq { |
| 19 |
u32 flags; |
| 20 |
u32 count; |
| 21 |
int irq_no; |
| 22 |
struct eventfd_ctx *trigger; |
| 23 |
char *name; |
| 24 |
}; |
| 25 |
|
| 26 |
struct vfio_cdx_region { |
| 27 |
u32 flags; |
| 28 |
u32 type; |
| 29 |
u64 addr; |
| 30 |
resource_size_t size; |
| 31 |
}; |
| 32 |
|
| 33 |
struct vfio_cdx_device { |
| 34 |
struct vfio_device vdev; |
| 35 |
struct vfio_cdx_region *regions; |
| 36 |
struct mutex cdx_irqs_lock; |
| 37 |
struct vfio_cdx_irq *cdx_irqs; |
| 38 |
u32 flags; |
| 39 |
#define BME_SUPPORT BIT(0) |
| 40 |
u32 msi_count; |
| 41 |
u8 config_msi; |
| 42 |
}; |
| 43 |
|
| 44 |
#ifdef CONFIG_GENERIC_MSI_IRQ |
| 45 |
int vfio_cdx_set_irqs_ioctl(struct vfio_cdx_device *vdev, |
| 46 |
u32 flags, unsigned int index, |
| 47 |
unsigned int start, unsigned int count, |
| 48 |
void *data); |
| 49 |
|
| 50 |
void vfio_cdx_irqs_cleanup(struct vfio_cdx_device *vdev); |
| 51 |
#else |
| 52 |
static int vfio_cdx_set_irqs_ioctl(struct vfio_cdx_device *vdev, |
| 53 |
u32 flags, unsigned int index, |
| 54 |
unsigned int start, unsigned int count, |
| 55 |
void *data) |
| 56 |
{ |
| 57 |
return -EINVAL; |
| 58 |
} |
| 59 |
|
| 60 |
static void vfio_cdx_irqs_cleanup(struct vfio_cdx_device *vdev) |
| 61 |
{ |
| 62 |
} |
| 63 |
#endif |
| 64 |
|
| 65 |
#endif /* VFIO_CDX_PRIVATE_H */ |