From patchwork Mon Nov 13 20:28:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Spewock X-Patchwork-Id: 134179 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 883104331E; Mon, 13 Nov 2023 21:29:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 21486402E0; Mon, 13 Nov 2023 21:28:53 +0100 (CET) Received: from mail-wr1-f100.google.com (mail-wr1-f100.google.com [209.85.221.100]) by mails.dpdk.org (Postfix) with ESMTP id AB5B6402BD for ; Mon, 13 Nov 2023 21:28:50 +0100 (CET) Received: by mail-wr1-f100.google.com with SMTP id ffacd0b85a97d-32df66c691dso2831700f8f.3 for ; Mon, 13 Nov 2023 12:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1699907330; x=1700512130; 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=i9UcQ8zx68Np+yX5IAMjcBubVznqIP5sHjuu9kfrsgIoiHJTbNbSRbW5qvfyWqiq/w s33bEaSdRyYxSFi2o5/1LZvXbUPvX7raHb6SYukugecIQB5KPIMuEWXV7p53wgC5lM1w ZejuIrZvHq1RtSaC/7m9Qgv17NfVGzrFVoTIU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699907330; x=1700512130; 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=g3RyW29boCUdRsSB/mZQK93tfZ0YO/7CFObDs20F6Zmli4Gw8bA8XUg3yyTlsDkmM8 vjVvecG/7FF1Ami3ZfkR1TfNGxqQc5tTEPTecU3YfRhPeg4prTPi58EIGGmE7ORyEhwJ DhDPlGCej/y14cKo8F/wcjFmkyp7tviTlmYB1sYvJiiGd73gnWIo0iG9YEPC1WCIvH8W R2pDoK3n2ydAUm8gF2DTaMr0mQJGD/8m3wZ5gTegNCBkECySgzFLO7EQTKVvaA73VnWi j2PQ4h/hLr9huEerb4GzMrLMa0TflrB8clBD/CaGWKv1IqIMbGrt2tH5Vp3gPEfcHewh 9p2w== X-Gm-Message-State: AOJu0Yx46qsmUP3gHRIsQVebvoQz1e3mXOXwa+yF92F5yA9tX/EYdEAd 1nxvaKOQ6c0oJ112Ti95s0YKcFgTPagjiHc2bWXCrNuRhJGItg== X-Google-Smtp-Source: AGHT+IEa60Ta8d051AiOZH/JdcIGB5omEaDcmiD1AS/CkQEzImoH8D+dQgI6RFRUlaKVBDUWmqBj/Q8J55lk X-Received: by 2002:a5d:5445:0:b0:32d:8094:f4c8 with SMTP id w5-20020a5d5445000000b0032d8094f4c8mr5763595wrv.19.1699907330277; Mon, 13 Nov 2023 12:28:50 -0800 (PST) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id co12-20020a0560000a0c00b0033141c7f1a9sm779300wrb.103.2023.11.13.12.28.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Nov 2023 12:28:50 -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 2D8C0605C344; Mon, 13 Nov 2023 15:28:49 -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 v3 2/7] dts: add waiting for port up in testpmd Date: Mon, 13 Nov 2023 15:28:07 -0500 Message-ID: <20231113202833.12900-3-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231113202833.12900-1-jspewock@iol.unh.edu> References: <20231113202833.12900-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()