Skip to content

Commit f696bf6

Browse files
KAGA-KOKOjgunthorpe
authored andcommitted
RDMA: Constify the argument of the work request conversion functions
When posting a send work request, the work request that is posted is not modified by any of the RDMA drivers. Make this explicit by constifying most ib_send_wr pointers in RDMA transport drivers. Signed-off-by: Bart Van Assche <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Steve Wise <[email protected]> Reviewed-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 3e081b7 commit f696bf6

File tree

18 files changed

+97
-88
lines changed

18 files changed

+97
-88
lines changed

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ int bnxt_re_query_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
18761876
/* Routine for sending QP1 packets for RoCE V1 an V2
18771877
*/
18781878
static int bnxt_re_build_qp1_send_v2(struct bnxt_re_qp *qp,
1879-
struct ib_send_wr *wr,
1879+
const struct ib_send_wr *wr,
18801880
struct bnxt_qplib_swqe *wqe,
18811881
int payload_size)
18821882
{
@@ -2093,7 +2093,7 @@ static int is_ud_qp(struct bnxt_re_qp *qp)
20932093
}
20942094

20952095
static int bnxt_re_build_send_wqe(struct bnxt_re_qp *qp,
2096-
struct ib_send_wr *wr,
2096+
const struct ib_send_wr *wr,
20972097
struct bnxt_qplib_swqe *wqe)
20982098
{
20992099
struct bnxt_re_ah *ah = NULL;
@@ -2131,7 +2131,7 @@ static int bnxt_re_build_send_wqe(struct bnxt_re_qp *qp,
21312131
return 0;
21322132
}
21332133

2134-
static int bnxt_re_build_rdma_wqe(struct ib_send_wr *wr,
2134+
static int bnxt_re_build_rdma_wqe(const struct ib_send_wr *wr,
21352135
struct bnxt_qplib_swqe *wqe)
21362136
{
21372137
switch (wr->opcode) {
@@ -2163,7 +2163,7 @@ static int bnxt_re_build_rdma_wqe(struct ib_send_wr *wr,
21632163
return 0;
21642164
}
21652165

2166-
static int bnxt_re_build_atomic_wqe(struct ib_send_wr *wr,
2166+
static int bnxt_re_build_atomic_wqe(const struct ib_send_wr *wr,
21672167
struct bnxt_qplib_swqe *wqe)
21682168
{
21692169
switch (wr->opcode) {
@@ -2190,7 +2190,7 @@ static int bnxt_re_build_atomic_wqe(struct ib_send_wr *wr,
21902190
return 0;
21912191
}
21922192

2193-
static int bnxt_re_build_inv_wqe(struct ib_send_wr *wr,
2193+
static int bnxt_re_build_inv_wqe(const struct ib_send_wr *wr,
21942194
struct bnxt_qplib_swqe *wqe)
21952195
{
21962196
wqe->type = BNXT_QPLIB_SWQE_TYPE_LOCAL_INV;
@@ -2209,7 +2209,7 @@ static int bnxt_re_build_inv_wqe(struct ib_send_wr *wr,
22092209
return 0;
22102210
}
22112211

2212-
static int bnxt_re_build_reg_wqe(struct ib_reg_wr *wr,
2212+
static int bnxt_re_build_reg_wqe(const struct ib_reg_wr *wr,
22132213
struct bnxt_qplib_swqe *wqe)
22142214
{
22152215
struct bnxt_re_mr *mr = container_of(wr->mr, struct bnxt_re_mr, ib_mr);
@@ -2251,7 +2251,7 @@ static int bnxt_re_build_reg_wqe(struct ib_reg_wr *wr,
22512251
}
22522252

22532253
static int bnxt_re_copy_inline_data(struct bnxt_re_dev *rdev,
2254-
struct ib_send_wr *wr,
2254+
const struct ib_send_wr *wr,
22552255
struct bnxt_qplib_swqe *wqe)
22562256
{
22572257
/* Copy the inline data to the data field */
@@ -2281,7 +2281,7 @@ static int bnxt_re_copy_inline_data(struct bnxt_re_dev *rdev,
22812281
}
22822282

22832283
static int bnxt_re_copy_wr_payload(struct bnxt_re_dev *rdev,
2284-
struct ib_send_wr *wr,
2284+
const struct ib_send_wr *wr,
22852285
struct bnxt_qplib_swqe *wqe)
22862286
{
22872287
int payload_sz = 0;
@@ -2313,7 +2313,7 @@ static void bnxt_ud_qp_hw_stall_workaround(struct bnxt_re_qp *qp)
23132313

23142314
static int bnxt_re_post_send_shadow_qp(struct bnxt_re_dev *rdev,
23152315
struct bnxt_re_qp *qp,
2316-
struct ib_send_wr *wr)
2316+
const struct ib_send_wr *wr)
23172317
{
23182318
struct bnxt_qplib_swqe wqe;
23192319
int rc = 0, payload_sz = 0;

drivers/infiniband/hw/cxgb3/iwch_qp.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
#define NO_SUPPORT -1
4141

42-
static int build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr,
43-
u8 * flit_cnt)
42+
static int build_rdma_send(union t3_wr *wqe, const struct ib_send_wr *wr,
43+
u8 *flit_cnt)
4444
{
4545
int i;
4646
u32 plen;
@@ -84,8 +84,8 @@ static int build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr,
8484
return 0;
8585
}
8686

87-
static int build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr,
88-
u8 *flit_cnt)
87+
static int build_rdma_write(union t3_wr *wqe, const struct ib_send_wr *wr,
88+
u8 *flit_cnt)
8989
{
9090
int i;
9191
u32 plen;
@@ -125,8 +125,8 @@ static int build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr,
125125
return 0;
126126
}
127127

128-
static int build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr,
129-
u8 *flit_cnt)
128+
static int build_rdma_read(union t3_wr *wqe, const struct ib_send_wr *wr,
129+
u8 *flit_cnt)
130130
{
131131
if (wr->num_sge > 1)
132132
return -EINVAL;
@@ -146,8 +146,8 @@ static int build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr,
146146
return 0;
147147
}
148148

149-
static int build_memreg(union t3_wr *wqe, struct ib_reg_wr *wr,
150-
u8 *flit_cnt, int *wr_cnt, struct t3_wq *wq)
149+
static int build_memreg(union t3_wr *wqe, const struct ib_reg_wr *wr,
150+
u8 *flit_cnt, int *wr_cnt, struct t3_wq *wq)
151151
{
152152
struct iwch_mr *mhp = to_iwch_mr(wr->mr);
153153
int i;
@@ -189,8 +189,8 @@ static int build_memreg(union t3_wr *wqe, struct ib_reg_wr *wr,
189189
return 0;
190190
}
191191

192-
static int build_inv_stag(union t3_wr *wqe, struct ib_send_wr *wr,
193-
u8 *flit_cnt)
192+
static int build_inv_stag(union t3_wr *wqe, const struct ib_send_wr *wr,
193+
u8 *flit_cnt)
194194
{
195195
wqe->local_inv.stag = cpu_to_be32(wr->ex.invalidate_rkey);
196196
wqe->local_inv.reserved = 0;

drivers/infiniband/hw/cxgb4/qp.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
410410
}
411411

412412
static int build_immd(struct t4_sq *sq, struct fw_ri_immd *immdp,
413-
struct ib_send_wr *wr, int max, u32 *plenp)
413+
const struct ib_send_wr *wr, int max, u32 *plenp)
414414
{
415415
u8 *dstp, *srcp;
416416
u32 plen = 0;
@@ -480,7 +480,7 @@ static int build_isgl(__be64 *queue_start, __be64 *queue_end,
480480
}
481481

482482
static int build_rdma_send(struct t4_sq *sq, union t4_wr *wqe,
483-
struct ib_send_wr *wr, u8 *len16)
483+
const struct ib_send_wr *wr, u8 *len16)
484484
{
485485
u32 plen;
486486
int size;
@@ -547,7 +547,7 @@ static int build_rdma_send(struct t4_sq *sq, union t4_wr *wqe,
547547
}
548548

549549
static int build_rdma_write(struct t4_sq *sq, union t4_wr *wqe,
550-
struct ib_send_wr *wr, u8 *len16)
550+
const struct ib_send_wr *wr, u8 *len16)
551551
{
552552
u32 plen;
553553
int size;
@@ -589,7 +589,8 @@ static int build_rdma_write(struct t4_sq *sq, union t4_wr *wqe,
589589
return 0;
590590
}
591591

592-
static int build_rdma_read(union t4_wr *wqe, struct ib_send_wr *wr, u8 *len16)
592+
static int build_rdma_read(union t4_wr *wqe, const struct ib_send_wr *wr,
593+
u8 *len16)
593594
{
594595
if (wr->num_sge > 1)
595596
return -EINVAL;
@@ -648,7 +649,7 @@ static int build_srq_recv(union t4_recv_wr *wqe, struct ib_recv_wr *wr,
648649
}
649650

650651
static void build_tpte_memreg(struct fw_ri_fr_nsmr_tpte_wr *fr,
651-
struct ib_reg_wr *wr, struct c4iw_mr *mhp,
652+
const struct ib_reg_wr *wr, struct c4iw_mr *mhp,
652653
u8 *len16)
653654
{
654655
__be64 *p = (__be64 *)fr->pbl;
@@ -680,8 +681,8 @@ static void build_tpte_memreg(struct fw_ri_fr_nsmr_tpte_wr *fr,
680681
}
681682

682683
static int build_memreg(struct t4_sq *sq, union t4_wr *wqe,
683-
struct ib_reg_wr *wr, struct c4iw_mr *mhp, u8 *len16,
684-
bool dsgl_supported)
684+
const struct ib_reg_wr *wr, struct c4iw_mr *mhp,
685+
u8 *len16, bool dsgl_supported)
685686
{
686687
struct fw_ri_immd *imdp;
687688
__be64 *p;
@@ -743,7 +744,8 @@ static int build_memreg(struct t4_sq *sq, union t4_wr *wqe,
743744
return 0;
744745
}
745746

746-
static int build_inv_stag(union t4_wr *wqe, struct ib_send_wr *wr, u8 *len16)
747+
static int build_inv_stag(union t4_wr *wqe, const struct ib_send_wr *wr,
748+
u8 *len16)
747749
{
748750
wqe->inv.stag_inv = cpu_to_be32(wr->ex.invalidate_rkey);
749751
wqe->inv.r2 = 0;
@@ -862,7 +864,8 @@ static int ib_to_fw_opcode(int ib_opcode)
862864
return opcode;
863865
}
864866

865-
static int complete_sq_drain_wr(struct c4iw_qp *qhp, struct ib_send_wr *wr)
867+
static int complete_sq_drain_wr(struct c4iw_qp *qhp,
868+
const struct ib_send_wr *wr)
866869
{
867870
struct t4_cqe cqe = {};
868871
struct c4iw_cq *schp;

drivers/infiniband/hw/hns/hns_roce_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ void hns_roce_qp_remove(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp);
985985
void hns_roce_qp_free(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp);
986986
void hns_roce_release_range_qp(struct hns_roce_dev *hr_dev, int base_qpn,
987987
int cnt);
988-
__be32 send_ieth(struct ib_send_wr *wr);
988+
__be32 send_ieth(const struct ib_send_wr *wr);
989989
int to_hr_qp_type(int qp_type);
990990

991991
struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void set_data_seg_v2(struct hns_roce_v2_wqe_data_seg *dseg,
5353
dseg->len = cpu_to_le32(sg->length);
5454
}
5555

56-
static void set_extend_sge(struct hns_roce_qp *qp, struct ib_send_wr *wr,
56+
static void set_extend_sge(struct hns_roce_qp *qp, const struct ib_send_wr *wr,
5757
unsigned int *sge_ind)
5858
{
5959
struct hns_roce_v2_wqe_data_seg *dseg;
@@ -100,7 +100,7 @@ static void set_extend_sge(struct hns_roce_qp *qp, struct ib_send_wr *wr,
100100
}
101101
}
102102

103-
static int set_rwqe_data_seg(struct ib_qp *ibqp, struct ib_send_wr *wr,
103+
static int set_rwqe_data_seg(struct ib_qp *ibqp, const struct ib_send_wr *wr,
104104
struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,
105105
void *wqe, unsigned int *sge_ind,
106106
struct ib_send_wr **bad_wr)

drivers/infiniband/hw/mlx4/qp.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ static int vf_get_qp0_qkey(struct mlx4_dev *dev, int qpn, u32 *qkey)
29252925
}
29262926

29272927
static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
2928-
struct ib_ud_wr *wr,
2928+
const struct ib_ud_wr *wr,
29292929
void *wqe, unsigned *mlx_seg_len)
29302930
{
29312931
struct mlx4_ib_dev *mdev = to_mdev(sqp->qp.ibqp.device);
@@ -3073,7 +3073,7 @@ static int fill_gid_by_hw_index(struct mlx4_ib_dev *ibdev, u8 port_num,
30733073
}
30743074

30753075
#define MLX4_ROCEV2_QP1_SPORT 0xC000
3076-
static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
3076+
static int build_mlx_header(struct mlx4_ib_sqp *sqp, const struct ib_ud_wr *wr,
30773077
void *wqe, unsigned *mlx_seg_len)
30783078
{
30793079
struct ib_device *ib_dev = sqp->qp.ibqp.device;
@@ -3355,7 +3355,7 @@ static __be32 convert_access(int acc)
33553355
}
33563356

33573357
static void set_reg_seg(struct mlx4_wqe_fmr_seg *fseg,
3358-
struct ib_reg_wr *wr)
3358+
const struct ib_reg_wr *wr)
33593359
{
33603360
struct mlx4_ib_mr *mr = to_mmr(wr->mr);
33613361

@@ -3385,7 +3385,7 @@ static __always_inline void set_raddr_seg(struct mlx4_wqe_raddr_seg *rseg,
33853385
}
33863386

33873387
static void set_atomic_seg(struct mlx4_wqe_atomic_seg *aseg,
3388-
struct ib_atomic_wr *wr)
3388+
const struct ib_atomic_wr *wr)
33893389
{
33903390
if (wr->wr.opcode == IB_WR_ATOMIC_CMP_AND_SWP) {
33913391
aseg->swap_add = cpu_to_be64(wr->swap);
@@ -3401,7 +3401,7 @@ static void set_atomic_seg(struct mlx4_wqe_atomic_seg *aseg,
34013401
}
34023402

34033403
static void set_masked_atomic_seg(struct mlx4_wqe_masked_atomic_seg *aseg,
3404-
struct ib_atomic_wr *wr)
3404+
const struct ib_atomic_wr *wr)
34053405
{
34063406
aseg->swap_add = cpu_to_be64(wr->swap);
34073407
aseg->swap_add_mask = cpu_to_be64(wr->swap_mask);
@@ -3410,7 +3410,7 @@ static void set_masked_atomic_seg(struct mlx4_wqe_masked_atomic_seg *aseg,
34103410
}
34113411

34123412
static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
3413-
struct ib_ud_wr *wr)
3413+
const struct ib_ud_wr *wr)
34143414
{
34153415
memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof (struct mlx4_av));
34163416
dseg->dqpn = cpu_to_be32(wr->remote_qpn);
@@ -3421,7 +3421,7 @@ static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
34213421

34223422
static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev,
34233423
struct mlx4_wqe_datagram_seg *dseg,
3424-
struct ib_ud_wr *wr,
3424+
const struct ib_ud_wr *wr,
34253425
enum mlx4_ib_qp_type qpt)
34263426
{
34273427
union mlx4_ext_av *av = &to_mah(wr->ah)->av;
@@ -3443,7 +3443,8 @@ static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev,
34433443
dseg->qkey = cpu_to_be32(IB_QP_SET_QKEY);
34443444
}
34453445

3446-
static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_seg_len)
3446+
static void build_tunnel_header(const struct ib_ud_wr *wr, void *wqe,
3447+
unsigned *mlx_seg_len)
34473448
{
34483449
struct mlx4_wqe_inline_seg *inl = wqe;
34493450
struct mlx4_ib_tunnel_header hdr;
@@ -3526,9 +3527,9 @@ static void __set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ib_sge *sg)
35263527
dseg->addr = cpu_to_be64(sg->addr);
35273528
}
35283529

3529-
static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_ud_wr *wr,
3530-
struct mlx4_ib_qp *qp, unsigned *lso_seg_len,
3531-
__be32 *lso_hdr_sz, __be32 *blh)
3530+
static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe,
3531+
const struct ib_ud_wr *wr, struct mlx4_ib_qp *qp,
3532+
unsigned *lso_seg_len, __be32 *lso_hdr_sz, __be32 *blh)
35323533
{
35333534
unsigned halign = ALIGN(sizeof *wqe + wr->hlen, 16);
35343535

@@ -3546,7 +3547,7 @@ static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_ud_wr *wr,
35463547
return 0;
35473548
}
35483549

3549-
static __be32 send_ieth(struct ib_send_wr *wr)
3550+
static __be32 send_ieth(const struct ib_send_wr *wr)
35503551
{
35513552
switch (wr->opcode) {
35523553
case IB_WR_SEND_WITH_IMM:

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ struct mlx5_umr_wr {
469469
u32 mkey;
470470
};
471471

472-
static inline struct mlx5_umr_wr *umr_wr(struct ib_send_wr *wr)
472+
static inline const struct mlx5_umr_wr *umr_wr(const struct ib_send_wr *wr)
473473
{
474474
return container_of(wr, struct mlx5_umr_wr, wr);
475475
}

0 commit comments

Comments
 (0)