From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 635C0A0487 for ; Wed, 3 Jul 2019 08:13:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5B5824D27; Wed, 3 Jul 2019 08:13:52 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 5689C2B99 for ; Wed, 3 Jul 2019 08:13:50 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2019 23:13:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,446,1557212400"; d="scan'208";a="154654766" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga007.jf.intel.com with ESMTP; 02 Jul 2019 23:13:47 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 2 Jul 2019 23:13:44 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 2 Jul 2019 23:13:44 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.134]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.240]) with mapi id 14.03.0439.000; Wed, 3 Jul 2019 14:13:37 +0800 From: "Tu, Lijuan" To: "Li, WenjieX A" , "dts@dpdk.org" CC: "Peng, Yuan" , "Li, WenjieX A" Thread-Topic: [dts] [PATCH V1] tests: add new script enable_package_download_in_ice_driver Thread-Index: AQHVLLvuxMjZwJCNgkCj6/Ag89z336a4c2kw Date: Wed, 3 Jul 2019 06:13:36 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BADA434@SHSMSX101.ccr.corp.intel.com> References: <1561653562-14740-1-git-send-email-wenjiex.a.li@intel.com> <1561653562-14740-3-git-send-email-wenjiex.a.li@intel.com> In-Reply-To: <1561653562-14740-3-git-send-email-wenjiex.a.li@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2E2MjgxOGMtMjhhNC00OGI1LWJiZTMtOTRmNmEwYjFmZWMwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSTVVWWJSZGM2UFhtVTFQcTFBXC9ZNUx4RnJtd2YxXC9VeU9HWWJVR2dSNFRyWnB0bmMzVDBHbW95YTRyWUs4RCtiIn0= x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1] tests: add new script enable_package_download_in_ice_driver 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" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Wenjie Li > Sent: Friday, June 28, 2019 12:39 AM > To: dts@dpdk.org > Cc: Peng, Yuan ; Li, WenjieX A > > Subject: [dts] [PATCH V1] tests: add new script > enable_package_download_in_ice_driver >=20 > add new script >=20 > Signed-off-by: Wenjie Li > --- > ...e_enable_package_download_in_ice_driver.py | 270 ++++++++++++++++++ > 1 file changed, 270 insertions(+) > create mode 100644 > tests/TestSuite_enable_package_download_in_ice_driver.py >=20 > diff --git a/tests/TestSuite_enable_package_download_in_ice_driver.py > b/tests/TestSuite_enable_package_download_in_ice_driver.py > new file mode 100644 > index 0000000..b5e3e2f > --- /dev/null > +++ b/tests/TestSuite_enable_package_download_in_ice_driver.py > @@ -0,0 +1,270 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2019 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 > +import re > +import os > +from test_case import TestCase > +from pmd_output import PmdOutput > + > +class TestEnable_Package_Download_In_Ice_Driver(TestCase): > + > + def set_up_all(self): > + self.verify(self.nic in ["columbiaville_100g", "columbiaville_25= g"], "NIC > Unsupported: " + str(self.nic)) > + self.dut_ports =3D self.dut.get_ports(self.nic) > + self.verify(len(self.dut_ports) >=3D 2, "Insufficient ports") > + self.PF_QUEUE =3D 16 > + > + localPort0 =3D self.tester.get_local_port(self.dut_ports[0]) > + localPort1 =3D self.tester.get_local_port(self.dut_ports[1]) > + self.tester_p0 =3D self.tester.get_interface(localPort0) > + self.tester_p1 =3D self.tester.get_interface(localPort1) > + self.tester.send_expect("ifconfig %s -promisc" % self.tester_p0,= "#") > + self.tester.send_expect("ifconfig %s -promisc" % > + self.tester_p1, "#") > + > + self.dut_p0_mac =3D self.dut.get_mac_address(self.dut_ports[0]) > + self.tester_p0_mac =3D self.tester.get_mac(localPort0) > + self.dut_testpmd =3D PmdOutput(self.dut) > + > + self.pkg_file =3D '/lib/firmware/intel/ice/ddp/ice.pkg' > + out =3D self.dut.send_expect("ls %s" % self.pkg_file, "#") > + self.verify("No such file or directory" not in out, "Cannot find= %s, > please check you system/driver." % self.pkg_file) > + self.backup_recover_ice_pkg("backup") > + > + def set_up(self): > + pass > + > + def backup_recover_ice_pkg(self, flag=3D"backup"): > + """ > + if backup =3D=3D true: backup /lib/firmware/intel/ice/ddp/ice.pk= g to > ~/ice.pkg_backup > + else: recover ~/ice.pkg_backup to /lib/firmware/intel/ice/ddp/ic= e.pkg > + """ > + backup_file =3D '/opt/ice.pkg_backup' > + if flag =3D=3D "backup": > + self.dut.send_expect("\cp %s %s" % (self.pkg_file, backup_fi= le), "#") > + else: > + self.dut.send_expect("\cp %s %s" % (backup_file, > + self.pkg_file), "#") > + > + def use_correct_ice_pkg(self, flag=3D"true"): > + """ > + if flag =3D=3D true: use /lib/firmware/intel/ice/ddp/ice.pkg > + else: touch a wrong /lib/firmware/intel/ice/ddp/ice.pkg > + """ > + if flag =3D=3D "true": > + self.backup_recover_ice_pkg("recover") > + else: > + self.dut.send_expect("rm -rf %s" % self.pkg_file, "#") > + self.dut.send_expect("touch %s" % self.pkg_file, "#") > + > + def start_testpmd(self, flag=3D"true"): > + out =3D self.dut_testpmd.start_testpmd("all", "--nb-cores=3D8 --= rxq=3D%s -- > txq=3D%s --port-topology=3Dchained" % (self.PF_QUEUE, self.PF_QUEUE)) > + if flag !=3D "true": > + error_messages =3D ["ice_load_pkg(): failed to allocate buf = of size 0 for > package", \ > + "ice_load_pkg(): failed to allocate buf of size 0 fo= r package", \ > + "ice_dev_init(): Failed to load the DDP package,Ente= ring Safe > Mode", \ > + "ice_init_rss(): RSS is not supported in safe mode"] > + for error_message in error_messages: > + self.verify(error_message in out, "There should be error= messages > in out: %s" % out) > + self.dut_testpmd.execute_cmd('set promisc all off') > + self.dut_testpmd.execute_cmd('set verbose 1') > + > + def tcpdump_start_sniffing(self, ifaces=3D[]): > + """ > + Starts tcpdump in the background to sniff the tester interface w= here > + the packets are transmitted to and from the self.dut. > + All the captured packets are going to be stored in a file for a > + post-analysis. > + """ > + > + for iface in ifaces: > + command =3D ('tcpdump -w tcpdump_{0}.pcap -i {0} > 2>tcpdump_{0}.out &').format(iface) > + del_cmd =3D ('rm -f tcpdump_{0}.pcap').format(iface) > + self.tester.send_expect(del_cmd, '#') > + self.tester.send_expect(command, '#') > + > + def tcpdump_stop_sniff(self): > + """ > + Stops the tcpdump process running in the background. > + """ > + self.tester.send_expect('killall tcpdump', '#') > + time.sleep(1) > + self.tester.send_expect('echo "Cleaning buffer"', '#') > + time.sleep(1) > + > + def tcpdump_command(self, command): > + """ > + Sends a tcpdump related command and returns an integer from the > output > + """ > + result =3D self.tester.send_expect(command, '#') > + print result > + return int(result.strip()) > + > + def number_of_packets(self, iface): > + """ > + By reading the file generated by tcpdump it counts how many pack= ets > were > + forwarded by the sample app and received in the self.tester. The > sample app > + will add a known MAC address for the test to look for. > + """ > + command =3D ('tcpdump -A -nn -e -v -r tcpdump_{iface}.pcap 2>/de= v/null > | ' + > + 'grep -c "IPv4"') > + return self.tcpdump_command(command.format(**locals())) > + > + def tcpdump_scanner(self, scanner): > + """ > + Execute scanner to return results > + """ > + scanner_result =3D self.tester.send_expect(scanner, '#') > + fially_result =3D re.findall(r'length( \d+)', scanner_result) > + return list(fially_result) > + > + def send_packet(self, tran_type, flag): > + """ > + Sends packets. > + """ > + self.loading_size =3D 30 > + self.tester.scapy_foreground() > + self.tester.scapy_append('sys.path.append("./")') > + self.tester.scapy_append('from sctp import *') > + if tran_type =3D=3D "ipv4-other": > + for i in range(1): > + packet =3D r'sendp([Ether(dst=3D"%s", src=3D"%s")/IP(src= =3D"192.168.0.%d", > dst=3D"192.168.0.%d")/("X"*%s)], iface=3D"%s")' % ( > + self.dut_p0_mac, self.tester_p0_mac, i + 1, i + 2, > self.loading_size, self.tester_p0) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv4-tcp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", src=3D"%s")/IP(src= =3D"192.168.0.%d", > dst=3D"192.168.0.%d")/TCP(sport=3D1024,dport=3D1024)], iface=3D"%s")' % ( > + self.dut_p0_mac, self.tester_p0_mac, i + 1, i + 2, s= elf.tester_p0) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv4-udp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", src=3D"%s")/IP(src= =3D"192.168.0.%d", > dst=3D"192.168.0.%d")/UDP(sport=3D1024,dport=3D1024)], iface=3D"%s")' % ( > + self.dut_p0_mac, self.tester_p0_mac, i + 1, i + 2, s= elf.tester_p0) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv4-sctp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", src=3D"%s")/IP(src= =3D"192.168.0.%d", > dst=3D"192.168.0.%d")/SCTP(sport=3D1024,dport=3D1024)], iface=3D"%s")' % = ( > + self.dut_p0_mac, self.tester_p0_mac, i + 1, i + 2, s= elf.tester_p0) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv6-tcp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", src=3D"%s")/IPv6(s= rc=3D"::%d", > dst=3D"::%d")/TCP(sport=3D1024,dport=3D1024)], iface=3D"%s")' % ( > + self.dut_p0_mac, self.tester_p0_mac, i + 1, i + 2, s= elf.tester_p0) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv6-udp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", src=3D"%s")/IPv6(s= rc=3D"::%d", > dst=3D"::%d")/UDP(sport=3D1024,dport=3D1024)], iface=3D"%s")' % ( > + self.dut_p0_mac, self.tester_p0_mac, i + 1, i + 2, s= elf.tester_p0) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "ipv6-sctp": > + for i in range(16): > + packet =3D r'sendp([Ether(dst=3D"%s", src=3D"%s")/IPv6(s= rc=3D"::%d", > dst=3D"::%d",nh=3D132)/SCTP(sport=3D1024,dport=3D1024)], iface=3D"%s")' %= ( > + self.dut_p0_mac, self.tester_p0_mac, i + 1, i + 2, s= elf.tester_p0) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + else: > + print "\ntran_type error!\n" > + > + self.verifyResult(tran_type=3Dtran_type, flag=3Dflag) > + > + def verifyResult(self, tran_type, flag): > + """ > + Verify whether or not the result passes. > + """ > + if tran_type =3D=3D "ipv4-other": > + self.tcpdump_stop_sniff() > + p0_stats =3D self.number_of_packets(self.tester_p0) > + p1_stats =3D self.number_of_packets(self.tester_p1) > + self.verify(p0_stats =3D=3D p1_stats, "tester p0 and p1: pac= ket number > match") > + else: > + out =3D self.dut.get_session_output() > + queue_list =3D [] > + lines =3D out.split("\r\n") > + for line in lines: > + line =3D line.strip() > + if len(line) !=3D 0 and line.startswith(("port 0/queue "= ,)): > + for item in line.split(":"): > + item =3D item.strip() > + if(item.startswith("port 0/queue ")): > + queue_id =3D item.split(" ", 2)[-1] > + queue_list.append(queue_id) > + print list(set(queue_list)) > + if flag =3D=3D "true": > + self.verify(len(list(set(queue_list))) > 1, "All packets= enter the same > queue: %s" % queue_list) > + else: > + self.verify(len(list(set(queue_list))) =3D=3D 1 and > int(list(set(queue_list))[0]) =3D=3D 0, \ > + "All packets should enter queue 0, but > + entered %s" % queue_list) > + > + def download_the_package(self, flag): > + """ > + if flag =3D=3D true: use the correct ice.pkg file; in rxonly mod= e, all packets > should enter different queues of port 0 > + else: use wrong ice.pkg, all packets enter queue 0 of port 0 > + """ > + self.use_correct_ice_pkg(flag=3Dflag) > + self.start_testpmd(flag=3Dflag) > + self.dut_testpmd.execute_cmd('set fwd mac') > + self.dut_testpmd.execute_cmd('start') > + self.tcpdump_start_sniffing([self.tester_p0, self.tester_p1]) > + self.send_packet(tran_type=3D"ipv4-other", flag=3Dflag) > + > + self.dut_testpmd.execute_cmd('stop') > + self.dut_testpmd.execute_cmd('set fwd rxonly') > + self.dut_testpmd.execute_cmd('start') > + for tran_types in ["ipv4-tcp", "ipv4-udp", "ipv4-sctp", "ipv6-tc= p", "ipv6- > udp", "ipv6-sctp"]: > + print tran_types > + self.send_packet(tran_type=3Dtran_types, flag=3Dflag) > + > + def test_download_the_package_successfully(self): > + self.download_the_package(flag=3D"true") > + > + def test_download_the_package_failed(self): > + self.download_the_package(flag=3D"false") > + > + def tear_down(self): > + self.dut_testpmd.quit() > + > + def tear_down_all(self): > + """ > + After test, recover the default ice.pkg > + """ > + self.backup_recover_ice_pkg("recover") > -- > 2.17.1