2022-11-26 10:40:25

by xuhaoyue (A)

[permalink] [raw]
Subject: [PATCH for-next 0/6] Bugfix for GID and PBL page

This patch set mainly fixes the GID problem caused by free mr.
The second and third patches fix the error on the PBL.
The last three patches fix minor errors found while running
the rdma-core tests.

1.#1: The GID problem caused by free mr
2.#2-#3: Fix the error on the PBL
3.#4-#5: Two minor return errors
4.#6: The default caps error

Chengchang Tang (5):
RDMA/hns: Fix AH attr queried by query_qp
RDMA/hns: Fix PBL page MTR find
RDMA/hns: Fix page size cap from firmwall
RDMA/hns: Fix error code of CMD
RDMA/hns: Fix XRC caps on HIP08

Yixing Liu (1):
RDMA/hns: Fix the gid problem caused by free mr

drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 214 ++++++++++++++++-----
drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 11 +-
2 files changed, 179 insertions(+), 46 deletions(-)

--
2.30.0


2022-11-26 10:41:19

by xuhaoyue (A)

[permalink] [raw]
Subject: [PATCH for-next 6/6] RDMA/hns: Fix XRC caps on HIP08

From: Chengchang Tang <[email protected]>

XRC caps has been set by default. But in fact, XRC is not supported
in HIP08.

Fixes: 32548870d438 ("RDMA/hns: Add support for XRC on HIP09")
Signed-off-by: Chengchang Tang <[email protected]>
Signed-off-by: Haoyue Xu <[email protected]>
---
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index f32100c6f1d9..2716852f5e92 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -2051,13 +2051,14 @@ static void set_default_caps(struct hns_roce_dev *hr_dev)

caps->flags |= HNS_ROCE_CAP_FLAG_ATOMIC | HNS_ROCE_CAP_FLAG_MW |
HNS_ROCE_CAP_FLAG_SRQ | HNS_ROCE_CAP_FLAG_FRMR |
- HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL | HNS_ROCE_CAP_FLAG_XRC;
+ HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL;

caps->gid_table_len[0] = HNS_ROCE_V2_GID_INDEX_NUM;

if (hr_dev->pci_dev->revision >= PCI_REVISION_ID_HIP09) {
caps->flags |= HNS_ROCE_CAP_FLAG_STASH |
- HNS_ROCE_CAP_FLAG_DIRECT_WQE;
+ HNS_ROCE_CAP_FLAG_DIRECT_WQE |
+ HNS_ROCE_CAP_FLAG_XRC;
caps->max_sq_inline = HNS_ROCE_V3_MAX_SQ_INLINE;
} else {
caps->max_sq_inline = HNS_ROCE_V2_MAX_SQ_INLINE;
--
2.30.0

2022-11-26 10:43:41

by xuhaoyue (A)

[permalink] [raw]
Subject: [PATCH for-next 2/6] RDMA/hns: Fix AH attr queried by query_qp

From: Chengchang Tang <[email protected]>

The queried AH attr is invalid. This patch fix it.

This problem is found by rdma-core test test_mr_rereg_pd

ERROR: test_mr_rereg_pd (tests.test_mr.MRTest)
Test that cover rereg MR's PD with this flow:
----------------------------------------------------------------------
Traceback (most recent call last):
File "./tests/test_mr.py", line 157, in test_mr_rereg_pd
self.restate_qps()
File "./tests/test_mr.py", line 113, in restate_qps
self.server.qp.to_rts(self.server_qp_attr)
File "qp.pyx", line 1137, in pyverbs.qp.QP.to_rts
File "qp.pyx", line 1123, in pyverbs.qp.QP.to_rtr
pyverbs.pyverbs_error.PyverbsRDMAError: Failed to modify QP state to RTR.
Errno: 22, Invalid argument

Fixes: 926a01dc000d ("RDMA/hns: Add QP operations support for hip08 SoC")
Signed-off-by: Chengchang Tang <[email protected]>
Signed-off-by: Haoyue Xu <[email protected]>
---
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 93c677239686..a8f8c790d31d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -5470,6 +5470,8 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,

rdma_ah_set_sl(&qp_attr->ah_attr,
hr_reg_read(&context, QPC_SL));
+ rdma_ah_set_port_num(&qp_attr->ah_attr, hr_qp->port + 1);
+ rdma_ah_set_ah_flags(&qp_attr->ah_attr, IB_AH_GRH);
grh->flow_label = hr_reg_read(&context, QPC_FL);
grh->sgid_index = hr_reg_read(&context, QPC_GMV_IDX);
grh->hop_limit = hr_reg_read(&context, QPC_HOPLIMIT);
--
2.30.0

2022-11-26 10:44:05

by xuhaoyue (A)

[permalink] [raw]
Subject: [PATCH for-next 5/6] RDMA/hns: Fix error code of CMD

From: Chengchang Tang <[email protected]>

The error code is fixed to EIO when CMD fails to excute. This patch
converts the error status reported by firmware to linux errno.

Fixes: a04ff739f2a9 ("RDMA/hns: Add command queue support for hip08 RoCE driver")
Signed-off-by: Chengchang Tang <[email protected]>
Signed-off-by: Haoyue Xu <[email protected]>
---
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 26 +++++++++++++++++++++-
drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 5 +++++
2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 6e74735bbcf8..f32100c6f1d9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -1277,6 +1277,30 @@ static void update_cmdq_status(struct hns_roce_dev *hr_dev)
hr_dev->cmd.state = HNS_ROCE_CMDQ_STATE_FATAL_ERR;
}

