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#ifndef MTHCA_PROVIDER_H
36#define MTHCA_PROVIDER_H
37
38#include <rdma/ib_verbs.h>
39#include <rdma/ib_pack.h>
40
41#define MTHCA_MPT_FLAG_ATOMIC (1 << 14)
42#define MTHCA_MPT_FLAG_REMOTE_WRITE (1 << 13)
43#define MTHCA_MPT_FLAG_REMOTE_READ (1 << 12)
44#define MTHCA_MPT_FLAG_LOCAL_WRITE (1 << 11)
45#define MTHCA_MPT_FLAG_LOCAL_READ (1 << 10)
46
47struct mthca_buf_list {
48 void *buf;
49 DEFINE_DMA_UNMAP_ADDR(mapping);
50};
51
52union mthca_buf {
53 struct mthca_buf_list direct;
54 struct mthca_buf_list *page_list;
55};
56
57struct mthca_uar {
58 unsigned long pfn;
59 int index;
60};
61
62struct mthca_user_db_table;
63
64struct mthca_ucontext {
65 struct ib_ucontext ibucontext;
66 struct mthca_uar uar;
67 struct mthca_user_db_table *db_tab;
68 int reg_mr_warned;
69};
70
71struct mthca_mtt;
72
73struct mthca_mr {
74 struct ib_mr ibmr;
75 struct ib_umem *umem;
76 struct mthca_mtt *mtt;
77};
78
79struct mthca_pd {
80 struct ib_pd ibpd;
81 u32 pd_num;
82 atomic_t sqp_count;
83 struct mthca_mr ntmr;
84 int privileged;
85};
86
87struct mthca_eq {
88 struct mthca_dev *dev;
89 int eqn;
90 u32 eqn_mask;
91 u32 cons_index;
92 u16 msi_x_vector;
93 u16 msi_x_entry;
94 int have_irq;
95 int nent;
96 struct mthca_buf_list *page_list;
97 struct mthca_mr mr;
98 char irq_name[IB_DEVICE_NAME_MAX];
99};
100
101struct mthca_av;
102
103enum mthca_ah_type {
104 MTHCA_AH_ON_HCA,
105 MTHCA_AH_PCI_POOL,
106 MTHCA_AH_KMALLOC
107};
108
109struct mthca_ah {
110 struct ib_ah ibah;
111 enum mthca_ah_type type;
112 u32 key;
113 struct mthca_av *av;
114 dma_addr_t avdma;
115};
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167struct mthca_cq_buf {
168 union mthca_buf queue;
169 struct mthca_mr mr;
170 int is_direct;
171};
172
173struct mthca_cq_resize {
174 struct mthca_cq_buf buf;
175 int cqe;
176 enum {
177 CQ_RESIZE_ALLOC,
178 CQ_RESIZE_READY,
179 CQ_RESIZE_SWAPPED
180 } state;
181};
182
183struct mthca_cq {
184 struct ib_cq ibcq;
185 spinlock_t lock;
186 int refcount;
187 int cqn;
188 u32 cons_index;
189 struct mthca_cq_buf buf;
190 struct mthca_cq_resize *resize_buf;
191 int is_kernel;
192
193
194 int set_ci_db_index;
195 __be32 *set_ci_db;
196 int arm_db_index;
197 __be32 *arm_db;
198 int arm_sn;
199
200 wait_queue_head_t wait;
201 struct mutex mutex;
202};
203
204struct mthca_srq {
205 struct ib_srq ibsrq;
206 spinlock_t lock;
207 int refcount;
208 int srqn;
209 int max;
210 int max_gs;
211 int wqe_shift;
212 int first_free;
213 int last_free;
214 u16 counter;
215 int db_index;
216 __be32 *db;
217 void *last;
218
219 int is_direct;
220 u64 *wrid;
221 union mthca_buf queue;
222 struct mthca_mr mr;
223
224 wait_queue_head_t wait;
225 struct mutex mutex;
226};
227
228struct mthca_wq {
229 spinlock_t lock;
230 int max;
231 unsigned next_ind;
232 unsigned last_comp;
233 unsigned head;
234 unsigned tail;
235 void *last;
236 int max_gs;
237 int wqe_shift;
238
239 int db_index;
240 __be32 *db;
241};
242
243struct mthca_sqp {
244 int pkey_index;
245 u32 qkey;
246 u32 send_psn;
247 struct ib_ud_header ud_header;
248 int header_buf_size;
249 void *header_buf;
250 dma_addr_t header_dma;
251};
252
253struct mthca_qp {
254 struct ib_qp ibqp;
255 int refcount;
256 u32 qpn;
257 int is_direct;
258 u8 port;
259 u8 alt_port;
260 u8 transport;
261 u8 state;
262 u8 atomic_rd_en;
263 u8 resp_depth;
264
265 struct mthca_mr mr;
266
267 struct mthca_wq rq;
268 struct mthca_wq sq;
269 enum ib_sig_type sq_policy;
270 int send_wqe_offset;
271 int max_inline_data;
272
273 u64 *wrid;
274 union mthca_buf queue;
275
276 wait_queue_head_t wait;
277 struct mutex mutex;
278 struct mthca_sqp *sqp;
279};
280
281static inline struct mthca_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
282{
283 return container_of(ibucontext, struct mthca_ucontext, ibucontext);
284}
285
286static inline struct mthca_mr *to_mmr(struct ib_mr *ibmr)
287{
288 return container_of(ibmr, struct mthca_mr, ibmr);
289}
290
291static inline struct mthca_pd *to_mpd(struct ib_pd *ibpd)
292{
293 return container_of(ibpd, struct mthca_pd, ibpd);
294}
295
296static inline struct mthca_ah *to_mah(struct ib_ah *ibah)
297{
298 return container_of(ibah, struct mthca_ah, ibah);
299}
300
301static inline struct mthca_cq *to_mcq(struct ib_cq *ibcq)
302{
303 return container_of(ibcq, struct mthca_cq, ibcq);
304}
305
306static inline struct mthca_srq *to_msrq(struct ib_srq *ibsrq)
307{
308 return container_of(ibsrq, struct mthca_srq, ibsrq);
309}
310
311static inline struct mthca_qp *to_mqp(struct ib_qp *ibqp)
312{
313 return container_of(ibqp, struct mthca_qp, ibqp);
314}
315
316#endif
317