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 A3E35A0579; Wed, 18 Mar 2020 09:36:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 928742C28; Wed, 18 Mar 2020 09:36:25 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 3BE8D3B5 for ; Wed, 18 Mar 2020 09:36:23 +0100 (CET) IronPort-SDR: dybxxZO2li+j2oOCmptR2D29TzVf4jQpxjrb2aX94jm5qQd1AUWQj++Uy05M4Qj6nQgC3Ku912 vifz4pH6waMg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2020 01:36:22 -0700 IronPort-SDR: XUA2yAd231jbiOMNMu0ic7XCMCKCa2VgOTL77x2dlEo9ZQM21limIiOjUcDWhZdNM6yonCXtSd S+mGTrRvPVRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,566,1574150400"; d="scan'208";a="324099898" Received: from unknown (HELO dpdk-xiaoqimai-dut.sh.intel.com) ([10.240.183.52]) by orsmga001.jf.intel.com with ESMTP; 18 Mar 2020 01:36:21 -0700 From: Xiao Qimai To: dts@dpdk.org Cc: Xiao Qimai Date: Wed, 18 Mar 2020 16:31:24 +0800 Message-Id: <1584520284-299370-2-git-send-email-qimaix.xiao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1584520284-299370-1-git-send-email-qimaix.xiao@intel.com> References: <1584520284-299370-1-git-send-email-qimaix.xiao@intel.com> Subject: [dts] [PATCH V1 2/2]tests/rte_flow_common: add new methods for passthru 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" *. add new methods for cvl_fdir update Signed-off-by: Xiao Qimai --- tests/rte_flow_common.py | 170 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 118 insertions(+), 52 deletions(-) diff --git a/tests/rte_flow_common.py b/tests/rte_flow_common.py index 7592114..873d4c0 100644 --- a/tests/rte_flow_common.py +++ b/tests/rte_flow_common.py @@ -34,61 +34,66 @@ import time import re from utils import GREEN, RED + # switch filter common functions -def get_packet_number(out,match_string): +def get_packet_number(out, match_string): """ get the rx packets number. """ - out_lines=out.splitlines() - pkt_num =0 + out_lines = out.splitlines() + pkt_num = 0 for i in range(len(out_lines)): - if match_string in out_lines[i]: + if match_string in out_lines[i]: result_scanner = r'RX-packets:\s?(\d+)' scanner = re.compile(result_scanner, re.DOTALL) - m = scanner.search(out_lines[i+1]) + m = scanner.search(out_lines[i + 1]) pkt_num = int(m.group(1)) break return pkt_num -def get_port_rx_packets_number(out,port_num): + +def get_port_rx_packets_number(out, port_num): """ get the port rx packets number. """ - match_string="---------------------- Forward statistics for port %d" % port_num - pkt_num = get_packet_number(out,match_string) + match_string = "---------------------- Forward statistics for port %d" % port_num + pkt_num = get_packet_number(out, match_string) return pkt_num + def get_queue_rx_packets_number(out, port_num, queue_id): """ get the queue rx packets number. """ - match_string="------- Forward Stats for RX Port= %d/Queue= %d" % (port_num, queue_id) - pkt_num = get_packet_number(out,match_string) + match_string = "------- Forward Stats for RX Port= %d/Queue= %d" % (port_num, queue_id) + pkt_num = get_packet_number(out, match_string) return pkt_num + def check_output_log_in_queue(out, func_param, expect_results): """ check if the expect queue received the expected number packets. """ - #parse input parameters + # parse input parameters expect_port = func_param["expect_port"] expect_queue = func_param["expect_queues"] expect_pkts = expect_results["expect_pkts"] - pkt_num = get_queue_rx_packets_number(out,expect_port,expect_queue) + pkt_num = get_queue_rx_packets_number(out, expect_port, expect_queue) log_msg = "" - #check the result + # check the result if pkt_num == expect_pkts: return True, log_msg else: log_msg = "Port= %d/Queue= %d receive %d packets" % (expect_port, expect_queue, pkt_num) return False, log_msg + def check_output_log_queue_region(out, func_param, expect_results): """ Check if the expect queues received the expected number packets. """ - #parse input parameters + # parse input parameters expect_port = func_param["expect_port"] expect_queues = func_param["expect_queues"] expect_pkts = expect_results["expect_pkts"] @@ -98,7 +103,7 @@ def check_output_log_queue_region(out, func_param, expect_results): pkt_num = get_queue_rx_packets_number(out, expect_port, queue_id) packet_sumnum += pkt_num - #check the result + # check the result log_msg = "" if packet_sumnum == expect_pkts: return True, log_msg @@ -106,24 +111,26 @@ def check_output_log_queue_region(out, func_param, expect_results): log_msg = "queue region: Not all packets are received in expect_queues" return False, log_msg + def check_output_log_queue_region_mismatched(out, func_param, expect_results): """ when the action is queue region, check the expect port received the expect number packets, while the corresponding queues not receive any packets. """ - #parse input parameters + # parse input parameters expect_port = func_param["expect_port"] expect_queues = func_param["expect_queues"] expect_pkts = expect_results["expect_pkts"] log_msg = "" - #check expect_port received expect number packets + # check expect_port received expect number packets pkt_num = get_port_rx_packets_number(out, expect_port) if pkt_num != expect_pkts: - log_msg = "queue region mismatched: port %d receive %d packets, not receive %d packet" % (expect_port, pkt_num, expect_pkts) + log_msg = "queue region mismatched: port %d receive %d packets, not receive %d packet" % ( + expect_port, pkt_num, expect_pkts) return False, log_msg else: - #check expect queues not received packets + # check expect queues not received packets packet_sumnum = 0 for queue_id in expect_queues: pkt_num = get_queue_rx_packets_number(out, expect_port, queue_id) @@ -136,39 +143,42 @@ def check_output_log_queue_region_mismatched(out, func_param, expect_results): log_msg = "queue region mismatched: expect queues should receive 0 packets, but it received %d packets" % packet_sumnum return False, log_msg + def check_output_log_in_queue_mismatched(out, func_param, expect_results): """ when the action is to queue, check the expect port received the expect number packets, while the corresponding queue not receive any packets. """ - #parse input parameters + # parse input parameters expect_port = func_param["expect_port"] expect_queue = func_param["expect_queues"] expect_pkts = expect_results["expect_pkts"] log_msg = "" - #check expect_port received expect number packets + # check expect_port received expect number packets pkt_num = get_port_rx_packets_number(out, expect_port) if pkt_num != expect_pkts: log_msg = "mismatched: port %d receive %d packets, not receive %d packet" % (expect_port, pkt_num, expect_pkts) return False, log_msg else: - #check expect queue not received packets + # check expect queue not received packets pkt_num = get_queue_rx_packets_number(out, expect_port, expect_queue) log_msg = "" if pkt_num == 0: return True, log_msg else: - log_msg = "mismatched: expect queue Port= %d/Queue= %d should receive 0 packets, but it received %d packets" % (expect_port, expect_queue, pkt_num) + log_msg = "mismatched: expect queue Port= %d/Queue= %d should receive 0 packets, but it received %d packets" % ( + expect_port, expect_queue, pkt_num) return False, log_msg + def check_output_log_drop(out, func_param, expect_results): """ check the expect port not receive any packets. """ - #parse input parameters + # parse input parameters expect_port = func_param["expect_port"] - #check expect_port not received the packets + # check expect_port not received the packets pkt_num = get_port_rx_packets_number(out, expect_port) log_msg = "" @@ -178,33 +188,36 @@ def check_output_log_drop(out, func_param, expect_results): log_msg = "Port %d packets not dropped, received %d packets" % (expect_port, pkt_num) return False, log_msg + def check_output_log_drop_mismatched(out, func_param, expect_results): """ check the expect port received the mismatched packets. """ - #parse input parameters + # parse input parameters expect_port = func_param["expect_port"] expect_pkts = expect_results["expect_pkts"] log_msg = "" - #check expect_port received expect number packets + # check expect_port received expect number packets pkt_num = get_port_rx_packets_number(out, expect_port) if pkt_num == expect_pkts: return True, log_msg else: - log_msg = "drop mismatched: port %d receive %d packets, should receive %d packet" % (expect_port, pkt_num, expect_pkts) + log_msg = "drop mismatched: port %d receive %d packets, should receive %d packet" % ( + expect_port, pkt_num, expect_pkts) return False, log_msg + def check_rule_in_list_by_id(out, rule_num, only_last=True): """ check if the rule with ID "rule_num" is in list, after executing the command "flow list 0". """ - out_lines=out.splitlines() + out_lines = out.splitlines() if len(out_lines) == 1: return False if only_last: - last_rule = out_lines[len(out_lines)-1] + last_rule = out_lines[len(out_lines) - 1] last_rule_list = last_rule.split('\t') rule_id = int(last_rule_list[0]) if rule_id == rule_num: @@ -212,10 +225,10 @@ def check_rule_in_list_by_id(out, rule_num, only_last=True): else: return False else: - #check the list for the rule + # check the list for the rule for i in range(len(out_lines)): if "ID" in out_lines[i]: - rules_list = out_lines[i+1:] + rules_list = out_lines[i + 1:] break for per_rule in rules_list: per_rule_list = per_rule.split('\t') @@ -230,6 +243,7 @@ def verify(passed, description): if not passed: raise AssertionError(description) + def check_queue(out, pkt_num, 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"] @@ -240,22 +254,27 @@ def check_queue(out, pkt_num, check_param, stats=True): 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)) + verify(res_num == pkt_num, + "fail: got wrong number of packets, expect pakcet number %s, got %s." % (pkt_num, res_num)) 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)) + 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))) 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)) + 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))) 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)) + 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))) 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)) + 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))) else: raise Exception("wrong action value, expect queue_index or queue_group") @@ -271,11 +290,13 @@ 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) @@ -289,7 +310,7 @@ def check_mark(out, pkt_num, check_param, stats=True): 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) + "failed: some packet mark id of %s not match" % mark_list) else: check_drop(out[1], pkt_num, check_param, stats) verify(not res, "should has no mark_id in %s" % res) @@ -300,6 +321,45 @@ def check_mark(out, pkt_num, check_param, stats=True): check_drop(out[1], pkt_num, check_param, stats) verify(not res, "should has no mark_id in %s" % res) + +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) + 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') + + +def check_passthru(out, pkt_num, check_param, stats=True): + port_id = check_param["port_id"] if check_param.get("port_id") is not None else 0 + rxq = check_param['rxq'] if check_param.get("rxq") is not None else 64 + fdir_scanner = re.compile("FDIR matched ID=(0x\w+)") + fdir_flag = fdir_scanner.search(out[0]) + p = re.compile( + r"Forward Stats for RX Port= %s/Queue=(\s?\d+)\s.*\n.*RX-packets:(\s?\d+)\s+TX-packets" % port_id) + res = p.findall(out[1]) + if res: + pkt_li = [int(i[1]) for i in res] + pkt_queue = [int(i[0]) 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 stats: + if check_param.get("mark_id") == "NOT_SHOW": + verify(not fdir_flag, 'FDIR exists') + elif "mark_id" in check_param: + verify(int(fdir_flag.group(1), 16) == check_param["mark_id"], "FDIR ID not matched") + else: + verify(fdir_flag, 'FDIR not exists') + else: + verify(not fdir_flag, 'FDIR exists') + verify_directed_by_rss(out[0], rxq=rxq, stats=True) + return pkt_queue + + # rss common functions def check_packets_of_each_queue(out): """ @@ -309,15 +369,15 @@ def check_packets_of_each_queue(out): queueid_rxpackets_list = [] log_msg = "" for q in queue_result: - queue_id =get_queue_id(q[0]) - rx_packets=get_rxpackets(q[1]) + queue_id = get_queue_id(q[0]) + rx_packets = get_rxpackets(q[1]) if (queue_id != -1): queueid_rxpackets_list.append([queue_id, rx_packets]) if (len(queueid_rxpackets_list) == 10): if (queueid_rxpackets_list > 0): return True, log_msg - else : + else: log_msg = "The queue is rx-packets" % id return False, log_msg @@ -331,6 +391,7 @@ def check_packets_of_each_queue(out): else: return False, "queue %s out of range %s" % (queue_set, verify_set) + def check_symmetric_queue(out): """ check each packets in which queue @@ -340,10 +401,11 @@ def check_symmetric_queue(out): log_msg = "" for i in range(m - 1): if queue_list[i] == queue_list[i + 1]: - return True, log_msg + return True, log_msg else: - log_msg = "packets not in same queue and cause to fail" - return False, log_msg + log_msg = "packets not in same queue and cause to fail" + return False, log_msg + def check_simplexor_queue(out): """ @@ -354,17 +416,19 @@ def check_simplexor_queue(out): log_msg = "" for i in range(m - 1): if queue_list[i] == queue_list[i + 1]: - return True, log_msg + return True, log_msg else: - log_msg = "packets not in same queue and cause to fail" - return False, log_msg + log_msg = "packets not in same queue and cause to fail" + return False, log_msg + def check_rx_tx_packets_match(out, count): rx_stats = int(re.findall('RX-total:\s+(\d*)', out)[0]) - if rx_stats == count : - return True, "The Rx packets has matched to the Tx packets" + if rx_stats == count: + return True, "The Rx packets has matched to the Tx packets" else: - return False, "rx and tx packets error!" + return False, "rx and tx packets error!" + def get_queue_id(line1): try: @@ -373,6 +437,7 @@ def get_queue_id(line1): except: return -1 + def get_rxpackets(line2): try: result = re.search(r"RX-packets:\s*(\d*)", line2) @@ -380,6 +445,7 @@ def get_rxpackets(line2): except: return -1 + def find_queueid_rxpackets_list(id, q_rx_list): for item in q_rx_list: if (int(item[0]) == id): -- 1.8.3.1