From patchwork Wed Jul 22 16:16:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Madalin Bucur X-Patchwork-Id: 498708 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 818471402CA for ; Thu, 23 Jul 2015 02:23:40 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 6200E1A1F3A for ; Thu, 23 Jul 2015 02:23:40 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0138.outbound.protection.outlook.com [157.56.110.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42EA41A1A74 for ; Thu, 23 Jul 2015 02:18:24 +1000 (AEST) Received: from BY2PR03CA057.namprd03.prod.outlook.com (10.141.249.30) by BL2PR03MB545.namprd03.prod.outlook.com (10.141.90.14) with Microsoft SMTP Server (TLS) id 15.1.219.17; Wed, 22 Jul 2015 16:18:15 +0000 Received: from BL2FFO11OLC003.protection.gbl (2a01:111:f400:7c09::136) by BY2PR03CA057.outlook.office365.com (2a01:111:e400:2c5d::30) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Wed, 22 Jul 2015 16:18:14 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11OLC003.mail.protection.outlook.com (10.173.161.187) with Microsoft SMTP Server (TLS) id 15.1.225.13 via Frontend Transport; Wed, 22 Jul 2015 16:18:13 +0000 Received: from localhost.localdomain (fsr-fed1764-003.ea.freescale.net [10.171.73.45]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t6MGHwTb021477; Wed, 22 Jul 2015 09:18:10 -0700 From: Madalin Bucur To: Subject: [PATCH 06/10] dpaa_eth: add ethtool functionality Date: Wed, 22 Jul 2015 19:16:42 +0300 Message-ID: <1437581806-17420-6-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1437581806-17420-5-git-send-email-madalin.bucur@freescale.com> References: <1437581806-17420-1-git-send-email-madalin.bucur@freescale.com> <1437581806-17420-2-git-send-email-madalin.bucur@freescale.com> <1437581806-17420-3-git-send-email-madalin.bucur@freescale.com> <1437581806-17420-4-git-send-email-madalin.bucur@freescale.com> <1437581806-17420-5-git-send-email-madalin.bucur@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC003; 1:zxshmNYKNmL+uEl9mltYmlkyegmrifSuukIp023xD/taiTk2vCpNEwh0uuRrNevOn7tU86kBe0pxZsqoXMiiO1Mj93wOGm7mSVwcT7aipsV6yQzts1FfXFujaaDkFzbO1eKb2Jqlo7ekPgW58tNvO4Rg2sPjVzZLX5yXG/BXtDP49koSMXsy/Eb7oW8wH3h3amp3msrXnuq2yd56UJv1rvARUqNmstB1zL46BaBGrNpelXChZUbHNd6rcPqxfX1G/rfy0NK9SesjohhXoNNFt2+phieoYvHKWSu0DCt4NvCBd/zBRPatZSrkzTWULwtSpeoVanluaWj73XMu4XVQUQ== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(19580405001)(229853001)(86362001)(575784001)(2351001)(48376002)(46102003)(19580395003)(87936001)(5003940100001)(104016003)(2950100001)(33646002)(105606002)(50226001)(43066003)(85426001)(5001960100002)(106466001)(93886004)(6806004)(36756003)(50466002)(47776003)(77096005)(189998001)(110136002)(107886002)(50986999)(53806999)(49486002)(62966003)(76176999)(77156002)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR03MB545; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB545; 2:wauqXaX6WldOHoTLVKd1bOJxd3VUnd4zehFUFm7oLWIxFPf57eoTQO983XBfhKHW; 3:AxFplU5qU9m5GegFvN4lP5srm6ZBRbDjRSD2yg9PX0g1nx6Zcpf6VXTBMfx0J96VHjozm55E7xe1FL9y142zYxrt9sFcbMJjHjaoZgvwusdvwyOwsnLwzdO4dx2eVUiEu6UAD6AqIXnzlrNu+88V8v4SHZ4m5FFy4DgBTC84NL74Cs448K6tUzEPKob5uJb3q1lLPMaxB8+MgNNG1vuiJ61yfOYh7lDQ4TBwO17VAxU=; 25:9lt2w5HxyPd0gXlMJHk13Xp2sPNLcedVKkXe3jTWIs1b1BgoQdrt20Trz0z8lkFufJphWhdYXIwHO8dxCM8plFncAcSCiYOx+vzdxFw5zJVbiWxw7UKH2hphtZIZhaABl0RH36mQzou9Kp53bO72yuYC+KHDcYj6nLuucVKw8wnTksW6RHa39P0lyM9WuGAJ0JyUzP/Vx8t39CRh1ftBN77wuA/DjAiP09epnlNVerv/vi02wR9iAwAkjpOEIHB5zZ4vtgAPIv8gEY5t9tRz5g==; 20:3eZ5frNYc6BZJ8dxNhPIxbnhNJ78Fp3vHBwP4NhkLtOxtYsIEiIxJL7nTKlZUguAIvxTIx1cllIkkYb605WUZ9KjCvmtiuR/q/Qloxcz8PH5oxqUeTdV1FxaxbtPKqdq47uBPL3FcnzkXJ29NM0k7tZkyukgd0GH6PszYt8FO5pZbBp/OD0Q1xPecOREC9rYSdEdYfPvo3wSko6xVpdtc1FTfoTfTtOXWNCUgzWIaqteYfT6J0fn2Z8KDCNsLEoVDPF2R6lHX+OHGiA4O+nAKnVPwUKXbQKaIKiBkjpwX7WYO3PDNUxYaoQJHH7sW8zeLa9iJnPFjayipG41I8BbP3ShPAuD4BlU9DGPBT1kdkc= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB545; BL2PR03MB545: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BL2PR03MB545; BCL:0; PCL:0; RULEID:; SRVR:BL2PR03MB545; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB545; 4:xiZibi3sHLvwBvccg8brKbvdvgJ1aKDQrP4HjJqTgPQ1b6uT5+OI+FW8D+QRFOT1WbBktRU2RYaB14gDbFe3aWyvEz7VjEoHxphU+VugvVuw1RKy/tTS83cteiG6aZMpirSkNoQF6hOGfH0uXbat4pA0/2ibcXvuN/Zy5/F7mQMT4DROwXgn13YNpksaNudVumwZezNut4SY/LS4OhY1juFiPsIpGsEOG5Z7bZwIAnZ+CZAACGLtHGZ1XbjN779mRkJow5oM6h8+cLbBABL2exqhQFayVnDBM/uNppizHEs= X-Forefront-PRVS: 0645BEB7AA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB545; 23:H1zSza6Xtftx2K389pIsKC5cwZrMkoqiXuId5fgU5P?= =?us-ascii?Q?immZema8PZp/dTNjHK9NhJwqMvrO9zhapEwftc6BWHHK74fyWFagh1p7eWEH?= =?us-ascii?Q?uDgI1cSbYyDoX6Tt39DldAGCNG++Cfj3pME6+9EBA60BbHbhs872VLDxS9vE?= =?us-ascii?Q?hLeanSPSZM5r4UKKyt4uXAjdhpUpM6U8fZxuELQxagYAq1xLBFljxaSM5jxP?= =?us-ascii?Q?bfw7+Q6V0g3ZoBZij4V//yieY1l4+IydUncXtu4BwabELtuMy0WV6Sf0DtPF?= =?us-ascii?Q?0CCsIfEKzaOWQqw9ztt6v0HtMP9cMvSX9NRGP/AidvHvymTw94cczLaRo0ZE?= =?us-ascii?Q?b4fruMxcc0J1erAfA1nGtmFqpBtZdmNEQabZ8MQpkOVZxE5RpqMI8ViRLymv?= =?us-ascii?Q?00ts6eKEfmFn+cGNhaIqEve5ySC8gY+lGgxjrc5rpW0tMv0Zm2p5lUcB5qq/?= =?us-ascii?Q?s/dT/Giogr0qi/B07w00ypyhCnplU0LcK/a1tGmeC8yfeQ3faUrnn+uIuBlW?= =?us-ascii?Q?V5T3TeNbvXkQS4tpAc/fzZgT34rc2rpBIcsAKG1+11qY2oxPDDkCGLOZT9su?= =?us-ascii?Q?yw9hmdBuJ7cke4lb93wOSiOLayy5W367gIYyXmM9+ap/XaASrocR17MwVEGw?= =?us-ascii?Q?NdFSA/DuFG+QBBq8hoEDaFMVImOk+YwuxH5O7pLX/XpGMvhaeupQu1dlnfG+?= =?us-ascii?Q?TbiV592TDUluKA3eIo4C4TVAgLK9tzssOiQEmKY7M0ULpUVN7rVb+Az67kTc?= =?us-ascii?Q?4tzxqoz3CXqNh8eTJcVCMWcjNmdmPFkgMwFyi4B+GJ8PBJIomY0cF++NJeRZ?= =?us-ascii?Q?yeffiq41WN0j3i2b8iBau3hevlhWqNTI3eHZ3p0HXMemYlkhpVpAX3ZUFtDz?= =?us-ascii?Q?ZIHIfsLOBNA7llgs4lMtgkZpcBrx/ZbG5VCQJTJsuNHp7TE6ClJwP/CJpnnU?= =?us-ascii?Q?+r6+hcziJ6LNlQ5gFjCW7Zd6ynreSqH687+2a7zW5rv+7OvtDWzlURq6iylz?= =?us-ascii?Q?xhZloreaUkuuMAduNMetuO5nL9nCjByYYOhfazfSbRDKfdbZM7NFbeLv3L/7?= =?us-ascii?Q?BKmNI=3D?= X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB545; 5:S1cbtw6MZB7/Da2vrkvjDwjJzxBv9LC2B0khkPt8SwA6s35HK/GE9QQRZ9cEZc+iuXYA98dizwyS8kEPPNyDP/8jMLXPuIsPb4jdxmoYAFkKrYJb44L7UTV1VStVQrlAaOuaxw0UK7IbjqIzAEggCQ==; 24:qvRazYsCiGCB1B9ibUdTnSy/DLk/OtR0j72W9KbG6NpNEicb/fPkLzF3yR1bfyB24K9iVcqQNHZyN75jEwQ390BNc4HvVHdCm533cG/5hI4=; 20:gWECPBmUaVp2o4uw0TnaMiCKAdRrrGB0jcrURxMm3L/jQVlx6uQ6hPJhJFtpNeoGAN+T+lWQr5Ngtvoz5pb07Q== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2015 16:18:13.5802 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB545 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: madalin.bucur@freescale.com Cc: pebolle@tiscali.nl, linux-kernel@vger.kernel.org, ppc@mindchasers.com, igal.liberman@freescale.com, scottwood@freescale.com, joe@perches.com, linuxppc-dev@lists.ozlabs.org, Madalin Bucur Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Add support for basic ethtool operations. Signed-off-by: Madalin Bucur --- drivers/net/ethernet/freescale/dpaa/Makefile | 2 +- .../net/ethernet/freescale/dpaa/dpaa_eth_common.c | 2 + .../net/ethernet/freescale/dpaa/dpaa_eth_common.h | 3 + drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 230 +++++++++++++++++++++ 4 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c diff --git a/drivers/net/ethernet/freescale/dpaa/Makefile b/drivers/net/ethernet/freescale/dpaa/Makefile index cf126dd..e137146 100644 --- a/drivers/net/ethernet/freescale/dpaa/Makefile +++ b/drivers/net/ethernet/freescale/dpaa/Makefile @@ -10,4 +10,4 @@ ccflags-y += -I$(FMAN)/flib obj-$(CONFIG_FSL_DPAA_ETH) += fsl_dpa.o -fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o +fsl_dpa-objs += dpaa_eth.o dpaa_eth_sg.o dpaa_eth_common.o dpaa_ethtool.o diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c index b571635..aeb2baf 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.c @@ -81,6 +81,8 @@ int dpa_netdev_init(struct net_device *net_dev, memcpy(net_dev->perm_addr, mac_addr, net_dev->addr_len); memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len); + net_dev->ethtool_ops = &dpa_ethtool_ops; + net_dev->needed_headroom = priv->tx_headroom; net_dev->watchdog_timeo = msecs_to_jiffies(tx_timeout); diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h index 75d0ac9..49dc8d4 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_common.h @@ -58,6 +58,9 @@ /* used in napi related functions */ extern u16 qman_portal_max; +/* from dpa_ethtool.c */ +extern const struct ethtool_ops dpa_ethtool_ops; + int dpa_netdev_init(struct net_device *net_dev, const u8 *mac_addr, u16 tx_timeout); diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c new file mode 100644 index 0000000..cabd5f8 --- /dev/null +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c @@ -0,0 +1,230 @@ +/* Copyright 2008-2015 Freescale Semiconductor, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include + +#include "dpaa_eth.h" +#include "mac.h" +#include "dpaa_eth_common.h" + +static int dpa_get_settings(struct net_device *net_dev, + struct ethtool_cmd *et_cmd) +{ + int err; + struct dpa_priv_s *priv; + + priv = netdev_priv(net_dev); + + if (unlikely(!priv->mac_dev->phy_dev)) { + netdev_dbg(net_dev, "phy device not initialized\n"); + return 0; + } + + err = phy_ethtool_gset(priv->mac_dev->phy_dev, et_cmd); + + return err; +} + +static int dpa_set_settings(struct net_device *net_dev, + struct ethtool_cmd *et_cmd) +{ + int err; + struct dpa_priv_s *priv; + + priv = netdev_priv(net_dev); + + if (unlikely(!priv->mac_dev->phy_dev)) { + netdev_err(net_dev, "phy device not initialized\n"); + return -ENODEV; + } + + err = phy_ethtool_sset(priv->mac_dev->phy_dev, et_cmd); + if (unlikely(err < 0)) + netdev_err(net_dev, "phy_ethtool_sset() = %d\n", err); + + return err; +} + +static void dpa_get_drvinfo(struct net_device *net_dev, + struct ethtool_drvinfo *drvinfo) +{ + int len; + + strlcpy(drvinfo->driver, KBUILD_MODNAME, + sizeof(drvinfo->driver)); + len = snprintf(drvinfo->version, sizeof(drvinfo->version), + "%X", 0); + len = snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), + "%X", 0); + + if (unlikely(len >= sizeof(drvinfo->fw_version))) { + /* Truncated output */ + netdev_notice(net_dev, "snprintf() = %d\n", len); + } + strlcpy(drvinfo->bus_info, dev_name(net_dev->dev.parent->parent), + sizeof(drvinfo->bus_info)); +} + +static u32 dpa_get_msglevel(struct net_device *net_dev) +{ + return ((struct dpa_priv_s *)netdev_priv(net_dev))->msg_enable; +} + +static void dpa_set_msglevel(struct net_device *net_dev, + u32 msg_enable) +{ + ((struct dpa_priv_s *)netdev_priv(net_dev))->msg_enable = msg_enable; +} + +static int dpa_nway_reset(struct net_device *net_dev) +{ + int err; + struct dpa_priv_s *priv; + + priv = netdev_priv(net_dev); + + if (unlikely(!priv->mac_dev->phy_dev)) { + netdev_err(net_dev, "phy device not initialized\n"); + return -ENODEV; + } + + err = 0; + if (priv->mac_dev->phy_dev->autoneg) { + err = phy_start_aneg(priv->mac_dev->phy_dev); + if (unlikely(err < 0)) + netdev_err(net_dev, "phy_start_aneg() = %d\n", + err); + } + + return err; +} + +static void dpa_get_pauseparam(struct net_device *net_dev, + struct ethtool_pauseparam *epause) +{ + struct dpa_priv_s *priv; + struct mac_device *mac_dev; + struct phy_device *phy_dev; + + priv = netdev_priv(net_dev); + mac_dev = priv->mac_dev; + + phy_dev = mac_dev->phy_dev; + if (unlikely(!phy_dev)) { + netdev_err(net_dev, "phy device not initialized\n"); + return; + } + + epause->autoneg = mac_dev->autoneg_pause; + epause->rx_pause = mac_dev->rx_pause_active; + epause->tx_pause = mac_dev->tx_pause_active; +} + +static int dpa_set_pauseparam(struct net_device *net_dev, + struct ethtool_pauseparam *epause) +{ + struct dpa_priv_s *priv; + struct mac_device *mac_dev; + struct phy_device *phy_dev; + int err; + u32 newadv, oldadv; + bool rx_pause, tx_pause; + + priv = netdev_priv(net_dev); + mac_dev = priv->mac_dev; + + phy_dev = mac_dev->phy_dev; + if (unlikely(!phy_dev)) { + netdev_err(net_dev, "phy device not initialized\n"); + return -ENODEV; + } + + if (!(phy_dev->supported & SUPPORTED_Pause) || + (!(phy_dev->supported & SUPPORTED_Asym_Pause) && + (epause->rx_pause != epause->tx_pause))) + return -EINVAL; + + /* The MAC should know how to handle PAUSE frame autonegotiation before + * adjust_link is triggered by a forced renegotiation of sym/asym PAUSE + * settings. + */ + mac_dev->autoneg_pause = !!epause->autoneg; + mac_dev->rx_pause_req = !!epause->rx_pause; + mac_dev->tx_pause_req = !!epause->tx_pause; + + /* Determine the sym/asym advertised PAUSE capabilities from the desired + * rx/tx pause settings. + */ + newadv = 0; + if (epause->rx_pause) + newadv = ADVERTISED_Pause | ADVERTISED_Asym_Pause; + if (epause->tx_pause) + newadv |= ADVERTISED_Asym_Pause; + + oldadv = phy_dev->advertising & + (ADVERTISED_Pause | ADVERTISED_Asym_Pause); + + /* If there are differences between the old and the new advertised + * values, restart PHY autonegotiation and advertise the new values. + */ + if (oldadv != newadv) { + phy_dev->advertising &= ~(ADVERTISED_Pause + | ADVERTISED_Asym_Pause); + phy_dev->advertising |= newadv; + if (phy_dev->autoneg) { + err = phy_start_aneg(phy_dev); + if (unlikely(err < 0)) + netdev_err(net_dev, "phy_start_aneg() = %d\n", + err); + } + } + + get_pause_cfg(mac_dev, &rx_pause, &tx_pause); + err = set_mac_active_pause(mac_dev, rx_pause, tx_pause); + if (unlikely(err < 0)) + netdev_err(net_dev, "set_mac_active_pause() = %d\n", err); + + return err; +} + +const struct ethtool_ops dpa_ethtool_ops = { + .get_settings = dpa_get_settings, + .set_settings = dpa_set_settings, + .get_drvinfo = dpa_get_drvinfo, + .get_msglevel = dpa_get_msglevel, + .set_msglevel = dpa_set_msglevel, + .nway_reset = dpa_nway_reset, + .get_pauseparam = dpa_get_pauseparam, + .set_pauseparam = dpa_set_pauseparam, + .get_link = ethtool_op_get_link, +};