| 1 |
# SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) |
| 2 |
# Copyright (c) 2021 NVIDIA Corporation . All rights reserved. See COPYING file |
| 3 |
|
| 4 |
""" |
| 5 |
Test module for Mlx5 DV query port. |
| 6 |
""" |
| 7 |
|
| 8 |
import unittest |
| 9 |
import errno |
| 10 |
|
| 11 |
from pyverbs.pyverbs_error import PyverbsRDMAError |
| 12 |
from pyverbs.providers.mlx5.mlx5dv import Mlx5Context |
| 13 |
from tests.mlx5_base import Mlx5PyverbsAPITestCase |
| 14 |
from pyverbs.providers.mlx5.mlx5_enums import MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_RX_, \ |
| 15 |
MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_TX_, MLX5DV_QUERY_PORT_VPORT_REG_C0_ |
| 16 |
|
| 17 |
|
| 18 |
class Mlx5DVQueryPortTestCase(Mlx5PyverbsAPITestCase): |
| 19 |
def test_dv_query_port(self): |
| 20 |
""" |
| 21 |
Test the DV query port and that no error is returned. |
| 22 |
""" |
| 23 |
for port in range (1, self.attr_ex.phys_port_cnt_ex + 1): |
| 24 |
try: |
| 25 |
port_attr = Mlx5Context.query_mlx5_port(self.ctx, port) |
| 26 |
except PyverbsRDMAError as ex: |
| 27 |
if ex.error_code in [errno.EOPNOTSUPP, errno.EPROTONOSUPPORT]: |
| 28 |
raise unittest.SkipTest(f'mlx5dv_query_port() isn\'t supported') |
| 29 |
raise ex |
| 30 |
|
| 31 |
if (port_attr.flags & MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_RX_): |
| 32 |
self.assertNotEqual(port_attr.vport_steering_icm_rx, 0, |
| 33 |
f'Vport steering icm rx address is zero') |
| 34 |
|
| 35 |
if (port_attr.flags & MLX5DV_QUERY_PORT_VPORT_STEERING_ICM_TX_): |
| 36 |
self.assertNotEqual(port_attr.vport_steering_icm_tx, 0, |
| 37 |
f'Vport steering icm tx address is zero') |
| 38 |
|
| 39 |
if (port_attr.flags & MLX5DV_QUERY_PORT_VPORT_REG_C0_): |
| 40 |
self.assertNotEqual(port_attr.reg_c0_mask, 0, |
| 41 |
f'Vport reg c0 mask is zero') |