.. | .. |
---|
36 | 36 | |
---|
37 | 37 | #include <asm/io.h> |
---|
38 | 38 | |
---|
| 39 | +#include <rdma/uverbs_ioctl.h> |
---|
| 40 | + |
---|
39 | 41 | #include "mthca_dev.h" |
---|
40 | 42 | #include "mthca_cmd.h" |
---|
41 | 43 | #include "mthca_memfree.h" |
---|
.. | .. |
---|
95 | 97 | static void mthca_tavor_init_srq_context(struct mthca_dev *dev, |
---|
96 | 98 | struct mthca_pd *pd, |
---|
97 | 99 | struct mthca_srq *srq, |
---|
98 | | - struct mthca_tavor_srq_context *context) |
---|
| 100 | + struct mthca_tavor_srq_context *context, |
---|
| 101 | + struct ib_udata *udata) |
---|
99 | 102 | { |
---|
| 103 | + struct mthca_ucontext *ucontext = rdma_udata_to_drv_context( |
---|
| 104 | + udata, struct mthca_ucontext, ibucontext); |
---|
| 105 | + |
---|
100 | 106 | memset(context, 0, sizeof *context); |
---|
101 | 107 | |
---|
102 | 108 | context->wqe_base_ds = cpu_to_be64(1 << (srq->wqe_shift - 4)); |
---|
103 | 109 | context->state_pd = cpu_to_be32(pd->pd_num); |
---|
104 | 110 | context->lkey = cpu_to_be32(srq->mr.ibmr.lkey); |
---|
105 | 111 | |
---|
106 | | - if (pd->ibpd.uobject) |
---|
107 | | - context->uar = |
---|
108 | | - cpu_to_be32(to_mucontext(pd->ibpd.uobject->context)->uar.index); |
---|
| 112 | + if (udata) |
---|
| 113 | + context->uar = cpu_to_be32(ucontext->uar.index); |
---|
109 | 114 | else |
---|
110 | 115 | context->uar = cpu_to_be32(dev->driver_uar.index); |
---|
111 | 116 | } |
---|
.. | .. |
---|
113 | 118 | static void mthca_arbel_init_srq_context(struct mthca_dev *dev, |
---|
114 | 119 | struct mthca_pd *pd, |
---|
115 | 120 | struct mthca_srq *srq, |
---|
116 | | - struct mthca_arbel_srq_context *context) |
---|
| 121 | + struct mthca_arbel_srq_context *context, |
---|
| 122 | + struct ib_udata *udata) |
---|
117 | 123 | { |
---|
| 124 | + struct mthca_ucontext *ucontext = rdma_udata_to_drv_context( |
---|
| 125 | + udata, struct mthca_ucontext, ibucontext); |
---|
118 | 126 | int logsize, max; |
---|
119 | 127 | |
---|
120 | 128 | memset(context, 0, sizeof *context); |
---|
.. | .. |
---|
129 | 137 | context->lkey = cpu_to_be32(srq->mr.ibmr.lkey); |
---|
130 | 138 | context->db_index = cpu_to_be32(srq->db_index); |
---|
131 | 139 | context->logstride_usrpage = cpu_to_be32((srq->wqe_shift - 4) << 29); |
---|
132 | | - if (pd->ibpd.uobject) |
---|
133 | | - context->logstride_usrpage |= |
---|
134 | | - cpu_to_be32(to_mucontext(pd->ibpd.uobject->context)->uar.index); |
---|
| 140 | + if (udata) |
---|
| 141 | + context->logstride_usrpage |= cpu_to_be32(ucontext->uar.index); |
---|
135 | 142 | else |
---|
136 | 143 | context->logstride_usrpage |= cpu_to_be32(dev->driver_uar.index); |
---|
137 | 144 | context->eq_pd = cpu_to_be32(MTHCA_EQ_ASYNC << 24 | pd->pd_num); |
---|
.. | .. |
---|
145 | 152 | } |
---|
146 | 153 | |
---|
147 | 154 | static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd, |
---|
148 | | - struct mthca_srq *srq) |
---|
| 155 | + struct mthca_srq *srq, struct ib_udata *udata) |
---|
149 | 156 | { |
---|
150 | 157 | struct mthca_data_seg *scatter; |
---|
151 | 158 | void *wqe; |
---|
152 | 159 | int err; |
---|
153 | 160 | int i; |
---|
154 | 161 | |
---|
155 | | - if (pd->ibpd.uobject) |
---|
| 162 | + if (udata) |
---|
156 | 163 | return 0; |
---|
157 | 164 | |
---|
158 | 165 | srq->wrid = kmalloc_array(srq->max, sizeof(u64), GFP_KERNEL); |
---|
.. | .. |
---|
197 | 204 | } |
---|
198 | 205 | |
---|
199 | 206 | int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, |
---|
200 | | - struct ib_srq_attr *attr, struct mthca_srq *srq) |
---|
| 207 | + struct ib_srq_attr *attr, struct mthca_srq *srq, |
---|
| 208 | + struct ib_udata *udata) |
---|
201 | 209 | { |
---|
202 | 210 | struct mthca_mailbox *mailbox; |
---|
203 | 211 | int ds; |
---|
.. | .. |
---|
235 | 243 | if (err) |
---|
236 | 244 | goto err_out; |
---|
237 | 245 | |
---|
238 | | - if (!pd->ibpd.uobject) { |
---|
| 246 | + if (!udata) { |
---|
239 | 247 | srq->db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SRQ, |
---|
240 | 248 | srq->srqn, &srq->db); |
---|
241 | 249 | if (srq->db_index < 0) { |
---|
.. | .. |
---|
251 | 259 | goto err_out_db; |
---|
252 | 260 | } |
---|
253 | 261 | |
---|
254 | | - err = mthca_alloc_srq_buf(dev, pd, srq); |
---|
| 262 | + err = mthca_alloc_srq_buf(dev, pd, srq, udata); |
---|
255 | 263 | if (err) |
---|
256 | 264 | goto err_out_mailbox; |
---|
257 | 265 | |
---|
.. | .. |
---|
261 | 269 | mutex_init(&srq->mutex); |
---|
262 | 270 | |
---|
263 | 271 | if (mthca_is_memfree(dev)) |
---|
264 | | - mthca_arbel_init_srq_context(dev, pd, srq, mailbox->buf); |
---|
| 272 | + mthca_arbel_init_srq_context(dev, pd, srq, mailbox->buf, udata); |
---|
265 | 273 | else |
---|
266 | | - mthca_tavor_init_srq_context(dev, pd, srq, mailbox->buf); |
---|
| 274 | + mthca_tavor_init_srq_context(dev, pd, srq, mailbox->buf, udata); |
---|
267 | 275 | |
---|
268 | 276 | err = mthca_SW2HW_SRQ(dev, mailbox, srq->srqn); |
---|
269 | 277 | |
---|
.. | .. |
---|
297 | 305 | mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err); |
---|
298 | 306 | |
---|
299 | 307 | err_out_free_buf: |
---|
300 | | - if (!pd->ibpd.uobject) |
---|
| 308 | + if (!udata) |
---|
301 | 309 | mthca_free_srq_buf(dev, srq); |
---|
302 | 310 | |
---|
303 | 311 | err_out_mailbox: |
---|
304 | 312 | mthca_free_mailbox(dev, mailbox); |
---|
305 | 313 | |
---|
306 | 314 | err_out_db: |
---|
307 | | - if (!pd->ibpd.uobject && mthca_is_memfree(dev)) |
---|
| 315 | + if (!udata && mthca_is_memfree(dev)) |
---|
308 | 316 | mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index); |
---|
309 | 317 | |
---|
310 | 318 | err_out_icm: |
---|
.. | .. |
---|
561 | 569 | dev->kar + MTHCA_RECEIVE_DOORBELL, |
---|
562 | 570 | MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); |
---|
563 | 571 | } |
---|
564 | | - |
---|
565 | | - /* |
---|
566 | | - * Make sure doorbells don't leak out of SRQ spinlock and |
---|
567 | | - * reach the HCA out of order: |
---|
568 | | - */ |
---|
569 | | - mmiowb(); |
---|
570 | 572 | |
---|
571 | 573 | spin_unlock_irqrestore(&srq->lock, flags); |
---|
572 | 574 | return err; |
---|