From: "Wang, Yinan" <yinan.wang@intel.com>
To: "Zhao, XinfengX" <xinfengx.zhao@intel.com>,
"dts@dpdk.org" <dts@dpdk.org>
Subject: Re: [dts] [PATCH V1] tests: add new suite for af_xdp_2 test
Date: Mon, 6 Jan 2020 08:19:34 +0000 [thread overview]
Message-ID: <E0CBA5A1980F1F408E1F28F9991B5B1D50F79D8C@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <44051B25D8C8784BB77FFB604D6A70CA120B78E3@shsmsx102.ccr.corp.intel.com>
Acked-by: Wang, Yinan <yinan.wang@intel.com>
> -----Original Message-----
> From: Zhao, XinfengX <xinfengx.zhao@intel.com>
> Sent: 2020年1月3日 16:45
> To: dts@dpdk.org; Wang, Yinan <yinan.wang@intel.com>
> Subject: RE: [dts][PATCH V1] tests: add new suite for af_xdp_2 test
>
> Tested-by: Zhao, Xinfeng<xinfengx.zhao@intel.com>
>
> -----Original Message-----
> From: Zhao, XinfengX
> Sent: Friday, January 3, 2020 8:02 AM
> To: dts@dpdk.org
> Cc: Zhao, XinfengX <xinfengx.zhao@intel.com>
> Subject: [dts][PATCH V1] tests: add new suite for af_xdp_2 test
>
> Signed-off-by: Xinfeng Zhao <xinfengx.zhao@intel.com>
> ---
> tests/TestSuite_af_xdp_2.py | 437
> ++++++++++++++++++++++++++++++++++++
> 1 file changed, 437 insertions(+)
> create mode 100644 tests/TestSuite_af_xdp_2.py
>
> diff --git a/tests/TestSuite_af_xdp_2.py b/tests/TestSuite_af_xdp_2.py new 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 = [64, 128, 256, 512, 1024, 1518]
> + self.dut_ports = self.dut.get_ports()
> + self.verify(len(self.dut_ports) >= 2, "Insufficient ports for
> + testing")
> +
> + self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
> +
> + self.header_size = 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=[64, 128, 256]")
> + # get the frame_sizes from cfg file
> + if 'packet_sizes' in self.get_suite_cfg():
> + self.frame_sizes = self.get_suite_cfg()['packet_sizes']
> +
> + self.out_path = '/tmp'
> + out = 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 = self.dut.base_dir.replace('~', '/root')
> + self.pktgen_helper = PacketGeneratorHelper()
> +
> + self.prepare_dpdk()
> + self.dut.restore_interfaces()
> + self.irqs_set = self.dut.new_session(suite="irqs-set")
> +
> + def set_up(self):
> + pass
> +
> + def prepare_dpdk(self):
> + self.dut.send_expect(
> + "sed -i
> 's/CONFIG_RTE_LIBRTE_PMD_AF_XDP=n$/CONFIG_RTE_LIBRTE_PMD_AF_XDP
> =y/' 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 = frame_size - self.header_size
> + tgen_input = []
> +
> + dst_mac = self.dut.get_mac_address(self.dut_ports[rx_port])
> + flow = 'Ether(dst="%s")/IP(dst="192.168.%d.1",
> proto=255)/UDP()/("X"*%d)' % (dst_mac, rx_port+1, payload)
> + pkt = Packet(pkt_str=flow)
> + pcap = 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 = frame_size - self.header_size
> + tgen_input = []
> +
> + rule = self.rule[rule_index]
> + flow = 'Ether()/IP()/UDP(sport=%d, dport=%d)/("X"*%d)' % (rule[-2],
> rule[-1], payload)
> + pkt = Packet(pkt_str=flow)
> + pcap = 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 = 1, []
> + for i in range(self.port_num):
> + intf = self.dut.ports_info[i]['port'].get_interface_name()
> + self.irqs_set.send_expect("ethtool -N %s rx-flow-hash udp4 fn" %
> 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 += 2
> + time.sleep(1)
> + self.rule =rule
> +
> + 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 = "1S/%dC/1T" % (self.nb_cores + 1 + max(self.port_num,
> self.vdev_num) * self.queue_number)
> + self.core_list = self.dut.get_core_list(
> + core_config, socket=self.ports_socket)
> +
> + def assign_port_core(self, separate=True):
> + if separate:
> + core_list = self.core_list[-max(self.port_num, self.vdev_num) *
> self.queue_number:]
> + else:
> + core_list = 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 = self.dut.ports_info[i]['port'].get_interface_name()
> + cores = ','.join(core_list[i * self.queue_number: (i+1) *
> self.queue_number])
> + if self.port_num == 1 and self.vdev_num == 2:
> + cores = ','.join(core_list)
> + command = "%s/set_irq_affinity %s %s" % ("/root", cores, intf)
> + out = 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 = []
> +
> + if self.port_num == 1:
> + intf = 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 = ''
> + vdev =
> "net_af_xdp%d,iface=%s,start_queue=%d,queue_count=%d" % (i, intf, i *
> self.queue_number, self.queue_number)
> + vdev_list.append(vdev)
> + else:
> + for i in range(self.port_num):
> + vdev = ''
> + intf = self.dut.ports_info[i]['port'].get_interface_name()
> + self.set_port_queue(intf)
> + vdev = "net_af_xdp%d,iface=%s" % (i, intf)
> + vdev_list.append(vdev)
> +
> + return vdev_list
> +
> + def launch_testpmd(self, fwd_mode='', topology='', rss_ip=False):
> + self.get_core_list()
> +
> + vdev = self.get_vdev_list()
> +
> + if topology:
> + topology = "--port-topology=%s" % topology
> + if fwd_mode:
> + fwd_mode = "--forward-mode=%s" % fwd_mode
> + if rss_ip:
> + rss_ip = "--rss-ip"
> + else:
> + rss_ip = ""
> +
> + eal_params =
> self.dut.create_eal_parameters(cores=self.core_list[:-max(self.port_num,
> self.vdev_num) * self.queue_number],
> + vdevs=vdev, no_pci=True)
> + command_line = "./%s/app/testpmd %s
> --log-level=pmd.net.af_xdp:8 -- -i %s %s --auto-start --nb-cores=%d --rxq=%d
> --txq=%d %s"
> + command = command_line % (self.dut.target, eal_params,
> fwd_mode, 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=1):
> + if self.port_num ==2 or index == 2:
> + self.table_header = ["FrameSize(B)", "Queue number", "Port0
> Throughput(Mpps)",
> + "Port0 % linerate", "Port1 Throughput(Mpps)",
> "Port1 % linerate"]
> + else:
> + self.table_header = ["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 = {'delay': 5}
> +
> + # clear streams before add new streams
> + self.tester.pktgen.clear_streams()
> +
> + # run packet generator
> + fields_config = {'ip': {'dst': {'action': 'random'}, }, }
> + streams =
> self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100,
> + fields_config,
> self.tester.pktgen)
> + _, pps =
> + self.tester.pktgen.measure_throughput(stream_ids=streams,
> + options=traffic_opt)
> +
> + Mpps = pps / 1000000.0
> +
> + if fwd_mode != "rxonly":
> + self.verify(Mpps > 0, "can not receive packets of frame size %d" %
> (frame_size))
> + throughput = 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 = re.findall("Forward statistics for port %d" %
> + port_index, self.out)
> + index = self.out.find(info[0])
> + rx = re.search("RX-packets:\s*(\d*)", self.out[index:])
> + tx = re.search("TX-packets:\s*(\d*)", self.out[index:])
> + rx_packets = int(rx.group(1))
> + tx_packets = 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 = re.findall("RX\s*Port=\s*%d/Queue=\s*%d" %
> + (port_index, queue_index), self.out)
> + queue = queue_info[0]
> + index = self.out.find(queue)
> + rx = re.search("RX-packets:\s*(\d*)", self.out[index:])
> + tx = re.search("TX-packets:\s*(\d*)", self.out[index:])
> + rx_packets = int(rx.group(1))
> + tx_packets = 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='', fwd_mode=""):
> + for frame_size in self.frame_sizes:
> + info = "Running test %s, and %d frame size." %
> (self.running_case, frame_size)
> + self.logger.info(info)
> +
> + result = [frame_size, self.queue_number]
> +
> + if pkt_type.lower() == "udp":
> + num = len(self.rule)
> + else:
> + num = self.port_num
> +
> + for i in range(num):
> + if pkt_type.lower() == "udp":
> + tgen_input = self.config_rule_stream(i, frame_size)
> + else:
> + tgen_input = self.config_stream(i, frame_size)
> +
> + Mpps, throughput =
> self.calculate_avg_throughput(frame_size, tgen_input, fwd_mode)
> + result.append(Mpps)
> + result.append(throughput)
> +
> + self.out = self.dut.send_expect("stop", "testpmd> ",
> + 60)
> +
> + if self.queue_number == 1:
> + self.check_packets_of_each_port(i)
> + elif self.vdev_num == 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) == 6:
> + self.verify(round((result[-2] - result[-4])/result[-4], 2) <= 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 = 1
> + self.queue_number = 1
> + self.port_num = 1
> + self.vdev_num = 1
> +
> + self.create_table()
> + self.launch_testpmd(topology="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 = 2
> + self.queue_number = 2
> + self.port_num = 1
> + self.vdev_num = 1
> +
> + self.create_table()
> + self.launch_testpmd(topology="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 = 2
> + self.queue_number = 2
> + self.port_num = 1
> + self.vdev_num = 1
> +
> + self.create_table()
> + self.launch_testpmd(topology="loop")
> + self.assign_port_core(separate=False)
> + 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 = 2
> + self.queue_number = 1
> + self.port_num = 2
> + self.vdev_num = 2
> +
> + self.create_table()
> + self.launch_testpmd(topology="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 = 2
> + self.queue_number = 1
> + self.port_num = 2
> + self.vdev_num = 2
> +
> + self.create_table()
> + self.launch_testpmd(topology="loop")
> + self.assign_port_core(separate=False)
> + 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 = 2
> + self.queue_number = 1
> + self.port_num = 1
> + self.vdev_num = 2
> +
> + self.create_table(2)
> + self.launch_testpmd(topology="loop")
> + self.assign_port_core()
> + self.ethtool_set_rule()
> + self.send_and_verify_throughput(pkt_type='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 = 8
> + self.queue_number = 4
> + self.port_num = 1
> + self.vdev_num = 2
> +
> + self.create_table()
> + self.launch_testpmd(topology="loop", rss_ip=True)
> + 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=y$/CONFIG_RTE_LIBRTE_PMD_AF_XDP
> =n/' config/common_base", "# ")
> + self.dut.build_install_dpdk(self.dut.target)
> --
> 2.17.1
next prev parent reply other threads:[~2020-01-06 8:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-03 0:01 Xinfeng Zhao
2020-01-03 8:44 ` Zhao, XinfengX
2020-01-06 8:19 ` Wang, Yinan [this message]
2020-01-06 8:45 ` Tu, Lijuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E0CBA5A1980F1F408E1F28F9991B5B1D50F79D8C@SHSMSX104.ccr.corp.intel.com \
--to=yinan.wang@intel.com \
--cc=dts@dpdk.org \
--cc=xinfengx.zhao@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).