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 28CE1A00C2; Thu, 23 Apr 2020 07:50:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0A7641C257; Thu, 23 Apr 2020 07:50:09 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 6BB291C24F for ; Thu, 23 Apr 2020 07:50:07 +0200 (CEST) IronPort-SDR: glMlAQM8xfOMEaBQuSU0Vj5SY17ggWkP5TWs/ufr+saHxZoExZ5YgHIv8salVU7dNXf821c07j Ke6KrBumumkQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2020 22:50:06 -0700 IronPort-SDR: 7IdHYRR27+EMfNRiYMRfAzeZVRx/s6kFk0q3KioXRmkPAu/Z+DJJphNIE74wmoAzTArgY3Ev6K DeiIARof0Fvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,305,1583222400"; d="scan'208";a="259313884" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga006.jf.intel.com with ESMTP; 22 Apr 2020 22:50:06 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 22 Apr 2020 22:49:45 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 22 Apr 2020 22:49:44 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.129]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.146]) with mapi id 14.03.0439.000; Thu, 23 Apr 2020 13:49:38 +0800 From: "Tu, Lijuan" To: "Zhao, XinfengX" , "dts@dpdk.org" CC: "Zhao, XinfengX" Thread-Topic: [dts] [PATCH V1] tests: add a new suite for ntb test Thread-Index: AQHWGE/RW8GBXsC3tkie2nLC6ZOvNqiGNUwQ Date: Thu, 23 Apr 2020 05:49:37 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BC0F19A@SHSMSX101.ccr.corp.intel.com> References: <20200421193713.5407-1-xinfengx.zhao@intel.com> In-Reply-To: <20200421193713.5407-1-xinfengx.zhao@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="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1] tests: add a new suite for ntb test 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 xinfengx > Sent: Wednesday, April 22, 2020 3:37 AM > To: dts@dpdk.org > Cc: Zhao, XinfengX > Subject: [dts] [PATCH V1] tests: add a new suite for ntb test >=20 > Signed-off-by: xinfengx > --- > tests/TestSuite_ntb.py | 340 > +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 340 insertions(+) > create mode 100644 tests/TestSuite_ntb.py >=20 > diff --git a/tests/TestSuite_ntb.py b/tests/TestSuite_ntb.py new file mod= e > 100644 index 0000000..e01bd4b > --- /dev/null > +++ b/tests/TestSuite_ntb.py > @@ -0,0 +1,340 @@ > +# BSD LICENSE > +# > +# 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 os > +import re > +import time > +from test_case import TestCase > +from net_device import GetNicObj > +from settings import HEADER_SIZE > +from packet import Packet > +from pktgen import PacketGeneratorHelper > + > +class TestNtb(TestCase): > + > + def set_up_all(self): > + self.verify(len(self.duts) >=3D 2, "Insufficient duts for NTB!!!= ") > + self.ntb_host =3D self.duts[0] > + self.ntb_client =3D self.duts[1] > + > + # each dut required one ports > + self.verify(len(self.ntb_host.get_ports()) >=3D 1 and > + len(self.ntb_client.get_ports()) >=3D 1, > + "Insufficient ports for testing") > + > + self.host_port =3D self.ntb_host.get_ports()[0] > + self.client_port =3D self.ntb_client.get_ports()[0] > + self.host_mac =3D self.ntb_host.get_mac_address(self.host_port) > + self.client_mac =3D > + self.ntb_client.get_mac_address(self.client_port) > + > + self.tester.extend_external_packet_generator(TestNtb, self) > + self.frame_sizes =3D [64, 128, 256, 512, 1024, 1518] > + self.header_size =3D HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + > HEADER_SIZE['udp'] > + self.pktgen_helper =3D PacketGeneratorHelper() > + > + self.out_path =3D '/tmp' > + out =3D self.tester.send_expect('ls -d %s' % self.out_path, '# '= ) > + if 'No such file or directory' in out: > + self.tester.send_expect('mkdir -p %s' % self.out_path, '# ') > + out =3D self.ntb_host.send_expect('ls -d %s' % self.out_path, '#= ') > + if 'No such file or directory' in out: > + self.ntb_host.send_expect('mkdir -p %s' % self.out_path, '# > + ') > + > + self.prepare_dpdk_app(self.ntb_host) > + self.prepare_dpdk_app(self.ntb_client) > + > + def set_up(self): > + pass > + > + def create_table(self, index=3D1): > + self.table_header =3D ["FrameSize(B)", "Throughput(Mpps)", "% li= nerate"] > + self.result_table_create(self.table_header) > + > + def prepare_dpdk_app(self, crb): > + out =3D crb.send_expect("ls ./" + crb.target + "/kmod/igb_uio.ko= ", "#", 10) > + if "No such file or directory" in out: > + crb.build_install_dpdk(crb.target) > + > + out =3D crb.build_dpdk_apps("./examples/ntb") > + self.verify("Error" not in out, "Compilation error") > + self.verify("No such" not in out, "Compilation error") > + > + def get_core_list(self): > + core_number =3D 5 > + core_config =3D '1S/{}C/1T'.format(core_number) > + self.host_core_list =3D self.ntb_host.get_core_list(core_config) > + self.client_core_list =3D self.ntb_client.get_core_list(core_con= fig) > + self.verify(len(self.host_core_list) >=3D core_number and > len(self.client_core_list) >=3D core_number, > + 'There have not enough cores to start testpmd on > + duts') > + > + def get_ntb_port(self, crb): > + device =3D crb.send_expect("lspci -D | grep Non-Transparent |awk= '{{print > $1}}'", "# ", 10) > + self.verify(device, "Falied to find ntb device") > + addr_array =3D device.strip().split(':') > + domain_id =3D addr_array[0] > + bus_id =3D addr_array[1] > + devfun_id =3D addr_array[2] > + port =3D GetNicObj(crb, domain_id, bus_id, devfun_id) > + return port > + > + def set_driver(self, driver=3D""): > + self.ntb_host.restore_interfaces() > + self.ntb_client.restore_interfaces() > + > + for crb in [self.ntb_host, self.ntb_client]: > + crb.setup_modules(crb.target, driver, None) > + if driver =3D=3D "igb_uio": > + crb.send_expect("rmmod -f igb_uio", "#", 30) > + crb.send_expect("insmod ./" + crb.target + "/kmod/igb_ui= o.ko > wc_activate=3D1", "#", 30) > + if driver =3D=3D "vfio-pci": > + crb.send_expect("echo 'base=3D0x39bfa0000000 size=3D0x40= 0000 > type=3Dwrite-combining' >> /proc/mtrr", "#", 10) > + crb.send_expect("echo 'base=3D0x39bfa0000000 > + size=3D0x4000000 type=3Dwrite-combining' >> /proc/mtrr", "#", 10) > + > + def port_bind_driver(self, driver=3D""): > + self.ntb_host.bind_interfaces_linux(driver=3Ddriver) > + self.ntb_client.bind_interfaces_linux(driver=3Ddriver) > + > + def ntb_bind_driver(self, driver=3D""): > + ntb =3D self.get_ntb_port(self.ntb_host) > + ntb.bind_driver(driver) > + > + ntb =3D self.get_ntb_port(self.ntb_client) > + ntb.bind_driver(driver) > + > + def launch_ntb_fwd(self, **param): > + """ > + launch ntb_fwd on ntb host and ntb client > + """ > + cmd_opt =3D " ".join(["{}=3D{}".format(key, param[key]) for key = in > + param.keys()]) > + > + self.get_core_list() > + app =3D "./examples/ntb/build/ntb_fwd" > + eal_host =3D > self.ntb_host.create_eal_parameters(cores=3Dself.host_core_list) > + eal_client =3D > self.ntb_client.create_eal_parameters(cores=3Dself.client_core_list) > + host_cmd_line =3D ' '.join([app, eal_host, cmd_opt]) > + client_cmd_line =3D ' '.join([app, eal_client, cmd_opt]) > + self.ntb_host.send_expect(host_cmd_line, 'Checking ntb link stat= us', 30) > + self.ntb_client.send_expect(client_cmd_line, 'Checking ntb link = status', > 30) > + time.sleep(3) > + self.ntb_host.send_expect(" ", 'ntb> ', 10) > + self.ntb_client.send_expect(" ", 'ntb> ', 10) > + > + def start_ntb_fwd_on_dut(self, crb, fwd_mode=3D'io'): > + crb.send_expect('set fwd %s' % fwd_mode, 'ntb> ', 30) > + crb.send_expect('start', 'ntb> ', 30) > + > + def config_stream(self, frame_size): > + payload =3D frame_size - self.header_size > + tgen_input =3D [] > + > + for i, each_mac in enumerate([self.host_mac, self.client_mac]): > + flow =3D 'Ether(dst=3D"%s")/IP(dst=3D"192.168.%d.1", > proto=3D255)/UDP()/("X"*%d)' % (each_mac, i, payload) > + pkt =3D Packet(pkt_str=3Dflow) > + pcap =3D os.path.join(self.out_path, "ntb_%d_%d.pcap" % > + (i, frame_size)) > + pkt.save_pcapfile(None, pcap) > + tgen_input.append((i, (i+1)%2, pcap)) > + > + return tgen_input > + > + def calculate_avg_throughput(self, frame_size, tgen_input): > + """ > + send packet and get the throughput > + """ > + # set traffic option > + traffic_opt =3D {'delay': 5} > + > + # clear streams before add new streams > + self.tester.pktgen.clear_streams() > + > + # run packet generator > + fields_config =3D {'ip': {'dst': {'action': 'random'}, }, } > + streams =3D > self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100, > + fields_config, self.tester.p= ktgen) > + _, pps =3D > + self.tester.pktgen.measure_throughput(stream_ids=3Dstreams, > + options=3Dtraffic_opt) > + > + Mpps =3D pps / 1000000.0 > + > + throughput =3D Mpps * 100 / \ > + float(self.wirespeed(self.nic, frame_size, 1)) > + return Mpps, throughput > + > + def get_packets_of_each_port(self, crb): > + out =3D crb.send_expect('show port stats', 'ntb> ', 10) > + info =3D re.findall("statistics for NTB port", out) > + index =3D out.find(info[0]) > + tx =3D re.search("Tx-packets:\s*(\d*)", out[index:]) > + rx =3D re.search("Rx-packets:\s*(\d*)", out[index:]) > + rx_packets =3D int(rx.group(1)) > + tx_packets =3D int(tx.group(1)) > + self.logger.info("tx-packets:%d, rx-packets:%d" % > + (tx_packets, rx_packets)) > + return tx_packets, rx_packets > + > + def check_packets_for_iofwd(self): > + """ > + check transmit/receive packets for iofwd mode > + """ > + tx, rx =3D self.get_packets_of_each_port(self.ntb_host) > + self.verify(tx > 0 and rx > 0, > + "tx-packets:%d, rx-packets:%d" % (tx, rx)) > + > + tx, rx =3D self.get_packets_of_each_port(self.ntb_client) > + self.verify(tx > 0 and rx > 0, > + "tx-packets:%d, rx-packets:%d" % (tx, rx)) > + > + def check_packets_for_rxtx(self): > + """ > + check transmit/receive packets for rxonly and txonly mode > + """ > + tx, rx =3D self.get_packets_of_each_port(self.ntb_host) > + self.verify(tx =3D=3D 0 and rx > 0, > + "tx-packets:%d, rx-packets:%d" % (tx, rx)) > + > + tx, rx =3D self.get_packets_of_each_port(self.ntb_client) > + self.verify(tx > 0 and rx =3D=3D 0, > + "tx-packets:%d, rx-packets:%d" % (tx, rx)) > + > + def send_file_and_verify(self): > + # Send file from host > + src_file =3D "{}/ntb.txt".format(self.out_path) > + base_dir =3D self.ntb_client.base_dir.replace('~', '/root') > + dst_file =3D "{}/ntb_recv_file0".format(base_dir) > + content =3D "ntb!123" > + self.ntb_client.alt_session.send_expect("rm {}".format(dst_file)= , '# ') > + self.ntb_host.alt_session.send_expect("echo '{}' >{}".format(con= tent, > src_file), '# ') > + self.ntb_host.send_expect('send {}'.format(src_file), 'ntb> ', 3= 0) > + time.sleep(3) > + > + # Check file received on client. > + cnt =3D self.ntb_client.alt_session.send_expect('cat %s' % dst_f= ile, '# ') > + self.verify(cnt =3D=3D content, "the content can't match with th= e > + sent") > + > + def send_pkg_and_verify(self): > + for frame_size in self.frame_sizes: > + info =3D "Running test: %s, frame size: %d." % (self.running= _case, > frame_size) > + self.logger.info(info) > + self.ntb_host.send_expect("stop", "ntb> ", 60) > + self.ntb_host.send_expect("start", "ntb> ", 60) > + self.ntb_client.send_expect("stop", "ntb> ", 60) > + self.ntb_client.send_expect("start", "ntb> ", 60) > + time.sleep(1) > + > + result =3D [frame_size] > + tgen_input =3D self.config_stream(frame_size) > + Mpps, throughput =3D self.calculate_avg_throughput(frame_siz= e, > tgen_input) > + result.append(Mpps) > + result.append(throughput) > + > + self.check_packets_for_iofwd() > + self.update_table_info(result) > + > + def test_file_tran_mode_and_igb_uio(self): > + driver =3D "igb_uio" > + self.set_driver(driver) > + self.ntb_bind_driver(driver) > + > + self.launch_ntb_fwd(**{"buf-size": 65407}) > + self.start_ntb_fwd_on_dut(self.ntb_host, fwd_mode=3D"file-trans"= ) > + self.start_ntb_fwd_on_dut(self.ntb_client, fwd_mode=3D"file-tran= s") > + self.send_file_and_verify() > + > + def test_file_tran_mode_and_vfio_pci(self): > + driver =3D "vfio-pci" > + self.set_driver(driver) > + self.ntb_bind_driver(driver) > + > + self.launch_ntb_fwd(**{"buf-size": 65407}) > + self.start_ntb_fwd_on_dut(self.ntb_host, fwd_mode=3D"file-trans"= ) > + self.start_ntb_fwd_on_dut(self.ntb_client, fwd_mode=3D"file-tran= s") > + self.send_file_and_verify() > + > + def test_pkt_rxtx_mode_and_igb_uio(self): > + driver =3D "igb_uio" > + self.set_driver(driver) > + self.ntb_bind_driver(driver) > + > + self.launch_ntb_fwd(**{"buf-size": 65407}) > + self.start_ntb_fwd_on_dut(self.ntb_host, fwd_mode=3D"rxonly") > + self.start_ntb_fwd_on_dut(self.ntb_client, fwd_mode=3D"txonly") > + time.sleep(1) > + self.check_packets_for_rxtx() > + > + def test_pkt_rxtx_mode_and_vfio_pci(self): > + driver =3D "vfio-pci" > + self.set_driver(driver) > + self.ntb_bind_driver(driver) > + > + self.launch_ntb_fwd(**{"buf-size": 65407}) > + self.start_ntb_fwd_on_dut(self.ntb_host, fwd_mode=3D"rxonly") > + self.start_ntb_fwd_on_dut(self.ntb_client, fwd_mode=3D"txonly") > + time.sleep(1) > + self.check_packets_for_rxtx() > + > + def test_perf_iofwd_mode_and_igb_uio(self): > + driver =3D "igb_uio" > + self.set_driver(driver) > + self.ntb_bind_driver(driver) > + self.port_bind_driver(driver) > + > + self.create_table() > + self.launch_ntb_fwd(**{"burst": 32}) > + self.start_ntb_fwd_on_dut(self.ntb_host, fwd_mode=3D"iofwd") > + self.start_ntb_fwd_on_dut(self.ntb_client, fwd_mode=3D"iofwd") > + self.send_pkg_and_verify() > + > + self.result_table_print() > + > + def test_perf_iofwd_mode_and_vfio_pci(self): > + driver =3D "vfio-pci" > + self.set_driver(driver) > + self.ntb_bind_driver(driver) > + self.port_bind_driver(driver) > + > + self.create_table() > + self.launch_ntb_fwd(**{"burst": 32}) > + self.start_ntb_fwd_on_dut(self.ntb_host, fwd_mode=3D"iofwd") > + self.start_ntb_fwd_on_dut(self.ntb_client, fwd_mode=3D"iofwd") > + self.send_pkg_and_verify() > + > + self.result_table_print() > + > + def update_table_info(self, *param): > + for each in param: > + self.result_table_add(each) > + > + def tear_down(self): > + self.ntb_host.send_expect('quit', '# ', 30) > + self.ntb_client.send_expect('quit', '# ', 30) > + > + def tear_down_all(self): > + self.ntb_host.kill_all() > + self.ntb_client.kill_all() > -- > 2.17.1