Skip to content

Commit

Permalink
tests: Check if geneve fields supported
Browse files Browse the repository at this point in the history
Before running geneve match rx test, check if the device
supports geneve fields.

Signed-off-by: Shachar Kagan <[email protected]>
Signed-off-by: Edward Srouji <[email protected]>
  • Loading branch information
ShacharKagan authored and EdwardSro committed Aug 1, 2023
1 parent 8b79085 commit d1c71a2
Show file tree
Hide file tree
Showing 3 changed files with 372 additions and 3 deletions.
336 changes: 336 additions & 0 deletions tests/mlx5_prm_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ class QueryHcaVportGidOut(Packet):

class QueryHcaCapOp:
HCA_CAP_2 = 0X20
HCA_NIC_FLOW_TABLE_CAP = 0x7


class QueryHcaCapMod:
Expand Down Expand Up @@ -1967,3 +1968,338 @@ class QueryQosCapOut(Packet):
StrFixedLenField('reserved2', None, length=8),
PadField(PacketField('capability', QosCaps(), QosCaps), 4096, padwith=b"\x00"),
]


class FlowTableFieldsSupported2(Packet):
fields_desc = [
BitField('reserved1', 0, 10),
BitField('lag_rx_port_affinity', 0, 1),
BitField('inner_esp_seq_num', 0, 1),
BitField('outer_esp_seq_num', 0, 1),
BitField('hash_result', 0, 1),
BitField('bth_opcode', 0, 1),
BitField('tunnel_header_2_3', 0, 1),
BitField('tunnel_header_0_1', 0, 1),
BitField('macsec_syndrome', 0, 1),
BitField('macsec_tag', 0, 1),
BitField('outer_lrh_sl', 0, 1),
BitField('inner_ipv4_ihl', 0, 1),
BitField('outer_ipv4_ihl', 0, 1),
BitField('nisp_syndrome', 0, 1),
BitField('inner_l3_ok', 0, 1),
BitField('inner_l4_ok', 0, 1),
BitField('outer_l3_ok', 0, 1),
BitField('outer_l4_ok', 0, 1),
BitField('nisp_header', 0, 1),
BitField('inner_ipv4_checksum_ok', 0, 1),
BitField('inner_l4_checksum_ok', 0, 1),
BitField('outer_ipv4_checksum_ok', 0, 1),
BitField('outer_l4_checksum_ok', 0, 1),
StrFixedLenField('reserved2', None, length=12),
]


