Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4321400pxb; Tue, 26 Jan 2021 19:33:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJybBhjxI4Zo5XVUsoLmP6leX/MXCBA0Jz1qFqBGuxGYZBNhSnHwhgRqK5efjrmdj4ICuL4q X-Received: by 2002:a50:f0cc:: with SMTP id a12mr7224074edm.219.1611718426182; Tue, 26 Jan 2021 19:33:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611718426; cv=none; d=google.com; s=arc-20160816; b=dKuIGCGmCimySTSQDSYK3ueZuZ5YIC7X+30LFBq7e64xdhAOI4VyS+koe2SdM5AEvS 26eKhhChA5tki0K0/HwW3uXIDCpepYw8DhlziG+Q6lp45ZZeCe8niJESHaeg/7IYKeSX bHjdIerl/bnAG246ZXSQVepl0X9LpYIDmGx8cdyE7Fk3AYXJNCh1/R9OrPaoAcCHlGCS scbFmRPOOUzyWsJMvDsgbE/TzZTKC4OMuEeJr+jv3ApxJfXRGPtltRrYtTUKy9qFazPB 2cvS2x7NlyDQtZvNDooHmzyEIRY4PPyDrznzKK7f3+KotRe665EDWL5ril1IVHJs0Sna QDDw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M5T8IVEuH9uBT6rA34kAGJxS5Tq8grPx+kUaZQ66ui0=; b=YyLMuJfNmoaFHPty0khG5L+LMNdGRmFAxnItm6p+QuIbCeeS+ZnOTSAz4NcsVVF104 J022BBnMeVaE2ZYU7713RXfQOSdZQTcFI3dNnefL6c78aJqgu14UgAsKLP9zgebBWn8v /ZnOJ12vUcSnEUqShdwkTW0RKLjw/L22+xmXgcDll9a+YgnOgDfdlAPZg03MH7xAAQWT FCnZVYaurSy/4CrkagenKb6BYDOvPdOZyTPYCDW1ZkU7/T0aWHaluAZejKDYywViRVlE y5hgjsOxJ0qSbJ1svGyXoMzNa+Plf40y20SUnGnfyafyyTEiBjBDQgHRjQS5tCeOLFN4 ItsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@blackbox.su header.s=mail header.b=JQTcv+8f; 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; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=blackbox.su Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cn6si288590edb.153.2021.01.26.19.33.21; Tue, 26 Jan 2021 19:33:46 -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; dkim=pass header.i=@blackbox.su header.s=mail header.b=JQTcv+8f; 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; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=blackbox.su Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387709AbhAZFag (ORCPT + 99 others); Tue, 26 Jan 2021 00:30:36 -0500 Received: from 95-165-96-9.static.spd-mgts.ru ([95.165.96.9]:37606 "EHLO blackbox.su" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727495AbhAYKVx (ORCPT ); Mon, 25 Jan 2021 05:21:53 -0500 Received: from metabook.localnet (metabook.metanet [192.168.2.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by blackbox.su (Postfix) with ESMTPSA id 02E5682102; Mon, 25 Jan 2021 11:58:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackbox.su; s=mail; t=1611565129; bh=M5T8IVEuH9uBT6rA34kAGJxS5Tq8grPx+kUaZQ66ui0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JQTcv+8fFv/j0Eh4Hlq23VBnUHR1TdsKHqkXHbaxwZIa0SNtu438xVWhgFbeJCpm+ CkiBOTHRNhih3+ahC5/YwsvOdAa/IFVspj71B36UMJhZwX7ltgX3MvRqPgbcC6RoWW WDCEqTCje0pt+JRMozRNncst7ayCH/LbhUkoQ5ql2Ax1K6v/5svT3HCXI6Fr957jN7 QG1QPMH4jqJgG103Mv3GBdlx92bWPkaRL2iuyIE1Rryy0CC345mI7b6GOlayRmmw+J VRdTeVIgbyiHtOb9fAbmmTxfvAYqhdvOs6DojNInzJTPB3hrB4AuoEAqbL2LzVvFts fuuX8OJdhCaMw== From: Sergej Bauer To: Florian Fainelli Cc: Andrew Lunn , netdev@vger.kernel.org, "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 Date: Mon, 25 Jan 2021 11:57:54 +0300 Message-ID: <4225841.iQuhppFpKy@metabook> In-Reply-To: References: <20210122214247.6536-1-sbauer@blackbox.su> <4496952.bab7Homqhv@metabook> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Saturday, January 23, 2021 4:39:47 AM MSK Florian Fainelli wrote: > On 1/22/2021 5:01 PM, Sergej Bauer wrote: > > On Saturday, January 23, 2021 3:01:47 AM MSK Florian Fainelli wrote: > >> On 1/22/2021 3:58 PM, Sergej Bauer wrote: > >>> On Saturday, January 23, 2021 2:23:25 AM MSK Andrew Lunn wrote: > >>>>>>> @@ -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 > >>>> > >>>> There are drivers which call phy_disconnect() on a fixed_link. e.g. > >>>> > >>>> https://elixir.bootlin.com/linux/v5.11-rc4/source/drivers/net/usb/lan78 > >>>> xx > >>>> .c# L3555. > >>>> > >>>> > >>>> It could be your missing call to fixed_phy_unregister() is leaving > >>>> behind bad state. > >>> > >>> lan743x_virtual_phy_disconnect removes sysfs-links and calls > >>> fixed_phy_unregister() > >>> and the reason was phydev in sysfs. > >>> > >>>>> It was to make ethtool show full set of supported speeds and MII only > >>>>> in > >>>>> supported ports (without TP and the no any ports in the bare card). > >>>> > >>>> But fixed link does not support the full set of speed. It is fixed. It > >>>> supports only one speed it is configured with. > >>> > >>> That's why I "re-implemented the fixed PHY driver" as Florian said. > >>> The goal of virtual phy was to make an illusion of real device working > >>> in > >>> loopback mode. So I could use ethtool and ioctl's to switch speed of > >>> device.> > >>> > >>>> And by setting it > >>>> wrongly, you are going to allow the user to do odd things, like use > >>>> ethtool force the link speed to a speed which is not actually > >>>> supported. > >>> > >>> I have lan743x only and in loopback mode it allows to use speeds > >>> 10/100/1000MBps > >>> in full-duplex mode only. But the highest speed I have achived was > >>> something near > >>> 752Mbps... > >>> And I can switch speed on the fly, without reloading the module. > >>> > >>> May by I should limit the list of acceptable devices? > >> > >> It is not clear what your use case is so maybe start with explaining it > >> and we can help you define something that may be acceptable for upstream > >> inclusion. > > > > it migth be helpful for developers work on userspace networking tools with > > PHY-less lan743x (the interface even could not be brought up) > > of course, there nothing much to do without TP port but the difference is > > representative. > > You are still not explaining why fixed PHY is not a suitable emulation > and what is different, providing the output of ethtool does not tell me > how you are using it. > > Literally everyone using Ethernet switches or MAC to MAC Ethernet > connections uses fixed PHY and is reasonably happy with it. Florian, the key idea is to make virtual phy device which acts as real 802.11 standard phy. original fixed_phy and swphy are little bit useless as they do not support write operation. in contrast of them virtual_phy supports write to all registers. and can change the speed of interface by means of SIOCSMIIREG ioctl call either ethtool. changing of appropriate bits in register 0 will change speed reflecting in ethtool and vise versa. -- Regards, Sergej