From patchwork Wed Aug 21 15:10:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13771768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B6ADC52D6F for ; Wed, 21 Aug 2024 15:17:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5gwqbj98vuyM7J95UWGmzg8cn+b44rPUXY5HHwKHfQ4=; b=kfjX5v/giI1qvggOuRAtTb744U lbLWTPLUAP8HxyD0Rt6MQzKRJ92dh64lZ+ANZeRvTA8x4syE50xkAHQJ1fjqB5WqsD3gfLBeHjTC1 7WaDmDSxHdZIS6BuFMRiWqTNF2ZA8Z5V+n8ejjJrK3YgbEDKpGk7ouo6jMWT6l+hBatykXzBmuXft s9hnQsuE2+jqTeypVcy4YAWfL/njl9GmaHlX6HCGlgXmsGgyzr7CJyRA0lypwPjzMzF0ZVLVFOBSR M9B807zS3NA77/1+Ioy3Nnp828Dz8AVU1Aixfx6mWse0jbppZSblWZG114mx4FJfWKu+VYm0vEFnT HXhVdzng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgn5W-00000009Sul-0rs6; Wed, 21 Aug 2024 15:17:30 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgmyl-00000009RDI-0wLU for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 15:10:32 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 419D540004; Wed, 21 Aug 2024 15:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724253029; 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=5gwqbj98vuyM7J95UWGmzg8cn+b44rPUXY5HHwKHfQ4=; b=To+OO1+6j5svzpn8SVwXehDH93r9mZdjzNw5PEHBiCtQS5+oa7AdDTwR6GRSxYfZzlCq1J dBedBn6g+bkpkqYyLS1R7KyFbuCbVhDtArFHL0Nl1jtnWoIAlz0VtwpmZCriUskrxsZIUR t8heJfEif66LRtwNokQgMdF0TIf891qBt2JlIvahe4X8hrU07xtamY7vuKAVQHNSUQ3jbA rK+fWq1IgU/uxe7Pwp8RiMshGTqaPxkcEuGcAZu/C9uE38nxwRxVB61a2X8fCGbqrf3MiE Pg2sPrHeSs5Ji7rRlXDlltpodOhm+zXht3Fdl1MB0GCLnRf51VF4ofAGWejsHw== 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_Maincent?= , Jesse Brandeburg , =?utf-8?q?Marek_Beh=C3=BAn?= , Piergiorgio Beruto , Oleksij Rempel , =?utf-8?q?Nicol=C3=B2_Veronese?= , Simon Horman , mwojtas@chromium.org, Nathan Chancellor , Antoine Tenart , Marc Kleine-Budde , Dan Carpenter , Romain Gantois Subject: [PATCH net-next v18 09/13] net: ethtool: plca: Target the command to the requested PHY Date: Wed, 21 Aug 2024 17:10:03 +0200 Message-ID: <20240821151009.1681151-10-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240821151009.1681151-1-maxime.chevallier@bootlin.com> References: <20240821151009.1681151-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_081031_548729_E0D3CF29 X-CRM114-Status: GOOD ( 14.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org PLCA is a PHY-specific command. Instead of targeting the command towards dev->phydev, use the request to pick the targeted PHY. Signed-off-by: Maxime Chevallier Reviewed-by: Christophe Leroy Tested-by: Christophe Leroy --- net/ethtool/plca.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/net/ethtool/plca.c b/net/ethtool/plca.c index b1e2e3b5027f..d95d92f173a6 100644 --- a/net/ethtool/plca.c +++ b/net/ethtool/plca.c @@ -25,7 +25,7 @@ struct plca_reply_data { const struct nla_policy ethnl_plca_get_cfg_policy[] = { [ETHTOOL_A_PLCA_HEADER] = - NLA_POLICY_NESTED(ethnl_header_policy), + NLA_POLICY_NESTED(ethnl_header_policy_phy), }; static void plca_update_sint(int *dst, struct nlattr **tb, u32 attrid, @@ -58,10 +58,14 @@ static int plca_get_cfg_prepare_data(const struct ethnl_req_info *req_base, struct plca_reply_data *data = PLCA_REPDATA(reply_base); struct net_device *dev = reply_base->dev; const struct ethtool_phy_ops *ops; + struct nlattr **tb = info->attrs; + struct phy_device *phydev; int ret; + phydev = ethnl_req_get_phydev(req_base, tb[ETHTOOL_A_PLCA_HEADER], + info->extack); // check that the PHY device is available and connected - if (!dev->phydev) { + if (IS_ERR_OR_NULL(phydev)) { ret = -EOPNOTSUPP; goto out; } @@ -80,7 +84,7 @@ static int plca_get_cfg_prepare_data(const struct ethnl_req_info *req_base, memset(&data->plca_cfg, 0xff, sizeof_field(struct plca_reply_data, plca_cfg)); - ret = ops->get_plca_cfg(dev->phydev, &data->plca_cfg); + ret = ops->get_plca_cfg(phydev, &data->plca_cfg); ethnl_ops_complete(dev); out: @@ -129,7 +133,7 @@ static int plca_get_cfg_fill_reply(struct sk_buff *skb, const struct nla_policy ethnl_plca_set_cfg_policy[] = { [ETHTOOL_A_PLCA_HEADER] = - NLA_POLICY_NESTED(ethnl_header_policy), + NLA_POLICY_NESTED(ethnl_header_policy_phy), [ETHTOOL_A_PLCA_ENABLED] = NLA_POLICY_MAX(NLA_U8, 1), [ETHTOOL_A_PLCA_NODE_ID] = NLA_POLICY_MAX(NLA_U32, 255), [ETHTOOL_A_PLCA_NODE_CNT] = NLA_POLICY_RANGE(NLA_U32, 1, 255), @@ -141,15 +145,17 @@ const struct nla_policy ethnl_plca_set_cfg_policy[] = { static int ethnl_set_plca(struct ethnl_req_info *req_info, struct genl_info *info) { - struct net_device *dev = req_info->dev; const struct ethtool_phy_ops *ops; struct nlattr **tb = info->attrs; struct phy_plca_cfg plca_cfg; + struct phy_device *phydev; bool mod = false; int ret; + phydev = ethnl_req_get_phydev(req_info, tb[ETHTOOL_A_PLCA_HEADER], + info->extack); // check that the PHY device is available and connected - if (!dev->phydev) + if (IS_ERR_OR_NULL(phydev)) return -EOPNOTSUPP; ops = ethtool_phy_ops; @@ -168,7 +174,7 @@ ethnl_set_plca(struct ethnl_req_info *req_info, struct genl_info *info) if (!mod) return 0; - ret = ops->set_plca_cfg(dev->phydev, &plca_cfg, info->extack); + ret = ops->set_plca_cfg(phydev, &plca_cfg, info->extack); return ret < 0 ? ret : 1; } @@ -191,7 +197,7 @@ const struct ethnl_request_ops ethnl_plca_cfg_request_ops = { const struct nla_policy ethnl_plca_get_status_policy[] = { [ETHTOOL_A_PLCA_HEADER] = - NLA_POLICY_NESTED(ethnl_header_policy), + NLA_POLICY_NESTED(ethnl_header_policy_phy), }; static int plca_get_status_prepare_data(const struct ethnl_req_info *req_base, @@ -201,10 +207,14 @@ static int plca_get_status_prepare_data(const struct ethnl_req_info *req_base, struct plca_reply_data *data = PLCA_REPDATA(reply_base); struct net_device *dev = reply_base->dev; const struct ethtool_phy_ops *ops; + struct nlattr **tb = info->attrs; + struct phy_device *phydev; int ret; + phydev = ethnl_req_get_phydev(req_base, tb[ETHTOOL_A_PLCA_HEADER], + info->extack); // check that the PHY device is available and connected - if (!dev->phydev) { + if (IS_ERR_OR_NULL(phydev)) { ret = -EOPNOTSUPP; goto out; } @@ -223,7 +233,7 @@ static int plca_get_status_prepare_data(const struct ethnl_req_info *req_base, memset(&data->plca_st, 0xff, sizeof_field(struct plca_reply_data, plca_st)); - ret = ops->get_plca_status(dev->phydev, &data->plca_st); + ret = ops->get_plca_status(phydev, &data->plca_st); ethnl_ops_complete(dev); out: return ret;