Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp365435rdh; Tue, 19 Dec 2023 00:57:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLiESNlRbSOuUNu2opazAQFrgZWbcRvzBiO+gKK2GqbSeRwtxocerVgvf/BtwMPap4h13n X-Received: by 2002:a05:6402:2051:b0:54c:5f17:1163 with SMTP id bc17-20020a056402205100b0054c5f171163mr9152032edb.58.1702976275868; Tue, 19 Dec 2023 00:57:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702976275; cv=none; d=google.com; s=arc-20160816; b=IrOB9Mlt39G13BFXAaTFpJ4VD75z0D+bmUq3NPejLkP/O1qCv9fyT7iqMl6bC4TPKt pbFUSI2sMAtE2JZogxDo8qbtzay1qLfezIONZhy1nt2Ls8i+iXAxvxZSOvtT6FXdJYmF VWdrAQvcHxe+QTx9YEtjA2qUVYKU0mjAxL08OhOxooDO+qg5iDyUwfPU7eACVrGv1uKP WWAx8i5XGSG3zETbDjJEME21AL7kC3ATRnf+USNT3EDXtM/OLVlgGh+ZnGEs9/mLy4j5 y0hthw8VTyJf0yNdYWLkqe4avrbV2dxXcXm7PmNPL2W7Kgo2A94tVcdFTxhRHTZru5YO bOCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=O6kKRxAEMf9r8V0Buts42FnZW/tY03H7B8kDUM8Pb4o=; fh=45bi2tkHiIxkR4AeeXs4jT/AokC/uWZabNA35zm/75w=; b=JBZ8DoZtvjivCqapKurcC+OQbex2mq7AdHJYUM02O7W/veC65YBkRotimy/cyL3cM8 isTOpGKO6UpEsEkFJ1I39Ic/UpUKo8dH+KRlVVxuVXtBaqphn2Z69kUrVfkZsMNd2Hc8 g7BObqmmDNhdT5z0k56Suwg1aD9NuniJ1FW9XvGQ+8lZCNF6bWa+XE/nY0/t+CoEvzuX ZgJdYvhKtzyNMjwFNmL8EUjDbQJJJVASfsIAwJIJdNTKP+6iFR+Q92OyDVqHfE3zkMAK DNSFCxmk4bPduNXl8hL/sk6kyvI4YrzyIN34jOrDlIu62Em8S/rO6m+l+LUzquVism2R JhZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hNntwxVd; spf=pass (google.com: domain of linux-kernel+bounces-4929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bd4-20020a056402206400b0055353fb5644si1426551edb.488.2023.12.19.00.57.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 00:57:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hNntwxVd; spf=pass (google.com: domain of linux-kernel+bounces-4929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id A045A1F23946 for ; Tue, 19 Dec 2023 08:57:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9281A134CE; Tue, 19 Dec 2023 08:57:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hNntwxVd" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.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 C156E134B2; Tue, 19 Dec 2023 08:57:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D49CAC433C7; Tue, 19 Dec 2023 08:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702976254; bh=Qdl2WTOHb4rTUwS9hPDzncPiZEnkbpJEzM85A3gmzoY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hNntwxVdsfrEB7fJ+mBfl5fRUwDuZSaMhdg+6Z0g4/+wp4Wc3XwfudEx4JdcLfO16 Mld/NrcEPGDK+Hu7SRevyZCr7gZGAPB1e3HSvMpW3SkrGW5R8SD48RgKcD9KqAsQgw sEVKEsxp/aAGCWqASiwnW7CU6oDYK5jrN661HMTohdO+NDs4FwecRk4t7RDNTpRk9G OogsU38OtIc8qsyAcec7Y03IBJyrUyX46+We9bQbEOYDFyZSE7yOlxtsqZECb6POwg +n+unclTpiSz7n1RCfXlAcj0g9vvC+zIyTV9aEWXOqVV+RdCGIuAlZ1Au7ilG/ydHd TprBpLr7klKhw== Date: Tue, 19 Dec 2023 08:55:57 +0000 From: Simon Horman To: Maxime Chevallier Cc: davem@davemloft.net, 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?B?S8O2cnk=?= Maincent , Jesse Brandeburg , Jonathan Corbet , Marek =?utf-8?B?QmVow7pu?= , Piergiorgio Beruto , Oleksij Rempel , =?utf-8?Q?Nicol=C3=B2?= Veronese Subject: Re: [PATCH net-next v4 07/13] net: ethtool: Introduce a command to list PHYs on an interface Message-ID: <20231219085557.GB811967@kernel.org> References: <20231215171237.1152563-1-maxime.chevallier@bootlin.com> <20231215171237.1152563-8-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231215171237.1152563-8-maxime.chevallier@bootlin.com> On Fri, Dec 15, 2023 at 06:12:29PM +0100, Maxime Chevallier wrote: > As we have the ability to track the PHYs connected to a net_device > through the link_topology, we can expose this list to userspace. This > allows userspace to use these identifiers for phy-specific commands and > take the decision of which PHY to target by knowing the link topology. > > Add PHY_GET and PHY_DUMP, which can be a filtered DUMP operation to list > devices on only one interface. > > Signed-off-by: Maxime Chevallier Hi Maxime, some minor feedback from my side. > +static int ethnl_phy_parse_request(struct ethnl_req_info *req_base, > + struct nlattr **tb) > +{ > + struct phy_req_info *req_info = PHY_REQINFO(req_base); > + struct phy_link_topology *topo = &req_base->dev->link_topo; > + struct phy_device_node *pdn; nit: Please consider arranging local variables in reverse xmas tree order - longest line to shortest. > + > + if (!req_base->phydev) > + return 0; > + > + pdn = xa_load(&topo->phys, req_base->phydev->phyindex); > + memcpy(&req_info->pdn, pdn, sizeof(*pdn)); > + > + return 0; > +} ... > +static int ethnl_phy_dump_one_dev(struct sk_buff *skb, struct net_device *dev, > + struct netlink_callback *cb) > +{ > + struct ethnl_phy_dump_ctx *ctx = (void *)cb->ctx; > + struct phy_req_info *pri = ctx->phy_req_info; > + struct phy_device_node *pdn; > + unsigned long index = 1; > + void *ehdr; > + int ret; > + > + pri->base.dev = dev; > + > + xa_for_each(&dev->link_topo.phys, index, pdn) { > + ehdr = ethnl_dump_put(skb, cb, > + ETHTOOL_MSG_PHY_GET_REPLY); > + if (!ehdr) { > + ret = -EMSGSIZE; > + break; > + } > + > + ret = ethnl_fill_reply_header(skb, dev, > + ETHTOOL_A_PHY_HEADER); > + if (ret < 0) { > + genlmsg_cancel(skb, ehdr); > + break; > + } > + > + memcpy(&pri->pdn, pdn, sizeof(*pdn)); > + ret = ethnl_phy_fill_reply(&pri->base, skb); > + > + genlmsg_end(skb, ehdr); > + } > + > + return ret; I'm unsure if it can happen, but if the loop runs zero times then ret will be used uninitialised here. Flagged by Smatch. > +} ...