Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2181589rdb; Tue, 20 Feb 2024 22:25:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVg51x+n+KrNYT91P/zMVXrzgeRkZDedrIdigawbXLRZxYJkon8GJu4gOdcb1WE8OMdKyFVOWiB9nt9zcXlJZoEc6AC6Xk+8crjhblD8Q== X-Google-Smtp-Source: AGHT+IEyD9FHyOMiBg5+TK3qM9eOvitELeMMZvEZxDuUFhEudIZ1O1w6M+yJ6F7DEOBniEB5zyrR X-Received: by 2002:a17:903:1cf:b0:1dc:1379:213b with SMTP id e15-20020a17090301cf00b001dc1379213bmr5257249plh.35.1708496725347; Tue, 20 Feb 2024 22:25:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708496725; cv=pass; d=google.com; s=arc-20160816; b=wTVPtNw3yO2tJS+1o5znocHHHdSLDV5GTHsQM1GhYPRHwd5PXuMKNo6gFrRBo4LCI5 hoexAMUJ7yIoWNxRpYH/gzrgR5cH8YVgLk2AnkED+9mPglsmoz5k9RIwtZXZvt6VenyN gZCpUq9AXuxKE46h0EZGeFBvSBkTpjRIfudjGSGGtKzOFS3z1SbK0igp756yA0itqadk sTIAvFUjzITsemtsKH72le6xZill3gLh+M3sPL3pXuuOagN8NYh1drBIWEGEn62I/Psy prXbQm9f8wRnZPgES44gLTP+6LDRpUhx9Neza/i23xe1yGQJ4fA6worAqHTDYYjCbO/O 1I3Q== 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=CbEIRGcA9AHZLViJ6dpqmFq3kFiASw5k9Z/bSqsXspU=; fh=Z3AakHyZxCIxzcEMoIHNDSzvhjhv+HMsD8Ki54Zfyg0=; b=m2XJh5uPp23mD95OO/Gqw8Q56gJgjH3S+6BU12JgQBmXZe+5bqtT43qLqgyEn2BYdn 8FLceLNj9Bg3ZU4uCqgaSF5w5z6AcwJt6jqfvf4oZEWpr5IJljy0o3rpFSXPvamnVANh ftWmG0jA6jZf824QWZ4edld3DecZ889Owd4RwBj0gtxi3AfSAvSglJdDzdu1R1h0j9Kd TUP8LpW9n94Fmd5W7kVeobwF1BQYpJ4CKzM38DlPKZj0zvYWYyzdhnqFiAAXhu6GfgrO aAWuAiku9TVtFr5jdCKbO3gOA0S+IUQjmvrtC5CkcCDCNQSEtvyPA2SkvFTsp1vGCLds wtXg==; 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-74146-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74146-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l2-20020a170902f68200b001dc30bbb5d8si599045plg.385.2024.02.20.22.25.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 22:25:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74146-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-74146-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74146-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 CB5F7B24CFF for ; Wed, 21 Feb 2024 06:24:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76D0A3D0B5; Wed, 21 Feb 2024 06:21:27 +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 B0CDF3AC2D for ; Wed, 21 Feb 2024 06:21:23 +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=1708496487; cv=none; b=O1LZ0msvhL0Y2lGcCDS9PKRbbCPfrbfDrK7f4XinNnTkb9omkZ7hl7vtDkgBgVvAmVe0keZc8rQtlMu/oHS1x/BxE3DLtWig8eRE5G02ng+sztFmqUJ4y6CDy4xamCiWIoBU3276TFs8EEW1Xit9gL1W6Dg2Q9Y3fXq+452zBYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708496487; c=relaxed/simple; bh=sCu7CsPnjRQfodfi0hEsEkf+BIEEHY2CoyGZE7cOM1o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pCEV9cgaCN3Ftoy77adCTxVUq96+/kaai/xp450SIP1eX5M+arm7acS2PtXxl8DGfjd9iO78euf4AGgbCM389wyPhhspo1OD/tYNzEbvhy/2kYEC8ibecQ5dWm4jXtAb5y/e6YCbbs0JyQn6xGQmtsGsrYoe3o/I+Hn6TXqlW+o= 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-00010P-4X; 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-001zF9-Kk; 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-003GZm-1s; 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: Russell King , 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 1/8] net: add helpers for EEE configuration Date: Wed, 21 Feb 2024 07:21:00 +0100 Message-Id: <20240221062107.778661-2-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: 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 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 000000000000..1232658b32f4 --- /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