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 E361CA04DD; Thu, 2 Jan 2020 04:29:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DA5B21BF9B; Thu, 2 Jan 2020 04:29:20 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 0D0BB1BF9B for ; Thu, 2 Jan 2020 04:29:18 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jan 2020 19:29:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,385,1571727600"; d="scan'208";a="419618089" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga005.fm.intel.com with ESMTP; 01 Jan 2020 19:29:18 -0800 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 1 Jan 2020 19:29:18 -0800 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 1 Jan 2020 19:29:17 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.197]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.89]) with mapi id 14.03.0439.000; Thu, 2 Jan 2020 11:29:16 +0800 From: "Chen, Zhaoyan" To: "Mo, YufengX" , "dts@dpdk.org" , "Wang, Yinan" , "Ma, LihongX" CC: "Mo, YufengX" , "Chen, Zhaoyan" Thread-Topic: [dts] [PATCH V3 5/5] framework/pktgen_trex: add new features Thread-Index: AQHVppO+eqK7hcZ8b0+sVU+SXOyzCafW7HLA Date: Thu, 2 Jan 2020 03:29:15 +0000 Message-ID: <9DEEADBC57E43F4DA73B571777FECECA41E76D1D@SHSMSX104.ccr.corp.intel.com> References: <20191129090315.60124-1-yufengx.mo@intel.com> <20191129090315.60124-6-yufengx.mo@intel.com> In-Reply-To: <20191129090315.60124-6-yufengx.mo@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 V3 5/5] framework/pktgen_trex: add new features 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" Acked-by: Zhaoyan Chen Regards, Zhaoyan Chen > -----Original Message----- > From: dts On Behalf Of yufengmx > Sent: Friday, November 29, 2019 5:03 PM > To: dts@dpdk.org; Wang, Yinan ; Ma, LihongX > > Cc: Mo, YufengX > Subject: [dts] [PATCH V3 5/5] framework/pktgen_trex: add new features >=20 >=20 > *. remove duration option in trex module, move duration option in > testing scenario methods(latency/loss/throughput) in pktgen_base modul= e. > *. remove sample_delay option in trex module. > *. remove runtim_stat in trex module. >=20 > Signed-off-by: yufengmx > --- > framework/pktgen_trex.py | 63 ++++++++++++++-------------------------- > 1 file changed, 22 insertions(+), 41 deletions(-) >=20 > 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 =3D [] > self._traffic_ports =3D [] > self._rx_ports =3D [] > - self.runtime_stats =3D {} >=20 > conf_inst =3D self._get_generator_conf_instance() > self.conf =3D conf_inst.load_pktgen_config() @@ -450,6 +449,23 @= @ class > TrexPacketGenerator(PacketGenerator): > from trex_stl_lib.api import STLClient > # set trex class > self.STLClient =3D 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 =3D self.conf.get("core_mask") > + if _core_mask: > + if '0x' in _core_mask: > + self.core_mask =3D \ > + [int(item[2:], 16) for item in _core_mask.split(',')= ] > + else: > + self.core_mask =3D self.STLClient.CORE_MASK_PIN \ > + if _core_mask.upper() =3D=3D 'CORE_MASK_PIN' else \ > + None > + else: > + self.core_mask =3D None >=20 > def _connect(self): > self._conn =3D self.STLClient(server=3Dself.conf["server"]) > @@ -652,7 +668,7 @@ class TrexPacketGenerator(PacketGenerator): > def _throughput_stats(self, stream, stats): > # tx packet > tx_port_id =3D stream["tx_port"] > - port_stats =3D self.runtime_stats.get(tx_port_id) > + port_stats =3D stats.get(tx_port_id) > if not port_stats: > msg =3D "failed to get tx_port {0} statistics".format(tx_por= t_id) > raise Exception(msg) > @@ -666,7 +682,7 @@ class TrexPacketGenerator(PacketGenerator): > self.logger.debug(os.linesep.join(msg)) > # rx bps/pps > rx_port_id =3D stream["rx_port"] > - port_stats =3D self.runtime_stats.get(rx_port_id) > + port_stats =3D stats.get(rx_port_id) > if not port_stats: > msg =3D "failed to get rx_port {0} statistics".format(rx_por= t_id) > raise Exception(msg) > @@ -768,65 +784,30 @@ class TrexPacketGenerator(PacketGenerator): > self._preset_trex_port() >=20 > def _start_transmission(self, stream_ids, options=3D{}): > - ''' > - :param sample_delay: > - After traffic start ``sample_delay`` seconds, start get runtime = statistics > - ''' > + test_mode =3D options.get('method') > # get rate percentage > rate_percent =3D "{0}%".format(options.get('rate') or > self._traffic_opt.get('rate') or > '100') > - # get duration > - duration =3D options.get("duration") or 20 > - duration =3D int(duration) if isinstance(duration, (str, unicode= )) \ > - else duration > - # get sample interval > - _sample_delay =3D options.get("sample_delay") or duration/2 > - sample_delay =3D int(_sample_delay) \ > - if isinstance(_sample_delay, (str, unicode))= \ > - else _sample_delay > - # get configuration from pktgen config file > - warmup =3D int(self.conf["warmup"]) if self.conf.has_key("warmup= ") \ > - else 25 > - # set trex coremask > - wait_interval, core_mask =3D ( > - 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 =3D { > '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 =3D self._conn.get_stats() > - self.logger.debug(pformat(self.runtime_stats)) > - ########################################### > - # Block until traffic on specified port(s) has ended > - wait_opt =3D {'ports': self._traffic_ports} > - if duration: > - time.sleep(wait_interval + 10) > - wait_opt['timeout'] =3D wait_interval + duration > - self._conn.wait_on_traffic(**wait_opt) > except Exception as e: > self.logger.error(e) >=20 > def _stop_transmission(self, stream_id): > if self._traffic_ports: > self._conn.stop(ports=3Dself._traffic_ports, rx_delay_ms=3D5= 000) > + self.logger.info("traffic completed. ") >=20 > def _retrieve_port_statistic(self, stream_id, mode): > ''' > -- > 2.21.0