Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp791332rdb; Fri, 26 Jan 2024 10:42:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPSC1/Myn166w5JqI+sFR1kIAiAvPhfdA3SS9VtqSLsTYVaS3lnlD+0+68q/YjvxI3uIKC X-Received: by 2002:aca:2308:0:b0:3be:151:3279 with SMTP id e8-20020aca2308000000b003be01513279mr170124oie.90.1706294532666; Fri, 26 Jan 2024 10:42:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706294532; cv=pass; d=google.com; s=arc-20160816; b=i+h7oYsVcNm1PxRj5cg7WIMyIhtuorL4PPzm6BC9fZ2xjXVBpoQzfpxzqJrGkhysq+ 69NF4wLdHkmORIEYiv1MNR0J1b+qDR4BfAoOU2O9NMGzvu5jMxVUGUUCnpI+25tkxuB7 fSNpucJhGCnGKWb5Gaoahz6P3KT/+iOPIcYTuV9OTnhiPmqBzo8aATK+b7RZQqYUErFm nrOpp6OqaX6aCpZtOLePdvlFaeGyCYb7HwyyTKd6gTHLkfdDiS4ZWSzEkNTflfJBMbMx e5s8XC1RVF8ZUDtJaZHwudSH0qwn/vV+1GenO8NQy/ZMnaR6A/ytSVVp2zDUr1sA+qh1 BotQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FnNMgoupugsdw+R23wgvwumgSeblUqTDDp2m63cNowA=; fh=d3Krop4IPE3x6nBOvh3GY5QHg6bS91zVnQiH59I3hyM=; b=C6ikp2oT441tZI1f2Su3gpVVHVMdllaZR8e2eHa5eS5w37qtwSyBTGPuMyeWR2qaI+ Q5Zlcxz7KduCJguyaCBICnvMT1VCBbhoEsnYyGq54Piv+twsFs4xXsAnVOOdPTe7Gor5 f1EFfd0fAxIq0oNu033jM5hPoyWMCIxKrYAq5AoWnWBQXq4nEM3kjCXH+R8DD2FQR67Z Z0E+inU05py8aHnqgb0O/ZqxpKTXaRIp3qYexzx/3Znfd5CwPpX05+clPpSlejD5AgDo GmBMArpNZymI8/kU5TjgyHX4mZhIXA1nK1dwvdBDCQwVhj5Q1+PBsblJPnhjZasnBvk4 78eA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=imJklIwo; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-40513-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40513-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f15-20020a05620a15af00b007834a2f5ef6si1823380qkk.369.2024.01.26.10.42.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:42:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40513-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=imJklIwo; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-40513-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40513-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6AA8A1C22D26 for ; Fri, 26 Jan 2024 18:42:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F2C5481C8; Fri, 26 Jan 2024 18:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="imJklIwo" Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 3BC4024A15; Fri, 26 Jan 2024 18:39:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706294353; cv=none; b=OAS2WYYDDJaAABtSCQ7zfrIKtQgUmHEC8xVeFtDJZkbEpLI54Qy2UcW7D82G36fhnAAPT1GAbMVs9TD1EwdF8vb/VwWfYxbH6Syg5yubp/4CsIMjuVmQ0Zuah1yYh97jgDpNsZiQTy6irui7I4GL2AP5NjLBK0BwZqKqtS32wJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706294353; c=relaxed/simple; bh=GKEXFBjzRvjdkY+Q1FYw1g1lQsspMWdBGKx/7/eg//I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HtYQBOwkCDP6S3f1eCCAxlVCphiAShrbSE6U+XIoGnK5W5bQxEpQM4GiNJ6gZBrLTEiZu6rvScJSpklQQPr7Y1Au0QJM0V5276pSAxOhSEQd1ZdmoEd/dgcImWrqLK0bG5oryk1LZVxQYLN5xTEKUpFnXZkK6ra4aKHkgHuy8MU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=imJklIwo; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 6D9FAFF806; Fri, 26 Jan 2024 18:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706294349; 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=FnNMgoupugsdw+R23wgvwumgSeblUqTDDp2m63cNowA=; b=imJklIwo0XmfvupiNEhJGnfBgTk5idU0G1wHRyIm6y5myIKW5GkSZG5j3Y4+oPtt7bUIM0 vPSR347dSVMUh+rAqPSs9UCTi4XdHfnsyrSrrUsGazk2iIFAXbRSybfIM7ShIP0s/nGSYq jmo0i4hbu+EUDJeNxgEyoZzP5LWIefhkF9Ps3QlNzi84gPLyWP4ZLoIxjZ+uPjrug+JeMz DrihNF2Mg0RwjJXMSfDrtD/p6lM+3apHu3eFlbeMa/k5vcf7QaEWfZ61i/Bub0zA3tw+1c luVJ+wsb/rkccxqFvPFijzZgKuhipXfrXv64fcf5oQ2wQZRC+vJUffDiH1td2g== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?q?K=C3=B6ry=20Maincent?= , Jesse Brandeburg , Jonathan Corbet , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?UTF-8?q?Nicol=C3=B2=20Veronese?= , Simon Horman Subject: [PATCH net-next v6 12/13] net: ethtool: strset: Allow querying phy stats by index Date: Fri, 26 Jan 2024 19:38:49 +0100 Message-ID: <20240126183851.2081418-13-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240126183851.2081418-1-maxime.chevallier@bootlin.com> References: <20240126183851.2081418-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: maxime.chevallier@bootlin.com The ETH_SS_PHY_STATS command gets PHY statistics. Use the phydev pointer from the ethnl request to allow query phy stats from each PHY on the link. Signed-off-by: Maxime Chevallier --- V6: Use dedicated policy V5: Added Andrew's R-b V4: No changes V3: No changes V2: New patch net/ethtool/strset.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/ethtool/strset.c b/net/ethtool/strset.c index c678b484a079..edc826407564 100644 --- a/net/ethtool/strset.c +++ b/net/ethtool/strset.c @@ -126,7 +126,7 @@ struct strset_reply_data { const struct nla_policy ethnl_strset_get_policy[] = { [ETHTOOL_A_STRSET_HEADER] = - NLA_POLICY_NESTED(ethnl_header_policy), + NLA_POLICY_NESTED(ethnl_header_policy_phy), [ETHTOOL_A_STRSET_STRINGSETS] = { .type = NLA_NESTED }, [ETHTOOL_A_STRSET_COUNTS_ONLY] = { .type = NLA_FLAG }, }; @@ -233,17 +233,18 @@ static void strset_cleanup_data(struct ethnl_reply_data *reply_base) } static int strset_prepare_set(struct strset_info *info, struct net_device *dev, - unsigned int id, bool counts_only) + struct phy_device *phydev, unsigned int id, + bool counts_only) { const struct ethtool_phy_ops *phy_ops = ethtool_phy_ops; const struct ethtool_ops *ops = dev->ethtool_ops; void *strings; int count, ret; - if (id == ETH_SS_PHY_STATS && dev->phydev && + if (id == ETH_SS_PHY_STATS && phydev && !ops->get_ethtool_phy_stats && phy_ops && phy_ops->get_sset_count) - ret = phy_ops->get_sset_count(dev->phydev); + ret = phy_ops->get_sset_count(phydev); else if (ops->get_sset_count && ops->get_strings) ret = ops->get_sset_count(dev, id); else @@ -258,10 +259,10 @@ static int strset_prepare_set(struct strset_info *info, struct net_device *dev, strings = kcalloc(count, ETH_GSTRING_LEN, GFP_KERNEL); if (!strings) return -ENOMEM; - if (id == ETH_SS_PHY_STATS && dev->phydev && + if (id == ETH_SS_PHY_STATS && phydev && !ops->get_ethtool_phy_stats && phy_ops && phy_ops->get_strings) - phy_ops->get_strings(dev->phydev, strings); + phy_ops->get_strings(phydev, strings); else ops->get_strings(dev, id, strings); info->strings = strings; @@ -305,8 +306,8 @@ static int strset_prepare_data(const struct ethnl_req_info *req_base, !data->sets[i].per_dev) continue; - ret = strset_prepare_set(&data->sets[i], dev, i, - req_info->counts_only); + ret = strset_prepare_set(&data->sets[i], dev, req_base->phydev, + i, req_info->counts_only); if (ret < 0) goto err_ops; } -- 2.43.0