From patchwork Mon Mar 27 14:21:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 75501 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1565799vqo; Mon, 27 Mar 2023 07:47:11 -0700 (PDT) X-Google-Smtp-Source: AKy350aQiNmX8SX70cz9JPk7q98AnUMJP0eRXTKor8cuMv6KYxWHddrK4sYk6S2hdNgXexnPj9Qs X-Received: by 2002:a17:907:d047:b0:945:2f54:5eae with SMTP id vb7-20020a170907d04700b009452f545eaemr2987537ejc.77.1679928431015; Mon, 27 Mar 2023 07:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679928431; cv=none; d=google.com; s=arc-20160816; b=AYDAP8K6d9qwnVpkZmocAHeSUDKFAgFuF+1A6iSY/9NPioww9l6UG1UGJ/mYeAnmJb qdyjZJjBrcw2Kl3uz09mQIyggcitETllgR3lgmo28CdvBbnDAv00GrI6i0I5XT1hALRv AAD9eRCaDkTtzMbHzJUnVs9U35QryctF5oLKS4NsUYmAGE+8+scQMn53csn6JcMtHDIW Zq4eU2+gNgjDCYt/SmKRcsnbrM2YPJmm2luviKIYzh4evoTvtvChgqcrFoE7J/kHsjrT KEKz3ilZ4EWl2SOP2hIvWxeNeo/DymuTZO6Xr+vsIswA/5S7Znl/qjlgEFGMG6fvAoPx MSUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gFaxqRFIyhSZshPbsXa7V3/MnHbXQkvs1SE+2DDrqLQ=; b=OCx5PGR9dBc8w0FA+Vgx8gj/Mxzgcuow0O6PNXCUL93LK461X01vyTw+jlWkJ1MXxq uWoimdLEnNi/Cc9qDmdg2o4fB+zdQuodUTAEks+KSpQAXRJRy/b/gf1Hhk7sFNcSPh2a 0nbpF+IV2Yy5lAvw7UEHZFWOs6DIT1e6Y7QF/FTmuCj5Ih2SKYpUUHkkZuNX2CEfwoMv Zo8zGRS7PfOWNOmBBxonCUoTeHyQKEJe5y6X0iWhdxNgR0HUeFUthseKVwTxHU33UWau PDTIwYmk/FO8mtG+XKIQTH2zfqwsLew/hHEz5lrwKE78BjOi7gU9jc97RZyKH8DZ4BmO nB6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo22-20020a0564020b3600b004bdf14718c0si26987874edb.99.2023.03.27.07.46.47; Mon, 27 Mar 2023 07:47:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233034AbjC0OYP (ORCPT + 99 others); Mon, 27 Mar 2023 10:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232132AbjC0OXs (ORCPT ); Mon, 27 Mar 2023 10:23:48 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B6697D8E for ; Mon, 27 Mar 2023 07:22:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hj-Kt; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IK-7Q; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00Fkik-PV; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 1/8] net: phy: Add driver-specific get/set_eee support for non-standard PHYs Date: Mon, 27 Mar 2023 16:21:55 +0200 Message-Id: <20230327142202.3754446-2-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> 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.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761532634145993733?= X-GMAIL-MSGID: =?utf-8?q?1761532634145993733?= Not all PHYs are implemented fully according to the IEEE 802.3 specification and cannot be handled by the generic phy_ethtool_get/set_eee() functions. To address this, this commit adds driver-specific get/set_eee support, enabling better handling of such PHYs. This is particularly important for handling PHYs with SmartEEE support, which requires specialized management. Signed-off-by: Oleksij Rempel Reviewed-by: Andrew Lunn --- drivers/net/phy/phy.c | 10 ++++++++-- include/linux/phy.h | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 0c0df38cd1ab..103484c24437 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1568,7 +1568,10 @@ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data) return -EIO; mutex_lock(&phydev->lock); - ret = genphy_c45_ethtool_get_eee(phydev, data); + if (phydev->drv->get_eee) + ret = phydev->drv->get_eee(phydev, data); + else + ret = genphy_c45_ethtool_get_eee(phydev, data); mutex_unlock(&phydev->lock); return ret; @@ -1590,7 +1593,10 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data) return -EIO; mutex_lock(&phydev->lock); - ret = genphy_c45_ethtool_set_eee(phydev, data); + if (phydev->drv->set_eee) + ret = phydev->drv->set_eee(phydev, data); + else + ret = genphy_c45_ethtool_set_eee(phydev, data); mutex_unlock(&phydev->lock); return ret; diff --git a/include/linux/phy.h b/include/linux/phy.h index fefd5091bc24..07cebf110aa6 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1056,6 +1056,11 @@ struct phy_driver { /** @get_plca_status: Return the current PLCA status info */ int (*get_plca_status)(struct phy_device *dev, struct phy_plca_status *plca_st); + + /** @get_eee: Return the current EEE configuration */ + int (*get_eee)(struct phy_device *phydev, struct ethtool_eee *e); + /** @set_eee: Set the EEE configuration */ + int (*set_eee)(struct phy_device *phydev, struct ethtool_eee *e); }; #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) From patchwork Mon Mar 27 14:21:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 75493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1559012vqo; Mon, 27 Mar 2023 07:36:01 -0700 (PDT) X-Google-Smtp-Source: AKy350bpRqNQ63sag3FBlGXtoOApbxlYaAVLALzhnNRVs4A2IoWRWpmXs6271yUGVLLtayc6XhLu X-Received: by 2002:aa7:ce0f:0:b0:502:24a4:b0ad with SMTP id d15-20020aa7ce0f000000b0050224a4b0admr11268303edv.4.1679927761765; Mon, 27 Mar 2023 07:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679927761; cv=none; d=google.com; s=arc-20160816; b=T9/GiLi3ARrLnU4nz/R4WvpSbMBd9Xa/O0ct6jYJg50K7NThys7CQvDNBwTAwa/ZUh h2/uDPamFfkcVahBWOuXp4FoGAvrRSHMYWmtr3C1PQGoMDu1StTiG3cqxP/he6NP5rAP E8A43iKJHfn6Qk6+g+/VXG4mr9oSlpN5RsB6BbRFUuyjQywsqtHsHXT97ke74rn3CvBW pNbd0b95zeFR7SCcS2lpZZ0HgmLtlU2c/eZROh5ep1fDdpczjtBhsPS3fCks8RFc89cx Mu/XbGP8JCe2xG+qp/xtBXw/W7DJQTo96Cdp0QqovK9k45qIgFzk4w1ah0rj4SRu05/f Rurw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=oAh4+LVUnwglLUYHPcoH7jtFkM2FIJJSUl0J3Xsp7CM=; b=iXdcQLGJHDOXqHY5hId8+V0DWMQfnJSPA45hNeB/YT+uEtyG4Ds5poDDHbUvRpQXMk bi8nnYwSHEEqsvoUYyp/BzQwbLrWkR5xgHNPqpDnW8xNP/5/7VZjDhlym17wx6a0sNFK uP13/1J2xJ15Ci9dtrNLnULIh8ow4H8GyHAhyCH2HxzvUoeJSWp1zEmwdAf5s9wZ+tYs /8N5vwWm45jo8hu8zls+TGrSZ042/khtrLUE6oYly/KLsSpxiEu6hiJLOtmELJ3jFcPf IqZdsCLI5xtQIwPoUlt4fPY6vNYxB6NH9UQqiFJxloRUHvDbrRdIwdFLeEveOTbfPa2+ yeuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p24-20020aa7d318000000b004e1db2eb805si27001147edq.494.2023.03.27.07.35.37; Mon, 27 Mar 2023 07:36:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233023AbjC0OYM (ORCPT + 99 others); Mon, 27 Mar 2023 10:24:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjC0OXs (ORCPT ); Mon, 27 Mar 2023 10:23:48 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87E017D8A for ; Mon, 27 Mar 2023 07:22:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hm-Kr; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IT-N2; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00Fkit-Qe; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 2/8] net: phy: add is_smart_eee_phy variable for SmartEEE support Date: Mon, 27 Mar 2023 16:21:56 +0200 Message-Id: <20230327142202.3754446-3-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> 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.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761531932716370631?= X-GMAIL-MSGID: =?utf-8?q?1761531932716370631?= This commit introduces a new variable, is_smart_eee_phy, to the PHY layer. This variable is used to indicate whether a PHY supports the SmartEEE functionality, which is a Low Power Idle (LPI) implementation on the PHY side, typically handled by the MAC. By adding the is_smart_eee_phy variable, PHY drivers and the PHYlib framework can provide proper configuration depending on the side that implements LPI (PHY or MAC). Signed-off-by: Oleksij Rempel --- include/linux/phy.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index 07cebf110aa6..6622b59ab5a1 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -547,6 +547,7 @@ struct macsec_ops; * @downshifted_rate: Set true if link speed has been downshifted. * @is_on_sfp_module: Set true if PHY is located on an SFP module. * @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY + * @is_smart_eee_phy: Set true if PHY is a Smart EEE PHY * @state: State of the PHY for management purposes * @dev_flags: Device-specific flags used by the PHY driver. * @@ -642,6 +643,7 @@ struct phy_device { unsigned downshifted_rate:1; unsigned is_on_sfp_module:1; unsigned mac_managed_pm:1; + unsigned is_smart_eee_phy:1; unsigned autoneg:1; /* The most recently read link state */ From patchwork Mon Mar 27 14:21:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 75498 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1564811vqo; Mon, 27 Mar 2023 07:45:36 -0700 (PDT) X-Google-Smtp-Source: AK7set9qGR5qASp/EOkfhtWZrVj2VyuuFGA/vNS8AlyAtnB0a7+KgY8ZtLvh/B7H9qKHtpE0a9lt X-Received: by 2002:a05:6a20:6695:b0:cc:fa4b:3a6a with SMTP id o21-20020a056a20669500b000ccfa4b3a6amr12303195pzh.58.1679928336280; Mon, 27 Mar 2023 07:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679928336; cv=none; d=google.com; s=arc-20160816; b=zCMuENTg7a0UXAK1hZ3d734EyAZccMe7cLJjxBRNY9XjP1K5TlQsDwE8OAqBsEktlF CFikOPl/9+Fhj1Cv3N7PLkucKXvW4rZPHfxU3ZUW0VyysnM8oDEGIUXrrVZPGD+MInxn e31N0e2IFTqFZb8gS9u3OhPXyH5gpC1DFpk62ciVBpp8MUX+/0PAwZX8YGWDpIAC3aw5 wviR3UB85LQxrQqGn9b8ELJ3XKLkdJ1adKxFeGlxlE1vuggGxj3zbUGxourY3pgH3Qz2 OTLoEnlcLB9wVAgw3hw5Q35+kce8WKXmggI8y7hzEeJkl9SvlVt3RvInUr2at7PEpchC H/CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hmjVQlXF5SpEk9CrStYCK8mK9s5ttk/L8isIdQB3N0k=; b=r2rVTzmAO73H6xPL5u3hBeEn+kgkpAUUDMMBlTrxk5JUnxwIw+EnMqXCR5I5Tx4M+v 2Jzy2HO4LPqt12T2v+Y+bqRcajTJdCmYoX8n74BQzWdl9ya5win8fXYf//aYy6yVN8ia c5E6mei2BVFWRI8uwjmfBgKcq53FdgUaB7S2tAde7Ido8l++2tkD3aEUSR3rFi/Rce/a hSWiqWpCoWkfZGdh/oaxTx1Foaq2sLtj7M0+3ZAdehNkBtTR0tM56Fnyuw20NyIr8Jf3 kAyW4un5pe5w4kMujVy4zmx+cfoQ7TX6bE1CG1c6ok3RPygpXNpau9kZMbP2eMUKyutn GbUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r137-20020a632b8f000000b0050fbc594e1asi13693298pgr.207.2023.03.27.07.45.23; Mon, 27 Mar 2023 07:45:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232514AbjC0OYJ (ORCPT + 99 others); Mon, 27 Mar 2023 10:24:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232065AbjC0OXs (ORCPT ); Mon, 27 Mar 2023 10:23:48 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87ED97D8C for ; Mon, 27 Mar 2023 07:22:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hi-L1; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjX-0076IH-SB; Mon, 27 Mar 2023 16:22:03 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00Fkj2-RP; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 3/8] net: phy: Add mac_supports_eee variable for EEE support and LPI handling Date: Mon, 27 Mar 2023 16:21:57 +0200 Message-Id: <20230327142202.3754446-4-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> 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.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761532535070644048?= X-GMAIL-MSGID: =?utf-8?q?1761532535070644048?= This commit introduces a new variable, mac_supports_eee, to the PHY layer. This variable is used to indicate if a MAC provides EEE support or is responsible for Low Power Idle (LPI) handling. The mac_supports_eee variable should be used in conjunction with is_smart_eee_phy to make proper configuration decisions based on the capabilities of both the PHY and MAC. By adding the mac_supports_eee variable, PHY drivers and the PHYlib framework can better coordinate EEE and LPI management between the PHY and MAC. Signed-off-by: Oleksij Rempel --- include/linux/phy.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index 6622b59ab5a1..573ad3fc2bf7 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -548,6 +548,7 @@ struct macsec_ops; * @is_on_sfp_module: Set true if PHY is located on an SFP module. * @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY * @is_smart_eee_phy: Set true if PHY is a Smart EEE PHY + * @mac_supports_eee: Set true if MAC supports EEE * @state: State of the PHY for management purposes * @dev_flags: Device-specific flags used by the PHY driver. * @@ -644,6 +645,7 @@ struct phy_device { unsigned is_on_sfp_module:1; unsigned mac_managed_pm:1; unsigned is_smart_eee_phy:1; + unsigned mac_supports_eee:1; unsigned autoneg:1; /* The most recently read link state */ From patchwork Mon Mar 27 14:21:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 75499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1565202vqo; Mon, 27 Mar 2023 07:46:07 -0700 (PDT) X-Google-Smtp-Source: AKy350YAou6gBZ4wC6tGs4ZSxvTOHlYCBrw3pGp/v660WjrgXl+aJFxjdpTgJgjpv3adSSncUvP6 X-Received: by 2002:a17:906:4fc5:b0:939:4d6d:1f26 with SMTP id i5-20020a1709064fc500b009394d6d1f26mr15255057ejw.50.1679928367430; Mon, 27 Mar 2023 07:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679928367; cv=none; d=google.com; s=arc-20160816; b=SjcD1OSsFdqyjmCI4+6YlOe9cH4aZTlV3fNVuzE7u2urgcJLaz3O0clf8RKSBpiGiB ozjRChckTzO83Fky4Mq36E1VwLdMhXaxdhQm799HuDpkSdrN4u8FSgRs/7jP/UGmrcTh j7OoIenjwTasRiyA7AecW+Adnmu+miVuTvtJt/gXsKq29xxKgwmQaRO0Xfjf3Jhi44hp 83p8ahvUnVyOf5ku8XCIqrPa5Oiw6BNI/suOWs6/Z0Twbz4a81h41qaPIaEE5dF1uj0m JSGrxE5vZjz9m+9bOAJIE6luC3VcAgQi+shq1Csq94yCQlKMY1G/J23tUp2yG0CWYyew 44hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Mi81lf7gYehfE4ww7QLFP9NLyE4pD3JPoG5CxLIHipk=; b=c2MxLEL3v9uNc5wfKtHMMRHk2vYSmxI4sxGw5zwLT6L6y0H30xxi5fU6RQzUMNkYnB OZjm5CLVgVO7K3Qx/yec21F3LRhAy3LiXFfylcXCCHCL9TNRIDmO6vFuUrHnRb4ySWhX DKPAZLse4JIh9ih9oaRXxqDTdWPw58cp6mtPg2XIPtpSmtkii0RWATS/u0ni609W3Mo2 DJ62JtNvJcajKPuNEO3xmzPUjzPI1dsjIS1DBrp7rqefVcXrZ+fuTJ+IDiuHmRpSe1S8 8OLkXjxEWVUxKXRP++ytdnlzv/EVDBmq69vyU+1YCqFfCj3NJYWcIVgAthQTIcHRZQRP HGtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp7-20020a1709073e0700b00932e6d5bd8asi30856964ejc.980.2023.03.27.07.45.44; Mon, 27 Mar 2023 07:46:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233108AbjC0OY0 (ORCPT + 99 others); Mon, 27 Mar 2023 10:24:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232314AbjC0OXt (ORCPT ); Mon, 27 Mar 2023 10:23:49 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8D257D96 for ; Mon, 27 Mar 2023 07:22:15 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hl-Ky; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IQ-J2; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00FkjB-SC; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 4/8] ethtool: eee: Rework get/set handler for SmartEEE-capable PHYs with non-EEE MACs Date: Mon, 27 Mar 2023 16:21:58 +0200 Message-Id: <20230327142202.3754446-5-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> 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.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761532567621969042?= X-GMAIL-MSGID: =?utf-8?q?1761532567621969042?= This patch reworks the ethtool handler to allow accessing set/get EEE properties of SmartEEE-capable PHYs, even when the associated MAC does not provide EEE support. Previously, the handler would not allow configuration or management of EEE properties for such PHYs, limiting their functionality and energy efficiency. Signed-off-by: Oleksij Rempel --- net/ethtool/common.c | 38 ++++++++++++++++++++++++++++++++++++++ net/ethtool/common.h | 2 ++ net/ethtool/eee.c | 17 +++++++++++------ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/net/ethtool/common.c b/net/ethtool/common.c index 5fb19050991e..267fd3600f15 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -661,6 +661,44 @@ int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index) } EXPORT_SYMBOL(ethtool_get_phc_vclocks); +int __ethtool_get_eee(struct net_device *dev, struct ethtool_eee *eee) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + struct phy_device *phydev = dev->phydev; + int ret; + + if (ops->get_eee) + ret = ops->get_eee(dev, eee); + else + ret = -EOPNOTSUPP; + + if (ret == -EOPNOTSUPP) { + if (phydev && phydev->is_smart_eee_phy) + ret = phy_ethtool_get_eee(phydev, eee); + } + + return ret; +} + +int __ethtool_set_eee(struct net_device *dev, struct ethtool_eee *eee) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + struct phy_device *phydev = dev->phydev; + int ret; + + if (ops->set_eee) + ret = ops->set_eee(dev, eee); + else + ret = -EOPNOTSUPP; + + if (ret == -EOPNOTSUPP) { + if (phydev && phydev->is_smart_eee_phy) + ret = phy_ethtool_set_eee(phydev, eee); + } + + return ret; +} + const struct ethtool_phy_ops *ethtool_phy_ops; void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops) diff --git a/net/ethtool/common.h b/net/ethtool/common.h index 28b8aaaf9bcb..59c1906ec800 100644 --- a/net/ethtool/common.h +++ b/net/ethtool/common.h @@ -45,6 +45,8 @@ bool convert_legacy_settings_to_link_ksettings( int ethtool_get_max_rxfh_channel(struct net_device *dev, u32 *max); int ethtool_get_max_rxnfc_channel(struct net_device *dev, u64 *max); int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info); +int __ethtool_get_eee(struct net_device *dev, struct ethtool_eee *eee); +int __ethtool_set_eee(struct net_device *dev, struct ethtool_eee *eee); extern const struct ethtool_phy_ops *ethtool_phy_ops; extern const struct ethtool_pse_ops *ethtool_pse_ops; diff --git a/net/ethtool/eee.c b/net/ethtool/eee.c index 42104bcb0e47..43b866184297 100644 --- a/net/ethtool/eee.c +++ b/net/ethtool/eee.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only +#include + #include "netlink.h" #include "common.h" #include "bitset.h" @@ -32,12 +34,10 @@ static int eee_prepare_data(const struct ethnl_req_info *req_base, struct net_device *dev = reply_base->dev; int ret; - if (!dev->ethtool_ops->get_eee) - return -EOPNOTSUPP; ret = ethnl_ops_begin(dev); if (ret < 0) return ret; - ret = dev->ethtool_ops->get_eee(dev, &data->eee); + ret = __ethtool_get_eee(dev, &data->eee); ethnl_ops_complete(dev); return ret; @@ -123,8 +123,13 @@ static int ethnl_set_eee_validate(struct ethnl_req_info *req_info, struct genl_info *info) { const struct ethtool_ops *ops = req_info->dev->ethtool_ops; + struct net_device *dev = req_info->dev; + + if ((ops->get_eee && ops->set_eee) || + (dev->phydev && dev->phydev->is_smart_eee_phy)) + return 1; - return ops->get_eee && ops->set_eee ? 1 : -EOPNOTSUPP; + return -EOPNOTSUPP; } static int @@ -136,7 +141,7 @@ ethnl_set_eee(struct ethnl_req_info *req_info, struct genl_info *info) bool mod = false; int ret; - ret = dev->ethtool_ops->get_eee(dev, &eee); + ret = __ethtool_get_eee(dev, &eee); if (ret < 0) return ret; @@ -153,7 +158,7 @@ ethnl_set_eee(struct ethnl_req_info *req_info, struct genl_info *info) if (!mod) return 0; - ret = dev->ethtool_ops->set_eee(dev, &eee); + ret = __ethtool_set_eee(dev, &eee); return ret < 0 ? ret : 1; } From patchwork Mon Mar 27 14:21:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 75500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1565686vqo; Mon, 27 Mar 2023 07:47:01 -0700 (PDT) X-Google-Smtp-Source: AKy350a7vjXDjglTZSLzldoPCg6PHYniex0ZXlongVsX6kg4Z21QahjiHTfKGUkOFGezXHwfzycY X-Received: by 2002:a17:906:1e13:b0:92f:e40d:1489 with SMTP id g19-20020a1709061e1300b0092fe40d1489mr13558249ejj.61.1679928421722; Mon, 27 Mar 2023 07:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679928421; cv=none; d=google.com; s=arc-20160816; b=A3mf7FZ6oOwTt3EYX3xP05qrg6oAJn5ZnojQbXlopr3JCNCBg/BC15Yy9QvCmkiOuk gKbG8r84uQ35kcXY79MN416LVzTrGVrAdTBvDPySY7Zk2cUB7eKzKq58HUjGLgiXxaEl G7xkFsvhRMDm6P4XmDeN2NaKyF4Wi+2r5kWiLGmRA0hNN6v+t0xlsECPmyzI5H4WU5dI uMKXxyjr5whRUfTLmggLDTLdWozlqekebmxEqkCLwn1+8Md7ySNhrYaW8/2W4wEHQFIN zOlMeHOjB1GYgI0DDUC2Kng9RYDXyAhK2DZP8lK30edz3x/bez6wGCuFIdapreaIXj4L 9Ntg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YFp4Uz+Q0TStFy7KNyI/XRQaH9zgVzDIisIuoe/C3xk=; b=FDw+Sd4AcoQBbrShceEjyCp2m9rzkeWzffAcBycUtn8IfWyRJnALnpBtIdu4xEDHT3 1Lk2dbVCh4NYmvrHMvYW4DXtvsLY6y2DiEFQ3Md6tadFHmrmHCF63pVp2uOWWj6Fwtp6 MA/h2C5lrCoMZg20keopFP2bztIRXQ6kPqFTWPpxklGi//i/Yu/KnbTaJYcDIFAMEhRj DCiklYBal9w2CSVnwN1kd6hin0C6V449pLj7ir3Xvy/h41w9jix9jDf5ewnAdPwkU3eh mAp4a5J0xNnci/Gtkjc55kWG5vnOyjVt0D72PfIYM/03aM0zyPZDMSoqZwexzGl6Pt3Y 4Abw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k3-20020aa7d8c3000000b004bc501f34d4si25685380eds.250.2023.03.27.07.46.39; Mon, 27 Mar 2023 07:47:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233065AbjC0OYS (ORCPT + 99 others); Mon, 27 Mar 2023 10:24:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232885AbjC0OXt (ORCPT ); Mon, 27 Mar 2023 10:23:49 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C41B76BA for ; Mon, 27 Mar 2023 07:22:15 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hp-Kw; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IZ-Ss; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00FkjK-T0; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 5/8] net: phy: at803x: Indicate SmartEEE support for AR8035 and AR8031 PHYs Date: Mon, 27 Mar 2023 16:21:59 +0200 Message-Id: <20230327142202.3754446-6-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> 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.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761532624810665455?= X-GMAIL-MSGID: =?utf-8?q?1761532624810665455?= This commit adds SmartEEE support indication for the AR8035 and AR8031 PHYs in the at803x driver. These PHYs support the SmartEEE functionality, which is a Low Power Idle (LPI) implementation on the PHY side, typically handled by the MAC. By indicating SmartEEE support for these PHYs, the at803x driver and the PHYlib framework can provide proper configuration and management of EEE and LPI features. This allows for improved power management and energy efficiency in devices using AR8035 and AR8031 PHYs. Signed-off-by: Oleksij Rempel --- drivers/net/phy/at803x.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 656136628ffd..653d27a2e62b 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -856,6 +856,12 @@ static int at803x_probe(struct phy_device *phydev) if (ret) return ret; + if (phydev->drv->phy_id == ATH8035_PHY_ID || + phydev->drv->phy_id == ATH8031_PHY_ID) { + if (!(priv->flags & AT803X_DISABLE_SMARTEEE)) + phydev->is_smart_eee_phy = true; + } + if (priv->vddio) { ret = regulator_enable(priv->vddio); if (ret < 0) From patchwork Mon Mar 27 14:22:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 75490 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1554017vqo; Mon, 27 Mar 2023 07:28:50 -0700 (PDT) X-Google-Smtp-Source: AKy350Zsm+x3TY8ukBkYvVyUVhnod4grrL3WfkH68nt5oNGfIEmE+22R4wGq+FIxNG2XTZSB3NEG X-Received: by 2002:a17:906:eb49:b0:889:58bd:86f1 with SMTP id mc9-20020a170906eb4900b0088958bd86f1mr12105805ejb.14.1679927330433; Mon, 27 Mar 2023 07:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679927330; cv=none; d=google.com; s=arc-20160816; b=TiLtwZxFBwZL7h9cYiFYgPOY3IURSagNdodl97ULDm+8aTAq17oBO3BsMyHBsPevPW jJxjdKeWYKxRxLznJy+bd4vItUeEOElgc6ARtEeJUQQ/AIW9CQ7P2Dd4EuNSZzbxaSOC fYhihJDAMRcET/sufY7Av27YfdpDkg5l3XxK8lIabrhOXCGGOwHzrgOIc9spFkS53XkJ HkYVsRfDPxCnn5ZrJC+eGMdE2A0CJXIvsDSTv0pzh8v6gl5BbF51l78SFgrPdtfxNa0Z tEkeCcRY/Q8zE5r/qujrcJF/keuvHh44Yun9GwcmbOxxSBRVrIIUzeAUAixzCPU5N868 rR3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JC6b3/xK7fIASxtsTckrVYfNiYhWEZIV+wseaCflVZw=; b=VtvQwk1OwkKhH4EN5UGG1fBk641uWktvlns6GnyyDn7nyYZolwDM/31mQwx5pyT3rh B1Uuv41ttgRe+HYkvjqXW4MxaxoY3+VAc86jhpBhRkcYb00a0Row6dhCaYGAt3I+GhkT FvKxKTncpPjO8uun4ZtyaOSiFejH5LjErT9hO5W3T3xp3rF8EaDRx5vyqMEl6i6kjbNP IUCXPBneBb6akBtAgMSob84yO1lfhMPpIWi8E0oilCw14+ldhyVXcQS4F2wKDAcAyRq0 w6a2OHVNIBAqayUq+A2IbV4wh9bIr6FZvrMSWAFSwzmg5+pE7lkcoy6d/iWNHPISEpzD OkPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y16-20020aa7ccd0000000b004af6a174397si29371585edt.231.2023.03.27.07.28.26; Mon, 27 Mar 2023 07:28:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233083AbjC0OYU (ORCPT + 99 others); Mon, 27 Mar 2023 10:24:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232919AbjC0OXt (ORCPT ); Mon, 27 Mar 2023 10:23:49 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 649DE422F for ; Mon, 27 Mar 2023 07:22:15 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hk-Kt; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IN-Cv; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00FkjT-Th; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 6/8] net: phy: at803x: Make SmartEEE support optional and configurable via ethtool Date: Mon, 27 Mar 2023 16:22:00 +0200 Message-Id: <20230327142202.3754446-7-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> 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.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761531480406424413?= X-GMAIL-MSGID: =?utf-8?q?1761531480406424413?= This commit makes SmartEEE support in the AR8035 PHY optional and configurable through the ethtool eee_set/get interface. Before this patch, SmartEEE was always enabled except when a device tree option was preventing it. Since EEE support not only provides advantages in power management, but can also uncover compatibility issues and other bugs, it is beneficial to allow users to control this functionality. By making SmartEEE support optional and configurable via ethtool, the at803x driver can adapt to different MAC configurations and properly handle EEE and LPI features. This flexibility empowers users to manage the trade-offs between power management, compatibility, and overall performance as needed. Signed-off-by: Oleksij Rempel --- drivers/net/phy/at803x.c | 126 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 118 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 653d27a2e62b..4f65b3ebf806 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -165,8 +165,18 @@ #define AT803X_MMD3_SMARTEEE_CTL1 0x805b #define AT803X_MMD3_SMARTEEE_CTL2 0x805c +#define AT803X_MMD3_SMARTEEE_LPI_TIME_LOW GENMASK(15, 0) +#define AT803X_MMD3_SMARTEEE_LPI_TIME_15_0 GENMASK(15, 0) #define AT803X_MMD3_SMARTEEE_CTL3 0x805d #define AT803X_MMD3_SMARTEEE_CTL3_LPI_EN BIT(8) +#define AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH GENMASK(7, 0) +#define AT803X_MMD3_SMARTEEE_LPI_TIME_23_16 GENMASK(23, 16) +/* Tx LPI timer resolution */ +#define AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS 163840 +#define AT803X_MMD3_SMARTEEE_LPI_TIME_MAX_US \ + ((GENMASK(23, 0) * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS) / \ + NSEC_PER_USEC) +#define AT803X_MMD3_SMARTEEE_LPI_TIME_DEF_US 335544 #define ATH9331_PHY_ID 0x004dd041 #define ATH8030_PHY_ID 0x004dd076 @@ -302,6 +312,8 @@ struct at803x_priv { u8 smarteee_lpi_tw_100m; bool is_fiber; bool is_1000basex; + bool tx_lpi_on; + u32 tx_lpi_timer; struct regulator_dev *vddio_rdev; struct regulator_dev *vddh_rdev; struct regulator *vddio; @@ -858,8 +870,12 @@ static int at803x_probe(struct phy_device *phydev) if (phydev->drv->phy_id == ATH8035_PHY_ID || phydev->drv->phy_id == ATH8031_PHY_ID) { - if (!(priv->flags & AT803X_DISABLE_SMARTEEE)) + if (!(priv->flags & AT803X_DISABLE_SMARTEEE)) { phydev->is_smart_eee_phy = true; + priv->tx_lpi_on = true; + priv->tx_lpi_timer = + AT803X_MMD3_SMARTEEE_LPI_TIME_DEF_US; + } } if (priv->vddio) { @@ -959,10 +975,12 @@ static int at803x_get_features(struct phy_device *phydev) static int at803x_smarteee_config(struct phy_device *phydev) { struct at803x_priv *priv = phydev->priv; + u64 tx_lpi_timer_raw; + u64 tx_lpi_timer_ns; u16 mask = 0, val = 0; int ret; - if (priv->flags & AT803X_DISABLE_SMARTEEE) + if (!priv->tx_lpi_on) return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, AT803X_MMD3_SMARTEEE_CTL3_LPI_EN, 0); @@ -983,9 +1001,27 @@ static int at803x_smarteee_config(struct phy_device *phydev) if (ret) return ret; + tx_lpi_timer_ns = priv->tx_lpi_timer * NSEC_PER_USEC; + tx_lpi_timer_raw = + DIV_ROUND_CLOSEST_ULL(tx_lpi_timer_ns, + AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS); + val = FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_LOW, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_15_0, + tx_lpi_timer_raw)); + + ret = phy_write_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL2, + val); + if (ret) + return ret; + + val = AT803X_MMD3_SMARTEEE_CTL3_LPI_EN | + FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16, + tx_lpi_timer_raw)); + return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, - AT803X_MMD3_SMARTEEE_CTL3_LPI_EN, - AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + AT803X_MMD3_SMARTEEE_CTL3_LPI_EN | + AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, val); } static int at803x_clk_out_config(struct phy_device *phydev) @@ -1072,10 +1108,6 @@ static int at803x_config_init(struct phy_device *phydev) if (ret < 0) return ret; - ret = at803x_smarteee_config(phydev); - if (ret < 0) - return ret; - ret = at803x_clk_out_config(phydev); if (ret < 0) return ret; @@ -1359,6 +1391,16 @@ static int at803x_config_aneg(struct phy_device *phydev) return ret; } + /* only after PHY is attached we will be able to see if MAC supports + * EEE + */ + if (phydev->mac_supports_eee) + priv->tx_lpi_on = false; + + ret = at803x_smarteee_config(phydev); + if (ret < 0) + return ret; + return __genphy_config_aneg(phydev, ret); } @@ -1617,6 +1659,72 @@ static int at803x_cable_test_start(struct phy_device *phydev) return 0; } +static int at803x_get_eee(struct phy_device *phydev, struct ethtool_eee *data) +{ + struct at803x_priv *priv = phydev->priv; + u32 tx_timer_raw; + u64 tx_timer_ns; + int ret; + + /* If SmartEEE is not enabled, it is expected that tx_lpi_* fields + * are processed by the MAC driver. + */ + if (priv->flags & AT803X_DISABLE_SMARTEEE) + return genphy_c45_ethtool_get_eee(phydev, data); + + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, + AT803X_MMD3_SMARTEEE_CTL2); + tx_timer_raw = FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_15_0, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_LOW, + ret)); + if (ret < 0) + return ret; + + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, + AT803X_MMD3_SMARTEEE_CTL3); + if (ret < 0) + return ret; + + tx_timer_raw |= FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, + ret)); + tx_timer_ns = tx_timer_raw * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS; + data->tx_lpi_timer = DIV_ROUND_CLOSEST_ULL(tx_timer_ns, NSEC_PER_USEC); + + data->tx_lpi_enabled = !!(ret & AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + + return genphy_c45_ethtool_get_eee(phydev, data); +} + +static int at803x_set_eee(struct phy_device *phydev, struct ethtool_eee *data) +{ + struct at803x_priv *priv = phydev->priv; + int ret; + + /* If SmartEEE is not enabled, it is expected that tx_lpi_* fields + * are processed by the MAC driver. + */ + if (phydev->mac_supports_eee || !phydev->is_smart_eee_phy) + return genphy_c45_ethtool_set_eee(phydev, data); + + if (data->tx_lpi_timer > AT803X_MMD3_SMARTEEE_LPI_TIME_MAX_US) { + phydev_err(phydev, "Max LPI timer is %lu microsecs\n", + AT803X_MMD3_SMARTEEE_LPI_TIME_MAX_US); + return -EINVAL; + } + + /* Changing Tx LPI on/off or Tx LPI timer settings + * do not require link reset. + */ + priv->tx_lpi_timer = data->tx_lpi_timer; + priv->tx_lpi_on = data->tx_lpi_enabled; + ret = at803x_smarteee_config(phydev); + if (ret) + return ret; + + return genphy_c45_ethtool_set_eee(phydev, data); +} + static int qca83xx_config_init(struct phy_device *phydev) { u8 switch_revision; @@ -2043,6 +2151,8 @@ static struct phy_driver at803x_driver[] = { .set_tunable = at803x_set_tunable, .cable_test_start = at803x_cable_test_start, .cable_test_get_status = at803x_cable_test_get_status, + .get_eee = at803x_get_eee, + .set_eee = at803x_set_eee, }, { /* Qualcomm Atheros AR8030 */ .phy_id = ATH8030_PHY_ID, From patchwork Mon Mar 27 14:22:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 75502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1566353vqo; Mon, 27 Mar 2023 07:48:10 -0700 (PDT) X-Google-Smtp-Source: AKy350YMI35J9j4MPRcjcZj7Fs9rNLRq/xAECt8rtDS+VWjEYr4FicswRvS21H+KPZRfN7hRD5bl X-Received: by 2002:a17:90a:b88e:b0:23e:cea5:d37e with SMTP id o14-20020a17090ab88e00b0023ecea5d37emr11952871pjr.46.1679928490000; Mon, 27 Mar 2023 07:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679928489; cv=none; d=google.com; s=arc-20160816; b=fDagFmRU9pvtraNyMgaPj4vzB6SuEVpx3bNWxEOa0r6R8DMFueDEYPFWNk0jmjOeCS d7aahwhnZY8tUE9n4ecMPRk4op1FhivMkvFSVfgazi2SloDORJqQnKtFrSx440trz7LB U31GxSYX/cE/SI3vz1ZVzypxftf+5WuHfDs6jksB//ZhLHhUcHy7gWE/ock+Vdt0vQ6t HwDyyT4yqEpCh4ohvLklOei1TgVI7zeguaugaxIcdKp6MAs1TFZQs5fk7HRtOWZCFLm7 itpiKZLot3S7cgq/tKlF2XK9zsiLiZWdYbOJaVaMtEkNM+Rbgd5vC9NlYDy9joC6k9Rq sKiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cT7jn9K64zIvhfLwiW+KDr4+cZArazZceUhKKJt2UcM=; b=cXtV3B1gxalVLQHHDwxR1/7203oy42bQ1+SeJvnXa9pbpZKZ6gQtxbT4DA9D21VGvq d8GYGhsYbTnqMNDjriKik+vrrPgAK77dLr5vtVt0cS6UuYNfUHP2Cw5WCkB77551qhz2 fuDVk2sWF6+rED9i3/sxd/owYTu3o1TTgPST7OEz+pXTld7U1g3NGoR7IvAc4CHixsjw IDcWSrfKVJHr84DNlK4fFLlqr4W8xA3zObLQgQOirzOHqmYCja9jiTsyYKAS26gIwgqm v0NRe555BGcuGpJGhXebJSojVE8Frzse8IWngf0Qq7jhiwf4YZsLAfelV/Uh9YUYkKYL 1s0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fr17-20020a17090ae2d100b0023fcb58b0e0si10595937pjb.162.2023.03.27.07.47.57; Mon, 27 Mar 2023 07:48:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233094AbjC0OYX (ORCPT + 99 others); Mon, 27 Mar 2023 10:24:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232891AbjC0OXt (ORCPT ); Mon, 27 Mar 2023 10:23:49 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E01A7D94 for ; Mon, 27 Mar 2023 07:22:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Ho-L2; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjY-0076IX-RR; Mon, 27 Mar 2023 16:22:04 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00Fkjc-UV; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 7/8] net: phy: at803x: Fix SmartEEE support for some link configurations Date: Mon, 27 Mar 2023 16:22:01 +0200 Message-Id: <20230327142202.3754446-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> 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.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761532696222167370?= X-GMAIL-MSGID: =?utf-8?q?1761532696222167370?= This commit fixes SmartEEE support for certain link configurations on the AR8035 PHY. Before this patch, if AR8035 was running with SmartEEE enabled (EEE and LPI are on), it would not be able to establish a 100BaseTX/Half or 1000BaseT/Half link. A similar issue would occur with 100BaseTX/Full and an LPI TX timer configured to less than 80 msec. To avoid this issue, we need to keep LPI disabled before the link is established and enable it only when a supported link configuration is detected. By implementing this fix, the at803x driver can now correctly handle SmartEEE features for various link configurations, improving link establishment, compatibility, and overall performance. Signed-off-by: Oleksij Rempel --- drivers/net/phy/at803x.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 4f65b3ebf806..5a12f778d675 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -1014,10 +1014,15 @@ static int at803x_smarteee_config(struct phy_device *phydev) if (ret) return ret; - val = AT803X_MMD3_SMARTEEE_CTL3_LPI_EN | - FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, - FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16, - tx_lpi_timer_raw)); + val = FIELD_PREP(AT803X_MMD3_SMARTEEE_LPI_TIME_HIGH, + FIELD_GET(AT803X_MMD3_SMARTEEE_LPI_TIME_23_16, + tx_lpi_timer_raw)); + + if (phydev->state == PHY_RUNNING && + phy_check_valid(phydev->speed, phydev->duplex, + phydev->supported_eee)) { + val |= AT803X_MMD3_SMARTEEE_CTL3_LPI_EN; + } return phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_MMD3_SMARTEEE_CTL3, AT803X_MMD3_SMARTEEE_CTL3_LPI_EN | @@ -1691,7 +1696,7 @@ static int at803x_get_eee(struct phy_device *phydev, struct ethtool_eee *data) tx_timer_ns = tx_timer_raw * AT803X_MMD3_SMARTEEE_LPI_TIME_RESOL_NS; data->tx_lpi_timer = DIV_ROUND_CLOSEST_ULL(tx_timer_ns, NSEC_PER_USEC); - data->tx_lpi_enabled = !!(ret & AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + data->tx_lpi_enabled = priv->tx_lpi_on; return genphy_c45_ethtool_get_eee(phydev, data); } @@ -1725,6 +1730,28 @@ static int at803x_set_eee(struct phy_device *phydev, struct ethtool_eee *data) return genphy_c45_ethtool_set_eee(phydev, data); } +static void at8035_link_change_notify(struct phy_device *phydev) +{ + struct at803x_priv *priv = phydev->priv; + + if (phydev->mac_supports_eee || !phydev->is_smart_eee_phy) + return; + + if (phydev->state == PHY_RUNNING) { + if (priv->tx_lpi_on && phy_check_valid(phydev->speed, + phydev->duplex, + phydev->supported_eee)) + phy_set_bits_mmd(phydev, MDIO_MMD_PCS, + AT803X_MMD3_SMARTEEE_CTL3, + AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + } else { + if (priv->tx_lpi_on) + phy_clear_bits_mmd(phydev, MDIO_MMD_PCS, + AT803X_MMD3_SMARTEEE_CTL3, + AT803X_MMD3_SMARTEEE_CTL3_LPI_EN); + } +} + static int qca83xx_config_init(struct phy_device *phydev) { u8 switch_revision; @@ -2153,6 +2180,7 @@ static struct phy_driver at803x_driver[] = { .cable_test_get_status = at803x_cable_test_get_status, .get_eee = at803x_get_eee, .set_eee = at803x_set_eee, + .link_change_notify = at8035_link_change_notify, }, { /* Qualcomm Atheros AR8030 */ .phy_id = ATH8030_PHY_ID, From patchwork Mon Mar 27 14:22:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksij Rempel X-Patchwork-Id: 75489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1553226vqo; Mon, 27 Mar 2023 07:27:30 -0700 (PDT) X-Google-Smtp-Source: AKy350aXwLsN8V4Yktp9gJkLal8kvBScroDtB5ubCdN7UhX1dLT9PQO3zicMnIcezjYb+IjYXK4D X-Received: by 2002:a17:906:2d52:b0:930:e055:8698 with SMTP id e18-20020a1709062d5200b00930e0558698mr12844919eji.70.1679927250696; Mon, 27 Mar 2023 07:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679927250; cv=none; d=google.com; s=arc-20160816; b=MgpQ/JH/I6tpojdh7eyL48YDK9IPc9yn5Rdn3qgyFt1uGub0TfO3HIp14Mrnby0Wt7 0XiMmkJeoFWHg/MhAF9vxcUKWE3izcow5dpvCM4G4M5aITZzZwAClMA0+LDe6h+9DxF5 OGOah7ct07PX2F2PnyRCTDWHoEaf+8j1ME7iKte0ql8/Asguf0lAnu8FMe23KjZ9X2+D GCWjm715Y/sAwc2snKRJcwr4UiqjuXo69ghCemENUS7LJFKrUOmDlN3jbBTvqNCILnan nMfCRKmqbVWhEFA84Vu+kCyc61jHsUK2KZHmyUILVhSKjEVsbnLDItGbkhDeTx25hQPw g9WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=5Zf1STTwJ9iKQw9+iSaw0Pc1W6pOATpV1KWeJ7B3Zh4=; b=rg44ar8m6JAAMlYKKZ6fmUhBPkT4/FrJLp921w+f7xbu+85zngsKXDDLYntQLOPil/ LSGt7B6fXJQEgla5JsmYErK1BemKDrfd+/HnLKJdx9A/mGKFaB79NJz4841iBinAlKL0 AFtKDoS/Ei+VF8jfGULLg3lQohMn5F4jdXxEjCoDQI2xhVvOkOgZo9kh7BB7RxBYU91H LTi4zl1svXSt/aGqJxHaih99mg07MXTnuzivP74S/pPP7W9x2P+HAK2z6TaZChFVZ65W t17jRnrDlN9Uv1dxD032lAIFhkCHzSJjP8YBzrTaTuon4eY7K08svPkZuDeTb2oP2nSD q/lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 10-20020a170906208a00b009395b8121cesi17022061ejq.178.2023.03.27.07.27.05; Mon, 27 Mar 2023 07:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232948AbjC0OYH (ORCPT + 99 others); Mon, 27 Mar 2023 10:24:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbjC0OXr (ORCPT ); Mon, 27 Mar 2023 10:23:47 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 875D47D84 for ; Mon, 27 Mar 2023 07:22:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pgnja-0008Hq-Kw; Mon, 27 Mar 2023 16:22:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pgnjZ-0076If-Bh; Mon, 27 Mar 2023 16:22:05 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pgnjW-00Fkjl-VA; Mon, 27 Mar 2023 16:22:02 +0200 From: Oleksij Rempel To: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Shenwei Wang , Clark Wang , NXP Linux Team , Amit Cohen , Gal Pressman , Alexandru Tachici , Piergiorgio Beruto , Willem de Bruijn , Vladimir Oltean Subject: [PATCH net-next v2 8/8] net: fec: Indicate EEE (LPI) support for some FEC Ethernet controllers Date: Mon, 27 Mar 2023 16:22:02 +0200 Message-Id: <20230327142202.3754446-9-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230327142202.3754446-1-o.rempel@pengutronix.de> References: <20230327142202.3754446-1-o.rempel@pengutronix.de> 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.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761531396631489809?= X-GMAIL-MSGID: =?utf-8?q?1761531396631489809?= This commit adds EEE (LPI) support indication for specific FEC Ethernet controllers. By indicating EEE support for these controllers, it allows PHY drivers to choose the right configuration for EEE and LPI features, depending on whether the MAC or the PHY is responsible for handling them. This change provides more flexibility and control over energy-saving features, enabling PHY drivers to disable SmartEEE functionality in favor of MAC EEE support when appropriate, depending on their specific use cases and requirements. Signed-off-by: Oleksij Rempel Reviewed-by: Wei Fang --- drivers/net/ethernet/freescale/fec_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index f3b16a6673e2..554a5dc92817 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2318,6 +2318,8 @@ static int fec_enet_mii_probe(struct net_device *ndev) fep->link = 0; fep->full_duplex = 0; + if (fep->quirks & FEC_QUIRK_HAS_EEE) + phy_dev->mac_supports_eee = true; phy_dev->mac_managed_pm = true; phy_attached_info(phy_dev);