Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1374932pxb; Fri, 22 Jan 2021 14:13:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMdMi15v8k+/UmNmxgtgnkMGFiwQMQRc/memP/iAX3P51XKGGzcFnlqhjGHMZNVDcWOAWI X-Received: by 2002:a05:6402:4310:: with SMTP id m16mr4903275edc.207.1611353596383; Fri, 22 Jan 2021 14:13:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611353596; cv=none; d=google.com; s=arc-20160816; b=x96dJctZDSOi50MLFX/9XlyXIHuQa0uRL0PKzTLSUrp71BVkerSp7MJq83VKKABW5s JaGdmqVP/uVGgQeShBxW5zuqgtbNzXOqpuNVLputN7I07v03gvKVWyP5qzgVLFLLc/6S MeQaGN6TW3fwYN1KMsrj93HJu30H5AkiVbzVcg1p+ssargXQQnFfA9MeQdbYHvy5a3aS 0OpDp5Yef3g+Xby6l/8YMzsDKvQOzdT4B9o0zl5D625xo8GfkG6T7o7Arj+UDl2ZVwRK IBce5H9dtCK9X9y7+0GjGtk2d7+qo0hUu0HBcvcNpBROsD/dB+l+1jlQu1r6NKr6aAq1 jWEQ== 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; bh=sZuc0QBCY34CEW0qwH6I9hOm8D0BxjDK80kdpI8feOQ=; b=hhOQ6yiz/MawZ+qurIGmCybBdmTMbOrmwbXmeXaHPW4khypg7ouGrsIHSeMzZ0j2g4 9YQfMSvCZvs7tBcEBCB8k/a0E7FAHFbQiDAlQFpaHMvXErGTHGinXXmCTi2oaogXKCY3 b5l1xQ2ll6mE6V7WKPlRp/3MMQTwBhlLbGT9H9mTxP6+Q/eRAk3Kmg2pmWVyfp3XPe+/ j9Z8O8r7uHbImzRvLHfr+VLGIk7AoZa18V0C2dFqJyc4jNQClghf97j9Aq6fqWNntPSQ DQLIoDkKMip+WYl2D/5VpgHYfQ/e5wPCe5oSzHI3q8B2/VBG3Drt4L5eKOEDulOQNjnJ R7cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si3642138edd.595.2021.01.22.14.12.52; Fri, 22 Jan 2021 14:13:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730265AbhAVWL6 (ORCPT + 99 others); Fri, 22 Jan 2021 17:11:58 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:55214 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729912AbhAVWJT (ORCPT ); Fri, 22 Jan 2021 17:09:19 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1l34b5-0029Gh-PB; Fri, 22 Jan 2021 23:08:03 +0100 Date: Fri, 22 Jan 2021 23:08:03 +0100 From: Andrew Lunn To: Sergej Bauer Cc: netdev@vger.kernel.org, f.fainelli@gmail.com, "David S. Miller" , Jakub Kicinski , Bryan Whitehead , UNGLinuxDriver@microchip.com, Simon Horman , Mark Einon , Madalin Bucur , Arnd Bergmann , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] lan743x: add virtual PHY for PHY-less devices Message-ID: References: <20210122214247.6536-1-sbauer@blackbox.su> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210122214247.6536-1-sbauer@blackbox.su> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 23, 2021 at 12:42:41AM +0300, Sergej Bauer wrote: > From: sbauer@blackbox.su > > v1->v2: > switch to using of fixed_phy as was suggested by Andrew and Florian > also features-related parts are removed This is not using fixed_phy, at least not in the normal way. Take a look at bgmac_phy_connect_direct() for example. Call fixed_phy_register(), and then phy_connect_direct() with the phydev. End of story. Done. > +int lan743x_set_link_ksettings(struct net_device *netdev, > + const struct ethtool_link_ksettings *cmd) > +{ > + if (!netdev->phydev) > + return -ENETDOWN; > + > + return phy_is_pseudo_fixed_link(netdev->phydev) ? > + lan743x_set_virtual_link_ksettings(netdev, cmd) > + : phy_ethtool_set_link_ksettings(netdev, cmd); > +} There should not be any need to do something different. The whole point of fixed_phy is it looks like a PHY. So calling phy_ethtool_set_link_ksettings() should work, nothing special needed. > @@ -1000,8 +1005,10 @@ static void lan743x_phy_close(struct lan743x_adapter *adapter) > struct net_device *netdev = adapter->netdev; > > phy_stop(netdev->phydev); > - phy_disconnect(netdev->phydev); > - netdev->phydev = NULL; > + if (phy_is_pseudo_fixed_link(netdev->phydev)) > + lan743x_virtual_phy_disconnect(netdev->phydev); > + else > + phy_disconnect(netdev->phydev); phy_disconnect() should work. You might want to call fixed_phy_unregister() afterwards, so you do not leak memory. > + if (phy_is_pseudo_fixed_link(phydev)) { > + ret = phy_connect_direct(netdev, phydev, > + lan743x_virtual_phy_status_change, > + PHY_INTERFACE_MODE_MII); > + } else { > + ret = phy_connect_direct(netdev, phydev, > + lan743x_phy_link_status_change, There should not be any need for a special link change callback. lan743x_phy_link_status_change() should work fine, the MAC should have no idea it is using a fixed_phy. > + PHY_INTERFACE_MODE_GMII); > + } > + > if (ret) > goto return_error; > } > @@ -1031,6 +1049,15 @@ static int lan743x_phy_open(struct lan743x_adapter *adapter) > /* MAC doesn't support 1000T Half */ > phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT); > > + if (phy_is_pseudo_fixed_link(phydev)) { > + phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_TP_BIT); > + linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, > + phydev->supported); > + linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, > + phydev->supported); > + phy_advertise_supported(phydev); > + } The fixed PHY driver will set these bits depending on the speed it has been configured for. No need to change them. The MAC should also not care if it is TP, AUI, Fibre or smoke signals. Andrew