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 026CCA04F5; Fri, 19 Jun 2020 10:23:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DD42F5F69; Fri, 19 Jun 2020 10:23:57 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 0ABF55B3C for ; Fri, 19 Jun 2020 10:23:55 +0200 (CEST) IronPort-SDR: 5fvuxxWlE0W5QEG48fg5KsJCGYHJXSVJuEUF2HtflAHAy3qus7s+f3kjMm6E5pMIbm07xg8m8W 2rrPhU2vcrLw== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="141958067" X-IronPort-AV: E=Sophos;i="5.75,254,1589266800"; d="scan'208";a="141958067" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 01:23:55 -0700 IronPort-SDR: LLNrrRSS24hHpFT9FCuhhWn6NUYM6mtVedKPFaLizM3bPpSi0DE2nFDbb8vGc+oPORAxDqZYy3 CEQ6UZaEpoxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,254,1589266800"; d="scan'208";a="383769768" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 19 Jun 2020 01:23:55 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 19 Jun 2020 01:23:54 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 19 Jun 2020 01:23:54 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.85]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.185]) with mapi id 14.03.0439.000; Fri, 19 Jun 2020 16:23:52 +0800 From: "Tu, Lijuan" To: "Zeng, XiaoxiaoX" , "dts@dpdk.org" CC: "Zeng, XiaoxiaoX" Thread-Topic: [dts] [PATCH V2]tests/cvl_switch_filter:optimization_cvl_switch_filter Thread-Index: AQHWQuaDZ2R2ljRkDka0mjIHKp38xKjfoBcA Date: Fri, 19 Jun 2020 08:23:51 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BC61023@SHSMSX101.ccr.corp.intel.com> References: <20200615160804.5693-1-xiaoxiaox.zeng@intel.com> In-Reply-To: <20200615160804.5693-1-xiaoxiaox.zeng@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="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V2]tests/cvl_switch_filter:optimization_cvl_switch_filter 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, thanks -----Original Message----- From: dts On Behalf Of Zeng Xiaoxiao Sent: 2020=1B$BG/=1B(B6=1B$B7n=1B(B16=1B$BF|=1B(B 0:08 To: dts@dpdk.org Cc: Zeng, XiaoxiaoX Subject: [dts] [PATCH V2]tests/cvl_switch_filter:optimization_cvl_switch_fi= lter *.Avoid that with different dpdk code, packet default queue same as queue t= hat rule set. *.Realize dynamic set rule in testpmd. Signed-off-by: Zeng Xiaoxiao --- tests/TestSuite_cvl_switch_filter.py | 81 +++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/tests/TestSuite_cvl_switch_filter.py b/tests/TestSuite_cvl_swi= tch_filter.py index ffd9af4..dc54fe7 100644 --- a/tests/TestSuite_cvl_switch_filter.py +++ b/tests/TestSuite_cvl_switch_filter.py @@ -34,6 +34,8 @@ import json import time import re import copy +import random +from itertools import groupby =20 from test_case import TestCase from pmd_output import PmdOutput @@ -2571,6 +2573,45 @@ class SwitchFilterTest(TestCase): result_flag, log_msg =3D dic["check_func"]["func"](out, dic["check= _func"]["param"], dic["expect_results"]) return result_flag, log_msg =20 + def send_packet_get_queue(self, dic): + """ + general packets processing workflow. + """ + self.dut.send_expect("start", "testpmd> ") + # send packets + for per_packet in dic["scapy_str"]: + pkt =3D Packet(pkt_str=3Dper_packet) + pkt.send_pkt(self.tester, tx_port=3Dself.__tx_iface, count=3D1= ) + out =3D self.dut.send_expect("stop", "testpmd> ") + p =3D re.compile(r"Forward Stats for RX Port=3D \d+/Queue=3D(\s?\d= +)") + res =3D p.findall(out) + default_queue =3D [int(i) for i in res] + return default_queue + + def get_available_queue_num(self, default_queue, expect_queue, pmd_que= ue=3D8): + """ + general packets processing workflow. + """ + queue_list =3D list(range(1, pmd_queue)) + # check if expect_queue length is power of 2 + q_len =3D len(expect_queue) + self.verify(q_len & (q_len - 1) =3D=3D 0, "defualt_queue length is= not power of 2!") + for q in default_queue: + if q in queue_list: + queue_list.remove(q) + # according to expect_queue length get available queue + set_queue_list =3D [] + if q_len =3D=3D 1: + set_queue =3D random.choice(queue_list) + set_queue_list.append(set_queue) + else: + fun =3D lambda x: x[1] - x[0] + for k, g in groupby(enumerate(queue_list), fun): + list_group =3D [j for i, j in g] + if len(list_group) >=3D q_len: + set_queue_list =3D list_group[:q_len] + return set_queue_list + def save_results(self, pattern_name, flag, result_flag, log_msg, overa= ll_result): """ save results to dictionary: test_results. @@ -2598,10 +2639,48 @@ class SwitchFilterTest(TestCase): overall_result =3D True test_results.clear() for tv in test_vectors: + # get packet default_queue number + mismatched_dic =3D tv["mismatched"] + default_queue =3D self.send_packet_get_queue(mismatched_dic) + + # check if default_queue same with expect_queue + expect_queue =3D tv["mismatched"]["check_func"]["param"]["expe= ct_queues"] + if expect_queue !=3D "null": + if isinstance(expect_queue, int): + eq_list =3D [] + eq_list.append(expect_queue) + elif isinstance(expect_queue, list): + eq_list =3D expect_queue + recover_flag =3D list(set(eq_list) & set(default_queue)) + else: + recover_flag =3D None + + # if default_queue has same one with expect_queue, recover rul= e + if recover_flag: + # exclude defult_queue number and get set_queue + set_queue_list =3D self.get_available_queue_num(default_qu= eue, eq_list) + # recover rule command and check queue + if isinstance(expect_queue, int): + rule_command =3D tv["rte_flow_pattern"].replace("/ end= actions queue index %s" % str(expect_queue), + "/ end a= ctions queue index %s" % str(set_queue_list[0])) + tv["matched"]["check_func"]["param"]["expect_queues"] = =3D set_queue_list[0] + tv["mismatched"]["check_func"]["param"]["expect_queues= "] =3D set_queue_list[0] + elif isinstance(expect_queue, list): + q =3D [str(i) for i in expect_queue] + expect_queue_str =3D " ".join(q) + s =3D [str(i) for i in set_queue_list] + set_queue_str =3D " ".join(s) + rule_command =3D tv["rte_flow_pattern"].replace("/ end= actions rss queues %s" % expect_queue_str, + "/ end a= ctions rss queues %s" % set_queue_str) + tv["matched"]["check_func"]["param"]["expect_queues"] = =3D set_queue_list + tv["mismatched"]["check_func"]["param"]["expect_queues= "] =3D set_queue_list + else: + rule_command =3D tv["rte_flow_pattern"] + pattern_name =3D tv["name"] test_results[pattern_name] =3D OrderedDict() =20 - out =3D self.dut.send_expect(tv["rte_flow_pattern"], "testpmd>= ", 15) #create a rule + out =3D self.dut.send_expect(rule_command, "testpmd> ", 15) #= create a rule #get the rule number rule_num =3D self.get_rule_number(out) =20 --=20 2.17.1