예제 #1
0
 def test_dest_array(self):
     """
     Creates RX domain, root table with matcher on source mac. Create a rule
     to forward all traffic to the non-root table. On this table add a rule
     with multi dest array action which include destination QP actions and
     next FT (also with QP action).
     Validate on all QPs the received packets.
     """
     max_actions = 8
     self.client = Mlx5DrResources(qp_count=max_actions, **self.dev_info)
     self.server = Mlx5DrResources(qp_count=max_actions, **self.dev_info)
     self.domain_rx = DrDomain(self.server.ctx, dve.MLX5DV_DR_DOMAIN_TYPE_NIC_RX)
     actions = []
     dest_attrs = []
     for qp in self.server.qps[:-1]:
         qp_action = DrActionQp(qp)
         actions.append(qp_action)
         dest_attrs.append(DrActionDestAttr(dve.MLX5DV_DR_ACTION_DEST, qp_action))
     ft_action = DrTable(self.domain_rx, 0xff)
     last_table_action = DrActionDestTable(ft_action)
     smac_mask = bytes([0xff] * 6) + bytes(2)
     mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask)
     last_matcher = DrMatcher(ft_action, 1, u.MatchCriteriaEnable.OUTER, mask_param)
     dest_attrs.append(DrActionDestAttr(dve.MLX5DV_DR_ACTION_DEST, last_table_action))
     last_qp_action = DrActionQp(self.server.qps[max_actions - 1])
     smac_value = struct.pack('!6s2s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')),
                              bytes(2))
     value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value)
     self.rules.append(DrRule(last_matcher, value_param, [last_qp_action]))
     multi_dest_a = DrActionDestArray(self.domain_rx, len(dest_attrs), dest_attrs)
     smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
     self.create_rx_recv_qp_rule(smac_value, [multi_dest_a], domain=self.domain_rx)
     u.raw_traffic(self.client, self.server, self.iters)
예제 #2
0
 def test_tx_def_miss_action(self):
     """
     Create TX root table and forward all traffic to next SW steering table,
     create two matchers with different priorities, one with default miss
     action (on TX it's go to wire action) and one with drop action, default
     miss action should occur before the drop action hence packets
     should reach server side which has RX rule with QP action.
     """
     self.create_players(Mlx5DrResources)
     self.domain_tx = DrDomain(self.client.ctx,
                               dve.MLX5DV_DR_DOMAIN_TYPE_NIC_TX)
     tx_def_miss = DrActionDefMiss()
     tx_drop_action = DrActionDrop()
     smac_value = struct.pack(
         '!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
     self.tx_table, self.tx_dest_act = self.create_rx_recv_rules(
         smac_value, [tx_def_miss], domain=self.domain_tx)
     qp_action = DrActionQp(self.server.qp)
     self.create_rx_recv_rules(smac_value, [qp_action])
     smac_mask = bytes([0xff] * 6) + bytes(2)
     mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask)
     matcher_tx2 = DrMatcher(self.tx_table, 2, u.MatchCriteriaEnable.OUTER,
                             mask_param)
     smac_value += bytes(2)
     value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value)
     self.rules.append(DrRule(matcher_tx2, value_param, [tx_drop_action]))
     u.raw_traffic(self.client, self.server, self.iters)
