Nicolas Morey 9035bc
From 3b1f864c904915b3baebffb31ea05ee704b0df3c Mon Sep 17 00:00:00 2001
Nicolas Morey 9035bc
From: Luoyouming <luoyouming@huawei.com>
Nicolas Morey 9035bc
Date: Thu, 22 Sep 2022 20:33:13 +0800
Nicolas Morey 9035bc
Subject: [PATCH 1/1] RDMA/hns: Repacing 'dseg_len' by macros in
Nicolas Morey 9035bc
 fill_ext_sge_inl_data()
Nicolas Morey 9035bc
Git-commit: 3b1f864c904915b3baebffb31ea05ee704b0df3c
Nicolas Morey 9035bc
Patch-mainline: v6.1
Nicolas Morey 9035bc
References: git-fixes
Nicolas Morey 9035bc
Nicolas Morey 9035bc
The sge size is known to be constant, so it's unnecessary to use sizeof to
Nicolas Morey 9035bc
calculate.
Nicolas Morey 9035bc
Nicolas Morey 9035bc
Link: https://lore.kernel.org/r/20220922123315.3732205-11-xuhaoyue1@hisilicon.com
Nicolas Morey 9035bc
Signed-off-by: Luoyouming <luoyouming@huawei.com>
Nicolas Morey 9035bc
Signed-off-by: Haoyue Xu <xuhaoyue1@hisilicon.com>
Nicolas Morey 9035bc
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Nicolas Morey 9035bc
Acked-by: Nicolas Morey <nmorey@suse.com>
Nicolas Morey 9035bc
---
Nicolas Morey 9035bc
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 7 +++----
Nicolas Morey 9035bc
 1 file changed, 3 insertions(+), 4 deletions(-)
Nicolas Morey 9035bc
Nicolas Morey 9035bc
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
Nicolas Morey 9035bc
index 31bfea15cdfc..e1716f100dce 100644
Nicolas Morey 9035bc
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
Nicolas Morey 9035bc
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
Nicolas Morey 9035bc
@@ -193,8 +193,7 @@ static int fill_ext_sge_inl_data(struct hns_roce_qp *qp,
Nicolas Morey 9035bc
 				 unsigned int *sge_idx, u32 msg_len)
Nicolas Morey 9035bc
 {
Nicolas Morey 9035bc
 	struct ib_device *ibdev = &(to_hr_dev(qp->ibqp.device))->ib_dev;
Nicolas Morey 9035bc
-	unsigned int dseg_len = sizeof(struct hns_roce_v2_wqe_data_seg);
Nicolas Morey 9035bc
-	unsigned int ext_sge_sz = qp->sq.max_gs * dseg_len;
Nicolas Morey 9035bc
+	unsigned int ext_sge_sz = qp->sq.max_gs * HNS_ROCE_SGE_SIZE;
Nicolas Morey 9035bc
 	unsigned int left_len_in_pg;
Nicolas Morey 9035bc
 	unsigned int idx = *sge_idx;
Nicolas Morey 9035bc
 	unsigned int i = 0;
Nicolas Morey 9035bc
@@ -222,7 +221,7 @@ static int fill_ext_sge_inl_data(struct hns_roce_qp *qp,
Nicolas Morey 9035bc
 		if (len <= left_len_in_pg) {
Nicolas Morey 9035bc
 			memcpy(dseg, addr, len);
Nicolas Morey 9035bc
 
Nicolas Morey 9035bc
-			idx += len / dseg_len;
Nicolas Morey 9035bc
+			idx += len / HNS_ROCE_SGE_SIZE;
Nicolas Morey 9035bc
 
Nicolas Morey 9035bc
 			i++;
Nicolas Morey 9035bc
 			if (i >= wr->num_sge)
Nicolas Morey 9035bc
@@ -237,7 +236,7 @@ static int fill_ext_sge_inl_data(struct hns_roce_qp *qp,
Nicolas Morey 9035bc
 
Nicolas Morey 9035bc
 			len -= left_len_in_pg;
Nicolas Morey 9035bc
 			addr += left_len_in_pg;
Nicolas Morey 9035bc
-			idx += left_len_in_pg / dseg_len;
Nicolas Morey 9035bc
+			idx += left_len_in_pg / HNS_ROCE_SGE_SIZE;
Nicolas Morey 9035bc
 			dseg = hns_roce_get_extend_sge(qp,
Nicolas Morey 9035bc
 						idx & (qp->sge.sge_cnt - 1));
Nicolas Morey 9035bc
 			left_len_in_pg = 1 << HNS_HW_PAGE_SHIFT;
Nicolas Morey 9035bc
-- 
Nicolas Morey 9035bc
2.38.0.1.gee35aeee4b76
Nicolas Morey 9035bc