Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2180801rdb; Tue, 20 Feb 2024 22:23:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3IFLEwZ2/p1+UQyWFyOzrE2p/ka9kcMbZFuLQ/oS4jLkRMrQ2u+P6UlsceRlEfiq6x0mqYUqDEyOlw/9oWPICZgNNstuCVJy6FUl0/g== X-Google-Smtp-Source: AGHT+IG4JJpZAcAXGHRJAZcDumyfvFHq08gwDr6XcRtohb3Ym9u31ukbrJAyak77wgw9MJDd3LzR X-Received: by 2002:a05:6358:c83:b0:176:b156:f69d with SMTP id o3-20020a0563580c8300b00176b156f69dmr15850921rwj.31.1708496580047; Tue, 20 Feb 2024 22:23:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708496580; cv=pass; d=google.com; s=arc-20160816; b=Z/ffLYDQpAUnfYD3xZyZoBosBHognanpNllWCmDJf53jUdRcyV6zL9Ry6W3x1iJNKj UVDG1iAWw4Yg+jV1RLpNz732vIXq8yIyUr2ACHWiryxheugilPgXUGfCB9YKenwsSvDb QJtBBhAkSkvo78F6XTKJsSZ3o2aCGpyvVMtNKzxx+SeutAqW93szd6sjZuzFhmrnClQt oSaqcmFt8uZeaXsLQ1AuV8yDJQ+OAZ/p0Tetvv6/QZqeLkjLLxjyfzGgIHj/jbVGDeXh Gc+ApueNy0t4PxLUQUDvsW4pqExgyMW2X9SJG4HtKR9OM8x3x1EEWhQw8ph6FT7fz4yZ G8eA== 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=xL/i0p65W+2xQATbVMcF5za6d8u/lQhRi7vIrEG+QpM=; fh=/mFbHcqW6l4fLIJBfKVNbHEV0oGb2iio8Q6EPf9P78A=; b=Ghec/0g20ec0eJ9SEdqByF4hkcaoft/Ke6LFMn9d58kx2qbVlmOuwMEwooNwC6Ax8T /yRhA1r05VX17M+5v0m5d6SGHI5a5R82IBPYHMSc+ZcfLor1DXC8e5Q8hn6PdgXin3MR uCiVWHDSJVVWGW0G2d9HKZOEdQxGgr3dtPo1syRyB5GcNwKrj7Gk/UsaIbuxYe3Orp5p Hr01jPfVqAA7oDrCTYGH7R8sJTm/337+P9jwhMEv8uxsw2WViHJcI5reCZjQg9xs/O83 qpxOg+ZObXsxwmegqjVw/+g5H34q63Rm9kHEVlKr2/140RWl82sYP3XBDd47ARXVY4n5 Dm3A==; 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-74140-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74140-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id cm6-20020a056a020a0600b005dc7e782167si7802574pgb.462.2024.02.20.22.22.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 22:23:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74140-linux.lists.archive=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-74140-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74140-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EDF35B21209 for ; Wed, 21 Feb 2024 06:22:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99DED3AC16; Wed, 21 Feb 2024 06:21:23 +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 7B8123A1B9 for ; Wed, 21 Feb 2024 06:21:21 +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=1708496483; cv=none; b=M7+Y37JGzyWch/YudGr1oZBc/BGYqMHn0r9PmbXW76phOtPdya1BTz6h+l6vy2xbkmItLs35F7ynE2mExncuQ22iSUPfePppko02vm2hIUI4Ib66pUteR1/kBA01eJRxCuTxOG5h3IsGBzZQOIVM+ILZ82xNRQezWQ3TH+rowtA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708496483; c=relaxed/simple; bh=YZLo9HSF/faK5zQ17nqGCE9Gy+ZnAPuEAPsUQSjAZOo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h4t+pC+vCZeMgEPkbPm5wCmPRqgJRm7I6POB2owRaxtR8sE4sbiK3ohC4YHy/p8ecPLKS5ewJ00ksQGLgP6GuPu8ui9hVP7OrFcD48Tt9novvlHmoGjTykQfwvFSnk5VWCAvRnEQXuHrBfoevu9g3clIRCGkJ9001lE99yoDFvA= 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 1rcfyh-00010Q-6z; Wed, 21 Feb 2024 07:21:11 +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 1rcfye-001zFA-M6; Wed, 21 Feb 2024 07:21:08 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rcfye-003GZw-1w; Wed, 21 Feb 2024 07:21:08 +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 v5 2/8] net: phy: Add phydev->enable_tx_lpi to simplify adjust link callbacks Date: Wed, 21 Feb 2024 07:21:01 +0100 Message-Id: <20240221062107.778661-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240221062107.778661-1-o.rempel@pengutronix.de> References: <20240221062107.778661-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 --- 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 14224e06d69f..a54b1daf5d5f 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 e3ab2c347a59..a880f6d7170e 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