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 968C0A04EF; Tue, 2 Jun 2020 08:45:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8C9DE1BFEB; Tue, 2 Jun 2020 08:45:23 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 0081C1BEC0 for ; Tue, 2 Jun 2020 08:45:20 +0200 (CEST) IronPort-SDR: KZ9NGfzqzuIRUencY4txraYEdISDs09JM64ARUs3OjWB8Tb7baEAsVZBM7DoW5k8H9a2UAnQjR wpAm5E5B9c7w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2020 23:45:20 -0700 IronPort-SDR: 3oxaWR60V3ukJ7SrzwFQPt++LGXNT5QpfKwAoTUq4Cl2XMDX22cIcfqdbX7b/R0FoaaZbou1Mt mTGLr+Ig1msA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,463,1583222400"; d="scan'208";a="286538171" Received: from unknown (HELO xqm-virtio_tester.sh.intel.com) ([10.240.183.52]) by orsmga002.jf.intel.com with ESMTP; 01 Jun 2020 23:45:19 -0700 From: Xiao Qimai To: dts@dpdk.org Cc: Xiao Qimai Date: Tue, 2 Jun 2020 14:37:19 +0800 Message-Id: <1591079839-137998-4-git-send-email-qimaix.xiao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591079839-137998-1-git-send-email-qimaix.xiao@intel.com> References: <1591079839-137998-1-git-send-email-qimaix.xiao@intel.com> Subject: [dts] [PATCH V2 3/3]tests/rte_flow_common: update rte_flow_common for cvl fdir 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: Xiao Qimai --- tests/rte_flow_common.py | 102 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 32 deletions(-) diff --git a/tests/rte_flow_common.py b/tests/rte_flow_common.py index fb1a245..5a45a7d 100644 --- a/tests/rte_flow_common.py +++ b/tests/rte_flow_common.py @@ -324,35 +324,37 @@ def verify(passed, description): if not passed: raise AssertionError(description) -def check_queue(out, pkt_num, check_param, stats=True): + +def check_queue(out, check_param, stats=True): port_id = check_param["port_id"] if check_param.get("port_id") is not None else 0 queue = check_param["queue"] - p = re.compile( - r"Forward Stats for RX Port= %s/Queue=(\s?\d+)\s.*\n.*RX-packets:(\s?\d+)\s+TX-packets" % port_id) + p = re.compile(r"port\s+%s/queue(.+?):\s+received\s+(\d+)\s+packets" % port_id) res = p.findall(out) if res: - res_queue = [int(i[0]) for i in res] - pkt_li = [int(i[1]) for i in res] - res_num = sum(pkt_li) - verify(res_num == pkt_num, "fail: got wrong number of packets, expect pakcet number %s, got %s." % (pkt_num, res_num)) + pkt_queue = set([int(i[0]) for i in res]) if stats: if isinstance(queue, int): - verify(all(q == queue for q in res_queue), "fail: queue id not matched, expect queue %s, got %s" % (queue, res_queue)) - print((GREEN("pass: queue id %s matched" % res_queue))) + verify(all(q == queue for q in pkt_queue), + "fail: queue id not matched, expect queue %s, got %s" % (queue, pkt_queue)) + print((GREEN("pass: queue id %s matched" % pkt_queue))) elif isinstance(queue, list): - verify(all(q in queue for q in res_queue), "fail: queue id not matched, expect queue %s, got %s" % (queue, res_queue)) - print((GREEN("pass: queue id %s matched" % res_queue))) + verify(all(q in queue for q in pkt_queue), + "fail: queue id not matched, expect queue %s, got %s" % (queue, pkt_queue)) + print((GREEN("pass: queue id %s matched" % pkt_queue))) else: raise Exception("wrong queue value, expect int or list") else: if isinstance(queue, int): - verify(not any(q == queue for q in res_queue), "fail: queue id should not matched, expect queue %s, got %s" % (queue, res_queue)) - print((GREEN("pass: queue id %s not matched" % res_queue))) + verify(not any(q == queue for q in pkt_queue), + "fail: queue id should not matched, expect queue %s, got %s" % (queue, pkt_queue)) + print((GREEN("pass: queue id %s not matched" % pkt_queue))) elif isinstance(queue, list): - verify(not any(q in queue for q in res_queue), "fail: each queue in %s should not in queue %s" % (res_queue, queue)) - print((GREEN("pass: queue id %s not matched" % res_queue))) + verify(not any(q in queue for q in pkt_queue), + "fail: each queue in %s should not in queue %s" % (pkt_queue, queue)) + print((GREEN("pass: queue id %s not matched" % pkt_queue))) else: raise Exception("wrong action value, expect queue_index or queue_group") + return pkt_queue else: raise Exception("got wrong output, not match pattern %s" % p.pattern) @@ -365,34 +367,70 @@ def check_drop(out, pkt_num, check_param, stats=True): pkt_li = p.findall(out) if pkt_li: res = {k: v for k, v in zip(title_li, list(map(int, list(pkt_li[0]))))} - verify(pkt_num == res["rx-total"], "failed: get wrong amount of packet %d, expected %d" % (res["rx-total"], pkt_num)) + verify(pkt_num == res["rx-total"], + "failed: get wrong amount of packet %d, expected %d" % (res["rx-total"], pkt_num)) if stats: verify(res["rx-dropped"] == pkt_num, "failed: dropped packets number %s not match" % res["rx-dropped"]) else: - verify(res["rx-dropped"] == 0 and res["rx-packets"] == pkt_num, "failed: dropped packets number should be 0") + verify(res["rx-dropped"] == 0 and res["rx-packets"] == pkt_num, + "failed: dropped packets number should be 0") else: raise Exception("got wrong output, not match pattern %s" % p.pattern) def check_mark(out, pkt_num, check_param, stats=True): - mark_scanner = "FDIR matched ID=(0x\w+)" - res = re.findall(mark_scanner, out[0]) + mark_id = check_param.get("mark_id") + queue = check_param.get("queue") + rss_flag = check_param.get("rss") + rxq = check_param['rxq'] if check_param.get("rxq") is not None else 64 + drop_flag = check_param.get("drop") + port_id = check_param["port_id"] if check_param.get("port_id") is not None else 0 + fdir_scanner = re.compile("FDIR matched ID=(0x\w+)") + fdir_flag = fdir_scanner.search(out) + pkt_queue = None if stats: - if check_param.get("queue") is not None: - check_queue(out[1], pkt_num, check_param, stats) - mark_list = [i[0] for i in res] - verify(len(res) == pkt_num, "get wrong number of packet with mark_id") - verify(all([int(i, 16) == check_param["mark_id"] for i in res]), - "failed: some packet mark id of %s not match" % mark_list) + if drop_flag is None: + p = re.compile(r"port\s+%s/queue(.+?):\s+received\s+(\d+)\s+packets" % port_id) + res = p.findall(out) + if res: + pkt_li = [int(i[1]) for i in res] + res_num = sum(pkt_li) + verify(res_num == pkt_num, + "fail: got wrong number of packets, expect pakcet number %s, got %s." % (pkt_num, res_num)) + else: + raise Exception("got wrong output, not match pattern %s" % p.pattern) + if mark_id is not None: + mark_list = set(int(i, 16) for i in fdir_scanner.findall(out)) + verify(all([i == check_param["mark_id"] for i in mark_list]), + "failed: some packet mark id of %s not match" % mark_list) + else: + verify(not fdir_flag, "output should not include mark id") + if queue is not None: + check_queue(out, check_param, stats) + if rss_flag: + pkt_queue = verify_directed_by_rss(out, rxq, stats=True) else: - check_drop(out[1], pkt_num, check_param, stats) - verify(not res, "should has no mark_id in %s" % res) + check_drop(out, pkt_num, check_param, stats) + verify(not fdir_flag, "should has no mark_id in %s" % out) else: - if check_param.get("queue") is not None: - check_queue(out[1], pkt_num, check_param, stats) + if drop_flag is None: + pkt_queue = verify_directed_by_rss(out, rxq, stats=True) else: - check_drop(out[1], pkt_num, check_param, stats) - verify(not res, "should has no mark_id in %s" % res) + check_drop(out, pkt_num, check_param, stats) + verify(not fdir_flag, "should has no mark_id in %s" % out) + return pkt_queue + + +def verify_directed_by_rss(out, rxq=64, stats=True): + p = re.compile('RSS\shash=(\w+)\s-\sRSS\squeue=(\w+)') + pkt_info = p.findall(out) + pkt_queue = set([int(i[1], 16) for i in pkt_info]) + if stats: + verify(all([int(i[0], 16) % rxq == int(i[1], 16) for i in pkt_info]), 'some pkt not directed by rss.') + else: + verify(not any([int(i[0], 16) % rxq == int(i[1], 16) for i in pkt_info]), 'some pkt directed by rss') + return pkt_queue + # IAVF fdir common functions def check_iavf_fdir_queue(out, pkt_num, check_param, stats=True): @@ -632,4 +670,4 @@ def check_pf_rss_queue(out, count): if packet_sumnum == count and len(queue_num) == 10: return True else: - return False \ No newline at end of file + return False -- 1.8.3.1