From patchwork Sat Mar 2 19:53:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 209252 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp629856dyc; Sat, 2 Mar 2024 11:55:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVCBxpOkvYmKI/hGreRoOu6tBo3+QIvF/5JmcJBdwAreHzny5JSvVBG2UE3c3J4Rl60TekUgQTh7Pa04BBBpVDvC15FaQ== X-Google-Smtp-Source: AGHT+IHrmO6hc4gHwsKd/iWj4GqmvzTAmpp3QPlG2vCambk/1Hh/jd1MIULl5j1anu1yEFdjbTlc X-Received: by 2002:a05:6512:39c5:b0:513:3472:b514 with SMTP id k5-20020a05651239c500b005133472b514mr4472574lfu.22.1709409333019; Sat, 02 Mar 2024 11:55:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709409332; cv=pass; d=google.com; s=arc-20160816; b=Ryef9vp6+j6YuGxFQdTZSf3fufGfF+kY2AIMcH0jQHuXSNihxF1KoFwC2QzJgpiQG+ eo6l7GA9xayRdlfBZ6W1zZxIiiRmvYXy7bFL0NCdf5UZae1Dtmoj7Hr7BuvxrZ9YdOfe gChrV5thOuP1+0MRKlbIBPEciqg+98A4bJOXHWqt9C+UQCcDKm+cJIKllHafyMob9RRv 3lTm7VwzMUQrdl4TQtBj5ACDwCIvSS9H8RG6GETtIaJIchyHRrbsnm1ODdPlSiT0klbP wcJShyM88h3t7kCwB6WThC/TUgwzBDe4Kmu5ujtz6dUx1xEXkou/Fap+uCEAO8ZoySsY OCjQ== 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=8d0h8UxhhaYmnojDbvE/Ojrlx4kzbXVE1uhGEqKaiqw=; fh=sVZ6H5f6ewU2fC+U58NocBocCWosMlAmPb9AApl9d+c=; b=uXf9WHJ75Ffh6h/BqcPMbmrjSvCYrUo8Oxep3gFG5gjwTOcpTVWbbXsrHqsDsE8fda IVqc0OzZ0OHcb/VH6HF19iKK8nUP54fwIWDs4T8+Iz+BxFzYLLv00ob/nETIIkQj6bkv tN29Dzei3WyujoxATD3nF3EwTa3M7UwWpuLMMPjAklrzsSTqAlxHxrnncJ42fRJfqUSV 3x1Y/cWvGRY8eDpmy60JO6hkr/bcV7C4dvByw7U0dCDX6sAOb57GKbKWGScfxu6A2dpl CYTJwAyv4j5w6fI1GbQYxK6MKcyLTJB8sd/uJYQOFgelRuwIcH2XIbeo2UHe5iuHNVhG yUYg==; 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-89574-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89574-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kz15-20020a17090777cf00b00a44c24e6a29si606477ejc.380.2024.03.02.11.55.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 11:55:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89574-ouuuleilei=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-89574-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89574-ouuuleilei=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 958E71F21FD6 for ; Sat, 2 Mar 2024 19:55:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 230A74DA1F; Sat, 2 Mar 2024 19:53: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 CC8A54087C for ; Sat, 2 Mar 2024 19:53: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=1709409203; cv=none; b=qM8dcQ7nNq3mPuvJn9HBKd11+rzq8DpkY8+6m30ZaoX4c15hD5Y1Uc7YOMToqF59Pcf9+LcSUbj7HIzRnPr919gSLj/fpkrsQM5K4WXWFz81ztkDUYBw2yvoanY3RRc2S7oyptY7TBUNPcFo6SE5qWbaYhFEJ7sqLaIZfYaGjOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709409203; c=relaxed/simple; bh=dVniOLfoKxaNTw/jk9o77Mf8NrQSWJwOOaH6nhjN2VM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LySc2ZeGrVCLaAwsklWUFtrOSuCXFtCFSE0gmLRR/GiMPhl0GN8dbeV5lvhabQonfqk9CnFv+JYKkoSJy7gWRoiOXHXnnMimzdyEltxfZuAxH63FYAelyw0KxN/unDsyZ5eULO3i1bomudX88VzP0TdW07j3M6OMMo18jjSZ9e4= 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 1rgVPx-0007Gt-MY; Sat, 02 Mar 2024 20:53:09 +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 1rgVPv-0041mC-Nq; Sat, 02 Mar 2024 20:53:07 +0100 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rgVPv-00DSU3-27; Sat, 02 Mar 2024 20:53:07 +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 v9 1/7] net: add helpers for EEE configuration Date: Sat, 2 Mar 2024 20:53:00 +0100 Message-Id: <20240302195306.3207716-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240302195306.3207716-1-o.rempel@pengutronix.de> References: <20240302195306.3207716-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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792445600601531138 X-GMAIL-MSGID: 1792445600601531138 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 --- v8: change dst<>src order --- 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..84837aba3cd9e --- /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(struct ethtool_keee *eee, + const struct eee_config *eeecfg) +{ + 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(struct eee_config *eeecfg, + const struct ethtool_keee *eee) +{ + eeecfg->tx_lpi_timer = eee->tx_lpi_timer; + eeecfg->tx_lpi_enabled = eee->tx_lpi_enabled; + eeecfg->eee_enabled = eee->eee_enabled; +} + +#endif