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 1125CA034E; Thu, 4 Jun 2020 10:57:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B3E6F1D5E2; Thu, 4 Jun 2020 10:57:03 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id C9A691D5CF for ; Thu, 4 Jun 2020 10:57:01 +0200 (CEST) IronPort-SDR: 0aX89y5sGbNR1ESLpskTG37sMAYZ81+C/MVgDdu/lGImvoNLBrEza6vwAwnuf6dkWP97tAgvad hnf01dCPQ70A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2020 01:57:00 -0700 IronPort-SDR: vN3KYAUYmkyV7mQqOoqazcMAIpu+ssDBC7CP+MmUaQEjh3G34Ol5Nl8U4GHxFFQKhhzRgqMqJK z8eOtJnjqCvw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,471,1583222400"; d="scan'208";a="258838262" Received: from dpdk-lihong-ub1604.sh.intel.com ([10.67.118.174]) by fmsmga008.fm.intel.com with ESMTP; 04 Jun 2020 01:56:59 -0700 From: lihong To: dts@dpdk.org, weix.xie@intel.com Cc: lihong Date: Thu, 4 Jun 2020 09:25:39 +0800 Message-Id: <1591233939-19335-1-git-send-email-lihongx.ma@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dts] [PATCH V1] framework/pktgen_trex: check the port status before start transmission 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" Signed-off-by: lihong --- framework/pktgen_trex.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/framework/pktgen_trex.py b/framework/pktgen_trex.py index 202c778..8da0c84 100644 --- a/framework/pktgen_trex.py +++ b/framework/pktgen_trex.py @@ -790,6 +790,21 @@ class TrexPacketGenerator(PacketGenerator): rate_percent = "{0}%".format(options.get('rate') or self._traffic_opt.get('rate') or '100') + # check the link status before transmission + self.logger.info('check the trex port link status') + for port in self._traffic_ports: + try_times = 0 + port_attr = self._conn.get_port_attr(port) + while try_times < 5: + self.logger.info(pformat(port_attr)) + if 'link' in port_attr.keys() and port_attr['link'].lower() == 'down': + time.sleep(2) + try_times = try_times + 1 + port_attr = self._conn.get_port_attr(port) + else: + break + if try_times == 5 and port_attr['link'].lower() == 'down': + self.logger.error('the port: %d link status is down, the transmission can not work right' % port) try: # clear the stats before injecting self._conn.clear_stats() -- 2.7.4