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 B996AA046B for ; Thu, 27 Jun 2019 08:56:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 61B76DED; Thu, 27 Jun 2019 08:56:02 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 1855B2AB for ; Thu, 27 Jun 2019 08:55:59 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2019 23:55:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,422,1557212400"; d="scan'208";a="173030264" Received: from ubuntu.sh.intel.com ([10.67.119.68]) by orsmga002.jf.intel.com with ESMTP; 26 Jun 2019 23:55:57 -0700 From: lihong To: dts@dpdk.org Cc: yinan.wang@intel.com, lihong Date: Thu, 27 Jun 2019 07:34:08 +0800 Message-Id: <1561592048-2504-1-git-send-email-lihongx.ma@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [PATCH V2] tests: add testsuite pvp virtio user 2M hugepages 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" Signed-off-by: lihong --- tests/TestSuite_pvp_virtio_user_2M_hugepages.py | 180 ++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 tests/TestSuite_pvp_virtio_user_2M_hugepages.py diff --git a/tests/TestSuite_pvp_virtio_user_2M_hugepages.py b/tests/TestSuite_pvp_virtio_user_2M_hugepages.py new file mode 100644 index 0000000..56f285a --- /dev/null +++ b/tests/TestSuite_pvp_virtio_user_2M_hugepages.py @@ -0,0 +1,180 @@ +# BSD LICENSE +# +# Copyright(c) <2019> 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. + +""" +DPDK Test suite. +vhost/virtio-user pvp with 2M hugepage. +""" + +import utils +import time +from test_case import TestCase +from settings import HEADER_SIZE +from pktgen import PacketGeneratorHelper + + +class TestPVPVirtioWith2Mhuge(TestCase): + + def set_up_all(self): + """ + Run at the start of each test suite. + """ + hugepages_size = self.dut.send_expect("awk '/Hugepagesize/ {print $2}' /proc/meminfo", "# ") + self.verify(int(hugepages_size) == 2048, "Please config you hugepages_size to 2048") + self.core_config = "1S/4C/1T" + self.dut_ports = self.dut.get_ports() + self.ports_socket = self.dut.get_numa_id(self.dut_ports[0]) + self.cores_num = len([n for n in self.dut.cores if int(n['socket']) == + self.ports_socket]) + self.verify(len(self.dut_ports) >= 1, "Insufficient ports for testing") + self.verify(self.cores_num >= 4, + "There has not enought cores to test this suite %s" % + self.suite_name) + + self.core_list = self.dut.get_core_list( + self.core_config, socket=self.ports_socket) + self.core_list_virtio_user = self.core_list[0:2] + self.core_list_vhost_user = self.core_list[2:4] + self.core_mask_virtio_user = utils.create_mask(self.core_list_virtio_user) + self.core_mask_vhost_user = utils.create_mask(self.core_list_vhost_user) + self.mem_channels = self.dut.get_memory_channels() + self.dst_mac = self.dut.get_mac_address(self.dut_ports[0]) + self.header_size = HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + HEADER_SIZE['tcp'] + self.frame_sizes = [64, 128, 256, 512, 1024, 1518] + self.logger.info("You can config packet_size in file %s.cfg," % self.suite_name + \ + " in region 'suite' like packet_sizes=[64, 128, 256]") + if 'packet_sizes' in self.get_suite_cfg(): + self.frame_sizes = self.get_suite_cfg()['packet_sizes'] + # create an instance to set stream field setting + self.pktgen_helper = PacketGeneratorHelper() + + def set_up(self): + """ + Run before each test case. + """ + self.dut.send_expect("rm -rf ./vhost-net*", "# ") + self.dut.send_expect("killall -s INT testpmd", "# ") + self.vhost_user = self.dut.new_session(suite="vhost-user") + self.virtio_user = self.dut.new_session(suite="virtio-user") + # Prepare the result table + self.table_header = ['Frame'] + self.table_header.append("Mode") + self.table_header.append("Mpps") + self.table_header.append("Queue Num") + self.table_header.append("% linerate") + self.result_table_create(self.table_header) + + def send_and_verify(self): + """ + Send packet with packet generator and verify + """ + for frame_size in self.frame_sizes: + payload_size = frame_size - self.header_size + tgen_input = [] + rx_port = self.tester.get_local_port(self.dut_ports[0]) + tx_port = self.tester.get_local_port(self.dut_ports[0]) + self.tester.scapy_append( + 'wrpcap("vhost.pcap", [Ether(dst="%s")/IP()/TCP()/("X"*%d)])' % + (self.dst_mac, payload_size)) + tgen_input.append((tx_port, rx_port, "vhost.pcap")) + + self.tester.scapy_execute() + self.tester.pktgen.clear_streams() + streams = self.pktgen_helper.prepare_stream_from_tginput(tgen_input, 100, + None, self.tester.pktgen) + _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams) + Mpps = pps / 1000000.0 + self.verify(Mpps > 0, "%s can not receive packets" % (self.running_case)) + throughput = Mpps * 100 / \ + float(self.wirespeed(self.nic, 64, 1)) + + results_row = [frame_size] + results_row.append("2M Hugepages") + results_row.append(Mpps) + results_row.append("1") + results_row.append(throughput) + self.result_table_add(results_row) + + def start_testpmd_as_vhost(self): + """ + start testpmd on vhost + """ + command_line_client = "%s/app/testpmd -c %s -n %d " + \ + "--socket-mem 1024,1024 --file-prefix=vhost " + \ + "--vdev 'net_vhost0,iface=vhost-net,queues=1' -- -i" + command_line_client = command_line_client % (self.target, + self.core_mask_vhost_user, self.mem_channels) + self.vhost_user.send_expect(command_line_client, "testpmd> ", 120) + self.vhost_user.send_expect("start", "testpmd> ", 120) + + def start_testpmd_as_virtio(self): + """ + start testpmd on virtio + """ + command_line_user = "./%s/app/testpmd -n %d -c %s " + \ + "--no-pci --socket-mem 1024,1024 " + \ + "--file-prefix=virtio-user --single-file-segments " + \ + "--vdev=net_virtio_user0,mac=00:11:22:33:44:10,path=./vhost-net,queues=1 -- -i" + command_line_user = command_line_user % (self.target, + self.mem_channels, self.core_mask_virtio_user) + self.virtio_user.send_expect(command_line_user, "testpmd> ", 120) + self.virtio_user.send_expect("start", "testpmd> ", 120) + + def close_all_apps(self): + """ + close testpmd and vhost-switch + """ + self.virtio_user.send_expect("quit", "# ", 60) + self.vhost_user.send_expect("quit", "# ", 60) + self.dut.close_session(self.vhost_user) + self.dut.close_session(self.virtio_user) + + def test_perf_pvp_virtio_user_with_2M_hugepages(self): + """ + Basic test for virtio-user 2M hugepage + """ + self.start_testpmd_as_vhost() + self.start_testpmd_as_virtio() + self.send_and_verify() + self.result_table_print() + self.close_all_apps() + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.send_expect("killall -s INT testpmd", "# ") + + def tear_down_all(self): + """ + Run after each test suite. + """ + pass -- 2.7.4