linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates
@ 2020-09-19 10:03 Weihang Li
  2020-09-19 10:03 ` [PATCH v3 for-next 1/8] RDMA/hns: Refactor process about opcode in post_send() Weihang Li
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Weihang Li @ 2020-09-19 10:03 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

Here are some miscellaneous cleanups and fixes for the hns driver,
including refactor, some newly added checks and so on.

Previous discussion:
v2: https://patchwork.kernel.org/cover/11765125/
v1: https://patchwork.kernel.org/cover/11761647/

Changes since v2:
Fix some issuses according to Jason's comments.
- Change 'unlikely' to 'WARN_ON' and remove prints when getting illegal
  opcodes.
- Drop patch #2 from v1 because the newly added check is meaningless for
  sparse.
- Add fixes tag for patch #3 ~ #5.
- Change '1 << PAGE_SHIFT' to 'PAGE_SIZE' in patch #6.

Changes since v1:
- Fix a missing assignment of owner_bit in set_rc_wqe()

Jiaran Zhang (2):
  RDMA/hns: Add check for the validity of sl configuration
  RDMA/hns: Solve the overflow of the calc_pg_sz()

Lang Cheng (1):
  RDMA/hns: Correct typo of hns_roce_create_cq()

Weihang Li (3):
  RDMA/hns: Refactor process about opcode in post_send()
  RDMA/hns: Fix configuration of ack_req_freq in QPC
  RDMA/hns: Fix missing sq_sig_type when querying QP

Wenpeng Liang (1):
  RDMA/hns: Fix the wrong value of rnr_retry when querying qp

Yangyang Li (1):
  RDMA/hns: Add interception for resizing SRQs

 drivers/infiniband/hw/hns/hns_roce_cq.c    |   2 +-
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 178 ++++++++++++++++++-----------
 drivers/infiniband/hw/hns/hns_roce_hw_v2.h |   2 +
 3 files changed, 114 insertions(+), 68 deletions(-)

-- 
2.8.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3 for-next 1/8] RDMA/hns: Refactor process about opcode in post_send()
  2020-09-19 10:03 [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Weihang Li
@ 2020-09-19 10:03 ` Weihang Li
  2020-09-24 18:59   ` Jason Gunthorpe
  2020-09-19 10:03 ` [PATCH v3 for-next 2/8] RDMA/hns: Add interception for resizing SRQs Weihang Li
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Weihang Li @ 2020-09-19 10:03 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

According to the IB specifications, the verbs should return an immediate
error when the users set an unsupported opcode. Furthermore, refactor codes
about opcode in process of post_send to make the difference between opcodes
clearer.

Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 133 +++++++++++++++++------------
 1 file changed, 78 insertions(+), 55 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 3966262..6a217f9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -292,6 +292,33 @@ static unsigned int calc_wr_sge_num(const struct ib_send_wr *wr,
 	return valid_num;
 }
 
