RDMA/hns: Add supports for stash
Subsystems (2)
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
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
@@ -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
@@ -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
@@ -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
PATCH 2/3 RDMA/hns: Add new interfaces to set/clear/read fields in QPC
In reply to Weihang LiFrom: 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
@@ -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
Jason Gunthorpe
maintainerRe: [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.Signed-off-by Lang Cheng <[email protected]>Signed-off-by Weihang Li <[email protected]>drivers/infiniband/hw/hns/hns_roce_common.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)drivers/infiniband/hw/hns/hns_roce_common.h +12
-0+++ 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
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.Signed-off-by Lang Cheng <[email protected]>Signed-off-by Weihang Li <[email protected]>drivers/infiniband/hw/hns/hns_roce_common.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)drivers/infiniband/hw/hns/hns_roce_common.h +12
-0+++ 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
PATCH 3/3 RDMA/hns: Add support for QP stash
In reply to Weihang LiFrom: 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
@@ -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
@@ -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