コード例 #1
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)
コード例 #2
0
    def test_tx_packet_reformat(self):
        """
        Creates packet reformat (encap) action on TX and with QP action on RX
        verifies that the packet was encapsulated as expected.
        """
        self.client = Mlx5FlowResources(**self.dev_info)
        outer = u.gen_outer_headers(self.client.msg_size)
        # Due to encapsulation action Ipv4 and UDP checksum of the outer header
        # will be recalculated, need to skip them during packet validation.
        ipv4_id_idx = [18, 19]
        ipv4_chksum_idx = [24, 25]
        udp_chksum_idx = [34, 35]
        # Server will receive encaped packet so message size must include the
        # length of the outer part.
        self.server = Mlx5FlowResources(msg_size=self.client.msg_size +
                                        len(outer),
                                        **self.dev_info)
        empty_bytes_arr = bytes(MAX_MATCH_PARAM_SIZE)
        empty_value_param = Mlx5FlowMatchParameters(len(empty_bytes_arr),
                                                    empty_bytes_arr)

        # TX steering
        tx_matcher = self.client.create_matcher(
            empty_bytes_arr, u.MatchCriteriaEnable.NONE,
            e.IBV_FLOW_ATTR_FLAGS_EGRESS, dve.MLX5DV_FLOW_TABLE_TYPE_NIC_TX_)
        # Create encap action
        reformat_action = Mlx5PacketReformatFlowAction(
            self.client.ctx,
            data=outer,
            reformat_type=dve.
            MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L2_TUNNEL_,
            ft_type=dve.MLX5DV_FLOW_TABLE_TYPE_NIC_TX_)
        action_reformat_attr = Mlx5FlowActionAttr(
            flow_action=reformat_action,
            action_type=dve.MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION)
        self.client.flow = Mlx5Flow(tx_matcher, empty_value_param,
                                    [action_reformat_attr], 1)

        # RX steering
        rx_matcher = self.server.create_matcher(empty_bytes_arr,
                                                u.MatchCriteriaEnable.NONE)
        action_qp_attr = Mlx5FlowActionAttr(
            action_type=dve.MLX5DV_FLOW_ACTION_DEST_IBV_QP, qp=self.server.qp)
        self.server.flow = Mlx5Flow(rx_matcher, empty_value_param,
                                    [action_qp_attr], 1)

        # Send traffic and validate packet
        packet = u.gen_packet(self.client.msg_size)
        u.raw_traffic(self.client,
                      self.server,
                      self.iters,
                      expected_packet=outer + packet,
                      skip_idxs=ipv4_id_idx + ipv4_chksum_idx + udp_chksum_idx)
コード例 #3
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)
コード例 #4
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)