Skip to contentSkip to conversation

RDMA/hns: Optimize MTR level-0 addressing to access huge page

PATCH Applied Weihang Li 2 participants 2 messages Jun 30, 2020 – Jul 7, 2020

Subsystems (2)
lore
Share & tools
lore

Weihang Li

author
#0 lore raw

PATCH 1/1 RDMA/hns: Optimize MTR level-0 addressing to access huge page

From: Xi Wang <[email protected]>

If hns ROCEE is set to level-0 addressing, the length of the entire buffer can be used as the page size. The driver needn't to split the buffer into small units because all pages are continuous.

---
 drivers/infiniband/hw/hns/hns_roce_device.h |  20 +--
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c  |   7 +-
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  |  44 +-----
 drivers/infiniband/hw/hns/hns_roce_mr.c     | 208 +++++++++++++++++-----------
 4 files changed, 147 insertions(+), 132 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +11 -9
index a61f0c4..c0bc8c4 100644
@@ -348,20 +348,22 @@ struct hns_roce_buf_attr {
 	bool mtt_only; /* only alloc buffer-required MTT memory */
 };
 
+struct hns_roce_hem_cfg {
+	dma_addr_t	root_ba; /* root BA table's address */
+	bool		is_direct; /* addressing without BA table */
+	unsigned int	ba_pg_shift; /* BA table page shift */
+	unsigned int	buf_pg_shift; /* buffer page shift */
+	unsigned int	buf_pg_count;  /* buffer page count */
+	struct hns_roce_buf_region region[HNS_ROCE_MAX_BT_REGION];
+	int		region_count;
+};
+
 /* memory translate region */
 struct hns_roce_mtr {
 	struct hns_roce_hem_list hem_list; /* multi-hop addressing resource */
 	struct ib_umem		*umem; /* user space buffer */
 	struct hns_roce_buf	*kmem; /* kernel space buffer */
-	struct {
-		dma_addr_t	root_ba; /* root BA table's address */
-		bool		is_direct; /* addressing without BA table */
-		unsigned int	ba_pg_shift; /* BA table page shift */
-		unsigned int	buf_pg_shift; /* buffer page shift */
-		int		buf_pg_count;  /* buffer page count */
-		struct hns_roce_buf_region region[HNS_ROCE_MAX_BT_REGION];
-		unsigned int	region_count;
-	} hem_cfg; /* config for hardware addressing */
+	struct hns_roce_hem_cfg  hem_cfg; /* config for hardware addressing */
 };
 
 struct hns_roce_mw {
drivers/infiniband/hw/hns/hns_roce_hw_v1.c +3 -4
index d02207c..ef7f8b3 100644
@@ -2483,7 +2483,6 @@ static int find_wqe_mtt(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
 			u64 *sq_ba, u64 *rq_ba, dma_addr_t *bt_ba)
 {
 	struct ib_device *ibdev = &hr_dev->ib_dev;
-	int rq_pa_start;
 	int count;
 
 	count = hns_roce_mtr_find(hr_dev, &hr_qp->mtr, 0, sq_ba, 1, bt_ba);
@@ -2491,9 +2490,9 @@ static int find_wqe_mtt(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
 		ibdev_err(ibdev, "Failed to find SQ ba\n");
 		return -ENOBUFS;
 	}
-	rq_pa_start = hr_qp->rq.offset >> hr_qp->mtr.hem_cfg.buf_pg_shift;
-	count = hns_roce_mtr_find(hr_dev, &hr_qp->mtr, rq_pa_start, rq_ba, 1,
-				  NULL);
+
+	count = hns_roce_mtr_find(hr_dev, &hr_qp->mtr, hr_qp->rq.offset, rq_ba,
+				  1, NULL);
 	if (!count) {
 		ibdev_err(ibdev, "Failed to find RQ ba\n");
 		return -ENOBUFS;
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +7 -37

74 lines not on this page · raw message

drivers/infiniband/hw/hns/hns_roce_mr.c +126 -82

306 lines not on this page · raw message

Signature · 1 line
2.8.1
maintainer Applied
#1 lore raw
Quoted 6 lines · Weihang Li

From: Xi Wang <[email protected]>

If hns ROCEE is set to level-0 addressing, the length of the entire buffer can be used as the page size. The driver needn't to split the buffer into small units because all pages are continuous.

Quoted 8 lines
---
 drivers/infiniband/hw/hns/hns_roce_device.h |  20 +--
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c  |   7 +-
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  |  44 +-----
 drivers/infiniband/hw/hns/hns_roce_mr.c     | 208 +++++++++++++++++-----------
 4 files changed, 147 insertions(+), 132 deletions(-)

Applied to for-next, thanks

Jason