From patchwork Thu Feb 29 14:07:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 208374 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp420422dyb; Thu, 29 Feb 2024 06:10:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW1BDan+keDcnFmsX1hNNq7Vj706t8iLRMn8uWmqshL25Sz2HFFnPMq5KMyl2pPukxTJwleQYtayjxX5yAqM2XEYDQQ4A== X-Google-Smtp-Source: AGHT+IFHe+j+M4uj5RQEeDJaVhBkqlHlN333KbrnSeyXnjFwIb+S+o/MwMWtU75omZlLINZB9Nh0 X-Received: by 2002:a05:6e02:52d:b0:365:15f6:2435 with SMTP id h13-20020a056e02052d00b0036515f62435mr2500736ils.1.1709215835935; Thu, 29 Feb 2024 06:10:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709215835; cv=pass; d=google.com; s=arc-20160816; b=1IO3L0ScSNLQbYetuRmsI2UvHoZLgcN9PlygOhHUSTY2PGXscRiq9VQ3hL5xJUhx2y FFQYTUy6YbYN2MDGokfQAuuHxu6Fg1C+MGXGHLxsasOu25yRtzaCjBq01CM/5fl219Lb QyxC1w4NL1mKlXSNwv24LUnSMRYlt72rSdp+hjpAXYQyttI06l8jy6aSsx9fk+St8pAg cK+HGKYzsNKNoFct7U0y+39r0CKmNSlLOYJ0X/LP5xRxA4M0iCLaDRqPC4rThUjhXchy h6b5ZmnOsULpPcjeqxskVA+U7hDq9B8jlSeYh8ZcaF6OdhVOSLe2rIMLfYNFTavhYJjF GAyw== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86801-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z8-20020a92da08000000b00365000485d6si483590ilm.47.2024.02.29.06.10.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 06:10:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86801-ouuuleilei=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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86801-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A55AD285598 for ; Thu, 29 Feb 2024 14:10:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82A9514A4C3; Thu, 29 Feb 2024 14:08: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 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 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: 1792242704549226016 X-GMAIL-MSGID: 1792242704549226016 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