Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp188323lqg; Fri, 1 Mar 2024 02:03:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZ/KTJDneUF9m3FrBSGEyy2f46pbVGDVG9y+NAascEZcvgB7T7jvjOYbMG95fJ0oYojnXQEpVIZhqPcz+P8f1HRCGKzUCNA95i2m/P5g== X-Google-Smtp-Source: AGHT+IHAAo2c/nOwTv0/2+QuarF2a+Rz+FVf/jqDGRzOBE0itE9b1Ge/udQXF8L+C3fYEAAXg0Ls X-Received: by 2002:a17:906:489b:b0:a44:52c3:9003 with SMTP id v27-20020a170906489b00b00a4452c39003mr816136ejq.72.1709287388637; Fri, 01 Mar 2024 02:03:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287388; cv=pass; d=google.com; s=arc-20160816; b=MAb0Fl3EBTgTC4Rh8Wu1EcHGcEfiLiL7yVbHiuSs36EaT9TPZPg6Yd5EGImvBO5pI8 st9Eo6sepXQ1uZw6MYKVXTxDIcQf+Vxo+AsSCEm6qCtGu1waQ8Q8voE5Dyz1M4X25TYb +U77XnI7qSClCvlvOJyLxTDMoy/eaTkw6pjTmisk2NyXDUfntmpkfWttqmbDDfO+V/og hOVOd6pKprO6YclHOfoky98H4cCS3rq72eZpwo9KQFVADU+IzfQepzb7GQAVhczs43Vv w9aif8uQLaxKcJcVu9gPUjpigKravGxkpuAuTHORo1mhyMfQ+5escUGbbrp+pMCGKW2a u1Bg== 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=P6tjsturxLCrxwr7ztKLNqrH12MLD4+K4T6sW2fBlvc=; fh=/mFbHcqW6l4fLIJBfKVNbHEV0oGb2iio8Q6EPf9P78A=; b=bD4czar7/ytdLkarTQfXIEKr++805KFvhFAnE2oTrs5IIAoLf0DO5uvBkY9ZuKncQA w1E0GcXn9165HX6Ft05PfVw8S2K9fmdpXE1F9eiZNMTLmtS/vvwm37uK3MLsfZJDvdPI IHFxVonVo/FZbFzDIlLEvWSscXhWr6w9Uh3xxUng3ORp97Ya5J8QNCaJ5TepcvL1wy1S 6P/gBPnp2AZcugXLRYgYVzSXBbIIFSp5Q9D7ip/+1XVzwLg3JL26aME9Vk2kFhzqrCOf r/6iFJeIbvbqPxxRzQ4gHVD9RK8cAL8TM/drT868tBa6jalvCH92b6pXeuOeiRrxX8bW LcQg==; 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-88221-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88221-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 va2-20020a17090711c200b00a444f7c377dsi1108155ejb.960.2024.03.01.02.03.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:03:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88221-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-88221-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88221-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 5C6881F23AB4 for ; Fri, 1 Mar 2024 10:03:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 329646CDA7; 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 CFBA66A8DB for ; Fri, 1 Mar 2024 10:02:06 +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=1709287328; cv=none; b=F+B26glj9lHVZTKJLnmzxEblk4j2DEhe0//O8su7HGfcwTkOkr+KNv29yccpYWUdqdgqAni0L/t10Isr9wKd3iqhfzMB4tFEHbiX9OE82xjalSmHcGkenL8CrpAOmEvIgXvb5eWYwLHO9oRH3kgPb2IFYXAipyqq5NtQ+BGuyWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287328; c=relaxed/simple; bh=JO8ieonndskihpfJzOJE8oPTytpJgtmq3zUd6sxNeYM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IyzxsBiTKCl0myPhQX0LDvT6AwwXE2tyjsvW7veV8cV4NBLAneaaIOtcAedw5M25iE2rA74MGAvxorRoirxc1e/UguRVLvu8dur2htsCo9pAPuOyWQUFGuXRzixzvW1AiZwbtF76mtQ0MaXs74TtE4Pa2kqJffI3IkjGR+P/wto= 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-0003od-LC; 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-003kq4-Hp; 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-003tMU-1X; 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: 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 v8 2/8] net: phy: Add phydev->enable_tx_lpi to simplify adjust link callbacks Date: Fri, 1 Mar 2024 11:01:47 +0100 Message-Id: <20240301100153.927743-3-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 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 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 14224e06d69fa..2bc0a7d51c63f 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 e3ab2c347a598..a880f6d7170ea 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; -- 2.39.2