Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1763644ybz; Thu, 30 Apr 2020 05:12:10 -0700 (PDT) X-Google-Smtp-Source: APiQypK60H0OOa2yqZBIWg+hJpdprqg6jgcAiWMj1Pa2XZCVYAxSRXzcFdp/SF+vfl6qZfvPtGAD X-Received: by 2002:aa7:c40e:: with SMTP id j14mr2394292edq.125.1588248730619; Thu, 30 Apr 2020 05:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588248730; cv=none; d=google.com; s=arc-20160816; b=Yr312gZwKjbFXxtmCBVS/zwDfJM58QutJDIuuXx28em92yIvnyAC5WhYsQjp8hrj54 2h8H0Edf5K/4BGwLfhl3aPtVHzaV4UZKoqUJZOI9LGpFGSGjMo/97FyTuSC9IcKDXe4W +8/TtqmpRpO4PuUX4WYXWl9vysKBVyQlOdV0rLHxozTey/D9rkag14Hoxk+Y1IU4rhMd ysT5eaPs+gByptNNtHh2EEJDzg0/3WYgch20MYtyo4+Vj02gD7MaMPe2zv5+lLK2btp4 VJMs+6qPc4xKszTp5Ot0H8zFX1DSqBmTKGvKsqlFR3Dd5LcW/dAfyR6g2cuORaj7L1N2 bFwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=YzCtgSpDWg0KEKPKdqpiSAO+cABYfeJvFxNFbUvou7Y=; b=QlE2NLj5oXVNGpzj3I4wAlj2Jt8q5p+BpP7sbosFbRoNKOgwr52nr8yAaVflZ5JRat PApBWkfSs1aoSypvCaGa9XRekf0cqjY0c+n1Wd9WZ85W5F3yyP0ZMW7vFmqgjcV/we91 keIl/Zpfoc7eRM3dxu6rnOksZ8tupFEJyjJ44Uzg7C6uP5mRD6o1zniHzmYcaLwNeTDg 6IP3rOjE4eug/ac8aWnRwurx3skBUhD2zOh+GDIxyomUjdz5WRWJv3FZeyNId6J86lKq Y4AhJ3ws+9ttPDR4lG3Az5Jc6MrfHA+x4A/3obtpq3MwyTY0yf+cG4LuWlS9YuJf71lq 1dyQ== 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 g24si5315929edu.104.2020.04.30.05.11.47; Thu, 30 Apr 2020 05:12:10 -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 S1726924AbgD3MJ4 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 30 Apr 2020 08:09:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726515AbgD3MJ4 (ORCPT ); Thu, 30 Apr 2020 08:09:56 -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 E3B73C035494 for ; Thu, 30 Apr 2020 05:09:55 -0700 (PDT) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jU80j-0004eL-2T; Thu, 30 Apr 2020 14:09:49 +0200 Received: from ore by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1jU80f-0000EE-BC; Thu, 30 Apr 2020 14:09:45 +0200 Date: Thu, 30 Apr 2020 14:09:45 +0200 From: Oleksij Rempel To: Michal Kubecek Cc: Marek Vasut , Andrew Lunn , Florian Fainelli , Jonathan Corbet , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Russell King , mkl@pengutronix.de, kernel@pengutronix.de, David Jander , Jakub Kicinski , Christian Herber , "David S. Miller" , Heiner Kallweit Subject: Re: [PATCH net-next v3 1/2] ethtool: provide UAPI for PHY master/slave configuration. Message-ID: <20200430120945.GA7370@pengutronix.de> References: <20200428075308.2938-1-o.rempel@pengutronix.de> <20200428075308.2938-2-o.rempel@pengutronix.de> <20200429195222.GA17581@lion.mk-sys.cz> <20200430050058.cetxv76pyboanbkz@pengutronix.de> <20200430082020.GC17581@lion.mk-sys.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <20200430082020.GC17581@lion.mk-sys.cz> 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: 14:03:23 up 232 days, 51 min, 517 users, load average: 22.23, 19.35, 22.10 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michal, On Thu, Apr 30, 2020 at 10:20:20AM +0200, Michal Kubecek wrote: > On Thu, Apr 30, 2020 at 07:00:58AM +0200, Oleksij Rempel wrote: > > > > diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h > > > > index 92f737f101178..eb680e3d6bda5 100644 > > > > --- a/include/uapi/linux/ethtool.h > > > > +++ b/include/uapi/linux/ethtool.h > > > > @@ -1666,6 +1666,31 @@ static inline int ethtool_validate_duplex(__u8 duplex) > > > > return 0; > > > > } > > > > > > > > +/* Port mode */ > > > > +#define PORT_MODE_CFG_UNKNOWN 0 > > > > +#define PORT_MODE_CFG_MASTER_PREFERRED 1 > > > > +#define PORT_MODE_CFG_SLAVE_PREFERRED 2 > > > > +#define PORT_MODE_CFG_MASTER_FORCE 3 > > > > +#define PORT_MODE_CFG_SLAVE_FORCE 4 > > > > +#define PORT_MODE_STATE_UNKNOWN 0 > > > > +#define PORT_MODE_STATE_MASTER 1 > > > > +#define PORT_MODE_STATE_SLAVE 2 > > > > +#define PORT_MODE_STATE_ERR 3 > > > > > > You have "MASTER_SLAVE" or "master_slave" everywhere but "PORT_MODE" in > > > these constants which is inconsistent. > > > > What will be preferred name? > > Not sure, that would be rather question for people more familiar with > the hardware. What I wanted to say is that whether we use "master_slave" > or "port_mode", we should use the same everywhere. Ok, I rename it all to MASTER_SLAVE prefix. It is the only common name across the all documentations. > > > > + > > > > +static inline int ethtool_validate_master_slave_cfg(__u8 cfg) > > > > +{ > > > > + switch (cfg) { > > > > + case PORT_MODE_CFG_MASTER_PREFERRED: > > > > + case PORT_MODE_CFG_SLAVE_PREFERRED: > > > > + case PORT_MODE_CFG_MASTER_FORCE: > > > > + case PORT_MODE_CFG_SLAVE_FORCE: > > > > + case PORT_MODE_CFG_UNKNOWN: > > > > + return 1; > > > > + } > > > > + > > > > + return 0; > > > > +} > > > > > > Should we really allow CFG_UNKNOWN in client requests? As far as I can > > > see, this value is handled as no-op which should be rather expressed by > > > absence of the attribute. Allowing the client to request a value, > > > keeping current one and returning 0 (success) is IMHO wrong. > > > > ok > > > > > Also, should this function be in UAPI header? > > > > It is placed together with other validate functions: > > ethtool_validate_duplex > > ethtool_validate_speed > > > > Doing it in a different place, would be inconsistent. > > Those two have been there since "ever". The important question is if we > want this function to be provided to userspace as part of UAPI (which > would also limit our options for future modifications. good argument. Moved it to other location. > > > > > [...] > > > > @@ -119,7 +123,12 @@ static int linkmodes_fill_reply(struct sk_buff *skb, > > > > } > > > > > > > > if (nla_put_u32(skb, ETHTOOL_A_LINKMODES_SPEED, lsettings->speed) || > > > > - nla_put_u8(skb, ETHTOOL_A_LINKMODES_DUPLEX, lsettings->duplex)) > > > > + nla_put_u8(skb, ETHTOOL_A_LINKMODES_DUPLEX, lsettings->duplex) || > > > > + nla_put_u8(skb, ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG, > > > > + lsettings->master_slave_cfg) || > > > > + nla_put_u8(skb, ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE, > > > > + lsettings->master_slave_state)) > > > > + > > > > return -EMSGSIZE; > > > > > > From the two handlers you introduced, it seems we only get CFG_UNKNOWN > > > or STATE_UNKNOWN if driver or device does not support the feature at all > > > so it would be IMHO more appropriate to omit the attribute in such case. > > > > STATE_UNKNOWN is returned if link is not active. > > How about distinguishing the two cases then? Omitting both if CFG is > CFG_UNKNOWN (i.e. driver does not support the feature) and sending > STATE=STATE_UNKNOWN to userspace only if we know it's a meaningful value > actually reported by the driver? Hm... after thinking about it, we should keep state and config separately. The TJA1102 PHY do not provide actual state. Even no error related to Master/Master conflict. I reworked the code to have unsupported and unknown values. In case we know, that state or config is not supported, it will not be exported to the user space. Regards, Oleksij -- 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 |