linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lijun Ou <oulijun@huawei.com>
To: <dledford@redhat.com>, <jgg@ziepe.ca>
Cc: <leon@kernel.org>, <linux-rdma@vger.kernel.org>, <linuxarm@huawei.com>
Subject: [PATCH V4 for-next 01/14] RDMA/hns: Encapsulate some lines for setting sq size in user mode
Date: Thu, 8 Aug 2019 22:53:41 +0800	[thread overview]
Message-ID: <1565276034-97329-2-git-send-email-oulijun@huawei.com> (raw)
In-Reply-To: <1565276034-97329-1-git-send-email-oulijun@huawei.com>

It needs to check the sq size with integrity when configures
the relatived parameters of sq. Here moves the relatived code
into a special function.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
V3->V4:
1. Remove replace operation for the origin dev print interface.

V1->V2:
1. Use the new print interface according to Gal Pressman because it
   can print the detail ib_device name
---
 drivers/infiniband/hw/hns/hns_roce_qp.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c
index 9c272c2..5fcc17e6 100644
--- a/drivers/infiniband/hw/hns/hns_roce_qp.c
+++ b/drivers/infiniband/hw/hns/hns_roce_qp.c
@@ -324,16 +324,12 @@ static int hns_roce_set_rq_size(struct hns_roce_dev *hr_dev,
 	return 0;
 }
 
-static int hns_roce_set_user_sq_size(struct hns_roce_dev *hr_dev,
-				     struct ib_qp_cap *cap,
-				     struct hns_roce_qp *hr_qp,
-				     struct hns_roce_ib_create_qp *ucmd)
+static int check_sq_size_with_integrity(struct hns_roce_dev *hr_dev,
+					struct ib_qp_cap *cap,
+					struct hns_roce_ib_create_qp *ucmd)
 {
 	u32 roundup_sq_stride = roundup_pow_of_two(hr_dev->caps.max_sq_desc_sz);
 	u8 max_sq_stride = ilog2(roundup_sq_stride);
-	u32 ex_sge_num;
-	u32 page_size;
-	u32 max_cnt;
 
 	/* Sanity check SQ size before proceeding */
 	if ((u32)(1 << ucmd->log_sq_bb_count) > hr_dev->caps.max_wqes ||
@@ -349,6 +345,25 @@ static int hns_roce_set_user_sq_size(struct hns_roce_dev *hr_dev,
 		return -EINVAL;
 	}
 
+	return 0;
+}
+
+static int hns_roce_set_user_sq_size(struct hns_roce_dev *hr_dev,
+				     struct ib_qp_cap *cap,
+				     struct hns_roce_qp *hr_qp,
+				     struct hns_roce_ib_create_qp *ucmd)
+{
+	u32 ex_sge_num;
+	u32 page_size;
+	u32 max_cnt;
+	int ret;
+
+	ret = check_sq_size_with_integrity(hr_dev, cap, ucmd);
+	if (ret) {
+		ibdev_err(&hr_dev->ib_dev, "Sanity check sq size failed\n");
+		return ret;
+	}
+
 	hr_qp->sq.wqe_cnt = 1 << ucmd->log_sq_bb_count;
 	hr_qp->sq.wqe_shift = ucmd->log_sq_stride;
 
-- 
1.9.1


  reply	other threads:[~2019-08-08 14:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-08 14:53 [PATCH V4 for-next 00/14] Updates for 5.3-rc2 Lijun Ou
2019-08-08 14:53 ` Lijun Ou [this message]
2019-08-08 14:53 ` [PATCH V4 for-next 02/14] RDMA/hns: Optimize hns_roce_modify_qp function Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 03/14] RDMA/hns: Update the prompt message for creating and destroy qp Lijun Ou
2019-08-12 14:47   ` Doug Ledford
2019-08-08 14:53 ` [PATCH V4 for-next 04/14] RDMA/hns: Remove unnessary init for cmq reg Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 05/14] RDMA/hns: Clean up unnecessary initial assignment Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 06/14] RDMA/hns: Update some comments style Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 07/14] RDMA/hns: Handling the error return value of hem function Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 08/14] RDMA/hns: Split bool statement and assign statement Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 09/14] RDMA/hns: Refactor irq request code Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 10/14] RDMA/hns: Remove unnecessary kzalloc Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 11/14] RDMA/hns: Refactor hns_roce_v2_set_hem for hip08 Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 12/14] RDMA/hns: Remove redundant print in hns_roce_v2_ceq_int() Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 13/14] RDMA/hns: Disable alw_lcl_lpbk of SSU Lijun Ou
2019-08-08 14:53 ` [PATCH V4 for-next 14/14] RDMA/hns: Use the new APIs for printing log Lijun Ou
2019-08-12 14:48   ` Doug Ledford
2019-08-13  9:13     ` oulijun
2019-08-13  9:31       ` oulijun
2019-08-13 13:33         ` Doug Ledford
2019-08-12 14:48 ` [PATCH V4 for-next 00/14] Updates for 5.3-rc2 Doug Ledford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1565276034-97329-2-git-send-email-oulijun@huawei.com \
    --to=oulijun@huawei.com \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).