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
45#include <rdma/ib_verbs.h>
46#include <rdma/ib_umem.h>
47#include <rdma/ib_user_verbs.h>
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70struct ib_uverbs_device {
71 struct kref ref;
72 struct completion comp;
73 int devnum;
74 struct cdev *cdev;
75 struct device *dev;
76 struct ib_device *ib_dev;
77 int num_comp_vectors;
78};
79
80struct ib_uverbs_event_file {
81 struct kref ref;
82 struct ib_uverbs_file *uverbs_file;
83 spinlock_t lock;
84 wait_queue_head_t poll_wait;
85 struct fasync_struct *async_queue;
86 struct list_head event_list;
87 int is_async;
88 int is_closed;
89};
90
91struct ib_uverbs_file {
92 struct kref ref;
93 struct mutex mutex;
94 struct ib_uverbs_device *device;
95 struct ib_ucontext *ucontext;
96 struct ib_event_handler event_handler;
97 struct ib_uverbs_event_file *async_file;
98};
99
100struct ib_uverbs_event {
101 union {
102 struct ib_uverbs_async_event_desc async;
103 struct ib_uverbs_comp_event_desc comp;
104 } desc;
105 struct list_head list;
106 struct list_head obj_list;
107 u32 *counter;
108};
109
110struct ib_uverbs_mcast_entry {
111 struct list_head list;
112 union ib_gid gid;
113 u16 lid;
114};
115
116struct ib_uevent_object {
117 struct ib_uobject uobject;
118 struct list_head event_list;
119 u32 events_reported;
120};
121
122struct ib_uqp_object {
123 struct ib_uevent_object uevent;
124 struct list_head mcast_list;
125};
126
127struct ib_ucq_object {
128 struct ib_uobject uobject;
129 struct ib_uverbs_file *uverbs_file;
130 struct list_head comp_list;
131 struct list_head async_list;
132 u32 comp_events_reported;
133 u32 async_events_reported;
134};
135
136extern spinlock_t ib_uverbs_idr_lock;
137extern struct idr ib_uverbs_pd_idr;
138extern struct idr ib_uverbs_mr_idr;
139extern struct idr ib_uverbs_mw_idr;
140extern struct idr ib_uverbs_ah_idr;
141extern struct idr ib_uverbs_cq_idr;
142extern struct idr ib_uverbs_qp_idr;
143extern struct idr ib_uverbs_srq_idr;
144
145void idr_remove_uobj(struct idr *idp, struct ib_uobject *uobj);
146
147struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
148 int is_async, int *fd);
149struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd);
150
151void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
152 struct ib_uverbs_event_file *ev_file,
153 struct ib_ucq_object *uobj);
154void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
155 struct ib_uevent_object *uobj);
156
157void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context);
158void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr);
159void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr);
160void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr);
161void ib_uverbs_event_handler(struct ib_event_handler *handler,
162 struct ib_event *event);
163
164#define IB_UVERBS_DECLARE_CMD(name) \
165 ssize_t ib_uverbs_##name(struct ib_uverbs_file *file, \
166 const char __user *buf, int in_len, \
167 int out_len)
168
169IB_UVERBS_DECLARE_CMD(get_context);
170IB_UVERBS_DECLARE_CMD(query_device);
171IB_UVERBS_DECLARE_CMD(query_port);
172IB_UVERBS_DECLARE_CMD(alloc_pd);
173IB_UVERBS_DECLARE_CMD(dealloc_pd);
174IB_UVERBS_DECLARE_CMD(reg_mr);
175IB_UVERBS_DECLARE_CMD(dereg_mr);
176IB_UVERBS_DECLARE_CMD(create_comp_channel);
177IB_UVERBS_DECLARE_CMD(create_cq);
178IB_UVERBS_DECLARE_CMD(resize_cq);
179IB_UVERBS_DECLARE_CMD(poll_cq);
180IB_UVERBS_DECLARE_CMD(req_notify_cq);
181IB_UVERBS_DECLARE_CMD(destroy_cq);
182IB_UVERBS_DECLARE_CMD(create_qp);
183IB_UVERBS_DECLARE_CMD(query_qp);
184IB_UVERBS_DECLARE_CMD(modify_qp);
185IB_UVERBS_DECLARE_CMD(destroy_qp);
186IB_UVERBS_DECLARE_CMD(post_send);
187IB_UVERBS_DECLARE_CMD(post_recv);
188IB_UVERBS_DECLARE_CMD(post_srq_recv);
189IB_UVERBS_DECLARE_CMD(create_ah);
190IB_UVERBS_DECLARE_CMD(destroy_ah);
191IB_UVERBS_DECLARE_CMD(attach_mcast);
192IB_UVERBS_DECLARE_CMD(detach_mcast);
193IB_UVERBS_DECLARE_CMD(create_srq);
194IB_UVERBS_DECLARE_CMD(modify_srq);
195IB_UVERBS_DECLARE_CMD(query_srq);
196IB_UVERBS_DECLARE_CMD(destroy_srq);
197
198#endif
199