Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6851689rwb; Mon, 5 Dec 2022 19:38:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf5PFOvNEzz6D5BfMeWo4exTnq98IrD3PbJ8TGP6PI3Fd89F1uReyFly5lPsvS16TmwWZmYM X-Received: by 2002:a05:6402:3210:b0:46c:6f53:6176 with SMTP id g16-20020a056402321000b0046c6f536176mr10278921eda.190.1670297888376; Mon, 05 Dec 2022 19:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670297888; cv=none; d=google.com; s=arc-20160816; b=is9z+2WX9ylsgQojXEMBF5SZk78BDnYAjB33lqmAWvxKq0zQqojxE9pY+ofvKBFq6F Ttr3lbQHgLSZmU6qYxBi+PIeDeAXNp2QKaiXAYmtCMdJW/i+Xlh26k8Nbvxv2UqUbV44 DKpis0zU6gERqOdOAnbbnAH52dSgThXlDSIYwL/EoS/AAxvNb5YipgRmZpB0hPZZn2KX b8JM8W0nxHYjiKhBAxa55a0uQQgYkQAZx0W5Bs8L/WOk+sxznE1o4M38Bk5O0yuKl8kw 8UbE7LOhe275hGOiAoDpNLJ5zUDy89BTbvc82QRjqr5nPyFCYd1pklGKX46diHWb9yCB luqw== 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=knlKMQxu2kigd4KXDxW0Ewl4mzT6NSR6mAtv/z2qQcw=; b=zymkMGfRy7ahdjovdilOd8kX7BlBlwDO+a44DMPvwK3BdwEj9WOawmxqi5jN7P3f0x ImWp6o8WqcjLfghKVgUMlQ0S33MX1oASj/2nNG1TZGAf+yy5lmyt31B0MHddky6ewkE9 CgnXAIVY8hVWt/H6JsY2KsuR+RGWMSGMO3DomxlEQ1jspf//cMm1A+nZdBBC7DEoTBCg xPuMEMghPlCN9MTv+cjFF3xnSuKV6ueDXR0FtPG/v0+BqAfE+wKxcfF6t9iokBD+zRa5 WzuiqkFBnN25FBNlSie0LZV5Jctd0vpi6cuBTl+q0CKEWA0u8wBwEJKSey11l0XXorBt 7vEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=r1DQ7eAP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne1-20020a1709077b8100b00779f8e7ec5bsi14935661ejc.42.2022.12.05.19.37.49; Mon, 05 Dec 2022 19:38:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=r1DQ7eAP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233661AbiLFDEq (ORCPT + 79 others); Mon, 5 Dec 2022 22:04:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbiLFDEo (ORCPT ); Mon, 5 Dec 2022 22:04:44 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92288B486; Mon, 5 Dec 2022 19:04:42 -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=knlKMQxu2kigd4KXDxW0Ewl4mzT6NSR6mAtv/z2qQcw=; b=r1DQ7eAPTdvXGxIH2eFI+ItaLM NWx9JL+5znG2RQGIkm5g/TY1ivfSzB5HjwvkBa5bFJlfqZsez/ARFtXRyqjyH7wd1qQEKrQB9krcc Yx+y84XcercxCnzaHwWewc4lAcsmYpEHkl6Gv0NXeZJcmphmTc9l0qFaQpP2Zt/aZA8s=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1p2OF3-004TRN-Ji; Tue, 06 Dec 2022 04:03:33 +0100 Date: Tue, 6 Dec 2022 04:03:33 +0100 From: Andrew Lunn To: Piergiorgio Beruto Cc: "Russell King (Oracle)" , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Oleksij Rempel Subject: Re: [PATCH v3 net-next 1/4] net/ethtool: add netlink interface for the PLCA RS Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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 > > Also, why do they need to be exported to modules? From what I can see, > > the only user of these functions is phy_device.c, which is part of > > the same module as phy.c where the functions live, meaning that they > > don't need to be exported. > I did this because similar functions in the same file are all exported > to modules (e.g. phy_config_aneg, phy_speed_down, phy_start_cable_test). > Therefore, I assumed the intention was to let modules (maybe out-of-tree > modules?) make use of these functions. If you think we should not do > this, would kindly explain why for example the phy_start_cable_test is > exported? phy_start_cable_test probably should not be exported. I probably got this wrong. At one point, it might of been called directly from net/ethtool/cabletest.c, but not any more. It is now accessed via phy_ethtool_phy_ops. Each kernel module is its own name space. You can only reference something within a kernel module if it is exported. So you will find all the helper functions in phy_device.c which are used by PHY drivers are exported, for example. You need to watch out for circular dependencies between modules, since they are loaded sequentially. PHYs are generally leaves, they depend on phylib and nothing else, so that is simple. The phylib module is loaded first, and then the PHY drivers. But there are more complex scenarios. A built in driver cannot reference a module, that would result in undefined symbols. That is probably what i got wrong with cable tests. I did all my testing with it built in. But phylib can be built as a module. But that then implies the core ethtool code cannot be built in, otherwise you get undefined reference. So it was reworked to reference phylib via phy_ethtool_phy_ops. So as Russell says, if a function is only referenced within a module, there is no need to export it, so keeping the kernel namespace clean. Andrew