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 71804A04F0; Fri, 27 Dec 2019 09:07:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 160BB1BFEB; Fri, 27 Dec 2019 09:07:09 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 839FF1BFA8 for ; Fri, 27 Dec 2019 09:07:07 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Dec 2019 00:07:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,362,1571727600"; d="scan'208";a="220051900" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga006.jf.intel.com with ESMTP; 27 Dec 2019 00:07:06 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 27 Dec 2019 00:07:05 -0800 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 27 Dec 2019 00:06:52 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.19]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.164]) with mapi id 14.03.0439.000; Fri, 27 Dec 2019 16:06:51 +0800 From: "Tu, Lijuan" To: "Xie, WeiX" , "dts@dpdk.org" CC: "Xie, WeiX" Thread-Topic: [dts] [PATCH V2] tests/macsec_for_ixgbe:add an automation Thread-Index: AQHVvGBh+mPwkYPeXEW3A8AkVRFoXqfNoGYQ Date: Fri, 27 Dec 2019 08:06:50 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BB8EEC0@SHSMSX101.ccr.corp.intel.com> References: <1577415303-87479-1-git-send-email-weix.xie@intel.com> In-Reply-To: <1577415303-87479-1-git-send-email-weix.xie@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="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V2] tests/macsec_for_ixgbe:add an automation 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 > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Xie Wei > Sent: Friday, December 27, 2019 10:55 AM > To: dts@dpdk.org > Cc: Xie, WeiX > Subject: [dts] [PATCH V2] tests/macsec_for_ixgbe:add an automation >=20 > a new automation according to test plan >=20 > Signed-off-by: Xie Wei > --- > tests/TestSuite_macsec_for_ixgbe.py | 469 > ++++++++++++++++++++++++++++ > 1 file changed, 469 insertions(+) > create mode 100644 tests/TestSuite_macsec_for_ixgbe.py >=20 > diff --git a/tests/TestSuite_macsec_for_ixgbe.py > b/tests/TestSuite_macsec_for_ixgbe.py > new file mode 100644 > index 0000000..ad14383 > --- /dev/null > +++ b/tests/TestSuite_macsec_for_ixgbe.py > @@ -0,0 +1,469 @@ > +# BSD LICENSE > +# > +# Copyright (c) <2017>, Intel Corporation. All rights reserved. > +# > +# Redistribution and use in source and binary forms, with or without # > +modification, are permitted provided that the following conditions # > +are met: > +# > +# * Redistributions of source code must retain the above copyright > +# notice, this list of conditions and the following disclaimer. > +# * Redistributions in binary form must reproduce the above copyright > +# notice, this list of conditions and the following disclaimer in > +# the documentation and/or other materials provided with the > +# distribution. > +# * Neither the name of Intel Corporation nor the names of its > +# contributors may be used to endorse or promote products derived > +# from this software without specific prior written permission. > +# > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > CONTRIBUTORS # > +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > # > +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS > FOR # > +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > COPYRIGHT # > +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, # > +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > NOT # > +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF > USE, # > +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND > ON ANY # > +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > # > +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF > THE USE # > +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > DAMAGE. > + > + > +import re > +import time > +import os > + > +from test_case import TestCase > +from dut import Dut > +from pktgen import PacketGeneratorHelper from packet import Packet > + > +class TestMacsecForIxgbe(TestCase): > + def set_up_all(self): > + """ > + Prerequisite steps for each test suite. > + """ > + self.verify(self.nic in ["niantic"], "NIC Unsupported: " + str(s= elf.nic)) > + self.dut_ports =3D self.dut.get_ports(self.nic) > + self.verify(len(self.dut_ports) >=3D 2, "Insufficient ports") > + self.core_list =3D self.dut.get_core_list('1S/4C/1T') > + self.verify(len(self.core_list) >=3D 4, "There has not enought c= ores to test > this suite") > + self.session_sec =3D self.dut.new_session() > + self.pci_rx =3D self.dut.ports_info[self.dut_ports[1]]['pci'] > + self.pci_tx =3D self.dut.ports_info[self.dut_ports[0]]['pci'] > + self.mac0 =3D self.dut.get_mac_address(self.dut_ports[0]) > + self.mac1 =3D self.dut.get_mac_address(self.dut_ports[1]) > + > + if self.logger.log_path.startswith(os.sep): > + self.output_path =3D self.logger.log_path > + else: > + cur_path =3D > os.path.dirname(os.path.dirname(os.path.realpath(__file__))) > + self.output_path =3D os.sep.join([cur_path, self.logger.log_= path]) > + # create an instance to set stream field setting > + self.pktgen_helper =3D PacketGeneratorHelper() > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + self.ol_flags =3D 1 > + > + def start_testpmd_rx(self): > + eal_params =3D self.dut.create_eal_parameters(cores=3Dself.core_= list[0:2], > ports=3D[self.pci_rx], prefix=3D'rx') > + cmd_rx =3D self.target + '/app/testpmd ' + eal_params + '-- -i -= -port- > topology=3Dchained' > + return self.dut.send_expect(cmd_rx, "testpmd", 120) > + > + def start_testpmd_tx(self): > + eal_params =3D self.dut.create_eal_parameters(cores=3Dself.core_= list[2:4], > ports=3D[self.pci_tx], prefix=3D'tx') > + cmd_tx =3D self.target + '/app/testpmd ' + eal_params + '-- -i -= -port- > topology=3Dchained' > + return self.session_sec.send_expect(cmd_tx, "testpmd", 120) > + > + def start_testpmd_perf(self): > + eal_params =3D self.dut.create_eal_parameters(cores=3Dself.core_= list[0:2]) > + cmd =3D self.target + '/app/testpmd ' + eal_params + '-- -i --po= rt- > topology=3Dchained' > + self.dut.send_expect(cmd, "testpmd", 120) > + self.rx_set_macsec_offload('on', 'on') > + self.dut.send_expect("set fwd mac", "testpmd>", 2) > + self.dut.send_expect("start", "testpmd>", 2) > + > + def show_xstats(self): > + time.sleep(0.1) > + self.session_sec.send_expect("stop", "testpmd>", 2) > + out_out =3D self.session_sec.send_expect("show port xstats 0", > "testpmd>") > + out_pkts_encrypted =3D > int(re.compile('out_pkts_encrypted:\s+(.*?)\s+?').findall(out_out, re.S)[= 0]) > + out_octets_encrypted =3D > int(re.compile('out_octets_encrypted:\s+(.*?)\s+?').findall(out_out, re.S= )[0]) > + out_pkts_protected =3D > int(re.compile('out_pkts_protected:\s+(.*?)\s+?').findall(out_out, re.S)[= 0]) > + out_octets_protected =3D > int(re.compile('out_octets_protected:\s+(.*?)\s+?').findall(out_out, re.S= )[0]) > + tx_good_packets =3D > int(re.compile('tx_good_packets:\s+(.*?)\s+?').findall(out_out, re.S)[0]) > + if self.ol_flags =3D=3D 0: > + pkts_content =3D self.dut.get_session_output(timeout=3D2) > + > + self.dut.send_expect("stop", "testpmd>", 2) > + out_in =3D self.dut.send_expect("show port xstats 0", "testpmd>"= ) > + rx_good_packets =3D > int(re.compile('rx_good_packets:\s+(.*?)\s+?').findall(out_in, re.S)[0]) > + in_pkts_ok =3D int(re.compile('in_pkts_ok:\s+(.*?)\s+?').findall= (out_in, > re.S)[0]) > + in_octets_decrypted =3D > int(re.compile('in_octets_decrypted:\s+(.*?)\s+?').findall(out_in, re.S)[= 0]) > + in_octets_validated =3D > int(re.compile('in_octets_validated:\s+(.*?)\s+?').findall(out_in, re.S)[= 0]) > + in_pkts_late =3D int(re.compile('in_pkts_late:\s+(.*?)\s+?').fin= dall(out_in, > re.S)[0]) > + in_pkts_notvalid =3D > int(re.compile('in_pkts_notvalid:\s+(.*?)\s+?').findall(out_in, re.S)[0]) > + in_pkts_nosci =3D > int(re.compile('in_pkts_nosci:\s+(.*?)\s+?').findall(out_in, re.S)[0]) > + in_pkts_notusingsa =3D > + int(re.compile('in_pkts_notusingsa:\s+(.*?)\s+?').findall(out_in, > + re.S)[0]) > + > + list_1 =3D ['out_pkts_encrypted', 'out_octets_encrypted', > 'out_pkts_protected', 'out_octets_protected', 'tx_good_packets', > 'rx_good_packets', > + 'in_pkts_ok', 'in_octets_decrypted', 'in_octets_vali= dated', > 'in_pkts_late', 'in_pkts_notvalid', 'in_pkts_nosci', 'in_pkts_notusingsa'= ] > + list_2 =3D [out_pkts_encrypted, out_octets_encrypted, > out_pkts_protected, out_octets_protected, tx_good_packets, > rx_good_packets, > + in_pkts_ok, in_octets_decrypted, in_octets_validated= , > in_pkts_late, in_pkts_notvalid, in_pkts_nosci, in_pkts_notusingsa] > + result_dict =3D dict(zip(list_1, list_2)) > + print result_dict > + > + if self.ol_flags =3D=3D 0: > + return result_dict, pkts_content > + return result_dict > + > + def clear_port_xstats(self): > + self.dut.send_expect("clear port xstats 0", "testpmd>") > + self.session_sec.send_expect("clear port xstats 0", "testpmd>") > + > + def rx_set_macsec_offload(self, encrypt_rx, replay_rx): > + # rx port > + self.dut.send_expect("port stop 0", "testpmd>", 2) > + self.dut.send_expect("set macsec offload 0 on encrypt %s replay- > protect %s" % (encrypt_rx, replay_rx), "testpmd>") > + self.dut.send_expect("port start 0", "testpmd>", 2) > + > + def tx_set_macsec_offload(self, encrypt_tx, replay_tx): > + # tx port > + self.session_sec.send_expect("port stop 0", "testpmd>", 2) > + self.session_sec.send_expect("set macsec offload 0 on encrypt %s > replay-protect %s" % (encrypt_tx, replay_tx), "testpmd>") > + self.session_sec.send_expect("port start 0", "testpmd>", 2) > + > + def rx_set_macsec_various_param(self, pi, idx, an, pn, key): > + # rx port > + self.dut.send_expect("set macsec sc rx 0 %s %s" % (self.mac0, pi= ), > "testpmd>") > + self.dut.send_expect("set macsec sa rx 0 %s %s %s %s" % (idx, an= , pn, > key), "testpmd>") > + self.dut.send_expect("set macsec sc tx 0 %s %s" % (self.mac1, pi= ), > "testpmd>") > + self.dut.send_expect("set macsec sa tx 0 %s %s %s %s" % (idx, an= , pn, > key), "testpmd>") > + self.dut.send_expect("set fwd rxonly", "testpmd>") > + self.dut.send_expect("set promisc all on", "testpmd>") > + if self.ol_flags =3D=3D 0: > + self.dut.send_expect("set verbose 1", "testpmd>") > + self.dut.send_expect("start", "testpmd>", 2) > + > + def tx_set_macsec_various_param(self, pi, idx, an, pn, key): > + # tx port > + self.session_sec.send_expect("set macsec sc tx 0 %s %s" % (self.= mac0, > pi), "testpmd>") > + self.session_sec.send_expect("set macsec sa tx 0 %s %s %s %s" % = (idx, > an, pn, key), "testpmd>") > + self.session_sec.send_expect("set macsec sc rx 0 %s %s" % (self.= mac1, > pi), "testpmd>") > + self.session_sec.send_expect("set macsec sa rx 0 %s %s %s %s" % = (idx, > an, pn, key), "testpmd>") > + self.session_sec.send_expect("set fwd txonly", "testpmd>") > + self.session_sec.send_expect("start", "testpmd>", 2) > + > + def packets_receive_num(self): > + time.sleep(0.1) > + self.session_sec.send_expect("stop", "testpmd>", 2) > + self.dut.send_expect("stop", "testpmd>", 2) > + out =3D self.dut.send_expect("show port stats 0", "testpmd>") > + packet_number =3D re.compile('RX-packets:\s+(.*?)\s+?').findall(= out, re.S) > + return packet_number > + > + def check_MACsec_pkts_receive(self): > + xstats =3D self.show_xstats() > + self.verify(xstats.get('out_pkts_protected') =3D=3D 0 > + and xstats.get('out_pkts_encrypted') =3D=3D xstats.g= et('in_pkts_ok') > =3D=3D xstats.get('tx_good_packets') =3D=3D xstats.get('rx_good_packets') > + and xstats.get('in_pkts_ok') !=3D 0 > + and xstats.get('out_octets_encrypted') =3D=3D > xstats.get('in_octets_decrypted') > + and xstats.get('out_octets_encrypted') !=3D 0 > + and xstats.get('out_octets_protected') =3D=3D > xstats.get('in_octets_validated') > + and xstats.get('out_octets_protected') !=3D 0, > + "MACsec pkts receive failed") > + > + def test_MACsec_pkts_tx_and_rx(self): > + """ > + MACsec packets send and receive > + """ > + self.start_testpmd_rx() > + self.rx_set_macsec_offload('on', 'on') > + self.rx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + self.start_testpmd_tx() > + self.tx_set_macsec_offload('on', 'on') > + self.tx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + self.check_MACsec_pkts_receive() > + > + def test_MACsec_encrypt_off_and_replay_protect_off(self): > + """ > + encrypt on/off, replay-protect on/off > + """ > + self.start_testpmd_rx() > + self.rx_set_macsec_offload('on', 'on') > + self.rx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + self.start_testpmd_tx() > + self.tx_set_macsec_offload('off', 'on') > + self.tx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + xstats =3D self.show_xstats() > + self.verify(xstats.get('out_pkts_encrypted') =3D=3D 0 > + and xstats.get('out_pkts_protected') =3D=3D xstats.g= et('in_pkts_ok') > =3D=3D xstats.get('tx_good_packets') =3D=3D xstats.get('rx_good_packets') > + and xstats.get('in_pkts_ok') !=3D 0 > + and xstats.get('out_octets_encrypted') =3D=3D 0 and > xstats.get('in_octets_decrypted') =3D=3D 0 > + and xstats.get('out_octets_protected') =3D=3D > xstats.get('in_octets_validated') > + and xstats.get('out_pkts_protected') !=3D 0, "failed= ") > + self.session_sec.send_expect("quit", "#") > + self.dut.send_expect("quit", "#") > + > + self.start_testpmd_rx() > + self.rx_set_macsec_offload('on', 'on') > + self.rx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + self.start_testpmd_tx() > + self.tx_set_macsec_offload('on', 'off') > + self.tx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + self.check_MACsec_pkts_receive() > + > + def test_MACsec_tx_and_rx_with_various_param(self): > + """ > + Set MACsec packets send and receive with various parameters, but > keep the same value on both sides. > + """ > + # rx side > + self.start_testpmd_rx() > + self.rx_set_macsec_offload('on', 'on') > + # tx side > + self.start_testpmd_tx() > + self.tx_set_macsec_offload('on', 'on') > + > + # subcase1:set various index on rx and tx port > + for i in [1, 2]: > + if i =3D=3D 2: > + result =3D self.dut.send_expect("set macsec sa rx 0 %s 0= 0 > 00112200000000000000000000000000" % i, "testpmd>") > + self.verify("invalid" in result, "set idx to 2 failed") > + break > + else: > + self.rx_set_macsec_various_param(0, i, 0, 0, > '00112200000000000000000000000000') > + self.tx_set_macsec_various_param(0, i, 0, 0, > '00112200000000000000000000000000') > + self.check_MACsec_pkts_receive() > + self.clear_port_xstats() > + > + # subcase2:set various an on rx and tx port > + for i in range(1, 5): > + if i =3D=3D 4: > + result =3D self.dut.send_expect("set macsec sa rx 0 0 %s= 0 > 00112200000000000000000000000000" % i, "testpmd>") > + self.verify("invalid" in result, "set an to 4 failed") > + break > + else: > + self.rx_set_macsec_various_param(0, 0, i, 0, > '00112200000000000000000000000000') > + self.tx_set_macsec_various_param(0, 0, i, 0, > '00112200000000000000000000000000') > + self.check_MACsec_pkts_receive() > + self.clear_port_xstats() > + self.session_sec.send_expect("quit", "#") > + self.dut.send_expect("quit", "#") > + > + # subcase3:set various pn on rx and tx port > + for i in ['0xffffffed', '0xffffffee', '0xffffffef', '0xfffffff0'= , '0xffffffec', > '0x100000000']: > + # rx side > + self.start_testpmd_rx() > + self.rx_set_macsec_offload('on', 'on') > + # tx side > + self.start_testpmd_tx() > + self.tx_set_macsec_offload('on', 'on') > + if i =3D=3D '0x100000000': > + result =3D self.dut.send_expect("set macsec sa rx 0 0 0 = %s > 00112200000000000000000000000000" % i, "testpmd>") > + self.verify("Bad arguments" in result, "set pn to 0x1000= 00000 > failed") > + break > + else: > + self.rx_set_macsec_various_param(0, 0, 0, i, > '00112200000000000000000000000000') > + self.tx_set_macsec_various_param(0, 0, 0, i, > '00112200000000000000000000000000') > + pkt_num =3D self.packets_receive_num() > + if i =3D=3D '0xffffffec': > + self.verify(int(pkt_num[0]) =3D=3D 4, "Rx port can't= receive four pkts") > + self.clear_port_xstats() > + else: > + self.verify(int(pkt_num[0]) =3D=3D 3, "Rx port can't= receive three > pkts") > + self.session_sec.send_expect("quit", "#") > + self.dut.send_expect("quit", "#") > + > + # subcase4:set various key on rx and tx port > + for i in ['00000000000000000000000000000000', > 'ffffffffffffffffffffffffffffffff']: > + self.rx_set_macsec_various_param(0, 0, 0, 0, i) > + self.tx_set_macsec_various_param(0, 0, 0, 0, i) > + self.check_MACsec_pkts_receive() > + self.clear_port_xstats() > + > + # subcase5:set various pi on rx and tx port > + for i in [1, '0xffff', '0x10000']: > + if i =3D=3D '0x10000': > + result =3D self.dut.send_expect("set macsec sc rx 0 %s %= s" % > (self.mac0, i), "testpmd>") > + self.verify("Bad arguments" in result, "set pi to 0x1000= 0 failed") > + break > + else: > + self.rx_set_macsec_various_param(i, 0, 0, 0, > '0112200000000000000000000000000') > + self.tx_set_macsec_various_param(i, 0, 0, 0, > '0112200000000000000000000000000') > + pkt_num =3D self.packets_receive_num() > + self.verify(int(pkt_num[0]) =3D=3D 0, "MACsec pkts can't= be > + received") > + > + def test_MACsec_pkts_send_and_normal_receive(self): > + """ > + Disable MACsec offload on rx port,enable MACsec offload on tx po= rt > + """ > + self.ol_flags =3D 0 > + # rx port > + self.start_testpmd_rx() > + self.dut.send_expect("port stop 0", "testpmd>", 2) > + self.dut.send_expect("set macsec offload 0 off", "testpmd>") > + self.dut.send_expect("port start 0", "testpmd>", 2) > + self.dut.send_expect("set fwd rxonly", "testpmd>") > + self.dut.send_expect("set promisc all on", "testpmd>") > + self.dut.send_expect("set verbose 1", "testpmd>") > + self.dut.send_expect("start", "testpmd>", 2) > + > + # tx port > + self.start_testpmd_tx() > + self.tx_set_macsec_offload('on', 'on') > + self.tx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + xstats, pkts_content =3D self.show_xstats() > + self.verify("L2_ETHER" in pkts_content > + and "L3_IPV4" not in pkts_content > + and "L4_UDP" not in pkts_content, "The received pack= ets are not > encrypted") > + self.verify(xstats.get('in_octets_decrypted') =3D=3D 0 and > xstats.get('in_octets_validated') =3D=3D 0, > + "Error:in_octets_decrypted and in_octets_validated > + increase") > + > + def test_normal_pkts_send_and_MACsec_receive(self): > + """ > + Enable MACsec offload on rx port,disable MACsec offload on tx po= rt > + """ > + # rx port > + self.ol_flags =3D 0 > + self.start_testpmd_rx() > + self.rx_set_macsec_offload('on', 'on') > + self.rx_set_macsec_various_param(0, 0, 0, 0, > + '00112200000000000000000000000000') > + > + # tx port > + self.start_testpmd_tx() > + self.session_sec.send_expect("port stop 0", "testpmd>", 2) > + self.session_sec.send_expect("set macsec offload 0 off", "testpm= d>") > + self.session_sec.send_expect("port start 0", "testpmd>", 2) > + self.session_sec.send_expect("set fwd txonly", "testpmd>") > + self.session_sec.send_expect("start", "testpmd>", 2) > + > + xstats, pkts_content=3D self.show_xstats() > + self.verify("L2_ETHER L3_IPV4 L4_UDP" in pkts_content, "The rece= ived > packets are encrypted") > + self.verify(xstats.get('in_octets_decrypted') =3D=3D 0 and > xstats.get('out_pkts_encrypted') =3D=3D 0, > + "Error:in_octets_decrypted and out_pkts_encrypted > + increase") > + > + def test_MACsec_tx_and_rx_with_wrong_param(self): > + """ > + MACsec packets send and receive with wrong parameters > + """ > + # rx side > + self.start_testpmd_rx() > + self.rx_set_macsec_offload('on', 'on') > + # tx side > + self.start_testpmd_tx() > + self.tx_set_macsec_offload('on', 'on') > + > + # subcase1:set different pn on rx and tx port > + self.rx_set_macsec_various_param(0, 0, 0, 2, > '00112200000000000000000000000000') > + self.tx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + xstats =3D self.show_xstats() > + self.verify(xstats.get('out_pkts_encrypted') =3D=3D xstats.get('= in_pkts_ok') + > xstats.get('in_pkts_late') > + and xstats.get('out_octets_encrypted') =3D=3D > xstats.get('in_octets_decrypted'), "subcase1:failed") > + self.clear_port_xstats() > + # Rx port can receive the packets until the pn equals the pn of = tx port > + self.rx_set_macsec_various_param(0, 0, 0, 2, > '00112200000000000000000000000000') > + self.tx_set_macsec_various_param(0, 0, 0, 2, > '00112200000000000000000000000000') > + self.check_MACsec_pkts_receive() > + self.clear_port_xstats() > + > + # subcase2:set different keys on rx and tx port > + self.rx_set_macsec_various_param(0, 0, 0, 0, > '00000000000000000000000000000000') > + self.tx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + xstats =3D self.show_xstats() > + self.verify(xstats.get('in_pkts_ok') =3D=3D 0 > + and xstats.get('out_pkts_encrypted') =3D=3D > xstats.get('in_pkts_notvalid') > + and xstats.get('out_octets_encrypted') =3D=3D > xstats.get('in_octets_decrypted'), "subcase2:failed") > + pkt_num =3D self.packets_receive_num() > + self.verify(int(pkt_num[0]) =3D=3D 0, "Rx port can't receive pkt= s") > + self.clear_port_xstats() > + > + # subcase3:set different pi on rx and tx port > + self.rx_set_macsec_various_param(1, 0, 0, 0, > '0112200000000000000000000000000') > + self.tx_set_macsec_various_param(0, 0, 0, 0, > '0112200000000000000000000000000') > + xstats =3D self.show_xstats() > + self.verify(xstats.get('in_pkts_ok') =3D=3D 0 and > xstats.get('out_pkts_encrypted') =3D=3D xstats.get('in_pkts_nosci') > + and xstats.get('out_octets_encrypted') =3D=3D > xstats.get('in_octets_decrypted'), "subcase3:failed") > + self.clear_port_xstats() > + > + # subcase4:set different an on rx and tx port > + self.rx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + self.tx_set_macsec_various_param(0, 0, 1, 0, > '00112200000000000000000000000000') > + xstats =3D self.show_xstats() > + self.verify(xstats.get('in_pkts_ok') =3D=3D 0 and > xstats.get('out_pkts_encrypted') =3D=3D xstats.get('in_pkts_notusingsa') > + and xstats.get('out_octets_encrypted') =3D=3D > xstats.get('in_octets_decrypted'), "subcase4:failed") > + self.clear_port_xstats() > + > + # subcase5:set different index on rx and tx port > + self.rx_set_macsec_various_param(0, 0, 0, 0, > '00112200000000000000000000000000') > + self.tx_set_macsec_various_param(0, 1, 0, 0, > '00112200000000000000000000000000') > + xstats =3D self.show_xstats() > + self.verify(xstats.get('out_pkts_encrypted') =3D=3D xstats.get('= in_pkts_ok') > + and xstats.get('out_octets_encrypted') =3D=3D > + xstats.get('in_octets_decrypted'), "subcase5:failed") > + > + def test_packet_length(self): > + """ > + On IXIA side, start IXIA port6 transmit, start the IXIA capture. > + View the IXIA port5 captured packet, the protocol is MACsec, the > EtherType > + is 0x88E5, and the packet length is 96bytes, while the normal pa= cket > length > + is 64bytes. > + """ > + self.tester_itf_0 =3D self.tester.get_interface(self.dut_ports[0= ]) > + self.tester_itf_1 =3D self.tester.get_interface(self.dut_ports[1= ]) > + self.start_testpmd_perf() > + # start tcpdump > + self.tester.send_expect("rm -rf ./tcpdump_test.cap", "#") > + self.tester.send_expect("tcpdump -i %s ether src %s - > w ./tcpdump_test.cap 2> /dev/null& " % (self.tester_itf_0, self.mac0), "#= ") > + p =3D Packet() > + pkt =3D 'Ether(dst=3D"%s", src=3D"02:00:00:00:00:01")/IP()/UDP()= /("X"*22)' % > self.mac1 > + p.append_pkt(pkt) > + p.send_pkt(self.tester, tx_port=3Dself.tester_itf_1, count=3D10,= timeout=3D3) > + # get tcpdump package > + self.tester.send_expect("killall tcpdump", "#") > + out =3D self.tester.send_expect("tcpdump -nn -e -v - > r ./tcpdump_test.cap", "#", 120) > + self.verify("length 96" in out and "0x88e5" in out, "the > + EtherType isn't 0x88E5, and the packet length isn't 96bytes") > + > + def test_perf_Tx_linerate(self): > + """ > + performance test > + """ > + self.table_header =3D ['Frame Size', 'Mpps', '% linerate'] > + self.result_table_create(self.table_header) > + txPort =3D self.tester.get_local_port(self.dut_ports[1]) > + rxPort =3D self.tester.get_local_port(self.dut_ports[0]) > + self.start_testpmd_perf() > + # prepare traffic generator input > + flow =3D 'Ether(dst=3D"%s", src=3D"02:00:00:00:00:01")/IP()/UDP(= )/("X"*22)' % > self.mac1 > + pcap =3D os.sep.join([self.output_path, "test.pcap"]) > + self.tester.scapy_append('wrpcap("%s", [%s])' % (pcap, flow)) > + self.tester.scapy_execute() > + tgenInput =3D [] > + pcap =3D os.sep.join([self.output_path, "test.pcap"]) > + tgenInput.append((txPort, rxPort, pcap)) > + > + # clear streams before add new streams > + self.tester.pktgen.clear_streams() > + # run packet generator > + streams =3D self.pktgen_helper.prepare_stream_from_tginput(tgenI= nput, > 100, None, self.tester.pktgen) > + _, pps =3D self.tester.pktgen.measure_throughput(stream_ids=3Dst= reams) > + self.verify(pps > 0, "No traffic detected") > + pps /=3D 1000000.0 > + rate =3D (pps * 100) / self.wirespeed(self.nic, 96, 1) > + self.result_table_add([96, pps, rate]) > + self.result_table_print() > + self.verify(rate >=3D 96, "performance test failed") > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.session_sec.send_expect("quit", "#") > + self.dut.send_expect("quit", "#") > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + self.dut.kill_all() > + self.dut.close_session(self.session_sec) > -- > 2.17.2