Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6835414rdb; Fri, 15 Dec 2023 09:27:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3RQa8HHdDtY+63zieUzRknTP6w4CywXJ/vhaclyuWM/K8zyp9/gI38EaTVIW8vWphLriv X-Received: by 2002:a05:6a20:1385:b0:18c:9175:eae6 with SMTP id hn5-20020a056a20138500b0018c9175eae6mr6831228pzc.24.1702661242600; Fri, 15 Dec 2023 09:27:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702661242; cv=none; d=google.com; s=arc-20160816; b=lDd9VfIt50vvqvkYYGlfnZSrZlQvWnGbKCXAaiXD/AmqQIRYqYvbBCEUK3jkyJQ5lJ 3Yc7QMetsvUR8ZaapfJ4hCVJ0C6s1A3N5rARlh5+5dZDFLfX3vanQWHjomBVd0wW6Lal iHGRvZaPJolIfN13FAb371bd4eNYbS+0FQ4FLOC1mQsfRdsakyvkhd8sFOv27lWK4KON kcMhYWJGn3K9clY7uulbHf9stS3GJVE5Ig/S0PylprF6kql6v5GFMcTjoXxHZ9g2Przo 7fP2zR486n9n33hXML6Ux7BlHs2Liv0GDZjMj0VKhiZyFGKfXcGFtJwdydce6TpecjVG 4g+A== ARC-Message-Signature: i=1; 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=rrUXd7NMMre9e9Vecy43ZuEpenDqyc3EJP1TkuGFMjo=; fh=01/i7K9ues3Vkkz8uyECvnCPITXmGs/30yOh5FbyFgY=; b=FlpLargZjovh/eVw69H+2HwTvIzbjp3OMSDA5vuGs0brORxaOg4fM7mCyy2c6szKzz 2PjB7dXS/S+I3JMDlHfcjIDlaZZdFEqyctMsDZe0bh47wol4FV3ugtLTs/rAudN7QI5/ yb6fCPc5KHpoDfTmH4upZdRYEuod4ewXsry1bVWeAOGNIIVBZySSVn5ChTcjNjrmjb6z LzbHBkNCn1jHrAZkDObfKoHzezuPoFq45ruMim8jm1x9gW8HKO4CwZyKvqocmR+J4PBy 4lQv6RDN/oPxOXZTW6h483/u0c9XkLH/GNTTnruILA37Pv2JZcTeOuzRu8sfAOf3Ijy4 6wHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="l/h89rrb"; spf=pass (google.com: domain of linux-kernel+bounces-1404-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1404-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t13-20020a056a00138d00b006b7560385efsi13666842pfg.203.2023.12.15.09.27.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:27:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1404-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="l/h89rrb"; spf=pass (google.com: domain of linux-kernel+bounces-1404-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1404-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AB678B23B1B for ; Fri, 15 Dec 2023 17:25:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7690B5F854; Fri, 15 Dec 2023 17:13:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="l/h89rrb" X-Original-To: linux-kernel@vger.kernel.org Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 04C697EFD1; Fri, 15 Dec 2023 17:12:58 +0000 (UTC) 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 36D41C0007; Fri, 15 Dec 2023 17:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702660377; 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=rrUXd7NMMre9e9Vecy43ZuEpenDqyc3EJP1TkuGFMjo=; b=l/h89rrbsW/zALXQp6FqNJw5mtAVNlftcS9dukzNjVd+27Y4DLheXWDCopsi35mPlHkBrg LEYWTo0zUclI3yD4u/fGwb1KsbqdP3dX3JWTg0kZkPjPwzI2bfBeYBOPLvmGOJY/Ijep+n Vkp99xttWq+PZP7bSMnn3ZIcUTvZk8+EIf7WlJlf9JbvZ4vDVHFf7/XIXbL4OOHS3m2XXz XL6eeKEEx3LWLpX0aOo9yBXtPoBh+499Ig8rt3/6WhdpD/u29TVxV/u/clEzzRNMO/cTlR 1nZQ8kmQpmYp7s06n5nCKgRVyOvZQPMZiwWYdPlGSmq9yAC8G7aPAq/iqGGXcA== 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?= Subject: [PATCH net-next v4 12/13] net: ethtool: strset: Allow querying phy stats by index Date: Fri, 15 Dec 2023 18:12:34 +0100 Message-ID: <20231215171237.1152563-13-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231215171237.1152563-1-maxime.chevallier@bootlin.com> References: <20231215171237.1152563-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 --- V4: No changes V3: No changes V2: New patch 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.43.0