Skip to content

Commit

Permalink
tests: Extend rule creation on root tables
Browse files Browse the repository at this point in the history
Extend some functions to support rules creation on root tables

Signed-off-by: Elyashiv Cohen <[email protected]>
Signed-off-by: Edward Srouji <[email protected]>
  • Loading branch information
Elyashiv Cohen authored and EdwardSro committed Aug 1, 2023
1 parent 1bbeca5 commit 05216d8
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions tests/test_mlx5_dr.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ def tearDown(self):
@skip_unsupported
def create_rx_recv_rules_based_on_match_params(self, mask_param, val_param, actions,
match_criteria=u.MatchCriteriaEnable.OUTER,
domain=None, log_matcher_size=None):
domain=None, log_matcher_size=None,
root_only=False):
"""
Creates a rule on RX domain that forwards packets that match on the provided parameters
to the SW steering flow table and another rule on that table
Expand All @@ -185,40 +186,48 @@ def create_rx_recv_rules_based_on_match_params(self, mask_param, val_param, acti
:param match_criteria: the match criteria enable flag to match on
:param domain: RX DR domain to use if provided, otherwise create default RX domain.
:param log_matcher_size: Size of the matcher table
:return: Non root table and dest table action to it
:param root_only : If True, rules are created only on root table
:return: Non-root table and dest table action to it if root=false else root_table
"""
self.domain_rx = domain if domain else DrDomain(self.server.ctx,
dve.MLX5DV_DR_DOMAIN_TYPE_NIC_RX)
root_table = DrTable(self.domain_rx, 0)
table = DrTable(self.domain_rx, 1)
root_matcher = DrMatcher(root_table, 0, match_criteria, mask_param)
if not root_only:
non_root_table = DrTable(self.domain_rx, 1)
table = root_table if root_only else non_root_table
self.matcher = DrMatcher(table, 1, match_criteria, mask_param)
if log_matcher_size:
self.matcher.set_layout(log_matcher_size)
self.dest_table_action = DrActionDestTable(table)
self.rules.append(DrRule(root_matcher, val_param, [self.dest_table_action]))
self.rules.append(DrRule(self.matcher, val_param, actions))
return table, self.dest_table_action
if not root_only:
self.root_matcher = DrMatcher(root_table, 0, match_criteria, mask_param)
self.dest_table_action = DrActionDestTable(table)
self.rules.append(DrRule(self.root_matcher, val_param, [self.dest_table_action]))
return table, self.dest_table_action
return table

@skip_unsupported
def create_rx_recv_rules(self, smac_value, actions, log_matcher_size=None, domain=None):
def create_rx_recv_rules(self, smac_value, actions, log_matcher_size=None, domain=None,
root_only=False):
"""
Creates a rule on RX domain that forwards packets that match the smac in the matcher
to the SW steering flow table and another rule on that table with provided actions.
:param smac_value: The smac matcher value.
:param actions: List of actions to attach to the recv rule.
:param log_matcher_size: Size of the matcher table
:param domain: RX DR domain to use if provided, otherwise create default RX domain.
:return: Non root table and dest table action to it
:param root_only : If True, rules are created only on root table
:return: Non-root table and dest table action to it if root=false else root_table
"""
smac_mask = bytes([0xff] * 6) + bytes(2)
mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask)
# Size of the matcher value should be modulo 4
smac_value += bytes(2)
smac_value = smac_value if root_only else smac_value + bytes(2)
value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value)
return self.create_rx_recv_rules_based_on_match_params(mask_param, value_param, actions,
u.MatchCriteriaEnable.OUTER,
domain, log_matcher_size)
domain, log_matcher_size,
root_only=root_only)

@skip_unsupported
def create_tx_modify_rule(self):
Expand Down

0 comments on commit 05216d8

Please sign in to comment.