Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp188749lqg; Fri, 1 Mar 2024 02:03:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXD246xaPdi7fDeaBXeKYt955OKz9Ipo7yRhOciPcE4uFjbHiKV/9uDy/R4qQyrYYRZthS7OATzczgj8v1yO0BJxLfWTacPZwo/iEFZXg== X-Google-Smtp-Source: AGHT+IEgnSWPTL4CgKPV3G3729jvBqXEwPLBfcjETz8xc810XeRwzvKrt+63UzmOd0l0EyO6jCoY X-Received: by 2002:a05:6402:1d3a:b0:565:6dde:ed2e with SMTP id dh26-20020a0564021d3a00b005656ddeed2emr825097edb.33.1709287436096; Fri, 01 Mar 2024 02:03:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709287436; cv=pass; d=google.com; s=arc-20160816; b=Kvpu7HAqBIx8A20WbTZWQAKPWmdbSznN5Tt1QcHemxFQLxspltfsalTAqmp3M2WkuC xrTIierd9Z3L60bGpQNN25rvc4XS4wM7v/sAeg3fHx6xnYniTHhBySEwH3gusnc6CLny l1GqVnV0RcJ/mPfH/MFQdJIouUEN6qOJO65oyOzXLUkRKJMgF6VLYxuJUnZGmirSBHH7 RxifLXsHBOQTfbKuVkFnlkU7NCiaf3a2syHpOy76oDR5YzKGwHs3xIvTnZ1EnJScsgZm UvB7EUVUIzLi8iaN5X/jW6GedAisQ0mXRFKV77qldF8pQ4QztcOskJ1H0q52yi9+xaTu kRog== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88222-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 dk7-20020a0564021d8700b00566b0e52eb9si982168edb.516.2024.03.01.02.03.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:03:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88222-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-88222-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88222-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 CF6A11F23879 for ; Fri, 1 Mar 2024 10:03:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6D6F6A8DD; 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 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 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: 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 -- 2.39.2