From patchwork Thu Nov 9 23:07:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 134040 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AA91B432EC; Fri, 10 Nov 2023 00:09:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1182F41148; Fri, 10 Nov 2023 00:09:13 +0100 (CET) Received: from mail-il1-f228.google.com (mail-il1-f228.google.com [209.85.166.228]) by mails.dpdk.org (Postfix) with ESMTP id 8EEF04064C for ; Fri, 10 Nov 2023 00:09:09 +0100 (CET) Received: by mail-il1-f228.google.com with SMTP id e9e14a558f8ab-3576e74ae9dso5708155ab.3 for ; Thu, 09 Nov 2023 15:09:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1699571349; x=1700176149; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cBVZ6Ako4cf++sKNKESsCUqzqNGyv1mmpwPM3X84mWU=; b=SLRg0zmZ+w1lQS2RDF6Yf07kTEnGCM4ugxleVYLXrIfGyNPDMtvvr+1/xWtZQQvQBE EjNzomJ9kXajlMpsuVsjVJUvLfy7yyfPIeTaYRxGiekwauJOLcvg5gvDBKrZMaGwgH9R idP2slSb6u6Uq/wWazAFKGtSxXzjCJ+V4j17U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699571349; x=1700176149; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cBVZ6Ako4cf++sKNKESsCUqzqNGyv1mmpwPM3X84mWU=; b=fnHoadbyPamhSmvWAzlIAJJt/dA2SuzjXZZ337jCEvVzuC/HquZxzuppw3uQNh7dIL gq7/fU6/uFnu+pni/LuMJzrW9L1M4miMclet26vdN9meSyN6IE2NdC2C3t8EZIKhjP2k t2teOVsRRAqtVVvSDLBijIQuSCJ0wNQhKpcVH4RfiXONLaE6K3dl777Od9OR2K/O9vwp PNEiYRBQMkvjY/7iumeCxegdvqyZuAkqZJIchWqL/kVx2HZ0nsjNasecxAAfKQbjyZJ9 bLGzRccs7eQvIAtWADEK1vTUoCrMcraWO9ojny02Cva5m8/TalnofkmuecHtCnRDC5rg Da6A== X-Gm-Message-State: AOJu0Yz1BxdMUA2YX6td3Z0h4o/8gx3JLVffyIMjSNSORruE+D5mN4EB 8ngDiLxqNSU3wOJ4aUhkshf+y0lcugvXcMX8SEmSVnjKI5F6kUEJx0TsPikhvYADOw== X-Google-Smtp-Source: AGHT+IGjpasNGv99RA+9DRQK9KKSF5ILguB/wHi+Ayt3najQUJHBpPnb7NXuk9LDJj0Wl6EpHhkeq7odOKcU X-Received: by 2002:a92:cd89:0:b0:359:cbff:fc69 with SMTP id r9-20020a92cd89000000b00359cbfffc69mr6919256ilb.12.1699571348876; Thu, 09 Nov 2023 15:09:08 -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 do6-20020a0566384c8600b0043a226a8838sm975756jab.35.2023.11.09.15.09.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2023 15:09:08 -0800 (PST) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1271:90f9:1b64:f6e6:867f]) by postal.iol.unh.edu (Postfix) with ESMTP id 38C50605C318; Thu, 9 Nov 2023 18:09:08 -0500 (EST) From: jspewock@iol.unh.edu To: Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech, thomas@monjalon.net, wathsala.vithanage@arm.com, probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru Cc: dev@dpdk.org, Jeremy Spewock Subject: [PATCH v1 2/7] dts: add waiting for port up in testpmd Date: Thu, 9 Nov 2023 18:07:32 -0500 Message-ID: <20231109230900.24572-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231109230900.24572-1-jspewock@iol.unh.edu> References: <20231109230900.24572-1-jspewock@iol.unh.edu> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Jeremy Spewock Added a method within the testpmd interactive shell that polls the status of ports and verifies that the link status on a given port is "up." Polling will continue until either the link comes up, or the timeout is reached. Signed-off-by: Jeremy Spewock --- .../remote_session/remote/testpmd_shell.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/framework/remote_session/remote/testpmd_shell.py index 1455b5a199..3ea16c7ab3 100644 --- a/dts/framework/remote_session/remote/testpmd_shell.py +++ b/dts/framework/remote_session/remote/testpmd_shell.py @@ -1,9 +1,12 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2023 University of New Hampshire +import time from pathlib import PurePath from typing import Callable +from framework.settings import SETTINGS + from .interactive_shell import InteractiveShell @@ -47,3 +50,29 @@ def get_devices(self) -> list[TestPmdDevice]: if "device name:" in line.lower(): dev_list.append(TestPmdDevice(line)) return dev_list + + def wait_link_status_up(self, port_id: int, timeout=SETTINGS.timeout) -> bool: + """Wait until the link status on the given port is "up". + + Arguments: + port_id: Port to check the link status on. + timeout: time to wait for the link to come up. + + Returns: + If the link came up in time or not. + """ + time_to_stop = time.time() + timeout + while time.time() < time_to_stop: + port_info = self.send_command(f"show port info {port_id}") + if "Link status: up" in port_info: + break + time.sleep(0.5) + else: + self._logger.error( + f"The link for port {port_id} did not come up in the given timeout." + ) + return "Link status: up" in port_info + + def close(self) -> None: + self.send_command("exit", "") + return super().close()