class FlowTableFieldsSupported(Packet):
fields_desc = [
BitField('outer_dmac', 0, 1),
BitField('outer_smac', 0, 1),
BitField('outer_ether_type', 0, 1),
BitField('outer_ip_version', 0, 1),
BitField('outer_first_prio', 0, 1),
BitField('outer_first_cfi', 0, 1),
BitField('outer_first_vid', 0, 1),
BitField('outer_ipv4_ttl', 0, 1),
BitField('outer_second_prio', 0, 1),
BitField('outer_second_cfi', 0, 1),
BitField('outer_second_vid', 0, 1),
BitField('outer_ipv6_flow_label', 0, 1),
BitField('outer_sip', 0, 1),
BitField('outer_dip', 0, 1),
BitField('outer_frag', 0, 1),
BitField('outer_ip_protocol', 0, 1),
BitField('outer_ip_ecn', 0, 1),
BitField('outer_ip_dscp', 0, 1),
BitField('outer_udp_sport', 0, 1),
BitField('outer_udp_dport', 0, 1),
BitField('outer_tcp_sport', 0, 1),
BitField('outer_tcp_dport', 0, 1),
BitField('outer_tcp_flags', 0, 1),
BitField('outer_gre_protocol', 0, 1),
BitField('outer_gre_key', 0, 1),
BitField('outer_vxlan_vni', 0, 1),
BitField('outer_geneve_vni', 0, 1),
BitField('outer_geneve_oam', 0, 1),
BitField('outer_geneve_protocol_type', 0, 1),
BitField('outer_geneve_opt_len', 0, 1),
BitField('source_vhca_port', 0, 1),
BitField('source_eswitch_port', 0, 1),
BitField('inner_dmac', 0, 1),
BitField('inner_smac', 0, 1),
BitField('inner_ether_type', 0, 1),
BitField('inner_ip_version', 0, 1),
BitField('inner_first_prio', 0, 1),
BitField('inner_first_cfi', 0, 1),
BitField('inner_first_vid', 0, 1),
BitField('inner_ipv4_ttl', 0, 1),
BitField('inner_second_prio', 0, 1),
BitField('inner_second_cfi', 0, 1),
BitField('inner_second_vid', 0, 1),
BitField('inner_ipv6_flow_label', 0, 1),
BitField('inner_sip', 0, 1),
BitField('inner_dip', 0, 1),
BitField('inner_frag', 0, 1),
BitField('inner_ip_protocol', 0, 1),
BitField('inner_ip_ecn', 0, 1),
BitField('inner_ip_dscp', 0, 1),
BitField('inner_udp_sport', 0, 1),
BitField('inner_udp_dport', 0, 1),
BitField('inner_tcp_sport', 0, 1),
BitField('inner_tcp_dport', 0, 1),
BitField('inner_tcp_flags', 0, 1),
BitField('outer_tcp_seq_num', 0, 1),
BitField('inner_tcp_seq_num', 0, 1),
BitField('prog_sample_field', 0, 1),
BitField('outer_first_mpls_over_udp_cw', 0, 1),
BitField('outer_tcp_ack_num', 0, 1),
BitField('inner_tcp_ack_num', 0, 1),
BitField('outer_first_mpls_over_gre_cw', 0, 1),
BitField('metadata_reg_b', 0, 1),
BitField('metadata_reg_a', 0, 1),
BitField('geneve_tlv_option_0_data', 0, 1),
BitField('geneve_tlv_option_0_exist', 0, 1),
BitField('outer_vxlan_gpe_vni', 0, 1),
BitField('outer_vxlan_gpe_flags', 0, 1),
BitField('outer_vxlan_gpe_next_protocol', 0, 1),
BitField('outer_first_mpls_over_gre_ttl', 0, 1),
BitField('outer_first_mpls_over_gre_s_bos', 0, 1),
BitField('outer_first_mpls_over_gre_exp', 0, 1),
BitField('outer_first_mpls_over_gre_label', 0, 1),
BitField('outer_first_mpls_over_udp_ttl', 0, 1),
BitField('outer_first_mpls_over_udp_s_bos', 0, 1),
BitField('outer_first_mpls_over_udp_exp', 0, 1),
BitField('outer_first_mpls_over_udp_label', 0, 1),
BitField('inner_first_mpls_ttl', 0, 1),
BitField('inner_first_mpls_s_bos', 0, 1),
BitField('inner_first_mpls_exp', 0, 1),
BitField('inner_first_mpls_label', 0, 1),
BitField('outer_first_mpls_ttl', 0, 1),
BitField('outer_first_mpls_s_bos', 0, 1),
BitField('outer_first_mpls_exp', 0, 1),
BitField('outer_first_mpls_label', 0, 1),
BitField('outer_emd_tag', 0, 1),
BitField('inner_esp_spi', 0, 1),
BitField('outer_esp_spi', 0, 1),
BitField('inner_ipv6_hop_limit', 0, 1),
BitField('outer_ipv6_hop_limit', 0, 1),
BitField('bth_dst_qp', 0, 1),
BitField('inner_first_svlan', 0, 1),
BitField('inner_second_svlan', 0, 1),
BitField('outer_first_svlan', 0, 1),
BitField('outer_second_svlan', 0, 1),
BitField('source_sqn', 0, 1),
BitField('outer_gre_c_present', 0, 1),
BitField('outer_gre_k_present', 0, 1),
BitField('outer_gre_s_present', 0, 1),
BitField('ipsec_syndrome', 0, 1),
BitField('ipsec_next_header', 0, 1),
BitField('gtpu_first_ext_dw_0', 0, 1),
BitField('gtpu_dw_0', 0, 1),
BitField('gtpu_teid', 0, 1),
BitField('gtpu_msg_type', 0, 1),
BitField('gtpu_flags', 0, 1),
BitField('outer_lrh_lid', 0, 1),
BitField('outer_grh_flow_label', 0, 1),
BitField('outer_grh_tclass', 0, 1),
BitField('outer_grh_gid', 0, 1),
BitField('outer_bth_pkey', 0, 1),
BitField('gtpu_dw_2', 0, 1),
BitField('reserved1', 0, 2),
BitField('icmpv6_code', 0, 1),
BitField('icmp_code', 0, 1),
BitField('icmpv6_type', 0, 1),
BitField('icmp_type', 0, 1),
BitField('icmpv6_header_data', 0, 1),
BitField('icmp_header_data', 0, 1),
BitField('metadata_reg_c_7', 0, 1),
BitField('metadata_reg_c_6', 0, 1),
BitField('metadata_reg_c_5', 0, 1),
BitField('metadata_reg_c_4', 0, 1),
BitField('metadata_reg_c_3', 0, 1),
BitField('metadata_reg_c_2', 0, 1),
BitField('metadata_reg_c_1', 0, 1),
BitField('metadata_reg_c_0', 0, 1),
]


