From 7be6d311d4bbdb93d06abfc9888e9f805d2d6fdb Mon Sep 17 00:00:00 2001 From: Edward Srouji Date: Wed, 30 Dec 2020 17:03:34 +0200 Subject: [PATCH] tests: Check CQE compression cap before using it Add a CQE compression capability check in mlx5 CQ tests before creating a CQ. If the device does not support the requested CQE compression type, the test will be skipped. Fixes: 8aae7abe241c ("tests: Add mlx5 CQ tests") Signed-off-by: Edward Srouji Reviewed-by: Ido Kalir --- tests/test_mlx5_cq.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_mlx5_cq.py b/tests/test_mlx5_cq.py index 1f757c27345e..8be568c54262 100644 --- a/tests/test_mlx5_cq.py +++ b/tests/test_mlx5_cq.py @@ -2,7 +2,7 @@ import unittest import errno from pyverbs.providers.mlx5.mlx5dv import Mlx5Context, Mlx5DVContextAttr, \ - Mlx5DVCQInitAttr, Mlx5CQ, context_flags_to_str + Mlx5DVCQInitAttr, Mlx5CQ, context_flags_to_str, cqe_comp_to_str from pyverbs.pyverbs_error import PyverbsRDMAError, PyverbsUserError from tests.base import RDMATestCase, RCResources import pyverbs.providers.mlx5.mlx5_enums as dve @@ -22,6 +22,12 @@ def create_dv_cq(res): if res.cqe_comp_res_format: dvcq_init_attr.cqe_comp_res_format = res.cqe_comp_res_format dvcq_init_attr.comp_mask |= dve.MLX5DV_CQ_INIT_ATTR_MASK_COMPRESSED_CQE + # Check CQE compression capability + cqe_comp_caps = res.ctx.query_mlx5_device().cqe_comp_caps + if not (cqe_comp_caps['supported_format'] & res.cqe_comp_res_format) or \ + not cqe_comp_caps['max_num']: + cqe_comp_str = cqe_comp_to_str(res.cqe_comp_res_format) + raise unittest.SkipTest(f'CQE compression {cqe_comp_str} is not supported') if res.flags: dvcq_init_attr.flags = res.flags dvcq_init_attr.comp_mask |= dve.MLX5DV_CQ_INIT_ATTR_MASK_FLAGS -- 2.25.4