Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2954658ybk; Tue, 12 May 2020 12:13:06 -0700 (PDT) X-Google-Smtp-Source: APiQypICBtPL3yiuSOGm5K0Dcplvuob2bdr2+OoT63Ynj1gacql8/nitQVahZrFXeskhAI7CHOSj X-Received: by 2002:a50:e80a:: with SMTP id e10mr19322548edn.204.1589310786544; Tue, 12 May 2020 12:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589310786; cv=none; d=google.com; s=arc-20160816; b=Huqckmy+Ty663+Gel0zmosrqQUJV6yL5OKpLwIF4NFS0vNuPa0NjGdpIB0JeJfg5CK 5JsptWBy+9NSQCjTOVogEzCuqJcTzTE00xchX4LOZAT/dgQBOSUSGvkkksjuEPNBfudT PQ/zJf5xj/ady6GYfImlDUAtivvhq3pfxEpU/V9v4Es72IRE1gi1/tm/vZRKT6iarjMz yLyFt/GPOinVOAlJLmrpAoq/Dyx820pkU6UUEfPuRunxvm46OqveUY6vtGKWMiVu7k3u /InQg9FkfNzgr6RUfxPed1Ps+Fi1XgUlyHYu72uns45S1M4C2FewBGxyNGcSWMYgLnES v+0g== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=P143mQB/dfvqg51ssKk6KCXCwTGEXSw9TVidC5IUVkk=; b=gxZxpRySyLN/UPJTgluIer72Db/otBsl62hfhjNgUGgNC3ymOBcLPxDh2jMS75u02d RayT2lQTOQMS2VU4p/zeGIcsbOfrSbXT8vAo3fNJAhUIYd6iKwCF/riB4nwWQpChpqlN bSseJI6v3K/4QN8VC05y2C+i9z4njT461DsY1TsFyfH7nVOo/kzIUdE4sdPoNjCMwDYE 45ZPzbFjHiSW6xIVSMcFL9IMVhBlkx5UrI65ANeigQTRfqTlM0ehc76WqBApNBfWJ66i 2NFq5BcPBBoBaFXnqhFPMs1XcHxAjZ8/qGstpPkj40yfjWr3Ycd8tlSbPbRS7A3fKA3J vo0g== 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 w21si8356362edt.595.2020.05.12.12.12.42; Tue, 12 May 2020 12:13:06 -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 S1730903AbgELTI7 (ORCPT + 99 others); Tue, 12 May 2020 15:08:59 -0400 Received: from mx2.suse.de ([195.135.220.15]:34620 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730610AbgELTI7 (ORCPT ); Tue, 12 May 2020 15:08:59 -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 6683FAF9F; Tue, 12 May 2020 19:08:59 +0000 (UTC) Received: by lion.mk-sys.cz (Postfix, from userid 1000) id E7954604F3; Tue, 12 May 2020 21:08:55 +0200 (CEST) Date: Tue, 12 May 2020 21:08:55 +0200 From: Michal Kubecek To: netdev@vger.kernel.org Cc: Doug Berger , Andrew Lunn , "David S. Miller" , Florian Fainelli , Heiner Kallweit , Russell King , bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 1/4] net: ethernet: validate pause autoneg setting Message-ID: <20200512190855.GB9071@lion.mk-sys.cz> References: <1589243050-18217-1-git-send-email-opendmb@gmail.com> <1589243050-18217-2-git-send-email-opendmb@gmail.com> <20200512004714.GD409897@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue, May 12, 2020 at 11:31:39AM -0700, Doug Berger wrote: > On 5/11/2020 5:47 PM, Andrew Lunn wrote: > > On Mon, May 11, 2020 at 05:24:07PM -0700, Doug Berger wrote: > >> A comment in uapi/linux/ethtool.h states "Drivers should reject a > >> non-zero setting of @autoneg when autoneogotiation is disabled (or > >> not supported) for the link". > >> > >> That check should be added to phy_validate_pause() to consolidate > >> the code where possible. > >> > >> Fixes: 22b7d29926b5 ("net: ethernet: Add helper to determine if pause configuration is supported") > > > > Hi Doug > > > > If this is a real fix, please submit this to net, not net-next. > > > > Andrew > > > This was intended as a fix, but I thought it would be better to keep it > as part of this set for context and since net-next is currently open. > > The context is trying to improve the phylib support for offloading > ethtool pause configuration and this is something that could be checked > in a single location rather than by individual drivers. > > I included it here to get feedback about its appropriateness as a common > behavior. I should have been more explicit about that. > > Personally, I'm actually not that fond of this change since it can > easily be a source of confusion with the ethtool interface because the > link autonegotiation and the pause autonegotiation are controlled by > different commands. > > Since the ethtool -A command performs a read/modify/write of pause > parameters, you can get strange results like these: > # ethtool -s eth0 speed 100 duplex full autoneg off > # ethtool -A eth0 tx off > Cannot set device pause parameters: Invalid argument > # > Because, the get read pause autoneg as enabled and only the tx_pause > member of the structure was updated. This would be indeed unfortunate. We could use extack to make the error message easier to understand but the real problem IMHO is that ethtool_ops::get_pauseparam() returns value which is rejected by ethtool_ops::set_pauseparam(). This is something we should avoid. If we really wanted to reject ethtool_pauseparam::autoneg on when general autonegotiation is off, we would have to disable pause autonegotiation whenever general autonegotiation is disabled. I don't like that idea, however, as that would mean that ethtool -s dev autoneg off ... ethtool -s dev autoneg on ... would reset the setting of pause autonegotiation. Therefore I believe the comment should be rather replaced by a warning that even if ethtool_pauseparam::autoneg is enabled, pause autonegotiation is only active if general autonegotiation is also enabled. Michal