From 8ac2197f74c355973eeafd918e55becd6d3bd9b5 Mon Sep 17 00:00:00 2001 From: Mohammad Heib Date: Wed, 30 Oct 2024 11:01:59 -0400 Subject: [PATCH 1/2] tests: resize cq handle provider output properly bnxt_re driver implement the CQ shrinking operation in a way that allows users to shrink CQ with a size smaller than the existing CQE and still have access to old CQEs please see: - https://github.com/linux-rdma/rdma-core/pull/1315 The test_resize_cq assumes that when shrinking an active CQ with unpolled entries it fail with an EINVAL error, which is not true for bnxt_re devices. To avoid this failure for bnxt/irdma update the test to check for compilation if no error was returned from th Signed-off-by: Mohammad Heib --- tests/test_cq.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_cq.py b/tests/test_cq.py index 98485e3f8..732d5a143 100644 --- a/tests/test_cq.py +++ b/tests/test_cq.py @@ -112,20 +112,24 @@ def test_resize_cq(self): # Increase the CQ size. new_cq_size = 7 + post_send_num = new_cq_size - 1 self.client.cq.resize(new_cq_size) self.assertTrue(self.client.cq.cqe >= new_cq_size, f'The actual CQ size ({self.client.cq.cqe}) is less ' 'than guaranteed ({new_cq_size})') - irdma.skip_if_irdma_dev(d.Context(name=self.dev_name)) # Fill the CQ entries except one for avoid cq_overrun warnings. send_wr, _ = u.get_send_elements(self.client, False) ah_client = u.get_global_ah(self.client, self.gid_index, self.ib_port) - for i in range(self.client.cq.cqe - 1): + for i in range(post_send_num): u.send(self.client, send_wr, ah=ah_client) # Decrease the CQ size to less than the CQ unpolled entries. new_cq_size = 1 - with self.assertRaises(PyverbsRDMAError) as ex: + try: self.client.cq.resize(new_cq_size) - self.assertEqual(ex.exception.error_code, errno.EINVAL) + except PyverbsRDMAError as ex: + self.assertEqual(ex.error_code, errno.EINVAL) + finally: + for i in range(post_send_num): + u.poll_cq(self.client.cq) From 906b2106bc7974d499fa67ee90bfd49e960fd4b3 Mon Sep 17 00:00:00 2001 From: Mohammad Heib Date: Thu, 31 Oct 2024 05:59:04 -0400 Subject: [PATCH 2/2] bnxt_re: set errno to 'EINVAL' in cq creation bad flow Currently when the user creates a CQ with CQEs greater than the device max_depth bnxt_re lib will catch this error flow and return immediately without creating a CQ, some test cases expect to have EINVAL in errno which is not set by bnxt. This patch updates the bnxt_re lib to set the errno to EINVAL in case of bad cq creation flow. Signed-off-by: Mohammad Heib --- providers/bnxt_re/verbs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/providers/bnxt_re/verbs.c b/providers/bnxt_re/verbs.c index e35f665b3..18e6893d5 100644 --- a/providers/bnxt_re/verbs.c +++ b/providers/bnxt_re/verbs.c @@ -328,8 +328,10 @@ struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe, struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx); struct bnxt_re_dev *dev = to_bnxt_re_dev(ibvctx->device); - if (ncqe > dev->max_cq_depth) + if (ncqe > dev->max_cq_depth) { + errno = EINVAL; return NULL; + } cq = calloc(1, (sizeof(*cq) + sizeof(struct bnxt_re_queue))); if (!cq)