class HeaderModifyCapProperties(Packet):
fields_desc = [
PacketField('set_action_field_support', FlowTableFieldsSupported(),
FlowTableFieldsSupported),
PacketField('set_action_field_support_2', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('add_action_field_support', FlowTableFieldsSupported(),
FlowTableFieldsSupported),
PacketField('add_action_field_support_2', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('copy_action_field_support', FlowTableFieldsSupported(),
FlowTableFieldsSupported),
PacketField('copy_action_field_support_2', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
StrFixedLenField('reserved1', None, length=32),
]


class FlowTablePropLayout(Packet):
fields_desc = [
BitField('ft_support', 0, 1),
BitField('flow_tag', 0, 1),
BitField('flow_counter', 0, 1),
BitField('flow_modify_en', 0, 1),
BitField('modify_root', 0, 1),
BitField('identified_miss_table', 0, 1),
BitField('flow_table_modify', 0, 1),
BitField('reformat', 0, 1),
BitField('decap', 0, 1),
BitField('reset_root_to_default', 0, 1),
BitField('pop_vlan', 0, 1),
BitField('push_vlan', 0, 1),
BitField('fpga_vendor_acceleration', 0, 1),
BitField('pop_vlan_2', 0, 1),
BitField('push_vlan_2', 0, 1),
BitField('reformat_and_vlan_action', 0, 1),
BitField('modify_and_vlan_action', 0, 1),
BitField('sw_owner', 0, 1),
BitField('reformat_l3_tunnel_to_l2', 0, 1),
BitField('reformat_l2_to_l3_tunnel', 0, 1),
BitField('reformat_and_modify_action', 0, 1),
BitField('ignore_flow_level', 0, 1),
BitField('reserved1', 0, 1),
BitField('table_miss_action_domain', 0, 1),
BitField('termination_table', 0, 1),
BitField('reformat_and_fwd_to_table', 0, 1),
BitField('forward_vhca_rx_root', 0, 1),
BitField('forward_vhca_tx_root', 0, 1),
BitField('ipsec_encrypt', 0, 1),
BitField('ipsec_decrypt', 0, 1),
BitField('sw_owner_v2', 0, 1),
BitField('wqe_based_flow_update', 0, 1),
BitField('termination_table_raw_traffic', 0, 1),
BitField('vlan_and_fwd_to_table', 0, 1),
BitField('log_max_ft_size', 0, 6),
ByteField('log_max_modify_header_context', 0),
ByteField('max_modify_header_actions', 0),
ByteField('max_ft_level', 0),
BitField('reformat_add_esp_transport', 0, 1),
BitField('reformat_l2_to_l3_esp_tunnel', 0, 1),
BitField('reformat_add_esp_transport_over_udp', 0, 1),
BitField('reformat_del_esp_transport', 0, 1),
BitField('reformat_l3_esp_tunnel_to_l2', 0, 1),
BitField('reformat_del_esp_transport_over_udp', 0, 1),
BitField('execute_aso', 0, 1),
BitField('forward_flow_meter', 0, 1),
ByteField('log_max_flow_sampler_num', 0),
ByteField('metadata_reg_b_width', 0),
ByteField('metadata_reg_a_width', 0),
BitField('reformat_l2_to_l3_nisp_tunnel', 0, 1),
BitField('reformat_l3_nisp_tunnel_to_l2', 0, 1),
BitField('reformat_insert', 0, 1),
BitField('reformat_remove', 0, 1),
BitField('macsec_encrypt', 0, 1),
BitField('macsec_decrypt', 0, 1),
BitField('nisp_encrypt', 0, 1),
BitField('nisp_decrypt', 0, 1),
BitField('reformat_add_macsec', 0, 1),
BitField('reformat_remove_macsec', 0, 1),
BitField('reparse', 0, 1),
BitField('reserved2', 0, 1),
BitField('cross_vhca_object', 0, 1),
BitField('reserved3', 0, 11),
ByteField('log_max_ft_num', 0),
ShortField('reserved4', 0),
ByteField('log_max_flow_counter', 0),
ByteField('log_max_destination', 0),
BitField('reserved5', 0, 24),
ByteField('log_max_flow', 0),
StrFixedLenField('reserved6', None, length=8),
PacketField('ft_field_support', FlowTableFieldsSupported(), FlowTableFieldsSupported),
PacketField('ft_field_bitmask_support', FlowTableFieldsSupported(),
FlowTableFieldsSupported),
]


class FlowTableNicCap(Packet):
fields_desc = [
BitField('nic_rx_multi_path_tirs', 0, 1),
BitField('nic_rx_multi_path_tirs_fts', 0, 1),
BitField('allow_sniffer_and_nic_rx_shared_tir', 0, 1),
BitField('reserved1', 0, 1),
BitField('nic_rx_flow_tag_multipath_en', 0, 1),
BitField('ttl_checksum_correction', 0, 1),
BitField('nic_rx_rdma_fwd_tir', 0, 1),
BitField('sw_owner_reformat_supported', 0, 1),
ShortField('reserved2', 0),
ByteField('nic_receive_max_steering_depth', 0),
BitField('encap_general_header', 0, 1),
BitField('reserved3', 0, 10),
BitField('log_max_packet_reformat_context', 0, 5),
BitField('reserved4', 0, 6),
BitField('max_encap_header_size', 0, 10),
StrFixedLenField('reserved5', None, length=56),
PacketField('flow_table_properties_nic_receive', FlowTablePropLayout(),
FlowTablePropLayout),
PacketField('flow_table_properties_nic_receive_rdma', FlowTablePropLayout(),
FlowTablePropLayout),
PacketField('flow_table_properties_nic_receive_sniffer', FlowTablePropLayout(),
FlowTablePropLayout),
PacketField('flow_table_properties_nic_transmit', FlowTablePropLayout(),
FlowTablePropLayout),
PacketField('flow_table_properties_nic_transmit_rdma', FlowTablePropLayout(),
FlowTablePropLayout),
PacketField('flow_table_properties_nic_transmit_sniffer', FlowTablePropLayout(),
FlowTablePropLayout),
StrFixedLenField('reserved6', None, length=64),
PacketField('header_modify_nic_receive', HeaderModifyCapProperties(),
HeaderModifyCapProperties),
PacketField('ft_field_support_2_nic_receive', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_bitmask_support_2_nic_receive', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_support_2_nic_receive_rdma', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_bitmask_support_2_nic_receive_rdma', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_support_2_nic_receive_sniffer', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_bitmask_support_2_nic_receive_sniffer', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_support_2_nic_transmit', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_bitmask_support_2_nic_transmit', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_support_2_nic_transmit_rdma', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_bitmask_support_2_nic_transmit_rdma', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_support_2_nic_transmit_sniffer', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
PacketField('ft_field_bitmask_support_2_nic_transmit_sniffer', FlowTableFieldsSupported2(),
FlowTableFieldsSupported2),
StrFixedLenField('reserved7', None, length=64),
PacketField('header_modify_nic_transmit', HeaderModifyCapProperties(),
HeaderModifyCapProperties),
LongField('sw_steering_nic_rx_action_drop_icm_address', 0),
LongField('sw_steering_nic_tx_action_drop_icm_address', 0),
LongField('sw_steering_nic_tx_action_allow_icm_address', 0),
StrFixedLenField('reserved8', None, length=40),
]


class QueryCmdHcaNicFlowTableCapOut(Packet):
fields_desc = [
ByteField('status', 0),
BitField('reserved1', 0, 24),
IntField('syndrome', 0),
StrFixedLenField('reserved2', None, length=8),
PadField(PacketField('capability', FlowTableNicCap(), FlowTableNicCap), 2048,
padwith=b"\x00"),
]
15 changes: 13 additions & 2 deletions tests/test_mlx5_dr.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ def skip_if_has_geneve_tx_bug(ctx):
raise unittest.SkipTest('This test is not supported on cx5/6')


def requires_geneve_fields_rx_support(func):
def func_wrapper(instance):
nic_tbl_caps = u.query_nic_flow_table_caps(instance)
field_support = nic_tbl_caps.flow_table_properties_nic_receive.ft_field_support
if not (field_support.outer_geneve_vni and field_support.outer_geneve_oam and
field_support.outer_geneve_protocol_type and field_support.outer_geneve_opt_len):
raise unittest.SkipTest('NIC flow table does not support geneve fields')
return func(instance)
return func_wrapper


class Mlx5DrResources(RawResources):
"""
Test various functionalities of the mlx5 direct rules class.
Expand Down Expand Up @@ -1007,15 +1018,15 @@ def geneve_match_rx(self, root_only=False):
self.assertEqual(recv_packets_rx, self.iters,
'Counter rx counts more than expected recv packets')

@skip_unsupported
@requires_geneve_fields_rx_support
def test_root_geneve_match_rx(self):
"""
Creates matcher on RX root table to match on Geneve related fields
with counter and qp action, sends packets and verifies the matcher.
"""
self.geneve_match_rx(root_only=True)

@skip_unsupported
@requires_geneve_fields_rx_support
def test_geneve_match_rx(self):
"""
Creates matcher on RX non-root table to match on Geneve related
Expand Down

0 comments on commit d1c71a2

Please sign in to comment.