Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp108959rdb; Tue, 31 Oct 2023 02:09:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGysUx4DZw8RTsVj0AmNx4FxKxkSOxb7A0yi8VNaJszczR6dd6o9AF3XYjhlZKXibU2AJKY X-Received: by 2002:a17:90b:38c4:b0:280:37c3:3bcf with SMTP id nn4-20020a17090b38c400b0028037c33bcfmr2577457pjb.13.1698743356058; Tue, 31 Oct 2023 02:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698743356; cv=none; d=google.com; s=arc-20160816; b=oborr8yxFbYnm2IVDt9yENsdXpswhedlwvOnt0ppnvK4MnJ7V/v4G0kW3mYZsMW1/M D9OqOnEY3MOQjKXBp34glmVjr4HfecZgu6WUI/U4JAozh8vNKV4nRHQroUj/jQqfKJt4 U3pEX+rmT1g2PgBvVxUa6545nEo4guqAfUXCQ96VpT5pfblxW+Ib/gCH91Vdt5vFPs+i aGWFnPYi6AsI5gm8b8YKEKENiosTQzqT0arsmGWNzWLNc0IwEaV40KdrAPwmW4FADBFv 0tyLpjKY828MJMj/LDnpTKaqDP/2kvKi22Wfo72+Mx1JTfs38lbibiwvQQObeR+Pfa9k akOQ== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=IMJYz5PL4lee6U7IF6ZC/L+9tCsfFfPvBLsrgdkwPIk=; fh=gMEzTPT75I1dzO0hil803eMgyZJoTivYiEW5NQYo6E8=; b=oymLGwapsK0+tUp0Iz1SjfRrknfpOhSKtFSXlOIWdufRou5mtkCYKkfGjJTCQeFtIL osQkE5dnEq1c8Z16Mhx+vZ6ggEFuKfSsN1tsTSorKIp89Kty3UpQ6rFTe+dP2eReDB8a DNeN9P/NACRx/BG6JkIMpMLxFyMQAGOABmW2WHVaxkLx03YG8VSw4xDu2kCWuhuoTFIO +Dw9RC+97WQbRXxO1PNB7p26lKbGIUVrgu4U7mOssolISY0xGHIlw7FQESWkn5RxTxIB vtdY/kmOA/gPcll2Phpd4bR079ucm0+c1Ynn3uDl4UCric/99NCzszBshQgVPV2LGOsy WGtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="sUZmG/RF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f14-20020a63f10e000000b005b884a11fdcsi776804pgi.28.2023.10.31.02.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 02:09:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="sUZmG/RF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5EFB08026DF3; Tue, 31 Oct 2023 02:09:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343740AbjJaJJN (ORCPT + 99 others); Tue, 31 Oct 2023 05:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235349AbjJaJJL (ORCPT ); Tue, 31 Oct 2023 05:09:11 -0400 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 050C4B3; Tue, 31 Oct 2023 02:09:08 -0700 (PDT) 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-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding: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=IMJYz5PL4lee6U7IF6ZC/L+9tCsfFfPvBLsrgdkwPIk=; b=sUZmG/RFEtT5CUSTwWE84dNfmj Lu7041AN7U9klqaW8qufPLdh7gVEr/ZttDINRJsQeInEQtiIoabyLVUanZcXffJzzUVd96iQvvYUq sj0QBZbpJHd0kFjId7JBvALESJjns77y0mHAIctZa8yWM1gIlVkTRkkdj/KULHoRtV/Y7wYUWhDtO xS3ZRlsrjYMja2FXFObosjqMAceNoaU8FvOL044cJnhW8Sfu9b27Q4ab+4hPezKHPAdGf/wrtsVJ0 gio1oRWo/stVF+v137iItzb57Vav67q3/e+5cFrrFR9LyY/FcJUihQwZdE94xxH+z96kSEzGoXVTx 1hrCZMxA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:44018) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qxkjy-0002V5-1u; Tue, 31 Oct 2023 09:08:50 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qxkjx-0004yS-7I; Tue, 31 Oct 2023 09:08:49 +0000 Date: Tue, 31 Oct 2023 09:08:49 +0000 From: "Russell King (Oracle)" To: "Gan, Yi Fang" Cc: Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , "netdev@vger.kernel.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "Looi, Hong Aun" , "Voon, Weifeng" , "Song, Yoong Siang" , "Ahmad Tarmizi, Noor Azura" Subject: Re: [PATCH net-next 1/1] net: stmmac: add check for advertising linkmode request for set-eee Message-ID: References: <20231027065054.3808352-1-yi.fang.gan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 31 Oct 2023 02:09:14 -0700 (PDT) On Tue, Oct 31, 2023 at 08:44:23AM +0000, Gan, Yi Fang wrote: > Hi Russell King, > > > Why should this functionality be specific to stmmac? > This functionality is not specific to stmmac but other drivers can have their > own implementation. > (e.g. https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/qlogic/qede/qede_ethtool.c#L1855) This is probably wrong (see below.) > > > Why do we need this? > Current implementation will not take any effect if user enters unsupported value but user might > not aware. With this, an error will be prompted if unsupported value is given. Why can't the user read back what settings were actually set like the other ethtool APIs? This is how ETHTOOL_GLINKSETTINGS works. > > What is wrong with the checking and masking that phylib is doing? > Nothing wrong with the phylib but there is no error return back to ethtool commands > if unsupported value is given. Maybe because that is the correct implementation? > > Why should we trust the value in edata->supported provided by the user? > The edata->supported is getting from the current setting and the value is set upon bootup. > Users are not allowed to change it. "not allowed" but there is nothing that prevents it. So an easy way to bypass your check is: struct ethtool_eee eeecmd; eeecmd.cmd = ETHTOOL_GEEE; send_ioctl(..., &eeecmd); eeecmd.cmd = ETHTOOL_SEEE; eeecmd.supported = ~0; eeecmd.advertised = ~0; error = send_ioctl(..., &eeecmd); and that won't return any error. So your check is weak at best, and relies upon the user doing the right thing. > > Sorry, but no. I see no reason that this should be done, especially not in the stmmac driver. > I understand your reasoning. From your point of view, is this kind of error message/ error handling > not needed? It is not - ethtool APIs don't return errors if the advertise mask is larger than the supported mask - they merely limit to what is supported and set that. When subsequently querying the settings, they return what is actually set (so the advertise mask will always be a subset of the supported mask at that point.) So, if in userspace you really want to know if some modes were dropped, then you have to do a set-get-check sequence. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!