+static int hns_roce_cmd_err_convert_errno(u16 desc_ret)
+{
+ struct hns_roce_cmd_errcode errcode_table[] = {
+ {CMD_EXEC_SUCCESS, 0},
+ {CMD_NO_AUTH, -EPERM},
+ {CMD_NOT_EXIST, -EOPNOTSUPP},
+ {CMD_CRQ_FULL, -EXFULL},
+ {CMD_NEXT_ERR, -ENOSR},
+ {CMD_NOT_EXEC, -ENOTBLK},
+ {CMD_PARA_ERR, -EINVAL},
+ {CMD_RESULT_ERR, -ERANGE},
+ {CMD_TIMEOUT, -ETIME},
+ {CMD_HILINK_ERR, -ENOLINK},
+ {CMD_INFO_ILLEGAL, -ENXIO},
+ {CMD_INVALID, -EBADR},
+ };
+ u16 i;
+
+ for (i = 0; i < ARRAY_SIZE(errcode_table); i++)
+ if (desc_ret == errcode_table[i].return_status)
+ return errcode_table[i].errno;
+ return -EIO;
+}
+
static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
struct hns_roce_cmq_desc *desc, int num)
{
@@ -1322,7 +1346,7 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,
dev_err_ratelimited(hr_dev->dev,
"Cmdq IO error, opcode = 0x%x, return = 0x%x.\n",
desc->opcode, desc_ret);
- ret = -EIO;
+ ret = hns_roce_cmd_err_convert_errno(desc_ret);
}
} else {
/* FW/HW reset or incorrect number of desc */
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
index 017462e52843..47fad456839d 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
@@ -273,6 +273,11 @@ enum hns_roce_cmd_return_status {
CMD_OTHER_ERR = 0xff
};

+struct hns_roce_cmd_errcode {
+ enum hns_roce_cmd_return_status return_status;
+ int errno;
+};
+
enum hns_roce_sgid_type {
GID_TYPE_FLAG_ROCE_V1 = 0,
GID_TYPE_FLAG_ROCE_V2_IPV4,
--
2.30.0

2022-12-08 01:12:57

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: [PATCH for-next 0/6] Bugfix for GID and PBL page

On Sat, Nov 26, 2022 at 06:29:05PM +0800, Haoyue Xu wrote:
> This patch set mainly fixes the GID problem caused by free mr.
> The second and third patches fix the error on the PBL.
> The last three patches fix minor errors found while running
> the rdma-core tests.
>
> 1.#1: The GID problem caused by free mr
> 2.#2-#3: Fix the error on the PBL
> 3.#4-#5: Two minor return errors
> 4.#6: The default caps error
>
> Chengchang Tang (5):
> RDMA/hns: Fix AH attr queried by query_qp
> RDMA/hns: Fix PBL page MTR find
> RDMA/hns: Fix page size cap from firmwall
> RDMA/hns: Fix error code of CMD
> RDMA/hns: Fix XRC caps on HIP08
>
> Yixing Liu (1):
> RDMA/hns: Fix the gid problem caused by free mr

Applied to for-next

Thanks,
Jason