test suite reviews and discussions
 help / color / mirror / Atom feed
From: yufengmx <yufengx.mo@intel.com>
To: dts@dpdk.org
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V1 2/2] [next]framework/pktgen_trex: convert core mask setting to
Date: Tue,  6 Aug 2019 10:42:32 +0800	[thread overview]
Message-ID: <1565059352-215395-3-git-send-email-yufengx.mo@intel.com> (raw)
In-Reply-To: <1565059352-215395-1-git-send-email-yufengx.mo@intel.com>

 list format

*. convert core mask setting to list format.
*. create _get_traffic_option to convert pktgen.cfg setting value to traffic start options.

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

diff --git a/framework/pktgen_trex.py b/framework/pktgen_trex.py
index 159750e..9044682 100644
--- a/framework/pktgen_trex.py
+++ b/framework/pktgen_trex.py
@@ -451,6 +451,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")
+        self.core_mask = \
+            [int(item[2:], 16) for item in _core_mask.split(',')] \
+            if _core_mask and '0x' in _core_mask else \
+            None
+        # In case of several ports, ensure their transmitting time is
+        # synchronized. 
+        _synchronized = self.conf.get("synchronized")
+        self.sync = True \
+                    if _synchronized and _synchronized.lower() == 'true' else \
+                    False
 
     def _connect(self):
         self._conn = self.STLClient(server=self.conf["server"])
@@ -792,10 +809,9 @@ class TrexPacketGenerator(PacketGenerator):
         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)
+        wait_interval = warmup+30 \
+                        if self.conf.has_key("core_mask") \
+                        else warmup+5
 
         try:
             ###########################################
@@ -806,7 +822,8 @@ class TrexPacketGenerator(PacketGenerator):
                 'ports':    self._traffic_ports,
                 'mult':     rate_percent,
                 'duration': duration,
-                'core_mask':core_mask,
+                'core_mask': self.core_mask,
+                'synchronized': self.sync,
                 'force':    True,}
             self.logger.info("begin traffic ......")
             self._conn.start(**run_opt)
-- 
1.9.3


  parent reply	other threads:[~2019-08-06  2:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06  2:42 [dts] [PATCH V1 0/2] [next]dts/pktgen: TREX core mask configuration yufengmx
2019-08-06  2:42 ` [dts] [PATCH V1 1/2] [next]conf/pktgen: update option description yufengmx
2019-08-06  2:42 ` yufengmx [this message]
2019-08-08  5:40 ` [dts] [PATCH V1 0/2] [next]dts/pktgen: TREX core mask configuration 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=1565059352-215395-3-git-send-email-yufengx.mo@intel.com \
    --to=yufengx.mo@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).