Blame SOURCES/0001-tests-Check-CQE-compression-cap-before-using-it.patch

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