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);