Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp151696lqe; Thu, 4 Apr 2024 02:34:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8mPDk3C2md9BEo/GT6mxapBlXBKQt9zjX4ymnwAZsCePisLKtgNnDBwQeg1Ev9Ilq6QyX3GfVPEqTd7xGBIpQqqek1RzBJ5bGjL7P/g== X-Google-Smtp-Source: AGHT+IHUStBFksaapEUr03yYVsR60TXTm4/GocBRDLvBnm6QCgMwXEnt7tWIMebvh5I7trhRSFwM X-Received: by 2002:ae9:ec03:0:b0:788:3101:b1f0 with SMTP id h3-20020ae9ec03000000b007883101b1f0mr1651771qkg.64.1712223264498; Thu, 04 Apr 2024 02:34:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712223264; cv=pass; d=google.com; s=arc-20160816; b=AjrhD9tBk22je78gc1TsRnwTAtmka17P+4jFbJ7sbzhG2ghNoZ/91J0fXdqJjosRbZ hVscz17Gfrs9fXTEqvf1qfyXk7DQvGlv9UovVMg6rJ14bkguej8rJM4uGSq+dN8RdIjx td0Gqb1WBYe0mRAEuz/07pdmgq7KeH+LDahUMUn14S738jpdKkRUFJucRmoubTe/jAh/ 9+TzCJC7TiVVkazySthcLRLjAxffZJwpuYq9z1OTL2f4Pt63Omo4qcaoZMdNgtcFcEAP 9VeL24qJIfXws1OarnMboP8NIJUo2roGM4q+HeuE4NRhNsCxa36IF3hK/rF18FT1vICj 2ddw== 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=UBh2km2hezKBa4wXxj5pMCZ+qwNiT09vuk1hI4HqVJ4=; fh=1vUu/d1GTjraph6G+ET+Z0z13QVrf6oL/IrrK9zaTF8=; b=QkvxdSV7Ed4xusch7qseGxUVpFpwIen4Frz1CAEitw6Eeuxw75XQK9nbwkKr3kePRw b5gPtkongFxa6X4DcNQJcqzifTS72SbPhlx0Y5GBDdM1MFa10OZoBjNKmec8CQPzbsck mfKwfFyEEew2j1bVxPwcv+UkaXxOT0LMb1Ry9tqifrk1Lb5tbwpYAGdYnnSAXfa/X9ag Ecu7LNOuFtuxf5EaUj0umAYsT1XGscMJxnSHeEkVoDPGepsg62Cvd6xvQnwMG/UbmF/g nzHQkgpJ5xJe7RpMbj6e44iVB2S+uVGc4XBOp+WN5V/4OEbZt0OdAS6Xf/e1inkuV7XS cVuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=EFX54zPf; 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-131183-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131183-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o24-20020a05620a0d5800b00789c6c92980si16071425qkl.504.2024.04.04.02.34.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 02:34:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131183-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=EFX54zPf; 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-131183-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131183-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 3821D1C26612 for ; Thu, 4 Apr 2024 09:34:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8249612837E; Thu, 4 Apr 2024 09:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="EFX54zPf" 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 6334286630; Thu, 4 Apr 2024 09:30:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712223029; cv=none; b=tUgWStEZSoXBWAsVBXWQiTL9Aame0WkwLVy+sXmui/WtUNrzfeAdixfM7rtPJxiVnCUb5Vp8K+S35p6cfqawcX3MmlzBtYbJLaPqgrhh1wSsian6P02UTnu9a9DWDUUjA50xIJPBYBAipTl2xVvKAVSYiPTMVBdB//+I/DfXIIU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712223029; c=relaxed/simple; bh=B5E3X79JB1ZKEKuI6M5OF+gwSTLtivEtiGnGkNmemQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bb7Dmq+ayRFsP1ARg8BWAX/QavE52FxNX0bfUj2lyDdgbP2kT7EFvQERe5fMFFxAP73UELiVhcnJP0yI0pAPwSggh5fvPTxtOGb4yapUWTlCLgMJOXEb5ZLfgMh/ajmeIgwmqnCH/ykjimqeb2OYnlD97Qppt2+zFBk0WmdWdMk= 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=EFX54zPf; arc=none smtp.client-ip=217.70.183.198 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 A86D1C0005; Thu, 4 Apr 2024 09:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712223024; 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=UBh2km2hezKBa4wXxj5pMCZ+qwNiT09vuk1hI4HqVJ4=; b=EFX54zPfX/U0KMzr4qSxmruuvNxCmFt2X2XzkBazDeQX19QJndRk+UWTADS9o3XTPJQ3dE whCjcor4h7dmYw92PB2bN9+8Ep+zZKAXFPgbi1SUybAGcHafZ20YJjjA/iDferTa/EpH/S I1D+2lluLGFWhuNPXn5WeBngRBLWcMUJYSGCQr6JMVaqW584fWspzc+MAZftE/ZISPI/jJ f80R+/75ON890KIpyvRYJKEgIBquE9ASjRX0U9zs4nv3lyC1oFewGTNpbTKYEh2wyt7TBZ rfjHzBtDfJG6vZ1VH7qDDaLNR1gprF+YaHKbMJqE5NDiltHDTLxQsgjiI6OXpw== 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 v11 12/13] net: ethtool: strset: Allow querying phy stats by index Date: Thu, 4 Apr 2024 11:30:02 +0200 Message-ID: <20240404093004.2552221-13-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404093004.2552221-1-maxime.chevallier@bootlin.com> References: <20240404093004.2552221-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 --- V11: No changes V10: No changes V9: No changes V8: No changes 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.44.0