From patchwork Tue Sep 3 16:06:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 1156976 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=analog.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="auBBgZ6X"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46N6fd2PLzz9sPQ for ; Tue, 3 Sep 2019 23:06:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729395AbfICNGs (ORCPT ); Tue, 3 Sep 2019 09:06:48 -0400 Received: from mx0b-00128a01.pphosted.com ([148.163.139.77]:53382 "EHLO mx0b-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729385AbfICNGq (ORCPT ); Tue, 3 Sep 2019 09:06:46 -0400 Received: from pps.filterd (m0167090.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x83D2xOc027325; Tue, 3 Sep 2019 09:06:42 -0400 Received: from nam05-by2-obe.outbound.protection.outlook.com (mail-by2nam05lp2055.outbound.protection.outlook.com [104.47.50.55]) by mx0b-00128a01.pphosted.com with ESMTP id 2uqnh5d9db-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 03 Sep 2019 09:06:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kWNLZJsrL+Gx29sXZHWnwJKQVsJ1rblbOW0DnWH8hebHcpVTimqkes56OMfb7f8IPVn3Sf1JZVizPhznTHOEGxVyKOAxS30lyQ1Atb4ntNuV/pn5doBKeK+GDCeoRgomwr4g60X+XSz9JhM0kdcB2x0jgq36ItiKJFVoAbBil4FdSzznBc9VA7f1Wzg/Uc4G20wjbeuLGPVbS7NdnfwV3bohhY8Mxe9wkdqlOmx6V6zOSH6nOZKCJ/Snz8Xa6Yj9SjYMxw5ZDwpV8hQ5bFIfVgWuVcXODPebnXtb7yQGestyGVKDS38h6DtoZeyMnifExby+y+MH1iI2u9CKafArww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EwyWsWTTjnhaEVbnOb0I+raOCV6dgAKf/IPOLbO6ze0=; b=EaUMg78lnkIRgl7o/z4dsvsZGyP1BPJiGBbbaxBh2BnNSVbkxlRN6IBV8kJUf7pgC0W6sKcibvM8MNJQhDion4SrKCG3HYpFAT0O8eSptTZFqFr8VoTa0Gc0TQXXRbPFCNanVQVMGMgnRAHiEiKE1OawWSq00YpOL9qYVqjRhVNJpsPHkIiRCgrlidkf34CK2vnZlCkwTarzdoTX3hTlGWRdn8nqH38qhyTwb8vKlH3l735n3A/eH2slSq6EyLo7MC/88jj3ACGTz5+R+XBEtmvNu1t2N3zId6OQ3lr+hO+hM/AlIep1hz4WxTGxVaNEB1C7duNsihAKP6do+2ymsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.55) smtp.rcpttodomain=lunn.ch smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EwyWsWTTjnhaEVbnOb0I+raOCV6dgAKf/IPOLbO6ze0=; b=auBBgZ6XvDfuqF+PEwz5mDI+zOR4b3nKIla8pufvC5BQbc93oOakrKIGOo1EAbMqiZYDRbn6q9E5GDh7vWRkyL1BVj8d77jikmVN1Oa2YNENmod7/whiY7nJf/m1SsIyfc4T/sUj2+mUtjXndX7vACJB9e4ICksurAqOfstdMAE= Received: from BN6PR03CA0013.namprd03.prod.outlook.com (2603:10b6:404:23::23) by DM5PR03MB3340.namprd03.prod.outlook.com (2603:10b6:4:43::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.19; Tue, 3 Sep 2019 13:06:38 +0000 Received: from BL2NAM02FT016.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::200) by BN6PR03CA0013.outlook.office365.com (2603:10b6:404:23::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.19 via Frontend Transport; Tue, 3 Sep 2019 13:06:38 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BL2NAM02FT016.mail.protection.outlook.com (10.152.77.171) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2220.16 via Frontend Transport; Tue, 3 Sep 2019 13:06:38 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x83D6XFE024841 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Tue, 3 Sep 2019 06:06:33 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Tue, 3 Sep 2019 09:06:37 -0400 From: Alexandru Ardelean To: , CC: , , , , Alexandru Ardelean Subject: [PATCH 1/4] ethtool: implement Energy Detect Powerdown support via phy-tunable Date: Tue, 3 Sep 2019 19:06:23 +0300 Message-ID: <20190903160626.7518-2-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190903160626.7518-1-alexandru.ardelean@analog.com> References: <20190903160626.7518-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(136003)(346002)(39860400002)(396003)(2980300002)(189003)(199004)(11346002)(186003)(486006)(5660300002)(50466002)(126002)(476003)(446003)(2616005)(48376002)(478600001)(2906002)(107886003)(36756003)(4326008)(76176011)(336012)(426003)(26005)(2870700001)(51416003)(7696005)(47776003)(1076003)(8936002)(70206006)(106002)(110136005)(316002)(14444005)(7636002)(6666004)(356004)(50226002)(305945005)(86362001)(44832011)(8676002)(70586007)(246002)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB3340; H:nwd2mta1.analog.com; FPR:; SPF:Pass; LANG:en; PTR:nwd2mail10.analog.com; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3de575bd-aba8-4b3f-e394-08d7306f8e5f X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328); SRVR:DM5PR03MB3340; X-MS-TrafficTypeDiagnostic: DM5PR03MB3340: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-Forefront-PRVS: 01494FA7F7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: MNMTj/Rt8shYCr1a21nEIGDwkYuFBYU/1Mc+HBkfXrc9R0PEFRvhFqQz4Non744C97IQkbJJoUb1eW+8XTL2AKuwq+oiK0gK6MnF7BZ9HvMAIDyLQpAOCd11C/Sn+umb72GOKJ/IUNVBSNNQWcHBNT2zumWpBNEFa05FpNOH9dELtWIjcXGxdiWPQFGmspddFx3iEIwMyCme9FIYvrir+r8i9dCRvr2uJy88e8/WAMziMQVIsFCBzFPsnMPMqCtSZGkFssx5/69Z7DBl0L7I98s1VJNVJWs8pq8xPajhr9szIVq5FiemBQuoy9v1mlein/XleHp/kEdU2NYC4w4y7uxh/6StHpKmaLF6nHQArkDLdZlf0G3d75rnCUrGTQ+is0a1I1srTUVzHgrOVzk8fM9ek9PjJSjC2aVdSajS8eo= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2019 13:06:38.3245 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3de575bd-aba8-4b3f-e394-08d7306f8e5f X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a; Ip=[137.71.25.55]; Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB3340 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-03_02:2019-09-03,2019-09-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 mlxscore=0 adultscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1909030137 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The `phy_tunable_id` has been named `ETHTOOL_PHY_EDPD` since it looks like this feature is common across other PHYs (like EEE), and defining `ETHTOOL_PHY_ENERGY_DETECT_POWER_DOWN` seems too long. The way EDPD works, is that the RX block is put to a lower power mode, except for link-pulse detection circuits. The TX block is also put to low power mode, but the PHY wakes-up periodically to send link pulses, to avoid lock-ups in case the other side is also in EDPD mode. Currently, there are 2 PHY drivers that look like they could use this new PHY tunable feature: the `adin` && `micrel` PHYs. The ADIN's datasheet mentions that TX pulses are at intervals of 1 second default each, and they can be disabled. For the Micrel KSZ9031 PHY, the datasheet does not mention whether they can be disabled, but mentions that they can modified. The way this change is structured, is similar to the PHY tunable downshift control: * a `ETHTOOL_PHY_EDPD_DFLT_TX_INTERVAL` value is exposed to cover a default TX interval; some PHYs could specify a certain value that makes sense * `ETHTOOL_PHY_EDPD_NO_TX` would disable TX when EDPD is enabled * `ETHTOOL_PHY_EDPD_DISABLE` will disable EDPD This should allow PHYs to: * enable EDPD and not enable TX pulses (interval would be 0) * enable EDPD and configure TX pulse interval; note that TX interval units would be PHY specific; we could consider `seconds` as units, but it could happen that some PHYs would be prefer 500 milliseconds as a unit; a maximum of 32766 units should be sufficient * disable EDPD Signed-off-by: Alexandru Ardelean --- include/uapi/linux/ethtool.h | 5 +++++ net/core/ethtool.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index dd06302aa93e..0349e9c4350f 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -259,10 +259,15 @@ struct ethtool_tunable { #define ETHTOOL_PHY_FAST_LINK_DOWN_ON 0 #define ETHTOOL_PHY_FAST_LINK_DOWN_OFF 0xff +#define ETHTOOL_PHY_EDPD_DFLT_TX_INTERVAL 0x7fff +#define ETHTOOL_PHY_EDPD_NO_TX 0x8000 +#define ETHTOOL_PHY_EDPD_DISABLE 0 + enum phy_tunable_id { ETHTOOL_PHY_ID_UNSPEC, ETHTOOL_PHY_DOWNSHIFT, ETHTOOL_PHY_FAST_LINK_DOWN, + ETHTOOL_PHY_EDPD, /* * Add your fresh new phy tunable attribute above and remember to update * phy_tunable_strings[] in net/core/ethtool.c diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 6288e69e94fc..c763106c73fc 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -133,6 +133,7 @@ phy_tunable_strings[__ETHTOOL_PHY_TUNABLE_COUNT][ETH_GSTRING_LEN] = { [ETHTOOL_ID_UNSPEC] = "Unspec", [ETHTOOL_PHY_DOWNSHIFT] = "phy-downshift", [ETHTOOL_PHY_FAST_LINK_DOWN] = "phy-fast-link-down", + [ETHTOOL_PHY_EDPD] = "phy-energy-detect-power-down", }; static int ethtool_get_features(struct net_device *dev, void __user *useraddr) @@ -2451,6 +2452,11 @@ static int ethtool_phy_tunable_valid(const struct ethtool_tunable *tuna) tuna->type_id != ETHTOOL_TUNABLE_U8) return -EINVAL; break; + case ETHTOOL_PHY_EDPD: + if (tuna->len != sizeof(u16) || + tuna->type_id != ETHTOOL_TUNABLE_U16) + return -EINVAL; + break; default: return -EINVAL; } From patchwork Tue Sep 3 16:06:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 1156980 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=analog.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="43bpidk9"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46N6g102dhz9sPT for ; Tue, 3 Sep 2019 23:07:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729464AbfICNHD (ORCPT ); Tue, 3 Sep 2019 09:07:03 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:3756 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729408AbfICNGt (ORCPT ); Tue, 3 Sep 2019 09:06:49 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x83D37Bk010249; Tue, 3 Sep 2019 09:06:44 -0400 Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2053.outbound.protection.outlook.com [104.47.38.53]) by mx0a-00128a01.pphosted.com with ESMTP id 2uqjrad1ke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 03 Sep 2019 09:06:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k9tvkM5bS0bVAsUM+PvqbE/HKABT8sP0+W/njMSGph2YsmLyx2LeC/2JSrUZJLBpAF4afznV0/7AX42KXU2qgEM30NauvNwL4kHiN73jpxCcClgY2cBd45ETW+ZjsxowExVhasqNJhPqIocsL5MORMm6XX35C9DhrJDE8UM0z9hEMvk0zzeHc8uY/ux3LozSjvXoxkHrRnKCxfptzP+cyfo4ot4p7N3DYqtxx9t8qu+ytvb0ybXTczBA4MBiZHFw/i2hc1lDeA1yzDW37dDCAP1C4tFu6W6rw2tH5c6NdcWI0mkfL3jW0PDjbTPeFkdBV28/7it33k/n87lYh8khBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RvpRXjaK49Pl+OJZXrl2LvhnlYwDN+zG08M/5anhrLo=; b=S6yYa9+meS5irk9FyLpOkTxbTeHvrIcLze1rvIQSl7rbC5Cb/gwfwBHpun5jz3saS0HCVPPnMzUSS4eBROaylkWAgI9vIskbiF9V5JLX2/o8Y67Mzj5ElhY64z30HZURUkcJQy4OI44okQTNgzEzViNtCOIY7gBEvIJG66MQwuXe10/ChonsxFWc6rFKIaczW06u7I3jZSX0hyPbF0VYZojjcvItLZhJJorCELePk63jZ7XQSCMR8eqO1iEzgn8QJxBB9ht4qj1wdWPN8nB7B8jYXitETwhrxqpqCzMGe172k6leNhQZMj6CpxHwMg1ScFkNQ/rTZZdVzm9jLNvVCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.55) smtp.rcpttodomain=lunn.ch smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RvpRXjaK49Pl+OJZXrl2LvhnlYwDN+zG08M/5anhrLo=; b=43bpidk9Ej9g0R9wYFOJ0WNXSSkJIERMs7YiDnVNjcS9HdVozdLghDjR3j0ts1fIjUxKDpfTL/o+vwRZhwA2mGS9ESHRUzzVtrsPutIqXu8hGDKjoKF2WIJ0+sdUAP3AEa34OfirUSjP5GjnAvYoec0y7gca4WZu05cJqy4HK0c= Received: from BYAPR03CA0029.namprd03.prod.outlook.com (2603:10b6:a02:a8::42) by MWHPR03MB2479.namprd03.prod.outlook.com (2603:10b6:300:e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.18; Tue, 3 Sep 2019 13:06:40 +0000 Received: from BL2NAM02FT031.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::205) by BYAPR03CA0029.outlook.office365.com (2603:10b6:a02:a8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.21 via Frontend Transport; Tue, 3 Sep 2019 13:06:40 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BL2NAM02FT031.mail.protection.outlook.com (10.152.77.173) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2220.16 via Frontend Transport; Tue, 3 Sep 2019 13:06:40 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x83D6ZBi024853 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Tue, 3 Sep 2019 06:06:35 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Tue, 3 Sep 2019 09:06:39 -0400 From: Alexandru Ardelean To: , CC: , , , , Alexandru Ardelean Subject: [PATCH 2/4] net: phy: adin: implement Energy Detect Powerdown mode via phy-tunable Date: Tue, 3 Sep 2019 19:06:24 +0300 Message-ID: <20190903160626.7518-3-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190903160626.7518-1-alexandru.ardelean@analog.com> References: <20190903160626.7518-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(376002)(136003)(396003)(346002)(2980300002)(189003)(199004)(7696005)(50466002)(76176011)(50226002)(48376002)(478600001)(4326008)(316002)(47776003)(305945005)(11346002)(426003)(51416003)(106002)(110136005)(54906003)(107886003)(446003)(8936002)(70586007)(356004)(6666004)(70206006)(36756003)(486006)(5660300002)(2906002)(126002)(2870700001)(8676002)(186003)(14444005)(2616005)(476003)(7636002)(26005)(246002)(44832011)(86362001)(1076003)(336012); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2479; H:nwd2mta1.analog.com; FPR:; SPF:Pass; LANG:en; PTR:nwd2mail10.analog.com; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6320045e-30f9-423b-05a7-08d7306f8f6f X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328); SRVR:MWHPR03MB2479; X-MS-TrafficTypeDiagnostic: MWHPR03MB2479: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 01494FA7F7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: yk1oo3LXnmhN+VJ7PmiAPu/CVSV025LKFf9h5No4TCJT6RFlLnVlU3W8pa7JYtPZpDHCaq+rl7JgcfA83K0Z0Wxg/DE2Q2k4Xl5nMXGkJmk9mVvZwwoYXgiXjPYV6IKxiYHPJ6fKtdLqRylhfArbDdIES/fk74HXgemB1KCP//nL0rSilTlAbqrXAk+/nYoaLSaQTaGqsJY/2bsqpOIOknoYNCynwl5+gdByInhSzuB1Xzc4EYpeNDPryAo7af7FCTyIs1orl5Eh3A4fcN8n5ReQKZSfMXeqkESM1R99eeY9f3FM0+Gxxvjh915Ivgo+bCyP4+kLtaiF3xETpHMDerKjKbZDLyHEXt0VUDKUafAtOYOPcKWpMpiSrkJrbkX/efjA5MtV/rmHhS00Rrsj936sX5CdNRGPx8gIsgaPycU= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2019 13:06:40.1154 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6320045e-30f9-423b-05a7-08d7306f8f6f X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a; Ip=[137.71.25.55]; Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2479 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-03_02:2019-09-03,2019-09-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 spamscore=0 malwarescore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 adultscore=0 mlxscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1909030137 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This driver becomes the first user of the kernel's `ETHTOOL_PHY_EDPD` phy-tunable feature. EDPD is also enabled by default on PHY config_init, but can be disabled via the phy-tunable control. When enabling EDPD, it's also a good idea (for the ADIN PHYs) to enable TX periodic pulses, so that in case the other PHY is also on EDPD mode, there is no lock-up situation where both sides are waiting for the other to transmit. Via the phy-tunable control, TX pulses can be disabled if specifying 0 `tx-interval` via ethtool. Signed-off-by: Alexandru Ardelean --- drivers/net/phy/adin.c | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c index 4dec83df048d..742728ab2a5d 100644 --- a/drivers/net/phy/adin.c +++ b/drivers/net/phy/adin.c @@ -26,6 +26,11 @@ #define ADIN1300_RX_ERR_CNT 0x0014 +#define ADIN1300_PHY_CTRL_STATUS2 0x0015 +#define ADIN1300_NRG_PD_EN BIT(3) +#define ADIN1300_NRG_PD_TX_EN BIT(2) +#define ADIN1300_NRG_PD_STATUS BIT(1) + #define ADIN1300_PHY_CTRL2 0x0016 #define ADIN1300_DOWNSPEED_AN_100_EN BIT(11) #define ADIN1300_DOWNSPEED_AN_10_EN BIT(10) @@ -328,12 +333,51 @@ static int adin_set_downshift(struct phy_device *phydev, u8 cnt) ADIN1300_DOWNSPEEDS_EN); } +static int adin_get_edpd(struct phy_device *phydev, u16 *tx_interval) +{ + int val; + + val = phy_read(phydev, ADIN1300_PHY_CTRL_STATUS2); + if (val < 0) + return val; + + if (ADIN1300_NRG_PD_EN & val) { + if (val & ADIN1300_NRG_PD_TX_EN) + *tx_interval = 1; + else + *tx_interval = ETHTOOL_PHY_EDPD_NO_TX; + } else { + *tx_interval = ETHTOOL_PHY_EDPD_DISABLE; + } + + return 0; +} + +static int adin_set_edpd(struct phy_device *phydev, u16 tx_interval) +{ + u16 val; + + if (tx_interval == ETHTOOL_PHY_EDPD_DISABLE) + return phy_clear_bits(phydev, ADIN1300_PHY_CTRL_STATUS2, + (ADIN1300_NRG_PD_EN | ADIN1300_NRG_PD_TX_EN)); + + val = ADIN1300_NRG_PD_EN; + if (tx_interval != ETHTOOL_PHY_EDPD_NO_TX) + val |= ADIN1300_NRG_PD_TX_EN; + + return phy_modify(phydev, ADIN1300_PHY_CTRL_STATUS2, + (ADIN1300_NRG_PD_EN | ADIN1300_NRG_PD_TX_EN), + val); +} + static int adin_get_tunable(struct phy_device *phydev, struct ethtool_tunable *tuna, void *data) { switch (tuna->id) { case ETHTOOL_PHY_DOWNSHIFT: return adin_get_downshift(phydev, data); + case ETHTOOL_PHY_EDPD: + return adin_get_edpd(phydev, data); default: return -EOPNOTSUPP; } @@ -345,6 +389,8 @@ static int adin_set_tunable(struct phy_device *phydev, switch (tuna->id) { case ETHTOOL_PHY_DOWNSHIFT: return adin_set_downshift(phydev, *(const u8 *)data); + case ETHTOOL_PHY_EDPD: + return adin_set_edpd(phydev, *(const u16 *)data); default: return -EOPNOTSUPP; } @@ -368,6 +414,10 @@ static int adin_config_init(struct phy_device *phydev) if (rc < 0) return rc; + rc = adin_set_edpd(phydev, 1); + if (rc < 0) + return rc; + phydev_dbg(phydev, "PHY is using mode '%s'\n", phy_modes(phydev->interface)); From patchwork Tue Sep 3 16:06:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 1156978 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=analog.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="4vfgjxQR"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46N6fl2J8sz9s4Y for ; Tue, 3 Sep 2019 23:06:55 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729444AbfICNGx (ORCPT ); Tue, 3 Sep 2019 09:06:53 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:5264 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729415AbfICNGv (ORCPT ); Tue, 3 Sep 2019 09:06:51 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x83D33SO010211; Tue, 3 Sep 2019 09:06:47 -0400 Received: from nam01-bn3-obe.outbound.protection.outlook.com (mail-bn3nam01lp2056.outbound.protection.outlook.com [104.47.33.56]) by mx0a-00128a01.pphosted.com with ESMTP id 2uqjrad1kn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 03 Sep 2019 09:06:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UlUFOi7C/oRMqkgEN49YrQCVNR0JfIwSYxumJEDU6DSOAE2UOmmLC8hVc68G0LqthmT6Un3kzhJcfMkeDumUTSjjkmvXrj0DWz/FYSNITdQ3XTvLb2CjE1FcK8RioZcCR84CLaPeAcK1FaU40kGEk81xSevYsiPzPkg2soF5uRU4/Y9PVRLDmLxCqXxFYWGtxPe44hQCfM6HUjkWxPbtTYu/gMhC15vs/pvfdbAKCwSgNIGwUTyZIi2vGHRZi+mGM2IGcsooxeen0N+5UCGDIdv8rzTBeul9JzIgp7xE+4fPXUlB7CsNNqPQA+xdhMVf02CAiu0Q1obtudijsVqj2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ya/l7clJw6vh6zlCmc3x8CghWEV1gLPHER6lGbw8BbA=; b=A6aOAF7/ihqZzVeXdpeONbdcokRezxVn7GgHyDe/iEPnagG3H0X6sWMjcYGL5eWT5fg0R5ikbYpDR0ADytuipu5Cbtcy++TESOAZFpivAtGohulshpym/VDwcRn1JV1wXP8KhgfLPf+W2r28RB41wYunwE9qK+45u1xsUyH8S4sspU3nklKgCHIbZRU0mp/0HLg3mXnXGjeDQmjFbzppUrrdK/XcDUtpJYQ5mwbnzYPjvh1rin7jAD9/vIn700bH7QE1+m2Rnor2ao65wZ6L1l71FtdMPx28TvrTvyFfPOZfmEjhQAS2HhzfIX+iBw1Pq3f+QqP8knpAF6pl7Rjt+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.55) smtp.rcpttodomain=lunn.ch smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ya/l7clJw6vh6zlCmc3x8CghWEV1gLPHER6lGbw8BbA=; b=4vfgjxQRQ76TXFGNhUdMFxk7YvMqXuYp7PVxgLrubjGJe4SBeXMUtk3fnoW1Kuu3nR04HCcGwp1bVH4VXERUnb9F5UyolOLUrsxOfntPbBYzmljJ5MKW2B8iphLhQhZ2dTMdiXTY0P1xAbgZrWiakLWqMVho4UrUgeyijwxUO1g= Received: from BN6PR03CA0071.namprd03.prod.outlook.com (2603:10b6:404:4c::33) by DM6PR03MB3675.namprd03.prod.outlook.com (2603:10b6:5:b2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Tue, 3 Sep 2019 13:06:44 +0000 Received: from BL2NAM02FT064.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::208) by BN6PR03CA0071.outlook.office365.com (2603:10b6:404:4c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2220.19 via Frontend Transport; Tue, 3 Sep 2019 13:06:43 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BL2NAM02FT064.mail.protection.outlook.com (10.152.77.119) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2220.16 via Frontend Transport; Tue, 3 Sep 2019 13:06:43 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x83D6boT024865 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Tue, 3 Sep 2019 06:06:37 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Tue, 3 Sep 2019 09:06:41 -0400 From: Alexandru Ardelean To: , CC: , , , , Alexandru Ardelean Subject: [PATCH 3/4] [ethtool] ethtool: sync ethtool-copy.h: adds support for EDPD (3rd Sep 2019) Date: Tue, 3 Sep 2019 19:06:25 +0300 Message-ID: <20190903160626.7518-4-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190903160626.7518-1-alexandru.ardelean@analog.com> References: <20190903160626.7518-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(346002)(136003)(376002)(396003)(2980300002)(199004)(189003)(5660300002)(186003)(246002)(54906003)(110136005)(106002)(2906002)(7636002)(107886003)(7696005)(51416003)(478600001)(305945005)(8676002)(8936002)(356004)(6666004)(50226002)(26005)(2870700001)(70586007)(426003)(70206006)(126002)(44832011)(476003)(11346002)(486006)(336012)(446003)(36756003)(2616005)(316002)(19627235002)(50466002)(14444005)(48376002)(47776003)(86362001)(1076003)(76176011)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR03MB3675; H:nwd2mta1.analog.com; FPR:; SPF:Pass; LANG:en; PTR:nwd2mail10.analog.com; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b5484ab4-bd6e-4504-2ec7-08d7306f918d X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328); SRVR:DM6PR03MB3675; X-MS-TrafficTypeDiagnostic: DM6PR03MB3675: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:854; X-Forefront-PRVS: 01494FA7F7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: CL9cYAsPhWHVJRkTjkJjZxITKizh0JgQY3etoshXoYSB1n9wGuu0m7JHCW2ovxH11H/dK0Hu0ICB+iqWyMTynqpdecotL2Lu/IcvnKR7zUsLxJJHXf7V44gPsVxjmMQkIryDYf+XCID2VHxUQwSICP5l7hIk0BcCWCEeMX05qsz9lfwdzWF4vcHqc199yrqQKNN4Yf91sKUErDj8q0shpAFJRW49e5q8no7DkDBHbGK02NWTFPoMVloA0RzNdl0nf+v0GsAPd1gWeAPy41Sl+Pr0FQ8otQctcJANCJ4ig1DgZy3ViSA1fdp7KwmwDD/9VVzCQai04Se2nb1AFBGiZTFg0Tb3uIDq00jdMzocUCYdJTeYoU3xukyPtW+ITy14XyeEoi4i4Ps/wUf7uSSEryCm1o10zV4N+TpbgtXgJdk= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2019 13:06:43.6625 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5484ab4-bd6e-4504-2ec7-08d7306f918d X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a; Ip=[137.71.25.55]; Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB3675 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-03_02:2019-09-03,2019-09-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=968 spamscore=0 malwarescore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 adultscore=0 mlxscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1909030137 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This change syncs the `ethtool-copy.h` file with Linux net-next to add support for Energy Detect Powerdown control via phy tunable. Some formatting also changes with this sync. Signed-off-by: Alexandru Ardelean --- ethtool-copy.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ethtool-copy.h b/ethtool-copy.h index ad16e8f..8b9a87d 100644 --- a/ethtool-copy.h +++ b/ethtool-copy.h @@ -257,10 +257,15 @@ struct ethtool_tunable { #define ETHTOOL_PHY_FAST_LINK_DOWN_ON 0 #define ETHTOOL_PHY_FAST_LINK_DOWN_OFF 0xff +#define ETHTOOL_PHY_EDPD_DFLT_TX_INTERVAL 0x7fff +#define ETHTOOL_PHY_EDPD_NO_TX 0x8000 +#define ETHTOOL_PHY_EDPD_DISABLE 0 + enum phy_tunable_id { ETHTOOL_PHY_ID_UNSPEC, ETHTOOL_PHY_DOWNSHIFT, ETHTOOL_PHY_FAST_LINK_DOWN, + ETHTOOL_PHY_EDPD, /* * Add your fresh new phy tunable attribute above and remember to update * phy_tunable_strings[] in net/core/ethtool.c @@ -1481,8 +1486,8 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_200000baseLR4_ER4_FR4_Full_BIT = 64, ETHTOOL_LINK_MODE_200000baseDR4_Full_BIT = 65, ETHTOOL_LINK_MODE_200000baseCR4_Full_BIT = 66, - ETHTOOL_LINK_MODE_100baseT1_Full_BIT = 67, - ETHTOOL_LINK_MODE_1000baseT1_Full_BIT = 68, + ETHTOOL_LINK_MODE_100baseT1_Full_BIT = 67, + ETHTOOL_LINK_MODE_1000baseT1_Full_BIT = 68, /* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS @@ -1712,8 +1717,8 @@ static __inline__ int ethtool_validate_duplex(__u8 duplex) #define ETH_MODULE_SFF_8436 0x4 #define ETH_MODULE_SFF_8436_LEN 256 -#define ETH_MODULE_SFF_8636_MAX_LEN 640 -#define ETH_MODULE_SFF_8436_MAX_LEN 640 +#define ETH_MODULE_SFF_8636_MAX_LEN 640 +#define ETH_MODULE_SFF_8436_MAX_LEN 640 /* Reset flags */ /* The reset() operation must clear the flags for the components which From patchwork Tue Sep 3 16:06:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 1156979 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=analog.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=analog.onmicrosoft.com header.i=@analog.onmicrosoft.com header.b="rqYXtqkP"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46N6fs5Pj3z9sPT for ; Tue, 3 Sep 2019 23:07:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729433AbfICNGx (ORCPT ); Tue, 3 Sep 2019 09:06:53 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:6334 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729419AbfICNGv (ORCPT ); Tue, 3 Sep 2019 09:06:51 -0400 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x83D32pN016281; Tue, 3 Sep 2019 09:06:47 -0400 Received: from nam03-dm3-obe.outbound.protection.outlook.com (mail-dm3nam03lp2058.outbound.protection.outlook.com [104.47.41.58]) by mx0a-00128a01.pphosted.com with ESMTP id 2uqnt8cv6s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 03 Sep 2019 09:06:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UMVNdy/bsiL2ufOsN8YGmzVwHCGsFFNlbzpJwiNTflaI0XS3+dhVth+jhPcbEtQZv9bu7nR+whNoUcDaP984CXmjww2FMlrMtv87LP/rkrbn/UyJEzNtUgxfxRYGBn25Exp6Mb4OEvL8WUimTDUF81Sll/+33XMejBbbkgX1ULF+RPUMrUmYIoMzOWkO4cQmYzaGrQ59iczkKMx2SaSGnuOG5w6NFMjgvX55HbQbssX9xLy37KxA4jDQE3ilAcx+2h7UrAWrJDUNGXMzBlD0aUr+nBRmClAyTIzWl1H/OpGgAhm/Ma2k/OTP5cgITfBvSki/JkSt2/+jHnknomDFig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=126dswSa853dDGm6mfNb71XOC2qutR9mP2EDaU0Qs9M=; b=baqF5zUA2DfX5VREn7LA0TWfIKzuBLeFfaCPsWTKQWTZo7xO4Z58EWXr7iaoHqKYN+fZopRBcDdELddnEYTr/rYTgVckr4NIzBM2thcQOGCtebrPsUYU/fWM/x2aBN0NLnVIL2PgHwxycSAguASUG+epU3ae5Whpca5dt6h/FFpMrx+M5Vp7RF/S3WkUgJz1SAUigU8pz/IHoejFYAW8bACeOXbiio9HUfTX7j+n36In/3cDJdlOhij/aLEYr6uyP9le5BOGtEQIr24eqhWZfTlcz8m3R4p05NHRziWC4tu3SsvPxyLQqMOWGwcsUw+Y7RRGBmc/NEKp5PgW3Z5tnQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 137.71.25.55) smtp.rcpttodomain=lunn.ch smtp.mailfrom=analog.com; dmarc=bestguesspass action=none header.from=analog.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector2-analog-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=126dswSa853dDGm6mfNb71XOC2qutR9mP2EDaU0Qs9M=; b=rqYXtqkPNQDggLvcGC4J31QJP+KnCU1QE+wTzYt5eK2uqWqML3pHDBfsUmcEkJmTlIPkvMn5NEIwpwvOLGApnOiGzGXVBZnJgNHig16/UCSRcELXCcpHB5k390qq8UQj3SJcw8asTfYaztldtAbIPJU3yEakjy9b2cmjSMXLaBM= Received: from DM6PR03CA0069.namprd03.prod.outlook.com (2603:10b6:5:100::46) by SN2PR03MB2285.namprd03.prod.outlook.com (2603:10b6:804:d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2220.20; Tue, 3 Sep 2019 13:06:45 +0000 Received: from BL2NAM02FT025.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::203) by DM6PR03CA0069.outlook.office365.com (2603:10b6:5:100::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.19 via Frontend Transport; Tue, 3 Sep 2019 13:06:45 +0000 Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BL2NAM02FT025.mail.protection.outlook.com (10.152.77.151) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2220.16 via Frontend Transport; Tue, 3 Sep 2019 13:06:44 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x83D6dZw024888 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Tue, 3 Sep 2019 06:06:39 -0700 Received: from saturn.ad.analog.com (10.48.65.123) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Tue, 3 Sep 2019 09:06:43 -0400 From: Alexandru Ardelean To: , CC: , , , , Alexandru Ardelean Subject: [PATCH 4/4] [ethtool] ethtool: implement support for Energy Detect Power Down Date: Tue, 3 Sep 2019 19:06:26 +0300 Message-ID: <20190903160626.7518-5-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190903160626.7518-1-alexandru.ardelean@analog.com> References: <20190903160626.7518-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(396003)(346002)(136003)(376002)(39860400002)(2980300002)(85664002)(189003)(199004)(316002)(107886003)(336012)(70586007)(7696005)(76176011)(86362001)(26005)(70206006)(6666004)(356004)(54906003)(110136005)(2906002)(106002)(50466002)(1076003)(44832011)(36756003)(50226002)(186003)(126002)(476003)(8936002)(51416003)(426003)(7636002)(486006)(14444005)(305945005)(47776003)(2870700001)(446003)(478600001)(8676002)(5660300002)(246002)(11346002)(48376002)(4326008)(2616005)(461764006); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2285; H:nwd2mta1.analog.com; FPR:; SPF:Pass; LANG:en; PTR:nwd2mail10.analog.com; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85e4eb23-fa35-43b2-b9de-08d7306f91cc X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(4709080)(1401327)(4618075)(2017052603328); SRVR:SN2PR03MB2285; X-MS-TrafficTypeDiagnostic: SN2PR03MB2285: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:323; X-Forefront-PRVS: 01494FA7F7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: yWqMKhkgC1b7XtXhbNLPI2H8RWpHMpxNPtYY3ztHXBIUrrSsawfJ4L7pA2iNEmoVwbbXP7ow+QnybmJIY8tltEpjENGr0rJ8Z59KMsnq7ACckBSou8NK5JL6vAVnGOhhIWuquvwQqNpLDEcSZCcpnjqU1soqHA6UPdmUTcykLle56P0xkcMX7x22NOK+g6o1jWmHY7bTpMd5uut1mCNTe06mQ2KGtrf8sJrQvUpNkqG3pOCaOASqR4dqy1qGD+/oDlwTzduqdAgYQxDofhoUt0eBYrqU1OAJnaqUYba0sqDO12yjlp2Gp5raNPJMIVnehq5dPWblw8IJErVzSfEQ+FCGtjoErsEmVfGM5hDVNvMxnXbIAJZ6sKje1ChF8mgQOXICeYZjo9HXJT19hSR9+UE7mqGZwzFFiJGsRElp9vA= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2019 13:06:44.0749 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85e4eb23-fa35-43b2-b9de-08d7306f91cc X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a; Ip=[137.71.25.55]; Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2285 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-03_02:2019-09-03,2019-09-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 suspectscore=9 lowpriorityscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1909030137 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This change adds control for enabling/disabling Energy Detect Power Down mode, as well as configuring wake-up intervals for TX pulses, via the new ETHTOOL_PHY_EDPD control added in PHY tunable, in the kernel. Signed-off-by: Alexandru Ardelean --- ethtool.8.in | 28 +++++++++++++++++ ethtool.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 111 insertions(+), 4 deletions(-) diff --git a/ethtool.8.in b/ethtool.8.in index cd3be91..a32d48b 100644 --- a/ethtool.8.in +++ b/ethtool.8.in @@ -362,11 +362,17 @@ ethtool \- query or control network driver and hardware settings .A1 on off .BN msecs .RB ] +.RB [ +.B energy\-detect\-power\-down +.A1 on off +.BN tx-interval +.RB ] .HP .B ethtool \-\-get\-phy\-tunable .I devname .RB [ downshift ] .RB [ fast-link-down ] +.RB [ energy-detect-power-down ] .HP .B ethtool \-\-reset .I devname @@ -1100,6 +1106,24 @@ lB l. Sets the period after which the link is reported as down. Note that the PHY may choose the closest supported value. Only on reading back the tunable do you get the actual value. .TE +.TP +.A2 energy-detect-power-down on off +Specifies whether Energy Detect Power Down (EDPD) should be enabled (if supported). +This will put the RX and TX circuit blocks into a low power mode, and the PHY will +wake up periodically to send link pulses to avoid any lock-up situation with a peer +PHY that may also have EDPD enabled. By default, this setting will also enable the +periodic transmission of TX pulses. +.TS +nokeep; +lB l. +.BI tx-interval \ N + Some PHYs support configuration of the wake-up interval to send TX pulses. + This setting allows the control of this interval, and 0 disables TX pulses + if the PHY supports this. Disabling TX pulses can create a lock-up situation + where neither of the PHYs wakes the other one. If the PHY supports only + a single interval, any non-zero value will enable this. +.TE +.TP .PD .RE .TP @@ -1122,6 +1146,10 @@ Some PHYs support a Fast Link Down Feature and may allow configuration of the de before a broken link is reported as being down. Gets the PHY Fast Link Down status / period. +.TP +.B energy\-detect\-power\-down +Gets the current configured setting for Energy Detect Power Down (if supported). + .RE .TP .B \-\-reset diff --git a/ethtool.c b/ethtool.c index c0e2903..c0a18f8 100644 --- a/ethtool.c +++ b/ethtool.c @@ -4897,6 +4897,30 @@ static int do_get_phy_tunable(struct cmd_context *ctx) else fprintf(stdout, "Fast Link Down enabled, %d msecs\n", cont.msecs); + } else if (!strcmp(argp[0], "energy-detect-power-down")) { + struct { + struct ethtool_tunable ds; + u16 tx_interval; + } cont; + + cont.ds.cmd = ETHTOOL_PHY_GTUNABLE; + cont.ds.id = ETHTOOL_PHY_EDPD; + cont.ds.type_id = ETHTOOL_TUNABLE_U16; + cont.ds.len = 2; + if (send_ioctl(ctx, &cont.ds) < 0) { + perror("Cannot Get PHY Energy Detect Power Down value"); + return 87; + } + + if (cont.tx_interval == ETHTOOL_PHY_EDPD_DISABLE) + fprintf(stdout, "Energy Detect Power Down: disabled\n"); + else if (cont.tx_interval == ETHTOOL_PHY_EDPD_NO_TX) + fprintf(stdout, + "Energy Detect Power Down: enabled, TX disabled\n"); + else + fprintf(stdout, + "Energy Detect Power Down: enabled, TX %u intervals\n", + cont.tx_interval); } else { exit_bad_args(); } @@ -5018,7 +5042,8 @@ static int parse_named_bool(struct cmd_context *ctx, const char *name, u8 *on) return 1; } -static int parse_named_u8(struct cmd_context *ctx, const char *name, u8 *val) +static int parse_named_uint(struct cmd_context *ctx, const char *name, + void *val, enum tunable_type_id type_id) { if (ctx->argc < 2) return 0; @@ -5026,7 +5051,16 @@ static int parse_named_u8(struct cmd_context *ctx, const char *name, u8 *val) if (strcmp(*ctx->argp, name)) return 0; - *val = get_uint_range(*(ctx->argp + 1), 0, 0xff); + switch (type_id) { + case ETHTOOL_TUNABLE_U8: + *(u8 *)val = get_uint_range(*(ctx->argp + 1), 0, 0xff); + break; + case ETHTOOL_TUNABLE_U16: + *(u16 *)val = get_uint_range(*(ctx->argp + 1), 0, 0xffff); + break; + default: + return 0; + } ctx->argc -= 2; ctx->argp += 2; @@ -5034,6 +5068,16 @@ static int parse_named_u8(struct cmd_context *ctx, const char *name, u8 *val) return 1; } +static int parse_named_u8(struct cmd_context *ctx, const char *name, u8 *val) +{ + return parse_named_uint(ctx, name, val, ETHTOOL_TUNABLE_U8); +} + +static int parse_named_u16(struct cmd_context *ctx, const char *name, u16 *val) +{ + return parse_named_uint(ctx, name, val, ETHTOOL_TUNABLE_U16); +} + static int do_set_phy_tunable(struct cmd_context *ctx) { int err = 0; @@ -5041,6 +5085,8 @@ static int do_set_phy_tunable(struct cmd_context *ctx) u8 ds_changed = 0, ds_has_cnt = 0, ds_enable = 0; u8 fld_changed = 0, fld_enable = 0; u8 fld_msecs = ETHTOOL_PHY_FAST_LINK_DOWN_ON; + u8 edpd_changed = 0, edpd_enable = 0; + u16 edpd_tx_interval = ETHTOOL_PHY_EDPD_DFLT_TX_INTERVAL; /* Parse arguments */ if (parse_named_bool(ctx, "downshift", &ds_enable)) { @@ -5050,6 +5096,11 @@ static int do_set_phy_tunable(struct cmd_context *ctx) fld_changed = 1; if (fld_enable) parse_named_u8(ctx, "msecs", &fld_msecs); + } else if (parse_named_bool(ctx, "energy-detect-power-down", + &edpd_enable)) { + edpd_changed = 1; + if (edpd_enable) + parse_named_u16(ctx, "tx-interval", &edpd_tx_interval); } else { exit_bad_args(); } @@ -5074,6 +5125,16 @@ static int do_set_phy_tunable(struct cmd_context *ctx) fld_msecs = ETHTOOL_PHY_FAST_LINK_DOWN_OFF; else if (fld_msecs == ETHTOOL_PHY_FAST_LINK_DOWN_OFF) exit_bad_args(); + } else if (edpd_changed) { + if (!edpd_enable) + edpd_tx_interval = ETHTOOL_PHY_EDPD_DISABLE; + else if (edpd_tx_interval == 0) + edpd_tx_interval = ETHTOOL_PHY_EDPD_NO_TX; + else if (edpd_tx_interval > ETHTOOL_PHY_EDPD_DFLT_TX_INTERVAL) { + fprintf(stderr, "'tx-interval' max value is %d.\n", + (ETHTOOL_PHY_EDPD_DFLT_TX_INTERVAL - 1)); + exit_bad_args(); + } } /* Do it */ @@ -5109,6 +5170,22 @@ static int do_set_phy_tunable(struct cmd_context *ctx) perror("Cannot Set PHY Fast Link Down value"); err = 87; } + } else if (edpd_changed) { + struct { + struct ethtool_tunable fld; + u16 tx_interval; + } cont; + + cont.fld.cmd = ETHTOOL_PHY_STUNABLE; + cont.fld.id = ETHTOOL_PHY_EDPD; + cont.fld.type_id = ETHTOOL_TUNABLE_U16; + cont.fld.len = 2; + cont.tx_interval = edpd_tx_interval; + err = send_ioctl(ctx, &cont.fld); + if (err < 0) { + perror("Cannot Set PHY Energy Detect Power Down"); + err = 87; + } } return err; @@ -5361,10 +5438,12 @@ static const struct option { " [ tx-timer %d ]\n"}, { "--set-phy-tunable", 1, do_set_phy_tunable, "Set PHY tunable", " [ downshift on|off [count N] ]\n" - " [ fast-link-down on|off [msecs N] ]\n"}, + " [ fast-link-down on|off [msecs N] ]\n" + " [ energy-detect-power-down on|off [tx-interval N] ]\n"}, { "--get-phy-tunable", 1, do_get_phy_tunable, "Get PHY tunable", " [ downshift ]\n" - " [ fast-link-down ]\n"}, + " [ fast-link-down ]\n" + " [ energy-detect-power-down ]\n"}, { "--reset", 1, do_reset, "Reset components", " [ flags %x ]\n" " [ mgmt ]\n"