1
2#ifndef _LINUX_UACCE_H
3#define _LINUX_UACCE_H
4
5#include <linux/cdev.h>
6#include <uapi/misc/uacce/uacce.h>
7
8#define UACCE_NAME "uacce"
9#define UACCE_MAX_REGION 2
10#define UACCE_MAX_NAME_SIZE 64
11
12struct uacce_queue;
13struct uacce_device;
14
15
16
17
18
19struct uacce_qfile_region {
20 enum uacce_qfrt type;
21};
22
23
24
25
26
27
28
29
30
31
32
33
34struct uacce_ops {
35 int (*get_available_instances)(struct uacce_device *uacce);
36 int (*get_queue)(struct uacce_device *uacce, unsigned long arg,
37 struct uacce_queue *q);
38 void (*put_queue)(struct uacce_queue *q);
39 int (*start_queue)(struct uacce_queue *q);
40 void (*stop_queue)(struct uacce_queue *q);
41 int (*is_q_updated)(struct uacce_queue *q);
42 int (*mmap)(struct uacce_queue *q, struct vm_area_struct *vma,
43 struct uacce_qfile_region *qfr);
44 long (*ioctl)(struct uacce_queue *q, unsigned int cmd,
45 unsigned long arg);
46};
47
48
49
50
51
52
53
54struct uacce_interface {
55 char name[UACCE_MAX_NAME_SIZE];
56 unsigned int flags;
57 const struct uacce_ops *ops;
58};
59
60enum uacce_q_state {
61 UACCE_Q_ZOMBIE = 0,
62 UACCE_Q_INIT,
63 UACCE_Q_STARTED,
64};
65
66
67
68
69
70
71
72
73
74
75
76
77struct uacce_queue {
78 struct uacce_device *uacce;
79 void *priv;
80 wait_queue_head_t wait;
81 struct list_head list;
82 struct uacce_qfile_region *qfrs[UACCE_MAX_REGION];
83 enum uacce_q_state state;
84 u32 pasid;
85 struct iommu_sva *handle;
86};
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105struct uacce_device {
106 const char *algs;
107 const char *api_ver;
108 const struct uacce_ops *ops;
109 unsigned long qf_pg_num[UACCE_MAX_REGION];
110 struct device *parent;
111 bool is_vf;
112 u32 flags;
113 u32 dev_id;
114 struct cdev *cdev;
115 struct device dev;
116 void *priv;
117 struct list_head queues;
118 struct mutex queues_lock;
119 struct inode *inode;
120};
121
122#if IS_ENABLED(CONFIG_UACCE)
123
124struct uacce_device *uacce_alloc(struct device *parent,
125 struct uacce_interface *interface);
126int uacce_register(struct uacce_device *uacce);
127void uacce_remove(struct uacce_device *uacce);
128
129#else
130
131static inline
132struct uacce_device *uacce_alloc(struct device *parent,
133 struct uacce_interface *interface)
134{
135 return ERR_PTR(-ENODEV);
136}
137
138static inline int uacce_register(struct uacce_device *uacce)
139{
140 return -EINVAL;
141}
142
143static inline void uacce_remove(struct uacce_device *uacce) {}
144
145#endif
146
147#endif
148