| 1 |
import unittest |
| 2 |
import errno |
| 3 |
|
| 4 |
from pyverbs.providers.mlx5.mlx5dv_sched import Mlx5dvSchedAttr, \ |
| 5 |
Mlx5dvSchedNode, Mlx5dvSchedLeaf |
| 6 |
from tests.mlx5_base import Mlx5RDMATestCase, Mlx5PyverbsAPITestCase |
| 7 |
from pyverbs.pyverbs_error import PyverbsRDMAError |
| 8 |
from pyverbs.providers.mlx5.mlx5dv import Mlx5QP |
| 9 |
from pyverbs.providers.mlx5.mlx5_enums import mlx5dv_sched_elem_attr_flags |
| 10 |
from tests.base import RCResources |
| 11 |
import tests.utils as u |
| 12 |
|
| 13 |
|
| 14 |
class Mlx5SchedTest(Mlx5PyverbsAPITestCase): |
| 15 |
def test_create_sched_tree(self): |
| 16 |
""" |
| 17 |
Create schedule elements tree. Test the schedule elements API, this |
| 18 |
includes creating schedule nodes with different flags and connecting |
| 19 |
them with schedule leaves. In addition, modify some nodes with |
| 20 |
different BW share and max BW. |
| 21 |
""" |
| 22 |
try: |
| 23 |
root_node = Mlx5dvSchedNode(self.ctx, Mlx5dvSchedAttr()) |
| 24 |
# Create a node with only max_avg_bw argument. |
| 25 |
max_sched_attr = Mlx5dvSchedAttr(root_node, max_avg_bw=10, |
| 26 |
flags=mlx5dv_sched_elem_attr_flags.MLX5DV_SCHED_ELEM_ATTR_FLAGS_MAX_AVG_BW) |
| 27 |
max_bw_node = Mlx5dvSchedNode(self.ctx, max_sched_attr) |
| 28 |
|
| 29 |
# Create a node with only bw_share argument. |
| 30 |
weighed_sched_attr = Mlx5dvSchedAttr(root_node, bw_share=10, |
| 31 |
flags=mlx5dv_sched_elem_attr_flags.MLX5DV_SCHED_ELEM_ATTR_FLAGS_BW_SHARE) |
| 32 |
max_bw_node = Mlx5dvSchedNode(self.ctx, weighed_sched_attr) |
| 33 |
|
| 34 |
# Create a node with max_avg_bw and bw_share arguments. |
| 35 |
mixed_flags = mlx5dv_sched_elem_attr_flags.MLX5DV_SCHED_ELEM_ATTR_FLAGS_MAX_AVG_BW | \ |
| 36 |
mlx5dv_sched_elem_attr_flags.MLX5DV_SCHED_ELEM_ATTR_FLAGS_BW_SHARE |
| 37 |
mixed_sched_attr = Mlx5dvSchedAttr(root_node, max_avg_bw=10, bw_share=2, |
| 38 |
flags=mixed_flags) |
| 39 |
mixed_bw_node = Mlx5dvSchedNode(self.ctx, mixed_sched_attr) |
| 40 |
|
| 41 |
# Modify a node. |
| 42 |
modify_sched_attr = Mlx5dvSchedAttr(root_node, max_avg_bw=4, bw_share=1, |
| 43 |
flags=mixed_flags) |
| 44 |
mixed_bw_node.modify(modify_sched_attr) |
| 45 |
|
| 46 |
# Attach sched leaf to mixed_bw_node |
| 47 |
max_sched_attr = Mlx5dvSchedAttr(mixed_bw_node) |
| 48 |
sched_leaf = Mlx5dvSchedLeaf(self.ctx, max_sched_attr) |
| 49 |
|
| 50 |
# Modify a leaf. |
| 51 |
modify_sched_attr = Mlx5dvSchedAttr(mixed_bw_node, max_avg_bw=3, bw_share=3, |
| 52 |
flags=mixed_flags) |
| 53 |
sched_leaf.modify(modify_sched_attr) |
| 54 |
except PyverbsRDMAError as ex: |
| 55 |
if ex.error_code == errno.EOPNOTSUPP: |
| 56 |
raise unittest.SkipTest('Create schedule elements is not supported') |
| 57 |
raise ex |
| 58 |
|
| 59 |
|
| 60 |
class Mlx5SchedTrafficTest(Mlx5RDMATestCase): |
| 61 |
def setUp(self): |
| 62 |
super().setUp() |
| 63 |
self.iters = 10 |
| 64 |
self.server = None |
| 65 |
self.client = None |
| 66 |
self.traffic_args = None |
| 67 |
|
| 68 |
def test_sched_per_qp_traffic(self): |
| 69 |
""" |
| 70 |
Tests attaching a QP to a sched leaf. The test creates a sched tree |
| 71 |
consisting of a root node and a leaf with max BW and share BW, modifies |
| 72 |
two RC QPs to be attached to the sched leaf and then run traffic using |
| 73 |
those QPs. |
| 74 |
""" |
| 75 |
self.create_players(RCResources) |
| 76 |
try: |
| 77 |
root_node = Mlx5dvSchedNode(self.server.ctx, Mlx5dvSchedAttr()) |
| 78 |
mixed_flags = mlx5dv_sched_elem_attr_flags.MLX5DV_SCHED_ELEM_ATTR_FLAGS_MAX_AVG_BW | \ |
| 79 |
mlx5dv_sched_elem_attr_flags.MLX5DV_SCHED_ELEM_ATTR_FLAGS_BW_SHARE |
| 80 |
mixed_sched_attr = Mlx5dvSchedAttr(root_node, max_avg_bw=10, |
| 81 |
bw_share=2, flags=mixed_flags) |
| 82 |
leaf = Mlx5dvSchedLeaf(self.server.ctx, mixed_sched_attr) |
| 83 |
Mlx5QP.modify_qp_sched_elem(self.server.qp, req_sched_leaf=leaf, |
| 84 |
resp_sched_leaf=leaf) |
| 85 |
except PyverbsRDMAError as ex: |
| 86 |
if ex.error_code == errno.EOPNOTSUPP: |
| 87 |
raise unittest.SkipTest('Creation or usage of schedule elements is not supported') |
| 88 |
raise ex |
| 89 |
u.traffic(**self.traffic_args) |