Skip to contentSkip to conversation

RDMA/hns: Add supports for stash

PATCH Superseded Weihang Li 2 participants 6 messages Sep 30, 2020 – Oct 9, 2020

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Weihang Li

author
#0 lore raw

cover RDMA/hns: Add supports for stash

Stash is a mechanism that uses the core information carried by the ARM AXI bus to access the L3 cache. The CPU and I/O subsystems can access the L3 cache consistently by enabling stash, so the performance can be improved.

Lang Cheng (3):
RDMA/hns: Add support for CQ stash
RDMA/hns: Add new interfaces to set/clear/read fields in QPC RDMA/hns: Add support for QP stash

 drivers/infiniband/hw/hns/hns_roce_common.h | 26 ++++++++++++++++++++++++++
 drivers/infiniband/hw/hns/hns_roce_device.h |  1 +
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  |  9 +++++++++
 drivers/infiniband/hw/hns/hns_roce_hw_v2.h  |  5 +++++
 4 files changed, 41 insertions(+)
Signature · 1 line
2.8.1
author
#1 lore raw

PATCH 1/3 RDMA/hns: Add support for CQ stash

From: Lang Cheng <[email protected]>

Stash is a mechanism that uses the core information carried by the ARM AXI bus to access the L3 cache. It can be used to improve the performance by increasing the hit ratio of L3 cache. CQs need to enable stash by default.

---
 drivers/infiniband/hw/hns/hns_roce_device.h | 1 +
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c  | 3 +++
 drivers/infiniband/hw/hns/hns_roce_hw_v2.h  | 2 ++
 3 files changed, 6 insertions(+)
drivers/infiniband/hw/hns/hns_roce_device.h +1 -0
index 6d2acff..87d3e57 100644
@@ -221,6 +221,7 @@ enum {
 	HNS_ROCE_CAP_FLAG_FRMR                  = BIT(8),
 	HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL		= BIT(9),
 	HNS_ROCE_CAP_FLAG_ATOMIC		= BIT(10),
+	HNS_ROCE_CAP_FLAG_STASH			= BIT(17),
 };
 
 #define HNS_ROCE_DB_TYPE_COUNT			2
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -0
index 6d30850..154afc0 100644
@@ -3059,6 +3059,9 @@ static void hns_roce_v2_write_cqc(struct hns_roce_dev *hr_dev,
 		       V2_CQC_BYTE_8_CQE_SIZE_S, hr_cq->cqe_size ==
 		       HNS_ROCE_V3_CQE_SIZE ? 1 : 0);
 
