test suite reviews and discussions
 help / color / mirror / Atom feed
From: yufengmx <yufengx.mo@intel.com>
To: dts@dpdk.org, yinan.wang@intel.com, lihongx.ma@intel.com
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V3 5/5] framework/pktgen_trex: add new features
Date: Fri, 29 Nov 2019 17:03:15 +0800	[thread overview]
Message-ID: <20191129090315.60124-6-yufengx.mo@intel.com> (raw)
In-Reply-To: <20191129090315.60124-1-yufengx.mo@intel.com>


*. remove duration option in trex module, move duration option in
   testing scenario methods(latency/loss/throughput) in pktgen_base module.
*. remove sample_delay option in trex module.
*. remove runtim_stat in trex module.

Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
 framework/pktgen_trex.py | 63 ++++++++++++++--------------------------
 1 file changed, 22 insertions(+), 41 deletions(-)

diff --git a/framework/pktgen_trex.py b/framework/pktgen_trex.py
index 690d070..6a1b36a 100644
--- a/framework/pktgen_trex.py
+++ b/framework/pktgen_trex.py
@@ -411,7 +411,6 @@ class TrexPacketGenerator(PacketGenerator):
         self._ports = []
         self._traffic_ports = []
         self._rx_ports = []
-        self.runtime_stats = {}
 
         conf_inst = self._get_generator_conf_instance()
         self.conf = conf_inst.load_pktgen_config()
@@ -450,6 +449,23 @@ class TrexPacketGenerator(PacketGenerator):
         from trex_stl_lib.api import STLClient
         # set trex class
         self.STLClient = STLClient
+        # get configuration from pktgen config file
+        self._get_traffic_option()
+
+    def _get_traffic_option(self):
+        ''' get configuration from pktgen config file '''
+        # set trex coremask
+        _core_mask = self.conf.get("core_mask")
+        if _core_mask:
+            if '0x' in _core_mask:
+                self.core_mask = \
+                    [int(item[2:], 16) for item in _core_mask.split(',')]
+            else:
+                self.core_mask = self.STLClient.CORE_MASK_PIN \
+                    if _core_mask.upper() == 'CORE_MASK_PIN' else \
+                    None
+        else:
+            self.core_mask = None
 
     def _connect(self):
         self._conn = self.STLClient(server=self.conf["server"])
@@ -652,7 +668,7 @@ class TrexPacketGenerator(PacketGenerator):
     def _throughput_stats(self, stream, stats):
         # tx packet
         tx_port_id = stream["tx_port"]
-        port_stats = self.runtime_stats.get(tx_port_id)
+        port_stats = stats.get(tx_port_id)
         if not port_stats:
             msg = "failed to get tx_port {0} statistics".format(tx_port_id)
             raise Exception(msg)
@@ -666,7 +682,7 @@ class TrexPacketGenerator(PacketGenerator):
         self.logger.debug(os.linesep.join(msg))
         # rx bps/pps
         rx_port_id = stream["rx_port"]
-        port_stats = self.runtime_stats.get(rx_port_id)
+        port_stats = stats.get(rx_port_id)
         if not port_stats:
             msg = "failed to get rx_port {0} statistics".format(rx_port_id)
             raise Exception(msg)
@@ -768,65 +784,30 @@ class TrexPacketGenerator(PacketGenerator):
         self._preset_trex_port()
 
     def _start_transmission(self, stream_ids, options={}):
-        '''
-        :param sample_delay:
-        After traffic start ``sample_delay`` seconds, start get runtime statistics
-        '''
+        test_mode = options.get('method')
         # get rate percentage
         rate_percent = "{0}%".format(options.get('rate') or
                                      self._traffic_opt.get('rate') or
                                      '100')
-        # get duration
-        duration = options.get("duration") or 20
-        duration = int(duration) if isinstance(duration, (str, unicode)) \
-                                      else duration
-        # get sample interval
-        _sample_delay = options.get("sample_delay") or duration/2
-        sample_delay = int(_sample_delay) \
-                            if isinstance(_sample_delay, (str, unicode)) \
-                            else _sample_delay
-        # get configuration from pktgen config file
-        warmup = int(self.conf["warmup"]) if self.conf.has_key("warmup") \
-                                          else 25
-        # set trex coremask
-        wait_interval, core_mask = (
-                        warmup+30, int(self.conf["core_mask"], 16)) \
-                            if self.conf.has_key("core_mask") \
-                            else (warmup+5, 0x3)
-
         try:
-            ###########################################
             # clear the stats before injecting
             self._conn.clear_stats()
             # Start traffic on port(s)
             run_opt = {
                 'ports':    self._traffic_ports,
                 'mult':     rate_percent,
-                'duration': duration,
-                'core_mask':core_mask,
+                'core_mask': self.core_mask,
                 'force':    True,}
             self.logger.info("begin traffic ......")
             self.logger.debug(run_opt)
             self._conn.start(**run_opt)
-            ###########################################
-            if sample_delay:
-                time.sleep(sample_delay) # wait
-                # get ports runtime statistics
-                self.runtime_stats = self._conn.get_stats()
-                self.logger.debug(pformat(self.runtime_stats))
-            ###########################################
-            # Block until traffic on specified port(s) has ended
-            wait_opt = {'ports':  self._traffic_ports}
-            if duration:
-                time.sleep(wait_interval + 10)
-                wait_opt['timeout'] = wait_interval + duration
-            self._conn.wait_on_traffic(**wait_opt)
         except Exception as e:
             self.logger.error(e)
 
     def _stop_transmission(self, stream_id):
         if self._traffic_ports:
             self._conn.stop(ports=self._traffic_ports, rx_delay_ms=5000)
+            self.logger.info("traffic completed. ")
 
     def _retrieve_port_statistic(self, stream_id, mode):
         '''
-- 
2.21.0


  parent reply	other threads:[~2019-11-29  9:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-29  9:03 [dts] [PATCH V3 0/5] dts/pktgen: " yufengmx
2019-11-29  9:03 ` [dts] [PATCH V3 1/5] conf/pktgen: remove un-used optons yufengmx
2020-01-02  3:29   ` Chen, Zhaoyan
2019-11-29  9:03 ` [dts] [PATCH V3 2/5] doc/dts_gsg/pktgen_prog_guide: update description yufengmx
2020-01-02  3:29   ` Chen, Zhaoyan
2019-11-29  9:03 ` [dts] [PATCH V3 3/5] framework/pktgen_base: add new features yufengmx
2020-01-02  3:29   ` Chen, Zhaoyan
2019-11-29  9:03 ` [dts] [PATCH V3 4/5] framework/pktgen_ixia: " yufengmx
2019-11-29  9:03 ` yufengmx [this message]
2020-01-02  3:29   ` [dts] [PATCH V3 5/5] framework/pktgen_trex: " Chen, Zhaoyan
2020-01-02  3:28 ` [dts] [PATCH V3 0/5] dts/pktgen: " Chen, Zhaoyan
2020-01-02  5:04 ` Tu, Lijuan

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=20191129090315.60124-6-yufengx.mo@intel.com \
    --to=yufengx.mo@intel.com \
    --cc=dts@dpdk.org \
    --cc=lihongx.ma@intel.com \
    --cc=yinan.wang@intel.com \
    /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).