Skip to content

Commit 8eaa6f7

Browse files
Luoyoumingjgunthorpe
authored andcommitted
RDMA/hns: Fix ext_sge num error when post send
In the HNS ROCE driver, The sge is divided into standard sge and extended sge. There are 2 standard sge in RC/XRC, and the UD standard sge is 0. In the scenario of RC SQ inline, if the data does not exceed 32bytes, the standard sge will be used. If it exceeds, only the extended sge will be used to fill the data. Currently, when filling the extended sge, max_gs is directly used as the number of the extended sge, which did not subtract the number of standard sge. There is a logical error. The new algorithm subtracts the number of standard sge from max_gs to get the actual number of extended sge. Fixes: 30b7078 ("RDMA/hns: Support inline data in extented sge space for RC") Link: https://lore.kernel.org/r/20221108133847.2304539-2-xuhaoyue1@hisilicon.com Signed-off-by: Luoyouming <luoyouming@huawei.com> Signed-off-by: Haoyue Xu <xuhaoyue1@hisilicon.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 7d984da commit 8eaa6f7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,29 @@ static void set_atomic_seg(const struct ib_send_wr *wr,
188188
hr_reg_write(rc_sq_wqe, RC_SEND_WQE_SGE_NUM, valid_num_sge);
189189
}
190190

191+
static unsigned int get_std_sge_num(struct hns_roce_qp *qp)
192+
{
193+
if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_UD)
194+
return 0;
195+
196+
return HNS_ROCE_SGE_IN_WQE;
197+
}
198+
191199
static int fill_ext_sge_inl_data(struct hns_roce_qp *qp,
192200
const struct ib_send_wr *wr,
193201
unsigned int *sge_idx, u32 msg_len)
194202
{
195203
struct ib_device *ibdev = &(to_hr_dev(qp->ibqp.device))->ib_dev;
196-
unsigned int ext_sge_sz = qp->sq.max_gs * HNS_ROCE_SGE_SIZE;
197204
unsigned int left_len_in_pg;
198205
unsigned int idx = *sge_idx;
206+
unsigned int std_sge_num;
199207
unsigned int i = 0;
200208
unsigned int len;
201209
void *addr;
202210
void *dseg;
203211

204-
if (msg_len > ext_sge_sz) {
212+
std_sge_num = get_std_sge_num(qp);
213+
if (msg_len > (qp->sq.max_gs - std_sge_num) * HNS_ROCE_SGE_SIZE) {
205214
ibdev_err(ibdev,
206215
"no enough extended sge space for inline data.\n");
207216
return -EINVAL;

0 commit comments

Comments
 (0)