workqueue: Make worker_attach/detach_pool() update worker->pool
[linux/fpc-iii.git] / drivers / misc / ocxl / ocxl_internal.h
blob5d421824afd921e1f679dfba3976516140bff879
1 // SPDX-License-Identifier: GPL-2.0+
2 // Copyright 2017 IBM Corp.
3 #ifndef _OCXL_INTERNAL_H_
4 #define _OCXL_INTERNAL_H_
6 #include <linux/pci.h>
7 #include <linux/cdev.h>
8 #include <linux/list.h>
9 #include <misc/ocxl.h>
11 #define MAX_IRQ_PER_LINK 2000
12 #define MAX_IRQ_PER_CONTEXT MAX_IRQ_PER_LINK
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)
17 extern struct pci_driver ocxl_pci_driver;
20 struct ocxl_fn {
21 struct device dev;
22 int bar_used[3];
23 struct ocxl_fn_config config;
24 struct list_head afu_list;
25 int pasid_base;
26 int actag_base;
27 int actag_enabled;
28 int actag_supported;
29 struct list_head pasid_list;
30 struct list_head actag_list;
31 void *link;
34 struct ocxl_afu {
35 struct ocxl_fn *fn;
36 struct list_head list;
37 struct device dev;
38 struct cdev cdev;
39 struct ocxl_afu_config config;
40 int pasid_base;
41 int pasid_count; /* opened contexts */
42 int pasid_max; /* maximum number of contexts */
43 int actag_base;
44 int actag_enabled;
45 struct mutex contexts_lock;
46 struct idr contexts_idr;
47 struct mutex afu_control_lock;
48 u64 global_mmio_start;
49 u64 irq_base_offset;
50 void __iomem *global_mmio_ptr;
51 u64 pp_mmio_start;
52 struct bin_attribute attr_global_mmio;
55 enum ocxl_context_status {
56 CLOSED,
57 OPENED,
58 ATTACHED,
61 // Contains metadata about a translation fault
62 struct ocxl_xsl_error {
63 u64 addr; // The address that triggered the fault
64 u64 dsisr; // the value of the dsisr register
65 u64 count; // The number of times this fault has been triggered
68 struct ocxl_context {
69 struct ocxl_afu *afu;
70 int pasid;
71 struct mutex status_mutex;
72 enum ocxl_context_status status;
73 struct address_space *mapping;
74 struct mutex mapping_lock;
75 wait_queue_head_t events_wq;
76 struct mutex xsl_error_lock;
77 struct ocxl_xsl_error xsl_error;
78 struct mutex irq_lock;
79 struct idr irq_idr;
82 struct ocxl_process_element {
83 __be64 config_state;
84 __be32 reserved1[11];
85 __be32 lpid;
86 __be32 tid;
87 __be32 pid;
88 __be32 reserved2[10];
89 __be64 amr;
90 __be32 reserved3[3];
91 __be32 software_state;
95 extern struct ocxl_afu *ocxl_afu_get(struct ocxl_afu *afu);
96 extern void ocxl_afu_put(struct ocxl_afu *afu);
98 extern int ocxl_create_cdev(struct ocxl_afu *afu);
99 extern void ocxl_destroy_cdev(struct ocxl_afu *afu);
100 extern int ocxl_register_afu(struct ocxl_afu *afu);
101 extern void ocxl_unregister_afu(struct ocxl_afu *afu);
103 extern int ocxl_file_init(void);
104 extern void ocxl_file_exit(void);
106 extern int ocxl_pasid_afu_alloc(struct ocxl_fn *fn, u32 size);
107 extern void ocxl_pasid_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
108 extern int ocxl_actag_afu_alloc(struct ocxl_fn *fn, u32 size);
109 extern void ocxl_actag_afu_free(struct ocxl_fn *fn, u32 start, u32 size);
111 extern struct ocxl_context *ocxl_context_alloc(void);
112 extern int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
113 struct address_space *mapping);
114 extern int ocxl_context_attach(struct ocxl_context *ctx, u64 amr);
115 extern int ocxl_context_mmap(struct ocxl_context *ctx,
116 struct vm_area_struct *vma);
117 extern int ocxl_context_detach(struct ocxl_context *ctx);
118 extern void ocxl_context_detach_all(struct ocxl_afu *afu);
119 extern void ocxl_context_free(struct ocxl_context *ctx);
121 extern int ocxl_sysfs_add_afu(struct ocxl_afu *afu);
122 extern void ocxl_sysfs_remove_afu(struct ocxl_afu *afu);
124 extern int ocxl_afu_irq_alloc(struct ocxl_context *ctx, u64 *irq_offset);
125 extern int ocxl_afu_irq_free(struct ocxl_context *ctx, u64 irq_offset);
126 extern void ocxl_afu_irq_free_all(struct ocxl_context *ctx);
127 extern int ocxl_afu_irq_set_fd(struct ocxl_context *ctx, u64 irq_offset,
128 int eventfd);
129 extern u64 ocxl_afu_irq_get_addr(struct ocxl_context *ctx, u64 irq_offset);
131 #endif /* _OCXL_INTERNAL_H_ */