Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3704389rwb; Mon, 16 Jan 2023 11:41:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXvUHPTgdBPoAFPJvmta4CE4N8NuzHe1epuXiIFhm6hxOBMUaSxbUteyznCUaQPp9ZfKJKsT X-Received: by 2002:a17:902:d48a:b0:192:48d1:f06c with SMTP id c10-20020a170902d48a00b0019248d1f06cmr31680682plg.35.1673898089757; Mon, 16 Jan 2023 11:41:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673898089; cv=none; d=google.com; s=arc-20160816; b=xLSluA6AGpiDBBSKv7qVQax+HTOtmB9s1I+kSssusS+aHIAp5v54P9oFZooKPJzp5h noq4k8AUkdEkpX0XsQilS0Lnkov/EpaFBDbqJojLQmil4TbBOIG/7pYg0byRkgVtE2Uk 3VIBFghF5t9OsEjiny5QL9pY47RxmCBbGasD8eJzGZ+j4ZIs3RpJT0qse6H3TyuhLPeN spgZT82YFjLHg5WaR+n0TbsSYsFIyg0PlV1XndwWP/G6iy1i1Kh6J9nRrk22cYTadHUN 7UOemsJXTKBnv0lagy+k6BJOchImHANZYbFMgGm+Yb2gk23RzAYeQMYy2HeM7M/k7H5m +UAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hkNFVtbzzp0XpZsfx3emQeVOO5FVZGr7hZw/Jma4LVA=; b=RhVB0HlQKPXHXaLzkTCX4ty0XWXQYzWFTV07vSCye3SOyW4fz3eHnfALbu3owU2u9n iZVLf/n99XLkaAdID2GD+kMBVCKCLsswS5gRNPSdCF49fK0DbNA/awJi6q6moLx9aT68 dULkweG9MGJu82oz5bdwpAkQszgcECxVb/VDRISS3lFqJ1H5+aCiLUVlH6KJBC3E4PSO 2N4MH/Nw0QabIxFBcCfmJ+oVJbF8BVvov5eCoGijdBvKNbFkGTq+ZpOP+Cx6DdmIbobF 47BnyyxjlVz14TFIKSBVa4vYEdVAKbRcz1og1r27hRSAhGqe14vzrzBKtjeVs2Hdre4B 5N1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=UupanAH6; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a170902aa9100b00189bbc95db1si10195842plr.11.2023.01.16.11.41.22; Mon, 16 Jan 2023 11:41:29 -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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=UupanAH6; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232743AbjAPTP2 (ORCPT + 50 others); Mon, 16 Jan 2023 14:15:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232346AbjAPTP0 (ORCPT ); Mon, 16 Jan 2023 14:15:26 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C625D16ADA; Mon, 16 Jan 2023 11:15:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hkNFVtbzzp0XpZsfx3emQeVOO5FVZGr7hZw/Jma4LVA=; b=UupanAH6GT+TSgnVN/G70/Kw+B jPITqiNGkh1JrRh4mlCwzBvLRsti1vU9cmXyJwxNBF6EbMEIaedOKbOf5aXZyJDsqzmkpMfvc18bl 8hRllSvXxKlcUQMjMA0GqDTdHEauQuSd7+Q0vPKWYL/ZAaMVaTUKwmZj5F6tMVh5UQVW5Si47khOP D8HQcYo1QZAI0HVfnrpxtKXyWSt48mw3gp6ZHPKDTzQvP2OwOTqL8aFQ//OfBy5osBf0GYWPClAXX Mtxn6D6nH3BEvK5dwzHfSQICxaXXLSBafF1KyzaFFy3Pf9AGmpBag8BDGPNkJrPhHv5ISf8I/8uIO unUC1hPg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:36150) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pHUwp-0005k4-0o; Mon, 16 Jan 2023 19:15:10 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pHUwl-0006Gj-Bh; Mon, 16 Jan 2023 19:15:07 +0000 Date: Mon, 16 Jan 2023 19:15:07 +0000 From: "Russell King (Oracle)" To: =?iso-8859-1?Q?Bj=F8rn?= Mork Cc: Frank Wunderlich , Frank Wunderlich , linux-mediatek@lists.infradead.org, Alexander Couzens , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] net: mtk_sgmii: implement mtk_pcs_ops Message-ID: References: <87bkmy33ph.fsf@miraculix.mork.no> <875yd630cu.fsf@miraculix.mork.no> <871qnu2ztz.fsf@miraculix.mork.no> <87pmbe1hu0.fsf@miraculix.mork.no> <87lem21hkq.fsf@miraculix.mork.no> <87a62i1ge4.fsf@miraculix.mork.no> <875yd61fg3.fsf@miraculix.mork.no> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <875yd61fg3.fsf@miraculix.mork.no> Sender: Russell King (Oracle) 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_NONE,SPF_NONE 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 On Mon, Jan 16, 2023 at 07:50:52PM +0100, Bj?rn Mork wrote: > Made things fail with 2.5G, as expected I guess. But this actually works > with 1G! > > Except for an unexpected packet drop. But at least there are packets > coming through at 1G now. This is the remote end of the link: > > ns-enp3s0# ethtool -s enp3s0 autoneg off speed 1000 duplex full > ns-enp3s0# ping 192.168.0.1 > PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data. > 64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.544 ms > 64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.283 ms > 64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=0.261 ms > 64 bytes from 192.168.0.1: icmp_seq=5 ttl=64 time=0.295 ms > 64 bytes from 192.168.0.1: icmp_seq=6 ttl=64 time=0.273 ms > 64 bytes from 192.168.0.1: icmp_seq=7 ttl=64 time=0.290 ms > 64 bytes from 192.168.0.1: icmp_seq=8 ttl=64 time=0.266 ms > 64 bytes from 192.168.0.1: icmp_seq=9 ttl=64 time=0.269 ms > 64 bytes from 192.168.0.1: icmp_seq=10 ttl=64 time=0.270 ms > 64 bytes from 192.168.0.1: icmp_seq=11 ttl=64 time=0.261 ms > 64 bytes from 192.168.0.1: icmp_seq=12 ttl=64 time=0.261 ms > 64 bytes from 192.168.0.1: icmp_seq=13 ttl=64 time=0.266 ms > ^C > --- 192.168.0.1 ping statistics --- > 13 packets transmitted, 12 received, 7.69231% packet loss, time 12282ms > rtt min/avg/max/mdev = 0.261/0.294/0.544/0.075 ms > ns-enp3s0# ethtool enp3s0 > Settings for enp3s0: > Supported ports: [ TP ] > Supported link modes: 100baseT/Full > 1000baseT/Full > 10000baseT/Full > 2500baseT/Full > 5000baseT/Full > Supported pause frame use: Symmetric Receive-only > Supports auto-negotiation: Yes > Supported FEC modes: Not reported > Advertised link modes: 1000baseT/Full > Advertised pause frame use: Symmetric > Advertised auto-negotiation: No > Advertised FEC modes: Not reported > Speed: 1000Mb/s > Duplex: Full > Auto-negotiation: off > Port: Twisted Pair > PHYAD: 0 > Transceiver: internal > MDI-X: Unknown > Supports Wake-on: pg > Wake-on: g > Current message level: 0x00000005 (5) > drv link > Link detected: yes > . > > The MT7986 end looks like this: > > root@OpenWrt:/# [ 55.659413] mtk_pcs_get_state: bm=0x81140, adv=0x1a0 > [ 55.664380] mtk_pcs_get_state: bm=0x81140, adv=0x1a0 > [ 58.779924] mtk_pcs_get_state: bm=0x81140, adv=0x1a0 > [ 58.784884] mtk_pcs_get_state: bm=0x81140, adv=0x1a0 > [ 58.789841] mtk_sgmii_select_pcs: id=1 > [ 58.793581] mtk_pcs_config: interface=4 > [ 58.797399] offset:0 0x81140 > [ 58.797401] offset:4 0x4d544950 > [ 58.800273] offset:8 0x1a0 > [ 58.803397] offset:0x20 0x31120118 This looks like it's configured for 1000base-X at this point. > [ 58.806089] forcing AN > [ 58.811826] mtk_pcs_config: rgc3=0x0, advertise=0x1 (changed), link_timer=1600000, sgm_mode=0x103, bmcr=0x1200, use_an=1 > [ 58.822759] mtk_pcs_restart_an > [ 58.825800] mtk_pcs_get_state: bm=0x81140, adv=0xda014001 > [ 58.831184] mtk_pcs_get_state: bm=0x2c1140, adv=0xda014001 > [ 58.836649] mtk_pcs_link_up: interface=4 > [ 58.840559] offset:0 0xac1140 > [ 58.840561] offset:4 0x4d544950 > [ 58.843512] offset:8 0xda014001 > [ 58.846636] offset:0x20 0x3112011b and here we've reconfigured it for SGMII mode - and we can see the Mediatek PCS has set the ACK bit (bit 14) in its advertisement register as one would expect. > Now, if we only could figure out what the difference is between this and > what we configure when the mode is changed from 2500base-x to sgmii. Maybe there is something missing which we need to do on the Mediatek side to properly switch between 2500base-X and SGMII. It has a feel of a problem changing the underlying link speed between 3.125 and 1.25Gbps, which is done by the ANA_RGC3 register. Hmm, maybe the PCS needs to be powered down to change the speed, in other words, SGMII_PHYA_PWD needs to be set before the write to the ANA_RGC3 register? -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!