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 4FDD7A00C4; Thu, 13 Jan 2022 07:38:44 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 49EBD4271B; Thu, 13 Jan 2022 07:38:44 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id AB6DD40150 for ; Thu, 13 Jan 2022 07:38:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642055921; x=1673591921; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=++mjNOO+TZK/AIkZ228KhnC79ZfAp23ABrr+PtMWUI8=; b=LHQzHNSvwDptzOwWlquRcqCRmmqueXYDV+bTacqVqO7Eeu6xEEJZKEuz 42PBB3XnpmGsPKu20NfjmgrHQ7dAquRS6W9QRxDEjshzvDDXA5mr6jZl3 iAFjuCNLKcdTsJRKDaVwlqJ/WQd9EC41MJIcJdbhVTJOBMYShlu7DFwVa 3K1Et/mbT9Z9h0bZAUGmQ0mOCO34Sl6gWzFF6or3tHZePo+9TujD6zwQL 28BP4XXBYTlGTQ6VRk/vG56JbTHnbGeIIpeL9ZUK+2UWOJEFhY1AfvPKF /VZYhsM47ELDAj4kT9U09/7eXDETsFMCcFRvRhkSgzLCJAHsIkQWyuc3A w==; X-IronPort-AV: E=McAfee;i="6200,9189,10225"; a="241501755" X-IronPort-AV: E=Sophos;i="5.88,284,1635231600"; d="scan'208";a="241501755" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2022 22:38:41 -0800 X-IronPort-AV: E=Sophos;i="5.88,284,1635231600"; d="scan'208";a="670419135" Received: from unknown (HELO localhost.localdomain) ([10.239.251.93]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2022 22:38:39 -0800 From: Zhimin Huang To: dts@dpdk.org Cc: Zhimin Huang Subject: [dts][PATCH V2 2/4] tests/cvl_advanced_rss:add pf rss cases Date: Thu, 13 Jan 2022 23:07:51 +0800 Message-Id: <20220113150753.27031-3-zhiminx.huang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220113150753.27031-1-zhiminx.huang@intel.com> References: <20220113150753.27031-1-zhiminx.huang@intel.com> 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 add pf rss test case with checksum as inputset. Signed-off-by: Zhimin Huang --- tests/TestSuite_cvl_advanced_rss.py | 454 +++++++++++++++++++++++++++- 1 file changed, 446 insertions(+), 8 deletions(-) diff --git a/tests/TestSuite_cvl_advanced_rss.py b/tests/TestSuite_cvl_advanced_rss.py index d84ef395..0ab61f74 100644 --- a/tests/TestSuite_cvl_advanced_rss.py +++ b/tests/TestSuite_cvl_advanced_rss.py @@ -37,7 +37,7 @@ from framework.packet import Packet from framework.pmd_output import PmdOutput from framework.test_case import TestCase -from .rte_flow_common import RssProcessing +from .rte_flow_common import RssProcessing, FdirProcessing, check_mark # toeplitz related data start mac_ipv4_toeplitz_basic_pkt = { @@ -683,6 +683,40 @@ mac_ipv4_all = { ], } +mac_ipv4_ipv4_chksum = { + 'sub_casename': 'mac_ipv4_ipv4_chksum', + 'port_id': 0, + 'rule': 'flow create 0 ingress pattern eth / ipv4 / end actions rss types ipv4-chksum end queues end / end', + 'test': [ + { + 'send_packet': eval(str(mac_ipv4_toeplitz_basic_pkt['ipv4-nonfrag']).replace('src="192.168.0.2"', + 'src="192.168.0.2", chksum=0x1')), + 'action': 'save_hash', + }, + { + 'send_packet': eval(str(mac_ipv4_toeplitz_basic_pkt['ipv4-nonfrag']).replace('src="192.168.0.2"', + 'src="192.168.0.2", chksum=0xffff')), + 'action': 'check_hash_different', + }, + { + 'send_packet': eval(str(mac_ipv4_toeplitz_basic_pkt['ipv4-nonfrag']).replace('dst="192.168.0.1", src="192.168.0.2"', + 'dst="192.168.1.1", src="192.168.1.2", chksum=0x1')), + 'action': 'check_hash_same', + }, + { + 'send_packet': mac_ipv6_toeplitz_basic_pkt['ipv6-nonfrag'], + 'action': 'check_no_hash', + }, + ], + 'post-test': [ + { + 'send_packet': eval(str(mac_ipv4_toeplitz_basic_pkt['ipv4-nonfrag']).replace('src="192.168.0.2"', + 'src="192.168.0.2", chksum=0x1')), + 'action': 'check_no_hash', + }, + ], +} + #mac ipv4_udp mac_ipv4_udp_l2_src = { 'sub_casename': 'mac_ipv4_udp_l2_src', @@ -1146,6 +1180,72 @@ mac_ipv4_udp_ipv4 = { ], } +mac_ipv4_udp_l4_chksum = { + 'sub_casename': 'mac_ipv4_udp_l4_chksum', + 'port_id': 0, + 'rule': 'flow create 0 ingress pattern eth / ipv4 / udp / end actions rss types l4-chksum end queues end / end', + 'test': [ + { + 'send_packet': eval(str(mac_ipv4_udp_toeplitz_basic_pkt['ipv4-udp']).replace("dport=23", "dport=23,chksum=0xffff")), + 'action': 'save_hash', + }, + { + 'send_packet': eval(str(mac_ipv4_udp_toeplitz_basic_pkt['ipv4-udp']).replace("dport=23", "dport=23,chksum=0xfffe")), + 'action': 'check_hash_different', + }, + { + 'send_packet': eval(str(mac_ipv4_udp_toeplitz_basic_pkt['ipv4-udp']).replace('dst="192.168.0.1", src="192.168.0.2"', + 'dst="192.168.1.1", src="192.168.1.2", chksum=0x3') + .replace('sport=22,dport=23', 'sport=32,dport=33,chksum=0xffff')), + 'action': 'check_hash_same', + }, + { + 'send_packet': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1",dst="192.168.0.2")/SCTP(sport=22, dport=23,chksum=0xffff)/("X"*48)', + 'action': 'check_no_hash', + }, + ], + 'post-test': [ + { + 'send_packet': eval(str(mac_ipv4_udp_toeplitz_basic_pkt['ipv4-udp']).replace("dport=23", "dport=23,chksum=0xffff")), + 'action': 'check_no_hash', + }, + ], +} + +mac_ipv4_udp_ipv4_chksum = { + 'sub_casename': 'mac_ipv4_udp_ipv4_chksum', + 'port_id': 0, + 'rule': 'flow create 0 ingress pattern eth / ipv4 / udp / end actions rss types ipv4-chksum end queues end / end', + 'test': [ + { + 'send_packet': eval(str(mac_ipv4_udp_toeplitz_basic_pkt['ipv4-udp']).replace('src="192.168.0.2"', 'src="192.168.0.2",chksum=0xffff')), + 'action': 'save_hash', + }, + { + 'send_packet': eval(str(mac_ipv4_udp_toeplitz_basic_pkt['ipv4-udp']).replace('src="192.168.0.2"', 'src="192.168.0.2",chksum=0xfffe')), + 'action': 'check_hash_different', + }, + { + 'send_packet': eval(str(mac_ipv4_udp_toeplitz_basic_pkt['ipv4-udp']).replace('dst="192.168.0.1", src="192.168.0.2"', + 'dst="192.168.1.1", src="192.168.1.2", chksum=0xffff') + .replace('sport=22,dport=23', 'sport=32,dport=33,chksum=0xffff')), + 'action': 'check_hash_same', + }, + { + 'send_packet': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1",dst="192.168.0.2")/SCTP(sport=22, dport=23,chksum=0xffff)/("X"*48)', + 'action': 'check_no_hash', + }, + ], + 'post-test': [ + { + 'send_packet': eval(str(mac_ipv4_udp_toeplitz_basic_pkt['ipv4-udp']).replace('src="192.168.0.2"', 'src="192.168.0.2",chksum=0xffff')), + 'action': 'check_no_hash', + }, + ], +} + +mac_ipv4_udp_chksum = [mac_ipv4_udp_l4_chksum, mac_ipv4_udp_ipv4_chksum] + #mac ipv4_tcp mac_ipv4_tcp_l2_src = { 'sub_casename': 'mac_ipv4_tcp_l2_src', @@ -1609,6 +1709,11 @@ mac_ipv4_tcp_ipv4 = { ], } +mac_ipv4_tcp_chksum = [eval(str(element).replace("mac_ipv4_udp", "mac_ipv4_tcp") + .replace("ipv4 / udp", "ipv4 / tcp") + .replace("/UDP(sport=", "/TCP(sport=")) + for element in mac_ipv4_udp_chksum] + #mac ipv4_sctp mac_ipv4_sctp_l2_src = { 'sub_casename': 'mac_ipv4_sctp_l2_src', @@ -2072,6 +2177,12 @@ mac_ipv4_sctp_ipv4 = { ], } +mac_ipv4_sctp_chksum = [eval(str(element).replace("mac_ipv4_udp", "mac_ipv4_sctp") + .replace("SCTP(sport=", "TCP(sport=") + .replace("ipv4 / udp", "ipv4 / sctp") + .replace("/UDP(sport=", "/SCTP(sport=")) + for element in mac_ipv4_udp_chksum] + #mac_ipv6 mac_ipv6_l2_src = { 'sub_casename': 'mac_ipv6_l2_src', @@ -2997,6 +3108,38 @@ mac_ipv6_udp_ipv6 = { ], } +mac_ipv6_udp_l4_chksum = { + 'sub_casename': 'mac_ipv6_udp_l4_chksum', + 'port_id': 0, + 'rule': 'flow create 0 ingress pattern eth / ipv6 / udp / end actions rss types l4-chksum end queues end / end', + 'test': [ + { + 'send_packet': eval(str(mac_ipv6_toeplitz_basic_pkt['ipv6-udp']).replace("dport=23", "dport=23, chksum=0x1")), + 'action': 'save_hash', + }, + { + 'send_packet': eval(str(mac_ipv6_toeplitz_basic_pkt['ipv6-udp']).replace("dport=23", "dport=23, chksum=0x2")), + 'action': 'check_hash_different', + }, + { + 'send_packet': eval(str(mac_ipv6_toeplitz_basic_pkt['ipv6-udp']).replace("sport=22,dport=23", "sport=22,dport=23,chksum=0x1") + .replace("1800:2929", "1800:3939") + .replace("2020", "3030")), + 'action': 'check_hash_same', + }, + { + 'send_packet': eval(str(mac_ipv6_toeplitz_basic_pkt['ipv6-udp']).replace("/UDP(sport=22,dport=23)", "/SCTP(sport=22,dport=23,chksum=0x1)")), + 'action': 'check_no_hash', + }, + ], + 'post-test': [ + { + 'send_packet': eval(str(mac_ipv6_toeplitz_basic_pkt['ipv6-udp']).replace("dport=23", "dport=23, chksum=0x1")), + 'action': 'check_no_hash', + }, + ], +} + #mac_ipv6_tcp mac_ipv6_tcp_l2_src = { 'sub_casename': 'mac_ipv6_tcp_l2_src', @@ -3444,6 +3587,10 @@ mac_ipv6_tcp_ipv6 = { ], } +mac_ipv6_tcp_l4_chksum = eval(str(mac_ipv6_udp_l4_chksum).replace("mac_ipv6_udp", "mac_ipv6_tcp") + .replace("ipv6 / udp", "ipv6 / tcp") + .replace("/UDP(sport=", "/TCP(sport=")) + #mac_ipv6_sctp mac_ipv6_sctp_l2_src = { 'sub_casename': 'mac_ipv6_sctp_l2_src', @@ -3891,42 +4038,47 @@ mac_ipv6_sctp_ipv6 = { ], } +mac_ipv6_sctp_l4_chksum = eval(str(mac_ipv6_udp_l4_chksum).replace("mac_ipv6_udp", "mac_ipv6_sctp") + .replace("/SCTP(sport=", "/TCP(sport=") + .replace("ipv6 / udp", "ipv6 / sctp") + .replace("/UDP(sport=", "/SCTP(sport=")) + # toeplitz related data end -mac_ipv4_1 = [mac_ipv4_l2_src, mac_ipv4_l2_dst, mac_ipv4_l2src_l2dst] +mac_ipv4_1 = [mac_ipv4_l2_src, mac_ipv4_l2_dst, mac_ipv4_l2src_l2dst, mac_ipv4_ipv4_chksum] mac_ipv4_2 = [mac_ipv4_l3_src, mac_ipv4_l3_dst, mac_ipv4_all] mac_ipv4_udp = [mac_ipv4_udp_l2_src, mac_ipv4_udp_l2_dst, mac_ipv4_udp_l2src_l2dst, mac_ipv4_udp_l3_src, mac_ipv4_udp_l3_dst, mac_ipv4_udp_l3src_l4src, mac_ipv4_udp_l3src_l4dst, mac_ipv4_udp_l3dst_l4src, mac_ipv4_udp_l3dst_l4dst, - mac_ipv4_udp_l4_src, mac_ipv4_udp_l4_dst, mac_ipv4_udp_all, mac_ipv4_udp_ipv4] + mac_ipv4_udp_l4_src, mac_ipv4_udp_l4_dst, mac_ipv4_udp_all, mac_ipv4_udp_ipv4] + mac_ipv4_udp_chksum mac_ipv4_tcp = [mac_ipv4_tcp_l2_src, mac_ipv4_tcp_l2_dst, mac_ipv4_tcp_l2src_l2dst, mac_ipv4_tcp_l3_src, mac_ipv4_tcp_l3_dst, mac_ipv4_tcp_l3src_l4src, mac_ipv4_tcp_l3src_l4dst, mac_ipv4_tcp_l3dst_l4src, mac_ipv4_tcp_l3dst_l4dst, - mac_ipv4_tcp_l4_src, mac_ipv4_tcp_l4_dst, mac_ipv4_tcp_all, mac_ipv4_tcp_ipv4] + mac_ipv4_tcp_l4_src, mac_ipv4_tcp_l4_dst, mac_ipv4_tcp_all, mac_ipv4_tcp_ipv4] + mac_ipv4_tcp_chksum mac_ipv4_sctp = [mac_ipv4_sctp_l2_src, mac_ipv4_sctp_l2_dst, mac_ipv4_sctp_l2src_l2dst, mac_ipv4_sctp_l3_src, mac_ipv4_sctp_l3_dst, mac_ipv4_sctp_l3src_l4src, mac_ipv4_sctp_l3src_l4dst, mac_ipv4_sctp_l3dst_l4src, mac_ipv4_sctp_l3dst_l4dst, - mac_ipv4_sctp_l4_src, mac_ipv4_sctp_l4_dst, mac_ipv4_sctp_all, mac_ipv4_sctp_ipv4] + mac_ipv4_sctp_l4_src, mac_ipv4_sctp_l4_dst, mac_ipv4_sctp_all, mac_ipv4_sctp_ipv4] + mac_ipv4_sctp_chksum mac_ipv6 = [mac_ipv6_l2_src, mac_ipv6_l2_dst, mac_ipv6_l2src_l2dst, mac_ipv6_l3_src, mac_ipv6_l3_dst, mac_ipv6_all] mac_ipv6_udp = [mac_ipv6_udp_l2_src, mac_ipv6_udp_l2_dst, mac_ipv6_udp_l2src_l2dst, mac_ipv6_udp_l3_src, mac_ipv6_udp_l3_dst, mac_ipv6_udp_l3src_l4src, mac_ipv6_udp_l3src_l4dst, mac_ipv6_udp_l3dst_l4src, mac_ipv6_udp_l3dst_l4dst, - mac_ipv6_udp_l4_src, mac_ipv6_udp_l4_dst, mac_ipv6_udp_all, mac_ipv6_udp_ipv6] + mac_ipv6_udp_l4_src, mac_ipv6_udp_l4_dst, mac_ipv6_udp_all, mac_ipv6_udp_ipv6, mac_ipv6_udp_l4_chksum] mac_ipv6_tcp = [mac_ipv6_tcp_l2_src, mac_ipv6_tcp_l2_dst, mac_ipv6_tcp_l2src_l2dst, mac_ipv6_tcp_l3_src, mac_ipv6_tcp_l3_dst, mac_ipv6_tcp_l3src_l4src, mac_ipv6_tcp_l3src_l4dst, mac_ipv6_tcp_l3dst_l4src, mac_ipv6_tcp_l3dst_l4dst, - mac_ipv6_tcp_l4_src, mac_ipv6_tcp_l4_dst, mac_ipv6_tcp_all, mac_ipv6_tcp_ipv6] + mac_ipv6_tcp_l4_src, mac_ipv6_tcp_l4_dst, mac_ipv6_tcp_all, mac_ipv6_tcp_ipv6, mac_ipv6_tcp_l4_chksum] mac_ipv6_sctp = [mac_ipv6_sctp_l2_src, mac_ipv6_sctp_l2_dst, mac_ipv6_sctp_l2src_l2dst, mac_ipv6_sctp_l3_src, mac_ipv6_sctp_l3_dst, mac_ipv6_sctp_l3src_l4src, mac_ipv6_sctp_l3src_l4dst, mac_ipv6_sctp_l3dst_l4src, mac_ipv6_sctp_l3dst_l4dst, - mac_ipv6_sctp_l4_src, mac_ipv6_sctp_l4_dst, mac_ipv6_sctp_all, mac_ipv6_sctp_ipv6] + mac_ipv6_sctp_l4_src, mac_ipv6_sctp_l4_dst, mac_ipv6_sctp_all, mac_ipv6_sctp_ipv6, mac_ipv6_sctp_l4_chksum] # symmetric related data start mac_ipv4_symmetric = { @@ -5061,6 +5213,14 @@ class AdvancedRSSTest(TestCase): for i in rules_val: out = self.pmd_output.execute_cmd(i, timeout=1) self.verify('Invalid argument' in out, "rule %s validate successfully" % i) + + rules_chksum = [ + 'flow create 0 ingress pattern eth / ipv4 / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv6 / end actions rss types ipv6-chksum end queues end / end' + ] + for i in rules_chksum: + out = self.pmd_output.execute_cmd(i) + self.verify('Invalid argument' in out or 'Bad arguments' in out, "negative rules not support to create") def test_multirules(self): self.switch_testpmd(symmetric=True) @@ -5236,6 +5396,284 @@ class AdvancedRSSTest(TestCase): self.rssprocess.destroy_rule(port_id=0, rule_id=rule_id_0) self.verify(not self.rssprocess.error_msgs, 'some subcases failed') + def test_checksum_for_different_payload_length(self): + self.rssprocess.error_msgs = [] + self.pmd_output.quit() + self.pmd_output.start_testpmd(cores="1S/4C/1T", param="--rxq={0} --txq={0}".format(self.rxq), + eal_param=f"-a {self.pci0}", socket=self.ports_socket) + self.pmd_output.execute_cmd("set verbose 1") + self.pmd_output.execute_cmd("set fwd rxonly") + self.pmd_output.execute_cmd("start") + pkt_list = [ + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP()/("X"*48)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP()/("X"*64)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP()/UDP()/("X"*48)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP()/UDP()/("X"*64)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP()/TCP()/("X"*48)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP()/TCP()/("X"*64)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP()/SCTP()/("X"*48)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP()/SCTP()/("X"*64)', + ] + rule_list = [ + 'flow create 0 ingress pattern eth / ipv4 / udp / end actions rss types ipv4-udp end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / tcp / end actions rss types ipv4-tcp end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / sctp / end actions rss types ipv4-sctp end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / udp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / tcp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / sctp / end actions rss types l4-chksum end queues end / end' + ] + test_temp = { + 'send_packet': '', + 'action': '', + } + pre_test = [] + for i in range(len(pkt_list)): + if i == 0: + tests = eval(str(test_temp).replace("'send_packet': ''", "'send_packet': '{}'".format(pkt_list[i])) + .replace("'action': ''", "'action': 'save_hash'")) + else: + tests = eval(str(test_temp).replace("'send_packet': ''", "'send_packet': '{}'".format(pkt_list[i])) + .replace("'action': ''", "'action': 'check_hash_same'")) + pre_test.append(tests) + self.rssprocess.handle_tests(pre_test) + test_5_tuple = [] + rules = self.rssprocess.create_rule(rule_list[0:3]) + self.rssprocess.check_rule(rule_list=rules) + for i in range(len(pkt_list)): + if i % 2 == 0: + tests = eval(str(test_temp).replace("'send_packet': ''", "'send_packet': '{}'".format(pkt_list[i])) + .replace("'action': ''", "'action': 'save_hash'")) + else: + tests = eval(str(test_temp).replace("'send_packet': ''", "'send_packet': '{}'".format(pkt_list[i])) + .replace("'action': ''", "'action': 'check_hash_same'")) + test_5_tuple.append(tests) + self.rssprocess.handle_tests(test_5_tuple) + test_l4_chksum = [] + rules = self.rssprocess.create_rule(rule_list[3:]) + self.rssprocess.check_rule(rule_list=rules) + for i in range(2, len(pkt_list)): + if i % 2 == 0: + tests = eval(str(test_temp).replace("'send_packet': ''", "'send_packet': '{}'".format(pkt_list[i])) + .replace("'action': ''", "'action': 'save_hash'")) + else: + tests = eval(str(test_temp).replace("'send_packet': ''", "'send_packet': '{}'".format(pkt_list[i])) + .replace("'action': ''", "'action': 'check_hash_different'")) + test_l4_chksum.append(tests) + self.rssprocess.handle_tests(test_l4_chksum) + test_ipv4_chksum = [] + ipv4_chksum_rule = eval(str(rule_list).replace("l4-chksum", "ipv4-chksum")) + rules = self.rssprocess.create_rule(ipv4_chksum_rule[3:] + ["flow create 0 ingress pattern eth / ipv4 / end actions rss types ipv4-chksum end queues end / end"]) + self.rssprocess.check_rule(rule_list=rules) + for i in range(len(pkt_list)): + if i % 2 == 0: + tests = eval(str(test_temp).replace("'send_packet': ''", "'send_packet': '{}'".format(pkt_list[i])) + .replace("'action': ''", "'action': 'save_hash'")) + else: + tests = eval(str(test_temp).replace("'send_packet': ''", "'send_packet': '{}'".format(pkt_list[i])) + .replace("'action': ''", "'action': 'check_hash_different'")) + test_ipv4_chksum.append(tests) + self.rssprocess.handle_tests(test_ipv4_chksum) + self.verify(not self.rssprocess.error_msgs, 'some subcases failed') + + def validate_packet_checksum(self, pkts, expect_pkts): + expect_chksum = dict() + checksum_pattern = re.compile("chksum.*=.*(0x[0-9a-z]+)") + self.tester.send_expect("scapy", ">>> ") + sniff_src = self.dut.get_mac_address(self.dut_ports[0]) + for pkt in expect_pkts: + self.tester.send_expect("p = %s" % expect_pkts[pkt], ">>>") + out = self.tester.send_expect("p.show2()", ">>>") + chksums = checksum_pattern.findall(out) + expect_chksum[pkt] = chksums + self.logger.info(expect_chksum) + self.tester.send_expect("exit()", "#") + for pkt in pkts: + inst = self.tester.tcpdump_sniff_packets(intf=self.tester_iface0, count=len(pkts), filters=[{'layer': 'ether', 'config': {'src': sniff_src}}]) + out = self.rssprocess.send_pkt_get_output(pkts=pkts[pkt]) + rece_pkt = self.tester.load_tcpdump_sniff_packets(inst) + rece_chksum = rece_pkt[0].sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%").split(";") + self.logger.info(rece_chksum) + test_chksum = [] + [test_chksum.append(i) for i in rece_chksum if i != '??'] + self.logger.info("expect_chksum:{} test_chksum:{}".format(expect_chksum[pkt], test_chksum)) + self.verify(expect_chksum[pkt] == test_chksum, 'tx checksum is incorrect') + + def test_flow_rule_not_impact_rx_tx_chksum(self): + self.pmd_output.quit() + self.pmd_output.start_testpmd(cores="1S/4C/1T", param="--rxq={0} --txq={0}".format(self.rxq), + eal_param=f"-a {self.pci0}", socket=self.ports_socket) + self.pmd_output.execute_cmd("set verbose 1") + self.pmd_output.execute_cmd("port stop all") + self.pmd_output.execute_cmd("set fwd csum") + self.pmd_output.execute_cmd("csum set ip hw 0") + self.pmd_output.execute_cmd("csum set udp hw 0") + self.pmd_output.execute_cmd("csum set tcp hw 0") + self.pmd_output.execute_cmd("csum set sctp hw 0") + self.pmd_output.execute_cmd("port start all") + self.pmd_output.execute_cmd("start") + self.tester.check_interfaces_link(self.tester_iface0) + pkt_list = { + 'IP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1", chksum=0xfff3)/("X"*48)', + 'IP/TCP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1")/TCP(sport=22, chksum=0xfff3)/("X"*48)', + 'IP/UDP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1")/UDP(sport=22, chksum=0x1)/("X"*48)', + 'IP/SCTP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1")/SCTP(sport=22, chksum=0x0)/("X"*48)', + 'IPv6/TCP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IPv6()/TCP(sport=22, chksum=0xe38)/("X"*48)', + 'IPv6/UDP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IPv6()/UDP(sport=22, chksum=0xe38)/("X"*48)', + 'IPv6/SCTP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IPv6()/SCTP(sport=22, chksum=0x0)/("X"*48)', + } + expect_pkt = { + 'IP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1")/("X"*48)', + 'IP/TCP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1")/TCP(sport=22)/("X"*48)', + 'IP/UDP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1")/UDP(sport=22)/("X"*48)', + 'IP/SCTP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1")/SCTP(sport=22)/("X"*48)', + 'IPv6/TCP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IPv6()/TCP(sport=22)/("X"*48)', + 'IPv6/UDP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IPv6()/UDP(sport=22)/("X"*48)', + 'IPv6/SCTP': 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IPv6()/SCTP(sport=22)/("X"*48)', + } + rule_list = [ + 'flow create 0 ingress pattern eth / ipv4 / end actions rss types ipv4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / tcp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / udp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / sctp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv6 / tcp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv6 / udp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv6 / sctp / end actions rss types l4-chksum end queues end / end', + ] + self.validate_packet_checksum(pkt_list, expect_pkt) + rss_test = { + 'sub_casename': 'rss_test', + 'port_id': 0, + 'rule': rule_list, + 'pre-test': [ + { + 'send_packet': pkt_list['IP'], + 'action': {'save_hash': 'IP'}, + }, + { + 'send_packet': pkt_list['IP/TCP'], + 'action': {'save_hash': 'IP/TCP'}, + }, + { + 'send_packet': pkt_list['IP/UDP'], + 'action': {'save_hash': 'IP/UDP'}, + }, + { + 'send_packet': pkt_list['IP/SCTP'], + 'action': {'save_hash': 'IP/SCTP'}, + }, + { + 'send_packet': pkt_list['IPv6/TCP'], + 'action': {'save_hash': 'IPv6/TCP'}, + }, + { + 'send_packet': pkt_list['IPv6/UDP'], + 'action': {'save_hash': 'IPv6/UDP'}, + }, + { + 'send_packet': pkt_list['IPv6/SCTP'], + 'action': {'save_hash': 'IPv6/SCTP'}, + }, + ], + 'test': [ + { + 'send_packet': pkt_list['IP'], + 'action': {'check_hash_different': 'IP'}, + }, + { + 'send_packet': pkt_list['IP/TCP'], + 'action': {'check_hash_different': 'IP/TCP'}, + }, + { + 'send_packet': pkt_list['IP/UDP'], + 'action': {'check_hash_different': 'IP/UDP'}, + }, + { + 'send_packet': pkt_list['IP/SCTP'], + 'action': {'check_hash_different': 'IP/SCTP'}, + }, + { + 'send_packet': pkt_list['IPv6/TCP'], + 'action': {'check_hash_different': 'IPv6/TCP'}, + }, + { + 'send_packet': pkt_list['IPv6/UDP'], + 'action': {'check_hash_different': 'IPv6/UDP'}, + }, + { + 'send_packet': pkt_list['IPv6/SCTP'], + 'action': {'check_hash_different': 'IPv6/SCTP'}, + }, + ], + } + self.rssprocess.handle_rss_distribute_cases(rss_test) + self.validate_packet_checksum(pkt_list, expect_pkt) + + def test_combined_case_with_fdir_queue_group(self): + fdirprocess = FdirProcessing(self, self.pmd_output, [self.tester_iface0, self.tester_iface1], self.rxq) + hash_and_queue_list = [] + queue_group = re.compile("end actions rss queues (\d+)\s(\d+)") + self.pmd_output.quit() + self.pmd_output.start_testpmd(cores="1S/4C/1T", param="--rxq={0} --txq={0}".format(self.rxq), + eal_param=f"-a {self.pci0}", socket=self.ports_socket) + self.pmd_output.execute_cmd("set verbose 1") + self.pmd_output.execute_cmd("set fwd rxonly") + self.pmd_output.execute_cmd("start") + pkt_list = [ + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1", chksum=0xfff3)/("X"*48)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1")/TCP(sport=22, chksum=0xfff3)/("X"*48)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1")/UDP(sport=22, chksum=0x1)/("X"*48)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IP(src="192.168.0.1")/SCTP(sport=22, chksum=0x1)/("X"*48)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IPv6()/TCP(sport=22, chksum=0xe38)/("X"*48)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IPv6()/UDP(sport=22, chksum=0xe38)/("X"*48)', + 'Ether(dst="00:11:22:33:44:55", src="52:00:00:00:00:00")/IPv6(src="ABAB:910A:2222:5498:8475:1111:3900:1010")/SCTP(sport=22, chksum=0xf)/("X"*48)', + ] + rss_rule_list = [ + 'flow create 0 ingress pattern eth / ipv4 / end actions rss types ipv4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / tcp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / udp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv4 / sctp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv6 / tcp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv6 / udp / end actions rss types l4-chksum end queues end / end', + 'flow create 0 ingress pattern eth / ipv6 / sctp / end actions rss types l4-chksum end queues end / end', + ] + fdir_rule_list = [ + 'flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / ipv4 / tcp / end actions rss queues 4 5 end / mark / end', + 'flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / ipv4 / udp / end actions rss queues 6 7 end / mark / end', + 'flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / ipv4 / sctp / end actions rss queues 8 9 end / mark / end', + 'flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / ipv6 / tcp / end actions rss queues 10 11 end / mark / end', + 'flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / ipv6 / udp / end actions rss queues 12 13 end / mark / end', + 'flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / ipv6 / sctp / end actions rss queues 14 15 end / mark / end', + ] + fdirprocess.create_rule(fdir_rule_list) + fdir_rule_list.insert(0, "") + for i in range(len(pkt_list)): + out = fdirprocess.send_pkt_get_output(pkt_list[i]) + hash_and_queue_tuple = self.rssprocess.get_hash_and_queues(out) + if i == 0: + check_mark(out, pkt_num=1, check_param={"port_id": 0, "rss": True}) + else: + queue_list = list(map(int, queue_group.search(fdir_rule_list[i]).groups())) + check_mark(out, pkt_num=1, check_param={"port_id": 0, "queue": queue_list, "mark_id": 0}) + hash_and_queue_list.append(hash_and_queue_tuple) + self.rssprocess.create_rule(rss_rule_list) + for i in range(len(pkt_list)): + out = fdirprocess.send_pkt_get_output(pkt_list[i]) + hashes, queues = self.rssprocess.get_hash_and_queues(out) + if i == 0: + check_mark(out, pkt_num=1, check_param={"port_id": 0, "rss": True}) + hashes_0 = hashes + else: + queue_list = list(map(int, queue_group.search(fdir_rule_list[i]).groups())) + check_mark(out, pkt_num=1, check_param={"port_id": 0, "queue": queue_list, "mark_id": 0}) + self.logger.info("pre_hash: {} test_hash: {}".format(hash_and_queue_list[i][0], hashes)) + self.verify(hash_and_queue_list[i][0] != hashes, "expect hash values changed") + self.rssprocess.create_rule("flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / ipv4 / end actions rss queues 0 1 2 3 end / end") + out = fdirprocess.send_pkt_get_output(pkt_list[0]) + hashes, queues = self.rssprocess.get_hash_and_queues(out) + check_mark(out, pkt_num=1, check_param={"port_id": 0, "queue": [1, 2, 3, 4]}) + self.logger.info("test_hash: {} post_hash: {}".format(hashes_0, hashes)) + self.verify(hashes == hashes_0, "expect hash values not changed") + def tear_down(self): # destroy all flow rule on port 0 self.dut.send_command("flow flush 0", timeout=1) -- 2.17.1