Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp458384lqb; Thu, 29 Feb 2024 06:08:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUBQ88BNkvKqO8ty+b4GJM7IED0GkbxGzsv5qsuD2DfPpgUnnu9RdbeV6ryULYk3BdwojFO+LbpQ/8SQxkMca5ZewKwOr5622/T8G3Ckw== X-Google-Smtp-Source: AGHT+IEohG7q2pAgPF23d8JuogGoqJgcKLyfdvmUcBiVTqHVGoU2m4OIEKjXzU6EyZkC9yEOJ64m X-Received: by 2002:a17:906:dda:b0:a3f:1139:13bc with SMTP id p26-20020a1709060dda00b00a3f113913bcmr1316566eji.74.1709215732515; Thu, 29 Feb 2024 06:08:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709215732; cv=pass; d=google.com; s=arc-20160816; b=HE2G3/Uzk/dJQnaW0t9XsHl3zE3IksNSQ8LgMpEDVP1DU/dTIFWGlx+odkZ8vpefo5 Q0fHiTgwcauSwZBcr97RlGuonftdeiYFKSF9rhbBJ/PnAo4lYLVByqWZg/RAIK0GsGLz WvrCFBaSY55yRUbuJY2dv7GDOvPDbI6s2KKWoeSfWwid1gip8FULoCw4FsYqdtT3/ktn 384ks7n1VoysvviJTHna/anqbY5zfOkxa7aTrtfsf9BULC8IJlC7HHz5hi+TZrCeoWd7 X7lrhTYOtqZRy+8tfU/+WeKN5Vmj2SYsojRXBtPYbk83bHSkM+f+d8LWfCZlDkG5ar/w F1mQ== 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=WNmGdwEPdSSbQqgKoAA0ctSBHNDCEaVDPhu7VCmGgM4=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=GDlB/Ax3B2QCCTsMWWAVzVILiszNnUqvNubn0PCvSNwEKcWVUExy34qYGjZMi8+n52 31+8EiGU4bwaXoRjWqzIwMIvoFor3TGoSSKtSNysaOZ1z1yNZWz0+Qlb2GmSjBY1KILD lzktLIrQMkewL3M5LhOxz3yGoY2/ZAxvP7LSSC2UaMVT3W3TFQAMbNpYf6qjFraV+mxi Vwa916px7UsRjhjTD2tTo1k1A9SsO6mxgnhp7vYrVxj1UiBceHhMO9Fz0XaxdThB3TPf sU+pYMLkP4US7FK6q7jlPSQs9Zim+cHbHhkOduKuiZ4jNZKl+VoB4/sNdDludQzxJTHs uubg==; 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-86799-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86799-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id js20-20020a170906ca9400b00a441fccae15si612495ejb.151.2024.02.29.06.08.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 06:08:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86799-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-86799-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86799-linux.lists.archive=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 3C20B1F23696 for ; Thu, 29 Feb 2024 14:08:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BFBC1361D4; Thu, 29 Feb 2024 14:08:24 +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 C92DC12AAC1 for ; Thu, 29 Feb 2024 14:08:20 +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=1709215703; cv=none; b=RtjnRk0tduL3vqJUuu58xYG4mg9BmaVtYGVYUIjVHeZUKaNAaRCbGtFAWcXyw95BZTSLzgHHOZ6ruJzdxlZhD4593pVCwVxvBKTEZGYFVo7FXcJtsbXtcV5AlwPKBAe0lGrcf+ZGJPtgiH84/nplR0hV6BhjCSOVFuiMEc8SQbc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709215703; c=relaxed/simple; bh=7Ye85qjcN7kaawh5AqqUO/lIXibzvDdJYFw778hqsHQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YTVI94qCY6aTGFe3IlMEr1uo6BdzNx+pgF0NBwLTp2MYx57W1y+Tnd6HCEzymql88mG1V5sVzDvfrJOUFJO17CH3GYoVvX+1oEQewtGDmL1NlkinxG5HbDrzGwkAVxNLbos2p5KrVn1l5k83Z2pAWsLMq534s8AC8BLxvCeWNfA= 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 1rfh4t-0000Sx-CE; Thu, 29 Feb 2024 15:08:03 +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 1rfh4s-003ba2-3c; Thu, 29 Feb 2024 15:08:02 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rfh4r-00ELmw-2x; Thu, 29 Feb 2024 15:08:01 +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 v7 6/8] net: phy: Add phy_support_eee() indicating MAC support EEE Date: Thu, 29 Feb 2024 15:07:58 +0100 Message-Id: <20240229140800.3420180-7-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240229140800.3420180-1-o.rempel@pengutronix.de> References: <20240229140800.3420180-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 Content-Transfer-Encoding: 8bit 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 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 2eefee9708510..72452e6a478c0 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 c315928357c8c..661c2c969b191 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); -- 2.39.2