rvt was using ib_sge as part of it's ABI, which is not allowed. Introduce a new struct with the same layout and use it instead.
Unified · Split
| @@ -1847,8 +1847,11 @@ int rvt_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, · 1846 unmodified lines | ||
| 1847 | 1847 | wqe = rvt_get_rwqe_ptr(&qp->r_rq, wq->head); |
| 1848 | 1848 | wqe->wr_id = wr->wr_id; |
| 1849 | 1849 | wqe->num_sge = wr->num_sge; |
| 1850 | − for (i = 0; i < wr->num_sge; i++) | |
| 1851 | − wqe->sg_list[i] = wr->sg_list[i]; | |
| 1850 | + for (i = 0; i < wr->num_sge; i++) { | |
| 1851 | + wqe->sg_list[i].addr = wr->sg_list[i].addr; | |
| 1852 | + wqe->sg_list[i].length = wr->sg_list[i].length; | |
| 1853 | + wqe->sg_list[i].lkey = wr->sg_list[i].lkey; | |
| 1854 | + } | |
| 1852 | 1855 | /* |
| 1853 | 1856 | * Make sure queue entry is written |
| 1854 | 1857 | * before the head index. |
| @@ -2250,8 +2253,11 @@ int rvt_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, · 395 unmodified lines | ||
| 2250 | 2253 | wqe = rvt_get_rwqe_ptr(&srq->rq, wq->head); |
| 2251 | 2254 | wqe->wr_id = wr->wr_id; |
| 2252 | 2255 | wqe->num_sge = wr->num_sge; |
| 2253 | − for (i = 0; i < wr->num_sge; i++) | |
| 2254 | − wqe->sg_list[i] = wr->sg_list[i]; | |
| 2256 | + for (i = 0; i < wr->num_sge; i++) { | |
| 2257 | + wqe->sg_list[i].addr = wr->sg_list[i].addr; | |
| 2258 | + wqe->sg_list[i].length = wr->sg_list[i].length; | |
| 2259 | + wqe->sg_list[i].lkey = wr->sg_list[i].lkey; | |
| 2260 | + } | |
| 2255 | 2261 | /* Make sure queue entry is written before the head index. */ |
| 2256 | 2262 | smp_store_release(&wq->head, next); |
| 2257 | 2263 | spin_unlock_irqrestore(&srq->rq.kwq->p_lock, flags); |
| @@ -2259,6 +2265,22 @@ int rvt_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, · 1 unmodified line | ||
| 2259 | 2265 | return 0; |
| 2260 | 2266 | } |
| 2261 | 2267 | |
| 2268 | +/* | |
| 2269 | + * rvt used the internal kernel struct as part of its ABI, for now make sure | |
| 2270 | + * the kernel struct does not change layout. FIXME: rvt should never cast the | |
| 2271 | + * user struct to a kernel struct. | |
| 2272 | + */ | |
| 2273 | +static struct ib_sge *rvt_cast_sge(struct rvt_wqe_sge *sge) | |
| 2274 | +{ | |
| 2275 | + BUILD_BUG_ON(offsetof(struct ib_sge, addr) != | |
| 2276 | + offsetof(struct rvt_wqe_sge, addr)); | |
| 2277 | + BUILD_BUG_ON(offsetof(struct ib_sge, length) != | |
| 2278 | + offsetof(struct rvt_wqe_sge, length)); | |
| 2279 | + BUILD_BUG_ON(offsetof(struct ib_sge, lkey) != | |
| 2280 | + offsetof(struct rvt_wqe_sge, lkey)); | |
| 2281 | + return (struct ib_sge *)sge; | |
| 2282 | +} | |
| 2283 | + | |
| 2262 | 2284 | /* |
| 2263 | 2285 | * Validate a RWQE and fill in the SGE state. |
| 2264 | 2286 | * Return 1 if OK. |
| @@ -2282,7 +2304,7 @@ static int init_sge(struct rvt_qp *qp, struct rvt_rwqe *wqe) · 17 unmodified lines | ||
| 2282 | 2304 | continue; |
| 2283 | 2305 | /* Check LKEY */ |
| 2284 | 2306 | ret = rvt_lkey_ok(rkt, pd, j ? &ss->sg_list[j - 1] : &ss->sge, |
| 2285 | − NULL, &wqe->sg_list[i], | |
| 2307 | + NULL, rvt_cast_sge(&wqe->sg_list[i]), | |
| 2286 | 2308 | IB_ACCESS_LOCAL_WRITE); |
| 2287 | 2309 | if (unlikely(ret <= 0)) |
| 2288 | 2310 | goto bad_lkey; |
| @@ -10,11 +10,16 @@ · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | #include <linux/types.h> |
| 12 | 12 | #include <rdma/ib_user_verbs.h> |
| 13 | −#include <rdma/ib_verbs.h> | |
| 14 | 13 | #ifndef RDMA_ATOMIC_UAPI |
| 15 | 14 | #define RDMA_ATOMIC_UAPI(_type, _name) struct{ _type val; } _name |
| 16 | 15 | #endif |
| 17 | 16 | |
| 17 | +struct rvt_wqe_sge { | |
| 18 | + __aligned_u64 addr; | |
| 19 | + __u32 length; | |
| 20 | + __u32 lkey; | |
| 21 | +}; | |
| 22 | + | |
| 18 | 23 | /* |
| 19 | 24 | * This structure is used to contain the head pointer, tail pointer, |
| 20 | 25 | * and completion queue entries as a single memory allocation so |
| @@ -39,7 +44,7 @@ struct rvt_rwqe { · 18 unmodified lines | ||
| 39 | 44 | __u64 wr_id; |
| 40 | 45 | __u8 num_sge; |
| 41 | 46 | __u8 padding[7]; |
| 42 | − struct ib_sge sg_list[]; | |
| 47 | + struct rvt_wqe_sge sg_list[]; | |
| 43 | 48 | }; |
| 44 | 49 | |
| 45 | 50 | /* |