Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/86079/?format=api
http://patches.dpdk.org/api/patches/86079/?format=api", "web_url": "http://patches.dpdk.org/project/dts/patch/20210107103507.3793974-1-weix.ling@intel.com/", "project": { "id": 3, "url": "http://patches.dpdk.org/api/projects/3/?format=api", "name": "DTS", "link_name": "dts", "list_id": "dts.dpdk.org", "list_email": "dts@dpdk.org", "web_url": "", "scm_url": "git://dpdk.org/tools/dts", "webscm_url": "http://git.dpdk.org/tools/dts/", "list_archive_url": "https://inbox.dpdk.org/dts", "list_archive_url_format": "https://inbox.dpdk.org/dts/{}", "commit_url_format": "" }, "msgid": "<20210107103507.3793974-1-weix.ling@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dts/20210107103507.3793974-1-weix.ling@intel.com", "date": "2021-01-07T10:35:07", "name": "[V1] tests/vswitch_sample_cbdma:add test suite sync with test plan", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "3128cf19b315abed6749f5469c18bf78210779df", "submitter": { "id": 1828, "url": "http://patches.dpdk.org/api/people/1828/?format=api", "name": "Ling, WeiX", "email": "weix.ling@intel.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dts/patch/20210107103507.3793974-1-weix.ling@intel.com/mbox/", "series": [ { "id": 14565, "url": "http://patches.dpdk.org/api/series/14565/?format=api", "web_url": "http://patches.dpdk.org/project/dts/list/?series=14565", "date": "2021-01-07T10:35:07", "name": "[V1] tests/vswitch_sample_cbdma:add test suite sync with test plan", "version": 1, "mbox": "http://patches.dpdk.org/series/14565/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/86079/comments/", "check": "pending", "checks": "http://patches.dpdk.org/api/patches/86079/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dts-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id D74F8A09FF;\n\tThu, 7 Jan 2021 03:42:25 +0100 (CET)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id CF91A140E6C;\n\tThu, 7 Jan 2021 03:42:25 +0100 (CET)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by mails.dpdk.org (Postfix) with ESMTP id 520A5140E49\n for <dts@dpdk.org>; Thu, 7 Jan 2021 03:42:23 +0100 (CET)", "from fmsmga008.fm.intel.com ([10.253.24.58])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 06 Jan 2021 18:42:21 -0800", "from unknown (HELO localhost.localdomain) ([10.240.183.222])\n by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 06 Jan 2021 18:42:20 -0800" ], "IronPort-SDR": [ "\n OXH6YRQJ1OwJjHZE5j7YSJnyc8V8roh7PJYCJyCVDSey4OLaYPTO8a16huUMvoQt/5QaC5uXfQ\n NVwn1Vr02u4w==", "\n Nw2g24IOzNKa1gTEVwGvNMBYcraPuQe7Oh9+hLyF2m18gTewggwb15A3WH/yYV78N3jLR913cW\n cwgXfSPWoxyg==" ], "X-IronPort-AV": [ "E=McAfee;i=\"6000,8403,9856\"; a=\"164435096\"", "E=Sophos;i=\"5.79,328,1602572400\"; d=\"scan'208\";a=\"164435096\"", "E=Sophos;i=\"5.79,328,1602572400\"; d=\"scan'208\";a=\"351097627\"" ], "From": "Ling Wei <weix.ling@intel.com>", "To": "dts@dpdk.org", "Cc": "Ling Wei <weix.ling@intel.com>", "Date": "Thu, 7 Jan 2021 10:35:07 +0000", "Message-Id": "<20210107103507.3793974-1-weix.ling@intel.com>", "X-Mailer": "git-send-email 2.25.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "quoted-printable", "Subject": "[dts] [PATCH V1] tests/vswitch_sample_cbdma:add test suite sync\n with test plan", "X-BeenThere": "dts@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "test suite reviews and discussions <dts.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dts>,\n <mailto:dts-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dts/>", "List-Post": "<mailto:dts@dpdk.org>", "List-Help": "<mailto:dts-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dts>,\n <mailto:dts-request@dpdk.org?subject=subscribe>", "Errors-To": "dts-bounces@dpdk.org", "Sender": "\"dts\" <dts-bounces@dpdk.org>" }, "content": "add test suite sync with test plan\n\nSigned-off-by: Ling Wei <weix.ling@intel.com>\n---\n tests/TestSuite_vswitch_sample_cbdma.py | 625 ++++++++++++++++++++++++\n 1 file changed, 625 insertions(+)\n create mode 100644 tests/TestSuite_vswitch_sample_cbdma.py", "diff": "diff --git a/tests/TestSuite_vswitch_sample_cbdma.py b/tests/TestSuite_vswitch_sample_cbdma.py\nnew file mode 100644\nindex 00000000..f0b8330c\n--- /dev/null\n+++ b/tests/TestSuite_vswitch_sample_cbdma.py\n@@ -0,0 +1,625 @@\n+# BSD LICENSE\r\n+#\r\n+# Copyright(c) <2019> Intel Corporation. All rights reserved.\r\n+# All rights reserved.\r\n+#\r\n+# Redistribution and use in source and binary forms, with or without\r\n+# modification, are permitted provided that the following conditions\r\n+# are met:\r\n+#\r\n+# * Redistributions of source code must retain the above copyright\r\n+# notice, this list of conditions and the following disclaimer.\r\n+# * Redistributions in binary form must reproduce the above copyright\r\n+# notice, this list of conditions and the following disclaimer in\r\n+# the documentation and/or other materials provided with the\r\n+# distribution.\r\n+# * Neither the name of Intel Corporation nor the names of its\r\n+# contributors may be used to endorse or promote products derived\r\n+# from this software without specific prior written permission.\r\n+#\r\n+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n+# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\n+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\n+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\n+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\n+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\n+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\n+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\n+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\n+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n+\r\n+\"\"\"\r\n+DPDK Test suite.\r\n+\"\"\"\r\n+\r\n+import utils\r\n+import re\r\n+import time\r\n+import os\r\n+from test_case import TestCase\r\n+from packet import Packet\r\n+from pktgen import PacketGeneratorHelper\r\n+from pmd_output import PmdOutput\r\n+from virt_common import VM\r\n+\r\n+\r\n+class TestVswitchSampleCBDMA(TestCase):\r\n+\r\n+ def set_up_all(self):\r\n+ \"\"\"\r\n+ Run at the start of each test suite.\r\n+ \"\"\"\r\n+ self.set_max_queues(512)\r\n+ self.dut_ports = self.dut.get_ports()\r\n+ self.verify(len(self.dut_ports) >= 1, \"Insufficient ports for testing\")\r\n+ self.tester_tx_port_num = 1\r\n+ self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])\r\n+ self.dut_ports = self.dut.get_ports()\r\n+ self.socket = self.dut.get_numa_id(self.dut_ports[0])\r\n+ self.cores = self.dut.get_core_list(\"all\", socket=self.socket)\r\n+ self.vhost_core_list = self.cores[0:2]\r\n+ self.vuser0_core_list = self.cores[2:4]\r\n+ self.vuser1_core_list = self.cores[4:6]\r\n+ self.vhost_core_mask = utils.create_mask(self.vhost_core_list)\r\n+ self.mem_channels = self.dut.get_memory_channels()\r\n+ # get cbdma device\r\n+ self.cbdma_dev_infos = []\r\n+ self.dmas_info = None\r\n+ self.device_str = None\r\n+ self.out_path = '/tmp'\r\n+ out = self.tester.send_expect('ls -d %s' % self.out_path, '# ')\r\n+ if 'No such file or directory' in out:\r\n+ self.tester.send_expect('mkdir -p %s' % self.out_path, '# ')\r\n+ self.base_dir = self.dut.base_dir.replace('~', '/root')\r\n+ txport = self.tester.get_local_port(self.dut_ports[0])\r\n+ self.txItf = self.tester.get_interface(txport)\r\n+ self.virtio_dst_mac0 = '00:11:22:33:44:10'\r\n+ self.virtio_dst_mac1 = '00:11:22:33:44:11'\r\n+ self.vm_dst_mac0 = '52:54:00:00:00:01'\r\n+ self.vm_dst_mac1 = '52:54:00:00:00:02'\r\n+ self.vm_num = 2\r\n+ self.vm_dut = []\r\n+ self.vm = []\r\n+ self.app_testpmd_path = self.dut.apps_name['test-pmd']\r\n+ # create an instance to set stream field setting\r\n+ self.pktgen_helper = PacketGeneratorHelper()\r\n+\r\n+\r\n+ def set_up(self):\r\n+ \"\"\"\r\n+ Run before each test case.\r\n+ \"\"\"\r\n+ self.dut.send_expect(\"rm -rf %s/vhost-net*\" % self.base_dir, \"#\")\r\n+ self.dut.send_expect(\"killall -I qemu-system-x86_64\", '#', 20)\r\n+ self.vhost_user = self.dut.new_session(suite=\"vhost-user\")\r\n+ self.virtio_user0 = self.dut.new_session(suite=\"virtio-user0\")\r\n+ self.virtio_user1 = self.dut.new_session(suite=\"virtio-user1\")\r\n+ self.virtio_user0_pmd = PmdOutput(self.dut, self.virtio_user0)\r\n+ self.virtio_user1_pmd = PmdOutput(self.dut, self.virtio_user1)\r\n+\r\n+ def set_async_threshold(self, async_threshold=256):\r\n+ self.logger.info(\"Configure async_threshold to {}\".format(async_threshold))\r\n+ self.dut.send_expect(\"sed -i -e 's/f.async_threshold = .*$/f.async_threshold = {};/' \"\r\n+ \"./examples/vhost/main.c\".format(async_threshold), \"#\", 20)\r\n+\r\n+ def set_max_queues(self, max_queues=512):\r\n+ self.logger.info(\"Configure MAX_QUEUES to {}\".format(max_queues))\r\n+ self.dut.send_expect(\"sed -i -e 's/#define MAX_QUEUES .*$/#define MAX_QUEUES {}/' \"\r\n+ \"./examples/vhost/main.c\".format(max_queues), \"#\", 20)\r\n+\r\n+ def build_vhost_app(self):\r\n+ out = self.dut.build_dpdk_apps('./examples/vhost')\r\n+ self.verify('Error' not in out, 'compilation vhost error')\r\n+\r\n+ @property\r\n+ def check_2M_env(self):\r\n+ out = self.dut.send_expect(\"cat /proc/meminfo |grep Hugepagesize|awk '{print($2)}'\", \"# \")\r\n+ return True if out == '2048' else False\r\n+\r\n+ def start_vhost_app(self, with_cbdma=True, cbdma_num=1, socket_num=1, client_mode=False):\r\n+ \"\"\"\r\n+ launch the vhost app on vhost side\r\n+ \"\"\"\r\n+ self.app_path = self.dut.apps_name['vhost']\r\n+ socket_file_param = ''\r\n+ for item in range(socket_num):\r\n+ socket_file_param += '--socket-file ./vhost-net{} '.format(item)\r\n+ allow_pci = [self.dut.ports_info[0]['pci']]\r\n+ for item in range(cbdma_num):\r\n+ allow_pci.append(self.cbdma_dev_infos[item])\r\n+ allow_option = ''\r\n+ for item in allow_pci:\r\n+ allow_option += ' -a {}'.format(item)\r\n+ if with_cbdma:\r\n+ if client_mode:\r\n+ params = (\" -c {} -n {} {} -- -p 0x1 --mergeable 1 --vm2vm 1 --dma-type ioat --stats 1 \"\r\n+ + socket_file_param + \"--dmas [{}] --client\").format(self.vhost_core_mask, self.mem_channels,\r\n+ allow_option, self.dmas_info)\r\n+ else:\r\n+ params = (\" -c {} -n {} {} -- -p 0x1 --mergeable 1 --vm2vm 1 --dma-type ioat --stats 1 \"\r\n+ + socket_file_param + \"--dmas [{}]\").format(self.vhost_core_mask, self.mem_channels,\r\n+ allow_option, self.dmas_info)\r\n+ else:\r\n+ params = (\" -c {} -n {} {} -- -p 0x1 --mergeable 1 --vm2vm 1 --stats 1 \" + socket_file_param).format(\r\n+ self.vhost_core_mask, self.mem_channels, allow_option)\r\n+ self.command_line = self.app_path + params\r\n+ self.vhost_user.send_command(self.command_line)\r\n+ # After started dpdk-vhost app, wait 3 seconds\r\n+ time.sleep(3)\r\n+\r\n+ def start_virtio_testpmd(self, pmd_session, dev_mac, dev_id, cores, prefix, enable_queues=1, server_mode=False,\r\n+ nb_cores=1, used_queues=1):\r\n+ \"\"\"\r\n+ launch the testpmd as virtio with vhost_net0\r\n+ \"\"\"\r\n+ if server_mode:\r\n+ eal_params = \" --vdev=net_virtio_user0,mac={},path=./vhost-net{},queues={},server=1\".format(dev_mac, dev_id,\r\n+ enable_queues)\r\n+ else:\r\n+ eal_params = \" --vdev=net_virtio_user0,mac={},path=./vhost-net{},queues={}\".format(dev_mac, dev_id,\r\n+ enable_queues)\r\n+ if self.check_2M_env:\r\n+ eal_params += \" --single-file-segments\"\r\n+ params = \"--nb-cores={} --rxq={} --txq={} --txd=1024 --rxd=1024\".format(nb_cores, used_queues, used_queues)\r\n+ pmd_session.start_testpmd(cores=cores, param=params, eal_param=eal_params, no_pci=True, ports=[], prefix=prefix,\r\n+ fixed_prefix=True)\r\n+\r\n+ def start_vms(self, mode=0, mergeable=True):\r\n+ \"\"\"\r\n+ start two VM, each VM has one virtio device\r\n+ \"\"\"\r\n+ if mode == 0:\r\n+ setting_args = \"disable-modern=true\"\r\n+ elif mode == 1:\r\n+ setting_args = \"disable-modern=false\"\r\n+ elif mode == 2:\r\n+ setting_args = \"disable-modern=false,packed=on\"\r\n+ if mergeable is True:\r\n+ setting_args += \",\" + \"mrg_rxbuf=on\"\r\n+ else:\r\n+ setting_args += \",\" + \"mrg_rxbuf=off\"\r\n+ setting_args += \",csum=on,gso=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on\"\r\n+\r\n+ for i in range(self.vm_num):\r\n+ vm_dut = None\r\n+ vm_info = VM(self.dut, 'vm%d' % i, 'vhost_sample')\r\n+ vm_params = {}\r\n+ vm_params['driver'] = 'vhost-user'\r\n+ vm_params['opt_path'] = self.base_dir + '/vhost-net%d' % i\r\n+ vm_params['opt_mac'] = \"52:54:00:00:00:0%d\" % (i+1)\r\n+ vm_params['opt_settings'] = setting_args\r\n+ vm_info.set_vm_device(**vm_params)\r\n+ time.sleep(3)\r\n+ try:\r\n+ vm_dut = vm_info.start()\r\n+ if vm_dut is None:\r\n+ raise Exception(\"Set up VM ENV failed\")\r\n+ except Exception as e:\r\n+ print((utils.RED(\"Failure for %s\" % str(e))))\r\n+ raise e\r\n+ self.vm_dut.append(vm_dut)\r\n+ self.vm.append(vm_info)\r\n+\r\n+ def start_vm_testpmd(self, pmd_session):\r\n+ \"\"\"\r\n+ launch the testpmd in vm\r\n+ \"\"\"\r\n+ self.vm_cores = [1,2]\r\n+ param = \"--rxq=1 --txq=1 --nb-cores=1 --txd=1024 --rxd=1024\"\r\n+ pmd_session.start_testpmd(cores=self.vm_cores, param=param)\r\n+\r\n+ def repeat_bind_driver(self, dut, repeat_times=50):\r\n+ i = 0\r\n+ while i < repeat_times:\r\n+ dut.unbind_interfaces_linux()\r\n+ dut.bind_interfaces_linux(driver='virtio-pci')\r\n+ dut.bind_interfaces_linux(driver='vfio-pci')\r\n+ i += 1\r\n+\r\n+ def get_cbdma_ports_info_and_bind_to_dpdk(self, cbdma_num):\r\n+ \"\"\"\r\n+ get all cbdma ports\r\n+ \"\"\"\r\n+ str_info = 'Misc (rawdev) devices using kernel driver'\r\n+ out = self.dut.send_expect('./usertools/dpdk-devbind.py --status-dev misc', '# ', 30)\r\n+ device_info = out.split('\\n')\r\n+ for device in device_info:\r\n+ pci_info = re.search('\\s*(0000:\\d*:\\d*.\\d*)', device)\r\n+ if pci_info is not None:\r\n+ dev_info = pci_info.group(1)\r\n+ # the numa id of ioat dev, only add the device which on same socket with nic dev\r\n+ bus = int(dev_info[5:7], base=16)\r\n+ if bus >= 128:\r\n+ cur_socket = 1\r\n+ else:\r\n+ cur_socket = 0\r\n+ if self.ports_socket == cur_socket:\r\n+ self.cbdma_dev_infos.append(pci_info.group(1))\r\n+ self.verify(len(self.cbdma_dev_infos) >= cbdma_num, 'There no enough cbdma device to run this suite')\r\n+ used_cbdma = self.cbdma_dev_infos[0:cbdma_num]\r\n+ dmas_info = ''\r\n+ for dmas in used_cbdma:\r\n+ number = used_cbdma.index(dmas)\r\n+ dmas = 'txd{}@{},'.format(number, dmas.replace('0000:', ''))\r\n+ dmas_info += dmas\r\n+ self.dmas_info = dmas_info[:-1]\r\n+ self.device_str = ' '.join(used_cbdma)\r\n+ self.dut.setup_modules(self.target, \"igb_uio\",\"None\")\r\n+ self.dut.send_expect('./usertools/dpdk-devbind.py --force --bind=%s %s' % (\"igb_uio\", self.device_str), '# ', 60)\r\n+\r\n+ def send_vlan_packet(self, dts_mac, pkt_size=64, pkt_count=1):\r\n+ \"\"\"\r\n+ Send a vlan packet with vlan id 1000\r\n+ \"\"\"\r\n+ pkt = Packet(pkt_type='VLAN_UDP', pkt_len=pkt_size)\r\n+ pkt.config_layer('ether', {'dst': dts_mac})\r\n+ pkt.config_layer('vlan', {'vlan': 1000})\r\n+ pkt.send_pkt(self.tester, tx_port=self.txItf, count=pkt_count)\r\n+\r\n+ def verify_receive_packet(self, pmd_session, expected_pkt_count):\r\n+ out = pmd_session.execute_cmd(\"show port stats all\")\r\n+ rx_num = re.compile('RX-packets: (.*?)\\s+?').findall(out, re.S)\r\n+ self.verify((int(rx_num[0]) >= int(expected_pkt_count)), \"Can't receive enough packets from tester\")\r\n+\r\n+ def bind_cbdma_device_to_kernel(self):\r\n+ if self.device_str is not None:\r\n+ self.dut.send_expect('modprobe ioatdma', '# ')\r\n+ self.dut.send_expect('./usertools/dpdk-devbind.py -u %s' % self.device_str, '# ', 30)\r\n+ self.dut.send_expect('./usertools/dpdk-devbind.py --force --bind=ioatdma %s' % self.device_str, '# ', 60)\r\n+\r\n+ def config_stream(self, frame_size, port_num, dst_mac_list):\r\n+ tgen_input = []\r\n+ rx_port = self.tester.get_local_port(self.dut_ports[0])\r\n+ tx_port = self.tester.get_local_port(self.dut_ports[0])\r\n+ for item in range(port_num):\r\n+ for dst_mac in dst_mac_list:\r\n+ pkt = Packet(pkt_type='VLAN_UDP', pkt_len=frame_size)\r\n+ pkt.config_layer('ether', {'dst': dst_mac})\r\n+ pkt.config_layer('vlan', {'vlan': 1000})\r\n+ pcap = os.path.join(self.out_path, \"vswitch_sample_cbdma_%s_%s_%s.pcap\" % (item, dst_mac, frame_size))\r\n+ pkt.save_pcapfile(None, pcap)\r\n+ tgen_input.append((rx_port, tx_port, pcap))\r\n+ return tgen_input\r\n+\r\n+ def perf_test(self, frame_size, dst_mac_list):\r\n+ # Create test results table\r\n+ table_header = ['Frame Size(Byte)', 'Throughput(Mpps)']\r\n+ self.result_table_create(table_header)\r\n+ # Begin test perf\r\n+ test_result = {}\r\n+ for frame_size in frame_size:\r\n+ self.logger.info(\"Test running at parameters: \" + \"framesize: {}\".format(frame_size))\r\n+ tgenInput = self.config_stream(frame_size, self.tester_tx_port_num, dst_mac_list)\r\n+ # clear streams before add new streams\r\n+ self.tester.pktgen.clear_streams()\r\n+ # run packet generator\r\n+ streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100, None, self.tester.pktgen)\r\n+ # set traffic option\r\n+ traffic_opt = {'duration': 5}\r\n+ _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams, options=traffic_opt)\r\n+ self.verify(pps > 0, \"No traffic detected\")\r\n+ throughput = pps / 1000000.0\r\n+ test_result[frame_size] = throughput\r\n+ self.result_table_add([frame_size, throughput])\r\n+ self.result_table_print()\r\n+ return test_result\r\n+\r\n+ def pvp_test_with_cbdma(self, socket_num=1, with_cbdma=True, cbdma_num=1):\r\n+ self.frame_sizes = [64, 512, 1024, 1518]\r\n+ self.start_vhost_app(with_cbdma=with_cbdma, cbdma_num=cbdma_num, socket_num=socket_num, client_mode=False)\r\n+ self.start_virtio_testpmd(pmd_session=self.virtio_user0_pmd, dev_mac=self.virtio_dst_mac0, dev_id=0,\r\n+ cores=self.vuser0_core_list, prefix='testpmd0', enable_queues=1, server_mode=False,\r\n+ nb_cores=1, used_queues=1)\r\n+ self.virtio_user0_pmd.execute_cmd('set fwd mac')\r\n+ self.virtio_user0_pmd.execute_cmd('start tx_first')\r\n+ self.virtio_user0_pmd.execute_cmd('stop')\r\n+ self.virtio_user0_pmd.execute_cmd('start')\r\n+ dst_mac_list = [self.virtio_dst_mac0]\r\n+ perf_result = self.perf_test(frame_size=self.frame_sizes,dst_mac_list=dst_mac_list)\r\n+ return perf_result\r\n+\r\n+ def test_perf_check_with_cbdma_channel_using_vhost_async_driver(self):\r\n+ \"\"\"\r\n+ Test Case1: PVP performance check with CBDMA channel using vhost async driver\r\n+ \"\"\"\r\n+ perf_result = []\r\n+ self.get_cbdma_ports_info_and_bind_to_dpdk(1)\r\n+\r\n+ # test cbdma copy\r\n+ # CBDMA copy needs vhost enqueue with cbdma channel using parameter '-dmas'\r\n+ self.set_async_threshold(1518)\r\n+ self.build_vhost_app()\r\n+ cbmda_copy = self.pvp_test_with_cbdma(socket_num=1, with_cbdma=True, cbdma_num=1)\r\n+\r\n+ self.virtio_user0_pmd.execute_cmd(\"quit\", \"#\")\r\n+ self.vhost_user.send_expect(\"^C\", \"# \", 20)\r\n+\r\n+ # test sync copy\r\n+ # Sync copy needs vhost enqueue with cbdma channel, but threshold ( can be adjusted by change value of\r\n+ # f.async_threshold in dpdk code) is larger than forwarding packet length\r\n+ self.set_async_threshold(0)\r\n+ self.build_vhost_app()\r\n+ sync_copy = self.pvp_test_with_cbdma(socket_num=1, with_cbdma=True, cbdma_num=1)\r\n+\r\n+ self.virtio_user0_pmd.execute_cmd(\"quit\", \"#\")\r\n+ self.vhost_user.send_expect(\"^C\", \"# \", 20)\r\n+\r\n+ # test CPU copy\r\n+ # CPU copy means vhost enqueue w/o cbdma channel\r\n+ cpu_copy = self.pvp_test_with_cbdma(socket_num=1, with_cbdma=False, cbdma_num=0)\r\n+\r\n+ self.virtio_user0_pmd.execute_cmd(\"quit\", \"#\")\r\n+ self.vhost_user.send_expect(\"^C\", \"# \", 20)\r\n+\r\n+ self.table_header = ['Frame Size(Byte)', 'Mode', 'Throughput(Mpps)']\r\n+ self.result_table_create(self.table_header)\r\n+ for key in cbmda_copy.keys():\r\n+ perf_result.append([key, 'cbdma_copy', cbmda_copy[key]])\r\n+ for key in sync_copy.keys():\r\n+ perf_result.append([key, 'sync_copy', sync_copy[key]])\r\n+ for key in cpu_copy.keys():\r\n+ perf_result.append([key, 'cpu_copy', cpu_copy[key]])\r\n+ for table_row in perf_result:\r\n+ self.result_table_add(table_row)\r\n+ self.result_table_print()\r\n+\r\n+ def pvp_test_with_multi_cbdma(self, socket_num=2, with_cbdma=True, cbdma_num=1, launch_virtio=True, quit_vhost=False):\r\n+ self.frame_sizes = [1518]\r\n+ self.start_vhost_app(with_cbdma=with_cbdma, cbdma_num=cbdma_num, socket_num=socket_num, client_mode=True)\r\n+ if launch_virtio:\r\n+ self.start_virtio_testpmd(pmd_session=self.virtio_user0_pmd, dev_mac=self.virtio_dst_mac0, dev_id=0,\r\n+ cores=self.vuser0_core_list, prefix='testpmd0', enable_queues=1, server_mode=True,\r\n+ nb_cores=1, used_queues=1)\r\n+ self.start_virtio_testpmd(pmd_session=self.virtio_user1_pmd, dev_mac=self.virtio_dst_mac1, dev_id=1,\r\n+ cores=self.vuser1_core_list, prefix='testpmd1', enable_queues=1, server_mode=True,\r\n+ nb_cores=1, used_queues=1)\r\n+ self.virtio_user0_pmd.execute_cmd('set fwd mac')\r\n+ self.virtio_user0_pmd.execute_cmd('start tx_first')\r\n+ self.virtio_user0_pmd.execute_cmd('stop')\r\n+ self.virtio_user0_pmd.execute_cmd('start')\r\n+ self.virtio_user1_pmd.execute_cmd('set fwd mac')\r\n+ self.virtio_user1_pmd.execute_cmd('start tx_first')\r\n+ self.virtio_user1_pmd.execute_cmd('stop')\r\n+ self.virtio_user1_pmd.execute_cmd('start')\r\n+ else:\r\n+ self.virtio_user0_pmd.execute_cmd('stop', 'testpmd> ', 30)\r\n+ self.virtio_user0_pmd.execute_cmd('start tx_first', 'testpmd> ', 30)\r\n+ self.virtio_user1_pmd.execute_cmd('stop', 'testpmd> ', 30)\r\n+ self.virtio_user1_pmd.execute_cmd('start tx_first', 'testpmd> ', 30)\r\n+ dst_mac_list = [self.virtio_dst_mac0, self.virtio_dst_mac1]\r\n+ perf_result = self.perf_test(self.frame_sizes, dst_mac_list)\r\n+ if quit_vhost:\r\n+ self.vhost_user.send_expect(\"^C\", \"# \", 20)\r\n+ return perf_result\r\n+\r\n+ def test_perf_check_with_multiple_cbdma_channels_using_vhost_async_driver(self):\r\n+ \"\"\"\r\n+ Test Case2: PVP test with multiple CBDMA channels using vhost async driver\r\n+ \"\"\"\r\n+ perf_result = []\r\n+ self.get_cbdma_ports_info_and_bind_to_dpdk(2)\r\n+ self.set_async_threshold(256)\r\n+ self.build_vhost_app()\r\n+\r\n+ self.logger.info(\"Launch vhost app perf test\")\r\n+ before_relunch= self.pvp_test_with_multi_cbdma(socket_num=2, with_cbdma=True, cbdma_num=2, launch_virtio=True, quit_vhost=True)\r\n+\r\n+ self.logger.info(\"Relaunch vhost app perf test\")\r\n+ after_relunch = self.pvp_test_with_multi_cbdma(socket_num=2, with_cbdma=True, cbdma_num=2, launch_virtio=False, quit_vhost=False)\r\n+\r\n+ self.virtio_user0_pmd.execute_cmd(\"quit\", \"#\")\r\n+ self.virtio_user1_pmd.execute_cmd(\"quit\", \"#\")\r\n+ self.vhost_user.send_expect(\"^C\", \"# \", 20)\r\n+\r\n+ self.table_header = ['Frame Size(Byte)', 'Mode', 'Throughput(Mpps)']\r\n+ self.result_table_create(self.table_header)\r\n+ for key in before_relunch.keys():\r\n+ perf_result.append([key, 'Before Re-launch vhost', before_relunch[key]])\r\n+ for key in after_relunch.keys():\r\n+ perf_result.append([key, 'After Re-launch vhost', after_relunch[key]])\r\n+ for table_row in perf_result:\r\n+ self.result_table_add(table_row)\r\n+ self.result_table_print()\r\n+\r\n+ self.verify(abs(before_relunch[1518] - after_relunch[1518]) / before_relunch[1518] < 0.1, \"Perf is unstable, \\\r\n+ before relaunch vhost app: %s, after relaunch vhost app: %s\" % (before_relunch[1518], after_relunch[1518]))\r\n+\r\n+ def get_receive_throughput(self, pmd_session, count=5):\r\n+ i = 0\r\n+ while i < count:\r\n+ pmd_session.execute_cmd('show port stats all')\r\n+ i += 1\r\n+ else:\r\n+ out = pmd_session.execute_cmd('show port stats all')\r\n+ pmd_session.execute_cmd('stop')\r\n+ rx_throughput = re.compile('Rx-pps: \\s+(.*?)\\s+?').findall(out, re.S)\r\n+ return float(rx_throughput[0]) / 1000000.0\r\n+\r\n+ def set_testpmd0_param(self, pmd_session, eth_peer_mac):\r\n+ pmd_session.execute_cmd('set fwd mac')\r\n+ pmd_session.execute_cmd('start tx_first')\r\n+ pmd_session.execute_cmd('stop')\r\n+ pmd_session.execute_cmd('set eth-peer 0 %s' % eth_peer_mac)\r\n+ pmd_session.execute_cmd('start')\r\n+\r\n+ def set_testpmd1_param(self, pmd_session, eth_peer_mac):\r\n+ pmd_session.execute_cmd('set fwd mac')\r\n+ pmd_session.execute_cmd('set eth-peer 0 %s' % eth_peer_mac)\r\n+\r\n+ def send_pkts_from_testpmd1(self, pmd_session, pkt_len):\r\n+ pmd_session.execute_cmd('set txpkts %s' % pkt_len)\r\n+ pmd_session.execute_cmd('start tx_first')\r\n+\r\n+ def vm2vm_check_with_two_cbdma(self, with_cbdma=True, cbdma_num=2, socket_num=2):\r\n+ frame_sizes = [256, 2000]\r\n+ self.start_vhost_app(with_cbdma=with_cbdma, cbdma_num=cbdma_num, socket_num=socket_num, client_mode=False)\r\n+ self.start_virtio_testpmd(pmd_session=self.virtio_user0_pmd, dev_mac=self.virtio_dst_mac0, dev_id=0,\r\n+ cores=self.vuser0_core_list, prefix='testpmd0', enable_queues=1, server_mode=False,\r\n+ nb_cores=1, used_queues=1)\r\n+ self.start_virtio_testpmd(pmd_session=self.virtio_user1_pmd, dev_mac=self.virtio_dst_mac1, dev_id=1,\r\n+ cores=self.vuser1_core_list, prefix='testpmd1', enable_queues=1, server_mode=False,\r\n+ nb_cores=1, used_queues=1)\r\n+ self.set_testpmd0_param(self.virtio_user0_pmd, self.virtio_dst_mac1)\r\n+ self.set_testpmd1_param(self.virtio_user1_pmd, self.virtio_dst_mac0)\r\n+\r\n+ rx_throughput = {}\r\n+ for frame_size in frame_sizes:\r\n+ self.send_pkts_from_testpmd1(pmd_session=self.virtio_user1_pmd, pkt_len=frame_size)\r\n+ # Create test results table\r\n+ table_header = ['Frame Size(Byte)', 'Throughput(Mpps)']\r\n+ self.result_table_create(table_header)\r\n+ rx_pps = self.get_receive_throughput(pmd_session=self.virtio_user1_pmd)\r\n+ self.result_table_add([frame_size, rx_pps])\r\n+ rx_throughput[frame_size] = rx_pps\r\n+ self.result_table_print()\r\n+ return rx_throughput\r\n+\r\n+ def test_vm2vm_check_with_two_cbdma_channels_using_vhost_async_driver(self):\r\n+ \"\"\"\r\n+ Test Case3: VM2VM performance test with two CBDMA channels using vhost async driver\r\n+ \"\"\"\r\n+ perf_result = []\r\n+ self.get_cbdma_ports_info_and_bind_to_dpdk(2)\r\n+ self.set_async_threshold(256)\r\n+ self.build_vhost_app()\r\n+\r\n+ cbdma_enable = self.vm2vm_check_with_two_cbdma(with_cbdma=True, cbdma_num=2, socket_num=2)\r\n+\r\n+ self.virtio_user0_pmd.execute_cmd(\"quit\", \"#\")\r\n+ self.virtio_user1_pmd.execute_cmd(\"quit\", \"#\")\r\n+ self.vhost_user.send_expect(\"^C\", \"# \", 20)\r\n+\r\n+ cbdma_disable = self.vm2vm_check_with_two_cbdma(with_cbdma=False, cbdma_num=2, socket_num=2)\r\n+\r\n+ self.virtio_user0_pmd.execute_cmd(\"quit\", \"#\")\r\n+ self.virtio_user1_pmd.execute_cmd(\"quit\", \"#\")\r\n+ self.vhost_user.send_expect(\"^C\", \"# \", 20)\r\n+\r\n+ self.table_header = ['Frame Size(Byte)', 'CBDMA Enable/Disable', 'Throughput(Mpps)']\r\n+ self.result_table_create(self.table_header)\r\n+ for key in cbdma_enable.keys():\r\n+ perf_result.append([key, 'Enable', cbdma_enable[key]])\r\n+ for key in cbdma_disable.keys():\r\n+ perf_result.append([key, 'Disable', cbdma_disable[key]])\r\n+ for table_row in perf_result:\r\n+ self.result_table_add(table_row)\r\n+ self.result_table_print()\r\n+\r\n+ for cbdma_key in cbdma_enable.keys():\r\n+ if cbdma_key == '2000':\r\n+ self.verify(cbdma_enable[cbdma_key] > cbdma_disable[cbdma_key],\r\n+ \"CBDMA Enable Performance {} should better than CBDMA Disable Performance {} when send 2000\"\r\n+ \" length packets\".format(cbdma_enable[cbdma_key], cbdma_disable[cbdma_key]))\r\n+ elif cbdma_key == '256':\r\n+ self.verify(cbdma_disable[cbdma_key] > cbdma_enable[cbdma_key],\r\n+ \"CBDMA Enable Performance {} should lower than CBDMA Disable Performance {} when send 256\"\r\n+ \" length packets\".format(cbdma_enable[cbdma_key], cbdma_disable[cbdma_key]))\r\n+\r\n+ def vm2vm_check_with_two_vhost_device(self, with_cbdma=True, cbdma_num=2, socket_num=2, launch=True):\r\n+ frame_sizes = [256, 2000]\r\n+ if launch:\r\n+ self.start_vhost_app(with_cbdma=with_cbdma, cbdma_num=cbdma_num, socket_num=socket_num, client_mode=False)\r\n+ self.start_vms(mode=0, mergeable=False)\r\n+ self.vm0_pmd = PmdOutput(self.vm_dut[0])\r\n+ self.vm1_pmd = PmdOutput(self.vm_dut[1])\r\n+ self.start_vm_testpmd(self.vm0_pmd)\r\n+ self.start_vm_testpmd(self.vm1_pmd)\r\n+ self.set_testpmd0_param(self.vm0_pmd, self.vm_dst_mac1)\r\n+ self.set_testpmd1_param(self.vm1_pmd, self.vm_dst_mac0)\r\n+\r\n+ rx_throughput = {}\r\n+ for frame_size in frame_sizes:\r\n+ self.send_pkts_from_testpmd1(pmd_session=self.vm1_pmd, pkt_len=frame_size)\r\n+ # Create test results table\r\n+ table_header = ['Frame Size(Byte)', 'Throughput(Mpps)']\r\n+ self.result_table_create(table_header)\r\n+ rx_pps = self.get_receive_throughput(pmd_session=self.vm1_pmd)\r\n+ self.result_table_add([frame_size, rx_pps])\r\n+ rx_throughput[frame_size] = rx_pps\r\n+ self.result_table_print()\r\n+\r\n+ return rx_throughput\r\n+\r\n+ def start_vms_testpmd_and_test(self, launch, quit_vm_testpmd=False):\r\n+ # start vm0 amd vm1 testpmd, send 256 and 2000 length packets from vm1 testpmd\r\n+ perf_result = self.vm2vm_check_with_two_vhost_device(with_cbdma=True, cbdma_num=2, socket_num=2, launch=launch)\r\n+ # stop vm1 and clear vm1 stats\r\n+ self.vm1_pmd.execute_cmd(\"stop\")\r\n+ self.vm1_pmd.execute_cmd(\"clear port stats all\")\r\n+ # stop vm0 and clear vm0 stats\r\n+ self.vm0_pmd.execute_cmd(\"stop\")\r\n+ self.vm0_pmd.execute_cmd(\"clear port stats all\")\r\n+ # only start vm0 and send packets from tester, and check vm0 can receive more then tester send packets' count\r\n+ self.vm0_pmd.execute_cmd(\"start\")\r\n+ self.send_vlan_packet(dts_mac=self.vm_dst_mac0, pkt_size=64, pkt_count=100)\r\n+ time.sleep(3)\r\n+ self.verify_receive_packet(pmd_session=self.vm0_pmd, expected_pkt_count=100)\r\n+ # stop vm0\r\n+ self.vm0_pmd.execute_cmd(\"stop\")\r\n+ # only start vm1 and send packets from tester, and check vm1 can receive more then tester send packets' count\r\n+ self.vm1_pmd.execute_cmd(\"start\")\r\n+ # clear vm1 stats after send start command\r\n+ self.vm1_pmd.execute_cmd(\"clear port stats all\")\r\n+ self.send_vlan_packet(dts_mac=self.vm_dst_mac1, pkt_size=64, pkt_count=100)\r\n+ time.sleep(3)\r\n+ self.verify_receive_packet(pmd_session=self.vm1_pmd, expected_pkt_count=100)\r\n+ if quit_vm_testpmd:\r\n+ self.vm0_pmd.execute_cmd(\"quit\", \"#\")\r\n+ self.vm1_pmd.execute_cmd(\"quit\", \"#\")\r\n+ return perf_result\r\n+\r\n+ def test_vm2vm_check_with_two_vhost_device_using_vhost_async_driver(self):\r\n+ \"\"\"\r\n+ Test Case4: VM2VM test with 2 vhost device using vhost async driver\r\n+ \"\"\"\r\n+ perf_result = []\r\n+ self.get_cbdma_ports_info_and_bind_to_dpdk(2)\r\n+ self.set_async_threshold(256)\r\n+ self.build_vhost_app()\r\n+\r\n+ before_rebind = self.start_vms_testpmd_and_test(launch=True, quit_vm_testpmd=True)\r\n+ # repeat bind 50 time from virtio-pci to vfio-pci\r\n+ self.repeat_bind_driver(dut=self.vm_dut[0], repeat_times=50)\r\n+ self.repeat_bind_driver(dut=self.vm_dut[1], repeat_times=50)\r\n+ # start vm0 and vm1 testpmd\r\n+ self.start_vm_testpmd(pmd_session=self.vm0_pmd)\r\n+ self.start_vm_testpmd(pmd_session=self.vm1_pmd)\r\n+ after_bind = self.start_vms_testpmd_and_test(launch=False, quit_vm_testpmd=False)\r\n+\r\n+ for i in range(len(self.vm)):\r\n+ self.vm[i].stop()\r\n+ self.vhost_user.send_expect(\"^C\", \"# \", 20)\r\n+\r\n+ self.table_header = ['Frame Size(Byte)', 'Before/After Bind VM Driver', 'Throughput(Mpps)']\r\n+ self.result_table_create(self.table_header)\r\n+ for key in before_rebind.keys():\r\n+ perf_result.append([key, 'Before rebind driver', before_rebind[key]])\r\n+ for key in after_bind.keys():\r\n+ perf_result.append([key, 'After rebind driver', after_bind[key]])\r\n+ for table_row in perf_result:\r\n+ self.result_table_add(table_row)\r\n+ self.result_table_print()\r\n+\r\n+ def close_all_session(self):\r\n+ if getattr(self, 'vhost_user', None):\r\n+ self.dut.close_session(self.vhost_user)\r\n+ if getattr(self, 'virtio-user0', None):\r\n+ self.dut.close_session(self.virtio_user0)\r\n+ if getattr(self, 'virtio-user1', None):\r\n+ self.dut.close_session(self.virtio_user1)\r\n+\r\n+ def tear_down(self):\r\n+ \"\"\"\r\n+ Run after each test case.\r\n+ \"\"\"\r\n+ self.bind_cbdma_device_to_kernel()\r\n+ self.close_all_session()\r\n+\r\n+ def tear_down_all(self):\r\n+ \"\"\"\r\n+ Run after each test suite.\r\n+ \"\"\"\r\n+ self.set_max_queues(128)\r\n+ self.set_async_threshold(256)\r\n+ self.dut.build_install_dpdk(self.target)\n\\ No newline at end of file\n", "prefixes": [ "V1" ] }{ "id": 86079, "url": "