Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp176356pxy; Wed, 28 Apr 2021 01:53:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCPzGc5cojJ+8zrVsfv1zV3+qNyqvvc6RiyNS9G8bCCBZllWMEZZBBT0LCil+/QsO+cE2f X-Received: by 2002:a17:907:7b9f:: with SMTP id ne31mr12247334ejc.139.1619599983908; Wed, 28 Apr 2021 01:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619599983; cv=none; d=google.com; s=arc-20160816; b=LNfSRsCAmWgteE544jqwOK6KGlIKJc1Ep6VW85nmHxgLvQzurS9s5wqrYGN+WODFJG mazkPDjF5gWei7VVzKUKN1e2qT5ukATOBJrwjLHVmhyBDI3o5mabX8RDw/KZdbzCU1OR V2fVSi+eUI6rTCNk5JZqwtKBgd+tx5cKOlUTc3r/mbEmbWOXpYBjp6iDAZPX1nTMZVUJ m5PP1GyznbIU0gW6iucZAijCRE7TLx1hus0Fqbldht9s2MKs8a62nLckYqyDpE18oHdp MxmECReik+j92foxjYgJ80PKYg7bEg5dJAoiviZrAqomGlGLLpqLpfAwxrnl/XUoGAtg bJwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Ye0Zp+KVYRqiWUkXAd6MMVTpfvF1dJgTbt8YtPlMeyc=; b=qr3md4j+4u4lsNshZhEbVpJ5wsvSLo4CS+aAb/n4mNB8ocfMVB/KYcUWCBG3Ru/0SP rJFqVnIeVAmgPJjut6LhayszwxBmWHBFKtdZiPURyw3NkQ71ZGvbQltiJ93m8A75OAN7 WidZ31t04bh/AwgUJDk1JkO629rg+jMrPLiSnEDS+Q/marJVvyrrKmfsF/LO4BEuf6fe NSI8I1OoH5oCh+9jBvjDcA+ktV3UTGzX6xPKVGRkxeQoRv38ejRQeACUchhygBR3FwAT wCSrRNfiwEIqROMX5RSOd39wWzoSh/nNqTl0IPs5fk51k1G8L3FXPtwlFVPtZOdlsc1m N3dw== 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 w9si4979201edq.453.2021.04.28.01.52.40; Wed, 28 Apr 2021 01:53:03 -0700 (PDT) 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 S229643AbhD1IwE (ORCPT + 99 others); Wed, 28 Apr 2021 04:52:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbhD1IwE (ORCPT ); Wed, 28 Apr 2021 04:52:04 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1721C06138A for ; Wed, 28 Apr 2021 01:51:19 -0700 (PDT) Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lbfuf-0003Qd-8A; Wed, 28 Apr 2021 10:51:17 +0200 Received: from ore by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1lbfud-00013v-7s; Wed, 28 Apr 2021 10:51:15 +0200 Date: Wed, 28 Apr 2021 10:51:15 +0200 From: Oleksij Rempel To: Joakim Zhang Cc: Florian Fainelli , Andrew Lunn , Fabio Estevam , Fugang Duan , "netdev@vger.kernel.org" , Sascha Hauer , "linux-kernel@vger.kernel.org" , Russell King , Philippe Schenker , dl-linux-imx , "kernel@pengutronix.de" , David Jander , Shawn Guo , "linux-arm-kernel@lists.infradead.org" , Heiner Kallweit Subject: Re: [PATCH net-next v3 0/6] provide generic net selftest support Message-ID: <20210428085115.mehvsj2vlqmbmib5@pengutronix.de> References: <20210419130106.6707-1-o.rempel@pengutronix.de> <20210423043729.tup7nntmmyv6vurm@pengutronix.de> <6416c580-0df9-7d36-c42d-65293c40aa25@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 10:45:15 up 146 days, 22:51, 47 users, load average: 0.08, 0.06, 0.07 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 28, 2021 at 08:06:05AM +0000, Joakim Zhang wrote: > > Hi Florian, > > > -----Original Message----- > > From: Florian Fainelli > > Sent: 2021年4月28日 0:41 > > To: Joakim Zhang ; Oleksij Rempel > > > > Cc: Shawn Guo ; Sascha Hauer > > ; Andrew Lunn ; Heiner Kallweit > > ; Fugang Duan ; > > kernel@pengutronix.de; netdev@vger.kernel.org; > > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > > dl-linux-imx ; Fabio Estevam ; > > David Jander ; Russell King ; > > Philippe Schenker > > Subject: Re: [PATCH net-next v3 0/6] provide generic net selftest support > > > > > > > > On 4/26/2021 9:48 PM, Joakim Zhang wrote: > > > > > >> -----Original Message----- > > >> From: Oleksij Rempel > > >> Sent: 2021年4月23日 12:37 > > >> To: Joakim Zhang > > >> Cc: Shawn Guo ; Sascha Hauer > > >> ; Andrew Lunn ; Florian > > >> Fainelli ; Heiner Kallweit > > >> ; Fugang Duan ; > > >> kernel@pengutronix.de; netdev@vger.kernel.org; > > >> linux-arm-kernel@lists.infradead.org; > > >> linux-kernel@vger.kernel.org; dl-linux-imx ; Fabio > > >> Estevam ; David Jander ; > > >> Russell King ; Philippe Schenker > > >> > > >> Subject: Re: [PATCH net-next v3 0/6] provide generic net selftest > > >> support > > >> > > >> Hi Joakim, > > >> > > >> On Fri, Apr 23, 2021 at 03:18:32AM +0000, Joakim Zhang wrote: > > >>> > > >>> Hi Oleksij, > > >>> > > >>> I look both stmmac selftest code and this patch set. For stmmac, if > > >>> PHY > > >> doesn't support loopback, it will fallthrough to MAC loopback. > > >>> You provide this generic net selftest support based on PHY loopback, > > >>> I have a > > >> question, is it possible to extend it also support MAC loopback later? > > >> > > >> Yes. If you have interest and time to implement it, please do. > > >> It should be some kind of generic callback as phy_loopback() and if > > >> PHY and MAC loopbacks are supported we need to tests both variants. > > > Hi Oleksij, > > > > > > Yes, I can try to implement it when I am free, but I still have some questions: > > > 1. Where we place the generic function? Such as mac_loopback(). > > > 2. MAC is different from PHY, need program different registers to enable > > loopback on different SoCs, that means we need get MAC private data from > > "struct net_device". > > > So we need a callback for MAC drivers, where we extend this callback? Could > > be "struct net_device_ops"? Such as ndo_set_loopback? > > > > Even for PHY devices, if we implemented external PHY loopback in the future, > > the programming would be different from one vendor to another. I am starting > > to wonder if the existing ethtool self-tests are the best API to expose the ability > > for an user to perform PHY and MAC loopback testing. > > > > From an Ethernet MAC and PHY driver perspective, what I would imagine we > > could have for a driver API is: > > > > enum ethtool_loopback_mode { > > ETHTOOL_LOOPBACK_OFF, > > ETHTOOL_LOOPBACK_PHY_INTERNAL, > > ETHTOOL_LOOPBACK_PHY_EXTERNAL, > > ETHTOOL_LOOPBACK_MAC_INTERNAL, > > ETHTOOL_LOOPBACK_MAC_EXTERNAL, > > ETHTOOL_LOOPBACK_FIXTURE, > > __ETHTOOL_LOOPBACK_MAX > > }; > > What's the difference between internal and external loopback for both PHY and MAC? I am not familiar with these concepts. Thanks. For example KSZ9031 PHY. It supports two loopback modes. See page 23: https://ww1.microchip.com/downloads/en/DeviceDoc/00002096E.pdf TI DP83TC811R-Q1 PHY supports 4 modes. See page 27: https://www.ti.com/lit/ds/symlink/dp83tc811r-q1.pdf > Best Regards, > Joakim Zhang > > int (*ndo_set_loopback_mode)(struct net_device *dev, enum > > ethtool_loopback_mode mode); > > > > and within the Ethernet MAC driver you would do something like this: > > > > switch (mode) { > > case ETHTOOL_LOOPBACK_PHY_INTERNAL: > > case ETHTOOL_LOOPBACK_PHY_EXTERNAL: > > case ETHTOOL_LOOPBACK_OFF: > > ret = phy_loopback(ndev->phydev, mode); > > break; > > /* Other case statements implemented in driver */ > > > > we would need to change the signature of phy_loopback() to accept being > > passed ethtool_loopback_mode so we can support different modes. > > > > Whether we want to continue using the self-tests API, or if we implement a > > new ethtool command in order to request a loopback operation is up for > > discussion. > > -- > > Florian -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |