From: "Xiao, QimaiX" <qimaix.xiao@intel.com>
To: "dts@dpdk.org" <dts@dpdk.org>
Subject: Re: [dts] [PATCH V1 2/2]tests/rte_flow_common: add new methods for passthru
Date: Wed, 18 Mar 2020 08:39:01 +0000 [thread overview]
Message-ID: <0ce762fde54e4bbdb21256a8cebf977f@intel.com> (raw)
In-Reply-To: <1584520284-299370-2-git-send-email-qimaix.xiao@intel.com>
[-- Attachment #1: Type: text/plain, Size: 19874 bytes --]
Tested-by: Xiao, QimaiX <qimaix.xiao@intel.com>
Regards,
Xiao Qimai
> -----Original Message-----
> From: Xiao, QimaiX
> Sent: Wednesday, March 18, 2020 4:31 PM
> To: dts@dpdk.org
> Cc: Xiao, QimaiX <qimaix.xiao@intel.com>
> Subject: [dts][PATCH V1 2/2]tests/rte_flow_common: add new methods for
> passthru
>
> *. add new methods for cvl_fdir update
>
> Signed-off-by: Xiao Qimai <qimaix.xiao@intel.com>
> ---
> 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
[-- Attachment #2: TestCVLFdir.log --]
[-- Type: application/octet-stream, Size: 7442564 bytes --]
prev parent reply other threads:[~2020-03-18 8:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-18 8:31 [dts] [PATCH V1 1/2]tests/TestSuite_cvl_fdir: update script according to testplan Xiao Qimai
2020-03-18 8:31 ` [dts] [PATCH V1 2/2]tests/rte_flow_common: add new methods for passthru Xiao Qimai
2020-03-18 8:39 ` Xiao, QimaiX [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ce762fde54e4bbdb21256a8cebf977f@intel.com \
--to=qimaix.xiao@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).