From patchwork Fri Mar 1 10:01:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208734 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp973735dyb; Fri, 1 Mar 2024 02:04:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXxuRK7JNflSugHmB8P7askLI60thTHk1X6jbdONpcNrjTWfevJGj6yPMf4celTs+e0Ry4jmsU8BXCN4oh1eU7xUoU2EA== X-Google-Smtp-Source: AGHT+IFU9AYmBjvchwkiEDcBDl3X9zqGCQp+v6efGqSfyW5e4HWbYzSauepVAuEOMs6GagduzVRt X-Received: by 2002:a05:6a00:9388:b0:6e5:bb8:dc19 with SMTP id ka8-20020a056a00938800b006e50bb8dc19mr1677721pfb.15.1709287446848; Fri, 01 Mar 2024 02:04:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287446; cv=pass; d=google.com; s=arc-20160816; b=BpMEXuqO7ikNTf5K4EvdYjo7w8P/kwQtQipDUXRZ6vShC1V8AmZhfxsDcyfjNS2R+B RfTEkV1n5NwArbGGFqi0qrjD0wx7r7BrOofDsnakEbi8N5+gR7yDLujKTBLBFc5BKbJn uFb/kNHkFEfWdo+WFQyK1vEMfOlhWO0HAackVWnGbr9WDC+fCNm/62OrPIYL28d1u9uV k9I48p9lcjaFd41NGYg/NaBUp0zJX/5gaz10ck0JSvH+D2Ew3KkLWaeYRTVwjNfihplO d8K2rk+CCglRzsXuBcmYIqkga+cpV2CQB9Q6tKS6i0gmUeBJglNwMsoqTeO51SRJftht JvdQ== 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=iBCoj7JiTzlzAfrBTfqgNXc2faCGasfEsBa65zMBsUxEg9jakSyJ1sTr7c6zdm2c9O zeRQFIwx07QRY2+tgNEtkmMQBxwR5H406DawsQK13gdIfkDQ/FfZGouaapay/IRuI7nH hH0yH1LEFtnBnfmUI9oBRY1sITGFk93Rp7AgbqS6gt4YcF2nJVlIYipwSDeKPsTon76O 9ZJBXTI76kFmC0Rf7tNkJVFEdcI06qR2azRt9VyPXSWcayyaaqxgpqVk113iEng4PXTm NwX8WDeiEOyQ85Y92lRpPy2vq32bRqGw8O5gbQMWAsMqUu7q+k5NfAITISfqymrp2XpW 1Sfg==; 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-88216-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88216-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i137-20020a639d8f000000b005e430f63a76si3192942pgd.449.2024.03.01.02.04.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:04:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88216-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-88216-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88216-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 11A36283D43 for ; Fri, 1 Mar 2024 10:03:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 534DE6CDB2; Fri, 1 Mar 2024 10:02:10 +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 4F4DD1E4BD for ; Fri, 1 Mar 2024 10:02:05 +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=1709287326; cv=none; b=GTEDkm3jpgQU2lE6rCzJus8fggmavca0Mkh2m+MZ8L2+auDLWO6KttCq1qMVhBPDP58EqVqwyMCAoqt0eH0S5+GMefwr3vayEFrUg6VTtNNRAaQ4B3apbthmV1u9F8H+m9wOG/B4+lSewU7qNDlhzZj+5O8sufC0NRidzVvW6H0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287326; c=relaxed/simple; bh=7Ye85qjcN7kaawh5AqqUO/lIXibzvDdJYFw778hqsHQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SjwUk3a4X5P4b4NsnhldzHMT6lmckw0GnSHTyn+Vp0NqO1g0RuwQ3dCHq+7L0/MPBUHghUxkVTlXiiT6JghzQUvMHUKn8rPDDW1vLcOVwdyml3pk+90yqc56JFmsXIXDNpBa0PrN3J4ObTwVmtXrT39Q0aKEqP1uBe89gX88UIY= 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 1rfziG-0003oi-BB; Fri, 01 Mar 2024 11:01:56 +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 1rfziE-003kqB-MC; Fri, 01 Mar 2024 11:01:54 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rfziE-003tN9-1o; Fri, 01 Mar 2024 11:01:54 +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 v8 6/8] net: phy: Add phy_support_eee() indicating MAC support EEE Date: Fri, 1 Mar 2024 11:01:51 +0100 Message-Id: <20240301100153.927743-7-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240301100153.927743-1-o.rempel@pengutronix.de> References: <20240301100153.927743-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: 1792317794037958232 X-GMAIL-MSGID: 1792317794037958232 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);