Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp3111065rdb; Tue, 13 Feb 2024 07:13:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXCNCFfIFPuF3V1bfIJbpcFBIwJQmVsrvoAaZKpZdI1F0h2wRVQnB2oLM0ABgmOSLN86E2W+7IXRrQMm6uuuNfDymNLgYOsaYvMqOkE3g== X-Google-Smtp-Source: AGHT+IGEte4bkDWjv9pvhuKDsT2zNdpxr/iTtQgs2xJPJow6sp51HtNY1jU7I5OdmaUNa+1BR8V/ X-Received: by 2002:a1f:e402:0:b0:4bd:752b:8d3d with SMTP id b2-20020a1fe402000000b004bd752b8d3dmr4919637vkh.9.1707837210455; Tue, 13 Feb 2024 07:13:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707837210; cv=pass; d=google.com; s=arc-20160816; b=MKlwWHcMeAqPIi9l36SH8EBXASQQE2suFPs4ZnVHjvRPiGsxDyHk90Rk7tBCKQI+oz 6lE9UINJQJwEOFnIkbNVG1Mjs+lzCvkb2huGJ7IkOhS841fcpuNlIZnit6W3vBl5p+au BrBGe21TVl2PpFVewikj++jwmu8tMWPNQl0ePgn27sQNsDiJX9Vx43rzAplZL9AWJT6g 8z2xKohuUlqegwftIggIsQcoMxZyZ9uVsVBWrGy3sq8T3yMjXHAyea2qqwyZDiAVhVl9 bX+4RXsKUz52dbl64rsKecqioQP2ywcWQBDFf/n5TRuGRfW4uOpkk1O9TmBQd6zzLUbe ninA== 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=VpcLvlmRCP8z4hAlqgEJxn9ClN29g/4O7Rm+VP+Hs9w=; fh=R5JKeFq7F4EDPA3T2bJQ6tB4EUEqAuuGcj1Av9QtsqU=; b=gWErlsAGIrXwHruj+kY3IR8/R1MihwvPVSongTw8rEGWA7lSkFZMIdaWqU4JxulG3Y 4XgeVlXhBbE/IaAbWvFr4bDWBd+JHcZZ8i43qDiOX2L+f5Fl/k9BrTGA+gav2NCSJTaS PAW93NDfbP2/RQQmB+FMNeMymunQAzeDs8qa7k/23vXfeYX7rjib3Y5fvhMFHY8fNkgJ A0ph4lzjIdWovhCDWOSHQJgK/2FhNyFeva/LyunwwM9TEiGf/ZvWuB52VTSKrmiEsJQx poMyblQCR1lO0hNem334vO+lC7uLKrO60AOIboOSej0rI5Q7RxU8wDOoVqrE8iMz15Vg C1Sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=X9imBKQN; 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-63777-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63777-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=2; AJvYcCXOlyGIytxmIWD2KR3RIk/cWWtH50C50tBjDc1QtVIgM64cskox8KRJrYxtj4Jl08H6S4h2VMrcG0IKhYEigN56Zl1etp87ZYeNG2xXBQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id di4-20020a056122468400b004c091b1417dsi515337vkb.132.2024.02.13.07.13.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 07:13:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63777-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=X9imBKQN; 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-63777-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63777-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 0F5071C27EEF for ; Tue, 13 Feb 2024 15:10:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D739D60EE9; Tue, 13 Feb 2024 15:04:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="X9imBKQN" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 D18FD60BB7; Tue, 13 Feb 2024 15:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707836695; cv=none; b=DzGF+GfFNr2Y+oGTEglXxwpVN+plWwXI0zzlIBlsXgIQO5+S9cuPYjVJHTupGzbGitqW7NnZerYuiND4y4EyFM4ZUwC4Jr5ypiqurfGyzbAweXh+aJlfS6SVO70CQoFp3lrQlMTCiNtKNjqjihIlN48WQ2ZdIGAcUvesYn1V9VI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707836695; c=relaxed/simple; bh=rn6DALXlDmbDVCt5dynIqvf6ymqJW0h7IDOc9cDX4Ss=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hazxa0DKep2+f/5hwMtE7IGOre4Xi5my/HmaqtiwfYDHpC1AZFDYuT6W3RJ3APBQMvHHwDeBxDCLBmWNbx5C8EqgfsUP6yEBY9nJ7mDSAhKLsPqlI5BC6YFrz3sUIbBhI4HmMbPZZFF4Pc8dS8fZPIL6/fETdoG0vqTU1ceVjWk= 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=X9imBKQN; arc=none smtp.client-ip=217.70.183.201 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 218191BF20E; Tue, 13 Feb 2024 15:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707836692; 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=VpcLvlmRCP8z4hAlqgEJxn9ClN29g/4O7Rm+VP+Hs9w=; b=X9imBKQNLAigr714rynkVDtm/WslD/djWOsUskD+lRqtUxrzGZKe9p9/mNeeBLTi8rpD0X E0jAYdmlU7BeEjcuD97j8QXxd3KXmr6LlTAlyqjci28mF2E3QGok6W/F9APvzD1J/iJB27 sjQozGbaEr5blLZr5gW1hqUAL/vQKJhAt1xHC9ujmcuEaavpZtJm18oPwUloYaSVzWQ7ty WwPuD8h4b1xjQD2f3UazA2Z2Q4yrxO91UBKcFcY6hslFS0OCkLQ6wZNA2WpT/1AzSsddpV llHEmy/oDRBTUKWyDxwqfqo7EQPucvYwWVZEbBZ0T1fSg76gjRLUPXcI6vDFlQ== 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 , mwojtas@chromium.org Subject: [PATCH net-next v7 12/13] net: ethtool: strset: Allow querying phy stats by index Date: Tue, 13 Feb 2024 16:04:29 +0100 Message-ID: <20240213150431.1796171-13-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213150431.1796171-1-maxime.chevallier@bootlin.com> References: <20240213150431.1796171-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 --- V7: No changes 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