From mboxrd@z Thu Jan 1 00:00:00 1970 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 EA03FC54798 for ; Sat, 9 Mar 2024 05:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e6mT4TMlZ+u9CYTqjkzp/2RsLAwePZvGuyeA38bSTFo=; b=qvzhRYiF362Oxu IJ4uQqgPEApnJZ/nRTBO13xKbAAaYqCgMhgmodidoSqcnEg1cRCIef+8G4t933toc7xlrQB0580+c 3vSZuULlnTBxYgVUpf8lWFKw3RBpHU5+6FKAgYLQduxnsiiQt4Bxuyj9Ck31OUitFq8uGAloO/Vks 43UKnI3fbXTqJHGY1l0J/qPM5XoDfWS6PdOtjS+C58LkHL8D1dchKtYG4FRyqPJL9WpPnCRf8ehdq 8aqRW45KACpIBsAHfqE1zFisyMa4tsbZtCX9bMIsRGLnCWY/nR9fAdW/45kRx2yAPFdfHOyDn6gtv GF8GJJd56EkUB1AUr8ZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1riopu-0000000CWA0-38o6; Sat, 09 Mar 2024 05:01:30 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1riopq-0000000CW7h-2tx7 for linux-arm-kernel@lists.infradead.org; Sat, 09 Mar 2024 05:01:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 38A9E60180; Sat, 9 Mar 2024 05:01:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 088EAC433C7; Sat, 9 Mar 2024 05:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709960482; bh=M8WzXsIw4eiekdfMBQOV1EE+w+xXtWIPGcGgOy2XVZg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eGvsp2445SIEWJOB/eilitOYMaKkKywyIDgLixJUdT9E71GLyD3ftl0yqD7um3gIs IEdJcdDrE7XBkzO5j1FC2Jy4iqLuUP+nBzeYhg23mAxJV4OoiBqit7Zy1NdS76kmR7 GDEXg0kQkhVBeBFfyZMhldFtgtlpZjNCXLNuLh2jxeqH6+W/BSidtxspMLy7ENZDYz +zpraxRKLYhUccWA2Mk+4j9SrAmi3bOlEGpK0hGSlIjqkKHUAjnV4kpgkpKJciFzuZ O0uLiBZyZkpcZRgCxhIo+L3jr8GYe0vRpnlTUyanewzZPLcwB4LXiF/D+P0Boib53U cFTbXwcjDg3hQ== Date: Fri, 8 Mar 2024 21:01:21 -0800 From: Jakub Kicinski To: Maxime Chevallier Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?UTF-8?B?S8O2cnk=?= Maincent , Jesse Brandeburg , Jonathan Corbet , Marek =?UTF-8?B?QmVow7pu?= , Piergiorgio Beruto , Oleksij Rempel , =?UTF-8?B?Tmljb2zDsg==?= Veronese , Simon Horman , mwojtas@chromium.org Subject: Re: [PATCH net-next v10 05/13] net: ethtool: Allow passing a phy index for some commands Message-ID: <20240308210121.0c6a33f9@kernel.org> In-Reply-To: <20240304151011.1610175-6-maxime.chevallier@bootlin.com> References: <20240304151011.1610175-1-maxime.chevallier@bootlin.com> <20240304151011.1610175-6-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240308_210126_864004_66A170A5 X-CRM114-Status: GOOD ( 17.91 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 4 Mar 2024 16:10:01 +0100 Maxime Chevallier wrote: > +``ETHTOOL_A_HEADER_PHY_INDEX`` identify the ethernet PHY the message relates to. identifies Ethernet > +As there are numerous commands that are related to PHY configuration, and because > +we can have more than one PHY on the link, the PHY index can be passed in the we can have -> there may be > +request for the commands that needs it. It is however not mandatory, and if it commas around however > +is not passed for commands that target a PHY, the net_device.phydev pointer > +is used, as a fallback that keeps the legacy behaviour. s/ that keeps the legacy behaviour// feels more like a default than legacy TBH > @@ -104,7 +124,7 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info, > /* No validation here, command policy should have a nested policy set > * for the header, therefore validation should have already been done. > */ > - ret = nla_parse_nested(tb, ARRAY_SIZE(ethnl_header_policy) - 1, header, > + ret = nla_parse_nested(tb, ARRAY_SIZE(ethnl_header_policy_phy) - 1, header, > NULL, extack); > if (ret < 0) > return ret; > @@ -145,6 +165,26 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info, > return -EINVAL; > } > > + if (dev) { > + if (tb[ETHTOOL_A_HEADER_PHY_INDEX]) { > + u32 phy_index = nla_get_u32(tb[ETHTOOL_A_HEADER_PHY_INDEX]); > + > + phydev = phy_link_topo_get_phy(dev->link_topo, > + phy_index); > + if (!phydev) { > + NL_SET_ERR_MSG_ATTR(extack, header, > + "no phy matches phy index"); > + return -EINVAL; You can drop the msg, and use ENODEV? Also point at the index, not header: struct nl_attr *phyid; phyid = tb[ETHTOOL_A_HEADER_PHY_INDEX]; phydev = phy_link_topo_get_phy(dev->link_topo, nla_get_u32(phyid)); if (!... NL_SET_ERR_ATTR(extack, phyid); return -ENODEV; > + } > + } else { > + /* If we need a PHY but no phy index is specified, fallback > + * to dev->phydev > + */ > + phydev = dev->phydev; > + } > + } else if (tb[ETHTOOL_A_HEADER_PHY_INDEX]) { NL_SET_ERR_MSG_ATTR("can't target a PHY without a netdev") ... ? just in case someone calls this with _phy policy and no dev required? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel