| 1 |
# SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) |
| 2 |
# Copyright (c) 2020 Nvidia All rights reserved. See COPYING file |
| 3 |
""" |
| 4 |
Test module for pyverbs' mlx5 dr module. |
| 5 |
""" |
| 6 |
|
| 7 |
from os import path, system |
| 8 |
import unittest |
| 9 |
import struct |
| 10 |
import socket |
| 11 |
import errno |
| 12 |
import math |
| 13 |
|
| 14 |
from pyverbs.providers.mlx5.dr_action import DrActionQp, DrActionModify, \ |
| 15 |
DrActionFlowCounter, DrActionDrop, DrActionTag, DrActionDestTable, \ |
| 16 |
DrActionPopVLan, DrActionPushVLan, DrActionDestAttr, DrActionDestArray, \ |
| 17 |
DrActionDefMiss, DrActionVPort, DrActionIBPort, DrActionDestTir, DrActionPacketReformat,\ |
| 18 |
DrFlowSamplerAttr, DrActionFlowSample, DrFlowMeterAttr, DrActionFlowMeter |
| 19 |
from pyverbs.providers.mlx5.mlx5dv import Mlx5DevxObj, Mlx5Context, Mlx5DVContextAttr |
| 20 |
from tests.utils import skip_unsupported, requires_eswitch_on, PacketConsts, requires_cap_net_raw,\ |
| 21 |
requires_eth, requires_root |
| 22 |
from tests.mlx5_base import Mlx5RDMATestCase, PyverbsAPITestCase, MELLANOX_VENDOR_ID |
| 23 |
from pyverbs.providers.mlx5.mlx5dv_flow import Mlx5FlowMatchParameters |
| 24 |
from pyverbs.pyverbs_error import PyverbsRDMAError, PyverbsUserError |
| 25 |
from pyverbs.providers.mlx5.dr_matcher import DrMatcher |
| 26 |
from pyverbs.providers.mlx5.dr_domain import DrDomain |
| 27 |
from pyverbs.providers.mlx5.dr_table import DrTable |
| 28 |
from pyverbs.providers.mlx5.dr_rule import DrRule |
| 29 |
from pyverbs.providers.mlx5.mlx5_enums import mlx5dv_dr_domain_type, mlx5dv_dr_action_flags, \ |
| 30 |
mlx5dv_dr_matcher_layout_flags, mlx5dv_dr_action_dest_type, mlx5dv_dr_action_flags, \ |
| 31 |
MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL_, \ |
| 32 |
MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL_, \ |
| 33 |
MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2_, \ |
| 34 |
MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2_ |
| 35 |
|
| 36 |
from tests.test_mlx5_flow import requires_reformat_support |
| 37 |
from pyverbs.cq import CqInitAttrEx, CQEX, CQ |
| 38 |
from pyverbs.wq import WQInitAttr, WQ, WQAttr |
| 39 |
from tests.base import RawResources |
| 40 |
from pyverbs.libibverbs_enums import ibv_wq_attr_mask, ibv_wq_state, ibv_wr_opcode, ibv_create_cq_wc_flags, \ |
| 41 |
IBV_WC_STANDARD_FLAGS |
| 42 |
import tests.utils as u |
| 43 |
|
| 44 |
SET_ACTION = 0x1 |
| 45 |
MAX_MATCH_PARAM_SIZE = 0x180 |
| 46 |
PF_VPORT = 0x0 |
| 47 |
GENEVE_PACKET_OUTER_LENGTH = 50 |
| 48 |
ROCE_PACKET_OUTER_LENGTH = 58 |
| 49 |
SAMPLER_ERROR_MARGIN = 0.2 |
| 50 |
SAMPLE_RATIO = 4 |
| 51 |
METADATA_C_FIELDS = ['metadata_reg_c_0', 'metadata_reg_c_1', 'metadata_reg_c_2', |
| 52 |
'metadata_reg_c_3', 'metadata_reg_c_4', 'metadata_reg_c_5'] |
| 53 |
FLOW_METER_GREEN = 2 |
| 54 |
FLOW_METER_RED = 0 |
| 55 |
REG_C_DATA = 0x1234 |
| 56 |
|
| 57 |
|
| 58 |
class ModifyFields: |
| 59 |
""" |
| 60 |
Supported SW steering modify fields. |
| 61 |
""" |
| 62 |
OUT_SMAC_47_16 = 0x1 |
| 63 |
OUT_SMAC_15_0 = 0x2 |
| 64 |
META_DATA_REG_C_0 = 0x51 |
| 65 |
META_DATA_REG_C_1 = 0x52 |
| 66 |
|
| 67 |
|
| 68 |
class ModifyFieldsLen: |
| 69 |
""" |
| 70 |
Supported SW steering modify fields length. |
| 71 |
""" |
| 72 |
MAC_47_16 = 32 |
| 73 |
MAC_15_0 = 16 |
| 74 |
META_DATA_REG_C = 32 |
| 75 |
|
| 76 |
|
| 77 |
def skip_if_has_geneve_tx_bug(ctx): |
| 78 |
""" |
| 79 |
Some mlx5 devices such as CX5 and CX6 has a bug matching on Geneve fields |
| 80 |
on TX side. |
| 81 |
Raises unittest.SkipTest if that's the case. |
| 82 |
:param ctx: Mlx5 Context |
| 83 |
""" |
| 84 |
dev_attrs = ctx.query_device() |
| 85 |
mlx5_cx5_cx6 = [0x1017, 0x1018, 0x1019, 0x101a, 0x101b] |
| 86 |
if dev_attrs.vendor_id == MELLANOX_VENDOR_ID and \ |
| 87 |
dev_attrs.vendor_part_id in mlx5_cx5_cx6: |
| 88 |
raise unittest.SkipTest('This test is not supported on cx5/6') |
| 89 |
|
| 90 |
|
| 91 |
def requires_geneve_fields_rx_support(func): |
| 92 |
def func_wrapper(instance): |
| 93 |
nic_tbl_caps = u.query_nic_flow_table_caps(instance) |
| 94 |
field_support = nic_tbl_caps.flow_table_properties_nic_receive.ft_field_support |
| 95 |
if not (field_support.outer_geneve_vni and field_support.outer_geneve_oam and |
| 96 |
field_support.outer_geneve_protocol_type and field_support.outer_geneve_opt_len): |
| 97 |
raise unittest.SkipTest('NIC flow table does not support geneve fields') |
| 98 |
return func(instance) |
| 99 |
return func_wrapper |
| 100 |
|
| 101 |
|
| 102 |
def requires_flow_counter_support(func): |
| 103 |
def func_wrapper(instance): |
| 104 |
nic_tbl_caps = u.query_nic_flow_table_caps(instance) |
| 105 |
rx_counter_support = nic_tbl_caps.flow_table_properties_nic_receive.flow_counter |
| 106 |
tx_counter_support = nic_tbl_caps.flow_table_properties_nic_transmit.flow_counter |
| 107 |
if not (rx_counter_support and tx_counter_support): |
| 108 |
raise unittest.SkipTest('NIC flow tables do not support counter action') |
| 109 |
return func(instance) |
| 110 |
return func_wrapper |
| 111 |
|
| 112 |
|
| 113 |
class Mlx5DrResources(RawResources): |
| 114 |
""" |
| 115 |
Test various functionalities of the mlx5 direct rules class. |
| 116 |
""" |
| 117 |
def create_context(self): |
| 118 |
mlx5dv_attr = Mlx5DVContextAttr() |
| 119 |
try: |
| 120 |
self.ctx = Mlx5Context(mlx5dv_attr, name=self.dev_name) |
| 121 |
except PyverbsUserError as ex: |
| 122 |
raise unittest.SkipTest(f'Could not open mlx5 context ({ex})') |
| 123 |
except PyverbsRDMAError: |
| 124 |
raise unittest.SkipTest('Opening mlx5 context is not supported') |
| 125 |
|
| 126 |
def __init__(self, dev_name, ib_port, gid_index=0, wc_flags=0, msg_size=1024, qp_count=1): |
| 127 |
self.wc_flags = wc_flags |
| 128 |
super().__init__(dev_name=dev_name, ib_port=ib_port, gid_index=gid_index, |
| 129 |
msg_size=msg_size, qp_count=qp_count) |
| 130 |
|
| 131 |
@requires_cap_net_raw() |
| 132 |
@requires_eth() |
| 133 |
def create_qps(self): |
| 134 |
super().create_qps() |
| 135 |
|
| 136 |
def create_cq(self): |
| 137 |
""" |
| 138 |
Create an Extended CQ. |
| 139 |
""" |
| 140 |
wc_flags = IBV_WC_STANDARD_FLAGS | self.wc_flags |
| 141 |
cia = CqInitAttrEx(cqe=self.num_msgs, wc_flags=wc_flags) |
| 142 |
try: |
| 143 |
self.cq = CQEX(self.ctx, cia) |
| 144 |
except PyverbsRDMAError as ex: |
| 145 |
if ex.error_code == errno.EOPNOTSUPP: |
| 146 |
raise unittest.SkipTest('Create Extended CQ is not supported') |
| 147 |
raise ex |
| 148 |
|
| 149 |
def get_first_flow_meter_reg_id(self): |
| 150 |
""" |
| 151 |
Queries hca caps for supported reg C indexes for flow meter. |
| 152 |
:return: First reg C index that is supported |
| 153 |
""" |
| 154 |
from tests.mlx5_prm_structs import QueryHcaCapIn, QueryQosCapOut, DevxOps |
| 155 |
query_cap_in = QueryHcaCapIn(op_mod=DevxOps.MLX5_CMD_OP_QUERY_QOS_CAP << 1) |
| 156 |
cmd_res = self.ctx.devx_general_cmd(query_cap_in, len(QueryQosCapOut())) |
| 157 |
query_cap_out = QueryQosCapOut(cmd_res) |
| 158 |
if query_cap_out.status: |
| 159 |
raise PyverbsRDMAError(f'QUERY_HCA_CAP has failed with status ({query_cap_out.status}) ' |
| 160 |
f'and syndrome ({query_cap_out.syndrome})') |
| 161 |
bit_regs = query_cap_out.capability.flow_meter_reg_id |
| 162 |
if bit_regs == 0: |
| 163 |
raise unittest.SkipTest('Reg C is not supported') |
| 164 |
return int(math.log2(bit_regs & -bit_regs)) |
| 165 |
|
| 166 |
|
| 167 |
class Mlx5DrTirResources(Mlx5DrResources): |
| 168 |
def __init__(self, dev_name, ib_port, gid_index=0, wc_flags=0, msg_size=1024, |
| 169 |
qp_count=1, server=False): |
| 170 |
self.server = server |
| 171 |
super().__init__(dev_name=dev_name, ib_port=ib_port, gid_index=gid_index, |
| 172 |
wc_flags=wc_flags, msg_size=msg_size, qp_count=qp_count) |
| 173 |
|
| 174 |
def create_cq(self): |
| 175 |
self.cq = CQ(self.ctx, cqe=self.num_msgs) |
| 176 |
|
| 177 |
@requires_cap_net_raw() |
| 178 |
@requires_eth() |
| 179 |
def create_qps(self): |
| 180 |
if not self.server: |
| 181 |
super().create_qps() |
| 182 |
else: |
| 183 |
from tests.mlx5_prm_structs import Tirc, CreateTirIn, CreateTirOut |
| 184 |
self.qps = [WQ(self.ctx, WQInitAttr(wq_pd=self.pd, wq_cq=self.cq))] |
| 185 |
self.qps[0].modify(WQAttr(attr_mask=ibv_wq_attr_mask.IBV_WQ_ATTR_STATE, wq_state=ibv_wq_state.IBV_WQS_RDY)) |
| 186 |
tir_ctx = Tirc(inline_rqn=self.qps[0].wqn) |
| 187 |
self.tir = Mlx5DevxObj(self.ctx, CreateTirIn(tir_context=tir_ctx), len(CreateTirOut())) |
| 188 |
|
| 189 |
|
| 190 |
class Mlx5DrTest(Mlx5RDMATestCase): |
| 191 |
def setUp(self): |
| 192 |
super().setUp() |
| 193 |
self.iters = 10 |
| 194 |
self.server = None |
| 195 |
self.client = None |
| 196 |
self.rules = [] |
| 197 |
|
| 198 |
def tearDown(self): |
| 199 |
if self.server: |
| 200 |
self.server.ctx.close() |
| 201 |
if self.client: |
| 202 |
self.client.ctx.close() |
| 203 |
|
| 204 |
@skip_unsupported |
| 205 |
def create_rx_recv_rules_based_on_match_params(self, mask_param, val_param, actions, |
| 206 |
match_criteria=u.MatchCriteriaEnable.OUTER, |
| 207 |
domain=None, log_matcher_size=None, |
| 208 |
root_only=False): |
| 209 |
""" |
| 210 |
Creates a rule on RX domain that forwards packets that match on the provided parameters |
| 211 |
to the SW steering flow table and another rule on that table |
| 212 |
with provided actions. |
| 213 |
:param mask_param: The FlowTableEntryMatchParamSW mask matcher value. |
| 214 |
:param val_param: The FlowTableEntryMatchParamSW value matcher value. |
| 215 |
:param actions: List of actions to attach to the recv rule. |
| 216 |
:param match_criteria: the match criteria enable flag to match on |
| 217 |
:param domain: RX DR domain to use if provided, otherwise create default RX domain. |
| 218 |
:param log_matcher_size: Size of the matcher table |
| 219 |
:param root_only : If True, rules are created only on root table |
| 220 |
:return: Non-root table and dest table action to it if root=false else root_table |
| 221 |
""" |
| 222 |
self.domain_rx = domain if domain else DrDomain(self.server.ctx, |
| 223 |
mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 224 |
root_table = DrTable(self.domain_rx, 0) |
| 225 |
if not root_only: |
| 226 |
non_root_table = DrTable(self.domain_rx, 1) |
| 227 |
table = root_table if root_only else non_root_table |
| 228 |
self.matcher = DrMatcher(table, 1, match_criteria, mask_param) |
| 229 |
if log_matcher_size: |
| 230 |
self.matcher.set_layout(log_matcher_size) |
| 231 |
self.rules.append(DrRule(self.matcher, val_param, actions)) |
| 232 |
if not root_only: |
| 233 |
self.root_matcher = DrMatcher(root_table, 0, match_criteria, mask_param) |
| 234 |
self.dest_table_action = DrActionDestTable(table) |
| 235 |
self.rules.append(DrRule(self.root_matcher, val_param, [self.dest_table_action])) |
| 236 |
return table, self.dest_table_action |
| 237 |
return table |
| 238 |
|
| 239 |
@skip_unsupported |
| 240 |
def create_rx_recv_rules(self, smac_value, actions, log_matcher_size=None, domain=None, |
| 241 |
root_only=False): |
| 242 |
""" |
| 243 |
Creates a rule on RX domain that forwards packets that match the smac in the matcher |
| 244 |
to the SW steering flow table and another rule on that table with provided actions. |
| 245 |
:param smac_value: The smac matcher value. |
| 246 |
:param actions: List of actions to attach to the recv rule. |
| 247 |
:param log_matcher_size: Size of the matcher table |
| 248 |
:param domain: RX DR domain to use if provided, otherwise create default RX domain. |
| 249 |
:param root_only : If True, rules are created only on root table |
| 250 |
:return: Non-root table and dest table action to it if root_only=false else root_table |
| 251 |
""" |
| 252 |
smac_mask = bytes([0xff] * 6) + bytes(2) |
| 253 |
mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask) |
| 254 |
# Size of the matcher value should be modulo 4 |
| 255 |
smac_value = smac_value if root_only else smac_value + bytes(2) |
| 256 |
value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value) |
| 257 |
return self.create_rx_recv_rules_based_on_match_params(mask_param, value_param, actions, |
| 258 |
u.MatchCriteriaEnable.OUTER, |
| 259 |
domain, log_matcher_size, |
| 260 |
root_only=root_only) |
| 261 |
|
| 262 |
def send_client_raw_packets(self, iters, src_mac=None): |
| 263 |
""" |
| 264 |
Send raw packets. |
| 265 |
:param iters: Number of packets to send. |
| 266 |
:param src_mac: If set, src mac to set in the packets. |
| 267 |
""" |
| 268 |
c_send_wr, _, _ = u.get_send_elements_raw_qp(self.client, src_mac=src_mac) |
| 269 |
poll_cq = u.poll_cq_ex if isinstance(self.client.cq, CQEX) else u.poll_cq |
| 270 |
for _ in range(iters): |
| 271 |
u.send(self.client, c_send_wr, ibv_wr_opcode.IBV_WR_SEND) |
| 272 |
poll_cq(self.client.cq) |
| 273 |
|
| 274 |
def send_server_fdb_to_nic_packets(self, iters): |
| 275 |
""" |
| 276 |
Server sends and receives raw packets. |
| 277 |
:param iters: Number of packets to send. |
| 278 |
""" |
| 279 |
s_recv_wr = u.get_recv_wr(self.server) |
| 280 |
u.post_recv(self.server, s_recv_wr, qp_idx=0) |
| 281 |
c_send_wr, _, msg = u.get_send_elements_raw_qp(self.server) |
| 282 |
for _ in range(iters): |
| 283 |
u.send(self.server, c_send_wr, ibv_wr_opcode.IBV_WR_SEND) |
| 284 |
u.poll_cq_ex(self.server.cq) |
| 285 |
u.poll_cq_ex(self.server.cq) |
| 286 |
u.post_recv(self.server, s_recv_wr, qp_idx=0) |
| 287 |
msg_received = self.server.mr.read(self.server.msg_size, 0) |
| 288 |
u.validate_raw(msg_received, msg, []) |
| 289 |
|
| 290 |
def dest_port(self, is_vport=True): |
| 291 |
""" |
| 292 |
Creates FDB domain, root table with matcher on source mac on the server |
| 293 |
side. Create a rule to forward all traffic to the non-root table. |
| 294 |
On this table apply VPort/IBPort action goto PF. |
| 295 |
On the server open another RX domain on PF with QP action and validate |
| 296 |
packets by sending traffic from client, catch all traffic with |
| 297 |
VPort/IBPort action goto PF, open another RX domain on PF with QP |
| 298 |
action and validate packets. |
| 299 |
:param is_vport: A flag to indicate if to use VPort or IBPort action. |
| 300 |
""" |
| 301 |
self.client = Mlx5DrResources(**self.dev_info) |
| 302 |
self.server = Mlx5DrResources(**self.dev_info) |
| 303 |
self.domain_fdb = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_FDB) |
| 304 |
port_action = DrActionVPort(self.domain_fdb, PF_VPORT) if is_vport \ |
| 305 |
else DrActionIBPort(self.domain_fdb, self.ib_port) |
| 306 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 307 |
self.fdb_table, self.fdb_dest_act = self.create_rx_recv_rules(smac_value, [port_action], |
| 308 |
domain=self.domain_fdb) |
| 309 |
self.domain_rx = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 310 |
rx_table = DrTable(self.domain_rx, 0) |
| 311 |
qp_action = DrActionQp(self.server.qp) |
| 312 |
smac_mask = bytes([0xff] * 6) |
| 313 |
mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask) |
| 314 |
rx_matcher = DrMatcher(rx_table, 0, u.MatchCriteriaEnable.OUTER, mask_param) |
| 315 |
value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value) |
| 316 |
self.rules.append(DrRule(rx_matcher, value_param, [qp_action])) |
| 317 |
# Validate traffic on RX |
| 318 |
u.raw_traffic(self.client, self.server, self.iters) |
| 319 |
|
| 320 |
@staticmethod |
| 321 |
def create_dest_mac_params(): |
| 322 |
from tests.mlx5_prm_structs import FlowTableEntryMatchParamSW |
| 323 |
|
| 324 |
eth_match_mask = FlowTableEntryMatchParamSW() |
| 325 |
eth_match_mask.outer_headers.dmac = PacketConsts.MAC_MASK |
| 326 |
eth_match_value = FlowTableEntryMatchParamSW() |
| 327 |
eth_match_value.outer_headers.dmac = PacketConsts.DST_MAC |
| 328 |
mask_param = Mlx5FlowMatchParameters(len(eth_match_mask), eth_match_mask) |
| 329 |
value_param = Mlx5FlowMatchParameters(len(eth_match_value), eth_match_value) |
| 330 |
return mask_param, value_param |
| 331 |
|
| 332 |
@staticmethod |
| 333 |
def create_counter(ctx): |
| 334 |
""" |
| 335 |
Create flow counter. |
| 336 |
:param ctx: The player context to create the counter on. |
| 337 |
:return: The counter object and the flow counter ID . |
| 338 |
""" |
| 339 |
from tests.mlx5_prm_structs import AllocFlowCounterIn, AllocFlowCounterOut |
| 340 |
counter = Mlx5DevxObj(ctx, AllocFlowCounterIn(), len(AllocFlowCounterOut())) |
| 341 |
flow_counter_id = AllocFlowCounterOut(counter.out_view).flow_counter_id |
| 342 |
return counter, flow_counter_id |
| 343 |
|
| 344 |
@staticmethod |
| 345 |
def query_counter_packets(counter, flow_counter_id): |
| 346 |
""" |
| 347 |
Query flow counter packets count. |
| 348 |
:param counter: The counter for the query. |
| 349 |
:param flow_counter_id: The flow counter ID for the query. |
| 350 |
:return: Number of packets on this counter. |
| 351 |
""" |
| 352 |
from tests.mlx5_prm_structs import QueryFlowCounterIn, QueryFlowCounterOut |
| 353 |
query_in = QueryFlowCounterIn(flow_counter_id=flow_counter_id) |
| 354 |
counter_out = QueryFlowCounterOut(counter.query(query_in, len(QueryFlowCounterOut()))) |
| 355 |
return counter_out.flow_statistics.packets |
| 356 |
|
| 357 |
@staticmethod |
| 358 |
def gen_gre_tunnel_encap_header(msg_size, is_l2_tunnel=True): |
| 359 |
gre_ether_type = PacketConsts.ETHER_TYPE_ETH if is_l2_tunnel else \ |
| 360 |
PacketConsts.ETHER_TYPE_IPV4 |
| 361 |
gre_header = u.gen_gre_header(ether_type=gre_ether_type) |
| 362 |
ip_header = u.gen_ipv4_header(packet_len=msg_size + len(gre_header), |
| 363 |
next_proto=socket.IPPROTO_GRE) |
| 364 |
mac_header = u.gen_ethernet_header() |
| 365 |
return mac_header + ip_header + gre_header |
| 366 |
|
| 367 |
@staticmethod |
| 368 |
def gen_geneve_tunnel_encap_header(msg_size, is_l2_tunnel=True): |
| 369 |
proto = PacketConsts.ETHER_TYPE_ETH if is_l2_tunnel else PacketConsts.ETHER_TYPE_IPV4 |
| 370 |
geneve_header = u.gen_geneve_header(proto=proto) |
| 371 |
udp_header = u.gen_udp_header(packet_len=msg_size + len(geneve_header), |
| 372 |
dst_port=PacketConsts.GENEVE_PORT) |
| 373 |
ip_header = u.gen_ipv4_header(packet_len=msg_size + len(udp_header) + len(geneve_header)) |
| 374 |
mac_header = u.gen_ethernet_header() |
| 375 |
return mac_header + ip_header + udp_header + geneve_header |
| 376 |
|
| 377 |
@staticmethod |
| 378 |
def create_geneve_params(): |
| 379 |
from tests.mlx5_prm_structs import FlowTableEntryMatchParamSW |
| 380 |
geneve_mask = FlowTableEntryMatchParamSW() |
| 381 |
geneve_mask.misc_parameters.geneve_vni = 0xffffff |
| 382 |
geneve_mask.misc_parameters.geneve_oam = 1 |
| 383 |
geneve_value = FlowTableEntryMatchParamSW() |
| 384 |
geneve_value.misc_parameters.geneve_vni = PacketConsts.GENEVE_VNI |
| 385 |
geneve_value.misc_parameters.geneve_oam = PacketConsts.GENEVE_OAM |
| 386 |
mask_param = Mlx5FlowMatchParameters(len(geneve_mask), geneve_mask) |
| 387 |
value_param = Mlx5FlowMatchParameters(len(geneve_value), geneve_value) |
| 388 |
return mask_param, value_param |
| 389 |
|
| 390 |
@staticmethod |
| 391 |
def gen_roce_bth_header(msg_size): |
| 392 |
mac_header = u.gen_ethernet_header() |
| 393 |
ip_header = u.gen_ipv4_header(packet_len=msg_size + PacketConsts.UDP_HEADER_SIZE + |
| 394 |
PacketConsts.BTH_HEADER_SIZE) |
| 395 |
udp_header = u.gen_udp_header(packet_len=msg_size + PacketConsts.BTH_HEADER_SIZE, |
| 396 |
dst_port=PacketConsts.ROCE_PORT) |
| 397 |
bth_header = u.gen_bth_header() |
| 398 |
return mac_header + ip_header + udp_header + bth_header |
| 399 |
|
| 400 |
@staticmethod |
| 401 |
def create_roce_bth_params(): |
| 402 |
from tests.mlx5_prm_structs import FlowTableEntryMatchParamSW |
| 403 |
roce_mask = FlowTableEntryMatchParamSW() |
| 404 |
roce_mask.misc_parameters.bth_opcode = 0xff |
| 405 |
roce_mask.misc_parameters.bth_dst_qp = 0xffffff |
| 406 |
roce_mask.misc_parameters.bth_a = 0x1 |
| 407 |
roce_value = FlowTableEntryMatchParamSW() |
| 408 |
roce_value.misc_parameters.bth_opcode = PacketConsts.BTH_OPCODE |
| 409 |
roce_value.misc_parameters.bth_dst_qp = PacketConsts.BTH_DST_QP |
| 410 |
roce_value.misc_parameters.bth_a = PacketConsts.BTH_A |
| 411 |
mask_param = Mlx5FlowMatchParameters(len(roce_mask), roce_mask) |
| 412 |
value_param = Mlx5FlowMatchParameters(len(roce_value), roce_value) |
| 413 |
return mask_param, value_param |
| 414 |
|
| 415 |
def create_empty_matcher_go_to_tbl(self, src_tbl, dst_tbl): |
| 416 |
""" |
| 417 |
Create rule that forward all packets (by empty matcher) from src_tbl to |
| 418 |
dst_tbl. |
| 419 |
""" |
| 420 |
from tests.mlx5_prm_structs import FlowTableEntryMatchParamSW |
| 421 |
|
| 422 |
empty_param = Mlx5FlowMatchParameters(len(FlowTableEntryMatchParamSW()), |
| 423 |
FlowTableEntryMatchParamSW()) |
| 424 |
matcher = DrMatcher(src_tbl, 0, u.MatchCriteriaEnable.NONE, empty_param) |
| 425 |
go_to_tbl_action = DrActionDestTable(dst_tbl) |
| 426 |
self.rules.append(DrRule(matcher, empty_param, [go_to_tbl_action])) |
| 427 |
return go_to_tbl_action |
| 428 |
|
| 429 |
@requires_eswitch_on |
| 430 |
@skip_unsupported |
| 431 |
def test_dest_vport(self): |
| 432 |
self.dest_port() |
| 433 |
|
| 434 |
@requires_eswitch_on |
| 435 |
@skip_unsupported |
| 436 |
def test_dest_ib_port(self): |
| 437 |
self.dest_port(False) |
| 438 |
|
| 439 |
@skip_unsupported |
| 440 |
def add_qp_rule_and_send_pkts(self, root_only=False): |
| 441 |
""" |
| 442 |
:param root_only : If True, rules are created only on root table |
| 443 |
""" |
| 444 |
self.create_players(Mlx5DrResources) |
| 445 |
self.qp_action = DrActionQp(self.server.qp) |
| 446 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 447 |
self.create_rx_recv_rules(smac_value, [self.qp_action], root_only=root_only) |
| 448 |
u.raw_traffic(self.client, self.server, self.iters) |
| 449 |
|
| 450 |
@requires_root() |
| 451 |
def test_tbl_qp_rule(self): |
| 452 |
""" |
| 453 |
Creates RX domain, SW table with matcher on source mac. Creates QP action |
| 454 |
and a rule with this action on the matcher. |
| 455 |
""" |
| 456 |
self.add_qp_rule_and_send_pkts() |
| 457 |
|
| 458 |
def test_root_tbl_qp_rule(self): |
| 459 |
""" |
| 460 |
Creates RX domain, SW table with matcher on source mac. Creates QP action |
| 461 |
and a rule with this action on the matcher. |
| 462 |
""" |
| 463 |
self.add_qp_rule_and_send_pkts(root_only=True) |
| 464 |
|
| 465 |
@skip_unsupported |
| 466 |
def modify_tx_smac_and_send_pkts(self, root_only=False): |
| 467 |
""" |
| 468 |
Create a rule on TX domain that modifies smac of matched packet and |
| 469 |
sends it to the wire. |
| 470 |
:param root_only : If True, rules are created only on root table |
| 471 |
""" |
| 472 |
from tests.mlx5_prm_structs import SetActionIn |
| 473 |
self.create_players(Mlx5DrResources) |
| 474 |
self.domain_tx = DrDomain(self.client.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX) |
| 475 |
root_table_tx = DrTable(self.domain_tx, 0) |
| 476 |
if not root_only: |
| 477 |
non_root_table_tx = DrTable(self.domain_tx, 1) |
| 478 |
self.move_action = self.create_empty_matcher_go_to_tbl(root_table_tx, non_root_table_tx) |
| 479 |
table = root_table_tx if root_only else non_root_table_tx |
| 480 |
smac_mask = bytes([0xff] * 6) |
| 481 |
mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask) |
| 482 |
matcher_tx = DrMatcher(table, 0, u.MatchCriteriaEnable.OUTER, mask_param) |
| 483 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 484 |
smac_value += bytes(2) |
| 485 |
value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value) |
| 486 |
action1 = SetActionIn(action_type=SET_ACTION, field=ModifyFields.OUT_SMAC_47_16, |
| 487 |
data=0x88888888, length=ModifyFieldsLen.MAC_47_16) |
| 488 |
action2 = SetActionIn(action_type=SET_ACTION, field=ModifyFields.OUT_SMAC_15_0, |
| 489 |
data=0x8888, length=ModifyFieldsLen.MAC_15_0) |
| 490 |
flags = mlx5dv_dr_action_flags.MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL if root_only else 0 |
| 491 |
self.modify_action_tx = DrActionModify(self.domain_tx, flags, [action1, action2]) |
| 492 |
self.rules.append(DrRule(matcher_tx, value_param, [self.modify_action_tx])) |
| 493 |
src_mac = struct.pack('!6s', bytes.fromhex("88:88:88:88:88:88".replace(':', ''))) |
| 494 |
self.qp_action = DrActionQp(self.server.qp) |
| 495 |
self.create_rx_recv_rules(src_mac, [self.qp_action], root_only=root_only) |
| 496 |
exp_packet = u.gen_packet(self.client.msg_size, src_mac=src_mac) |
| 497 |
u.raw_traffic(self.client, self.server, self.iters, expected_packet=exp_packet) |
| 498 |
|
| 499 |
@skip_unsupported |
| 500 |
@requires_root() |
| 501 |
def test_tbl_modify_header_rule(self): |
| 502 |
""" |
| 503 |
Creates TX domain, SW table with matcher on source mac and modify the smac. |
| 504 |
Then creates RX domain and rule that forwards packets with the new smac |
| 505 |
to server QP. Perform traffic that do this flow. |
| 506 |
""" |
| 507 |
self.modify_tx_smac_and_send_pkts() |
| 508 |
|
| 509 |
@skip_unsupported |
| 510 |
def test_root_tbl_modify_header_rule(self): |
| 511 |
""" |
| 512 |
Creates TX domain, root table with matcher on source mac and modify the smac. |
| 513 |
Then creates RX domain and rule that forwards packets with the new smac |
| 514 |
to server QP. Perform traffic that do this flow. |
| 515 |
""" |
| 516 |
self.modify_tx_smac_and_send_pkts(root_only=True) |
| 517 |
|
| 518 |
@skip_unsupported |
| 519 |
@requires_root() |
| 520 |
def test_metadata_modify_action_set_copy_match(self): |
| 521 |
""" |
| 522 |
Verify modify header with set and copy actions. |
| 523 |
TX and RX: |
| 524 |
- Root table: |
| 525 |
Match empty (hit all): |
| 526 |
Rule: prio 0 - val empty. Action: Go TO Table 1 |
| 527 |
- Table 1: |
| 528 |
Match empty (hit all): |
| 529 |
Rule: prio 0 - val empty. Action: Modify Header (set reg_c_0 to REG_C_DATA) |
| 530 |
+ Go TO Table 2 |
| 531 |
- Table 2: |
| 532 |
Match empty (hit all): |
| 533 |
Rule: prio 0 - val empty. Action: Modify Header (copy reg_c_0 to reg_c_1) |
| 534 |
+ Go To Table 3 |
| 535 |
TX: |
| 536 |
- Table 3: |
| 537 |
Match reg_c_0 and reg_c_1: |
| 538 |
Rule: prio 0 - val REG_C_DATA. Action: Counter |
| 539 |
RX: |
| 540 |
- Table 3: |
| 541 |
Match reg_c_0 and reg_c_1: |
| 542 |
Rule: prio 0 - val REG_C_DATA. Action: Go To QP |
| 543 |
""" |
| 544 |
from tests.mlx5_prm_structs import FlowTableEntryMatchParamSW, FlowTableEntryMatchSetMisc2, \ |
| 545 |
SetActionIn, CopyActionIn |
| 546 |
|
| 547 |
self.create_players(Mlx5DrResources) |
| 548 |
match_param = FlowTableEntryMatchParamSW() |
| 549 |
empty_param = Mlx5FlowMatchParameters(len(match_param), match_param) |
| 550 |
mask_metadata = FlowTableEntryMatchParamSW(misc_parameters_2= |
| 551 |
FlowTableEntryMatchSetMisc2(metadata_reg_c_0=0xffff, metadata_reg_c_1=0xffff)) |
| 552 |
mask_param = Mlx5FlowMatchParameters(len(match_param), mask_metadata) |
| 553 |
value_metadata = FlowTableEntryMatchParamSW(misc_parameters_2= |
| 554 |
FlowTableEntryMatchSetMisc2(metadata_reg_c_0=REG_C_DATA, |
| 555 |
metadata_reg_c_1=REG_C_DATA)) |
| 556 |
value_param = Mlx5FlowMatchParameters(len(match_param), value_metadata) |
| 557 |
self.client.domain = DrDomain(self.client.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX) |
| 558 |
self.server.domain = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 559 |
for player in [self.client, self.server]: |
| 560 |
player.tables = [] |
| 561 |
player.matchers = [] |
| 562 |
for i in range(4): |
| 563 |
player.tables.append(DrTable(player.domain, i)) |
| 564 |
for i in range(2): |
| 565 |
player.matchers.append(DrMatcher(player.tables[i + 1], 0, |
| 566 |
u.MatchCriteriaEnable.NONE, empty_param)) |
| 567 |
player.matchers.append(DrMatcher(player.tables[3], 0, |
| 568 |
u.MatchCriteriaEnable.MISC_2, mask_param)) |
| 569 |
player.go_to_tbl1_action = self.create_empty_matcher_go_to_tbl(player.tables[0], |
| 570 |
player.tables[1]) |
| 571 |
set_reg = SetActionIn(field=ModifyFields.META_DATA_REG_C_0, |
| 572 |
length=ModifyFieldsLen.META_DATA_REG_C, data=REG_C_DATA) |
| 573 |
player.modify_action_set = DrActionModify(player.domain, 0, [set_reg]) |
| 574 |
player.go_to_tbl2_action = DrActionDestTable(player.tables[2]) |
| 575 |
self.rules.append(DrRule(player.matchers[0], empty_param, [player.modify_action_set, |
| 576 |
player.go_to_tbl2_action])) |
| 577 |
copy_reg = CopyActionIn(src_field=ModifyFields.META_DATA_REG_C_0, |
| 578 |
length=ModifyFields.META_DATA_REG_C_0, |
| 579 |
dst_field=ModifyFields.META_DATA_REG_C_1) |
| 580 |
player.modify_action_copy = DrActionModify(player.domain, 0, [copy_reg]) |
| 581 |
player.go_to_tbl3_action = DrActionDestTable(player.tables[3]) |
| 582 |
self.rules.append(DrRule(player.matchers[1], empty_param, [player.modify_action_copy, |
| 583 |
player.go_to_tbl3_action])) |
| 584 |
counter, flow_counter_id = self.create_counter(self.client.ctx) |
| 585 |
counter_action = DrActionFlowCounter(counter) |
| 586 |
self.rules.append(DrRule(self.client.matchers[2], value_param, [counter_action])) |
| 587 |
qp_action = DrActionQp(self.server.qp) |
| 588 |
self.rules.append(DrRule(self.server.matchers[2], value_param, [qp_action])) |
| 589 |
u.raw_traffic(self.client, self.server, self.iters) |
| 590 |
sent_packets = self.query_counter_packets(counter, flow_counter_id) |
| 591 |
self.assertEqual(sent_packets, self.iters, 'Counter of metadata missed some sent packets') |
| 592 |
|
| 593 |
@skip_unsupported |
| 594 |
def add_counter_action_and_send_pkts(self, root_only=False): |
| 595 |
""" |
| 596 |
:param root_only : If True, rules are created only on root table |
| 597 |
""" |
| 598 |
self.create_players(Mlx5DrResources) |
| 599 |
counter, flow_counter_id = self.create_counter(self.server.ctx) |
| 600 |
self.server_counter_action = DrActionFlowCounter(counter) |
| 601 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 602 |
self.qp_action = DrActionQp(self.server.qp) |
| 603 |
self.create_rx_recv_rules(smac_value, [self.qp_action, self.server_counter_action], |
| 604 |
root_only=root_only) |
| 605 |
u.raw_traffic(self.client, self.server, self.iters) |
| 606 |
recv_packets = self.query_counter_packets(counter, flow_counter_id) |
| 607 |
self.assertEqual(recv_packets, self.iters, 'Counter missed some recv packets') |
| 608 |
|
| 609 |
@skip_unsupported |
| 610 |
def test_root_tbl_counter_action(self): |
| 611 |
""" |
| 612 |
Create flow counter object, on root table attach it to a rule using counter action |
| 613 |
and perform traffic that hit this rule. Verify that the packets counter |
| 614 |
increased. |
| 615 |
""" |
| 616 |
self.add_counter_action_and_send_pkts(root_only=True) |
| 617 |
|
| 618 |
@skip_unsupported |
| 619 |
@requires_root() |
| 620 |
def test_tbl_counter_action(self): |
| 621 |
""" |
| 622 |
Create flow counter object, on non-root table attach it to a rule using counter action |
| 623 |
and perform traffic that hit this rule. Verify that the packets counter |
| 624 |
increased. |
| 625 |
""" |
| 626 |
self.add_counter_action_and_send_pkts() |
| 627 |
|
| 628 |
|
| 629 |
@skip_unsupported |
| 630 |
@requires_root() |
| 631 |
def test_prevent_duplicate_rule(self): |
| 632 |
""" |
| 633 |
Creates RX domain, sets duplicate rule to be not allowed on that domain, |
| 634 |
try creating duplicate rule. Fail if creation succeeded. |
| 635 |
""" |
| 636 |
from tests.mlx5_prm_structs import FlowTableEntryMatchParamSW |
| 637 |
self.server = Mlx5DrResources(**self.dev_info) |
| 638 |
domain_rx = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 639 |
domain_rx.allow_duplicate_rules(False) |
| 640 |
table = DrTable(domain_rx, 1) |
| 641 |
empty_param = Mlx5FlowMatchParameters(len(FlowTableEntryMatchParamSW()), |
| 642 |
FlowTableEntryMatchParamSW()) |
| 643 |
matcher = DrMatcher(table, 0, u.MatchCriteriaEnable.NONE, empty_param) |
| 644 |
self.qp_action = DrActionQp(self.server.qp) |
| 645 |
self.drop_action = DrActionDrop() |
| 646 |
self.rules.append(DrRule(matcher, empty_param, [self.qp_action])) |
| 647 |
with self.assertRaises(PyverbsRDMAError) as ex: |
| 648 |
self.rules.append(DrRule(matcher, empty_param, [self.drop_action])) |
| 649 |
self.assertEqual(ex.exception.error_code, errno.EEXIST) |
| 650 |
|
| 651 |
def _drop_action(self, root_only=False): |
| 652 |
self.create_players(Mlx5DrResources) |
| 653 |
# Initiate the sender side |
| 654 |
domain_tx = DrDomain(self.client.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX) |
| 655 |
tx_root_table = DrTable(domain_tx, 0) |
| 656 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 657 |
if not root_only: |
| 658 |
tx_non_root_table = DrTable(domain_tx, 1) |
| 659 |
tx_dest_table_action = self.fwd_packets_to_table(tx_root_table, tx_non_root_table) |
| 660 |
smac_value += bytes(2) |
| 661 |
tx_test_table = tx_root_table if root_only else tx_non_root_table |
| 662 |
mask_param = Mlx5FlowMatchParameters(len(bytes([0xff] * 6)), bytes([0xff] * 6)) |
| 663 |
matcher = DrMatcher(tx_test_table, 0, u.MatchCriteriaEnable.OUTER, mask_param) |
| 664 |
value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value) |
| 665 |
self.tx_drop_action = DrActionDrop() |
| 666 |
self.rules.append(DrRule(matcher, value_param, [self.tx_drop_action])) |
| 667 |
# Initiate the receiver side |
| 668 |
domain_rx = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 669 |
rx_root_table = DrTable(domain_rx, 0) |
| 670 |
if not root_only: |
| 671 |
rx_non_root_table = DrTable(domain_rx, 1) |
| 672 |
rx_dest_table_action = self.fwd_packets_to_table(rx_root_table, rx_non_root_table) |
| 673 |
rx_test_table = rx_root_table if root_only else rx_non_root_table |
| 674 |
# Create server counter. |
| 675 |
counter, flow_counter_id = self.create_counter(self.server.ctx) |
| 676 |
self.server_counter_action = DrActionFlowCounter(counter) |
| 677 |
mask_param, value_param = self.create_dest_mac_params() |
| 678 |
matcher = DrMatcher(rx_test_table, 0, u.MatchCriteriaEnable.OUTER, mask_param) |
| 679 |
self.rx_drop_action = DrActionDrop() |
| 680 |
self.rules.append(DrRule(matcher, value_param, [self.server_counter_action, |
| 681 |
self.rx_drop_action])) |
| 682 |
# Send packets with two different smacs and expect half to be dropped. |
| 683 |
src_mac_drop = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 684 |
src_mac_non_drop = struct.pack('!6s', bytes.fromhex("88:88:88:88:88:88".replace(':', ''))) |
| 685 |
self.send_client_raw_packets(int(self.iters / 2), src_mac=src_mac_drop) |
| 686 |
recv_packets = self.query_counter_packets(counter, flow_counter_id) |
| 687 |
self.assertEqual(recv_packets, 0, 'Drop action did not drop the TX packets') |
| 688 |
self.send_client_raw_packets(int(self.iters / 2), src_mac=src_mac_non_drop) |
| 689 |
recv_packets = self.query_counter_packets(counter, flow_counter_id) |
| 690 |
self.assertEqual(recv_packets, int(self.iters/2), |
| 691 |
'Drop action dropped TX packets that not matched the rule') |
| 692 |
|
| 693 |
@skip_unsupported |
| 694 |
def test_root_tbl_drop_action(self): |
| 695 |
""" |
| 696 |
Create root drop actions on TX and RX. Verify using counter on the server RX that |
| 697 |
only packets which miss the drop rule arrived to the server RX. |
| 698 |
""" |
| 699 |
self._drop_action(root_only=True) |
| 700 |
|
| 701 |
@skip_unsupported |
| 702 |
@requires_root() |
| 703 |
def test_tbl_drop_action(self): |
| 704 |
""" |
| 705 |
Create non-root drop actions on TX and RX. Verify using counter on the server RX that |
| 706 |
only packets that which the drop rule arrived to the server RX. |
| 707 |
""" |
| 708 |
self._drop_action() |
| 709 |
|
| 710 |
@skip_unsupported |
| 711 |
def add_qp_tag_rule_and_send_pkts(self, root_only=False): |
| 712 |
""" |
| 713 |
Creates RX domain, table with matcher on source mac. Creates QP action |
| 714 |
and tag action. Creates a rule with those actions on the matcher. |
| 715 |
Verifies traffic and tag. |
| 716 |
:param root_only : If True, rules are created only on root table |
| 717 |
""" |
| 718 |
self.wc_flags = ibv_create_cq_wc_flags.IBV_WC_EX_WITH_FLOW_TAG |
| 719 |
self.create_players(Mlx5DrResources, wc_flags=ibv_create_cq_wc_flags.IBV_WC_EX_WITH_FLOW_TAG) |
| 720 |
qp_action = DrActionQp(self.server.qp) |
| 721 |
tag = 0x123 |
| 722 |
tag_action = DrActionTag(tag) |
| 723 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 724 |
self.create_rx_recv_rules(smac_value, [tag_action, qp_action], root_only=root_only) |
| 725 |
self.domain_rx.sync() |
| 726 |
u.raw_traffic(self.client, self.server, self.iters) |
| 727 |
# Verify tag |
| 728 |
self.assertEqual(self.server.cq.read_flow_tag(), tag, 'Wrong tag value') |
| 729 |
|
| 730 |
@skip_unsupported |
| 731 |
@requires_root() |
| 732 |
def test_tbl_qp_tag_rule(self): |
| 733 |
""" |
| 734 |
Creates RX domain, non-root table with matcher on source mac. Creates QP action |
| 735 |
and tag action. Creates a rule with those actions on the matcher. |
| 736 |
Verifies traffic and tag. |
| 737 |
""" |
| 738 |
self.add_qp_tag_rule_and_send_pkts() |
| 739 |
|
| 740 |
@skip_unsupported |
| 741 |
def test_root_tbl_qp_tag_rule(self): |
| 742 |
""" |
| 743 |
Creates RX domain, root table with matcher on source mac. Creates QP action |
| 744 |
and tag action. Creates a rule with those actions on the matcher. |
| 745 |
Verifies traffic and tag. |
| 746 |
""" |
| 747 |
self.add_qp_tag_rule_and_send_pkts(root_only=True) |
| 748 |
|
| 749 |
@skip_unsupported |
| 750 |
@requires_root() |
| 751 |
def test_set_matcher_layout(self): |
| 752 |
""" |
| 753 |
Creates a non root matcher and sets its size. Creates a rule on that |
| 754 |
matcher and increases the matcher size. Verifies the rule. |
| 755 |
""" |
| 756 |
log_matcher_size = 5 |
| 757 |
self.create_players(Mlx5DrResources) |
| 758 |
self.qp_action = DrActionQp(self.server.qp) |
| 759 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 760 |
self.create_rx_recv_rules(smac_value, [self.qp_action], log_matcher_size) |
| 761 |
self.matcher.set_layout(log_matcher_size + 1) |
| 762 |
u.raw_traffic(self.client, self.server, self.iters) |
| 763 |
self.matcher.set_layout(flags=mlx5dv_dr_matcher_layout_flags.MLX5DV_DR_MATCHER_LAYOUT_RESIZABLE) |
| 764 |
u.raw_traffic(self.client, self.server, self.iters) |
| 765 |
|
| 766 |
@skip_unsupported |
| 767 |
@requires_root() |
| 768 |
def test_push_vlan(self): |
| 769 |
""" |
| 770 |
Creates RX domain, root table with matcher on source mac. Create a rule to forward |
| 771 |
all traffic to the non-root table. Creates QP action and push VLAN action. |
| 772 |
Creates a rule with those actions on the matcher. |
| 773 |
Verifies traffic and packet with specified VLAN. |
| 774 |
""" |
| 775 |
self.client = Mlx5DrResources(**self.dev_info) |
| 776 |
vlan_hdr = struct.pack('!HH', PacketConsts.VLAN_TPID, (PacketConsts.VLAN_PRIO << 13) + |
| 777 |
(PacketConsts.VLAN_CFI << 12) + PacketConsts.VLAN_ID) |
| 778 |
self.server = Mlx5DrResources(msg_size=self.client.msg_size + PacketConsts.VLAN_HEADER_SIZE, |
| 779 |
**self.dev_info) |
| 780 |
self.domain_tx = DrDomain(self.client.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX) |
| 781 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 782 |
push_action = DrActionPushVLan(self.domain_tx, struct.unpack('I', vlan_hdr)[0]) |
| 783 |
self.tx_table, self.tx_dest_act = self.create_rx_recv_rules(smac_value, [push_action], |
| 784 |
domain=self.domain_tx) |
| 785 |
self.domain_rx = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 786 |
qp_action = DrActionQp(self.server.qp) |
| 787 |
self.create_rx_recv_rules(smac_value, [qp_action], domain=self.domain_rx) |
| 788 |
exp_packet = u.gen_packet(self.client.msg_size + PacketConsts.VLAN_HEADER_SIZE, |
| 789 |
with_vlan=True) |
| 790 |
u.raw_traffic(self.client, self.server, self.iters, expected_packet=exp_packet) |
| 791 |
|
| 792 |
@skip_unsupported |
| 793 |
@requires_root() |
| 794 |
def test_pop_vlan(self): |
| 795 |
""" |
| 796 |
Creates RX domain, root table with matcher on source mac. Create a rule to forward |
| 797 |
all traffic to the non-root table. Creates QP action and pop VLAN action. |
| 798 |
Creates a rule with those actions on the matcher. |
| 799 |
Verifies packets received without VLAN header. |
| 800 |
""" |
| 801 |
self.server = Mlx5DrResources(**self.dev_info) |
| 802 |
self.client = Mlx5DrResources(**self.dev_info) |
| 803 |
exp_packet = u.gen_packet(self.server.msg_size - PacketConsts.VLAN_HEADER_SIZE) |
| 804 |
qp_action = DrActionQp(self.server.qp) |
| 805 |
pop_action = DrActionPopVLan() |
| 806 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 807 |
self.create_rx_recv_rules(smac_value, [pop_action, qp_action]) |
| 808 |
u.raw_traffic(self.client, self.server, self.iters, with_vlan=True, expected_packet=exp_packet) |
| 809 |
|
| 810 |
@skip_unsupported |
| 811 |
def dest_array(self, root_only=False): |
| 812 |
""" |
| 813 |
Creates RX domain, root table with matcher on source mac. Create a rule |
| 814 |
to forward all traffic to the non-root table. On this table add a rule |
| 815 |
with multi dest array action which include destination QP actions and |
| 816 |
next FT (also with QP action). |
| 817 |
Validate on all QPs the received packets. |
| 818 |
:param root_only : If True, rules are created only on root table |
| 819 |
""" |
| 820 |
max_actions = 8 |
| 821 |
self.client = Mlx5DrResources(qp_count=max_actions, **self.dev_info) |
| 822 |
self.server = Mlx5DrResources(qp_count=max_actions, **self.dev_info) |
| 823 |
self.domain_rx = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 824 |
actions = [] |
| 825 |
dest_attrs = [] |
| 826 |
for qp in self.server.qps[:-1]: |
| 827 |
qp_action = DrActionQp(qp) |
| 828 |
actions.append(qp_action) |
| 829 |
dest_attrs.append(DrActionDestAttr(mlx5dv_dr_action_dest_type.MLX5DV_DR_ACTION_DEST, qp_action)) |
| 830 |
ft_action = DrTable(self.domain_rx, 0xff) |
| 831 |
last_table_action = DrActionDestTable(ft_action) |
| 832 |
smac_mask = bytes([0xff] * 6) + bytes(2) |
| 833 |
mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask) |
| 834 |
last_matcher = DrMatcher(ft_action, 1, u.MatchCriteriaEnable.OUTER, mask_param) |
| 835 |
dest_attrs.append(DrActionDestAttr(mlx5dv_dr_action_dest_type.MLX5DV_DR_ACTION_DEST, last_table_action)) |
| 836 |
last_qp_action = DrActionQp(self.server.qps[max_actions - 1]) |
| 837 |
smac_value = struct.pack('!6s2s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')), |
| 838 |
bytes(2)) |
| 839 |
value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value) |
| 840 |
self.rules.append(DrRule(last_matcher, value_param, [last_qp_action])) |
| 841 |
multi_dest_a = DrActionDestArray(self.domain_rx, len(dest_attrs), dest_attrs) |
| 842 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 843 |
self.create_rx_recv_rules(smac_value, [multi_dest_a], domain=self.domain_rx, |
| 844 |
root_only=root_only) |
| 845 |
u.raw_traffic(self.client, self.server, self.iters) |
| 846 |
|
| 847 |
@skip_unsupported |
| 848 |
@requires_root() |
| 849 |
def test_root_dest_array(self): |
| 850 |
""" |
| 851 |
Creates RX domain, root table with matcher on source mac.on root table |
| 852 |
add a rule with multi dest array action which include destination QP actions and |
| 853 |
next FT (also with QP action). |
| 854 |
Validate on all QPs the received packets. |
| 855 |
""" |
| 856 |
self.dest_array(root_only=True) |
| 857 |
|
| 858 |
@skip_unsupported |
| 859 |
@requires_root() |
| 860 |
def test_dest_array(self): |
| 861 |
""" |
| 862 |
Creates RX domain, non-root table with matcher on source mac. Create a rule |
| 863 |
to forward all traffic to the non-root table. On this table add a rule |
| 864 |
with multi dest array action which include destination QP actions and |
| 865 |
next FT (also with QP action). |
| 866 |
Validate on all QPs the received packets. |
| 867 |
""" |
| 868 |
self.dest_array() |
| 869 |
|
| 870 |
@skip_unsupported |
| 871 |
@requires_root() |
| 872 |
def test_tx_def_miss_action(self): |
| 873 |
""" |
| 874 |
Create TX root table and forward all traffic to next SW steering table, |
| 875 |
create two matchers with different priorities, one with default miss |
| 876 |
action (on TX it's go to wire action) and one with drop action, default |
| 877 |
miss action should occur before the drop action hence packets |
| 878 |
should reach server side which has RX rule with QP action. |
| 879 |
""" |
| 880 |
self.create_players(Mlx5DrResources) |
| 881 |
self.domain_tx = DrDomain(self.client.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX) |
| 882 |
tx_def_miss = DrActionDefMiss() |
| 883 |
tx_drop_action = DrActionDrop() |
| 884 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 885 |
self.tx_table, self.tx_dest_act = self.create_rx_recv_rules(smac_value, [tx_def_miss], |
| 886 |
domain=self.domain_tx) |
| 887 |
qp_action = DrActionQp(self.server.qp) |
| 888 |
self.create_rx_recv_rules(smac_value, [qp_action]) |
| 889 |
smac_mask = bytes([0xff] * 6) + bytes(2) |
| 890 |
mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask) |
| 891 |
matcher_tx2 = DrMatcher(self.tx_table, 2, u.MatchCriteriaEnable.OUTER, mask_param) |
| 892 |
smac_value += bytes(2) |
| 893 |
value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value) |
| 894 |
self.rules.append(DrRule(matcher_tx2, value_param, [tx_drop_action])) |
| 895 |
u.raw_traffic(self.client, self.server, self.iters) |
| 896 |
|
| 897 |
@skip_unsupported |
| 898 |
def add_dest_tir_action_send_pkts(self, root_only=False): |
| 899 |
""" |
| 900 |
:param root_only: If True, rules are created only on root table |
| 901 |
""" |
| 902 |
self.client = Mlx5DrTirResources(**self.dev_info) |
| 903 |
self.server = Mlx5DrTirResources(**self.dev_info, server=True) |
| 904 |
tir_action = DrActionDestTir(self.server.tir) |
| 905 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 906 |
self.create_rx_recv_rules(smac_value, [tir_action], root_only=root_only) |
| 907 |
u.raw_traffic(self.client, self.server, self.iters) |
| 908 |
|
| 909 |
@skip_unsupported |
| 910 |
@requires_root() |
| 911 |
def test_dest_tir(self): |
| 912 |
self.add_dest_tir_action_send_pkts() |
| 913 |
|
| 914 |
@skip_unsupported |
| 915 |
def test_root_dest_tir(self): |
| 916 |
self.add_dest_tir_action_send_pkts(root_only=True) |
| 917 |
|
| 918 |
def packet_reformat_actions(self, outer, root_only=False, l2_ref_type=True): |
| 919 |
""" |
| 920 |
Creates packet reformat actions on TX (encap) and on RX (decap). |
| 921 |
:param outer: The outer header to encap. |
| 922 |
:param root_only: If True create actions only on root tables |
| 923 |
:param l2_ref_type: If False use L2 to L3 tunneling reformat |
| 924 |
""" |
| 925 |
smac_mask = bytes([0xff] * 6) + bytes(2) |
| 926 |
mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask) |
| 927 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 928 |
value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value) |
| 929 |
reformat_flag = mlx5dv_dr_action_flags.MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL if root_only else 0 |
| 930 |
# TX |
| 931 |
domain_tx = DrDomain(self.client.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX) |
| 932 |
tx_root_table = DrTable(domain_tx, 0) |
| 933 |
tx_root_matcher = DrMatcher(tx_root_table, 0, u.MatchCriteriaEnable.OUTER, mask_param) |
| 934 |
if not root_only: |
| 935 |
tx_table = DrTable(domain_tx, 1) |
| 936 |
tx_matcher = DrMatcher(tx_table, 1, u.MatchCriteriaEnable.OUTER, mask_param) |
| 937 |
dest_table_action_tx = DrActionDestTable(tx_table) |
| 938 |
self.rules.append(DrRule(tx_root_matcher, value_param, [dest_table_action_tx])) |
| 939 |
reformat_matcher = tx_root_matcher if root_only else tx_matcher |
| 940 |
# Create encap action |
| 941 |
tx_reformat_type = MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL_ if \ |
| 942 |
l2_ref_type else MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL_ |
| 943 |
reformat_action_tx = DrActionPacketReformat(domain=domain_tx, flags=reformat_flag, |
| 944 |
reformat_type=tx_reformat_type, data=outer) |
| 945 |
smac_value_tx = smac_value + bytes(2) |
| 946 |
value_param = Mlx5FlowMatchParameters(len(smac_value_tx), smac_value_tx) |
| 947 |
self.rules.append(DrRule(reformat_matcher, value_param, [reformat_action_tx])) |
| 948 |
# RX |
| 949 |
domain_rx = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 950 |
# Create decap action |
| 951 |
data = struct.pack('!6s6s', |
| 952 |
bytes.fromhex(PacketConsts.DST_MAC.replace(':', '')), |
| 953 |
bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 954 |
data += PacketConsts.ETHER_TYPE_IPV4.to_bytes(2, 'big') |
| 955 |
rx_reformat_type = MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2_ if \ |
| 956 |
l2_ref_type else MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2_ |
| 957 |
reformat_action_rx = DrActionPacketReformat(domain=domain_rx, flags=reformat_flag, |
| 958 |
reformat_type=rx_reformat_type, |
| 959 |
data=None if l2_ref_type else data) |
| 960 |
qp_action = DrActionQp(self.server.qp) |
| 961 |
if root_only: |
| 962 |
rx_root_table = DrTable(domain_rx, 0) |
| 963 |
rx_root_matcher = DrMatcher(rx_root_table, 0, u.MatchCriteriaEnable.OUTER, mask_param) |
| 964 |
self.rules.append(DrRule(rx_root_matcher, value_param, [reformat_action_rx, qp_action])) |
| 965 |
else: |
| 966 |
self.create_rx_recv_rules(smac_value, [reformat_action_rx, qp_action], domain=domain_rx) |
| 967 |
|
| 968 |
# Send traffic and validate packet |
| 969 |
u.raw_traffic(self.client, self.server, self.iters) |
| 970 |
|
| 971 |
@skip_unsupported |
| 972 |
@requires_root() |
| 973 |
def test_flow_sampler(self): |
| 974 |
""" |
| 975 |
Flow sampler has a default table (all the packets are forwarded to it) |
| 976 |
and a sampler actions (for sampled packets) |
| 977 |
The default table has counter action. |
| 978 |
For NIC RX table sampler actions are counter and TIR. |
| 979 |
Verify that default counter counts all the packets. |
| 980 |
Verify that sampled packets counter and receiving them on QP(from TIR) |
| 981 |
""" |
| 982 |
self.client = Mlx5DrTirResources(**self.dev_info) |
| 983 |
self.server = Mlx5DrTirResources(**self.dev_info, server=True) |
| 984 |
self.iters = 1000 |
| 985 |
# Create tir & counter actions for sampler attr |
| 986 |
tir_action = DrActionDestTir(self.server.tir) |
| 987 |
counter_1, flow_counter_id_1 = self.create_counter(self.server.ctx) |
| 988 |
self.server_counter_action = DrActionFlowCounter(counter_1) |
| 989 |
# Create resources |
| 990 |
smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 991 |
rx_domain = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 992 |
default_tbl = DrTable(rx_domain, 2) |
| 993 |
# Create sampler action on NIC RX table |
| 994 |
sample_actions = [self.server_counter_action, tir_action] |
| 995 |
sampler_attr = DrFlowSamplerAttr(sample_ratio=SAMPLE_RATIO, default_next_table=default_tbl, |
| 996 |
sample_actions=sample_actions) |
| 997 |
sampler_action = DrActionFlowSample(sampler_attr) |
| 998 |
tbl, _ = self.create_rx_recv_rules(smac_value, [sampler_action], domain=rx_domain) |
| 999 |
smac_mask = bytes([0xff] * 6) + bytes(2) |
| 1000 |
mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask) |
| 1001 |
self.default_matcher = DrMatcher(default_tbl, 1, u.MatchCriteriaEnable.OUTER, mask_param) |
| 1002 |
# Size of the matcher value should be modulo 4 |
| 1003 |
smac_value += bytes(2) |
| 1004 |
value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value) |
| 1005 |
# Create Counter action on default table |
| 1006 |
counter_2, flow_counter_id_2 = self.create_counter(self.server.ctx) |
| 1007 |
self.server_counter_action_2 = DrActionFlowCounter(counter_2) |
| 1008 |
self.rules.append(DrRule(self.default_matcher, value_param, [self.server_counter_action_2])) |
| 1009 |
# Send traffic and validate packet |
| 1010 |
u.sampler_traffic(self.client, self.server, self.iters) |
| 1011 |
recv_packets = self.query_counter_packets(counter=counter_1, |
| 1012 |
flow_counter_id=flow_counter_id_1) |
| 1013 |
exp_packets = math.ceil((self.iters / SAMPLE_RATIO)) |
| 1014 |
max_exp_packets = int(exp_packets * (1 + SAMPLER_ERROR_MARGIN)) |
| 1015 |
min_exp_packets = int(exp_packets * (1 - SAMPLER_ERROR_MARGIN)) |
| 1016 |
is_sampled_packets_in_error_margin = min_exp_packets <= recv_packets <= max_exp_packets |
| 1017 |
self.assertTrue(is_sampled_packets_in_error_margin, |
| 1018 |
f'Expected sampled packets {exp_packets} is more than ' |
| 1019 |
f'{SAMPLER_ERROR_MARGIN * 100}% \ndiffernt from actual {recv_packets}') |
| 1020 |
recv_packets_from_default_tbl = \ |
| 1021 |
self.query_counter_packets(counter=counter_2, flow_counter_id=flow_counter_id_2) |
| 1022 |
self.assertEqual(recv_packets_from_default_tbl, self.iters, |
| 1023 |
'Counter on default table missed some recv packets') |
| 1024 |
|
| 1025 |
@skip_unsupported |
| 1026 |
def geneve_match_rx(self, root_only=False): |
| 1027 |
""" |
| 1028 |
Creates matcher on RX to match on Geneve related fields with counter and qp action, |
| 1029 |
sends packets and verifies the matcher. |
| 1030 |
:param root_only: If True, rules are created only on root table |
| 1031 |
""" |
| 1032 |
self.create_players(Mlx5DrResources) |
| 1033 |
geneve_mask, geneve_val = self.create_geneve_params() |
| 1034 |
domain_rx = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 1035 |
counter, flow_counter_id = self.create_counter(self.server.ctx) |
| 1036 |
self.server_counter_action = DrActionFlowCounter(counter) |
| 1037 |
self.qp_action = DrActionQp(self.server.qp) |
| 1038 |
self.create_rx_recv_rules_based_on_match_params(geneve_mask, geneve_val, |
| 1039 |
[self.qp_action, self.server_counter_action], |
| 1040 |
match_criteria=u.MatchCriteriaEnable.MISC, |
| 1041 |
domain=domain_rx, root_only=root_only) |
| 1042 |
inner_msg_size = self.client.msg_size - GENEVE_PACKET_OUTER_LENGTH |
| 1043 |
outer = self.gen_geneve_tunnel_encap_header(inner_msg_size) |
| 1044 |
packet_to_send = outer + u.gen_packet(msg_size=inner_msg_size) |
| 1045 |
# Send traffic and validate packet |
| 1046 |
u.raw_traffic(self.client, self.server, self.iters, packet_to_send=packet_to_send) |
| 1047 |
recv_packets_rx = self.query_counter_packets(counter, flow_counter_id) |
| 1048 |
self.assertEqual(recv_packets_rx, self.iters, 'Counter rx missed some recv packets') |
| 1049 |
src_mac = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 1050 |
self.send_client_raw_packets(self.iters, src_mac=src_mac) |
| 1051 |
recv_packets_rx = self.query_counter_packets(counter, flow_counter_id) |
| 1052 |
self.assertEqual(recv_packets_rx, self.iters, |
| 1053 |
'Counter rx counts more than expected recv packets') |
| 1054 |
|
| 1055 |
@requires_geneve_fields_rx_support |
| 1056 |
def test_root_geneve_match_rx(self): |
| 1057 |
""" |
| 1058 |
Creates matcher on RX root table to match on Geneve related fields |
| 1059 |
with counter and qp action, sends packets and verifies the matcher. |
| 1060 |
""" |
| 1061 |
self.geneve_match_rx(root_only=True) |
| 1062 |
|
| 1063 |
@requires_geneve_fields_rx_support |
| 1064 |
@requires_root() |
| 1065 |
def test_geneve_match_rx(self): |
| 1066 |
""" |
| 1067 |
Creates matcher on RX non-root table to match on Geneve related |
| 1068 |
fields with counter and qp action, sends packets and verifies the matcher. |
| 1069 |
""" |
| 1070 |
self.geneve_match_rx() |
| 1071 |
|
| 1072 |
@skip_unsupported |
| 1073 |
def test_geneve_match_tx(self): |
| 1074 |
""" |
| 1075 |
Creates matcher on TX to match on Geneve related fields with counter action, |
| 1076 |
sends packets and verifies the matcher. |
| 1077 |
""" |
| 1078 |
from tests.mlx5_prm_structs import FlowTableEntryMatchParamSW |
| 1079 |
self.create_players(Mlx5DrResources) |
| 1080 |
skip_if_has_geneve_tx_bug(self.client.ctx) |
| 1081 |
geneve_mask, geneve_val = self.create_geneve_params() |
| 1082 |
# TX |
| 1083 |
self.domain_tx = DrDomain(self.client.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX) |
| 1084 |
tx_root_table = DrTable(self.domain_tx, 0) |
| 1085 |
tx_root_matcher = DrMatcher(tx_root_table, 0, u.MatchCriteriaEnable.MISC, geneve_mask) |
| 1086 |
tx_table = DrTable(self.domain_tx, 1) |
| 1087 |
self.tx_matcher = DrMatcher(tx_table, 1, u.MatchCriteriaEnable.MISC, geneve_mask) |
| 1088 |
counter, flow_counter_id = self.create_counter(self.client.ctx) |
| 1089 |
self.client_counter_action = DrActionFlowCounter(counter) |
| 1090 |
self.dest_table_action_tx = DrActionDestTable(tx_table) |
| 1091 |
self.rules.append(DrRule(tx_root_matcher, geneve_val, [self.dest_table_action_tx])) |
| 1092 |
self.rules.append(DrRule(self.tx_matcher, geneve_val, [self.client_counter_action])) |
| 1093 |
# RX |
| 1094 |
domain_rx = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 1095 |
self.qp_action = DrActionQp(self.server.qp) |
| 1096 |
empty_param = Mlx5FlowMatchParameters(len(FlowTableEntryMatchParamSW()), |
| 1097 |
FlowTableEntryMatchParamSW()) |
| 1098 |
self.create_rx_recv_rules_based_on_match_params\ |
| 1099 |
(empty_param, empty_param, [self.qp_action], |
| 1100 |
match_criteria=u.MatchCriteriaEnable.NONE, domain=domain_rx) |
| 1101 |
inner_msg_size = self.client.msg_size - GENEVE_PACKET_OUTER_LENGTH |
| 1102 |
outer = self.gen_geneve_tunnel_encap_header(inner_msg_size) |
| 1103 |
packet_to_send = outer + u.gen_packet(msg_size=inner_msg_size) |
| 1104 |
# Send traffic and validate packet |
| 1105 |
u.raw_traffic(self.client, self.server, self.iters, packet_to_send=packet_to_send) |
| 1106 |
recv_packets_tx = self.query_counter_packets(counter, flow_counter_id) |
| 1107 |
self.assertEqual(recv_packets_tx, self.iters, 'Counter tx missed some recv packets') |
| 1108 |
src_mac = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 1109 |
self.send_client_raw_packets(self.iters, src_mac=src_mac) |
| 1110 |
recv_packets_tx = self.query_counter_packets(counter, flow_counter_id) |
| 1111 |
self.assertEqual(recv_packets_tx, self.iters, |
| 1112 |
'Counter tx counts more than expected recv packets') |
| 1113 |
|
| 1114 |
def roce_bth_match(self, domain_flag=mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX): |
| 1115 |
""" |
| 1116 |
Creates RoCE BTH rule on RX/TX domain. For RX domain, will match on BTH related |
| 1117 |
fields with counter and qp action. For TX domain, will match on BTH relate fields |
| 1118 |
with counter action. And then generate and send RoCE BTH hit and miss traffic according |
| 1119 |
to the matcher and validate the result. |
| 1120 |
:param domain_flag: RX/TX Domain for the test. |
| 1121 |
""" |
| 1122 |
from tests.mlx5_prm_structs import FlowTableEntryMatchParamSW |
| 1123 |
self.create_players(Mlx5DrResources) |
| 1124 |
roce_bth_mask, roce_bth_val = self.create_roce_bth_params() |
| 1125 |
empty_param = Mlx5FlowMatchParameters(len(FlowTableEntryMatchParamSW()), |
| 1126 |
FlowTableEntryMatchParamSW()) |
| 1127 |
self.domain = DrDomain(self.server.ctx, domain_flag) |
| 1128 |
root_table = DrTable(self.domain, 0) |
| 1129 |
root_matcher = DrMatcher(root_table, 0, u.MatchCriteriaEnable.NONE, empty_param) |
| 1130 |
table = DrTable(self.domain, 1) |
| 1131 |
self.matcher = DrMatcher(table, 1, u.MatchCriteriaEnable.MISC, roce_bth_mask) |
| 1132 |
if domain_flag == mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX: |
| 1133 |
counter, flow_counter_id = self.create_counter(self.server.ctx) |
| 1134 |
else: |
| 1135 |
counter, flow_counter_id = self.create_counter(self.client.ctx) |
| 1136 |
self.dest_tbl_action = DrActionDestTable(table) |
| 1137 |
self.qp_action = DrActionQp(self.server.qp) |
| 1138 |
self.counter_action = DrActionFlowCounter(counter) |
| 1139 |
self.rules.append(DrRule(root_matcher, empty_param, [self.dest_tbl_action])) |
| 1140 |
if domain_flag == mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX: |
| 1141 |
self.rules.append(DrRule(self.matcher, roce_bth_val, [self.qp_action, self.counter_action])) |
| 1142 |
else: |
| 1143 |
self.rules.append(DrRule(self.matcher, roce_bth_val, [self.counter_action])) |
| 1144 |
if domain_flag == mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX: |
| 1145 |
domain_rx = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 1146 |
self.create_rx_recv_rules_based_on_match_params\ |
| 1147 |
(empty_param, empty_param, [self.qp_action], |
| 1148 |
match_criteria=u.MatchCriteriaEnable.NONE, domain=domain_rx) |
| 1149 |
inner_msg_size = self.client.msg_size - ROCE_PACKET_OUTER_LENGTH |
| 1150 |
outer = self.gen_roce_bth_header(inner_msg_size) |
| 1151 |
packet_to_send = outer + u.gen_packet(msg_size=inner_msg_size) |
| 1152 |
# Send traffic hit the rule and validate by the counter action |
| 1153 |
u.raw_traffic(self.client, self.server, self.iters, packet_to_send=packet_to_send) |
| 1154 |
recv_packets = self.query_counter_packets(counter, flow_counter_id) |
| 1155 |
self.assertEqual(recv_packets, self.iters, 'Counter missed some recv packets') |
| 1156 |
# Send traffic miss the rule and validate by the counter action |
| 1157 |
src_mac = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 1158 |
self.send_client_raw_packets(self.iters, src_mac=src_mac) |
| 1159 |
recv_packets = self.query_counter_packets(counter, flow_counter_id) |
| 1160 |
self.assertEqual(recv_packets, self.iters, |
| 1161 |
'Counter counts more than expected recv packets') |
| 1162 |
|
| 1163 |
@u.requires_roce_disabled |
| 1164 |
@skip_unsupported |
| 1165 |
def test_roce_bth_match_rx(self): |
| 1166 |
""" |
| 1167 |
Verify RX matching on RoCE BTH. |
| 1168 |
""" |
| 1169 |
self.roce_bth_match() |
| 1170 |
|
| 1171 |
@u.requires_roce_disabled |
| 1172 |
@skip_unsupported |
| 1173 |
def test_roce_bth_match_tx(self): |
| 1174 |
""" |
| 1175 |
Verify TX matching on RoCE BTH. |
| 1176 |
""" |
| 1177 |
self.roce_bth_match(domain_flag=mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX) |
| 1178 |
|
| 1179 |
@skip_unsupported |
| 1180 |
@requires_root() |
| 1181 |
def test_packet_reformat_l2_gre(self): |
| 1182 |
""" |
| 1183 |
Creates GRE packet with non-root l2 to l2 reformat actions on TX (encap) |
| 1184 |
and on RX (decap). |
| 1185 |
""" |
| 1186 |
self.create_players(Mlx5DrResources) |
| 1187 |
encap_header = self.gen_gre_tunnel_encap_header(self.client.msg_size, is_l2_tunnel=True) |
| 1188 |
self.packet_reformat_actions(outer=encap_header) |
| 1189 |
|
| 1190 |
@requires_reformat_support |
| 1191 |
@u.requires_encap_disabled_if_eswitch_on |
| 1192 |
@skip_unsupported |
| 1193 |
def test_packet_reformat_root_l2_gre(self): |
| 1194 |
""" |
| 1195 |
Creates GRE packet with root l2 to l2 reformat actions on TX (encap) and |
| 1196 |
on RX (decap). |
| 1197 |
""" |
| 1198 |
self.create_players(Mlx5DrResources) |
| 1199 |
encap_header = self.gen_gre_tunnel_encap_header(self.client.msg_size, is_l2_tunnel=True) |
| 1200 |
self.packet_reformat_actions(outer=encap_header, root_only=True) |
| 1201 |
|
| 1202 |
@skip_unsupported |
| 1203 |
@requires_root() |
| 1204 |
def test_packet_reformat_l3_gre(self): |
| 1205 |
""" |
| 1206 |
Creates GRE packet with non-root l2 to l3 reformat actions on TX (encap) |
| 1207 |
and on RX (decap). |
| 1208 |
""" |
| 1209 |
self.create_players(Mlx5DrResources) |
| 1210 |
encap_header = self.gen_gre_tunnel_encap_header(self.client.msg_size, is_l2_tunnel=False) |
| 1211 |
self.packet_reformat_actions(outer=encap_header, l2_ref_type=False) |
| 1212 |
|
| 1213 |
@requires_reformat_support |
| 1214 |
@u.requires_encap_disabled_if_eswitch_on |
| 1215 |
@skip_unsupported |
| 1216 |
def test_packet_reformat_root_l3_gre(self): |
| 1217 |
""" |
| 1218 |
Creates GRE packet with root l2 to l3 reformat actions on TX (encap) and |
| 1219 |
on RX (decap). |
| 1220 |
""" |
| 1221 |
self.create_players(Mlx5DrResources) |
| 1222 |
encap_header = self.gen_gre_tunnel_encap_header(self.client.msg_size, is_l2_tunnel=False) |
| 1223 |
self.packet_reformat_actions(outer=encap_header, root_only=True, l2_ref_type=False) |
| 1224 |
|
| 1225 |
@skip_unsupported |
| 1226 |
@requires_root() |
| 1227 |
def test_packet_reformat_l2_geneve(self): |
| 1228 |
""" |
| 1229 |
Creates Geneve packet with non-root l2 to l2 reformat actions on TX |
| 1230 |
(encap) and on RX (decap). |
| 1231 |
""" |
| 1232 |
self.create_players(Mlx5DrResources) |
| 1233 |
encap_header = self.gen_geneve_tunnel_encap_header(self.client.msg_size, is_l2_tunnel=True) |
| 1234 |
self.packet_reformat_actions(outer=encap_header) |
| 1235 |
|
| 1236 |
@requires_reformat_support |
| 1237 |
@u.requires_encap_disabled_if_eswitch_on |
| 1238 |
@skip_unsupported |
| 1239 |
def test_packet_reformat_root_l2_geneve(self): |
| 1240 |
""" |
| 1241 |
Creates Geneve packet with root l2 to l2 reformat actions on TX (encap) |
| 1242 |
and on RX (decap). |
| 1243 |
""" |
| 1244 |
self.create_players(Mlx5DrResources) |
| 1245 |
encap_header = self.gen_geneve_tunnel_encap_header(self.client.msg_size, is_l2_tunnel=True) |
| 1246 |
self.packet_reformat_actions(outer=encap_header, root_only=True) |
| 1247 |
|
| 1248 |
@skip_unsupported |
| 1249 |
@requires_root() |
| 1250 |
def test_packet_reformat_l3_geneve(self): |
| 1251 |
""" |
| 1252 |
Creates Geneve packet with non-root l2 to l3 tunnel reformat actions on |
| 1253 |
TX (encap) and on RX (decap). |
| 1254 |
""" |
| 1255 |
self.create_players(Mlx5DrResources) |
| 1256 |
encap_header = self.gen_geneve_tunnel_encap_header(self.client.msg_size, is_l2_tunnel=False) |
| 1257 |
self.packet_reformat_actions(outer=encap_header, l2_ref_type=False) |
| 1258 |
|
| 1259 |
@requires_reformat_support |
| 1260 |
@u.requires_encap_disabled_if_eswitch_on |
| 1261 |
@skip_unsupported |
| 1262 |
def test_packet_reformat_root_l3_geneve(self): |
| 1263 |
""" |
| 1264 |
Creates Geneve packet with root l2 to l3 reformat actions on TX (encap) |
| 1265 |
and on RX (decap). |
| 1266 |
""" |
| 1267 |
self.create_players(Mlx5DrResources) |
| 1268 |
encap_header = self.gen_geneve_tunnel_encap_header(self.client.msg_size, is_l2_tunnel=False) |
| 1269 |
self.packet_reformat_actions(outer=encap_header, root_only=True, l2_ref_type=False) |
| 1270 |
|
| 1271 |
@skip_unsupported |
| 1272 |
@requires_root() |
| 1273 |
def test_flow_meter(self): |
| 1274 |
""" |
| 1275 |
Create flow meter actions on TX and RX non-root tables. Add green and |
| 1276 |
red counters to the meter rules to verify the packets split to different |
| 1277 |
colors. Send minimal traffic to see that both counters increased. |
| 1278 |
""" |
| 1279 |
from tests.mlx5_prm_structs import FlowTableEntryMatchParamSW, FlowTableEntryMatchSetMisc2,\ |
| 1280 |
FlowMeterParams |
| 1281 |
self.create_players(Mlx5DrResources) |
| 1282 |
# Common resources |
| 1283 |
matcher_len = len(FlowTableEntryMatchParamSW()) |
| 1284 |
empty_param = Mlx5FlowMatchParameters(matcher_len, FlowTableEntryMatchParamSW()) |
| 1285 |
reg_c_idx = self.client.get_first_flow_meter_reg_id() |
| 1286 |
reg_c_field = METADATA_C_FIELDS[reg_c_idx] |
| 1287 |
meter_param = FlowMeterParams(valid=0x1, bucket_overflow=0x1, start_color=0x2, |
| 1288 |
cir_mantissa=1, cir_exponent=6) # 15.625MBps |
| 1289 |
reg_c_mask = Mlx5FlowMatchParameters(matcher_len, FlowTableEntryMatchParamSW( |
| 1290 |
misc_parameters_2=FlowTableEntryMatchSetMisc2(**{reg_c_field: 0xffffffff}))) |
| 1291 |
reg_c_green = Mlx5FlowMatchParameters(matcher_len, FlowTableEntryMatchParamSW( |
| 1292 |
misc_parameters_2=FlowTableEntryMatchSetMisc2(**{reg_c_field: FLOW_METER_GREEN}))) |
| 1293 |
reg_c_red = Mlx5FlowMatchParameters(matcher_len, FlowTableEntryMatchParamSW( |
| 1294 |
misc_parameters_2=FlowTableEntryMatchSetMisc2(**{reg_c_field: FLOW_METER_RED}))) |
| 1295 |
|
| 1296 |
self.client.domain = DrDomain(self.client.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX) |
| 1297 |
self.server.domain = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 1298 |
|
| 1299 |
for player in [self.client, self.server]: |
| 1300 |
player.root_table = DrTable(player.domain, 0) |
| 1301 |
player.table = DrTable(player.domain, 1) |
| 1302 |
player.next_table = DrTable(player.domain, 2) |
| 1303 |
player.root_matcher = DrMatcher(player.root_table, 0, u.MatchCriteriaEnable.NONE, |
| 1304 |
empty_param) |
| 1305 |
player.matcher = DrMatcher(player.table, 0, u.MatchCriteriaEnable.NONE, empty_param) |
| 1306 |
player.reg_c_matcher = DrMatcher(player.next_table, 2, u.MatchCriteriaEnable.MISC_2, |
| 1307 |
reg_c_mask) |
| 1308 |
meter_attr = DrFlowMeterAttr(player.next_table, 1, reg_c_idx, meter_param) |
| 1309 |
player.meter_action = DrActionFlowMeter(meter_attr) |
| 1310 |
player.dest_action = DrActionDestTable(player.table) |
| 1311 |
self.rules.append(DrRule(player.root_matcher, empty_param, [player.dest_action])) |
| 1312 |
self.rules.append(DrRule(player.matcher, empty_param, [player.meter_action])) |
| 1313 |
player.counter_green, player.flow_counter_id_green = self.create_counter(player.ctx) |
| 1314 |
player.counter_action_green = DrActionFlowCounter(player.counter_green) |
| 1315 |
player.counter_red, player.flow_counter_id_red = self.create_counter(player.ctx) |
| 1316 |
player.counter_action_red = DrActionFlowCounter(player.counter_red) |
| 1317 |
self.rules.append(DrRule(player.reg_c_matcher, reg_c_green, |
| 1318 |
[player.counter_action_green])) |
| 1319 |
self.rules.append(DrRule(player.reg_c_matcher, reg_c_red, [player.counter_action_red])) |
| 1320 |
|
| 1321 |
packet = u.gen_packet(self.client.msg_size) |
| 1322 |
# We want to send at least at 30MBps speed |
| 1323 |
rate_limit = 30 |
| 1324 |
u.high_rate_send(self.client, packet, rate_limit) |
| 1325 |
|
| 1326 |
for name, player in {'client': self.client, 'server': self.server}.items(): |
| 1327 |
green_packets = self.query_counter_packets(player.counter_green, |
| 1328 |
player.flow_counter_id_green) |
| 1329 |
red_packets = self.query_counter_packets(player.counter_red, player.flow_counter_id_red) |
| 1330 |
self.assertTrue(green_packets > 0, f'No packet of {name} got green color') |
| 1331 |
self.assertTrue(red_packets > 0, f'No packet of {name} got red color') |
| 1332 |
|
| 1333 |
def fwd_packets_to_table(self, src_table, dst_table): |
| 1334 |
""" |
| 1335 |
Forward all traffic from one table to another using empty matcher |
| 1336 |
:param src_table: Source table |
| 1337 |
:param dst_table: Destination table |
| 1338 |
:return: DrActionDestTable used to move the packets from src_table to dst_table |
| 1339 |
""" |
| 1340 |
from tests.mlx5_prm_structs import FlowTableEntryMatchParamSW |
| 1341 |
empty_param = Mlx5FlowMatchParameters(len(FlowTableEntryMatchParamSW()), |
| 1342 |
FlowTableEntryMatchParamSW()) |
| 1343 |
matcher = DrMatcher(src_table, 0, u.MatchCriteriaEnable.NONE, empty_param) |
| 1344 |
dest_table_action = DrActionDestTable(dst_table) |
| 1345 |
self.rules.append(DrRule(matcher, empty_param, [dest_table_action])) |
| 1346 |
return dest_table_action |
| 1347 |
|
| 1348 |
def gen_two_smac_rules(self, table, actions): |
| 1349 |
""" |
| 1350 |
Generate two rules that match over different smacs values. |
| 1351 |
The rules use the same actions and matchers. |
| 1352 |
:param table: The table the rules are applied on |
| 1353 |
:param actions: SMAC rule actions |
| 1354 |
:return: The two generated smacs |
| 1355 |
""" |
| 1356 |
smac_mask = bytes([0xff] * 6) + bytes(2) |
| 1357 |
mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask) |
| 1358 |
matcher = DrMatcher(table, 0, u.MatchCriteriaEnable.OUTER, mask_param) |
| 1359 |
src_mac_1 = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', ''))) |
| 1360 |
src_mac_2 = struct.pack('!6s', bytes.fromhex("88:88:88:88:88:88".replace(':', ''))) |
| 1361 |
src_mac_1_for_matcher = src_mac_1 + bytes(2) |
| 1362 |
src_mac_2_for_matcher = src_mac_2 + bytes(2) |
| 1363 |
value_param_1 = Mlx5FlowMatchParameters(len(src_mac_1_for_matcher), src_mac_1_for_matcher) |
| 1364 |
value_param_2 = Mlx5FlowMatchParameters(len(src_mac_2_for_matcher), src_mac_2_for_matcher) |
| 1365 |
self.rules.append(DrRule(matcher, value_param_1, actions)) |
| 1366 |
self.rules.append(DrRule(matcher, value_param_2, actions)) |
| 1367 |
return src_mac_1, src_mac_2 |
| 1368 |
|
| 1369 |
def reuse_action_and_matcher(self, root_only=False): |
| 1370 |
""" |
| 1371 |
Creates rules with same matcher and actions, the rules match over different smacs. |
| 1372 |
Over TX side, creates rule to counter action, over RX side - creates rule to counter and |
| 1373 |
drop actions. Send traffic to match the rules, verify them by querying the counters. |
| 1374 |
:param root_only: If True, rules are created only on root table. |
| 1375 |
""" |
| 1376 |
self.create_players(Mlx5DrResources) |
| 1377 |
# Create TX resources |
| 1378 |
self.domain_tx = DrDomain(self.client.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_TX) |
| 1379 |
tx_root_table = DrTable(self.domain_tx, 0) |
| 1380 |
if not root_only: |
| 1381 |
tx_non_root_table = DrTable(self.domain_tx, 1) |
| 1382 |
tx_dest_table_action = self.fwd_packets_to_table(tx_root_table, tx_non_root_table) |
| 1383 |
tx_table = tx_root_table if root_only else tx_non_root_table |
| 1384 |
# Create client counter. |
| 1385 |
client_counter, tx_flow_counter_id = self.create_counter(self.client.ctx) |
| 1386 |
self.client_counter_action = DrActionFlowCounter(client_counter) |
| 1387 |
tx_actions = [self.client_counter_action] |
| 1388 |
self.gen_two_smac_rules(tx_table, tx_actions) |
| 1389 |
# Create RX resources |
| 1390 |
self.domain_rx = DrDomain(self.server.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 1391 |
rx_root_table = DrTable(self.domain_rx, 0) |
| 1392 |
if not root_only: |
| 1393 |
rx_non_root_table = DrTable(self.domain_rx, 1) |
| 1394 |
rx_dest_table_action = self.fwd_packets_to_table(rx_root_table, rx_non_root_table) |
| 1395 |
rx_table = rx_root_table if root_only else rx_non_root_table |
| 1396 |
# Create server counter. |
| 1397 |
server_counter, rx_flow_counter_id = self.create_counter(self.server.ctx) |
| 1398 |
self.server_counter_action = DrActionFlowCounter(server_counter) |
| 1399 |
self.rx_drop_action = DrActionDrop() |
| 1400 |
actions = [self.server_counter_action, self.rx_drop_action] |
| 1401 |
src_mac_1, src_mac_2 = self.gen_two_smac_rules(rx_table, actions) |
| 1402 |
# Send packets with two different smacs which are used and reused in action and matcher |
| 1403 |
self.send_client_raw_packets(int(self.iters / 2), src_mac=src_mac_1) |
| 1404 |
self.send_client_raw_packets(int(self.iters / 2), src_mac=src_mac_2) |
| 1405 |
matched_packets_tx = self.query_counter_packets(client_counter, tx_flow_counter_id) |
| 1406 |
self.assertEqual(matched_packets_tx, self.iters, 'Reuse action or matcher failed on TX') |
| 1407 |
matched_packets_rx = self.query_counter_packets(server_counter, rx_flow_counter_id) |
| 1408 |
self.assertEqual(matched_packets_rx, self.iters, 'Reuse action or matcher failed on RX') |
| 1409 |
|
| 1410 |
@skip_unsupported |
| 1411 |
@requires_flow_counter_support |
| 1412 |
def test_root_reuse_action_and_matcher(self): |
| 1413 |
""" |
| 1414 |
Create root rules on TX and RX that use the same matcher and actions |
| 1415 |
""" |
| 1416 |
self.reuse_action_and_matcher(root_only=True) |
| 1417 |
|
| 1418 |
@skip_unsupported |
| 1419 |
@requires_root() |
| 1420 |
def test_reuse_action_and_matcher(self): |
| 1421 |
""" |
| 1422 |
Create non-root rules on TX and RX that use the same matcher and actions |
| 1423 |
""" |
| 1424 |
self.reuse_action_and_matcher() |
| 1425 |
|
| 1426 |
|
| 1427 |
class Mlx5DrDumpTest(PyverbsAPITestCase): |
| 1428 |
def setUp(self): |
| 1429 |
super().setUp() |
| 1430 |
self.res = None |
| 1431 |
|
| 1432 |
def tearDown(self): |
| 1433 |
super().tearDown() |
| 1434 |
if self.res: |
| 1435 |
self.res.ctx.close() |
| 1436 |
|
| 1437 |
@skip_unsupported |
| 1438 |
def test_domain_dump(self): |
| 1439 |
dump_file = '/tmp/dump.txt' |
| 1440 |
self.res = Mlx5DrResources(self.dev_name, self.ib_port) |
| 1441 |
self.domain_rx = DrDomain(self.res.ctx, mlx5dv_dr_domain_type.MLX5DV_DR_DOMAIN_TYPE_NIC_RX) |
| 1442 |
self.domain_rx.dump(dump_file) |
| 1443 |
self.assertTrue(path.isfile(dump_file), 'Dump file does not exist.') |
| 1444 |
self.assertGreater(path.getsize(dump_file), 0, 'Dump file is empty') |