Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp459346lqb; Thu, 29 Feb 2024 06:09:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVi+mMYNRQdIsoamONumqs+p1JHwS6YPeeVfc4ZY42wGcXpph1pkOJNOFs95azL5B/ToVKEKnD/2Yjr2Vt1ZBoyS473nJEFvSS2jUZzOw== X-Google-Smtp-Source: AGHT+IH5nMlaqU7EKMWVgCRBCb+X6zR2gn2jBcdzoc8ZOKkb6/xOjvBHPHpo3RzgIxKLFPz7g4V8 X-Received: by 2002:a5d:9650:0:b0:7c7:9b2a:ff13 with SMTP id d16-20020a5d9650000000b007c79b2aff13mr2250976ios.15.1709215794805; Thu, 29 Feb 2024 06:09:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709215794; cv=pass; d=google.com; s=arc-20160816; b=hJIH2jo73xtzNvESjxIVBYC8J7dEzvz1t4sQwDfw/paKRR+WEQD9fAHojjhgD7QlMp jHioZVCx2GlEl9PyOVUzNV/0LBRrB0wpUN17LFhoMXnIDjb/le3KKW9I26j3Pqei2h4w WybKtkPVtwV990GzmH8LmgBt7p5+Z7RHDBTiRDNh6aF59VjkbrXFmR+fSoBjdLI62vnb e1LrVygQBnWiHjd2u2r5XR0fcLulWVK0CHtl76vOwc2coCB1RbSetsB1TmiqQXzL7AAS 8mo1dIOy2w4GcS7eRiYc38N37ZF8YYhI510gDfIuUCRIzxfNxvPJmHfNS4aeGvxWxzMU BmVA== 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=S51QUGug0Q7Ds3/hgpcm7IIzM0t2qYTUCN5BDuxwjtLBcnz+1M4Czep8srqVUMFXds Ln15QbHKhgWxmSEinAxM10uc0De6cHrQsolku4R3ENwV9wqVodRTo+6XWSkiC8dYFaah OUehCEIOOcZI/6XmSlS3hnWz2t/LXXjF60hHhLE5rrr6OXXSvGPLwfTbocuyMFVqbJID XvOE1AMjygmXon/fDu4JoX3LJ6awfjqvEw7QfCCvWBWqgVBK5mDmWQY7BJ9Fn05QBSPG wfrbP0fK+6UArz5Au0CYoj2BF9MFR2AHOzgWUFsMgMp/n1w4j/EstfozY5ddcuQlqrQ8 DQLg==; 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-86801-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86801-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a21-20020a5d9ed5000000b007c7e7ea87b6si447009ioe.134.2024.02.29.06.09.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 06:09:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86801-linux.lists.archive=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-86801-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86801-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 76EC92864E9 for ; Thu, 29 Feb 2024 14:09:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D181113B29A; Thu, 29 Feb 2024 14:08:25 +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 C945712E1FD for ; Thu, 29 Feb 2024 14:08:20 +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=1709215704; cv=none; b=loEgVKX/P31NnQm4P83k7ZNA/xhY+6yiDRvXwAOvifN8fpO9qPFCOdYc2W9xfr+zoxpMMJwwpur6IJ71V5KEglW6wrNIoco5krH0NkMJc8pbmwmPS6qldQwPUAXc0RSapy1ksgEQiHPHcDYgVD7wzHAbhh7x4LrFB1eKcHXlExM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709215704; c=relaxed/simple; bh=bnczvboHhvoEalEW9xSpju92M4P2dgF3JOLgOD2eOHI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oDie7iCA/J2dCRagqkRPcYImziFLq4eXWXqPML7Z5fjbpFn/IdY8nVYaxT65e+KGqzGyii4rN+j0UK9Q9EMX8umzxSo6Z7udSIF86q7VrAQmC8KTc/lXANfr6quo931KmOrGk8UIF33ekp1oH/NUfBQRMdhvv6KG5CxnzhlP6vg= 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 1rfh4t-0000Ss-MX; Thu, 29 Feb 2024 15:08:03 +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 1rfh4r-003bZm-J4; Thu, 29 Feb 2024 15:08:01 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rfh4r-00ELln-1C; Thu, 29 Feb 2024 15:08:01 +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 v7 1/8] net: add helpers for EEE configuration Date: Thu, 29 Feb 2024 15:07:53 +0100 Message-Id: <20240229140800.3420180-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240229140800.3420180-1-o.rempel@pengutronix.de> References: <20240229140800.3420180-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