From patchwork Thu Apr 3 06:04:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 14036927 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 703882E3365; Thu, 3 Apr 2025 06:04:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743660282; cv=none; b=GjF5s+Pl/ag4maoX45qJfO+/6KEspIO9gwoSElFGJ4DSmAs88+bO/Vr4iKtcxhcNQ5QC39S3SqaDcYNMKj6op9LzOBgx5+x0MQXFiwoSDu9Tg2EMiETBNMSWJhkqrEQ6fvTJIik/HBhAvYCa7CbhxnhDOXEq2oGvBop63shtZ+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743660282; c=relaxed/simple; bh=EDye05dsnyrMncweEzXTa0ZsocH3DBIYBUZadMP5ZOc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H5lYSP+DqE0klDg3cbiv1bmici4krCuPBv0j/y1Et7clxngLQ4VUdCtr8xmSpS7UASXWVG8INe1Cb1JVT+kWPqYelRc9QFOmpdpFDIr6kY2yfslnCO/J45rk3c/T0TBZqqDwZOuKubDMKBsZSNG9ltEnwlcWesrIFd61V1HXKmQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nVEDU+yw; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nVEDU+yw" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-227aaa82fafso5577715ad.2; Wed, 02 Apr 2025 23:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743660281; x=1744265081; darn=vger.kernel.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=gMWz8BrcdL/ag4zgf9L4Rza6vwBAXPSPwY8SyGUExDc=; b=nVEDU+yww+2RGO5lx59/WvNYXCJv9IKFCizB48hwP3jipgHHpHiRs1OrEpP/5urBCP Gs7hZ5K+l2VPnIoPM75CF15hjRplht5MQeVw6wal/NvAqjuNLEyli4P99Mr5P11lY4hv XupDaU8nIcDQQR5MwVi1mIOhO2ewUmp29atqVHnKla+XOTwncpQnXW7jYAxDihWWjVFx 7vrH+684wJsoa/I9D5xLuJLQw1X8sEq1GG56IoLdsE+JIeplc2/hT1Ara38cCdBL9mDx RCReAogVRXQhoLAQTBL99QpdhYjYCMw02UTYFlIAozq424y8QR36msPmEg/WDf95E2ou EuTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743660281; x=1744265081; 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=gMWz8BrcdL/ag4zgf9L4Rza6vwBAXPSPwY8SyGUExDc=; b=k84V17yxrumHaa/ucg/BqHP4Q1CvgdyfAbTGD9Y1BW1u/x7Stp/EcCIfXFaHjZclIg lC5SKjYEXYvqcZNm9cWw+hAKGyCte6m04wsosdjZyB24eGZ4+ueLZD23Pzgq2Qaer0w1 DNeWdJVko+alkNiyPVc7BAI5DTLJ6hqL6TQlVNDEpnJNkHFR4UQaASR48wVPg+GIKkxE JO3JeFFKauEtgkiFPX5Yx2pCinkIKZrme62uqXDcNrivKa9HJbd0p8P4Cs4aqDDaZzRR BMwYexe5YFzmhHLBDIvhrfurp0bad6YNro418medktI+kj3HItEGcUhl+Eu5Lp8D6VBX t0bQ== X-Forwarded-Encrypted: i=1; AJvYcCUwDGt/O0UZ6TAgVLTFazln5c2wc5V9lYdjQKdH0aPK1DmKUK6ncQtAD0XLGCyUEbZuqh/lmiFA3roK6MBWZdY=@vger.kernel.org, AJvYcCXdMbHyp5VQoHQ6yWv+v39kxcnRg2RUm+bKjRfP8n45Tr9DQRuy2dySIpF5wfFjivaEsTyHayKK@vger.kernel.org X-Gm-Message-State: AOJu0YzuNwRizxHIu8VWrSECH56dqOJzRc6m9BwYQHMILxg+P8yPx5qt UYnTdMNz5oqUwWSdx6AcBubJeBC9fIRyJENRuVrLVdYJUc5jHGqc X-Gm-Gg: ASbGnctQsGcNH4xXfSFGpI+zdN+WgH3qBN7DGicypFxyntGVxYF/f16iHCHPojuK5MQ Ewic4mRqPVEwaW+QeapzshAE+dh8yEc5RaLYA2uVDpvKQccpBvcQ7YFB9nJPSrC8eJwQqS0KZNM 1ZIwCLy882hm0TZ78CR5LdZLbXk8Az5VFFEt9HGgu6DxQ47zWdubbfbDCkujAPqaqxc6wjz0ZcI 25U9NuzIMaJGAwL4TFwFlsIBGEeEWIAGeP0ikSRzZuACNQAzVVZpsSYKtaLp28Rv7FXjZujwhTa aX9kY9Mkp3y1EgKzAQdlT0SyWApCD8ZmuA== X-Google-Smtp-Source: AGHT+IF6HC0JY72zZoF5DR3ldPATrzb+moz+S8Ga7FYjv2fp6tWgfdKHWYCuA3oJrb+geNUx+2ouIA== X-Received: by 2002:a17:903:1a04:b0:223:6657:5008 with SMTP id d9443c01a7336-22977dab04cmr23444235ad.24.1743660280477; Wed, 02 Apr 2025 23:04:40 -0700 (PDT) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-739da0e3141sm615340b3a.173.2025.04.02.23.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Apr 2025 23:04:39 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, andrew+netdev@lunn.ch, horms@kernel.org, shuah@kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: kory.maincent@bootlin.com, willemb@google.com, aleksander.lobakin@intel.com, ecree.xilinx@gmail.com, almasrymina@google.com, daniel.zahka@gmail.com, jianbol@nvidia.com, gal@nvidia.com, michael.chan@broadcom.com, ap420073@gmail.com Subject: [PATCH net 1/2] net: ethtool: fix ethtool_ringparam_get_cfg() returns a hds_thresh value always as 0. Date: Thu, 3 Apr 2025 06:04:22 +0000 Message-Id: <20250403060423.1209435-2-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250403060423.1209435-1-ap420073@gmail.com> References: <20250403060423.1209435-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org When hds-thresh is configured, ethnl_set_rings() is called, and it calls ethtool_ringparam_get_cfg() to get ringparameters from .get_ringparam() callback and dev->cfg. Both hds_config and hds_thresh values should be set from dev->cfg, not from .get_ringparam(). But ethtool_ringparam_get_cfg() sets only hds_config from dev->cfg. So, ethtool_ringparam_get_cfg() returns always a hds_thresh as 0. If an input value of hds-thresh is 0, a hds_thresh value from ethtool_ringparam_get_cfg() are same. So ethnl_set_rings() does nothing and returns immediately. It causes a bug that setting a hds-thresh value to 0 is not working. Reproducer: modprobe netdevsim echo 1 > /sys/bus/netdevsim/new_device ethtool -G eth0 hds-thresh 100 ethtool -G eth0 hds-thresh 0 ethtool -g eth0 #hds-thresh value should be 0, but it shows 100. The tools/testing/selftests/drivers/net/hds.py can test it too with applying a following patch for hds.py. Fixes: 928459bbda19 ("net: ethtool: populate the default HDS params in the core") Signed-off-by: Taehee Yoo --- The ethtool command doesn't support hds-thresh option yet. So, RFC[1] patch is needed to be applied. net/ethtool/common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 0cb6da1f692a..49bea6b45bd5 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -830,6 +830,7 @@ void ethtool_ringparam_get_cfg(struct net_device *dev, /* Driver gives us current state, we want to return current config */ kparam->tcp_data_split = dev->cfg->hds_config; + kparam->hds_thresh = dev->cfg->hds_thresh; } static void ethtool_init_tsinfo(struct kernel_ethtool_ts_info *info) From patchwork Thu Apr 3 06:04:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taehee Yoo X-Patchwork-Id: 14036928 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D67B219D8A3; Thu, 3 Apr 2025 06:04:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743660288; cv=none; b=eCRAvP7odYCC65a3FCiTzkN1orpeTGuXzM6wzZQpq/11lFzRq7t+peVON61BqQXrI3KfeQkltTwwRL0Sp+0v22ikAweBv8ENqprNvPHfNinTbG09iX7v3ygl1Zdu1kKfwkHSu+t/Q8maOXw7/3/lyavBUH7VjpknEVVLABJhy5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743660288; c=relaxed/simple; bh=MX3akoveBpk/g6fzPhVqkT1XvOiHRNKYkwBOefY2+BQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YuID8RPv+L/fQ48ZMz9sZTFd2gtnNRahYmmRO3UW/Ec0xGF74Zb4abqRJPGHvRwxD2GDfQAn4yN6wlhY8tun4SQMTCs1dQHOhtfIy0fhF7eeNxIEZleT0+hA8kzy2jSzL3Jr/D6jSBnjcL3DlZA7Y56VYAjn76/DBWeS0WbDeMQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QAUkKyyH; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QAUkKyyH" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-224191d92e4so5162805ad.3; Wed, 02 Apr 2025 23:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743660286; x=1744265086; darn=vger.kernel.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=OSW8mNF0B+bCZ674Cbi4bHO+4cmTiu59GXWSDpHNJV4=; b=QAUkKyyHmu7AgE09mkKV8MOWKlx0R4QspAcCgoTd7AWZQWwIO3vUCSIF48gzbOgVtr X71biA+CNjn54U3rPDqR2LJhhKfjCLMRFd2I6I9tuZxOYTnPz4YyemM4/aR6So/3BA4D vTUzB4DVx6HqVWjSlpRcjl/QcPC9KQCCIvHK7t/TZSjZQETyqcHAGx7J6yebhiDY0W0I ufCSQo3liEMfRu3GZAqZR85Jt5Gy9xHvTg95wI13oQOZHFLTSMXIlZ9Df2Ca4D9QB4EQ 2ygxIPuatqmmd3BY5t/Xa1aX6QeEhYsYPedk+2W45tp5xWGDcoZu68QFRiHfrqFAefNw /m7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743660286; x=1744265086; 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=OSW8mNF0B+bCZ674Cbi4bHO+4cmTiu59GXWSDpHNJV4=; b=CLHlYTgGJ6YWN3aCnhDa7T4XWENjdk+iqppTGHMsANH2iuJHaNxsJ3Xvg2nB9Xtat5 2uygfAhXQUUmbfWgY0RXr4Fxv1OF9C7/dXz9/KlIpScCkKm3CkcGK7sZM2AGAbYZ4rLv bjFSlAyMTSleki/sZrP7E4XgG7P/N+KMVu1qe+K5B93iNswoPS26lbhHH34UVAhFIUlF AIO9KsvBQu3pFp19FFhsXhcFS6fgIButOHJPioO6txpTPwVo2ZulLkLw78xvem3TV9Tw C2XZUnx3leEWl/qG4q4PihfE6LP4DLe4KHA9VozIWeko725MVPO2OWoFMdMC5zAWwQlF OEkQ== X-Forwarded-Encrypted: i=1; AJvYcCV+AqlqgIC6mq53hgg1MG30qnN4bV0vWe8xuhhRMmb8YbXDwe4ejqK+yrskbf6QxRma6rgpor/6@vger.kernel.org, AJvYcCWakCFi/Om8/W/4Jy5HbeNOfHXXKX9KvAwCZGU9DpmFrVTHb8CrJ1/kJC34di9SKyzCwCBAXK8JljLSLPbSdbA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxpk956hzLPktfQTNSLXuhHw93B/G8n2F6ijsUJq/Y674nwMjx8 8nLI3zzJxFDwWVVD0RS0bhmS4INbApbAHRhl9w9I0wm6wQC2xeWa X-Gm-Gg: ASbGncuEFnUj/gQE63Xpys7FDEXay4vWGCC7WDeM9OvXdSfXJzPx9dCP0xvlXXD5Qpc 7vwbGSwXRA0ZSvoFp34kRCQN18kbJXmtVRhySSpgxsYOnwx+xMTiMBGVP7XE+DfXxsZAhSZgiwl I23Lnh4aI9U6lrImsGECAblhf9s3gGfjXRcEHIwlh/TqNVOpwZbV/Tj2cnKtsXhg69s1WcILMQb bhVNwvIxi8ZQ+GZZLxx611UPBnNCJHguBh+CHsu8MirT9K0b4/hXClrg/7C4vjJFCDLxpTs1OhQ Ln/14dbCIzv0OfpBSrsPWMmFuYd/5OGr5A== X-Google-Smtp-Source: AGHT+IHvMkGeAGIKqJ1OslvBnx2ENYo4vMaCu+L7pXWzG7OXj07BbI4fimHMIsbFMOAx1/Zp4PuPLw== X-Received: by 2002:a17:902:f651:b0:224:1221:1ab4 with SMTP id d9443c01a7336-22977d9c36fmr24868545ad.22.1743660286001; Wed, 02 Apr 2025 23:04:46 -0700 (PDT) Received: from ap.. ([182.213.254.91]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-739da0e3141sm615340b3a.173.2025.04.02.23.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Apr 2025 23:04:45 -0700 (PDT) From: Taehee Yoo To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, andrew+netdev@lunn.ch, horms@kernel.org, shuah@kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: kory.maincent@bootlin.com, willemb@google.com, aleksander.lobakin@intel.com, ecree.xilinx@gmail.com, almasrymina@google.com, daniel.zahka@gmail.com, jianbol@nvidia.com, gal@nvidia.com, michael.chan@broadcom.com, ap420073@gmail.com Subject: [PATCH net 2/2] selftests: drv-net: test random value for hds-thresh Date: Thu, 3 Apr 2025 06:04:23 +0000 Message-Id: <20250403060423.1209435-3-ap420073@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250403060423.1209435-1-ap420073@gmail.com> References: <20250403060423.1209435-1-ap420073@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org hds.py has been testing 0(set_hds_thresh_zero()), MAX(set_hds_thresh_max()), GT(set_hds_thresh_gt()) values for hds-thresh. However if a hds-thresh value was already 0, set_hds_thresh_zero() can't test properly. So, it tests random value first and then tests 0, MAX, GT values. Testing bnxt: TAP version 13 1..13 ok 1 hds.get_hds ok 2 hds.get_hds_thresh ok 3 hds.set_hds_disable # SKIP disabling of HDS not supported by the device ok 4 hds.set_hds_enable ok 5 hds.set_hds_thresh_random ok 6 hds.set_hds_thresh_zero ok 7 hds.set_hds_thresh_max ok 8 hds.set_hds_thresh_gt ok 9 hds.set_xdp ok 10 hds.enabled_set_xdp ok 11 hds.ioctl ok 12 hds.ioctl_set_xdp ok 13 hds.ioctl_enabled_set_xdp # Totals: pass:12 fail:0 xfail:0 xpass:0 skip:1 error:0 Testing lo: TAP version 13 1..13 ok 1 hds.get_hds # SKIP tcp-data-split not supported by device ok 2 hds.get_hds_thresh # SKIP hds-thresh not supported by device ok 3 hds.set_hds_disable # SKIP ring-set not supported by the device ok 4 hds.set_hds_enable # SKIP ring-set not supported by the device ok 5 hds.set_hds_thresh_random # SKIP hds-thresh not supported by device ok 6 hds.set_hds_thresh_zero # SKIP ring-set not supported by the device ok 7 hds.set_hds_thresh_max # SKIP hds-thresh not supported by device ok 8 hds.set_hds_thresh_gt # SKIP hds-thresh not supported by device ok 9 hds.set_xdp # SKIP tcp-data-split not supported by device ok 10 hds.enabled_set_xdp # SKIP tcp-data-split not supported by device ok 11 hds.ioctl # SKIP tcp-data-split not supported by device ok 12 hds.ioctl_set_xdp # SKIP tcp-data-split not supported by device ok 13 hds.ioctl_enabled_set_xdp # SKIP tcp-data-split not supported by device # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:13 error:0 Signed-off-by: Taehee Yoo --- tools/testing/selftests/drivers/net/hds.py | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/hds.py b/tools/testing/selftests/drivers/net/hds.py index 8b7f6acad15f..3ba8e4d69c4c 100755 --- a/tools/testing/selftests/drivers/net/hds.py +++ b/tools/testing/selftests/drivers/net/hds.py @@ -6,7 +6,7 @@ import os from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_raises, KsftSkipEx from lib.py import CmdExitFailure, EthtoolFamily, NlError from lib.py import NetDrvEnv -from lib.py import defer, ethtool, ip +from lib.py import defer, ethtool, ip, random def _get_hds_mode(cfg, netnl) -> str: @@ -109,6 +109,31 @@ def set_hds_thresh_zero(cfg, netnl) -> None: ksft_eq(0, rings['hds-thresh']) +def set_hds_thresh_random(cfg, netnl) -> None: + try: + rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) + except NlError as e: + raise KsftSkipEx('ring-get not supported by device') + if 'hds-thresh' not in rings: + raise KsftSkipEx('hds-thresh not supported by device') + if 'hds-thresh-max' not in rings: + raise KsftSkipEx('hds-thresh-max not defined by device') + + while True: + hds_thresh = random.randint(1, rings['hds-thresh-max']) + if hds_thresh != rings['hds-thresh']: + break + + try: + netnl.rings_set({'header': {'dev-index': cfg.ifindex}, 'hds-thresh': hds_thresh}) + except NlError as e: + if e.error == errno.EINVAL: + raise KsftSkipEx("hds-thresh-set not supported by the device") + elif e.error == errno.EOPNOTSUPP: + raise KsftSkipEx("ring-set not supported by the device") + rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) + ksft_eq(hds_thresh, rings['hds-thresh']) + def set_hds_thresh_max(cfg, netnl) -> None: try: rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}}) @@ -243,6 +268,7 @@ def main() -> None: get_hds_thresh, set_hds_disable, set_hds_enable, + set_hds_thresh_random, set_hds_thresh_zero, set_hds_thresh_max, set_hds_thresh_gt,