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 E8749A04F1; Mon, 6 Jan 2020 09:45:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C15781D5FD; Mon, 6 Jan 2020 09:45:29 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 736621D5FC for ; Mon, 6 Jan 2020 09:45:28 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jan 2020 00:45:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,401,1571727600"; d="scan'208";a="394953802" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga005.jf.intel.com with ESMTP; 06 Jan 2020 00:45:27 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Jan 2020 00:45:27 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 6 Jan 2020 00:45:26 -0800 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 6 Jan 2020 00:45:26 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.30]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.89]) with mapi id 14.03.0439.000; Mon, 6 Jan 2020 16:45:24 +0800 From: "Tu, Lijuan" To: "Zhao, XinfengX" , "dts@dpdk.org" CC: "Zhao, XinfengX" Thread-Topic: [dts] [PATCH V1] tests: add new suite for af_xdp_2 test Thread-Index: AQHVwhIBz/VmyNtB7Ei4Xn+vByF9UqfdVxtw Date: Mon, 6 Jan 2020 08:45:24 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BBA241D@SHSMSX101.ccr.corp.intel.com> References: <1578009713-146934-1-git-send-email-xinfengx.zhao@intel.com> In-Reply-To: <1578009713-146934-1-git-send-email-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 new suite for af_xdp_2 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 > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Xinfeng Zhao > Sent: Friday, January 3, 2020 8:02 AM > To: dts@dpdk.org > Cc: Zhao, XinfengX > Subject: [dts] [PATCH V1] tests: add new suite for af_xdp_2 test >=20 > Signed-off-by: Xinfeng Zhao > --- > tests/TestSuite_af_xdp_2.py | 437 > ++++++++++++++++++++++++++++++++++++ > 1 file changed, 437 insertions(+) > create mode 100644 tests/TestSuite_af_xdp_2.py >=20 > diff --git a/tests/TestSuite_af_xdp_2.py b/tests/TestSuite_af_xdp_2.py ne= w > file mode 100644 index 0000000..4397597 > --- /dev/null > +++ b/tests/TestSuite_af_xdp_2.py > @@ -0,0 +1,437 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2019-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 os > +import re > +import time > +from settings import HEADER_SIZE > +from test_case import TestCase > +from packet import Packet > +from pktgen import PacketGeneratorHelper > + > + > +class TestAfXdp(TestCase): > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + #self.verify(self.nic in ("fortville_spirit"), "the port can not= run this > suite") > + self.tester.extend_external_packet_generator(TestAfXdp, self) > + self.frame_sizes =3D [64, 128, 256, 512, 1024, 1518] > + self.dut_ports =3D self.dut.get_ports() > + self.verify(len(self.dut_ports) >=3D 2, "Insufficient ports for > + testing") > + > + self.ports_socket =3D self.dut.get_numa_id(self.dut_ports[0]) > + > + self.header_size =3D HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + > + HEADER_SIZE['udp'] > + > + self.logger.info("you can config packet_size in file %s.cfg," % > self.suite_name + \ > + "in region 'suite' like packet_sizes=3D[64, 128, 256= ]") > + # get the frame_sizes from cfg file > + if 'packet_sizes' in self.get_suite_cfg(): > + self.frame_sizes =3D self.get_suite_cfg()['packet_sizes'] > + > + 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, '# ') > + self.base_dir =3D self.dut.base_dir.replace('~', '/root') > + self.pktgen_helper =3D PacketGeneratorHelper() > + > + self.prepare_dpdk() > + self.dut.restore_interfaces() > + self.irqs_set =3D self.dut.new_session(suite=3D"irqs-set") > + > + def set_up(self): > + pass > + > + def prepare_dpdk(self): > + self.dut.send_expect( > + "sed -i > 's/CONFIG_RTE_LIBRTE_PMD_AF_XDP=3Dn$/CONFIG_RTE_LIBRTE_PMD_AF_XD > P=3Dy/' config/common_base", "# ") > + self.dut.build_install_dpdk(self.dut.target) > + > + def set_port_queue(self, intf): > + self.dut.send_expect("ethtool -L %s combined %d" % (intf, > + self.nb_cores/self.port_num), "# ") > + > + def config_stream(self, rx_port, frame_size): > + payload =3D frame_size - self.header_size > + tgen_input =3D [] > + > + dst_mac =3D self.dut.get_mac_address(self.dut_ports[rx_port]) > + flow =3D 'Ether(dst=3D"%s")/IP(dst=3D"192.168.%d.1", > proto=3D255)/UDP()/("X"*%d)' % (dst_mac, rx_port+1, payload) > + pkt =3D Packet(pkt_str=3Dflow) > + pcap =3D os.path.join(self.out_path, "af_xdp_%d_%d_%d.pcap" % > + (self.port_num, rx_port, frame_size)) > + pkt.save_pcapfile(None, pcap) > + tgen_input.append((rx_port, rx_port, pcap)) > + > + return tgen_input > + > + def config_rule_stream(self, rule_index, frame_size): > + payload =3D frame_size - self.header_size > + tgen_input =3D [] > + > + rule =3D self.rule[rule_index] > + flow =3D 'Ether()/IP()/UDP(sport=3D%d, dport=3D%d)/("X"*%d)' % (= rule[-2], > rule[-1], payload) > + pkt =3D Packet(pkt_str=3Dflow) > + pcap =3D os.path.join(self.out_path, "af_xdp_%d_%d.pcap" % > + (rule[-2], frame_size)) > + pkt.save_pcapfile(None, pcap) > + tgen_input.append((rule[0], rule[0], pcap)) > + > + return tgen_input > + > + def ethtool_set_rule(self): > + rule_id, rule =3D 1, [] > + for i in range(self.port_num): > + intf =3D self.dut.ports_info[i]['port'].get_interface_name() > + self.irqs_set.send_expect("ethtool -N %s rx-flow-hash udp4 f= n" % intf, > "# ") > + self.irqs_set.send_expect("ethtool -N %s flow-type udp4 src-= port > 4243 dst-port 4243 action 0 loc %d" > + % (intf, rule_id), "# ") > + self.irqs_set.send_expect("ethtool -N %s flow-type udp4 src-= port > 4242 dst-port 4242 action 1 loc %d" > + % (intf, rule_id + 1), "# ") > + rule.append((i, intf, rule_id, 4243, 4243)) > + rule.append((i, intf, rule_id+1, 4242, 4242)) > + rule_id +=3D 2 > + time.sleep(1) > + self.rule =3Drule > + > + def ethtool_del_rule(self): > + for each in self.rule: > + self.irqs_set.send_expect("ethtool -N %s delete %d" % > + (each[1], each[2]), "# ") > + > + def get_core_list(self): > + core_config =3D "1S/%dC/1T" % (self.nb_cores + 1 + max(self.port= _num, > self.vdev_num) * self.queue_number) > + self.core_list =3D self.dut.get_core_list( > + core_config, socket=3Dself.ports_socket) > + > + def assign_port_core(self, separate=3DTrue): > + if separate: > + core_list =3D self.core_list[-max(self.port_num, self.vdev_n= um) * > self.queue_number:] > + else: > + core_list =3D self.core_list[:-max(self.port_num, self.vdev_= num) * > self.queue_number]\ > + [-max(self.port_num, > + self.vdev_num) * self.queue_number:] > + > + for i in range(self.port_num): > + intf =3D self.dut.ports_info[i]['port'].get_interface_name() > + cores =3D ','.join(core_list[i * self.queue_number: (i+1) * > self.queue_number]) > + if self.port_num =3D=3D 1 and self.vdev_num =3D=3D 2: > + cores =3D ','.join(core_list) > + command =3D "%s/set_irq_affinity %s %s" % ("/root", cores, i= ntf) > + out =3D self.irqs_set.send_expect(command, "# ") > + self.verify("No such file or directory" not in out, "can not= find the > set_irq_affinity in dut root") > + time.sleep(1) > + > + def get_vdev_list(self): > + vdev_list =3D [] > + > + if self.port_num =3D=3D 1: > + intf =3D self.dut.ports_info[0]['port'].get_interface_name() > + self.set_port_queue(intf) > + time.sleep(1) > + for i in range(self.vdev_num): > + vdev =3D '' > + vdev =3D > "net_af_xdp%d,iface=3D%s,start_queue=3D%d,queue_count=3D%d" % (i, intf, i= * > self.queue_number, self.queue_number) > + vdev_list.append(vdev) > + else: > + for i in range(self.port_num): > + vdev =3D '' > + intf =3D self.dut.ports_info[i]['port'].get_interface_na= me() > + self.set_port_queue(intf) > + vdev =3D "net_af_xdp%d,iface=3D%s" % (i, intf) > + vdev_list.append(vdev) > + > + return vdev_list > + > + def launch_testpmd(self, fwd_mode=3D'', topology=3D'', rss_ip=3DFals= e): > + self.get_core_list() > + > + vdev =3D self.get_vdev_list() > + > + if topology: > + topology =3D "--port-topology=3D%s" % topology > + if fwd_mode: > + fwd_mode =3D "--forward-mode=3D%s" % fwd_mode > + if rss_ip: > + rss_ip =3D "--rss-ip" > + else: > + rss_ip =3D "" > + > + eal_params =3D self.dut.create_eal_parameters(cores=3Dself.core_= list[:- > max(self.port_num, self.vdev_num) * self.queue_number], > + vdevs=3Dvdev, no_pci=3DTrue) > + command_line =3D "./%s/app/testpmd %s --log-level=3Dpmd.net.af_x= dp:8 -- > -i %s %s --auto-start --nb-cores=3D%d --rxq=3D%d --txq=3D%d %s" > + command =3D command_line % (self.dut.target, eal_params, fwd_mod= e, > rss_ip, > + self.nb_cores, self.queue_number, self.queue_number, > + topology) > + > + self.logger.info('start testpmd') > + self.dut.send_expect(command, "testpmd> ", 120) > + > + def create_table(self, index=3D1): > + if self.port_num =3D=3D2 or index =3D=3D 2: > + self.table_header =3D ["FrameSize(B)", "Queue number", "Port= 0 > Throughput(Mpps)", > + "Port0 % linerate", "Port1 Throughput(Mpps)", "Port1= % linerate"] > + else: > + self.table_header =3D ["FrameSize(B)", "Queue number", "Port > Throughput(Mpps)", > + "Port % linerate"] > + self.result_table_create(self.table_header) > + > + def update_table_info(self, *param): > + for each in param: > + self.result_table_add(each) > + > + def calculate_avg_throughput(self, frame_size, tgen_input, fwd_mode)= : > + """ > + 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 > + > + if fwd_mode !=3D "rxonly": > + self.verify(Mpps > 0, "can not receive packets of frame size= %d" % > (frame_size)) > + throughput =3D Mpps * 100 / \ > + float(self.wirespeed(self.nic, frame_size, 1)) > + > + return Mpps, throughput > + > + def check_packets_of_each_port(self, port_index): > + """ > + check each port has receive packets > + """ > + info =3D re.findall("Forward statistics for port %d" % > + port_index, self.out) > + index =3D self.out.find(info[0]) > + rx =3D re.search("RX-packets:\s*(\d*)", self.out[index:]) > + tx =3D re.search("TX-packets:\s*(\d*)", self.out[index:]) > + rx_packets =3D int(rx.group(1)) > + tx_packets =3D int(tx.group(1)) > + self.verify(rx_packets > 0 and tx_packets > 0, > + "rx-packets:%d, tx-packets:%d" % > + (rx_packets, tx_packets)) > + > + def check_packets_of_each_queue(self, port_index): > + """ > + check port queue has receive packets > + """ > + for queue_index in range(0, self.queue_number): > + queue_info =3D re.findall("RX\s*Port=3D\s*%d/Queue=3D\s*%d" = % > + (port_index, queue_index), self.out) > + queue =3D queue_info[0] > + index =3D self.out.find(queue) > + rx =3D re.search("RX-packets:\s*(\d*)", self.out[index:]) > + tx =3D re.search("TX-packets:\s*(\d*)", self.out[index:]) > + rx_packets =3D int(rx.group(1)) > + tx_packets =3D int(tx.group(1)) > + self.verify(rx_packets > 0 and tx_packets > 0, > + "The port %s queue %d, rx-packets:%d, tx-packets:%d"= % > + (port_index, queue_index, rx_packets, tx_packets)) > + > + def check_packets_of_all_queue(self, port_num): > + """ > + check all queue has receive packets > + """ > + for port_index in range(0, port_num): > + self.check_packets_of_each_queue(port_index) > + > + def send_and_verify_throughput(self, pkt_type=3D'', fwd_mode=3D""): > + for frame_size in self.frame_sizes: > + info =3D "Running test %s, and %d frame size." % (self.runni= ng_case, > frame_size) > + self.logger.info(info) > + > + result =3D [frame_size, self.queue_number] > + > + if pkt_type.lower() =3D=3D "udp": > + num =3D len(self.rule) > + else: > + num =3D self.port_num > + > + for i in range(num): > + if pkt_type.lower() =3D=3D "udp": > + tgen_input =3D self.config_rule_stream(i, frame_size= ) > + else: > + tgen_input =3D self.config_stream(i, frame_size) > + > + Mpps, throughput =3D self.calculate_avg_throughput(frame= _size, > tgen_input, fwd_mode) > + result.append(Mpps) > + result.append(throughput) > + > + self.out =3D self.dut.send_expect("stop", "testpmd> ", > + 60) > + > + if self.queue_number =3D=3D 1: > + self.check_packets_of_each_port(i) > + elif self.vdev_num =3D=3D 2: > + self.check_packets_of_all_queue(2) > + else: > + self.check_packets_of_each_queue(i) > + > + self.dut.send_expect("start", "testpmd> ", 60) > + > + self.update_table_info(result) > + > + # check the throughput between two port > + if len(result) =3D=3D 6: > + self.verify(round((result[-2] - result[-4])/result[-4], = 2) <=3D 0.1, > + "The gap is too big btween two port's > + throughput") > + > + def test_perf_one_port_single_queue_and_separate_irqs(self): > + """ > + single port test with PMD and IRQs are pinned to separate cores > + """ > + self.nb_cores =3D 1 > + self.queue_number =3D 1 > + self.port_num =3D 1 > + self.vdev_num =3D 1 > + > + self.create_table() > + self.launch_testpmd(topology=3D"loop") > + self.assign_port_core() > + self.send_and_verify_throughput() > + > + self.result_table_print() > + > + def test_perf_one_port_multiqueue_and_separate_irqs(self): > + """ > + multiqueue test with PMD and IRQs are pinned to separate cores > + """ > + self.nb_cores =3D 2 > + self.queue_number =3D 2 > + self.port_num =3D 1 > + self.vdev_num =3D 1 > + > + self.create_table() > + self.launch_testpmd(topology=3D"loop") > + self.assign_port_core() > + self.send_and_verify_throughput() > + > + self.result_table_print() > + > + def test_perf_one_port_multiqueue_and_same_irqs(self): > + """ > + multiqueue test with PMD and IRQs pinned to same cores > + """ > + self.nb_cores =3D 2 > + self.queue_number =3D 2 > + self.port_num =3D 1 > + self.vdev_num =3D 1 > + > + self.create_table() > + self.launch_testpmd(topology=3D"loop") > + self.assign_port_core(separate=3DFalse) > + self.send_and_verify_throughput() > + > + self.result_table_print() > + > + def test_perf_two_port_and_separate_irqs(self): > + """ > + two port test with PMD and IRQs are pinned to separate cores > + """ > + self.nb_cores =3D 2 > + self.queue_number =3D 1 > + self.port_num =3D 2 > + self.vdev_num =3D 2 > + > + self.create_table() > + self.launch_testpmd(topology=3D"loop") > + self.assign_port_core() > + self.send_and_verify_throughput() > + > + self.result_table_print() > + > + def test_perf_two_port_and_same_irqs(self): > + """ > + two ports test with PMD and IRQs pinned to same cores > + """ > + self.nb_cores =3D 2 > + self.queue_number =3D 1 > + self.port_num =3D 2 > + self.vdev_num =3D 2 > + > + self.create_table() > + self.launch_testpmd(topology=3D"loop") > + self.assign_port_core(separate=3DFalse) > + self.send_and_verify_throughput() > + > + self.result_table_print() > + > + def test_perf_one_port_single_queue_with_two_vdev(self): > + """ > + one port with two vdev and single queue test > + """ > + self.nb_cores =3D 2 > + self.queue_number =3D 1 > + self.port_num =3D 1 > + self.vdev_num =3D 2 > + > + self.create_table(2) > + self.launch_testpmd(topology=3D"loop") > + self.assign_port_core() > + self.ethtool_set_rule() > + self.send_and_verify_throughput(pkt_type=3D'udp') > + self.ethtool_del_rule() > + > + self.result_table_print() > + > + def test_perf_one_port_multiqueues_with_two_vdev(self): > + """ > + one port with two vdev and multi-queues test > + """ > + self.nb_cores =3D 8 > + self.queue_number =3D 4 > + self.port_num =3D 1 > + self.vdev_num =3D 2 > + > + self.create_table() > + self.launch_testpmd(topology=3D"loop", rss_ip=3DTrue) > + self.assign_port_core() > + self.send_and_verify_throughput() > + > + self.result_table_print() > + > + def tear_down(self): > + self.dut.send_expect("quit", "#", 60) > + > + def tear_down_all(self): > + self.dut.kill_all() > + > + self.dut.send_expect( > + "sed -i > 's/CONFIG_RTE_LIBRTE_PMD_AF_XDP=3Dy$/CONFIG_RTE_LIBRTE_PMD_AF_XD > P=3Dn/' config/common_base", "# ") > + self.dut.build_install_dpdk(self.dut.target) > -- > 2.17.1