+static __le32 get_immtdata(const struct ib_send_wr *wr)
+{
+	switch (wr->opcode) {
+	case IB_WR_SEND_WITH_IMM:
+	case IB_WR_RDMA_WRITE_WITH_IMM:
+		return cpu_to_le32(be32_to_cpu(wr->ex.imm_data));
+	default:
+		return 0;
+	}
+}
+
+static int set_ud_opcode(struct hns_roce_v2_ud_send_wqe *ud_sq_wqe,
+			 const struct ib_send_wr *wr)
+{
+	u32 ib_op = wr->opcode;
+
+	if (ib_op != IB_WR_SEND && ib_op != IB_WR_SEND_WITH_IMM)
+		return -EINVAL;
+
+	ud_sq_wqe->immtdata = get_immtdata(wr);
+
+	roce_set_field(ud_sq_wqe->byte_4, V2_UD_SEND_WQE_BYTE_4_OPCODE_M,
+		       V2_UD_SEND_WQE_BYTE_4_OPCODE_S, to_hr_opcode(ib_op));
+
+	return 0;
+}
+
 static inline int set_ud_wqe(struct hns_roce_qp *qp,
 			     const struct ib_send_wr *wr,
 			     void *wqe, unsigned int *sge_idx,
@@ -300,15 +327,21 @@ static inline int set_ud_wqe(struct hns_roce_qp *qp,
 	struct hns_roce_dev *hr_dev = to_hr_dev(qp->ibqp.device);
 	struct hns_roce_ah *ah = to_hr_ah(ud_wr(wr)->ah);
 	struct hns_roce_v2_ud_send_wqe *ud_sq_wqe = wqe;
+	struct ib_device *ibdev = &hr_dev->ib_dev;
 	unsigned int curr_idx = *sge_idx;
 	int valid_num_sge;
 	u32 msg_len = 0;
 	bool loopback;
 	u8 *smac;
+	int ret;
 
 	valid_num_sge = calc_wr_sge_num(wr, &msg_len);
 	memset(ud_sq_wqe, 0, sizeof(*ud_sq_wqe));
 
+	ret = set_ud_opcode(ud_sq_wqe, wr);
+	if (WARN_ON(ret))
+		return ret;
+
 	roce_set_field(ud_sq_wqe->dmac, V2_UD_SEND_WQE_DMAC_0_M,
 		       V2_UD_SEND_WQE_DMAC_0_S, ah->av.mac[0]);
 	roce_set_field(ud_sq_wqe->dmac, V2_UD_SEND_WQE_DMAC_1_M,
@@ -329,23 +362,8 @@ static inline int set_ud_wqe(struct hns_roce_qp *qp,
 	roce_set_bit(ud_sq_wqe->byte_40,
 		     V2_UD_SEND_WQE_BYTE_40_LBI_S, loopback);
 
-	roce_set_field(ud_sq_wqe->byte_4,
-		       V2_UD_SEND_WQE_BYTE_4_OPCODE_M,
-		       V2_UD_SEND_WQE_BYTE_4_OPCODE_S,
-		       HNS_ROCE_V2_WQE_OP_SEND);
-
 	ud_sq_wqe->msg_len = cpu_to_le32(msg_len);
 
-	switch (wr->opcode) {
-	case IB_WR_SEND_WITH_IMM:
-	case IB_WR_RDMA_WRITE_WITH_IMM:
-		ud_sq_wqe->immtdata = cpu_to_le32(be32_to_cpu(wr->ex.imm_data));
-		break;
-	default:
-		ud_sq_wqe->immtdata = 0;
-		break;
-	}
-
 	/* Set sig attr */
 	roce_set_bit(ud_sq_wqe->byte_4, V2_UD_SEND_WQE_BYTE_4_CQE_S,
 		     (wr->send_flags & IB_SEND_SIGNALED) ? 1 : 0);
@@ -402,34 +420,66 @@ static inline int set_ud_wqe(struct hns_roce_qp *qp,
 	return 0;
 }
 
+static int set_rc_opcode(struct hns_roce_v2_rc_send_wqe *rc_sq_wqe,
+			 const struct ib_send_wr *wr)
+{
+	u32 ib_op = wr->opcode;
+
+	rc_sq_wqe->immtdata = get_immtdata(wr);
+
+	switch (ib_op) {
+	case IB_WR_RDMA_READ:
+	case IB_WR_RDMA_WRITE:
+	case IB_WR_RDMA_WRITE_WITH_IMM:
+		rc_sq_wqe->rkey = cpu_to_le32(rdma_wr(wr)->rkey);
+		rc_sq_wqe->va = cpu_to_le64(rdma_wr(wr)->remote_addr);
+		break;
+	case IB_WR_SEND:
+	case IB_WR_SEND_WITH_IMM:
+		break;
+	case IB_WR_ATOMIC_CMP_AND_SWP:
+	case IB_WR_ATOMIC_FETCH_AND_ADD:
+		rc_sq_wqe->rkey = cpu_to_le32(atomic_wr(wr)->rkey);
+		rc_sq_wqe->va = cpu_to_le64(atomic_wr(wr)->remote_addr);
+		break;
+	case IB_WR_REG_MR:
+		set_frmr_seg(rc_sq_wqe, reg_wr(wr));
+		break;
+	case IB_WR_LOCAL_INV:
+		roce_set_bit(rc_sq_wqe->byte_4, V2_RC_SEND_WQE_BYTE_4_SO_S, 1);
+		fallthrough;
+	case IB_WR_SEND_WITH_INV:
+		rc_sq_wqe->inv_key = cpu_to_le32(wr->ex.invalidate_rkey);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	roce_set_field(rc_sq_wqe->byte_4, V2_RC_SEND_WQE_BYTE_4_OPCODE_M,
+		       V2_RC_SEND_WQE_BYTE_4_OPCODE_S, to_hr_opcode(ib_op));
+
+	return 0;
+}
 static inline int set_rc_wqe(struct hns_roce_qp *qp,
 			     const struct ib_send_wr *wr,
 			     void *wqe, unsigned int *sge_idx,
 			     unsigned int owner_bit)
 {
+	struct ib_device *ibdev = &to_hr_dev(qp->ibqp.device)->ib_dev;
 	struct hns_roce_v2_rc_send_wqe *rc_sq_wqe = wqe;
 	unsigned int curr_idx = *sge_idx;
 	unsigned int valid_num_sge;
 	u32 msg_len = 0;
-	int ret = 0;
+	int ret;
 
 	valid_num_sge = calc_wr_sge_num(wr, &msg_len);
 	memset(rc_sq_wqe, 0, sizeof(*rc_sq_wqe));
 
 	rc_sq_wqe->msg_len = cpu_to_le32(msg_len);
 
-	switch (wr->opcode) {
-	case IB_WR_SEND_WITH_IMM:
-	case IB_WR_RDMA_WRITE_WITH_IMM:
-		rc_sq_wqe->immtdata = cpu_to_le32(be32_to_cpu(wr->ex.imm_data));
-		break;
-	case IB_WR_SEND_WITH_INV:
-		rc_sq_wqe->inv_key = cpu_to_le32(wr->ex.invalidate_rkey);
-		break;
-	default:
-		rc_sq_wqe->immtdata = 0;
-		break;
-	}
+	ret = set_rc_opcode(rc_sq_wqe, wr);
+	if (WARN_ON(ret))
+		return ret;
 
 	roce_set_bit(rc_sq_wqe->byte_4, V2_RC_SEND_WQE_BYTE_4_FENCE_S,
 		     (wr->send_flags & IB_SEND_FENCE) ? 1 : 0);
@@ -443,33 +493,6 @@ static inline int set_rc_wqe(struct hns_roce_qp *qp,
 	roce_set_bit(rc_sq_wqe->byte_4, V2_RC_SEND_WQE_BYTE_4_OWNER_S,
 		     owner_bit);
 
-	switch (wr->opcode) {
-	case IB_WR_RDMA_READ:
-	case IB_WR_RDMA_WRITE:
-	case IB_WR_RDMA_WRITE_WITH_IMM:
-		rc_sq_wqe->rkey = cpu_to_le32(rdma_wr(wr)->rkey);
-		rc_sq_wqe->va = cpu_to_le64(rdma_wr(wr)->remote_addr);
-		break;
-	case IB_WR_LOCAL_INV:
-		roce_set_bit(rc_sq_wqe->byte_4, V2_RC_SEND_WQE_BYTE_4_SO_S, 1);
-		rc_sq_wqe->inv_key = cpu_to_le32(wr->ex.invalidate_rkey);
-		break;
-	case IB_WR_REG_MR:
-		set_frmr_seg(rc_sq_wqe, reg_wr(wr));
-		break;
-	case IB_WR_ATOMIC_CMP_AND_SWP:
-	case IB_WR_ATOMIC_FETCH_AND_ADD:
-		rc_sq_wqe->rkey = cpu_to_le32(atomic_wr(wr)->rkey);
-		rc_sq_wqe->va = cpu_to_le64(atomic_wr(wr)->remote_addr);
-		break;
-	default:
-		break;
-	}
-
-	roce_set_field(rc_sq_wqe->byte_4, V2_RC_SEND_WQE_BYTE_4_OPCODE_M,
-		       V2_RC_SEND_WQE_BYTE_4_OPCODE_S,
-		       to_hr_opcode(wr->opcode));
-
 	if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP ||
 	    wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD)
 		set_atomic_seg(wr, rc_sq_wqe, valid_num_sge);
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 for-next 2/8] RDMA/hns: Add interception for resizing SRQs
  2020-09-19 10:03 [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Weihang Li
  2020-09-19 10:03 ` [PATCH v3 for-next 1/8] RDMA/hns: Refactor process about opcode in post_send() Weihang Li
@ 2020-09-19 10:03 ` Weihang Li
  2020-09-19 10:03 ` [PATCH v3 for-next 3/8] RDMA/hns: Correct typo of hns_roce_create_cq() Weihang Li
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Weihang Li @ 2020-09-19 10:03 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

From: Yangyang Li <liyangyang20@huawei.com>

HIP08 doesn't support modifying the maximum number of outstanding WR in an
SRQ. However, the driver does not return a failure message, and users may
mistakenly think that the resizing is executed successfully. So the driver
needs to intercept this operation.

Fixes: ffb1308b88b6 ("RDMA/hns: Move SRQ code to the reasonable place")
Signed-off-by: Yangyang Li <liyangyang20@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 6a217f9..715e0b9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -5036,6 +5036,10 @@ static int hns_roce_v2_modify_srq(struct ib_srq *ibsrq,
 	struct hns_roce_cmd_mailbox *mailbox;
 	int ret;
 
+	/* Resizing SRQs is not supported yet */
+	if (srq_attr_mask & IB_SRQ_MAX_WR)
+		return -EINVAL;
+
 	if (srq_attr_mask & IB_SRQ_LIMIT) {
 		if (srq_attr->srq_limit >= srq->wqe_cnt)
 			return -EINVAL;
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 for-next 3/8] RDMA/hns: Correct typo of hns_roce_create_cq()
  2020-09-19 10:03 [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Weihang Li
  2020-09-19 10:03 ` [PATCH v3 for-next 1/8] RDMA/hns: Refactor process about opcode in post_send() Weihang Li
  2020-09-19 10:03 ` [PATCH v3 for-next 2/8] RDMA/hns: Add interception for resizing SRQs Weihang Li
@ 2020-09-19 10:03 ` Weihang Li
  2020-09-19 10:03 ` [PATCH v3 for-next 4/8] RDMA/hns: Add check for the validity of sl configuration Weihang Li
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Weihang Li @ 2020-09-19 10:03 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

From: Lang Cheng <chenglang@huawei.com>

Change "initialze" to "initialize".

Fixes: 8f3e9f3ea087 ("IB/hns: Add code for refreshing CQ CI using TPTR")
Signed-off-by: Lang Cheng <chenglang@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_cq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_cq.c b/drivers/infiniband/hw/hns/hns_roce_cq.c
index c5acf33..34f86d9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_cq.c
+++ b/drivers/infiniband/hw/hns/hns_roce_cq.c
@@ -287,7 +287,7 @@ int hns_roce_create_cq(struct ib_cq *ib_cq, const struct ib_cq_init_attr *attr,
 	/*
 	 * For the QP created by kernel space, tptr value should be initialized
 	 * to zero; For the QP created by user space, it will cause synchronous
-	 * problems if tptr is set to zero here, so we initialze it in user
+	 * problems if tptr is set to zero here, so we initialize it in user
 	 * space.
 	 */
 	if (!udata && hr_cq->tptr_addr)
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 for-next 4/8] RDMA/hns: Add check for the validity of sl configuration
  2020-09-19 10:03 [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Weihang Li
                   ` (2 preceding siblings ...)
  2020-09-19 10:03 ` [PATCH v3 for-next 3/8] RDMA/hns: Correct typo of hns_roce_create_cq() Weihang Li
@ 2020-09-19 10:03 ` Weihang Li
  2020-09-19 10:03 ` [PATCH v3 for-next 5/8] RDMA/hns: Solve the overflow of the calc_pg_sz() Weihang Li
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Weihang Li @ 2020-09-19 10:03 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

From: Jiaran Zhang <zhangjiaran@huawei.com>

According to the RoCE v1 specification, the sl (service level) 0-7 are
mapped directly to priorities 0-7 respectively, sl 8-15 are reserved. The
driver should verify whether the the value of sl is larger than 7, if so,
an exception should be returned.

Fixes: 926a01dc000d ("RDMA/hns: Add QP operations support for hip08 SoC")
Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 12 ++++++++++--
 drivers/infiniband/hw/hns/hns_roce_hw_v2.h |  2 ++
 2 files changed, 12 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 715e0b9..761d8c6 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -4291,11 +4291,19 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp,
 		       V2_QPC_BYTE_28_FL_S, 0);
 	memcpy(context->dgid, grh->dgid.raw, sizeof(grh->dgid.raw));
 	memset(qpc_mask->dgid, 0, sizeof(grh->dgid.raw));
+
+	hr_qp->sl = rdma_ah_get_sl(&attr->ah_attr);
+	if (unlikely(hr_qp->sl > MAX_SERVICE_LEVEL)) {
+		ibdev_err(ibdev,
+			  "failed to fill QPC, sl (%d) shouldn't be larger than %d.\n",
+			  hr_qp->sl, MAX_SERVICE_LEVEL);
+		return -EINVAL;
+	}
+
 	roce_set_field(context->byte_28_at_fl, V2_QPC_BYTE_28_SL_M,
-		       V2_QPC_BYTE_28_SL_S, rdma_ah_get_sl(&attr->ah_attr));
+		       V2_QPC_BYTE_28_SL_S, hr_qp->sl);
 	roce_set_field(qpc_mask->byte_28_at_fl, V2_QPC_BYTE_28_SL_M,
 		       V2_QPC_BYTE_28_SL_S, 0);
-	hr_qp->sl = rdma_ah_get_sl(&attr->ah_attr);
 
 	return 0;
 }
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
index ac29be4..17f35f9 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h
@@ -1941,6 +1941,8 @@ struct hns_roce_eq_context {
 #define HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_S 0
 #define HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_M GENMASK(23, 0)
 
+#define MAX_SERVICE_LEVEL 0x7
+
 struct hns_roce_wqe_atomic_seg {
 	__le64          fetchadd_swap_data;
 	__le64          cmp_data;
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 for-next 5/8] RDMA/hns: Solve the overflow of the calc_pg_sz()
  2020-09-19 10:03 [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Weihang Li
                   ` (3 preceding siblings ...)
  2020-09-19 10:03 ` [PATCH v3 for-next 4/8] RDMA/hns: Add check for the validity of sl configuration Weihang Li
@ 2020-09-19 10:03 ` Weihang Li
  2020-09-19 10:03 ` [PATCH v3 for-next 6/8] RDMA/hns: Fix the wrong value of rnr_retry when querying qp Weihang Li
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Weihang Li @ 2020-09-19 10:03 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

From: Jiaran Zhang <zhangjiaran@huawei.com>

calc_pg_sz() may gets a data calculation overflow if the PAGE_SIZE is 64 KB
and hop_num is 2. It is because that all variables involved in calculation
are defined in type of int. So change the type of bt_chunk_size,
buf_chunk_size and obj_per_chunk_default to u64.

Fixes: ba6bb7e97421 ("RDMA/hns: Add interfaces to get pf capabilities from firmware")
Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 761d8c6..1cc4abe 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -1793,9 +1793,9 @@ static void calc_pg_sz(int obj_num, int obj_size, int hop_num, int ctx_bt_num,
 		       int *buf_page_size, int *bt_page_size, u32 hem_type)
 {
 	u64 obj_per_chunk;
-	int bt_chunk_size = 1 << PAGE_SHIFT;
-	int buf_chunk_size = 1 << PAGE_SHIFT;
-	int obj_per_chunk_default = buf_chunk_size / obj_size;
+	u64 bt_chunk_size = PAGE_SIZE;
+	u64 buf_chunk_size = PAGE_SIZE;
+	u64 obj_per_chunk_default = buf_chunk_size / obj_size;
 
 	*buf_page_size = 0;
 	*bt_page_size = 0;
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 for-next 6/8] RDMA/hns: Fix the wrong value of rnr_retry when querying qp
  2020-09-19 10:03 [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Weihang Li
                   ` (4 preceding siblings ...)
  2020-09-19 10:03 ` [PATCH v3 for-next 5/8] RDMA/hns: Solve the overflow of the calc_pg_sz() Weihang Li
@ 2020-09-19 10:03 ` Weihang Li
  2020-09-19 10:03 ` [PATCH v3 for-next 7/8] RDMA/hns: Fix configuration of ack_req_freq in QPC Weihang Li
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Weihang Li @ 2020-09-19 10:03 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

From: Wenpeng Liang <liangwenpeng@huawei.com>

The rnr_retry returned to the user is not correct, it should be got from
another fields in QPC.

Fixes: bfe860351e31 ("RDMA/hns: Fix cast from or to restricted __le32 for driver")
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 +++-
 1 file changed, 3 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 1cc4abe..316cdb6 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -4799,7 +4799,9 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
 	qp_attr->retry_cnt = roce_get_field(context.byte_212_lsn,
 					    V2_QPC_BYTE_212_RETRY_CNT_M,
 					    V2_QPC_BYTE_212_RETRY_CNT_S);
-	qp_attr->rnr_retry = le32_to_cpu(context.rq_rnr_timer);
+	qp_attr->rnr_retry = roce_get_field(context.byte_244_rnr_rxack,
+					    V2_QPC_BYTE_244_RNR_CNT_M,
+					    V2_QPC_BYTE_244_RNR_CNT_S);
 
 done:
 	qp_attr->cur_qp_state = qp_attr->qp_state;
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 for-next 7/8] RDMA/hns: Fix configuration of ack_req_freq in QPC
  2020-09-19 10:03 [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Weihang Li
                   ` (5 preceding siblings ...)
  2020-09-19 10:03 ` [PATCH v3 for-next 6/8] RDMA/hns: Fix the wrong value of rnr_retry when querying qp Weihang Li
@ 2020-09-19 10:03 ` Weihang Li
  2020-09-19 10:03 ` [PATCH v3 for-next 8/8] RDMA/hns: Fix missing sq_sig_type when querying QP Weihang Li
  2020-09-24 19:00 ` [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Jason Gunthorpe
  8 siblings, 0 replies; 12+ messages in thread
From: Weihang Li @ 2020-09-19 10:03 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

The hardware will add AckReq flag in BTH header according to the value of
ack_req_freq to request ACK from responder for the packets with this flag.
It should be greater than or equal to lp_pktn_ini instead of using a fixed
value.

Fixes: 7b9bd73ed13d ("RDMA/hns: Fix wrong assignment of lp_pktn_ini in QPC")
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 316cdb6..f0101a7 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -3664,9 +3664,6 @@ static void modify_qp_reset_to_init(struct ib_qp *ibqp,
 			     V2_QPC_BYTE_76_SRQ_EN_S, 1);
 	}
 
-	roce_set_field(context->byte_172_sq_psn, V2_QPC_BYTE_172_ACK_REQ_FREQ_M,
-		       V2_QPC_BYTE_172_ACK_REQ_FREQ_S, 4);
-
 	roce_set_bit(context->byte_172_sq_psn, V2_QPC_BYTE_172_FRE_S, 1);
 
 	hr_qp->access_flags = attr->qp_access_flags;
@@ -3977,6 +3974,7 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
 	dma_addr_t trrl_ba;
 	dma_addr_t irrl_ba;
 	enum ib_mtu mtu;
+	u8 lp_pktn_ini;
 	u8 port_num;
 	u64 *mtts;
 	u8 *dmac;
@@ -4084,13 +4082,21 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp,
 	}
 
 #define MAX_LP_MSG_LEN 65536
-	/* MTU*(2^LP_PKTN_INI) shouldn't be bigger than 64kb */
+	/* MTU * (2 ^ LP_PKTN_INI) shouldn't be bigger than 64KB */
+	lp_pktn_ini = ilog2(MAX_LP_MSG_LEN / ib_mtu_enum_to_int(mtu));
+
 	roce_set_field(context->byte_56_dqpn_err, V2_QPC_BYTE_56_LP_PKTN_INI_M,
-		       V2_QPC_BYTE_56_LP_PKTN_INI_S,
-		       ilog2(MAX_LP_MSG_LEN / ib_mtu_enum_to_int(mtu)));
+		       V2_QPC_BYTE_56_LP_PKTN_INI_S, lp_pktn_ini);
 	roce_set_field(qpc_mask->byte_56_dqpn_err, V2_QPC_BYTE_56_LP_PKTN_INI_M,
 		       V2_QPC_BYTE_56_LP_PKTN_INI_S, 0);
 
+	/* ACK_REQ_FREQ should be larger than or equal to LP_PKTN_INI */
+	roce_set_field(context->byte_172_sq_psn, V2_QPC_BYTE_172_ACK_REQ_FREQ_M,
+		       V2_QPC_BYTE_172_ACK_REQ_FREQ_S, lp_pktn_ini);
+	roce_set_field(qpc_mask->byte_172_sq_psn,
+		       V2_QPC_BYTE_172_ACK_REQ_FREQ_M,
+		       V2_QPC_BYTE_172_ACK_REQ_FREQ_S, 0);
+
 	roce_set_bit(qpc_mask->byte_108_rx_reqepsn,
 		     V2_QPC_BYTE_108_RX_REQ_PSN_ERR_S, 0);
 	roce_set_field(qpc_mask->byte_96_rx_reqmsn, V2_QPC_BYTE_96_RX_REQ_MSN_M,
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3 for-next 8/8] RDMA/hns: Fix missing sq_sig_type when querying QP
  2020-09-19 10:03 [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Weihang Li
                   ` (6 preceding siblings ...)
  2020-09-19 10:03 ` [PATCH v3 for-next 7/8] RDMA/hns: Fix configuration of ack_req_freq in QPC Weihang Li
@ 2020-09-19 10:03 ` Weihang Li
  2020-09-24 19:00 ` [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Jason Gunthorpe
  8 siblings, 0 replies; 12+ messages in thread
From: Weihang Li @ 2020-09-19 10:03 UTC (permalink / raw)
  To: dledford, jgg; +Cc: leon, linux-rdma, linuxarm

The sq_sig_type field should be filled when querying QP, or the users may
get a wrong value.

Fixes: 926a01dc000d ("RDMA/hns: Add QP operations support for hip08 SoC")
Signed-off-by: Weihang Li <liweihang@huawei.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index f0101a7..99efe0e 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -4823,6 +4823,7 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
 	}
 
 	qp_init_attr->cap = qp_attr->cap;
+	qp_init_attr->sq_sig_type = hr_qp->sq_signal_bits;
 
 out:
 	mutex_unlock(&hr_qp->mutex);
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 for-next 1/8] RDMA/hns: Refactor process about opcode in post_send()
  2020-09-19 10:03 ` [PATCH v3 for-next 1/8] RDMA/hns: Refactor process about opcode in post_send() Weihang Li
@ 2020-09-24 18:59   ` Jason Gunthorpe
  2020-09-25  1:31     ` liweihang
  0 siblings, 1 reply; 12+ messages in thread
From: Jason Gunthorpe @ 2020-09-24 18:59 UTC (permalink / raw)
  To: Weihang Li; +Cc: dledford, leon, linux-rdma, linuxarm

On Sat, Sep 19, 2020 at 06:03:15PM +0800, Weihang Li wrote:
> According to the IB specifications, the verbs should return an immediate
> error when the users set an unsupported opcode. Furthermore, refactor codes
> about opcode in process of post_send to make the difference between opcodes
> clearer.
> 
> Signed-off-by: Weihang Li <liweihang@huawei.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 133 +++++++++++++++++------------
>  1 file changed, 78 insertions(+), 55 deletions(-)

This gives compile warnings:

drivers/infiniband/hw/hns/hns_roce_hw_v2.c: In function ‘set_ud_wqe’:
drivers/infiniband/hw/hns/hns_roce_hw_v2.c:330:20: warning: unused variable ‘ibdev’ [-Wunused-variable]
  330 |  struct ib_device *ibdev = &hr_dev->ib_dev;
      |                    ^~~~~
drivers/infiniband/hw/hns/hns_roce_hw_v2.c: In function ‘set_rc_wqe’:
drivers/infiniband/hw/hns/hns_roce_hw_v2.c:468:20: warning: unused variable ‘ibdev’ [-Wunused-variable]
  468 |  struct ib_device *ibdev = &to_hr_dev(qp->ibqp.device)->ib_dev;
      |                    ^~~~~

I deleted the unused variables

Jason

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates
  2020-09-19 10:03 [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Weihang Li
                   ` (7 preceding siblings ...)
  2020-09-19 10:03 ` [PATCH v3 for-next 8/8] RDMA/hns: Fix missing sq_sig_type when querying QP Weihang Li
@ 2020-09-24 19:00 ` Jason Gunthorpe
  8 siblings, 0 replies; 12+ messages in thread
From: Jason Gunthorpe @ 2020-09-24 19:00 UTC (permalink / raw)
  To: Weihang Li; +Cc: dledford, leon, linux-rdma, linuxarm

On Sat, Sep 19, 2020 at 06:03:14PM +0800, Weihang Li wrote:
> Here are some miscellaneous cleanups and fixes for the hns driver,
> including refactor, some newly added checks and so on.
> 
> Previous discussion:
> v2: https://patchwork.kernel.org/cover/11765125/
> v1: https://patchwork.kernel.org/cover/11761647/
> 
> Changes since v2:
> Fix some issuses according to Jason's comments.
> - Change 'unlikely' to 'WARN_ON' and remove prints when getting illegal
>   opcodes.
> - Drop patch #2 from v1 because the newly added check is meaningless for
>   sparse.
> - Add fixes tag for patch #3 ~ #5.
> - Change '1 << PAGE_SHIFT' to 'PAGE_SIZE' in patch #6.
> 
> Changes since v1:
> - Fix a missing assignment of owner_bit in set_rc_wqe()
> 
> Jiaran Zhang (2):
>   RDMA/hns: Add check for the validity of sl configuration
>   RDMA/hns: Solve the overflow of the calc_pg_sz()
> 
> Lang Cheng (1):
>   RDMA/hns: Correct typo of hns_roce_create_cq()
> 
> Weihang Li (3):
>   RDMA/hns: Refactor process about opcode in post_send()
>   RDMA/hns: Fix configuration of ack_req_freq in QPC
>   RDMA/hns: Fix missing sq_sig_type when querying QP
> 
> Wenpeng Liang (1):
>   RDMA/hns: Fix the wrong value of rnr_retry when querying qp
> 
> Yangyang Li (1):
>   RDMA/hns: Add interception for resizing SRQs

Applied to for-next, thanks

Jason

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 for-next 1/8] RDMA/hns: Refactor process about opcode in post_send()
  2020-09-24 18:59   ` Jason Gunthorpe
@ 2020-09-25  1:31     ` liweihang
  0 siblings, 0 replies; 12+ messages in thread
From: liweihang @ 2020-09-25  1:31 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: dledford, leon, linux-rdma, Linuxarm

On 2020/9/25 3:00, Jason Gunthorpe wrote:
> On Sat, Sep 19, 2020 at 06:03:15PM +0800, Weihang Li wrote:
>> According to the IB specifications, the verbs should return an immediate
>> error when the users set an unsupported opcode. Furthermore, refactor codes
>> about opcode in process of post_send to make the difference between opcodes
>> clearer.
>>
>> Signed-off-by: Weihang Li <liweihang@huawei.com>
>> ---
>>  drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 133 +++++++++++++++++------------
>>  1 file changed, 78 insertions(+), 55 deletions(-)
> 
> This gives compile warnings:
> 
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c: In function ‘set_ud_wqe’:
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c:330:20: warning: unused variable ‘ibdev’ [-Wunused-variable]
>   330 |  struct ib_device *ibdev = &hr_dev->ib_dev;
>       |                    ^~~~~
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c: In function ‘set_rc_wqe’:
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c:468:20: warning: unused variable ‘ibdev’ [-Wunused-variable]
>   468 |  struct ib_device *ibdev = &to_hr_dev(qp->ibqp.device)->ib_dev;
>       |                    ^~~~~
> 
> I deleted the unused variables
> 
> Jason
> 

I forgot to remove them when I replace the prints with WARN_ON(), thank you :)

Weihang

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-09-25  1:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-19 10:03 [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Weihang Li
2020-09-19 10:03 ` [PATCH v3 for-next 1/8] RDMA/hns: Refactor process about opcode in post_send() Weihang Li
2020-09-24 18:59   ` Jason Gunthorpe
2020-09-25  1:31     ` liweihang
2020-09-19 10:03 ` [PATCH v3 for-next 2/8] RDMA/hns: Add interception for resizing SRQs Weihang Li
2020-09-19 10:03 ` [PATCH v3 for-next 3/8] RDMA/hns: Correct typo of hns_roce_create_cq() Weihang Li
2020-09-19 10:03 ` [PATCH v3 for-next 4/8] RDMA/hns: Add check for the validity of sl configuration Weihang Li
2020-09-19 10:03 ` [PATCH v3 for-next 5/8] RDMA/hns: Solve the overflow of the calc_pg_sz() Weihang Li
2020-09-19 10:03 ` [PATCH v3 for-next 6/8] RDMA/hns: Fix the wrong value of rnr_retry when querying qp Weihang Li
2020-09-19 10:03 ` [PATCH v3 for-next 7/8] RDMA/hns: Fix configuration of ack_req_freq in QPC Weihang Li
2020-09-19 10:03 ` [PATCH v3 for-next 8/8] RDMA/hns: Fix missing sq_sig_type when querying QP Weihang Li
2020-09-24 19:00 ` [PATCH v3 for-next 0/8] RDMA/hns: Misc Updates Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).