예제 #3
0
 def test_push_vlan(self):
     """
     Creates RX domain, root table with matcher on source mac. Create a rule to forward
     all traffic to the non-root table. Creates QP action and push VLAN action.
     Creates a rule with those actions on the matcher.
     Verifies traffic and packet with specified VLAN.
     """
     self.client = Mlx5DrResources(**self.dev_info)
     vlan_hdr = struct.pack(
         '!HH', PacketConsts.VLAN_TPID, (PacketConsts.VLAN_PRIO << 13) +
         (PacketConsts.VLAN_CFI << 12) + PacketConsts.VLAN_ID)
     self.server = Mlx5DrResources(msg_size=self.client.msg_size +
                                   PacketConsts.VLAN_HEADER_SIZE,
                                   **self.dev_info)
     self.domain_tx = DrDomain(self.client.ctx,
                               dve.MLX5DV_DR_DOMAIN_TYPE_NIC_TX)
     smac_value = struct.pack(
         '!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
     push_action = DrActionPushVLan(self.domain_tx,
                                    struct.unpack('I', vlan_hdr)[0])
     self.tx_table, self.tx_dest_act = self.create_rx_recv_rules(
         smac_value, [push_action], domain=self.domain_tx)
     self.domain_rx = DrDomain(self.server.ctx,
                               dve.MLX5DV_DR_DOMAIN_TYPE_NIC_RX)
     qp_action = DrActionQp(self.server.qp)
     self.create_rx_recv_rules(smac_value, [qp_action],
                               domain=self.domain_rx)
     exp_packet = u.gen_packet(self.client.msg_size +
                               PacketConsts.VLAN_HEADER_SIZE,
                               with_vlan=True)
     u.raw_traffic(self.client,
                   self.server,
                   self.iters,
                   expected_packet=exp_packet)
예제 #4
0
 def dest_port(self, is_vport=True):
     """
     Creates FDB domain, root table with matcher on source mac on the server
     side. Create a rule to forward all traffic to the non-root table.
     On this table apply VPort/IBPort action goto PF.
     Validate RX side of FDB:
     On the server open another RX domain on PF with QP action and validate
     packets by sending traffic from client, catch all traffic with
     VPort/IBPort action goto PF, open another RX domain on PF with QP
     action and validate packets.
     Validate TX side of FDB:
     Send traffic from server and validate packets on servers' QP
     with the same rules.
     :param is_vport: A flag to indicate if to use VPort or IBPort action.
     """
     self.client = Mlx5DrResources(**self.dev_info)
     self.server = Mlx5DrResources(**self.dev_info)
     self.domain_fdb = DrDomain(self.server.ctx, dve.MLX5DV_DR_DOMAIN_TYPE_FDB)
     port_action = DrActionVPort(self.domain_fdb, PF_VPORT) if is_vport \
         else DrActionIBPort(self.domain_fdb, self.ib_port)
     smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
     self.fdb_table, self.fdb_dest_act = self.create_rx_recv_qp_rule(smac_value, [port_action],
                                                                     domain=self.domain_fdb)
     self.domain_rx = DrDomain(self.server.ctx, dve.MLX5DV_DR_DOMAIN_TYPE_NIC_RX)
     rx_table = DrTable(self.domain_rx, 0)
     qp_action = DrActionQp(self.server.qp)
     smac_mask = bytes([0xff] * 6)
     mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask)
     rx_matcher = DrMatcher(rx_table, 0, u.MatchCriteriaEnable.OUTER, mask_param)
     value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value)
     self.rules.append(DrRule(rx_matcher, value_param, [qp_action]))
     # Validate traffic on RX
     u.raw_traffic(self.client, self.server, self.iters)
     # Validate traffic on TX
     self.send_server_fdb_to_nic_packets(self.iters)
예제 #5
0
 def test_tbl_qp_rule(self):
     """
     Creates RX domain, SW table with matcher on source mac. Creates QP action
     and a rule with this action on the matcher.
     """
     self.create_players(Mlx5DrResources)
     self.qp_action = DrActionQp(self.server.qp)
     smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
     self.create_rx_recv_qp_rule(smac_value, [self.qp_action])
     u.raw_traffic(self.client, self.server, self.iters)
