new file mode 100644
@@ -0,0 +1,151 @@
+# BSD LICENSE
+#
+# Copyright(c)2021 Intel Corporation. All rights reserved.
+# 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.
+
+from packet import Packet
+from pmd_output import PmdOutput
+from test_case import TestCase
+from smoke_base import SmokeTest
+from smoke_base import JUMBO_FRAME_LENGTH
+from smoke_base import JUMBO_FRAME_MTU
+from smoke_base import DEFAULT_MTU_VALUE
+from smoke_base import LAUNCH_QUEUE
+
+
+class TestPfSmoke(TestCase):
+
+ def set_up_all(self):
+ """
+ Run at the start of each test suite.
+
+
+ Smoke Prerequisites
+ """
+
+ # Based on h/w type, choose how many ports to use
+ self.smoke_dut_ports = self.dut.get_ports(self.nic)
+
+ # Verify that enough ports are available
+ self.verify(len(self.smoke_dut_ports) >= 1, "Insufficient ports")
+ self.smoke_tester_port = self.tester.get_local_port(self.smoke_dut_ports[0])
+ self.smoke_tester_nic = self.tester.get_interface(self.smoke_tester_port)
+ self.smoke_tester_mac = self.tester.get_mac(self.smoke_dut_ports[0])
+ self.smoke_dut_mac = self.dut.get_mac_address(self.smoke_dut_ports[0])
+
+ # Verify that enough core
+ self.cores = self.dut.get_core_list("1S/4C/1T")
+ self.verify(self.cores is not None, "Insufficient cores for speed testing")
+
+ # init pkt
+ self.pkt = Packet()
+
+ # set default app parameter
+ self.pmd_out = PmdOutput(self.dut)
+ self.ports = [self.dut.ports_info[self.smoke_dut_ports[0]]['pci']]
+ self.param = '--max-pkt-len={} --tx-offloads=0x8000 --rxq={} --txq={}'.format(JUMBO_FRAME_LENGTH,
+ LAUNCH_QUEUE,
+ LAUNCH_QUEUE)
+ self.test_func = SmokeTest(self)
+ self.check_session = self.dut.new_session(suite="pf_smoke_test")
+
+ def set_up(self):
+ """
+ Run before each test case.
+ """
+ # verify app launch state.
+ out = self.check_session.send_expect("ls -l /var/run/dpdk |awk '/^d/ {print $NF}'", '# ', 1)
+ if out == '' or 'No such file or directory' in out:
+ self.pf_launch_dpdk_app()
+
+ # set tester mtu
+ if self._suite_result.test_case == "test_pf_jumbo_frames":
+ self.tester.send_expect("ifconfig {} mtu {}".format(self.smoke_tester_nic, JUMBO_FRAME_MTU), '# ')
+
+ def pf_launch_dpdk_app(self):
+ self.pmd_out.start_testpmd(cores=self.cores, ports=self.ports, param=self.param)
+
+ # set default param
+ self.dut.send_expect("set promisc all off", "testpmd> ")
+ self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0])
+
+ def test_pf_jumbo_frames(self):
+ """
+ This case aims to test transmitting jumbo frame packet on testpmd with
+ jumbo frame support.
+ """
+ self.dut.send_expect("set fwd mac", "testpmd> ")
+ self.dut.send_expect("set verbose 3", "testpmd> ")
+ self.dut.send_expect("start", "testpmd> ")
+ self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0])
+ result = self.test_func.check_jumbo_frames()
+ self.verify(result, "enable disable jumbo frames failed")
+
+ def test_pf_rss(self):
+ """
+ Check default rss function.
+ """
+ self.dut.send_expect("set fwd rxonly", "testpmd> ")
+ self.dut.send_expect("set verbose 1", "testpmd> ")
+ self.dut.send_expect("start", "testpmd> ")
+ self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0])
+ result = self.test_func.check_rss()
+ self.verify(result, "enable disable rss failed")
+
+ def test_pf_tx_rx_queue(self):
+ """
+ Check dpdk queue configure.
+ """
+ self.dut.send_expect("set verbose 1", "testpmd> ")
+ self.dut.send_expect("set fwd rxonly", "testpmd> ")
+ self.dut.send_expect("start", "testpmd> ")
+ self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0])
+ result = self.test_func.check_tx_rx_queue()
+ self.verify(result, "check tx rx queue failed")
+
+ def tear_down(self):
+ self.pmd_out.execute_cmd("stop")
+
+ # set tester mtu to default value
+ if self._suite_result.test_case == "test_pf_jumbo_frames":
+ self.tester.send_expect("ifconfig {} mtu {}".format(self.smoke_tester_nic, DEFAULT_MTU_VALUE), '# ')
+
+ # set dpdk queues to launch value
+ if self._suite_result.test_case == "test_pf_tx_rx_queue":
+ self.dut.send_expect("stop", "testpmd> ")
+ self.dut.send_expect("port stop all", "testpmd> ")
+ self.dut.send_expect("port config all rxq {}".format(LAUNCH_QUEUE), "testpmd> ")
+ self.dut.send_expect("port config all txq {}".format(LAUNCH_QUEUE), "testpmd> ")
+ self.dut.send_expect("port start all", "testpmd> ")
+
+ def tear_down_all(self):
+ if self.check_session:
+ self.dut.close_session(self.check_session)
+ self.check_session = None
+ self.dut.kill_all()
new file mode 100644
@@ -0,0 +1,171 @@
+# BSD LICENSE
+#
+# Copyright(c)2021 Intel Corporation. All rights reserved.
+# 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.
+
+from packet import Packet
+from pmd_output import PmdOutput
+from test_case import TestCase
+from smoke_base import SmokeTest
+from smoke_base import JUMBO_FRAME_LENGTH
+from smoke_base import JUMBO_FRAME_MTU
+from smoke_base import DEFAULT_MTU_VALUE
+from smoke_base import LAUNCH_QUEUE
+
+VF_MAC_ADDR = '00:11:22:33:44:55'
+
+
+class TestVfSmoke(TestCase):
+
+ def set_up_all(self):
+ """
+ Run at the start of each test suite.
+
+
+ Smoke Prerequisites
+ """
+
+ # Based on h/w type, choose how many ports to use
+ self.smoke_dut_ports = self.dut.get_ports(self.nic)
+ self.check_session = None
+
+ # Verify that enough ports are available
+ self.verify(len(self.smoke_dut_ports) >= 1, "Insufficient ports")
+ self.pf_interface = self.dut.ports_info[self.smoke_dut_ports[0]]['intf']
+ self.smoke_tester_port = self.tester.get_local_port(self.smoke_dut_ports[0])
+ self.smoke_tester_nic = self.tester.get_interface(self.smoke_tester_port)
+ self.smoke_tester_mac = self.tester.get_mac(self.smoke_dut_ports[0])
+ self.smoke_dut_mac = VF_MAC_ADDR
+
+ # Verify that enough core
+ self.cores = self.dut.get_core_list("1S/4C/1T")
+ self.verify(self.cores is not None, "Insufficient cores for speed testing")
+
+ # init pkt
+ self.pkt = Packet()
+
+ # generate vf
+ self.dut.bind_interfaces_linux(self.kdriver)
+ self.dut.generate_sriov_vfs_by_port(self.smoke_dut_ports[0], 1, self.kdriver)
+ self.vf_ports = self.dut.ports_info[self.smoke_dut_ports[0]]['vfs_port']
+ self.verify(len(self.vf_ports) != 0, "VF create failed")
+ for port in self.vf_ports:
+ port.bind_driver(self.drivername)
+ self.vf0_prop = {'opt_host': self.vf_ports[0].pci}
+ self.dut.send_expect("ifconfig %s up" % self.pf_interface, "# ")
+ self.tester.send_expect("ifconfig %s up" % self.smoke_tester_nic, "# ")
+
+ # set vf mac address
+ self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.pf_interface, self.smoke_dut_mac), "# ")
+
+ # set default app parameter
+ if self.vf0_prop is not None:
+ self.ports = [self.vf0_prop['opt_host']]
+
+ self.pmd_out = PmdOutput(self.dut)
+ self.param = '--max-pkt-len={} --tx-offloads=0x8000 --rxq={} --txq={}'.format(JUMBO_FRAME_LENGTH,
+ LAUNCH_QUEUE,
+ LAUNCH_QUEUE)
+ self.test_func = SmokeTest(self)
+ self.check_session = self.dut.new_session(suite="vf_smoke_test")
+
+ def set_up(self):
+ """
+ Run before each test case.
+ """
+ # verify app launch state.
+ out = self.check_session.send_expect("ls -l /var/run/dpdk |awk '/^d/ {print $NF}'", '# ', 1)
+ if out == '' or 'No such file or directory' in out:
+ self.vf_launch_dpdk_app()
+
+ if self._suite_result.test_case == "test_vf_jumbo_frames":
+ self.tester.send_expect("ifconfig {} mtu {}".format(self.smoke_tester_nic, JUMBO_FRAME_MTU), '# ')
+
+ def vf_launch_dpdk_app(self):
+ self.pmd_out.start_testpmd(cores=self.cores, ports=self.ports, param=self.param)
+
+ # set default param
+ self.dut.send_expect("set promisc all off", "testpmd> ")
+ self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0])
+
+ def test_vf_jumbo_frames(self):
+ """
+ This case aims to test transmitting jumbo frame packet on testpmd with
+ jumbo frame support.
+ """
+ self.dut.send_expect("set verbose 3", "testpmd> ")
+ self.dut.send_expect("set fwd mac", "testpmd> ")
+ self.dut.send_expect("start", "testpmd> ")
+ self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0])
+ result = self.test_func.check_jumbo_frames()
+ self.verify(result, "enable disable jumbo frames failed")
+
+ def test_vf_rss(self):
+ """
+ Check default rss function.
+ """
+ self.dut.send_expect("set verbose 1", "testpmd> ")
+ self.dut.send_expect("set fwd rxonly", "testpmd> ")
+ self.dut.send_expect("start", "testpmd> ")
+ self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0])
+ result = self.test_func.check_rss()
+ self.verify(result, "enable disable rss failed")
+
+ def test_vf_tx_rx_queue(self):
+ """
+ Check dpdk queue configure.
+ """
+ self.dut.send_expect("set fwd rxonly", "testpmd> ")
+ self.dut.send_expect("set verbose 1", "testpmd> ")
+ self.dut.send_expect("start", "testpmd> ")
+ self.pmd_out.wait_link_status_up(self.smoke_dut_ports[0])
+ result = self.test_func.check_tx_rx_queue()
+ self.verify(result, "check tx rx queue failed")
+
+ def tear_down(self):
+ # set tester mtu to default value
+ self.pmd_out.execute_cmd("stop")
+ if self._suite_result.test_case == "test_vf_jumbo_frames":
+ self.tester.send_expect("ifconfig {} mtu {}".format(self.smoke_tester_nic, DEFAULT_PKG_LEN), '# ')
+
+ # set dpdk queues to launch value
+ if self._suite_result.test_case == "test_vf_tx_rx_queue":
+ self.dut.send_expect("port stop all", "testpmd> ")
+ self.dut.send_expect("port config all rxq {}".format(LAUNCH_QUEUE), "testpmd> ")
+ self.dut.send_expect("port config all txq {}".format(LAUNCH_QUEUE), "testpmd> ")
+ self.dut.send_expect("port start all", "testpmd> ")
+
+ def tear_down_all(self):
+ if self.check_session:
+ self.dut.close_session(self.check_session)
+ self.check_session = None
+ self.dut.kill_all()
+ if self.vf0_prop:
+ self.dut.destroy_sriov_vfs_by_port(self.smoke_dut_ports[0])
+ self.dut.bind_interfaces_linux(self.drivername)
new file mode 100644
@@ -0,0 +1,177 @@
+# BSD LICENSE
+#
+# Copyright(c)2021 Intel Corporation. All rights reserved.
+# 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
+from settings import HEADER_SIZE
+
+JUMBO_FRAME_MTU = 9600
+DEFAULT_MTU_VALUE = 1500
+COMMON_PKT_LEN = 64
+JUMBO_FRAME_LENGTH = 9000
+IPV4_SRC = '192.168.0.11'
+IPV4_DST = '192.168.0.12'
+LAUNCH_QUEUE = 4
+PACKAGE_COUNT = 32
+
+
+class SmokeTest(object):
+ def __init__(self, test_case, **kwargs):
+ self.test_case = test_case
+ for name in kwargs:
+ setattr(self, name, kwargs[name])
+
+ def send_pkg_return_stats(self, pkt_size=COMMON_PKT_LEN, l3_src=IPV4_SRC, l3_dst=IPV4_DST, rss=False):
+ self.test_case.dut.send_expect("clear port stats all", "testpmd> ")
+ l3_len = pkt_size - HEADER_SIZE['eth']
+ payload = pkt_size - HEADER_SIZE['eth'] - HEADER_SIZE['ip']
+ hash_flag = False
+ if rss:
+ pkt = []
+ # generate PACKAGE_COUNT count package, the IP dst is random.
+ for i in range(0, PACKAGE_COUNT):
+ p = "Ether(dst='{}',src='{}')/IP(src='{}',dst=RandIP(),len={})/Raw(load='X'*{})".format(
+ self.test_case.smoke_dut_mac,
+ self.test_case.smoke_tester_mac,
+ l3_src,
+ l3_len,
+ payload)
+ pkt.append(p)
+ else:
+ pkt = ["Ether(dst='{}',src='{}')/IP(src='{}',dst='{}',len={})/Raw(load='X'*{})".format(
+ self.test_case.smoke_dut_mac,
+ self.test_case.smoke_tester_mac,
+ l3_src,
+ l3_dst,
+ l3_len,
+ payload)]
+
+ self.test_case.pkt.update_pkt(pkt)
+
+ # wait package update
+ time.sleep(1)
+ self.test_case.pkt.send_pkt(crb=self.test_case.tester, tx_port=self.test_case.smoke_tester_nic)
+ time.sleep(.5)
+ out = self.test_case.pmd_out.get_output(timeout=1)
+ queue_pattern = re.compile(r'Receive\squeue=(\w+)')
+ # collect all queues
+ queues = queue_pattern.findall(out)
+ # get dpdk statistical information
+ stats = self.test_case.pmd_out.get_pmd_stats(self.test_case.smoke_dut_ports[0])
+ if 'PKT_RX_RSS_HASH' in out:
+ hash_flag = True
+
+ if rss:
+ rss_pattern = re.compile(r'-\sRSS\shash=(\w+)')
+ # collect all hash value
+ rss_hash = rss_pattern.findall(out)
+ if 0 != len(rss_hash):
+ return hash_flag, queues, rss_hash
+ else:
+ if 0 != len(queues):
+ return hash_flag, queues, None
+ else:
+ return hash_flag, None, None
+ if 0 != len(queues):
+ return queues[0], stats
+ return None, stats
+
+ def check_jumbo_frames(self):
+ """
+ The packet total size include ethernet header, ip header, and payload.
+ ethernet header length is 18 bytes, ip standard header length is 20 bytes.
+ The packet forwarded failed.
+ """
+ pkg_size = JUMBO_FRAME_LENGTH + 1
+ queues, stats = self.send_pkg_return_stats(pkg_size)
+ if 1 != stats['RX-errors'] and 0 != stats['TX-packets']:
+ self.test_case.logger.info("jumbo frame: The RX[{}] or TX[{}] packet error".format(stats['RX-errors'],
+ stats['TX-packets']))
+ return False
+
+ # The packet can be forwarded successfully.
+ pkg_size = JUMBO_FRAME_LENGTH
+ queues, stats = self.send_pkg_return_stats(pkg_size)
+ if 1 != stats['TX-packets']:
+ self.test_case.logger.info("jumbo frame: The TX[{}] packet error".format(stats['TX-packets']))
+ return False
+
+ return True
+
+ def check_rss(self):
+ """
+ Test the basic functions of RSS, every queue can receive packets.
+ """
+ hash_flag, queues, hash_values = self.send_pkg_return_stats(rss=True)
+ if queues is None or hash_values is None:
+ return False
+ queues = list(set(queues))
+ hash_values = list(set(hash_values))
+
+ # verify that each queue has packets, verify hash value are not equal, and hash flag exists.
+ if LAUNCH_QUEUE != len(queues) or 1 == hash_values or hash_flag is False:
+ self.test_case.logger.info("rss the hash flag [{}] [{}] error".format(queues, hash_values))
+ return False
+
+ return True
+
+ def check_tx_rx_queue(self):
+ """
+ Test configuration queue function can work.
+ """
+ # verify default configure can work
+ queues, stats = self.send_pkg_return_stats()
+ if queues is None:
+ self.test_case.logger.info("txq rxq the queues[{}] error".format(queues))
+ return False
+
+ self.test_case.dut.send_expect("stop", "testpmd> ")
+ self.test_case.dut.send_expect("port stop all", "testpmd> ")
+ self.test_case.dut.send_expect("port config all rxq 1", "testpmd> ")
+ self.test_case.dut.send_expect("port config all txq 1", "testpmd> ")
+ out = self.test_case.dut.send_expect("show config rxtx", "testpmd> ")
+ if 'RX queue number: 1' not in out:
+ self.test_case.logger.info("RX queue number 1 no display")
+ return False
+ if 'Tx queue number: 1' not in out:
+ self.test_case.logger.info("Tx queue number 1 no display")
+ return False
+
+ self.test_case.dut.send_expect("port start all", "testpmd> ")
+ self.test_case.dut.send_expect("start", "testpmd> ")
+ self.test_case.pmd_out.wait_link_status_up(self.test_case.smoke_dut_ports[0])
+ queue_after, stats = self.send_pkg_return_stats()
+
+ if queue_after is None:
+ self.test_case.logger.info("after txq rxq the queue [{}] error".format(queue_after))
+ return False
+
+ return True