From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BA9B9A0C45; Wed, 4 Aug 2021 05:14:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D90B4014F; Wed, 4 Aug 2021 05:14:04 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id A1E254003C for ; Wed, 4 Aug 2021 05:14:02 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10065"; a="213868531" X-IronPort-AV: E=Sophos;i="5.84,293,1620716400"; d="scan'208";a="213868531" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2021 20:14:01 -0700 X-IronPort-AV: E=Sophos;i="5.84,293,1620716400"; d="scan'208";a="521659240" Received: from unknown (HELO localhost.localdomain) ([10.240.183.222]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2021 20:13:59 -0700 From: Wei Ling To: dts@dpdk.org Cc: Wei Ling Date: Wed, 4 Aug 2021 11:06:13 +0800 Message-Id: <20210804030613.3397183-1-weix.ling@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dts] [PATCH V1] tests/vswitch_sample_cbdma: fix code issue and sync with testplan X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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" 1.Modify get_cbdma_ports_info_and_bind_to_dpdk method match regular inorder to get the "0000:e1:00.01" device and retrun full pci name. 2.Fix the code not sync with testplan issue. 3.Add check the result steps in test case. Signed-off-by: Wei Ling --- tests/TestSuite_vswitch_sample_cbdma.py | 115 ++++++++++++------------ 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/tests/TestSuite_vswitch_sample_cbdma.py b/tests/TestSuite_vswitch_sample_cbdma.py index 08422ea3..8a7f83db 100644 --- a/tests/TestSuite_vswitch_sample_cbdma.py +++ b/tests/TestSuite_vswitch_sample_cbdma.py @@ -81,8 +81,6 @@ class TestVswitchSampleCBDMA(TestCase): self.vm_dst_mac0 = '52:54:00:00:00:01' self.vm_dst_mac1 = '52:54:00:00:00:02' self.vm_num = 2 - self.vm_dut = [] - self.vm = [] self.app_testpmd_path = self.dut.apps_name['test-pmd'] # create an instance to set stream field setting self.pktgen_helper = PacketGeneratorHelper() @@ -106,7 +104,11 @@ class TestVswitchSampleCBDMA(TestCase): Run before each test case. """ self.dut.send_expect("rm -rf %s/vhost-net*" % self.base_dir, "#") + self.dut.send_expect("killall -I dpdk-vhost", '#', 20) + self.dut.send_expect("killall -I dpdk-testpmd", '#', 20) self.dut.send_expect("killall -I qemu-system-x86_64", '#', 20) + self.vm_dut = [] + self.vm = [] def set_max_queues(self, max_queues=512): self.logger.info("Configure MAX_QUEUES to {}".format(max_queues)) @@ -172,22 +174,14 @@ class TestVswitchSampleCBDMA(TestCase): pmd_session.start_testpmd(cores=cores, param=params, eal_param=eal_params, no_pci=True, ports=[], prefix=prefix, fixed_prefix=True) - def start_vms(self, mode=0, mergeable=True, server_mode=False, set_target=True): + def start_vms(self, mergeable=True, packed=False, server_mode=False, set_target=True, bind_dev=True, vm_diff_param=False): """ start two VM, each VM has one virtio device """ - if mode == 0: - setting_args = "disable-modern=true" - elif mode == 1: - setting_args = "disable-modern=false" - elif mode == 2: - setting_args = "disable-modern=true,packed=on" - if mergeable is True: - setting_args += "," + "mrg_rxbuf=on" - else: - setting_args += "," + "mrg_rxbuf=off" - setting_args += ",csum=on,gso=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on" - + mergeable = 'on' if mergeable else 'off' + setting_args = "disable-modern=true,mrg_rxbuf={0},csum=on,guest_csum=on,host_tso4=on,guest_tso4=on,guest_ecn=on".format(mergeable) + if packed: + setting_args = setting_args + ',packed=on' for i in range(self.vm_num): vm_dut = None vm_info = VM(self.dut, 'vm%d' % i, 'vhost_sample') @@ -198,11 +192,14 @@ class TestVswitchSampleCBDMA(TestCase): else: vm_params['opt_path'] = self.base_dir + '/vhost-net%d' % i vm_params['opt_mac'] = "52:54:00:00:00:0%d" % (i + 1) - vm_params['opt_settings'] = setting_args + if vm_diff_param and i > 0: + vm_params['opt_settings'] = setting_args + ',packed=on' + else: + vm_params['opt_settings'] = setting_args vm_info.set_vm_device(**vm_params) time.sleep(3) try: - vm_dut = vm_info.start(set_target=set_target) + vm_dut = vm_info.start(set_target=set_target, bind_dev=bind_dev) if vm_dut is None: raise Exception("Set up VM ENV failed") except Exception as e: @@ -238,7 +235,7 @@ class TestVswitchSampleCBDMA(TestCase): out = self.dut.send_expect('./usertools/dpdk-devbind.py --status-dev misc', '# ', 30) device_info = out.split('\n') for device in device_info: - pci_info = re.search('\s*(0000:\d*:\d*.\d*)', device) + pci_info = re.search('\s*(0000:\S*:\d*.\d*)', device) if pci_info is not None: dev_info = pci_info.group(1) # the numa id of ioat dev, only add the device which on same socket with nic dev @@ -254,7 +251,7 @@ class TestVswitchSampleCBDMA(TestCase): dmas_info = '' for dmas in used_cbdma: number = used_cbdma.index(dmas) - dmas = 'txd{}@{},'.format(number, dmas.replace('0000:', '')) + dmas = 'txd{}@{},'.format(number, dmas) dmas_info += dmas self.dmas_info = dmas_info[:-1] self.device_str = ' '.join(used_cbdma) @@ -281,7 +278,7 @@ class TestVswitchSampleCBDMA(TestCase): self.dut.send_expect('./usertools/dpdk-devbind.py -u %s' % self.device_str, '# ', 30) self.dut.send_expect('./usertools/dpdk-devbind.py --force --bind=ioatdma %s' % self.device_str, '# ', 60) - def config_stream(self, frame_size, port_num, dst_mac_list): + def config_stream(self, frame_size, dst_mac_list): tgen_input = [] rx_port = self.tester.get_local_port(self.dut_ports[0]) tx_port = self.tester.get_local_port(self.dut_ports[0]) @@ -303,7 +300,7 @@ class TestVswitchSampleCBDMA(TestCase): test_result = {} for frame_size in frame_sizes: self.logger.info("Test running at parameters: " + "framesize: {}".format(frame_size)) - tgenInput = self.config_stream(frame_size, self.tester_tx_port_num, dst_mac_list) + tgenInput = self.config_stream(frame_size, dst_mac_list) # clear streams before add new streams self.tester.pktgen.clear_streams() # run packet generator @@ -311,9 +308,7 @@ class TestVswitchSampleCBDMA(TestCase): # set traffic option traffic_opt = {'duration': 5} _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams, options=traffic_opt) - self.virtio_user0_pmd.execute_cmd('show port stats all') throughput = pps / 1000000.0 - self.verify(throughput > 0, "No traffic detected") test_result[frame_size] = throughput self.result_table_add([frame_size, throughput]) self.result_table_print() @@ -349,17 +344,16 @@ class TestVswitchSampleCBDMA(TestCase): packed_ring_result = self.pvp_test_with_cbdma() # relaunch split ring in_order vectorized with cbdma + self.virtio_user0_pmd.execute_cmd("quit", "# ") self.mrg_rxbuf = 1 self.in_order = 1 self.vectorized = 1 self.packed_vq = 0 self.server = 1 - self.virtio_user0_pmd.execute_cmd("quit", "#") + self.start_virtio_testpmd(pmd_session=self.virtio_user0_pmd, dev_mac=self.virtio_dst_mac0, dev_id=0, cores=self.vuser0_core_list, prefix='testpmd0', nb_cores=1, used_queues=1) split_ring_reult = self.pvp_test_with_cbdma() - self.virtio_user0_pmd.execute_cmd("quit", "#") - self.vhost_user.send_expect("^C", "# ", 20) self.table_header = ['Frame Size(Byte)', 'Mode', 'Throughput(Mpps)'] self.result_table_create(self.table_header) @@ -370,10 +364,12 @@ class TestVswitchSampleCBDMA(TestCase): for table_row in perf_result: self.result_table_add(table_row) self.result_table_print() - self.virtio_user0_pmd.execute_cmd("quit", "#") - self.vhost_user.send_expect("^C", "# ", 20) + for key in packed_ring_result.keys(): + self.verify(packed_ring_result[key] > 1, "The perf test result is lower than 1 Mpps") + for key in split_ring_reult.keys(): + self.verify(split_ring_reult[key] > 1, "The perf test result is lower than 1 Mpps") - def config_stream_imix(self, frame_sizes, port_num, dst_mac_list): + def config_stream_imix(self, frame_sizes, dst_mac_list): tgen_input = [] rx_port = self.tester.get_local_port(self.dut_ports[0]) tx_port = self.tester.get_local_port(self.dut_ports[0]) @@ -395,7 +391,7 @@ class TestVswitchSampleCBDMA(TestCase): self.result_table_create(table_header) # Begin test perf test_result = {} - tgenInput = self.config_stream_imix(frame_sizes, self.tester_tx_port_num, dst_mac_list) + tgenInput = self.config_stream_imix(frame_sizes, dst_mac_list) fields_config = {'ip': {'src': {'action': 'random'}, }, } # clear streams before add new streams self.tester.pktgen.clear_streams() @@ -404,10 +400,7 @@ class TestVswitchSampleCBDMA(TestCase): # set traffic option traffic_opt = {'delay': 5, 'duration': 5} _, pps = self.tester.pktgen.measure_throughput(stream_ids=streams, options=traffic_opt) - self.virtio_user0_pmd.execute_cmd("show port stats all") - self.virtio_user1_pmd.execute_cmd("show port stats all") throughput = pps / 1000000.0 - self.verify(throughput > 0, "traffic is too low: throughput=%s" % throughput) test_result['imix'] = throughput self.result_table_add(['imix', throughput]) self.result_table_print() @@ -446,7 +439,7 @@ class TestVswitchSampleCBDMA(TestCase): self.mrg_rxbuf = 0 self.in_order = 1 self.vectorized = 1 - self.packed_vq = 0 + self.packed_vq = 1 self.server = 1 self.start_virtio_testpmd(pmd_session=self.virtio_user0_pmd, dev_mac=self.virtio_dst_mac0, dev_id=0, cores=self.vuser0_core_list, prefix='testpmd0', nb_cores=1, used_queues=1) @@ -473,9 +466,10 @@ class TestVswitchSampleCBDMA(TestCase): for table_row in perf_result: self.result_table_add(table_row) self.result_table_print() - self.virtio_user0_pmd.execute_cmd("quit", "#") - self.virtio_user1_pmd.execute_cmd("quit", "#") - self.vhost_user.send_expect("^C", "# ", 20) + for key in before_relunch.keys(): + self.verify(before_relunch[key] > 1, "The perf test result is lower than 1 Mpps") + for key in after_relunch.keys(): + self.verify(after_relunch[key] > 1, "The perf test result is lower than 1 Mpps") def get_receive_throughput(self, pmd_session, count=10): i = 0 @@ -513,9 +507,11 @@ class TestVswitchSampleCBDMA(TestCase): frame_sizes = [64, 2000, 8000, 'imix'] if relaunch: self.virtio_user0_pmd.execute_cmd('stop') - self.virtio_user0_pmd.execute_cmd('clear port stats all') self.virtio_user1_pmd.execute_cmd('stop') + self.virtio_user0_pmd.execute_cmd('clear port stats all') self.virtio_user1_pmd.execute_cmd('clear port stats all') + self.virtio_user0_pmd.execute_cmd('show port stats all') + self.virtio_user1_pmd.execute_cmd('show port stats all') self.set_testpmd0_param(self.virtio_user0_pmd, self.virtio_dst_mac1) self.set_testpmd1_param(self.virtio_user1_pmd, self.virtio_dst_mac0) @@ -541,20 +537,21 @@ class TestVswitchSampleCBDMA(TestCase): self.logger.info("Launch vhost app perf test") self.start_vhost_app(with_cbdma=True, cbdma_num=2, socket_num=2, client_mode=True) self.mrg_rxbuf = 1 - self.in_order = 1 + self.in_order = 0 self.vectorized = 1 - self.packed_vq = 0 + self.packed_vq = 1 self.server = 1 self.start_virtio_testpmd(pmd_session=self.virtio_user0_pmd, dev_mac=self.virtio_dst_mac0, dev_id=0, cores=self.vuser0_core_list, prefix='testpmd0', nb_cores=1, used_queues=1) self.mrg_rxbuf = 1 - self.in_order = 1 + self.in_order = 0 self.vectorized = 1 self.packed_vq = 0 self.server = 1 self.start_virtio_testpmd(pmd_session=self.virtio_user1_pmd, dev_mac=self.virtio_dst_mac1, dev_id=1, cores=self.vuser1_core_list, prefix='testpmd1', nb_cores=1, used_queues=1) before_relunch_result = self.vm2vm_check_with_two_cbdma() + self.logger.info("Relaunch vhost app perf test") self.vhost_user.send_expect("^C", "# ", 20) self.start_vhost_app(with_cbdma=True, cbdma_num=2, socket_num=2, client_mode=True) @@ -569,9 +566,16 @@ class TestVswitchSampleCBDMA(TestCase): for table_row in perf_result: self.result_table_add(table_row) self.result_table_print() - self.virtio_user0_pmd.execute_cmd("quit", "# ") - self.virtio_user1_pmd.execute_cmd("quit", "# ") - self.vhost_user.send_expect("^C", "# ", 20) + for key in before_relunch_result.keys(): + if key == 64: + self.verify(before_relunch_result[key] > 1, "The perf test result is lower than 1 Mpps") + else: + self.verify(before_relunch_result[key] > 0.1, "The perf test result is lower than 0.1 Mpps") + for key in after_relunch_result.keys(): + if key == 64: + self.verify(after_relunch_result[key] > 1, "The perf test result is lower than 1 Mpps") + else: + self.verify(after_relunch_result[key] > 0.1, "The perf test result is lower than 0.1 Mpps") def vm2vm_check_with_two_vhost_device(self): rx_throughput = {} @@ -589,7 +593,7 @@ class TestVswitchSampleCBDMA(TestCase): def start_vms_testpmd_and_test(self, need_start_vm=True): if need_start_vm: - self.start_vms(mode=2, mergeable=True, server_mode=True) + self.start_vms(mergeable=True, packed=False, server_mode=True, set_target=True, bind_dev=True, vm_diff_param=True) self.vm0_pmd = PmdOutput(self.vm_dut[0]) self.vm1_pmd = PmdOutput(self.vm_dut[1]) self.start_vm_testpmd(self.vm0_pmd) @@ -608,11 +612,11 @@ class TestVswitchSampleCBDMA(TestCase): perf_result = [] self.get_cbdma_ports_info_and_bind_to_dpdk(cbdma_num=2) - self.logger.info("Before rebind perf VM Driver test") + self.logger.info("Before rebind VM Driver perf test") self.start_vhost_app(with_cbdma=True, cbdma_num=2, socket_num=2, client_mode=True) before_rebind = self.start_vms_testpmd_and_test(need_start_vm=True) - self.logger.info("After rebind perf VM Driver test") + self.logger.info("After rebind VM Driver perf test") # repeat bind 50 time from virtio-pci to vfio-pci self.repeat_bind_driver(dut=self.vm_dut[0], repeat_times=50) self.repeat_bind_driver(dut=self.vm_dut[1], repeat_times=50) @@ -622,9 +626,6 @@ class TestVswitchSampleCBDMA(TestCase): # repeat bind 50 time from virtio-pci to vfio-pci self.repeat_bind_driver(dut=self.vm_dut[0], repeat_times=50) self.repeat_bind_driver(dut=self.vm_dut[1], repeat_times=50) - for i in range(len(self.vm)): - self.vm[i].stop() - self.vhost_user.send_expect("^C", "# ", 20) self.table_header = ['Frame Size(Byte)', 'Before/After Bind VM Driver', 'Throughput(Mpps)'] self.result_table_create(self.table_header) @@ -710,9 +711,9 @@ class TestVswitchSampleCBDMA(TestCase): md5_revd = md5_revd[: md5_revd.find(' ')] self.verify(md5_send == md5_revd, 'the received file is different with send file') - def start_iperf_and_scp_test_in_vms(self, need_start_vm=True, mode=0, mergeable=False, server_mode=False): + def start_iperf_and_scp_test_in_vms(self, need_start_vm=True, mergeable=False, packed=False, server_mode=False): if need_start_vm: - self.start_vms(mode=mode, mergeable=mergeable, server_mode=server_mode, set_target=False) + self.start_vms(mergeable=mergeable, packed=packed, server_mode=server_mode, set_target=True, bind_dev=False) self.vm0_pmd = PmdOutput(self.vm_dut[0]) self.vm1_pmd = PmdOutput(self.vm_dut[1]) self.config_vm_env() @@ -730,7 +731,7 @@ class TestVswitchSampleCBDMA(TestCase): self.logger.info("launch vhost") self.start_vhost_app(with_cbdma=True, cbdma_num=2, socket_num=2, client_mode=True) - before_rerun = self.start_iperf_and_scp_test_in_vms(need_start_vm=True, mode=0, mergeable=False, server_mode=True) + before_rerun = self.start_iperf_and_scp_test_in_vms(need_start_vm=True, mergeable=False, packed=False, server_mode=True) self.logger.info("relaunch vhost") self.vhost_user.send_expect("^C", "# ", 20) @@ -762,7 +763,7 @@ class TestVswitchSampleCBDMA(TestCase): self.get_cbdma_ports_info_and_bind_to_dpdk(cbdma_num=2) self.start_vhost_app(with_cbdma=True, cbdma_num=2, socket_num=2, client_mode=False) - before_rerun = self.start_iperf_and_scp_test_in_vms(need_start_vm=True, mode=2, mergeable=False, server_mode=False) + before_rerun = self.start_iperf_and_scp_test_in_vms(need_start_vm=True, mergeable=False, packed=True, server_mode=False) self.logger.info("rerun scp and iperf test") rerun_test_1 = self.start_iperf_and_scp_test_in_vms(need_start_vm=False) @@ -770,6 +771,7 @@ class TestVswitchSampleCBDMA(TestCase): rerun_test_3 = self.start_iperf_and_scp_test_in_vms(need_start_vm=False) rerun_test_4 = self.start_iperf_and_scp_test_in_vms(need_start_vm=False) rerun_test_5 = self.start_iperf_and_scp_test_in_vms(need_start_vm=False) + self.table_header = ['Path', 'Before/After rerun scp/iperf', 'Throughput(Mpps)'] self.result_table_create(self.table_header) perf_result.append(['packed ring', 'Before rerun test', before_rerun]) @@ -794,6 +796,10 @@ class TestVswitchSampleCBDMA(TestCase): """ Run after each test case. """ + self.dut.kill_all() + for i in range(len(self.vm)): + self.vm[i].stop() + self.vhost_user.send_expect("^C", "# ", 20) self.bind_cbdma_device_to_kernel() def tear_down_all(self): @@ -801,5 +807,4 @@ class TestVswitchSampleCBDMA(TestCase): Run after each test suite. """ self.set_max_queues(128) - self.dut.build_install_dpdk(self.target) self.close_all_session() -- 2.25.1