forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-20 e636c8d336489bf3eed5878299e6cc045bbad077
kernel/drivers/vfio/pci/vfio_pci_private.h
....@@ -1,10 +1,7 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2012 Red Hat, Inc. All rights reserved.
34 * Author: Alex Williamson <alex.williamson@redhat.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License version 2 as
7
- * published by the Free Software Foundation.
85 *
96 * Derived from original vfio:
107 * Copyright 2010 Cisco Systems, Inc. All rights reserved.
....@@ -15,6 +12,8 @@
1512 #include <linux/pci.h>
1613 #include <linux/irqbypass.h>
1714 #include <linux/types.h>
15
+#include <linux/uuid.h>
16
+#include <linux/notifier.h>
1817
1918 #ifndef VFIO_PCI_PRIVATE_H
2019 #define VFIO_PCI_PRIVATE_H
....@@ -34,12 +33,14 @@
3433
3534 struct vfio_pci_ioeventfd {
3635 struct list_head next;
36
+ struct vfio_pci_device *vdev;
3737 struct virqfd *virqfd;
3838 void __iomem *addr;
3939 uint64_t data;
4040 loff_t pos;
4141 int bar;
4242 int count;
43
+ bool test_mem;
4344 };
4445
4546 struct vfio_pci_irq_ctx {
....@@ -59,6 +60,12 @@
5960 size_t count, loff_t *ppos, bool iswrite);
6061 void (*release)(struct vfio_pci_device *vdev,
6162 struct vfio_pci_region *region);
63
+ int (*mmap)(struct vfio_pci_device *vdev,
64
+ struct vfio_pci_region *region,
65
+ struct vm_area_struct *vma);
66
+ int (*add_capability)(struct vfio_pci_device *vdev,
67
+ struct vfio_pci_region *region,
68
+ struct vfio_info_cap *caps);
6269 };
6370
6471 struct vfio_pci_region {
....@@ -76,6 +83,17 @@
7683 struct list_head res_next;
7784 };
7885
86
+struct vfio_pci_reflck {
87
+ struct kref kref;
88
+ struct mutex lock;
89
+};
90
+
91
+struct vfio_pci_vf_token {
92
+ struct mutex lock;
93
+ uuid_t uuid;
94
+ int users;
95
+};
96
+
7997 struct vfio_pci_mmap_vma {
8098 struct vm_area_struct *vma;
8199 struct list_head vma_next;
....@@ -83,8 +101,8 @@
83101
84102 struct vfio_pci_device {
85103 struct pci_dev *pdev;
86
- void __iomem *barmap[PCI_STD_RESOURCE_END + 1];
87
- bool bar_mmap_supported[PCI_STD_RESOURCE_END + 1];
104
+ void __iomem *barmap[PCI_STD_NUM_BARS];
105
+ bool bar_mmap_supported[PCI_STD_NUM_BARS];
88106 u8 *pci_config_map;
89107 u8 *vconfig;
90108 struct perm_bits *msi_perm;
....@@ -108,7 +126,10 @@
108126 bool has_vga;
109127 bool needs_reset;
110128 bool nointx;
129
+ bool needs_pm_restore;
111130 struct pci_saved_state *pci_saved_state;
131
+ struct pci_saved_state *pm_save;
132
+ struct vfio_pci_reflck *reflck;
112133 int refcnt;
113134 int ioeventfds_nr;
114135 struct eventfd_ctx *err_trigger;
....@@ -116,6 +137,8 @@
116137 struct list_head dummy_resources_list;
117138 struct mutex ioeventfds_lock;
118139 struct list_head ioeventfds_list;
140
+ struct vfio_pci_vf_token *vf_token;
141
+ struct notifier_block nb;
119142 struct mutex vma_lock;
120143 struct list_head vma_list;
121144 struct rw_semaphore memory_lock;
....@@ -158,6 +181,9 @@
158181 const struct vfio_pci_regops *ops,
159182 size_t size, u32 flags, void *data);
160183
184
+extern int vfio_pci_set_power_state(struct vfio_pci_device *vdev,
185
+ pci_power_t state);
186
+
161187 extern bool __vfio_pci_memory_enabled(struct vfio_pci_device *vdev);
162188 extern void vfio_pci_zap_and_down_write_memory_lock(struct vfio_pci_device
163189 *vdev);
....@@ -173,4 +199,30 @@
173199 return -ENODEV;
174200 }
175201 #endif
202
+#ifdef CONFIG_VFIO_PCI_NVLINK2
203
+extern int vfio_pci_nvdia_v100_nvlink2_init(struct vfio_pci_device *vdev);
204
+extern int vfio_pci_ibm_npu2_init(struct vfio_pci_device *vdev);
205
+#else
206
+static inline int vfio_pci_nvdia_v100_nvlink2_init(struct vfio_pci_device *vdev)
207
+{
208
+ return -ENODEV;
209
+}
210
+
211
+static inline int vfio_pci_ibm_npu2_init(struct vfio_pci_device *vdev)
212
+{
213
+ return -ENODEV;
214
+}
215
+#endif
216
+
217
+#ifdef CONFIG_VFIO_PCI_ZDEV
218
+extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_device *vdev,
219
+ struct vfio_info_cap *caps);
220
+#else
221
+static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_device *vdev,
222
+ struct vfio_info_cap *caps)
223
+{
224
+ return -ENODEV;
225
+}
226
+#endif
227
+
176228 #endif /* VFIO_PCI_PRIVATE_H */