diff mbox series

[3/4] RDMA/siw: Set qp_state in siw_query_qp

Message ID 20231129032418.26705-4-guoqing.jiang@linux.dev (mailing list archive)
State Superseded
Headers show
Series Misc changes for siw | expand

Commit Message

Guoqing Jiang Nov. 29, 2023, 3:24 a.m. UTC
Run test_query_rc_qp against siw failed since siw didn't set qp_state
accordingly. To address it, introduce siw_qp_state_to_ib_qp_state
which convert SIW_QP_STATE_IDLE to IB_QPS_INIT which is similar as
in cxgb4.

rdma-core# ./build/bin/run_tests.py --dev siw0 tests.test_qp.QPTest.test_query_rc_qp -v
test_query_rc_qp (tests.test_qp.QPTest)
Queries an RC QP after creation. Verifies that its properties are as ... FAIL

======================================================================
FAIL: test_query_rc_qp (tests.test_qp.QPTest)
Queries an RC QP after creation. Verifies that its properties are as
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gjiang/rdma-core/tests/test_qp.py", line 284, in test_query_rc_qp
    self.query_qp_common_test(e.IBV_QPT_RC)
  File "/home/gjiang/rdma-core/tests/test_qp.py", line 265, in query_qp_common_test
    self.verify_qp_attrs(caps, e.IBV_QPS_INIT, qp_init_attr, qp_attr)
  File "/home/gjiang/rdma-core/tests/test_qp.py", line 239, in verify_qp_attrs
    self.assertEqual(state, attr.qp_state)
AssertionError: <ibv_qp_state.IBV_QPS_INIT: 1> != 0

----------------------------------------------------------------------
Ran 1 test in 0.057s

FAILED (failures=1)

Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
---
 drivers/infiniband/sw/siw/siw_verbs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Bernard Metzler Nov. 30, 2023, 6:09 p.m. UTC | #1
> -----Original Message-----
> From: Guoqing Jiang <guoqing.jiang@linux.dev>
> Sent: Wednesday, November 29, 2023 4:24 AM
> To: Bernard Metzler <BMT@zurich.ibm.com>; jgg@ziepe.ca; leon@kernel.org
> Cc: linux-rdma@vger.kernel.org; guoqing.jiang@linux.dev
> Subject: [EXTERNAL] [PATCH 3/4] RDMA/siw: Set qp_state in siw_query_qp
> 
> Run test_query_rc_qp against siw failed since siw didn't set qp_state
> accordingly. To address it, introduce siw_qp_state_to_ib_qp_state
> which convert SIW_QP_STATE_IDLE to IB_QPS_INIT which is similar as
> in cxgb4.
> 
> rdma-core# ./build/bin/run_tests.py --dev siw0
> tests.test_qp.QPTest.test_query_rc_qp -v
> test_query_rc_qp (tests.test_qp.QPTest)
> Queries an RC QP after creation. Verifies that its properties are as ...
> FAIL
> 
> ======================================================================
> FAIL: test_query_rc_qp (tests.test_qp.QPTest)
> Queries an RC QP after creation. Verifies that its properties are as
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/home/gjiang/rdma-core/tests/test_qp.py", line 284, in
> test_query_rc_qp
>     self.query_qp_common_test(e.IBV_QPT_RC)
>   File "/home/gjiang/rdma-core/tests/test_qp.py", line 265, in
> query_qp_common_test
>     self.verify_qp_attrs(caps, e.IBV_QPS_INIT, qp_init_attr, qp_attr)
>   File "/home/gjiang/rdma-core/tests/test_qp.py", line 239, in
> verify_qp_attrs
>     self.assertEqual(state, attr.qp_state)
> AssertionError: <ibv_qp_state.IBV_QPS_INIT: 1> != 0
> 
> ----------------------------------------------------------------------
> Ran 1 test in 0.057s
> 
> FAILED (failures=1)
> 
> Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>

Very nice finding! How could that remain undetected.
Probably no real application checks QP state 
Guoqing Jiang Dec. 1, 2023, 1:29 a.m. UTC | #2
Hi Bernard,

