From patchwork Fri Feb 23 09:44:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 205260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp479942dyb; Fri, 23 Feb 2024 01:49:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVBos768GXkj9w4iQHAf4lZi/mFl5GaI4MJ7EGdWeh94wjpv7keTQdEPHwgcvqY71xuFoSNBdDuZ/3EyMBjwW4K7AtfuQ== X-Google-Smtp-Source: AGHT+IGfoXXff5wOF6nmJtEI5cim9bt3UEn8mqV0tE5G64bCMGNlsSTcC+8psXajxQCGmd6y9vyX X-Received: by 2002:a05:6402:336:b0:561:33dd:621c with SMTP id q22-20020a056402033600b0056133dd621cmr1227961edw.7.1708681749202; Fri, 23 Feb 2024 01:49:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708681749; cv=pass; d=google.com; s=arc-20160816; b=VXWzVL5wEzrY9ghc3OPosOfbotVRkSPvTQPetc7A7S2864/46fHCmIKN5cLLVg0q6J ZrPqTdC/3CucS5AEDCe+XnhkISy6j3uF4hwMOB4zbf8QvdnvoSo1YKFfLL/xPrFIyhuv kB1JFsMaNSc1WczQtkU6am4/9aks05cwDgeaXNT02rjNNoj83qUX7aNSYdZOzZP7RtYk uZUaZlV68/i7xVDwJ7zd8UNfucmPLQx1PVPOqg62id64SmTSXM513MA9yTyDabGTGoxh 9qV3Yy1C3uOQBdV7sUbGtNroh3ucFfdE22b/pV3YO9XiGNtIM3k5JN5iXDylcb/purpA IxOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Y+VdvFSLYL4Q2hUhuiOR7a6bsGkCRuhHi5rflJOJ9qw=; fh=sVZ6H5f6ewU2fC+U58NocBocCWosMlAmPb9AApl9d+c=; b=QOp1O5wV44R/w7s2FSnzzTWsMAc34voRgnIgW3ch6KYOQFbL//wlUezo9qHjOhXqA/ 9Uo11O2GZSP9vzwhn00SOvEJ6tGgCyLUgk4/VKtwy6ktvZYW2mELifhAc7oxRVRBas6L 2mL+dBwHOGEBKG2098Bx5tcbeDYll83KyCRiaMcwthXKqtk3G0xD5Ud7EEYcYMdv1sqx 5D1+1p3CkD+YnIipLwOsb8e8wQcx+pppTVrQxA0HQdqf1/kqc3VlurCbSul09zQH5t1v oZaJQXWJXeqcTKn2IxbHsxV0Q6eRZ0+pGmbZRIQkCGbXkQo5+47ZdLD/56OZtoAntxK5 99hQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78065-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e20-20020a50d4d4000000b005617dcf505bsi6157246edj.70.2024.02.23.01.49.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:49:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78065-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78065-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CD54A1F21D99 for ; Fri, 23 Feb 2024 09:49:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5FD35FF04; Fri, 23 Feb 2024 09:45:02 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2B7A5CDF8 for ; Fri, 23 Feb 2024 09:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681497; cv=none; b=azvvUEEPW4odUmoAtrmyFG2UjVMXO51dbmfiSq6oxh70jnTPxFxfFaouIOKDiNWb9xWP3PFRrdLtiVrtIiWXwLtxyNEvot9DuYPM3V3+2dDWy1x+ybZm3W/JyR+dVXVyBxsxS+hqU5vPemml7AsDh6p5/yFpdq5MeBuJGT+n57s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681497; c=relaxed/simple; bh=XkWQE6zG1apQhBmdO+aLa8+bgHqVdq0lI1BXT90sPtQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PJk9RmT6MiRwOwy5W1KiqGW0mo8y8q0WTPcvnm06Dl76UDcT3+WWZXM+QzNN7tvWfSQfwDsRUX3KIoonghc7m8Tjj66fCuSfsXqC/QQqwImkspksoeP3g3uRAZKas3N1tb8lQsC0lwNz7UmdtJ1+jYvijySTksLViLABPazfQWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rdS6W-00080k-LH; Fri, 23 Feb 2024 10:44:28 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdS6V-002OkS-9O; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tpR-0j; Fri, 23 Feb 2024 10:44:27 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Russell King , Florian Fainelli , Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v6 1/8] net: add helpers for EEE configuration Date: Fri, 23 Feb 2024 10:44:18 +0100 Message-Id: <20240223094425.691209-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791682673811238378 X-GMAIL-MSGID: 1791682673811238378 From: Russell King Add helpers that phylib and phylink can use to manage EEE configuration and determine whether the MAC should be permitted to use LPI based on that configuration. Signed-off-by: Russell King (Oracle) Signed-off-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Oleksij Rempel --- include/net/eee.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 include/net/eee.h diff --git a/include/net/eee.h b/include/net/eee.h new file mode 100644 index 000000000000..1232658b32f4 --- /dev/null +++ b/include/net/eee.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _EEE_H +#define _EEE_H + +#include + +struct eee_config { + u32 tx_lpi_timer; + bool tx_lpi_enabled; + bool eee_enabled; +}; + +static inline bool eeecfg_mac_can_tx_lpi(const struct eee_config *eeecfg) +{ + /* eee_enabled is the master on/off */ + if (!eeecfg->eee_enabled || !eeecfg->tx_lpi_enabled) + return false; + + return true; +} + +static inline void eeecfg_to_eee(const struct eee_config *eeecfg, + struct ethtool_keee *eee) +{ + eee->tx_lpi_timer = eeecfg->tx_lpi_timer; + eee->tx_lpi_enabled = eeecfg->tx_lpi_enabled; + eee->eee_enabled = eeecfg->eee_enabled; +} + +static inline void eee_to_eeecfg(const struct ethtool_keee *eee, + struct eee_config *eeecfg) +{ + eeecfg->tx_lpi_timer = eee->tx_lpi_timer; + eeecfg->tx_lpi_enabled = eee->tx_lpi_enabled; + eeecfg->eee_enabled = eee->eee_enabled; +} + +#endif From patchwork Fri Feb 23 09:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 205272 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp482156dyb; Fri, 23 Feb 2024 01:56:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXGVQW+0PNi6FAVcJWAh57+mU8xwF1HEzH8R/xOnkkyzDeyysoELwpMq2RAwwGXSVTySI4iJBcROrVBpeWlQfRPNcWNbA== X-Google-Smtp-Source: AGHT+IH6G7ME5RmSIiy35QUyoQ3JRqOopdpNwJFcvAC4QOitALlCfutI1GauSZUb8/ntQ0Fk9ACu X-Received: by 2002:a17:902:6f08:b0:1dc:2120:2467 with SMTP id w8-20020a1709026f0800b001dc21202467mr1142030plk.44.1708682191727; Fri, 23 Feb 2024 01:56:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708682191; cv=pass; d=google.com; s=arc-20160816; b=vT45KkgX0hKhXPX603uwaq/EzrmC3QQX6x1dhRVP4bWJl//de0Zwq+zzmBtvLdX5Th /FTpStr2KqIW00Md+h8K8ezE8h8cIUkqZ5C7usgWrsYAuPHFObuK1aOssvCsa2hM6QlE L5eRgTYPqoGcC1tl2jJ805dxWOITOnjhIMs8guGQom+spF6ViCfY+FHSewvHBCg/2XR1 mXIr3OE1DQkREPKMwJxG5OKXUdWXJsOwVfm9LKYCGUTtSF7VnC/9XkvEia+spv1rS0xk Uq5Ka02qFlzXWwkSM3ccNO8NnmVmGlclTFFah08NjXssM+1hMXKPnxF8Cw4nVK2u/1Iy 3gKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=uMZz3Rym5sPkSk5AavCCPES8XuvGaOlsetdtNgLDqX4=; fh=/mFbHcqW6l4fLIJBfKVNbHEV0oGb2iio8Q6EPf9P78A=; b=RVI+MkF1iM/BDKPLnkfd0wgSMp5Ib2fWi3cZLha2Y8Q8YPebYcdHjhxMDSOxeZ8KaY yRebEiFuikgN1mLL+4lcBuU0mSqhlCl+GNskdW2B7TgpeSV6z2lXWg227tJndAFZlK89 /TSpTcWdaCBQRzbiUwt5OZR7GspeBFVj1hWBii9XiNxpHrhMLKUHGj7UeGdJ3KxvPESt bx1bDhkK6FlyU+yjP46J4PoPpfEAMl/1cL4Wu7mFff9URKUe5CIb7wqvBSojPMeSrt6i O6JOwjquKmhNML8q9NK2VtoE7x1LNwUW6j9djaE3lO/Nwzfdnwe0Ng89oVxdIfcq0iOM XP5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78062-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78062-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a10-20020a170902ee8a00b001da2c896119si11592516pld.432.2024.02.23.01.56.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:56:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78062-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78062-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78062-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BB0A7B26C5A for ; Fri, 23 Feb 2024 09:48:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D968D5FDCD; Fri, 23 Feb 2024 09:45:01 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D08175EE71 for ; Fri, 23 Feb 2024 09:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681491; cv=none; b=iIpWLO8So57ergRLeRJkF4IGiD/MzYdLy5NbQclxuEMylMURPhE+Uh9DqWLHOE9fs46ABEogaTxKrRMxHp+iEBDddeyNWgpr4tqwd0VFoSWMhBCZwZcoXp4LQn6KHKmSJanS81klx1T6mihKuAYJpOiWe3F6EcEBSCaAIGQoTAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681491; c=relaxed/simple; bh=JmFgZtEJFcZh4DjZNnu6vM0KJrQ9j13y+0zGMDqBKA4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N2UPUoH+GEH8mEhiHAsXfypKoPg8Cr0kFLd00yiv0mB0W40QgbVkJlcF1QNJkz2yQQaU41IHceJfgkTj/a6JinimdxnLAEitenxjvLFw//120I0eFgDNk7eVX4GVI84kuUa3td5/ML1ftWLDlCSnIE7oHVYgX+VnFm8uUQ0/RzM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rdS6W-00080m-LP; Fri, 23 Feb 2024 10:44:28 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdS6V-002OkT-Aq; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tpb-0o; Fri, 23 Feb 2024 10:44:27 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Florian Fainelli , Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v6 2/8] net: phy: Add phydev->enable_tx_lpi to simplify adjust link callbacks Date: Fri, 23 Feb 2024 10:44:19 +0100 Message-Id: <20240223094425.691209-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791683137840965727 X-GMAIL-MSGID: 1791683137840965727 From: Andrew Lunn MAC drivers which support EEE need to know the results of the EEE auto-neg in order to program the hardware to perform EEE or not. The oddly named phy_init_eee() can be used to determine this, it returns 0 if EEE should be used, or a negative error code, e.g. -EOPPROTONOTSUPPORT if the PHY does not support EEE or negotiate resulted in it not being used. However, many MAC drivers get this wrong. Add phydev->enable_tx_lpi which indicates the result of the autoneg for EEE, including if EEE is administratively disabled with ethtool. The MAC driver can then access this in the same way as link speed and duplex in the adjust link callback. If enable_tx_lpi is true, the MAC should send low power indications and does not need to consider anything else with respect to EEE. Reviewed-by: Florian Fainelli Signed-off-by: Andrew Lunn Signed-off-by: Oleksij Rempel --- v2: Check for errors from genphy_c45_eee_is_active v5: Rename to enable_tx_lpi to fit better with phylink changes v6: enable_tx_lpi = !!err --- drivers/net/phy/phy.c | 7 +++++++ include/linux/phy.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 14224e06d69f..2bc0a7d51c63 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -983,9 +983,16 @@ static int phy_check_link_status(struct phy_device *phydev) if (phydev->link && phydev->state != PHY_RUNNING) { phy_check_downshift(phydev); phydev->state = PHY_RUNNING; + err = genphy_c45_eee_is_active(phydev, + NULL, NULL, NULL); + if (err < 0) + phydev->enable_tx_lpi = false; + else + phydev->enable_tx_lpi = !!err; phy_link_up(phydev); } else if (!phydev->link && phydev->state != PHY_NOLINK) { phydev->state = PHY_NOLINK; + phydev->enable_tx_lpi = false; phy_link_down(phydev); } diff --git a/include/linux/phy.h b/include/linux/phy.h index e3ab2c347a59..a880f6d7170e 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -594,6 +594,7 @@ struct macsec_ops; * @supported_eee: supported PHY EEE linkmodes * @advertising_eee: Currently advertised EEE linkmodes * @eee_enabled: Flag indicating whether the EEE feature is enabled + * @enable_tx_lpi: When True, MAC should transmit LPI to PHY * @lp_advertising: Current link partner advertised linkmodes * @host_interfaces: PHY interface modes supported by host * @eee_broken_modes: Energy efficient ethernet modes which should be prohibited @@ -713,6 +714,7 @@ struct phy_device { /* Energy efficient ethernet modes which should be prohibited */ u32 eee_broken_modes; + bool enable_tx_lpi; #ifdef CONFIG_LED_TRIGGER_PHY struct phy_led_trigger *phy_led_triggers; From patchwork Fri Feb 23 09:44:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 205261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp480013dyb; Fri, 23 Feb 2024 01:49:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUn68DEmk9IaHVq1MJmniKs857OGSsc4VBuHyNM/Mg3ALZ6Hlr8A20ROXBnfocTcWSWouVbyFijiwIeOCtCDC+n67+oyw== X-Google-Smtp-Source: AGHT+IF1PB8j9AEo4mE/aHhAD1XhOfNbbnE2d/+GEH5AiSYromQ6ycYnOElnQGDh1hGQ8Xp0HAZ1 X-Received: by 2002:a05:6102:32c3:b0:470:4aa5:2c5b with SMTP id o3-20020a05610232c300b004704aa52c5bmr1675869vss.0.1708681761378; Fri, 23 Feb 2024 01:49:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708681761; cv=pass; d=google.com; s=arc-20160816; b=BCIFDhMH5qy6zopGBBTZ2a5QkMzE4ZjWJR0MiQIJiD+84idMUMmr8XOg0Ha3e/qe9u yiyUK4Kf9Apv0WImZ546ayvlEXt5eE/vHEPxeaXb4bh+BNRfACQqX2o1lf1c3tY4PXqi G3uLr6sScPU07VWRjMoJOSAhItqjvn3MmdBxGOFP8waV51Wu3ni4gG8a3hQhnvecmnPc /o9JHqmv8XhtaeWe8Jo7lEG7JT+10Z7s66g5O7g8Nb+YAIwCJ6Cd9eTbCwG7bsY2kCYT o8vd5Mc0QF+tP8vc/IQtc3CpCIA688kYydSxo+aq4tfJIilYEQ4jHnewIV1EVUhnWdK1 hqYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=zCp7BA6mWer8o+IS54iUdXDIJ8On/1WEXgkoDVAL7YA=; fh=/mFbHcqW6l4fLIJBfKVNbHEV0oGb2iio8Q6EPf9P78A=; b=GbSTw/eBLKy8NGDNH1A6h8EqXkoKLiWTNpnla8jTIQXDP2qpYBcZhOjx6PPzuhm6m1 Keas8koEwkaN7xCTMCaX50gUH/0UwlJz8HWcs1LJnpxtZSVCfyzgONxI7xcBXKviAcbb vpIB/usn/dF+TfOc+TCaIWN86oozNpH3iCB5CuLqkRMZa8PdCpBMM6OeBnWRBAC8Cwu0 oVTnDrf1CRzc9lM15rDuCK4cSNscN/wO9XAU4ULX1a/jhI4tVfiLc+gxpD/OndYcXprd tIP1fQCh84dkxgoPqMzd4LEVeqHvUPr+NFdZ+TG/Hm8ynySqjOwl4tPX7Tx8D+x+meAd eeWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78066-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g7-20020a05620a13c700b0078724a3d83bsi14763591qkl.178.2024.02.23.01.49.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:49:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78066-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78066-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2484D1C24840 for ; Fri, 23 Feb 2024 09:49:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 288F65FF16; Fri, 23 Feb 2024 09:45:03 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99E4D5C91F for ; Fri, 23 Feb 2024 09:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681498; cv=none; b=AGgOghVegss1Kb5qxGeW59HSKdIB+OBwMQqbf1ARIj8RVS01n4JQ9HGUMwbKbWDkdZnsVkTpizhDeuc0G9p8QGDUOnyHpmd1CY5rpFqTqLh2USEPVwClqTwmuVx9E16ISLlSMsT4P3NdVytsARFp3FaW0D+0H778sec9rsEeUx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681498; c=relaxed/simple; bh=Q16DNgegfwpHQ9ZZfUC5bEHajPNhkT5JWZ+zZi0btB4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rFk9MPPEOcwUHra3CE8MnaMbyeG3igvUT2xwNMuHBKvYi17NTCR2cItv80ETxILpP3Ti8Xu4YFOPXbMN4YFpULtSO3dhVVJupN9UREXUHnir8fIT2M65LiYR+GvavX0pphuQlyOv1qhrEqSIGnj7CK4fuhVT3J2cA4K5X8QE1SY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rdS6W-00080l-LM; Fri, 23 Feb 2024 10:44:28 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdS6V-002OkU-B6; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tpl-0s; Fri, 23 Feb 2024 10:44:27 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Florian Fainelli , Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v6 3/8] net: phy: Add helper to set EEE Clock stop enable bit Date: Fri, 23 Feb 2024 10:44:20 +0100 Message-Id: <20240223094425.691209-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791682686907973232 X-GMAIL-MSGID: 1791682686907973232 From: Andrew Lunn The MAC driver can request that the PHY stops the clock during EEE LPI. This has normally been does as part of phy_init_eee(), however that function is overly complex and often wrongly used. Add a standalone helper, to aid removing phy_init_eee(). Signed-off-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Oleksij Rempel --- drivers/net/phy/phy.c | 20 ++++++++++++++++++++ include/linux/phy.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 2bc0a7d51c63..ab18b0d9beb4 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1579,6 +1579,26 @@ void phy_mac_interrupt(struct phy_device *phydev) } EXPORT_SYMBOL(phy_mac_interrupt); +/** + * phy_eee_clk_stop_enable - Clock should stop during LIP + * @phydev: target phy_device struct + * + * Description: Program the MMD register 3.0 setting the "Clock stop enable" + * bit. + */ +int phy_eee_clk_stop_enable(struct phy_device *phydev) +{ + int ret; + + mutex_lock(&phydev->lock); + ret = phy_set_bits_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, + MDIO_PCS_CTRL1_CLKSTOP_EN); + mutex_unlock(&phydev->lock); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_eee_clk_stop_enable); + /** * phy_init_eee - init and check the EEE feature * @phydev: target phy_device struct diff --git a/include/linux/phy.h b/include/linux/phy.h index a880f6d7170e..432c561f5809 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1995,6 +1995,7 @@ int phy_unregister_fixup_for_id(const char *bus_id); int phy_unregister_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask); int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable); +int phy_eee_clk_stop_enable(struct phy_device *phydev); int phy_get_eee_err(struct phy_device *phydev); int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_keee *data); int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_keee *data); From patchwork Fri Feb 23 09:44:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 205262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp480076dyb; Fri, 23 Feb 2024 01:49:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWn1mCS1FFGJd+STNOQDt01wxCbE3kgv02ONVLLct0P3Q9r+GNnUKfDQ6M+g1oXVeM+flf+lfsPoS3S3jgQbnF0S5KndQ== X-Google-Smtp-Source: AGHT+IF0JFB/NX9b7gICndZqq3RNF5KKPHLq/x98waxOqUiqmEaH8xOfoWqLlMQqVr7EugIwyfdF X-Received: by 2002:a17:90a:9b8c:b0:299:3511:1554 with SMTP id g12-20020a17090a9b8c00b0029935111554mr1095139pjp.40.1708681771638; Fri, 23 Feb 2024 01:49:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708681771; cv=pass; d=google.com; s=arc-20160816; b=ji4EAskspqxeTBtotmXHEB6WK3YEUkxesOFrN6gHvDoCNyfyUBalmt+b8FyUTmOAjN KtTgVZmXmuWcLWTtxZ//l1dra/VfKxgBF3kj3J8jNVWx5FzJN4QLCfRu+AQbr3a4PCTN QaVFtDUiJEW2PX2nUr4m2hU7llV393TB374Dq/NKmIMSJxLa/1FZ3OAEA4hT0V5GQ60p QTBfSiVxd6/wxMXATYA5xulYCzjOwJFoHg7nYnwStWwoApHrvIxHB7AymOPCNPz839x9 IxNCixRKV4eslr1+1X7P3LzqEqOv89fu7ePpBSPp3XB1eZh2xABb8iXJ+dND+Qmy841q mEiA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=edFLDTuzDrwmqIbrAtjgmcPlEbZe7AtS/HF/+IvRl1w=; fh=sVZ6H5f6ewU2fC+U58NocBocCWosMlAmPb9AApl9d+c=; b=BgFfpC7/mdno3wQ1zBq6Bjml/5H2iILxcyAMu7CQfE7n4thIGP/SGfXbu1nhDBayit bUYajNyMT/vVRVL4JZvGI76yG7GCGKoKju/DmgUusYDRpqQArJod8suQXocKbz91pN+G eO0361qOgY0pWZ6SFizda/XQeaghUV4AFBnVE8wqBdG4975SxxNHtQ+HZnSJtuj+6ysK 8o5pmJ0xX+E2Slbevs3bCkVNR6jRRi9XAwaluSXx5Brp5K/jDk3cN6JEMKtbb+hwgDWS WTdABKj6gv3ObYWOo07YIwfxSfDd0XHfeETGIx6JtAfzI7f5zM6QiqbSLD35c0U2UIDH /BHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78067-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78067-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ss5-20020a17090b2ec500b00299f2cf5bf1si887278pjb.175.2024.02.23.01.49.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:49:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78067-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78067-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78067-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 770BE282D16 for ; Fri, 23 Feb 2024 09:49:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A963260247; Fri, 23 Feb 2024 09:45:03 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05D7A5D48C for ; Fri, 23 Feb 2024 09:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681499; cv=none; b=Qyfvfk+HQ2WxTKkRZVQcXMudH02mT+G0pUGQ0w84+S/w1ufPlb8dAjhhS93Vfc/3lYhJqYgsIfAOPnRLx5rosFwd0biMO9C5sJvmijemVi0IFynqCq7h8NxaE45pIMWmdeLGJDoyZO9KjZsQvhxNsl/r9/Ovk25EohdG+3dV7So= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681499; c=relaxed/simple; bh=TR/ZiArrOlLQxYU0ILdHl+xxn41A+NFoAQya+K+oN8A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EOwuwogsQyp9YwljQtznIwd4qmgOqRaptZFxdxFhVZtyav6N8FHSVn0cA+Tl9k3ZqbufD5K8z6J5PMnxrgrmoA48VlUwP3C+sSIJJVp/zE1Kp23uJrU/9yQ71Nu7JI0bhlTiIh5oSrDdxH37K3xMLuAA/ewe4YYoZ5ZSck6z3Wc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rdS6W-00080n-LP; Fri, 23 Feb 2024 10:44:28 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdS6V-002OkW-Cm; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tpv-0w; Fri, 23 Feb 2024 10:44:27 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Russell King , Florian Fainelli , Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v6 4/8] net: phy: Keep track of EEE configuration Date: Fri, 23 Feb 2024 10:44:21 +0100 Message-Id: <20240223094425.691209-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791682697774053719 X-GMAIL-MSGID: 1791682697774053719 From: Andrew Lunn Have phylib keep track of the EEE configuration. This simplifies the MAC drivers, in that they don't need to store it. Future patches to phylib will also make use of this information to further simplify the MAC drivers. Reviewed-by: Russell King (Oracle) Signed-off-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Oleksij Rempel --- v6: add @ in front of eee_cfg --- drivers/net/phy/phy.c | 7 +++++-- include/linux/phy.h | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index ab18b0d9beb4..f0ed07c74a36 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1660,8 +1660,8 @@ EXPORT_SYMBOL(phy_get_eee_err); * @phydev: target phy_device struct * @data: ethtool_keee data * - * Description: it reportes the Supported/Advertisement/LP Advertisement - * capabilities. + * Description: reports the Supported/Advertisement/LP Advertisement + * capabilities, etc. */ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_keee *data) { @@ -1672,6 +1672,7 @@ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_keee *data) mutex_lock(&phydev->lock); ret = genphy_c45_ethtool_get_eee(phydev, data); + eeecfg_to_eee(&phydev->eee_cfg, data); mutex_unlock(&phydev->lock); return ret; @@ -1694,6 +1695,8 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_keee *data) mutex_lock(&phydev->lock); ret = genphy_c45_ethtool_set_eee(phydev, data); + if (!ret) + eee_to_eeecfg(data, &phydev->eee_cfg); mutex_unlock(&phydev->lock); return ret; diff --git a/include/linux/phy.h b/include/linux/phy.h index 432c561f5809..c315928357c8 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -30,6 +30,7 @@ #include #include +#include #define PHY_DEFAULT_FEATURES (SUPPORTED_Autoneg | \ SUPPORTED_TP | \ @@ -595,6 +596,7 @@ struct macsec_ops; * @advertising_eee: Currently advertised EEE linkmodes * @eee_enabled: Flag indicating whether the EEE feature is enabled * @enable_tx_lpi: When True, MAC should transmit LPI to PHY + * @eee_cfg: User configuration of EEE * @lp_advertising: Current link partner advertised linkmodes * @host_interfaces: PHY interface modes supported by host * @eee_broken_modes: Energy efficient ethernet modes which should be prohibited @@ -715,6 +717,7 @@ struct phy_device { /* Energy efficient ethernet modes which should be prohibited */ u32 eee_broken_modes; bool enable_tx_lpi; + struct eee_config eee_cfg; #ifdef CONFIG_LED_TRIGGER_PHY struct phy_led_trigger *phy_led_triggers; From patchwork Fri Feb 23 09:44:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 205273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp482253dyb; Fri, 23 Feb 2024 01:56:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUkVLwC/K2FxWOCD21bL41o4IOScwjJf6Mtnq5Rd5hIEipBu9bKl+VISmawhxiXthN1hfe/iWFbkqz+D9/lhA3Zh7lxjQ== X-Google-Smtp-Source: AGHT+IE//dXHkAC5/g3Cpf4mc6Ixfcjg/EHXZR1QxJnABSg3RBDEqBJhLFBvDY72L4PLBMd5k6Zt X-Received: by 2002:a05:6a21:1207:b0:1a0:c655:723 with SMTP id oe7-20020a056a21120700b001a0c6550723mr1167756pzb.29.1708682218659; Fri, 23 Feb 2024 01:56:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708682218; cv=pass; d=google.com; s=arc-20160816; b=I/LhDuzGyWRyd2ZXWL0AhRVMq5AaRCA3huSjn8VWJd4o4r65J1SR6k3D8/2dx82012 JJD86+xlYEwDXikgz3lB5f17WSZC/RbRKEjo6rFYHPqk6Y1o+Jz2PPRLmu+ISa388fsJ UHHpukmtm0TDjf8C6Yq1h8N8b1o597Lg6Z3got/9lhSq6mLk6h/1kIrBDmrko51wpoBs 4RNLW0CkRS2lcZh8R6AjFp+83LbvNGgeRfY5jARvdq1TLhf0Mr7SIwt7XOttwtJLAPam OPjLjs7JNRQzLs6nBxODNTo/EG7v3Nb1aYZE0oos+rWjVaAjKJMa2RkgYsYf3S2xyFZH 7Uvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=MoZAfHV+t0ink7pwI8YcV6nIQ2tEOeqs3wjBlIFrcWc=; fh=/mFbHcqW6l4fLIJBfKVNbHEV0oGb2iio8Q6EPf9P78A=; b=QBDCsp4vh19EJUpLv7YlHuCeQt6m7aLxLRZssKWxFmK6vVyPQYOAn2ZFLWkTNN82xU ihkDtP+Jp09mfdNodf8YfIcDS/kopcXPtEQJAQHxgjmiKpEC/p1uFCGocKAqEOERRTEe 6hiM/OGdDfyHrXVECgIufIvW1SKHRzW0vCGQQ6B0PX+dDdagQvKp7kgQxQUiUo5Dk0xX BMc3+r9R+oxMCW+MAMT1NuKeW9oa3iWXIgvYPzhubiWrOiZeT19yrnLBsjsJFOubDcrv +zdpYMiBqu1o8RNh7qjaATlqdEK3CNJoWHozByArvHtKeTtU1ZNWOb1gJ+Wj9SKTo/XY h2ww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78064-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e6-20020a170902ef4600b001dc679303a6si1326598plx.71.2024.02.23.01.56.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:56:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78064-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78064-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BD801B26EB6 for ; Fri, 23 Feb 2024 09:49:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DEAA5FEF1; Fri, 23 Feb 2024 09:45:02 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 509065CDE0 for ; Fri, 23 Feb 2024 09:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681496; cv=none; b=nAwbMMCrEert8+doaQoynhuoKyCZ6q007Meu62Qg/8r6tq49ByPO0Ap9u6j6TBfA77PsSM7fIYCp7mj8ib6iRng5a6PALD0TFEa92eVUVF1uDmcMhBsFMq2R2sWLEpGJsYtwaODIGSjzuUJtijSe5WcAY144yW30qKgJAlTlScA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681496; c=relaxed/simple; bh=W5GUBN+TQsdqma/oE8PqIZprbboAR43YBWGFUolTyEM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JudKAmo8+i38NZptHUvN+TQz2krRymJSslLGfT2io/vt2bz3rI6RSkqEBzkuOvWWo0iywNybBPg6+UChaqjbpQ5BnbK0wryZoCxNkwtxCZ9azwRie3jnZESoXtQoDYn+gsEnGzsAhpbdYhGWd58yHgteCMhvlMJWRzuRBmhHJqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rdS6W-00080p-LO; Fri, 23 Feb 2024 10:44:28 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdS6V-002OkY-CV; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tq5-0z; Fri, 23 Feb 2024 10:44:27 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Florian Fainelli , Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v6 5/8] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes Date: Fri, 23 Feb 2024 10:44:22 +0100 Message-Id: <20240223094425.691209-6-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791683166010447453 X-GMAIL-MSGID: 1791683166010447453 From: Andrew Lunn The MAC driver changes its EEE hardware configuration in its adjust_link callback. This is called when auto-neg completes. Disabling EEE via eee_enabled false will trigger an autoneg, and as a result the adjust_link callback will be called with phydev->enable_tx_lpi set to false. Similarly, eee_enabled set to true and with a change of advertised link modes will result in a new autoneg, and a call the adjust_link call. If set_eee is called with only a change to tx_lpi_enabled which does not trigger an auto-neg, it is necessary to call the adjust_link callback so that the MAC is reconfigured to take this change into account. When setting phydev->enable_tx_lpi, take both eee_enabled and tx_lpi_enabled into account, so the MAC drivers just needs to act on phydev->enable_tx_lpi and not the whole EEE configuration. Signed-off-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Oleksij Rempel --- v7: remove ' comment and parenthesis or return --- drivers/net/phy/phy-c45.c | 11 ++++++++--- drivers/net/phy/phy.c | 25 ++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index fa5145c9328e..f98600ed3b35 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -1550,6 +1550,8 @@ EXPORT_SYMBOL(genphy_c45_ethtool_get_eee); * advertised, but the previously advertised link modes are * retained. This allows EEE to be enabled/disabled in a * non-destructive way. + * Returns either error code, 0 if there was no change, or positive + * value if there was a change which triggered auto-neg. */ int genphy_c45_ethtool_set_eee(struct phy_device *phydev, struct ethtool_keee *data) @@ -1581,9 +1583,12 @@ int genphy_c45_ethtool_set_eee(struct phy_device *phydev, ret = genphy_c45_an_config_eee_aneg(phydev); if (ret < 0) return ret; - if (ret > 0) - return phy_restart_aneg(phydev); - + if (ret > 0) { + ret = phy_restart_aneg(phydev); + if (ret < 0) + return ret; + return 1; + } return 0; } EXPORT_SYMBOL(genphy_c45_ethtool_set_eee); diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index f0ed07c74a36..9e26508d5a31 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -988,7 +988,8 @@ static int phy_check_link_status(struct phy_device *phydev) if (err < 0) phydev->enable_tx_lpi = false; else - phydev->enable_tx_lpi = !!err; + phydev->enable_tx_lpi = (err & phydev->eee_cfg.tx_lpi_enabled); + phy_link_up(phydev); } else if (!phydev->link && phydev->state != PHY_NOLINK) { phydev->state = PHY_NOLINK; @@ -1679,6 +1680,21 @@ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_keee *data) } EXPORT_SYMBOL(phy_ethtool_get_eee); +/* auto-neg not triggered, directly inform the MAC if something + * changed + */ +static void phy_ethtool_set_eee_noneg(struct phy_device *phydev, + struct ethtool_keee *data) +{ + if (phydev->eee_cfg.tx_lpi_enabled != + data->tx_lpi_enabled) { + eee_to_eeecfg(data, &phydev->eee_cfg); + phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg); + if (phydev->link) + phy_link_up(phydev); + } +} + /** * phy_ethtool_set_eee - set EEE supported and status * @phydev: target phy_device struct @@ -1695,11 +1711,14 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_keee *data) mutex_lock(&phydev->lock); ret = genphy_c45_ethtool_set_eee(phydev, data); - if (!ret) + if (ret >= 0) { + if (ret == 0) + phy_ethtool_set_eee_noneg(phydev, data); eee_to_eeecfg(data, &phydev->eee_cfg); + } mutex_unlock(&phydev->lock); - return ret; + return ret < 0 ? ret : 0; } EXPORT_SYMBOL(phy_ethtool_set_eee); From patchwork Fri Feb 23 09:44:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 205271 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp482107dyb; Fri, 23 Feb 2024 01:56:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWT92ixiG+Kss1wZ1K+cVWs+ooXkFrfxIVYKlyUzapCOdGvWJ9NrffGtFp8/HfjKNo0fjrgnE4PDE8JNLUOFu4LwrlXCw== X-Google-Smtp-Source: AGHT+IEGBueBV+lHKICrbdgh/7f9HNiMxWOnF6IsfTrEIalZPf8yO9Qhm7jWWeZDGp0eyC75wLcX X-Received: by 2002:a17:90b:4f4a:b0:29a:7392:2ea9 with SMTP id pj10-20020a17090b4f4a00b0029a73922ea9mr1140087pjb.7.1708682183708; Fri, 23 Feb 2024 01:56:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708682183; cv=pass; d=google.com; s=arc-20160816; b=Oa0carl6BDctlYD1VODnBiSXdrwinNupNu5Qynt573E9UWo8PCYFqA18B4DyvV3lPy 7f1Ht8HvdIaB9jcDPs8L+n3uHrRrOEv0JrRry3haBDVT9ZuWEtKMGJFo1J05yo2txwJX B6UwrfiVHpCZYwX0PKbnAiFQ7AAYL5xgEuC8Xn93W9yNMogLppmdSR3jYOHrh+5Bw0sp UHcBCrUO9YpY1+fbzhXbdguYBX0DSOhdcozQLyZEDrw1n3IuoxTqjpIiqWwOE59c4Bgp Mr4fbLprSg/H84c/NLRZMa0SWXd6ugd4Nzz16us9k33QibLH4bdgaG3S21O1J83NgZwR dpaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=o91fmAMukUAaYFatpyCTEUfLfbJhCMnt4Mo6GZ5zrSM=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=g99Q2k/q1r0LTnBwaKC67WA4aEvtt5imtMJrYs74dmuA4c77GQgAv0RlzaFf2dLKca eGM4ANvWy0PZtzg2SYBDDif6kV6CP2J/Ypzv1scFVMZwDMpkib8BdXSQDoE19AhuXqzF 7HUy2ashViI8i0EivAkv3F3uB8Bqj8jI84erV9syGczOi6PHmNPlfz/QCG/8Ru2U/4a3 zvdd5tnN6xuIkkWC8YFFgdCZlG6jQGNrBx6HJkHmqTGCntxvmDBrDu5AJfVKG/NwDSNl iUMFzRnvpfYbMHpv5qvT26B2nEyNNp88iIo4e2Gxc4+NBuNiJyQ6ucBiVbYXSoxyr5+P Zerw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78059-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78059-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l18-20020a637012000000b005dc484bc9efsi11950312pgc.22.2024.02.23.01.56.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:56:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78059-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78059-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78059-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8D971B23920 for ; Fri, 23 Feb 2024 09:48:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8ADD55FDAD; Fri, 23 Feb 2024 09:45:01 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D3F15DF2D for ; Fri, 23 Feb 2024 09:44:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681488; cv=none; b=QQPCySLYd/VGLmhyJ1CuYlCam6/lqNfTws5gyDujO35b8Ld6tahzRsD5AjpMJlHIG5na5/4MoAgDqOMP9uSAzkQ1AuHKlKGLeG2GeMhjAI4fvk+j+L54ZhaJfiyYs2/2bvCzCwkWFe9CxW0O+KYWdYTO1g6ZoYcjJa++oNhyYWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681488; c=relaxed/simple; bh=oildCgA8lIKBTQwWR1dqMg71z9FE4p8hTesSr2gGjm8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E9b4dCN94YgsW1eONoAr5RAtl73DeFRb0qAQhW8mVYFIgukBdm0JG8UHm7ITeZFTMEIs/nL4zCLV0RSgNjEsNOEGFS51kE5MvVK5cGqx3lBBB+NJ4LH2/0ZEGdMPWKXSBhjIBbKd6+aICXJKpWvxQdDJCemhXih3f3zPUqxs3P8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rdS6W-00080o-F4; Fri, 23 Feb 2024 10:44:28 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdS6V-002Oka-DR; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tqH-13; Fri, 23 Feb 2024 10:44:27 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v6 6/8] net: phy: Add phy_support_eee() indicating MAC support EEE Date: Fri, 23 Feb 2024 10:44:23 +0100 Message-Id: <20240223094425.691209-7-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791683129875322420 X-GMAIL-MSGID: 1791683129875322420 From: Andrew Lunn In order for EEE to operate, both the MAC and the PHY need to support it, similar to how pause works. With some exception - a number of PHYs have SmartEEE or AutoGrEEEn support in order to provide some EEE-like power savings with non-EEE capable MACs. Copy the pause concept and add the call phy_support_eee() which the MAC makes after connecting the PHY to indicate it supports EEE. phylib will then advertise EEE when auto-neg is performed. Signed-off-by: Andrew Lunn Signed-off-by: Oleksij Rempel --- v6: reword commit message and comment for phy_support_eee() --- drivers/net/phy/phy_device.c | 28 ++++++++++++++++++++++++++++ include/linux/phy.h | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 2eefee970851..72452e6a478c 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2910,6 +2910,34 @@ void phy_advertise_eee_all(struct phy_device *phydev) } EXPORT_SYMBOL_GPL(phy_advertise_eee_all); +/** + * phy_support_eee - Set initial EEE policy configuration + * @phydev: Target phy_device struct + * + * This function configures the initial policy for Energy Efficient Ethernet + * (EEE) on the specified PHY device, influencing that EEE capabilities are + * advertised before the link is established. It should be called during PHY + * registration by the MAC driver and/or the PHY driver (for SmartEEE PHYs) + * if MAC supports LPI or PHY is capable to compensate missing LPI functionality + * of the MAC. + * + * The function sets default EEE policy parameters, including preparing the PHY + * to advertise EEE capabilities based on hardware support. + * + * It also sets the expected configuration for Low Power Idle (LPI) in the MAC + * driver. If the PHY framework determines that both local and remote + * advertisements support EEE, and the negotiated link mode is compatible with + * EEE, it will set enable_tx_lpi = true. The MAC driver is expected to act on + * this setting by enabling the LPI timer if enable_tx_lpi is set. + */ +void phy_support_eee(struct phy_device *phydev) +{ + linkmode_copy(phydev->advertising_eee, phydev->supported_eee); + phydev->eee_cfg.tx_lpi_enabled = true; + phydev->eee_cfg.eee_enabled = true; +} +EXPORT_SYMBOL(phy_support_eee); + /** * phy_support_sym_pause - Enable support of symmetrical pause * @phydev: target phy_device struct diff --git a/include/linux/phy.h b/include/linux/phy.h index c315928357c8..661c2c969b19 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -706,7 +706,7 @@ struct phy_device { __ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising); /* used with phy_speed_down */ __ETHTOOL_DECLARE_LINK_MODE_MASK(adv_old); - /* used for eee validation */ + /* used for eee validation and configuration*/ __ETHTOOL_DECLARE_LINK_MODE_MASK(supported_eee); __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising_eee); bool eee_enabled; @@ -1973,6 +1973,7 @@ void phy_advertise_supported(struct phy_device *phydev); void phy_advertise_eee_all(struct phy_device *phydev); void phy_support_sym_pause(struct phy_device *phydev); void phy_support_asym_pause(struct phy_device *phydev); +void phy_support_eee(struct phy_device *phydev); void phy_set_sym_pause(struct phy_device *phydev, bool rx, bool tx, bool autoneg); void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx); From patchwork Fri Feb 23 09:44:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 205259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp479903dyb; Fri, 23 Feb 2024 01:49:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXbEXQo6QJAufw1KgsrvOCYzf1s1sEuSyjpkgZyDry43fM5SMfvJW66kzmK/Xk5ebZfXt4bhmwZIYWzf7tw+Kx8CWZCvw== X-Google-Smtp-Source: AGHT+IHAA3PMgUx7JH/kVq4kIaVN8t3Ipw3P712EbZaAXELf972+ngSE6+K5i7yCMmYZ1zXkVQrk X-Received: by 2002:a05:620a:214b:b0:787:8148:ee4c with SMTP id m11-20020a05620a214b00b007878148ee4cmr1497086qkm.47.1708681743097; Fri, 23 Feb 2024 01:49:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708681743; cv=pass; d=google.com; s=arc-20160816; b=o1Wa/Ful/uBuoNSlFgfhjGfXaz8HyhEm1em4h2tPsNtaJA0HEKHMr6wCcMZows23hj +WhDhqsu8AWRnAEb2c6AYYWd4nUpymCb5B9Y5LlQ1dLUoF0Yg7fpqE1QH/hJTjghqa9r GWBbpi9cZm3Fp2tFuO/vG2ss2UMI2H2g9/hlpd+3+vR/pVuxMD87wnY9ihrCTaHF/ZNc 9T0cENa2UknvVjte+e2aghXBZRMyG8wbuJBJk7fYLSzvktIsXemh3gcr+wWA5FAdIpFZ W578hfMx7gDREtsWTkcmEoTgwzafL53y3AjidbUBabXWu5kv4D6hTQLETfbFoVOEF16+ Ib7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=itjR1WvG8tov6WBmnWp0zImRYwxk+J2bqa+1guHXKQA=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=akVpsatqLmgPOKGe3dtwWWmY6fcz/S8BJFUSz6aFdhNkD6Li8RS+o0doIAcTIb1QZO sp3p6ll85wcs7L/IL0rmAbHRrjtPCDccvvvBjSc//ofsn21sluszQL7Txek/0s2vM8q9 Rv/L55gMQJlj8jOOH/fMtVPfZevxFKVKCIiVpD+G23RuA5i6U9BFN5J4QXGB+oLnLEHg XHdBqriWl20kkIzCUySZQQlz/GXToqGzzSGN8RPpYZcDTiCJ8QQqa3iJv5wFsq46eMAV ebENaXZuUyl7M78VEXGi2tO3/BQxgj96W3uTXqfL6ol65uCR6U2YyqG+zQrG9fMZwWpz Jgfw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78063-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78063-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id du48-20020a05620a47f000b0078786dce315si5076187qkb.354.2024.02.23.01.49.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:49:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78063-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78063-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78063-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C81291C248AB for ; Fri, 23 Feb 2024 09:49:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AE655FEEC; Fri, 23 Feb 2024 09:45:02 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A45F5CDC2 for ; Fri, 23 Feb 2024 09:44:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681494; cv=none; b=k7K9ubd15JUcr1GWNs+Hn0Iz4spEy6/vllY0ktGrc/6W8zXaPhBQG7IdzheX3TIpdhYEVnXuK/KCVXyaq2tYvID2dlhdZwuj9j/iDGFg9G6yWwB8AIHt1fCCdKK/KWT5U/EhLItI0SBDic8bU1qlh9OsW5LdKsAp0PI6RaI9mug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681494; c=relaxed/simple; bh=RUBXoykfHsI8g81DTZ9jhWky7Ii6+Okm8CvBUDS9aVU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CLBS47GRz7i+LwfmGQwtcW+qUKJXcdQC2hqqjeDRsi2VAvDbP20B1RRH3T1HCWoLvjybrvjZiO7YLL0EsVajA0w8glTSs1wTYeAWQf44jB85jzObF/dMOuc4egDt2/1d88qVFE6ddGzD4Cam/PYvF2UdPWIe9E6rREa6zI8njEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rdS6W-00080r-F4; Fri, 23 Feb 2024 10:44:28 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdS6V-002Okb-Fa; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tqR-17; Fri, 23 Feb 2024 10:44:27 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v6 7/8] net: fec: Move fec_enet_eee_mode_set() and helper earlier Date: Fri, 23 Feb 2024 10:44:24 +0100 Message-Id: <20240223094425.691209-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791682667457875054 X-GMAIL-MSGID: 1791682667457875054 From: Andrew Lunn FEC is about to get its EEE code re-written. To allow this, move fec_enet_eee_mode_set() before fec_enet_adjust_link() which will need to call it. Signed-off-by: Andrew Lunn Signed-off-by: Oleksij Rempel Reviewed-by: Wei Fang --- drivers/net/ethernet/freescale/fec_main.c | 75 ++++++++++++----------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 207f1f66c117..a2c786550342 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2017,6 +2017,44 @@ static int fec_get_mac(struct net_device *ndev) /* * Phy section */ + +/* LPI Sleep Ts count base on tx clk (clk_ref). + * The lpi sleep cnt value = X us / (cycle_ns). + */ +static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) +{ + struct fec_enet_private *fep = netdev_priv(ndev); + + return us * (fep->clk_ref_rate / 1000) / 1000; +} + +static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) +{ + struct fec_enet_private *fep = netdev_priv(ndev); + struct ethtool_keee *p = &fep->eee; + unsigned int sleep_cycle, wake_cycle; + int ret = 0; + + if (enable) { + ret = phy_init_eee(ndev->phydev, false); + if (ret) + return ret; + + sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); + wake_cycle = sleep_cycle; + } else { + sleep_cycle = 0; + wake_cycle = 0; + } + + p->tx_lpi_enabled = enable; + + writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); + writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); + + return 0; +} + static void fec_enet_adjust_link(struct net_device *ndev) { struct fec_enet_private *fep = netdev_priv(ndev); @@ -3121,43 +3159,6 @@ static int fec_enet_set_coalesce(struct net_device *ndev, return 0; } -/* LPI Sleep Ts count base on tx clk (clk_ref). - * The lpi sleep cnt value = X us / (cycle_ns). - */ -static int fec_enet_us_to_tx_cycle(struct net_device *ndev, int us) -{ - struct fec_enet_private *fep = netdev_priv(ndev); - - return us * (fep->clk_ref_rate / 1000) / 1000; -} - -static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) -{ - struct fec_enet_private *fep = netdev_priv(ndev); - struct ethtool_keee *p = &fep->eee; - unsigned int sleep_cycle, wake_cycle; - int ret = 0; - - if (enable) { - ret = phy_init_eee(ndev->phydev, false); - if (ret) - return ret; - - sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); - wake_cycle = sleep_cycle; - } else { - sleep_cycle = 0; - wake_cycle = 0; - } - - p->tx_lpi_enabled = enable; - - writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); - writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); - - return 0; -} - static int fec_enet_get_eee(struct net_device *ndev, struct ethtool_keee *edata) { From patchwork Fri Feb 23 09:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 205258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp479750dyb; Fri, 23 Feb 2024 01:48:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUP2Lg4pCUt9469fbLEX8kKdyH6VFvrX0EDm9Ym0PJJT22wsT9zAkGCkKgy+7NiBJqE68aN6ETy4lnH3zxT7tA5H95V3A== X-Google-Smtp-Source: AGHT+IFX28KeSQ8P7bDw3eu69v669XgfEpKegiu6A7rXDM5LTh042B5Y1BRairjeYa27kXw3D9PT X-Received: by 2002:a17:90b:2394:b0:29a:6d80:364 with SMTP id mr20-20020a17090b239400b0029a6d800364mr1101005pjb.39.1708681715048; Fri, 23 Feb 2024 01:48:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708681715; cv=pass; d=google.com; s=arc-20160816; b=Qe2ZyHwlGoXbOB763ZRpFLvuPttmB/f28T7tozaFi3rixBMmyVRQMGCdfV4xnnzjHc 7xAfw+JXeT5nF/eh9gMCGVLsm+xDAFL6X0SbkAka3lzpmQ4ZcLVoKESIF/0O4aYgT75b Dy7hZDg1qjuygg3vPzV/KG3mn26xAGq0jM6xrKT2P8Ceca2x/Khwg6a1gK4TFjq/6UcA A5rC3eWKPKrJsZJV8OBwFdKc0xqvtpJN97Xd8AUEmFJvL3AurQaffqdR5dNCAGzaH35Y UYJFSsh4SM9QuA7YByfJSttjh2ZJ/XnLm9gsgVBpR0uUOgT5UrV6BBjMqqupsp4jkz6V X2sQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=DDbrUC5I1OaMgn5CRqUriz+FGHjAWn0xlJzdmc+uPbg=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=rmYFh/cVhvm0iHzEAvX+pT80zheUV+nAP+ZVrrnVZDqMJdADYIo/28hFSxk9GftyK+ mMzctwVXgyRBC+iXOVYjMcMoiPykBgZK2Uauj1onffD3A5XdteGf62MbgowpEC663eUL h+6xuxeDxAFXR/7MqEVJlil8trWysEIBQajMKmOvGtNZ1jMrRN+zk1cDqTmwYFl2VlSP GSFJdrZhJSiofbpvCv54MWbYv+WDkVRpPQz93sD76tIVvltnjeEyEkMOPlPjn82/BZSt LXySAwfXbjohBVpXjawhccy6kqv3VT8RzcvcbqGm5ExXHbIyKzQ8e3Kos8lMlrwXRw9Q wXxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78061-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78061-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ss5-20020a17090b2ec500b00299f2cf5bf1si887278pjb.175.2024.02.23.01.48.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:48:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78061-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-78061-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78061-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8EBF6282F5D for ; Fri, 23 Feb 2024 09:48:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 752BD5FDA1; Fri, 23 Feb 2024 09:45:01 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB4E65CDC3 for ; Fri, 23 Feb 2024 09:44:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681490; cv=none; b=OlE1unc9hg/gSoNbhvMyW4SXHhd3m5Wfo3pJwoeUIgq2VVVmDTU7r3jJtbe41ntAQn9K5TNOPLjQS+6RO5NMQjQ4RbjwOAc2wOM4vKio73BhRA3yacv+AP/kz4G1gncMqbIUl5ct4Z4EohsNps32KY9bzINXVJ+U6xIgROuWumw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681490; c=relaxed/simple; bh=XKcT45bumpicsgmOQeai5NcHMqk50lyvyruWB4lGLD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Hsq6pIcRVUYoul4xgBMVZH4owqw14gsSYDkILXJPKtts3AdAXvvYu/gvqOKp7n+5Qtxw+r8fh/tdq0jthMeakp90csBuueOaO47aXEzovCLuccQXP7CoifRYHj8NopL8bSQ2/7z6YU7MlJy8z1Qzk3t41fKtQiA2D66PDz8YT7o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rdS6W-00080q-F4; Fri, 23 Feb 2024 10:44:28 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdS6V-002Okf-F4; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tqb-1A; Fri, 23 Feb 2024 10:44:27 +0100 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team Subject: [PATCH net-next v6 8/8] net: fec: Fixup EEE Date: Fri, 23 Feb 2024 10:44:25 +0100 Message-Id: <20240223094425.691209-9-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-1-o.rempel@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791682637817334150 X-GMAIL-MSGID: 1791682637817334150 From: Andrew Lunn The enabling/disabling of EEE in the MAC should happen as a result of auto negotiation. So move the enable/disable into fec_enet_adjust_link() which gets called by phylib when there is a change in link status. fec_enet_set_eee() now just stores away the LPI timer value. Everything else is passed to phylib, so it can correctly setup the PHY. fec_enet_get_eee() relies on phylib doing most of the work, the MAC driver just adds the LPI timer value. Call phy_support_eee() if the quirk is present to indicate the MAC actually supports EEE. Signed-off-by: Andrew Lunn Tested-by: Oleksij Rempel (On iMX8MP debix) Signed-off-by: Oleksij Rempel Reviewed-by: Wei Fang --- v2: Only call fec_enet_eee_mode_set for those that support EEE v7: update against kernel v6.8-rc4 --- drivers/net/ethernet/freescale/fec_main.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index a2c786550342..d7693fdf640d 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2033,13 +2033,8 @@ static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) struct fec_enet_private *fep = netdev_priv(ndev); struct ethtool_keee *p = &fep->eee; unsigned int sleep_cycle, wake_cycle; - int ret = 0; if (enable) { - ret = phy_init_eee(ndev->phydev, false); - if (ret) - return ret; - sleep_cycle = fec_enet_us_to_tx_cycle(ndev, p->tx_lpi_timer); wake_cycle = sleep_cycle; } else { @@ -2047,8 +2042,6 @@ static int fec_enet_eee_mode_set(struct net_device *ndev, bool enable) wake_cycle = 0; } - p->tx_lpi_enabled = enable; - writel(sleep_cycle, fep->hwp + FEC_LPI_SLEEP); writel(wake_cycle, fep->hwp + FEC_LPI_WAKE); @@ -2094,6 +2087,8 @@ static void fec_enet_adjust_link(struct net_device *ndev) netif_tx_unlock_bh(ndev); napi_enable(&fep->napi); } + if (fep->quirks & FEC_QUIRK_HAS_EEE) + fec_enet_eee_mode_set(ndev, phy_dev->enable_tx_lpi); } else { if (fep->link) { netif_stop_queue(ndev); @@ -2453,6 +2448,9 @@ static int fec_enet_mii_probe(struct net_device *ndev) else phy_set_max_speed(phy_dev, 100); + if (fep->quirks & FEC_QUIRK_HAS_EEE) + phy_support_eee(phy_dev); + fep->link = 0; fep->full_duplex = 0; @@ -3172,7 +3170,6 @@ fec_enet_get_eee(struct net_device *ndev, struct ethtool_keee *edata) return -ENETDOWN; edata->tx_lpi_timer = p->tx_lpi_timer; - edata->tx_lpi_enabled = p->tx_lpi_enabled; return phy_ethtool_get_eee(ndev->phydev, edata); } @@ -3182,7 +3179,6 @@ fec_enet_set_eee(struct net_device *ndev, struct ethtool_keee *edata) { struct fec_enet_private *fep = netdev_priv(ndev); struct ethtool_keee *p = &fep->eee; - int ret = 0; if (!(fep->quirks & FEC_QUIRK_HAS_EEE)) return -EOPNOTSUPP; @@ -3192,15 +3188,6 @@ fec_enet_set_eee(struct net_device *ndev, struct ethtool_keee *edata) p->tx_lpi_timer = edata->tx_lpi_timer; - if (!edata->eee_enabled || !edata->tx_lpi_enabled || - !edata->tx_lpi_timer) - ret = fec_enet_eee_mode_set(ndev, false); - else - ret = fec_enet_eee_mode_set(ndev, true); - - if (ret) - return ret; - return phy_ethtool_set_eee(ndev->phydev, edata); }