Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C88BC30ACEC for ; Wed, 24 Sep 2025 12:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758717661; cv=none; b=mQsiz1GS9VtGPjXclMpd2+WMGP4tYbbRyNkdPjNKA8M89PyVlybVSBILNs9wqfOVK0RtfBMJ6lu3yOgm8LHS9ZoqLfiZhHI/zcyjzioEwyqoHOWm2l9rOIcdSrE9Yzx8Go0Kz16BLrIsAqcywW/RANoh4T7mA36HX1TwGShTXg8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758717661; c=relaxed/simple; bh=DHVXLcwddHcBxYKMAV6H60WigJg9BCU3/yxZUrz1nvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G+b5FKxaEDscJJRtQdMlhJ9MD9K0AT7X4zm8spfzI9kV1gUPM/CKUcjz7jsMz7PcDgsxpA3EI5SNGrMjXlefNSF3JX9A2tTVsseieRZVev5ERDfGnbMkuRJvjxoAW1xl/pXGwJYuf+QcAkG0/Tck+soZuAEhg4m1P21MVef6mnk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=lnj7V6jV; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="lnj7V6jV" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1758717657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HDGo5NsaOWxAVdRlSv/qyz+9ho8tgsHJrjJhMpfwDKg=; b=lnj7V6jVdd2CvGFzsSfvI3rdiYtpqSC7u8a3TT4EUOAqhCEVA25a8Jf7uI4yQo1GESlI+x yVVv/wr10j8dAgWTzZncnQ3Hf7CL0mfSBNHlTRN6dSkmXAPnP+3+1ldUuycAJh/NWBBNdu Qgewnx4oS6lTfDkrh7Zq35coq88v0NA= From: Vadim Fedorenko To: Jakub Kicinski , Andrew Lunn , Michael Chan , Pavan Chebbi , Tariq Toukan , Gal Pressman , intel-wired-lan@lists.osuosl.org, Donald Hunter , Carolina Jubran , Aleksandr Loktionov , Vadim Fedorenko Cc: Paolo Abeni , Simon Horman , netdev@vger.kernel.org Subject: [PATCH net-next v6 5/5] selftests: net-drv: stats: sanity check FEC histogram Date: Wed, 24 Sep 2025 12:40:37 +0000 Message-ID: <20250924124037.1508846-6-vadim.fedorenko@linux.dev> In-Reply-To: <20250924124037.1508846-1-vadim.fedorenko@linux.dev> References: <20250924124037.1508846-1-vadim.fedorenko@linux.dev> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Simple tests to validate kernel's output. FEC bin range should be valid means high boundary should be not less than low boundary. Bin boundaries have to be provided as well as error counter value. Per-plane value should match bin's value. Signed-off-by: Vadim Fedorenko --- tools/testing/selftests/drivers/net/stats.py | 35 ++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py index c2bb5d3f1ca1..04d0a2a13e73 100755 --- a/tools/testing/selftests/drivers/net/stats.py +++ b/tools/testing/selftests/drivers/net/stats.py @@ -57,6 +57,36 @@ def check_fec(cfg) -> None: ksft_true(data['stats'], "driver does not report stats") +def check_fec_hist(cfg) -> None: + """ + Check that drivers which support FEC histogram statistics report + reasonable values. + """ + + try: + data = ethnl.fec_get({"header": {"dev-index": cfg.ifindex, + "flags": {'stats'}}}) + except NlError as e: + if e.error == errno.EOPNOTSUPP: + raise KsftSkipEx("FEC not supported by the device") from e + raise + if 'stats' not in data: + raise KsftSkipEx("FEC stats not supported by the device") + if 'hist' not in data['stats']: + raise KsftSkipEx("FEC histogram not supported by the device") + + hist = data['stats']['hist'] + for fec_bin in hist: + for key in ['bin-low', 'bin-high', 'bin-val']: + ksft_in(key, fec_bin, + "Drivers should always report FEC bin range and value") + ksft_ge(fec_bin['bin-high'], fec_bin['bin-low'], + "FEC bin range should be valid") + if 'bin-val-per-lane' in fec_bin: + ksft_eq(sum(fec_bin['bin-val-per-lane']), fec_bin['bin-val'], + "FEC bin value should be equal to sum of per-plane values") + + def pkt_byte_sum(cfg) -> None: """ Check that qstat and interface stats match in value. @@ -279,8 +309,9 @@ def main() -> None: """ Ksft boiler plate main """ with NetDrvEnv(__file__, queue_count=100) as cfg: - ksft_run([check_pause, check_fec, pkt_byte_sum, qstat_by_ifindex, - check_down, procfs_hammer, procfs_downup_hammer], + ksft_run([check_pause, check_fec, check_fec_hist, pkt_byte_sum, + qstat_by_ifindex, check_down, procfs_hammer, + procfs_downup_hammer], args=(cfg, )) ksft_exit() -- 2.47.3