On 12/1/23 02:09, Bernard Metzler wrote:
>> -----Original Message-----
>> From: Guoqing Jiang <guoqing.jiang@linux.dev>
>> Sent: Wednesday, November 29, 2023 4:24 AM
>> To: Bernard Metzler <BMT@zurich.ibm.com>; jgg@ziepe.ca; leon@kernel.org
>> Cc: linux-rdma@vger.kernel.org; guoqing.jiang@linux.dev
>> Subject: [EXTERNAL] [PATCH 3/4] RDMA/siw: Set qp_state in siw_query_qp
>>
>> Run test_query_rc_qp against siw failed since siw didn't set qp_state
>> accordingly. To address it, introduce siw_qp_state_to_ib_qp_state
>> which convert SIW_QP_STATE_IDLE to IB_QPS_INIT which is similar as
>> in cxgb4.
>>
>> rdma-core# ./build/bin/run_tests.py --dev siw0
>> tests.test_qp.QPTest.test_query_rc_qp -v
>> test_query_rc_qp (tests.test_qp.QPTest)
>> Queries an RC QP after creation. Verifies that its properties are as ...
>> FAIL
>>
>> ======================================================================
>> FAIL: test_query_rc_qp (tests.test_qp.QPTest)
>> Queries an RC QP after creation. Verifies that its properties are as
>> ----------------------------------------------------------------------
>> Traceback (most recent call last):
>>    File "/home/gjiang/rdma-core/tests/test_qp.py", line 284, in
>> test_query_rc_qp
>>      self.query_qp_common_test(e.IBV_QPT_RC)
>>    File "/home/gjiang/rdma-core/tests/test_qp.py", line 265, in
>> query_qp_common_test
>>      self.verify_qp_attrs(caps, e.IBV_QPS_INIT, qp_init_attr, qp_attr)
>>    File "/home/gjiang/rdma-core/tests/test_qp.py", line 239, in
>> verify_qp_attrs
>>      self.assertEqual(state, attr.qp_state)
>> AssertionError: <ibv_qp_state.IBV_QPS_INIT: 1> != 0
>>
>> ----------------------------------------------------------------------
>> Ran 1 test in 0.057s
>>
>> FAILED (failures=1)
>>
>> Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
> Very nice finding! How could that remain undetected.
> Probably no real application checks QP state 
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
index dca6a155523d..233985434cfd 100644
--- a/drivers/infiniband/sw/siw/siw_verbs.c
+++ b/drivers/infiniband/sw/siw/siw_verbs.c
@@ -19,6 +19,15 @@ 
 #include "siw_verbs.h"
 #include "siw_mem.h"
 
+static int siw_qp_state_to_ib_qp_state[IB_QPS_ERR] = {
+	[SIW_QP_STATE_IDLE] = IB_QPS_INIT,
+	[SIW_QP_STATE_RTR] = IB_QPS_RTR,
+	[SIW_QP_STATE_RTS] = IB_QPS_RTS,
+	[SIW_QP_STATE_CLOSING] = IB_QPS_SQD,
+	[SIW_QP_STATE_TERMINATE] = IB_QPS_SQE,
+	[SIW_QP_STATE_ERROR] = IB_QPS_ERR
+};
+
 static int ib_qp_state_to_siw_qp_state[IB_QPS_ERR + 1] = {
 	[IB_QPS_RESET] = SIW_QP_STATE_IDLE,
 	[IB_QPS_INIT] = SIW_QP_STATE_IDLE,
@@ -504,6 +513,7 @@  int siw_query_qp(struct ib_qp *base_qp, struct ib_qp_attr *qp_attr,
 	} else {
 		return -EINVAL;
 	}
+	qp_attr->qp_state = siw_qp_state_to_ib_qp_state[qp->attrs.state];
 	qp_attr->cap.max_inline_data = SIW_MAX_INLINE;
 	qp_attr->cap.max_send_wr = qp->attrs.sq_size;
 	qp_attr->cap.max_send_sge = qp->attrs.sq_max_sges;