This source file includes following definitions.
- ib_uverbs_init_udata
- ib_uverbs_init_udata_buf_or_null
- make_port_cap_flags
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 #include <rdma/uverbs_std_types.h>
50
51 #define UVERBS_MODULE_NAME ib_uverbs
52 #include <rdma/uverbs_named_ioctl.h>
53
54 static inline void
55 ib_uverbs_init_udata(struct ib_udata *udata,
56 const void __user *ibuf,
57 void __user *obuf,
58 size_t ilen, size_t olen)
59 {
60 udata->inbuf = ibuf;
61 udata->outbuf = obuf;
62 udata->inlen = ilen;
63 udata->outlen = olen;
64 }
65
66 static inline void
67 ib_uverbs_init_udata_buf_or_null(struct ib_udata *udata,
68 const void __user *ibuf,
69 void __user *obuf,
70 size_t ilen, size_t olen)
71 {
72 ib_uverbs_init_udata(udata,
73 ilen ? ibuf : NULL, olen ? obuf : NULL,
74 ilen, olen);
75 }
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99 struct ib_uverbs_device {
100 atomic_t refcount;
101 u32 num_comp_vectors;
102 struct completion comp;
103 struct device dev;
104
105 const struct attribute_group *groups[2];
106 struct ib_device __rcu *ib_dev;
107 int devnum;
108 struct cdev cdev;
109 struct rb_root xrcd_tree;
110 struct mutex xrcd_tree_mutex;
111 struct srcu_struct disassociate_srcu;
112 struct mutex lists_mutex;
113 struct list_head uverbs_file_list;
114 struct list_head uverbs_events_file_list;
115 struct uverbs_api *uapi;
116 };
117
118 struct ib_uverbs_event_queue {
119 spinlock_t lock;
120 int is_closed;
121 wait_queue_head_t poll_wait;
122 struct fasync_struct *async_queue;
123 struct list_head event_list;
124 };
125
126 struct ib_uverbs_async_event_file {
127 struct ib_uverbs_event_queue ev_queue;
128 struct ib_uverbs_file *uverbs_file;
129 struct kref ref;
130 struct list_head list;
131 };
132
133 struct ib_uverbs_completion_event_file {
134 struct ib_uobject uobj;
135 struct ib_uverbs_event_queue ev_queue;
136 };
137
138 struct ib_uverbs_file {
139 struct kref ref;
140 struct ib_uverbs_device *device;
141 struct mutex ucontext_lock;
142
143
144
145
146 struct ib_ucontext *ucontext;
147 struct ib_event_handler event_handler;
148 struct ib_uverbs_async_event_file *async_file;
149 struct list_head list;
150
151
152
153
154
155
156
157 struct rw_semaphore hw_destroy_rwsem;
158 spinlock_t uobjects_lock;
159 struct list_head uobjects;
160
161 struct mutex umap_lock;
162 struct list_head umaps;
163 struct page *disassociate_page;
164
165 struct xarray idr;
166 };
167
168 struct ib_uverbs_event {
169 union {
170 struct ib_uverbs_async_event_desc async;
171 struct ib_uverbs_comp_event_desc comp;
172 } desc;
173 struct list_head list;
174 struct list_head obj_list;
175 u32 *counter;
176 };
177
178 struct ib_uverbs_mcast_entry {
179 struct list_head list;
180 union ib_gid gid;
181 u16 lid;
182 };
183
184 struct ib_uevent_object {
185 struct ib_uobject uobject;
186 struct list_head event_list;
187 u32 events_reported;
188 };
189
190 struct ib_uxrcd_object {
191 struct ib_uobject uobject;
192 atomic_t refcnt;
193 };
194
195 struct ib_usrq_object {
196 struct ib_uevent_object uevent;
197 struct ib_uxrcd_object *uxrcd;
198 };
199
200 struct ib_uqp_object {
201 struct ib_uevent_object uevent;
202
203 struct mutex mcast_lock;
204 struct list_head mcast_list;
205 struct ib_uxrcd_object *uxrcd;
206 };
207
208 struct ib_uwq_object {
209 struct ib_uevent_object uevent;
210 };
211
212 struct ib_ucq_object {
213 struct ib_uobject uobject;
214 struct list_head comp_list;
215 struct list_head async_list;
216 u32 comp_events_reported;
217 u32 async_events_reported;
218 };
219
220 extern const struct file_operations uverbs_event_fops;
221 void ib_uverbs_init_event_queue(struct ib_uverbs_event_queue *ev_queue);
222 struct file *ib_uverbs_alloc_async_event_file(struct ib_uverbs_file *uverbs_file,
223 struct ib_device *ib_dev);
224 void ib_uverbs_free_async_event_file(struct ib_uverbs_file *uverbs_file);
225 void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res);
226
227 void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
228 struct ib_uverbs_completion_event_file *ev_file,
229 struct ib_ucq_object *uobj);
230 void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
231 struct ib_uevent_object *uobj);
232 void ib_uverbs_release_file(struct kref *ref);
233
234 void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context);
235 void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr);
236 void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr);
237 void ib_uverbs_wq_event_handler(struct ib_event *event, void *context_ptr);
238 void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr);
239 void ib_uverbs_event_handler(struct ib_event_handler *handler,
240 struct ib_event *event);
241 int ib_uverbs_dealloc_xrcd(struct ib_uobject *uobject, struct ib_xrcd *xrcd,
242 enum rdma_remove_reason why,
243 struct uverbs_attr_bundle *attrs);
244
245 int uverbs_dealloc_mw(struct ib_mw *mw);
246 void ib_uverbs_detach_umcast(struct ib_qp *qp,
247 struct ib_uqp_object *uobj);
248
249 long ib_uverbs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
250
251 struct ib_uverbs_flow_spec {
252 union {
253 union {
254 struct ib_uverbs_flow_spec_hdr hdr;
255 struct {
256 __u32 type;
257 __u16 size;
258 __u16 reserved;
259 };
260 };
261 struct ib_uverbs_flow_spec_eth eth;
262 struct ib_uverbs_flow_spec_ipv4 ipv4;
263 struct ib_uverbs_flow_spec_esp esp;
264 struct ib_uverbs_flow_spec_tcp_udp tcp_udp;
265 struct ib_uverbs_flow_spec_ipv6 ipv6;
266 struct ib_uverbs_flow_spec_action_tag flow_tag;
267 struct ib_uverbs_flow_spec_action_drop drop;
268 struct ib_uverbs_flow_spec_action_handle action;
269 struct ib_uverbs_flow_spec_action_count flow_count;
270 };
271 };
272
273 int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
274 const void *kern_spec_mask,
275 const void *kern_spec_val,
276 size_t kern_filter_sz,
277 union ib_flow_spec *ib_spec);
278
279 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_DEVICE);
280 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_PD);
281 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_MR);
282 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_COMP_CHANNEL);
283 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_CQ);
284 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_QP);
285 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_AH);
286 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_MW);
287 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_SRQ);
288 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_FLOW);
289 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_WQ);
290 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_RWQ_IND_TBL);
291 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_XRCD);
292 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_FLOW_ACTION);
293 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_DM);
294 extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_COUNTERS);
295
296
297
298
299
300 static inline u32 make_port_cap_flags(const struct ib_port_attr *attr)
301 {
302 u32 res;
303
304
305
306
307
308
309 res = attr->port_cap_flags & ~(u32)IB_UVERBS_PCF_IP_BASED_GIDS;
310
311 if (attr->ip_gids)
312 res |= IB_UVERBS_PCF_IP_BASED_GIDS;
313
314 return res;
315 }
316
317
318 void copy_port_attr_to_resp(struct ib_port_attr *attr,
319 struct ib_uverbs_query_port_resp *resp,
320 struct ib_device *ib_dev, u8 port_num);
321 #endif