Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp850294rdb; Fri, 23 Feb 2024 01:47:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWlHJBkIKHlyB0yQtdjPV9wkX8C1muUG3JLit1SNfMhuiJvJrCcxIxaXFCNbNQZHz10W0/JYmjOs8WD5aiXkV91fj6S9Dl/WUOZqM5hzA== X-Google-Smtp-Source: AGHT+IEo6cBAFdQJE4CyBBIuUS8uty0Uivok1wpzzaEKrr8tPcA2cQxdJCbQZU8Xm1qDcpPjSOKo X-Received: by 2002:a0c:f0cb:0:b0:68f:416f:689c with SMTP id d11-20020a0cf0cb000000b0068f416f689cmr1458518qvl.53.1708681676917; Fri, 23 Feb 2024 01:47:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708681676; cv=pass; d=google.com; s=arc-20160816; b=h566B5+Q/irXBLFtfyLUtDq/zi9aw58EeZkELVwu3ga/jdVKdrNPM1H7M40RA9X4be RKgYNkirncJ8ERnsbF6AkgundBbSJxHHexzCWBnaG+vLiNTWsMaH8xE45jRjf/qt4T/3 FkJBPk7E9hVqpZ+xUd3o7uwrsDkunNTak8fYlA4YMAugUj9GqtdATmhqvO7ExC7VdOp3 UJGNU9+9NN2zIBWS+WA49YpsGQsL/vyyL1ZuxQreMvP6uawGEc66y3UjY9JP0WsXHB/L j1zNt6IzKEFz2zl/SR//YSdvBf4CMj4CQDKB66/C+WZO67CceDmb0ZzVtd0cyv+dy7Xh nMLg== 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=Y+VdvFSLYL4Q2hUhuiOR7a6bsGkCRuhHi5rflJOJ9qw=; fh=sVZ6H5f6ewU2fC+U58NocBocCWosMlAmPb9AApl9d+c=; b=QOp1O5wV44R/w7s2FSnzzTWsMAc34voRgnIgW3ch6KYOQFbL//wlUezo9qHjOhXqA/ 9Uo11O2GZSP9vzwhn00SOvEJ6tGgCyLUgk4/VKtwy6ktvZYW2mELifhAc7oxRVRBas6L 2mL+dBwHOGEBKG2098Bx5tcbeDYll83KyCRiaMcwthXKqtk3G0xD5Ud7EEYcYMdv1sqx 5D1+1p3CkD+YnIipLwOsb8e8wQcx+pppTVrQxA0HQdqf1/kqc3VlurCbSul09zQH5t1v oZaJQXWJXeqcTKn2IxbHsxV0Q6eRZ0+pGmbZRIQkCGbXkQo5+47ZdLD/56OZtoAntxK5 99hQ==; 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-78065-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78065-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id fq6-20020a056214258600b0068fa4b5ec4asi5109968qvb.350.2024.02.23.01.47.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 01:47:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78065-linux.lists.archive=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-78065-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78065-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9EB081C246FD for ; Fri, 23 Feb 2024 09:47:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A5F65F85B; Fri, 23 Feb 2024 09:44:59 +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 C2B7A5CDF8 for ; Fri, 23 Feb 2024 09:44:42 +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=1708681497; cv=none; b=azvvUEEPW4odUmoAtrmyFG2UjVMXO51dbmfiSq6oxh70jnTPxFxfFaouIOKDiNWb9xWP3PFRrdLtiVrtIiWXwLtxyNEvot9DuYPM3V3+2dDWy1x+ybZm3W/JyR+dVXVyBxsxS+hqU5vPemml7AsDh6p5/yFpdq5MeBuJGT+n57s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708681497; c=relaxed/simple; bh=XkWQE6zG1apQhBmdO+aLa8+bgHqVdq0lI1BXT90sPtQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PJk9RmT6MiRwOwy5W1KiqGW0mo8y8q0WTPcvnm06Dl76UDcT3+WWZXM+QzNN7tvWfSQfwDsRUX3KIoonghc7m8Tjj66fCuSfsXqC/QQqwImkspksoeP3g3uRAZKas3N1tb8lQsC0lwNz7UmdtJ1+jYvijySTksLViLABPazfQWc= 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 1rdS6W-00080k-LH; Fri, 23 Feb 2024 10:44:28 +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 1rdS6V-002OkS-9O; Fri, 23 Feb 2024 10:44:27 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rdS6V-002tpR-0j; Fri, 23 Feb 2024 10:44:27 +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 v6 1/8] net: add helpers for EEE configuration Date: Fri, 23 Feb 2024 10:44:18 +0100 Message-Id: <20240223094425.691209-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223094425.691209-1-o.rempel@pengutronix.de> References: <20240223094425.691209-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 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