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 5DA797289 for ; Thu, 29 Mar 2018 21:16:47 +0200 (CEST) Received: by mail-qt0-f226.google.com with SMTP id f16so7385109qth.3 for ; Thu, 29 Mar 2018 12:16:47 -0700 (PDT) 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=ur+17u5mAHmBayMajb/47MY/zfaTF4kXPxbGKs77P+8=; b=caLgW5P+UTQ6UqY0Btm9yVNbdib82w3k7DbBrvUAB48CxrNtNQDi2UmHHNWvb/5K3e KLqABK37mZH5+VJQK0F8e0WStCX7Pgq2A8tesQK9hA3opZxe2nHW8mCJDojDx+iY/Tk5 Phc639Y7lG4OaIqTBIvpCanvfgzQoT21noCQA= 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=ur+17u5mAHmBayMajb/47MY/zfaTF4kXPxbGKs77P+8=; b=DS66Lv2gk1oJA9P8D41bpe7iKQstKZ1vbC7fZnRqEkBpd+yqA2Ek7L1Q/fPb3PSMXn BO76Kb86olt+A06ANeebaSjRbDt7mHXtKOMbEc3W8Olwh2mguRu5m711TzV1o5I6sqiy 6c1nF5ft8nQRkYlt2EkDOmy13+9cNZE0+jCobipjAMEDsGu+IipdXYzxWQwPsMnaI/og fjHsSUdrQP36KgeumNaRHyR9kuDZeLqaeehMJFJnLy1pG8mRH6laBl1wNi7vatrFLko4 CFMRmwnL9UT72KAdpF5rEwCzzrVCcLVmVjgO6YuSZNPcoutTCSptB2KAA+ycndzPc6KD FGyg== X-Gm-Message-State: ALQs6tCGrklr6MlHrIBlvk82jOvKQutOHZqjfYBGOan4nlPgpqhAVm1Q JDP5G+suy1dNzP1l1MJb3Rzm/pCpQfzhkSrchLwS4Afx9RLJ3Ec+Z09mivW9/r+Uc7sr+/5bUub dyVs5NjnIirclz3dhnzM+EXpSLjtkGx32m0cAzWGeAzYyxOrGG2fYMs3PhU3spyOxwAeLyt2DJA == X-Google-Smtp-Source: AIpwx497KvyjMAvbgwNlpFvTAzCpkQrzCMbJJg29A7kKh1HiIKltL9AmcKuVkrjffm3n3yFSeVYZYKY5qaJa X-Received: by 10.200.20.2 with SMTP id k2mr12743048qtj.142.1522351006807; Thu, 29 Mar 2018 12:16:46 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id s204sm1281892qke.9.2018.03.29.12.16.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 12:16:46 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from groose.ofa (unknown [IPv6:2606:4100:3880:1240:cc3b:885c:7cb:4a8e]) by postal.iol.unh.edu (Postfix) with ESMTP id 109BB6045DC5; Thu, 29 Mar 2018 15:16:46 -0400 (EDT) From: Patrick MacArthur To: dts@dpdk.org Cc: dpdklab@iol.unh.edu Date: Thu, 29 Mar 2018 15:16:03 -0400 Message-Id: <20180329191605.5404-6-pmacarth@iol.unh.edu> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180329191605.5404-1-pmacarth@iol.unh.edu> References: <20180329191605.5404-1-pmacarth@iol.unh.edu> Subject: [dts] [PATCH for-next v3 5/7] 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: Thu, 29 Mar 2018 19:16:47 -0000 The currently merged patchset for T-Rex does not actually start T-Rex. Add a configuration option "start_trex" and start T-Rex during the prepare_generator() step if this is set to a non-empty string. 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 configuration option assumes that T-Rex will always be run on the tester node. Signed-off-by: Patrick MacArthur --- conf/pktgen.cfg | 2 ++ framework/pktgen.py | 34 +++++++++++++++++++++++----------- framework/tester.py | 1 + 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/conf/pktgen.cfg b/conf/pktgen.cfg index 1f3c7952f7f8..cc3fe61356b1 100644 --- a/conf/pktgen.cfg +++ b/conf/pktgen.cfg @@ -9,6 +9,7 @@ # socket_memory --socket-mem: Memory to allocate on specific sockets # mapping_ports -m: Matrix for mapping ports to logical cores. # pcap_port_num -s P:file: The PCAP packet file to stream. P is the port number. +# start_trex: Set to a nonempty value to start trex ourselves. [TREX] trex_root_path=/opt/trex-core-2.26 config_file=/etc/trex_cfg.yaml @@ -20,3 +21,4 @@ ip_src=16.0.0.1 ip_dst=10.0.0.1 warmup=15 duration=-1 +#start_trex=yes diff --git a/framework/pktgen.py b/framework/pktgen.py index 9e052c832da9..86110382e9ab 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) @@ -287,15 +287,20 @@ class TrexPacketGenerator(PacketGenerator): return vm def _prepare_generator(self): - app_param_temp = "-i" - - for key in self.conf: - #key, value = pktgen_conf - if key == 'config_file': - app_param_temp = app_param_temp + " --cfg " + self.conf[key] - elif key == 'core_num': - app_param_temp = app_param_temp + " -c " + self.conf[key] - + if self.conf.has_key('start_trex') and self.conf['start_trex']: + app_param_temp = "-i" + + for key in self.conf: + #key, value = pktgen_conf + if key == 'config_file': + 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,6 +382,7 @@ class TrexPacketGenerator(PacketGenerator): if self.conf.has_key("warmup"): warmup = int(self.conf["warmup"]) + self._traffic_ports = [] for stream_id in stream_ids: stream = self._get_stream(stream_id) # tester port to Trex port @@ -421,7 +427,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() + if self.control_session is not None: + self.tester.send_expect('pkill -f _t-rex-64', '# ') + time.sleep(5) + 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