From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt0-f226.google.com (mail-qt0-f226.google.com [209.85.216.226]) by dpdk.org (Postfix) with ESMTP id 8E6CF1B03C for ; Tue, 20 Feb 2018 18:26:18 +0100 (CET) Received: by mail-qt0-f226.google.com with SMTP id g60so9166148qtd.11 for ; Tue, 20 Feb 2018 09:26:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vPXItKvZp0YT7exwm92TKPxnSYpcTXCiw7piG/aYr+U=; b=XjVAm536lruDBRfgAF/3INl/ZgbKxrf6yPfYHCqanDg142P837h40WwnGzUPgEavAu 8B94JQg1eOfbHN3WDQ2xKIm1TprPp5y/vBw3wBt8pque4paGP/YHY9LYAkDZVILoLuQm HG+kFwmFI2/PXjcFnY7lV636+JaUTdScmE10s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vPXItKvZp0YT7exwm92TKPxnSYpcTXCiw7piG/aYr+U=; b=l7cadZefy8nx3Ix7uEEbZ0riAtDDrV983LP5akTufgwvMu2YJnoTyATSYN3p+lRdoJ I3/CPnEE3QZRaLeoCNzAyqq13V/VujDVOWuc1SbOMjuSpskmOfZ06ngphzuh8f5QKJrW 3kWOohYZDUPwEjXDWgYlnEydsYA6sCUUZ/2IyPjHffrAGtqKfAVJHuDGj1/Fl3lMOZCp l4vl3NTVIVZq8C84ck+P0NZedYDsH6e3zW2RkaZp7EPz/5vagbVkiWU6cxf54UleIkYn hOy2rIQr+8kPgls9cI8dxtSvSZ6IXtw0oFFIouRew4vFDLIgkMckK7JCf8KvnSYLnPai 0GEQ== X-Gm-Message-State: APf1xPCKprxedE9yP9MNAKCsyuY0jxg7zhICgAZhQ+VTRLo4ENBftlsn C0jcT1FQxk9AkQBlHNWoaeSHd/1WkblIhrKcagROe9VZ/pHVOF/T86QHc/NqMKxg7ixhs+De+Sq iuHI3q+a+BIz46RMotYV99xMyMXUMWOdvj/2q0wh58ZUKG5qQSA6uFmmBXX1UKS55WvikiS/vk0 kbgz1SN5IsJJPu+g== X-Google-Smtp-Source: AH8x2246UtSJ4Cd9BfBbbCIbEppb7pOpaNnrmiGF+EvII+a/a2X6hqsEroMryOKDa3TErJz2GUhr6smPDRSi X-Received: by 10.200.16.11 with SMTP id z11mr559559qti.292.1519147578002; Tue, 20 Feb 2018 09:26:18 -0800 (PST) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [2606:4100:3880:1234::84]) by smtp-relay.gmail.com with ESMTPS id t123sm79332qkh.8.2018.02.20.09.26.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2018 09:26:17 -0800 (PST) X-Relaying-Domain: iol.unh.edu Received: from groose.iol.unh.edu (unknown [IPv6:2606:4100:3880:1240:948e:929b:6d8b:f08a]) by postal.iol.unh.edu (Postfix) with ESMTP id 21B876132CA1; Tue, 20 Feb 2018 12:26:17 -0500 (EST) From: Patrick MacArthur To: dts@dpdk.org Cc: pmacarth@iol.unh.edu, dpdklab@iol.unh.edu Date: Tue, 20 Feb 2018 12:26:11 -0500 Message-Id: <20180220172612.11973-6-pmacarth@iol.unh.edu> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180220172612.11973-1-pmacarth@iol.unh.edu> References: <20180220172612.11973-1-pmacarth@iol.unh.edu> Subject: [dts] [PATCH for-next 5/6] framework/pktgen: Start T-Rex during prepare_generator() 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: , X-List-Received-Date: Tue, 20 Feb 2018 17:26:18 -0000 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 Signed-off-by: Patrick MacArthur --- 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_root_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_port']]) + + 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