Skip to contentSkip to conversation

RDMA/hns: Support to set mininum depth of qp to 0

PATCH Superseded Weihang Li 3 participants 5 messages Mar 2, 2020 – Mar 11, 2020

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Weihang Li

author
#0 lore raw

PATCH 1/1 RDMA/hns: Support to set mininum depth of qp to 0

From: Lang Cheng <[email protected]>

Minimum depth of qp should be allowed to be set to 0 according to the firmware configuration. And when qp is changed from reset to reset, the capability of minimum qp depth was used to identify hardware of hip06, it should be changed into a more readable form.

---
 drivers/infiniband/hw/hns/hns_roce_qp.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +6 -7
index 2a75355..10c4354 100644
@@ -382,10 +382,10 @@ static int set_rq_size(struct hns_roce_dev *hr_dev,
 			return -EINVAL;
 		}
 
-		if (hr_dev->caps.min_wqes)
+		if (cap->max_recv_wr)
 			max_cnt = max(cap->max_recv_wr, hr_dev->caps.min_wqes);
 		else
-			max_cnt = cap->max_recv_wr;
+			max_cnt = 0;
 
 		hr_qp->rq.wqe_cnt = roundup_pow_of_two(max_cnt);
 
@@ -652,10 +652,10 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,
 
 	hr_qp->sq.wqe_shift = ilog2(hr_dev->caps.max_sq_desc_sz);
 
-	if (hr_dev->caps.min_wqes)
+	if (cap->max_send_wr)
 		max_cnt = max(cap->max_send_wr, hr_dev->caps.min_wqes);
 	else
