[dts] [PATCH for-next 5/6] framework/pktgen: Start T-Rex during prepare_generator()

Liu, Yong yong.liu at intel.com
Fri Mar 2 02:51:46 CET 2018


Hi Patrick,
In our deployment, multiple tester machine may be connected to one Packet Generation Machine. 
If we run multiple execution tasks on those machines at the same time, there will be mutual interference between the tasks.

My suggestion is that import additional configure option like Trex_setup. If this option is true, DTS will start/stop Trex.

Thanks,
Marvin

> -----Original Message-----
> From: dts [mailto:dts-bounces at dpdk.org] On Behalf Of Patrick MacArthur
> Sent: Wednesday, February 21, 2018 1:26 AM
> To: dts at dpdk.org
> Cc: pmacarth at iol.unh.edu; dpdklab at iol.unh.edu
> Subject: [dts] [PATCH for-next 5/6] framework/pktgen: Start T-Rex during
> prepare_generator()
> 
> The currently merged patchset for T-Rex does not actually start T-Rex.
> Add some code to start T-Rex as part of packet generator setup during
> the prepare_generator() step. We need T-Rex running during this step so
> we can determine which ports the T-Rex API is making available to the
> DUT before we set up the DUT's network interfaces accordingly.
> 
> This change assumes that T-Rex will always be run on the tester node.
> 
> Tested-by: Ali Alnubani <alialnu at mellanox.com>
> Signed-off-by: Patrick MacArthur <pmacarth at iol.unh.edu>
> ---
>  framework/pktgen.py | 30 +++++++++++++++++++++++-------
>  framework/tester.py |  1 +
>  2 files changed, 24 insertions(+), 7 deletions(-)
> 
> diff --git a/framework/pktgen.py b/framework/pktgen.py
> index 9e052c832da9..c7fc81ae58fc 100644
> --- a/framework/pktgen.py
> +++ b/framework/pktgen.py
> @@ -204,6 +204,7 @@ class TrexPacketGenerator(PacketGenerator):
>      def __init__(self, tester):
>          self.pktgen_type = "trex"
>          self._conn = None
> +        self.control_session = None
>          self._ports = []
>          self._traffic_ports = []
>          self._transmit_streams = {}
> @@ -218,7 +219,6 @@ class TrexPacketGenerator(PacketGenerator):
> 
>      def connect(self):
>          self._conn = self.trex_client(server=self.conf["server"])
> -        time.sleep(30)
>          self._conn.connect()
>          for p in self._conn.get_all_ports():
>              self._ports.append(p)
> @@ -295,7 +295,11 @@ class TrexPacketGenerator(PacketGenerator):
>                  app_param_temp = app_param_temp + " --cfg " +
> self.conf[key]
>              elif key == 'core_num':
>                  app_param_temp = app_param_temp + " -c " + self.conf[key]
> -
> +        app = self.conf['trex_root_path'] + os.sep + self.trex_app
> +        cmd = app + " " + app_param_temp
> +        self.control_session =
> self.tester.create_session('trex_control_session')
> +        self.control_session.send_expect('cd ' +
> self.conf['trex_root_path'] + os.sep + 'scripts', '# ')
> +        self.control_session.send_expect(app + " " + app_param_temp, '-
> Per port stats table', 30)
> 
>          # Insert Trex api library
>          sys.path.insert(0,
> "{0}/scripts/automation/trex_control_plane/stl".format(self.conf['trex_roo
> t_path']))
> @@ -377,16 +381,22 @@ class TrexPacketGenerator(PacketGenerator):
>          if self.conf.has_key("warmup"):
>              warmup = int(self.conf["warmup"])
> 
> +        self._traffic_ports = list()
> +        for stream_id in stream_ids:
> +
> self._traffic_ports.append(self._ports[self._get_stream(stream_id)['tx_por
> t']])
> +
> +        print self._traffic_ports
> +        self._conn.set_service_mode(ports=self._traffic_ports,
> enabled=True)
> +        self._conn.resolve(ports=self._traffic_ports)
> +        self._conn.set_service_mode(ports=self._traffic_ports,
> enabled=False)
> +
>          for stream_id in stream_ids:
>              stream = self._get_stream(stream_id)
>              # tester port to Trex port
>              tx_port = stream["tx_port"]
>              p = self._ports[tx_port]
> -            self._conn.add_streams(self._transmit_streams[stream_id],
> ports=[p])
> +            sid =
> self._conn.add_streams(self._transmit_streams[stream_id], ports=[p])
>              rate = stream["options"]["rate"]
> -            self._traffic_ports.append(p)
> -
> -        print self._traffic_ports
> 
>          if self.conf.has_key("core_mask"):
>              self._conn.start(ports=self._traffic_ports, mult=rate,
> duration=warmup, core_mask=self.conf["core_mask"])
> @@ -421,7 +431,13 @@ class TrexPacketGenerator(PacketGenerator):
>          return rate_rx_bits, rate_rx_pkts
> 
>      def quit_generator(self):
> -        self.disconnect()
> +        if self._conn is not None:
> +            self.disconnect()
> +        self.tester.send_expect('pkill -f _t-rex-64', '# ')
> +        time.sleep(5)
> +        if self.control_session is not None:
> +            self.tester.destroy_session(self.control_session)
> +            self.control_session = None
> 
>  def getPacketGenerator(tester, pktgen_type="trex"):
>      """
> diff --git a/framework/tester.py b/framework/tester.py
> index be5b0e13897c..e20c4f8ffcf7 100755
> --- a/framework/tester.py
> +++ b/framework/tester.py
> @@ -743,5 +743,6 @@ class Tester(Crb):
>          """
>          Close all resource before crb exit
>          """
> +        self.pktgen.quit_generator()
>          self.logger.logger_exit()
>          self.close()
> --
> 2.14.1



More information about the dts mailing list