From patchwork Tue Nov 10 06:18:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yufen.Mo" X-Patchwork-Id: 83877 X-Patchwork-Delegate: zhaoyan.chen@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3239FA09D2; Tue, 10 Nov 2020 07:24:06 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 98919BC60; Tue, 10 Nov 2020 07:24:04 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id B505769A4 for ; Tue, 10 Nov 2020 07:24:01 +0100 (CET) IronPort-SDR: ouHg6fzHCkJwFtZuXsssdTkDIj89K91yUUdtVQoPg8ebmrCVAC8gK57G+zcEumeq0IxynerJBT DyLOGgQX6/wQ== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="149203856" X-IronPort-AV: E=Sophos;i="5.77,465,1596524400"; d="scan'208";a="149203856" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 22:24:00 -0800 IronPort-SDR: tO2bD+/+brsJmNVD7+L+0UTq32IwOy3INQRBPtLu9F3DpvZzd/4K9jVLtlg4ZTPwTMc2YXl8B5 Ic/T461xQXZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,465,1596524400"; d="scan'208";a="529660539" Received: from dpdk-moyufen06.sh.intel.com ([10.67.116.208]) by fmsmga006.fm.intel.com with ESMTP; 09 Nov 2020 22:23:59 -0800 From: yufengmx To: dts@dpdk.org, hailinx.xu@intel.com Cc: yufengmx Date: Tue, 10 Nov 2020 14:18:56 +0800 Message-Id: <20201110061858.5525-2-yufengx.mo@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20201110061858.5525-1-yufengx.mo@intel.com> References: <20201110061858.5525-1-yufengx.mo@intel.com> MIME-Version: 1.0 Subject: [dts] [PATCH V6 1/3] flexible_rxd: unify common test content X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" unify common test content. Signed-off-by: yufengmx Acked-by: zhaoyan.chen@intel.com --- tests/flexible_common.py | 483 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 483 insertions(+) create mode 100644 tests/flexible_common.py diff --git a/tests/flexible_common.py b/tests/flexible_common.py new file mode 100644 index 0000000..fa3c64d --- /dev/null +++ b/tests/flexible_common.py @@ -0,0 +1,483 @@ +# BSD LICENSE +# +# Copyright(c) 2020 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import time +from packet import Packet +from pmd_output import PmdOutput + + +class FlexibleRxdBase(object): + + def init_base(self, pci, dst_mac, test_type, dut_index=0): + tester_port_id = self.tester.get_local_port(self.dut_ports[dut_index]) + self.__tester_intf = self.tester.get_interface(tester_port_id) + self.__src_mac = self.tester.get_mac(tester_port_id) + self.__dst_mac = dst_mac + + self.__app_path = self.dut.apps_name["test-pmd"] + self.__pmdout = PmdOutput(self.dut) + self.__test_type = test_type + self.__pci = pci + self.__pkg_count = 1 + self.__is_pmd_on = False + + @property + def __is_iavf(self): + return self.__test_type == 'iavf' + + @property + def __is_pf(self): + return self.__test_type == 'pf' + + def __get_port_option(self, flex_opt='', queue_num=None): + nb_core = 2 + num = 4 if self.nic == 'foxville' or self.__is_iavf else 32 + queue_num = queue_num if queue_num else num + # port option + port_option = ( + '{queue} ' + '--portmask=0x1 ' + '--nb-cores={nb_core}').format(**{ + 'queue': '--rxq={0} --txq={0} '.format(queue_num) + if flex_opt != 'ip_offset' else '', + 'nb_core': nb_core, + }) + return port_option + + def __check_rxdid(self, rxdid, out): + rxdid = rxdid if isinstance(rxdid, list) else [rxdid] + pat = "RXDID\[(\d+)\]" + for rx in rxdid: + if self.__is_pf: + value = re.findall(pat, rx) + if not value: + continue + check_str = "RXDID : {}".format(value[0]) + self.verify( + check_str in out, + "rxdid value error, expected rxdid is %s" % check_str) + else: + self.verify( + rx in out, + "rxdid value error, expected rxdid is %s" % rx) + + def start_testpmd(self, flex_opt, rxdid, queue_num=None): + """ + start testpmd + """ + param_type = 'proto_xtr' + # port option + port_option = self.__get_port_option(flex_opt, queue_num=queue_num) + # start test pmd + out = self.__pmdout.start_testpmd( + "1S/3C/1T", + param=port_option, + eal_param='' if self.__is_iavf else '--log-level="ice,8"', + ports=[self.__pci], + port_options={self.__pci: '%s=%s' % (param_type, flex_opt)}) + self.__is_pmd_on = True + # check rxdid value correct + self.__check_rxdid(rxdid, out) + # set test pmd command + if flex_opt == 'ip_offset': + cmds = [ + 'set verbose 1', + 'start', + ] + else: + cmds = [ + "set verbose 1", + "set fwd io", + "set promisc all off", + "clear port stats all", + "start", ] + [self.dut.send_expect(cmd, "testpmd> ", 15) for cmd in cmds] + + def close_testpmd(self): + if not self.__is_pmd_on: + return + try: + self.__pmdout.quit() + self.__is_pmd_on = False + except Exception as e: + pass + + def __send_pkts_and_get_output(self, pkt_str): + pkt = Packet(pkt_str) + pkt.send_pkt( + self.tester, + tx_port=self.__tester_intf, + count=self.__pkg_count, + timeout=30) + time.sleep(0.5) + output = self.dut.get_session_output(timeout=3) + return output + + def __verify_common(self, pkts_list, msg=None): + """ + send MPLS type packet, verify packet ip_offset value correct + param pkts_list: + [send packets list, ip_offset expected value] + """ + msg = msg if msg else "ip_offset value error, case test failed" + for pkt_str, expected_strs in pkts_list: + out = self.__send_pkts_and_get_output( + pkt_str.format(**{ + 'src_mac': self.__src_mac, + 'dst_mac': self.__dst_mac})) + # validation results + _expected_strs = [expected_strs] \ + if isinstance(expected_strs, str) else \ + expected_strs + self.verify(all([e in out for e in _expected_strs]), msg) + + def check_single_VLAN_fields_in_RXD_8021Q(self): + """ + Check single VLAN fields in RXD (802.1Q) + """ + self.start_testpmd("vlan", "RXDID[17]") + pkts_str = 'Ether(src="{src_mac}", dst="{dst_mac}", type=0x8100)/Dot1Q(prio=1,vlan=23)/IP()/UDP()/DNS()' + msg = "The packet does not carry a VLAN tag." + fields_list = ["vlan"] + self.__verify_common([[pkts_str, fields_list]], msg) + + def check_single_VLAN_fields_in_RXD_8021ad(self): + """ + Check single VLAN fields in RXD (802.1ad) + """ + self.start_testpmd("vlan", "RXDID[17]") + pkts_str = 'Ether(src="{src_mac}", dst="{dst_mac}", type=0x88A8)/Dot1Q(prio=1,vlan=23)/IP()/UDP()/DNS()' + msg = "stag result is not expected (stag=1:0:23)" + fields_list = ["stag=1:0:23"] + self.__verify_common([[pkts_str, fields_list]], msg) + + def check_double_VLAN_fields_in_RXD_8021Q_1_VLAN_tag(self): + """ + Check double VLAN fields in RXD (802.1Q) only 1 VLAN tag + """ + self.start_testpmd("vlan", "RXDID[17]") + pkts_str = 'Ether(src="{src_mac}", dst="{dst_mac}", type=0x9100)/Dot1Q(prio=1,vlan=23)/IP()/UDP()/DNS()' + msg = "stag result is not expected (stag=1:0:23)" + fields_list = ["stag=1:0:23"] + self.__verify_common([[pkts_str, fields_list]], msg) + + def check_double_VLAN_fields_in_RXD_8021Q_2_VLAN_tag(self): + """ + Check double VLAN fields in RXD (802.1Q) 2 VLAN tags + """ + self.start_testpmd("vlan", "RXDID[17]") + pkts_str = 'Ether(src="{src_mac}", dst="{dst_mac}", type=0x9100)/Dot1Q(prio=1,vlan=23)/Dot1Q(prio=4,vlan=56)/IP()/UDP()/DNS()' + msg = "There are no related fields in the received VLAN packet" + fields_list = ["stag=1:0:23", "ctag=4:0:56"] + self.__verify_common([[pkts_str, fields_list]], msg) + + def check_double_VLAN_fields_in_RXD_8021ad(self): + """ + Check double VLAN fields in RXD (802.1ad) + """ + self.start_testpmd("vlan", "RXDID[17]") + pkts_str = 'Ether(src="{src_mac}", dst="{dst_mac}", type=0x88A8)/Dot1Q(prio=1,vlan=23)/Dot1Q(prio=4,vlan=56)/IP()/UDP()/DNS()' + msg = "There are no related fields in the received VLAN packet" + fields_list = ["stag=1:0:23", "ctag=4:0:56"] + self.__verify_common([[pkts_str, fields_list]], msg) + + def check_IPv4_fields_in_RXD(self): + """ + Check IPv4 fields in RXD + """ + self.start_testpmd("ipv4", "RXDID[18]") + pkts_str = 'Ether(src="{src_mac}", dst="{dst_mac}")/IP(tos=23, ttl=98)/UDP()/Raw(load="XXXXXXXXXX")' + msg = "There are no related fields in the received IPV4 packet" + fields_list = ["ver=4", "hdrlen=5", "tos=23", "ttl=98", "proto=17"] + self.__verify_common([[pkts_str, fields_list]], msg) + + def check_IPv6_fields_in_RXD(self): + """ + Check IPv6 fields in RXD + """ + self.start_testpmd("ipv6", "RXDID[19]") + pkts_str = 'Ether(src="{src_mac}", dst="{dst_mac}")/IPv6(tc=12,hlim=34,fl=0x98765)/UDP()/Raw(load="XXXXXXXXXX")' + msg = "There are no related fields in the received IPV6 packet" + fields_list = [ + "ver=6", "tc=12", "flow_hi4=0x9", "nexthdr=17", "hoplimit=34"] + self.__verify_common([[pkts_str, fields_list]], msg) + + def check_IPv6_flow_field_in_RXD(self): + """ + Check IPv6 flow field in RXD + """ + self.start_testpmd("ipv6_flow", "RXDID[20]") + pkts_str = 'Ether(src="{src_mac}", dst="{dst_mac}")/IPv6(tc=12,hlim=34,fl=0x98765)/UDP()/Raw(load="XXXXXXXXXX")' + msg = "There are no related fields in the received IPV6_flow packet" + fields_list = ["ver=6", "tc=12", "flow=0x98765"] + self.__verify_common([[pkts_str, fields_list]], msg) + + def check_TCP_fields_in_IPv4_in_RXD(self): + """ + Check TCP fields in IPv4 in RXD + """ + self.start_testpmd("tcp", "RXDID[21]") + pkts_str = 'Ether(src="{src_mac}", dst="{dst_mac}")/IP()/TCP(flags="AS")/Raw(load="XXXXXXXXXX")' + msg = "There are no related fields in the received TCP packet" + fields_list = ["doff=5", "flags=AS"] + self.__verify_common([[pkts_str, fields_list]], msg) + + def check_TCP_fields_in_IPv6_in_RXD(self): + """ + Check TCP fields in IPv6 in RXD + """ + self.start_testpmd("tcp", "RXDID[21]") + pkts_str = 'Ether(src="{src_mac}", dst="{dst_mac}")/IPv6()/TCP(flags="S")/Raw(load="XXXXXXXXXX")' + msg = "There are no related fields in the received TCP packet" + fields_list = ["doff=5", "flags=S"] + self.__verify_common([[pkts_str, fields_list]], msg) + + def check_IPv4_IPv6_TCP_fields_in_RXD_on_specific_queues(self): + """ + Check IPv4, IPv6, TCP fields in RXD on specific queues + """ + self.start_testpmd( + "'[(2):ipv4,(3):ipv6,(4):tcp]'", + ["RXDID[18]", "RXDID[19]", "RXDID[22]"] if self.__is_iavf else + ["RXDID[18]", "RXDID[19]", "RXDID[21]", "RXDID[22]"], + 16) + self.dut.send_expect( + "flow create 0 ingress pattern eth {}/ ipv4 src is 192.168.0.1 dst is 192.168.0.2 tos is 23 ttl is 98 / end actions queue index 2 / end".format( + '' if self.__is_iavf else "dst is {} ".format(self.__dst_mac)), + "created") + self.dut.send_expect( + "flow create 0 ingress pattern eth / ipv6 src is 2001::3 dst is 2001::4 tc is 12 / end actions queue index 3 / end", + "created") + # send IPv4 + pkts_str = \ + 'Ether(dst="{dst_mac}")/IP(src="192.168.0.1",dst="192.168.0.2",tos=23,ttl=98)/UDP()/Raw(load="XXXXXXXXXX")' + msg1 = "There are no relevant fields in the received IPv4 packet." + fields_list1 = ["Receive queue=0x2", "ver=4", + "hdrlen=5", "tos=23", "ttl=98", "proto=17"] + self.__verify_common([[pkts_str, fields_list1]], msg1) + + # send IPv6 + pkts_str = \ + 'Ether(src="{src_mac}", dst="{dst_mac}")/IPv6(src="2001::3", dst="2001::4", tc=12, hlim=34,fl=0x98765)/UDP()/Raw(load="XXXXXXXXXX")' + msg2 = "There are no relevant fields in the received IPv6 packet." + fields_list2 = [ + "Receive queue=0x3", + "ver=6", + "tc=12", + "flow_hi4=0x9", + "nexthdr=17", + "hoplimit=34"] + self.__verify_common([[pkts_str, fields_list2]], msg2) + + # send TCP + self.dut.send_expect("flow flush 0", "testpmd>") + self.dut.send_expect( + "flow create 0 ingress pattern eth {0}/ ipv4 src is 192.168.0.1 dst is 192.168.0.2 / tcp src is 25 dst is 23 / end actions queue index {1} / end".format( + '' if self.__is_iavf else "dst is {} ".format(self.__dst_mac), + 4, ), + "created") + pkts_str = \ + 'Ether(dst="{dst_mac}")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(flags="AS", dport=23, sport=25)/Raw(load="XXXXXXXXXX")' + msg3 = "There are no relevant fields in the received TCP packet." + fields_list3 = [ + "Receive queue=0x4", + "doff=5", + "flags=AS"] + self.__verify_common([[pkts_str, fields_list3]], msg3) + + def check_testpmd_use_different_parameters(self): + """ + Check testpmd use different parameters start + """ + param_type = 'proto_xtr' + # port option + port_opt = self.__get_port_option() + # use error parameter Launch testpmd, testpmd can not be started + cmd = ( + "-l 1,2,3 " + "-n {mem_channel} " + "-w {pci},{param_type}=vxlan " + "-- -i " + "{port_opt}").format(**{ + 'mem_channel': self.dut.get_memory_channels(), + "pci": self.__pci, + "param_type": param_type, + "port_opt": port_opt, + }) + try: + out = self.__pmdout.execute_cmd(self.__app_path + cmd, "#") + self.__is_pmd_on = False + except Exception as e: + self.__is_pmd_on = True + expected = \ + "iavf_lookup_proto_xtr_type(): wrong proto_xtr type, it should be: vlan|ipv4|ipv6|ipv6_flow|tcp|ip_offset" \ + if self.__is_iavf else \ + "handle_proto_xtr_arg(): The protocol extraction parameter is wrong : 'vxlan'" + self.close_testpmd() + self.verify(expected in out, "case test failed, testpmd started") + # don't use parameter launch testpmd, testpmd started and rxdid value + # is the default + cmd = ( + "-l 1,2,3 " + "-n {mem_channel} " + "-w {pci} " + "--log-level='ice,8' " + "-- -i " + "{port_opt}").format(**{ + 'mem_channel': self.dut.get_memory_channels(), + "pci": self.__pci, + "param_type": param_type, + "port_opt": port_opt, + }) + out = self.__pmdout.execute_cmd(self.__app_path + cmd, "testpmd>") + self.__is_pmd_on = True + self.close_testpmd() + self.__check_rxdid("RXDID[22]", out) + + def check_ip_offset_of_ip(self): + """ + Check ip offset of ip + """ + self.start_testpmd("ip_offset", "RXDID[25]") + pkts_list = [ + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=1)/IP()', + 'ip_offset=18'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=1)/IPv6()', + 'ip_offset=18']] + self.__verify_common(pkts_list) + + def check_ip_offset_with_vlan(self): + """ + check ip offset with vlan + """ + self.start_testpmd("ip_offset", "RXDID[25]") + pkts_list = [ + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=1)/IP()', + 'ip_offset=22'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=1)/IPv6()', + 'ip_offset=22']] + self.__verify_common(pkts_list) + + def check_ip_offset_with_2_vlan_tag(self): + """ + check offset with 2 vlan tag + """ + self.start_testpmd("ip_offset", "RXDID[25]") + pkts_list = [ + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=1)/IP()', + 'ip_offset=26'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=1)/IPv6()', + 'ip_offset=26']] + self.__verify_common(pkts_list) + + def check_ip_offset_with_multi_MPLS(self): + """ + check ip offset with multi MPLS + """ + self.start_testpmd("ip_offset", "RXDID[25]") + pkts_list = [ + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=1)/IP()', + 'ip_offset=18'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=22'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=26'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=30'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=34'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=1)/IPv6()', + 'ip_offset=18'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=22'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=26'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=30'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=34']] + self.__verify_common(pkts_list) + + def check_ip_offset_with_multi_MPLS_with_vlan_tag(self): + """ + check ip offset with multi MPLS with vlan tag + """ + self.start_testpmd("ip_offset", "RXDID[25]") + pkts_list = [ + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=1)/IP()', + 'ip_offset=22'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=26'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=30'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=34'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=38'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=1)/IPv6()', + 'ip_offset=22'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=26'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=30'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=34'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=38']] + self.__verify_common(pkts_list) + + def check_ip_offset_with_multi_MPLS_with_2_vlan_tag(self): + """ + check ip offset with multi MPLS with 2 vlan tag + """ + self.start_testpmd("ip_offset", "RXDID[25]") + pkts_list = [ + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=1)/IP()', + 'ip_offset=26'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=30'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=34'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=38'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IP()', + 'ip_offset=42'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=1)/IPv6()', + 'ip_offset=26'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=30'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=34'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=38'], + ['Ether(src="{src_mac}", dst="{dst_mac}",type=0x88A8)/Dot1Q(type=0x8100)/Dot1Q(type=0x8847)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=0)/MPLS(s=1)/IPv6()', + 'ip_offset=42']] + self.__verify_common(pkts_list) From patchwork Tue Nov 10 06:18:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yufen.Mo" X-Patchwork-Id: 83875 X-Patchwork-Delegate: zhaoyan.chen@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8A2FBA0545; Tue, 10 Nov 2020 07:24:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6D4C2AD10; Tue, 10 Nov 2020 07:24:04 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id BCF536C96 for ; Tue, 10 Nov 2020 07:24:02 +0100 (CET) IronPort-SDR: Pxxr+Q/vbI+o4VMgCuTcfv0BDLkr6oIWuuXiyaquyCNnuDXi1DLbSGOMJs0H2TH4cFV5L+vyBE jes6tr77xurg== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="149203858" X-IronPort-AV: E=Sophos;i="5.77,465,1596524400"; d="scan'208";a="149203858" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 22:24:02 -0800 IronPort-SDR: Cdeo9ky0qdpOOinec3eGC3XL6uIKJtlxICSfzPi6igoVmibaRAeQqP1UxcFb/0Y6IYD6TtsLK5 42efLgwrfKkQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,465,1596524400"; d="scan'208";a="529660575" Received: from dpdk-moyufen06.sh.intel.com ([10.67.116.208]) by fmsmga006.fm.intel.com with ESMTP; 09 Nov 2020 22:24:01 -0800 From: yufengmx To: dts@dpdk.org, hailinx.xu@intel.com Cc: yufengmx Date: Tue, 10 Nov 2020 14:18:57 +0800 Message-Id: <20201110061858.5525-3-yufengx.mo@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20201110061858.5525-1-yufengx.mo@intel.com> References: <20201110061858.5525-1-yufengx.mo@intel.com> MIME-Version: 1.0 Subject: [dts] [PATCH V6 2/3] flexible_rxd: add mpls test cases X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" add mpls test cases. Signed-off-by: yufengmx --- tests/TestSuite_flexible_rxd.py | 255 ++++++++++++-------------------- 1 file changed, 96 insertions(+), 159 deletions(-) diff --git a/tests/TestSuite_flexible_rxd.py b/tests/TestSuite_flexible_rxd.py index 7bef76c..733c62e 100644 --- a/tests/TestSuite_flexible_rxd.py +++ b/tests/TestSuite_flexible_rxd.py @@ -1,4 +1,4 @@ -# Copyright (c) <2019> Intel Corporation +# Copyright (c) <2020> Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -33,246 +33,183 @@ import time from test_case import TestCase -from packet import Packet -from pmd_output import PmdOutput +from flexible_common import FlexibleRxdBase -class TestFlexibleRxd(TestCase): +class TestFlexibleRxd(TestCase, FlexibleRxdBase): + + def preset_compilation(self): + """ + Modify the dpdk code. + """ + cmds = [ + "cd " + self.dut.base_dir, + "cp ./app/test-pmd/util.c .", + r"""sed -i "/if dpdk_conf.has('RTE_NET_IXGBE')/i\if dpdk_conf.has('RTE_NET_ICE')\n\tdeps += 'net_ice'\nendif" app/test-pmd/meson.build""", + "sed -i '/#include /a\#include ' app/test-pmd/util.c", + "sed -i '/if (is_timestamp_enabled(mb))/i\ rte_net_ice_dump_proto_xtr_metadata(mb);' app/test-pmd/util.c", + ] + [self.dut.send_expect(cmd, "#", 15, alt_session=True) for cmd in cmds] + self.dut.build_install_dpdk(self.dut.target) + + def restore_compilation(self): + """ + Resume editing operation. + """ + cmds = [ + "cd " + self.dut.base_dir, + "cp ./util.c ./app/test-pmd/", + "sed -i '/pmd_ice/d' app/test-pmd/meson.build", + "rm -rf ./util.c", + ] + [self.dut.send_expect(cmd, "#", 15, alt_session=True) for cmd in cmds] + self.dut.build_install_dpdk(self.dut.target) def set_up_all(self): """ run at the start of each test suite. """ - self.verify(self.nic in ["columbiaville_25g", "columbiaville_100g", "foxville"], - "flexible rxd only supports CVL NIC.") - self.nb_core = 2 - self.pkg_count = 1 + support_nics = [ + "columbiaville_25g", + "columbiaville_100g", + "foxville", + ] + self.verify(self.nic in support_nics, + "flexible rxd only supports CVL NIC.") self.dut_ports = self.dut.get_ports(self.nic) self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing") - self.pci_info = self.dut.ports_info[0]['pci'] self.ports_socket = self.dut.get_numa_id(self.dut_ports[0]) self.cores = self.dut.get_core_list("1S/3C/1T", socket=self.ports_socket) - self.verify(len(self.cores) >= 3, "The machine has too few cores.") - self.tx_interface = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])) + self.verify(len(self.cores) >= 3, "Insufficient cpu cores for testing") + self.preset_compilation() + self.pci = self.dut.ports_info[0]['pci'] self.dst_mac = self.dut.get_mac_address(self.dut_ports[0]) - self.src_mac = self.tester.get_mac(self.tester.get_local_port(self.dut_ports[0])) - self.pmdout = PmdOutput(self.dut) - self.prepare_test_pmd() + self.init_base(self.pci, self.dst_mac, 'pf') - def set_up(self): - """ - Run before each test case. - """ - pass - - def prepare_test_pmd(self): + def tear_down_all(self): """ - Modify the dpdk code. + Run after each test suite. """ - self.dut.send_expect("cp ./app/test-pmd/util.c .", "#", 15) - self.dut.send_expect("cp ./app/test-pmd/meson.build /root/", "#", 15) - pattern = r"/if dpdk_conf.has('RTE_NET_IXGBE')/i\if dpdk_conf.has('RTE_NET_ICE')\n\tdeps += 'net_ice'\nendif" - self.dut.send_expect(f'sed -i "{pattern}" app/test-pmd/meson.build', "#", 15) - self.dut.send_expect( - "sed -i '/#include /a\#include ' app/test-pmd/util.c", "#", 15) - self.dut.send_expect( - "sed -i '/if (ol_flags & PKT_RX_TIMESTAMP)/i\ rte_net_ice_dump_proto_xtr_metadata(mb);' app/test-pmd/util.c", "#", 15) - self.dut.build_install_dpdk(self.dut.target) + self.restore_compilation() - def restory_test_pmd(self): + def set_up(self): """ - Resume editing operation. + Run before each test case. """ - self.dut.send_expect("\cp ./util.c ./app/test-pmd/", "#", 15) - self.dut.send_expect("\cp /root/meson.build ./app/test-pmd/", "#", 15) - self.dut.send_expect("rm -rf /root/meson.build", "#", 15) - self.dut.send_expect("rm -rf ./util.c", "#", 15) - self.dut.build_install_dpdk(self.dut.target) - - def start_testpmd(self, proto_xdr): - """ - start testpmd - """ - num = '4' if self.nic == 'foxville' else '32' - para = '--rxq=%s --txq=%s --portmask=0x1 --nb-cores=%d' % (num, num, self.nb_core) - self.pmdout.start_testpmd("1S/3C/1T", param=para, ports=[self.pci_info], port_options={self.pci_info: 'proto_xtr=%s' % proto_xdr}) - self.pmdout.execute_cmd("set verbose 1", "testpmd> ", 120) - self.pmdout.execute_cmd("set fwd io", "testpmd> ", 120) - self.pmdout.execute_cmd("set promisc all off", "testpmd> ", 120) - self.pmdout.execute_cmd("clear port stats all", "testpmd> ", 120) - self.pmdout.execute_cmd("start", "testpmd> ", 120) + pass - def verify_result(self, fields_list, out, mesg): + def tear_down(self): """ - Validation results + Run after each test case. """ - for field in fields_list: - self.verify(field in out, mesg) - self.dut.send_expect("quit", "#", 15) - - def send_pkts_and_get_output(self, pkts_str): - pkt = Packet(pkts_str) - pkt.send_pkt(self.tester, tx_port=self.tx_interface, count=self.pkg_count, timeout=30) - time.sleep(3) - out_info = self.dut.get_session_output(timeout=3) - return out_info + self.close_testpmd() + time.sleep(2) + self.dut.kill_all() def test_check_single_VLAN_fields_in_RXD_8021Q(self): """ Check single VLAN fields in RXD (802.1Q) """ - self.start_testpmd("vlan") - pkts_str = 'Ether(src="%s", dst="%s", type=0x8100)/Dot1Q(prio=1,vlan=23)/IP()/UDP()/DNS()' % (self.src_mac, self.dst_mac) - out = self.send_pkts_and_get_output(pkts_str) - mesg = "The packet does not carry a VLAN tag." - fields_list = ["vlan"] - self.verify_result(fields_list, out, mesg) + self.check_single_VLAN_fields_in_RXD_8021Q() def test_check_single_VLAN_fields_in_RXD_8021ad(self): """ Check single VLAN fields in RXD (802.1ad) """ - self.start_testpmd("vlan") - pkts_str = 'Ether(src="%s", dst="%s", type=0x88A8)/Dot1Q(prio=1,vlan=23)/IP()/UDP()/DNS()' % (self.src_mac, self.dst_mac) - out = self.send_pkts_and_get_output(pkts_str) - mesg = "stag result is not expected (stag=1:0:23)" - fields_list = ["stag=1:0:23"] - self.verify_result(fields_list, out, mesg) + self.check_single_VLAN_fields_in_RXD_8021ad() def test_check_double_VLAN_fields_in_RXD_8021Q_1_VLAN_tag(self): """ Check double VLAN fields in RXD (802.1Q) only 1 VLAN tag """ - self.start_testpmd("vlan") - pkts_str = 'Ether(src="%s", dst="%s", type=0x9100)/Dot1Q(prio=1,vlan=23)/IP()/UDP()/DNS()' % (self.src_mac, self.dst_mac) - out = self.send_pkts_and_get_output(pkts_str) - mesg = "stag result is not expected (stag=1:0:23)" - fields_list = ["stag=1:0:23"] - self.verify_result(fields_list, out, mesg) + self.check_double_VLAN_fields_in_RXD_8021Q_1_VLAN_tag() def test_check_double_VLAN_fields_in_RXD_8021Q_2_VLAN_tag(self): """ Check double VLAN fields in RXD (802.1Q) 2 VLAN tags """ - self.start_testpmd("vlan") - pkts_str = 'Ether(src="%s", dst="%s", type=0x9100)/Dot1Q(prio=1,vlan=23)/Dot1Q(prio=4,vlan=56)/IP()/UDP()/DNS()' % (self.src_mac, self.dst_mac) - out = self.send_pkts_and_get_output(pkts_str) - mesg = "There are no related fields in the received VLAN packet" - fields_list = ["stag=1:0:23", "ctag=4:0:56"] - self.verify_result(fields_list, out, mesg) + self.check_double_VLAN_fields_in_RXD_8021Q_2_VLAN_tag() def test_check_double_VLAN_fields_in_RXD_8021ad(self): """ Check double VLAN fields in RXD (802.1ad) """ - self.start_testpmd("vlan") - pkts_str = 'Ether(src="%s", dst="%s", type=0x88A8)/Dot1Q(prio=1,vlan=23)/Dot1Q(prio=4,vlan=56)/IP()/UDP()/DNS()' % (self.src_mac, self.dst_mac) - out = self.send_pkts_and_get_output(pkts_str) - mesg = "There are no related fields in the received VLAN packet" - fields_list = ["stag=1:0:23", "ctag=4:0:56"] - self.verify_result(fields_list, out, mesg) + self.check_double_VLAN_fields_in_RXD_8021ad() def test_check_IPv4_fields_in_RXD(self): """ Check IPv4 fields in RXD """ - self.start_testpmd("ipv4") - pkts_str = 'Ether(src="%s", dst="%s")/IP(tos=23, ttl=98)/UDP()/Raw(load="XXXXXXXXXX")' % (self.src_mac, self.dst_mac) - out = self.send_pkts_and_get_output(pkts_str) - mesg = "There are no related fields in the received IPV4 packet" - fields_list = ["ver=4", "hdrlen=5", "tos=23", "ttl=98", "proto=17"] - self.verify_result(fields_list, out, mesg) + self.check_IPv4_fields_in_RXD() def test_check_IPv6_fields_in_RXD(self): """ Check IPv6 fields in RXD """ - self.start_testpmd("ipv6") - pkts_str = 'Ether(src="%s", dst="%s")/IPv6(tc=12,hlim=34,fl=0x98765)/UDP()/Raw(load="XXXXXXXXXX")' % (self.src_mac, self.dst_mac) - out = self.send_pkts_and_get_output(pkts_str) - mesg = "There are no related fields in the received IPV6 packet" - fields_list = ["ver=6", "tc=12", "flow_hi4=0x9", "nexthdr=17", "hoplimit=34"] - self.verify_result(fields_list, out, mesg) + self.check_IPv6_fields_in_RXD() def test_check_IPv6_flow_field_in_RXD(self): """ Check IPv6 flow field in RXD """ - self.start_testpmd("ipv6_flow") - pkts_str = 'Ether(src="%s", dst="%s")/IPv6(tc=12,hlim=34,fl=0x98765)/UDP()/Raw(load="XXXXXXXXXX")' % (self.src_mac, self.dst_mac) - out = self.send_pkts_and_get_output(pkts_str) - mesg = "There are no related fields in the received IPV6_flow packet" - fields_list = ["ver=6", "tc=12", "flow=0x98765"] - self.verify_result(fields_list, out, mesg) + self.check_IPv6_flow_field_in_RXD() def test_check_TCP_fields_in_IPv4_in_RXD(self): """ Check TCP fields in IPv4 in RXD """ - self.start_testpmd("tcp") - pkts_str = 'Ether(src="%s", dst="%s")/IP()/TCP(flags="AS")/Raw(load="XXXXXXXXXX")' % (self.src_mac, self.dst_mac) - out = self.send_pkts_and_get_output(pkts_str) - mesg = "There are no related fields in the received TCP packet" - fields_list = ["doff=5", "flags=AS"] - self.verify_result(fields_list, out, mesg) + self.check_TCP_fields_in_IPv4_in_RXD() def test_check_TCP_fields_in_IPv6_in_RXD(self): """ Check TCP fields in IPv6 in RXD """ - self.start_testpmd("tcp") - pkts_str = 'Ether(src="%s", dst="%s")/IPv6()/TCP(flags="S")/Raw(load="XXXXXXXXXX")' % (self.src_mac, self.dst_mac) - out = self.send_pkts_and_get_output(pkts_str) - mesg = "There are no related fields in the received TCP packet" - fields_list = ["doff=5", "flags=S"] - self.verify_result(fields_list, out, mesg) + self.check_TCP_fields_in_IPv6_in_RXD() def test_check_IPv4_IPv6_TCP_fields_in_RXD_on_specific_queues(self): """ Check IPv4, IPv6, TCP fields in RXD on specific queues """ - self.start_testpmd("'[(2):ipv4,(3):ipv6,(4):tcp]'") - self.dut.send_expect( - "flow create 0 ingress pattern eth dst is %s / ipv4 src is 192.168.0.1 dst is 192.168.0.2 tos is 23 ttl is 98 / end actions queue index 2 / end" % self.dst_mac, "created") - self.dut.send_expect( - "flow create 0 ingress pattern eth / ipv6 src is 2001::3 dst is 2001::4 tc is 12 / end actions queue index 3 / end", "created") - self.dut.send_expect( - "flow create 0 ingress pattern eth dst is %s / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / tcp src is 25 dst is 23 / end actions queue index 4 / end" % self.dst_mac, "created") + self.check_IPv4_IPv6_TCP_fields_in_RXD_on_specific_queues() + + def test_check_testpmd_use_different_parameters(self): + """ + Check testpmd use different parameters start + """ + self.check_testpmd_use_different_parameters() + + def test_check_ip_offset_of_ip(self): + """ + Check ip offset of ip + """ + self.check_ip_offset_of_ip() - # send IPv4 - pkts_str = 'Ether(dst="%s")/IP(src="192.168.0.1",dst="192.168.0.2",tos=23,ttl=98)/UDP()/Raw(load="XXXXXXXXXX")' % (self.dst_mac) - out1 = self.send_pkts_and_get_output(pkts_str) - mesg1 = "There are no relevant fields in the received IPv4 packet." - fields_list1 = ["Receive queue=0x2", "ver=4", "hdrlen=5", "tos=23", "ttl=98", "proto=17"] - for field1 in fields_list1: - self.verify(field1 in out1, mesg1) + def test_check_ip_offset_with_vlan(self): + """ + check ip offset with vlan + """ + self.check_ip_offset_with_vlan() - # send IPv6 - pkts_str = "Ether(src='%s', dst='%s')/IPv6(src='2001::3', dst='2001::4', tc=12,hlim=34,fl=0x98765)/UDP()/Raw(load='XXXXXXXXXX')" % (self.src_mac, self.dst_mac) - out2 = self.send_pkts_and_get_output(pkts_str) - mesg2 = "There are no relevant fields in the received IPv6 packet." - fields_list2 = ["Receive queue=0x3", "ver=6", "tc=12", "flow_hi4=0x9", "nexthdr=17", "hoplimit=34"] - for field2 in fields_list2: - self.verify(field2 in out2, mesg2) + def test_check_ip_offset_with_2_vlan_tag(self): + """ + check offset with 2 vlan tag + """ + self.check_ip_offset_with_2_vlan_tag() - # send TCP - pkts_str = 'Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(flags="AS", dport=23, sport=25)/Raw(load="XXXXXXXXXX")' % (self.dst_mac) - out3 = self.send_pkts_and_get_output(pkts_str) - mesg3 = "There are no relevant fields in the received TCP packet." - fields_list3 = ["Receive queue=0x4", "doff=5", "flags=AS"] - for field3 in fields_list3: - self.verify(field3 in out3, mesg3) - self.dut.send_expect("quit", "#", 15) + def test_check_ip_offset_with_multi_MPLS(self): + """ + check ip offset with multi MPLS + """ + self.check_ip_offset_with_multi_MPLS() - def tear_down(self): + def test_check_ip_offset_with_multi_MPLS_with_vlan_tag(self): """ - Run after each test case. + check ip offset with multi MPLS with vlan tag """ - self.dut.kill_all() - time.sleep(2) + self.check_ip_offset_with_multi_MPLS_with_vlan_tag() - def tear_down_all(self): + def test_check_ip_offset_with_multi_MPLS_with_2_vlan_tag(self): """ - Run after each test suite. + check ip offset with multi MPLS with 2 vlan tag """ - self.restory_test_pmd() + self.check_ip_offset_with_multi_MPLS_with_2_vlan_tag() From patchwork Tue Nov 10 06:18:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yufen.Mo" X-Patchwork-Id: 83878 X-Patchwork-Delegate: zhaoyan.chen@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D19BEA052A; Tue, 10 Nov 2020 07:24:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C80D4BC76; Tue, 10 Nov 2020 07:24:06 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 32FDE69A4 for ; Tue, 10 Nov 2020 07:24:04 +0100 (CET) IronPort-SDR: wymL/xzTBGMYtCM27F5vCjPmyRPeFj/E5X1aorWzeVcAZW2FcHzE4ULASsIB6lR5tVq2lgljxx nO0DATS3D/4w== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="149203860" X-IronPort-AV: E=Sophos;i="5.77,465,1596524400"; d="scan'208";a="149203860" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 22:24:03 -0800 IronPort-SDR: r6xuLQexU4mpNgyU+PYYhFsbavDsAk8l3BbHAMRvTw9O1banxa5G+Py14WxUygC1BY4pCq5sgp lzvG3AUUPE6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,465,1596524400"; d="scan'208";a="529660580" Received: from dpdk-moyufen06.sh.intel.com ([10.67.116.208]) by fmsmga006.fm.intel.com with ESMTP; 09 Nov 2020 22:24:02 -0800 From: yufengmx To: dts@dpdk.org, hailinx.xu@intel.com Cc: yufengmx Date: Tue, 10 Nov 2020 14:18:58 +0800 Message-Id: <20201110061858.5525-4-yufengx.mo@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20201110061858.5525-1-yufengx.mo@intel.com> References: <20201110061858.5525-1-yufengx.mo@intel.com> MIME-Version: 1.0 Subject: [dts] [PATCH V6 3/3] iavf_flexible_descriptor: upload suite X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" upload iavf_flexible_descriptor suite. Signed-off-by: yufengmx --- tests/TestSuite_iavf_flexible_descriptor.py | 246 ++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 tests/TestSuite_iavf_flexible_descriptor.py diff --git a/tests/TestSuite_iavf_flexible_descriptor.py b/tests/TestSuite_iavf_flexible_descriptor.py new file mode 100644 index 0000000..69f38bf --- /dev/null +++ b/tests/TestSuite_iavf_flexible_descriptor.py @@ -0,0 +1,246 @@ +# Copyright (c) <2020> Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# - Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# - Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +# OF THE POSSIBILITY OF SUCH DAMAGE. + + +import time +import traceback + + +from test_case import TestCase +from flexible_common import FlexibleRxdBase + + +class TestIavfFlexibleDescriptor(TestCase, FlexibleRxdBase): + + def preset_compilation(self): + """ + Modify the dpdk code. + """ + cmds = [ + "cd " + self.dut.base_dir, + "cp ./app/test-pmd/util.c .", + r"""sed -i "/if dpdk_conf.has('RTE_NET_IXGBE')/i\if dpdk_conf.has('RTE_NET_ICE')\n\tdeps += ['net_ice', 'net_iavf']\nendif" app/test-pmd/meson.build""", + "sed -i '/#include /a\#include ' app/test-pmd/util.c", + "sed -i '/if (ol_flags & PKT_RX_RSS_HASH)/i\ rte_pmd_ifd_dump_proto_xtr_metadata(mb);' app/test-pmd/util.c", + ] + [self.dut.send_expect(cmd, "#", 15, alt_session=True) for cmd in cmds] + self.dut.build_install_dpdk(self.dut.target) + + def restore_compilation(self): + """ + Resume editing operation. + """ + cmds = [ + "cd " + self.dut.base_dir, + "cp ./util.c ./app/test-pmd/", + "sed -i '/pmd_iavf/d' app/test-pmd/meson.build", + "rm -rf ./util.c", + ] + [self.dut.send_expect(cmd, "#", 15, alt_session=True) for cmd in cmds] + self.dut.build_install_dpdk(self.dut.target) + + def create_vf(self): + # vf relevant content + dut_index = 0 + used_dut_port = self.dut_ports[dut_index] + self.dut.send_expect('modprobe vfio-pci', '#') + # bind pf to kernel + for port in self.dut_ports: + netdev = self.dut.ports_info[port]['port'] + netdev.bind_driver(driver=self.kdriver) + # set vf assign method and vf driver + vf_driver = 'vfio-pci' + # generate 2 VFs on PF + self.dut.generate_sriov_vfs_by_port( + used_dut_port, 1, driver=self.kdriver) + pf0_intf = self.dut.ports_info[self.dut_ports[dut_index]]['intf'] + vf_mac = "00:11:22:33:44:55" + self.dut.send_expect( + 'ip link set {} vf 0 mac {}'.format(pf0_intf, vf_mac), '#') + sriov_vf0 = self.dut.ports_info[used_dut_port]['vfs_port'][0] + sriov_vf0.bind_driver(vf_driver) + return sriov_vf0, vf_mac + + def destroy_vf(self): + try: + port_id = 0 + self.dut.destroy_sriov_vfs_by_port(port_id) + port_obj = self.dut.ports_info[port_id]['port'] + port_obj.bind_driver(self.drivername) + except Exception as e: + self.logger.info(traceback.format_exc()) + + def set_up_all(self): + """ + run at the start of each test suite. + """ + support_nics = [ + "columbiaville_25g", + "columbiaville_100g", + "foxville", + ] + self.verify(self.nic in support_nics, + "flexible rxd only supports CVL NIC.") + self.dut_ports = self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing") + self.preset_compilation() + self.sriov_vf0, vf_mac = self.create_vf() + self.init_base(self.sriov_vf0.pci, vf_mac, "iavf") + + def tear_down_all(self): + """ + Run after each test suite. + """ + self.destroy_vf() + self.restore_compilation() + + def set_up(self): + """ + Run before each test case. + """ + pass + + def tear_down(self): + """ + Run after each test case. + """ + self.close_testpmd() + time.sleep(2) + self.dut.kill_all() + + def test_check_single_VLAN_fields_in_RXD_8021Q(self): + """ + Check single VLAN fields in RXD (802.1Q) + """ + self.check_single_VLAN_fields_in_RXD_8021Q() + + def test_check_single_VLAN_fields_in_RXD_8021ad(self): + """ + Check single VLAN fields in RXD (802.1ad) + """ + self.check_single_VLAN_fields_in_RXD_8021ad() + + def test_check_double_VLAN_fields_in_RXD_8021Q_1_VLAN_tag(self): + """ + Check double VLAN fields in RXD (802.1Q) only 1 VLAN tag + """ + self.check_double_VLAN_fields_in_RXD_8021Q_1_VLAN_tag() + + def test_check_double_VLAN_fields_in_RXD_8021Q_2_VLAN_tag(self): + """ + Check double VLAN fields in RXD (802.1Q) 2 VLAN tags + """ + self.check_double_VLAN_fields_in_RXD_8021Q_2_VLAN_tag() + + def test_check_double_VLAN_fields_in_RXD_8021ad(self): + """ + Check double VLAN fields in RXD (802.1ad) + """ + self.check_double_VLAN_fields_in_RXD_8021ad() + + def test_check_IPv4_fields_in_RXD(self): + """ + Check IPv4 fields in RXD + """ + self.check_IPv4_fields_in_RXD() + + def test_check_IPv6_fields_in_RXD(self): + """ + Check IPv6 fields in RXD + """ + self.check_IPv6_fields_in_RXD() + + def test_check_IPv6_flow_field_in_RXD(self): + """ + Check IPv6 flow field in RXD + """ + self.check_IPv6_flow_field_in_RXD() + + def test_check_TCP_fields_in_IPv4_in_RXD(self): + """ + Check TCP fields in IPv4 in RXD + """ + self.check_TCP_fields_in_IPv4_in_RXD() + + def test_check_TCP_fields_in_IPv6_in_RXD(self): + """ + Check TCP fields in IPv6 in RXD + """ + self.check_TCP_fields_in_IPv6_in_RXD() + + def test_check_IPv4_IPv6_TCP_fields_in_RXD_on_specific_queues(self): + """ + Check IPv4, IPv6, TCP fields in RXD on specific queues + """ + self.check_IPv4_IPv6_TCP_fields_in_RXD_on_specific_queues() + + def test_check_testpmd_use_different_parameters(self): + """ + Check testpmd use different parameters start + """ + self.check_testpmd_use_different_parameters() + + def test_check_ip_offset_of_ip(self): + """ + Check ip offset of ip + """ + self.check_ip_offset_of_ip() + + def test_check_ip_offset_with_vlan(self): + """ + check ip offset with vlan + """ + self.check_ip_offset_with_vlan() + + def test_check_ip_offset_with_2_vlan_tag(self): + """ + check offset with 2 vlan tag + """ + self.check_ip_offset_with_2_vlan_tag() + + def test_check_ip_offset_with_multi_MPLS(self): + """ + check ip offset with multi MPLS + """ + self.check_ip_offset_with_multi_MPLS() + + def test_check_ip_offset_with_multi_MPLS_with_vlan_tag(self): + """ + check ip offset with multi MPLS with vlan tag + """ + self.check_ip_offset_with_multi_MPLS_with_vlan_tag() + + def test_check_ip_offset_with_multi_MPLS_with_2_vlan_tag(self): + """ + check ip offset with multi MPLS with 2 vlan tag + """ + self.check_ip_offset_with_multi_MPLS_with_2_vlan_tag()