From: lihong <lihongx.ma@intel.com>
To: dts@dpdk.org
Cc: lihong <lihongx.ma@intel.com>
Subject: [dts] [PATCH V2] tests/vf_port_start_stop: use scapy instead of pktgen send pkts
Date: Tue, 24 Sep 2019 07:32:57 +0800 [thread overview]
Message-ID: <1569281577-24766-1-git-send-email-lihongx.ma@intel.com> (raw)
Signed-off-by: lihong <lihongx.ma@intel.com>
---
tests/TestSuite_vf_port_start_stop.py | 99 +++++++++--------------------------
1 file changed, 25 insertions(+), 74 deletions(-)
diff --git a/tests/TestSuite_vf_port_start_stop.py b/tests/TestSuite_vf_port_start_stop.py
index 2ff2d1c..7be5116 100644
--- a/tests/TestSuite_vf_port_start_stop.py
+++ b/tests/TestSuite_vf_port_start_stop.py
@@ -9,7 +9,6 @@ from pmd_output import PmdOutput
from utils import RED, GREEN
from net_device import NetDevice
from crb import Crb
-from scapy.all import *
VM_CORES_MASK = 'all'
class TestVfPortStartStop(TestCase):
@@ -22,6 +21,8 @@ class TestVfPortStartStop(TestCase):
self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
self.vm0 = None
self.filename = "/tmp/vf.pcap"
+ self.tester_tx_port = self.tester.get_local_port(self.dut_ports[0])
+ self.tester_tintf = self.tester.get_interface(self.tester_tx_port)
# set vf assign method and vf driver
self.vf_driver = self.get_suite_cfg()['vf_driver']
@@ -37,86 +38,39 @@ class TestVfPortStartStop(TestCase):
def set_up(self):
self.setup_1pf_2vf_1vm_env_flag = 0
-
- def pktgen_prerequisites(self):
- """
- igb_uio.ko should be put in ~ before you using pktgen
- """
- out = self.tester.send_expect("ls", "#")
- self.verify("igb_uio.ko" in out, "No file igb_uio.ko, please add it in ~")
- self.tester.send_expect("modprobe uio", "#", 70)
- out = self.tester.send_expect("lsmod | grep igb_uio", "#")
- if "igb_uio" in out:
- self.tester.send_expect("rmmod -f igb_uio", "#", 70)
- self.tester.send_expect("insmod ~/igb_uio.ko", "#", 60)
- out = self.tester.send_expect("lsmod | grep igb_uio", "#")
- assert ("igb_uio" in out), "Failed to insmod igb_uio"
-
- total_huge_pages = self.tester.get_total_huge_pages()
- if total_huge_pages == 0:
- self.tester.mount_huge_pages()
- self.tester.set_huge_pages(2048)
-
- def pktgen_kill(self):
- """
- Kill all pktgen on tester.
- """
- pids = []
- pid_reg = r'p(\d+)'
- out = self.tester.alt_session.send_expect("lsof -Fp /var/run/.pg_config", "#", 20)
- if len(out):
- lines = out.split('\r\n')
- for line in lines:
- m = re.match(pid_reg, line)
- if m:
- pids.append(m.group(1))
- for pid in pids:
- self.tester.alt_session.send_expect('kill -9 %s' % pid, '# ', 20)
+ self.send_pks_session = None
def send_and_verify(self, dst_mac, testpmd):
"""
- Generates packets by pktgen
+ Generates packets and verify
"""
self.testpmd_reset_status(testpmd)
- self.pktgen_prerequisites()
- # bind ports
- self.tester_tx_port = self.tester.get_local_port(self.dut_ports[0])
- self.tester_tx_pci = self.tester.ports_info[self.tester_tx_port]['pci']
- port = self.tester.ports_info[self.tester_tx_port]['port']
- self.tester_port_driver = port.get_nic_driver()
- self.tester.send_expect("./dpdk-devbind.py --force --bind=igb_uio %s" % self.tester_tx_pci, "#")
-
- src_mac = self.tester.get_mac(self.tester_tx_port)
+ src_mac = self.tester.get_mac(self.tester_tx_port)
if src_mac == 'N/A':
src_mac = "02:00:00:00:01"
-
- self.create_pcap_file(self.filename, dst_mac, src_mac)
-
- self.tester.send_expect("./pktgen -c 0x1f -n 2 --proc-type auto --socket-mem 128,128 --file-prefix pg -- -P -T -m '1.0' -s 0:%s" % self.filename, "Pktgen >", 100)
- time.sleep(1)
- self.tester.send_expect("start all", "Pktgen>")
+ self.send_pkts(self.filename, dst_mac, src_mac)
time.sleep(1)
self.check_port_start_stop(testpmd)
- # quit pktgen
- self.tester.send_expect("stop all", "Pktgen>")
- self.tester.send_expect("quit", "# ")
+ self.tester.send_expect('killall -s INT scapy', '# ')
+ self.tester.destroy_session(self.send_pks_session)
+ self.send_pks_session = None
- def create_pcap_file(self, filename, dst_mac, src_mac):
+ def send_pkts(self, filename, dst_mac, src_mac):
"""
Generates a valid PCAP file with the given configuration.
"""
- def_pkts = {'IP/UDP': Ether(dst="%s" % dst_mac, src="%s" % src_mac)/IP(src="127.0.0.2")/UDP()/("X"*46),
- 'IP/TCP': Ether(dst="%s" % dst_mac, src="%s" % src_mac)/IP(src="127.0.0.2")/TCP()/("X"*46),
- 'IP/SCTP': Ether(dst="%s" % dst_mac, src="%s" % src_mac)/IP(src="127.0.0.2")/SCTP()/("X"*48),
- 'IPv6/UDP': Ether(dst="%s" % dst_mac, src="%s" % src_mac)/IPv6(src="::2")/UDP()/("X"*46),
- 'IPv6/TCP': Ether(dst="%s" % dst_mac, src="%s" % src_mac)/IPv6(src="::2")/TCP()/("X"*46),}
-
- pkts = []
- for key in def_pkts.keys():
- pkts.append(def_pkts[key])
-
- wrpcap(filename, pkts)
+ sendp_fmt = "sendp(pk, iface='%s', loop=1)" % (self.tester_tintf)
+ self.send_pks_session = self.tester.create_session("scapy1")
+ self.send_pks_session.send_expect("scapy", ">>>")
+ self.send_pks_session.send_expect("from scapy.layers.sctp import SCTP, SCTPChunkData", ">>>")
+ self.send_pks_session.send_expect('pk1=[Ether(dst="%s", src="%s")/IP(src="127.0.0.2")/UDP()/("X"*46)]'%(dst_mac, src_mac), '>>>')
+ self.send_pks_session.send_expect('pk2=[Ether(dst="%s", src="%s")/IP(src="127.0.0.2")/TCP()/("X"*46)]'%(dst_mac, src_mac), '>>>')
+ self.send_pks_session.send_expect('pk3=[Ether(dst="%s", src="%s")/IP(src="127.0.0.2")/SCTP()/("X"*48)]'%(dst_mac, src_mac), '>>>')
+ self.send_pks_session.send_expect('pk4=[Ether(dst="%s", src="%s")/IPv6(src="::2")/UDP()/("X"*46)]'%(dst_mac, src_mac), '>>>')
+ self.send_pks_session.send_expect('pk5=[Ether(dst="%s", src="%s")/IPv6(src="::2")/TCP()/("X"*46)]'%(dst_mac, src_mac), '>>>')
+ self.send_pks_session.send_expect('pk = pk1+pk2+pk3+pk4+pk5', '>>>')
+ self.send_pks_session.send_command(sendp_fmt)
def testpmd_reset_status(self, testpmd):
"""
@@ -242,13 +196,10 @@ class TestVfPortStartStop(TestCase):
def tear_down_all(self):
- self.pktgen_kill()
- if getattr(self, 'tester_port_driver', None) and \
- getattr(self, 'tester_tx_pci', None):
- self.tester.send_expect("./dpdk-devbind.py --bind=%s %s" \
- %(self.tester_port_driver, self.tester_tx_pci), "#")
- tx_interface = self.tester.get_interface(self.tester_tx_port)
- self.tester.send_expect("ifconfig %s up" % tx_interface, "#")
+ if self.send_pks_session:
+ self.tester.send_expect('killall -s INT scapy', '# ')
+ self.tester.destroy_session(self.send_pks_session)
+ self.send_pks_session = None
if getattr(self, 'vm0', None):
self.vm0.stop()
--
2.7.4
next reply other threads:[~2019-09-24 6:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-23 23:32 lihong [this message]
2019-09-24 6:59 ` Zhang, YanX A
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=1569281577-24766-1-git-send-email-lihongx.ma@intel.com \
--to=lihongx.ma@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).