forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/drivers/misc/ocxl/ocxl_internal.h
....@@ -1,4 +1,4 @@
1
-// SPDX-License-Identifier: GPL-2.0+
1
+/* SPDX-License-Identifier: GPL-2.0+ */
22 // Copyright 2017 IBM Corp.
33 #ifndef _OCXL_INTERNAL_H_
44 #define _OCXL_INTERNAL_H_
....@@ -11,11 +11,7 @@
1111 #define MAX_IRQ_PER_LINK 2000
1212 #define MAX_IRQ_PER_CONTEXT MAX_IRQ_PER_LINK
1313
14
-#define to_ocxl_function(d) container_of(d, struct ocxl_fn, dev)
15
-#define to_ocxl_afu(d) container_of(d, struct ocxl_afu, dev)
16
-
1714 extern struct pci_driver ocxl_pci_driver;
18
-
1915
2016 struct ocxl_fn {
2117 struct device dev;
....@@ -31,11 +27,17 @@
3127 void *link;
3228 };
3329
34
-struct ocxl_afu {
35
- struct ocxl_fn *fn;
36
- struct list_head list;
30
+struct ocxl_file_info {
31
+ struct ocxl_afu *afu;
3732 struct device dev;
3833 struct cdev cdev;
34
+ struct bin_attribute attr_global_mmio;
35
+};
36
+
37
+struct ocxl_afu {
38
+ struct kref kref;
39
+ struct ocxl_fn *fn;
40
+ struct list_head list;
3941 struct ocxl_afu_config config;
4042 int pasid_base;
4143 int pasid_count; /* opened contexts */
....@@ -49,7 +51,7 @@
4951 u64 irq_base_offset;
5052 void __iomem *global_mmio_ptr;
5153 u64 pp_mmio_start;
52
- struct bin_attribute attr_global_mmio;
54
+ void *private;
5355 };
5456
5557 enum ocxl_context_status {
....@@ -92,41 +94,58 @@
9294 __be32 software_state;
9395 };
9496
97
+int ocxl_create_cdev(struct ocxl_afu *afu);
98
+void ocxl_destroy_cdev(struct ocxl_afu *afu);
99
+int ocxl_file_register_afu(struct ocxl_afu *afu);
100
+void ocxl_file_unregister_afu(struct ocxl_afu *afu);
95101
96
-extern struct ocxl_afu *ocxl_afu_get(struct ocxl_afu *afu);
97
-extern void ocxl_afu_put(struct ocxl_afu *afu);
102
+int ocxl_file_init(void);
103
+void ocxl_file_exit(void);
98104
99
-extern int ocxl_create_cdev(struct ocxl_afu *afu);
100
-extern void ocxl_destroy_cdev(struct ocxl_afu *afu);
101
-extern int ocxl_register_afu(struct ocxl_afu *afu);
102
-extern void ocxl_unregister_afu(struct ocxl_afu *afu);
105
+int ocxl_pasid_afu_alloc(struct ocxl_fn *fn, u32 size);
106
+void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
107
+int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size);
108
+void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
103109
104
-extern int ocxl_file_init(void);
105
-extern void ocxl_file_exit(void);
110
+/*
111
+ * Get the max PASID value that can be used by the function
112
+ */
113
+int ocxl_config_get_pasid_info(struct pci_dev *dev, int *count);
106114
107
-extern int ocxl_pasid_afu_alloc(struct ocxl_fn *fn, u32 size);
108
-extern void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
109
-extern int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size);
110
-extern void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
115
+/*
116
+ * Control whether the FPGA is reloaded on a link reset
117
+ */
118
+int ocxl_config_get_reset_reload(struct pci_dev *dev, int *val);
119
+int ocxl_config_set_reset_reload(struct pci_dev *dev, int val);
111120
112
-extern struct ocxl_context *ocxl_context_alloc(void);
113
-extern int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
114
- struct address_space *mapping);
115
-extern int ocxl_context_attach(struct ocxl_context *ctx, u64 amr);
116
-extern int ocxl_context_mmap(struct ocxl_context *ctx,
121
+/*
122
+ * Check if an AFU index is valid for the given function.
123
+ *
124
+ * AFU indexes can be sparse, so a driver should check all indexes up
125
+ * to the maximum found in the function description
126
+ */
127
+int ocxl_config_check_afu_index(struct pci_dev *dev,
128
+ struct ocxl_fn_config *fn, int afu_idx);
129
+
130
+/**
131
+ * ocxl_link_update_pe() - Update values within a Process Element
132
+ * @link_handle: the link handle associated with the process element
133
+ * @pasid: the PASID for the AFU context
134
+ * @tid: the new thread id for the process element
135
+ *
136
+ * Returns 0 on success
137
+ */
138
+int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid);
139
+
140
+int ocxl_context_mmap(struct ocxl_context *ctx,
117141 struct vm_area_struct *vma);
118
-extern int ocxl_context_detach(struct ocxl_context *ctx);
119
-extern void ocxl_context_detach_all(struct ocxl_afu *afu);
120
-extern void ocxl_context_free(struct ocxl_context *ctx);
142
+void ocxl_context_detach_all(struct ocxl_afu *afu);
121143
122
-extern int ocxl_sysfs_add_afu(struct ocxl_afu *afu);
123
-extern void ocxl_sysfs_remove_afu(struct ocxl_afu *afu);
144
+int ocxl_sysfs_register_afu(struct ocxl_file_info *info);
145
+void ocxl_sysfs_unregister_afu(struct ocxl_file_info *info);
124146
125
-extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, u64 *irq_offset);
126
-extern int ocxl_afu_irq_free(struct ocxl_context *ctx, u64 irq_offset);
127
-extern void ocxl_afu_irq_free_all(struct ocxl_context *ctx);
128
-extern int ocxl_afu_irq_set_fd(struct ocxl_context *ctx, u64 irq_offset,
129
- int eventfd);
130
-extern u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, u64 irq_offset);
147
+int ocxl_irq_offset_to_id(struct ocxl_context *ctx, u64 offset);
148
+u64 ocxl_irq_id_to_offset(struct ocxl_context *ctx, int irq_id);
149
+void ocxl_afu_irq_free_all(struct ocxl_context *ctx);
131150
132151 #endif /* _OCXL_INTERNAL_H_ */