Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp604666rdb; Fri, 17 Nov 2023 07:42:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IH88LxMwOnWIKgx+mJjo7qQzinGT1DsYKShvGywrlzooUG6W4P9kdE8umzavNYZSAiQ++dS X-Received: by 2002:a05:6a00:2d1b:b0:6bd:2c0a:e82 with SMTP id fa27-20020a056a002d1b00b006bd2c0a0e82mr17745380pfb.7.1700235751271; Fri, 17 Nov 2023 07:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700235751; cv=none; d=google.com; s=arc-20160816; b=jGg+OqP12pcOfvg9kjEGcABEPri0CMf4/aUFgyScbST94c/n41fYgAoXR0ukLQwDav Yzl9SScwZ2fMFcSeD8K+WB+nNnTE1pF43/+zOEgO2+fkuOfgc7H8I1mSMfGvj8ZGzO1E 8Ics2OjObXQIJjGKLtTi757BIpdNU49G3WuiWyXFuksBI0qHl0lcZEN7hBMYpHv2SY4b rESRZ/iVHelCrrpqOPdjgErm0wSjYWRRkRnvvsEz/dA9OXJZ6dol8RqLOIFQDJAFrFkj oZbapFgVaARYAPXHdz3q13Rw4t8tehedd3WpukK5W7QsrOTBwJQvSxrl3t2sGdkrUrX/ 1hCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AMhHnpOtm9zMrjPprPoDTbWEP4fYLLWMhwm1QFdxOsE=; fh=1WRQxG55ASsvt/9NxVDhUbJ1aQecLyVglFoTAx66NyA=; b=aDztRMlbfZwJmUekfPpZ35udFnoq1SIad0alaJJINBFIRiGHBQnqdeUVlq79Dk6QpK tQNF1TdTAdJQxTNIQ+prKLAsjQ7CiH8810IdPau4YYCMOxV2So1xksutd42XmNGaV2Sx /c3xmO+cM5OtIKLHay6RsXC56dUDS2N5iGJGQgdPzNLLK/lkQ2eSlYH0lnR8SG4+FVkN sLMwVkBpdQKjXjH6EX7lPm0Es7cB4vVG0vOp85pbcSPUql0Vc+/L/HqA7yvNKV4PJLop eI9hUsIepB6SvTOrOyYY8Ogq4koztwFMVQk3KEqbHdNUX6cwc9CAeNltu4jFD0oxHE+v 74+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HpBQbko2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ca3-20020a056a02068300b005b930e0b604si2386133pgb.549.2023.11.17.07.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 07:42:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HpBQbko2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A5D6C80792F9; Fri, 17 Nov 2023 07:41:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346064AbjKQPks (ORCPT + 99 others); Fri, 17 Nov 2023 10:40:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232653AbjKQPkc (ORCPT ); Fri, 17 Nov 2023 10:40:32 -0500 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3057F1730; Fri, 17 Nov 2023 07:40:28 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0D9B11BF206; Fri, 17 Nov 2023 15:40:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700235626; 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=AMhHnpOtm9zMrjPprPoDTbWEP4fYLLWMhwm1QFdxOsE=; b=HpBQbko2Lfth30TFQzansAXpsxycav51T3K2MMk8X3mitJt+eNTtKgTx0il2lKPXspLtpy hLn3wh7LeC1k4LlH4mOOlObCCIILQxB5RidLTsQnfYM3DF/erXiQugVQIYyzPSWnIUuloe h/MXkybt862u9rGD3RzwkHgLL21kOQErRHn633whTu8lC/SImQ/Urb0nvm865Fxug6V1lF dhJ2Nd4NpiclZuNlOzbWseJqSwsmRLPXhb9GzHjW4915DytziIjqpgXFLGA1KZsqrL8SzO TCcYzgz+NRT06ROZVWXz3245KGLyQhDFERhgkJ+mFCIKQoxmE403cyx3eGnzlQ== 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 Subject: [RFC PATCH net-next v2 10/10] net: ethtool: strset: Allow querying phy stats by index Date: Fri, 17 Nov 2023 17:23:21 +0100 Message-ID: <20231117162323.626979-11-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231117162323.626979-1-maxime.chevallier@bootlin.com> References: <20231117162323.626979-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: maxime.chevallier@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 07:41:00 -0800 (PST) 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 --- net/ethtool/strset.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/net/ethtool/strset.c b/net/ethtool/strset.c index c678b484a079..70c00631c51f 100644 --- a/net/ethtool/strset.c +++ b/net/ethtool/strset.c @@ -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.41.0