From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D9EEC8300B for ; Thu, 30 Apr 2020 12:25:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67F512076D for ; Thu, 30 Apr 2020 12:25:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726774AbgD3MZz (ORCPT ); Thu, 30 Apr 2020 08:25:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:33934 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbgD3MZz (ORCPT ); Thu, 30 Apr 2020 08:25:55 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4ED94AB3D; Thu, 30 Apr 2020 12:25:52 +0000 (UTC) Received: by lion.mk-sys.cz (Postfix, from userid 1000) id B49F960341; Thu, 30 Apr 2020 14:25:51 +0200 (CEST) Date: Thu, 30 Apr 2020 14:25:51 +0200 From: Michal Kubecek To: Oleksij Rempel 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: <20200430122551.GB8934@lion.mk-sys.cz> 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> <20200430120945.GA7370@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200430120945.GA7370@pengutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 30, 2020 at 02:09:45PM +0200, Oleksij Rempel wrote: > > > > > @@ -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. Sounds good to me, splitting "unsupported" and "unknown" states will be probably the best option. Michal