Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp294984lqr; Wed, 5 Jun 2024 06:28:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWggWueD8ldWEqn5AERVLbBN2+cV96SjQeYvlFAw0hbBfUpNnyedlTCFq/S0oNduyLshyo2t6E3/qcZnWyRF1RXCH1Cz5mJTdVMRYtdlA== X-Google-Smtp-Source: AGHT+IHgck5TrZLMNjzM1NESscuQjV82E8TSV5RJj7A+wpRNf1O03lMbxBP+GqkQPyRWwoX/adxp X-Received: by 2002:a17:902:d48c:b0:1f6:828e:869b with SMTP id d9443c01a7336-1f6a5a6990fmr36546595ad.53.1717594104400; Wed, 05 Jun 2024 06:28:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717594104; cv=pass; d=google.com; s=arc-20160816; b=IBIgd6BT38TXGEURBgn618tMKGg13bmv665WZ5tqW1+LCNOQydkqkvkimLzFO0hi2o Bcn7c3+lgVwpZfa1oEYdTLhLG92N67JZKLoq01W4QWOfG5lBoCMp63EPF3866lIM1R0+ zFeFtxmAcRgaol8IkEPzTlae9comXAHpB5SOMbjCfWEikBSlJWwZqwLLMmRwOMbFgDi1 U/bCSoT+8bQUWhS3lst/m36XBpNimPwoabQRX5zyfXMqQuYXsTwlWxYtBI1qgLREYz7i /X0w6fRqhl78AvpebZ1hdYAptliKrxyJFXfNiRdjTsw8ggCGsF/4e5/HDfIsHlQndarT n19A== 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=FlCBtrrN4O1NkxVEqf+U2Ke5M/AbKXE1bJWLbBR2omw=; fh=Dinp91LF2KcnzfyOXGg1vCezYXJAYX+8GKPCxLQjq1Q=; b=LjglM5iwi2X8GXSybH8ykJUVgQTjqcaZAJfegdOeVY850LAWW2mrSbcl9CKQIso9nt r+zrOcBuvAX2cqFIofq4QaD67Uf5U9zPrDPr0Anqnnw/bq8yNJasX0T7+I0cKRpbPBuV Up05DESlS4r0yvp7MbdRTe6DFs6Vpn3KVnye+21JygaV77ES0P45nHpeMyJRimVZPYL1 KbjEOgSAKZn/VNJiIBloBrpTb5ljjKfEZjzzHe+ucjzhsfQMsf2Ze0VJa1dnqXwugC7J /Ayu96inAjW4imrSTPNMuKTAuSyKCKSarnQCtnLrz6wPiwqyjcwdY/Tliz+CpJyncLCD 1Odg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=gnQ7LPNL; 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-202655-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f6323eb417si2111775ad.384.2024.06.05.06.28.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 06:28:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202655-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=gnQ7LPNL; 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-202655-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202655-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 02D3C2983C0 for ; Wed, 5 Jun 2024 13:28:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3C811C6173; Wed, 5 Jun 2024 12:49:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="gnQ7LPNL" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 EB1E81C5386; Wed, 5 Jun 2024 12:49:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717591787; cv=none; b=iKNCySyRKKaVyd+8EXHFqTePqbf1O1o5XKKoD10IuNLuLU5ZhjlStwQRcViDOQ9GNdyzwchKqHhzqQZfQ+nMx3lKj5Qf50WweLDt1CX69/P1B8zGZQtJZOs8EbnSCjfoLahS5LSgMkFDytAsYNLTvUcbA2ZJ5XKsF+1AzITE2B4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717591787; c=relaxed/simple; bh=jwu/j/bium2nmY7xxsHmU/royhIK1ofwZ/phXeBLl94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tbgjt1UYHuy737RuXfMK71XpPQqrJWn4FkQSEFWwQwUZE/4YM6jcVt4zywC1CsBXUOtl2AoNcEMEq1PzRnLUzDEw/PPZzgTjQQ8P/ytC6FaqxsvTYeAqMJXK0ErTi7tOu/nUIImt1ppcFXVxcxvSqEAHZA39BCjg3HNYecKK27U= 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=gnQ7LPNL; arc=none smtp.client-ip=217.70.183.200 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 C1EA320014; Wed, 5 Jun 2024 12:49:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1717591784; 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=FlCBtrrN4O1NkxVEqf+U2Ke5M/AbKXE1bJWLbBR2omw=; b=gnQ7LPNL6FiMIun1JlIX9IZ2fc7Iz0PJdcEEGUuXDa9JX2JkeEc3H7jZgDYnJSrR9uP/t2 NdEwfDi6SJ2h9rMe1gH+A33hk4LWTjBc/72dbzfgT03BW7PIjjoGkTXaYxcVjHR/u3u11I tuap/znSSXEVCwIjGZ3uv7h7Om5LV+haTcmW/yIWovYdAtndQwku8KesdC7Ev+bACSG2l0 XmZuVdPPcflPa5FOE94Zn2Ht4rlxm2Kr3Vy6RqIDn8LTt2r1F/Tcs9Nk2Oq28xRnwn+3QC rzqkWvibuM+s+DgKsDwQxjD2T34D/MToOuJTLdHoR/6JLnL09w+sJrDcQ39NJw== 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 , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?UTF-8?q?Nicol=C3=B2=20Veronese?= , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart Subject: [PATCH net-next v12 12/13] net: ethtool: strset: Allow querying phy stats by index Date: Wed, 5 Jun 2024 14:49:17 +0200 Message-ID: <20240605124920.720690-13-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240605124920.720690-1-maxime.chevallier@bootlin.com> References: <20240605124920.720690-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 Reviewed-by: Andrew Lunn --- 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.45.1