예제 #6
0
 def test_tbl_modify_header_rule(self):
     """
     Creates TX domain, SW table with matcher on source mac and modify the smac.
     Then creates RX domain and rule that forwards packets with the new smac
     to server QP. Perform traffic that do this flow.
     """
     self.create_players(Mlx5DrResources)
     self.create_tx_modify_rule()
     src_mac = struct.pack('!6s', bytes.fromhex("88:88:88:88:88:88".replace(':', '')))
     self.qp_action = DrActionQp(self.server.qp)
     self.create_rx_recv_qp_rule(src_mac, [self.qp_action])
     exp_packet = u.gen_packet(self.client.msg_size, src_mac=src_mac)
     u.raw_traffic(self.client, self.server, self.iters, expected_packet=exp_packet)
예제 #7
0
 def test_set_matcher_layout(self):
     """
     Creates a non root matcher and sets its size. Creates a rule on that
     matcher and increases the matcher size. Verifies the rule.
     """
     log_matcher_size = 5
     self.create_players(Mlx5DrResources)
     self.qp_action = DrActionQp(self.server.qp)
     smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
     self.create_rx_recv_qp_rule(smac_value, [self.qp_action], log_matcher_size)
     self.matcher.set_layout(log_matcher_size + 1)
     u.raw_traffic(self.client, self.server, self.iters)
     self.matcher.set_layout(flags=dve.MLX5DV_DR_MATCHER_LAYOUT_RESIZABLE)
     u.raw_traffic(self.client, self.server, self.iters)
예제 #8
0
 def test_pop_vlan(self):
     """
     Creates RX domain, root table with matcher on source mac. Create a rule to forward
     all traffic to the non-root table. Creates QP action and pop VLAN action.
     Creates a rule with those actions on the matcher.
     Verifies packets received without VLAN header.
     """
     self.server = Mlx5DrResources(**self.dev_info)
     self.client = Mlx5DrResources(**self.dev_info)
     exp_packet = u.gen_packet(self.server.msg_size - PacketConsts.VLAN_HEADER_SIZE)
     qp_action = DrActionQp(self.server.qp)
     pop_action = DrActionPopVLan()
     smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
     self.create_rx_recv_qp_rule(smac_value, [pop_action, qp_action])
     u.raw_traffic(self.client, self.server, self.iters, with_vlan=True, expected_packet=exp_packet)
예제 #9
0
 def test_tbl_counter_action(self):
     """
     Create flow counter object, attach it to a rule using counter action
     and perform traffic that hit this rule. Verify that the counter packets
     increased.
     """
     self.create_players(Mlx5DrResources)
     self.server.create_counter()
     self.server_counter_action = DrActionFlowCounter(self.server.counter)
     smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
     self.qp_action = DrActionQp(self.server.qp)
     self.create_rx_recv_qp_rule(smac_value, [self.qp_action, self.server_counter_action])
     u.raw_traffic(self.client, self.server, self.iters)
     recv_packets = self.server.query_counter_packets()
     self.assertEqual(recv_packets, self.iters, 'Counter missed some recv packets')
예제 #10
0
 def test_root_tbl_qp_rule(self):
     """
     Creates RX domain, root table with matcher on source mac. Creates QP
     action and a rule with this action on the matcher.
     """
     self.create_players(Mlx5DrResources)
     domain_rx = DrDomain(self.server.ctx, dve.MLX5DV_DR_DOMAIN_TYPE_NIC_RX)
     table = DrTable(domain_rx, 0)
     smac_mask = bytes([0xff] * 6)
     mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask)
     matcher = DrMatcher(table, 0, u.MatchCriteriaEnable.OUTER, mask_param)
     qp_action = DrActionQp(self.server.qp)
     smac_value = struct.pack(
         '!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
     value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value)
     self.rule = DrRule(matcher, value_param, [qp_action])
     u.raw_traffic(self.client, self.server, self.iters)