-		max_cnt = cap->max_send_wr;
+		max_cnt = 0;
 
 	hr_qp->sq.wqe_cnt = roundup_pow_of_two(max_cnt);
 	if ((u32)hr_qp->sq.wqe_cnt > hr_dev->caps.max_wqes) {
@@ -1394,11 +1394,10 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 		goto out;
 
 	if (cur_state == new_state && cur_state == IB_QPS_RESET) {
-		if (hr_dev->caps.min_wqes) {
+		if (hr_dev->hw_rev == HNS_ROCE_HW_VER1) {
 			ret = -EPERM;
 			ibdev_err(&hr_dev->ib_dev,
-				"cur_state=%d new_state=%d\n", cur_state,
-				new_state);
+				  "Unsupport to modify qp from reset to reset\n");
 		} else {
 			ret = 0;
 		}
Signature · 1 line
2.8.1
#1 lore raw
Quoted 6 lines · Weihang Li

From: Lang Cheng <[email protected]>

Minimum depth of qp should be allowed to be set to 0 according to the firmware configuration. And when qp is changed from reset to reset, the capability of minimum qp depth was used to identify hardware of hip06, it should be changed into a more readable form.

And what does it mean "qp depth == 0"?

Quoted 12 lines
---
 drivers/infiniband/hw/hns/hns_roce_qp.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
index 2a75355..10c4354 100644

drivers/infiniband/hw/hns/hns_roce_qp.c static int set_rq_size(struct hns_roce_dev *hr_dev, · line 388

Quoted 9 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -2
@@ -382,10 +382,10 @@ static int set_rq_size(struct hns_roce_dev *hr_dev,
 			return -EINVAL;
 		}
 
-		if (hr_dev->caps.min_wqes)
+		if (cap->max_recv_wr)
 			max_cnt = max(cap->max_recv_wr, hr_dev->caps.min_wqes);
 		else
-			max_cnt = cap->max_recv_wr;
+			max_cnt = 0;

It is basically the same thing: cap->max_recv_wr == 0.

drivers/infiniband/hw/hns/hns_roce_qp.c static int set_kernel_sq_size(struct hns_roce_dev *hr_dev, · line 658

Quoted 13 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -2
 		hr_qp->rq.wqe_cnt = roundup_pow_of_two(max_cnt);
 
@@ -652,10 +652,10 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,
 
 	hr_qp->sq.wqe_shift = ilog2(hr_dev->caps.max_sq_desc_sz);
 
-	if (hr_dev->caps.min_wqes)
+	if (cap->max_send_wr)
 		max_cnt = max(cap->max_send_wr, hr_dev->caps.min_wqes);
 	else
-		max_cnt = cap->max_send_wr;
+		max_cnt = 0;

Ditto

Quoted 4 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
 	hr_qp->sq.wqe_cnt = roundup_pow_of_two(max_cnt);
 	if ((u32)hr_qp->sq.wqe_cnt > hr_dev->caps.max_wqes) {

drivers/infiniband/hw/hns/hns_roce_qp.c int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, · line 1400

Quoted 10 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -3
@@ -1394,11 +1394,10 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 		goto out;
 
 	if (cur_state == new_state && cur_state == IB_QPS_RESET) {
-		if (hr_dev->caps.min_wqes) {
+		if (hr_dev->hw_rev == HNS_ROCE_HW_VER1) {
 			ret = -EPERM;
 			ibdev_err(&hr_dev->ib_dev,
-				"cur_state=%d new_state=%d\n", cur_state,
-				new_state);
+				  "Unsupport to modify qp from reset to reset\n");

"RST2RST state is not supported\n"

Quoted 6 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -1
 		} else {
 			ret = 0;
 		}
--

2.8.1

#2 lore raw
Quoted 10 lines · Leon Romanovsky
Quoted 6 lines · Weihang Li

From: Lang Cheng <[email protected]>

Minimum depth of qp should be allowed to be set to 0 according to the firmware configuration. And when qp is changed from reset to reset, the capability of minimum qp depth was used to identify hardware of hip06, it should be changed into a more readable form.

And what does it mean "qp depth == 0"?

Here are 2 related test cases can be executed successfully:
1,Just create qp with 0-depth sq and 0-depth rq, but do not perform sending and receiving.
2. Create a qp with 0-depth rq, the send operation can be completed.

Perhaps supporting 0-depth qp would provide some flexibility for some features.

Or should we return error when ULP try to create a 0-depth queue?

Quoted 16 lines
Quoted 16 lines
---
  drivers/infiniband/hw/hns/hns_roce_qp.c | 13 ++++++-------
  1 file changed, 6 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
index 2a75355..10c4354 100644
@@ -382,10 +382,10 @@ static int set_rq_size(struct hns_roce_dev *hr_dev,
  			return -EINVAL;
  		}
 
Quoted 8 lines

drivers/infiniband/hw/hns/hns_roce_qp.c static int set_rq_size(struct hns_roce_dev *hr_dev, · line 388

Quoted 6 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -2
-		if (hr_dev->caps.min_wqes)
+		if (cap->max_recv_wr)
  			max_cnt = max(cap->max_recv_wr, hr_dev->caps.min_wqes);
  		else
-			max_cnt = cap->max_recv_wr;
+			max_cnt = 0;

It is basically the same thing: cap->max_recv_wr == 0.

The current firmware has not specified the minimum depth of qp, resulting in hr_dev-> caps.min_wqes always being 0, the process will always go into the else branch, so there is no minimum depth check for qp.

The firmware will support configuring the minimum depth of qp, so this patch checks all the use of this caps.

Quoted 23 lines
Quoted 5 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
  		hr_qp->rq.wqe_cnt = roundup_pow_of_two(max_cnt);
 

drivers/infiniband/hw/hns/hns_roce_qp.c static int set_kernel_sq_size(struct hns_roce_dev *hr_dev, · line 658

Quoted 9 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -2
@@ -652,10 +652,10 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,
 
  	hr_qp->sq.wqe_shift = ilog2(hr_dev->caps.max_sq_desc_sz);
 
-	if (hr_dev->caps.min_wqes)
+	if (cap->max_send_wr)
  		max_cnt = max(cap->max_send_wr, hr_dev->caps.min_wqes);
  	else
-		max_cnt = cap->max_send_wr;
+		max_cnt = 0;

Ditto

Quoted 6 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
  	hr_qp->sq.wqe_cnt = roundup_pow_of_two(max_cnt);
  	if ((u32)hr_qp->sq.wqe_cnt > hr_dev->caps.max_wqes) {
@@ -1394,11 +1394,10 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
  		goto out;
 
Quoted 10 lines

drivers/infiniband/hw/hns/hns_roce_qp.c int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, · line 1400

Quoted 8 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -3
  	if (cur_state == new_state && cur_state == IB_QPS_RESET) {
-		if (hr_dev->caps.min_wqes) {
+		if (hr_dev->hw_rev == HNS_ROCE_HW_VER1) {
  			ret = -EPERM;
  			ibdev_err(&hr_dev->ib_dev,
-				"cur_state=%d new_state=%d\n", cur_state,
-				new_state);
+				  "Unsupport to modify qp from reset to reset\n");

"RST2RST state is not supported\n"

Will be modified in next, thanks.

Quoted 10 lines
Quoted 7 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -1
  		} else {
  			ret = 0;
  		}
--

2.8.1

.

#3 lore raw
Quoted 20 lines · Lang Cheng
Quoted 10 lines · Leon Romanovsky
Quoted 6 lines · Weihang Li

From: Lang Cheng <[email protected]>

Minimum depth of qp should be allowed to be set to 0 according to the firmware configuration. And when qp is changed from reset to reset, the capability of minimum qp depth was used to identify hardware of hip06, it should be changed into a more readable form.

And what does it mean "qp depth == 0"?

Here are 2 related test cases can be executed successfully:
1,Just create qp with 0-depth sq and 0-depth rq, but do not perform sending and receiving.
2. Create a qp with 0-depth rq, the send operation can be completed.

Quoted 4 lines

Perhaps supporting 0-depth qp would provide some flexibility for some features.

Or should we return error when ULP try to create a 0-depth queue?

"0" looks like not valid value and you can't explain what will be expected behavior if user sets such value, so returning an error sounds like a good solution.

Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
---
  drivers/infiniband/hw/hns/hns_roce_qp.c | 13 ++++++-------
  1 file changed, 6 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
index 2a75355..10c4354 100644
@@ -382,10 +382,10 @@ static int set_rq_size(struct hns_roce_dev *hr_dev,
  			return -EINVAL;
  		}
 
Quoted 8 lines

drivers/infiniband/hw/hns/hns_roce_qp.c static int set_rq_size(struct hns_roce_dev *hr_dev, · line 388

Quoted 6 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -2
-		if (hr_dev->caps.min_wqes)
+		if (cap->max_recv_wr)
  			max_cnt = max(cap->max_recv_wr, hr_dev->caps.min_wqes);
  		else
-			max_cnt = cap->max_recv_wr;
+			max_cnt = 0;

It is basically the same thing: cap->max_recv_wr == 0.

Quoted 6 lines

The current firmware has not specified the minimum depth of qp, resulting in hr_dev-> caps.min_wqes always being 0, the process will always go into the else branch, so there is no minimum depth check for qp.

The firmware will support configuring the minimum depth of qp, so this patch checks all the use of this caps.

if (cap->max_recv_wr)
cap->max_recv_wr != 0
else
cap->max_recv_wr == 0
=> max_cnt = 0 and max_cnt = cap->max_recv_wr are the same

Thanks

Quoted 49 lines
Quoted 24 lines
Quoted 6 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
  		hr_qp->rq.wqe_cnt = roundup_pow_of_two(max_cnt);
 

drivers/infiniband/hw/hns/hns_roce_qp.c static int set_kernel_sq_size(struct hns_roce_dev *hr_dev, · line 658

Quoted 9 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -2
@@ -652,10 +652,10 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,
 
  	hr_qp->sq.wqe_shift = ilog2(hr_dev->caps.max_sq_desc_sz);
 
-	if (hr_dev->caps.min_wqes)
+	if (cap->max_send_wr)
  		max_cnt = max(cap->max_send_wr, hr_dev->caps.min_wqes);
  	else
-		max_cnt = cap->max_send_wr;
+		max_cnt = 0;

Ditto

Quoted 6 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
  	hr_qp->sq.wqe_cnt = roundup_pow_of_two(max_cnt);
  	if ((u32)hr_qp->sq.wqe_cnt > hr_dev->caps.max_wqes) {
@@ -1394,11 +1394,10 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
  		goto out;
 
Quoted 10 lines

drivers/infiniband/hw/hns/hns_roce_qp.c int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, · line 1400

Quoted 8 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -3
  	if (cur_state == new_state && cur_state == IB_QPS_RESET) {
-		if (hr_dev->caps.min_wqes) {
+		if (hr_dev->hw_rev == HNS_ROCE_HW_VER1) {
  			ret = -EPERM;
  			ibdev_err(&hr_dev->ib_dev,
-				"cur_state=%d new_state=%d\n", cur_state,
-				new_state);
+				  "Unsupport to modify qp from reset to reset\n");

"RST2RST state is not supported\n"

Will be modified in next, thanks.

Quoted 10 lines
Quoted 7 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -1
  		} else {
  			ret = 0;
  		}
--

2.8.1

.

#4 lore raw
Quoted 21 lines · Leon Romanovsky
Quoted 20 lines · Lang Cheng
Quoted 10 lines · Leon Romanovsky
Quoted 6 lines · Weihang Li

From: Lang Cheng <[email protected]>

Minimum depth of qp should be allowed to be set to 0 according to the firmware configuration. And when qp is changed from reset to reset, the capability of minimum qp depth was used to identify hardware of hip06, it should be changed into a more readable form.

And what does it mean "qp depth == 0"?

Here are 2 related test cases can be executed successfully:
1,Just create qp with 0-depth sq and 0-depth rq, but do not perform sending and receiving.
2. Create a qp with 0-depth rq, the send operation can be completed.

Quoted 9 lines
Quoted 4 lines

Perhaps supporting 0-depth qp would provide some flexibility for some features.

Or should we return error when ULP try to create a 0-depth queue?

"0" looks like not valid value and you can't explain what will be expected behavior if user sets such value, so returning an error sounds like a good solution.

Check depth 0 in next.

Thanks.

Quoted 94 lines
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
---
   drivers/infiniband/hw/hns/hns_roce_qp.c | 13 ++++++-------
   1 file changed, 6 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
index 2a75355..10c4354 100644
@@ -382,10 +382,10 @@ static int set_rq_size(struct hns_roce_dev *hr_dev,
   			return -EINVAL;
   		}
 
Quoted 8 lines

drivers/infiniband/hw/hns/hns_roce_qp.c static int set_rq_size(struct hns_roce_dev *hr_dev, · line 388

Quoted 6 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -2
-		if (hr_dev->caps.min_wqes)
+		if (cap->max_recv_wr)
   			max_cnt = max(cap->max_recv_wr, hr_dev->caps.min_wqes);
   		else
-			max_cnt = cap->max_recv_wr;
+			max_cnt = 0;

It is basically the same thing: cap->max_recv_wr == 0.

Quoted 6 lines

The current firmware has not specified the minimum depth of qp, resulting in hr_dev-> caps.min_wqes always being 0, the process will always go into the else branch, so there is no minimum depth check for qp.

The firmware will support configuring the minimum depth of qp, so this patch checks all the use of this caps.

if (cap->max_recv_wr)
cap->max_recv_wr != 0
else
cap->max_recv_wr == 0
=> max_cnt = 0 and max_cnt = cap->max_recv_wr are the same

Thanks

Quoted 35 lines
Quoted 24 lines
Quoted 6 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
   		hr_qp->rq.wqe_cnt = roundup_pow_of_two(max_cnt);
 

drivers/infiniband/hw/hns/hns_roce_qp.c static int set_kernel_sq_size(struct hns_roce_dev *hr_dev, · line 658

Quoted 9 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -2
@@ -652,10 +652,10 @@ static int set_kernel_sq_size(struct hns_roce_dev *hr_dev,
 
   	hr_qp->sq.wqe_shift = ilog2(hr_dev->caps.max_sq_desc_sz);
 
-	if (hr_dev->caps.min_wqes)
+	if (cap->max_send_wr)
   		max_cnt = max(cap->max_send_wr, hr_dev->caps.min_wqes);
   	else
-		max_cnt = cap->max_send_wr;
+		max_cnt = 0;

Ditto

Quoted 6 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -0
   	hr_qp->sq.wqe_cnt = roundup_pow_of_two(max_cnt);
   	if ((u32)hr_qp->sq.wqe_cnt > hr_dev->caps.max_wqes) {
@@ -1394,11 +1394,10 @@ int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
   		goto out;
 
Quoted 10 lines

drivers/infiniband/hw/hns/hns_roce_qp.c int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, · line 1400

Quoted 8 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +2 -3
   	if (cur_state == new_state && cur_state == IB_QPS_RESET) {
-		if (hr_dev->caps.min_wqes) {
+		if (hr_dev->hw_rev == HNS_ROCE_HW_VER1) {
   			ret = -EPERM;
   			ibdev_err(&hr_dev->ib_dev,
-				"cur_state=%d new_state=%d\n", cur_state,
-				new_state);
+				  "Unsupport to modify qp from reset to reset\n");

"RST2RST state is not supported\n"

Quoted 14 lines

Will be modified in next, thanks.

Quoted 10 lines
Quoted 7 lines
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -1
   		} else {
   			ret = 0;
   		}
--

2.8.1

.

.