@@ -154,47 +154,24 @@ static void set_extend_sge(struct hns_roce_qp *qp, const struct ib_send_wr *wr,
154
154
unsigned int * sge_ind , int valid_num_sge )
155
155
{
156
156
struct hns_roce_v2_wqe_data_seg * dseg ;
157
- struct ib_sge * sg ;
158
- int num_in_wqe = 0 ;
159
- int extend_sge_num ;
160
- int fi_sge_num ;
161
- int se_sge_num ;
162
- int shift ;
163
- int i ;
157
+ struct ib_sge * sge = wr -> sg_list ;
158
+ unsigned int idx = * sge_ind ;
159
+ int cnt = valid_num_sge ;
164
160
165
- if (qp -> ibqp .qp_type == IB_QPT_RC || qp -> ibqp .qp_type == IB_QPT_UC )
166
- num_in_wqe = HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE ;
167
- extend_sge_num = valid_num_sge - num_in_wqe ;
168
- sg = wr -> sg_list + num_in_wqe ;
169
- shift = qp -> mtr .hem_cfg .buf_pg_shift ;
161
+ if (qp -> ibqp .qp_type == IB_QPT_RC || qp -> ibqp .qp_type == IB_QPT_UC ) {
162
+ cnt -= HNS_ROCE_SGE_IN_WQE ;
163
+ sge += HNS_ROCE_SGE_IN_WQE ;
164
+ }
170
165
171
- /*
172
- * Check whether wr->num_sge sges are in the same page. If not, we
173
- * should calculate how many sges in the first page and the second
174
- * page.
175
- */
176
- dseg = hns_roce_get_extend_sge (qp , (* sge_ind ) & (qp -> sge .sge_cnt - 1 ));
177
- fi_sge_num = (round_up ((uintptr_t )dseg , 1 << shift ) -
178
- (uintptr_t )dseg ) /
179
- sizeof (struct hns_roce_v2_wqe_data_seg );
180
- if (extend_sge_num > fi_sge_num ) {
181
- se_sge_num = extend_sge_num - fi_sge_num ;
182
- for (i = 0 ; i < fi_sge_num ; i ++ ) {
183
- set_data_seg_v2 (dseg ++ , sg + i );
184
- (* sge_ind )++ ;
185
- }
186
- dseg = hns_roce_get_extend_sge (qp ,
187
- (* sge_ind ) & (qp -> sge .sge_cnt - 1 ));
188
- for (i = 0 ; i < se_sge_num ; i ++ ) {
189
- set_data_seg_v2 (dseg ++ , sg + fi_sge_num + i );
190
- (* sge_ind )++ ;
191
- }
192
- } else {
193
- for (i = 0 ; i < extend_sge_num ; i ++ ) {
194
- set_data_seg_v2 (dseg ++ , sg + i );
195
- (* sge_ind )++ ;
196
- }
166
+ while (cnt > 0 ) {
167
+ dseg = hns_roce_get_extend_sge (qp , idx & (qp -> sge .sge_cnt - 1 ));
168
+ set_data_seg_v2 (dseg , sge );
169
+ idx ++ ;
170
+ sge ++ ;
171
+ cnt -- ;
197
172
}
173
+
174
+ * sge_ind = idx ;
198
175
}
199
176
200
177
static int set_rwqe_data_seg (struct ib_qp * ibqp , const struct ib_send_wr * wr ,
@@ -232,7 +209,7 @@ static int set_rwqe_data_seg(struct ib_qp *ibqp, const struct ib_send_wr *wr,
232
209
roce_set_bit (rc_sq_wqe -> byte_4 , V2_RC_SEND_WQE_BYTE_4_INLINE_S ,
233
210
1 );
234
211
} else {
235
- if (valid_num_sge <= HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE ) {
212
+ if (valid_num_sge <= HNS_ROCE_SGE_IN_WQE ) {
236
213
for (i = 0 ; i < wr -> num_sge ; i ++ ) {
237
214
if (likely (wr -> sg_list [i ].length )) {
238
215
set_data_seg_v2 (dseg , wr -> sg_list + i );
@@ -245,8 +222,8 @@ static int set_rwqe_data_seg(struct ib_qp *ibqp, const struct ib_send_wr *wr,
245
222
V2_RC_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_S ,
246
223
(* sge_ind ) & (qp -> sge .sge_cnt - 1 ));
247
224
248
- for (i = 0 ; i < wr -> num_sge &&
249
- j < HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE ; i ++ ) {
225
+ for (i = 0 ; i < wr -> num_sge && j < HNS_ROCE_SGE_IN_WQE ;
226
+ i ++ ) {
250
227
if (likely (wr -> sg_list [i ].length )) {
251
228
set_data_seg_v2 (dseg , wr -> sg_list + i );
252
229
dseg ++ ;
@@ -675,7 +652,7 @@ static int hns_roce_v2_post_recv(struct ib_qp *ibqp,
675
652
}
676
653
677
654
/* rq support inline data */
678
- if (hr_dev -> caps . flags & HNS_ROCE_CAP_FLAG_RQ_INLINE ) {
655
+ if (hr_qp -> rq_inl_buf . wqe_cnt ) {
679
656
sge_list = hr_qp -> rq_inl_buf .wqe_list [wqe_idx ].sg_list ;
680
657
hr_qp -> rq_inl_buf .wqe_list [wqe_idx ].sge_cnt =
681
658
(u32 )wr -> num_sge ;
@@ -3491,29 +3468,18 @@ static void set_qpc_wqe_cnt(struct hns_roce_qp *hr_qp,
3491
3468
struct hns_roce_v2_qp_context * context ,
3492
3469
struct hns_roce_v2_qp_context * qpc_mask )
3493
3470
{
3494
- if (hr_qp -> ibqp .qp_type == IB_QPT_GSI )
3495
- roce_set_field (context -> byte_4_sqpn_tst ,
3496
- V2_QPC_BYTE_4_SGE_SHIFT_M ,
3497
- V2_QPC_BYTE_4_SGE_SHIFT_S ,
3498
- ilog2 ((unsigned int )hr_qp -> sge .sge_cnt ));
3499
- else
3500
- roce_set_field (context -> byte_4_sqpn_tst ,
3501
- V2_QPC_BYTE_4_SGE_SHIFT_M ,
3502
- V2_QPC_BYTE_4_SGE_SHIFT_S ,
3503
- hr_qp -> sq .max_gs >
3504
- HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE ?
3505
- ilog2 ((unsigned int )hr_qp -> sge .sge_cnt ) : 0 );
3471
+ roce_set_field (context -> byte_4_sqpn_tst ,
3472
+ V2_QPC_BYTE_4_SGE_SHIFT_M , V2_QPC_BYTE_4_SGE_SHIFT_S ,
3473
+ to_hr_hem_entries_shift (hr_qp -> sge .sge_cnt ,
3474
+ hr_qp -> sge .sge_shift ));
3506
3475
3507
3476
roce_set_field (context -> byte_20_smac_sgid_idx ,
3508
3477
V2_QPC_BYTE_20_SQ_SHIFT_M , V2_QPC_BYTE_20_SQ_SHIFT_S ,
3509
- ilog2 (( unsigned int ) hr_qp -> sq .wqe_cnt ));
3478
+ ilog2 (hr_qp -> sq .wqe_cnt ));
3510
3479
3511
3480
roce_set_field (context -> byte_20_smac_sgid_idx ,
3512
3481
V2_QPC_BYTE_20_RQ_SHIFT_M , V2_QPC_BYTE_20_RQ_SHIFT_S ,
3513
- (hr_qp -> ibqp .qp_type == IB_QPT_XRC_INI ||
3514
- hr_qp -> ibqp .qp_type == IB_QPT_XRC_TGT ||
3515
- hr_qp -> ibqp .srq ) ? 0 :
3516
- ilog2 ((unsigned int )hr_qp -> rq .wqe_cnt ));
3482
+ ilog2 (hr_qp -> rq .wqe_cnt ));
3517
3483
}
3518
3484
3519
3485
static void modify_qp_reset_to_init (struct ib_qp * ibqp ,
@@ -3781,26 +3747,26 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
3781
3747
3782
3748
roce_set_field (context -> byte_12_sq_hop , V2_QPC_BYTE_12_SQ_HOP_NUM_M ,
3783
3749
V2_QPC_BYTE_12_SQ_HOP_NUM_S ,
3784
- hr_dev -> caps .wqe_sq_hop_num == HNS_ROCE_HOP_NUM_0 ?
3785
- 0 : hr_dev -> caps . wqe_sq_hop_num );
3750
+ to_hr_hem_hopnum ( hr_dev -> caps .wqe_sq_hop_num ,
3751
+ hr_qp -> sq . wqe_cnt ) );
3786
3752
roce_set_field (qpc_mask -> byte_12_sq_hop , V2_QPC_BYTE_12_SQ_HOP_NUM_M ,
3787
3753
V2_QPC_BYTE_12_SQ_HOP_NUM_S , 0 );
3788
3754
3789
3755
roce_set_field (context -> byte_20_smac_sgid_idx ,
3790
3756
V2_QPC_BYTE_20_SGE_HOP_NUM_M ,
3791
3757
V2_QPC_BYTE_20_SGE_HOP_NUM_S ,
3792
- ((ibqp -> qp_type == IB_QPT_GSI ) ||
3793
- hr_qp -> sq .max_gs > HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE ) ?
3794
- hr_dev -> caps .wqe_sge_hop_num : 0 );
3758
+ to_hr_hem_hopnum (hr_dev -> caps .wqe_sge_hop_num ,
3759
+ hr_qp -> sge .sge_cnt ));
3795
3760
roce_set_field (qpc_mask -> byte_20_smac_sgid_idx ,
3796
3761
V2_QPC_BYTE_20_SGE_HOP_NUM_M ,
3797
3762
V2_QPC_BYTE_20_SGE_HOP_NUM_S , 0 );
3798
3763
3799
3764
roce_set_field (context -> byte_20_smac_sgid_idx ,
3800
3765
V2_QPC_BYTE_20_RQ_HOP_NUM_M ,
3801
3766
V2_QPC_BYTE_20_RQ_HOP_NUM_S ,
3802
- hr_dev -> caps .wqe_rq_hop_num == HNS_ROCE_HOP_NUM_0 ?
3803
- 0 : hr_dev -> caps .wqe_rq_hop_num );
3767
+ to_hr_hem_hopnum (hr_dev -> caps .wqe_rq_hop_num ,
3768
+ hr_qp -> rq .wqe_cnt ));
3769
+
3804
3770
roce_set_field (qpc_mask -> byte_20_smac_sgid_idx ,
3805
3771
V2_QPC_BYTE_20_RQ_HOP_NUM_M ,
3806
3772
V2_QPC_BYTE_20_RQ_HOP_NUM_S , 0 );
@@ -3977,7 +3943,7 @@ static int modify_qp_rtr_to_rts(struct ib_qp *ibqp,
3977
3943
return - EINVAL ;
3978
3944
}
3979
3945
3980
- if (hr_qp -> sge .offset ) {
3946
+ if (hr_qp -> sge .sge_cnt > 0 ) {
3981
3947
page_size = 1 << hr_qp -> mtr .hem_cfg .buf_pg_shift ;
3982
3948
count = hns_roce_mtr_find (hr_dev , & hr_qp -> mtr ,
3983
3949
hr_qp -> sge .offset / page_size ,
@@ -4011,15 +3977,12 @@ static int modify_qp_rtr_to_rts(struct ib_qp *ibqp,
4011
3977
V2_QPC_BYTE_168_SQ_CUR_BLK_ADDR_M ,
4012
3978
V2_QPC_BYTE_168_SQ_CUR_BLK_ADDR_S , 0 );
4013
3979
4014
- context -> sq_cur_sge_blk_addr = ((ibqp -> qp_type == IB_QPT_GSI ) ||
4015
- hr_qp -> sq .max_gs > HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE ) ?
4016
- cpu_to_le32 (to_hr_hw_page_addr (sge_cur_blk )) : 0 ;
3980
+ context -> sq_cur_sge_blk_addr =
3981
+ cpu_to_le32 (to_hr_hw_page_addr (sge_cur_blk ));
4017
3982
roce_set_field (context -> byte_184_irrl_idx ,
4018
3983
V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_M ,
4019
3984
V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_S ,
4020
- ((ibqp -> qp_type == IB_QPT_GSI ) || hr_qp -> sq .max_gs >
4021
- HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE ) ?
4022
- upper_32_bits (to_hr_hw_page_addr (sge_cur_blk )) : 0 );
3985
+ upper_32_bits (to_hr_hw_page_addr (sge_cur_blk )));
4023
3986
qpc_mask -> sq_cur_sge_blk_addr = 0 ;
4024
3987
roce_set_field (qpc_mask -> byte_184_irrl_idx ,
4025
3988
V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_M ,
0 commit comments