From patchwork Fri Mar 1 10:01:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208738 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp974117dyb; Fri, 1 Mar 2024 02:04:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVysBH9vaqXCfOhlh71eo7jVmhWkki1q9sTSFARyFHvX7VqnS2nRFol3tgJK2k9dKhslnWM9jDLN0iJZ6yiAc4aQcj9bQ== X-Google-Smtp-Source: AGHT+IG6ClwFNCRjohmC6GWUEs3hqCNbVRTqE6uy/qr7pNLXOp6CREiqwdcKG/f2K3szGgRqZ0rk X-Received: by 2002:a5e:a90b:0:b0:7c8:8e6:413e with SMTP id c11-20020a5ea90b000000b007c808e6413emr1127509iod.16.1709287488418; Fri, 01 Mar 2024 02:04:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287488; cv=pass; d=google.com; s=arc-20160816; b=Gk2eAFcIBicZhAEQr4KR89sYxFNBGZXyxoQ0eWdKLYbEVCFi5LtwwkLDqn/Jc9bGfb RZLEmrNnO66/IL+Kc+XWbacIhtBZm4dLt8g1Rez1EgWB4FM3ERdEq56EQ+yx2oVhmV6t W8q8AFj5bi3MGcWVZNEowWV4lF3kirSEXMU5CF+CtmPe5mcQ7FoupvpzqLi7oZpXxyWe JM3ZBKay086I7szvVwLE600S8VMlU1Us1EfwseVyJbqjJXun/aScsrK9mI7nXDBMIk6c FDcuJ6r1KnVzLUKrDIBrxAjMXBM/TGy0hemggSkrsPssc8WlKygbNct2Puuf1S65o8mg Qi9Q== 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=td7kS9gt91g/A2UHhz9pGTPQE896rclKgN7t6g6JVTc=; fh=sVZ6H5f6ewU2fC+U58NocBocCWosMlAmPb9AApl9d+c=; b=v86qgYHUXhBAYgD6OvDsAsYYxFYS3Kd6pwD9jCG/P3x922nn58fxWB0QHfEZovaf5A pYUHel417ZAu/QcE/eAXDkMkBtRyvelLmvEKW721JySmcHlMb8FdFTBTiFvdkIJeHS8b aOZCnMEon/bID1TmjGQp6pKjlQZR8nwHW1/QBeudZe9lTyFuY2o9PKUS1BUiTTGbYBUp ONk/JBB5LLgeU+PnZJAXjcRDRS0iKtX9RQ+aARJ/MRtHUEUHn1qs5Msa+LozBint7rKU 1ZnWSTP1Bo9U328rY8DGlE6m/7HvM18ry9nclwZxKR2auXHn6uGOxPornCOF+qp4KRGV p9WA==; 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-88222-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88222-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 u64-20020a637943000000b005e428bf5de1si3320889pgc.749.2024.03.01.02.04.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:04:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88222-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-88222-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88222-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 0EC4E28303B for ; Fri, 1 Mar 2024 10:04:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F073C6A8D4; Fri, 1 Mar 2024 10:02:12 +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 18A3F6BFB4 for ; Fri, 1 Mar 2024 10:02:09 +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=1709287331; cv=none; b=V4A/OT8SqOc34zJK5fMHZH3eZehkzMXHCmqMYq9YKoboMW3eHLTZAslTr9EiK34ZsgooHFzqUpnz0fI57bIzsa8AS57hO/Ls+/BH2bntscD0gp9xNySyqaa5ENjcODANdDQ2DQa6J2+fTNRZp5GPJu5PJxWwehI9PPf1FHxkwjo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287331; c=relaxed/simple; bh=bnczvboHhvoEalEW9xSpju92M4P2dgF3JOLgOD2eOHI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ODwH3B+qvv2o3PNNAJbASMigp7IXDDBiiZHKRbEMNDZk71Rw+563ad4yU00+VJIs5Gvbc7IGeeGlMkHR0rPTyIYk9KvmgFR4jBDiPdcDXiOZ7lLvNZoOTrDXASNhhrqlKOXstI2RNSMcypby1Xord/bdmSqwVroR+r5fme+TZnA= 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-0003oe-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-003kq3-H9; 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-003tMK-1S; 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: 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 v8 1/8] net: add helpers for EEE configuration Date: Fri, 1 Mar 2024 11:01:46 +0100 Message-Id: <20240301100153.927743-2-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: 1792317837335913449 X-GMAIL-MSGID: 1792317837335913449 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 0000000000000..1232658b32f40 --- /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 Mar 1 10:01:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208737 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp974027dyb; Fri, 1 Mar 2024 02:04:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUUAx+qUtYITRrQuNMr5/AMGr5pQOj39MhKM6cRWXfPYJcDmqQ7pHvdUV7Uli6XnGO1CtgPkzw79mD/IR5fgrfpIVKIzA== X-Google-Smtp-Source: AGHT+IEyhYW5cMQ45zCErOaIqouhBr/dUSoYk4Rfobt9N61WapP/yXBZ4Y7+zypt3/TU1GBn8ugX X-Received: by 2002:a05:6a00:9a3:b0:6e4:f761:1a4c with SMTP id u35-20020a056a0009a300b006e4f7611a4cmr1559055pfg.12.1709287477136; Fri, 01 Mar 2024 02:04:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287477; cv=pass; d=google.com; s=arc-20160816; b=p9/DKluBbNSVbkLJgz4EFx2UttG/497R4TzSn3+NJjivmgVyRQEf/sluDROyTzs+fu /ltJdcjaiaXdDI3G2SMHhKNOLz2I6jyEs7zOdo/WoINFdn8Mg//y0i9NRDTK8sKDRYUs onN6+pp6UBFd1KSMOJa60ScBA5nXgn8tCZD3T9r9dK1X44w5DSuZruEivTTQN83HQbPG +7ZH+dGgSypr61BYmFm3+TiZGoxuEjVZNyItiRxcfd9as3lCTmM5yE2irmUTLP5ry+Y5 XQnr12LpvgWzZ3jWSNP9oh5YairiRhVLaXC6o+Vd0LM09e0NzPO2hU+tlDaNOrl5eIHS Uq+Q== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88221-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 w26-20020aa7859a000000b006e52f0b49basi3152002pfn.209.2024.03.01.02.04.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:04:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88221-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-88221-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88221-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 09D5B28A0E1 for ; Fri, 1 Mar 2024 10:03:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BE3E6E2BE; Fri, 1 Mar 2024 10:02:12 +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 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: 1792317825240529629 X-GMAIL-MSGID: 1792317825240529629 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; From patchwork Fri Mar 1 10:01:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208735 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp973773dyb; Fri, 1 Mar 2024 02:04:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCURCvep+0VSG2/YrqX70o3yLpiCMV0fKwjzT5RNJkiCdsLNpYn/XukZcY3PghTZX6hLuN2I59sYFZ9RBhKnK3SKefwOhQ== X-Google-Smtp-Source: AGHT+IGETC0NwU94uN7Gp0hT00X/HY5Ajsw9/vjfr0VMjeFGiaoGAttNzNA/ThdvfMDNJeA2Vshw X-Received: by 2002:a05:6808:a89:b0:3c1:bc9c:3865 with SMTP id q9-20020a0568080a8900b003c1bc9c3865mr1151183oij.19.1709287452369; Fri, 01 Mar 2024 02:04:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287452; cv=pass; d=google.com; s=arc-20160816; b=ruuDzJ2BgTiTw2DpwUOLuDF6UXrPscMIbEBvbKa1sf+VpOWXoLqIg/ZTdiuxSVpx4p f7m18n4tIuZ7tj9D18DQ6J/ob9O6BKSqgZ2gyTWW1tGsr3GrfzbxwV8erc4xJU3xqLFG aEAYTywG4GoYEoEGZ15ZFbh6VjXJI1ii0Rv9WveSWkQL6rAdo1lYBayUBmR1TzkY9xji T+Vow3uLU8etv1XmAV3GgP2jviuZCvz4WJjrs9naczByTEwSxKPGJCb2VEpFDlurO/uS T9gWEQFmBnC5ZvFrmP/GywqubqyiDGKMZhs8nSug0RKxMt7NoFNsNUoHXnxi0Q1qwI4f ceiw== 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=YxLqpfGEexTK0JV4X7kB9kkD3dWrPVESJYoHgjLCMi4=; fh=/mFbHcqW6l4fLIJBfKVNbHEV0oGb2iio8Q6EPf9P78A=; b=i4ys6vqTXEAIFOOm79FW6WsSMI61O+R9Zf3IhcDKzR3j6+ei+aqUzAf3DU/bw5iIlY Z7omnnfkgjLtkhGrxxPVV2Tl/DLpD7X+3zLtn+UL5U7edBTGPVHvQQi7OU+PnDRpRsRP zSkW6VQWBmSPWgqNC0Rx0vB9dN686Drg5EIDJl8gD/J08+ObmBqTCiOefuoBziPCDda+ 3XFwemmsYjn3E8SnTWCzXv3oroALqnzZdUp06Y8ZM4FjGdU2/gNqHu+kJZfkXu6Cd05y q6KYdu5WZ+Pn3rn2aepgybXSg7Ey1LoHYplBCEeLbz1vQR2cdMBuY6V8wB623vnhFbq1 EwiQ==; 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-88217-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88217-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 y6-20020a62f246000000b006e5936840dfsi2974284pfl.336.2024.03.01.02.04.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:04:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88217-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-88217-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88217-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 9E246288095 for ; Fri, 1 Mar 2024 10:03:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D5BD6CDC8; 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 CA43C482C1 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=1709287327; cv=none; b=a6F0cj9jclKP3juafFEwyWJb6CNC38bQMIEldBDHr3pGzr/geMAOupryNagTBlpP9qtOBYszm3DDYAPpCo20eQ/EhQgKa5vpkZuoyntOsbyE9xXyQne0fkbg1J0meER1Xj999qzg9Bbcc9ldMiddvfNrmie0Xwnun21Z671oGyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287327; c=relaxed/simple; bh=uCZhXHLSFkdy7i0Gfza9gulaJphXTOfQr0iTmcrT+Y0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=spRkd+eDHRXbMy1z3hu8v92woegWvu6SHPB1Je1rkuOpdO2dL7t4OYLUdOLqhlfO4oHenRfNYkgO5n+B21Kr+s5bA0QjxsvUWZAZPQwV7fkmgsZ1E3bRYbC2BCXTtBhPMlWAZ6BCbtrccqczQbVqo16e642cFiWR32979B+tAKo= 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-0003og-LB; 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-003kq5-Ii; 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-003tMe-1b; 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 3/8] net: phy: Add helper to set EEE Clock stop enable bit Date: Fri, 1 Mar 2024 11:01:48 +0100 Message-Id: <20240301100153.927743-4-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: 1792317799466288705 X-GMAIL-MSGID: 1792317799466288705 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 2bc0a7d51c63f..ab18b0d9beb47 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 a880f6d7170ea..432c561f58098 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 Mar 1 10:01:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208747 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp975649dyb; Fri, 1 Mar 2024 02:08:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUdnLE3+mKDxADJ6G+IVc5ZEA7ORm7qQSdFxDTOGvGS7z4uG19cGRdADOgKWuZt6y+xg393nztZSG9n3QgjYm/R75Uqqw== X-Google-Smtp-Source: AGHT+IE3BSAKbz95tdfoZZCY9NSQuk/mBiO7W8TEF0yp+Iu0z/FBSTHeK9stLyNoOD05lQsiYuiu X-Received: by 2002:a17:906:8d6:b0:a43:1862:d7b with SMTP id o22-20020a17090608d600b00a4318620d7bmr930186eje.15.1709287683692; Fri, 01 Mar 2024 02:08:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287683; cv=pass; d=google.com; s=arc-20160816; b=HxbLf2WQ+sFPlk04uEff5zkQZODMfHH64Wh53s/ThJcAnALJZEVSzaSrbURIFXdXC6 tvmrUbdCLr3yST+boVcJwB+FdDLIvaUvKU6T66Bx7uvzdhyf7WmfgLdCtOnFohGHzF6h wCRqST3Z2uj7apSdzWup9dHMCrR/v3pFTnYLofyWlE8K/E273vHjBYD7pnbWJb0j7o9v va65lQeA8V1bI6zv8UsMnagJTXl2+W4L2oeGHDb3FFFn3yr9zp3tDmlf4i9cfZ1SHqb7 hCIEjXxGPsjXwPGBxJHsPXiD6RR0InTLm+sOb4eP6GvFvjqIzXRDFlBE9Db6qut3F6JP +JHA== 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=9YsSAjmT+/hFU+VxkrfHtXWIoAPQ5d5y5/WIvvBVfsc=; fh=sVZ6H5f6ewU2fC+U58NocBocCWosMlAmPb9AApl9d+c=; b=F8kBAfAwrRR6zLpTo0OFpQAhoum/8JGrpQ0I+HOLXOvb9shP48SEjrdZUu1HHSXRIn bjlCbDcS3VuKIuLR7W6qk881UaFnRQ8qiE1l2/2KlOWmQhrS9sN76CyH1WclXFs5cgf4 pGnhyxXlh/xOww0KLFOBxzS/ZqjuoMIUd2uaSU8IEWKMALrxtPNURkauF4cUo4Y1jDum nyXCZJuiD7AtPoJqjYoJzAzWIUcPZfWLw36Yplg1d4TH7BqSHPwx3Vc08AQc/64AQ/9t KXJ8SinnxfEJBf3c4yjmUdavWnKtufcpykTY4thHIDD6MWJm3HU/6hVh6U5z6rXzKCVq MW/g==; 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-88234-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88234-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qq26-20020a17090720da00b00a441b001c6bsi1340385ejb.479.2024.03.01.02.08.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:08:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88234-ouuuleilei=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-88234-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88234-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 50F1F1F25E42 for ; Fri, 1 Mar 2024 10:08:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A008B6D1A6; Fri, 1 Mar 2024 10:04:20 +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 5E581482C1 for ; Fri, 1 Mar 2024 10:04:17 +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=1709287458; cv=none; b=fnSJaNOx77n5fCHf8dU2M8y4lSG2bKvCuPJqDEHGF5T/SD386bPlG+mszhOKLzwENKNd0gWaXfw05W8JOgr65KKQYGs03MdCLJ6q0wfrxO9KOJ2BojcIKINnoDoYosm51+iYCrcZ6O1uVlSZoB0HdRALvRbcrdTQIGTpJJfLHX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287458; c=relaxed/simple; bh=2gdb8QFpvX/+BfbeE/tU8fiuiVqBgFxh855Pe4Pdm2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bLtp9V9qmdXn4BjTvueNxChA44OFOFRD5RXLGXl70BU8gV9b4S/BXsmVsfcuNqkQrwH7yrSVR/cthSBTN+nk6RmMBDwo1tH/D4Q2Gp9TIgkl7nxz58r+BZ3/OAQ4IpUs00rMKGVNyrO8TZ5wPx8lSdLHBFZqq5nYnaTDYIzgehA= 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-0003of-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-003kq7-JZ; 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-003tMo-1g; 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: 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 v8 4/8] net: phy: Keep track of EEE configuration Date: Fri, 1 Mar 2024 11:01:49 +0100 Message-Id: <20240301100153.927743-5-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: 1792318042163622623 X-GMAIL-MSGID: 1792318042163622623 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 ab18b0d9beb47..f0ed07c74a36e 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 432c561f58098..c315928357c8c 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 Mar 1 10:01:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208740 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp974808dyb; Fri, 1 Mar 2024 02:06:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU02jLl3pOAzqqE/a6IMz0OsJ4hN7l6VKGZNqneoFI7KXEZO79cwOYmokfr1aNI4nRs/T8HWYt755KfvAYBA8NEuq2mrw== X-Google-Smtp-Source: AGHT+IFJ5o4rrYfxf85MStC/shHzA+mG8ntI0wtbmiIOKwDe9/eOvIdevhyqFIDRChTNRJnv/EMv X-Received: by 2002:a17:902:d485:b0:1dc:518e:45b7 with SMTP id c5-20020a170902d48500b001dc518e45b7mr1276825plg.49.1709287572761; Fri, 01 Mar 2024 02:06:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287572; cv=pass; d=google.com; s=arc-20160816; b=PRx2dD1rTQ6ITcA4C6fP1aBnHm/wSSGLhiFCvds2X/0F4uGA3o1FG/h7fyTgRRHT4Z TF+SqcWvbQDYsThvkyTjW9dND4OC9IuSY/wDJI57mkRt1r2XqwPwOhVPrJWOAH3U3mP2 Q7rFFh5aRi9EiiEC9c6acp57YTUiVhvahJy4sqP7zX4COQZw/7vC13lsanpuCLQwwE6t 693l1Y/qPTO1yt3rETqMoGAxPFJkZ+h/ggX8lOcgT7VRIKWW4qR/5lBm7mDutrYjeemp QuLSycUouRY9MxcIoH2N6xOTEoA8LCSl2O5kqI5DIRo0Rza8IxyTTwN6ZyvCjRS2LYtf LfoA== 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=VpVbmnx1NJOYGbZ6b5wvMkoneC7Q5uxAnGZHOR2r6BU=; fh=/mFbHcqW6l4fLIJBfKVNbHEV0oGb2iio8Q6EPf9P78A=; b=wtYH9ZjqXHk5kvc1MXQkriN5J0RwSezaXNo/fcH8Q9wSLFzep6fKh1we4TKc0+YKnz Y4xfEbPzyTro5nkXY4ZZvD9pmky1ZpdrIJptzmgxjARMxDSmqod7rrXeAtSSGE46vJSE fe1F79iYrZN4ADeHLQ9RqW0WH0G6NZIAeOhIzhgd3eJA8rdyVzvYcYHVRxrIJgzYRSqh neXoN3Z5+hC21UXuzFD3jCiiXzr3XoJiBZJvwSi+/TQ8HSKkWD1qTcnCF+0Ev14Dj/Ep YQwJWQ5PEh4JOwffMxE30+dtIoDRxqomD4FiM2YRs8V+eBdf1bRuibKFiB83hPr3MlvC ld2A==; 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-88218-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88218-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 n4-20020a170902d2c400b001dcb17a9ef9si3381498plc.208.2024.03.01.02.06.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:06:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88218-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-88218-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88218-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 B097EB21A6D for ; Fri, 1 Mar 2024 10:03:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BC466D1BB; Fri, 1 Mar 2024 10:02:11 +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 DB12A6A8C8 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=1709287327; cv=none; b=f6CJMOJCkjybgqRaYCmTrT5LJsJD0s9u4dXNcMdcrJKX7ZLaHXOmt6yjiHmLyevJhaLrn+avixQtjYwUbOYC8tGQI4Z3GFtdhychlLbBXhuZAH/MJRh+lskLyq48yBsBSoR3+0q+wPxBskoizKIw5g+YwB4PrhcekMp/rahNwRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287327; c=relaxed/simple; bh=B/BwKhs+epEf7YfO4JNVAZA4ZuiMHkA19rrz8hv0HFM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X2aFgdQSDTKDbdIEE1dffQE5SVTntgwjXWVWSuwX7zr/exxUBvJhtZRvczgWvIEfYSMOmY3hCThVcrhKVzhsrfOLohbtv11fiGWNyI7k+ZkrOdCR0sSBWiSrUyVuc1gFNXKNDlizRfK5QrBI57P2fnNb/IsnH3e2zRTj2GFyr5s= 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-0003oh-LA; 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-003kq9-Km; 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-003tMz-1k; 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 5/8] net: phy: Immediately call adjust_link if only tx_lpi_enabled changes Date: Fri, 1 Mar 2024 11:01:50 +0100 Message-Id: <20240301100153.927743-6-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: 1792317925712251267 X-GMAIL-MSGID: 1792317925712251267 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. The same check should be done for tx_lpi_timer too. Signed-off-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Oleksij Rempel Reviewed-by: Andrew Lunn --- v6: remove ' comment and parenthesis or return v7: - add phy_link_down() before phy_link_up() - rewrite comment for phy_ethtool_set_eee_noneg() - add check for changed tx_lpi_timer v8: update phydev->link value before phy_link_down/up --- drivers/net/phy/phy-c45.c | 14 ++++++++++++-- drivers/net/phy/phy.c | 40 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 3e95b8a15f442..5695935fdce97 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) @@ -1576,8 +1578,16 @@ int genphy_c45_ethtool_set_eee(struct phy_device *phydev, phydev->eee_enabled = data->eee_enabled; ret = genphy_c45_an_config_eee_aneg(phydev); - if (ret > 0) - return phy_restart_aneg(phydev); + if (ret > 0) { + ret = phy_restart_aneg(phydev); + if (ret < 0) + return ret; + + /* explicitly return 1, otherwise (ret > 0) value will be + * overwritten by phy_restart_aneg(). + */ + return 1; + } return ret; } diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index f0ed07c74a36e..b6a2af20c1f32 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,36 @@ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_keee *data) } EXPORT_SYMBOL(phy_ethtool_get_eee); +/** + * phy_ethtool_set_eee_noneg - Adjusts MAC LPI configuration without PHY + * renegotiation + * @phydev: pointer to the target PHY device structure + * @data: pointer to the ethtool_keee structure containing the new EEE settings + * + * This function updates the Energy Efficient Ethernet (EEE) configuration + * for cases where only the MAC's Low Power Idle (LPI) configuration changes, + * without triggering PHY renegotiation. It ensures that the MAC is properly + * informed of the new LPI settings by cycling the link down and up, which + * is necessary for the MAC to adopt the new configuration. This adjustment + * is done only if there is a change in the tx_lpi_enabled or tx_lpi_timer + * configuration. + */ +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 || + phydev->eee_cfg.tx_lpi_timer != data->tx_lpi_timer) { + eee_to_eeecfg(data, &phydev->eee_cfg); + phydev->enable_tx_lpi = eeecfg_mac_can_tx_lpi(&phydev->eee_cfg); + if (phydev->link) { + phydev->link = false; + phy_link_down(phydev); + phydev->link = true; + phy_link_up(phydev); + } + } +} + /** * phy_ethtool_set_eee - set EEE supported and status * @phydev: target phy_device struct @@ -1695,11 +1726,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 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); From patchwork Fri Mar 1 10:01:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp973918dyb; Fri, 1 Mar 2024 02:04:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVingaEWAQPAi5Xj6aTaOiBmW43zfi5EQwuNen0i89dZytS13XtwMx93nPtQHPWcKIsENhsRHBh8jAfmDfBJ7ihpZN1iA== X-Google-Smtp-Source: AGHT+IHymBLMLrxjPpi86///vTodqws0oBgikkjusRz2hCtphEYGGXyn16tnUwrBdYBknqg73OW8 X-Received: by 2002:a17:902:e809:b0:1dc:afd1:a85a with SMTP id u9-20020a170902e80900b001dcafd1a85amr2029943plg.2.1709287465737; Fri, 01 Mar 2024 02:04:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287465; cv=pass; d=google.com; s=arc-20160816; b=T0bp5TG4phRx6LMUl4jZl1U/cBeyJH/mhpLv5CZFfsmoM2nJenZ12VUZYVQbsQtpRu IEB34Lla742zK32npA7hIbJTLGJSmHcouV/38L5tYS0jGg9Cr4fZ+uwdaKjgoHt7vE0m PtSf5HDq/fGciGlSP7brnv2GFpozVfnh7IN3QXcIcV6NzOpWSw8y/Xcu2qysWE4lg1sY bky2UAu65uTKWg8O7uEjJm5Q+BLQ9eNqkRkvckfmsPoP/s7hI5uBA8GOkQPbTJO9HECA 7wRXbJp5gr8GrQDYcBQVVC49J52v8IIOveaoyb/+NXOstcS4nTgB1DuRbXPt64mKtvF7 Qgww== 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=lUismf8tEPtJCxV3VOiEko0mhPuHABId0keZQzFBC/o=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=LqTjrfJPI9b4y7wwKtAGwGUtqmVugFTTaIMi+GsZPyiGJ5iMZ+aFZ96nTzZ86XDD32 9w+s49RnfmCPWfSWdTeTqM2mfH7bNpG57juMHuHxcKZHA2cf1kJNabctjI7ZWs62dJ8F PUvBcoavQSUEm+90gBG9BQY525ajv/2qSAeHXcFTeaKDoATLgU5NzNHUUdghKdpdTYh2 zu233eQhVclc6T5ct0sv96vhJXXM2mIaWNVuK+p21pPJiPDlZzejLjjh+NUJbHIl2vLt CZWtSLKBYSak4b826f896Hna6hOPKTZgh8pds2gROWWGX6FDH1bLUhr0Rv7jwxYAd3S5 n6kw==; 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-88219-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88219-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 u18-20020a170902e5d200b001dc8c54f079si3392075plf.80.2024.03.01.02.04.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:04:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88219-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-88219-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88219-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 CF8522897C2 for ; Fri, 1 Mar 2024 10:03:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6039A6D1D2; Fri, 1 Mar 2024 10:02:11 +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 2609B6A8B8 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=1709287328; cv=none; b=JhRnjy8nfQ1BI99mWypo+lC2/ENUVeyLn271FGssr3aKNfEmb99b5ufzggxL+P9iFzqLotNhzwVyU3YRmZplP+R/LOHdJ/hi7gHOCwidnc6kCqm4bSbCSLI62OIK2LON3Scbya+17QxaQhodaKlWdqsiF81MwWqegLFFWG4aQtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287328; c=relaxed/simple; bh=pwl/nm8VqR5HxU43/b+GLZActVEhfzu3cSXEyZSs9Ng=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HnNBlxODqW0mv5DyXIcr6kE8U2cjMfVoOpmopekxDnYc5qAxSuOr3WsXz6AwdTff/KQFxEhN7Y44WJwM0J9OUXamDt4gKzik6flVueMZ5SSSRRYkEAYgK0roK/8Go73JBRuc4ipzpkQictCDRuBjJ69NUwMQwbDCyoAcLzwdOmc= 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-0003ok-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-003kqD-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-003tNK-1r; 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 7/8] net: fec: Move fec_enet_eee_mode_set() and helper earlier Date: Fri, 1 Mar 2024 11:01:52 +0100 Message-Id: <20240301100153.927743-8-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: 1792317813907991447 X-GMAIL-MSGID: 1792317813907991447 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 207f1f66c117a..a2c786550342f 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 Mar 1 10:01:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp973704dyb; Fri, 1 Mar 2024 02:04:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWCSfgkD3+5fU1yoVLykjv6jzFcTKW4gjxctj5hDfvj97R2xTidh/FewtTMJACfMKmRwLy9GPbCCIbpHDHrYkajhANTNw== X-Google-Smtp-Source: AGHT+IHZqAEvaprJOUF0uCOTy5Qgfh/qduRGa2gIVvbpLLr/FVv1Z1lhnKyBpcU8Zs9ibUyyMUKk X-Received: by 2002:a05:6902:2383:b0:dc2:232d:7fde with SMTP id dp3-20020a056902238300b00dc2232d7fdemr1154075ybb.13.1709287442076; Fri, 01 Mar 2024 02:04:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287442; cv=pass; d=google.com; s=arc-20160816; b=Bpxbv8MnOIPEC2Mb8y4Vu8NC2je6Cze6H1g3Axqta9TGC10WnQRRkEuVZNv5YSoYEe HBoWeAd8FA++GvjyrahtEuFwUrh0aVjc9VZb7jsz7b95R4rgmn5vZfTtD9Rlj+NinF2E GNZwJBATagRNVFHlqmRIVk+P9fFoq8UOnDV99Icj2/0Bb/Yu6dm8WX75HTo5WN2bN9Y/ TWY+2Uc02PTAXleOAnSxlCNYDmNeGL33pE93nrbaM6AyEtShp7j6D6a5U0mk8V6zToGs FvhGGAOTSF1wfgGpQy+SfZ/4ntkEwxydmxD+LnkI8wuRaXc7xECY0E8f+Q6IbZpOvuc5 e9pA== 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=pgk4E3Cvc5LjD4Uhu9r9ZltitvR9BK7MtQIcW0C4Nuw=; fh=Ie8Lg/4B6LRJEAkd22XcdyKITG9FXA4PEPaBJgtxF+0=; b=oPG81oS3RCMmphRnWrWW8k/rCzYFWnqWANDCii1VZ8m2zP6BhD2VZr8GKkBKDedewT aQj7l3/kBlp8A95IyXJwydi7EIoD6ZCrwqFnarkoyEMCFTuKP4HLI6bPD+kTtW9xnJeS OWNAK47LkM7XiSPyWKVMthLX28ZRSRgf2vMXbeYO9+ocy5uVv9HPV48LeKtRZDh0y+3R BcMEv/7KF7MPQDHUzGzRtf5j+pgCG+pnDDhkVNCdL9YyOwy/nzoa/olR2upEzmea5HHQ Yg1jMX0cLuGnD0ddr6NbC7ko6Aan7zMhpPxLt9BGRbg6FR52SSEoon7FZhl95Yn21qby qBdg==; 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-88220-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88220-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 n15-20020ac8674f000000b0042dc7d56c01si3040181qtp.60.2024.03.01.02.04.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:04:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88220-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-88220-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88220-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 C3B451C22640 for ; Fri, 1 Mar 2024 10:04:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32D856E5E7; Fri, 1 Mar 2024 10:02:12 +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 DB1886A8CB 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=1709287328; cv=none; b=VtZ75JBbFF9++h8/Cx5FaO130Sub0pmaZNWSajf0NlFw7jF7/XAOyK7YHUi9XW8JNYeXAJmoMd2wNTEO34ztscQ5bQ8QMITwQJTPJDTu7uPlacRD11ftJUHuGDIwd9EyPvuj5BZUdNTlGNxbEfl85vmS6l2upr9PEZYh3NPFOik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709287328; c=relaxed/simple; bh=VwqUETHkMr9Jr4MpYgf8mhr2gN0RvJdCzWv8zQr3mPU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=midaiNVBp4eCr8bLddEdbsxxpw0W1yJ+OFu7TN38BxpqIVH/fbnYUuNoaxsIsKp4GmaOCBlupypSQiNQ4mHvELfH/usbagJYOLDDmYXD9EQk9tSISmoemQpXZCtPK+Xjw7B1raMylV2ktR+x4o4qu94cmR4ycrsFmBWLE+jfJYo= 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-0003oj-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-003kqF-MV; 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-003tNV-1v; 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 8/8] net: fec: Fixup EEE Date: Fri, 1 Mar 2024 11:01:53 +0100 Message-Id: <20240301100153.927743-9-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: 1792317789194581385 X-GMAIL-MSGID: 1792317789194581385 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 a2c786550342f..d7693fdf640d5 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); }