1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#ifndef UVERBS_H
38#define UVERBS_H
39
40#include <linux/kref.h>
41#include <linux/idr.h>
42#include <linux/mutex.h>
43#include <linux/completion.h>
44#include <linux/cdev.h>
45
46#include <rdma/ib_verbs.h>
47#include <rdma/ib_umem.h>
48#include <rdma/ib_user_verbs.h>
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71struct ib_uverbs_device {
72 struct kref ref;
73 int num_comp_vectors;
74 struct completion comp;
75 struct device *dev;
76 struct ib_device *ib_dev;
77 int devnum;
78 struct cdev cdev;
79 struct rb_root xrcd_tree;
80 struct mutex xrcd_tree_mutex;
81};
82
83struct ib_uverbs_event_file {
84 struct kref ref;
85 int is_async;
86 struct ib_uverbs_file *uverbs_file;
87 spinlock_t lock;
88 int is_closed;
89 wait_queue_head_t poll_wait;
90 struct fasync_struct *async_queue;
91 struct list_head event_list;
92};
93
94struct ib_uverbs_file {
95 struct kref ref;
96 struct mutex mutex;
97 struct ib_uverbs_device *device;
98 struct ib_ucontext *ucontext;
99 struct ib_event_handler event_handler;
100 struct ib_uverbs_event_file *async_file;
101};
102
103struct ib_uverbs_event {
104 union {
105 struct ib_uverbs_async_event_desc async;
106 struct ib_uverbs_comp_event_desc comp;
107 } desc;
108 struct list_head list;
109 struct list_head obj_list;
110 u32 *counter;
111};
112
113struct ib_uverbs_mcast_entry {
114 struct list_head list;
115 union ib_gid gid;
116 u16 lid;
117};
118
119struct ib_uevent_object {
120 struct ib_uobject uobject;
121 struct list_head event_list;
122 u32 events_reported;
123};
124
125struct ib_uxrcd_object {
126 struct ib_uobject uobject;
127 atomic_t refcnt;
128};
129
130struct ib_usrq_object {
131 struct ib_uevent_object uevent;
132 struct ib_uxrcd_object *uxrcd;
133};
134
135struct ib_uqp_object {
136 struct ib_uevent_object uevent;
137 struct list_head mcast_list;
138 struct ib_uxrcd_object *uxrcd;
139};
140
141struct ib_ucq_object {
142 struct ib_uobject uobject;
143 struct ib_uverbs_file *uverbs_file;
144 struct list_head comp_list;
145 struct list_head async_list;
146 u32 comp_events_reported;
147 u32 async_events_reported;
148};
149
150extern spinlock_t ib_uverbs_idr_lock;
151extern struct idr ib_uverbs_pd_idr;
152extern struct idr ib_uverbs_mr_idr;
153extern struct idr ib_uverbs_mw_idr;
154extern struct idr ib_uverbs_ah_idr;
155extern struct idr ib_uverbs_cq_idr;
156extern struct idr ib_uverbs_qp_idr;
157extern struct idr ib_uverbs_srq_idr;
158extern struct idr ib_uverbs_xrcd_idr;
159extern struct idr ib_uverbs_rule_idr;
160
161void idr_remove_uobj(struct idr *idp, struct ib_uobject *uobj);
162
163struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
164 int is_async);
165struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd);
166
167void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
168 struct ib_uverbs_event_file *ev_file,
169 struct ib_ucq_object *uobj);
170void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
171 struct ib_uevent_object *uobj);
172
173void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context);
174void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr);
175void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr);
176void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr);
177void ib_uverbs_event_handler(struct ib_event_handler *handler,
178 struct ib_event *event);
179void ib_uverbs_dealloc_xrcd(struct ib_uverbs_device *dev, struct ib_xrcd *xrcd);
180
181#define IB_UVERBS_DECLARE_CMD(name) \
182 ssize_t ib_uverbs_##name(struct ib_uverbs_file *file, \
183 const char __user *buf, int in_len, \
184 int out_len)
185
186IB_UVERBS_DECLARE_CMD(get_context);
187IB_UVERBS_DECLARE_CMD(query_device);
188IB_UVERBS_DECLARE_CMD(query_port);
189IB_UVERBS_DECLARE_CMD(alloc_pd);
190IB_UVERBS_DECLARE_CMD(dealloc_pd);
191IB_UVERBS_DECLARE_CMD(reg_mr);
192IB_UVERBS_DECLARE_CMD(dereg_mr);
193IB_UVERBS_DECLARE_CMD(alloc_mw);
194IB_UVERBS_DECLARE_CMD(dealloc_mw);
195IB_UVERBS_DECLARE_CMD(create_comp_channel);
196IB_UVERBS_DECLARE_CMD(create_cq);
197IB_UVERBS_DECLARE_CMD(resize_cq);
198IB_UVERBS_DECLARE_CMD(poll_cq);
199IB_UVERBS_DECLARE_CMD(req_notify_cq);
200IB_UVERBS_DECLARE_CMD(destroy_cq);
201IB_UVERBS_DECLARE_CMD(create_qp);
202IB_UVERBS_DECLARE_CMD(open_qp);
203IB_UVERBS_DECLARE_CMD(query_qp);
204IB_UVERBS_DECLARE_CMD(modify_qp);
205IB_UVERBS_DECLARE_CMD(destroy_qp);
206IB_UVERBS_DECLARE_CMD(post_send);
207IB_UVERBS_DECLARE_CMD(post_recv);
208IB_UVERBS_DECLARE_CMD(post_srq_recv);
209IB_UVERBS_DECLARE_CMD(create_ah);
210IB_UVERBS_DECLARE_CMD(destroy_ah);
211IB_UVERBS_DECLARE_CMD(attach_mcast);
212IB_UVERBS_DECLARE_CMD(detach_mcast);
213IB_UVERBS_DECLARE_CMD(create_srq);
214IB_UVERBS_DECLARE_CMD(modify_srq);
215IB_UVERBS_DECLARE_CMD(query_srq);
216IB_UVERBS_DECLARE_CMD(destroy_srq);
217IB_UVERBS_DECLARE_CMD(create_xsrq);
218IB_UVERBS_DECLARE_CMD(open_xrcd);
219IB_UVERBS_DECLARE_CMD(close_xrcd);
220#ifdef CONFIG_INFINIBAND_EXPERIMENTAL_UVERBS_FLOW_STEERING
221IB_UVERBS_DECLARE_CMD(create_flow);
222IB_UVERBS_DECLARE_CMD(destroy_flow);
223#endif
224
225#endif
226