예제 #11
0
 def test_tbl_qp_tag_rule(self):
     """
     Creates RX domain, table with matcher on source mac. Creates QP action
     and tag action. Creates a rule with those actions on the matcher.
     Verifies traffic and tag.
     """
     self.wc_flags = e.IBV_WC_EX_WITH_FLOW_TAG
     self.create_players(Mlx5DrResources,  wc_flags=e.IBV_WC_EX_WITH_FLOW_TAG)
     qp_action = DrActionQp(self.server.qp)
     tag = 0x123
     tag_action = DrActionTag(tag)
     smac_value = struct.pack('!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
     self.create_rx_recv_qp_rule(smac_value, [tag_action, qp_action])
     self.domain_rx.sync()
     u.raw_traffic(self.client, self.server, self.iters)
     # Verify tag
     self.assertEqual(self.server.cq.read_flow_tag(), tag, 'Wrong tag value')
예제 #12
0
    def test_prevent_duplicate_rule(self):
        """
        Creates RX domain, sets duplicate rule to be not allowed on that domain,
        try creating duplicate rule. Fail if creation succeeded.
        """
        from tests.mlx5_prm_structs import FlowTableEntryMatchParam

        self.server = Mlx5DrResources(**self.dev_info)
        domain_rx = DrDomain(self.server.ctx, dve.MLX5DV_DR_DOMAIN_TYPE_NIC_RX)
        domain_rx.allow_duplicate_rules(False)
        table = DrTable(domain_rx, 1)
        empty_param = Mlx5FlowMatchParameters(len(FlowTableEntryMatchParam()),
                                              FlowTableEntryMatchParam())
        matcher = DrMatcher(table, 0, u.MatchCriteriaEnable.NONE, empty_param)
        self.qp_action = DrActionQp(self.server.qp)
        self.drop_action = DrActionDrop()
        self.rules.append(DrRule(matcher, empty_param, [self.qp_action]))
        with self.assertRaises(PyverbsRDMAError) as ex:
            self.rules.append(DrRule(matcher, empty_param, [self.drop_action]))
            self.assertEqual(ex.exception.error_code, errno.EEXIST)
예제 #13
0
    def test_packet_reformat(self):
        """
        Creates packet reformat actions on TX (encap) and on RX (decap).
        """
        self.create_players(Mlx5DrResources)
        smac_mask = bytes([0xff] * 6) + bytes(2)
        mask_param = Mlx5FlowMatchParameters(len(smac_mask), smac_mask)
        smac_value = struct.pack(
            '!6s', bytes.fromhex(PacketConsts.SRC_MAC.replace(':', '')))
        value_param = Mlx5FlowMatchParameters(len(smac_value), smac_value)

        # TX steering
        domain_tx = DrDomain(self.client.ctx, dve.MLX5DV_DR_DOMAIN_TYPE_NIC_TX)
        tx_table = DrTable(domain_tx, 0)
        tx_matcher = DrMatcher(tx_table, 0, u.MatchCriteriaEnable.OUTER,
                               mask_param)
        # Create encap action
        outer = u.gen_outer_headers(self.client.msg_size)
        tx_reformat_type = dve.MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL_
        reformat_action_tx = DrActionPacketReformat(
            domain=domain_tx,
            data=outer,
            flags=dve.MLX5DV_DR_ACTION_FLAGS_ROOT_LEVEL,
            reformat_type=tx_reformat_type)
        self.rules.append(DrRule(tx_matcher, value_param,
                                 [reformat_action_tx]))

        # RX steering
        domain_rx = DrDomain(self.server.ctx, dve.MLX5DV_DR_DOMAIN_TYPE_NIC_RX)
        # Create decap action
        rx_reformat_type = dve.MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TUNNEL_TO_L2_
        reformat_action_rx = DrActionPacketReformat(
            domain=domain_rx, reformat_type=rx_reformat_type)
        qp_action = DrActionQp(self.server.qp)
        self.create_rx_recv_rules(smac_value, [reformat_action_rx, qp_action],
                                  domain=domain_rx)

        # Send traffic and validate packet
        u.raw_traffic(self.client, self.server, self.iters)