Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp92208rdf; Mon, 20 Nov 2023 17:40:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPg/iIXHcPTed5lCMR47eroeFDlKDGYkt3YoM5Qcm4RwS4/bXddi297u7axEWFT86WuSK/ X-Received: by 2002:a05:6a20:5b1a:b0:18a:be:9ce2 with SMTP id kl26-20020a056a205b1a00b0018a00be9ce2mr6492299pzb.38.1700530852564; Mon, 20 Nov 2023 17:40:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700530852; cv=none; d=google.com; s=arc-20160816; b=pi1XBStWpos7s8vfzHB/wHNQyF5fwd8q7KtDvlLUHsVUBzeX1+qvID6WWtgOTDud/m 40Zsr3VOIm9VSAOleee6HYTtr9xlcIG0z0OOQbcRwfwmYpE6pp+B3zzhaOc4ewniqrqc rVgBfJDmwWY8z2V10pooQTd4TrZv3QSiPIlxedDXmycRa/YCqYB+qmQGeUcZfA73yWCp yFT9zA4brFmpmXENUChWVfXcBZlNrcKR1EfB6UVIFRP7z0o4fDyp/uwni4EVOW0PDmT2 5W8k5QTonYPAfsU6l2jfCAeAyueLwAnENJ4vsZEHr2a2TxFtI8KfdoA7MDOk31w1/K1Y 2O/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=B1fysf3cQN9x0q/P/x3cZ79es+bupCMawmDAJDJfJlI=; fh=C0TfBJhgfV5KqzbS/KnZmKykOYUXFy9xkb3FDuNAbrk=; b=RGeo3EDbNp3RQv95e8VzBAPf7ZmdOhwOI8ZhRNIMjjAeeB4RNbUZhQ3ZIRAYhhnVAg RX3yz3hkPniCt+NZe4KxsibkcrHmf/Pm662IDoKJJj4Er5YSg5ZAwJXHskFOJn8l+v28 fSk8jVB9WQlNnEyz9jLJ/gYek030xaapDYuMUDNUuiHsjtr/6D7uggO8X/PAiOwXdcZC 7etroU30iL/1RP2+pdq0c0jqWbqj59o1805H4tmaClgJETRs8UmCBLj/sKrChDKpyzuD +vU9aPhrq32ZFkQIKNw/0VcjGR/3vDbAqVwmDGL8ffLuRk1TBijL9DV+GQ6SNUAqW26n FCjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=nDw1mAFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f9-20020a170902ce8900b001cf652d73fdsi2356199plg.284.2023.11.20.17.40.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 17:40:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=nDw1mAFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AAD7980D8F53; Mon, 20 Nov 2023 17:40:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232876AbjKUBkf (ORCPT + 99 others); Mon, 20 Nov 2023 20:40:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbjKUBke (ORCPT ); Mon, 20 Nov 2023 20:40:34 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2803BC3; Mon, 20 Nov 2023 17:40:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=B1fysf3cQN9x0q/P/x3cZ79es+bupCMawmDAJDJfJlI=; b=nDw1mAFC5u95hiHGnudwGD3Gx7 v1RB7Bv9HM615M9UbexMDjUOx+YSJsVvqRL8STd5OwddAbtJVqV9+IhxO7ZnmgfCrlSxIKITVtrLi s09gXa/hPlqgXszeuyMNFPCxW4O0dYh0PwBl932MrI95mKWQZpzl6NzhgnmCmogC8kV4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1r5FkZ-000i8t-O3; Tue, 21 Nov 2023 02:40:27 +0100 Date: Tue, 21 Nov 2023 02:40:27 +0100 From: Andrew Lunn To: Maxime Chevallier 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 , =?iso-8859-1?Q?K=F6ry?= 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: <97c04999-c3fe-421e-a8eb-642aff647536@lunn.ch> References: <20231117162323.626979-1-maxime.chevallier@bootlin.com> <20231117162323.626979-7-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231117162323.626979-7-maxime.chevallier@bootlin.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 17:40:50 -0800 (PST) > +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? 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. Andrew