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 B512BA04F5; Fri, 19 Jun 2020 05:22:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 89A50F12; Fri, 19 Jun 2020 05:22:06 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 038B3DE3 for ; Fri, 19 Jun 2020 05:22:03 +0200 (CEST) IronPort-SDR: La3syxDgamDDLkXc0xJKEcADh/FAfghkcDAs3WfjBZI2xk0iTAyqmZnwxZDdyPdblXX0wt+0xJ KtlkBZvJl87Q== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="227516020" X-IronPort-AV: E=Sophos;i="5.75,253,1589266800"; d="scan'208";a="227516020" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2020 20:22:03 -0700 IronPort-SDR: i7A9hPPnlHdHGt/NFIZdopJlTBEbPJIsHgdQVZzSeZXtY1W7OISCYR9hMquv2AR+hI+N02pItZ kZaYMfBGOxrw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,253,1589266800"; d="scan'208";a="383714195" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 18 Jun 2020 20:22:02 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 18 Jun 2020 20:22:02 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 18 Jun 2020 20:22:02 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 18 Jun 2020 20:22:02 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.85]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.185]) with mapi id 14.03.0439.000; Fri, 19 Jun 2020 11:21:59 +0800 From: "Tu, Lijuan" To: "He, Zhiwei" , "dts@dpdk.org" CC: "He, Zhiwei" Thread-Topic: [dts] [PATCH V1] tests:Add iavf package and driver error check script for CVL NIC Thread-Index: AQHWOza02ZEmnndMk0OnVqW1M54ZAajfWxvQ Date: Fri, 19 Jun 2020 03:21:57 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BC5F990@SHSMSX101.ccr.corp.intel.com> References: <1591360117-10613-1-git-send-email-zhiwei.he@intel.com> In-Reply-To: <1591360117-10613-1-git-send-email-zhiwei.he@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.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1] tests:Add iavf package and driver error check script for CVL NIC 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 On Behalf Of zhiwei.he Sent: 2020=1B$BG/=1B(B6=1B$B7n=1B(B5=1B$BF|=1B(B 20:29 To: dts@dpdk.org Cc: He, Zhiwei Subject: [dts] [PATCH V1] tests:Add iavf package and driver error check scr= ipt for CVL NIC From: "zhiwei.he" Signed-off-by: zhiwei.he --- .../TestSuite_iavf_package_driver_error_handle.py | 277 +++++++++++++++++= ++++ 1 file changed, 277 insertions(+) create mode 100644 tests/TestSuite_iavf_package_driver_error_handle.py diff --git a/tests/TestSuite_iavf_package_driver_error_handle.py b/tests/Te= stSuite_iavf_package_driver_error_handle.py new file mode 100644 index 0000000..a59b933 --- /dev/null +++ b/tests/TestSuite_iavf_package_driver_error_handle.py @@ -0,0 +1,277 @@ +# BSD LICENSE +# +# Copyright(c) 2019 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without #=20 +modification, are permitted provided that the following conditions #=20 +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 #=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +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 +from config import UserConf + +class Testiavf_package_and_driver_check(TestCase): + + def set_up_all(self): + self.verify(self.nic in ["columbiaville_100g", "columbiaville_25g"= ], "NIC Unsupported: " + str(self.nic)) + self.dut_ports =3D self.dut.get_ports(self.nic) + self.used_dut_port =3D self.dut_ports[0] + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") + self.PF_QUEUE =3D 16 + + conf_file =3D 'conf/iavf_driver_package.cfg' + conf_peer =3D UserConf(conf_file) + conf_session =3D conf_peer.conf._sections['suite'] + self.driverPath_latest =3D conf_session['ice_driver_file_location_= latest'] + self.driverPath_old =3D conf_session['ice_driver_ice_10_rc17_drive= r'] + localPort0 =3D self.tester.get_local_port(self.dut_ports[0]) + self.tester_p0 =3D self.tester.get_interface(localPort0) + self.tester.send_expect("ifconfig %s -promisc" %=20 + self.tester_p0, "#") + + 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_file1 =3D '/lib/firmware/intel/ice/ddp/ice.pkg' + self.pkg_file2 =3D '/lib/firmware/updates/intel/ice/ddp/ice.pkg' + out =3D self.dut.send_expect("ls %s" % self.pkg_file1, "#") + self.verify("No such file or directory" not in out, "Cannot find %= s, please check you system/driver." % self.pkg_file1) + out =3D self.dut.send_expect("ls %s" % self.pkg_file2, "#") + self.verify("No such file or directory" not in out, "Cannot find %= s, please check you system/driver." % self.pkg_file2) + 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.pkg = and /lib/firmware/updates/intel/ice/ddp/ice.pkg to /opt/ice.pkg_backup + else: recover /opt/ice.pkg_backup to /lib/firmware/intel/ice/ddp/i= ce.pkg and /lib/firmware/updates/intel/ice/ddp/ice.pkg + """ + backup_file =3D '/opt/ice.pkg_backup' + if flag =3D=3D "backup": + self.dut.send_expect("\cp %s %s" % (self.pkg_file1, backup_fil= e), "#") + else: + self.dut.send_expect("\cp %s %s" % (backup_file, self.pkg_file= 1), "#") + self.dut.send_expect("\cp %s %s" % (backup_file,=20 + self.pkg_file2), "#") + + def use_correct_ice_pkg(self, flag=3D"true"): + """ + if flag =3D=3D true: use correct /lib/firmware/intel/ice/ddp/ice.p= kg and /lib/firmware/updates/intel/ice/ddp/ice.pkg + else: touch a wrong /lib/firmware/intel/ice/ddp/ice.pkg and /lib/f= irmware/updates/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_file1, "#") + self.dut.send_expect("touch %s" % self.pkg_file1, "#") + self.dut.send_expect("rm -rf %s" % self.pkg_file2, "#") + self.dut.send_expect("touch %s" % self.pkg_file2, "#") + + def start_testpmd(self, ice_pkg=3D"true", safe_mode_support=3D"false")= : + self.eal_param =3D "" + if safe_mode_support =3D=3D "true": + for i in range(len(self.dut_ports)): + self.eal_param =3D self.eal_param + "-w %s,safe-mode-suppo= rt=3D1 " % self.dut.ports_info[i]['pci'] + out =3D self.dut_testpmd.start_testpmd("all", "--nb-cores=3D8 --rx= q=3D%s --txq=3D%s --port-topology=3Dchained" % (self.PF_QUEUE, self.PF_QUEU= E), eal_param=3Dself.eal_param) + if ice_pkg =3D=3D "false": + if safe_mode_support =3D=3D "true": + error_messages =3D ["ice_load_pkg(): failed to allocate bu= f of size 0 for package", \ + "ice_dev_init(): Failed to load the DDP package,Enteri= ng Safe Mode", \ + "ice_init_rss(): RSS is not supported in safe mode"] + if safe_mode_support =3D=3D "false": + error_messages =3D ["ice_load_pkg(): failed to allocate bu= f of size 0 for package", \ + "ice_dev_init(): Failed to load the DDP package,Use sa= fe-mode-support=3D1 to enter Safe Mode"] + for error_message in error_messages: + self.verify(error_message in out, "There should be error m= essages in out: %s" % out) + self.dut_testpmd.execute_cmd('set promisc all off') + self.dut_testpmd.execute_cmd('set verbose 1') + + def number_of_packets(self, iface): + """ + By reading the file generated by tcpdump it counts how many packet= s were + forwarded by the sample app and received in the self.tester. The s= ample 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>/dev/= null | ' + + 'grep -c "IPv4"') + return self.tcpdump_command(command.format(**locals())) + + def send_packet(self, tran_type, flag): + """ + Sends packets. + """ + self.loading_size =3D 30 + self.tester.scapy_foreground() + 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, sel= f.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)], i= face=3D"%s")' % ( + self.dut_p0_mac, self.tester_p0_mac, i + 1, i + 2, sel= f.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)], i= face=3D"%s")' % ( + self.dut_p0_mac, self.tester_p0_mac, i + 1, i + 2, sel= f.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, sel= f.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(src= =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, sel= f.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(src= =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, sel= f.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(src= =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, sel= f.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): + """ + if flag =3D=3D true: all packets should enter different queues of = port 0 + else: all packets enter queue 0 of port 0 + """ + 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: packe= t 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 e= nter the same queue: %s" % queue_list) + else: + self.verify(len(list(set(queue_list))) =3D=3D 1 and int(li= st(set(queue_list))[0]) =3D=3D 0, \ + "All packets should enter queue 0, but=20 + entered %s" % queue_list) + + def test_invalid_pkg_in_iavf(self): + """ + use wrong ice.pkg and start testpmd without "safe-mode-suppor", no= port is loaded in testpmd + """ + self.dut.bind_interfaces_linux('ice') + self.use_correct_ice_pkg(flag=3D"false") + #import pdb + #pdb.set_trace() + self.dut.send_expect("rmmod -f ice","#") =20 + self.dut.send_expect("insmod %s" % self.driverPath_latest, "#")=20 + #self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2) + self.dut.bind_interfaces_linux('ice') + self.used_dut_port_pci=3Dself.dut.ports_info[self.used_dut_port]['= port'].pci + cmd =3D "echo 2 > /sys/bus/pci/devices/%s/sriov_numvfs" % self.use= d_dut_port_pci + out =3D self.dut.send_expect(cmd, "#", 60) + #import pdb + #pdb.set_trace() + self.verify("write error: Operation not supported" in out,=20 + "There should be '%s' in out: %s" % ("write error: Operation not=20 + supported", out)) + + def test_invalid_driver_in_iavf(self): + """ + use wrong ice.pkg and start testpmd without "safe-mode-suppor",= no port is loaded in testpmd + """ + self.dut.bind_interfaces_linux('ice') + self.use_correct_ice_pkg('true') + self.dut.send_expect("rmmod -f ice","#") =20 + self.dut.send_expect("insmod %s" % self.driverPath_old, "#")=20 + =20 + self.used_dut_port_pci=3Dself.dut.ports_info[self.used_dut_port]['port'] + .pci + =20 + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2) + self.sriov_vfs_port =3D=20 + self.dut.ports_info[self.used_dut_port]['vfs_port'] + =20 + for port in self.sriov_vfs_port: + port.bind_driver('vfio-pci') + + testpmdcmd =3D'./x86_64-native-linuxapp-gcc/app/testpmd -l 6-9 = -n 4 --file-prefix=3Dvf -- -i --rxq=3D4 --txq=3D4 --nb-cores=3D2' + self.dut_testpmd.execute_cmd(testpmdcmd) + out=3Dself.dut_testpmd.execute_cmd('flow create 0 ingress patte= rn eth / ipv4 / end actions rss types l3-dst-only end key_len 0 queues end = / end') + self.verify("iavf_flow_create(): Failed to create flow" in=20 + out, "There should be '%s' in out: %s" % ("iavf_flow_create(): Failed=20 + to create flow", out)) + + def copy_specify_ice_pkg(self, pkg_ver): + """ + Copy 2 different ``ice-xxx.pkg`` from dts/dep to dut /tmp/ + pkg_files =3D ['ice-1.3.4.0.pkg', 'ice-1.3.10.0.pkg'] + """ + dst =3D "/tmp" + pkg_file =3D "ice-%s.pkg" % pkg_ver + src_file =3D r'./dep/%s' % pkg_file + self.dut.session.copy_file_to(src_file, dst) + + def generate_delete_specify_pkg(self, pkg_ver, sn, key=3D"true"): + self.dut.send_expect("rm -rf /lib/firmware/intel/ice/ddp/ice-%s.pk= g" % sn, "#") + if key =3D=3D "true": + self.dut.send_expect("\cp /tmp/ice-%s.pkg=20 + /lib/firmware/intel/ice/ddp/ice-%s.pkg" % (pkg_ver, sn), "#") + + 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") -- 1.8.3.1