Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp345221rdh; Thu, 23 Nov 2023 05:41:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTWpnuLJdwCMOeW3bTOeLEAwEJqT1AHGUp/7MJBMedZYSpEKU5DdAJ/VD+7t6KrivPIS0N X-Received: by 2002:a05:6a21:788e:b0:18b:92b1:158c with SMTP id bf14-20020a056a21788e00b0018b92b1158cmr2093197pzc.28.1700746877150; Thu, 23 Nov 2023 05:41:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700746877; cv=none; d=google.com; s=arc-20160816; b=JqXF0m1vyV96APZpnz9vkz9DgNu2LWL1N/+K9pY0z84T913cNpoF7OrT3Ry17aYFH5 yEqZwW3sOWkc8OvAGWPhHWpNmlxix51pvz8JJ0Xw7rFyEQw80pYrfUJXeR9SFYcCGkFF xRCwlmIyw3rKPaX9cDgeT8ZXnsgZ8H0uOVRv/LknI2k4kBRx36HCCjvpyeoe1QJuSsZI cXoMBOkn5ZTIX/jEcH9kCqhpc8OWymWXa66U2PxYCxmmN0apkPBicjMz2AI6+uRu0HOX jUoz97guTIrvjhzoetAPLA/n9KKnkUUTDoAXTE+Ew5tPvLSPu4qXAuPC8jdm7DhKQSLA usZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=aNsWgng4IthX8Dyj2PdimJwFQSUwFngI8Cl8W1jSZbY=; fh=IMYGoU7jS3HaS5iEdQiyiDhnAR9nxxNosD4SnzXeWBc=; b=rcad8mwXHEOVNYJ2RUtXmKXBqlGYq4NWORRRphkq47IR17dt6ESp26NCGza7Vqt1nb YbLKes8uT9XbCtbZHIZcLmSHRzjK/UNl6OUOhx+D8OXqTaESwjbP6gmld/iZTH4mqaml SpX2ZNyPM3u6k1W/Yb+u0frXnJgevhpsZXYRTS79QdNq731KIhz1s5+fJROxYurLPlpJ aWzJADAhX3gLNxsQDuUN44zwz0PP191Hl3fe/On9fU2ZjWTlUIRS+YyK3A2oVGfM/dXt /81BydA0kZh7rSwYH0lAZB66EvE8I4he7toW6HdX881Bx70uovh/BXkefVaqeHihXY0i VyuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XLzvxMc3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id bn21-20020a056a02031500b005b9a467330esi1428045pgb.707.2023.11.23.05.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 05:41:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XLzvxMc3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B4478808753E; Thu, 23 Nov 2023 05:41:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345538AbjKWNkw (ORCPT + 99 others); Thu, 23 Nov 2023 08:40:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345633AbjKWNkp (ORCPT ); Thu, 23 Nov 2023 08:40:45 -0500 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 151D2D42; Thu, 23 Nov 2023 05:40:50 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id A03BB1BF210; Thu, 23 Nov 2023 13:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700746849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aNsWgng4IthX8Dyj2PdimJwFQSUwFngI8Cl8W1jSZbY=; b=XLzvxMc3JyA80XZ7DzFZE1c/zFyrU9gpu/UfROvpF+Y+didEbBGxAASiVYnFOhD4SJ4ioJ oI4+F4Q+dITEq9ItZgKaeUgagzezayOpdaQHHwA6CswlCjApW5djMeUSGuQyDD56RuejtM FWUQufdGb4K+DfcvnvulPNrwWy+BXIRar+/uz4T+nB38Jnqu8PW7QGCOD41Ur/WoEThVs3 /vzwN/rs0Hi4P/R+t0cxm6AkaNKkIM9GxqO4Zc5+ISUPe/453+DF8ljyHJfCHq6V8IOceT LIMkt4PSQy/Qgemzx7pOVlPO8Qum4RmdYFqeOWjG4zfm6o+3/Ux9h6urN/7JfQ== Date: Thu, 23 Nov 2023 14:40:45 +0100 From: Maxime Chevallier To: Andrew Lunn Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, 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 Subject: Re: [RFC PATCH net-next v2 06/10] net: ethtool: Introduce a command to list PHYs on an interface Message-ID: <20231123144045.57574132@device.home> In-Reply-To: <97c04999-c3fe-421e-a8eb-642aff647536@lunn.ch> References: <20231117162323.626979-1-maxime.chevallier@bootlin.com> <20231117162323.626979-7-maxime.chevallier@bootlin.com> <97c04999-c3fe-421e-a8eb-642aff647536@lunn.ch> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-Sasl: maxime.chevallier@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 23 Nov 2023 05:41:14 -0800 (PST) On Tue, 21 Nov 2023 02:40:27 +0100 Andrew Lunn wrote: > > +ethnl_phy_reply_size(const struct ethnl_req_info *req_base, > > + struct netlink_ext_ack *extack) > > +{ > > + struct phy_device_node *pdn; > > + struct phy_device *phydev; > > + struct link_topology *lt; > > + unsigned long index; > > + size_t size; > > + > > + lt = &req_base->dev->link_topo; > > + > > + size = nla_total_size(0); > > + > > + xa_for_each(<->phys, index, pdn) { > > + phydev = pdn->phy; > > + > > + /* ETHTOOL_A_PHY_INDEX */ > > + size += nla_total_size(sizeof(u32)); > > + > > + /* ETHTOOL_A_DRVNAME */ > > + size += nla_total_size(strlen(phydev->drv->name)); > > + > > + /* ETHTOOL_A_NAME */ > > + size += nla_total_size(strlen(dev_name(&phydev->mdio.dev))); > > + > > + /* ETHTOOL_A_PHY_UPSTREAM_TYPE */ > > + size += nla_total_size(sizeof(u8)); > > + > > + /* ETHTOOL_A_PHY_ID */ > > + size += nla_total_size(sizeof(u32)); > > + > > + if (phy_on_sfp(phydev)) { > > + /* ETHTOOL_A_PHY_UPSTREAM_SFP_NAME */ > > + if (sfp_get_name(pdn->parent_sfp_bus)) > > + size += nla_total_size(strlen(sfp_get_name(pdn->parent_sfp_bus))); > > Have you tried a modular build? Now that you mention it, no. I did try with CONFIG_SFP disabled, but not as a module, I'll add it to my test suite. > > sfp_get_name() could be in a module, and then you will get linker > errors. It is all a bit messy calling into phylib from ethtool :-( > > This might actually be the only function you need? If so, its small > enough you can move it into a header as a static inline function. It's the only one indeed, so as add it as a header function then. Thanks, Maxime > Andrew