+	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_STASH)
+		roce_set_bit(cq_context->byte_8_cqn, V2_CQC_BYTE_8_STASH_S, 1);
+
 	cq_context->cqe_cur_blk_addr = cpu_to_le32(to_hr_hw_page_addr(mtts[0]));
 
 	roce_set_field(cq_context->byte_16_hop_addr,
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +2 -0
index 29c9dd4..cfa8caa 100644
@@ -315,6 +315,8 @@ struct hns_roce_v2_cq_context {
 #define V2_CQC_BYTE_8_CQE_SIZE_S 27
 #define V2_CQC_BYTE_8_CQE_SIZE_M GENMASK(28, 27)
 
+#define V2_CQC_BYTE_8_STASH_S 31
+
 #define	V2_CQC_BYTE_16_CQE_CUR_BLK_ADDR_S 0
 #define V2_CQC_BYTE_16_CQE_CUR_BLK_ADDR_M GENMASK(19, 0)
 
Signature · 1 line
2.8.1
author
#2 lore raw

PATCH 2/3 RDMA/hns: Add new interfaces to set/clear/read fields in QPC

In reply to Weihang Li

From: Lang Cheng <[email protected]>

For a field in extended QPC, there are four newly added interfaces:
- hr_reg_set(arr, field) can set all bits to 1,
- hr_reg_clear(arr, field) can clear all bits to 0,
- hr_reg_write(arr, field, val) can write a new value,
- hr_reg_read(arr, field) can read the value.
'arr' is the array name of extended QPC, and 'field' is the global bit offset of the whole array.

---
 drivers/infiniband/hw/hns/hns_roce_common.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/infiniband/hw/hns/hns_roce_common.h +26 -0
index f5669ff..ab2386d 100644
@@ -53,6 +53,32 @@
 #define roce_set_bit(origin, shift, val) \
 	roce_set_field((origin), (1ul << (shift)), (shift), (val))
 
+#define hr_reg_set(arr, field)                                                 \
+	((arr)[(field) / 32] |=                                                \
+	 cpu_to_le32((field##_W) +                                             \
+		     BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr))))
+
+#define hr_reg_clear(arr, field)                                               \
+	((arr)[(field) / 32] &=                                                \
+	 ~cpu_to_le32((field##_W) +                                            \
+		      BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr))))
+
+#define hr_reg_write(arr, field, val)                                          \
+	do {                                                                   \
+		BUILD_BUG_ON((field) / 32 >= ARRAY_SIZE(arr));                 \
+		(arr)[(field) / 32] &= ~cpu_to_le32(field##_W);                \
+		(arr)[(field) / 32] |= cpu_to_le32(                            \
+			((u32)(val) << ((field) % 32)) & (field##_W));         \
+	} while (0)
+
+#define hr_reg_read(arr, field)                                                \
+	(((le32_to_cpu((arr)[(field) / 32]) & (field##_W)) >> (field) % 32) +  \
+	 BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr)))
+
+#define V3_GENMASK(h, l)                                                       \
+	GENMASK(((h) + BUILD_BUG_ON_ZERO(((h) / 32) != ((l) / 32))) % 32,      \
+		((l) + BUILD_BUG_ON_ZERO((h) < (l))) % 32)
+
 #define ROCEE_GLB_CFG_ROCEE_DB_SQ_MODE_S 3
 #define ROCEE_GLB_CFG_ROCEE_DB_OTH_MODE_S 4
 
Signature · 1 line
2.8.1
maintainer
#3 lore raw

Re: [PATCH for-next 2/3] RDMA/hns: Add new interfaces to set/clear/read fields in QPC

Quoted 33 lines · Weihang Li

From: Lang Cheng <[email protected]>

For a field in extended QPC, there are four newly added interfaces:
- hr_reg_set(arr, field) can set all bits to 1,
- hr_reg_clear(arr, field) can clear all bits to 0,
- hr_reg_write(arr, field, val) can write a new value,
- hr_reg_read(arr, field) can read the value.
'arr' is the array name of extended QPC, and 'field' is the global bit offset of the whole array.

 drivers/infiniband/hw/hns/hns_roce_common.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/infiniband/hw/hns/hns_roce_common.h +12 -0
index f5669ff..ab2386d 100644
+++ b/drivers/infiniband/hw/hns/hns_roce_common.h
@@ -53,6 +53,32 @@
 #define roce_set_bit(origin, shift, val) \
 	roce_set_field((origin), (1ul << (shift)), (shift), (val))
 
+#define hr_reg_set(arr, field)                                                 \
+	((arr)[(field) / 32] |=                                                \
+	 cpu_to_le32((field##_W) +                                             \
+		     BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr))))
+
+#define hr_reg_clear(arr, field)                                               \
+	((arr)[(field) / 32] &=                                                \
+	 ~cpu_to_le32((field##_W) +                                            \
+		      BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr))))
+
+#define hr_reg_write(arr, field, val)                                          \

drivers/infiniband/hw/hns/hns_roce_common.h line 76

Quoted 10 lines
drivers/infiniband/hw/hns/hns_roce_common.h +10 -0
+	do {                                                                   \
+		BUILD_BUG_ON((field) / 32 >= ARRAY_SIZE(arr));                 \
+		(arr)[(field) / 32] &= ~cpu_to_le32(field##_W);                \
+		(arr)[(field) / 32] |= cpu_to_le32(                            \
+			((u32)(val) << ((field) % 32)) & (field##_W));         \
+	} while (0)
+
+#define hr_reg_read(arr, field)                                                \
+	(((le32_to_cpu((arr)[(field) / 32]) & (field##_W)) >> (field) % 32) +  \
+	 BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr)))

Why add these functions that are not used?

Jason

author
#4 lore raw

Re: [PATCH for-next 2/3] RDMA/hns: Add new interfaces to set/clear/read fields in QPC

Quoted 47 lines · Jason Gunthorpe
Quoted 33 lines · Weihang Li

From: Lang Cheng <[email protected]>

For a field in extended QPC, there are four newly added interfaces:
- hr_reg_set(arr, field) can set all bits to 1,
- hr_reg_clear(arr, field) can clear all bits to 0,
- hr_reg_write(arr, field, val) can write a new value,
- hr_reg_read(arr, field) can read the value.
'arr' is the array name of extended QPC, and 'field' is the global bit offset of the whole array.

 drivers/infiniband/hw/hns/hns_roce_common.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/infiniband/hw/hns/hns_roce_common.h +12 -0
index f5669ff..ab2386d 100644
+++ b/drivers/infiniband/hw/hns/hns_roce_common.h
@@ -53,6 +53,32 @@
 #define roce_set_bit(origin, shift, val) \
 	roce_set_field((origin), (1ul << (shift)), (shift), (val))
 
+#define hr_reg_set(arr, field)                                                 \
+	((arr)[(field) / 32] |=                                                \
+	 cpu_to_le32((field##_W) +                                             \
+		     BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr))))
+
+#define hr_reg_clear(arr, field)                                               \
+	((arr)[(field) / 32] &=                                                \
+	 ~cpu_to_le32((field##_W) +                                            \
+		      BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr))))
+
+#define hr_reg_write(arr, field, val)                                          \

drivers/infiniband/hw/hns/hns_roce_common.h line 76

Quoted 10 lines
drivers/infiniband/hw/hns/hns_roce_common.h +10 -0
+	do {                                                                   \
+		BUILD_BUG_ON((field) / 32 >= ARRAY_SIZE(arr));                 \
+		(arr)[(field) / 32] &= ~cpu_to_le32(field##_W);                \
+		(arr)[(field) / 32] |= cpu_to_le32(                            \
+			((u32)(val) << ((field) % 32)) & (field##_W));         \
+	} while (0)
+
+#define hr_reg_read(arr, field)                                                \
+	(((le32_to_cpu((arr)[(field) / 32]) & (field##_W)) >> (field) % 32) +  \
+	 BUILD_BUG_ON_ZERO((field) / 32 >= ARRAY_SIZE(arr)))

Why add these functions that are not used?

Quoted 2 lines

Jason

hr_reg_set() is to be used in patch 3/3 in this series, the others are prepared for follow-up series. I will put hr_reg_set() in patch #3 and add other interfaces only when required.

Thanks
Weihang

author
#5 lore raw

PATCH 3/3 RDMA/hns: Add support for QP stash

In reply to Weihang Li

From: Lang Cheng <[email protected]>

Stash is a mechanism that uses the core information carried by the ARM AXI bus to access the L3 cache. It can be used to improve the performance by increasing the hit ratio of L3 cache. QPs need to enable stash by default.

---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 ++++++
 drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 3 +++
 2 files changed, 9 insertions(+)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +6 -0
index 154afc0..d561e98 100644
@@ -3856,6 +3856,12 @@ static void modify_qp_reset_to_init(struct ib_qp *ibqp,
 	hr_qp->access_flags = attr->qp_access_flags;
 	roce_set_field(context->byte_252_err_txcqn, V2_QPC_BYTE_252_TX_CQN_M,
 		       V2_QPC_BYTE_252_TX_CQN_S, to_hr_cq(ibqp->send_cq)->cqn);
+
+	if (hr_dev->caps.qpc_sz < HNS_ROCE_V3_QPC_SZ)
+		return;
+
+	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_STASH)
+		hr_reg_set(context->ext, QPCEX_STASH);
 }
 
 static void modify_qp_init_to_init(struct ib_qp *ibqp,
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +3 -0
index cfa8caa..1692586 100644
@@ -889,6 +889,9 @@ struct hns_roce_v2_qp_context {
 #define	V2_QPC_BYTE_256_SQ_FLUSH_IDX_S 16
 #define V2_QPC_BYTE_256_SQ_FLUSH_IDX_M GENMASK(31, 16)
 
+#define QPCEX_STASH 82
+#define QPCEX_STASH_W V3_GENMASK(82, 82)
+
 #define	V2_QP_RWE_S 1 /* rdma write enable */
 #define	V2_QP_RRE_S 2 /* rdma read enable */
 #define	V2_QP_ATE_S 3 /* rdma atomic enable */
Signature · 1 line
2.8.1